From af8f193cc5877268a40f99e45bee3f3db18d6839 Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:27:58 -0700 Subject: [PATCH 01/13] Make Fabric work --- .../example/examples/Reanimated.windows.tsx | 19 + apps/common/noNavigationApp.tsx | 124 ++++ apps/fabric-windows-example/.gitignore | 3 + apps/fabric-windows-example/babel.config.js | 3 - apps/fabric-windows-example/index.js | 5 +- apps/fabric-windows-example/package.json | 3 +- .../windows/FabricExample/FabricExample.cpp | 2 + .../FabricExample/FabricExample.vcxproj | 1 + .../windows/FabricExample/packages.lock.json | 64 +- apps/fabric-windows-example/yarn.lock | 554 ++++++++------- apps/paper-windows-example/babel.config.js | 5 - apps/paper-windows-example/index.js | 2 +- apps/paper-windows-example/package.json | 6 +- ...react-native-view-shot+4.0.0-alpha.2.patch | 51 -- ...tch => react-native-windows+0.74.23.patch} | 2 +- .../windows/Example/packages.lock.json | 280 +++++++- apps/paper-windows-example/yarn.lock | 629 ++++++++---------- windows/RNSVG/BrushView.cpp | 5 - windows/RNSVG/BrushView.h | 7 +- windows/RNSVG/CircleView.cpp | 12 +- windows/RNSVG/CircleView.h | 5 +- windows/RNSVG/ClipPathView.cpp | 12 +- windows/RNSVG/ClipPathView.h | 4 +- windows/RNSVG/D2DHelpers.h | 2 +- windows/RNSVG/DefsView.cpp | 12 +- windows/RNSVG/DefsView.h | 6 +- windows/RNSVG/EllipseView.cpp | 22 +- windows/RNSVG/EllipseView.h | 9 +- windows/RNSVG/Fabric.idl | 30 +- windows/RNSVG/GroupView.cpp | 22 +- windows/RNSVG/GroupView.h | 8 +- windows/RNSVG/ImageView.cpp | 36 +- windows/RNSVG/ImageView.h | 8 +- windows/RNSVG/LineView.cpp | 22 +- windows/RNSVG/LineView.h | 10 +- windows/RNSVG/LinearGradientView.cpp | 31 +- windows/RNSVG/LinearGradientView.h | 8 +- windows/RNSVG/MarkerView.cpp | 13 +- windows/RNSVG/MarkerView.h | 9 +- windows/RNSVG/MaskView.cpp | 13 +- windows/RNSVG/MaskView.h | 9 +- windows/RNSVG/PathView.cpp | 16 +- windows/RNSVG/PathView.h | 8 +- windows/RNSVG/PatternView.cpp | 46 +- windows/RNSVG/PatternView.h | 10 +- windows/RNSVG/RadialGradientView.cpp | 36 +- windows/RNSVG/RadialGradientView.h | 10 +- windows/RNSVG/RectView.cpp | 26 +- windows/RNSVG/RectView.h | 8 +- windows/RNSVG/RenderableView.cpp | 80 ++- windows/RNSVG/RenderableView.h | 66 +- windows/RNSVG/SvgView.cpp | 145 ++-- windows/RNSVG/SvgView.h | 34 +- windows/RNSVG/SymbolView.cpp | 26 +- windows/RNSVG/SymbolView.h | 10 +- windows/RNSVG/TSpanView.cpp | 15 +- windows/RNSVG/TSpanView.h | 10 +- windows/RNSVG/TextView.cpp | 14 +- windows/RNSVG/TextView.h | 11 +- windows/RNSVG/UseView.cpp | 24 +- windows/RNSVG/UseView.h | 8 +- windows/RNSVG/packages.lock.json | 100 ++- 62 files changed, 1480 insertions(+), 1291 deletions(-) create mode 100644 apps/common/example/examples/Reanimated.windows.tsx create mode 100644 apps/common/noNavigationApp.tsx delete mode 100644 apps/paper-windows-example/patches/react-native-view-shot+4.0.0-alpha.2.patch rename apps/paper-windows-example/patches/{react-native-windows+0.74.9.patch => react-native-windows+0.74.23.patch} (97%) diff --git a/apps/common/example/examples/Reanimated.windows.tsx b/apps/common/example/examples/Reanimated.windows.tsx new file mode 100644 index 000000000..1ba5fc97e --- /dev/null +++ b/apps/common/example/examples/Reanimated.windows.tsx @@ -0,0 +1,19 @@ +import React from 'react'; +import {StyleSheet, Text} from 'react-native'; + +function ReanimatedRectExample() { + return ( + + Reanimated not supported in react-native-windows new arch currently + + ); +} +ReanimatedRectExample.title = 'reanimated rectangle'; + +const title = 'Reanimated'; +const samples = [ReanimatedRectExample]; + +const style = StyleSheet.create({text: {width: 30, height: 30}}); +const icon = R; + +export {icon, samples}; diff --git a/apps/common/noNavigationApp.tsx b/apps/common/noNavigationApp.tsx new file mode 100644 index 000000000..2db83aa2e --- /dev/null +++ b/apps/common/noNavigationApp.tsx @@ -0,0 +1,124 @@ +/** + * Sample React Native App for react-native-svg library + * https://github.com/software-mansion/react-native-svg/tree/main/apps/common/example + */ + +/** + * This is a very simple render of the examples for react-native-svg library, to avoid dependencies on @react-navigation, + * which may not be fully supported on all platforms and versions of react-native + */ +'use strict'; + +import React from 'react'; +import {ScrollView, Text, View} from 'react-native'; +import {examples} from './example/examples'; +import type {Example} from './example/utils/types'; +import {commonStyles} from './example/utils/commonStyles'; + +const ExampleBlock = ({example, index}: {example: Example; index: number}) => { + if (Array.isArray(example.samples)) { + return ( + + {example.icon} + + {example.samples.map((sample, index) => { + return ( + + {sample.title} + {sample({})} + + ); + })} + + ); + } + + throw new Error('Unhandled Example type'); +}; + +import { + Svg, + Defs, + LinearGradient, + Stop, + Text as TextS, + G, + Path, + Circle, +} from 'react-native-svg'; + +export default function App() { + /* + return ( + + + + + + + + + + + + FILL TEXT + + + ); + + */ + /* + return ( + + + + + + + + + + + + + + B + + + + + ) +*/ + return ( + + {Object.values(examples).map((example, index) => { + return ; + })} + + ); +} diff --git a/apps/fabric-windows-example/.gitignore b/apps/fabric-windows-example/.gitignore index d5ae45669..59b85d694 100644 --- a/apps/fabric-windows-example/.gitignore +++ b/apps/fabric-windows-example/.gitignore @@ -52,6 +52,9 @@ yarn-error.log **/fastlane/screenshots **/fastlane/test_output +# Locally installed nuget packages +/windows/packages + # Bundle artifact *.jsbundle diff --git a/apps/fabric-windows-example/babel.config.js b/apps/fabric-windows-example/babel.config.js index 0f949a107..f7b3da3b3 100644 --- a/apps/fabric-windows-example/babel.config.js +++ b/apps/fabric-windows-example/babel.config.js @@ -1,6 +1,3 @@ module.exports = { presets: ['module:@react-native/babel-preset'], - plugins: [ - 'react-native-reanimated/plugin', - ], }; diff --git a/apps/fabric-windows-example/index.js b/apps/fabric-windows-example/index.js index aa1be2128..62d72c3f9 100644 --- a/apps/fabric-windows-example/index.js +++ b/apps/fabric-windows-example/index.js @@ -3,7 +3,10 @@ */ import {AppRegistry} from 'react-native'; -import App from '../common'; +import App from '../common/noNavigationApp'; import {name as appName} from './app.json'; AppRegistry.registerComponent(appName, () => App); + + +AppRegistry.registerComponent("Example", () => App); diff --git a/apps/fabric-windows-example/package.json b/apps/fabric-windows-example/package.json index 886972a42..17f0eeee3 100644 --- a/apps/fabric-windows-example/package.json +++ b/apps/fabric-windows-example/package.json @@ -11,8 +11,7 @@ "dependencies": { "react": "18.2.0", "react-native": "0.74.2", - "react-native-windows": "0.74.9", - "react-native-reanimated": "3.9.0", + "react-native-windows": "0.74.23", "react-native-svg": "link:../../" }, "devDependencies": { diff --git a/apps/fabric-windows-example/windows/FabricExample/FabricExample.cpp b/apps/fabric-windows-example/windows/FabricExample/FabricExample.cpp index a94fd9c8c..eac183ee9 100644 --- a/apps/fabric-windows-example/windows/FabricExample/FabricExample.cpp +++ b/apps/fabric-windows-example/windows/FabricExample/FabricExample.cpp @@ -36,6 +36,8 @@ void UpdateRootViewSizeToAppWindow( winrt::Microsoft::UI::Windowing::OverlappedPresenterState::Minimized) { winrt::Microsoft::ReactNative::LayoutConstraints constraints; constraints.MaximumSize = constraints.MinimumSize = size; + constraints.LayoutDirection = + winrt::Microsoft::ReactNative::LayoutDirection::Undefined; rootView.Arrange(constraints, {0, 0}); } } diff --git a/apps/fabric-windows-example/windows/FabricExample/FabricExample.vcxproj b/apps/fabric-windows-example/windows/FabricExample/FabricExample.vcxproj index 1f60e5f21..f11c014fc 100644 --- a/apps/fabric-windows-example/windows/FabricExample/FabricExample.vcxproj +++ b/apps/fabric-windows-example/windows/FabricExample/FabricExample.vcxproj @@ -75,6 +75,7 @@ true %(AdditionalOptions) /bigobj 4453;28204 + stdcpp20 shell32.lib;user32.lib;windowsapp.lib;%(AdditionalDependenices) diff --git a/apps/fabric-windows-example/windows/FabricExample/packages.lock.json b/apps/fabric-windows-example/windows/FabricExample/packages.lock.json index c0281d927..97d588513 100644 --- a/apps/fabric-windows-example/windows/FabricExample/packages.lock.json +++ b/apps/fabric-windows-example/windows/FabricExample/packages.lock.json @@ -4,15 +4,15 @@ "native,Version=v0.0": { "boost": { "type": "Direct", - "requested": "[1.76.0, )", - "resolved": "1.76.0", - "contentHash": "p+w3YvNdXL8Cu9Fzrmexssu0tZbWxuf6ywsQqHjDlKFE5ojXHof1HIyMC3zDLfLnh80dIeFcEUAuR2Asg/XHRA==" + "requested": "[1.83.0, )", + "resolved": "1.83.0", + "contentHash": "cy53VNMzysEMvhBixDe8ujPk67Fcj3v6FPHQnH91NYJNLHpc6jxa2xq9ruCaaJjE4M3YrGSHDi4uUSTGBWw6EQ==" }, "Microsoft.JavaScript.Hermes": { "type": "Direct", - "requested": "[0.1.21, )", - "resolved": "0.1.21", - "contentHash": "5njCh+3eXTLOv7+8nOnp6nJ5C0r6it5ze54c0nuWleeDptuK8t3dEDB79XTU4D5DKNvAPlqJpgXRDOak5nYIug==" + "requested": "[0.1.23, )", + "resolved": "0.1.23", + "contentHash": "cA9t1GjY4Yo0JD1AfA//e1lOwk48hLANfuX6GXrikmEBNZVr2TIX5ONJt5tqCnpZyLz6xGiPDgTfFNKbSfb21g==" }, "Microsoft.VCRTForwarders.140": { "type": "Direct", @@ -35,6 +35,19 @@ "Microsoft.Windows.SDK.BuildTools": "10.0.22621.756" } }, + "Microsoft.UI.Xaml": { + "type": "Transitive", + "resolved": "2.8.0", + "contentHash": "vxdHxTr63s5KVtNddMFpgvjBjUH50z7seq/5jLWmmSuf8poxg+sXrywkofUdE8ZstbpO9y3FL/IXXUcPYbeesA==", + "dependencies": { + "Microsoft.Web.WebView2": "1.0.1264.42" + } + }, + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.1264.42", + "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" + }, "Microsoft.Windows.SDK.BuildTools": { "type": "Transitive", "resolved": "10.0.22621.756", @@ -43,7 +56,7 @@ "common": { "type": "Project", "dependencies": { - "boost": "[1.76.0, )" + "boost": "[1.83.0, )" } }, "fmt": { @@ -53,7 +66,7 @@ "type": "Project", "dependencies": { "Fmt": "[1.0.0, )", - "boost": "[1.76.0, )" + "boost": "[1.83.0, )" } }, "microsoft.reactnative": { @@ -61,17 +74,24 @@ "dependencies": { "Common": "[1.0.0, )", "Folly": "[1.0.0, )", - "Microsoft.JavaScript.Hermes": "[0.1.21, )", + "Microsoft.JavaScript.Hermes": "[0.1.23, )", "Microsoft.WindowsAppSDK": "[1.5.240227000, )", "ReactCommon": "[1.0.0, )", - "boost": "[1.76.0, )" + "boost": "[1.83.0, )" } }, "reactcommon": { "type": "Project", "dependencies": { "Folly": "[1.0.0, )", - "boost": "[1.76.0, )" + "boost": "[1.83.0, )" + } + }, + "reactnativeasyncstorage": { + "type": "Project", + "dependencies": { + "Microsoft.ReactNative": "[1.0.0, )", + "Microsoft.UI.Xaml": "[2.8.0, )" } }, "rnsvg": { @@ -80,7 +100,7 @@ "Microsoft.ReactNative": "[1.0.0, )", "Microsoft.VCRTForwarders.140": "[1.0.2-rc, )", "Microsoft.WindowsAppSDK": "[1.5.240227000, )", - "boost": "[1.76.0, )" + "boost": "[1.83.0, )" } } }, @@ -99,6 +119,11 @@ "dependencies": { "Microsoft.Windows.SDK.BuildTools": "10.0.22621.756" } + }, + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.1264.42", + "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" } }, "native,Version=v0.0/win-arm64": { @@ -116,6 +141,11 @@ "dependencies": { "Microsoft.Windows.SDK.BuildTools": "10.0.22621.756" } + }, + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.1264.42", + "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" } }, "native,Version=v0.0/win-x64": { @@ -133,6 +163,11 @@ "dependencies": { "Microsoft.Windows.SDK.BuildTools": "10.0.22621.756" } + }, + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.1264.42", + "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" } }, "native,Version=v0.0/win-x86": { @@ -150,6 +185,11 @@ "dependencies": { "Microsoft.Windows.SDK.BuildTools": "10.0.22621.756" } + }, + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.1264.42", + "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" } } } diff --git a/apps/fabric-windows-example/yarn.lock b/apps/fabric-windows-example/yarn.lock index c9ebc1ca5..561bc40db 100644 --- a/apps/fabric-windows-example/yarn.lock +++ b/apps/fabric-windows-example/yarn.lock @@ -919,7 +919,7 @@ "@babel/helper-create-regexp-features-plugin" "^7.18.6" "@babel/helper-plugin-utils" "^7.18.6" -"@babel/plugin-transform-arrow-functions@^7.0.0", "@babel/plugin-transform-arrow-functions@^7.0.0-0", "@babel/plugin-transform-arrow-functions@^7.24.1": +"@babel/plugin-transform-arrow-functions@^7.0.0", "@babel/plugin-transform-arrow-functions@^7.24.1": version "7.24.1" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.24.1.tgz#2bf263617060c9cc45bcdbf492b8cc805082bf27" integrity sha512-ngT/3NkRhsaep9ck9uj2Xhv9+xB1zShY3tM3g6om4xxCELwCDN4g4Aq5dRn48+0hasAql7s2hdBOysCfNpr4fw== @@ -1377,7 +1377,7 @@ dependencies: "@babel/helper-plugin-utils" "^7.24.7" -"@babel/plugin-transform-nullish-coalescing-operator@^7.0.0-0", "@babel/plugin-transform-nullish-coalescing-operator@^7.24.1": +"@babel/plugin-transform-nullish-coalescing-operator@^7.24.1": version "7.24.1" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-nullish-coalescing-operator/-/plugin-transform-nullish-coalescing-operator-7.24.1.tgz#0cd494bb97cb07d428bd651632cb9d4140513988" integrity sha512-iQ+caew8wRrhCikO5DrUYx0mrmdhkaELgFa+7baMcVuhxIkN7oxt06CZ51D65ugIb1UWRQ8oQe+HXAVM6qHFjw== @@ -1461,7 +1461,7 @@ "@babel/helper-plugin-utils" "^7.24.7" "@babel/plugin-syntax-optional-catch-binding" "^7.8.3" -"@babel/plugin-transform-optional-chaining@^7.0.0-0", "@babel/plugin-transform-optional-chaining@^7.24.1": +"@babel/plugin-transform-optional-chaining@^7.24.1": version "7.24.1" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-optional-chaining/-/plugin-transform-optional-chaining-7.24.1.tgz#26e588acbedce1ab3519ac40cc748e380c5291e6" integrity sha512-n03wmDt+987qXwAgcBlnUUivrZBPZ8z1plL0YvgQalLm+ZE5BMhGm94jhxXtA1wzv1Cu2aaOv1BM9vbVttrzSg== @@ -1617,7 +1617,7 @@ babel-plugin-polyfill-regenerator "^0.6.1" semver "^6.3.1" -"@babel/plugin-transform-shorthand-properties@^7.0.0", "@babel/plugin-transform-shorthand-properties@^7.0.0-0", "@babel/plugin-transform-shorthand-properties@^7.24.1": +"@babel/plugin-transform-shorthand-properties@^7.0.0", "@babel/plugin-transform-shorthand-properties@^7.24.1": version "7.24.1" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.24.1.tgz#ba9a09144cf55d35ec6b93a32253becad8ee5b55" integrity sha512-LyjVB1nsJ6gTTUKRjRWx9C1s9hE7dLfP/knKdrfeH9UPtAGjYGgxIbFfx7xyLIEWs7Xe1Gnf8EWiUqfjLhInZA== @@ -1661,7 +1661,7 @@ dependencies: "@babel/helper-plugin-utils" "^7.24.7" -"@babel/plugin-transform-template-literals@^7.0.0-0", "@babel/plugin-transform-template-literals@^7.24.1": +"@babel/plugin-transform-template-literals@^7.24.1": version "7.24.1" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.24.1.tgz#15e2166873a30d8617e3e2ccadb86643d327aab7" integrity sha512-WRkhROsNzriarqECASCNu/nojeXCDTE/F2HmRgOzi7NGvyfYGq1NEjKBK3ckLfRgGc6/lPAqP0vDOSw3YtG34g== @@ -1977,7 +1977,7 @@ "@babel/plugin-transform-modules-commonjs" "^7.24.7" "@babel/plugin-transform-typescript" "^7.24.7" -"@babel/preset-typescript@^7.13.0", "@babel/preset-typescript@^7.16.7": +"@babel/preset-typescript@^7.13.0": version "7.24.1" resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.24.1.tgz#89bdf13a3149a17b3b2a2c9c62547f06db8845ec" integrity sha512-1DBaMmRDpuYQBPWD8Pf/WEwCrtgRHxsZnP4mIy9G/X+hFfbI47Q2G4t1Paakld84+qsk2fSsUPMKg71jkoOOaQ== @@ -2493,16 +2493,6 @@ resolved "https://registry.yarnpkg.com/@opentelemetry/semantic-conventions/-/semantic-conventions-1.24.0.tgz#f074db930a7feb4d64103a9a576c5fbad046fcac" integrity sha512-yL0jI6Ltuz8R+Opj7jClGrul6pOoYrdfVmzQS4SITXRPH7I5IRZbrwe/6/v8v4WYMa6MYZG480S1+uc/IGfqsA== -"@react-native-community/cli-clean@13.6.6": - version "13.6.6" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-13.6.6.tgz#87c7ad8746c38dab0fe7b3c6ff89d44351d5d943" - integrity sha512-cBwJTwl0NyeA4nyMxbhkWZhxtILYkbU3TW3k8AXLg+iGphe0zikYMGB3T+haTvTc6alTyEFwPbimk9bGIqkjAQ== - dependencies: - "@react-native-community/cli-tools" "13.6.6" - chalk "^4.1.2" - execa "^5.0.0" - fast-glob "^3.3.2" - "@react-native-community/cli-clean@13.6.8": version "13.6.8" resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-13.6.8.tgz#95ce964047f005152ac100394b6dcd5d2cc2a474" @@ -2513,17 +2503,15 @@ execa "^5.0.0" fast-glob "^3.3.2" -"@react-native-community/cli-config@13.6.6": - version "13.6.6" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-13.6.6.tgz#69f590694b3a079c74f781baab3b762db74f5dbd" - integrity sha512-mbG425zCKr8JZhv/j11382arezwS/70juWMsn8j2lmrGTrP1cUdW0MF15CCIFtJsqyK3Qs+FTmqttRpq81QfSg== +"@react-native-community/cli-clean@13.6.9": + version "13.6.9" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-13.6.9.tgz#b6754f39c2b877c9d730feb848945150e1d52209" + integrity sha512-7Dj5+4p9JggxuVNOjPbduZBAP1SUgNhLKVw5noBUzT/3ZpUZkDM+RCSwyoyg8xKWoE4OrdUAXwAFlMcFDPKykA== dependencies: - "@react-native-community/cli-tools" "13.6.6" + "@react-native-community/cli-tools" "13.6.9" chalk "^4.1.2" - cosmiconfig "^5.1.0" - deepmerge "^4.3.0" + execa "^5.0.0" fast-glob "^3.3.2" - joi "^17.2.1" "@react-native-community/cli-config@13.6.8": version "13.6.8" @@ -2537,12 +2525,17 @@ fast-glob "^3.3.2" joi "^17.2.1" -"@react-native-community/cli-debugger-ui@13.6.6": - version "13.6.6" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-13.6.6.tgz#ac021ebd795b0fd66fb52a8987d1d41c5a4b8cb3" - integrity sha512-Vv9u6eS4vKSDAvdhA0OiQHoA7y39fiPIgJ6biT32tN4avHDtxlc6TWZGiqv7g98SBvDWvoVAmdPLcRf3kU+c8g== +"@react-native-community/cli-config@13.6.9": + version "13.6.9" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-13.6.9.tgz#d609a64d40a173c89bd7d24e31807bb7dcba69f9" + integrity sha512-rFfVBcNojcMm+KKHE/xqpqXg8HoKl4EC7bFHUrahMJ+y/tZll55+oX/PGG37rzB8QzP2UbMQ19DYQKC1G7kXeg== dependencies: - serve-static "^1.13.1" + "@react-native-community/cli-tools" "13.6.9" + chalk "^4.1.2" + cosmiconfig "^5.1.0" + deepmerge "^4.3.0" + fast-glob "^3.3.2" + joi "^17.2.1" "@react-native-community/cli-debugger-ui@13.6.8": version "13.6.8" @@ -2551,28 +2544,12 @@ dependencies: serve-static "^1.13.1" -"@react-native-community/cli-doctor@13.6.6": - version "13.6.6" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-13.6.6.tgz#ac0febff05601d9b86af3e03460e1a6b0a1d33a5" - integrity sha512-TWZb5g6EmQe2Ua2TEWNmyaEayvlWH4GmdD9ZC+p8EpKFpB1NpDGMK6sXbpb42TDvwZg5s4TDRplK0PBEA/SVDg== +"@react-native-community/cli-debugger-ui@13.6.9": + version "13.6.9" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-13.6.9.tgz#bc5727c51964206a00d417e5148b46331a81d5a5" + integrity sha512-TkN7IdFmGPPvTpAo3nCAH9uwGCPxWBEAwpqEZDrq0NWllI7Tdie8vDpGdrcuCcKalmhq6OYnkXzeBah7O1Ztpw== dependencies: - "@react-native-community/cli-config" "13.6.6" - "@react-native-community/cli-platform-android" "13.6.6" - "@react-native-community/cli-platform-apple" "13.6.6" - "@react-native-community/cli-platform-ios" "13.6.6" - "@react-native-community/cli-tools" "13.6.6" - chalk "^4.1.2" - command-exists "^1.2.8" - deepmerge "^4.3.0" - envinfo "^7.10.0" - execa "^5.0.0" - hermes-profile-transformer "^0.0.6" - node-stream-zip "^1.9.1" - ora "^5.4.1" - semver "^7.5.2" - strip-ansi "^5.2.0" - wcwidth "^1.0.1" - yaml "^2.2.1" + serve-static "^1.13.1" "@react-native-community/cli-doctor@13.6.8": version "13.6.8" @@ -2597,15 +2574,28 @@ wcwidth "^1.0.1" yaml "^2.2.1" -"@react-native-community/cli-hermes@13.6.6": - version "13.6.6" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-hermes/-/cli-hermes-13.6.6.tgz#590f55f151fec23b55498228f92d100a0e71d474" - integrity sha512-La5Ie+NGaRl3klei6WxKoOxmCUSGGxpOk6vU5pEGf0/O7ky+Ay0io+zXYUZqlNMi/cGpO7ZUijakBYOB/uyuFg== +"@react-native-community/cli-doctor@13.6.9": + version "13.6.9" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-13.6.9.tgz#f1d4eeff427ddc8a9d19851042621c10939c35cb" + integrity sha512-5quFaLdWFQB+677GXh5dGU9I5eg2z6Vg4jOX9vKnc9IffwyIFAyJfCZHrxLSRPDGNXD7biDQUdoezXYGwb6P/A== dependencies: - "@react-native-community/cli-platform-android" "13.6.6" - "@react-native-community/cli-tools" "13.6.6" + "@react-native-community/cli-config" "13.6.9" + "@react-native-community/cli-platform-android" "13.6.9" + "@react-native-community/cli-platform-apple" "13.6.9" + "@react-native-community/cli-platform-ios" "13.6.9" + "@react-native-community/cli-tools" "13.6.9" chalk "^4.1.2" + command-exists "^1.2.8" + deepmerge "^4.3.0" + envinfo "^7.10.0" + execa "^5.0.0" hermes-profile-transformer "^0.0.6" + node-stream-zip "^1.9.1" + ora "^5.4.1" + semver "^7.5.2" + strip-ansi "^5.2.0" + wcwidth "^1.0.1" + yaml "^2.2.1" "@react-native-community/cli-hermes@13.6.8": version "13.6.8" @@ -2617,17 +2607,15 @@ chalk "^4.1.2" hermes-profile-transformer "^0.0.6" -"@react-native-community/cli-platform-android@13.6.6": - version "13.6.6" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-13.6.6.tgz#9e3863cb092709021f11848890bff0fc16fc1609" - integrity sha512-/tMwkBeNxh84syiSwNlYtmUz/Ppc+HfKtdopL/5RB+fd3SV1/5/NPNjMlyLNgFKnpxvKCInQ7dnl6jGHJjeHjg== +"@react-native-community/cli-hermes@13.6.9": + version "13.6.9" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-hermes/-/cli-hermes-13.6.9.tgz#88c8dfe936a0d4272efc54429eda9ccc3fca3ad8" + integrity sha512-GvwiwgvFw4Ws+krg2+gYj8sR3g05evmNjAHkKIKMkDTJjZ8EdyxbkifRUs1ZCq3TMZy2oeblZBXCJVOH4W7ZbA== dependencies: - "@react-native-community/cli-tools" "13.6.6" + "@react-native-community/cli-platform-android" "13.6.9" + "@react-native-community/cli-tools" "13.6.9" chalk "^4.1.2" - execa "^5.0.0" - fast-glob "^3.3.2" - fast-xml-parser "^4.2.4" - logkitty "^0.7.1" + hermes-profile-transformer "^0.0.6" "@react-native-community/cli-platform-android@13.6.8": version "13.6.8" @@ -2641,17 +2629,17 @@ fast-xml-parser "^4.2.4" logkitty "^0.7.1" -"@react-native-community/cli-platform-apple@13.6.6": - version "13.6.6" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-apple/-/cli-platform-apple-13.6.6.tgz#d445fd6ed02c5ae2f43f9c45501e04fee53a2790" - integrity sha512-bOmSSwoqNNT3AmCRZXEMYKz1Jf1l2F86Nhs7qBcXdY/sGiJ+Flng564LOqvdAlVLTbkgz47KjNKCS2pP4Jg0Mg== +"@react-native-community/cli-platform-android@13.6.9": + version "13.6.9" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-13.6.9.tgz#b175b9b11334fc90da3f395432678bd53c30fae4" + integrity sha512-9KsYGdr08QhdvT3Ht7e8phQB3gDX9Fs427NJe0xnoBh+PDPTI2BD5ks5ttsH8CzEw8/P6H8tJCHq6hf2nxd9cw== dependencies: - "@react-native-community/cli-tools" "13.6.6" + "@react-native-community/cli-tools" "13.6.9" chalk "^4.1.2" execa "^5.0.0" fast-glob "^3.3.2" - fast-xml-parser "^4.0.12" - ora "^5.4.1" + fast-xml-parser "^4.2.4" + logkitty "^0.7.1" "@react-native-community/cli-platform-apple@13.6.8": version "13.6.8" @@ -2665,12 +2653,17 @@ fast-xml-parser "^4.0.12" ora "^5.4.1" -"@react-native-community/cli-platform-ios@13.6.6": - version "13.6.6" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-13.6.6.tgz#0cd700f36483ca37dda7ec044377f8a926b1df1f" - integrity sha512-vjDnRwhlSN5ryqKTas6/DPkxuouuyFBAqAROH4FR1cspTbn6v78JTZKDmtQy9JMMo7N5vZj1kASU5vbFep9IOQ== +"@react-native-community/cli-platform-apple@13.6.9": + version "13.6.9" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-apple/-/cli-platform-apple-13.6.9.tgz#02fb5dc47d62acd85f4d7a852e93216927a772fa" + integrity sha512-KoeIHfhxMhKXZPXmhQdl6EE+jGKWwoO9jUVWgBvibpVmsNjo7woaG/tfJMEWfWF3najX1EkQAoJWpCDBMYWtlA== dependencies: - "@react-native-community/cli-platform-apple" "13.6.6" + "@react-native-community/cli-tools" "13.6.9" + chalk "^4.1.2" + execa "^5.0.0" + fast-glob "^3.3.2" + fast-xml-parser "^4.0.12" + ora "^5.4.1" "@react-native-community/cli-platform-ios@13.6.8": version "13.6.8" @@ -2679,13 +2672,20 @@ dependencies: "@react-native-community/cli-platform-apple" "13.6.8" -"@react-native-community/cli-server-api@13.6.6": - version "13.6.6" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-13.6.6.tgz#467993006ef82361cdf7a9817999d5a09e85ca6a" - integrity sha512-ZtCXxoFlM7oDv3iZ3wsrT3SamhtUJuIkX2WePLPlN5bcbq7zimbPm2lHyicNJtpcGQ5ymsgpUWPCNZsWQhXBqQ== +"@react-native-community/cli-platform-ios@13.6.9": + version "13.6.9" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-13.6.9.tgz#f37ceab41c2302e8f0d4bcbd3bf58b3353db4306" + integrity sha512-CiUcHlGs8vE0CAB4oi1f+dzniqfGuhWPNrDvae2nm8dewlahTBwIcK5CawyGezjcJoeQhjBflh9vloska+nlnw== dependencies: - "@react-native-community/cli-debugger-ui" "13.6.6" - "@react-native-community/cli-tools" "13.6.6" + "@react-native-community/cli-platform-apple" "13.6.9" + +"@react-native-community/cli-server-api@13.6.8": + version "13.6.8" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-13.6.8.tgz#fc654a2990a5f0b6f0b67ef04b25f699bee63f63" + integrity sha512-Lx664oWTzpVfbKUTy+3GIX7e+Mt5Zn+zdkM4ehllNdik/lbB3tM9Nrg8PSvOfI+tTXs2w55+nIydLfH+0FqJVg== + dependencies: + "@react-native-community/cli-debugger-ui" "13.6.8" + "@react-native-community/cli-tools" "13.6.8" compression "^1.7.1" connect "^3.6.5" errorhandler "^1.5.1" @@ -2694,13 +2694,13 @@ serve-static "^1.13.1" ws "^6.2.2" -"@react-native-community/cli-server-api@13.6.8": - version "13.6.8" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-13.6.8.tgz#fc654a2990a5f0b6f0b67ef04b25f699bee63f63" - integrity sha512-Lx664oWTzpVfbKUTy+3GIX7e+Mt5Zn+zdkM4ehllNdik/lbB3tM9Nrg8PSvOfI+tTXs2w55+nIydLfH+0FqJVg== +"@react-native-community/cli-server-api@13.6.9": + version "13.6.9" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-13.6.9.tgz#269e666bc26e9d0b2f42c7f6099559b5f9259e9d" + integrity sha512-W8FSlCPWymO+tlQfM3E0JmM8Oei5HZsIk5S0COOl0MRi8h0NmHI4WSTF2GCfbFZkcr2VI/fRsocoN8Au4EZAug== dependencies: - "@react-native-community/cli-debugger-ui" "13.6.8" - "@react-native-community/cli-tools" "13.6.8" + "@react-native-community/cli-debugger-ui" "13.6.9" + "@react-native-community/cli-tools" "13.6.9" compression "^1.7.1" connect "^3.6.5" errorhandler "^1.5.1" @@ -2709,10 +2709,10 @@ serve-static "^1.13.1" ws "^6.2.2" -"@react-native-community/cli-tools@13.6.6": - version "13.6.6" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-13.6.6.tgz#55c40cbabafbfc56cfb95a4d5fbf73ef60ec3cbc" - integrity sha512-ptOnn4AJczY5njvbdK91k4hcYazDnGtEPrqIwEI+k/CTBHNdb27Rsm2OZ7ye6f7otLBqF8gj/hK6QzJs8CEMgw== +"@react-native-community/cli-tools@13.6.8": + version "13.6.8" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-13.6.8.tgz#65a9f49ce66f0e639d855e745c8dfa7ae7b6c142" + integrity sha512-1MYlae9EkbjC7DBYOGMH5xF9yDoeNYUKgEdDjL6WAUBoF2gtwiZPM6igLKi/+dhb5sCtC7fiLrLi0Oevdf+RmQ== dependencies: appdirsjs "^1.2.4" chalk "^4.1.2" @@ -2726,10 +2726,10 @@ shell-quote "^1.7.3" sudo-prompt "^9.0.0" -"@react-native-community/cli-tools@13.6.8": - version "13.6.8" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-13.6.8.tgz#65a9f49ce66f0e639d855e745c8dfa7ae7b6c142" - integrity sha512-1MYlae9EkbjC7DBYOGMH5xF9yDoeNYUKgEdDjL6WAUBoF2gtwiZPM6igLKi/+dhb5sCtC7fiLrLi0Oevdf+RmQ== +"@react-native-community/cli-tools@13.6.9": + version "13.6.9" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-13.6.9.tgz#2baee279358ba1a863e737b2fa9f45659ad91929" + integrity sha512-OXaSjoN0mZVw3nrAwcY1PC0uMfyTd9fz7Cy06dh+EJc+h0wikABsVRzV8cIOPrVV+PPEEXE0DBrH20T2puZzgQ== dependencies: appdirsjs "^1.2.4" chalk "^4.1.2" @@ -2743,13 +2743,6 @@ shell-quote "^1.7.3" sudo-prompt "^9.0.0" -"@react-native-community/cli-types@13.6.6": - version "13.6.6" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-13.6.6.tgz#b45af119d61888fea1074a7c32ddb093e3f119a9" - integrity sha512-733iaYzlmvNK7XYbnWlMjdE+2k0hlTBJW071af/xb6Bs+hbJqBP9c03FZuYH2hFFwDDntwj05bkri/P7VgSxug== - dependencies: - joi "^17.2.1" - "@react-native-community/cli-types@13.6.8": version "13.6.8" resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-13.6.8.tgz#1c357d3290a48232e3e639d48e43e31e422ce436" @@ -2757,28 +2750,12 @@ dependencies: joi "^17.2.1" -"@react-native-community/cli@13.6.6": - version "13.6.6" - resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-13.6.6.tgz#b929c8668e88344c03a46a3e635cb382dba16773" - integrity sha512-IqclB7VQ84ye8Fcs89HOpOscY4284VZg2pojHNl8H0Lzd4DadXJWQoxC7zWm8v2f8eyeX2kdhxp2ETD5tceIgA== - dependencies: - "@react-native-community/cli-clean" "13.6.6" - "@react-native-community/cli-config" "13.6.6" - "@react-native-community/cli-debugger-ui" "13.6.6" - "@react-native-community/cli-doctor" "13.6.6" - "@react-native-community/cli-hermes" "13.6.6" - "@react-native-community/cli-server-api" "13.6.6" - "@react-native-community/cli-tools" "13.6.6" - "@react-native-community/cli-types" "13.6.6" - chalk "^4.1.2" - commander "^9.4.1" - deepmerge "^4.3.0" - execa "^5.0.0" - find-up "^4.1.0" - fs-extra "^8.1.0" - graceful-fs "^4.1.3" - prompts "^2.4.2" - semver "^7.5.2" +"@react-native-community/cli-types@13.6.9": + version "13.6.9" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-13.6.9.tgz#08bfb796eacf0daeb31e2de516e81e78a36a1a55" + integrity sha512-RLxDppvRxXfs3hxceW/mShi+6o5yS+kFPnPqZTaMKKR5aSg7LwDpLQW4K2D22irEG8e6RKDkZUeH9aL3vO2O0w== + dependencies: + joi "^17.2.1" "@react-native-community/cli@13.6.8": version "13.6.8" @@ -2803,15 +2780,38 @@ prompts "^2.4.2" semver "^7.5.2" -"@react-native-windows/cli@0.74.0": - version "0.74.0" - resolved "https://registry.yarnpkg.com/@react-native-windows/cli/-/cli-0.74.0.tgz#da85c0f8d7f96a761080fae27323fe257560e22d" - integrity sha512-grOp6b/Pfa4T+n+oWmoo18BXI97CKZPbRKTlCg2Ne5Hsq2rj4Ewg8tnRFKFOMthy5dZcPWLqsphkT0J/sQBHXw== +"@react-native-community/cli@13.6.9": + version "13.6.9" + resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-13.6.9.tgz#ba6360b94e0aba9c4001bda256cf7e57e2ecb02c" + integrity sha512-hFJL4cgLPxncJJd/epQ4dHnMg5Jy/7Q56jFvA3MHViuKpzzfTCJCB+pGY54maZbtym53UJON9WTGpM3S81UfjQ== + dependencies: + "@react-native-community/cli-clean" "13.6.9" + "@react-native-community/cli-config" "13.6.9" + "@react-native-community/cli-debugger-ui" "13.6.9" + "@react-native-community/cli-doctor" "13.6.9" + "@react-native-community/cli-hermes" "13.6.9" + "@react-native-community/cli-server-api" "13.6.9" + "@react-native-community/cli-tools" "13.6.9" + "@react-native-community/cli-types" "13.6.9" + chalk "^4.1.2" + commander "^9.4.1" + deepmerge "^4.3.0" + execa "^5.0.0" + find-up "^4.1.0" + fs-extra "^8.1.0" + graceful-fs "^4.1.3" + prompts "^2.4.2" + semver "^7.5.2" + +"@react-native-windows/cli@0.74.7": + version "0.74.7" + resolved "https://registry.yarnpkg.com/@react-native-windows/cli/-/cli-0.74.7.tgz#a9d9e75af3aca9a30a5092a2059c097a813b51c1" + integrity sha512-QcMBxMRH9rutS24PvxMuWNB0V5sULNBMFXo62jYnLtU7mHcEW8lB5CsPrVc1JK5kb7pNFlKs9uHrkPMDn52c+g== dependencies: - "@react-native-windows/codegen" "0.74.0" - "@react-native-windows/fs" "0.74.0" - "@react-native-windows/package-utils" "0.74.0" - "@react-native-windows/telemetry" "0.74.0" + "@react-native-windows/codegen" "0.74.4" + "@react-native-windows/fs" "0.74.1" + "@react-native-windows/package-utils" "0.74.1" + "@react-native-windows/telemetry" "0.74.2" "@xmldom/xmldom" "^0.7.7" chalk "^4.1.0" cli-spinners "^2.2.0" @@ -2830,50 +2830,50 @@ xml-parser "^1.2.1" xpath "^0.0.27" -"@react-native-windows/codegen@0.74.0": - version "0.74.0" - resolved "https://registry.yarnpkg.com/@react-native-windows/codegen/-/codegen-0.74.0.tgz#9024ba6e871088e42356f94eb126697e6268487b" - integrity sha512-jSN5PZQKZIuaukoUJU9LOyHs2Y/KmG5xsLtSGRUcjG8wTrzP+xXxj3115hHdk9vreL80o+pup5o1UNfyLfvGIA== +"@react-native-windows/codegen@0.74.4": + version "0.74.4" + resolved "https://registry.yarnpkg.com/@react-native-windows/codegen/-/codegen-0.74.4.tgz#b191985af9784e4041d76762fe3188f50b1413c7" + integrity sha512-yiUHJweF1VY87x4MrdYfy/sFJpjcog1V5ZsCGqPYBtp7L1F2/aLvqTDoth8c5VK+5JB1lkRF4aJNAmRPQ9xnDg== dependencies: - "@react-native-windows/fs" "0.74.0" + "@react-native-windows/fs" "0.74.1" chalk "^4.1.0" - globby "^11.0.4" + globby "^11.1.0" mustache "^4.0.1" source-map-support "^0.5.19" yargs "^16.2.0" -"@react-native-windows/find-repo-root@0.74.0": - version "0.74.0" - resolved "https://registry.yarnpkg.com/@react-native-windows/find-repo-root/-/find-repo-root-0.74.0.tgz#687819c76825d3f7c58401a9d96c2c748774506f" - integrity sha512-6dxkKX+mtT+yXuTDUf7A+ZQnyX57WlYk3fDNeNTpI66xBR4QuRwPdzTNamZxvX6JEMSe4lm4PqXWlfAKYzPENw== +"@react-native-windows/find-repo-root@0.74.1": + version "0.74.1" + resolved "https://registry.yarnpkg.com/@react-native-windows/find-repo-root/-/find-repo-root-0.74.1.tgz#bf2f10545c29ffcdb76b9179fce346f84e15c5ab" + integrity sha512-k+Hk16/NmPhxsQYGCRtAfcQqCDCJvAxC74FLzFOO6+c/VDM0U05kEcJsJzI1dh/0kZh+YSZQo3w1RrA1z1S2gw== dependencies: - "@react-native-windows/fs" "0.74.0" + "@react-native-windows/fs" "0.74.1" find-up "^4.1.0" -"@react-native-windows/fs@0.74.0": - version "0.74.0" - resolved "https://registry.yarnpkg.com/@react-native-windows/fs/-/fs-0.74.0.tgz#bbef312e6c9541292a69e607c1e5fbc47e2a665c" - integrity sha512-YK8CkNHSwskU3PPCPTw1DPen3/QXS7qP7rAp+FNK4LfyOgiO1V9TiIyz3DcvqOsD+iwriXoEl/3Bvo/8HmlTbQ== +"@react-native-windows/fs@0.74.1": + version "0.74.1" + resolved "https://registry.yarnpkg.com/@react-native-windows/fs/-/fs-0.74.1.tgz#2c6ade1f937adc6056b1a6b052b7b85acb725a14" + integrity sha512-Qepr2KyMvCKugOwIXKXtgMqww5P3yI5HTtxIUWytBCoIPEk1lJdpx/sFjTGmir0QXaLlZxXbdrxpLLnN7eq3Tg== dependencies: graceful-fs "^4.2.8" -"@react-native-windows/package-utils@0.74.0": - version "0.74.0" - resolved "https://registry.yarnpkg.com/@react-native-windows/package-utils/-/package-utils-0.74.0.tgz#bdcd18f993d899a6f9914365863bde7ee4eee509" - integrity sha512-b7c2/DycLM3MK7K6Y4XVuKFBTLvyg0DSP7++f/yZsBWyCysFycAS5gCrlVbXk6Kez3CIEspSS7op+GJMduMp8g== +"@react-native-windows/package-utils@0.74.1": + version "0.74.1" + resolved "https://registry.yarnpkg.com/@react-native-windows/package-utils/-/package-utils-0.74.1.tgz#18e49bb5b2ed967f279605223eae65a3ea55112f" + integrity sha512-nzKo1H991npbRx2EJT0wkniGkngEw7ND5+oz6jhbNFQ3UCKIUBCLc2bPBBX1Z5jp40R+qoVbgnQP2fuAN5y9tA== dependencies: - "@react-native-windows/find-repo-root" "0.74.0" - "@react-native-windows/fs" "0.74.0" + "@react-native-windows/find-repo-root" "0.74.1" + "@react-native-windows/fs" "0.74.1" get-monorepo-packages "^1.2.0" lodash "^4.17.15" -"@react-native-windows/telemetry@0.74.0": - version "0.74.0" - resolved "https://registry.yarnpkg.com/@react-native-windows/telemetry/-/telemetry-0.74.0.tgz#e050312998d6c64f50f368bcb3299e9e3138fd10" - integrity sha512-80vMPWXLJpa3v+vAafXjCQM0GFE3Iq8breRkrwzmbANAfCEXoJdOI0Aju0sOqDyiE68OUekjU9lwWbIyFEQGJQ== +"@react-native-windows/telemetry@0.74.2": + version "0.74.2" + resolved "https://registry.yarnpkg.com/@react-native-windows/telemetry/-/telemetry-0.74.2.tgz#3ad1bdc2be0f43f2009f13368d5c6659064ec3db" + integrity sha512-fTqPYaYB7MtPHTr1ytarFsoPHLHch8EAegblTDTo1ha3a1neGOMTGoxZF2a8/l0y8HSDdsfyTfv8JjCO3w5oow== dependencies: "@azure/core-auth" "1.5.0" - "@react-native-windows/fs" "0.74.0" + "@react-native-windows/fs" "0.74.1" "@xmldom/xmldom" "^0.7.7" applicationinsights "2.9.1" ci-info "^3.2.0" @@ -2882,16 +2882,16 @@ os-locale "^5.0.0" xpath "^0.0.27" -"@react-native/assets-registry@0.74.83": - version "0.74.83" - resolved "https://registry.yarnpkg.com/@react-native/assets-registry/-/assets-registry-0.74.83.tgz#c1815dc10f9e1075e0d03b4c8a9619145969522e" - integrity sha512-2vkLMVnp+YTZYTNSDIBZojSsjz8sl5PscP3j4GcV6idD8V978SZfwFlk8K0ti0BzRs11mzL0Pj17km597S/eTQ== - "@react-native/assets-registry@0.74.84": version "0.74.84" resolved "https://registry.yarnpkg.com/@react-native/assets-registry/-/assets-registry-0.74.84.tgz#aa472f82c1b7d8a30098c8ba22fad7b3dbb5be5f" integrity sha512-dzUhwyaX04QosWZ8zyaaNB/WYZIdeDN1lcpfQbqiOhZJShRH+FLTDVONE/dqlMQrP+EO7lDqF0RrlIt9lnOCQQ== +"@react-native/assets-registry@0.74.87": + version "0.74.87" + resolved "https://registry.yarnpkg.com/@react-native/assets-registry/-/assets-registry-0.74.87.tgz#7dda64e48db14597e19e15f679e31abbb1c1fb4d" + integrity sha512-1XmRhqQchN+pXPKEKYdpJlwESxVomJOxtEnIkbo7GAlaN2sym84fHEGDXAjLilih5GVPpcpSmFzTy8jx3LtaFg== + "@react-native/assets@1.0.0": version "1.0.0" resolved "https://registry.yarnpkg.com/@react-native/assets/-/assets-1.0.0.tgz#c6f9bf63d274bafc8e970628de24986b30a55c8e" @@ -2904,13 +2904,6 @@ dependencies: "@react-native/codegen" "0.74.81" -"@react-native/babel-plugin-codegen@0.74.83": - version "0.74.83" - resolved "https://registry.yarnpkg.com/@react-native/babel-plugin-codegen/-/babel-plugin-codegen-0.74.83.tgz#971f9cfec980dd05598d81964c05a26c6166f9fb" - integrity sha512-+S0st3t4Ro00bi9gjT1jnK8qTFOU+CwmziA7U9odKyWrCoRJrgmrvogq/Dr1YXlpFxexiGIupGut1VHxr+fxJA== - dependencies: - "@react-native/codegen" "0.74.83" - "@react-native/babel-plugin-codegen@0.74.84": version "0.74.84" resolved "https://registry.yarnpkg.com/@react-native/babel-plugin-codegen/-/babel-plugin-codegen-0.74.84.tgz#a3a72c188d875601704a421e395f6909fdec40f3" @@ -2918,6 +2911,13 @@ dependencies: "@react-native/codegen" "0.74.84" +"@react-native/babel-plugin-codegen@0.74.87": + version "0.74.87" + resolved "https://registry.yarnpkg.com/@react-native/babel-plugin-codegen/-/babel-plugin-codegen-0.74.87.tgz#44457f4de69911f37a6ac308a7783203a757574a" + integrity sha512-+vJYpMnENFrwtgvDfUj+CtVJRJuUnzAUYT0/Pb68Sq9RfcZ5xdcCuUgyf7JO+akW2VTBoJY427wkcxU30qrWWw== + dependencies: + "@react-native/codegen" "0.74.87" + "@react-native/babel-preset@0.74.81": version "0.74.81" resolved "https://registry.yarnpkg.com/@react-native/babel-preset/-/babel-preset-0.74.81.tgz#80d0b96eef35d671f97eaf223c4d770170d7f23f" @@ -2967,10 +2967,10 @@ babel-plugin-transform-flow-enums "^0.0.2" react-refresh "^0.14.0" -"@react-native/babel-preset@0.74.83": - version "0.74.83" - resolved "https://registry.yarnpkg.com/@react-native/babel-preset/-/babel-preset-0.74.83.tgz#9828457779b4ce0219078652327ce3203115cdf9" - integrity sha512-KJuu3XyVh3qgyUer+rEqh9a/JoUxsDOzkJNfRpDyXiAyjDRoVch60X/Xa/NcEQ93iCVHAWs0yQ+XGNGIBCYE6g== +"@react-native/babel-preset@0.74.84": + version "0.74.84" + resolved "https://registry.yarnpkg.com/@react-native/babel-preset/-/babel-preset-0.74.84.tgz#703ebfc810d82c9f51f033352abd5f9fa70d492b" + integrity sha512-WUfu6Y4aGuVdocQZvx33BJiQWFH6kRCHYbZfBn2psgFrSRLgQWEQrDCxqPFObNAVSayM0rNhp2FvI5K/Eyeqlg== dependencies: "@babel/core" "^7.20.0" "@babel/plugin-proposal-async-generator-functions" "^7.0.0" @@ -3012,14 +3012,14 @@ "@babel/plugin-transform-typescript" "^7.5.0" "@babel/plugin-transform-unicode-regex" "^7.0.0" "@babel/template" "^7.0.0" - "@react-native/babel-plugin-codegen" "0.74.83" + "@react-native/babel-plugin-codegen" "0.74.84" babel-plugin-transform-flow-enums "^0.0.2" react-refresh "^0.14.0" -"@react-native/babel-preset@0.74.84": - version "0.74.84" - resolved "https://registry.yarnpkg.com/@react-native/babel-preset/-/babel-preset-0.74.84.tgz#703ebfc810d82c9f51f033352abd5f9fa70d492b" - integrity sha512-WUfu6Y4aGuVdocQZvx33BJiQWFH6kRCHYbZfBn2psgFrSRLgQWEQrDCxqPFObNAVSayM0rNhp2FvI5K/Eyeqlg== +"@react-native/babel-preset@0.74.87": + version "0.74.87" + resolved "https://registry.yarnpkg.com/@react-native/babel-preset/-/babel-preset-0.74.87.tgz#3d74517d2ea8898f83b5106027033607d5bda50d" + integrity sha512-hyKpfqzN2nxZmYYJ0tQIHG99FQO0OWXp/gVggAfEUgiT+yNKas1C60LuofUsK7cd+2o9jrpqgqW4WzEDZoBlTg== dependencies: "@babel/core" "^7.20.0" "@babel/plugin-proposal-async-generator-functions" "^7.0.0" @@ -3061,7 +3061,7 @@ "@babel/plugin-transform-typescript" "^7.5.0" "@babel/plugin-transform-unicode-regex" "^7.0.0" "@babel/template" "^7.0.0" - "@react-native/babel-plugin-codegen" "0.74.84" + "@react-native/babel-plugin-codegen" "0.74.87" babel-plugin-transform-flow-enums "^0.0.2" react-refresh "^0.14.0" @@ -3078,10 +3078,10 @@ mkdirp "^0.5.1" nullthrows "^1.1.1" -"@react-native/codegen@0.74.83": - version "0.74.83" - resolved "https://registry.yarnpkg.com/@react-native/codegen/-/codegen-0.74.83.tgz#7c56a82fe7603f0867f0d80ff29db3757b71be55" - integrity sha512-GgvgHS3Aa2J8/mp1uC/zU8HuTh8ZT5jz7a4mVMWPw7+rGyv70Ba8uOVBq6UH2Q08o617IATYc+0HfyzAfm4n0w== +"@react-native/codegen@0.74.84": + version "0.74.84" + resolved "https://registry.yarnpkg.com/@react-native/codegen/-/codegen-0.74.84.tgz#d3425a510b7da558ef5088d9b0aa5e0b1c05c783" + integrity sha512-0hXlnu9i0o8v+gXKQi+x6T471L85kCDwW4WrJiYAeOheWrQdNNW6rC3g8+LL7HXAf7QcHGU/8/d57iYfdVK2BQ== dependencies: "@babel/parser" "^7.20.0" glob "^7.1.1" @@ -3091,10 +3091,10 @@ mkdirp "^0.5.1" nullthrows "^1.1.1" -"@react-native/codegen@0.74.84": - version "0.74.84" - resolved "https://registry.yarnpkg.com/@react-native/codegen/-/codegen-0.74.84.tgz#d3425a510b7da558ef5088d9b0aa5e0b1c05c783" - integrity sha512-0hXlnu9i0o8v+gXKQi+x6T471L85kCDwW4WrJiYAeOheWrQdNNW6rC3g8+LL7HXAf7QcHGU/8/d57iYfdVK2BQ== +"@react-native/codegen@0.74.87": + version "0.74.87" + resolved "https://registry.yarnpkg.com/@react-native/codegen/-/codegen-0.74.87.tgz#47f07a627d0294c8270a03aee098991ed91f8ae9" + integrity sha512-GMSYDiD+86zLKgMMgz9z0k6FxmRn+z6cimYZKkucW4soGbxWsbjUAZoZ56sJwt2FJ3XVRgXCrnOCgXoH/Bkhcg== dependencies: "@babel/parser" "^7.20.0" glob "^7.1.1" @@ -3104,15 +3104,15 @@ mkdirp "^0.5.1" nullthrows "^1.1.1" -"@react-native/community-cli-plugin@0.74.83": - version "0.74.83" - resolved "https://registry.yarnpkg.com/@react-native/community-cli-plugin/-/community-cli-plugin-0.74.83.tgz#58808a58a5288895627548338731e72ebb5b507c" - integrity sha512-7GAFjFOg1mFSj8bnFNQS4u8u7+QtrEeflUIDVZGEfBZQ3wMNI5ycBzbBGycsZYiq00Xvoc6eKFC7kvIaqeJpUQ== +"@react-native/community-cli-plugin@0.74.84": + version "0.74.84" + resolved "https://registry.yarnpkg.com/@react-native/community-cli-plugin/-/community-cli-plugin-0.74.84.tgz#223a0defe8118dc57c8ac852ddd13517ea10c4e2" + integrity sha512-GBKE+1sUh86fS2XXV46gMCNHMc1KetshMbYJ0AhDhldpaILZHqRBX50mdVsiYVvkzp4QjM0nmYqefuJ9NVwicQ== dependencies: - "@react-native-community/cli-server-api" "13.6.6" - "@react-native-community/cli-tools" "13.6.6" - "@react-native/dev-middleware" "0.74.83" - "@react-native/metro-babel-transformer" "0.74.83" + "@react-native-community/cli-server-api" "13.6.8" + "@react-native-community/cli-tools" "13.6.8" + "@react-native/dev-middleware" "0.74.84" + "@react-native/metro-babel-transformer" "0.74.84" chalk "^4.0.0" execa "^5.1.1" metro "^0.80.3" @@ -3122,15 +3122,15 @@ querystring "^0.2.1" readline "^1.3.0" -"@react-native/community-cli-plugin@0.74.84": - version "0.74.84" - resolved "https://registry.yarnpkg.com/@react-native/community-cli-plugin/-/community-cli-plugin-0.74.84.tgz#223a0defe8118dc57c8ac852ddd13517ea10c4e2" - integrity sha512-GBKE+1sUh86fS2XXV46gMCNHMc1KetshMbYJ0AhDhldpaILZHqRBX50mdVsiYVvkzp4QjM0nmYqefuJ9NVwicQ== +"@react-native/community-cli-plugin@0.74.87": + version "0.74.87" + resolved "https://registry.yarnpkg.com/@react-native/community-cli-plugin/-/community-cli-plugin-0.74.87.tgz#4d9798d51381912f3771acded9b6b2804987e952" + integrity sha512-EgJG9lSr8x3X67dHQKQvU6EkO+3ksVlJHYIVv6U/AmW9dN80BEFxgYbSJ7icXS4wri7m4kHdgeq2PQ7/3vvrTQ== dependencies: - "@react-native-community/cli-server-api" "13.6.8" - "@react-native-community/cli-tools" "13.6.8" - "@react-native/dev-middleware" "0.74.84" - "@react-native/metro-babel-transformer" "0.74.84" + "@react-native-community/cli-server-api" "13.6.9" + "@react-native-community/cli-tools" "13.6.9" + "@react-native/dev-middleware" "0.74.87" + "@react-native/metro-babel-transformer" "0.74.87" chalk "^4.0.0" execa "^5.1.1" metro "^0.80.3" @@ -3140,23 +3140,23 @@ querystring "^0.2.1" readline "^1.3.0" -"@react-native/debugger-frontend@0.74.83": - version "0.74.83" - resolved "https://registry.yarnpkg.com/@react-native/debugger-frontend/-/debugger-frontend-0.74.83.tgz#48050afa4e086438073b95f041c0cc84fe3f20de" - integrity sha512-RGQlVUegBRxAUF9c1ss1ssaHZh6CO+7awgtI9sDeU0PzDZY/40ImoPD5m0o0SI6nXoVzbPtcMGzU+VO590pRfA== - "@react-native/debugger-frontend@0.74.84": version "0.74.84" resolved "https://registry.yarnpkg.com/@react-native/debugger-frontend/-/debugger-frontend-0.74.84.tgz#0bde122a988916b6a50f05a7c3ab1c5db029b149" integrity sha512-YUEA03UNFbiYzHpYxlcS2D9+3eNT5YLGkl5yRg3nOSN6KbCc/OttGnNZme+tuSOJwjMN/vcvtDKYkTqjJw8U0A== -"@react-native/dev-middleware@0.74.83": - version "0.74.83" - resolved "https://registry.yarnpkg.com/@react-native/dev-middleware/-/dev-middleware-0.74.83.tgz#9d09cfdb763e8ef81c003b0f99ae4ed1a3539639" - integrity sha512-UH8iriqnf7N4Hpi20D7M2FdvSANwTVStwFCSD7VMU9agJX88Yk0D1T6Meh2RMhUu4kY2bv8sTkNRm7LmxvZqgA== +"@react-native/debugger-frontend@0.74.87": + version "0.74.87" + resolved "https://registry.yarnpkg.com/@react-native/debugger-frontend/-/debugger-frontend-0.74.87.tgz#0bb4f4f54365d04fc975349d5f635cb575f6a5d8" + integrity sha512-MN95DJLYTv4EqJc+9JajA3AJZSBYJz2QEJ3uWlHrOky2vKrbbRVaW1ityTmaZa2OXIvNc6CZwSRSE7xCoHbXhQ== + +"@react-native/dev-middleware@0.74.84": + version "0.74.84" + resolved "https://registry.yarnpkg.com/@react-native/dev-middleware/-/dev-middleware-0.74.84.tgz#19ccfece791742f83f4c0a22a8c14593a45562a2" + integrity sha512-veYw/WmyrAOQHUiIeULzn2duJQnXDPiKq2jZ/lcmDo6jsLirpp+Q73lx09TYgy/oVoPRuV0nfmU3x9B6EV/7qQ== dependencies: "@isaacs/ttlcache" "^1.4.1" - "@react-native/debugger-frontend" "0.74.83" + "@react-native/debugger-frontend" "0.74.84" "@rnx-kit/chromium-edge-launcher" "^1.0.0" chrome-launcher "^0.15.2" connect "^3.6.5" @@ -3169,13 +3169,13 @@ temp-dir "^2.0.0" ws "^6.2.2" -"@react-native/dev-middleware@0.74.84": - version "0.74.84" - resolved "https://registry.yarnpkg.com/@react-native/dev-middleware/-/dev-middleware-0.74.84.tgz#19ccfece791742f83f4c0a22a8c14593a45562a2" - integrity sha512-veYw/WmyrAOQHUiIeULzn2duJQnXDPiKq2jZ/lcmDo6jsLirpp+Q73lx09TYgy/oVoPRuV0nfmU3x9B6EV/7qQ== +"@react-native/dev-middleware@0.74.87": + version "0.74.87" + resolved "https://registry.yarnpkg.com/@react-native/dev-middleware/-/dev-middleware-0.74.87.tgz#254807b579a3015ced659a14c374dbf029a9c04e" + integrity sha512-7TmZ3hTHwooYgIHqc/z87BMe1ryrIqAUi+AF7vsD+EHCGxHFdMjSpf1BZ2SUPXuLnF2cTiTfV2RwhbPzx0tYIA== dependencies: "@isaacs/ttlcache" "^1.4.1" - "@react-native/debugger-frontend" "0.74.84" + "@react-native/debugger-frontend" "0.74.87" "@rnx-kit/chromium-edge-launcher" "^1.0.0" chrome-launcher "^0.15.2" connect "^3.6.5" @@ -3212,31 +3212,31 @@ resolved "https://registry.yarnpkg.com/@react-native/eslint-plugin/-/eslint-plugin-0.74.81.tgz#ac53da7c41a35948b0f9d01d88d2a858e879edb1" integrity sha512-vlbLJ38MFJzcEgNxNswjgDRELvZX5e4SmGhtN9N1ZQpXLkgo3hs+l2m4ulSpKhSmqpbacB5XbuTTMgKOsLj/5w== -"@react-native/gradle-plugin@0.74.83": - version "0.74.83" - resolved "https://registry.yarnpkg.com/@react-native/gradle-plugin/-/gradle-plugin-0.74.83.tgz#4ac60a6d6295d5b920173cbf184ee32e53690810" - integrity sha512-Pw2BWVyOHoBuJVKxGVYF6/GSZRf6+v1Ygc+ULGz5t20N8qzRWPa2fRZWqoxsN7TkNLPsECYY8gooOl7okOcPAQ== - "@react-native/gradle-plugin@0.74.84": version "0.74.84" resolved "https://registry.yarnpkg.com/@react-native/gradle-plugin/-/gradle-plugin-0.74.84.tgz#6ff25fad5f78c276afde96ffc42e04e92d6d92b1" integrity sha512-wYWC5WWXqzCCe4PDogz9pNc4xH5ZamahW5XGSbrrYJ5V3walZ+7z43V6iEBJkZbLjj9YBcSttkXYGr1Xh4veAg== +"@react-native/gradle-plugin@0.74.87": + version "0.74.87" + resolved "https://registry.yarnpkg.com/@react-native/gradle-plugin/-/gradle-plugin-0.74.87.tgz#a66c01fda7a938a116dc27447f0ccce285796b2a" + integrity sha512-T+VX0N1qP+U9V4oAtn7FTX7pfsoVkd1ocyw9swYXgJqU2fK7hC9famW7b3s3ZiufPGPr1VPJe2TVGtSopBjL6A== + "@react-native/js-polyfills@0.74.81": version "0.74.81" resolved "https://registry.yarnpkg.com/@react-native/js-polyfills/-/js-polyfills-0.74.81.tgz#64780497be4ecbff1b27076294e3ebd7df1ba485" integrity sha512-o4MiR+/kkHoeoQ/zPwt81LnTm6pqdg0wOhU7S7vIZUqzJ7YUpnpaAvF+/z7HzUOPudnavoCN0wvcZPe/AMEyCA== -"@react-native/js-polyfills@0.74.83": - version "0.74.83" - resolved "https://registry.yarnpkg.com/@react-native/js-polyfills/-/js-polyfills-0.74.83.tgz#0e189ce3ab0efecd00223f3bfc53663ce08ba013" - integrity sha512-/t74n8r6wFhw4JEoOj3bN71N1NDLqaawB75uKAsSjeCwIR9AfCxlzZG0etsXtOexkY9KMeZIQ7YwRPqUdNXuqw== - "@react-native/js-polyfills@0.74.84": version "0.74.84" resolved "https://registry.yarnpkg.com/@react-native/js-polyfills/-/js-polyfills-0.74.84.tgz#edf0e8463616a2683269bbfe3957590f7ebd910c" integrity sha512-+PgxuUjBw9JVlz6m4ECsIJMLbDopnr4rpLmsG32hQaJrg0wMuvHtsgAY/J/aVCSG2GNUXexfjrnhc+O9yGOZXQ== +"@react-native/js-polyfills@0.74.87": + version "0.74.87" + resolved "https://registry.yarnpkg.com/@react-native/js-polyfills/-/js-polyfills-0.74.87.tgz#d28090a4dae417a2e9ad14e065fcf8cf52cc482c" + integrity sha512-M5Evdn76CuVEF0GsaXiGi95CBZ4IWubHqwXxV9vG9CC9kq0PSkoM2Pn7Lx7dgyp4vT7ccJ8a3IwHbe+5KJRnpw== + "@react-native/metro-babel-transformer@0.74.81": version "0.74.81" resolved "https://registry.yarnpkg.com/@react-native/metro-babel-transformer/-/metro-babel-transformer-0.74.81.tgz#f724eab91e6de82f8d098e6de57f25bb7501d2d6" @@ -3247,16 +3247,6 @@ hermes-parser "0.19.1" nullthrows "^1.1.1" -"@react-native/metro-babel-transformer@0.74.83": - version "0.74.83" - resolved "https://registry.yarnpkg.com/@react-native/metro-babel-transformer/-/metro-babel-transformer-0.74.83.tgz#ba87c3cf041f4c0d2b991231af1a6b4a216e9b5d" - integrity sha512-hGdx5N8diu8y+GW/ED39vTZa9Jx1di2ZZ0aapbhH4egN1agIAusj5jXTccfNBwwWF93aJ5oVbRzfteZgjbutKg== - dependencies: - "@babel/core" "^7.20.0" - "@react-native/babel-preset" "0.74.83" - hermes-parser "0.19.1" - nullthrows "^1.1.1" - "@react-native/metro-babel-transformer@0.74.84": version "0.74.84" resolved "https://registry.yarnpkg.com/@react-native/metro-babel-transformer/-/metro-babel-transformer-0.74.84.tgz#6c2c1632bdf557f176c9d489fbb676522ffb222a" @@ -3267,6 +3257,16 @@ hermes-parser "0.19.1" nullthrows "^1.1.1" +"@react-native/metro-babel-transformer@0.74.87": + version "0.74.87" + resolved "https://registry.yarnpkg.com/@react-native/metro-babel-transformer/-/metro-babel-transformer-0.74.87.tgz#f60958f5e7eb39008a2c01dc5248ab60240bdc01" + integrity sha512-UsJCO24sNax2NSPBmV1zLEVVNkS88kcgAiYrZHtYSwSjpl4WZ656tIeedBfiySdJ94Hr3kQmBYLipV5zk0NI1A== + dependencies: + "@babel/core" "^7.20.0" + "@react-native/babel-preset" "0.74.87" + hermes-parser "0.19.1" + nullthrows "^1.1.1" + "@react-native/metro-config@0.74.81": version "0.74.81" resolved "https://registry.yarnpkg.com/@react-native/metro-config/-/metro-config-0.74.81.tgz#3ed605c0bb51081905171af3e0326abd3adc0b27" @@ -3277,29 +3277,21 @@ metro-config "^0.80.3" metro-runtime "^0.80.3" -"@react-native/normalize-colors@0.74.83": - version "0.74.83" - resolved "https://registry.yarnpkg.com/@react-native/normalize-colors/-/normalize-colors-0.74.83.tgz#86ef925bacf219d74df115bcfb615f62d8142e85" - integrity sha512-jhCY95gRDE44qYawWVvhTjTplW1g+JtKTKM3f8xYT1dJtJ8QWv+gqEtKcfmOHfDkSDaMKG0AGBaDTSK8GXLH8Q== - "@react-native/normalize-colors@0.74.84": version "0.74.84" resolved "https://registry.yarnpkg.com/@react-native/normalize-colors/-/normalize-colors-0.74.84.tgz#4764d59775c17a6ed193509cb01ae2f42dd5c045" integrity sha512-Y5W6x8cC5RuakUcTVUFNAIhUZ/tYpuqHZlRBoAuakrTwVuoNHXfQki8lj1KsYU7rW6e3VWgdEx33AfOQpdNp6A== +"@react-native/normalize-colors@0.74.87": + version "0.74.87" + resolved "https://registry.yarnpkg.com/@react-native/normalize-colors/-/normalize-colors-0.74.87.tgz#a814169d0ce4ce13ffebcda0a3a5a3f780ccd772" + integrity sha512-Xh7Nyk/MPefkb0Itl5Z+3oOobeG9lfLb7ZOY2DKpFnoCE1TzBmib9vMNdFaLdSxLIP+Ec6icgKtdzYg8QUPYzA== + "@react-native/typescript-config@0.74.81": version "0.74.81" resolved "https://registry.yarnpkg.com/@react-native/typescript-config/-/typescript-config-0.74.81.tgz#a249b6a21b577d572a0a70056d7c48a55fd6662f" integrity sha512-jk4LJUKdRYmXxxpebRSW8mK9xJPW90W6BE1IE9LdFi0exdsnVv5gXM9QylG+9kDVZj3bltMuMVdijWnU7SRNbg== -"@react-native/virtualized-lists@0.74.83": - version "0.74.83" - resolved "https://registry.yarnpkg.com/@react-native/virtualized-lists/-/virtualized-lists-0.74.83.tgz#5595d6aefd9679d1295c56a1d1653b1fb261bd62" - integrity sha512-rmaLeE34rj7py4FxTod7iMTC7BAsm+HrGA8WxYmEJeyTV7WSaxAkosKoYBz8038mOiwnG9VwA/7FrB6bEQvn1A== - dependencies: - invariant "^2.2.4" - nullthrows "^1.1.1" - "@react-native/virtualized-lists@0.74.84": version "0.74.84" resolved "https://registry.yarnpkg.com/@react-native/virtualized-lists/-/virtualized-lists-0.74.84.tgz#cf32fffc93072942532c9c81bd7e4c01a2949626" @@ -3308,6 +3300,14 @@ invariant "^2.2.4" nullthrows "^1.1.1" +"@react-native/virtualized-lists@0.74.87": + version "0.74.87" + resolved "https://registry.yarnpkg.com/@react-native/virtualized-lists/-/virtualized-lists-0.74.87.tgz#31bc44d62617df7d893df22c4c57094f576677a0" + integrity sha512-lsGxoFMb0lyK/MiplNKJpD+A1EoEUumkLrCjH4Ht+ZlG8S0BfCxmskLZ6qXn3BiDSkLjfjI/qyZ3pnxNBvkXpQ== + dependencies: + invariant "^2.2.4" + nullthrows "^1.1.1" + "@rnx-kit/chromium-edge-launcher@^1.0.0": version "1.0.0" resolved "https://registry.yarnpkg.com/@rnx-kit/chromium-edge-launcher/-/chromium-edge-launcher-1.0.0.tgz#c0df8ea00a902c7a417cd9655aab06de398b939c" @@ -5489,7 +5489,7 @@ globalthis@^1.0.3: dependencies: define-properties "^1.1.3" -globby@^11.0.4, globby@^11.1.0: +globby@^11.1.0: version "11.1.0" resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== @@ -7627,43 +7627,29 @@ react-is@^17.0.1: resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== -react-native-reanimated@3.9.0: - version "3.9.0" - resolved "https://registry.yarnpkg.com/react-native-reanimated/-/react-native-reanimated-3.9.0.tgz#e5c5f303415a2aadd7db786005159b26c21ae495" - integrity sha512-OMZV2BVmxZvm8UhlXBrESO0y/ODGTRpQRQUO7U9QXysOF9RaR8FbO6KS0x99MH19zfFTV8cLGN/vYW1dFia9Rw== - dependencies: - "@babel/plugin-transform-arrow-functions" "^7.0.0-0" - "@babel/plugin-transform-nullish-coalescing-operator" "^7.0.0-0" - "@babel/plugin-transform-optional-chaining" "^7.0.0-0" - "@babel/plugin-transform-shorthand-properties" "^7.0.0-0" - "@babel/plugin-transform-template-literals" "^7.0.0-0" - "@babel/preset-typescript" "^7.16.7" - convert-source-map "^2.0.0" - invariant "^2.2.4" - "react-native-svg@link:../..": version "0.0.0" uid "" -react-native-windows@0.74.9: - version "0.74.9" - resolved "https://registry.yarnpkg.com/react-native-windows/-/react-native-windows-0.74.9.tgz#2abcc8eb99a4ce0ce80dfe2dea8ce249b8e21469" - integrity sha512-0WEwKhfi+WyjVswT6pRewfw2V694KYfTMIDSITDEu3Y3A9m1o0YyisnURxc4KRndRc0FQuw1iUf49uVK7BnXAw== +react-native-windows@0.74.23: + version "0.74.23" + resolved "https://registry.yarnpkg.com/react-native-windows/-/react-native-windows-0.74.23.tgz#50eb9494413e5efdf58045e9e573d2af398c1b25" + integrity sha512-r8YXuLff4fIxL8HNKquV4BYS5VZNWQzIuoRJUgsECSUCYwzd1z0oY0/cxifzNwf5c9XBVHuQZlSDjl3HMbWUgw== dependencies: "@babel/runtime" "^7.0.0" "@jest/create-cache-key-function" "^29.6.3" - "@react-native-community/cli" "13.6.6" - "@react-native-community/cli-platform-android" "13.6.6" - "@react-native-community/cli-platform-ios" "13.6.6" - "@react-native-windows/cli" "0.74.0" + "@react-native-community/cli" "13.6.9" + "@react-native-community/cli-platform-android" "13.6.9" + "@react-native-community/cli-platform-ios" "13.6.9" + "@react-native-windows/cli" "0.74.7" "@react-native/assets" "1.0.0" - "@react-native/assets-registry" "0.74.83" - "@react-native/codegen" "0.74.83" - "@react-native/community-cli-plugin" "0.74.83" - "@react-native/gradle-plugin" "0.74.83" - "@react-native/js-polyfills" "0.74.83" - "@react-native/normalize-colors" "0.74.83" - "@react-native/virtualized-lists" "0.74.83" + "@react-native/assets-registry" "0.74.87" + "@react-native/codegen" "0.74.87" + "@react-native/community-cli-plugin" "0.74.87" + "@react-native/gradle-plugin" "0.74.87" + "@react-native/js-polyfills" "0.74.87" + "@react-native/normalize-colors" "0.74.87" + "@react-native/virtualized-lists" "0.74.87" abort-controller "^3.0.0" anser "^1.4.9" ansi-regex "^5.0.0" diff --git a/apps/paper-windows-example/babel.config.js b/apps/paper-windows-example/babel.config.js index bd798c39e..f7b3da3b3 100644 --- a/apps/paper-windows-example/babel.config.js +++ b/apps/paper-windows-example/babel.config.js @@ -1,8 +1,3 @@ module.exports = { presets: ['module:@react-native/babel-preset'], - plugins: [ - '@babel/plugin-proposal-export-namespace-from', - 'module:react-native-dotenv', - 'react-native-reanimated/plugin', - ], }; diff --git a/apps/paper-windows-example/index.js b/apps/paper-windows-example/index.js index a7ab94e96..8526e8c4e 100644 --- a/apps/paper-windows-example/index.js +++ b/apps/paper-windows-example/index.js @@ -3,7 +3,7 @@ */ import { AppRegistry } from 'react-native'; -import App from '../common'; +import App from '../common/noNavigationApp'; import { name as appName } from './app.json'; AppRegistry.registerComponent(appName, () => App); diff --git a/apps/paper-windows-example/package.json b/apps/paper-windows-example/package.json index fec7cf7c7..e9c1e8ec1 100644 --- a/apps/paper-windows-example/package.json +++ b/apps/paper-windows-example/package.json @@ -14,14 +14,11 @@ "react": "18.2.0", "react-dom": "^18.2.0", "react-native": "0.74.2", - "react-native-reanimated": "3.15.4", "react-native-svg": "link:../../", - "react-native-view-shot": "4.0.0-alpha.2", - "react-native-windows": "0.74.9" + "react-native-windows": "0.74.23" }, "devDependencies": { "@babel/core": "^7.20.0", - "@babel/plugin-proposal-export-namespace-from": "^7.18.9", "@babel/preset-env": "^7.20.0", "@babel/runtime": "^7.20.0", "@react-native/babel-preset": "0.74.84", @@ -39,7 +36,6 @@ "patch-package": "^8.0.0", "postinstall-postinstall": "^2.1.0", "prettier": "2.8.8", - "react-native-dotenv": "^3.4.11", "react-test-renderer": "18.2.0", "typescript": "5.0.4" }, diff --git a/apps/paper-windows-example/patches/react-native-view-shot+4.0.0-alpha.2.patch b/apps/paper-windows-example/patches/react-native-view-shot+4.0.0-alpha.2.patch deleted file mode 100644 index 0caa56023..000000000 --- a/apps/paper-windows-example/patches/react-native-view-shot+4.0.0-alpha.2.patch +++ /dev/null @@ -1,51 +0,0 @@ -diff --git a/node_modules/react-native-view-shot/ios/RNViewShot.m b/node_modules/react-native-view-shot/ios/RNViewShot.m -index bd55b92..6a20e9d 100644 ---- a/node_modules/react-native-view-shot/ios/RNViewShot.m -+++ b/node_modules/react-native-view-shot/ios/RNViewShot.m -@@ -106,7 +106,7 @@ - (dispatch_queue_t)methodQueue - scrollView.frame = CGRectMake(0, 0, scrollView.contentSize.width, scrollView.contentSize.height); - } - -- UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:size]; -+ UIGraphicsBeginImageContextWithOptions(size, NO, 0); - - if (renderInContext) { - // this comes with some trade-offs such as inability to capture gradients or scrollview's content in full but it works for large views -@@ -117,8 +117,8 @@ - (dispatch_queue_t)methodQueue - // this doesn't work for large views and reports incorrect success even though the image is blank - success = [rendered drawViewHierarchyInRect:(CGRect){CGPointZero, size} afterScreenUpdates:YES]; - } -- -- UIImage *image = [renderer imageWithActions:^(UIGraphicsImageRendererContext * _Nonnull rendererContext) {}]; -+ UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); -+ UIGraphicsEndImageContext(); - - if (snapshotContentContainer) { - // Restore scroll & frame -@@ -152,11 +152,11 @@ - (dispatch_queue_t)methodQueue - NSString *res = nil; - if ([result isEqualToString:@"base64"]) { - // Return as a base64 raw string -- res = [data base64EncodedStringWithOptions: 0]; -+ res = [data base64EncodedStringWithOptions: NSDataBase64EncodingEndLineWithLineFeed]; - } - else if ([result isEqualToString:@"data-uri"]) { - // Return as a base64 data uri string -- NSString *base64 = [data base64EncodedStringWithOptions: 0]; -+ NSString *base64 = [data base64EncodedStringWithOptions: NSDataBase64EncodingEndLineWithLineFeed]; - NSString *imageFormat = ([format isEqualToString:@"jpg"]) ? @"jpeg" : format; - res = [NSString stringWithFormat:@"data:image/%@;base64,%@", imageFormat, base64]; - } -diff --git a/node_modules/react-native-view-shot/src/specs/NativeRNViewShot.ts b/node_modules/react-native-view-shot/src/specs/NativeRNViewShot.ts -index a6f4c00..1e9e6ce 100644 ---- a/node_modules/react-native-view-shot/src/specs/NativeRNViewShot.ts -+++ b/node_modules/react-native-view-shot/src/specs/NativeRNViewShot.ts -@@ -2,7 +2,7 @@ import type { TurboModule } from 'react-native'; - import { TurboModuleRegistry } from 'react-native'; - - export interface Spec extends TurboModule { -- releaseCapture: () => string; -+ releaseCapture: (uri: string) => void; - captureRef: (tag: number, options: Object) => Promise - captureScreen: (options: Object) => Promise; - } \ No newline at end of file diff --git a/apps/paper-windows-example/patches/react-native-windows+0.74.9.patch b/apps/paper-windows-example/patches/react-native-windows+0.74.23.patch similarity index 97% rename from apps/paper-windows-example/patches/react-native-windows+0.74.9.patch rename to apps/paper-windows-example/patches/react-native-windows+0.74.23.patch index 8d1dd2380..fdf1ad4dc 100644 --- a/apps/paper-windows-example/patches/react-native-windows+0.74.9.patch +++ b/apps/paper-windows-example/patches/react-native-windows+0.74.23.patch @@ -1,5 +1,5 @@ diff --git a/node_modules/react-native-windows/Microsoft.ReactNative/Modules/NativeUIManager.cpp b/node_modules/react-native-windows/Microsoft.ReactNative/Modules/NativeUIManager.cpp -index 97c1691..8136008 100644 +index fb25176..eb1201a 100644 --- a/node_modules/react-native-windows/Microsoft.ReactNative/Modules/NativeUIManager.cpp +++ b/node_modules/react-native-windows/Microsoft.ReactNative/Modules/NativeUIManager.cpp @@ -309,16 +309,10 @@ static YGValue YGValueOrDefault( diff --git a/apps/paper-windows-example/windows/Example/packages.lock.json b/apps/paper-windows-example/windows/Example/packages.lock.json index 30a6a0227..f5419aae6 100644 --- a/apps/paper-windows-example/windows/Example/packages.lock.json +++ b/apps/paper-windows-example/windows/Example/packages.lock.json @@ -4,9 +4,9 @@ "native,Version=v0.0": { "Microsoft.JavaScript.Hermes": { "type": "Direct", - "requested": "[0.1.21, )", - "resolved": "0.1.21", - "contentHash": "5njCh+3eXTLOv7+8nOnp6nJ5C0r6it5ze54c0nuWleeDptuK8t3dEDB79XTU4D5DKNvAPlqJpgXRDOak5nYIug==" + "requested": "[0.1.23, )", + "resolved": "0.1.23", + "contentHash": "cA9t1GjY4Yo0JD1AfA//e1lOwk48hLANfuX6GXrikmEBNZVr2TIX5ONJt5tqCnpZyLz6xGiPDgTfFNKbSfb21g==" }, "Microsoft.UI.Xaml": { "type": "Direct", @@ -25,18 +25,130 @@ }, "boost": { "type": "Transitive", - "resolved": "1.76.0", - "contentHash": "p+w3YvNdXL8Cu9Fzrmexssu0tZbWxuf6ywsQqHjDlKFE5ojXHof1HIyMC3zDLfLnh80dIeFcEUAuR2Asg/XHRA==" + "resolved": "1.83.0", + "contentHash": "cy53VNMzysEMvhBixDe8ujPk67Fcj3v6FPHQnH91NYJNLHpc6jxa2xq9ruCaaJjE4M3YrGSHDi4uUSTGBWw6EQ==" + }, + "Microsoft.Net.Native.Compiler": { + "type": "Transitive", + "resolved": "2.2.9-rel-29512-01", + "contentHash": "xjK9G8qoKaN1kUvOp/PuqYYxk6uGTZFwHUsHLrLXLyFVxnoHq/woqWyVb/n22uNWYtAoioeXlm6hZ0M8/f7eXw==", + "dependencies": { + "runtime.win10-arm.Microsoft.Net.Native.Compiler": "2.2.9-rel-29512-01", + "runtime.win10-arm64.Microsoft.Net.Native.Compiler": "2.2.9-rel-29512-01", + "runtime.win10-x64.Microsoft.Net.Native.Compiler": "2.2.9-rel-29512-01", + "runtime.win10-x86.Microsoft.Net.Native.Compiler": "2.2.9-rel-29512-01" + } + }, + "Microsoft.Net.UWPCoreRuntimeSdk": { + "type": "Transitive", + "resolved": "2.2.11", + "contentHash": "B1p3txWKwmO+Csf126X9y1gVQej/zOfUUAOE90iOmEHFMieIle/XfKrrAtlHIIo5snylwB8LgDsRn0kWlDsHhg==", + "dependencies": { + "runtime.win10-arm.Microsoft.Net.UWPCoreRuntimeSdk": "2.2.11", + "runtime.win10-x64.Microsoft.Net.UWPCoreRuntimeSdk": "2.2.11", + "runtime.win10-x86.Microsoft.Net.UWPCoreRuntimeSdk": "2.2.11" + } + }, + "Microsoft.NETCore.Platforms": { + "type": "Transitive", + "resolved": "2.1.0", + "contentHash": "ok+RPAtESz/9MUXeIEz6Lv5XAGQsaNmEYXMsgVALj4D7kqC8gveKWXWXbufLySR2fWrwZf8smyN5RmHu0e4BHA==" + }, + "Microsoft.NETCore.UniversalWindowsPlatform": { + "type": "Transitive", + "resolved": "6.2.11", + "contentHash": "YeOCD+m2tfqkYzQ2hAKZ52cTrHWU0HRS4/2vf3SeZ+KHWq+unmskH+TrRktaIj/pChwPUMwLdCTU5/+4WeQcWQ==", + "dependencies": { + "Microsoft.NETCore.Platforms": "2.1.0", + "Microsoft.Net.Native.Compiler": "2.2.9-rel-29512-01", + "Microsoft.Net.UWPCoreRuntimeSdk": "2.2.11", + "NETStandard.Library": "2.0.3" + } }, "Microsoft.Web.WebView2": { "type": "Transitive", "resolved": "1.0.1264.42", "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" }, + "NETStandard.Library": { + "type": "Transitive", + "resolved": "2.0.3", + "contentHash": "st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.1.0" + } + }, + "runtime.win10-arm.Microsoft.Net.Native.Compiler": { + "type": "Transitive", + "resolved": "2.2.9-rel-29512-01", + "contentHash": "p+v2gthEgj5Tgm4Cl05mfV0w6Q7IFMdOQXZQsiZRg4wBkKSdVoW9lgaxF8bVffBJYes2Vm8ovKpxwTrmEXRzFg==", + "dependencies": { + "runtime.win10-arm.Microsoft.Net.Native.SharedLibrary": "2.2.8-rel-29512-01" + } + }, + "runtime.win10-arm.Microsoft.Net.Native.SharedLibrary": { + "type": "Transitive", + "resolved": "2.2.8-rel-29512-01", + "contentHash": "GUQ7Ubf9ts1XfNNaDrJUnmpsKfpcyZ+8NeZoDyYlImgT/UukkW1cYaxqbxM8VH+g5iIGXeO7suVv8tkwE862FA==" + }, + "runtime.win10-arm.Microsoft.Net.UWPCoreRuntimeSdk": { + "type": "Transitive", + "resolved": "2.2.11", + "contentHash": "R1RaI4RSc+H9E5Pq9pndWzAv4dxztym4+TAII4VrsReePMGRM8eoJByg47BAPM4Y9mBv7esR0KhYc5J1/hpUIw==" + }, + "runtime.win10-arm64.Microsoft.Net.Native.Compiler": { + "type": "Transitive", + "resolved": "2.2.9-rel-29512-01", + "contentHash": "8ex2blgQcIw/MoaJH7hqRJdekTWgMUz5Qb+xmVeGvbB/lWl4BPv6/J9+cmcFxEM+Z7OA8xilFH1kwWFMyvak1A==", + "dependencies": { + "runtime.win10-arm64.Microsoft.Net.Native.SharedLibrary": "2.2.8-rel-29512-01" + } + }, + "runtime.win10-arm64.Microsoft.Net.Native.SharedLibrary": { + "type": "Transitive", + "resolved": "2.2.8-rel-29512-01", + "contentHash": "iYqXJq6hpg07RqAqq8RAffVU1308cQ2ta4ZZtfWI8tbVXGuKOU6he52AMgz4JfcP/Yb/khy9Gdxl62MVXcctzg==" + }, + "runtime.win10-x64.Microsoft.Net.Native.Compiler": { + "type": "Transitive", + "resolved": "2.2.9-rel-29512-01", + "contentHash": "sgiiODHWt4WZ9mDpZd+XkCdWYCBZukjZPNz3XJdeKeeNcRA4y4OTtd2+STWytXDxWAXUNRjImDF5XP48jNXj8A==", + "dependencies": { + "runtime.win10-x64.Microsoft.Net.Native.SharedLibrary": "2.2.8-rel-29512-01" + } + }, + "runtime.win10-x64.Microsoft.Net.Native.SharedLibrary": { + "type": "Transitive", + "resolved": "2.2.8-rel-29512-01", + "contentHash": "JoJavADSFAHk8KQo/bIHT+TTM1gn26X7A3DBltr0ocxcR+6FEnrFa1dLev2tFWmUcndeoyTklndZKwBkSFfEDw==" + }, + "runtime.win10-x64.Microsoft.Net.UWPCoreRuntimeSdk": { + "type": "Transitive", + "resolved": "2.2.11", + "contentHash": "7e8MH4/tzwVV25dUvq+eYgvH31Tyi7kpGNcsqfzfJDYxA6hpGijhfZFFn2QHjORRoTu/BVxGM/9xc/bP4J0vRg==" + }, + "runtime.win10-x86.Microsoft.Net.Native.Compiler": { + "type": "Transitive", + "resolved": "2.2.9-rel-29512-01", + "contentHash": "M586UCPkXEXFbbC7dNznyN9/uNSWNjOeWWHrKNhwztaIl5iCaqr9ITDu55hd7tRdsoi/mPthAH470k4Vml/UrA==", + "dependencies": { + "runtime.win10-x86.Microsoft.Net.Native.SharedLibrary": "2.2.8-rel-29512-01" + } + }, + "runtime.win10-x86.Microsoft.Net.Native.SharedLibrary": { + "type": "Transitive", + "resolved": "2.2.8-rel-29512-01", + "contentHash": "s+oRLOdFSD8FS/hG2MBLzcdPzvBOzQqydYGLl/E+jaB7ijqYs8Dd3yeK72HgWLmKvp3rtkPhCHeRqYhA54+1YQ==" + }, + "runtime.win10-x86.Microsoft.Net.UWPCoreRuntimeSdk": { + "type": "Transitive", + "resolved": "2.2.11", + "contentHash": "NF8tUTxFfwd8MXiA6ygCVuT7dVgEkaHpuwFnDeP1L2i1SIOxhk5w4HHySjmvbRSYtnjLA9BlOtwjGIJCztOHeg==" + }, "common": { "type": "Project", "dependencies": { - "boost": "[1.76.0, )" + "boost": "[1.83.0, )" } }, "fmt": { @@ -46,7 +158,7 @@ "type": "Project", "dependencies": { "Fmt": "[1.0.0, )", - "boost": "[1.76.0, )" + "boost": "[1.83.0, )" } }, "microsoft.reactnative": { @@ -54,17 +166,38 @@ "dependencies": { "Common": "[1.0.0, )", "Folly": "[1.0.0, )", - "Microsoft.JavaScript.Hermes": "[0.1.21, )", + "Microsoft.JavaScript.Hermes": "[0.1.23, )", "Microsoft.UI.Xaml": "[2.8.0, )", "ReactCommon": "[1.0.0, )", - "boost": "[1.76.0, )" + "boost": "[1.83.0, )" + } + }, + "microsoft.reactnative.managed": { + "type": "Project", + "dependencies": { + "Microsoft.NETCore.UniversalWindowsPlatform": "[6.2.9, )", + "Microsoft.ReactNative": "[1.0.0, )" } }, "reactcommon": { "type": "Project", "dependencies": { "Folly": "[1.0.0, )", - "boost": "[1.76.0, )" + "boost": "[1.83.0, )" + } + }, + "reactnativeasyncstorage": { + "type": "Project", + "dependencies": { + "Microsoft.ReactNative": "[1.0.0, )", + "Microsoft.UI.Xaml": "[2.8.0, )" + } + }, + "rnscreens": { + "type": "Project", + "dependencies": { + "Microsoft.ReactNative": "[1.0.0, )", + "Microsoft.UI.Xaml": "[2.8.0, )" } }, "rnsvg": { @@ -73,55 +206,182 @@ "Microsoft.ReactNative": "[1.0.0, )", "Microsoft.UI.Xaml": "[2.8.0, )" } + }, + "rnviewshot": { + "type": "Project", + "dependencies": { + "Microsoft.NETCore.UniversalWindowsPlatform": "[6.2.11, )", + "Microsoft.ReactNative": "[1.0.0, )", + "Microsoft.ReactNative.Managed": "[1.0.0, )" + } } }, "native,Version=v0.0/win10-arm": { + "Microsoft.NETCore.UniversalWindowsPlatform": { + "type": "Transitive", + "resolved": "6.2.11", + "contentHash": "YeOCD+m2tfqkYzQ2hAKZ52cTrHWU0HRS4/2vf3SeZ+KHWq+unmskH+TrRktaIj/pChwPUMwLdCTU5/+4WeQcWQ==", + "dependencies": { + "Microsoft.NETCore.Platforms": "2.1.0", + "Microsoft.Net.Native.Compiler": "2.2.9-rel-29512-01", + "Microsoft.Net.UWPCoreRuntimeSdk": "2.2.11", + "NETStandard.Library": "2.0.3", + "runtime.win10-arm.Microsoft.NETCore.UniversalWindowsPlatform": "6.2.11" + } + }, "Microsoft.Web.WebView2": { "type": "Transitive", "resolved": "1.0.1264.42", "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" + }, + "runtime.win10-arm.Microsoft.NETCore.UniversalWindowsPlatform": { + "type": "Transitive", + "resolved": "6.2.11", + "contentHash": "TMXtd4TVwVgENc4tFWZ+rfnJXZfwRmeL9vkkwMjyCK6+dknZaFuiRMnZ9ggPDMZ4qtq4eKXDqhp7GIVzLkmTxQ==" } }, "native,Version=v0.0/win10-arm-aot": { + "Microsoft.NETCore.UniversalWindowsPlatform": { + "type": "Transitive", + "resolved": "6.2.11", + "contentHash": "YeOCD+m2tfqkYzQ2hAKZ52cTrHWU0HRS4/2vf3SeZ+KHWq+unmskH+TrRktaIj/pChwPUMwLdCTU5/+4WeQcWQ==", + "dependencies": { + "Microsoft.NETCore.Platforms": "2.1.0", + "Microsoft.Net.Native.Compiler": "2.2.9-rel-29512-01", + "Microsoft.Net.UWPCoreRuntimeSdk": "2.2.11", + "NETStandard.Library": "2.0.3", + "runtime.win10-arm-aot.Microsoft.NETCore.UniversalWindowsPlatform": "6.2.11" + } + }, "Microsoft.Web.WebView2": { "type": "Transitive", "resolved": "1.0.1264.42", "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" + }, + "runtime.win10-arm-aot.Microsoft.NETCore.UniversalWindowsPlatform": { + "type": "Transitive", + "resolved": "6.2.11", + "contentHash": "Sn/jnBh7ggB1TqoxrsEM2S+JpFM8FOO8lXRfdp9LWbUI1Vgzb+a5wpS1bXki1lJK6cFrVldDjbZv4D4NEfJuyg==" } }, "native,Version=v0.0/win10-arm64-aot": { + "Microsoft.NETCore.UniversalWindowsPlatform": { + "type": "Transitive", + "resolved": "6.2.11", + "contentHash": "YeOCD+m2tfqkYzQ2hAKZ52cTrHWU0HRS4/2vf3SeZ+KHWq+unmskH+TrRktaIj/pChwPUMwLdCTU5/+4WeQcWQ==", + "dependencies": { + "Microsoft.NETCore.Platforms": "2.1.0", + "Microsoft.Net.Native.Compiler": "2.2.9-rel-29512-01", + "Microsoft.Net.UWPCoreRuntimeSdk": "2.2.11", + "NETStandard.Library": "2.0.3", + "runtime.win10-arm64-aot.Microsoft.NETCore.UniversalWindowsPlatform": "6.2.11" + } + }, "Microsoft.Web.WebView2": { "type": "Transitive", "resolved": "1.0.1264.42", "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" + }, + "runtime.win10-arm64-aot.Microsoft.NETCore.UniversalWindowsPlatform": { + "type": "Transitive", + "resolved": "6.2.11", + "contentHash": "07IvykpRbKdON7JjrBxshOKTqkJ39h7b6xc6AE09h8DaoP8CsUkyn+IBRlMGAzfVNnQwaoCKf+EWoSCueBKaqQ==" } }, "native,Version=v0.0/win10-x64": { + "Microsoft.NETCore.UniversalWindowsPlatform": { + "type": "Transitive", + "resolved": "6.2.11", + "contentHash": "YeOCD+m2tfqkYzQ2hAKZ52cTrHWU0HRS4/2vf3SeZ+KHWq+unmskH+TrRktaIj/pChwPUMwLdCTU5/+4WeQcWQ==", + "dependencies": { + "Microsoft.NETCore.Platforms": "2.1.0", + "Microsoft.Net.Native.Compiler": "2.2.9-rel-29512-01", + "Microsoft.Net.UWPCoreRuntimeSdk": "2.2.11", + "NETStandard.Library": "2.0.3", + "runtime.win10-x64.Microsoft.NETCore.UniversalWindowsPlatform": "6.2.11" + } + }, "Microsoft.Web.WebView2": { "type": "Transitive", "resolved": "1.0.1264.42", "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" + }, + "runtime.win10-x64.Microsoft.NETCore.UniversalWindowsPlatform": { + "type": "Transitive", + "resolved": "6.2.11", + "contentHash": "EqfKqHuQsosS4oPFBaKlUFMSV2ZSLh2VoxWnLkPiydVK9jIh31c2Au1csZ5ucQmXOra3vEuZLToOK4XNVLW2wQ==" } }, "native,Version=v0.0/win10-x64-aot": { + "Microsoft.NETCore.UniversalWindowsPlatform": { + "type": "Transitive", + "resolved": "6.2.11", + "contentHash": "YeOCD+m2tfqkYzQ2hAKZ52cTrHWU0HRS4/2vf3SeZ+KHWq+unmskH+TrRktaIj/pChwPUMwLdCTU5/+4WeQcWQ==", + "dependencies": { + "Microsoft.NETCore.Platforms": "2.1.0", + "Microsoft.Net.Native.Compiler": "2.2.9-rel-29512-01", + "Microsoft.Net.UWPCoreRuntimeSdk": "2.2.11", + "NETStandard.Library": "2.0.3", + "runtime.win10-x64-aot.Microsoft.NETCore.UniversalWindowsPlatform": "6.2.11" + } + }, "Microsoft.Web.WebView2": { "type": "Transitive", "resolved": "1.0.1264.42", "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" + }, + "runtime.win10-x64-aot.Microsoft.NETCore.UniversalWindowsPlatform": { + "type": "Transitive", + "resolved": "6.2.11", + "contentHash": "PfST4gE/8rgl0tPMlGYp7BqzFjrhSGMQd+V68P4IMze9V6cnlkyXof4apD9MDzl7MPMPO0wwlkMj89+4+vXP3A==" } }, "native,Version=v0.0/win10-x86": { + "Microsoft.NETCore.UniversalWindowsPlatform": { + "type": "Transitive", + "resolved": "6.2.11", + "contentHash": "YeOCD+m2tfqkYzQ2hAKZ52cTrHWU0HRS4/2vf3SeZ+KHWq+unmskH+TrRktaIj/pChwPUMwLdCTU5/+4WeQcWQ==", + "dependencies": { + "Microsoft.NETCore.Platforms": "2.1.0", + "Microsoft.Net.Native.Compiler": "2.2.9-rel-29512-01", + "Microsoft.Net.UWPCoreRuntimeSdk": "2.2.11", + "NETStandard.Library": "2.0.3", + "runtime.win10-x86.Microsoft.NETCore.UniversalWindowsPlatform": "6.2.11" + } + }, "Microsoft.Web.WebView2": { "type": "Transitive", "resolved": "1.0.1264.42", "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" + }, + "runtime.win10-x86.Microsoft.NETCore.UniversalWindowsPlatform": { + "type": "Transitive", + "resolved": "6.2.11", + "contentHash": "Svwt46NcUEBhH+LNdg+9J+phHiWW3mmfuKrKT1RGI9QCownxaFg0kI5NCT0YhoMcndFT6fLsUA5VLswApg3/HA==" } }, "native,Version=v0.0/win10-x86-aot": { + "Microsoft.NETCore.UniversalWindowsPlatform": { + "type": "Transitive", + "resolved": "6.2.11", + "contentHash": "YeOCD+m2tfqkYzQ2hAKZ52cTrHWU0HRS4/2vf3SeZ+KHWq+unmskH+TrRktaIj/pChwPUMwLdCTU5/+4WeQcWQ==", + "dependencies": { + "Microsoft.NETCore.Platforms": "2.1.0", + "Microsoft.Net.Native.Compiler": "2.2.9-rel-29512-01", + "Microsoft.Net.UWPCoreRuntimeSdk": "2.2.11", + "NETStandard.Library": "2.0.3", + "runtime.win10-x86-aot.Microsoft.NETCore.UniversalWindowsPlatform": "6.2.11" + } + }, "Microsoft.Web.WebView2": { "type": "Transitive", "resolved": "1.0.1264.42", "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" + }, + "runtime.win10-x86-aot.Microsoft.NETCore.UniversalWindowsPlatform": { + "type": "Transitive", + "resolved": "6.2.11", + "contentHash": "2Yz+NstJwZlo4+9jfpQ+5fVuowPVIOG/Lp2yABPtfmh4VhbxoKyiAjeRo7bZUMk1RdwZL+LjJ5zg2l2Sh3ZhEA==" } } } diff --git a/apps/paper-windows-example/yarn.lock b/apps/paper-windows-example/yarn.lock index 63d2ee810..403d1fa9d 100644 --- a/apps/paper-windows-example/yarn.lock +++ b/apps/paper-windows-example/yarn.lock @@ -252,7 +252,7 @@ dependencies: "@babel/types" "^7.25.9" -"@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.12.13", "@babel/helper-plugin-utils@^7.14.5", "@babel/helper-plugin-utils@^7.18.6", "@babel/helper-plugin-utils@^7.18.9", "@babel/helper-plugin-utils@^7.20.2", "@babel/helper-plugin-utils@^7.22.5", "@babel/helper-plugin-utils@^7.25.9", "@babel/helper-plugin-utils@^7.8.0", "@babel/helper-plugin-utils@^7.8.3": +"@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.12.13", "@babel/helper-plugin-utils@^7.14.5", "@babel/helper-plugin-utils@^7.18.6", "@babel/helper-plugin-utils@^7.20.2", "@babel/helper-plugin-utils@^7.22.5", "@babel/helper-plugin-utils@^7.25.9", "@babel/helper-plugin-utils@^7.8.0": version "7.25.9" resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.25.9.tgz#9cbdd63a9443a2c92a725cca7ebca12cc8dd9f46" integrity sha512-kSMlyUVdWe25rEsRGviIgOWnoT/nfABVWlqt9N19/dIPWViAOW2s9wznP5tURbs/IDuNk4gPy3YdYRgH3uxhBw== @@ -404,14 +404,6 @@ dependencies: "@babel/helper-plugin-utils" "^7.25.9" -"@babel/plugin-proposal-export-namespace-from@^7.18.9": - version "7.18.9" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-export-namespace-from/-/plugin-proposal-export-namespace-from-7.18.9.tgz#5f7313ab348cdb19d590145f9247540e94761203" - integrity sha512-k1NtHyOMvlDDFeb9G5PhUXuGj8m/wiwojgQVEhJ/fsVsMCpLyOP4h0uGEjYJKrRI+EVPlb5Jk+Gt9P97lOGwtA== - dependencies: - "@babel/helper-plugin-utils" "^7.18.9" - "@babel/plugin-syntax-export-namespace-from" "^7.8.3" - "@babel/plugin-proposal-logical-assignment-operators@^7.18.0": version "7.20.7" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-logical-assignment-operators/-/plugin-proposal-logical-assignment-operators-7.20.7.tgz#dfbcaa8f7b4d37b51e8bfb46d94a5aea2bb89d83" @@ -511,13 +503,6 @@ dependencies: "@babel/helper-plugin-utils" "^7.25.9" -"@babel/plugin-syntax-export-namespace-from@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-export-namespace-from/-/plugin-syntax-export-namespace-from-7.8.3.tgz#028964a9ba80dbc094c915c487ad7c4e7a66465a" - integrity sha512-MXf5laXo6c1IbEbegDmzGPwGNTsHZmEy6QGznu5Sh2UCWvueywb2ee+CCE4zQiZstxU9BMoQO9i6zUFSY0Kj0Q== - dependencies: - "@babel/helper-plugin-utils" "^7.8.3" - "@babel/plugin-syntax-flow@^7.12.1", "@babel/plugin-syntax-flow@^7.18.0", "@babel/plugin-syntax-flow@^7.25.9": version "7.25.9" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.25.9.tgz#30ddd09b4ad822f291efbbeb3bc4c5d3027af61d" @@ -631,7 +616,7 @@ "@babel/helper-create-regexp-features-plugin" "^7.18.6" "@babel/helper-plugin-utils" "^7.18.6" -"@babel/plugin-transform-arrow-functions@^7.0.0", "@babel/plugin-transform-arrow-functions@^7.0.0-0", "@babel/plugin-transform-arrow-functions@^7.25.9": +"@babel/plugin-transform-arrow-functions@^7.0.0", "@babel/plugin-transform-arrow-functions@^7.25.9": version "7.25.9" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.25.9.tgz#7821d4410bee5daaadbb4cdd9a6649704e176845" integrity sha512-6jmooXYIwn9ca5/RylZADJ+EnSxVUS5sjeJ9UPk6RWRzXCmOJCy6dqItPJFpw2cuCangPK4OYr5uhGKcmrm5Qg== @@ -670,7 +655,7 @@ dependencies: "@babel/helper-plugin-utils" "^7.25.9" -"@babel/plugin-transform-class-properties@^7.0.0-0", "@babel/plugin-transform-class-properties@^7.25.9": +"@babel/plugin-transform-class-properties@^7.25.9": version "7.25.9" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-class-properties/-/plugin-transform-class-properties-7.25.9.tgz#a8ce84fedb9ad512549984101fa84080a9f5f51f" integrity sha512-bbMAII8GRSkcd0h0b4X+36GksxuheLFjP65ul9w6C3KgAamI3JqErNgSrosX6ZPj+Mpim5VvEbawXxJCyEUV3Q== @@ -686,7 +671,7 @@ "@babel/helper-create-class-features-plugin" "^7.25.9" "@babel/helper-plugin-utils" "^7.25.9" -"@babel/plugin-transform-classes@^7.0.0", "@babel/plugin-transform-classes@^7.0.0-0", "@babel/plugin-transform-classes@^7.25.9": +"@babel/plugin-transform-classes@^7.0.0", "@babel/plugin-transform-classes@^7.25.9": version "7.25.9" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.25.9.tgz#7152457f7880b593a63ade8a861e6e26a4469f52" integrity sha512-mD8APIXmseE7oZvZgGABDyM34GUmK45Um2TXiBUt7PnuAxrgoSVf123qUzPxEr/+/BHrRn5NMZCdE2m/1F8DGg== @@ -861,7 +846,7 @@ dependencies: "@babel/helper-plugin-utils" "^7.25.9" -"@babel/plugin-transform-nullish-coalescing-operator@^7.0.0-0", "@babel/plugin-transform-nullish-coalescing-operator@^7.25.9": +"@babel/plugin-transform-nullish-coalescing-operator@^7.25.9": version "7.25.9" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-nullish-coalescing-operator/-/plugin-transform-nullish-coalescing-operator-7.25.9.tgz#bcb1b0d9e948168102d5f7104375ca21c3266949" integrity sha512-ENfftpLZw5EItALAD4WsY/KUWvhUlZndm5GC7G3evUsVeSJB6p0pBeLQUnRnBCBx7zV0RKQjR9kCuwrsIrjWog== @@ -899,7 +884,7 @@ dependencies: "@babel/helper-plugin-utils" "^7.25.9" -"@babel/plugin-transform-optional-chaining@^7.0.0-0", "@babel/plugin-transform-optional-chaining@^7.25.9": +"@babel/plugin-transform-optional-chaining@^7.25.9": version "7.25.9" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-optional-chaining/-/plugin-transform-optional-chaining-7.25.9.tgz#e142eb899d26ef715435f201ab6e139541eee7dd" integrity sha512-6AvV0FsLULbpnXeBjrY4dmWF8F7gf8QnvTEoO/wX/5xm/xE1Xo8oPuD3MPS+KS9f9XBEAWN7X1aWr4z9HdOr7A== @@ -997,7 +982,7 @@ babel-plugin-polyfill-regenerator "^0.6.1" semver "^6.3.1" -"@babel/plugin-transform-shorthand-properties@^7.0.0", "@babel/plugin-transform-shorthand-properties@^7.0.0-0", "@babel/plugin-transform-shorthand-properties@^7.25.9": +"@babel/plugin-transform-shorthand-properties@^7.0.0", "@babel/plugin-transform-shorthand-properties@^7.25.9": version "7.25.9" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.25.9.tgz#bb785e6091f99f826a95f9894fc16fde61c163f2" integrity sha512-MUv6t0FhO5qHnS/W8XCbHmiRWOphNufpE1IVxhK5kuN3Td9FT1x4rx4K42s3RYdMXCXpfWkGSbCSd0Z64xA7Ng== @@ -1019,7 +1004,7 @@ dependencies: "@babel/helper-plugin-utils" "^7.25.9" -"@babel/plugin-transform-template-literals@^7.0.0-0", "@babel/plugin-transform-template-literals@^7.25.9": +"@babel/plugin-transform-template-literals@^7.25.9": version "7.25.9" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.25.9.tgz#6dbd4a24e8fad024df76d1fac6a03cf413f60fe1" integrity sha512-o97AE4syN71M/lxrCtQByzphAdlYluKPDBzDVzMmfCobUjjhAryZV0AIpRPrxN0eAkxXO6ZLEScmt+PNhj2OTw== @@ -1059,7 +1044,7 @@ "@babel/helper-create-regexp-features-plugin" "^7.25.9" "@babel/helper-plugin-utils" "^7.25.9" -"@babel/plugin-transform-unicode-regex@^7.0.0", "@babel/plugin-transform-unicode-regex@^7.0.0-0", "@babel/plugin-transform-unicode-regex@^7.25.9": +"@babel/plugin-transform-unicode-regex@^7.0.0", "@babel/plugin-transform-unicode-regex@^7.25.9": version "7.25.9" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.25.9.tgz#5eae747fe39eacf13a8bd006a4fb0b5d1fa5e9b1" integrity sha512-yoxstj7Rg9dlNn9UQxzk4fcNivwv4nUYz7fYXBaKxvw/lnmPuOm/ikoELygbYq68Bls3D/D+NBPHiLwZdZZ4HA== @@ -1167,7 +1152,7 @@ "@babel/types" "^7.4.4" esutils "^2.0.2" -"@babel/preset-typescript@^7.13.0", "@babel/preset-typescript@^7.16.7": +"@babel/preset-typescript@^7.13.0": version "7.25.9" resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.25.9.tgz#bb82f26cda46dc2eb1ee10bf72fa994e759a08ba" integrity sha512-XWxw1AcKk36kgxf4C//fl0ikjLeqGUWn062/Fd8GtpTfDJOX6Ud95FK+4JlDA36BX4bNGndXi3a6Vr4Jo5/61A== @@ -1651,16 +1636,6 @@ resolved "https://registry.yarnpkg.com/@opentelemetry/semantic-conventions/-/semantic-conventions-1.27.0.tgz#1a857dcc95a5ab30122e04417148211e6f945e6c" integrity sha512-sAay1RrB+ONOem0OZanAR1ZI/k7yDpnOQSQmTMuGImUQb2y8EbSaCJ94FQluM74xoU03vlb2d2U90hZluL6nQg== -"@react-native-community/cli-clean@13.6.6": - version "13.6.6" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-13.6.6.tgz#87c7ad8746c38dab0fe7b3c6ff89d44351d5d943" - integrity sha512-cBwJTwl0NyeA4nyMxbhkWZhxtILYkbU3TW3k8AXLg+iGphe0zikYMGB3T+haTvTc6alTyEFwPbimk9bGIqkjAQ== - dependencies: - "@react-native-community/cli-tools" "13.6.6" - chalk "^4.1.2" - execa "^5.0.0" - fast-glob "^3.3.2" - "@react-native-community/cli-clean@13.6.8": version "13.6.8" resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-13.6.8.tgz#95ce964047f005152ac100394b6dcd5d2cc2a474" @@ -1671,17 +1646,15 @@ execa "^5.0.0" fast-glob "^3.3.2" -"@react-native-community/cli-config@13.6.6": - version "13.6.6" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-13.6.6.tgz#69f590694b3a079c74f781baab3b762db74f5dbd" - integrity sha512-mbG425zCKr8JZhv/j11382arezwS/70juWMsn8j2lmrGTrP1cUdW0MF15CCIFtJsqyK3Qs+FTmqttRpq81QfSg== +"@react-native-community/cli-clean@13.6.9": + version "13.6.9" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-13.6.9.tgz#b6754f39c2b877c9d730feb848945150e1d52209" + integrity sha512-7Dj5+4p9JggxuVNOjPbduZBAP1SUgNhLKVw5noBUzT/3ZpUZkDM+RCSwyoyg8xKWoE4OrdUAXwAFlMcFDPKykA== dependencies: - "@react-native-community/cli-tools" "13.6.6" + "@react-native-community/cli-tools" "13.6.9" chalk "^4.1.2" - cosmiconfig "^5.1.0" - deepmerge "^4.3.0" + execa "^5.0.0" fast-glob "^3.3.2" - joi "^17.2.1" "@react-native-community/cli-config@13.6.8": version "13.6.8" @@ -1695,12 +1668,17 @@ fast-glob "^3.3.2" joi "^17.2.1" -"@react-native-community/cli-debugger-ui@13.6.6": - version "13.6.6" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-13.6.6.tgz#ac021ebd795b0fd66fb52a8987d1d41c5a4b8cb3" - integrity sha512-Vv9u6eS4vKSDAvdhA0OiQHoA7y39fiPIgJ6biT32tN4avHDtxlc6TWZGiqv7g98SBvDWvoVAmdPLcRf3kU+c8g== +"@react-native-community/cli-config@13.6.9": + version "13.6.9" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-13.6.9.tgz#d609a64d40a173c89bd7d24e31807bb7dcba69f9" + integrity sha512-rFfVBcNojcMm+KKHE/xqpqXg8HoKl4EC7bFHUrahMJ+y/tZll55+oX/PGG37rzB8QzP2UbMQ19DYQKC1G7kXeg== dependencies: - serve-static "^1.13.1" + "@react-native-community/cli-tools" "13.6.9" + chalk "^4.1.2" + cosmiconfig "^5.1.0" + deepmerge "^4.3.0" + fast-glob "^3.3.2" + joi "^17.2.1" "@react-native-community/cli-debugger-ui@13.6.8": version "13.6.8" @@ -1709,28 +1687,12 @@ dependencies: serve-static "^1.13.1" -"@react-native-community/cli-doctor@13.6.6": - version "13.6.6" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-13.6.6.tgz#ac0febff05601d9b86af3e03460e1a6b0a1d33a5" - integrity sha512-TWZb5g6EmQe2Ua2TEWNmyaEayvlWH4GmdD9ZC+p8EpKFpB1NpDGMK6sXbpb42TDvwZg5s4TDRplK0PBEA/SVDg== +"@react-native-community/cli-debugger-ui@13.6.9": + version "13.6.9" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-13.6.9.tgz#bc5727c51964206a00d417e5148b46331a81d5a5" + integrity sha512-TkN7IdFmGPPvTpAo3nCAH9uwGCPxWBEAwpqEZDrq0NWllI7Tdie8vDpGdrcuCcKalmhq6OYnkXzeBah7O1Ztpw== dependencies: - "@react-native-community/cli-config" "13.6.6" - "@react-native-community/cli-platform-android" "13.6.6" - "@react-native-community/cli-platform-apple" "13.6.6" - "@react-native-community/cli-platform-ios" "13.6.6" - "@react-native-community/cli-tools" "13.6.6" - chalk "^4.1.2" - command-exists "^1.2.8" - deepmerge "^4.3.0" - envinfo "^7.10.0" - execa "^5.0.0" - hermes-profile-transformer "^0.0.6" - node-stream-zip "^1.9.1" - ora "^5.4.1" - semver "^7.5.2" - strip-ansi "^5.2.0" - wcwidth "^1.0.1" - yaml "^2.2.1" + serve-static "^1.13.1" "@react-native-community/cli-doctor@13.6.8": version "13.6.8" @@ -1755,15 +1717,28 @@ wcwidth "^1.0.1" yaml "^2.2.1" -"@react-native-community/cli-hermes@13.6.6": - version "13.6.6" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-hermes/-/cli-hermes-13.6.6.tgz#590f55f151fec23b55498228f92d100a0e71d474" - integrity sha512-La5Ie+NGaRl3klei6WxKoOxmCUSGGxpOk6vU5pEGf0/O7ky+Ay0io+zXYUZqlNMi/cGpO7ZUijakBYOB/uyuFg== +"@react-native-community/cli-doctor@13.6.9": + version "13.6.9" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-13.6.9.tgz#f1d4eeff427ddc8a9d19851042621c10939c35cb" + integrity sha512-5quFaLdWFQB+677GXh5dGU9I5eg2z6Vg4jOX9vKnc9IffwyIFAyJfCZHrxLSRPDGNXD7biDQUdoezXYGwb6P/A== dependencies: - "@react-native-community/cli-platform-android" "13.6.6" - "@react-native-community/cli-tools" "13.6.6" + "@react-native-community/cli-config" "13.6.9" + "@react-native-community/cli-platform-android" "13.6.9" + "@react-native-community/cli-platform-apple" "13.6.9" + "@react-native-community/cli-platform-ios" "13.6.9" + "@react-native-community/cli-tools" "13.6.9" chalk "^4.1.2" + command-exists "^1.2.8" + deepmerge "^4.3.0" + envinfo "^7.10.0" + execa "^5.0.0" hermes-profile-transformer "^0.0.6" + node-stream-zip "^1.9.1" + ora "^5.4.1" + semver "^7.5.2" + strip-ansi "^5.2.0" + wcwidth "^1.0.1" + yaml "^2.2.1" "@react-native-community/cli-hermes@13.6.8": version "13.6.8" @@ -1775,17 +1750,15 @@ chalk "^4.1.2" hermes-profile-transformer "^0.0.6" -"@react-native-community/cli-platform-android@13.6.6": - version "13.6.6" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-13.6.6.tgz#9e3863cb092709021f11848890bff0fc16fc1609" - integrity sha512-/tMwkBeNxh84syiSwNlYtmUz/Ppc+HfKtdopL/5RB+fd3SV1/5/NPNjMlyLNgFKnpxvKCInQ7dnl6jGHJjeHjg== +"@react-native-community/cli-hermes@13.6.9": + version "13.6.9" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-hermes/-/cli-hermes-13.6.9.tgz#88c8dfe936a0d4272efc54429eda9ccc3fca3ad8" + integrity sha512-GvwiwgvFw4Ws+krg2+gYj8sR3g05evmNjAHkKIKMkDTJjZ8EdyxbkifRUs1ZCq3TMZy2oeblZBXCJVOH4W7ZbA== dependencies: - "@react-native-community/cli-tools" "13.6.6" + "@react-native-community/cli-platform-android" "13.6.9" + "@react-native-community/cli-tools" "13.6.9" chalk "^4.1.2" - execa "^5.0.0" - fast-glob "^3.3.2" - fast-xml-parser "^4.2.4" - logkitty "^0.7.1" + hermes-profile-transformer "^0.0.6" "@react-native-community/cli-platform-android@13.6.8": version "13.6.8" @@ -1799,17 +1772,17 @@ fast-xml-parser "^4.2.4" logkitty "^0.7.1" -"@react-native-community/cli-platform-apple@13.6.6": - version "13.6.6" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-apple/-/cli-platform-apple-13.6.6.tgz#d445fd6ed02c5ae2f43f9c45501e04fee53a2790" - integrity sha512-bOmSSwoqNNT3AmCRZXEMYKz1Jf1l2F86Nhs7qBcXdY/sGiJ+Flng564LOqvdAlVLTbkgz47KjNKCS2pP4Jg0Mg== +"@react-native-community/cli-platform-android@13.6.9": + version "13.6.9" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-13.6.9.tgz#b175b9b11334fc90da3f395432678bd53c30fae4" + integrity sha512-9KsYGdr08QhdvT3Ht7e8phQB3gDX9Fs427NJe0xnoBh+PDPTI2BD5ks5ttsH8CzEw8/P6H8tJCHq6hf2nxd9cw== dependencies: - "@react-native-community/cli-tools" "13.6.6" + "@react-native-community/cli-tools" "13.6.9" chalk "^4.1.2" execa "^5.0.0" fast-glob "^3.3.2" - fast-xml-parser "^4.0.12" - ora "^5.4.1" + fast-xml-parser "^4.2.4" + logkitty "^0.7.1" "@react-native-community/cli-platform-apple@13.6.8": version "13.6.8" @@ -1823,12 +1796,17 @@ fast-xml-parser "^4.0.12" ora "^5.4.1" -"@react-native-community/cli-platform-ios@13.6.6": - version "13.6.6" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-13.6.6.tgz#0cd700f36483ca37dda7ec044377f8a926b1df1f" - integrity sha512-vjDnRwhlSN5ryqKTas6/DPkxuouuyFBAqAROH4FR1cspTbn6v78JTZKDmtQy9JMMo7N5vZj1kASU5vbFep9IOQ== +"@react-native-community/cli-platform-apple@13.6.9": + version "13.6.9" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-apple/-/cli-platform-apple-13.6.9.tgz#02fb5dc47d62acd85f4d7a852e93216927a772fa" + integrity sha512-KoeIHfhxMhKXZPXmhQdl6EE+jGKWwoO9jUVWgBvibpVmsNjo7woaG/tfJMEWfWF3najX1EkQAoJWpCDBMYWtlA== dependencies: - "@react-native-community/cli-platform-apple" "13.6.6" + "@react-native-community/cli-tools" "13.6.9" + chalk "^4.1.2" + execa "^5.0.0" + fast-glob "^3.3.2" + fast-xml-parser "^4.0.12" + ora "^5.4.1" "@react-native-community/cli-platform-ios@13.6.8": version "13.6.8" @@ -1837,13 +1815,20 @@ dependencies: "@react-native-community/cli-platform-apple" "13.6.8" -"@react-native-community/cli-server-api@13.6.6": - version "13.6.6" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-13.6.6.tgz#467993006ef82361cdf7a9817999d5a09e85ca6a" - integrity sha512-ZtCXxoFlM7oDv3iZ3wsrT3SamhtUJuIkX2WePLPlN5bcbq7zimbPm2lHyicNJtpcGQ5ymsgpUWPCNZsWQhXBqQ== +"@react-native-community/cli-platform-ios@13.6.9": + version "13.6.9" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-13.6.9.tgz#f37ceab41c2302e8f0d4bcbd3bf58b3353db4306" + integrity sha512-CiUcHlGs8vE0CAB4oi1f+dzniqfGuhWPNrDvae2nm8dewlahTBwIcK5CawyGezjcJoeQhjBflh9vloska+nlnw== + dependencies: + "@react-native-community/cli-platform-apple" "13.6.9" + +"@react-native-community/cli-server-api@13.6.8": + version "13.6.8" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-13.6.8.tgz#fc654a2990a5f0b6f0b67ef04b25f699bee63f63" + integrity sha512-Lx664oWTzpVfbKUTy+3GIX7e+Mt5Zn+zdkM4ehllNdik/lbB3tM9Nrg8PSvOfI+tTXs2w55+nIydLfH+0FqJVg== dependencies: - "@react-native-community/cli-debugger-ui" "13.6.6" - "@react-native-community/cli-tools" "13.6.6" + "@react-native-community/cli-debugger-ui" "13.6.8" + "@react-native-community/cli-tools" "13.6.8" compression "^1.7.1" connect "^3.6.5" errorhandler "^1.5.1" @@ -1852,13 +1837,13 @@ serve-static "^1.13.1" ws "^6.2.2" -"@react-native-community/cli-server-api@13.6.8": - version "13.6.8" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-13.6.8.tgz#fc654a2990a5f0b6f0b67ef04b25f699bee63f63" - integrity sha512-Lx664oWTzpVfbKUTy+3GIX7e+Mt5Zn+zdkM4ehllNdik/lbB3tM9Nrg8PSvOfI+tTXs2w55+nIydLfH+0FqJVg== +"@react-native-community/cli-server-api@13.6.9": + version "13.6.9" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-13.6.9.tgz#269e666bc26e9d0b2f42c7f6099559b5f9259e9d" + integrity sha512-W8FSlCPWymO+tlQfM3E0JmM8Oei5HZsIk5S0COOl0MRi8h0NmHI4WSTF2GCfbFZkcr2VI/fRsocoN8Au4EZAug== dependencies: - "@react-native-community/cli-debugger-ui" "13.6.8" - "@react-native-community/cli-tools" "13.6.8" + "@react-native-community/cli-debugger-ui" "13.6.9" + "@react-native-community/cli-tools" "13.6.9" compression "^1.7.1" connect "^3.6.5" errorhandler "^1.5.1" @@ -1867,10 +1852,10 @@ serve-static "^1.13.1" ws "^6.2.2" -"@react-native-community/cli-tools@13.6.6": - version "13.6.6" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-13.6.6.tgz#55c40cbabafbfc56cfb95a4d5fbf73ef60ec3cbc" - integrity sha512-ptOnn4AJczY5njvbdK91k4hcYazDnGtEPrqIwEI+k/CTBHNdb27Rsm2OZ7ye6f7otLBqF8gj/hK6QzJs8CEMgw== +"@react-native-community/cli-tools@13.6.8": + version "13.6.8" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-13.6.8.tgz#65a9f49ce66f0e639d855e745c8dfa7ae7b6c142" + integrity sha512-1MYlae9EkbjC7DBYOGMH5xF9yDoeNYUKgEdDjL6WAUBoF2gtwiZPM6igLKi/+dhb5sCtC7fiLrLi0Oevdf+RmQ== dependencies: appdirsjs "^1.2.4" chalk "^4.1.2" @@ -1884,10 +1869,10 @@ shell-quote "^1.7.3" sudo-prompt "^9.0.0" -"@react-native-community/cli-tools@13.6.8": - version "13.6.8" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-13.6.8.tgz#65a9f49ce66f0e639d855e745c8dfa7ae7b6c142" - integrity sha512-1MYlae9EkbjC7DBYOGMH5xF9yDoeNYUKgEdDjL6WAUBoF2gtwiZPM6igLKi/+dhb5sCtC7fiLrLi0Oevdf+RmQ== +"@react-native-community/cli-tools@13.6.9": + version "13.6.9" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-13.6.9.tgz#2baee279358ba1a863e737b2fa9f45659ad91929" + integrity sha512-OXaSjoN0mZVw3nrAwcY1PC0uMfyTd9fz7Cy06dh+EJc+h0wikABsVRzV8cIOPrVV+PPEEXE0DBrH20T2puZzgQ== dependencies: appdirsjs "^1.2.4" chalk "^4.1.2" @@ -1901,13 +1886,6 @@ shell-quote "^1.7.3" sudo-prompt "^9.0.0" -"@react-native-community/cli-types@13.6.6": - version "13.6.6" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-13.6.6.tgz#b45af119d61888fea1074a7c32ddb093e3f119a9" - integrity sha512-733iaYzlmvNK7XYbnWlMjdE+2k0hlTBJW071af/xb6Bs+hbJqBP9c03FZuYH2hFFwDDntwj05bkri/P7VgSxug== - dependencies: - joi "^17.2.1" - "@react-native-community/cli-types@13.6.8": version "13.6.8" resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-13.6.8.tgz#1c357d3290a48232e3e639d48e43e31e422ce436" @@ -1915,28 +1893,12 @@ dependencies: joi "^17.2.1" -"@react-native-community/cli@13.6.6": - version "13.6.6" - resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-13.6.6.tgz#b929c8668e88344c03a46a3e635cb382dba16773" - integrity sha512-IqclB7VQ84ye8Fcs89HOpOscY4284VZg2pojHNl8H0Lzd4DadXJWQoxC7zWm8v2f8eyeX2kdhxp2ETD5tceIgA== - dependencies: - "@react-native-community/cli-clean" "13.6.6" - "@react-native-community/cli-config" "13.6.6" - "@react-native-community/cli-debugger-ui" "13.6.6" - "@react-native-community/cli-doctor" "13.6.6" - "@react-native-community/cli-hermes" "13.6.6" - "@react-native-community/cli-server-api" "13.6.6" - "@react-native-community/cli-tools" "13.6.6" - "@react-native-community/cli-types" "13.6.6" - chalk "^4.1.2" - commander "^9.4.1" - deepmerge "^4.3.0" - execa "^5.0.0" - find-up "^4.1.0" - fs-extra "^8.1.0" - graceful-fs "^4.1.3" - prompts "^2.4.2" - semver "^7.5.2" +"@react-native-community/cli-types@13.6.9": + version "13.6.9" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-13.6.9.tgz#08bfb796eacf0daeb31e2de516e81e78a36a1a55" + integrity sha512-RLxDppvRxXfs3hxceW/mShi+6o5yS+kFPnPqZTaMKKR5aSg7LwDpLQW4K2D22irEG8e6RKDkZUeH9aL3vO2O0w== + dependencies: + joi "^17.2.1" "@react-native-community/cli@13.6.8": version "13.6.8" @@ -1961,15 +1923,38 @@ prompts "^2.4.2" semver "^7.5.2" -"@react-native-windows/cli@0.74.0": - version "0.74.0" - resolved "https://registry.yarnpkg.com/@react-native-windows/cli/-/cli-0.74.0.tgz#da85c0f8d7f96a761080fae27323fe257560e22d" - integrity sha512-grOp6b/Pfa4T+n+oWmoo18BXI97CKZPbRKTlCg2Ne5Hsq2rj4Ewg8tnRFKFOMthy5dZcPWLqsphkT0J/sQBHXw== +"@react-native-community/cli@13.6.9": + version "13.6.9" + resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-13.6.9.tgz#ba6360b94e0aba9c4001bda256cf7e57e2ecb02c" + integrity sha512-hFJL4cgLPxncJJd/epQ4dHnMg5Jy/7Q56jFvA3MHViuKpzzfTCJCB+pGY54maZbtym53UJON9WTGpM3S81UfjQ== + dependencies: + "@react-native-community/cli-clean" "13.6.9" + "@react-native-community/cli-config" "13.6.9" + "@react-native-community/cli-debugger-ui" "13.6.9" + "@react-native-community/cli-doctor" "13.6.9" + "@react-native-community/cli-hermes" "13.6.9" + "@react-native-community/cli-server-api" "13.6.9" + "@react-native-community/cli-tools" "13.6.9" + "@react-native-community/cli-types" "13.6.9" + chalk "^4.1.2" + commander "^9.4.1" + deepmerge "^4.3.0" + execa "^5.0.0" + find-up "^4.1.0" + fs-extra "^8.1.0" + graceful-fs "^4.1.3" + prompts "^2.4.2" + semver "^7.5.2" + +"@react-native-windows/cli@0.74.7": + version "0.74.7" + resolved "https://registry.yarnpkg.com/@react-native-windows/cli/-/cli-0.74.7.tgz#a9d9e75af3aca9a30a5092a2059c097a813b51c1" + integrity sha512-QcMBxMRH9rutS24PvxMuWNB0V5sULNBMFXo62jYnLtU7mHcEW8lB5CsPrVc1JK5kb7pNFlKs9uHrkPMDn52c+g== dependencies: - "@react-native-windows/codegen" "0.74.0" - "@react-native-windows/fs" "0.74.0" - "@react-native-windows/package-utils" "0.74.0" - "@react-native-windows/telemetry" "0.74.0" + "@react-native-windows/codegen" "0.74.4" + "@react-native-windows/fs" "0.74.1" + "@react-native-windows/package-utils" "0.74.1" + "@react-native-windows/telemetry" "0.74.2" "@xmldom/xmldom" "^0.7.7" chalk "^4.1.0" cli-spinners "^2.2.0" @@ -1988,50 +1973,50 @@ xml-parser "^1.2.1" xpath "^0.0.27" -"@react-native-windows/codegen@0.74.0": - version "0.74.0" - resolved "https://registry.yarnpkg.com/@react-native-windows/codegen/-/codegen-0.74.0.tgz#9024ba6e871088e42356f94eb126697e6268487b" - integrity sha512-jSN5PZQKZIuaukoUJU9LOyHs2Y/KmG5xsLtSGRUcjG8wTrzP+xXxj3115hHdk9vreL80o+pup5o1UNfyLfvGIA== +"@react-native-windows/codegen@0.74.4": + version "0.74.4" + resolved "https://registry.yarnpkg.com/@react-native-windows/codegen/-/codegen-0.74.4.tgz#b191985af9784e4041d76762fe3188f50b1413c7" + integrity sha512-yiUHJweF1VY87x4MrdYfy/sFJpjcog1V5ZsCGqPYBtp7L1F2/aLvqTDoth8c5VK+5JB1lkRF4aJNAmRPQ9xnDg== dependencies: - "@react-native-windows/fs" "0.74.0" + "@react-native-windows/fs" "0.74.1" chalk "^4.1.0" - globby "^11.0.4" + globby "^11.1.0" mustache "^4.0.1" source-map-support "^0.5.19" yargs "^16.2.0" -"@react-native-windows/find-repo-root@0.74.0": - version "0.74.0" - resolved "https://registry.yarnpkg.com/@react-native-windows/find-repo-root/-/find-repo-root-0.74.0.tgz#687819c76825d3f7c58401a9d96c2c748774506f" - integrity sha512-6dxkKX+mtT+yXuTDUf7A+ZQnyX57WlYk3fDNeNTpI66xBR4QuRwPdzTNamZxvX6JEMSe4lm4PqXWlfAKYzPENw== +"@react-native-windows/find-repo-root@0.74.1": + version "0.74.1" + resolved "https://registry.yarnpkg.com/@react-native-windows/find-repo-root/-/find-repo-root-0.74.1.tgz#bf2f10545c29ffcdb76b9179fce346f84e15c5ab" + integrity sha512-k+Hk16/NmPhxsQYGCRtAfcQqCDCJvAxC74FLzFOO6+c/VDM0U05kEcJsJzI1dh/0kZh+YSZQo3w1RrA1z1S2gw== dependencies: - "@react-native-windows/fs" "0.74.0" + "@react-native-windows/fs" "0.74.1" find-up "^4.1.0" -"@react-native-windows/fs@0.74.0": - version "0.74.0" - resolved "https://registry.yarnpkg.com/@react-native-windows/fs/-/fs-0.74.0.tgz#bbef312e6c9541292a69e607c1e5fbc47e2a665c" - integrity sha512-YK8CkNHSwskU3PPCPTw1DPen3/QXS7qP7rAp+FNK4LfyOgiO1V9TiIyz3DcvqOsD+iwriXoEl/3Bvo/8HmlTbQ== +"@react-native-windows/fs@0.74.1": + version "0.74.1" + resolved "https://registry.yarnpkg.com/@react-native-windows/fs/-/fs-0.74.1.tgz#2c6ade1f937adc6056b1a6b052b7b85acb725a14" + integrity sha512-Qepr2KyMvCKugOwIXKXtgMqww5P3yI5HTtxIUWytBCoIPEk1lJdpx/sFjTGmir0QXaLlZxXbdrxpLLnN7eq3Tg== dependencies: graceful-fs "^4.2.8" -"@react-native-windows/package-utils@0.74.0": - version "0.74.0" - resolved "https://registry.yarnpkg.com/@react-native-windows/package-utils/-/package-utils-0.74.0.tgz#bdcd18f993d899a6f9914365863bde7ee4eee509" - integrity sha512-b7c2/DycLM3MK7K6Y4XVuKFBTLvyg0DSP7++f/yZsBWyCysFycAS5gCrlVbXk6Kez3CIEspSS7op+GJMduMp8g== +"@react-native-windows/package-utils@0.74.1": + version "0.74.1" + resolved "https://registry.yarnpkg.com/@react-native-windows/package-utils/-/package-utils-0.74.1.tgz#18e49bb5b2ed967f279605223eae65a3ea55112f" + integrity sha512-nzKo1H991npbRx2EJT0wkniGkngEw7ND5+oz6jhbNFQ3UCKIUBCLc2bPBBX1Z5jp40R+qoVbgnQP2fuAN5y9tA== dependencies: - "@react-native-windows/find-repo-root" "0.74.0" - "@react-native-windows/fs" "0.74.0" + "@react-native-windows/find-repo-root" "0.74.1" + "@react-native-windows/fs" "0.74.1" get-monorepo-packages "^1.2.0" lodash "^4.17.15" -"@react-native-windows/telemetry@0.74.0": - version "0.74.0" - resolved "https://registry.yarnpkg.com/@react-native-windows/telemetry/-/telemetry-0.74.0.tgz#e050312998d6c64f50f368bcb3299e9e3138fd10" - integrity sha512-80vMPWXLJpa3v+vAafXjCQM0GFE3Iq8breRkrwzmbANAfCEXoJdOI0Aju0sOqDyiE68OUekjU9lwWbIyFEQGJQ== +"@react-native-windows/telemetry@0.74.2": + version "0.74.2" + resolved "https://registry.yarnpkg.com/@react-native-windows/telemetry/-/telemetry-0.74.2.tgz#3ad1bdc2be0f43f2009f13368d5c6659064ec3db" + integrity sha512-fTqPYaYB7MtPHTr1ytarFsoPHLHch8EAegblTDTo1ha3a1neGOMTGoxZF2a8/l0y8HSDdsfyTfv8JjCO3w5oow== dependencies: "@azure/core-auth" "1.5.0" - "@react-native-windows/fs" "0.74.0" + "@react-native-windows/fs" "0.74.1" "@xmldom/xmldom" "^0.7.7" applicationinsights "2.9.1" ci-info "^3.2.0" @@ -2040,28 +2025,21 @@ os-locale "^5.0.0" xpath "^0.0.27" -"@react-native/assets-registry@0.74.83": - version "0.74.83" - resolved "https://registry.yarnpkg.com/@react-native/assets-registry/-/assets-registry-0.74.83.tgz#c1815dc10f9e1075e0d03b4c8a9619145969522e" - integrity sha512-2vkLMVnp+YTZYTNSDIBZojSsjz8sl5PscP3j4GcV6idD8V978SZfwFlk8K0ti0BzRs11mzL0Pj17km597S/eTQ== - "@react-native/assets-registry@0.74.84": version "0.74.84" resolved "https://registry.yarnpkg.com/@react-native/assets-registry/-/assets-registry-0.74.84.tgz#aa472f82c1b7d8a30098c8ba22fad7b3dbb5be5f" integrity sha512-dzUhwyaX04QosWZ8zyaaNB/WYZIdeDN1lcpfQbqiOhZJShRH+FLTDVONE/dqlMQrP+EO7lDqF0RrlIt9lnOCQQ== +"@react-native/assets-registry@0.74.87": + version "0.74.87" + resolved "https://registry.yarnpkg.com/@react-native/assets-registry/-/assets-registry-0.74.87.tgz#7dda64e48db14597e19e15f679e31abbb1c1fb4d" + integrity sha512-1XmRhqQchN+pXPKEKYdpJlwESxVomJOxtEnIkbo7GAlaN2sym84fHEGDXAjLilih5GVPpcpSmFzTy8jx3LtaFg== + "@react-native/assets@1.0.0": version "1.0.0" resolved "https://registry.yarnpkg.com/@react-native/assets/-/assets-1.0.0.tgz#c6f9bf63d274bafc8e970628de24986b30a55c8e" integrity sha512-KrwSpS1tKI70wuKl68DwJZYEvXktDHdZMG0k2AXD/rJVSlB23/X2CB2cutVR0HwNMJIal9HOUOBB2rVfa6UGtQ== -"@react-native/babel-plugin-codegen@0.74.83": - version "0.74.83" - resolved "https://registry.yarnpkg.com/@react-native/babel-plugin-codegen/-/babel-plugin-codegen-0.74.83.tgz#971f9cfec980dd05598d81964c05a26c6166f9fb" - integrity sha512-+S0st3t4Ro00bi9gjT1jnK8qTFOU+CwmziA7U9odKyWrCoRJrgmrvogq/Dr1YXlpFxexiGIupGut1VHxr+fxJA== - dependencies: - "@react-native/codegen" "0.74.83" - "@react-native/babel-plugin-codegen@0.74.84": version "0.74.84" resolved "https://registry.yarnpkg.com/@react-native/babel-plugin-codegen/-/babel-plugin-codegen-0.74.84.tgz#a3a72c188d875601704a421e395f6909fdec40f3" @@ -2069,10 +2047,17 @@ dependencies: "@react-native/codegen" "0.74.84" -"@react-native/babel-preset@0.74.83": - version "0.74.83" - resolved "https://registry.yarnpkg.com/@react-native/babel-preset/-/babel-preset-0.74.83.tgz#9828457779b4ce0219078652327ce3203115cdf9" - integrity sha512-KJuu3XyVh3qgyUer+rEqh9a/JoUxsDOzkJNfRpDyXiAyjDRoVch60X/Xa/NcEQ93iCVHAWs0yQ+XGNGIBCYE6g== +"@react-native/babel-plugin-codegen@0.74.87": + version "0.74.87" + resolved "https://registry.yarnpkg.com/@react-native/babel-plugin-codegen/-/babel-plugin-codegen-0.74.87.tgz#44457f4de69911f37a6ac308a7783203a757574a" + integrity sha512-+vJYpMnENFrwtgvDfUj+CtVJRJuUnzAUYT0/Pb68Sq9RfcZ5xdcCuUgyf7JO+akW2VTBoJY427wkcxU30qrWWw== + dependencies: + "@react-native/codegen" "0.74.87" + +"@react-native/babel-preset@0.74.84": + version "0.74.84" + resolved "https://registry.yarnpkg.com/@react-native/babel-preset/-/babel-preset-0.74.84.tgz#703ebfc810d82c9f51f033352abd5f9fa70d492b" + integrity sha512-WUfu6Y4aGuVdocQZvx33BJiQWFH6kRCHYbZfBn2psgFrSRLgQWEQrDCxqPFObNAVSayM0rNhp2FvI5K/Eyeqlg== dependencies: "@babel/core" "^7.20.0" "@babel/plugin-proposal-async-generator-functions" "^7.0.0" @@ -2114,14 +2099,14 @@ "@babel/plugin-transform-typescript" "^7.5.0" "@babel/plugin-transform-unicode-regex" "^7.0.0" "@babel/template" "^7.0.0" - "@react-native/babel-plugin-codegen" "0.74.83" + "@react-native/babel-plugin-codegen" "0.74.84" babel-plugin-transform-flow-enums "^0.0.2" react-refresh "^0.14.0" -"@react-native/babel-preset@0.74.84": - version "0.74.84" - resolved "https://registry.yarnpkg.com/@react-native/babel-preset/-/babel-preset-0.74.84.tgz#703ebfc810d82c9f51f033352abd5f9fa70d492b" - integrity sha512-WUfu6Y4aGuVdocQZvx33BJiQWFH6kRCHYbZfBn2psgFrSRLgQWEQrDCxqPFObNAVSayM0rNhp2FvI5K/Eyeqlg== +"@react-native/babel-preset@0.74.87": + version "0.74.87" + resolved "https://registry.yarnpkg.com/@react-native/babel-preset/-/babel-preset-0.74.87.tgz#3d74517d2ea8898f83b5106027033607d5bda50d" + integrity sha512-hyKpfqzN2nxZmYYJ0tQIHG99FQO0OWXp/gVggAfEUgiT+yNKas1C60LuofUsK7cd+2o9jrpqgqW4WzEDZoBlTg== dependencies: "@babel/core" "^7.20.0" "@babel/plugin-proposal-async-generator-functions" "^7.0.0" @@ -2163,14 +2148,14 @@ "@babel/plugin-transform-typescript" "^7.5.0" "@babel/plugin-transform-unicode-regex" "^7.0.0" "@babel/template" "^7.0.0" - "@react-native/babel-plugin-codegen" "0.74.84" + "@react-native/babel-plugin-codegen" "0.74.87" babel-plugin-transform-flow-enums "^0.0.2" react-refresh "^0.14.0" -"@react-native/codegen@0.74.83": - version "0.74.83" - resolved "https://registry.yarnpkg.com/@react-native/codegen/-/codegen-0.74.83.tgz#7c56a82fe7603f0867f0d80ff29db3757b71be55" - integrity sha512-GgvgHS3Aa2J8/mp1uC/zU8HuTh8ZT5jz7a4mVMWPw7+rGyv70Ba8uOVBq6UH2Q08o617IATYc+0HfyzAfm4n0w== +"@react-native/codegen@0.74.84": + version "0.74.84" + resolved "https://registry.yarnpkg.com/@react-native/codegen/-/codegen-0.74.84.tgz#d3425a510b7da558ef5088d9b0aa5e0b1c05c783" + integrity sha512-0hXlnu9i0o8v+gXKQi+x6T471L85kCDwW4WrJiYAeOheWrQdNNW6rC3g8+LL7HXAf7QcHGU/8/d57iYfdVK2BQ== dependencies: "@babel/parser" "^7.20.0" glob "^7.1.1" @@ -2180,10 +2165,10 @@ mkdirp "^0.5.1" nullthrows "^1.1.1" -"@react-native/codegen@0.74.84": - version "0.74.84" - resolved "https://registry.yarnpkg.com/@react-native/codegen/-/codegen-0.74.84.tgz#d3425a510b7da558ef5088d9b0aa5e0b1c05c783" - integrity sha512-0hXlnu9i0o8v+gXKQi+x6T471L85kCDwW4WrJiYAeOheWrQdNNW6rC3g8+LL7HXAf7QcHGU/8/d57iYfdVK2BQ== +"@react-native/codegen@0.74.87": + version "0.74.87" + resolved "https://registry.yarnpkg.com/@react-native/codegen/-/codegen-0.74.87.tgz#47f07a627d0294c8270a03aee098991ed91f8ae9" + integrity sha512-GMSYDiD+86zLKgMMgz9z0k6FxmRn+z6cimYZKkucW4soGbxWsbjUAZoZ56sJwt2FJ3XVRgXCrnOCgXoH/Bkhcg== dependencies: "@babel/parser" "^7.20.0" glob "^7.1.1" @@ -2193,15 +2178,15 @@ mkdirp "^0.5.1" nullthrows "^1.1.1" -"@react-native/community-cli-plugin@0.74.83": - version "0.74.83" - resolved "https://registry.yarnpkg.com/@react-native/community-cli-plugin/-/community-cli-plugin-0.74.83.tgz#58808a58a5288895627548338731e72ebb5b507c" - integrity sha512-7GAFjFOg1mFSj8bnFNQS4u8u7+QtrEeflUIDVZGEfBZQ3wMNI5ycBzbBGycsZYiq00Xvoc6eKFC7kvIaqeJpUQ== +"@react-native/community-cli-plugin@0.74.84": + version "0.74.84" + resolved "https://registry.yarnpkg.com/@react-native/community-cli-plugin/-/community-cli-plugin-0.74.84.tgz#223a0defe8118dc57c8ac852ddd13517ea10c4e2" + integrity sha512-GBKE+1sUh86fS2XXV46gMCNHMc1KetshMbYJ0AhDhldpaILZHqRBX50mdVsiYVvkzp4QjM0nmYqefuJ9NVwicQ== dependencies: - "@react-native-community/cli-server-api" "13.6.6" - "@react-native-community/cli-tools" "13.6.6" - "@react-native/dev-middleware" "0.74.83" - "@react-native/metro-babel-transformer" "0.74.83" + "@react-native-community/cli-server-api" "13.6.8" + "@react-native-community/cli-tools" "13.6.8" + "@react-native/dev-middleware" "0.74.84" + "@react-native/metro-babel-transformer" "0.74.84" chalk "^4.0.0" execa "^5.1.1" metro "^0.80.3" @@ -2211,15 +2196,15 @@ querystring "^0.2.1" readline "^1.3.0" -"@react-native/community-cli-plugin@0.74.84": - version "0.74.84" - resolved "https://registry.yarnpkg.com/@react-native/community-cli-plugin/-/community-cli-plugin-0.74.84.tgz#223a0defe8118dc57c8ac852ddd13517ea10c4e2" - integrity sha512-GBKE+1sUh86fS2XXV46gMCNHMc1KetshMbYJ0AhDhldpaILZHqRBX50mdVsiYVvkzp4QjM0nmYqefuJ9NVwicQ== +"@react-native/community-cli-plugin@0.74.87": + version "0.74.87" + resolved "https://registry.yarnpkg.com/@react-native/community-cli-plugin/-/community-cli-plugin-0.74.87.tgz#4d9798d51381912f3771acded9b6b2804987e952" + integrity sha512-EgJG9lSr8x3X67dHQKQvU6EkO+3ksVlJHYIVv6U/AmW9dN80BEFxgYbSJ7icXS4wri7m4kHdgeq2PQ7/3vvrTQ== dependencies: - "@react-native-community/cli-server-api" "13.6.8" - "@react-native-community/cli-tools" "13.6.8" - "@react-native/dev-middleware" "0.74.84" - "@react-native/metro-babel-transformer" "0.74.84" + "@react-native-community/cli-server-api" "13.6.9" + "@react-native-community/cli-tools" "13.6.9" + "@react-native/dev-middleware" "0.74.87" + "@react-native/metro-babel-transformer" "0.74.87" chalk "^4.0.0" execa "^5.1.1" metro "^0.80.3" @@ -2229,23 +2214,23 @@ querystring "^0.2.1" readline "^1.3.0" -"@react-native/debugger-frontend@0.74.83": - version "0.74.83" - resolved "https://registry.yarnpkg.com/@react-native/debugger-frontend/-/debugger-frontend-0.74.83.tgz#48050afa4e086438073b95f041c0cc84fe3f20de" - integrity sha512-RGQlVUegBRxAUF9c1ss1ssaHZh6CO+7awgtI9sDeU0PzDZY/40ImoPD5m0o0SI6nXoVzbPtcMGzU+VO590pRfA== - "@react-native/debugger-frontend@0.74.84": version "0.74.84" resolved "https://registry.yarnpkg.com/@react-native/debugger-frontend/-/debugger-frontend-0.74.84.tgz#0bde122a988916b6a50f05a7c3ab1c5db029b149" integrity sha512-YUEA03UNFbiYzHpYxlcS2D9+3eNT5YLGkl5yRg3nOSN6KbCc/OttGnNZme+tuSOJwjMN/vcvtDKYkTqjJw8U0A== -"@react-native/dev-middleware@0.74.83": - version "0.74.83" - resolved "https://registry.yarnpkg.com/@react-native/dev-middleware/-/dev-middleware-0.74.83.tgz#9d09cfdb763e8ef81c003b0f99ae4ed1a3539639" - integrity sha512-UH8iriqnf7N4Hpi20D7M2FdvSANwTVStwFCSD7VMU9agJX88Yk0D1T6Meh2RMhUu4kY2bv8sTkNRm7LmxvZqgA== +"@react-native/debugger-frontend@0.74.87": + version "0.74.87" + resolved "https://registry.yarnpkg.com/@react-native/debugger-frontend/-/debugger-frontend-0.74.87.tgz#0bb4f4f54365d04fc975349d5f635cb575f6a5d8" + integrity sha512-MN95DJLYTv4EqJc+9JajA3AJZSBYJz2QEJ3uWlHrOky2vKrbbRVaW1ityTmaZa2OXIvNc6CZwSRSE7xCoHbXhQ== + +"@react-native/dev-middleware@0.74.84": + version "0.74.84" + resolved "https://registry.yarnpkg.com/@react-native/dev-middleware/-/dev-middleware-0.74.84.tgz#19ccfece791742f83f4c0a22a8c14593a45562a2" + integrity sha512-veYw/WmyrAOQHUiIeULzn2duJQnXDPiKq2jZ/lcmDo6jsLirpp+Q73lx09TYgy/oVoPRuV0nfmU3x9B6EV/7qQ== dependencies: "@isaacs/ttlcache" "^1.4.1" - "@react-native/debugger-frontend" "0.74.83" + "@react-native/debugger-frontend" "0.74.84" "@rnx-kit/chromium-edge-launcher" "^1.0.0" chrome-launcher "^0.15.2" connect "^3.6.5" @@ -2258,13 +2243,13 @@ temp-dir "^2.0.0" ws "^6.2.2" -"@react-native/dev-middleware@0.74.84": - version "0.74.84" - resolved "https://registry.yarnpkg.com/@react-native/dev-middleware/-/dev-middleware-0.74.84.tgz#19ccfece791742f83f4c0a22a8c14593a45562a2" - integrity sha512-veYw/WmyrAOQHUiIeULzn2duJQnXDPiKq2jZ/lcmDo6jsLirpp+Q73lx09TYgy/oVoPRuV0nfmU3x9B6EV/7qQ== +"@react-native/dev-middleware@0.74.87": + version "0.74.87" + resolved "https://registry.yarnpkg.com/@react-native/dev-middleware/-/dev-middleware-0.74.87.tgz#254807b579a3015ced659a14c374dbf029a9c04e" + integrity sha512-7TmZ3hTHwooYgIHqc/z87BMe1ryrIqAUi+AF7vsD+EHCGxHFdMjSpf1BZ2SUPXuLnF2cTiTfV2RwhbPzx0tYIA== dependencies: "@isaacs/ttlcache" "^1.4.1" - "@react-native/debugger-frontend" "0.74.84" + "@react-native/debugger-frontend" "0.74.87" "@rnx-kit/chromium-edge-launcher" "^1.0.0" chrome-launcher "^0.15.2" connect "^3.6.5" @@ -2301,35 +2286,25 @@ resolved "https://registry.yarnpkg.com/@react-native/eslint-plugin/-/eslint-plugin-0.74.84.tgz#f0e9618551c9340caca7624001f8ce32794715c9" integrity sha512-pDzo4Qm1uPZQne2sv0QK89ePxP/i+ZHjrBW3rkTVStLvsDVdyFahMmt6bzJTdYL2cGgK2oyNmfXtvO57INOu3Q== -"@react-native/gradle-plugin@0.74.83": - version "0.74.83" - resolved "https://registry.yarnpkg.com/@react-native/gradle-plugin/-/gradle-plugin-0.74.83.tgz#4ac60a6d6295d5b920173cbf184ee32e53690810" - integrity sha512-Pw2BWVyOHoBuJVKxGVYF6/GSZRf6+v1Ygc+ULGz5t20N8qzRWPa2fRZWqoxsN7TkNLPsECYY8gooOl7okOcPAQ== - "@react-native/gradle-plugin@0.74.84": version "0.74.84" resolved "https://registry.yarnpkg.com/@react-native/gradle-plugin/-/gradle-plugin-0.74.84.tgz#6ff25fad5f78c276afde96ffc42e04e92d6d92b1" integrity sha512-wYWC5WWXqzCCe4PDogz9pNc4xH5ZamahW5XGSbrrYJ5V3walZ+7z43V6iEBJkZbLjj9YBcSttkXYGr1Xh4veAg== -"@react-native/js-polyfills@0.74.83": - version "0.74.83" - resolved "https://registry.yarnpkg.com/@react-native/js-polyfills/-/js-polyfills-0.74.83.tgz#0e189ce3ab0efecd00223f3bfc53663ce08ba013" - integrity sha512-/t74n8r6wFhw4JEoOj3bN71N1NDLqaawB75uKAsSjeCwIR9AfCxlzZG0etsXtOexkY9KMeZIQ7YwRPqUdNXuqw== +"@react-native/gradle-plugin@0.74.87": + version "0.74.87" + resolved "https://registry.yarnpkg.com/@react-native/gradle-plugin/-/gradle-plugin-0.74.87.tgz#a66c01fda7a938a116dc27447f0ccce285796b2a" + integrity sha512-T+VX0N1qP+U9V4oAtn7FTX7pfsoVkd1ocyw9swYXgJqU2fK7hC9famW7b3s3ZiufPGPr1VPJe2TVGtSopBjL6A== "@react-native/js-polyfills@0.74.84": version "0.74.84" resolved "https://registry.yarnpkg.com/@react-native/js-polyfills/-/js-polyfills-0.74.84.tgz#edf0e8463616a2683269bbfe3957590f7ebd910c" integrity sha512-+PgxuUjBw9JVlz6m4ECsIJMLbDopnr4rpLmsG32hQaJrg0wMuvHtsgAY/J/aVCSG2GNUXexfjrnhc+O9yGOZXQ== -"@react-native/metro-babel-transformer@0.74.83": - version "0.74.83" - resolved "https://registry.yarnpkg.com/@react-native/metro-babel-transformer/-/metro-babel-transformer-0.74.83.tgz#ba87c3cf041f4c0d2b991231af1a6b4a216e9b5d" - integrity sha512-hGdx5N8diu8y+GW/ED39vTZa9Jx1di2ZZ0aapbhH4egN1agIAusj5jXTccfNBwwWF93aJ5oVbRzfteZgjbutKg== - dependencies: - "@babel/core" "^7.20.0" - "@react-native/babel-preset" "0.74.83" - hermes-parser "0.19.1" - nullthrows "^1.1.1" +"@react-native/js-polyfills@0.74.87": + version "0.74.87" + resolved "https://registry.yarnpkg.com/@react-native/js-polyfills/-/js-polyfills-0.74.87.tgz#d28090a4dae417a2e9ad14e065fcf8cf52cc482c" + integrity sha512-M5Evdn76CuVEF0GsaXiGi95CBZ4IWubHqwXxV9vG9CC9kq0PSkoM2Pn7Lx7dgyp4vT7ccJ8a3IwHbe+5KJRnpw== "@react-native/metro-babel-transformer@0.74.84": version "0.74.84" @@ -2341,6 +2316,16 @@ hermes-parser "0.19.1" nullthrows "^1.1.1" +"@react-native/metro-babel-transformer@0.74.87": + version "0.74.87" + resolved "https://registry.yarnpkg.com/@react-native/metro-babel-transformer/-/metro-babel-transformer-0.74.87.tgz#f60958f5e7eb39008a2c01dc5248ab60240bdc01" + integrity sha512-UsJCO24sNax2NSPBmV1zLEVVNkS88kcgAiYrZHtYSwSjpl4WZ656tIeedBfiySdJ94Hr3kQmBYLipV5zk0NI1A== + dependencies: + "@babel/core" "^7.20.0" + "@react-native/babel-preset" "0.74.87" + hermes-parser "0.19.1" + nullthrows "^1.1.1" + "@react-native/metro-config@0.74.84": version "0.74.84" resolved "https://registry.yarnpkg.com/@react-native/metro-config/-/metro-config-0.74.84.tgz#b2c1b45f62af9b8140a9a02798fa4fb2a3db7c0c" @@ -2351,29 +2336,21 @@ metro-config "^0.80.3" metro-runtime "^0.80.3" -"@react-native/normalize-colors@0.74.83": - version "0.74.83" - resolved "https://registry.yarnpkg.com/@react-native/normalize-colors/-/normalize-colors-0.74.83.tgz#86ef925bacf219d74df115bcfb615f62d8142e85" - integrity sha512-jhCY95gRDE44qYawWVvhTjTplW1g+JtKTKM3f8xYT1dJtJ8QWv+gqEtKcfmOHfDkSDaMKG0AGBaDTSK8GXLH8Q== - "@react-native/normalize-colors@0.74.84": version "0.74.84" resolved "https://registry.yarnpkg.com/@react-native/normalize-colors/-/normalize-colors-0.74.84.tgz#4764d59775c17a6ed193509cb01ae2f42dd5c045" integrity sha512-Y5W6x8cC5RuakUcTVUFNAIhUZ/tYpuqHZlRBoAuakrTwVuoNHXfQki8lj1KsYU7rW6e3VWgdEx33AfOQpdNp6A== +"@react-native/normalize-colors@0.74.87": + version "0.74.87" + resolved "https://registry.yarnpkg.com/@react-native/normalize-colors/-/normalize-colors-0.74.87.tgz#a814169d0ce4ce13ffebcda0a3a5a3f780ccd772" + integrity sha512-Xh7Nyk/MPefkb0Itl5Z+3oOobeG9lfLb7ZOY2DKpFnoCE1TzBmib9vMNdFaLdSxLIP+Ec6icgKtdzYg8QUPYzA== + "@react-native/typescript-config@0.74.84": version "0.74.84" resolved "https://registry.yarnpkg.com/@react-native/typescript-config/-/typescript-config-0.74.84.tgz#aff6132ced5679c99b33b4e3a6747338b99e5e09" integrity sha512-yMAyxl0wzRKT6JkQV0WCryiBQ1hj97u/JiT4LjXbwpPSErgiTRq+SKwhKH5vhSw9P0O8JCLIG6rS5rkbjranDg== -"@react-native/virtualized-lists@0.74.83": - version "0.74.83" - resolved "https://registry.yarnpkg.com/@react-native/virtualized-lists/-/virtualized-lists-0.74.83.tgz#5595d6aefd9679d1295c56a1d1653b1fb261bd62" - integrity sha512-rmaLeE34rj7py4FxTod7iMTC7BAsm+HrGA8WxYmEJeyTV7WSaxAkosKoYBz8038mOiwnG9VwA/7FrB6bEQvn1A== - dependencies: - invariant "^2.2.4" - nullthrows "^1.1.1" - "@react-native/virtualized-lists@0.74.84": version "0.74.84" resolved "https://registry.yarnpkg.com/@react-native/virtualized-lists/-/virtualized-lists-0.74.84.tgz#cf32fffc93072942532c9c81bd7e4c01a2949626" @@ -2382,6 +2359,14 @@ invariant "^2.2.4" nullthrows "^1.1.1" +"@react-native/virtualized-lists@0.74.87": + version "0.74.87" + resolved "https://registry.yarnpkg.com/@react-native/virtualized-lists/-/virtualized-lists-0.74.87.tgz#31bc44d62617df7d893df22c4c57094f576677a0" + integrity sha512-lsGxoFMb0lyK/MiplNKJpD+A1EoEUumkLrCjH4Ht+ZlG8S0BfCxmskLZ6qXn3BiDSkLjfjI/qyZ3pnxNBvkXpQ== + dependencies: + invariant "^2.2.4" + nullthrows "^1.1.1" + "@rnx-kit/chromium-edge-launcher@^1.0.0": version "1.0.0" resolved "https://registry.yarnpkg.com/@rnx-kit/chromium-edge-launcher/-/chromium-edge-launcher-1.0.0.tgz#c0df8ea00a902c7a417cd9655aab06de398b939c" @@ -3148,11 +3133,6 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== -base64-arraybuffer@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/base64-arraybuffer/-/base64-arraybuffer-1.0.2.tgz#1c37589a7c4b0746e34bd1feb951da2df01c1bdc" - integrity sha512-I3yl4r9QB5ZRY3XuJVEPfc2XhZO6YweFPI+UovAzn+8/hb3oJ6lnysaFcjVpkCPfVWFUDvoZ8kmVDP7WyRtYtQ== - base64-js@^1.3.1, base64-js@^1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" @@ -3574,13 +3554,6 @@ cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3: shebang-command "^2.0.0" which "^2.0.1" -css-line-break@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/css-line-break/-/css-line-break-2.1.0.tgz#bfef660dfa6f5397ea54116bb3cb4873edbc4fa0" - integrity sha512-FHcKFCZcAha3LwfVBhCQbW2nCNbkZXn7KVUJcsT5/P8YmfsVja0FMPJr0B903j/E69HUphKiV9iQArX8SDYA4w== - dependencies: - utrie "^1.0.2" - css-select@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/css-select/-/css-select-5.1.0.tgz#b8ebd6554c3637ccc76688804ad3f6a6fdaea8a6" @@ -3801,11 +3774,6 @@ domutils@^3.0.1: domelementtype "^2.3.0" domhandler "^5.0.3" -dotenv@^16.4.5: - version "16.4.5" - resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.5.tgz#cdd3b3b604cb327e286b4762e13502f717cb099f" - integrity sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg== - ee-first@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" @@ -4640,7 +4608,7 @@ globalthis@^1.0.3, globalthis@^1.0.4: define-properties "^1.2.1" gopd "^1.0.1" -globby@^11.0.4, globby@^11.1.0: +globby@^11.1.0: version "11.1.0" resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== @@ -4763,14 +4731,6 @@ html-escaper@^2.0.0: resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453" integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg== -html2canvas@^1.4.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/html2canvas/-/html2canvas-1.4.1.tgz#7cef1888311b5011d507794a066041b14669a543" - integrity sha512-fPU6BHNpsyIhr8yyMpTLLxAbkaK8ArIBcmZIRiBLiDhjeqvXolaEmDGmELFuX9I4xDcaKKcJl+TKZLqruBbmWA== - dependencies: - css-line-break "^2.1.0" - text-segmentation "^1.0.3" - http-errors@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-2.0.0.tgz#b7774a1486ef73cf7667ac9ae0858c012c57b9d3" @@ -6888,60 +6848,29 @@ react-is@^17.0.1: resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== -react-native-dotenv@^3.4.11: - version "3.4.11" - resolved "https://registry.yarnpkg.com/react-native-dotenv/-/react-native-dotenv-3.4.11.tgz#2e6c4eabd55d5f1bf109b3dd9141dadf9c55cdd4" - integrity sha512-6vnIE+WHABSeHCaYP6l3O1BOEhWxKH6nHAdV7n/wKn/sciZ64zPPp2NUdEUf1m7g4uuzlLbjgr+6uDt89q2DOg== - dependencies: - dotenv "^16.4.5" - -react-native-reanimated@3.15.4: - version "3.15.4" - resolved "https://registry.yarnpkg.com/react-native-reanimated/-/react-native-reanimated-3.15.4.tgz#0d4aa65b53f9c845fe8c33aa8a3ad3d06a23f063" - integrity sha512-jcpHE+MnsvSbClhHgAFoken7SnaHrUJ5gVA8BUw8S1j6rkrw2VzRpht6cxn14NlqYx5ytjfG9IXJDOzq8tFvfw== - dependencies: - "@babel/plugin-transform-arrow-functions" "^7.0.0-0" - "@babel/plugin-transform-class-properties" "^7.0.0-0" - "@babel/plugin-transform-classes" "^7.0.0-0" - "@babel/plugin-transform-nullish-coalescing-operator" "^7.0.0-0" - "@babel/plugin-transform-optional-chaining" "^7.0.0-0" - "@babel/plugin-transform-shorthand-properties" "^7.0.0-0" - "@babel/plugin-transform-template-literals" "^7.0.0-0" - "@babel/plugin-transform-unicode-regex" "^7.0.0-0" - "@babel/preset-typescript" "^7.16.7" - convert-source-map "^2.0.0" - invariant "^2.2.4" - "react-native-svg@link:../..": version "0.0.0" uid "" -react-native-view-shot@4.0.0-alpha.2: - version "4.0.0-alpha.2" - resolved "https://registry.yarnpkg.com/react-native-view-shot/-/react-native-view-shot-4.0.0-alpha.2.tgz#389f5323722c3acad1c002bf4f0f0539fd2508c9" - integrity sha512-BNQ+FoOUrB2Y6zxwhSZtZMMXVLewN2Ic8y5gS+5Y7hdgphqWmlHZIGbcLn/NmJS+soz0Pe3WO1sM5vX6u7h6VQ== - dependencies: - html2canvas "^1.4.1" - -react-native-windows@0.74.9: - version "0.74.9" - resolved "https://registry.yarnpkg.com/react-native-windows/-/react-native-windows-0.74.9.tgz#2abcc8eb99a4ce0ce80dfe2dea8ce249b8e21469" - integrity sha512-0WEwKhfi+WyjVswT6pRewfw2V694KYfTMIDSITDEu3Y3A9m1o0YyisnURxc4KRndRc0FQuw1iUf49uVK7BnXAw== +react-native-windows@0.74.23: + version "0.74.23" + resolved "https://registry.yarnpkg.com/react-native-windows/-/react-native-windows-0.74.23.tgz#50eb9494413e5efdf58045e9e573d2af398c1b25" + integrity sha512-r8YXuLff4fIxL8HNKquV4BYS5VZNWQzIuoRJUgsECSUCYwzd1z0oY0/cxifzNwf5c9XBVHuQZlSDjl3HMbWUgw== dependencies: "@babel/runtime" "^7.0.0" "@jest/create-cache-key-function" "^29.6.3" - "@react-native-community/cli" "13.6.6" - "@react-native-community/cli-platform-android" "13.6.6" - "@react-native-community/cli-platform-ios" "13.6.6" - "@react-native-windows/cli" "0.74.0" + "@react-native-community/cli" "13.6.9" + "@react-native-community/cli-platform-android" "13.6.9" + "@react-native-community/cli-platform-ios" "13.6.9" + "@react-native-windows/cli" "0.74.7" "@react-native/assets" "1.0.0" - "@react-native/assets-registry" "0.74.83" - "@react-native/codegen" "0.74.83" - "@react-native/community-cli-plugin" "0.74.83" - "@react-native/gradle-plugin" "0.74.83" - "@react-native/js-polyfills" "0.74.83" - "@react-native/normalize-colors" "0.74.83" - "@react-native/virtualized-lists" "0.74.83" + "@react-native/assets-registry" "0.74.87" + "@react-native/codegen" "0.74.87" + "@react-native/community-cli-plugin" "0.74.87" + "@react-native/gradle-plugin" "0.74.87" + "@react-native/js-polyfills" "0.74.87" + "@react-native/normalize-colors" "0.74.87" + "@react-native/virtualized-lists" "0.74.87" abort-controller "^3.0.0" anser "^1.4.9" ansi-regex "^5.0.0" @@ -7791,13 +7720,6 @@ test-exclude@^6.0.0: glob "^7.1.4" minimatch "^3.0.4" -text-segmentation@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/text-segmentation/-/text-segmentation-1.0.3.tgz#52a388159efffe746b24a63ba311b6ac9f2d7943" - integrity sha512-iOiPUo/BGnZ6+54OsWxZidGCsdU8YbE4PSpdPinp7DeMtUJNJBoJ/ouUSTJjHkh1KntHaltHl/gDs2FC4i5+Nw== - dependencies: - utrie "^1.0.2" - text-table@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" @@ -8034,13 +7956,6 @@ utils-merge@1.0.1: resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" integrity sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA== -utrie@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/utrie/-/utrie-1.0.2.tgz#d42fe44de9bc0119c25de7f564a6ed1b2c87a645" - integrity sha512-1MLa5ouZiOmQzUbjbu9VmjLzn1QLXBhwpUa7kdLUQK+KQ5KA9I1vk5U4YHe/X2Ch7PYnJfWuWT+VbuxbGwljhw== - dependencies: - base64-arraybuffer "^1.0.2" - uuid@^3.3.2: version "3.4.0" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" diff --git a/windows/RNSVG/BrushView.cpp b/windows/RNSVG/BrushView.cpp index 6436f2ee2..903b161ca 100644 --- a/windows/RNSVG/BrushView.cpp +++ b/windows/RNSVG/BrushView.cpp @@ -8,11 +8,6 @@ namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -BrushView::BrushView( - const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) : base_type(args) {} -#endif - void BrushView::SaveDefinition() { if (auto const &root{SvgRoot()}) { CreateBrush(); diff --git a/windows/RNSVG/BrushView.h b/windows/RNSVG/BrushView.h index 57aefa162..6c83ebdea 100644 --- a/windows/RNSVG/BrushView.h +++ b/windows/RNSVG/BrushView.h @@ -8,10 +8,6 @@ struct BrushView : BrushViewT { public: BrushView() = default; -#ifdef USE_FABRIC - BrushView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args); -#endif - // IRenderable void SaveDefinition(); @@ -29,6 +25,9 @@ struct BrushView : BrushViewT { }; } // namespace winrt::RNSVG::implementation +#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct BrushView : BrushViewT {}; } // namespace winrt::RNSVG::factory_implementation +#endif + diff --git a/windows/RNSVG/CircleView.cpp b/windows/RNSVG/CircleView.cpp index 131d18355..0a5141e5f 100644 --- a/windows/RNSVG/CircleView.cpp +++ b/windows/RNSVG/CircleView.cpp @@ -22,18 +22,8 @@ void CircleProps::SetProp( winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); } -CircleView::CircleView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) : base_type(args) {} - void CircleView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - builder.AddViewComponent( - L"RNSVGCircle", [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { - builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props) noexcept { - return winrt::make(props); - }); - builder.SetCreateComponentView([](const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) noexcept { - return winrt::make(args); - }); - }); + RegisterRenderableComponent(L"RNSVGCircle", builder); } void CircleView::UpdateProperties( diff --git a/windows/RNSVG/CircleView.h b/windows/RNSVG/CircleView.h index d14d8e965..ba73ac3c9 100644 --- a/windows/RNSVG/CircleView.h +++ b/windows/RNSVG/CircleView.h @@ -34,8 +34,6 @@ struct CircleView : CircleViewT {}; } // namespace winrt::RNSVG::factory_implementation +#endif diff --git a/windows/RNSVG/ClipPathView.cpp b/windows/RNSVG/ClipPathView.cpp index cecf21ac1..38c6eecc0 100644 --- a/windows/RNSVG/ClipPathView.cpp +++ b/windows/RNSVG/ClipPathView.cpp @@ -17,18 +17,8 @@ void ClipPathProps::SetProp( winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); } -ClipPathView::ClipPathView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) : base_type(args) {} - void ClipPathView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - builder.AddViewComponent( - L"RNSVGClipPath", [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { - builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props) noexcept { - return winrt::make(props); - }); - builder.SetCreateComponentView([](const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) noexcept { - return winrt::make(args); - }); - }); + RegisterRenderableComponent(L"RNSVGClipPath", builder); } #endif } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/ClipPathView.h b/windows/RNSVG/ClipPathView.h index 5f5b7856e..0634db6da 100644 --- a/windows/RNSVG/ClipPathView.h +++ b/windows/RNSVG/ClipPathView.h @@ -26,8 +26,6 @@ struct ClipPathView : ClipPathViewT {}; } // namespace winrt::RNSVG::factory_implementation +#endif \ No newline at end of file diff --git a/windows/RNSVG/D2DHelpers.h b/windows/RNSVG/D2DHelpers.h index 19b381a6a..0cf56e8f6 100644 --- a/windows/RNSVG/D2DHelpers.h +++ b/windows/RNSVG/D2DHelpers.h @@ -132,7 +132,7 @@ struct D2DHelpers { static DWRITE_FONT_WEIGHT FontWeightFrom( #ifdef USE_FABRIC - winrt::Microsoft::ReactNative::ComponentView const &parent, + IRenderableFabric const &parent, #else xaml::FrameworkElement const &parent, #endif diff --git a/windows/RNSVG/DefsView.cpp b/windows/RNSVG/DefsView.cpp index f36042367..9a19301a9 100644 --- a/windows/RNSVG/DefsView.cpp +++ b/windows/RNSVG/DefsView.cpp @@ -18,18 +18,8 @@ void DefsProps::SetProp( winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); } -DefsView::DefsView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) : base_type(args) {} - void DefsView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - builder.AddViewComponent( - L"RNSVGDefs", [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { - builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props) noexcept { - return winrt::make(props); - }); - builder.SetCreateComponentView([](const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) noexcept { - return winrt::make(args); - }); - }); + RegisterRenderableComponent(L"RNSVGDefs", builder); } #endif diff --git a/windows/RNSVG/DefsView.h b/windows/RNSVG/DefsView.h index ae9262a8c..ca777c56e 100644 --- a/windows/RNSVG/DefsView.h +++ b/windows/RNSVG/DefsView.h @@ -19,6 +19,8 @@ struct DefsProps : DefsPropsT { REACT_SVG_NODE_COMMON_PROPS; REACT_SVG_RENDERABLE_COMMON_PROPS; + REACT_SVG_GROUP_COMMON_PROPS; + }; #endif @@ -27,8 +29,6 @@ struct DefsView : DefsViewT { DefsView() = default; #ifdef USE_FABRIC - DefsView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args); - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; #endif @@ -37,6 +37,8 @@ struct DefsView : DefsViewT { }; } // namespace winrt::RNSVG::implementation +#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct DefsView : DefsViewT {}; } // namespace winrt::RNSVG::factory_implementation +#endif \ No newline at end of file diff --git a/windows/RNSVG/EllipseView.cpp b/windows/RNSVG/EllipseView.cpp index 2b1e0c854..5ce4a38cc 100644 --- a/windows/RNSVG/EllipseView.cpp +++ b/windows/RNSVG/EllipseView.cpp @@ -21,18 +21,8 @@ void EllipseProps::SetProp( winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); } -EllipseView::EllipseView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) : base_type(args) {} - void EllipseView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - builder.AddViewComponent( - L"RNSVGEllipse", [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { - builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props) noexcept { - return winrt::make(props); - }); - builder.SetCreateComponentView([](const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) noexcept { - return winrt::make(args); - }); - }); + RegisterRenderableComponent(L"RNSVGEllipse", builder); } void EllipseView::UpdateProperties( @@ -42,12 +32,10 @@ void EllipseView::UpdateProperties( bool invalidate) noexcept { auto ellipseProps = props.try_as(); if (ellipseProps) { - m_props = ellipseProps; - - m_cx = m_props->cx; - m_cy = m_props->cy; - m_rx = m_props->rx; - m_ry = m_props->ry; + m_cx = ellipseProps->cx; + m_cy = ellipseProps->cy; + m_rx = ellipseProps->rx; + m_ry = ellipseProps->ry; } base_type::UpdateProperties(props, oldProps, forceUpdate, invalidate); diff --git a/windows/RNSVG/EllipseView.h b/windows/RNSVG/EllipseView.h index e52363b6a..29415494b 100644 --- a/windows/RNSVG/EllipseView.h +++ b/windows/RNSVG/EllipseView.h @@ -36,8 +36,6 @@ struct EllipseView : EllipseViewT m_props; -#endif }; } // namespace winrt::RNSVG::implementation + +#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct EllipseView : EllipseViewT {}; } // namespace winrt::RNSVG::factory_implementation +#endif diff --git a/windows/RNSVG/Fabric.idl b/windows/RNSVG/Fabric.idl index fe8305ff8..f7f15a7a5 100644 --- a/windows/RNSVG/Fabric.idl +++ b/windows/RNSVG/Fabric.idl @@ -5,27 +5,24 @@ namespace RNSVG [experimental] interface IRenderableFabric { - Microsoft.ReactNative.ComponentView SvgParent { get; }; + IRenderableFabric SvgParent; void UpdateProperties(Microsoft.ReactNative.IComponentProps props, Microsoft.ReactNative.IComponentProps oldProps, Boolean forceUpdate, Boolean invalidate); }; [experimental] [default_interface] - runtimeclass SvgView : Microsoft.ReactNative.Composition.ViewComponentView, - Microsoft.ReactNative.Composition.Experimental.IInternalCreateVisual, IRenderable, IRenderableFabric, ISvgView + runtimeclass SvgView : IRenderable, IRenderableFabric, ISvgView { - SvgView(Microsoft.ReactNative.Composition.CreateCompositionComponentViewArgs args); - GroupView Group; Microsoft.ReactNative.Color CurrentColor{ get; }; + Microsoft.ReactNative.Composition.Theme Theme { get; }; }; [experimental] [default_interface] - unsealed runtimeclass RenderableView : Microsoft.ReactNative.ComponentView, IRenderable, IRenderableFabric, IRenderableView + unsealed runtimeclass RenderableView : IRenderable, IRenderableFabric, IRenderableView { - RenderableView(Microsoft.ReactNative.CreateComponentViewArgs args); SvgView SvgRoot{ get; }; Microsoft.ReactNative.Color Fill{ get; }; Microsoft.ReactNative.Color Stroke{ get; }; @@ -35,132 +32,113 @@ namespace RNSVG [default_interface] runtimeclass RectView : RenderableView { - RectView(Microsoft.ReactNative.CreateComponentViewArgs args); }; [experimental] [default_interface] runtimeclass CircleView : RenderableView { - CircleView(Microsoft.ReactNative.CreateComponentViewArgs args); }; [experimental] [default_interface] runtimeclass EllipseView : RenderableView { - EllipseView(Microsoft.ReactNative.CreateComponentViewArgs args); }; [experimental] [default_interface] runtimeclass LineView : RenderableView { - LineView(Microsoft.ReactNative.CreateComponentViewArgs args); }; [experimental] [default_interface] runtimeclass PathView : RenderableView { - PathView(Microsoft.ReactNative.CreateComponentViewArgs args); }; [experimental] [default_interface] runtimeclass UseView : RenderableView { - UseView(Microsoft.ReactNative.CreateComponentViewArgs args); }; [experimental] [default_interface] runtimeclass ImageView : RenderableView { - ImageView(Microsoft.ReactNative.CreateComponentViewArgs args); }; [experimental] [default_interface] unsealed runtimeclass GroupView : RenderableView, IGroupView { - GroupView(Microsoft.ReactNative.CreateComponentViewArgs args); }; [experimental] [default_interface] unsealed runtimeclass TextView : GroupView, ITextView { - TextView(Microsoft.ReactNative.CreateComponentViewArgs args); }; [experimental] [default_interface] runtimeclass TSpanView : TextView, ITSpanView { - TSpanView(Microsoft.ReactNative.CreateComponentViewArgs args); }; [experimental] [default_interface] runtimeclass DefsView : GroupView { - DefsView(Microsoft.ReactNative.CreateComponentViewArgs args); }; [experimental] [default_interface] runtimeclass SymbolView : GroupView, ISymbolView { - SymbolView(Microsoft.ReactNative.CreateComponentViewArgs args); }; [experimental] [default_interface] runtimeclass ClipPathView : GroupView { - ClipPathView(Microsoft.ReactNative.CreateComponentViewArgs args); }; [experimental] [default_interface] runtimeclass MarkerView : GroupView { - MarkerView(Microsoft.ReactNative.CreateComponentViewArgs args); }; [experimental] [default_interface] runtimeclass MaskView : GroupView { - MaskView(Microsoft.ReactNative.CreateComponentViewArgs args); }; [experimental] [default_interface] unsealed runtimeclass BrushView : GroupView, IBrushView { - BrushView(Microsoft.ReactNative.CreateComponentViewArgs args); }; [experimental] [default_interface] runtimeclass LinearGradientView : BrushView { - LinearGradientView(Microsoft.ReactNative.CreateComponentViewArgs args); }; [experimental] [default_interface] runtimeclass RadialGradientView : BrushView { - RadialGradientView(Microsoft.ReactNative.CreateComponentViewArgs args); }; [experimental] [default_interface] runtimeclass PatternView : BrushView { - PatternView(Microsoft.ReactNative.CreateComponentViewArgs args); }; } \ No newline at end of file diff --git a/windows/RNSVG/GroupView.cpp b/windows/RNSVG/GroupView.cpp index e8f9167c3..fd66de9b2 100644 --- a/windows/RNSVG/GroupView.cpp +++ b/windows/RNSVG/GroupView.cpp @@ -26,20 +26,8 @@ void SvgGroupCommonProps::SetProp( winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); } -GroupView::GroupView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) - : base_type(args), m_reactContext(args.ReactContext()) {} - void GroupView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - builder.AddViewComponent( - L"RNSVGGroup", [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { - builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props) noexcept { - return winrt::make(props); - }); - builder.SetCreateComponentView( - [](const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) noexcept { - return winrt::make(args); - }); - }); + RegisterRenderableComponent(L"RNSVGGroup", builder); } void GroupView::UpdateProperties( @@ -50,7 +38,7 @@ void GroupView::UpdateProperties( auto groupProps = props.as(); auto oldGroupProps = oldProps ? oldProps.as() : nullptr; - auto const &parent{Parent().try_as()}; + auto const &parent{SvgParent().try_as()}; if (!oldGroupProps || groupProps->font != oldGroupProps->font) { if (forceUpdate || !m_fontPropMap[RNSVG::FontProp::FontSize]) { @@ -86,11 +74,14 @@ void GroupView::UpdateProperties( base_type::UpdateProperties(props, oldProps, forceUpdate, false); + /* for (auto const &child : Children()) { + //auto rchild = winrt::get_self(child); child.as().UpdateProperties(props, oldProps, false, false); } + */ - if (invalidate && Parent()) { + if (invalidate && SvgParent()) { SvgRoot().Invalidate(); } } @@ -274,7 +265,6 @@ void GroupView::Unload() { child.as().Unload(); } - m_reactContext = nullptr; m_fontPropMap.clear(); #ifndef USE_FABRIC diff --git a/windows/RNSVG/GroupView.h b/windows/RNSVG/GroupView.h index e5d9ee26c..34590eae2 100644 --- a/windows/RNSVG/GroupView.h +++ b/windows/RNSVG/GroupView.h @@ -85,9 +85,8 @@ struct GroupView : GroupViewT { public: GroupView() = default; -#ifdef USE_FABRIC - GroupView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args); +#ifdef USE_FABRIC static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; // IRenderableFabric @@ -97,7 +96,7 @@ struct GroupView bool forceUpdate = true, bool invalidate = true) noexcept override; #else - GroupView(Microsoft::ReactNative::IReactContext const &context) : m_reactContext(context) {} + GroupView(Microsoft::ReactNative::IReactContext const & /*context*/) {} Windows::Foundation::Collections::IVector Children() { return m_children; } @@ -126,7 +125,6 @@ struct GroupView virtual void DrawGroup(RNSVG::D2DDeviceContext const &deviceContext, Windows::Foundation::Size const &size); private: - Microsoft::ReactNative::IReactContext m_reactContext{nullptr}; #ifndef USE_FABRIC Windows::Foundation::Collections::IVector m_children{ @@ -145,6 +143,8 @@ struct GroupView }; } // namespace winrt::RNSVG::implementation +#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct GroupView : GroupViewT {}; } // namespace winrt::RNSVG::factory_implementation +#endif diff --git a/windows/RNSVG/ImageView.cpp b/windows/RNSVG/ImageView.cpp index 1926c129d..43577ae25 100644 --- a/windows/RNSVG/ImageView.cpp +++ b/windows/RNSVG/ImageView.cpp @@ -35,18 +35,8 @@ void ImageProps::SetProp( winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); } -ImageView::ImageView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) : base_type(args) {} - void ImageView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - builder.AddViewComponent( - L"RNSVGImage", [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { - builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props) noexcept { - return winrt::make(props); - }); - builder.SetCreateComponentView([](const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) noexcept { - return winrt::make(args); - }); - }); + RegisterRenderableComponent(L"RNSVGImage", builder); } void ImageView::UpdateProperties( @@ -57,23 +47,21 @@ void ImageView::UpdateProperties( auto imageProps = props.try_as(); auto oldImageProps = oldProps.try_as(); if (imageProps) { - m_props = imageProps; - - m_x = m_props->x; - m_y = m_props->y; - m_width = m_props->width; - m_height = m_props->height; + m_x = imageProps->x; + m_y = imageProps->y; + m_width = imageProps->width; + m_height = imageProps->height; // preserveAspectRatio - m_align = m_props->align; - m_meetOrSlice = m_props->meetOrSlice; + m_align = imageProps->align; + m_meetOrSlice = imageProps->meetOrSlice; // IamgeSource - m_source.uri = m_props->src.uri; - m_source.method = m_props->src.method; - m_source.width = m_props->src.width; - m_source.height = m_props->src.height; - m_source.scale = m_props->src.scale; + m_source.uri = imageProps->src.uri; + m_source.method = imageProps->src.method; + m_source.width = imageProps->src.width; + m_source.height = imageProps->src.height; + m_source.scale = imageProps->src.scale; if (!oldImageProps || (oldImageProps->src.uri != imageProps->src.uri)) { LoadImageSourceAsync(true); diff --git a/windows/RNSVG/ImageView.h b/windows/RNSVG/ImageView.h index 3b3f5570a..a68096740 100644 --- a/windows/RNSVG/ImageView.h +++ b/windows/RNSVG/ImageView.h @@ -90,8 +90,6 @@ struct ImageView : ImageViewT ImageView() = default; #ifdef USE_FABRIC - ImageView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args); - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; // IRenderableFabric @@ -119,10 +117,6 @@ struct ImageView : ImageViewT ImageSourceType m_type{ImageSourceType::Uri}; ImageSourceFormat m_format{ImageSourceFormat::Bitmap}; -#ifdef USE_FABRIC - com_ptr m_props; -#endif - // preserveAspectRatio std::string m_align{""}; RNSVG::MeetOrSlice m_meetOrSlice{RNSVG::MeetOrSlice::Meet}; @@ -143,6 +137,8 @@ struct ImageView : ImageViewT }; } // namespace winrt::RNSVG::implementation +#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct ImageView : ImageViewT {}; } // namespace winrt::RNSVG::factory_implementation +#endif \ No newline at end of file diff --git a/windows/RNSVG/LineView.cpp b/windows/RNSVG/LineView.cpp index 582b6376a..8050305b8 100644 --- a/windows/RNSVG/LineView.cpp +++ b/windows/RNSVG/LineView.cpp @@ -22,18 +22,8 @@ void LineProps::SetProp( winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); } -LineView::LineView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) : base_type(args) {} - void LineView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - builder.AddViewComponent( - L"RNSVGLine", [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { - builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props) noexcept { - return winrt::make(props); - }); - builder.SetCreateComponentView([](const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) noexcept { - return winrt::make(args); - }); - }); + RegisterRenderableComponent(L"RNSVGLine", builder); } void LineView::UpdateProperties( @@ -43,12 +33,10 @@ void LineView::UpdateProperties( bool invalidate) noexcept { auto lineProps = props.try_as(); if (lineProps) { - m_props = lineProps; - - m_x1 = m_props->x1; - m_y1 = m_props->y1; - m_x2 = m_props->x2; - m_y2 = m_props->y2; + m_x1 = lineProps->x1; + m_y1 = lineProps->y1; + m_x2 = lineProps->x2; + m_y2 = lineProps->y2; } base_type::UpdateProperties(props, oldProps, forceUpdate, invalidate); diff --git a/windows/RNSVG/LineView.h b/windows/RNSVG/LineView.h index c2466cb80..b3298c687 100644 --- a/windows/RNSVG/LineView.h +++ b/windows/RNSVG/LineView.h @@ -36,8 +36,6 @@ struct LineView : LineViewT { LineView() = default; #ifdef USE_FABRIC - LineView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args); - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; // IRenderableFabric @@ -59,13 +57,11 @@ struct LineView : LineViewT { RNSVG::SVGLength m_y1{}; RNSVG::SVGLength m_x2{}; RNSVG::SVGLength m_y2{}; - -#ifdef USE_FABRIC - com_ptr m_props; -#endif - }; } // namespace winrt::RNSVG::implementation + +#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct LineView : LineViewT {}; } // namespace winrt::RNSVG::factory_implementation +#endif \ No newline at end of file diff --git a/windows/RNSVG/LinearGradientView.cpp b/windows/RNSVG/LinearGradientView.cpp index 298073431..06ea02588 100644 --- a/windows/RNSVG/LinearGradientView.cpp +++ b/windows/RNSVG/LinearGradientView.cpp @@ -21,18 +21,9 @@ void LinearGradientProps::SetProp( winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); } -LinearGradientView::LinearGradientView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) : base_type(args) {} - void LinearGradientView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - builder.AddViewComponent( - L"RNSVGLinearGradient", [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { - builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props) noexcept { - return winrt::make(props); - }); - builder.SetCreateComponentView([](const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) noexcept { - return winrt::make(args); - }); - }); + RegisterRenderableComponent( + L"RNSVGLinearGradient", builder); } void LinearGradientView::UpdateProperties( @@ -42,16 +33,14 @@ void LinearGradientView::UpdateProperties( bool invalidate) noexcept { auto linearGradientProps = props.try_as(); if (linearGradientProps) { - m_props = linearGradientProps; - - m_x1 = m_props->x1; - m_y1 = m_props->y1; - m_x2 = m_props->x2; - m_y2 = m_props->y2; - - m_stops = Utils::JSValueAsGradientStops(m_props->gradient); - m_gradientUnits = Utils::JSValueAsBrushUnits(m_props->gradientUnits); - m_transform = Utils::JSValueAsD2DTransform(m_props->gradientTransform); + m_x1 = linearGradientProps->x1; + m_y1 = linearGradientProps->y1; + m_x2 = linearGradientProps->x2; + m_y2 = linearGradientProps->y2; + + m_stops = Utils::JSValueAsGradientStops(linearGradientProps->gradient); + m_gradientUnits = Utils::JSValueAsBrushUnits(linearGradientProps->gradientUnits); + m_transform = Utils::JSValueAsD2DTransform(linearGradientProps->gradientTransform); } base_type::UpdateProperties(props, oldProps, forceUpdate, invalidate); diff --git a/windows/RNSVG/LinearGradientView.h b/windows/RNSVG/LinearGradientView.h index 0fca6abc8..6a9871eb1 100644 --- a/windows/RNSVG/LinearGradientView.h +++ b/windows/RNSVG/LinearGradientView.h @@ -43,8 +43,6 @@ struct LinearGradientView : LinearGradientViewT m_stops{}; std::string m_gradientUnits{"objectBoundingBox"}; -#ifdef USE_FABRIC - com_ptr m_props; -#endif - // BrushView void CreateBrush(); void UpdateBounds(); @@ -80,6 +74,8 @@ struct LinearGradientView : LinearGradientViewT {}; } // namespace winrt::RNSVG::factory_implementation +#endif diff --git a/windows/RNSVG/MarkerView.cpp b/windows/RNSVG/MarkerView.cpp index 9548c5f03..9d34e2ba7 100644 --- a/windows/RNSVG/MarkerView.cpp +++ b/windows/RNSVG/MarkerView.cpp @@ -18,18 +18,8 @@ void MarkerProps::SetProp( winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); } -MarkerView::MarkerView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) : base_type(args) {} - void MarkerView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - builder.AddViewComponent( - L"RNSVGMarker", [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { - builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props) noexcept { - return winrt::make(props); - }); - builder.SetCreateComponentView([](const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) noexcept { - return winrt::make(args); - }); - }); + RegisterRenderableComponent(L"RNSVGMarker", builder); } void MarkerView::UpdateProperties( @@ -39,7 +29,6 @@ void MarkerView::UpdateProperties( bool invalidate) noexcept { auto markerProps = props.try_as(); if (markerProps) { - m_props = markerProps; } base_type::UpdateProperties(props, oldProps, forceUpdate, invalidate); diff --git a/windows/RNSVG/MarkerView.h b/windows/RNSVG/MarkerView.h index 503de6c36..9ea2beb57 100644 --- a/windows/RNSVG/MarkerView.h +++ b/windows/RNSVG/MarkerView.h @@ -52,8 +52,6 @@ struct MarkerView : MarkerViewT { MarkerView() = default; #ifdef USE_FABRIC - MarkerView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args); - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; // IRenderableFabric @@ -68,14 +66,11 @@ struct MarkerView : MarkerViewT { void Draw(RNSVG::D2DDeviceContext const & /*deviceContext*/, Windows::Foundation::Size const & /*size*/){}; private: - -#ifdef USE_FABRIC - com_ptr m_props; -#endif - }; } // namespace winrt::RNSVG::implementation +#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct MarkerView : MarkerViewT {}; } // namespace winrt::RNSVG::factory_implementation +#endif \ No newline at end of file diff --git a/windows/RNSVG/MaskView.cpp b/windows/RNSVG/MaskView.cpp index ffac2648e..2b72ec584 100644 --- a/windows/RNSVG/MaskView.cpp +++ b/windows/RNSVG/MaskView.cpp @@ -18,18 +18,8 @@ void MaskProps::SetProp( winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); } -MaskView::MaskView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) : base_type(args) {} - void MaskView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - builder.AddViewComponent( - L"RNSVGMask", [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { - builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props) noexcept { - return winrt::make(props); - }); - builder.SetCreateComponentView([](const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) noexcept { - return winrt::make(args); - }); - }); + RegisterRenderableComponent(L"RNSVGMask", builder); } void MaskView::UpdateProperties( @@ -39,7 +29,6 @@ void MaskView::UpdateProperties( bool invalidate) noexcept { auto maskProps = props.try_as(); if (maskProps) { - m_props = maskProps; } base_type::UpdateProperties(props, oldProps, forceUpdate, invalidate); diff --git a/windows/RNSVG/MaskView.h b/windows/RNSVG/MaskView.h index 26ce0eee3..ba1a58bc3 100644 --- a/windows/RNSVG/MaskView.h +++ b/windows/RNSVG/MaskView.h @@ -40,8 +40,6 @@ struct MaskView : MaskViewT { MaskView() = default; #ifdef USE_FABRIC - MaskView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args); - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; // IRenderableFabric @@ -56,14 +54,11 @@ struct MaskView : MaskViewT { void Draw(RNSVG::D2DDeviceContext const & /*deviceContext*/, Windows::Foundation::Size const & /*size*/){}; private: - -#ifdef USE_FABRIC - com_ptr m_props; -#endif - }; } // namespace winrt::RNSVG::implementation +#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct MaskView : MaskViewT {}; } // namespace winrt::RNSVG::factory_implementation +#endif diff --git a/windows/RNSVG/PathView.cpp b/windows/RNSVG/PathView.cpp index 4307c185e..cc739aacf 100644 --- a/windows/RNSVG/PathView.cpp +++ b/windows/RNSVG/PathView.cpp @@ -25,18 +25,8 @@ void PathProps::SetProp( winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); } -PathView::PathView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) : base_type(args) {} - void PathView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - builder.AddViewComponent( - L"RNSVGPath", [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { - builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props) noexcept { - return winrt::make(props); - }); - builder.SetCreateComponentView([](const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) noexcept { - return winrt::make(args); - }); - }); + RegisterRenderableComponent(L"RNSVGPath", builder); } void PathView::UpdateProperties( @@ -47,9 +37,7 @@ void PathView::UpdateProperties( auto pathProps = props.try_as(); if (pathProps) { - m_props = pathProps; - - m_d = m_props->d; + m_d = pathProps->d; m_commands.clear(); m_segmentData.clear(); ParsePath(); diff --git a/windows/RNSVG/PathView.h b/windows/RNSVG/PathView.h index 4596566f0..3c9ae8340 100644 --- a/windows/RNSVG/PathView.h +++ b/windows/RNSVG/PathView.h @@ -30,8 +30,6 @@ struct PathView : PathViewT { PathView() = default; #ifdef USE_FABRIC - PathView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args); - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; // IRenderableFabric @@ -53,10 +51,6 @@ struct PathView : PathViewT { std::vector m_segmentData; std::vector m_commands; -#ifdef USE_FABRIC - com_ptr m_props; -#endif - std::unordered_map m_cmds{ {'M', D2D1_SVG_PATH_COMMAND_MOVE_ABSOLUTE}, {'m', D2D1_SVG_PATH_COMMAND_MOVE_RELATIVE}, @@ -97,6 +91,8 @@ struct PathView : PathViewT { }; } // namespace winrt::RNSVG::implementation +#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct PathView : PathViewT {}; } // namespace winrt::RNSVG::factory_implementation +#endif diff --git a/windows/RNSVG/PatternView.cpp b/windows/RNSVG/PatternView.cpp index 1c02fc03c..acfbd4c64 100644 --- a/windows/RNSVG/PatternView.cpp +++ b/windows/RNSVG/PatternView.cpp @@ -22,19 +22,9 @@ void PatternProps::SetProp( winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); } -PatternView::PatternView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) : base_type(args) {} - void PatternView::RegisterComponent( const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - builder.AddViewComponent( - L"RNSVGPattern", [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { - builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props) noexcept { - return winrt::make(props); - }); - builder.SetCreateComponentView([](const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) noexcept { - return winrt::make(args); - }); - }); + RegisterRenderableComponent(L"RNSVGPattern", builder); } void PatternView::UpdateProperties( @@ -44,24 +34,22 @@ void PatternView::UpdateProperties( bool invalidate) noexcept { auto patternProps = props.try_as(); if (patternProps) { - m_props = patternProps; - - m_x = m_props->x; - m_y = m_props->y; - m_width = m_props->width; - m_height = m_props->height; - - m_minX = m_props->minX; - m_minY = m_props->minY; - m_vbWidth = m_props->vbWidth; - m_vbHeight = m_props->vbHeight; - m_align = m_props->align; - m_meetOrSlice = m_props->meetOrSlice; - - m_patternUnits = Utils::JSValueAsBrushUnits(m_props->patternUnits); - m_patternContentUnits = Utils::JSValueAsBrushUnits(m_props->patternContentUnits, "userSpaceOnUse"); - - m_transform = Utils::JSValueAsD2DTransform(m_props->patternTransform); + m_x = patternProps->x; + m_y = patternProps->y; + m_width = patternProps->width; + m_height = patternProps->height; + + m_minX = patternProps->minX; + m_minY = patternProps->minY; + m_vbWidth = patternProps->vbWidth; + m_vbHeight = patternProps->vbHeight; + m_align = patternProps->align; + m_meetOrSlice = patternProps->meetOrSlice; + + m_patternUnits = Utils::JSValueAsBrushUnits(patternProps->patternUnits); + m_patternContentUnits = Utils::JSValueAsBrushUnits(patternProps->patternContentUnits, "userSpaceOnUse"); + + m_transform = Utils::JSValueAsD2DTransform(patternProps->patternTransform); } base_type::UpdateProperties(props, oldProps, forceUpdate, invalidate); diff --git a/windows/RNSVG/PatternView.h b/windows/RNSVG/PatternView.h index 95ea06836..eb61a3d2c 100644 --- a/windows/RNSVG/PatternView.h +++ b/windows/RNSVG/PatternView.h @@ -19,6 +19,7 @@ struct PatternProps : PatternPropsT { REACT_SVG_NODE_COMMON_PROPS; REACT_SVG_RENDERABLE_COMMON_PROPS; + REACT_SVG_GROUP_COMMON_PROPS; REACT_FIELD(x) RNSVG::SVGLength x{0, winrt::RNSVG::LengthType::Unknown}; @@ -55,8 +56,6 @@ struct PatternView : PatternViewT PatternView() = default; #ifdef USE_FABRIC - PatternView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args); - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; // IRenderableFabric @@ -89,10 +88,6 @@ struct PatternView : PatternViewT std::string m_align{""}; RNSVG::MeetOrSlice m_meetOrSlice{RNSVG::MeetOrSlice::Meet}; -#ifdef USE_FABRIC - com_ptr m_props; -#endif - // BrushView void CreateBrush(); void UpdateBounds(); @@ -104,6 +99,9 @@ struct PatternView : PatternViewT }; } // namespace winrt::RNSVG::implementation +#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct PatternView : PatternViewT {}; } // namespace winrt::RNSVG::factory_implementation +#endif + diff --git a/windows/RNSVG/RadialGradientView.cpp b/windows/RNSVG/RadialGradientView.cpp index 707acc771..b474aeeb1 100644 --- a/windows/RNSVG/RadialGradientView.cpp +++ b/windows/RNSVG/RadialGradientView.cpp @@ -21,20 +21,10 @@ void RadialGradientProps::SetProp( winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); } -RadialGradientView::RadialGradientView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) - : base_type(args) {} - void RadialGradientView::RegisterComponent( const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - builder.AddViewComponent( - L"RNSVGRadialGradient", [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { - builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props) noexcept { - return winrt::make(props); - }); - builder.SetCreateComponentView([](const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) noexcept { - return winrt::make(args); - }); - }); + RegisterRenderableComponent( + L"RNSVGRadialGradient", builder); } void RadialGradientView::UpdateProperties( @@ -44,18 +34,16 @@ void RadialGradientView::UpdateProperties( bool invalidate) noexcept { auto radialGradientProps = props.try_as(); if (radialGradientProps) { - m_props = radialGradientProps; - - m_rx = m_props->rx; - m_ry = m_props->ry; - m_fx = m_props->fx; - m_fy = m_props->fy; - m_cx = m_props->cx; - m_cy = m_props->cy; - - m_stops = Utils::JSValueAsGradientStops(m_props->gradient); - m_gradientUnits = Utils::JSValueAsBrushUnits(m_props->gradientUnits); - m_transform = Utils::JSValueAsD2DTransform(m_props->gradientTransform); + m_rx = radialGradientProps->rx; + m_ry = radialGradientProps->ry; + m_fx = radialGradientProps->fx; + m_fy = radialGradientProps->fy; + m_cx = radialGradientProps->cx; + m_cy = radialGradientProps->cy; + + m_stops = Utils::JSValueAsGradientStops(radialGradientProps->gradient); + m_gradientUnits = Utils::JSValueAsBrushUnits(radialGradientProps->gradientUnits); + m_transform = Utils::JSValueAsD2DTransform(radialGradientProps->gradientTransform); } base_type::UpdateProperties(props, oldProps, forceUpdate, invalidate); diff --git a/windows/RNSVG/RadialGradientView.h b/windows/RNSVG/RadialGradientView.h index 0735530c6..c9b12b43f 100644 --- a/windows/RNSVG/RadialGradientView.h +++ b/windows/RNSVG/RadialGradientView.h @@ -19,6 +19,7 @@ struct RadialGradientProps : RadialGradientPropsT m_stops{}; std::string m_gradientUnits{"objectBoundingBox"}; -#ifdef USE_FABRIC - com_ptr m_props; -#endif - // BrushView void CreateBrush(); void UpdateBounds(); @@ -85,6 +80,9 @@ struct RadialGradientView : RadialGradientViewT {}; } // namespace winrt::RNSVG::factory_implementation +#endif + diff --git a/windows/RNSVG/RectView.cpp b/windows/RNSVG/RectView.cpp index bf3f5a181..77d250a0b 100644 --- a/windows/RNSVG/RectView.cpp +++ b/windows/RNSVG/RectView.cpp @@ -22,18 +22,8 @@ void RectProps::SetProp( winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); } -RectView::RectView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) : base_type(args) {} - void RectView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - builder.AddViewComponent( - L"RNSVGRect", [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { - builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props) noexcept { - return winrt::make(props); - }); - builder.SetCreateComponentView([](const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) noexcept { - return winrt::make(args); - }); - }); + RegisterRenderableComponent(L"RNSVGRect", builder); } void RectView::UpdateProperties( @@ -43,14 +33,12 @@ void RectView::UpdateProperties( bool invalidate) noexcept { auto rectProps = props.try_as(); if (rectProps) { - m_props = rectProps; - - m_x = m_props->x; - m_y = m_props->y; - m_width = m_props->width; - m_height = m_props->height; - m_rx = m_props->rx; - m_ry = m_props->ry; + m_x = rectProps->x; + m_y = rectProps->y; + m_width = rectProps->width; + m_height = rectProps->height; + m_rx = rectProps->rx; + m_ry = rectProps->ry; } base_type::UpdateProperties(props, oldProps, forceUpdate, invalidate); diff --git a/windows/RNSVG/RectView.h b/windows/RNSVG/RectView.h index 8be7d78e6..295a38e59 100644 --- a/windows/RNSVG/RectView.h +++ b/windows/RNSVG/RectView.h @@ -40,8 +40,6 @@ struct RectView : RectViewT { RectView() = default; #ifdef USE_FABRIC - RectView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args); - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; // IRenderableFabric @@ -65,13 +63,11 @@ struct RectView : RectViewT { RNSVG::SVGLength m_y{}; RNSVG::SVGLength m_rx{}; RNSVG::SVGLength m_ry{}; - -#ifdef USE_FABRIC - com_ptr m_props; -#endif }; } // namespace winrt::RNSVG::implementation +#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct RectView : RectViewT {}; } // namespace winrt::RNSVG::factory_implementation +#endif \ No newline at end of file diff --git a/windows/RNSVG/RenderableView.cpp b/windows/RNSVG/RenderableView.cpp index 989d90670..ce7b61d6e 100644 --- a/windows/RNSVG/RenderableView.cpp +++ b/windows/RNSVG/RenderableView.cpp @@ -35,52 +35,59 @@ void SvgRenderableCommonProps::SetProp( winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); } -RenderableView::RenderableView( - const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) - : base_type(args), m_reactContext(args.ReactContext()) {} - void RenderableView::MountChildComponentView( - const winrt::Microsoft::ReactNative::ComponentView &childComponentView, - uint32_t index) noexcept { + const winrt::Microsoft::ReactNative::ComponentView&, + const winrt::Microsoft::ReactNative::MountChildComponentViewArgs& args) noexcept +{ const RNSVG::RenderableView &view{*this}; - const auto &group{view.try_as()}; - const auto &child{childComponentView.try_as()}; + if (auto userData = args.Child().UserData()) { + const auto &group{view.try_as()}; + const auto &child{userData.try_as()}; + m_children.InsertAt(args.Index(), child); - if (group && child) { - base_type::MountChildComponentView(childComponentView, index); - child.MergeProperties(*this); + userData.as().SvgParent(*this); - if (child.IsResponsible() && !IsResponsible()) { - IsResponsible(true); - } + assert(group && child); + if (group && child) { + child.MergeProperties(*this); + + if (child.IsResponsible() && !IsResponsible()) { + IsResponsible(true); + } - if (auto const &root{SvgRoot()}) { - root.Invalidate(); + if (auto const &root{SvgRoot()}) { + root.Invalidate(); + } } } } void RenderableView::UnmountChildComponentView( - const winrt::Microsoft::ReactNative::ComponentView &childComponentView, - uint32_t index) noexcept { - const RNSVG::RenderableView &view{*this}; - const auto &group{view.try_as()}; - const auto &child{childComponentView.try_as()}; - - if (group && child) { - if (!IsUnloaded()) { - child.Unload(); - } + const winrt::Microsoft::ReactNative::ComponentView &, + const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept { + if (auto userData = args.Child().UserData()) { + const RNSVG::RenderableView &view{*this}; + const auto &group{view.try_as()}; + const auto &child{userData.try_as()}; + + userData.as().SvgParent(nullptr); + + if (group && child) { + if (!IsUnloaded()) { + child.Unload(); + } - base_type::UnmountChildComponentView(childComponentView, index); + m_children.RemoveAt(args.Index()); - if (auto const &root{SvgRoot()}) { - root.Invalidate(); + if (auto const &root{SvgRoot()}) { + root.Invalidate(); + } } } } void RenderableView::UpdateProps( + const winrt::Microsoft::ReactNative::ComponentView & /*view*/, const winrt::Microsoft::ReactNative::IComponentProps &props, const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept { if (!props && !oldProps) @@ -98,7 +105,7 @@ void RenderableView::UpdateProperties( auto oldRenderableProps = oldProps ? oldProps.as() : nullptr; - auto const &parent{Parent().try_as()}; + auto const &parent{SvgParent().try_as()}; // propList /* @@ -207,7 +214,7 @@ void RenderableView::UpdateProperties( std::find(renderableProps->propList->begin(), renderableProps->propList->end(), "fill") != renderableProps->propList->end()}; - if (forceUpdate || !m_propSetMap[RNSVG::BaseProp::Fill]) { + if (forceUpdate || (fillSet && !m_propSetMap[RNSVG::BaseProp::Fill])) { winrt::Microsoft::ReactNative::Color fallbackColor{winrt::Microsoft::ReactNative::Color::Black()}; if (renderableProps->fill == std::nullopt && fillSet) { fallbackColor = winrt::Microsoft::ReactNative::Color::Transparent(); @@ -400,10 +407,15 @@ void RenderableView::UpdateProperties( m_recreateResources = true; - if (invalidate && Parent()) { + if (invalidate && SvgParent()) { SvgRoot().Invalidate(); } } + +const winrt::Windows::Foundation::Collections::IVector& RenderableView::Children() const noexcept { + return m_children; +} + #else void RenderableView::UpdateProperties(IJSValueReader const &reader, bool forceUpdate, bool invalidate) { const JSValueObject &propertyMap{JSValue::ReadObjectFrom(reader)}; @@ -717,8 +729,8 @@ RNSVG::SvgView RenderableView::SvgRoot() { if (auto parent = SvgParent()) { if (auto const &svgView{parent.try_as()}) { if (auto const &svgViewParent = svgView.SvgParent()) { - if (auto const &parent{svgViewParent.try_as()}) { - return parent.SvgRoot(); + if (auto const &renderableParent{svgViewParent.try_as()}) { + return renderableParent.SvgRoot(); } else { return svgView; } diff --git a/windows/RNSVG/RenderableView.h b/windows/RNSVG/RenderableView.h index 5b8b4fa20..da99da849 100644 --- a/windows/RNSVG/RenderableView.h +++ b/windows/RNSVG/RenderableView.h @@ -28,7 +28,15 @@ struct ColorStruct { std::string brushRef; bool operator==(const ColorStruct &rhs) const { - return type == rhs.type && payload == rhs.payload && brushRef == rhs.brushRef; + if (type != rhs.type || brushRef != rhs.brushRef) + return false; + + // When we move to a RNW version that provides Color::Equals switch to that for the payload comparison + auto writer = winrt::Microsoft::ReactNative::MakeJSValueTreeWriter(); + winrt::Microsoft::ReactNative::WriteValue(writer, payload); + auto rhsWriter = winrt::Microsoft::ReactNative::MakeJSValueTreeWriter(); + winrt::Microsoft::ReactNative::WriteValue(rhsWriter, rhs.payload); + return winrt::Microsoft::ReactNative::TakeJSValue(writer).Equals(winrt::Microsoft::ReactNative::TakeJSValue(rhsWriter)); } bool operator!=(const ColorStruct &rhs) const { @@ -129,22 +137,23 @@ struct RenderableView : RenderableViewT { RenderableView() = default; #ifdef USE_FABRIC - RenderableView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args); - // IRenderableFabric - winrt::Microsoft::ReactNative::ComponentView SvgParent() { return Parent(); } + IRenderableFabric SvgParent() { return m_parent; } + void SvgParent(IRenderableFabric const &value) { m_parent = value; } + winrt::Microsoft::ReactNative::Color Fill() { return m_fill; } winrt::Microsoft::ReactNative::Color Stroke() { return m_stroke; } // ComponentView void MountChildComponentView( - const winrt::Microsoft::ReactNative::ComponentView &childComponentView, - uint32_t index) noexcept; + const winrt::Microsoft::ReactNative::ComponentView &view, + const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept; void UnmountChildComponentView( - const winrt::Microsoft::ReactNative::ComponentView &childComponentView, - uint32_t index) noexcept; + const winrt::Microsoft::ReactNative::ComponentView &view, + const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept; virtual void UpdateProps( + const winrt::Microsoft::ReactNative::ComponentView & /*view*/, const winrt::Microsoft::ReactNative::IComponentProps &props, const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept; @@ -154,6 +163,8 @@ struct RenderableView : RenderableViewT { const winrt::Microsoft::ReactNative::IComponentProps &oldProps, bool forceUpdate = true, bool invalidate = true) noexcept; + + const winrt::Windows::Foundation::Collections::IVector &Children() const noexcept; #else RenderableView(Microsoft::ReactNative::IReactContext const &context) : m_reactContext(context) {} @@ -225,7 +236,7 @@ struct RenderableView : RenderableViewT { private: #ifdef USE_FABRIC - winrt::Microsoft::ReactNative::ComponentView m_parent{nullptr}; + IRenderableFabric m_parent{nullptr}; winrt::Microsoft::ReactNative::Color m_fill{winrt::Microsoft::ReactNative::Color::Black()}; winrt::Microsoft::ReactNative::Color m_stroke{winrt::Microsoft::ReactNative::Color::Transparent()}; @@ -233,6 +244,7 @@ struct RenderableView : RenderableViewT { std::optional &propValue, winrt::Microsoft::ReactNative::Color const &fallbackColor, std::string propName); + winrt::Windows::Foundation::Collections::IVector m_children{ winrt::single_threaded_vector() }; #else xaml::FrameworkElement m_parent{nullptr}; Windows::UI::Color m_fill{Colors::Black()}; @@ -266,6 +278,42 @@ struct RenderableView : RenderableViewT { }; } // namespace winrt::RNSVG::implementation +#ifdef USE_FABRIC +template +void RegisterRenderableComponent(const winrt::hstring& name, const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + builder.AddViewComponent( + name, [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { + builder.SetComponentViewInitializer([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept { + auto userData = winrt::make_self(); + view.UserData(*userData); + }); + builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props) noexcept { + return winrt::make(props); + }); + builder.SetUpdatePropsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view, + const winrt::Microsoft::ReactNative::IComponentProps &newProps, + const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept { + auto userData = view.UserData().as(); + userData->UpdateProps(view, newProps, oldProps); + }); + builder.SetMountChildComponentViewHandler( + [](const winrt::Microsoft::ReactNative::ComponentView &view, + const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept { + auto userData = view.UserData().as(); + return userData->MountChildComponentView(view, args); + }); + builder.SetUnmountChildComponentViewHandler( + [](const winrt::Microsoft::ReactNative::ComponentView &view, + const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept { + auto userData = view.UserData().as(); + return userData->UnmountChildComponentView(view, args); + }); + }); +} +#endif + +#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct RenderableView : RenderableViewT {}; } // namespace winrt::RNSVG::factory_implementation +#endif \ No newline at end of file diff --git a/windows/RNSVG/SvgView.cpp b/windows/RNSVG/SvgView.cpp index c40cd4c79..468a7c0c6 100644 --- a/windows/RNSVG/SvgView.cpp +++ b/windows/RNSVG/SvgView.cpp @@ -20,6 +20,7 @@ #ifdef USE_FABRIC #include +#include #include #endif @@ -31,22 +32,19 @@ namespace winrt::RNSVG::implementation { #ifdef USE_FABRIC SvgViewProps::SvgViewProps( - const winrt::Microsoft::ReactNative::ViewProps &props) - : m_props(props) {} + const winrt::Microsoft::ReactNative::ViewProps &props) + : m_props(props) {} void SvgViewProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); + uint32_t hash, + winrt::hstring propName, + winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); } -SvgView::SvgView(const winrt::Microsoft::ReactNative::Composition::CreateCompositionComponentViewArgs &args) - : base_type(args), - m_reactContext(args.ReactContext()), - m_compContext( - args.as() - .CompositionContext()) {} +SvgView::SvgView(const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext) + : m_compContext(compContext) + {} winrt::Microsoft::ReactNative::Composition::Experimental::IVisual SvgView::CreateInternalVisual() { m_visual = m_compContext.CreateSpriteVisual(); @@ -55,52 +53,112 @@ winrt::Microsoft::ReactNative::Composition::Experimental::IVisual SvgView::Creat } void SvgView::MountChildComponentView( - const winrt::Microsoft::ReactNative::ComponentView &childComponentView, - uint32_t index) noexcept { - auto const &group{childComponentView.try_as()}; - - if (group) { - // Every SvgView has exactly one child - a Group that gets - // all of Svg's children piped through. - Group(group); + const winrt::Microsoft::ReactNative::ComponentView&, + const winrt::Microsoft::ReactNative::MountChildComponentViewArgs& args) noexcept +{ + auto childUserData = args.Child().UserData(); + childUserData.as().SvgParent(*this); + + if (childUserData) { + auto const &group{childUserData.try_as()}; + if (group) { + // Every SvgView has exactly one child - a Group that gets + // all of Svg's children piped through. + Group(group); + } } - - base_type::MountChildComponentView(childComponentView, index); } void SvgView::UnmountChildComponentView( - const winrt::Microsoft::ReactNative::ComponentView &childComponentView, - uint32_t index) noexcept { + const winrt::Microsoft::ReactNative::ComponentView&, + const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs& args) noexcept +{ + auto userData = args.Child().UserData(); + userData.as().SvgParent(nullptr); + if (Group()) { Group().Unload(); } Group(nullptr); - - base_type::UnmountChildComponentView(childComponentView, index); } void SvgView::OnThemeChanged() noexcept { Invalidate(); - base_type::OnThemeChanged(); } void SvgView::UpdateProps( - const winrt::Microsoft::ReactNative::IComponentProps &props, + const winrt::Microsoft::ReactNative::ComponentView& /*view*/, + const winrt::Microsoft::ReactNative::IComponentProps &newProps, const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept { - UpdateProperties(props, oldProps); + UpdateProperties(newProps, oldProps); } -void SvgView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - builder.AddViewComponent(L"RNSVGSvgView", [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { - builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props) noexcept { - return winrt::make(props); - }); - auto compBuilder = builder.as(); - compBuilder.SetCreateViewComponentView([](const winrt::Microsoft::ReactNative::Composition::CreateCompositionComponentViewArgs &args) noexcept { - args.Features(args.Features() & ~winrt::Microsoft::ReactNative::Composition::ComponentViewFeatures::Background); - return winrt::make(args); - }); +void SvgView::Initialize(const winrt::Microsoft::ReactNative::ComponentView &sender) noexcept { + auto view = sender.as(); + m_wkView = view; + + sender.as() + .CreateInternalVisualHandler([wkThis = get_weak()](const winrt::Microsoft::ReactNative::ComponentView &) { + return wkThis.get()->CreateInternalVisual(); + }); + + sender.LayoutMetricsChanged( + [wkThis = get_weak()]( + const winrt::IInspectable &, const winrt::Microsoft::ReactNative::LayoutMetricsChangedArgs &args) { + if (auto strongThis = wkThis.get()) { + strongThis->UpdateLayoutMetrics(args.NewLayoutMetrics(), args.OldLayoutMetrics()); + } }); + + view.ThemeChanged( + [wkThis = get_weak()](const winrt::IInspectable & /*sender*/, const winrt::IInspectable & /*args*/) { + if (auto strongThis = wkThis.get()) { + strongThis->OnThemeChanged(); + } + }); +} + +void SvgView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + builder.AddViewComponent(L"RNSVGSvgView", [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { + builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props) noexcept { + return winrt::make(props); + }); + auto compBuilder = + builder.as(); + + compBuilder.SetViewComponentViewInitializer( + [](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept { + auto userData = winrt::make_self( + view.as() + .CompositionContext()); + userData->Initialize(view); + view.UserData(*userData); + }); + + builder.SetUpdatePropsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view, + const winrt::Microsoft::ReactNative::IComponentProps &newProps, + const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept { + auto userData = view.UserData().as(); + userData->UpdateProps(view, newProps, oldProps); + }); + + builder.SetMountChildComponentViewHandler( + [](const winrt::Microsoft::ReactNative::ComponentView &view, + const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept { + auto userData = view.UserData().as(); + return userData->MountChildComponentView(view, args); + }); + + builder.SetUnmountChildComponentViewHandler( + [](const winrt::Microsoft::ReactNative::ComponentView &view, + const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept { + auto userData = view.UserData().as(); + return userData->UnmountChildComponentView(view, args); + }); + + }); + + // TODO how to remove featureflag Background? } void SvgView::UpdateProperties( @@ -153,12 +211,19 @@ void SvgView::UpdateLayoutMetrics( const LayoutMetrics &metrics, const LayoutMetrics &oldMetrics) { m_layoutMetrics = metrics; - base_type::UpdateLayoutMetrics(metrics, oldMetrics); if (metrics != oldMetrics) { Invalidate(); } } + +winrt::Microsoft::ReactNative::Composition::Theme SvgView::Theme() const noexcept { + if (auto view = m_wkView.get()) { + return view.Theme(); + } + return nullptr; +} + #else SvgView::SvgView(IReactContext const &context) : m_reactContext(context) { uint32_t creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT; diff --git a/windows/RNSVG/SvgView.h b/windows/RNSVG/SvgView.h index 43bb7138c..145af4a2d 100644 --- a/windows/RNSVG/SvgView.h +++ b/windows/RNSVG/SvgView.h @@ -5,6 +5,7 @@ #ifdef USE_FABRIC #include "SvgViewProps.g.h" +#include #include #include "NativeModules.h" #endif @@ -51,12 +52,14 @@ struct SvgViewProps : SvgViewPropsT { struct SvgView : SvgViewT { public: +#ifndef USE_FABRIC SvgView() = default; +#endif #ifdef USE_FABRIC - SvgView(const winrt::Microsoft::ReactNative::Composition::CreateCompositionComponentViewArgs &args); - - winrt::Microsoft::ReactNative::ComponentView SvgParent() { return Parent(); } + SvgView(const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext); + IRenderableFabric SvgParent() { return m_parent; } + void SvgParent(IRenderableFabric const &value) { m_parent = value; } winrt::Microsoft::ReactNative::Color CurrentColor() { return m_currentColor; } // IRenderableFabric @@ -72,20 +75,27 @@ struct SvgView : SvgViewT { // ComponentView void UpdateProps( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept; + const winrt::Microsoft::ReactNative::ComponentView & /*view*/, + const winrt::Microsoft::ReactNative::IComponentProps &newProps, + const winrt::Microsoft::ReactNative::IComponentProps & /*oldProps*/) noexcept; void UpdateLayoutMetrics( const winrt::Microsoft::ReactNative::LayoutMetrics &metrics, const winrt::Microsoft::ReactNative::LayoutMetrics &oldMetrics); - void MountChildComponentView( - const winrt::Microsoft::ReactNative::ComponentView &childComponentView, - uint32_t index) noexcept; + void MountChildComponentView( + const winrt::Microsoft::ReactNative::ComponentView& view, + const winrt::Microsoft::ReactNative::MountChildComponentViewArgs& args) noexcept; void UnmountChildComponentView( - const winrt::Microsoft::ReactNative::ComponentView &childComponentView, - uint32_t index) noexcept; + const winrt::Microsoft::ReactNative::ComponentView& view, + const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs& args) noexcept; + void OnThemeChanged() noexcept; + void Initialize(const winrt::Microsoft::ReactNative::ComponentView & /*view*/) noexcept; + static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; + + winrt::Microsoft::ReactNative::Composition::Theme Theme() const noexcept; + #else SvgView(winrt::Microsoft::ReactNative::IReactContext const &context); @@ -140,10 +150,12 @@ struct SvgView : SvgViewT { private: #ifdef USE_FABRIC + IRenderableFabric m_parent{nullptr}; winrt::Microsoft::ReactNative::Composition::Experimental::ISpriteVisual m_visual{nullptr}; winrt::Microsoft::ReactNative::Color m_currentColor{nullptr}; winrt::Microsoft::ReactNative::LayoutMetrics m_layoutMetrics{{0, 0, 0, 0}, 1.0}; winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext m_compContext{nullptr}; + winrt::weak_ref m_wkView; #else bool m_loaded{false}; xaml::FrameworkElement m_parent{nullptr}; @@ -180,6 +192,8 @@ struct SvgView : SvgViewT { }; } // namespace winrt::RNSVG::implementation +#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct SvgView : SvgViewT {}; } // namespace winrt::RNSVG::factory_implementation +#endif diff --git a/windows/RNSVG/SymbolView.cpp b/windows/RNSVG/SymbolView.cpp index 451474bce..af6c7877e 100644 --- a/windows/RNSVG/SymbolView.cpp +++ b/windows/RNSVG/SymbolView.cpp @@ -20,18 +20,8 @@ void SymbolProps::SetProp( winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); } -SymbolView::SymbolView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) : base_type(args) {} - void SymbolView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - builder.AddViewComponent( - L"RNSVGSymbol", [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { - builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props) noexcept { - return winrt::make(props); - }); - builder.SetCreateComponentView([](const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) noexcept { - return winrt::make(args); - }); - }); + RegisterRenderableComponent(L"RNSVGSymbol", builder); } void SymbolView::UpdateProperties( @@ -41,14 +31,12 @@ void SymbolView::UpdateProperties( bool invalidate) noexcept { auto symbolProps = props.try_as(); if (symbolProps) { - m_props = symbolProps; - - m_minX = m_props->minX; - m_minY = m_props->minY; - m_vbWidth = m_props->vbWidth; - m_vbHeight = m_props->vbHeight; - m_align = m_props->align; - m_meetOrSlice = m_props->meetOrSlice; + m_minX = symbolProps->minX; + m_minY = symbolProps->minY; + m_vbWidth = symbolProps->vbWidth; + m_vbHeight = symbolProps->vbHeight; + m_align = symbolProps->align; + m_meetOrSlice = symbolProps->meetOrSlice; } base_type::UpdateProperties(props, oldProps, forceUpdate, invalidate); diff --git a/windows/RNSVG/SymbolView.h b/windows/RNSVG/SymbolView.h index 768749693..07a4aa536 100644 --- a/windows/RNSVG/SymbolView.h +++ b/windows/RNSVG/SymbolView.h @@ -19,6 +19,7 @@ struct SymbolProps : SymbolPropsT { REACT_SVG_NODE_COMMON_PROPS; REACT_SVG_RENDERABLE_COMMON_PROPS; + REACT_SVG_GROUP_COMMON_PROPS; REACT_FIELD(minX) float minX{0.0f}; @@ -40,8 +41,6 @@ struct SymbolView : SymbolViewT { SymbolView() = default; #ifdef USE_FABRIC - SymbolView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args); - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; // IRenderableFabric @@ -72,14 +71,11 @@ struct SymbolView : SymbolViewT { float m_vbHeight{0.0f}; std::string m_align{""}; RNSVG::MeetOrSlice m_meetOrSlice{RNSVG::MeetOrSlice::Meet}; - -#ifdef USE_FABRIC - com_ptr m_props; -#endif - }; } // namespace winrt::RNSVG::implementation +#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct SymbolView : SymbolViewT {}; } // namespace winrt::RNSVG::factory_implementation +#endif diff --git a/windows/RNSVG/TSpanView.cpp b/windows/RNSVG/TSpanView.cpp index 91ca8354f..25601cf07 100644 --- a/windows/RNSVG/TSpanView.cpp +++ b/windows/RNSVG/TSpanView.cpp @@ -23,18 +23,8 @@ void TSpanProps::SetProp( winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); } -TSpanView::TSpanView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) : base_type(args) {} - void TSpanView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - builder.AddViewComponent( - L"RNSVGTSpan", [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { - builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props) noexcept { - return winrt::make(props); - }); - builder.SetCreateComponentView([](const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) noexcept { - return winrt::make(args); - }); - }); + RegisterRenderableComponent(L"RNSVGTSpan", builder); } void TSpanView::UpdateProperties( @@ -44,8 +34,7 @@ void TSpanView::UpdateProperties( bool invalidate) noexcept { auto tspanProps = props.try_as(); if (tspanProps) { - m_props = tspanProps; - m_content = m_props->content; + m_content = tspanProps->content; } base_type::UpdateProperties(props, oldProps, forceUpdate, invalidate); diff --git a/windows/RNSVG/TSpanView.h b/windows/RNSVG/TSpanView.h index c7f15a8d9..eb4f0dbb3 100644 --- a/windows/RNSVG/TSpanView.h +++ b/windows/RNSVG/TSpanView.h @@ -32,8 +32,6 @@ struct TSpanView : TSpanViewT { TSpanView() = default; #ifdef USE_FABRIC - TSpanView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args); - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; // IRenderableFabric @@ -52,14 +50,12 @@ struct TSpanView : TSpanViewT { private: std::string m_content; - -#ifdef USE_FABRIC - com_ptr m_props; -#endif - }; } // namespace winrt::RNSVG::implementation +#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct TSpanView : TSpanViewT {}; } // namespace winrt::RNSVG::factory_implementation +#endif + diff --git a/windows/RNSVG/TextView.cpp b/windows/RNSVG/TextView.cpp index 6e65211c1..bbfdd397e 100644 --- a/windows/RNSVG/TextView.cpp +++ b/windows/RNSVG/TextView.cpp @@ -21,18 +21,8 @@ void SvgTextCommonProps::SetProp( winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); } -TextView::TextView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) : base_type(args) {} - void TextView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - builder.AddViewComponent( - L"RNSVGText", [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { - builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props) noexcept { - return winrt::make(props); - }); - builder.SetCreateComponentView([](const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) noexcept { - return winrt::make(args); - }); - }); + RegisterRenderableComponent(L"RNSVGText", builder); } void TextView::UpdateProperties( @@ -42,8 +32,6 @@ void TextView::UpdateProperties( bool invalidate) noexcept { auto textProps = props.try_as(); if (textProps) { - m_props = textProps; - if (textProps->x != std::nullopt) { m_x.Clear(); diff --git a/windows/RNSVG/TextView.h b/windows/RNSVG/TextView.h index 4865857bc..f8cd07fd3 100644 --- a/windows/RNSVG/TextView.h +++ b/windows/RNSVG/TextView.h @@ -33,6 +33,7 @@ struct SvgTextCommonProps : SvgTextCommonPropsT> dx; std::optional> dy; @@ -53,8 +54,6 @@ struct TextView : TextViewT { TextView() = default; #ifdef USE_FABRIC - TextView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args); - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; // IRenderableFabric @@ -83,13 +82,11 @@ struct TextView : TextViewT { Windows::Foundation::Collections::IVector m_dx{winrt::single_threaded_vector()}; Windows::Foundation::Collections::IVector m_dy{winrt::single_threaded_vector()}; Windows::Foundation::Collections::IVector m_rotate{winrt::single_threaded_vector()}; - -#ifdef USE_FABRIC - com_ptr m_props; -#endif - }; } // namespace winrt::RNSVG::implementation + +#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct TextView : TextViewT {}; } // namespace winrt::RNSVG::factory_implementation +#endif diff --git a/windows/RNSVG/UseView.cpp b/windows/RNSVG/UseView.cpp index 04de3e6e6..879e53acd 100644 --- a/windows/RNSVG/UseView.cpp +++ b/windows/RNSVG/UseView.cpp @@ -21,18 +21,8 @@ void UseProps::SetProp( winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); } -UseView::UseView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) : base_type(args) {} - void UseView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - builder.AddViewComponent( - L"RNSVGUse", [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { - builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props) noexcept { - return winrt::make(props); - }); - builder.SetCreateComponentView([](const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args) noexcept { - return winrt::make(args); - }); - }); + RegisterRenderableComponent(L"RNSVGUse", builder); } void UseView::UpdateProperties( @@ -42,13 +32,11 @@ void UseView::UpdateProperties( bool invalidate) noexcept { auto useProps = props.try_as(); if (useProps) { - m_props = useProps; - - m_href = winrt::to_hstring(m_props->href); - m_x = m_props->x; - m_y = m_props->y; - m_width = m_props->width; - m_height = m_props->height; + m_href = winrt::to_hstring(useProps->href); + m_x = useProps->x; + m_y = useProps->y; + m_width = useProps->width; + m_height = useProps->height; } base_type::UpdateProperties(props, oldProps, forceUpdate, invalidate); diff --git a/windows/RNSVG/UseView.h b/windows/RNSVG/UseView.h index 7aa78f25e..0cc3a7726 100644 --- a/windows/RNSVG/UseView.h +++ b/windows/RNSVG/UseView.h @@ -38,8 +38,6 @@ struct UseView : UseViewT { UseView() = default; #ifdef USE_FABRIC - UseView(const winrt::Microsoft::ReactNative::CreateComponentViewArgs &args); - // IRenderableFabric void UpdateProperties( const winrt::Microsoft::ReactNative::IComponentProps &props, @@ -63,14 +61,12 @@ struct UseView : UseViewT { RNSVG::SVGLength m_width{}; RNSVG::SVGLength m_height{}; -#ifdef USE_FABRIC - com_ptr m_props; -#endif - RNSVG::IRenderable GetRenderableTemplate(); }; } // namespace winrt::RNSVG::implementation +#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct UseView : UseViewT {}; } // namespace winrt::RNSVG::factory_implementation +#endif diff --git a/windows/RNSVG/packages.lock.json b/windows/RNSVG/packages.lock.json index 7bb350218..0c3b2eabf 100644 --- a/windows/RNSVG/packages.lock.json +++ b/windows/RNSVG/packages.lock.json @@ -2,17 +2,14 @@ "version": 1, "dependencies": { "native,Version=v0.0": { - "boost": { - "type": "Direct", - "requested": "[1.76.0, )", - "resolved": "1.76.0", - "contentHash": "p+w3YvNdXL8Cu9Fzrmexssu0tZbWxuf6ywsQqHjDlKFE5ojXHof1HIyMC3zDLfLnh80dIeFcEUAuR2Asg/XHRA==" - }, - "Microsoft.VCRTForwarders.140": { + "Microsoft.UI.Xaml": { "type": "Direct", - "requested": "[1.0.2-rc, )", - "resolved": "1.0.2-rc", - "contentHash": "/r+sjtEeCIGyDhobIZ5hSmYhC/dSyGZxf1SxYJpElUhB0LMCktOMFs9gXrauXypIFECpVynNyVjAmJt6hjJ5oQ==" + "requested": "[2.8.0, )", + "resolved": "2.8.0", + "contentHash": "vxdHxTr63s5KVtNddMFpgvjBjUH50z7seq/5jLWmmSuf8poxg+sXrywkofUdE8ZstbpO9y3FL/IXXUcPYbeesA==", + "dependencies": { + "Microsoft.Web.WebView2": "1.0.1264.42" + } }, "Microsoft.Windows.CppWinRT": { "type": "Direct", @@ -20,29 +17,25 @@ "resolved": "2.0.230706.1", "contentHash": "l0D7oCw/5X+xIKHqZTi62TtV+1qeSz7KVluNFdrJ9hXsst4ghvqQ/Yhura7JqRdZWBXAuDS0G0KwALptdoxweQ==" }, - "Microsoft.WindowsAppSDK": { - "type": "Direct", - "requested": "[1.5.240227000, )", - "resolved": "1.5.240227000", - "contentHash": "6rESOsREi8534J7IDpNfFYPvxQaSleXKt4A7ZYPeQyckNMQ0o1W0jZ420bJbEMz9Cw/S/8IbpPftLLZ9w/GTCQ==", - "dependencies": { - "Microsoft.Windows.SDK.BuildTools": "10.0.22621.756" - } + "boost": { + "type": "Transitive", + "resolved": "1.83.0", + "contentHash": "cy53VNMzysEMvhBixDe8ujPk67Fcj3v6FPHQnH91NYJNLHpc6jxa2xq9ruCaaJjE4M3YrGSHDi4uUSTGBWw6EQ==" }, "Microsoft.JavaScript.Hermes": { "type": "Transitive", - "resolved": "0.1.21", - "contentHash": "5njCh+3eXTLOv7+8nOnp6nJ5C0r6it5ze54c0nuWleeDptuK8t3dEDB79XTU4D5DKNvAPlqJpgXRDOak5nYIug==" + "resolved": "0.1.23", + "contentHash": "cA9t1GjY4Yo0JD1AfA//e1lOwk48hLANfuX6GXrikmEBNZVr2TIX5ONJt5tqCnpZyLz6xGiPDgTfFNKbSfb21g==" }, - "Microsoft.Windows.SDK.BuildTools": { + "Microsoft.Web.WebView2": { "type": "Transitive", - "resolved": "10.0.22621.756", - "contentHash": "7ZL2sFSioYm1Ry067Kw1hg0SCcW5kuVezC2SwjGbcPE61Nn+gTbH86T73G3LcEOVj0S3IZzNuE/29gZvOLS7VA==" + "resolved": "1.0.1264.42", + "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" }, "common": { "type": "Project", "dependencies": { - "boost": "[1.76.0, )" + "boost": "[1.83.0, )" } }, "fmt": { @@ -52,7 +45,7 @@ "type": "Project", "dependencies": { "Fmt": "[1.0.0, )", - "boost": "[1.76.0, )" + "boost": "[1.83.0, )" } }, "microsoft.reactnative": { @@ -60,19 +53,68 @@ "dependencies": { "Common": "[1.0.0, )", "Folly": "[1.0.0, )", - "Microsoft.JavaScript.Hermes": "[0.1.21, )", - "Microsoft.WindowsAppSDK": "[1.5.240227000, )", + "Microsoft.JavaScript.Hermes": "[0.1.23, )", + "Microsoft.UI.Xaml": "[2.8.0, )", "ReactCommon": "[1.0.0, )", - "boost": "[1.76.0, )" + "boost": "[1.83.0, )" } }, "reactcommon": { "type": "Project", "dependencies": { "Folly": "[1.0.0, )", - "boost": "[1.76.0, )" + "boost": "[1.83.0, )" } } + }, + "native,Version=v0.0/win10-arm": { + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.1264.42", + "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" + } + }, + "native,Version=v0.0/win10-arm-aot": { + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.1264.42", + "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" + } + }, + "native,Version=v0.0/win10-arm64-aot": { + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.1264.42", + "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" + } + }, + "native,Version=v0.0/win10-x64": { + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.1264.42", + "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" + } + }, + "native,Version=v0.0/win10-x64-aot": { + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.1264.42", + "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" + } + }, + "native,Version=v0.0/win10-x86": { + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.1264.42", + "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" + } + }, + "native,Version=v0.0/win10-x86-aot": { + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.1264.42", + "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" + } } } } \ No newline at end of file From 22bea7b8d6223ae94c1c328b822c4b59f758f597 Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Thu, 31 Oct 2024 15:48:29 -0700 Subject: [PATCH 02/13] Use D2D svg rendering --- apps/common/noNavigationApp.tsx | 184 +++++++++++ src/lib/extract/extractProps.windows.ts | 5 + windows/RNSVG/D2DHelpers.h | 6 +- windows/RNSVG/Fabric.idl | 38 +-- windows/RNSVG/Fabric/BrushView.cpp | 30 ++ windows/RNSVG/Fabric/BrushView.h | 33 ++ windows/RNSVG/Fabric/CircleView.cpp | 38 +++ windows/RNSVG/Fabric/CircleView.h | 39 +++ windows/RNSVG/Fabric/ClipPathView.cpp | 29 ++ windows/RNSVG/Fabric/ClipPathView.h | 30 ++ windows/RNSVG/Fabric/DefsView.cpp | 28 ++ windows/RNSVG/Fabric/DefsView.h | 31 ++ windows/RNSVG/Fabric/EllipseView.cpp | 37 +++ windows/RNSVG/Fabric/EllipseView.h | 40 +++ windows/RNSVG/Fabric/GroupView.cpp | 36 ++ windows/RNSVG/Fabric/GroupView.h | 93 ++++++ windows/RNSVG/Fabric/ImageView.cpp | 39 +++ windows/RNSVG/Fabric/ImageView.h | 80 +++++ windows/RNSVG/Fabric/LineView.cpp | 37 +++ windows/RNSVG/Fabric/LineView.h | 40 +++ windows/RNSVG/Fabric/LinearGradientView.cpp | 98 ++++++ windows/RNSVG/Fabric/LinearGradientView.h | 61 ++++ windows/RNSVG/Fabric/MarkerView.cpp | 32 ++ windows/RNSVG/Fabric/MarkerView.h | 55 +++ windows/RNSVG/Fabric/MaskView.cpp | 33 ++ windows/RNSVG/Fabric/MaskView.h | 43 +++ windows/RNSVG/Fabric/PathView.cpp | 37 +++ windows/RNSVG/Fabric/PathView.h | 34 ++ windows/RNSVG/Fabric/PatternView.cpp | 34 ++ windows/RNSVG/Fabric/PatternView.h | 60 ++++ windows/RNSVG/Fabric/RadialGradientView.cpp | 122 +++++++ windows/RNSVG/Fabric/RadialGradientView.h | 64 ++++ windows/RNSVG/Fabric/RectView.cpp | 50 +++ windows/RNSVG/Fabric/RectView.h | 43 +++ windows/RNSVG/Fabric/RenderableView.cpp | 306 +++++++++++++++++ windows/RNSVG/Fabric/RenderableView.h | 233 +++++++++++++ windows/RNSVG/Fabric/SvgStrings.h | 83 +++++ windows/RNSVG/Fabric/SvgView.cpp | 349 ++++++++++++++++++++ windows/RNSVG/Fabric/SvgView.h | 101 ++++++ windows/RNSVG/Fabric/SymbolView.cpp | 32 ++ windows/RNSVG/Fabric/SymbolView.h | 45 +++ windows/RNSVG/Fabric/TSpanView.cpp | 33 ++ windows/RNSVG/Fabric/TSpanView.h | 36 ++ windows/RNSVG/Fabric/TextView.cpp | 33 ++ windows/RNSVG/Fabric/TextView.h | 57 ++++ windows/RNSVG/Fabric/UseView.cpp | 42 +++ windows/RNSVG/Fabric/UseView.h | 41 +++ windows/RNSVG/RNSVG.vcxproj | 49 ++- windows/RNSVG/ReactPackageProvider.cpp | 38 +-- windows/RNSVG/SVGLength.cpp | 24 ++ windows/RNSVG/Utils.h | 12 - windows/RNSVG/packages.lock.json | 86 ++--- 52 files changed, 3118 insertions(+), 141 deletions(-) create mode 100644 windows/RNSVG/Fabric/BrushView.cpp create mode 100644 windows/RNSVG/Fabric/BrushView.h create mode 100644 windows/RNSVG/Fabric/CircleView.cpp create mode 100644 windows/RNSVG/Fabric/CircleView.h create mode 100644 windows/RNSVG/Fabric/ClipPathView.cpp create mode 100644 windows/RNSVG/Fabric/ClipPathView.h create mode 100644 windows/RNSVG/Fabric/DefsView.cpp create mode 100644 windows/RNSVG/Fabric/DefsView.h create mode 100644 windows/RNSVG/Fabric/EllipseView.cpp create mode 100644 windows/RNSVG/Fabric/EllipseView.h create mode 100644 windows/RNSVG/Fabric/GroupView.cpp create mode 100644 windows/RNSVG/Fabric/GroupView.h create mode 100644 windows/RNSVG/Fabric/ImageView.cpp create mode 100644 windows/RNSVG/Fabric/ImageView.h create mode 100644 windows/RNSVG/Fabric/LineView.cpp create mode 100644 windows/RNSVG/Fabric/LineView.h create mode 100644 windows/RNSVG/Fabric/LinearGradientView.cpp create mode 100644 windows/RNSVG/Fabric/LinearGradientView.h create mode 100644 windows/RNSVG/Fabric/MarkerView.cpp create mode 100644 windows/RNSVG/Fabric/MarkerView.h create mode 100644 windows/RNSVG/Fabric/MaskView.cpp create mode 100644 windows/RNSVG/Fabric/MaskView.h create mode 100644 windows/RNSVG/Fabric/PathView.cpp create mode 100644 windows/RNSVG/Fabric/PathView.h create mode 100644 windows/RNSVG/Fabric/PatternView.cpp create mode 100644 windows/RNSVG/Fabric/PatternView.h create mode 100644 windows/RNSVG/Fabric/RadialGradientView.cpp create mode 100644 windows/RNSVG/Fabric/RadialGradientView.h create mode 100644 windows/RNSVG/Fabric/RectView.cpp create mode 100644 windows/RNSVG/Fabric/RectView.h create mode 100644 windows/RNSVG/Fabric/RenderableView.cpp create mode 100644 windows/RNSVG/Fabric/RenderableView.h create mode 100644 windows/RNSVG/Fabric/SvgStrings.h create mode 100644 windows/RNSVG/Fabric/SvgView.cpp create mode 100644 windows/RNSVG/Fabric/SvgView.h create mode 100644 windows/RNSVG/Fabric/SymbolView.cpp create mode 100644 windows/RNSVG/Fabric/SymbolView.h create mode 100644 windows/RNSVG/Fabric/TSpanView.cpp create mode 100644 windows/RNSVG/Fabric/TSpanView.h create mode 100644 windows/RNSVG/Fabric/TextView.cpp create mode 100644 windows/RNSVG/Fabric/TextView.h create mode 100644 windows/RNSVG/Fabric/UseView.cpp create mode 100644 windows/RNSVG/Fabric/UseView.h diff --git a/apps/common/noNavigationApp.tsx b/apps/common/noNavigationApp.tsx index 2db83aa2e..acf133074 100644 --- a/apps/common/noNavigationApp.tsx +++ b/apps/common/noNavigationApp.tsx @@ -41,15 +41,199 @@ const ExampleBlock = ({example, index}: {example: Example; index: number}) => { import { Svg, Defs, + SvgXml, LinearGradient, + RadialGradient, Stop, + Rect, Text as TextS, G, Path, Circle, + Use, } from 'react-native-svg'; +import {useState, useEffect} from 'react'; + +//const fill = 'purple'; export default function App() { + /* + const [fill, setFill] = useState('yellow'); + + useEffect(() => { + let mounted = true; + + const timer = setTimeout(() => { + if (mounted) { + setFill('green'); + } + }, 4000); + + return () => { + mounted = false; + clearTimeout(timer); + }; + }, []); + + return ( + + + + + + ); +*/ + /* + return ( + + + + + + + + ); + */ + /* + return ( + + + + ); +*/ + /* + const svgXml = ` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + `; + +return ( + ); +*/ + /* +return ( + + + + + + + +) +*/ + /* +return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); + */ + /* +return ( + +); +*/ + /* + return ( + + ) + */ + /* +return ( + + + +) +*/ /* return ( diff --git a/src/lib/extract/extractProps.windows.ts b/src/lib/extract/extractProps.windows.ts index 2a949a8e3..558295206 100644 --- a/src/lib/extract/extractProps.windows.ts +++ b/src/lib/extract/extractProps.windows.ts @@ -6,6 +6,7 @@ import extractOpacity from './extractOpacity'; import { idPattern } from '../util'; import type { ClipProps, + ColorProps, extractedProps, FillProps, NumberProp, @@ -53,6 +54,7 @@ export default function extractProps( ResponderProps & StrokeProps & FillProps & + ColorProps & ClipProps, ref: object ) { @@ -75,6 +77,9 @@ export default function extractProps( extractResponder(extracted, props, ref); extractFill(extracted, props, inherited); extractStroke(extracted, props, inherited); + if (props.color) { + extracted.color = props.color; + } if (inherited.length) { extracted.propList = inherited; diff --git a/windows/RNSVG/D2DHelpers.h b/windows/RNSVG/D2DHelpers.h index 0cf56e8f6..48cc11941 100644 --- a/windows/RNSVG/D2DHelpers.h +++ b/windows/RNSVG/D2DHelpers.h @@ -130,12 +130,9 @@ struct D2DHelpers { return transform; } +#ifndef USE_FABRIC static DWRITE_FONT_WEIGHT FontWeightFrom( -#ifdef USE_FABRIC - IRenderableFabric const &parent, -#else xaml::FrameworkElement const &parent, -#endif hstring const &weight) { if (weight == L"normal") { return DWRITE_FONT_WEIGHT_NORMAL; @@ -158,6 +155,7 @@ struct D2DHelpers { return D2DHelpers::GetClosestFontWeight(std::stof(weight.c_str(), nullptr)); } +#endif // https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight#meaning_of_relative_weights static DWRITE_FONT_WEIGHT Bolder(DWRITE_FONT_WEIGHT weight) { diff --git a/windows/RNSVG/Fabric.idl b/windows/RNSVG/Fabric.idl index f7f15a7a5..eaa4fab6d 100644 --- a/windows/RNSVG/Fabric.idl +++ b/windows/RNSVG/Fabric.idl @@ -2,30 +2,16 @@ import "Views.idl"; namespace RNSVG { - [experimental] - interface IRenderableFabric - { - IRenderableFabric SvgParent; - - void UpdateProperties(Microsoft.ReactNative.IComponentProps props, Microsoft.ReactNative.IComponentProps oldProps, Boolean forceUpdate, Boolean invalidate); - }; - [experimental] [default_interface] - runtimeclass SvgView : IRenderable, IRenderableFabric, ISvgView + runtimeclass SvgView { - GroupView Group; - Microsoft.ReactNative.Color CurrentColor{ get; }; - Microsoft.ReactNative.Composition.Theme Theme { get; }; }; [experimental] [default_interface] - unsealed runtimeclass RenderableView : IRenderable, IRenderableFabric, IRenderableView + unsealed runtimeclass RenderableView { - SvgView SvgRoot{ get; }; - Microsoft.ReactNative.Color Fill{ get; }; - Microsoft.ReactNative.Color Stroke{ get; }; }; [experimental] @@ -72,19 +58,19 @@ namespace RNSVG [experimental] [default_interface] - unsealed runtimeclass GroupView : RenderableView, IGroupView + unsealed runtimeclass GroupView : RenderableView { }; [experimental] [default_interface] - unsealed runtimeclass TextView : GroupView, ITextView + unsealed runtimeclass TextView : GroupView { }; [experimental] [default_interface] - runtimeclass TSpanView : TextView, ITSpanView + runtimeclass TSpanView : TextView { }; @@ -96,7 +82,7 @@ namespace RNSVG [experimental] [default_interface] - runtimeclass SymbolView : GroupView, ISymbolView + runtimeclass SymbolView : GroupView { }; @@ -120,25 +106,19 @@ namespace RNSVG [experimental] [default_interface] - unsealed runtimeclass BrushView : GroupView, IBrushView - { - }; - - [experimental] - [default_interface] - runtimeclass LinearGradientView : BrushView + runtimeclass LinearGradientView : GroupView { }; [experimental] [default_interface] - runtimeclass RadialGradientView : BrushView + runtimeclass RadialGradientView : GroupView { }; [experimental] [default_interface] - runtimeclass PatternView : BrushView + runtimeclass PatternView : GroupView { }; } \ No newline at end of file diff --git a/windows/RNSVG/Fabric/BrushView.cpp b/windows/RNSVG/Fabric/BrushView.cpp new file mode 100644 index 000000000..903b161ca --- /dev/null +++ b/windows/RNSVG/Fabric/BrushView.cpp @@ -0,0 +1,30 @@ +#include "pch.h" +#include "BrushView.h" +#if __has_include("BrushView.g.cpp") +#include "BrushView.g.cpp" +#endif + +#include "D2DHelpers.h" + +namespace winrt::RNSVG::implementation { + +void BrushView::SaveDefinition() { + if (auto const &root{SvgRoot()}) { + CreateBrush(); + root.Brushes().Insert(Id(), *this); + } +} + +void BrushView::SetBounds(Rect const &rect) { + m_bounds = D2DHelpers::AsD2DRect(rect); + UpdateBounds(); +} + +void BrushView::Unload() { + if (m_brush) { + m_brush = nullptr; + } + + __super::Unload(); +} +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/BrushView.h b/windows/RNSVG/Fabric/BrushView.h new file mode 100644 index 000000000..6c83ebdea --- /dev/null +++ b/windows/RNSVG/Fabric/BrushView.h @@ -0,0 +1,33 @@ +#pragma once +#include "BrushView.g.h" +#include "GroupView.h" +#include "D2DBrush.h" + +namespace winrt::RNSVG::implementation { +struct BrushView : BrushViewT { + public: + BrushView() = default; + + // IRenderable + void SaveDefinition(); + + RNSVG::D2DBrush Brush() { return m_brush; } + virtual void CreateBrush() {} + virtual void Unload(); + void SetBounds(Windows::Foundation::Rect const &rect); + + protected: + RNSVG::D2DBrush m_brush; + D2D1_RECT_F m_bounds; + D2D1::Matrix3x2F m_transform{D2D1::Matrix3x2F::Identity()}; + + virtual void UpdateBounds() {} +}; +} // namespace winrt::RNSVG::implementation + +#ifndef USE_FABRIC +namespace winrt::RNSVG::factory_implementation { +struct BrushView : BrushViewT {}; +} // namespace winrt::RNSVG::factory_implementation +#endif + diff --git a/windows/RNSVG/Fabric/CircleView.cpp b/windows/RNSVG/Fabric/CircleView.cpp new file mode 100644 index 000000000..aa2c0e8a6 --- /dev/null +++ b/windows/RNSVG/Fabric/CircleView.cpp @@ -0,0 +1,38 @@ +#include "pch.h" +#include "CircleView.h" +#if __has_include("CircleView.g.cpp") +#include "CircleView.g.cpp" +#endif + +#include "JSValueXaml.h" + +using namespace winrt; +using namespace Microsoft::ReactNative; + +namespace winrt::RNSVG::implementation { + +CircleProps::CircleProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} + +void CircleProps::SetProp( + uint32_t hash, + winrt::hstring propName, + winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); +} + +const wchar_t *CircleView::GetSvgElementName() noexcept { + return L"circle"; +} + +void CircleView::OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement &svgElement) noexcept { + auto props = m_props.as(); + svgElement.SetAttributeValue(SvgStrings::cxAttributeName, props->cx); + svgElement.SetAttributeValue(SvgStrings::cyAttributeName, props->cy); + svgElement.SetAttributeValue(SvgStrings::rAttributeName, props->r); +} + +void CircleView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + RegisterRenderableComponent(L"RNSVGCircle", builder); +} + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/CircleView.h b/windows/RNSVG/Fabric/CircleView.h new file mode 100644 index 000000000..3e52650d3 --- /dev/null +++ b/windows/RNSVG/Fabric/CircleView.h @@ -0,0 +1,39 @@ +#pragma once + +#ifdef USE_FABRIC +#include "CircleProps.g.h" +#endif + +#include "CircleView.g.h" +#include "RenderableView.h" + +namespace winrt::RNSVG::implementation { + +REACT_STRUCT(CircleProps) +struct CircleProps : CirclePropsT { + CircleProps(const winrt::Microsoft::ReactNative::ViewProps &props); + + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept + override; + + REACT_SVG_NODE_COMMON_PROPS; + REACT_SVG_RENDERABLE_COMMON_PROPS; + + REACT_FIELD(r) + D2D1_SVG_LENGTH r{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; + REACT_FIELD(cx) + D2D1_SVG_LENGTH cx{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; + REACT_FIELD(cy) + D2D1_SVG_LENGTH cy{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; +}; + +struct CircleView : CircleViewT { + public: + CircleView() = default; + + const wchar_t *GetSvgElementName() noexcept override; + void OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement & /*element*/) noexcept override; + + static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; +}; +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/ClipPathView.cpp b/windows/RNSVG/Fabric/ClipPathView.cpp new file mode 100644 index 000000000..23ee6337d --- /dev/null +++ b/windows/RNSVG/Fabric/ClipPathView.cpp @@ -0,0 +1,29 @@ +#include "pch.h" +#include "ClipPathView.h" +#if __has_include("ClipPathView.g.cpp") +#include "ClipPathView.g.cpp" +#endif + +using namespace winrt; + +namespace winrt::RNSVG::implementation { +#ifdef USE_FABRIC +ClipPathProps::ClipPathProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} + +void ClipPathProps::SetProp( + uint32_t hash, + winrt::hstring propName, + winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); +} + + +const wchar_t *ClipPathView::GetSvgElementName() noexcept { + return L"clipPath"; +} + +void ClipPathView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + RegisterRenderableComponent(L"RNSVGClipPath", builder); +} +#endif +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/ClipPathView.h b/windows/RNSVG/Fabric/ClipPathView.h new file mode 100644 index 000000000..dd2e097d9 --- /dev/null +++ b/windows/RNSVG/Fabric/ClipPathView.h @@ -0,0 +1,30 @@ +#pragma once + +#include "ClipPathProps.g.h" +#include "ClipPathView.g.h" +#include "GroupView.h" + +namespace winrt::RNSVG::implementation { + +REACT_STRUCT(ClipPathProps) +struct ClipPathProps : ClipPathPropsT { + ClipPathProps(const winrt::Microsoft::ReactNative::ViewProps &props); + + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept + override; + + REACT_SVG_NODE_COMMON_PROPS; + REACT_SVG_RENDERABLE_COMMON_PROPS; + REACT_SVG_GROUP_COMMON_PROPS; +}; + +struct ClipPathView : ClipPathViewT { + public: + ClipPathView() = default; + + static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; + + const wchar_t *GetSvgElementName() noexcept override; +}; + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/DefsView.cpp b/windows/RNSVG/Fabric/DefsView.cpp new file mode 100644 index 000000000..66fabb43c --- /dev/null +++ b/windows/RNSVG/Fabric/DefsView.cpp @@ -0,0 +1,28 @@ +#include "pch.h" +#include "DefsView.h" +#if __has_include("DefsView.g.cpp") +#include "DefsView.g.cpp" +#endif + +using namespace winrt; + +namespace winrt::RNSVG::implementation { + +DefsProps::DefsProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} + +void DefsProps::SetProp( + uint32_t hash, + winrt::hstring propName, + winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); +} + +const wchar_t *DefsView::GetSvgElementName() noexcept { + return L"defs"; +} + +void DefsView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + RegisterRenderableComponent(L"RNSVGDefs", builder); +} + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/DefsView.h b/windows/RNSVG/Fabric/DefsView.h new file mode 100644 index 000000000..83454df8c --- /dev/null +++ b/windows/RNSVG/Fabric/DefsView.h @@ -0,0 +1,31 @@ +#pragma once + +#include "DefsProps.g.h" +#include "DefsView.g.h" +#include "GroupView.h" + +namespace winrt::RNSVG::implementation { + +REACT_STRUCT(DefsProps) +struct DefsProps : DefsPropsT { + DefsProps(const winrt::Microsoft::ReactNative::ViewProps &props); + + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept + override; + + REACT_SVG_NODE_COMMON_PROPS; + REACT_SVG_RENDERABLE_COMMON_PROPS; + REACT_SVG_GROUP_COMMON_PROPS; + +}; + +struct DefsView : DefsViewT { + public: + DefsView() = default; + + const wchar_t *GetSvgElementName() noexcept override; + + static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; + +}; +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/EllipseView.cpp b/windows/RNSVG/Fabric/EllipseView.cpp new file mode 100644 index 000000000..13820afb2 --- /dev/null +++ b/windows/RNSVG/Fabric/EllipseView.cpp @@ -0,0 +1,37 @@ +#include "pch.h" +#include "EllipseView.h" +#if __has_include("EllipseView.g.cpp") +#include "EllipseView.g.cpp" +#endif + +using namespace winrt; +using namespace Microsoft::ReactNative; + +namespace winrt::RNSVG::implementation { + +EllipseProps::EllipseProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} + +void EllipseProps::SetProp( + uint32_t hash, + winrt::hstring propName, + winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); +} + +const wchar_t *EllipseView::GetSvgElementName() noexcept { + return L"ellipse"; +} + +void EllipseView::OnRender(ID2D1SvgDocument & /* document*/, ID2D1SvgElement &svgElement) noexcept { + auto props = m_props.as(); + svgElement.SetAttributeValue(SvgStrings::cxAttributeName, props->cx); + svgElement.SetAttributeValue(SvgStrings::cyAttributeName, props->cy); + svgElement.SetAttributeValue(SvgStrings::rxAttributeName, props->rx); + svgElement.SetAttributeValue(SvgStrings::ryAttributeName, props->ry); +} + +void EllipseView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + RegisterRenderableComponent(L"RNSVGEllipse", builder); +} + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/EllipseView.h b/windows/RNSVG/Fabric/EllipseView.h new file mode 100644 index 000000000..9b7039b75 --- /dev/null +++ b/windows/RNSVG/Fabric/EllipseView.h @@ -0,0 +1,40 @@ +#pragma once + +#include "EllipseProps.g.h" +#include "EllipseView.g.h" +#include "RenderableView.h" + +namespace winrt::RNSVG::implementation { + +REACT_STRUCT(EllipseProps) +struct EllipseProps : EllipsePropsT { + EllipseProps(const winrt::Microsoft::ReactNative::ViewProps &props); + + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept + override; + + REACT_SVG_NODE_COMMON_PROPS; + REACT_SVG_RENDERABLE_COMMON_PROPS; + + REACT_FIELD(cx) + D2D1_SVG_LENGTH cx{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; + REACT_FIELD(cy) + D2D1_SVG_LENGTH cy{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; + REACT_FIELD(rx) + D2D1_SVG_LENGTH rx{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; + REACT_FIELD(ry) + D2D1_SVG_LENGTH ry{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; +}; + +struct EllipseView : EllipseViewT { + public: + EllipseView() = default; + + const wchar_t *GetSvgElementName() noexcept override; + void OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement & /*element*/) noexcept override; + + static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; +}; + +} // namespace winrt::RNSVG::implementation + diff --git a/windows/RNSVG/Fabric/GroupView.cpp b/windows/RNSVG/Fabric/GroupView.cpp new file mode 100644 index 000000000..eabb6734f --- /dev/null +++ b/windows/RNSVG/Fabric/GroupView.cpp @@ -0,0 +1,36 @@ +#include "pch.h" + +#include "JSValueXaml.h" + +#include "GroupView.h" +#if __has_include("GroupView.g.cpp") +#include "GroupView.g.cpp" +#endif + +#include "../SVGLength.h" + +using namespace winrt; +using namespace Microsoft::ReactNative; + +namespace winrt::RNSVG::implementation { +SvgGroupCommonProps::SvgGroupCommonProps( + const winrt::Microsoft::ReactNative::ViewProps &props) + : base_type(props) {} + +void SvgGroupCommonProps::SetProp( + uint32_t hash, + winrt::hstring propName, + winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); +} + +const wchar_t* GroupView::GetSvgElementName() noexcept +{ + return L"g"; +} + +void GroupView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + RegisterRenderableComponent(L"RNSVGGroup", builder); +} + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/GroupView.h b/windows/RNSVG/Fabric/GroupView.h new file mode 100644 index 000000000..b4d94d97b --- /dev/null +++ b/windows/RNSVG/Fabric/GroupView.h @@ -0,0 +1,93 @@ +#pragma once +#include "GroupView.g.h" +#include "RenderableView.h" + +#ifdef USE_FABRIC +#include "SvgGroupCommonProps.g.h" +#endif + +namespace winrt::RNSVG::implementation { +#ifdef USE_FABRIC +REACT_STRUCT(FontObject) +struct FontObject { + REACT_FIELD(fontStyle) + std::optional fontStyle; + REACT_FIELD(fontVariant) + std::optional fontVariant; + REACT_FIELD(fontWeight) + std::optional fontWeight; + REACT_FIELD(fontStretch) + std::optional fontStretch; + REACT_FIELD(fontSize) + std::optional fontSize; + REACT_FIELD(fontFamily) + std::optional fontFamily; + REACT_FIELD(textAnchor) + std::optional textAnchor; + REACT_FIELD(textDecoration) + std::optional textDecoration; + REACT_FIELD(letterSpacing) + std::optional letterSpacing; + REACT_FIELD(wordSpacing) + std::optional wordSpacing; + REACT_FIELD(kerning) + std::optional kerning; + REACT_FIELD(fontFeatureSettings) + std::optional fontFeatureSettings; + REACT_FIELD(fontVariantLigatures) + std::optional fontVariantLigatures; + REACT_FIELD(fontVariationSettings) + std::optional fontVariationSettings; + + bool operator==(const FontObject &rhs) const { + return fontStyle == rhs.fontStyle && fontVariant == rhs.fontVariant && + fontWeight == rhs.fontWeight && fontStretch == rhs.fontStretch && + fontSize == rhs.fontSize && fontFamily == rhs.fontFamily && + textAnchor == rhs.textAnchor && textDecoration == rhs.textDecoration && + letterSpacing == rhs.letterSpacing && wordSpacing == rhs.wordSpacing && + kerning == rhs.kerning && + fontFeatureSettings == rhs.fontFeatureSettings && + fontVariantLigatures == rhs.fontVariantLigatures && + fontVariationSettings == rhs.fontVariationSettings; + } + + bool operator!=(const FontObject &rhs) const { + return !(*this == rhs); + } +}; + +#define REACT_SVG_GROUP_COMMON_PROPS \ + REACT_FIELD(fontSize) \ + REACT_FIELD(fontWeight) \ + REACT_FIELD(font) + +REACT_STRUCT(SvgGroupCommonProps) +struct SvgGroupCommonProps + : SvgGroupCommonPropsT { + SvgGroupCommonProps(const winrt::Microsoft::ReactNative::ViewProps &props); + + void SetProp( + uint32_t hash, + winrt::hstring propName, + winrt::Microsoft::ReactNative::IJSValueReader value) noexcept; + + REACT_SVG_NODE_COMMON_PROPS; + REACT_SVG_RENDERABLE_COMMON_PROPS; + REACT_SVG_GROUP_COMMON_PROPS; + + std::string fontSize; + std::string fontWeight; + FontObject font; +}; +#endif + +struct GroupView + : GroupViewT { + public: + GroupView() = default; + + const wchar_t *GetSvgElementName() noexcept override; + + static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; +}; +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/ImageView.cpp b/windows/RNSVG/Fabric/ImageView.cpp new file mode 100644 index 000000000..555304eb7 --- /dev/null +++ b/windows/RNSVG/Fabric/ImageView.cpp @@ -0,0 +1,39 @@ +#include "pch.h" +#include "ImageView.h" +#if __has_include("ImageView.g.cpp") +#include "ImageView.g.cpp" +#endif + +#ifndef USE_FABRIC +#include +#endif + +using namespace winrt::Microsoft::ReactNative; +using namespace winrt::Windows::Security::Cryptography; +using namespace winrt::Windows::Storage::Streams; +using namespace winrt::Windows::Web::Http; + +namespace winrt::RNSVG::implementation { + +ImageProps::ImageProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} + +void ImageProps::SetProp( + uint32_t hash, + winrt::hstring propName, + winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); +} + +const wchar_t *ImageView::GetSvgElementName() noexcept { + return L"image"; +} + +bool ImageView::IsSupported() const noexcept { + return false; +} + +void ImageView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + RegisterRenderableComponent(L"RNSVGImage", builder); +} + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/ImageView.h b/windows/RNSVG/Fabric/ImageView.h new file mode 100644 index 000000000..aaff2e2a6 --- /dev/null +++ b/windows/RNSVG/Fabric/ImageView.h @@ -0,0 +1,80 @@ +#pragma once + +#include "ImageProps.g.h" +#include "ImageView.g.h" +#include "RenderableView.h" + +#include + +namespace winrt::RNSVG::implementation { +enum class ImageSourceType { Uri = 0, Download = 1, InlineData = 2 }; +enum class ImageSourceFormat { Bitmap = 0, Svg = 1 }; + +REACT_STRUCT(ImageSource) +struct ImageSource { + REACT_FIELD(uri) + std::string uri{""}; + REACT_FIELD(method) + std::string method{""}; + //REACT_FIELD(headers) + //std::vector headers; + REACT_FIELD(body) + std::string body{""}; + REACT_FIELD(width) + float width{0.0f}; + REACT_FIELD(height) + float height{0.0f}; + REACT_FIELD(scale) + float scale{1.0f}; + /*REACT_FIELD(packagerAsset) + bool packagerAsset{false}; + REACT_FIELD(type) + ImageSourceType type{ImageSourceType::Uri}; + REACT_FIELD(format) + ImageSourceFormat format{ImageSourceFormat::Bitmap};*/ + + bool operator==(const ImageSource &rhs) const { + return uri == rhs.uri && method == rhs.method && width == rhs.width && height == rhs.height && scale == rhs.scale; + } + + bool operator!=(const ImageSource &rhs) const { + return !(*this == rhs); + } +}; + +REACT_STRUCT(ImageProps) +struct ImageProps : ImagePropsT { + ImageProps(const winrt::Microsoft::ReactNative::ViewProps &props); + + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept + override; + + REACT_SVG_NODE_COMMON_PROPS; + REACT_SVG_RENDERABLE_COMMON_PROPS; + + REACT_FIELD(x) + RNSVG::SVGLength x{0, winrt::RNSVG::LengthType::Unknown}; + REACT_FIELD(y) + RNSVG::SVGLength y{0, winrt::RNSVG::LengthType::Unknown}; + REACT_FIELD(width) + RNSVG::SVGLength width{0, winrt::RNSVG::LengthType::Unknown}; + REACT_FIELD(height) + RNSVG::SVGLength height{0, winrt::RNSVG::LengthType::Unknown}; + REACT_FIELD(src) + ImageSource src; + REACT_FIELD(align) + std::string align{""}; + REACT_FIELD(meetOrSlice) + RNSVG::MeetOrSlice meetOrSlice{RNSVG::MeetOrSlice::Meet}; +}; + +struct ImageView : ImageViewT { + public: + ImageView() = default; + + const wchar_t *GetSvgElementName() noexcept override; + bool IsSupported() const noexcept override; + + static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; +}; +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/LineView.cpp b/windows/RNSVG/Fabric/LineView.cpp new file mode 100644 index 000000000..ad6cc9a56 --- /dev/null +++ b/windows/RNSVG/Fabric/LineView.cpp @@ -0,0 +1,37 @@ +#include "pch.h" +#include "LineView.h" +#if __has_include("LineView.g.cpp") +#include "LineView.g.cpp" +#endif + +using namespace winrt; +using namespace Microsoft::ReactNative; + +namespace winrt::RNSVG::implementation { + +LineProps::LineProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} + +void LineProps::SetProp( + uint32_t hash, + winrt::hstring propName, + winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); +} + +const wchar_t *LineView::GetSvgElementName() noexcept { + return L"line"; +} + +void LineView::OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement &svgElement) noexcept { + auto props = m_props.as(); + svgElement.SetAttributeValue(SvgStrings::x1AttributeName, props->x1); + svgElement.SetAttributeValue(SvgStrings::y1AttributeName, props->y1); + svgElement.SetAttributeValue(SvgStrings::x2AttributeName, props->x2); + svgElement.SetAttributeValue(SvgStrings::y2AttributeName, props->y2); +} + +void LineView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + RegisterRenderableComponent(L"RNSVGLine", builder); +} + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/LineView.h b/windows/RNSVG/Fabric/LineView.h new file mode 100644 index 000000000..5b8afa134 --- /dev/null +++ b/windows/RNSVG/Fabric/LineView.h @@ -0,0 +1,40 @@ +#pragma once + +#include "LineProps.g.h" +#include "LineView.g.h" +#include "RenderableView.h" + +namespace winrt::RNSVG::implementation { + +REACT_STRUCT(LineProps) +struct LineProps : LinePropsT { + LineProps(const winrt::Microsoft::ReactNative::ViewProps &props); + + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept + override; + + REACT_SVG_NODE_COMMON_PROPS; + REACT_SVG_RENDERABLE_COMMON_PROPS; + + REACT_FIELD(x1) + D2D1_SVG_LENGTH x1{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; + REACT_FIELD(y1) + D2D1_SVG_LENGTH y1{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; + REACT_FIELD(x2) + D2D1_SVG_LENGTH x2{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; + REACT_FIELD(y2) + D2D1_SVG_LENGTH y2{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; +}; + +struct LineView : LineViewT { + public: + LineView() = default; + + const wchar_t *GetSvgElementName() noexcept override; + void OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement & /*element*/) noexcept override; + + static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; + +}; + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/LinearGradientView.cpp b/windows/RNSVG/Fabric/LinearGradientView.cpp new file mode 100644 index 000000000..52514d904 --- /dev/null +++ b/windows/RNSVG/Fabric/LinearGradientView.cpp @@ -0,0 +1,98 @@ +#include "pch.h" +#include "LinearGradientView.h" +#if __has_include("LinearGradientView.g.cpp") +#include "LinearGradientView.g.cpp" +#endif + +using namespace winrt; +using namespace Microsoft::ReactNative; + +namespace winrt::RNSVG::implementation { + +LinearGradientProps::LinearGradientProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} + +void LinearGradientProps::SetProp( + uint32_t hash, + winrt::hstring propName, + winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); +} + + + +void LinearGradientView::UpdateProps( + const winrt::Microsoft::ReactNative::ComponentView &view, + const winrt::Microsoft::ReactNative::IComponentProps &newProps, + const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept { + auto props = newProps.as(); + m_stops.clear(); + + if (props->gradient) { + auto it = props->gradient->begin(); + while (it != props->gradient->end()) { + SvgLinearGradientStop stop; + + stop.offset = it->AsSingle(); + ++it; + auto clr = it->AsUInt32(); + stop.color = D2D1_COLOR_F{ + ((clr & 0x00FF0000) >> 16) / 255.0f, + ((clr & 0x0000FF00) >> 8) / 255.0f, + (clr & 0x000000FF) / 255.0f, + ((clr & 0xFF000000) >> 24) / 255.0f}; + stop.opacity = ((clr & 0xFF000000) >> 24) / 255.0f; + ++it; + m_stops.push_back(stop); + } + } + + base_type::UpdateProps(view, newProps, oldProps); +} + + +const wchar_t *LinearGradientView::GetSvgElementName() noexcept { + return L"linearGradient"; +} + +void LinearGradientView::OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement &svgElement) noexcept { + auto props = m_props.as(); + if (props->x1) + svgElement.SetAttributeValue(SvgStrings::x1AttributeName, D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, props->x1.value().c_str()); + if (props->y1) + svgElement.SetAttributeValue(SvgStrings::y1AttributeName, D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, props->y1.value().c_str()); + if (props->x2) + svgElement.SetAttributeValue(SvgStrings::x2AttributeName, D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, props->x2.value().c_str()); + if (props->y2) + svgElement.SetAttributeValue(SvgStrings::y2AttributeName, D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, props->y2.value().c_str()); + + + if (props->gradientUnits.value_or(0) == 0) { + svgElement.SetAttributeValue( + SvgStrings::gradientUnitsAttributeName, D2D1_SVG_UNIT_TYPE::D2D1_SVG_UNIT_TYPE_OBJECT_BOUNDING_BOX); + } else { + svgElement.SetAttributeValue( + SvgStrings::gradientUnitsAttributeName, D2D1_SVG_UNIT_TYPE::D2D1_SVG_UNIT_TYPE_USER_SPACE_ON_USE); + } + + if (props->gradientTransform) { + auto &matrix = props->gradientTransform.value(); + svgElement.SetAttributeValue( + SvgStrings::gradientTransformAttributeName, + D2D1_MATRIX_3X2_F{matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]}); + } + + for (const auto &stop : m_stops) { + winrt::com_ptr svgStop; + svgElement.CreateChild(SvgStrings::stopAttributeName, svgStop.put()); + svgStop->SetAttributeValue(SvgStrings::offsetAttributeName, stop.offset); + svgStop->SetAttributeValue(SvgStrings::stopColorAttributeName, stop.color); + svgStop->SetAttributeValue(SvgStrings::stopOpacityAttributeName, stop.opacity); + } +} + +void LinearGradientView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + RegisterRenderableComponent( + L"RNSVGLinearGradient", builder); +} + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/LinearGradientView.h b/windows/RNSVG/Fabric/LinearGradientView.h new file mode 100644 index 000000000..afe401808 --- /dev/null +++ b/windows/RNSVG/Fabric/LinearGradientView.h @@ -0,0 +1,61 @@ +#pragma once + +#include "LinearGradientProps.g.h" +#include "LinearGradientView.g.h" + +#include "GroupView.h" + +namespace winrt::RNSVG::implementation { + +struct SvgLinearGradientStop { + float offset{0}; + D2D1_COLOR_F color; + float opacity{1.0f}; +}; + +REACT_STRUCT(LinearGradientProps) +struct LinearGradientProps : LinearGradientPropsT { + LinearGradientProps(const winrt::Microsoft::ReactNative::ViewProps &props); + + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept + override; + + REACT_SVG_NODE_COMMON_PROPS; + REACT_SVG_RENDERABLE_COMMON_PROPS; + REACT_SVG_GROUP_COMMON_PROPS; + + REACT_FIELD(x1) + std::optional x1; + REACT_FIELD(y1) + std::optional y1; + REACT_FIELD(x2) + std::optional x2; + REACT_FIELD(y2) + std::optional y2; + REACT_FIELD(gradient) + std::optional> gradient{}; + REACT_FIELD(gradientUnits) + std::optional gradientUnits; + REACT_FIELD(gradientTransform) + std::optional> gradientTransform; +}; + +struct LinearGradientView : LinearGradientViewT { + public: + LinearGradientView() = default; + + void UpdateProps( + const winrt::Microsoft::ReactNative::ComponentView & /*view*/, + const winrt::Microsoft::ReactNative::IComponentProps &props, + const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept override; + + const wchar_t *GetSvgElementName() noexcept override; + void OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement & /*element*/) noexcept override; + + static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; + + private: + std::vector m_stops; +}; + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/MarkerView.cpp b/windows/RNSVG/Fabric/MarkerView.cpp new file mode 100644 index 000000000..61ca08ff7 --- /dev/null +++ b/windows/RNSVG/Fabric/MarkerView.cpp @@ -0,0 +1,32 @@ +#include "pch.h" +#include "MarkerView.h" +#if __has_include("MarkerView.g.cpp") +#include "MarkerView.g.cpp" +#endif + +using namespace winrt; + +namespace winrt::RNSVG::implementation { + +MarkerProps::MarkerProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} + +void MarkerProps::SetProp( + uint32_t hash, + winrt::hstring propName, + winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); +} + +const wchar_t *MarkerView::GetSvgElementName() noexcept { + return L"marker"; +} + +bool MarkerView::IsSupported() const noexcept { + return false; +} + +void MarkerView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + RegisterRenderableComponent(L"RNSVGMarker", builder); +} + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/MarkerView.h b/windows/RNSVG/Fabric/MarkerView.h new file mode 100644 index 000000000..a8b6e38c9 --- /dev/null +++ b/windows/RNSVG/Fabric/MarkerView.h @@ -0,0 +1,55 @@ +#pragma once + +#include "MarkerProps.g.h" +#include "MarkerView.g.h" +#include "GroupView.h" + +namespace winrt::RNSVG::implementation { + +REACT_STRUCT(MarkerProps) +struct MarkerProps : MarkerPropsT { + MarkerProps(const winrt::Microsoft::ReactNative::ViewProps &props); + + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept + override; + + REACT_SVG_NODE_COMMON_PROPS; + REACT_SVG_RENDERABLE_COMMON_PROPS; + + REACT_FIELD(refX) + RNSVG::SVGLength refX{0, winrt::RNSVG::LengthType::Unknown}; + REACT_FIELD(refY) + RNSVG::SVGLength refY{0, winrt::RNSVG::LengthType::Unknown}; + REACT_FIELD(markerHeight) + RNSVG::SVGLength markerHeight{0, winrt::RNSVG::LengthType::Unknown}; + REACT_FIELD(markerWidth) + RNSVG::SVGLength markerWidth{0, winrt::RNSVG::LengthType::Unknown}; + REACT_FIELD(markerUnits) + std::string markerUnits{""}; + REACT_FIELD(orient) + std::string orient{""}; + REACT_FIELD(minX) + float minX{0.0f}; + REACT_FIELD(minY) + float minY{0.0f}; + REACT_FIELD(vbWidth) + float vbWidth{0.0f}; + REACT_FIELD(vbHeight) + float vbHeight{0.0f}; + REACT_FIELD(align) + std::string align{""}; + REACT_FIELD(meetOrSlice) + RNSVG::MeetOrSlice meetOrSlice{RNSVG::MeetOrSlice::Meet}; +}; + +struct MarkerView : MarkerViewT { + public: + MarkerView() = default; + + const wchar_t *GetSvgElementName() noexcept override; + bool IsSupported() const noexcept override; + + static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; +}; + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/MaskView.cpp b/windows/RNSVG/Fabric/MaskView.cpp new file mode 100644 index 000000000..bc15cbd4d --- /dev/null +++ b/windows/RNSVG/Fabric/MaskView.cpp @@ -0,0 +1,33 @@ +#include "pch.h" +#include "MaskView.h" +#if __has_include("MaskView.g.cpp") +#include "MaskView.g.cpp" +#endif + +using namespace winrt; + +namespace winrt::RNSVG::implementation { + +MaskProps::MaskProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} + +void MaskProps::SetProp( + uint32_t hash, + winrt::hstring propName, + winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); +} + +const wchar_t *MaskView::GetSvgElementName() noexcept { + return L"mask"; +} + +bool MaskView::IsSupported() const noexcept { + return false; +} + +void MaskView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + RegisterRenderableComponent(L"RNSVGMask", builder); +} + + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/MaskView.h b/windows/RNSVG/Fabric/MaskView.h new file mode 100644 index 000000000..e67f390f0 --- /dev/null +++ b/windows/RNSVG/Fabric/MaskView.h @@ -0,0 +1,43 @@ +#pragma once + +#include "MaskProps.g.h" +#include "MaskView.g.h" +#include "GroupView.h" + +namespace winrt::RNSVG::implementation { + +REACT_STRUCT(MaskProps) +struct MaskProps : MaskPropsT { + MaskProps(const winrt::Microsoft::ReactNative::ViewProps &props); + + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept + override; + + REACT_SVG_NODE_COMMON_PROPS; + REACT_SVG_RENDERABLE_COMMON_PROPS; + + REACT_FIELD(x) + RNSVG::SVGLength x{0, winrt::RNSVG::LengthType::Unknown}; + REACT_FIELD(y) + RNSVG::SVGLength y{0, winrt::RNSVG::LengthType::Unknown}; + REACT_FIELD(height) + RNSVG::SVGLength height{0, winrt::RNSVG::LengthType::Unknown}; + REACT_FIELD(width) + RNSVG::SVGLength width{0, winrt::RNSVG::LengthType::Unknown}; + REACT_FIELD(maskUnits) + uint32_t maskUnits{0}; + REACT_FIELD(maskContentUnits) + uint32_t maskContentUnits{0}; +}; + +struct MaskView : MaskViewT { + public: + MaskView() = default; + + const wchar_t *GetSvgElementName() noexcept override; + bool IsSupported() const noexcept override; + + static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; +}; + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/PathView.cpp b/windows/RNSVG/Fabric/PathView.cpp new file mode 100644 index 000000000..601667d81 --- /dev/null +++ b/windows/RNSVG/Fabric/PathView.cpp @@ -0,0 +1,37 @@ +#include "pch.h" +#include "PathView.h" +#if __has_include("PathView.g.cpp") +#include "PathView.g.cpp" +#endif + +#include "d2d1svg.h" +#include + +using namespace winrt; +using namespace Microsoft::ReactNative; + +namespace winrt::RNSVG::implementation { + +PathProps::PathProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} + +void PathProps::SetProp( + uint32_t hash, + winrt::hstring propName, + winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); +} + +const wchar_t *PathView::GetSvgElementName() noexcept { + return L"path"; +} + +void PathView::OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement &svgElement) noexcept { + auto props = m_props.as(); + svgElement.SetAttributeValue(SvgStrings::dAttributeName, D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, props->d.c_str()); +} + +void PathView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + RegisterRenderableComponent(L"RNSVGPath", builder); +} + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/PathView.h b/windows/RNSVG/Fabric/PathView.h new file mode 100644 index 000000000..7179b98ec --- /dev/null +++ b/windows/RNSVG/Fabric/PathView.h @@ -0,0 +1,34 @@ +#pragma once + +#include "PathProps.g.h" +#include "PathView.g.h" +#include "RenderableView.h" + +namespace winrt::RNSVG::implementation { + +REACT_STRUCT(PathProps) +struct PathProps : PathPropsT { + PathProps(const winrt::Microsoft::ReactNative::ViewProps &props); + + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept + override; + + REACT_SVG_NODE_COMMON_PROPS; + REACT_SVG_RENDERABLE_COMMON_PROPS; + + REACT_FIELD(d) + std::wstring d; +}; + +struct PathView : PathViewT { + public: + PathView() = default; + + const wchar_t *GetSvgElementName() noexcept override; + void OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement & /*element*/) noexcept override; + + static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; + +}; + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/PatternView.cpp b/windows/RNSVG/Fabric/PatternView.cpp new file mode 100644 index 000000000..c0e546139 --- /dev/null +++ b/windows/RNSVG/Fabric/PatternView.cpp @@ -0,0 +1,34 @@ +#include "pch.h" +#include "PatternView.h" +#if __has_include("PatternView.g.cpp") +#include "PatternView.g.cpp" +#endif + +using namespace winrt; +using namespace Microsoft::ReactNative; + +namespace winrt::RNSVG::implementation { + +PatternProps::PatternProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} + +void PatternProps::SetProp( + uint32_t hash, + winrt::hstring propName, + winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); +} + +const wchar_t *PatternView::GetSvgElementName() noexcept { + return L"pattern"; +} + +bool PatternView::IsSupported() const noexcept { + return false; +} + +void PatternView::RegisterComponent( + const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + RegisterRenderableComponent(L"RNSVGPattern", builder); +} + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/PatternView.h b/windows/RNSVG/Fabric/PatternView.h new file mode 100644 index 000000000..7d7ec60c0 --- /dev/null +++ b/windows/RNSVG/Fabric/PatternView.h @@ -0,0 +1,60 @@ +#pragma once + +#include "PatternProps.g.h" +#include "PatternView.g.h" + +#include "GroupView.h" + +namespace winrt::RNSVG::implementation { + +REACT_STRUCT(PatternProps) +struct PatternProps : PatternPropsT { + PatternProps(const winrt::Microsoft::ReactNative::ViewProps &props); + + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept + override; + + REACT_SVG_NODE_COMMON_PROPS; + REACT_SVG_RENDERABLE_COMMON_PROPS; + REACT_SVG_GROUP_COMMON_PROPS; + + REACT_FIELD(x) + RNSVG::SVGLength x{0, winrt::RNSVG::LengthType::Unknown}; + REACT_FIELD(y) + RNSVG::SVGLength y{0, winrt::RNSVG::LengthType::Unknown}; + REACT_FIELD(width) + RNSVG::SVGLength width{0, winrt::RNSVG::LengthType::Unknown}; + REACT_FIELD(height) + RNSVG::SVGLength height{0, winrt::RNSVG::LengthType::Unknown}; + REACT_FIELD(patternUnits) + std::optional patternUnits; + REACT_FIELD(patternContentUnits) + std::optional patternContentUnits; + REACT_FIELD(patternTransform) + std::optional> patternTransform; + + REACT_FIELD(minX) + float minX{0.0f}; + REACT_FIELD(minY) + float minY{0.0f}; + REACT_FIELD(vbWidth) + float vbWidth{0.0f}; + REACT_FIELD(vbHeight) + float vbHeight{0.0f}; + REACT_FIELD(align) + std::string align{""}; + REACT_FIELD(meetOrSlice) + RNSVG::MeetOrSlice meetOrSlice{RNSVG::MeetOrSlice::Meet}; +}; + +struct PatternView : PatternViewT { + public: + PatternView() = default; + + const wchar_t *GetSvgElementName() noexcept override; + bool IsSupported() const noexcept override; + + static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; +}; + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/RadialGradientView.cpp b/windows/RNSVG/Fabric/RadialGradientView.cpp new file mode 100644 index 000000000..cd6229e04 --- /dev/null +++ b/windows/RNSVG/Fabric/RadialGradientView.cpp @@ -0,0 +1,122 @@ +#include "pch.h" +#include "RadialGradientView.h" +#if __has_include("RadialGradientView.g.cpp") +#include "RadialGradientView.g.cpp" +#endif + +using namespace winrt; +using namespace Microsoft::ReactNative; + +namespace winrt::RNSVG::implementation { + +RadialGradientProps::RadialGradientProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} + +void RadialGradientProps::SetProp( + uint32_t hash, + winrt::hstring propName, + winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); +} + +void RadialGradientView::UpdateProps( + const winrt::Microsoft::ReactNative::ComponentView & view, + const winrt::Microsoft::ReactNative::IComponentProps &newProps, + const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept { + + auto props = newProps.as(); + m_stops.clear(); + + if (props->gradient) { + auto it = props->gradient->begin(); + while (it != props->gradient->end()) { + SvgRadialGradientStop stop; + + stop.offset = it->AsSingle(); + ++it; + auto clr = it->AsUInt32(); + stop.color = D2D1_COLOR_F{ + ((clr & 0x00FF0000) >> 16) / 255.0f, + ((clr & 0x0000FF00) >> 8) / 255.0f, + (clr & 0x000000FF) / 255.0f, + ((clr & 0xFF000000) >> 24) / 255.0f}; + stop.opacity = ((clr & 0xFF000000) >> 24) / 255.0f; + ++it; + m_stops.push_back(stop); + } + } + + base_type::UpdateProps(view, newProps, oldProps); +} + +const wchar_t *RadialGradientView::GetSvgElementName() noexcept { + return L"radialGradient"; +} + +void RadialGradientView::OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement &svgElement) noexcept { + auto props = m_props.as(); + if (props->cx) + svgElement.SetAttributeValue( + SvgStrings::cxAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + props->cx->c_str()); + if (props->cy) + svgElement.SetAttributeValue( + SvgStrings::cyAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + props->cy->c_str()); + + // RNSVG can decompose r to rx and ry, but D2D svgs don't support rx or ry, so if that is specified then take rx as r, + // and make sure the specified rx and ry are the same. + assert(props->rx == props->ry); + + // TODO verify rx ry comment above + + if (props->rx) + svgElement.SetAttributeValue( + SvgStrings::rAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + props->rx->c_str()); + + if (props->fx) + svgElement.SetAttributeValue( + SvgStrings::fxAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + props->fx->c_str()); + + if (props->fy) + svgElement.SetAttributeValue( + SvgStrings::fyAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + props->fy->c_str()); + + if (props->gradientUnits.value_or(0) == 0) { + svgElement.SetAttributeValue( + SvgStrings::gradientUnitsAttributeName, D2D1_SVG_UNIT_TYPE::D2D1_SVG_UNIT_TYPE_OBJECT_BOUNDING_BOX); + } else { + svgElement.SetAttributeValue( + SvgStrings::gradientUnitsAttributeName, D2D1_SVG_UNIT_TYPE::D2D1_SVG_UNIT_TYPE_USER_SPACE_ON_USE); + } + + if (props->gradientTransform) { + auto &matrix = props->gradientTransform.value(); + svgElement.SetAttributeValue( + SvgStrings::gradientTransformAttributeName, + D2D1_MATRIX_3X2_F{matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]}); + } + + for (const auto& stop : m_stops ) { + winrt::com_ptr svgStop; + svgElement.CreateChild(SvgStrings::stopAttributeName, svgStop.put()); + svgStop->SetAttributeValue(SvgStrings::offsetAttributeName, stop.offset); + svgStop->SetAttributeValue(SvgStrings::stopColorAttributeName, stop.color); + svgStop->SetAttributeValue(SvgStrings::stopOpacityAttributeName, stop.opacity); + } +} + +void RadialGradientView::RegisterComponent( + const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + RegisterRenderableComponent( + L"RNSVGRadialGradient", builder); +} + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/RadialGradientView.h b/windows/RNSVG/Fabric/RadialGradientView.h new file mode 100644 index 000000000..6329cb502 --- /dev/null +++ b/windows/RNSVG/Fabric/RadialGradientView.h @@ -0,0 +1,64 @@ +#pragma once + +#include "RadialGradientProps.g.h" +#include "RadialGradientView.g.h" + +#include "GroupView.h" + +namespace winrt::RNSVG::implementation { + +struct SvgRadialGradientStop { + float offset{0}; + D2D1_COLOR_F color; + float opacity{1.0f}; +}; + +REACT_STRUCT(RadialGradientProps) +struct RadialGradientProps : RadialGradientPropsT { + RadialGradientProps(const winrt::Microsoft::ReactNative::ViewProps &props); + + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept + override; + + REACT_SVG_NODE_COMMON_PROPS; + REACT_SVG_RENDERABLE_COMMON_PROPS; + REACT_SVG_GROUP_COMMON_PROPS; + + REACT_FIELD(fx) + std::optional fx; + REACT_FIELD(fy) + std::optional fy; + REACT_FIELD(cx) + std::optional cx; + REACT_FIELD(cy) + std::optional cy; + REACT_FIELD(rx) + std::optional rx; + REACT_FIELD(ry) + std::optional ry; + REACT_FIELD(gradient) + std::optional> gradient{}; + REACT_FIELD(gradientUnits) + std::optional gradientUnits; + REACT_FIELD(gradientTransform) + std::optional> gradientTransform; +}; + +struct RadialGradientView : RadialGradientViewT { + public: + RadialGradientView() = default; + + void UpdateProps( + const winrt::Microsoft::ReactNative::ComponentView & /*view*/, + const winrt::Microsoft::ReactNative::IComponentProps &props, + const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept override; + const wchar_t *GetSvgElementName() noexcept override; + void OnRender(ID2D1SvgDocument& /*document*/, ID2D1SvgElement& /*element*/) noexcept override; + + static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; + + private: + std::vector m_stops; +}; + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/RectView.cpp b/windows/RNSVG/Fabric/RectView.cpp new file mode 100644 index 000000000..3ff62473f --- /dev/null +++ b/windows/RNSVG/Fabric/RectView.cpp @@ -0,0 +1,50 @@ +#include "pch.h" +#include "RectView.h" +#if __has_include("RectView.g.cpp") +#include "RectView.g.cpp" +#endif + +using namespace winrt; +using namespace Microsoft::ReactNative; + +namespace winrt::RNSVG::implementation { + +RectProps::RectProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} + +void RectProps::SetProp( + uint32_t hash, + winrt::hstring propName, + winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); +} + +const wchar_t *RectView::GetSvgElementName() noexcept { + return L"rect"; +} + +void RectView::OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement &svgElement) noexcept { + auto props = m_props.as(); + svgElement.SetAttributeValue( + SvgStrings::xAttributeName, D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, props->x.c_str()); + svgElement.SetAttributeValue( + SvgStrings::yAttributeName, D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, props->y.c_str()); + svgElement.SetAttributeValue( + SvgStrings::widthAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + props->width.c_str()); + svgElement.SetAttributeValue( + SvgStrings::heightAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + props->height.c_str()); + + if (props->rx.value) + svgElement.SetAttributeValue(SvgStrings::rxAttributeName, props->rx); + if (props->ry.value) + svgElement.SetAttributeValue(SvgStrings::ryAttributeName, props->ry); +} + +void RectView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + RegisterRenderableComponent(L"RNSVGRect", builder); +} + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/RectView.h b/windows/RNSVG/Fabric/RectView.h new file mode 100644 index 000000000..0656d6ee2 --- /dev/null +++ b/windows/RNSVG/Fabric/RectView.h @@ -0,0 +1,43 @@ +#pragma once + +#include "RectProps.g.h" +#include "RectView.g.h" +#include "RenderableView.h" + +namespace winrt::RNSVG::implementation { + +REACT_STRUCT(RectProps) +struct RectProps : RectPropsT { + RectProps(const winrt::Microsoft::ReactNative::ViewProps &props); + + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept + override; + + REACT_SVG_NODE_COMMON_PROPS; + REACT_SVG_RENDERABLE_COMMON_PROPS; + + REACT_FIELD(x) + std::wstring x; + REACT_FIELD(y) + std::wstring y; + REACT_FIELD(height) + std::wstring height; + REACT_FIELD(width) + std::wstring width; + REACT_FIELD(rx) + D2D1_SVG_LENGTH rx{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; + REACT_FIELD(ry) + D2D1_SVG_LENGTH ry{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; +}; + +struct RectView : RectViewT { + public: + RectView() = default; + + const wchar_t *GetSvgElementName() noexcept override; + void OnRender(ID2D1SvgDocument& /*document*/ , ID2D1SvgElement & /*element*/) noexcept override; + + static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; +}; + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/RenderableView.cpp b/windows/RNSVG/Fabric/RenderableView.cpp new file mode 100644 index 000000000..5949c4572 --- /dev/null +++ b/windows/RNSVG/Fabric/RenderableView.cpp @@ -0,0 +1,306 @@ +#include "pch.h" +#include "RenderableView.h" +#if __has_include("RenderableView.g.cpp") +#include "RenderableView.g.cpp" +#endif + +#include "SvgView.h" +#include "../D2DHelpers.h" + +using namespace winrt; +using namespace Microsoft::ReactNative; + +namespace winrt::Microsoft::ReactNative { + +void WriteValue(IJSValueWriter const &writer, const D2D1_SVG_LENGTH &value) noexcept { + if (value.units == D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_PERCENTAGE) { + writer.WriteString(winrt::to_hstring(std::to_string(value.value) + "%")); + } else { + writer.WriteDouble(value.value); + } +} + +void ReadValue(IJSValueReader const &reader, /*out*/ D2D1_SVG_LENGTH &value) noexcept { + switch (reader.ValueType()) { + case JSValueType::String: { + auto str = to_string(reader.GetString()); + + auto strLength{str.size()}; + if (strLength == 0 || str == "normal") { + value.units = D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER; + value.value = 0.0; + return; + } else if (str.back() == '%') { + value.units = D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_PERCENTAGE; + value.value = std::stof(str.substr(0, strLength - 1), nullptr); + return; + } else if (strLength > 2) { + auto end{strLength - 2}; + auto lastTwo{str.substr(end)}; + + if (lastTwo == "px") { + value.units = D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER; + } else if (lastTwo == "em") { + value.units = D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER; + // value.unit = D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_EM; + } else if (lastTwo == "ex") { + // value.unit = D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_EX; + value.units = D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER; + } else if (lastTwo == "cm") { + // value.unit = D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_CM; + value.units = D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER; + } else if (lastTwo == "mm") { + // value.unit = D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_MM; + value.units = D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER; + } else if (lastTwo == "in") { + // value.unit = D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_INCH; + value.units = D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER; + } else if (lastTwo == "pt") { + // value.unit = D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_POINT; + value.units = D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER; + } else if (lastTwo == "pc") { + // value.unit = D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_PICA; + value.units = D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER; + } else { + value.units = D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER; + end = strLength; + } + + value.value = std::stof(str.substr(0, end), nullptr); + return; + } + + value.units = D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER; + value.value = std::stof(str, nullptr); + } + return; + case JSValueType::Int64: + value.units = D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER; + value.value = static_cast(reader.GetInt64()); + return; + case JSValueType::Double: + value.units = D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER; + value.value = static_cast(reader.GetDouble()); + return; + default: + value.units = D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER; + value.value = 0.0f; + return; + } +} + +} + +namespace winrt::RNSVG::implementation { + +HRESULT +SetColorMode( + const SvgView &svgView, + ID2D1SvgElement &element, + const std::wstring &attribute, + const ColorStruct &colorProp) noexcept { + HRESULT hr = S_OK; + if (colorProp.type == 0 /*Native Color*/) { + hr = element.SetAttributeValue( + attribute.c_str(), D2DHelpers::AsD2DColor(colorProp.payload.AsWindowsColor(svgView.Theme()))); + } else if (colorProp.type == 1 /*Brush ref*/) { + std::wstring namedRefStr = L"url(#" + colorProp.brushRef + L")"; + hr = element.SetAttributeValue( + attribute.c_str(), D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, namedRefStr.c_str()); + } else if (colorProp.type == 2 /*Current Color*/) { + hr = element.SetAttributeValue( + attribute.c_str(), D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, L"currentColor"); + } else if (colorProp.type == 3 /*context-fill*/) { + hr = element.SetAttributeValue( + attribute.c_str(), D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, L"context-fill"); + } else if (colorProp.type == 4 /*context-stroke*/) { + hr = element.SetAttributeValue( + attribute.c_str(), D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, L"context-fill"); + } + + assert(hr == S_OK); + return hr; +} + +void SetCommonSvgProps( + const SvgView &svgView, + ID2D1SvgDocument& document, + ID2D1SvgElement &element, + const SvgRenderableCommonProps &commonProps) noexcept { + HRESULT hr = S_OK; + if (commonProps.color != std::nullopt) { + auto color = commonProps.color.value().AsWindowsColor(svgView.Theme()); + hr |= element.SetAttributeValue(SvgStrings::colorAttributeName, D2DHelpers::AsD2DColor(color)); + } + + if (commonProps.propList) { + for (auto &prop : commonProps.propList.value()) { + if (prop == "fill") { + if (commonProps.fill != std::nullopt) + hr |= SetColorMode(svgView, element, SvgStrings::fillAttributeName, commonProps.fill.value()); + else + hr |= element.SetAttributeValue( + SvgStrings::fillAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + SvgStrings::noneAttributeValue); + } else if (prop == "fillOpacity") { + if (commonProps.fillOpacity != std::nullopt) + hr |= element.SetAttributeValue(SvgStrings::fillOpacityAttributeName, commonProps.fillOpacity.value()); + } else if (prop == "fillRule") { + if (commonProps.fillRule != std::nullopt) { + hr |= element.SetAttributeValue(SvgStrings::fillRuleAttributeName, commonProps.fillRule.value()); + } + } else if (prop == "stroke") { + if (commonProps.stroke != std::nullopt) + hr |= SetColorMode(svgView, element, SvgStrings::strokeAttributeName, commonProps.stroke.value()); + else + hr |= element.SetAttributeValue( + SvgStrings::strokeAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + SvgStrings::noneAttributeValue); + } else if (prop == "strokeWidth") { + if (commonProps.strokeWidth != std::nullopt) + hr |= element.SetAttributeValue(SvgStrings::strokeWidthAttributeName, commonProps.strokeWidth.value()); + } else if (prop == "strokeOpacity") { + if (commonProps.strokeOpacity != std::nullopt) + hr |= element.SetAttributeValue(SvgStrings::strokeOpacityAttributeName, commonProps.strokeOpacity.value()); + } else if (prop == "strokeDasharray") { + if (commonProps.strokeDasharray != std::nullopt && !commonProps.strokeDasharray->empty()) { + winrt::com_ptr dashArray; + document.CreateStrokeDashArray( + &commonProps.strokeDasharray.value()[0], + static_cast(commonProps.strokeDasharray.value().size()), + dashArray.put()); + hr |= element.SetAttributeValue(SvgStrings::strokeDashArrayAttributeName, dashArray.get()); + } + } else if (prop == "strokeDashoffset") { + if (commonProps.strokeDashoffset != std::nullopt) { + hr |= element.SetAttributeValue( + SvgStrings::strokeDashOffsetAttributeName, commonProps.strokeDashoffset.value()); + } + } else if (prop == "strokeLinecap") { + if (commonProps.strokeLinecap != std::nullopt) { + static D2D1_SVG_LINE_CAP supportedCaps[] = { + D2D1_SVG_LINE_CAP_BUTT, D2D1_SVG_LINE_CAP_ROUND, D2D1_SVG_LINE_CAP_SQUARE}; + hr |= element.SetAttributeValue( + SvgStrings::strokeLinecapAttributeName, supportedCaps[commonProps.strokeLinecap.value()]); + } + } else if (prop == "strokeLinejoin") { + if (commonProps.strokeLinejoin != std::nullopt) { + static D2D1_SVG_LINE_JOIN supportedJoins[] = { + D2D1_SVG_LINE_JOIN_MITER, D2D1_SVG_LINE_JOIN_ROUND, D2D1_SVG_LINE_JOIN_BEVEL}; + hr |= element.SetAttributeValue( + SvgStrings::strokeLinejoinAttributeName, supportedJoins[commonProps.strokeLinejoin.value()]); + } + } else if (prop == "strokeMiterlimit") { + if (commonProps.strokeMiterlimit != std::nullopt) { + hr |= element.SetAttributeValue( + SvgStrings::strokeMiterLimitAttributeName, commonProps.strokeMiterlimit.value()); + } + } + } + } + + if (commonProps.clipPath != std::nullopt) { + std::wstring namedRefStr = L"url(#" + commonProps.clipPath.value() + L")"; + hr |= element.SetAttributeValue( + SvgStrings::clipPathAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + namedRefStr.c_str()); + } + + if (commonProps.clipRule != std::nullopt) { + hr |= element.SetAttributeValue(SvgStrings::clipRuleAttributeName, commonProps.clipRule.value()); + } + + if (commonProps.name != std::nullopt) + hr |= element.SetAttributeValue( + SvgStrings::idAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + commonProps.name.value().c_str()); + + if (commonProps.opacity != std::nullopt) + hr |= element.SetAttributeValue(SvgStrings::opacityAttributeName, commonProps.opacity.value()); + + if (commonProps.matrix != std::nullopt) { + auto &matrix = commonProps.matrix.value(); + hr |= element.SetAttributeValue( + SvgStrings::transformAttributeName, + D2D1_MATRIX_3X2_F{matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]}); + } + + assert(hr == S_OK); +} + +SvgNodeCommonProps::SvgNodeCommonProps(const winrt::Microsoft::ReactNative::ViewProps &props) : m_props(props) {} + +void SvgNodeCommonProps::SetProp( + uint32_t hash, + winrt::hstring propName, + winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); +} + +SvgRenderableCommonProps::SvgRenderableCommonProps(const winrt::Microsoft::ReactNative::ViewProps &props) + : base_type(props) {} + +void SvgRenderableCommonProps::SetProp( + uint32_t hash, + winrt::hstring propName, + winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); +} + +void RenderableView::Invalidate(const winrt::Microsoft::ReactNative::ComponentView &view) { + winrt::com_ptr svgView{nullptr}; + auto current = view.Parent(); + while (current && !svgView) { + svgView = current.UserData().try_as(); + current = current.Parent(); + } + + if (svgView) { + svgView->Invalidate(); + } +} + +void RenderableView::MountChildComponentView( + const winrt::Microsoft::ReactNative::ComponentView &parent, + const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &) noexcept { + Invalidate(parent); +} + +void RenderableView::UnmountChildComponentView( + const winrt::Microsoft::ReactNative::ComponentView &parent, + const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &) noexcept { + Invalidate(parent); +} + +void RenderableView::UpdateProps( + const winrt::Microsoft::ReactNative::ComponentView & /*view*/, + const winrt::Microsoft::ReactNative::IComponentProps &props, + const winrt::Microsoft::ReactNative::IComponentProps &) noexcept { + m_props = props.as(); +} + +void RenderableView::FinalizeUpates( + const winrt::Microsoft::ReactNative::ComponentView &view, + winrt::Microsoft::ReactNative::ComponentViewUpdateMask) noexcept { + Invalidate(view); +} + +ID2D1SvgElement &RenderableView::Render(const SvgView &svgView, ID2D1SvgDocument& document, ID2D1SvgElement &svgElement) noexcept { + svgElement.CreateChild(GetSvgElementName(), m_spD2DSvgElement.put()); + if (m_props) + SetCommonSvgProps(svgView, document, *m_spD2DSvgElement, *m_props); + OnRender(document , *m_spD2DSvgElement); + return *m_spD2DSvgElement; +} + +bool RenderableView::IsSupported() const noexcept { + return true; +} + +void RenderableView::OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement & /*element*/) noexcept {} + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/RenderableView.h b/windows/RNSVG/Fabric/RenderableView.h new file mode 100644 index 000000000..32d02c046 --- /dev/null +++ b/windows/RNSVG/Fabric/RenderableView.h @@ -0,0 +1,233 @@ +#pragma once + +#include "RenderableView.g.h" +#include "../SVGLength.h" + +#ifdef USE_FABRIC +#include "SvgNodeCommonProps.g.h" +#include "SvgRenderableCommonProps.g.h" + +#include +#endif + +#include +#include "SvgStrings.h" + +namespace winrt::Microsoft::ReactNative { +void WriteValue(IJSValueWriter const &writer, const D2D1_SVG_LENGTH &value) noexcept; +void ReadValue(IJSValueReader const &reader, /*out*/ D2D1_SVG_LENGTH &value) noexcept; +} // namespace winrt::Microsoft::ReactNative + +namespace winrt::RNSVG::implementation { + +struct SvgView; +struct SvgRenderableCommonProps; + +void SetCommonSvgProps( + const SvgView& svgView, + ID2D1SvgDocument &document, + ID2D1SvgElement &element, + const SvgRenderableCommonProps &commonProps) noexcept; + +REACT_STRUCT(ColorStruct) +struct ColorStruct { + REACT_FIELD(type) + int32_t type{-1}; + + REACT_FIELD(payload) + winrt::Microsoft::ReactNative::Color payload{nullptr}; + + REACT_FIELD(brushRef) + std::wstring brushRef; + + bool operator==(const ColorStruct &rhs) const { + if (type != rhs.type || brushRef != rhs.brushRef) + return false; + + // When we move to a RNW version that provides Color::Equals switch to that for the payload comparison + auto writer = winrt::Microsoft::ReactNative::MakeJSValueTreeWriter(); + winrt::Microsoft::ReactNative::WriteValue(writer, payload); + auto rhsWriter = winrt::Microsoft::ReactNative::MakeJSValueTreeWriter(); + winrt::Microsoft::ReactNative::WriteValue(rhsWriter, rhs.payload); + return winrt::Microsoft::ReactNative::TakeJSValue(writer).Equals(winrt::Microsoft::ReactNative::TakeJSValue(rhsWriter)); + } + + bool operator!=(const ColorStruct &rhs) const { + return !(*this == rhs); + } +}; + +// Currently no good way to do inheritance in REACT_STRUCTS +#define REACT_SVG_NODE_COMMON_PROPS \ + REACT_FIELD(name) \ + REACT_FIELD(opacity) \ + REACT_FIELD(matrix) \ + REACT_FIELD(mask) \ + REACT_FIELD(markerStart) \ + REACT_FIELD(markerMid) \ + REACT_FIELD(markerEnd) \ + REACT_FIELD(clipPath) \ + REACT_FIELD(clipRule) \ + REACT_FIELD(responsible) \ + REACT_FIELD(display) \ + REACT_FIELD(pointerEvents) + +REACT_STRUCT(SvgNodeCommonProps) +struct SvgNodeCommonProps : SvgNodeCommonPropsT { + SvgNodeCommonProps(const winrt::Microsoft::ReactNative::ViewProps &props); + + virtual void SetProp( + uint32_t hash, + winrt::hstring propName, + winrt::Microsoft::ReactNative::IJSValueReader value) noexcept; + + REACT_SVG_NODE_COMMON_PROPS; + + std::optional name; + std::optional opacity; // 1.0f + std::optional> matrix; + std::optional mask; + std::optional markerStart; + std::optional markerMid; + std::optional markerEnd; + std::optional clipPath; + + static_assert(D2D1_FILL_MODE::D2D1_FILL_MODE_WINDING == 1); // NonZero + static_assert(D2D1_FILL_MODE::D2D1_FILL_MODE_ALTERNATE == 0); // EvenOdd + std::optional clipRule; + std::optional responsible; + std::optional display; + std::optional pointerEvents; + + private: + winrt::Microsoft::ReactNative::ViewProps m_props{nullptr}; +}; + +// Currently no good way to do inheritance in REACT_STRUCTS +#define REACT_SVG_RENDERABLE_COMMON_PROPS \ + REACT_FIELD(fill) \ + REACT_FIELD(fillOpacity) \ + REACT_FIELD(fillRule) \ + REACT_FIELD(stroke) \ + REACT_FIELD(strokeOpacity) \ + REACT_FIELD(strokeWidth) \ + REACT_FIELD(strokeLinecap) \ + REACT_FIELD(strokeLinejoin) \ + REACT_FIELD(strokeDasharray) \ + REACT_FIELD(strokeDashoffset) \ + REACT_FIELD(strokeMiterlimit) \ + REACT_FIELD(vectorEffect) \ + REACT_FIELD(propList) + +REACT_STRUCT(SvgRenderableCommonProps) +struct SvgRenderableCommonProps + : SvgRenderableCommonPropsT { + SvgRenderableCommonProps(const winrt::Microsoft::ReactNative::ViewProps &props); + + void SetProp( + uint32_t hash, + winrt::hstring propName, + winrt::Microsoft::ReactNative::IJSValueReader value) noexcept override; + + REACT_SVG_NODE_COMMON_PROPS; + REACT_SVG_RENDERABLE_COMMON_PROPS; + + std::optional color; + std::optional fill; // TODO should handle setting a color directly - which would need a custom reader to read a explict color into a ColorStruct + std::optional fillOpacity; // 1.0f + + static_assert(D2D1_FILL_MODE::D2D1_FILL_MODE_WINDING == 1); // NonZero + static_assert(D2D1_FILL_MODE::D2D1_FILL_MODE_ALTERNATE == 0); // EvenOdd + std::optional fillRule; + std::optional stroke; // TODO should handle setting a color directly - which would need a custom reader to read a explict color into a ColorStruct + std::optional strokeOpacity; // 1.0f + std::optional strokeWidth; + std::optional strokeLinecap; + std::optional strokeLinejoin; + std::optional> strokeDasharray; + std::optional strokeDashoffset; + std::optional strokeMiterlimit; + std::optional vectorEffect; // 0 + std::optional> propList; +}; + +struct RenderableView : RenderableViewT { + public: + RenderableView() = default; + + virtual const wchar_t* GetSvgElementName() noexcept = 0; + + // ComponentView + void MountChildComponentView( + const winrt::Microsoft::ReactNative::ComponentView &view, + const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept; + void UnmountChildComponentView( + const winrt::Microsoft::ReactNative::ComponentView &view, + const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept; + + virtual void UpdateProps( + const winrt::Microsoft::ReactNative::ComponentView & /*view*/, + const winrt::Microsoft::ReactNative::IComponentProps &props, + const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept; + + virtual void FinalizeUpates( + const winrt::Microsoft::ReactNative::ComponentView & /*view*/, + winrt::Microsoft::ReactNative::ComponentViewUpdateMask mask) noexcept; + + const winrt::Windows::Foundation::Collections::IVector &Children() const noexcept; + + ID2D1SvgElement &Render(const SvgView &svgView, ID2D1SvgDocument &document, ID2D1SvgElement &svgElement) noexcept; + + virtual void OnRender(ID2D1SvgDocument &document, ID2D1SvgElement & /*svgElement*/) noexcept; + virtual bool IsSupported() const noexcept; + + RNSVG::SvgView SvgRoot(); + + void Invalidate(const winrt::Microsoft::ReactNative::ComponentView &view); + + protected: + winrt::com_ptr m_props; + + private: + winrt::com_ptr m_spD2DSvgElement; + Microsoft::ReactNative::IReactContext m_reactContext{nullptr}; // TODO need? +}; +} // namespace winrt::RNSVG::implementation + +template +void RegisterRenderableComponent(const winrt::hstring& name, const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + builder.AddViewComponent( + name, [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { + builder.SetComponentViewInitializer([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept { + auto userData = winrt::make_self(); + view.UserData(*userData); + }); + builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props) noexcept { + return winrt::make(props); + }); + builder.SetUpdatePropsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view, + const winrt::Microsoft::ReactNative::IComponentProps &newProps, + const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept { + auto userData = view.UserData().as(); + userData->UpdateProps(view, newProps, oldProps); + }); + builder.SetFinalizeUpdateHandler( + [](const winrt::Microsoft::ReactNative::ComponentView &view, + const winrt::Microsoft::ReactNative::ComponentViewUpdateMask mask) noexcept { + auto userData = view.UserData().as(); + userData->FinalizeUpates(view, mask); + }); + builder.SetMountChildComponentViewHandler( + [](const winrt::Microsoft::ReactNative::ComponentView &view, + const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept { + auto userData = view.UserData().as(); + return userData->MountChildComponentView(view, args); + }); + builder.SetUnmountChildComponentViewHandler( + [](const winrt::Microsoft::ReactNative::ComponentView &view, + const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept { + auto userData = view.UserData().as(); + return userData->UnmountChildComponentView(view, args); + }); + }); +} diff --git a/windows/RNSVG/Fabric/SvgStrings.h b/windows/RNSVG/Fabric/SvgStrings.h new file mode 100644 index 000000000..bb7962428 --- /dev/null +++ b/windows/RNSVG/Fabric/SvgStrings.h @@ -0,0 +1,83 @@ +#pragma once + +namespace winrt::RNSVG::SvgStrings { + constexpr wchar_t fillAttributeName[] = L"fill"; + constexpr wchar_t clipPathAttributeName[] = L"clip-path"; + constexpr wchar_t clipRuleAttributeName[] = L"clip-rule"; + constexpr wchar_t fillRuleAttributeName[] = L"fill-rule"; + constexpr wchar_t EvenOddValue[] = L"evenodd"; + constexpr wchar_t NonZeroValue[] = L"nonzero"; + + constexpr wchar_t colorAttributeName[] = L"color"; + constexpr wchar_t currentColorAttributeName[] = L"currentColor"; + constexpr wchar_t opacityAttributeName[] = L"opacity"; + constexpr wchar_t fillOpacityAttributeName[] = L"fill-opacity"; + constexpr wchar_t stopOpacityAttributeName[] = L"stop-opacity"; + constexpr wchar_t strokeAttributeName[] = L"stroke"; + constexpr wchar_t strokeWidthAttributeName[] = L"stroke-width"; + constexpr wchar_t strokeOpacityAttributeName[] = L"stroke-opacity"; + constexpr wchar_t strokeLinecapAttributeName[] = L"stroke-linecap"; + constexpr wchar_t strokeLinejoinAttributeName[] = L"stroke-linejoin"; + constexpr wchar_t strokeDashArrayAttributeName[] = L"stroke-dasharray"; + constexpr wchar_t strokeDashOffsetAttributeName[] = L"stroke-dashoffset"; + constexpr wchar_t strokeMiterLimitAttributeName[] = L"stroke-miterlimit"; + constexpr wchar_t idAttributeName[] = L"id"; + constexpr wchar_t transformAttributeName[] = L"transform"; + + constexpr wchar_t xAttributeName[] = L"x"; + constexpr wchar_t yAttributeName[] = L"y"; + constexpr wchar_t widthAttributeName[] = L"width"; + constexpr wchar_t heightAttributeName[] = L"height"; + + constexpr wchar_t cxAttributeName[] = L"cx"; + constexpr wchar_t cyAttributeName[] = L"cy"; + constexpr wchar_t rxAttributeName[] = L"rx"; + constexpr wchar_t ryAttributeName[] = L"ry"; + + constexpr wchar_t rAttributeName[] = L"r"; + constexpr wchar_t fxAttributeName[] = L"fx"; + constexpr wchar_t fyAttributeName[] = L"fy"; + + constexpr wchar_t x1AttributeName[] = L"x1"; + constexpr wchar_t y1AttributeName[] = L"y1"; + + constexpr wchar_t x2AttributeName[] = L"x2"; + constexpr wchar_t y2AttributeName[] = L"y2"; + + constexpr wchar_t gradientAttributeName[] = L"gradient"; + constexpr wchar_t gradientUnitsAttributeName[] = L"gradientUnits"; + constexpr wchar_t gradientTransformAttributeName[] = L"gradientTransform"; + constexpr wchar_t offsetAttributeName[] = L"offset"; + constexpr wchar_t stopColorAttributeName[] = L"stop-color"; + constexpr wchar_t stopAttributeName[] = L"stop"; + + constexpr wchar_t userSpaceOnUseAttributeName[] = L"userSpaceOnUse"; + constexpr wchar_t objectBoundingBoxAttributeName[] = L"objectBoundingBox"; + constexpr wchar_t hrefAttributeName[] = L"href"; + constexpr wchar_t xlinkhrefAttributeName[] = L"xlink:href"; + + constexpr wchar_t dAttributeName[] = L"d"; + constexpr wchar_t buttAttributeValue[] = L"butt"; + constexpr wchar_t squareAttributeValue[] = L"square"; + constexpr wchar_t roundAttributeValue[] = L"round"; + + constexpr wchar_t bevelAttributeValue[] = L"bevel"; + constexpr wchar_t miterAttributeValue[] = L"miter"; + + constexpr wchar_t sliceAttributeValue[] = L"slice"; + constexpr wchar_t meetAttributeValue[] = L"meet"; + + constexpr wchar_t noneAttributeValue[] = L"none"; + constexpr wchar_t xMinYMinAttributeValue[] = L"xMinYMin"; + constexpr wchar_t xMidYMinAttributeValue[] = L"xMidYMin"; + constexpr wchar_t xMaxYMinAttributeValue[] = L"xMaxYMin"; + constexpr wchar_t xMinYMidAttributeValue[] = L"xMinYMid"; + constexpr wchar_t xMidYMidAttributeValue[] = L"xMidYMid"; + constexpr wchar_t xMaxYMidAttributeValue[] = L"xMaxYMid"; + constexpr wchar_t xMinYMaxAttributeValue[] = L"xMinYMax"; + constexpr wchar_t xMidYMaxAttributeValue[] = L"xMidYMax"; + constexpr wchar_t xMaxYMaxAttributeValue[] = L"xMaxYMax"; + + constexpr wchar_t viewBoxAttributeName[] = L"viewBox"; + constexpr wchar_t preserveAspectRatioAttributeName[] = L"preserveAspectRatio"; +} \ No newline at end of file diff --git a/windows/RNSVG/Fabric/SvgView.cpp b/windows/RNSVG/Fabric/SvgView.cpp new file mode 100644 index 000000000..df1cda293 --- /dev/null +++ b/windows/RNSVG/Fabric/SvgView.cpp @@ -0,0 +1,349 @@ +#include "pch.h" + +#include "SvgView.h" +#if __has_include("SvgView.g.cpp") +#include "SvgView.g.cpp" +#endif + +#include +#include +#include + +#include "../D2DDevice.h" +#include "../D2DDeviceContext.h" +#include "../D2DHelpers.h" +#include "GroupView.h" + +#include +#include +#include + +#include + +using namespace winrt; + +namespace winrt::RNSVG::implementation { + +SvgViewProps::SvgViewProps(const winrt::Microsoft::ReactNative::ViewProps &props) : m_props(props) {} + +void SvgViewProps::SetProp( + uint32_t hash, + winrt::hstring propName, + winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); +} + +SvgView::SvgView(const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext) + : m_compContext(compContext) {} + +winrt::Microsoft::ReactNative::Composition::Experimental::IVisual SvgView::CreateInternalVisual() { + m_visual = m_compContext.CreateSpriteVisual(); + m_visual.Comment(L"SVGRoot"); + return m_visual; +} + +void SvgView::MountChildComponentView( + const winrt::Microsoft::ReactNative::ComponentView &, + const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &) noexcept { + Invalidate(); +} + +void SvgView::UnmountChildComponentView( + const winrt::Microsoft::ReactNative::ComponentView &, + const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &) noexcept { + Invalidate(); +} + +void SvgView::OnThemeChanged() noexcept { + Invalidate(); +} + +void SvgView::OnMounted() noexcept { + m_isMounted = true; + Invalidate(); +} + +void SvgView::OnUnmounted() noexcept { + m_isMounted = false; +} + +D2D1_SVG_ASPECT_ALIGN AlignToAspectAlign(const std::string &align) { + if (align.compare("xMinYMin") == 0) + return D2D1_SVG_ASPECT_ALIGN::D2D1_SVG_ASPECT_ALIGN_X_MIN_Y_MIN; + else if (align.compare("xMidYMin") == 0) + return D2D1_SVG_ASPECT_ALIGN::D2D1_SVG_ASPECT_ALIGN_X_MID_Y_MIN; + else if (align.compare("xMaxYMin") == 0) + return D2D1_SVG_ASPECT_ALIGN::D2D1_SVG_ASPECT_ALIGN_X_MAX_Y_MIN; + else if (align.compare("xMinYMid") == 0) + return D2D1_SVG_ASPECT_ALIGN::D2D1_SVG_ASPECT_ALIGN_X_MIN_Y_MID; + else if (align.compare("xMidYMid") == 0) + return D2D1_SVG_ASPECT_ALIGN::D2D1_SVG_ASPECT_ALIGN_X_MID_Y_MID; + else if (align.compare("xMaxYMid") == 0) + return D2D1_SVG_ASPECT_ALIGN::D2D1_SVG_ASPECT_ALIGN_X_MAX_Y_MID; + else if (align.compare("xMinYMax") == 0) + return D2D1_SVG_ASPECT_ALIGN::D2D1_SVG_ASPECT_ALIGN_X_MIN_Y_MAX; + else if (align.compare("xMidYMax") == 0) + return D2D1_SVG_ASPECT_ALIGN::D2D1_SVG_ASPECT_ALIGN_X_MID_Y_MAX; + else if (align.compare("xMaxYMax") == 0) + return D2D1_SVG_ASPECT_ALIGN::D2D1_SVG_ASPECT_ALIGN_X_MAX_Y_MAX; + else if (align.compare("none") == 0) + return D2D1_SVG_ASPECT_ALIGN::D2D1_SVG_ASPECT_ALIGN_NONE; + + assert(false); + return D2D1_SVG_ASPECT_ALIGN::D2D1_SVG_ASPECT_ALIGN_NONE; +} + +void SvgView::UpdateProps( + const winrt::Microsoft::ReactNative::ComponentView & /*view*/, + const winrt::Microsoft::ReactNative::IComponentProps &newProps, + const winrt::Microsoft::ReactNative::IComponentProps & /*oldProps*/) noexcept { + m_props = newProps.as(); + + if (m_props->align) { + m_aspectAlign = AlignToAspectAlign(m_props->align.value()); + } else { + m_aspectAlign = D2D1_SVG_ASPECT_ALIGN::D2D1_SVG_ASPECT_ALIGN_NONE; + } +} + +void SvgView::FinalizeUpates( + const winrt::Microsoft::ReactNative::ComponentView & /*view*/, + winrt::Microsoft::ReactNative::ComponentViewUpdateMask) noexcept { + Invalidate(); // Move to finalize +} + +void SvgView::Initialize(const winrt::Microsoft::ReactNative::ComponentView &sender) noexcept { + auto view = sender.as(); + m_wkView = view; + + sender.as() + .CreateInternalVisualHandler([wkThis = get_weak()](const winrt::Microsoft::ReactNative::ComponentView &) { + return wkThis.get()->CreateInternalVisual(); + }); + + sender.LayoutMetricsChanged( + [wkThis = get_weak()]( + const winrt::IInspectable &, const winrt::Microsoft::ReactNative::LayoutMetricsChangedArgs &args) { + if (auto strongThis = wkThis.get()) { + strongThis->UpdateLayoutMetrics(args.NewLayoutMetrics(), args.OldLayoutMetrics()); + } + }); + + view.ThemeChanged( + [wkThis = get_weak()](const winrt::IInspectable & /*sender*/, const winrt::IInspectable & /*args*/) { + if (auto strongThis = wkThis.get()) { + strongThis->OnThemeChanged(); + } + }); + + view.Mounted([wkThis = get_weak()]( + const winrt::IInspectable & /*sender*/, const winrt::Microsoft::ReactNative::ComponentView &) { + if (auto strongThis = wkThis.get()) { + strongThis->OnMounted(); + } + }); + + view.Unmounted([wkThis = get_weak()]( + const winrt::IInspectable & /*sender*/, const winrt::Microsoft::ReactNative::ComponentView &) { + if (auto strongThis = wkThis.get()) { + strongThis->OnUnmounted(); + } + }); +} + +void SvgView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + builder.AddViewComponent( + L"RNSVGSvgView", [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { + builder.SetCreateProps( + [](winrt::Microsoft::ReactNative::ViewProps props) noexcept { return winrt::make(props); }); + auto compBuilder = + builder.as(); + + compBuilder.SetViewComponentViewInitializer( + [](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept { + auto userData = winrt::make_self( + view.as() + .CompositionContext()); + userData->Initialize(view); + view.UserData(*userData); + }); + + builder.SetUpdatePropsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view, + const winrt::Microsoft::ReactNative::IComponentProps &newProps, + const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept { + auto userData = view.UserData().as(); + userData->UpdateProps(view, newProps, oldProps); + }); + + builder.SetFinalizeUpdateHandler( + [](const winrt::Microsoft::ReactNative::ComponentView &view, + const winrt::Microsoft::ReactNative::ComponentViewUpdateMask mask) noexcept { + auto userData = view.UserData().as(); + userData->FinalizeUpates(view, mask); + }); + + builder.SetMountChildComponentViewHandler( + [](const winrt::Microsoft::ReactNative::ComponentView &view, + const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept { + auto userData = view.UserData().as(); + return userData->MountChildComponentView(view, args); + }); + + builder.SetUnmountChildComponentViewHandler( + [](const winrt::Microsoft::ReactNative::ComponentView &view, + const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept { + auto userData = view.UserData().as(); + return userData->UnmountChildComponentView(view, args); + }); + }); + + // TODO how to remove featureflag Background? +} + +void SvgView::UpdateLayoutMetrics( + const winrt::Microsoft::ReactNative::LayoutMetrics &metrics, + const winrt::Microsoft::ReactNative::LayoutMetrics &oldMetrics) { + m_layoutMetrics = metrics; + + if (metrics != oldMetrics) { + Invalidate(); + } +} + +void RecurseRenderNode( + const SvgView *root, + const winrt::Microsoft::ReactNative::ComponentView &view, + ID2D1SvgDocument &document, + ID2D1SvgElement &svgElement) noexcept { + for (auto const &child : view.Children()) { + { + auto renderable = child.UserData().try_as(); + + if (renderable && renderable->IsSupported()) { + ID2D1SvgElement &newElement = renderable->Render(*root, document, svgElement); + RecurseRenderNode(root, child, document, newElement); + } + } + } +} + +void SvgView::Draw( + const winrt::Microsoft::ReactNative::Composition::ViewComponentView &view, + ID2D1DeviceContext &context, + Size const &size) noexcept { + + com_ptr deviceContext; + deviceContext.copy_from(&context); + + auto deviceContext5 = deviceContext.as(); + + winrt::com_ptr spSvgDocument; + deviceContext5->CreateSvgDocument(nullptr, D2D1_SIZE_F{size.Width, size.Height}, spSvgDocument.put()); + + winrt::com_ptr spRoot; + spSvgDocument->GetRoot(spRoot.put()); + + if (m_props->vbWidth != std::nullopt || m_props->vbHeight != std::nullopt) { + std::wstring viewBoxStr = std::to_wstring(m_props->minX.value_or(0)) + L" " + + std::to_wstring(m_props->minY.value_or(0)) + L" " + std::to_wstring(m_props->vbWidth.value_or(0)) + L" " + + std::to_wstring(m_props->vbHeight.value_or(0)); + spRoot->SetAttributeValue( + SvgStrings::viewBoxAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + viewBoxStr.c_str()); + } + + spRoot->SetAttributeValue( + SvgStrings::widthAttributeName, D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, std::to_wstring(size.Width).c_str()); + spRoot->SetAttributeValue( + SvgStrings::heightAttributeName, D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, std::to_wstring(size.Height).c_str()); + + if (m_props->color) { + spRoot->SetAttributeValue( + SvgStrings::colorAttributeName, D2DHelpers::AsD2DColor(m_props->color.AsWindowsColor(Theme()))); + } else + spRoot->SetAttributeValue( + SvgStrings::colorAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + SvgStrings::noneAttributeValue); + + if (m_props->align != std::nullopt || m_props->meetOrSlice != std::nullopt) { + D2D1_SVG_PRESERVE_ASPECT_RATIO preserveAspectRatio; + preserveAspectRatio.defer = false; + preserveAspectRatio.align = m_aspectAlign; + + preserveAspectRatio.meetOrSlice = m_props->meetOrSlice.value() == MeetOrSlice::Meet + ? D2D1_SVG_ASPECT_SCALING::D2D1_SVG_ASPECT_SCALING_MEET + : D2D1_SVG_ASPECT_SCALING::D2D1_SVG_ASPECT_SCALING_SLICE; + spRoot->SetAttributeValue(SvgStrings::preserveAspectRatioAttributeName, preserveAspectRatio); + } + + for (auto const &child : view.Children()) { + auto renderable = child.UserData().as(); + if (renderable->IsSupported()) { + RecurseRenderNode(this, child, *spSvgDocument, *spRoot); + } + } + + deviceContext5->DrawSvgDocument(spSvgDocument.get()); + + /* + winrt::com_ptr textHighlightBrush; + winrt::check_hresult( + deviceContext5->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::Black, 1.0f), textHighlightBrush.put())); + + const D2D1_RECT_F rect = { + 10, + 10, + 50, + 50}; + + deviceContext5->FillRectangle(rect, textHighlightBrush.get()); + */ +} + +winrt::Microsoft::ReactNative::Composition::Theme SvgView::Theme() const noexcept { + if (auto view = m_wkView.get()) { + return view.Theme(); + } + return nullptr; +} + +void SvgView::Invalidate() { + if (auto view = m_wkView.get()) { + Size size = winrt::Windows::Foundation::Size{m_layoutMetrics.Frame.Width, m_layoutMetrics.Frame.Height}; + + if (!m_isMounted) { + return; + } + + if (size.Height == 0 || size.Width == 0) { + return; + } + + auto drawingSurface = m_compContext.CreateDrawingSurfaceBrush( + size, + winrt::Windows::Graphics::DirectX::DirectXPixelFormat::B8G8R8A8UIntNormalized, + winrt::Windows::Graphics::DirectX::DirectXAlphaMode::Premultiplied); + + POINT offset; + { + ::Microsoft::ReactNative::Composition::AutoDrawDrawingSurface autoDraw(drawingSurface, 1.0, &offset); + if (auto deviceContext = autoDraw.GetRenderTarget()) { + auto transform = + Numerics::make_float3x2_translation({static_cast(offset.x), static_cast(offset.y)}); + deviceContext->SetTransform(D2DHelpers::AsD2DTransform(transform)); + + deviceContext->Clear(D2D1::ColorF(D2D1::ColorF::Black, 0.0f)); + + com_ptr spDeviceContext; + spDeviceContext.copy_from(deviceContext); + + Draw(view, *spDeviceContext, size); + } + } + + m_visual.Brush(drawingSurface); + } +} +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/SvgView.h b/windows/RNSVG/Fabric/SvgView.h new file mode 100644 index 000000000..8724fd90e --- /dev/null +++ b/windows/RNSVG/Fabric/SvgView.h @@ -0,0 +1,101 @@ +#pragma once + +#include "SvgView.g.h" + +#include "SvgViewProps.g.h" + +#include +#include +#include "NativeModules.h" + +#include "../SVGLength.h" + +namespace winrt::RNSVG::implementation { + +REACT_STRUCT(SvgViewProps) +struct SvgViewProps : SvgViewPropsT { + SvgViewProps(const winrt::Microsoft::ReactNative::ViewProps &props); + + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept; + + REACT_FIELD(bbWidth) + winrt::RNSVG::SVGLength bbWidth{0.0, winrt::RNSVG::LengthType::Unknown}; + + REACT_FIELD(bbHeight) + winrt::RNSVG::SVGLength bbHeight{0.0, winrt::RNSVG::LengthType::Unknown}; + + REACT_FIELD(minX) + std::optional minX; + REACT_FIELD(minY) + std::optional minY; + REACT_FIELD(vbWidth) + std::optional vbWidth; + REACT_FIELD(vbHeight) + std::optional vbHeight; + REACT_FIELD(align) + std::optional align; + REACT_FIELD(meetOrSlice) + std::optional meetOrSlice; + REACT_FIELD(color) + winrt::Microsoft::ReactNative::Color color{nullptr}; + private: + winrt::Microsoft::ReactNative::ViewProps m_props{nullptr}; +}; + +struct SvgView : SvgViewT { + public: + + SvgView(const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext); + + // Overrides + // IInternalCreateVisual + winrt::Microsoft::ReactNative::Composition::Experimental::IVisual CreateInternalVisual(); + + // ComponentView + void UpdateProps( + const winrt::Microsoft::ReactNative::ComponentView & /*view*/, + const winrt::Microsoft::ReactNative::IComponentProps &newProps, + const winrt::Microsoft::ReactNative::IComponentProps & /*oldProps*/) noexcept; + void UpdateLayoutMetrics( + const winrt::Microsoft::ReactNative::LayoutMetrics &metrics, + const winrt::Microsoft::ReactNative::LayoutMetrics &oldMetrics); + void MountChildComponentView( + const winrt::Microsoft::ReactNative::ComponentView& view, + const winrt::Microsoft::ReactNative::MountChildComponentViewArgs& args) noexcept; + void UnmountChildComponentView( + const winrt::Microsoft::ReactNative::ComponentView& view, + const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs& args) noexcept; + + void FinalizeUpates( + const winrt::Microsoft::ReactNative::ComponentView & /*view*/, + winrt::Microsoft::ReactNative::ComponentViewUpdateMask mask) noexcept; + + void OnThemeChanged() noexcept; + void OnMounted() noexcept; + void OnUnmounted() noexcept; + + void Initialize(const winrt::Microsoft::ReactNative::ComponentView & /*view*/) noexcept; + + static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; + + void Invalidate(); + winrt::Microsoft::ReactNative::Composition::Theme Theme() const noexcept; + + private: + void Draw( + const winrt::Microsoft::ReactNative::Composition::ViewComponentView &view, + ID2D1DeviceContext &context, + Windows::Foundation::Size const &size) noexcept; + + bool m_isMounted{false}; + winrt::Microsoft::ReactNative::Composition::Experimental::ISpriteVisual m_visual{nullptr}; + winrt::Microsoft::ReactNative::LayoutMetrics m_layoutMetrics{{0, 0, 0, 0}, 1.0}; + winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext m_compContext{nullptr}; + winrt::weak_ref m_wkView; // Do we have the view passed into all the methods that we need this? + D2D1_SVG_ASPECT_ALIGN m_aspectAlign; + winrt::com_ptr m_props; + + // Shared + Microsoft::ReactNative::IReactContext m_reactContext{nullptr}; +}; +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/SymbolView.cpp b/windows/RNSVG/Fabric/SymbolView.cpp new file mode 100644 index 000000000..239ea3e9a --- /dev/null +++ b/windows/RNSVG/Fabric/SymbolView.cpp @@ -0,0 +1,32 @@ +#include "pch.h" +#include "SymbolView.h" +#if __has_include("SymbolView.g.cpp") +#include "SymbolView.g.cpp" +#endif + +using namespace winrt; + +namespace winrt::RNSVG::implementation { + +SymbolProps::SymbolProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} + +void SymbolProps::SetProp( + uint32_t hash, + winrt::hstring propName, + winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); +} + +const wchar_t *SymbolView::GetSvgElementName() noexcept { + return L"symbol"; +} + +bool SymbolView::IsSupported() const noexcept { + return false; +} + +void SymbolView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + RegisterRenderableComponent(L"RNSVGSymbol", builder); +} + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/SymbolView.h b/windows/RNSVG/Fabric/SymbolView.h new file mode 100644 index 000000000..1d4efc2b1 --- /dev/null +++ b/windows/RNSVG/Fabric/SymbolView.h @@ -0,0 +1,45 @@ +#pragma once + +#include "SymbolProps.g.h" +#include "SymbolView.g.h" +#include "GroupView.h" + +namespace winrt::RNSVG::implementation { + +REACT_STRUCT(SymbolProps) +struct SymbolProps : SymbolPropsT { + SymbolProps(const winrt::Microsoft::ReactNative::ViewProps &props); + + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept + override; + + REACT_SVG_NODE_COMMON_PROPS; + REACT_SVG_RENDERABLE_COMMON_PROPS; + REACT_SVG_GROUP_COMMON_PROPS; + + REACT_FIELD(minX) + float minX{0.0f}; + REACT_FIELD(minY) + float minY{0.0f}; + REACT_FIELD(vbWidth) + float vbWidth{0.0f}; + REACT_FIELD(vbHeight) + float vbHeight{0.0f}; + REACT_FIELD(align) + std::string align{""}; + REACT_FIELD(meetOrSlice) + RNSVG::MeetOrSlice meetOrSlice{RNSVG::MeetOrSlice::Meet}; +}; + +struct SymbolView : SymbolViewT { + public: + SymbolView() = default; + + const wchar_t *GetSvgElementName() noexcept override; + bool IsSupported() const noexcept override; + + static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; + +}; + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/TSpanView.cpp b/windows/RNSVG/Fabric/TSpanView.cpp new file mode 100644 index 000000000..22b9bec2c --- /dev/null +++ b/windows/RNSVG/Fabric/TSpanView.cpp @@ -0,0 +1,33 @@ +#include "pch.h" +#include "TSpanView.h" +#if __has_include("TSpanView.g.cpp") +#include "TSpanView.g.cpp" +#endif + +using namespace winrt; +using namespace Microsoft::ReactNative; + +namespace winrt::RNSVG::implementation { + +TSpanProps::TSpanProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} + +void TSpanProps::SetProp( + uint32_t hash, + winrt::hstring propName, + winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); +} + +const wchar_t *TSpanView::GetSvgElementName() noexcept { + return L"tSpan"; +} + +bool TSpanView::IsSupported() const noexcept { + return false; +} + +void TSpanView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + RegisterRenderableComponent(L"RNSVGTSpan", builder); +} + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/TSpanView.h b/windows/RNSVG/Fabric/TSpanView.h new file mode 100644 index 000000000..4cf582bad --- /dev/null +++ b/windows/RNSVG/Fabric/TSpanView.h @@ -0,0 +1,36 @@ +#pragma once + +#include "TSpanProps.g.h" +#include "TSpanView.g.h" +#include "TextView.h" + +namespace winrt::RNSVG::implementation { + +REACT_STRUCT(TSpanProps) +struct TSpanProps : TSpanPropsT { + TSpanProps(const winrt::Microsoft::ReactNative::ViewProps &props); + + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept + override; + + REACT_SVG_NODE_COMMON_PROPS; + REACT_SVG_RENDERABLE_COMMON_PROPS; + REACT_SVG_GROUP_COMMON_PROPS; + REACT_SVG_TEXT_COMMON_PROPS; + + REACT_FIELD(content) + std::string content{""}; +}; + +struct TSpanView : TSpanViewT { +public: + TSpanView() = default; + + const wchar_t *GetSvgElementName() noexcept override; + bool IsSupported() const noexcept override; + + static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; +}; + +} // namespace winrt::RNSVG::implementation + diff --git a/windows/RNSVG/Fabric/TextView.cpp b/windows/RNSVG/Fabric/TextView.cpp new file mode 100644 index 000000000..650ba4292 --- /dev/null +++ b/windows/RNSVG/Fabric/TextView.cpp @@ -0,0 +1,33 @@ +#include "pch.h" +#include "TextView.h" +#if __has_include("TextView.g.cpp") +#include "TextView.g.cpp" +#endif + +using namespace winrt; +using namespace Microsoft::ReactNative; + +namespace winrt::RNSVG::implementation { + +SvgTextCommonProps::SvgTextCommonProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} + +void SvgTextCommonProps::SetProp( + uint32_t hash, + winrt::hstring propName, + winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); +} + +const wchar_t *TextView::GetSvgElementName() noexcept { + return L"text"; +} + +bool TextView::IsSupported() const noexcept { + return false; +} + +void TextView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + RegisterRenderableComponent(L"RNSVGText", builder); +} + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/TextView.h b/windows/RNSVG/Fabric/TextView.h new file mode 100644 index 000000000..b517a8432 --- /dev/null +++ b/windows/RNSVG/Fabric/TextView.h @@ -0,0 +1,57 @@ +#pragma once + +#include "SvgTextCommonProps.g.h" +#include "TextView.g.h" +#include "GroupView.h" + +namespace winrt::RNSVG::implementation { + +#define REACT_SVG_TEXT_COMMON_PROPS \ + REACT_FIELD(dx) \ + REACT_FIELD(dy) \ + REACT_FIELD(x) \ + REACT_FIELD(y) \ + REACT_FIELD(rotate) \ + REACT_FIELD(inlineSize) \ + REACT_FIELD(textLength) \ + REACT_FIELD(baselineShift) \ + REACT_FIELD(lengthAdjust) \ + REACT_FIELD(alignmentBaseline) \ + REACT_FIELD(verticalAlign) + +REACT_STRUCT(SvgTextCommonProps) +struct SvgTextCommonProps : SvgTextCommonPropsT { + SvgTextCommonProps(const winrt::Microsoft::ReactNative::ViewProps &props); + + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept + override; + + REACT_SVG_NODE_COMMON_PROPS; + REACT_SVG_RENDERABLE_COMMON_PROPS; + REACT_SVG_GROUP_COMMON_PROPS; + REACT_SVG_TEXT_COMMON_PROPS; + + std::optional> dx; + std::optional> dy; + std::optional> x; + std::optional> y; + std::optional> rotate; + RNSVG::SVGLength inlineSize{0, winrt::RNSVG::LengthType::Unknown}; + RNSVG::SVGLength textLength{0, winrt::RNSVG::LengthType::Unknown}; + RNSVG::SVGLength baselineShift{0, winrt::RNSVG::LengthType::Unknown}; + std::string lengthAdjust; + std::string alignmentBaseline; + RNSVG::SVGLength verticalAlign{0, winrt::RNSVG::LengthType::Unknown}; +}; + +struct TextView : TextViewT { + public: + TextView() = default; + + const wchar_t *GetSvgElementName() noexcept override; + bool IsSupported() const noexcept override; + + static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; +}; + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/UseView.cpp b/windows/RNSVG/Fabric/UseView.cpp new file mode 100644 index 000000000..40bb7ba93 --- /dev/null +++ b/windows/RNSVG/Fabric/UseView.cpp @@ -0,0 +1,42 @@ +#include "pch.h" +#include "UseView.h" +#if __has_include("UseView.g.cpp") +#include "UseView.g.cpp" +#endif + +using namespace winrt; +using namespace Microsoft::ReactNative; + +namespace winrt::RNSVG::implementation { + +UseProps::UseProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} + +void UseProps::SetProp( + uint32_t hash, + winrt::hstring propName, + winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); +} + +const wchar_t *UseView::GetSvgElementName() noexcept { + return L"use"; +} + +void UseView::OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement &svgElement) noexcept { + auto props = m_props.as(); + svgElement.SetAttributeValue( + SvgStrings::xlinkhrefAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + (L"#" + props->href).c_str()); + + svgElement.SetAttributeValue(SvgStrings::xAttributeName, props->x); + svgElement.SetAttributeValue(SvgStrings::yAttributeName, props->y); + svgElement.SetAttributeValue(SvgStrings::widthAttributeName, props->width); + svgElement.SetAttributeValue(SvgStrings::heightAttributeName, props->height); +} + +void UseView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + RegisterRenderableComponent(L"RNSVGUse", builder); +} + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/UseView.h b/windows/RNSVG/Fabric/UseView.h new file mode 100644 index 000000000..ac371b3ea --- /dev/null +++ b/windows/RNSVG/Fabric/UseView.h @@ -0,0 +1,41 @@ +#pragma once + +#include "UseProps.g.h" +#include "UseView.g.h" +#include "RenderableView.h" + +namespace winrt::RNSVG::implementation { + +REACT_STRUCT(UseProps) +struct UseProps : UsePropsT { + UseProps(const winrt::Microsoft::ReactNative::ViewProps &props); + + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept + override; + + REACT_SVG_NODE_COMMON_PROPS; + REACT_SVG_RENDERABLE_COMMON_PROPS; + + REACT_FIELD(href) + std::wstring href; + REACT_FIELD(x) + D2D1_SVG_LENGTH x{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; + REACT_FIELD(y) + D2D1_SVG_LENGTH y{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; + REACT_FIELD(width) + D2D1_SVG_LENGTH width{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; + REACT_FIELD(height) + D2D1_SVG_LENGTH height{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; +}; + +struct UseView : UseViewT { + public: + UseView() = default; + + const wchar_t *GetSvgElementName() noexcept override; + void OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement & /*element*/) noexcept override; + + static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; +}; + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/RNSVG.vcxproj b/windows/RNSVG/RNSVG.vcxproj index b8a0a8203..63a227885 100644 --- a/windows/RNSVG/RNSVG.vcxproj +++ b/windows/RNSVG/RNSVG.vcxproj @@ -195,13 +195,46 @@ - - - + + Create + + + ReactPackageProvider.idl + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -212,24 +245,14 @@ - - Create - - - ReactPackageProvider.idl - - - - - diff --git a/windows/RNSVG/ReactPackageProvider.cpp b/windows/RNSVG/ReactPackageProvider.cpp index b8e62dbce..ff4db9754 100644 --- a/windows/RNSVG/ReactPackageProvider.cpp +++ b/windows/RNSVG/ReactPackageProvider.cpp @@ -7,25 +7,25 @@ #include "RNSVGModule.h" #ifdef USE_FABRIC -#include "SvgView.h" -#include "RectView.h" -#include "CircleView.h" -#include "EllipseView.h" -#include "LineView.h" -#include "PathView.h" -#include "ImageView.h" -#include "UseView.h" -#include "GroupView.h" -#include "SymbolView.h" -#include "DefsView.h" -#include "ClipPathView.h" -#include "MarkerView.h" -#include "MaskView.h" -#include "LinearGradientView.h" -#include "RadialGradientView.h" -#include "PatternView.h" -#include "TextView.h" -#include "TSpanView.h" +#include "Fabric/SvgView.h" +#include "Fabric/RectView.h" +#include "Fabric/CircleView.h" +#include "Fabric/EllipseView.h" +#include "Fabric/LineView.h" +#include "Fabric/PathView.h" +#include "Fabric/ImageView.h" +#include "Fabric/UseView.h" +#include "Fabric/GroupView.h" +#include "Fabric/SymbolView.h" +#include "Fabric/DefsView.h" +#include "Fabric/ClipPathView.h" +#include "Fabric/MarkerView.h" +#include "Fabric/MaskView.h" +#include "Fabric/LinearGradientView.h" +#include "Fabric/RadialGradientView.h" +#include "Fabric/PatternView.h" +#include "Fabric/TextView.h" +#include "Fabric/TSpanView.h" #else #include "SvgViewManager.h" #include "GroupViewManager.h" diff --git a/windows/RNSVG/SVGLength.cpp b/windows/RNSVG/SVGLength.cpp index 7f757e715..c326652e5 100644 --- a/windows/RNSVG/SVGLength.cpp +++ b/windows/RNSVG/SVGLength.cpp @@ -104,4 +104,28 @@ void ReadValue(IJSValueReader const &reader, /*out*/ winrt::RNSVG::SVGLength &va } } + } // namespace winrt::Microsoft::ReactNative + +namespace winrt::RNSVG { + +D2D1_SVG_LENGTH D2dSvgLength(const winrt::RNSVG::SVGLength &value) noexcept { + switch (value.Unit) { + case RNSVG::LengthType::Percentage: + return {value.Value, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_PERCENTAGE}; + case RNSVG::LengthType::Unknown: + case RNSVG::LengthType::EMS: + case RNSVG::LengthType::EXS: + case RNSVG::LengthType::Centimeter: + case RNSVG::LengthType::Millimeter: + case RNSVG::LengthType::Inch: + case RNSVG::LengthType::Point: + case RNSVG::LengthType::Pica: + default: + // Unsupported unit type + __fallthrough; + case RNSVG::LengthType::Number: + return {value.Value, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; + } +} +} // namespace winrt::RNSVG diff --git a/windows/RNSVG/Utils.h b/windows/RNSVG/Utils.h index c6a53f9c5..72be64ea6 100644 --- a/windows/RNSVG/Utils.h +++ b/windows/RNSVG/Utils.h @@ -321,11 +321,7 @@ struct Utils { static com_ptr GetCanvasBrush( hstring const &brushId, -#ifdef USE_FABRIC - winrt::Microsoft::ReactNative::Color const &color, -#else Windows::UI::Color const &color, -#endif RNSVG::SvgView const &root, com_ptr const &geometry, RNSVG::D2DDeviceContext const &context) { @@ -337,11 +333,7 @@ struct Utils { if (root && brushId != L"") { if (brushId == L"currentColor") { com_ptr scb; -#ifdef USE_FABRIC - winColor = root.CurrentColor().AsWindowsColor(root.Theme()); -#else winColor = root.CurrentColor(); -#endif deviceContext->CreateSolidColorBrush(D2DHelpers::AsD2DColor(winColor), scb.put()); brush = scb.as(); } else if (auto const &brushView{root.Brushes().TryLookup(brushId)}) { @@ -360,11 +352,7 @@ struct Utils { if (!brush) { com_ptr scb; assert(root != nullptr); -#ifdef USE_FABRIC - winColor = color.AsWindowsColor(root.Theme()); -#else winColor = color; -#endif deviceContext->CreateSolidColorBrush(D2DHelpers::AsD2DColor(winColor), scb.put()); brush = scb.as(); } diff --git a/windows/RNSVG/packages.lock.json b/windows/RNSVG/packages.lock.json index 0c3b2eabf..f371378e7 100644 --- a/windows/RNSVG/packages.lock.json +++ b/windows/RNSVG/packages.lock.json @@ -2,14 +2,17 @@ "version": 1, "dependencies": { "native,Version=v0.0": { - "Microsoft.UI.Xaml": { + "boost": { "type": "Direct", - "requested": "[2.8.0, )", - "resolved": "2.8.0", - "contentHash": "vxdHxTr63s5KVtNddMFpgvjBjUH50z7seq/5jLWmmSuf8poxg+sXrywkofUdE8ZstbpO9y3FL/IXXUcPYbeesA==", - "dependencies": { - "Microsoft.Web.WebView2": "1.0.1264.42" - } + "requested": "[1.83.0, )", + "resolved": "1.83.0", + "contentHash": "cy53VNMzysEMvhBixDe8ujPk67Fcj3v6FPHQnH91NYJNLHpc6jxa2xq9ruCaaJjE4M3YrGSHDi4uUSTGBWw6EQ==" + }, + "Microsoft.VCRTForwarders.140": { + "type": "Direct", + "requested": "[1.0.2-rc, )", + "resolved": "1.0.2-rc", + "contentHash": "/r+sjtEeCIGyDhobIZ5hSmYhC/dSyGZxf1SxYJpElUhB0LMCktOMFs9gXrauXypIFECpVynNyVjAmJt6hjJ5oQ==" }, "Microsoft.Windows.CppWinRT": { "type": "Direct", @@ -17,20 +20,24 @@ "resolved": "2.0.230706.1", "contentHash": "l0D7oCw/5X+xIKHqZTi62TtV+1qeSz7KVluNFdrJ9hXsst4ghvqQ/Yhura7JqRdZWBXAuDS0G0KwALptdoxweQ==" }, - "boost": { - "type": "Transitive", - "resolved": "1.83.0", - "contentHash": "cy53VNMzysEMvhBixDe8ujPk67Fcj3v6FPHQnH91NYJNLHpc6jxa2xq9ruCaaJjE4M3YrGSHDi4uUSTGBWw6EQ==" + "Microsoft.WindowsAppSDK": { + "type": "Direct", + "requested": "[1.5.240227000, )", + "resolved": "1.5.240227000", + "contentHash": "6rESOsREi8534J7IDpNfFYPvxQaSleXKt4A7ZYPeQyckNMQ0o1W0jZ420bJbEMz9Cw/S/8IbpPftLLZ9w/GTCQ==", + "dependencies": { + "Microsoft.Windows.SDK.BuildTools": "10.0.22621.756" + } }, "Microsoft.JavaScript.Hermes": { "type": "Transitive", "resolved": "0.1.23", "contentHash": "cA9t1GjY4Yo0JD1AfA//e1lOwk48hLANfuX6GXrikmEBNZVr2TIX5ONJt5tqCnpZyLz6xGiPDgTfFNKbSfb21g==" }, - "Microsoft.Web.WebView2": { + "Microsoft.Windows.SDK.BuildTools": { "type": "Transitive", - "resolved": "1.0.1264.42", - "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" + "resolved": "10.0.22621.756", + "contentHash": "7ZL2sFSioYm1Ry067Kw1hg0SCcW5kuVezC2SwjGbcPE61Nn+gTbH86T73G3LcEOVj0S3IZzNuE/29gZvOLS7VA==" }, "common": { "type": "Project", @@ -54,7 +61,7 @@ "Common": "[1.0.0, )", "Folly": "[1.0.0, )", "Microsoft.JavaScript.Hermes": "[0.1.23, )", - "Microsoft.UI.Xaml": "[2.8.0, )", + "Microsoft.WindowsAppSDK": "[1.5.240227000, )", "ReactCommon": "[1.0.0, )", "boost": "[1.83.0, )" } @@ -66,55 +73,6 @@ "boost": "[1.83.0, )" } } - }, - "native,Version=v0.0/win10-arm": { - "Microsoft.Web.WebView2": { - "type": "Transitive", - "resolved": "1.0.1264.42", - "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" - } - }, - "native,Version=v0.0/win10-arm-aot": { - "Microsoft.Web.WebView2": { - "type": "Transitive", - "resolved": "1.0.1264.42", - "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" - } - }, - "native,Version=v0.0/win10-arm64-aot": { - "Microsoft.Web.WebView2": { - "type": "Transitive", - "resolved": "1.0.1264.42", - "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" - } - }, - "native,Version=v0.0/win10-x64": { - "Microsoft.Web.WebView2": { - "type": "Transitive", - "resolved": "1.0.1264.42", - "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" - } - }, - "native,Version=v0.0/win10-x64-aot": { - "Microsoft.Web.WebView2": { - "type": "Transitive", - "resolved": "1.0.1264.42", - "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" - } - }, - "native,Version=v0.0/win10-x86": { - "Microsoft.Web.WebView2": { - "type": "Transitive", - "resolved": "1.0.1264.42", - "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" - } - }, - "native,Version=v0.0/win10-x86-aot": { - "Microsoft.Web.WebView2": { - "type": "Transitive", - "resolved": "1.0.1264.42", - "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" - } } } } \ No newline at end of file From e10a2226fcb6050c5301973e3a4f67f556c5b22f Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Fri, 1 Nov 2024 11:04:44 -0700 Subject: [PATCH 03/13] Simplify build --- windows/RNSVG/Fabric.idl | 124 -------------------- windows/RNSVG/Fabric/BrushView.cpp | 30 ----- windows/RNSVG/Fabric/BrushView.h | 33 ------ windows/RNSVG/Fabric/CircleView.cpp | 5 - windows/RNSVG/Fabric/CircleView.h | 4 +- windows/RNSVG/Fabric/ClipPathView.cpp | 10 +- windows/RNSVG/Fabric/ClipPathView.h | 3 +- windows/RNSVG/Fabric/DefsView.cpp | 5 - windows/RNSVG/Fabric/DefsView.h | 3 +- windows/RNSVG/Fabric/EllipseView.cpp | 6 - windows/RNSVG/Fabric/EllipseView.h | 3 +- windows/RNSVG/Fabric/GroupView.cpp | 8 -- windows/RNSVG/Fabric/GroupView.h | 4 +- windows/RNSVG/Fabric/ImageView.cpp | 12 -- windows/RNSVG/Fabric/ImageView.h | 3 +- windows/RNSVG/Fabric/LineView.cpp | 6 - windows/RNSVG/Fabric/LineView.h | 3 +- windows/RNSVG/Fabric/LinearGradientView.cpp | 9 +- windows/RNSVG/Fabric/LinearGradientView.h | 3 +- windows/RNSVG/Fabric/MarkerView.cpp | 5 - windows/RNSVG/Fabric/MarkerView.h | 3 +- windows/RNSVG/Fabric/MaskView.cpp | 6 - windows/RNSVG/Fabric/MaskView.h | 3 +- windows/RNSVG/Fabric/PathView.cpp | 7 -- windows/RNSVG/Fabric/PathView.h | 3 +- windows/RNSVG/Fabric/PatternView.cpp | 6 - windows/RNSVG/Fabric/PatternView.h | 3 +- windows/RNSVG/Fabric/RadialGradientView.cpp | 8 +- windows/RNSVG/Fabric/RadialGradientView.h | 3 +- windows/RNSVG/Fabric/RectView.cpp | 6 - windows/RNSVG/Fabric/RectView.h | 3 +- windows/RNSVG/Fabric/RenderableView.cpp | 10 +- windows/RNSVG/Fabric/RenderableView.h | 19 ++- windows/RNSVG/Fabric/SvgView.cpp | 13 +- windows/RNSVG/Fabric/SvgView.h | 9 +- windows/RNSVG/Fabric/SymbolView.cpp | 5 - windows/RNSVG/Fabric/SymbolView.h | 3 +- windows/RNSVG/Fabric/TSpanView.cpp | 6 - windows/RNSVG/Fabric/TSpanView.h | 3 +- windows/RNSVG/Fabric/TextView.cpp | 6 - windows/RNSVG/Fabric/TextView.h | 3 +- windows/RNSVG/Fabric/UseView.cpp | 6 - windows/RNSVG/Fabric/UseView.h | 3 +- windows/RNSVG/RNSVG.vcxproj | 3 +- 44 files changed, 43 insertions(+), 376 deletions(-) delete mode 100644 windows/RNSVG/Fabric.idl delete mode 100644 windows/RNSVG/Fabric/BrushView.cpp delete mode 100644 windows/RNSVG/Fabric/BrushView.h diff --git a/windows/RNSVG/Fabric.idl b/windows/RNSVG/Fabric.idl deleted file mode 100644 index eaa4fab6d..000000000 --- a/windows/RNSVG/Fabric.idl +++ /dev/null @@ -1,124 +0,0 @@ -import "Views.idl"; - -namespace RNSVG -{ - [experimental] - [default_interface] - runtimeclass SvgView - { - }; - - [experimental] - [default_interface] - unsealed runtimeclass RenderableView - { - }; - - [experimental] - [default_interface] - runtimeclass RectView : RenderableView - { - }; - - [experimental] - [default_interface] - runtimeclass CircleView : RenderableView - { - }; - - [experimental] - [default_interface] - runtimeclass EllipseView : RenderableView - { - }; - - [experimental] - [default_interface] - runtimeclass LineView : RenderableView - { - }; - - [experimental] - [default_interface] - runtimeclass PathView : RenderableView - { - }; - - [experimental] - [default_interface] - runtimeclass UseView : RenderableView - { - }; - - [experimental] - [default_interface] - runtimeclass ImageView : RenderableView - { - }; - - [experimental] - [default_interface] - unsealed runtimeclass GroupView : RenderableView - { - }; - - [experimental] - [default_interface] - unsealed runtimeclass TextView : GroupView - { - }; - - [experimental] - [default_interface] - runtimeclass TSpanView : TextView - { - }; - - [experimental] - [default_interface] - runtimeclass DefsView : GroupView - { - }; - - [experimental] - [default_interface] - runtimeclass SymbolView : GroupView - { - }; - - [experimental] - [default_interface] - runtimeclass ClipPathView : GroupView - { - }; - - [experimental] - [default_interface] - runtimeclass MarkerView : GroupView - { - }; - - [experimental] - [default_interface] - runtimeclass MaskView : GroupView - { - }; - - [experimental] - [default_interface] - runtimeclass LinearGradientView : GroupView - { - }; - - [experimental] - [default_interface] - runtimeclass RadialGradientView : GroupView - { - }; - - [experimental] - [default_interface] - runtimeclass PatternView : GroupView - { - }; -} \ No newline at end of file diff --git a/windows/RNSVG/Fabric/BrushView.cpp b/windows/RNSVG/Fabric/BrushView.cpp deleted file mode 100644 index 903b161ca..000000000 --- a/windows/RNSVG/Fabric/BrushView.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "pch.h" -#include "BrushView.h" -#if __has_include("BrushView.g.cpp") -#include "BrushView.g.cpp" -#endif - -#include "D2DHelpers.h" - -namespace winrt::RNSVG::implementation { - -void BrushView::SaveDefinition() { - if (auto const &root{SvgRoot()}) { - CreateBrush(); - root.Brushes().Insert(Id(), *this); - } -} - -void BrushView::SetBounds(Rect const &rect) { - m_bounds = D2DHelpers::AsD2DRect(rect); - UpdateBounds(); -} - -void BrushView::Unload() { - if (m_brush) { - m_brush = nullptr; - } - - __super::Unload(); -} -} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/BrushView.h b/windows/RNSVG/Fabric/BrushView.h deleted file mode 100644 index 6c83ebdea..000000000 --- a/windows/RNSVG/Fabric/BrushView.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once -#include "BrushView.g.h" -#include "GroupView.h" -#include "D2DBrush.h" - -namespace winrt::RNSVG::implementation { -struct BrushView : BrushViewT { - public: - BrushView() = default; - - // IRenderable - void SaveDefinition(); - - RNSVG::D2DBrush Brush() { return m_brush; } - virtual void CreateBrush() {} - virtual void Unload(); - void SetBounds(Windows::Foundation::Rect const &rect); - - protected: - RNSVG::D2DBrush m_brush; - D2D1_RECT_F m_bounds; - D2D1::Matrix3x2F m_transform{D2D1::Matrix3x2F::Identity()}; - - virtual void UpdateBounds() {} -}; -} // namespace winrt::RNSVG::implementation - -#ifndef USE_FABRIC -namespace winrt::RNSVG::factory_implementation { -struct BrushView : BrushViewT {}; -} // namespace winrt::RNSVG::factory_implementation -#endif - diff --git a/windows/RNSVG/Fabric/CircleView.cpp b/windows/RNSVG/Fabric/CircleView.cpp index aa2c0e8a6..2eeb8506a 100644 --- a/windows/RNSVG/Fabric/CircleView.cpp +++ b/windows/RNSVG/Fabric/CircleView.cpp @@ -1,10 +1,5 @@ #include "pch.h" #include "CircleView.h" -#if __has_include("CircleView.g.cpp") -#include "CircleView.g.cpp" -#endif - -#include "JSValueXaml.h" using namespace winrt; using namespace Microsoft::ReactNative; diff --git a/windows/RNSVG/Fabric/CircleView.h b/windows/RNSVG/Fabric/CircleView.h index 3e52650d3..c96eb9708 100644 --- a/windows/RNSVG/Fabric/CircleView.h +++ b/windows/RNSVG/Fabric/CircleView.h @@ -4,7 +4,6 @@ #include "CircleProps.g.h" #endif -#include "CircleView.g.h" #include "RenderableView.h" namespace winrt::RNSVG::implementation { @@ -27,7 +26,8 @@ struct CircleProps : CirclePropsT { D2D1_SVG_LENGTH cy{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; }; -struct CircleView : CircleViewT { + +struct CircleView : winrt::implements { public: CircleView() = default; diff --git a/windows/RNSVG/Fabric/ClipPathView.cpp b/windows/RNSVG/Fabric/ClipPathView.cpp index 23ee6337d..1c19f09ad 100644 --- a/windows/RNSVG/Fabric/ClipPathView.cpp +++ b/windows/RNSVG/Fabric/ClipPathView.cpp @@ -1,13 +1,8 @@ #include "pch.h" #include "ClipPathView.h" -#if __has_include("ClipPathView.g.cpp") -#include "ClipPathView.g.cpp" -#endif - -using namespace winrt; namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC + ClipPathProps::ClipPathProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} void ClipPathProps::SetProp( @@ -17,7 +12,6 @@ void ClipPathProps::SetProp( winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); } - const wchar_t *ClipPathView::GetSvgElementName() noexcept { return L"clipPath"; } @@ -25,5 +19,5 @@ const wchar_t *ClipPathView::GetSvgElementName() noexcept { void ClipPathView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { RegisterRenderableComponent(L"RNSVGClipPath", builder); } -#endif + } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/ClipPathView.h b/windows/RNSVG/Fabric/ClipPathView.h index dd2e097d9..94018f789 100644 --- a/windows/RNSVG/Fabric/ClipPathView.h +++ b/windows/RNSVG/Fabric/ClipPathView.h @@ -1,7 +1,6 @@ #pragma once #include "ClipPathProps.g.h" -#include "ClipPathView.g.h" #include "GroupView.h" namespace winrt::RNSVG::implementation { @@ -18,7 +17,7 @@ struct ClipPathProps : ClipPathPropsT { REACT_SVG_GROUP_COMMON_PROPS; }; -struct ClipPathView : ClipPathViewT { +struct ClipPathView : winrt::implements { public: ClipPathView() = default; diff --git a/windows/RNSVG/Fabric/DefsView.cpp b/windows/RNSVG/Fabric/DefsView.cpp index 66fabb43c..63ecee660 100644 --- a/windows/RNSVG/Fabric/DefsView.cpp +++ b/windows/RNSVG/Fabric/DefsView.cpp @@ -1,10 +1,5 @@ #include "pch.h" #include "DefsView.h" -#if __has_include("DefsView.g.cpp") -#include "DefsView.g.cpp" -#endif - -using namespace winrt; namespace winrt::RNSVG::implementation { diff --git a/windows/RNSVG/Fabric/DefsView.h b/windows/RNSVG/Fabric/DefsView.h index 83454df8c..5620866e6 100644 --- a/windows/RNSVG/Fabric/DefsView.h +++ b/windows/RNSVG/Fabric/DefsView.h @@ -1,7 +1,6 @@ #pragma once #include "DefsProps.g.h" -#include "DefsView.g.h" #include "GroupView.h" namespace winrt::RNSVG::implementation { @@ -19,7 +18,7 @@ struct DefsProps : DefsPropsT { }; -struct DefsView : DefsViewT { +struct DefsView : winrt::implements { public: DefsView() = default; diff --git a/windows/RNSVG/Fabric/EllipseView.cpp b/windows/RNSVG/Fabric/EllipseView.cpp index 13820afb2..6a4e810e5 100644 --- a/windows/RNSVG/Fabric/EllipseView.cpp +++ b/windows/RNSVG/Fabric/EllipseView.cpp @@ -1,11 +1,5 @@ #include "pch.h" #include "EllipseView.h" -#if __has_include("EllipseView.g.cpp") -#include "EllipseView.g.cpp" -#endif - -using namespace winrt; -using namespace Microsoft::ReactNative; namespace winrt::RNSVG::implementation { diff --git a/windows/RNSVG/Fabric/EllipseView.h b/windows/RNSVG/Fabric/EllipseView.h index 9b7039b75..c7cefa6e5 100644 --- a/windows/RNSVG/Fabric/EllipseView.h +++ b/windows/RNSVG/Fabric/EllipseView.h @@ -1,7 +1,6 @@ #pragma once #include "EllipseProps.g.h" -#include "EllipseView.g.h" #include "RenderableView.h" namespace winrt::RNSVG::implementation { @@ -26,7 +25,7 @@ struct EllipseProps : EllipsePropsT { D2D1_SVG_LENGTH ry{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; }; -struct EllipseView : EllipseViewT { +struct EllipseView : winrt::implements { public: EllipseView() = default; diff --git a/windows/RNSVG/Fabric/GroupView.cpp b/windows/RNSVG/Fabric/GroupView.cpp index eabb6734f..5816099e6 100644 --- a/windows/RNSVG/Fabric/GroupView.cpp +++ b/windows/RNSVG/Fabric/GroupView.cpp @@ -3,14 +3,6 @@ #include "JSValueXaml.h" #include "GroupView.h" -#if __has_include("GroupView.g.cpp") -#include "GroupView.g.cpp" -#endif - -#include "../SVGLength.h" - -using namespace winrt; -using namespace Microsoft::ReactNative; namespace winrt::RNSVG::implementation { SvgGroupCommonProps::SvgGroupCommonProps( diff --git a/windows/RNSVG/Fabric/GroupView.h b/windows/RNSVG/Fabric/GroupView.h index b4d94d97b..33f10a417 100644 --- a/windows/RNSVG/Fabric/GroupView.h +++ b/windows/RNSVG/Fabric/GroupView.h @@ -1,5 +1,4 @@ #pragma once -#include "GroupView.g.h" #include "RenderableView.h" #ifdef USE_FABRIC @@ -81,8 +80,7 @@ struct SvgGroupCommonProps }; #endif -struct GroupView - : GroupViewT { +struct GroupView : winrt::implements { public: GroupView() = default; diff --git a/windows/RNSVG/Fabric/ImageView.cpp b/windows/RNSVG/Fabric/ImageView.cpp index 555304eb7..770248915 100644 --- a/windows/RNSVG/Fabric/ImageView.cpp +++ b/windows/RNSVG/Fabric/ImageView.cpp @@ -1,17 +1,5 @@ #include "pch.h" #include "ImageView.h" -#if __has_include("ImageView.g.cpp") -#include "ImageView.g.cpp" -#endif - -#ifndef USE_FABRIC -#include -#endif - -using namespace winrt::Microsoft::ReactNative; -using namespace winrt::Windows::Security::Cryptography; -using namespace winrt::Windows::Storage::Streams; -using namespace winrt::Windows::Web::Http; namespace winrt::RNSVG::implementation { diff --git a/windows/RNSVG/Fabric/ImageView.h b/windows/RNSVG/Fabric/ImageView.h index aaff2e2a6..3a654356a 100644 --- a/windows/RNSVG/Fabric/ImageView.h +++ b/windows/RNSVG/Fabric/ImageView.h @@ -1,7 +1,6 @@ #pragma once #include "ImageProps.g.h" -#include "ImageView.g.h" #include "RenderableView.h" #include @@ -68,7 +67,7 @@ struct ImageProps : ImagePropsT { RNSVG::MeetOrSlice meetOrSlice{RNSVG::MeetOrSlice::Meet}; }; -struct ImageView : ImageViewT { +struct ImageView : winrt::implements { public: ImageView() = default; diff --git a/windows/RNSVG/Fabric/LineView.cpp b/windows/RNSVG/Fabric/LineView.cpp index ad6cc9a56..8126c5b33 100644 --- a/windows/RNSVG/Fabric/LineView.cpp +++ b/windows/RNSVG/Fabric/LineView.cpp @@ -1,11 +1,5 @@ #include "pch.h" #include "LineView.h" -#if __has_include("LineView.g.cpp") -#include "LineView.g.cpp" -#endif - -using namespace winrt; -using namespace Microsoft::ReactNative; namespace winrt::RNSVG::implementation { diff --git a/windows/RNSVG/Fabric/LineView.h b/windows/RNSVG/Fabric/LineView.h index 5b8afa134..d598748ae 100644 --- a/windows/RNSVG/Fabric/LineView.h +++ b/windows/RNSVG/Fabric/LineView.h @@ -1,7 +1,6 @@ #pragma once #include "LineProps.g.h" -#include "LineView.g.h" #include "RenderableView.h" namespace winrt::RNSVG::implementation { @@ -26,7 +25,7 @@ struct LineProps : LinePropsT { D2D1_SVG_LENGTH y2{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; }; -struct LineView : LineViewT { +struct LineView : winrt::implements { public: LineView() = default; diff --git a/windows/RNSVG/Fabric/LinearGradientView.cpp b/windows/RNSVG/Fabric/LinearGradientView.cpp index 52514d904..c4cb83940 100644 --- a/windows/RNSVG/Fabric/LinearGradientView.cpp +++ b/windows/RNSVG/Fabric/LinearGradientView.cpp @@ -1,11 +1,5 @@ #include "pch.h" #include "LinearGradientView.h" -#if __has_include("LinearGradientView.g.cpp") -#include "LinearGradientView.g.cpp" -#endif - -using namespace winrt; -using namespace Microsoft::ReactNative; namespace winrt::RNSVG::implementation { @@ -45,8 +39,7 @@ void LinearGradientView::UpdateProps( m_stops.push_back(stop); } } - - base_type::UpdateProps(view, newProps, oldProps); + RenderableView::UpdateProps(view, newProps, oldProps); } diff --git a/windows/RNSVG/Fabric/LinearGradientView.h b/windows/RNSVG/Fabric/LinearGradientView.h index afe401808..ca013c041 100644 --- a/windows/RNSVG/Fabric/LinearGradientView.h +++ b/windows/RNSVG/Fabric/LinearGradientView.h @@ -1,7 +1,6 @@ #pragma once #include "LinearGradientProps.g.h" -#include "LinearGradientView.g.h" #include "GroupView.h" @@ -40,7 +39,7 @@ struct LinearGradientProps : LinearGradientPropsT> gradientTransform; }; -struct LinearGradientView : LinearGradientViewT { +struct LinearGradientView : winrt::implements { public: LinearGradientView() = default; diff --git a/windows/RNSVG/Fabric/MarkerView.cpp b/windows/RNSVG/Fabric/MarkerView.cpp index 61ca08ff7..5bd422e03 100644 --- a/windows/RNSVG/Fabric/MarkerView.cpp +++ b/windows/RNSVG/Fabric/MarkerView.cpp @@ -1,10 +1,5 @@ #include "pch.h" #include "MarkerView.h" -#if __has_include("MarkerView.g.cpp") -#include "MarkerView.g.cpp" -#endif - -using namespace winrt; namespace winrt::RNSVG::implementation { diff --git a/windows/RNSVG/Fabric/MarkerView.h b/windows/RNSVG/Fabric/MarkerView.h index a8b6e38c9..35e58befe 100644 --- a/windows/RNSVG/Fabric/MarkerView.h +++ b/windows/RNSVG/Fabric/MarkerView.h @@ -1,7 +1,6 @@ #pragma once #include "MarkerProps.g.h" -#include "MarkerView.g.h" #include "GroupView.h" namespace winrt::RNSVG::implementation { @@ -42,7 +41,7 @@ struct MarkerProps : MarkerPropsT { RNSVG::MeetOrSlice meetOrSlice{RNSVG::MeetOrSlice::Meet}; }; -struct MarkerView : MarkerViewT { +struct MarkerView : winrt::implements { public: MarkerView() = default; diff --git a/windows/RNSVG/Fabric/MaskView.cpp b/windows/RNSVG/Fabric/MaskView.cpp index bc15cbd4d..b0977f26e 100644 --- a/windows/RNSVG/Fabric/MaskView.cpp +++ b/windows/RNSVG/Fabric/MaskView.cpp @@ -1,10 +1,5 @@ #include "pch.h" #include "MaskView.h" -#if __has_include("MaskView.g.cpp") -#include "MaskView.g.cpp" -#endif - -using namespace winrt; namespace winrt::RNSVG::implementation { @@ -29,5 +24,4 @@ void MaskView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPack RegisterRenderableComponent(L"RNSVGMask", builder); } - } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/MaskView.h b/windows/RNSVG/Fabric/MaskView.h index e67f390f0..8d5af228a 100644 --- a/windows/RNSVG/Fabric/MaskView.h +++ b/windows/RNSVG/Fabric/MaskView.h @@ -1,7 +1,6 @@ #pragma once #include "MaskProps.g.h" -#include "MaskView.g.h" #include "GroupView.h" namespace winrt::RNSVG::implementation { @@ -30,7 +29,7 @@ struct MaskProps : MaskPropsT { uint32_t maskContentUnits{0}; }; -struct MaskView : MaskViewT { +struct MaskView : winrt::implements { public: MaskView() = default; diff --git a/windows/RNSVG/Fabric/PathView.cpp b/windows/RNSVG/Fabric/PathView.cpp index 601667d81..51270d9a9 100644 --- a/windows/RNSVG/Fabric/PathView.cpp +++ b/windows/RNSVG/Fabric/PathView.cpp @@ -1,14 +1,7 @@ #include "pch.h" #include "PathView.h" -#if __has_include("PathView.g.cpp") -#include "PathView.g.cpp" -#endif #include "d2d1svg.h" -#include - -using namespace winrt; -using namespace Microsoft::ReactNative; namespace winrt::RNSVG::implementation { diff --git a/windows/RNSVG/Fabric/PathView.h b/windows/RNSVG/Fabric/PathView.h index 7179b98ec..6cd01a3dc 100644 --- a/windows/RNSVG/Fabric/PathView.h +++ b/windows/RNSVG/Fabric/PathView.h @@ -1,7 +1,6 @@ #pragma once #include "PathProps.g.h" -#include "PathView.g.h" #include "RenderableView.h" namespace winrt::RNSVG::implementation { @@ -20,7 +19,7 @@ struct PathProps : PathPropsT { std::wstring d; }; -struct PathView : PathViewT { +struct PathView : winrt::implements { public: PathView() = default; diff --git a/windows/RNSVG/Fabric/PatternView.cpp b/windows/RNSVG/Fabric/PatternView.cpp index c0e546139..a0c990dc6 100644 --- a/windows/RNSVG/Fabric/PatternView.cpp +++ b/windows/RNSVG/Fabric/PatternView.cpp @@ -1,11 +1,5 @@ #include "pch.h" #include "PatternView.h" -#if __has_include("PatternView.g.cpp") -#include "PatternView.g.cpp" -#endif - -using namespace winrt; -using namespace Microsoft::ReactNative; namespace winrt::RNSVG::implementation { diff --git a/windows/RNSVG/Fabric/PatternView.h b/windows/RNSVG/Fabric/PatternView.h index 7d7ec60c0..6296e1823 100644 --- a/windows/RNSVG/Fabric/PatternView.h +++ b/windows/RNSVG/Fabric/PatternView.h @@ -1,7 +1,6 @@ #pragma once #include "PatternProps.g.h" -#include "PatternView.g.h" #include "GroupView.h" @@ -47,7 +46,7 @@ struct PatternProps : PatternPropsT { RNSVG::MeetOrSlice meetOrSlice{RNSVG::MeetOrSlice::Meet}; }; -struct PatternView : PatternViewT { +struct PatternView : winrt::implements { public: PatternView() = default; diff --git a/windows/RNSVG/Fabric/RadialGradientView.cpp b/windows/RNSVG/Fabric/RadialGradientView.cpp index cd6229e04..5c997bddd 100644 --- a/windows/RNSVG/Fabric/RadialGradientView.cpp +++ b/windows/RNSVG/Fabric/RadialGradientView.cpp @@ -1,11 +1,5 @@ #include "pch.h" #include "RadialGradientView.h" -#if __has_include("RadialGradientView.g.cpp") -#include "RadialGradientView.g.cpp" -#endif - -using namespace winrt; -using namespace Microsoft::ReactNative; namespace winrt::RNSVG::implementation { @@ -45,7 +39,7 @@ void RadialGradientView::UpdateProps( } } - base_type::UpdateProps(view, newProps, oldProps); + RenderableView::UpdateProps(view, newProps, oldProps); } const wchar_t *RadialGradientView::GetSvgElementName() noexcept { diff --git a/windows/RNSVG/Fabric/RadialGradientView.h b/windows/RNSVG/Fabric/RadialGradientView.h index 6329cb502..66700dd94 100644 --- a/windows/RNSVG/Fabric/RadialGradientView.h +++ b/windows/RNSVG/Fabric/RadialGradientView.h @@ -1,7 +1,6 @@ #pragma once #include "RadialGradientProps.g.h" -#include "RadialGradientView.g.h" #include "GroupView.h" @@ -44,7 +43,7 @@ struct RadialGradientProps : RadialGradientPropsT> gradientTransform; }; -struct RadialGradientView : RadialGradientViewT { +struct RadialGradientView : winrt::implements { public: RadialGradientView() = default; diff --git a/windows/RNSVG/Fabric/RectView.cpp b/windows/RNSVG/Fabric/RectView.cpp index 3ff62473f..353040c9a 100644 --- a/windows/RNSVG/Fabric/RectView.cpp +++ b/windows/RNSVG/Fabric/RectView.cpp @@ -1,11 +1,5 @@ #include "pch.h" #include "RectView.h" -#if __has_include("RectView.g.cpp") -#include "RectView.g.cpp" -#endif - -using namespace winrt; -using namespace Microsoft::ReactNative; namespace winrt::RNSVG::implementation { diff --git a/windows/RNSVG/Fabric/RectView.h b/windows/RNSVG/Fabric/RectView.h index 0656d6ee2..71b179fc4 100644 --- a/windows/RNSVG/Fabric/RectView.h +++ b/windows/RNSVG/Fabric/RectView.h @@ -1,7 +1,6 @@ #pragma once #include "RectProps.g.h" -#include "RectView.g.h" #include "RenderableView.h" namespace winrt::RNSVG::implementation { @@ -30,7 +29,7 @@ struct RectProps : RectPropsT { D2D1_SVG_LENGTH ry{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; }; -struct RectView : RectViewT { +struct RectView : winrt::implements { public: RectView() = default; diff --git a/windows/RNSVG/Fabric/RenderableView.cpp b/windows/RNSVG/Fabric/RenderableView.cpp index 5949c4572..f12d889dc 100644 --- a/windows/RNSVG/Fabric/RenderableView.cpp +++ b/windows/RNSVG/Fabric/RenderableView.cpp @@ -1,15 +1,9 @@ #include "pch.h" #include "RenderableView.h" -#if __has_include("RenderableView.g.cpp") -#include "RenderableView.g.cpp" -#endif #include "SvgView.h" #include "../D2DHelpers.h" -using namespace winrt; -using namespace Microsoft::ReactNative; - namespace winrt::Microsoft::ReactNative { void WriteValue(IJSValueWriter const &writer, const D2D1_SVG_LENGTH &value) noexcept { @@ -252,10 +246,10 @@ void SvgRenderableCommonProps::SetProp( } void RenderableView::Invalidate(const winrt::Microsoft::ReactNative::ComponentView &view) { - winrt::com_ptr svgView{nullptr}; + winrt::com_ptr svgView{nullptr}; auto current = view.Parent(); while (current && !svgView) { - svgView = current.UserData().try_as(); + svgView = current.UserData().try_as(); current = current.Parent(); } diff --git a/windows/RNSVG/Fabric/RenderableView.h b/windows/RNSVG/Fabric/RenderableView.h index 32d02c046..c3f1c8af4 100644 --- a/windows/RNSVG/Fabric/RenderableView.h +++ b/windows/RNSVG/Fabric/RenderableView.h @@ -1,6 +1,5 @@ #pragma once -#include "RenderableView.g.h" #include "../SVGLength.h" #ifdef USE_FABRIC @@ -151,8 +150,9 @@ struct SvgRenderableCommonProps std::optional> propList; }; -struct RenderableView : RenderableViewT { - public: +struct __declspec(uuid("a03986c0-b06e-4fb8-a86e-16fcc47b2f31")) RenderableView : public ::IUnknown { + +public: RenderableView() = default; virtual const wchar_t* GetSvgElementName() noexcept = 0; @@ -174,15 +174,11 @@ struct RenderableView : RenderableViewT { const winrt::Microsoft::ReactNative::ComponentView & /*view*/, winrt::Microsoft::ReactNative::ComponentViewUpdateMask mask) noexcept; - const winrt::Windows::Foundation::Collections::IVector &Children() const noexcept; - ID2D1SvgElement &Render(const SvgView &svgView, ID2D1SvgDocument &document, ID2D1SvgElement &svgElement) noexcept; virtual void OnRender(ID2D1SvgDocument &document, ID2D1SvgElement & /*svgElement*/) noexcept; virtual bool IsSupported() const noexcept; - RNSVG::SvgView SvgRoot(); - void Invalidate(const winrt::Microsoft::ReactNative::ComponentView &view); protected: @@ -190,7 +186,6 @@ struct RenderableView : RenderableViewT { private: winrt::com_ptr m_spD2DSvgElement; - Microsoft::ReactNative::IReactContext m_reactContext{nullptr}; // TODO need? }; } // namespace winrt::RNSVG::implementation @@ -208,25 +203,25 @@ void RegisterRenderableComponent(const winrt::hstring& name, const winrt::Micros builder.SetUpdatePropsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view, const winrt::Microsoft::ReactNative::IComponentProps &newProps, const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept { - auto userData = view.UserData().as(); + auto userData = winrt::get_self(view.UserData()); userData->UpdateProps(view, newProps, oldProps); }); builder.SetFinalizeUpdateHandler( [](const winrt::Microsoft::ReactNative::ComponentView &view, const winrt::Microsoft::ReactNative::ComponentViewUpdateMask mask) noexcept { - auto userData = view.UserData().as(); + auto userData = winrt::get_self(view.UserData()); userData->FinalizeUpates(view, mask); }); builder.SetMountChildComponentViewHandler( [](const winrt::Microsoft::ReactNative::ComponentView &view, const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept { - auto userData = view.UserData().as(); + auto userData = winrt::get_self(view.UserData()); return userData->MountChildComponentView(view, args); }); builder.SetUnmountChildComponentViewHandler( [](const winrt::Microsoft::ReactNative::ComponentView &view, const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept { - auto userData = view.UserData().as(); + auto userData = winrt::get_self(view.UserData()); return userData->UnmountChildComponentView(view, args); }); }); diff --git a/windows/RNSVG/Fabric/SvgView.cpp b/windows/RNSVG/Fabric/SvgView.cpp index df1cda293..4146764fa 100644 --- a/windows/RNSVG/Fabric/SvgView.cpp +++ b/windows/RNSVG/Fabric/SvgView.cpp @@ -1,9 +1,6 @@ #include "pch.h" #include "SvgView.h" -#if __has_include("SvgView.g.cpp") -#include "SvgView.g.cpp" -#endif #include #include @@ -20,8 +17,6 @@ #include -using namespace winrt; - namespace winrt::RNSVG::implementation { SvgViewProps::SvgViewProps(const winrt::Microsoft::ReactNative::ViewProps &props) : m_props(props) {} @@ -171,28 +166,28 @@ void SvgView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPacka builder.SetUpdatePropsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view, const winrt::Microsoft::ReactNative::IComponentProps &newProps, const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept { - auto userData = view.UserData().as(); + auto userData = winrt::get_self(view.UserData()); userData->UpdateProps(view, newProps, oldProps); }); builder.SetFinalizeUpdateHandler( [](const winrt::Microsoft::ReactNative::ComponentView &view, const winrt::Microsoft::ReactNative::ComponentViewUpdateMask mask) noexcept { - auto userData = view.UserData().as(); + auto userData = winrt::get_self(view.UserData()); userData->FinalizeUpates(view, mask); }); builder.SetMountChildComponentViewHandler( [](const winrt::Microsoft::ReactNative::ComponentView &view, const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept { - auto userData = view.UserData().as(); + auto userData = winrt::get_self(view.UserData()); return userData->MountChildComponentView(view, args); }); builder.SetUnmountChildComponentViewHandler( [](const winrt::Microsoft::ReactNative::ComponentView &view, const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept { - auto userData = view.UserData().as(); + auto userData = winrt::get_self(view.UserData()); return userData->UnmountChildComponentView(view, args); }); }); diff --git a/windows/RNSVG/Fabric/SvgView.h b/windows/RNSVG/Fabric/SvgView.h index 8724fd90e..594a6baf2 100644 --- a/windows/RNSVG/Fabric/SvgView.h +++ b/windows/RNSVG/Fabric/SvgView.h @@ -1,7 +1,5 @@ #pragma once -#include "SvgView.g.h" - #include "SvgViewProps.g.h" #include @@ -42,7 +40,12 @@ struct SvgViewProps : SvgViewPropsT { winrt::Microsoft::ReactNative::ViewProps m_props{nullptr}; }; -struct SvgView : SvgViewT { +struct __declspec(uuid("ed381ffa-461a-48Bf-a3c0-5d9a42eecd30")) ISvgView : public ::IUnknown { + virtual void Invalidate() = 0; +}; + +struct SvgView : winrt::implements { + //struct SvgView : SvgViewT { public: SvgView(const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext); diff --git a/windows/RNSVG/Fabric/SymbolView.cpp b/windows/RNSVG/Fabric/SymbolView.cpp index 239ea3e9a..aba199238 100644 --- a/windows/RNSVG/Fabric/SymbolView.cpp +++ b/windows/RNSVG/Fabric/SymbolView.cpp @@ -1,10 +1,5 @@ #include "pch.h" #include "SymbolView.h" -#if __has_include("SymbolView.g.cpp") -#include "SymbolView.g.cpp" -#endif - -using namespace winrt; namespace winrt::RNSVG::implementation { diff --git a/windows/RNSVG/Fabric/SymbolView.h b/windows/RNSVG/Fabric/SymbolView.h index 1d4efc2b1..0bb15c4ac 100644 --- a/windows/RNSVG/Fabric/SymbolView.h +++ b/windows/RNSVG/Fabric/SymbolView.h @@ -1,7 +1,6 @@ #pragma once #include "SymbolProps.g.h" -#include "SymbolView.g.h" #include "GroupView.h" namespace winrt::RNSVG::implementation { @@ -31,7 +30,7 @@ struct SymbolProps : SymbolPropsT { RNSVG::MeetOrSlice meetOrSlice{RNSVG::MeetOrSlice::Meet}; }; -struct SymbolView : SymbolViewT { +struct SymbolView : winrt::implements { public: SymbolView() = default; diff --git a/windows/RNSVG/Fabric/TSpanView.cpp b/windows/RNSVG/Fabric/TSpanView.cpp index 22b9bec2c..7f2c20022 100644 --- a/windows/RNSVG/Fabric/TSpanView.cpp +++ b/windows/RNSVG/Fabric/TSpanView.cpp @@ -1,11 +1,5 @@ #include "pch.h" #include "TSpanView.h" -#if __has_include("TSpanView.g.cpp") -#include "TSpanView.g.cpp" -#endif - -using namespace winrt; -using namespace Microsoft::ReactNative; namespace winrt::RNSVG::implementation { diff --git a/windows/RNSVG/Fabric/TSpanView.h b/windows/RNSVG/Fabric/TSpanView.h index 4cf582bad..b2767b59b 100644 --- a/windows/RNSVG/Fabric/TSpanView.h +++ b/windows/RNSVG/Fabric/TSpanView.h @@ -1,7 +1,6 @@ #pragma once #include "TSpanProps.g.h" -#include "TSpanView.g.h" #include "TextView.h" namespace winrt::RNSVG::implementation { @@ -22,7 +21,7 @@ struct TSpanProps : TSpanPropsT { std::string content{""}; }; -struct TSpanView : TSpanViewT { +struct TSpanView : winrt::implements { public: TSpanView() = default; diff --git a/windows/RNSVG/Fabric/TextView.cpp b/windows/RNSVG/Fabric/TextView.cpp index 650ba4292..417942ff1 100644 --- a/windows/RNSVG/Fabric/TextView.cpp +++ b/windows/RNSVG/Fabric/TextView.cpp @@ -1,11 +1,5 @@ #include "pch.h" #include "TextView.h" -#if __has_include("TextView.g.cpp") -#include "TextView.g.cpp" -#endif - -using namespace winrt; -using namespace Microsoft::ReactNative; namespace winrt::RNSVG::implementation { diff --git a/windows/RNSVG/Fabric/TextView.h b/windows/RNSVG/Fabric/TextView.h index b517a8432..0cdcd7d4a 100644 --- a/windows/RNSVG/Fabric/TextView.h +++ b/windows/RNSVG/Fabric/TextView.h @@ -1,7 +1,6 @@ #pragma once #include "SvgTextCommonProps.g.h" -#include "TextView.g.h" #include "GroupView.h" namespace winrt::RNSVG::implementation { @@ -44,7 +43,7 @@ struct SvgTextCommonProps : SvgTextCommonPropsT { +struct TextView : winrt::implements { public: TextView() = default; diff --git a/windows/RNSVG/Fabric/UseView.cpp b/windows/RNSVG/Fabric/UseView.cpp index 40bb7ba93..7acb97192 100644 --- a/windows/RNSVG/Fabric/UseView.cpp +++ b/windows/RNSVG/Fabric/UseView.cpp @@ -1,11 +1,5 @@ #include "pch.h" #include "UseView.h" -#if __has_include("UseView.g.cpp") -#include "UseView.g.cpp" -#endif - -using namespace winrt; -using namespace Microsoft::ReactNative; namespace winrt::RNSVG::implementation { diff --git a/windows/RNSVG/Fabric/UseView.h b/windows/RNSVG/Fabric/UseView.h index ac371b3ea..ec390acab 100644 --- a/windows/RNSVG/Fabric/UseView.h +++ b/windows/RNSVG/Fabric/UseView.h @@ -1,7 +1,6 @@ #pragma once #include "UseProps.g.h" -#include "UseView.g.h" #include "RenderableView.h" namespace winrt::RNSVG::implementation { @@ -28,7 +27,7 @@ struct UseProps : UsePropsT { D2D1_SVG_LENGTH height{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; }; -struct UseView : UseViewT { +struct UseView : winrt::implements { public: UseView() = default; diff --git a/windows/RNSVG/RNSVG.vcxproj b/windows/RNSVG/RNSVG.vcxproj index 63a227885..e54c308de 100644 --- a/windows/RNSVG/RNSVG.vcxproj +++ b/windows/RNSVG/RNSVG.vcxproj @@ -275,13 +275,12 @@ - - + From 1a3dc02e65ca1ff4fe99bfd5f030362777a94fcf Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Sat, 2 Nov 2024 09:23:07 -0700 Subject: [PATCH 04/13] Simplify props --- windows/RNSVG/D2DHelpers.h | 3 +- windows/RNSVG/Fabric/CircleView.cpp | 53 +-- windows/RNSVG/Fabric/CircleView.h | 32 +- windows/RNSVG/Fabric/ClipPathView.cpp | 34 +- windows/RNSVG/Fabric/ClipPathView.h | 21 +- windows/RNSVG/Fabric/DefsView.cpp | 38 ++- windows/RNSVG/Fabric/DefsView.h | 23 +- windows/RNSVG/Fabric/EllipseView.cpp | 55 +-- windows/RNSVG/Fabric/EllipseView.h | 30 +- windows/RNSVG/Fabric/GroupView.cpp | 44 ++- windows/RNSVG/Fabric/GroupView.h | 38 +-- windows/RNSVG/Fabric/ImageView.cpp | 2 +- windows/RNSVG/Fabric/ImageView.h | 19 +- windows/RNSVG/Fabric/LineView.cpp | 55 +-- windows/RNSVG/Fabric/LineView.h | 31 +- windows/RNSVG/Fabric/LinearGradientView.cpp | 178 ++++++---- windows/RNSVG/Fabric/LinearGradientView.h | 51 +-- windows/RNSVG/Fabric/MarkerView.cpp | 27 -- windows/RNSVG/Fabric/MarkerView.h | 54 --- windows/RNSVG/Fabric/MaskView.cpp | 27 -- windows/RNSVG/Fabric/MaskView.h | 42 --- windows/RNSVG/Fabric/PathView.cpp | 54 +-- windows/RNSVG/Fabric/PathView.h | 26 +- windows/RNSVG/Fabric/PatternView.cpp | 28 -- windows/RNSVG/Fabric/PatternView.h | 59 ---- windows/RNSVG/Fabric/RadialGradientView.cpp | 224 ++++++------ windows/RNSVG/Fabric/RadialGradientView.h | 55 +-- windows/RNSVG/Fabric/RectView.cpp | 89 +++-- windows/RNSVG/Fabric/RectView.h | 35 +- windows/RNSVG/Fabric/RenderableView.cpp | 142 +------- windows/RNSVG/Fabric/RenderableView.h | 358 ++++++++++++-------- windows/RNSVG/Fabric/SvgView.h | 4 +- windows/RNSVG/Fabric/SymbolView.cpp | 27 -- windows/RNSVG/Fabric/SymbolView.h | 44 --- windows/RNSVG/Fabric/TSpanView.cpp | 27 -- windows/RNSVG/Fabric/TSpanView.h | 35 -- windows/RNSVG/Fabric/TextView.cpp | 27 -- windows/RNSVG/Fabric/TextView.h | 56 --- windows/RNSVG/Fabric/UnsupportedSvgView.cpp | 33 ++ windows/RNSVG/Fabric/UnsupportedSvgView.h | 9 + windows/RNSVG/Fabric/UseView.cpp | 75 ++-- windows/RNSVG/Fabric/UseView.h | 32 +- windows/RNSVG/RNSVG.vcxproj | 9 +- windows/RNSVG/ReactPackageProvider.cpp | 41 +-- windows/RNSVG/ViewProps.idl | 107 ------ 45 files changed, 862 insertions(+), 1591 deletions(-) delete mode 100644 windows/RNSVG/Fabric/MarkerView.cpp delete mode 100644 windows/RNSVG/Fabric/MarkerView.h delete mode 100644 windows/RNSVG/Fabric/MaskView.cpp delete mode 100644 windows/RNSVG/Fabric/MaskView.h delete mode 100644 windows/RNSVG/Fabric/PatternView.cpp delete mode 100644 windows/RNSVG/Fabric/PatternView.h delete mode 100644 windows/RNSVG/Fabric/SymbolView.cpp delete mode 100644 windows/RNSVG/Fabric/SymbolView.h delete mode 100644 windows/RNSVG/Fabric/TSpanView.cpp delete mode 100644 windows/RNSVG/Fabric/TSpanView.h delete mode 100644 windows/RNSVG/Fabric/TextView.cpp delete mode 100644 windows/RNSVG/Fabric/TextView.h create mode 100644 windows/RNSVG/Fabric/UnsupportedSvgView.cpp create mode 100644 windows/RNSVG/Fabric/UnsupportedSvgView.h delete mode 100644 windows/RNSVG/ViewProps.idl diff --git a/windows/RNSVG/D2DHelpers.h b/windows/RNSVG/D2DHelpers.h index 48cc11941..3f0a27e1c 100644 --- a/windows/RNSVG/D2DHelpers.h +++ b/windows/RNSVG/D2DHelpers.h @@ -43,7 +43,7 @@ struct D2DHelpers { deviceContext->PushLayer(layerParams, opacityLayer.get()); } - +#ifndef USE_FABRIC static D2D1_CAP_STYLE GetLineCap(RNSVG::LineCap const &lineCap) { switch (lineCap) { case RNSVG::LineCap::Square: @@ -77,6 +77,7 @@ struct D2DHelpers { return D2D1_FILL_MODE_WINDING; } } +#endif static D2D1::ColorF AsD2DColor(winrt::Windows::UI::Color const &color) { return { diff --git a/windows/RNSVG/Fabric/CircleView.cpp b/windows/RNSVG/Fabric/CircleView.cpp index 2eeb8506a..d376cd567 100644 --- a/windows/RNSVG/Fabric/CircleView.cpp +++ b/windows/RNSVG/Fabric/CircleView.cpp @@ -1,32 +1,45 @@ #include "pch.h" #include "CircleView.h" -using namespace winrt; -using namespace Microsoft::ReactNative; - namespace winrt::RNSVG::implementation { -CircleProps::CircleProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} +REACT_STRUCT(CircleProps) +struct CircleProps : public winrt::implements { + CircleProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT {} -void CircleProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); + } -const wchar_t *CircleView::GetSvgElementName() noexcept { - return L"circle"; -} + REACT_SVG_RENDERABLE_COMMON_PROPS; -void CircleView::OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement &svgElement) noexcept { - auto props = m_props.as(); - svgElement.SetAttributeValue(SvgStrings::cxAttributeName, props->cx); - svgElement.SetAttributeValue(SvgStrings::cyAttributeName, props->cy); - svgElement.SetAttributeValue(SvgStrings::rAttributeName, props->r); -} + REACT_FIELD(r) + D2D1_SVG_LENGTH r{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; + REACT_FIELD(cx) + D2D1_SVG_LENGTH cx{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; + REACT_FIELD(cy) + D2D1_SVG_LENGTH cy{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; +}; + +struct CircleView : winrt::implements { + public: + CircleView() = default; + + const wchar_t *GetSvgElementName() noexcept override { + return L"circle"; + } + void OnRender(const SvgView &svgView, ID2D1SvgDocument &document, ID2D1SvgElement &element) noexcept override { + auto props = winrt::get_self(m_props); + + SetCommonSvgProps(svgView, document, element, *props); + + element.SetAttributeValue(SvgStrings::cxAttributeName, props->cx); + element.SetAttributeValue(SvgStrings::cyAttributeName, props->cy); + element.SetAttributeValue(SvgStrings::rAttributeName, props->r); + } +}; -void CircleView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { +void RegisterCircleComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { RegisterRenderableComponent(L"RNSVGCircle", builder); } diff --git a/windows/RNSVG/Fabric/CircleView.h b/windows/RNSVG/Fabric/CircleView.h index c96eb9708..2b03d4c22 100644 --- a/windows/RNSVG/Fabric/CircleView.h +++ b/windows/RNSVG/Fabric/CircleView.h @@ -1,39 +1,9 @@ #pragma once -#ifdef USE_FABRIC -#include "CircleProps.g.h" -#endif - #include "RenderableView.h" namespace winrt::RNSVG::implementation { -REACT_STRUCT(CircleProps) -struct CircleProps : CirclePropsT { - CircleProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - - REACT_FIELD(r) - D2D1_SVG_LENGTH r{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; - REACT_FIELD(cx) - D2D1_SVG_LENGTH cx{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; - REACT_FIELD(cy) - D2D1_SVG_LENGTH cy{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; -}; - - -struct CircleView : winrt::implements { - public: - CircleView() = default; - - const wchar_t *GetSvgElementName() noexcept override; - void OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement & /*element*/) noexcept override; +void RegisterCircleComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; -}; } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/ClipPathView.cpp b/windows/RNSVG/Fabric/ClipPathView.cpp index 1c19f09ad..e71b63f5f 100644 --- a/windows/RNSVG/Fabric/ClipPathView.cpp +++ b/windows/RNSVG/Fabric/ClipPathView.cpp @@ -3,20 +3,32 @@ namespace winrt::RNSVG::implementation { -ClipPathProps::ClipPathProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} +REACT_STRUCT(ClipPathProps) +struct ClipPathProps : winrt::implements { + ClipPathProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_GROUP_COMMON_PROPS_INIT {} -void ClipPathProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); + } -const wchar_t *ClipPathView::GetSvgElementName() noexcept { - return L"clipPath"; -} + REACT_SVG_GROUP_COMMON_PROPS; +}; + +struct ClipPathView : winrt::implements { + public: + ClipPathView() = default; + + void OnRender(const SvgView &svgView, ID2D1SvgDocument &document, ID2D1SvgElement &element) noexcept override { + auto props = winrt::get_self(m_props); + SetCommonSvgProps(svgView, document, element, *props); + } + + const wchar_t *GetSvgElementName() noexcept override { + return L"clipPath"; + } +}; -void ClipPathView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { +void RegisterClipPathComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { RegisterRenderableComponent(L"RNSVGClipPath", builder); } diff --git a/windows/RNSVG/Fabric/ClipPathView.h b/windows/RNSVG/Fabric/ClipPathView.h index 94018f789..2fda1f363 100644 --- a/windows/RNSVG/Fabric/ClipPathView.h +++ b/windows/RNSVG/Fabric/ClipPathView.h @@ -1,29 +1,10 @@ #pragma once -#include "ClipPathProps.g.h" #include "GroupView.h" namespace winrt::RNSVG::implementation { -REACT_STRUCT(ClipPathProps) -struct ClipPathProps : ClipPathPropsT { - ClipPathProps(const winrt::Microsoft::ReactNative::ViewProps &props); +void RegisterClipPathComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - REACT_SVG_GROUP_COMMON_PROPS; -}; - -struct ClipPathView : winrt::implements { - public: - ClipPathView() = default; - - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - - const wchar_t *GetSvgElementName() noexcept override; -}; } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/DefsView.cpp b/windows/RNSVG/Fabric/DefsView.cpp index 63ecee660..f88143aa1 100644 --- a/windows/RNSVG/Fabric/DefsView.cpp +++ b/windows/RNSVG/Fabric/DefsView.cpp @@ -3,21 +3,35 @@ namespace winrt::RNSVG::implementation { -DefsProps::DefsProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} +REACT_STRUCT(DefsProps) +struct DefsProps : winrt::implements { + DefsProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_GROUP_COMMON_PROPS_INIT {} -void DefsProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); + } -const wchar_t *DefsView::GetSvgElementName() noexcept { - return L"defs"; -} + REACT_SVG_GROUP_COMMON_PROPS; +}; + +struct DefsView : winrt::implements { + public: + DefsView() = default; + + const wchar_t *GetSvgElementName() noexcept override { + return L"defs"; + } + + void OnRender(const SvgView &svgView, ID2D1SvgDocument &document, ID2D1SvgElement &element) noexcept override { + if (m_props) { + auto props = winrt::get_self(m_props); + SetCommonSvgProps(svgView, document, element, *props); + } + } +}; -void DefsView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGDefs", builder); +void RegisterDefsComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + RegisterRenderableComponent(L"RNSVGDefs", builder); } } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/DefsView.h b/windows/RNSVG/Fabric/DefsView.h index 5620866e6..e421bac47 100644 --- a/windows/RNSVG/Fabric/DefsView.h +++ b/windows/RNSVG/Fabric/DefsView.h @@ -1,30 +1,9 @@ #pragma once -#include "DefsProps.g.h" #include "GroupView.h" namespace winrt::RNSVG::implementation { -REACT_STRUCT(DefsProps) -struct DefsProps : DefsPropsT { - DefsProps(const winrt::Microsoft::ReactNative::ViewProps &props); + void RegisterDefsComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - REACT_SVG_GROUP_COMMON_PROPS; - -}; - -struct DefsView : winrt::implements { - public: - DefsView() = default; - - const wchar_t *GetSvgElementName() noexcept override; - - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - -}; } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/EllipseView.cpp b/windows/RNSVG/Fabric/EllipseView.cpp index 6a4e810e5..8dbebde7e 100644 --- a/windows/RNSVG/Fabric/EllipseView.cpp +++ b/windows/RNSVG/Fabric/EllipseView.cpp @@ -3,29 +3,46 @@ namespace winrt::RNSVG::implementation { -EllipseProps::EllipseProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} +REACT_STRUCT(EllipseProps) +struct EllipseProps : winrt::implements { + EllipseProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT {} -void EllipseProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); + } -const wchar_t *EllipseView::GetSvgElementName() noexcept { - return L"ellipse"; -} + REACT_SVG_RENDERABLE_COMMON_PROPS; -void EllipseView::OnRender(ID2D1SvgDocument & /* document*/, ID2D1SvgElement &svgElement) noexcept { - auto props = m_props.as(); - svgElement.SetAttributeValue(SvgStrings::cxAttributeName, props->cx); - svgElement.SetAttributeValue(SvgStrings::cyAttributeName, props->cy); - svgElement.SetAttributeValue(SvgStrings::rxAttributeName, props->rx); - svgElement.SetAttributeValue(SvgStrings::ryAttributeName, props->ry); -} + REACT_FIELD(cx) + D2D1_SVG_LENGTH cx{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; + REACT_FIELD(cy) + D2D1_SVG_LENGTH cy{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; + REACT_FIELD(rx) + D2D1_SVG_LENGTH rx{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; + REACT_FIELD(ry) + D2D1_SVG_LENGTH ry{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; +}; + +struct EllipseView : winrt::implements { + public: + EllipseView() = default; + + const wchar_t *GetSvgElementName() noexcept override { + return L"ellipse"; + } + + void OnRender(const SvgView &svgView, ID2D1SvgDocument &document, ID2D1SvgElement &element) noexcept override { + auto props = m_props.as(); + SetCommonSvgProps(svgView, document, element, *props); + element.SetAttributeValue(SvgStrings::cxAttributeName, props->cx); + element.SetAttributeValue(SvgStrings::cyAttributeName, props->cy); + element.SetAttributeValue(SvgStrings::rxAttributeName, props->rx); + element.SetAttributeValue(SvgStrings::ryAttributeName, props->ry); + } +}; -void EllipseView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGEllipse", builder); +void RegisterEllipseComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + RegisterRenderableComponent(L"RNSVGEllipse", builder); } } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/EllipseView.h b/windows/RNSVG/Fabric/EllipseView.h index c7cefa6e5..2eef3ba6f 100644 --- a/windows/RNSVG/Fabric/EllipseView.h +++ b/windows/RNSVG/Fabric/EllipseView.h @@ -1,39 +1,11 @@ #pragma once -#include "EllipseProps.g.h" #include "RenderableView.h" namespace winrt::RNSVG::implementation { -REACT_STRUCT(EllipseProps) -struct EllipseProps : EllipsePropsT { - EllipseProps(const winrt::Microsoft::ReactNative::ViewProps &props); +void RegisterEllipseComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - - REACT_FIELD(cx) - D2D1_SVG_LENGTH cx{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; - REACT_FIELD(cy) - D2D1_SVG_LENGTH cy{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; - REACT_FIELD(rx) - D2D1_SVG_LENGTH rx{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; - REACT_FIELD(ry) - D2D1_SVG_LENGTH ry{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; -}; - -struct EllipseView : winrt::implements { - public: - EllipseView() = default; - - const wchar_t *GetSvgElementName() noexcept override; - void OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement & /*element*/) noexcept override; - - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; -}; } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/GroupView.cpp b/windows/RNSVG/Fabric/GroupView.cpp index 5816099e6..fcfcb3128 100644 --- a/windows/RNSVG/Fabric/GroupView.cpp +++ b/windows/RNSVG/Fabric/GroupView.cpp @@ -1,28 +1,36 @@ #include "pch.h" -#include "JSValueXaml.h" - #include "GroupView.h" namespace winrt::RNSVG::implementation { -SvgGroupCommonProps::SvgGroupCommonProps( - const winrt::Microsoft::ReactNative::ViewProps &props) - : base_type(props) {} - -void SvgGroupCommonProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} -const wchar_t* GroupView::GetSvgElementName() noexcept -{ - return L"g"; -} +REACT_STRUCT(SvgGroupProps) +struct SvgGroupProps : winrt::implements { + SvgGroupProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_GROUP_COMMON_PROPS_INIT {} + + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); + } + + REACT_SVG_GROUP_COMMON_PROPS; +}; + +struct GroupView : winrt::implements { + public: + GroupView() = default; + + const wchar_t *GetSvgElementName() noexcept override { + return L"g"; + } + + void OnRender(const SvgView &svgView, ID2D1SvgDocument &document, ID2D1SvgElement &element) noexcept override { + auto props = winrt::get_self(m_props); + SetCommonSvgProps(svgView, document, element, *props); + } +}; -void GroupView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGGroup", builder); +void RegisterGroupComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + RegisterRenderableComponent(L"RNSVGGroup", builder); } } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/GroupView.h b/windows/RNSVG/Fabric/GroupView.h index 33f10a417..dc96c2d3e 100644 --- a/windows/RNSVG/Fabric/GroupView.h +++ b/windows/RNSVG/Fabric/GroupView.h @@ -1,12 +1,8 @@ #pragma once #include "RenderableView.h" -#ifdef USE_FABRIC -#include "SvgGroupCommonProps.g.h" -#endif - namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC + REACT_STRUCT(FontObject) struct FontObject { REACT_FIELD(fontStyle) @@ -56,36 +52,20 @@ struct FontObject { }; #define REACT_SVG_GROUP_COMMON_PROPS \ + REACT_SVG_RENDERABLE_COMMON_PROPS \ REACT_FIELD(fontSize) \ + std::string fontSize; \ REACT_FIELD(fontWeight) \ - REACT_FIELD(font) + std::string fontWeight; \ + REACT_FIELD(font) \ + FontObject font; \ -REACT_STRUCT(SvgGroupCommonProps) -struct SvgGroupCommonProps - : SvgGroupCommonPropsT { - SvgGroupCommonProps(const winrt::Microsoft::ReactNative::ViewProps &props); +#define REACT_SVG_GROUP_COMMON_PROPS_INIT \ + : m_props(props) - void SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept; - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - REACT_SVG_GROUP_COMMON_PROPS; - std::string fontSize; - std::string fontWeight; - FontObject font; -}; -#endif +void RegisterGroupComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; -struct GroupView : winrt::implements { - public: - GroupView() = default; - const wchar_t *GetSvgElementName() noexcept override; - - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; -}; } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/ImageView.cpp b/windows/RNSVG/Fabric/ImageView.cpp index 770248915..e92cc5403 100644 --- a/windows/RNSVG/Fabric/ImageView.cpp +++ b/windows/RNSVG/Fabric/ImageView.cpp @@ -3,7 +3,7 @@ namespace winrt::RNSVG::implementation { -ImageProps::ImageProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} +ImageProps::ImageProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT {} void ImageProps::SetProp( uint32_t hash, diff --git a/windows/RNSVG/Fabric/ImageView.h b/windows/RNSVG/Fabric/ImageView.h index 3a654356a..23c784041 100644 --- a/windows/RNSVG/Fabric/ImageView.h +++ b/windows/RNSVG/Fabric/ImageView.h @@ -1,10 +1,7 @@ #pragma once -#include "ImageProps.g.h" #include "RenderableView.h" -#include - namespace winrt::RNSVG::implementation { enum class ImageSourceType { Uri = 0, Download = 1, InlineData = 2 }; enum class ImageSourceFormat { Bitmap = 0, Svg = 1 }; @@ -42,29 +39,27 @@ struct ImageSource { }; REACT_STRUCT(ImageProps) -struct ImageProps : ImagePropsT { +struct ImageProps : winrt::implements { ImageProps(const winrt::Microsoft::ReactNative::ViewProps &props); - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept; - REACT_SVG_NODE_COMMON_PROPS; REACT_SVG_RENDERABLE_COMMON_PROPS; REACT_FIELD(x) - RNSVG::SVGLength x{0, winrt::RNSVG::LengthType::Unknown}; + std::optional x; REACT_FIELD(y) - RNSVG::SVGLength y{0, winrt::RNSVG::LengthType::Unknown}; + std::optional y; REACT_FIELD(width) - RNSVG::SVGLength width{0, winrt::RNSVG::LengthType::Unknown}; + std::optional width; REACT_FIELD(height) - RNSVG::SVGLength height{0, winrt::RNSVG::LengthType::Unknown}; + std::optional height; REACT_FIELD(src) ImageSource src; REACT_FIELD(align) std::string align{""}; REACT_FIELD(meetOrSlice) - RNSVG::MeetOrSlice meetOrSlice{RNSVG::MeetOrSlice::Meet}; + int32_t meetOrSlice{0}; }; struct ImageView : winrt::implements { diff --git a/windows/RNSVG/Fabric/LineView.cpp b/windows/RNSVG/Fabric/LineView.cpp index 8126c5b33..f2f1456aa 100644 --- a/windows/RNSVG/Fabric/LineView.cpp +++ b/windows/RNSVG/Fabric/LineView.cpp @@ -3,29 +3,46 @@ namespace winrt::RNSVG::implementation { -LineProps::LineProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} +REACT_STRUCT(LineProps) +struct LineProps : winrt::implements { + LineProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT {} -void LineProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); + } -const wchar_t *LineView::GetSvgElementName() noexcept { - return L"line"; -} + REACT_SVG_RENDERABLE_COMMON_PROPS; -void LineView::OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement &svgElement) noexcept { - auto props = m_props.as(); - svgElement.SetAttributeValue(SvgStrings::x1AttributeName, props->x1); - svgElement.SetAttributeValue(SvgStrings::y1AttributeName, props->y1); - svgElement.SetAttributeValue(SvgStrings::x2AttributeName, props->x2); - svgElement.SetAttributeValue(SvgStrings::y2AttributeName, props->y2); -} + REACT_FIELD(x1) + D2D1_SVG_LENGTH x1{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; + REACT_FIELD(y1) + D2D1_SVG_LENGTH y1{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; + REACT_FIELD(x2) + D2D1_SVG_LENGTH x2{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; + REACT_FIELD(y2) + D2D1_SVG_LENGTH y2{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; +}; + +struct LineView : winrt::implements { + public: + LineView() = default; + + const wchar_t *GetSvgElementName() noexcept override { + return L"line"; + } + + void OnRender(const SvgView &svgView, ID2D1SvgDocument &document, ID2D1SvgElement &element) noexcept override { + auto props = m_props.as(); + SetCommonSvgProps(svgView, document, element, *props); + element.SetAttributeValue(SvgStrings::x1AttributeName, props->x1); + element.SetAttributeValue(SvgStrings::y1AttributeName, props->y1); + element.SetAttributeValue(SvgStrings::x2AttributeName, props->x2); + element.SetAttributeValue(SvgStrings::y2AttributeName, props->y2); + } +}; -void LineView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGLine", builder); +void RegisterLineComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + RegisterRenderableComponent(L"RNSVGLine", builder); } } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/LineView.h b/windows/RNSVG/Fabric/LineView.h index d598748ae..55c130698 100644 --- a/windows/RNSVG/Fabric/LineView.h +++ b/windows/RNSVG/Fabric/LineView.h @@ -1,39 +1,10 @@ #pragma once -#include "LineProps.g.h" #include "RenderableView.h" namespace winrt::RNSVG::implementation { -REACT_STRUCT(LineProps) -struct LineProps : LinePropsT { - LineProps(const winrt::Microsoft::ReactNative::ViewProps &props); +void RegisterLineComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - - REACT_FIELD(x1) - D2D1_SVG_LENGTH x1{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; - REACT_FIELD(y1) - D2D1_SVG_LENGTH y1{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; - REACT_FIELD(x2) - D2D1_SVG_LENGTH x2{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; - REACT_FIELD(y2) - D2D1_SVG_LENGTH y2{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; -}; - -struct LineView : winrt::implements { - public: - LineView() = default; - - const wchar_t *GetSvgElementName() noexcept override; - void OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement & /*element*/) noexcept override; - - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - -}; } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/LinearGradientView.cpp b/windows/RNSVG/Fabric/LinearGradientView.cpp index c4cb83940..b9e080a38 100644 --- a/windows/RNSVG/Fabric/LinearGradientView.cpp +++ b/windows/RNSVG/Fabric/LinearGradientView.cpp @@ -3,89 +3,121 @@ namespace winrt::RNSVG::implementation { -LinearGradientProps::LinearGradientProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} - -void LinearGradientProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - - +struct SvgLinearGradientStop { + float offset{0}; + D2D1_COLOR_F color; + float opacity{1.0f}; +}; + +REACT_STRUCT(LinearGradientProps) +struct LinearGradientProps : winrt::implements { + LinearGradientProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_GROUP_COMMON_PROPS_INIT {} + + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); + } -void LinearGradientView::UpdateProps( - const winrt::Microsoft::ReactNative::ComponentView &view, - const winrt::Microsoft::ReactNative::IComponentProps &newProps, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept { - auto props = newProps.as(); - m_stops.clear(); - - if (props->gradient) { - auto it = props->gradient->begin(); - while (it != props->gradient->end()) { - SvgLinearGradientStop stop; - - stop.offset = it->AsSingle(); - ++it; - auto clr = it->AsUInt32(); - stop.color = D2D1_COLOR_F{ - ((clr & 0x00FF0000) >> 16) / 255.0f, - ((clr & 0x0000FF00) >> 8) / 255.0f, - (clr & 0x000000FF) / 255.0f, - ((clr & 0xFF000000) >> 24) / 255.0f}; - stop.opacity = ((clr & 0xFF000000) >> 24) / 255.0f; - ++it; - m_stops.push_back(stop); + REACT_SVG_GROUP_COMMON_PROPS; + + REACT_FIELD(x1) + std::optional x1; + REACT_FIELD(y1) + std::optional y1; + REACT_FIELD(x2) + std::optional x2; + REACT_FIELD(y2) + std::optional y2; + REACT_FIELD(gradient) + std::optional> gradient{}; + REACT_FIELD(gradientUnits) + std::optional gradientUnits; + REACT_FIELD(gradientTransform) + std::optional> gradientTransform; +}; + +struct LinearGradientView : winrt::implements { + public: + LinearGradientView() = default; + + void UpdateProps( + const winrt::Microsoft::ReactNative::ComponentView &view, + const winrt::Microsoft::ReactNative::IComponentProps &newProps, + const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept override { + auto props = newProps.as(); + m_stops.clear(); + + if (props->gradient) { + auto it = props->gradient->begin(); + while (it != props->gradient->end()) { + SvgLinearGradientStop stop; + + stop.offset = it->AsSingle(); + ++it; + auto clr = it->AsUInt32(); + stop.color = D2D1_COLOR_F{ + ((clr & 0x00FF0000) >> 16) / 255.0f, + ((clr & 0x0000FF00) >> 8) / 255.0f, + (clr & 0x000000FF) / 255.0f, + ((clr & 0xFF000000) >> 24) / 255.0f}; + stop.opacity = ((clr & 0xFF000000) >> 24) / 255.0f; + ++it; + m_stops.push_back(stop); + } } + RenderableView::UpdateProps(view, newProps, oldProps); } - RenderableView::UpdateProps(view, newProps, oldProps); -} + const wchar_t *GetSvgElementName() noexcept override { + return L"linearGradient"; + } -const wchar_t *LinearGradientView::GetSvgElementName() noexcept { - return L"linearGradient"; -} + void OnRender(const SvgView &svgView, ID2D1SvgDocument &document, ID2D1SvgElement &element) noexcept override { + auto props = m_props.as(); + SetCommonSvgProps(svgView, document, element, *props); + if (props->x1) + element.SetAttributeValue( + SvgStrings::x1AttributeName, D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, props->x1.value().c_str()); + if (props->y1) + element.SetAttributeValue( + SvgStrings::y1AttributeName, D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, props->y1.value().c_str()); + if (props->x2) + element.SetAttributeValue( + SvgStrings::x2AttributeName, D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, props->x2.value().c_str()); + if (props->y2) + element.SetAttributeValue( + SvgStrings::y2AttributeName, D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, props->y2.value().c_str()); + + if (props->gradientUnits.value_or(0) == 0) { + element.SetAttributeValue( + SvgStrings::gradientUnitsAttributeName, D2D1_SVG_UNIT_TYPE::D2D1_SVG_UNIT_TYPE_OBJECT_BOUNDING_BOX); + } else { + element.SetAttributeValue( + SvgStrings::gradientUnitsAttributeName, D2D1_SVG_UNIT_TYPE::D2D1_SVG_UNIT_TYPE_USER_SPACE_ON_USE); + } -void LinearGradientView::OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement &svgElement) noexcept { - auto props = m_props.as(); - if (props->x1) - svgElement.SetAttributeValue(SvgStrings::x1AttributeName, D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, props->x1.value().c_str()); - if (props->y1) - svgElement.SetAttributeValue(SvgStrings::y1AttributeName, D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, props->y1.value().c_str()); - if (props->x2) - svgElement.SetAttributeValue(SvgStrings::x2AttributeName, D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, props->x2.value().c_str()); - if (props->y2) - svgElement.SetAttributeValue(SvgStrings::y2AttributeName, D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, props->y2.value().c_str()); - - - if (props->gradientUnits.value_or(0) == 0) { - svgElement.SetAttributeValue( - SvgStrings::gradientUnitsAttributeName, D2D1_SVG_UNIT_TYPE::D2D1_SVG_UNIT_TYPE_OBJECT_BOUNDING_BOX); - } else { - svgElement.SetAttributeValue( - SvgStrings::gradientUnitsAttributeName, D2D1_SVG_UNIT_TYPE::D2D1_SVG_UNIT_TYPE_USER_SPACE_ON_USE); - } + if (props->gradientTransform) { + auto &matrix = props->gradientTransform.value(); + element.SetAttributeValue( + SvgStrings::gradientTransformAttributeName, + D2D1_MATRIX_3X2_F{matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]}); + } - if (props->gradientTransform) { - auto &matrix = props->gradientTransform.value(); - svgElement.SetAttributeValue( - SvgStrings::gradientTransformAttributeName, - D2D1_MATRIX_3X2_F{matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]}); + for (const auto &stop : m_stops) { + winrt::com_ptr svgStop; + element.CreateChild(SvgStrings::stopAttributeName, svgStop.put()); + svgStop->SetAttributeValue(SvgStrings::offsetAttributeName, stop.offset); + svgStop->SetAttributeValue(SvgStrings::stopColorAttributeName, stop.color); + svgStop->SetAttributeValue(SvgStrings::stopOpacityAttributeName, stop.opacity); + } } - for (const auto &stop : m_stops) { - winrt::com_ptr svgStop; - svgElement.CreateChild(SvgStrings::stopAttributeName, svgStop.put()); - svgStop->SetAttributeValue(SvgStrings::offsetAttributeName, stop.offset); - svgStop->SetAttributeValue(SvgStrings::stopColorAttributeName, stop.color); - svgStop->SetAttributeValue(SvgStrings::stopOpacityAttributeName, stop.opacity); - } -} + private: + std::vector m_stops; +}; -void LinearGradientView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent( - L"RNSVGLinearGradient", builder); +void RegisterLinearGradientComponent( + const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + RegisterRenderableComponent(L"RNSVGLinearGradient", builder); } } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/LinearGradientView.h b/windows/RNSVG/Fabric/LinearGradientView.h index ca013c041..d901dd516 100644 --- a/windows/RNSVG/Fabric/LinearGradientView.h +++ b/windows/RNSVG/Fabric/LinearGradientView.h @@ -1,60 +1,11 @@ #pragma once -#include "LinearGradientProps.g.h" - #include "GroupView.h" namespace winrt::RNSVG::implementation { -struct SvgLinearGradientStop { - float offset{0}; - D2D1_COLOR_F color; - float opacity{1.0f}; -}; - -REACT_STRUCT(LinearGradientProps) -struct LinearGradientProps : LinearGradientPropsT { - LinearGradientProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - REACT_SVG_GROUP_COMMON_PROPS; - - REACT_FIELD(x1) - std::optional x1; - REACT_FIELD(y1) - std::optional y1; - REACT_FIELD(x2) - std::optional x2; - REACT_FIELD(y2) - std::optional y2; - REACT_FIELD(gradient) - std::optional> gradient{}; - REACT_FIELD(gradientUnits) - std::optional gradientUnits; - REACT_FIELD(gradientTransform) - std::optional> gradientTransform; -}; - -struct LinearGradientView : winrt::implements { - public: - LinearGradientView() = default; - - void UpdateProps( - const winrt::Microsoft::ReactNative::ComponentView & /*view*/, - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept override; - - const wchar_t *GetSvgElementName() noexcept override; - void OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement & /*element*/) noexcept override; - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; +void RegisterLinearGradientComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - private: - std::vector m_stops; -}; } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/MarkerView.cpp b/windows/RNSVG/Fabric/MarkerView.cpp deleted file mode 100644 index 5bd422e03..000000000 --- a/windows/RNSVG/Fabric/MarkerView.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "pch.h" -#include "MarkerView.h" - -namespace winrt::RNSVG::implementation { - -MarkerProps::MarkerProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} - -void MarkerProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - -const wchar_t *MarkerView::GetSvgElementName() noexcept { - return L"marker"; -} - -bool MarkerView::IsSupported() const noexcept { - return false; -} - -void MarkerView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGMarker", builder); -} - -} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/MarkerView.h b/windows/RNSVG/Fabric/MarkerView.h deleted file mode 100644 index 35e58befe..000000000 --- a/windows/RNSVG/Fabric/MarkerView.h +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once - -#include "MarkerProps.g.h" -#include "GroupView.h" - -namespace winrt::RNSVG::implementation { - -REACT_STRUCT(MarkerProps) -struct MarkerProps : MarkerPropsT { - MarkerProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - - REACT_FIELD(refX) - RNSVG::SVGLength refX{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(refY) - RNSVG::SVGLength refY{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(markerHeight) - RNSVG::SVGLength markerHeight{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(markerWidth) - RNSVG::SVGLength markerWidth{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(markerUnits) - std::string markerUnits{""}; - REACT_FIELD(orient) - std::string orient{""}; - REACT_FIELD(minX) - float minX{0.0f}; - REACT_FIELD(minY) - float minY{0.0f}; - REACT_FIELD(vbWidth) - float vbWidth{0.0f}; - REACT_FIELD(vbHeight) - float vbHeight{0.0f}; - REACT_FIELD(align) - std::string align{""}; - REACT_FIELD(meetOrSlice) - RNSVG::MeetOrSlice meetOrSlice{RNSVG::MeetOrSlice::Meet}; -}; - -struct MarkerView : winrt::implements { - public: - MarkerView() = default; - - const wchar_t *GetSvgElementName() noexcept override; - bool IsSupported() const noexcept override; - - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; -}; - -} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/MaskView.cpp b/windows/RNSVG/Fabric/MaskView.cpp deleted file mode 100644 index b0977f26e..000000000 --- a/windows/RNSVG/Fabric/MaskView.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "pch.h" -#include "MaskView.h" - -namespace winrt::RNSVG::implementation { - -MaskProps::MaskProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} - -void MaskProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - -const wchar_t *MaskView::GetSvgElementName() noexcept { - return L"mask"; -} - -bool MaskView::IsSupported() const noexcept { - return false; -} - -void MaskView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGMask", builder); -} - -} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/MaskView.h b/windows/RNSVG/Fabric/MaskView.h deleted file mode 100644 index 8d5af228a..000000000 --- a/windows/RNSVG/Fabric/MaskView.h +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once - -#include "MaskProps.g.h" -#include "GroupView.h" - -namespace winrt::RNSVG::implementation { - -REACT_STRUCT(MaskProps) -struct MaskProps : MaskPropsT { - MaskProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - - REACT_FIELD(x) - RNSVG::SVGLength x{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(y) - RNSVG::SVGLength y{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(height) - RNSVG::SVGLength height{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(width) - RNSVG::SVGLength width{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(maskUnits) - uint32_t maskUnits{0}; - REACT_FIELD(maskContentUnits) - uint32_t maskContentUnits{0}; -}; - -struct MaskView : winrt::implements { - public: - MaskView() = default; - - const wchar_t *GetSvgElementName() noexcept override; - bool IsSupported() const noexcept override; - - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; -}; - -} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/PathView.cpp b/windows/RNSVG/Fabric/PathView.cpp index 51270d9a9..28a56e8f9 100644 --- a/windows/RNSVG/Fabric/PathView.cpp +++ b/windows/RNSVG/Fabric/PathView.cpp @@ -5,26 +5,40 @@ namespace winrt::RNSVG::implementation { -PathProps::PathProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} - -void PathProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - -const wchar_t *PathView::GetSvgElementName() noexcept { - return L"path"; -} - -void PathView::OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement &svgElement) noexcept { - auto props = m_props.as(); - svgElement.SetAttributeValue(SvgStrings::dAttributeName, D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, props->d.c_str()); -} - -void PathView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGPath", builder); +REACT_STRUCT(PathProps) +struct PathProps : winrt::implements { + PathProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT {} + + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); + } + + REACT_SVG_RENDERABLE_COMMON_PROPS; + + REACT_FIELD(d) + std::wstring d; +}; + +struct PathView : winrt::implements { + public: + PathView() = default; + + const wchar_t *GetSvgElementName() noexcept override { + return L"path"; + } + + void OnRender(const SvgView &svgView, ID2D1SvgDocument &document, ID2D1SvgElement &element) noexcept override { + auto props = m_props.as(); + SetCommonSvgProps(svgView, document, element, *props); + element.SetAttributeValue( + SvgStrings::dAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + props->d.c_str()); + } +}; + +void RegisterPathComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + RegisterRenderableComponent(L"RNSVGPath", builder); } } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/PathView.h b/windows/RNSVG/Fabric/PathView.h index 6cd01a3dc..2279b028b 100644 --- a/windows/RNSVG/Fabric/PathView.h +++ b/windows/RNSVG/Fabric/PathView.h @@ -1,33 +1,9 @@ #pragma once -#include "PathProps.g.h" #include "RenderableView.h" namespace winrt::RNSVG::implementation { -REACT_STRUCT(PathProps) -struct PathProps : PathPropsT { - PathProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - - REACT_FIELD(d) - std::wstring d; -}; - -struct PathView : winrt::implements { - public: - PathView() = default; - - const wchar_t *GetSvgElementName() noexcept override; - void OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement & /*element*/) noexcept override; - - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - -}; +void RegisterPathComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/PatternView.cpp b/windows/RNSVG/Fabric/PatternView.cpp deleted file mode 100644 index a0c990dc6..000000000 --- a/windows/RNSVG/Fabric/PatternView.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "pch.h" -#include "PatternView.h" - -namespace winrt::RNSVG::implementation { - -PatternProps::PatternProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} - -void PatternProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - -const wchar_t *PatternView::GetSvgElementName() noexcept { - return L"pattern"; -} - -bool PatternView::IsSupported() const noexcept { - return false; -} - -void PatternView::RegisterComponent( - const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGPattern", builder); -} - -} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/PatternView.h b/windows/RNSVG/Fabric/PatternView.h deleted file mode 100644 index 6296e1823..000000000 --- a/windows/RNSVG/Fabric/PatternView.h +++ /dev/null @@ -1,59 +0,0 @@ -#pragma once - -#include "PatternProps.g.h" - -#include "GroupView.h" - -namespace winrt::RNSVG::implementation { - -REACT_STRUCT(PatternProps) -struct PatternProps : PatternPropsT { - PatternProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - REACT_SVG_GROUP_COMMON_PROPS; - - REACT_FIELD(x) - RNSVG::SVGLength x{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(y) - RNSVG::SVGLength y{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(width) - RNSVG::SVGLength width{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(height) - RNSVG::SVGLength height{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(patternUnits) - std::optional patternUnits; - REACT_FIELD(patternContentUnits) - std::optional patternContentUnits; - REACT_FIELD(patternTransform) - std::optional> patternTransform; - - REACT_FIELD(minX) - float minX{0.0f}; - REACT_FIELD(minY) - float minY{0.0f}; - REACT_FIELD(vbWidth) - float vbWidth{0.0f}; - REACT_FIELD(vbHeight) - float vbHeight{0.0f}; - REACT_FIELD(align) - std::string align{""}; - REACT_FIELD(meetOrSlice) - RNSVG::MeetOrSlice meetOrSlice{RNSVG::MeetOrSlice::Meet}; -}; - -struct PatternView : winrt::implements { - public: - PatternView() = default; - - const wchar_t *GetSvgElementName() noexcept override; - bool IsSupported() const noexcept override; - - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; -}; - -} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/RadialGradientView.cpp b/windows/RNSVG/Fabric/RadialGradientView.cpp index 5c997bddd..b04a72efd 100644 --- a/windows/RNSVG/Fabric/RadialGradientView.cpp +++ b/windows/RNSVG/Fabric/RadialGradientView.cpp @@ -3,114 +3,146 @@ namespace winrt::RNSVG::implementation { -RadialGradientProps::RadialGradientProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} - -void RadialGradientProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} +struct SvgRadialGradientStop { + float offset{0}; + D2D1_COLOR_F color; + float opacity{1.0f}; +}; + +REACT_STRUCT(RadialGradientProps) +struct RadialGradientProps : winrt::implements { + RadialGradientProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_GROUP_COMMON_PROPS_INIT {} + + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); + } -void RadialGradientView::UpdateProps( - const winrt::Microsoft::ReactNative::ComponentView & view, + REACT_SVG_GROUP_COMMON_PROPS; + + REACT_FIELD(fx) + std::optional fx; + REACT_FIELD(fy) + std::optional fy; + REACT_FIELD(cx) + std::optional cx; + REACT_FIELD(cy) + std::optional cy; + REACT_FIELD(rx) + std::optional rx; + REACT_FIELD(ry) + std::optional ry; + REACT_FIELD(gradient) + std::optional> gradient{}; + REACT_FIELD(gradientUnits) + std::optional gradientUnits; + REACT_FIELD(gradientTransform) + std::optional> gradientTransform; +}; + +struct RadialGradientView : winrt::implements { + public: + RadialGradientView() = default; + + void UpdateProps( + const winrt::Microsoft::ReactNative::ComponentView &view, const winrt::Microsoft::ReactNative::IComponentProps &newProps, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept { - - auto props = newProps.as(); - m_stops.clear(); - - if (props->gradient) { - auto it = props->gradient->begin(); - while (it != props->gradient->end()) { - SvgRadialGradientStop stop; - - stop.offset = it->AsSingle(); - ++it; - auto clr = it->AsUInt32(); - stop.color = D2D1_COLOR_F{ - ((clr & 0x00FF0000) >> 16) / 255.0f, - ((clr & 0x0000FF00) >> 8) / 255.0f, - (clr & 0x000000FF) / 255.0f, - ((clr & 0xFF000000) >> 24) / 255.0f}; - stop.opacity = ((clr & 0xFF000000) >> 24) / 255.0f; - ++it; - m_stops.push_back(stop); + const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept override { + auto props = newProps.as(); + m_stops.clear(); + + if (props->gradient) { + auto it = props->gradient->begin(); + while (it != props->gradient->end()) { + SvgRadialGradientStop stop; + + stop.offset = it->AsSingle(); + ++it; + auto clr = it->AsUInt32(); + stop.color = D2D1_COLOR_F{ + ((clr & 0x00FF0000) >> 16) / 255.0f, + ((clr & 0x0000FF00) >> 8) / 255.0f, + (clr & 0x000000FF) / 255.0f, + ((clr & 0xFF000000) >> 24) / 255.0f}; + stop.opacity = ((clr & 0xFF000000) >> 24) / 255.0f; + ++it; + m_stops.push_back(stop); + } } + + RenderableView::UpdateProps(view, newProps, oldProps); } - RenderableView::UpdateProps(view, newProps, oldProps); -} + const wchar_t *GetSvgElementName() noexcept override { + return L"radialGradient"; + } -const wchar_t *RadialGradientView::GetSvgElementName() noexcept { - return L"radialGradient"; -} + void OnRender(const SvgView &svgView, ID2D1SvgDocument &document, ID2D1SvgElement &element) noexcept override { + auto props = m_props.as(); + SetCommonSvgProps(svgView, document, element, *props); + if (props->cx) + element.SetAttributeValue( + SvgStrings::cxAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + props->cx->c_str()); + if (props->cy) + element.SetAttributeValue( + SvgStrings::cyAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + props->cy->c_str()); + + // RNSVG can decompose r to rx and ry, but D2D svgs don't support rx or ry, so if that is specified then take rx as + // r, and make sure the specified rx and ry are the same. + assert(props->rx == props->ry); + + if (props->rx) + element.SetAttributeValue( + SvgStrings::rAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + props->rx->c_str()); + + if (props->fx) + element.SetAttributeValue( + SvgStrings::fxAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + props->fx->c_str()); + + if (props->fy) + element.SetAttributeValue( + SvgStrings::fyAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + props->fy->c_str()); + + if (props->gradientUnits.value_or(0) == 0) { + element.SetAttributeValue( + SvgStrings::gradientUnitsAttributeName, D2D1_SVG_UNIT_TYPE::D2D1_SVG_UNIT_TYPE_OBJECT_BOUNDING_BOX); + } else { + element.SetAttributeValue( + SvgStrings::gradientUnitsAttributeName, D2D1_SVG_UNIT_TYPE::D2D1_SVG_UNIT_TYPE_USER_SPACE_ON_USE); + } -void RadialGradientView::OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement &svgElement) noexcept { - auto props = m_props.as(); - if (props->cx) - svgElement.SetAttributeValue( - SvgStrings::cxAttributeName, - D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, - props->cx->c_str()); - if (props->cy) - svgElement.SetAttributeValue( - SvgStrings::cyAttributeName, - D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, - props->cy->c_str()); - - // RNSVG can decompose r to rx and ry, but D2D svgs don't support rx or ry, so if that is specified then take rx as r, - // and make sure the specified rx and ry are the same. - assert(props->rx == props->ry); - - // TODO verify rx ry comment above - - if (props->rx) - svgElement.SetAttributeValue( - SvgStrings::rAttributeName, - D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, - props->rx->c_str()); - - if (props->fx) - svgElement.SetAttributeValue( - SvgStrings::fxAttributeName, - D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, - props->fx->c_str()); - - if (props->fy) - svgElement.SetAttributeValue( - SvgStrings::fyAttributeName, - D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, - props->fy->c_str()); - - if (props->gradientUnits.value_or(0) == 0) { - svgElement.SetAttributeValue( - SvgStrings::gradientUnitsAttributeName, D2D1_SVG_UNIT_TYPE::D2D1_SVG_UNIT_TYPE_OBJECT_BOUNDING_BOX); - } else { - svgElement.SetAttributeValue( - SvgStrings::gradientUnitsAttributeName, D2D1_SVG_UNIT_TYPE::D2D1_SVG_UNIT_TYPE_USER_SPACE_ON_USE); - } + if (props->gradientTransform) { + auto &matrix = props->gradientTransform.value(); + element.SetAttributeValue( + SvgStrings::gradientTransformAttributeName, + D2D1_MATRIX_3X2_F{matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]}); + } - if (props->gradientTransform) { - auto &matrix = props->gradientTransform.value(); - svgElement.SetAttributeValue( - SvgStrings::gradientTransformAttributeName, - D2D1_MATRIX_3X2_F{matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]}); + for (const auto &stop : m_stops) { + winrt::com_ptr svgStop; + element.CreateChild(SvgStrings::stopAttributeName, svgStop.put()); + svgStop->SetAttributeValue(SvgStrings::offsetAttributeName, stop.offset); + svgStop->SetAttributeValue(SvgStrings::stopColorAttributeName, stop.color); + svgStop->SetAttributeValue(SvgStrings::stopOpacityAttributeName, stop.opacity); + } } - for (const auto& stop : m_stops ) { - winrt::com_ptr svgStop; - svgElement.CreateChild(SvgStrings::stopAttributeName, svgStop.put()); - svgStop->SetAttributeValue(SvgStrings::offsetAttributeName, stop.offset); - svgStop->SetAttributeValue(SvgStrings::stopColorAttributeName, stop.color); - svgStop->SetAttributeValue(SvgStrings::stopOpacityAttributeName, stop.opacity); - } -} + private: + std::vector m_stops; +}; -void RadialGradientView::RegisterComponent( +void RegisterRadialGradientComponent( const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent( - L"RNSVGRadialGradient", builder); + RegisterRenderableComponent(L"RNSVGRadialGradient", builder); } } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/RadialGradientView.h b/windows/RNSVG/Fabric/RadialGradientView.h index 66700dd94..457300b17 100644 --- a/windows/RNSVG/Fabric/RadialGradientView.h +++ b/windows/RNSVG/Fabric/RadialGradientView.h @@ -1,63 +1,10 @@ #pragma once -#include "RadialGradientProps.g.h" - #include "GroupView.h" namespace winrt::RNSVG::implementation { -struct SvgRadialGradientStop { - float offset{0}; - D2D1_COLOR_F color; - float opacity{1.0f}; -}; - -REACT_STRUCT(RadialGradientProps) -struct RadialGradientProps : RadialGradientPropsT { - RadialGradientProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - REACT_SVG_GROUP_COMMON_PROPS; - - REACT_FIELD(fx) - std::optional fx; - REACT_FIELD(fy) - std::optional fy; - REACT_FIELD(cx) - std::optional cx; - REACT_FIELD(cy) - std::optional cy; - REACT_FIELD(rx) - std::optional rx; - REACT_FIELD(ry) - std::optional ry; - REACT_FIELD(gradient) - std::optional> gradient{}; - REACT_FIELD(gradientUnits) - std::optional gradientUnits; - REACT_FIELD(gradientTransform) - std::optional> gradientTransform; -}; - -struct RadialGradientView : winrt::implements { - public: - RadialGradientView() = default; - - void UpdateProps( - const winrt::Microsoft::ReactNative::ComponentView & /*view*/, - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept override; - const wchar_t *GetSvgElementName() noexcept override; - void OnRender(ID2D1SvgDocument& /*document*/, ID2D1SvgElement& /*element*/) noexcept override; - - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; +void RegisterRadialGradientComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - private: - std::vector m_stops; -}; } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/RectView.cpp b/windows/RNSVG/Fabric/RectView.cpp index 353040c9a..eb527fa23 100644 --- a/windows/RNSVG/Fabric/RectView.cpp +++ b/windows/RNSVG/Fabric/RectView.cpp @@ -3,42 +3,67 @@ namespace winrt::RNSVG::implementation { -RectProps::RectProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} +REACT_STRUCT(RectProps) +struct RectProps : winrt::implements { + RectProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT {} -void RectProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); + } -const wchar_t *RectView::GetSvgElementName() noexcept { - return L"rect"; -} + REACT_SVG_RENDERABLE_COMMON_PROPS; -void RectView::OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement &svgElement) noexcept { - auto props = m_props.as(); - svgElement.SetAttributeValue( - SvgStrings::xAttributeName, D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, props->x.c_str()); - svgElement.SetAttributeValue( - SvgStrings::yAttributeName, D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, props->y.c_str()); - svgElement.SetAttributeValue( - SvgStrings::widthAttributeName, - D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, - props->width.c_str()); - svgElement.SetAttributeValue( - SvgStrings::heightAttributeName, - D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, - props->height.c_str()); - - if (props->rx.value) - svgElement.SetAttributeValue(SvgStrings::rxAttributeName, props->rx); - if (props->ry.value) - svgElement.SetAttributeValue(SvgStrings::ryAttributeName, props->ry); -} + REACT_FIELD(x) + std::wstring x; + REACT_FIELD(y) + std::wstring y; + REACT_FIELD(height) + std::wstring height; + REACT_FIELD(width) + std::wstring width; + REACT_FIELD(rx) + D2D1_SVG_LENGTH rx{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; + REACT_FIELD(ry) + D2D1_SVG_LENGTH ry{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; +}; + +struct RectView : winrt::implements { + public: + RectView() = default; + + const wchar_t *GetSvgElementName() noexcept override { + return L"rect"; + } + + void OnRender(const SvgView &svgView, ID2D1SvgDocument &document, ID2D1SvgElement &element) noexcept override { + auto props = m_props.as(); + SetCommonSvgProps(svgView, document, element, *props); + element.SetAttributeValue( + SvgStrings::xAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + props->x.c_str()); + element.SetAttributeValue( + SvgStrings::yAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + props->y.c_str()); + element.SetAttributeValue( + SvgStrings::widthAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + props->width.c_str()); + element.SetAttributeValue( + SvgStrings::heightAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + props->height.c_str()); + + if (props->rx.value) + element.SetAttributeValue(SvgStrings::rxAttributeName, props->rx); + if (props->ry.value) + element.SetAttributeValue(SvgStrings::ryAttributeName, props->ry); + } +}; -void RectView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGRect", builder); +void RegisterRectComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + RegisterRenderableComponent(L"RNSVGRect", builder); } } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/RectView.h b/windows/RNSVG/Fabric/RectView.h index 71b179fc4..803be4dc9 100644 --- a/windows/RNSVG/Fabric/RectView.h +++ b/windows/RNSVG/Fabric/RectView.h @@ -1,42 +1,9 @@ #pragma once -#include "RectProps.g.h" #include "RenderableView.h" namespace winrt::RNSVG::implementation { -REACT_STRUCT(RectProps) -struct RectProps : RectPropsT { - RectProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - - REACT_FIELD(x) - std::wstring x; - REACT_FIELD(y) - std::wstring y; - REACT_FIELD(height) - std::wstring height; - REACT_FIELD(width) - std::wstring width; - REACT_FIELD(rx) - D2D1_SVG_LENGTH rx{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; - REACT_FIELD(ry) - D2D1_SVG_LENGTH ry{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; -}; - -struct RectView : winrt::implements { - public: - RectView() = default; - - const wchar_t *GetSvgElementName() noexcept override; - void OnRender(ID2D1SvgDocument& /*document*/ , ID2D1SvgElement & /*element*/) noexcept override; - - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; -}; +void RegisterRectComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/RenderableView.cpp b/windows/RNSVG/Fabric/RenderableView.cpp index f12d889dc..8a0002ae0 100644 --- a/windows/RNSVG/Fabric/RenderableView.cpp +++ b/windows/RNSVG/Fabric/RenderableView.cpp @@ -116,134 +116,6 @@ SetColorMode( return hr; } -void SetCommonSvgProps( - const SvgView &svgView, - ID2D1SvgDocument& document, - ID2D1SvgElement &element, - const SvgRenderableCommonProps &commonProps) noexcept { - HRESULT hr = S_OK; - if (commonProps.color != std::nullopt) { - auto color = commonProps.color.value().AsWindowsColor(svgView.Theme()); - hr |= element.SetAttributeValue(SvgStrings::colorAttributeName, D2DHelpers::AsD2DColor(color)); - } - - if (commonProps.propList) { - for (auto &prop : commonProps.propList.value()) { - if (prop == "fill") { - if (commonProps.fill != std::nullopt) - hr |= SetColorMode(svgView, element, SvgStrings::fillAttributeName, commonProps.fill.value()); - else - hr |= element.SetAttributeValue( - SvgStrings::fillAttributeName, - D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, - SvgStrings::noneAttributeValue); - } else if (prop == "fillOpacity") { - if (commonProps.fillOpacity != std::nullopt) - hr |= element.SetAttributeValue(SvgStrings::fillOpacityAttributeName, commonProps.fillOpacity.value()); - } else if (prop == "fillRule") { - if (commonProps.fillRule != std::nullopt) { - hr |= element.SetAttributeValue(SvgStrings::fillRuleAttributeName, commonProps.fillRule.value()); - } - } else if (prop == "stroke") { - if (commonProps.stroke != std::nullopt) - hr |= SetColorMode(svgView, element, SvgStrings::strokeAttributeName, commonProps.stroke.value()); - else - hr |= element.SetAttributeValue( - SvgStrings::strokeAttributeName, - D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, - SvgStrings::noneAttributeValue); - } else if (prop == "strokeWidth") { - if (commonProps.strokeWidth != std::nullopt) - hr |= element.SetAttributeValue(SvgStrings::strokeWidthAttributeName, commonProps.strokeWidth.value()); - } else if (prop == "strokeOpacity") { - if (commonProps.strokeOpacity != std::nullopt) - hr |= element.SetAttributeValue(SvgStrings::strokeOpacityAttributeName, commonProps.strokeOpacity.value()); - } else if (prop == "strokeDasharray") { - if (commonProps.strokeDasharray != std::nullopt && !commonProps.strokeDasharray->empty()) { - winrt::com_ptr dashArray; - document.CreateStrokeDashArray( - &commonProps.strokeDasharray.value()[0], - static_cast(commonProps.strokeDasharray.value().size()), - dashArray.put()); - hr |= element.SetAttributeValue(SvgStrings::strokeDashArrayAttributeName, dashArray.get()); - } - } else if (prop == "strokeDashoffset") { - if (commonProps.strokeDashoffset != std::nullopt) { - hr |= element.SetAttributeValue( - SvgStrings::strokeDashOffsetAttributeName, commonProps.strokeDashoffset.value()); - } - } else if (prop == "strokeLinecap") { - if (commonProps.strokeLinecap != std::nullopt) { - static D2D1_SVG_LINE_CAP supportedCaps[] = { - D2D1_SVG_LINE_CAP_BUTT, D2D1_SVG_LINE_CAP_ROUND, D2D1_SVG_LINE_CAP_SQUARE}; - hr |= element.SetAttributeValue( - SvgStrings::strokeLinecapAttributeName, supportedCaps[commonProps.strokeLinecap.value()]); - } - } else if (prop == "strokeLinejoin") { - if (commonProps.strokeLinejoin != std::nullopt) { - static D2D1_SVG_LINE_JOIN supportedJoins[] = { - D2D1_SVG_LINE_JOIN_MITER, D2D1_SVG_LINE_JOIN_ROUND, D2D1_SVG_LINE_JOIN_BEVEL}; - hr |= element.SetAttributeValue( - SvgStrings::strokeLinejoinAttributeName, supportedJoins[commonProps.strokeLinejoin.value()]); - } - } else if (prop == "strokeMiterlimit") { - if (commonProps.strokeMiterlimit != std::nullopt) { - hr |= element.SetAttributeValue( - SvgStrings::strokeMiterLimitAttributeName, commonProps.strokeMiterlimit.value()); - } - } - } - } - - if (commonProps.clipPath != std::nullopt) { - std::wstring namedRefStr = L"url(#" + commonProps.clipPath.value() + L")"; - hr |= element.SetAttributeValue( - SvgStrings::clipPathAttributeName, - D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, - namedRefStr.c_str()); - } - - if (commonProps.clipRule != std::nullopt) { - hr |= element.SetAttributeValue(SvgStrings::clipRuleAttributeName, commonProps.clipRule.value()); - } - - if (commonProps.name != std::nullopt) - hr |= element.SetAttributeValue( - SvgStrings::idAttributeName, - D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, - commonProps.name.value().c_str()); - - if (commonProps.opacity != std::nullopt) - hr |= element.SetAttributeValue(SvgStrings::opacityAttributeName, commonProps.opacity.value()); - - if (commonProps.matrix != std::nullopt) { - auto &matrix = commonProps.matrix.value(); - hr |= element.SetAttributeValue( - SvgStrings::transformAttributeName, - D2D1_MATRIX_3X2_F{matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]}); - } - - assert(hr == S_OK); -} - -SvgNodeCommonProps::SvgNodeCommonProps(const winrt::Microsoft::ReactNative::ViewProps &props) : m_props(props) {} - -void SvgNodeCommonProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - -SvgRenderableCommonProps::SvgRenderableCommonProps(const winrt::Microsoft::ReactNative::ViewProps &props) - : base_type(props) {} - -void SvgRenderableCommonProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} void RenderableView::Invalidate(const winrt::Microsoft::ReactNative::ComponentView &view) { winrt::com_ptr svgView{nullptr}; @@ -274,7 +146,7 @@ void RenderableView::UpdateProps( const winrt::Microsoft::ReactNative::ComponentView & /*view*/, const winrt::Microsoft::ReactNative::IComponentProps &props, const winrt::Microsoft::ReactNative::IComponentProps &) noexcept { - m_props = props.as(); + m_props = props; } void RenderableView::FinalizeUpates( @@ -285,16 +157,18 @@ void RenderableView::FinalizeUpates( ID2D1SvgElement &RenderableView::Render(const SvgView &svgView, ID2D1SvgDocument& document, ID2D1SvgElement &svgElement) noexcept { svgElement.CreateChild(GetSvgElementName(), m_spD2DSvgElement.put()); - if (m_props) - SetCommonSvgProps(svgView, document, *m_spD2DSvgElement, *m_props); - OnRender(document , *m_spD2DSvgElement); + OnRender(svgView, document, *m_spD2DSvgElement); return *m_spD2DSvgElement; } bool RenderableView::IsSupported() const noexcept { return true; } - -void RenderableView::OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement & /*element*/) noexcept {} +void RenderableView::OnRender( + const SvgView & /*svgView*/, + ID2D1SvgDocument & /*document*/, + ID2D1SvgElement & /*element*/) noexcept { + assert(false); +} } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/RenderableView.h b/windows/RNSVG/Fabric/RenderableView.h index c3f1c8af4..73a5dcc67 100644 --- a/windows/RNSVG/Fabric/RenderableView.h +++ b/windows/RNSVG/Fabric/RenderableView.h @@ -1,16 +1,11 @@ #pragma once -#include "../SVGLength.h" - -#ifdef USE_FABRIC -#include "SvgNodeCommonProps.g.h" -#include "SvgRenderableCommonProps.g.h" - #include -#endif #include +#include "../D2DHelpers.h" #include "SvgStrings.h" +#include "SvgView.h" namespace winrt::Microsoft::ReactNative { void WriteValue(IJSValueWriter const &writer, const D2D1_SVG_LENGTH &value) noexcept; @@ -19,15 +14,6 @@ void ReadValue(IJSValueReader const &reader, /*out*/ D2D1_SVG_LENGTH &value) noe namespace winrt::RNSVG::implementation { -struct SvgView; -struct SvgRenderableCommonProps; - -void SetCommonSvgProps( - const SvgView& svgView, - ID2D1SvgDocument &document, - ID2D1SvgElement &element, - const SvgRenderableCommonProps &commonProps) noexcept; - REACT_STRUCT(ColorStruct) struct ColorStruct { REACT_FIELD(type) @@ -42,13 +28,14 @@ struct ColorStruct { bool operator==(const ColorStruct &rhs) const { if (type != rhs.type || brushRef != rhs.brushRef) return false; - + // When we move to a RNW version that provides Color::Equals switch to that for the payload comparison auto writer = winrt::Microsoft::ReactNative::MakeJSValueTreeWriter(); winrt::Microsoft::ReactNative::WriteValue(writer, payload); auto rhsWriter = winrt::Microsoft::ReactNative::MakeJSValueTreeWriter(); winrt::Microsoft::ReactNative::WriteValue(rhsWriter, rhs.payload); - return winrt::Microsoft::ReactNative::TakeJSValue(writer).Equals(winrt::Microsoft::ReactNative::TakeJSValue(rhsWriter)); + return winrt::Microsoft::ReactNative::TakeJSValue(writer).Equals( + winrt::Microsoft::ReactNative::TakeJSValue(rhsWriter)); } bool operator!=(const ColorStruct &rhs) const { @@ -56,106 +43,75 @@ struct ColorStruct { } }; -// Currently no good way to do inheritance in REACT_STRUCTS -#define REACT_SVG_NODE_COMMON_PROPS \ - REACT_FIELD(name) \ - REACT_FIELD(opacity) \ - REACT_FIELD(matrix) \ - REACT_FIELD(mask) \ - REACT_FIELD(markerStart) \ - REACT_FIELD(markerMid) \ - REACT_FIELD(markerEnd) \ - REACT_FIELD(clipPath) \ - REACT_FIELD(clipRule) \ - REACT_FIELD(responsible) \ - REACT_FIELD(display) \ - REACT_FIELD(pointerEvents) - -REACT_STRUCT(SvgNodeCommonProps) -struct SvgNodeCommonProps : SvgNodeCommonPropsT { - SvgNodeCommonProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - virtual void SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept; - - REACT_SVG_NODE_COMMON_PROPS; - - std::optional name; - std::optional opacity; // 1.0f - std::optional> matrix; - std::optional mask; - std::optional markerStart; - std::optional markerMid; - std::optional markerEnd; - std::optional clipPath; - - static_assert(D2D1_FILL_MODE::D2D1_FILL_MODE_WINDING == 1); // NonZero - static_assert(D2D1_FILL_MODE::D2D1_FILL_MODE_ALTERNATE == 0); // EvenOdd - std::optional clipRule; - std::optional responsible; - std::optional display; - std::optional pointerEvents; +HRESULT SetColorMode( + const SvgView &svgView, + ID2D1SvgElement &element, + const std::wstring &attribute, + const ColorStruct &colorProp) noexcept; - private: +// Currently no good way to do inheritance in REACT_STRUCTS +#define REACT_SVG_RENDERABLE_COMMON_PROPS \ + REACT_FIELD(name) \ + std::optional name; \ + REACT_FIELD(opacity) \ + std::optional opacity; \ + REACT_FIELD(matrix) \ + std::optional> matrix; \ + REACT_FIELD(mask) \ + std::optional mask; \ + REACT_FIELD(markerStart) \ + std::optional markerStart; \ + REACT_FIELD(markerMid) \ + std::optional markerMid; \ + REACT_FIELD(markerEnd) \ + std::optional markerEnd; \ + REACT_FIELD(clipPath) \ + std::optional clipPath; \ + REACT_FIELD(clipRule) \ + std::optional clipRule; \ + REACT_FIELD(responsible) \ + std::optional responsible; \ + REACT_FIELD(display) \ + std::optional display; \ + REACT_FIELD(pointerEvents) \ + std::optional pointerEvents; \ + REACT_FIELD(fill) \ + std::optional fill; \ + REACT_FIELD(fillOpacity) \ + std::optional fillOpacity; \ + REACT_FIELD(fillRule) \ + std::optional fillRule; \ + REACT_FIELD(stroke) \ + std::optional stroke; \ + REACT_FIELD(strokeOpacity) \ + std::optional strokeOpacity; \ + REACT_FIELD(strokeWidth) \ + std::optional strokeWidth; \ + REACT_FIELD(strokeLinecap) \ + std::optional strokeLinecap; \ + REACT_FIELD(strokeLinejoin) \ + std::optional strokeLinejoin; \ + REACT_FIELD(strokeDasharray) \ + std::optional> strokeDasharray; \ + REACT_FIELD(strokeDashoffset) \ + std::optional strokeDashoffset; \ + REACT_FIELD(strokeMiterlimit) \ + std::optional strokeMiterlimit; \ + REACT_FIELD(vectorEffect) \ + std::optional vectorEffect; \ + REACT_FIELD(propList) \ + std::optional> propList; \ + std::optional color; \ winrt::Microsoft::ReactNative::ViewProps m_props{nullptr}; -}; -// Currently no good way to do inheritance in REACT_STRUCTS -#define REACT_SVG_RENDERABLE_COMMON_PROPS \ - REACT_FIELD(fill) \ - REACT_FIELD(fillOpacity) \ - REACT_FIELD(fillRule) \ - REACT_FIELD(stroke) \ - REACT_FIELD(strokeOpacity) \ - REACT_FIELD(strokeWidth) \ - REACT_FIELD(strokeLinecap) \ - REACT_FIELD(strokeLinejoin) \ - REACT_FIELD(strokeDasharray) \ - REACT_FIELD(strokeDashoffset) \ - REACT_FIELD(strokeMiterlimit) \ - REACT_FIELD(vectorEffect) \ - REACT_FIELD(propList) - -REACT_STRUCT(SvgRenderableCommonProps) -struct SvgRenderableCommonProps - : SvgRenderableCommonPropsT { - SvgRenderableCommonProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - - std::optional color; - std::optional fill; // TODO should handle setting a color directly - which would need a custom reader to read a explict color into a ColorStruct - std::optional fillOpacity; // 1.0f - - static_assert(D2D1_FILL_MODE::D2D1_FILL_MODE_WINDING == 1); // NonZero - static_assert(D2D1_FILL_MODE::D2D1_FILL_MODE_ALTERNATE == 0); // EvenOdd - std::optional fillRule; - std::optional stroke; // TODO should handle setting a color directly - which would need a custom reader to read a explict color into a ColorStruct - std::optional strokeOpacity; // 1.0f - std::optional strokeWidth; - std::optional strokeLinecap; - std::optional strokeLinejoin; - std::optional> strokeDasharray; - std::optional strokeDashoffset; - std::optional strokeMiterlimit; - std::optional vectorEffect; // 0 - std::optional> propList; -}; +#define REACT_SVG_RENDERABLE_COMMON_PROPS_INIT \ + : m_props(props) struct __declspec(uuid("a03986c0-b06e-4fb8-a86e-16fcc47b2f31")) RenderableView : public ::IUnknown { - -public: + public: RenderableView() = default; - virtual const wchar_t* GetSvgElementName() noexcept = 0; + virtual const wchar_t *GetSvgElementName() noexcept = 0; // ComponentView void MountChildComponentView( @@ -176,53 +132,163 @@ struct __declspec(uuid("a03986c0-b06e-4fb8-a86e-16fcc47b2f31")) RenderableView : ID2D1SvgElement &Render(const SvgView &svgView, ID2D1SvgDocument &document, ID2D1SvgElement &svgElement) noexcept; - virtual void OnRender(ID2D1SvgDocument &document, ID2D1SvgElement & /*svgElement*/) noexcept; + virtual void OnRender(const SvgView &svgView, ID2D1SvgDocument &document, ID2D1SvgElement & /*svgElement*/) noexcept; virtual bool IsSupported() const noexcept; void Invalidate(const winrt::Microsoft::ReactNative::ComponentView &view); protected: - winrt::com_ptr m_props; + winrt::Microsoft::ReactNative::IComponentProps m_props; private: winrt::com_ptr m_spD2DSvgElement; }; + +template +void SetCommonSvgProps( + const SvgView &svgView, + ID2D1SvgDocument &document, + ID2D1SvgElement &element, + const TProps &commonProps) noexcept { + HRESULT hr = S_OK; + if (commonProps.color != std::nullopt) { + auto color = commonProps.color.value().AsWindowsColor(svgView.Theme()); + hr |= element.SetAttributeValue(SvgStrings::colorAttributeName, D2DHelpers::AsD2DColor(color)); + } + + if (commonProps.propList) { + for (auto &prop : commonProps.propList.value()) { + if (prop == "fill") { + if (commonProps.fill != std::nullopt) + hr |= SetColorMode(svgView, element, SvgStrings::fillAttributeName, commonProps.fill.value()); + else + hr |= element.SetAttributeValue( + SvgStrings::fillAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + SvgStrings::noneAttributeValue); + } else if (prop == "fillOpacity") { + if (commonProps.fillOpacity != std::nullopt) + hr |= element.SetAttributeValue(SvgStrings::fillOpacityAttributeName, commonProps.fillOpacity.value()); + } else if (prop == "fillRule") { + if (commonProps.fillRule != std::nullopt) { + hr |= element.SetAttributeValue(SvgStrings::fillRuleAttributeName, commonProps.fillRule.value()); + } + } else if (prop == "stroke") { + if (commonProps.stroke != std::nullopt) + hr |= SetColorMode(svgView, element, SvgStrings::strokeAttributeName, commonProps.stroke.value()); + else + hr |= element.SetAttributeValue( + SvgStrings::strokeAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + SvgStrings::noneAttributeValue); + } else if (prop == "strokeWidth") { + if (commonProps.strokeWidth != std::nullopt) + hr |= element.SetAttributeValue(SvgStrings::strokeWidthAttributeName, commonProps.strokeWidth.value()); + } else if (prop == "strokeOpacity") { + if (commonProps.strokeOpacity != std::nullopt) + hr |= element.SetAttributeValue(SvgStrings::strokeOpacityAttributeName, commonProps.strokeOpacity.value()); + } else if (prop == "strokeDasharray") { + if (commonProps.strokeDasharray != std::nullopt && !commonProps.strokeDasharray->empty()) { + winrt::com_ptr dashArray; + document.CreateStrokeDashArray( + &commonProps.strokeDasharray.value()[0], + static_cast(commonProps.strokeDasharray.value().size()), + dashArray.put()); + hr |= element.SetAttributeValue(SvgStrings::strokeDashArrayAttributeName, dashArray.get()); + } + } else if (prop == "strokeDashoffset") { + if (commonProps.strokeDashoffset != std::nullopt) { + hr |= element.SetAttributeValue( + SvgStrings::strokeDashOffsetAttributeName, commonProps.strokeDashoffset.value()); + } + } else if (prop == "strokeLinecap") { + if (commonProps.strokeLinecap != std::nullopt) { + static D2D1_SVG_LINE_CAP supportedCaps[] = { + D2D1_SVG_LINE_CAP_BUTT, D2D1_SVG_LINE_CAP_ROUND, D2D1_SVG_LINE_CAP_SQUARE}; + hr |= element.SetAttributeValue( + SvgStrings::strokeLinecapAttributeName, supportedCaps[commonProps.strokeLinecap.value()]); + } + } else if (prop == "strokeLinejoin") { + if (commonProps.strokeLinejoin != std::nullopt) { + static D2D1_SVG_LINE_JOIN supportedJoins[] = { + D2D1_SVG_LINE_JOIN_MITER, D2D1_SVG_LINE_JOIN_ROUND, D2D1_SVG_LINE_JOIN_BEVEL}; + hr |= element.SetAttributeValue( + SvgStrings::strokeLinejoinAttributeName, supportedJoins[commonProps.strokeLinejoin.value()]); + } + } else if (prop == "strokeMiterlimit") { + if (commonProps.strokeMiterlimit != std::nullopt) { + hr |= element.SetAttributeValue( + SvgStrings::strokeMiterLimitAttributeName, commonProps.strokeMiterlimit.value()); + } + } + } + } + + if (commonProps.clipPath != std::nullopt) { + std::wstring namedRefStr = L"url(#" + commonProps.clipPath.value() + L")"; + hr |= element.SetAttributeValue( + SvgStrings::clipPathAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + namedRefStr.c_str()); + } + + if (commonProps.clipRule != std::nullopt) { + hr |= element.SetAttributeValue(SvgStrings::clipRuleAttributeName, commonProps.clipRule.value()); + } + + if (commonProps.name != std::nullopt) + hr |= element.SetAttributeValue( + SvgStrings::idAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + commonProps.name.value().c_str()); + + if (commonProps.opacity != std::nullopt) + hr |= element.SetAttributeValue(SvgStrings::opacityAttributeName, commonProps.opacity.value()); + + if (commonProps.matrix != std::nullopt) { + auto &matrix = commonProps.matrix.value(); + hr |= element.SetAttributeValue( + SvgStrings::transformAttributeName, + D2D1_MATRIX_3X2_F{matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]}); + } + + assert(hr == S_OK); +} } // namespace winrt::RNSVG::implementation -template -void RegisterRenderableComponent(const winrt::hstring& name, const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - builder.AddViewComponent( - name, [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { - builder.SetComponentViewInitializer([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept { - auto userData = winrt::make_self(); - view.UserData(*userData); - }); - builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props) noexcept { - return winrt::make(props); +template +void RegisterRenderableComponent( + const winrt::hstring &name, + const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + builder.AddViewComponent(name, [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { + builder.SetComponentViewInitializer([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept { + auto userData = winrt::make_self(); + view.UserData(*userData); + }); + builder.SetCreateProps( + [](winrt::Microsoft::ReactNative::ViewProps props) noexcept { return winrt::make(props); }); + builder.SetUpdatePropsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view, + const winrt::Microsoft::ReactNative::IComponentProps &newProps, + const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept { + auto userData = winrt::get_self(view.UserData()); + userData->UpdateProps(view, newProps, oldProps); + }); + builder.SetFinalizeUpdateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view, + const winrt::Microsoft::ReactNative::ComponentViewUpdateMask mask) noexcept { + auto userData = winrt::get_self(view.UserData()); + userData->FinalizeUpates(view, mask); + }); + builder.SetMountChildComponentViewHandler( + [](const winrt::Microsoft::ReactNative::ComponentView &view, + const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept { + auto userData = winrt::get_self(view.UserData()); + return userData->MountChildComponentView(view, args); }); - builder.SetUpdatePropsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view, - const winrt::Microsoft::ReactNative::IComponentProps &newProps, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept { + builder.SetUnmountChildComponentViewHandler( + [](const winrt::Microsoft::ReactNative::ComponentView &view, + const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept { auto userData = winrt::get_self(view.UserData()); - userData->UpdateProps(view, newProps, oldProps); + return userData->UnmountChildComponentView(view, args); }); - builder.SetFinalizeUpdateHandler( - [](const winrt::Microsoft::ReactNative::ComponentView &view, - const winrt::Microsoft::ReactNative::ComponentViewUpdateMask mask) noexcept { - auto userData = winrt::get_self(view.UserData()); - userData->FinalizeUpates(view, mask); - }); - builder.SetMountChildComponentViewHandler( - [](const winrt::Microsoft::ReactNative::ComponentView &view, - const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept { - auto userData = winrt::get_self(view.UserData()); - return userData->MountChildComponentView(view, args); - }); - builder.SetUnmountChildComponentViewHandler( - [](const winrt::Microsoft::ReactNative::ComponentView &view, - const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept { - auto userData = winrt::get_self(view.UserData()); - return userData->UnmountChildComponentView(view, args); - }); - }); + }); } diff --git a/windows/RNSVG/Fabric/SvgView.h b/windows/RNSVG/Fabric/SvgView.h index 594a6baf2..8452dc5fe 100644 --- a/windows/RNSVG/Fabric/SvgView.h +++ b/windows/RNSVG/Fabric/SvgView.h @@ -1,7 +1,5 @@ #pragma once -#include "SvgViewProps.g.h" - #include #include #include "NativeModules.h" @@ -11,7 +9,7 @@ namespace winrt::RNSVG::implementation { REACT_STRUCT(SvgViewProps) -struct SvgViewProps : SvgViewPropsT { +struct SvgViewProps : winrt::implements { SvgViewProps(const winrt::Microsoft::ReactNative::ViewProps &props); void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept; diff --git a/windows/RNSVG/Fabric/SymbolView.cpp b/windows/RNSVG/Fabric/SymbolView.cpp deleted file mode 100644 index aba199238..000000000 --- a/windows/RNSVG/Fabric/SymbolView.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "pch.h" -#include "SymbolView.h" - -namespace winrt::RNSVG::implementation { - -SymbolProps::SymbolProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} - -void SymbolProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - -const wchar_t *SymbolView::GetSvgElementName() noexcept { - return L"symbol"; -} - -bool SymbolView::IsSupported() const noexcept { - return false; -} - -void SymbolView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGSymbol", builder); -} - -} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/SymbolView.h b/windows/RNSVG/Fabric/SymbolView.h deleted file mode 100644 index 0bb15c4ac..000000000 --- a/windows/RNSVG/Fabric/SymbolView.h +++ /dev/null @@ -1,44 +0,0 @@ -#pragma once - -#include "SymbolProps.g.h" -#include "GroupView.h" - -namespace winrt::RNSVG::implementation { - -REACT_STRUCT(SymbolProps) -struct SymbolProps : SymbolPropsT { - SymbolProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - REACT_SVG_GROUP_COMMON_PROPS; - - REACT_FIELD(minX) - float minX{0.0f}; - REACT_FIELD(minY) - float minY{0.0f}; - REACT_FIELD(vbWidth) - float vbWidth{0.0f}; - REACT_FIELD(vbHeight) - float vbHeight{0.0f}; - REACT_FIELD(align) - std::string align{""}; - REACT_FIELD(meetOrSlice) - RNSVG::MeetOrSlice meetOrSlice{RNSVG::MeetOrSlice::Meet}; -}; - -struct SymbolView : winrt::implements { - public: - SymbolView() = default; - - const wchar_t *GetSvgElementName() noexcept override; - bool IsSupported() const noexcept override; - - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - -}; - -} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/TSpanView.cpp b/windows/RNSVG/Fabric/TSpanView.cpp deleted file mode 100644 index 7f2c20022..000000000 --- a/windows/RNSVG/Fabric/TSpanView.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "pch.h" -#include "TSpanView.h" - -namespace winrt::RNSVG::implementation { - -TSpanProps::TSpanProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} - -void TSpanProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - -const wchar_t *TSpanView::GetSvgElementName() noexcept { - return L"tSpan"; -} - -bool TSpanView::IsSupported() const noexcept { - return false; -} - -void TSpanView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGTSpan", builder); -} - -} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/TSpanView.h b/windows/RNSVG/Fabric/TSpanView.h deleted file mode 100644 index b2767b59b..000000000 --- a/windows/RNSVG/Fabric/TSpanView.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#include "TSpanProps.g.h" -#include "TextView.h" - -namespace winrt::RNSVG::implementation { - -REACT_STRUCT(TSpanProps) -struct TSpanProps : TSpanPropsT { - TSpanProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - REACT_SVG_GROUP_COMMON_PROPS; - REACT_SVG_TEXT_COMMON_PROPS; - - REACT_FIELD(content) - std::string content{""}; -}; - -struct TSpanView : winrt::implements { -public: - TSpanView() = default; - - const wchar_t *GetSvgElementName() noexcept override; - bool IsSupported() const noexcept override; - - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; -}; - -} // namespace winrt::RNSVG::implementation - diff --git a/windows/RNSVG/Fabric/TextView.cpp b/windows/RNSVG/Fabric/TextView.cpp deleted file mode 100644 index 417942ff1..000000000 --- a/windows/RNSVG/Fabric/TextView.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "pch.h" -#include "TextView.h" - -namespace winrt::RNSVG::implementation { - -SvgTextCommonProps::SvgTextCommonProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} - -void SvgTextCommonProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - -const wchar_t *TextView::GetSvgElementName() noexcept { - return L"text"; -} - -bool TextView::IsSupported() const noexcept { - return false; -} - -void TextView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGText", builder); -} - -} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/TextView.h b/windows/RNSVG/Fabric/TextView.h deleted file mode 100644 index 0cdcd7d4a..000000000 --- a/windows/RNSVG/Fabric/TextView.h +++ /dev/null @@ -1,56 +0,0 @@ -#pragma once - -#include "SvgTextCommonProps.g.h" -#include "GroupView.h" - -namespace winrt::RNSVG::implementation { - -#define REACT_SVG_TEXT_COMMON_PROPS \ - REACT_FIELD(dx) \ - REACT_FIELD(dy) \ - REACT_FIELD(x) \ - REACT_FIELD(y) \ - REACT_FIELD(rotate) \ - REACT_FIELD(inlineSize) \ - REACT_FIELD(textLength) \ - REACT_FIELD(baselineShift) \ - REACT_FIELD(lengthAdjust) \ - REACT_FIELD(alignmentBaseline) \ - REACT_FIELD(verticalAlign) - -REACT_STRUCT(SvgTextCommonProps) -struct SvgTextCommonProps : SvgTextCommonPropsT { - SvgTextCommonProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - REACT_SVG_GROUP_COMMON_PROPS; - REACT_SVG_TEXT_COMMON_PROPS; - - std::optional> dx; - std::optional> dy; - std::optional> x; - std::optional> y; - std::optional> rotate; - RNSVG::SVGLength inlineSize{0, winrt::RNSVG::LengthType::Unknown}; - RNSVG::SVGLength textLength{0, winrt::RNSVG::LengthType::Unknown}; - RNSVG::SVGLength baselineShift{0, winrt::RNSVG::LengthType::Unknown}; - std::string lengthAdjust; - std::string alignmentBaseline; - RNSVG::SVGLength verticalAlign{0, winrt::RNSVG::LengthType::Unknown}; -}; - -struct TextView : winrt::implements { - public: - TextView() = default; - - const wchar_t *GetSvgElementName() noexcept override; - bool IsSupported() const noexcept override; - - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; -}; - -} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/UnsupportedSvgView.cpp b/windows/RNSVG/Fabric/UnsupportedSvgView.cpp new file mode 100644 index 000000000..0723b667f --- /dev/null +++ b/windows/RNSVG/Fabric/UnsupportedSvgView.cpp @@ -0,0 +1,33 @@ +#include "pch.h" +#include "UnsupportedSvgView.h" + +namespace winrt::RNSVG::implementation { + +REACT_STRUCT(UnsupportedProps) +struct UnsupportedProps : public winrt::implements { + UnsupportedProps(const winrt::Microsoft::ReactNative::ViewProps &/*props*/) {} + + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); + } +}; + +struct UnsupportedSvgView : winrt::implements { + public: + UnsupportedSvgView() = default; + + const wchar_t *GetSvgElementName() noexcept override{ + assert(false); + return L"unsupported"; +} + + bool IsSupported() const noexcept override { + return false; + } +}; + +void RegisterUnsupportedSvgComponent(const winrt::hstring& name, const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + RegisterRenderableComponent(name, builder); +} + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/UnsupportedSvgView.h b/windows/RNSVG/Fabric/UnsupportedSvgView.h new file mode 100644 index 000000000..94ff3bc39 --- /dev/null +++ b/windows/RNSVG/Fabric/UnsupportedSvgView.h @@ -0,0 +1,9 @@ +#pragma once + +#include "RenderableView.h" + +namespace winrt::RNSVG::implementation { + +void RegisterUnsupportedSvgComponent(const winrt::hstring& name, const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; + +} // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/UseView.cpp b/windows/RNSVG/Fabric/UseView.cpp index 7acb97192..3212df6d1 100644 --- a/windows/RNSVG/Fabric/UseView.cpp +++ b/windows/RNSVG/Fabric/UseView.cpp @@ -3,34 +3,53 @@ namespace winrt::RNSVG::implementation { -UseProps::UseProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} - -void UseProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - -const wchar_t *UseView::GetSvgElementName() noexcept { - return L"use"; -} - -void UseView::OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement &svgElement) noexcept { - auto props = m_props.as(); - svgElement.SetAttributeValue( - SvgStrings::xlinkhrefAttributeName, - D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, - (L"#" + props->href).c_str()); - - svgElement.SetAttributeValue(SvgStrings::xAttributeName, props->x); - svgElement.SetAttributeValue(SvgStrings::yAttributeName, props->y); - svgElement.SetAttributeValue(SvgStrings::widthAttributeName, props->width); - svgElement.SetAttributeValue(SvgStrings::heightAttributeName, props->height); -} - -void UseView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGUse", builder); +REACT_STRUCT(UseProps) +struct UseProps : winrt::implements { + UseProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT {} + + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); + } + + REACT_SVG_RENDERABLE_COMMON_PROPS; + + REACT_FIELD(href) + std::wstring href; + REACT_FIELD(x) + D2D1_SVG_LENGTH x{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; + REACT_FIELD(y) + D2D1_SVG_LENGTH y{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; + REACT_FIELD(width) + D2D1_SVG_LENGTH width{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; + REACT_FIELD(height) + D2D1_SVG_LENGTH height{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; +}; + +struct UseView : winrt::implements { + public: + UseView() = default; + + const wchar_t *GetSvgElementName() noexcept override { + return L"use"; + } + + void OnRender(const SvgView &svgView, ID2D1SvgDocument &document, ID2D1SvgElement &element) noexcept override { + auto props = m_props.as(); + SetCommonSvgProps(svgView, document, element, *props); + element.SetAttributeValue( + SvgStrings::xlinkhrefAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + (L"#" + props->href).c_str()); + + element.SetAttributeValue(SvgStrings::xAttributeName, props->x); + element.SetAttributeValue(SvgStrings::yAttributeName, props->y); + element.SetAttributeValue(SvgStrings::widthAttributeName, props->width); + element.SetAttributeValue(SvgStrings::heightAttributeName, props->height); + } +}; + +void RegisterUseComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { + RegisterRenderableComponent(L"RNSVGUse", builder); } } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/UseView.h b/windows/RNSVG/Fabric/UseView.h index ec390acab..ac3ce4411 100644 --- a/windows/RNSVG/Fabric/UseView.h +++ b/windows/RNSVG/Fabric/UseView.h @@ -1,40 +1,10 @@ #pragma once -#include "UseProps.g.h" #include "RenderableView.h" namespace winrt::RNSVG::implementation { -REACT_STRUCT(UseProps) -struct UseProps : UsePropsT { - UseProps(const winrt::Microsoft::ReactNative::ViewProps &props); +void RegisterUseComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - - REACT_FIELD(href) - std::wstring href; - REACT_FIELD(x) - D2D1_SVG_LENGTH x{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; - REACT_FIELD(y) - D2D1_SVG_LENGTH y{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; - REACT_FIELD(width) - D2D1_SVG_LENGTH width{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; - REACT_FIELD(height) - D2D1_SVG_LENGTH height{0, D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER}; -}; - -struct UseView : winrt::implements { - public: - UseView() = default; - - const wchar_t *GetSvgElementName() noexcept override; - void OnRender(ID2D1SvgDocument & /*document*/, ID2D1SvgElement & /*element*/) noexcept override; - - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; -}; } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/RNSVG.vcxproj b/windows/RNSVG/RNSVG.vcxproj index e54c308de..358793bbc 100644 --- a/windows/RNSVG/RNSVG.vcxproj +++ b/windows/RNSVG/RNSVG.vcxproj @@ -209,7 +209,6 @@ - @@ -218,17 +217,12 @@ - - - - - - + @@ -279,7 +273,6 @@ - diff --git a/windows/RNSVG/ReactPackageProvider.cpp b/windows/RNSVG/ReactPackageProvider.cpp index ff4db9754..e232777ef 100644 --- a/windows/RNSVG/ReactPackageProvider.cpp +++ b/windows/RNSVG/ReactPackageProvider.cpp @@ -16,16 +16,11 @@ #include "Fabric/ImageView.h" #include "Fabric/UseView.h" #include "Fabric/GroupView.h" -#include "Fabric/SymbolView.h" #include "Fabric/DefsView.h" #include "Fabric/ClipPathView.h" -#include "Fabric/MarkerView.h" -#include "Fabric/MaskView.h" #include "Fabric/LinearGradientView.h" #include "Fabric/RadialGradientView.h" -#include "Fabric/PatternView.h" -#include "Fabric/TextView.h" -#include "Fabric/TSpanView.h" +#include "Fabric/UnsupportedSvgView.h" #else #include "SvgViewManager.h" #include "GroupViewManager.h" @@ -60,24 +55,24 @@ namespace winrt::RNSVG::implementation auto fabricPackageBuilder = packageBuilder.as(); SvgView::RegisterComponent(fabricPackageBuilder); - RectView::RegisterComponent(fabricPackageBuilder); - CircleView::RegisterComponent(fabricPackageBuilder); - EllipseView::RegisterComponent(fabricPackageBuilder); - LineView::RegisterComponent(fabricPackageBuilder); - PathView::RegisterComponent(fabricPackageBuilder); + RegisterRectComponent(fabricPackageBuilder); + RegisterCircleComponent(fabricPackageBuilder); + RegisterEllipseComponent(fabricPackageBuilder); + RegisterLineComponent(fabricPackageBuilder); + RegisterPathComponent(fabricPackageBuilder); ImageView::RegisterComponent(fabricPackageBuilder); - UseView::RegisterComponent(fabricPackageBuilder); - GroupView::RegisterComponent(fabricPackageBuilder); - SymbolView::RegisterComponent(fabricPackageBuilder); - DefsView::RegisterComponent(fabricPackageBuilder); - ClipPathView::RegisterComponent(fabricPackageBuilder); - MarkerView::RegisterComponent(fabricPackageBuilder); - MaskView::RegisterComponent(fabricPackageBuilder); - LinearGradientView::RegisterComponent(fabricPackageBuilder); - RadialGradientView::RegisterComponent(fabricPackageBuilder); - PatternView::RegisterComponent(fabricPackageBuilder); - TextView::RegisterComponent(fabricPackageBuilder); - TSpanView::RegisterComponent(fabricPackageBuilder); + RegisterUseComponent(fabricPackageBuilder); + RegisterGroupComponent(fabricPackageBuilder); + RegisterUnsupportedSvgComponent(L"RNSVGSymbol", fabricPackageBuilder); + RegisterDefsComponent(fabricPackageBuilder); + RegisterClipPathComponent(fabricPackageBuilder); + RegisterUnsupportedSvgComponent(L"RNSVGMarker", fabricPackageBuilder); + RegisterUnsupportedSvgComponent(L"RNSVGMask", fabricPackageBuilder); + RegisterLinearGradientComponent(fabricPackageBuilder); + RegisterRadialGradientComponent(fabricPackageBuilder); + RegisterUnsupportedSvgComponent(L"RNSVGPattern", fabricPackageBuilder); + RegisterUnsupportedSvgComponent(L"RNSVGText", fabricPackageBuilder); + RegisterUnsupportedSvgComponent(L"RNSVGTSpan", fabricPackageBuilder); #else packageBuilder.AddViewManager(L"SvgViewManager", []() { return winrt::make(); }); packageBuilder.AddViewManager(L"RectViewManager", []() { return winrt::make(); }); diff --git a/windows/RNSVG/ViewProps.idl b/windows/RNSVG/ViewProps.idl deleted file mode 100644 index e154a2175..000000000 --- a/windows/RNSVG/ViewProps.idl +++ /dev/null @@ -1,107 +0,0 @@ -namespace RNSVG -{ - [experimental] - [default_interface] - unsealed runtimeclass SvgNodeCommonProps : Microsoft.ReactNative.IComponentProps { - }; - - [experimental] - [default_interface] - unsealed runtimeclass SvgRenderableCommonProps : SvgNodeCommonProps { - }; - - [experimental] - [default_interface] - runtimeclass SvgViewProps : Microsoft.ReactNative.IComponentProps { - }; - - [experimental] - [default_interface] - unsealed runtimeclass RectProps : SvgRenderableCommonProps { - }; - - [experimental] - [default_interface] - unsealed runtimeclass CircleProps : SvgRenderableCommonProps { - }; - - [experimental] - [default_interface] - unsealed runtimeclass EllipseProps : SvgRenderableCommonProps { - }; - - [experimental] - [default_interface] - unsealed runtimeclass LineProps : SvgRenderableCommonProps { - }; - - [experimental] - [default_interface] - unsealed runtimeclass PathProps : SvgRenderableCommonProps { - }; - - [experimental] - [default_interface] - unsealed runtimeclass UseProps : SvgRenderableCommonProps { - }; - - [experimental] - [default_interface] - unsealed runtimeclass SymbolProps : SvgRenderableCommonProps { - }; - - [experimental] - [default_interface] - unsealed runtimeclass ImageProps : SvgRenderableCommonProps { - }; - - [experimental] - [default_interface] - unsealed runtimeclass SvgGroupCommonProps : SvgRenderableCommonProps { - }; - - [experimental] - [default_interface] - unsealed runtimeclass DefsProps : SvgGroupCommonProps { - }; - - [experimental] - [default_interface] - unsealed runtimeclass ClipPathProps : SvgGroupCommonProps { - }; - - [experimental] - [default_interface] - unsealed runtimeclass MarkerProps : SvgGroupCommonProps { - }; - - [experimental] - [default_interface] - unsealed runtimeclass MaskProps : SvgGroupCommonProps { - }; - - [experimental] - [default_interface] - unsealed runtimeclass LinearGradientProps : SvgGroupCommonProps { - }; - - [experimental] - [default_interface] - unsealed runtimeclass RadialGradientProps : SvgGroupCommonProps { - }; - - [experimental] - [default_interface] - unsealed runtimeclass PatternProps : SvgGroupCommonProps { - }; - - [experimental] - [default_interface] - unsealed runtimeclass SvgTextCommonProps : SvgGroupCommonProps { - }; - - [experimental] - [default_interface] - unsealed runtimeclass TSpanProps : SvgTextCommonProps { - }; -} \ No newline at end of file From d594ac09bb7bb6e79b4a5aded3ae44e4750d27a2 Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Sat, 2 Nov 2024 10:20:41 -0700 Subject: [PATCH 05/13] Image support --- windows/RNSVG/Fabric/ImageView.cpp | 118 ++++++++++++++++++++++--- windows/RNSVG/Fabric/ImageView.h | 67 +------------- windows/RNSVG/Fabric/SvgView.cpp | 2 +- windows/RNSVG/Fabric/SvgView.h | 2 + windows/RNSVG/ReactPackageProvider.cpp | 2 +- 5 files changed, 109 insertions(+), 82 deletions(-) diff --git a/windows/RNSVG/Fabric/ImageView.cpp b/windows/RNSVG/Fabric/ImageView.cpp index e92cc5403..0080da8af 100644 --- a/windows/RNSVG/Fabric/ImageView.cpp +++ b/windows/RNSVG/Fabric/ImageView.cpp @@ -3,24 +3,114 @@ namespace winrt::RNSVG::implementation { -ImageProps::ImageProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT {} +REACT_STRUCT(ImageSource) +struct ImageSource { + REACT_FIELD(uri) + std::wstring uri{}; + REACT_FIELD(width) + float width{0.0f}; + REACT_FIELD(height) + float height{0.0f}; -void ImageProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} + bool operator==(const ImageSource &rhs) const { + return uri == rhs.uri && width == rhs.width && height == rhs.height; + } -const wchar_t *ImageView::GetSvgElementName() noexcept { - return L"image"; -} + bool operator!=(const ImageSource &rhs) const { + return !(*this == rhs); + } +}; -bool ImageView::IsSupported() const noexcept { - return false; -} +REACT_STRUCT(ImageProps) +struct ImageProps : winrt::implements { + ImageProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT {} + + void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { + winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); + } + + REACT_SVG_RENDERABLE_COMMON_PROPS; + + REACT_FIELD(x) + std::optional x; + REACT_FIELD(y) + std::optional y; + REACT_FIELD(width) + std::optional width; + REACT_FIELD(height) + std::optional height; + REACT_FIELD(src) + ImageSource src; + REACT_FIELD(align) + std::optional align{""}; + REACT_FIELD(meetOrSlice) + std::optional meetOrSlice; +}; + +struct ImageView : winrt::implements { + public: + ImageView() = default; + + const wchar_t *GetSvgElementName() noexcept override { + return L"image"; + } + + void UpdateProps( + const winrt::Microsoft::ReactNative::ComponentView &view, + const winrt::Microsoft::ReactNative::IComponentProps &newProps, + const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept { + RenderableView::UpdateProps(view, newProps, oldProps); + + auto props = newProps.as(); + + if (!props->align) { + m_aspectAlign = AlignToAspectAlign(props->align.value()); + } else { + m_aspectAlign = D2D1_SVG_ASPECT_ALIGN::D2D1_SVG_ASPECT_ALIGN_NONE; + } + } + + void OnRender(const SvgView &svgView, ID2D1SvgDocument &document, ID2D1SvgElement &element) noexcept override { + auto props = m_props.as(); + SetCommonSvgProps(svgView, document, element, *props); + + if (props->x) { + element.SetAttributeValue(SvgStrings::xAttributeName, props->x.value()); + } + if (props->y) { + element.SetAttributeValue(SvgStrings::yAttributeName, props->y.value()); + } + if (props->width) { + element.SetAttributeValue(SvgStrings::widthAttributeName, props->width.value()); + } + if (props->height) { + element.SetAttributeValue(SvgStrings::heightAttributeName, props->height.value()); + } + + if (props->align != std::nullopt || props->meetOrSlice != std::nullopt) { + D2D1_SVG_PRESERVE_ASPECT_RATIO preserveAspectRatio; + preserveAspectRatio.defer = false; + preserveAspectRatio.align = m_aspectAlign; + + preserveAspectRatio.meetOrSlice = props->meetOrSlice.value() == MeetOrSlice::Meet + ? D2D1_SVG_ASPECT_SCALING::D2D1_SVG_ASPECT_SCALING_MEET + : D2D1_SVG_ASPECT_SCALING::D2D1_SVG_ASPECT_SCALING_SLICE; + element.SetAttributeValue(SvgStrings::preserveAspectRatioAttributeName, preserveAspectRatio); + } + + if (!props->src.uri.empty()) { + element.SetAttributeValue( + SvgStrings::xlinkhrefAttributeName, + D2D1_SVG_ATTRIBUTE_STRING_TYPE::D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, + props->src.uri.c_str()); + } + } + + private: + D2D1_SVG_ASPECT_ALIGN m_aspectAlign; +}; -void ImageView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { +void RegisterImageComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { RegisterRenderableComponent(L"RNSVGImage", builder); } diff --git a/windows/RNSVG/Fabric/ImageView.h b/windows/RNSVG/Fabric/ImageView.h index 23c784041..fd79aac4c 100644 --- a/windows/RNSVG/Fabric/ImageView.h +++ b/windows/RNSVG/Fabric/ImageView.h @@ -3,72 +3,7 @@ #include "RenderableView.h" namespace winrt::RNSVG::implementation { -enum class ImageSourceType { Uri = 0, Download = 1, InlineData = 2 }; -enum class ImageSourceFormat { Bitmap = 0, Svg = 1 }; -REACT_STRUCT(ImageSource) -struct ImageSource { - REACT_FIELD(uri) - std::string uri{""}; - REACT_FIELD(method) - std::string method{""}; - //REACT_FIELD(headers) - //std::vector headers; - REACT_FIELD(body) - std::string body{""}; - REACT_FIELD(width) - float width{0.0f}; - REACT_FIELD(height) - float height{0.0f}; - REACT_FIELD(scale) - float scale{1.0f}; - /*REACT_FIELD(packagerAsset) - bool packagerAsset{false}; - REACT_FIELD(type) - ImageSourceType type{ImageSourceType::Uri}; - REACT_FIELD(format) - ImageSourceFormat format{ImageSourceFormat::Bitmap};*/ +void RegisterImageComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - bool operator==(const ImageSource &rhs) const { - return uri == rhs.uri && method == rhs.method && width == rhs.width && height == rhs.height && scale == rhs.scale; - } - - bool operator!=(const ImageSource &rhs) const { - return !(*this == rhs); - } -}; - -REACT_STRUCT(ImageProps) -struct ImageProps : winrt::implements { - ImageProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept; - - REACT_SVG_RENDERABLE_COMMON_PROPS; - - REACT_FIELD(x) - std::optional x; - REACT_FIELD(y) - std::optional y; - REACT_FIELD(width) - std::optional width; - REACT_FIELD(height) - std::optional height; - REACT_FIELD(src) - ImageSource src; - REACT_FIELD(align) - std::string align{""}; - REACT_FIELD(meetOrSlice) - int32_t meetOrSlice{0}; -}; - -struct ImageView : winrt::implements { - public: - ImageView() = default; - - const wchar_t *GetSvgElementName() noexcept override; - bool IsSupported() const noexcept override; - - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; -}; } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/SvgView.cpp b/windows/RNSVG/Fabric/SvgView.cpp index 4146764fa..f88b8cc4c 100644 --- a/windows/RNSVG/Fabric/SvgView.cpp +++ b/windows/RNSVG/Fabric/SvgView.cpp @@ -62,7 +62,7 @@ void SvgView::OnUnmounted() noexcept { m_isMounted = false; } -D2D1_SVG_ASPECT_ALIGN AlignToAspectAlign(const std::string &align) { +D2D1_SVG_ASPECT_ALIGN AlignToAspectAlign(const std::string &align) noexcept { if (align.compare("xMinYMin") == 0) return D2D1_SVG_ASPECT_ALIGN::D2D1_SVG_ASPECT_ALIGN_X_MIN_Y_MIN; else if (align.compare("xMidYMin") == 0) diff --git a/windows/RNSVG/Fabric/SvgView.h b/windows/RNSVG/Fabric/SvgView.h index 8452dc5fe..4ba7ae711 100644 --- a/windows/RNSVG/Fabric/SvgView.h +++ b/windows/RNSVG/Fabric/SvgView.h @@ -8,6 +8,8 @@ namespace winrt::RNSVG::implementation { +D2D1_SVG_ASPECT_ALIGN AlignToAspectAlign(const std::string &align) noexcept; + REACT_STRUCT(SvgViewProps) struct SvgViewProps : winrt::implements { SvgViewProps(const winrt::Microsoft::ReactNative::ViewProps &props); diff --git a/windows/RNSVG/ReactPackageProvider.cpp b/windows/RNSVG/ReactPackageProvider.cpp index e232777ef..8777d1050 100644 --- a/windows/RNSVG/ReactPackageProvider.cpp +++ b/windows/RNSVG/ReactPackageProvider.cpp @@ -60,7 +60,7 @@ namespace winrt::RNSVG::implementation RegisterEllipseComponent(fabricPackageBuilder); RegisterLineComponent(fabricPackageBuilder); RegisterPathComponent(fabricPackageBuilder); - ImageView::RegisterComponent(fabricPackageBuilder); + RegisterImageComponent(fabricPackageBuilder); RegisterUseComponent(fabricPackageBuilder); RegisterGroupComponent(fabricPackageBuilder); RegisterUnsupportedSvgComponent(L"RNSVGSymbol", fabricPackageBuilder); From c09d93eb560c395e5c3403ac4288f6cc42596fc1 Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Mon, 4 Nov 2024 10:11:45 -0800 Subject: [PATCH 06/13] Simplify paper code by removing no longer used fabric code --- windows/RNSVG/BrushView.h | 2 - windows/RNSVG/CircleView.cpp | 32 --- windows/RNSVG/CircleView.h | 40 ---- windows/RNSVG/ClipPathView.cpp | 14 -- windows/RNSVG/ClipPathView.h | 23 -- windows/RNSVG/D2DHelpers.h | 5 +- windows/RNSVG/DefsView.cpp | 15 -- windows/RNSVG/DefsView.h | 25 -- windows/RNSVG/EllipseView.cpp | 30 --- windows/RNSVG/EllipseView.h | 39 --- windows/RNSVG/Fabric/ClipPathView.cpp | 4 +- windows/RNSVG/Fabric/D2DHelpers.h | 18 ++ windows/RNSVG/Fabric/DefsView.cpp | 4 +- windows/RNSVG/Fabric/GroupView.cpp | 6 +- windows/RNSVG/Fabric/GroupView.h | 63 ----- windows/RNSVG/Fabric/ImageView.cpp | 2 +- windows/RNSVG/Fabric/LinearGradientView.cpp | 4 +- windows/RNSVG/Fabric/RadialGradientView.cpp | 4 +- windows/RNSVG/Fabric/RenderableView.cpp | 2 +- windows/RNSVG/Fabric/RenderableView.h | 2 +- windows/RNSVG/Fabric/SvgView.cpp | 4 +- windows/RNSVG/Fabric/SvgView.h | 15 +- windows/RNSVG/GroupView.cpp | 74 ------ windows/RNSVG/GroupView.h | 92 ------- windows/RNSVG/ImageView.cpp | 51 ---- windows/RNSVG/ImageView.h | 77 ------ windows/RNSVG/LineView.cpp | 31 --- windows/RNSVG/LineView.h | 39 --- windows/RNSVG/LinearGradientView.cpp | 38 --- windows/RNSVG/LinearGradientView.h | 46 ---- windows/RNSVG/MarkerView.cpp | 27 --- windows/RNSVG/MarkerView.h | 55 ----- windows/RNSVG/MaskView.cpp | 28 --- windows/RNSVG/MaskView.h | 43 ---- windows/RNSVG/PathView.cpp | 32 --- windows/RNSVG/PathView.h | 33 --- windows/RNSVG/PatternView.cpp | 50 ---- windows/RNSVG/PatternView.h | 60 ----- windows/RNSVG/RNSVG.vcxproj | 12 +- windows/RNSVG/RadialGradientView.cpp | 41 ---- windows/RNSVG/RadialGradientView.h | 51 ---- windows/RNSVG/RectView.h | 43 ---- windows/RNSVG/RenderableView.h | 204 ---------------- windows/RNSVG/SVGLength.h | 2 - windows/RNSVG/SvgView.cpp | 251 -------------------- windows/RNSVG/SvgView.h | 98 -------- windows/RNSVG/SymbolView.cpp | 34 +-- windows/RNSVG/SymbolView.h | 44 ---- windows/RNSVG/TSpanView.cpp | 28 --- windows/RNSVG/TSpanView.h | 36 --- windows/RNSVG/TextView.cpp | 66 ----- windows/RNSVG/TextView.h | 57 ----- windows/RNSVG/UseView.cpp | 36 --- windows/RNSVG/UseView.h | 41 ---- windows/RNSVG/Utils.h | 54 ----- 55 files changed, 48 insertions(+), 2179 deletions(-) create mode 100644 windows/RNSVG/Fabric/D2DHelpers.h diff --git a/windows/RNSVG/BrushView.h b/windows/RNSVG/BrushView.h index 6c83ebdea..b92a75776 100644 --- a/windows/RNSVG/BrushView.h +++ b/windows/RNSVG/BrushView.h @@ -25,9 +25,7 @@ struct BrushView : BrushViewT { }; } // namespace winrt::RNSVG::implementation -#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct BrushView : BrushViewT {}; } // namespace winrt::RNSVG::factory_implementation -#endif diff --git a/windows/RNSVG/CircleView.cpp b/windows/RNSVG/CircleView.cpp index 0a5141e5f..12b0e91cc 100644 --- a/windows/RNSVG/CircleView.cpp +++ b/windows/RNSVG/CircleView.cpp @@ -12,37 +12,6 @@ using namespace Microsoft::ReactNative; namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -CircleProps::CircleProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} - -void CircleProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - -void CircleView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGCircle", builder); -} - -void CircleView::UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate, - bool invalidate) noexcept { - auto circleProps = props.try_as(); - if (circleProps) { - m_props = circleProps; - - m_cx = m_props->cx; - m_cy = m_props->cy; - m_r = m_props->r; - } - - base_type::UpdateProperties(props, oldProps, forceUpdate, invalidate); -} -#else void CircleView::UpdateProperties(IJSValueReader const &reader, bool forceUpdate, bool invalidate) { const JSValueObject &propertyMap{JSValue::ReadObjectFrom(reader)}; @@ -61,7 +30,6 @@ void CircleView::UpdateProperties(IJSValueReader const &reader, bool forceUpdate __super::UpdateProperties(reader, forceUpdate, invalidate); } -#endif void CircleView::CreateGeometry(RNSVG::D2DDeviceContext const &context) { auto const root{SvgRoot()}; diff --git a/windows/RNSVG/CircleView.h b/windows/RNSVG/CircleView.h index ba73ac3c9..e12061330 100644 --- a/windows/RNSVG/CircleView.h +++ b/windows/RNSVG/CircleView.h @@ -1,51 +1,16 @@ #pragma once -#ifdef USE_FABRIC -#include "CircleProps.g.h" -#endif - #include "CircleView.g.h" #include "RenderableView.h" namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -REACT_STRUCT(CircleProps) -struct CircleProps : CirclePropsT { - CircleProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - - REACT_FIELD(r) - RNSVG::SVGLength r{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(cx) - RNSVG::SVGLength cx{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(cy) - RNSVG::SVGLength cy{0, winrt::RNSVG::LengthType::Unknown}; -}; -#endif - struct CircleView : CircleViewT { public: CircleView() = default; -#ifdef USE_FABRIC - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - - // IRenderableFabric - void UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate = true, - bool invalidate = true) noexcept override; -#else // IRenderablePaper void UpdateProperties(Microsoft::ReactNative::IJSValueReader const &reader, bool forceUpdate, bool invalidate); -#endif // IRenderable void CreateGeometry(RNSVG::D2DDeviceContext const &context); @@ -55,14 +20,9 @@ struct CircleView : CircleViewT m_props; -#endif }; } // namespace winrt::RNSVG::implementation -#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct CircleView : CircleViewT {}; } // namespace winrt::RNSVG::factory_implementation -#endif diff --git a/windows/RNSVG/ClipPathView.cpp b/windows/RNSVG/ClipPathView.cpp index 38c6eecc0..9ed0465a8 100644 --- a/windows/RNSVG/ClipPathView.cpp +++ b/windows/RNSVG/ClipPathView.cpp @@ -7,18 +7,4 @@ using namespace winrt; namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -ClipPathProps::ClipPathProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} - -void ClipPathProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - -void ClipPathView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGClipPath", builder); -} -#endif } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/ClipPathView.h b/windows/RNSVG/ClipPathView.h index 0634db6da..f56c7cdc1 100644 --- a/windows/RNSVG/ClipPathView.h +++ b/windows/RNSVG/ClipPathView.h @@ -1,41 +1,18 @@ #pragma once -#ifdef USE_FABRIC -#include "ClipPathProps.g.h" -#endif - #include "ClipPathView.g.h" #include "GroupView.h" namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -REACT_STRUCT(ClipPathProps) -struct ClipPathProps : ClipPathPropsT { - ClipPathProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - REACT_SVG_GROUP_COMMON_PROPS; -}; -#endif struct ClipPathView : ClipPathViewT { public: ClipPathView() = default; -#ifdef USE_FABRIC - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; -#endif - // IRenderable void Draw(RNSVG::D2DDeviceContext const & /*deviceContext*/, Windows::Foundation::Size const & /*size*/){}; }; } // namespace winrt::RNSVG::implementation -#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct ClipPathView : ClipPathViewT {}; } // namespace winrt::RNSVG::factory_implementation -#endif \ No newline at end of file diff --git a/windows/RNSVG/D2DHelpers.h b/windows/RNSVG/D2DHelpers.h index 3f0a27e1c..931f86e44 100644 --- a/windows/RNSVG/D2DHelpers.h +++ b/windows/RNSVG/D2DHelpers.h @@ -43,7 +43,7 @@ struct D2DHelpers { deviceContext->PushLayer(layerParams, opacityLayer.get()); } -#ifndef USE_FABRIC + static D2D1_CAP_STYLE GetLineCap(RNSVG::LineCap const &lineCap) { switch (lineCap) { case RNSVG::LineCap::Square: @@ -77,7 +77,6 @@ struct D2DHelpers { return D2D1_FILL_MODE_WINDING; } } -#endif static D2D1::ColorF AsD2DColor(winrt::Windows::UI::Color const &color) { return { @@ -131,7 +130,6 @@ struct D2DHelpers { return transform; } -#ifndef USE_FABRIC static DWRITE_FONT_WEIGHT FontWeightFrom( xaml::FrameworkElement const &parent, hstring const &weight) { @@ -156,7 +154,6 @@ struct D2DHelpers { return D2DHelpers::GetClosestFontWeight(std::stof(weight.c_str(), nullptr)); } -#endif // https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight#meaning_of_relative_weights static DWRITE_FONT_WEIGHT Bolder(DWRITE_FONT_WEIGHT weight) { diff --git a/windows/RNSVG/DefsView.cpp b/windows/RNSVG/DefsView.cpp index 9a19301a9..9674cbe1e 100644 --- a/windows/RNSVG/DefsView.cpp +++ b/windows/RNSVG/DefsView.cpp @@ -8,20 +8,5 @@ using namespace winrt; namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -DefsProps::DefsProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} - -void DefsProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - -void DefsView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGDefs", builder); -} -#endif - void DefsView::Draw(RNSVG::D2DDeviceContext const& /*deviceContext*/, Size const & /*size*/) {} } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/DefsView.h b/windows/RNSVG/DefsView.h index ca777c56e..7176535f7 100644 --- a/windows/RNSVG/DefsView.h +++ b/windows/RNSVG/DefsView.h @@ -1,44 +1,19 @@ #pragma once -#ifdef USE_FABRIC -#include "DefsProps.g.h" -#endif - #include "DefsView.g.h" #include "GroupView.h" namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -REACT_STRUCT(DefsProps) -struct DefsProps : DefsPropsT { - DefsProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - REACT_SVG_GROUP_COMMON_PROPS; - -}; -#endif - struct DefsView : DefsViewT { public: DefsView() = default; -#ifdef USE_FABRIC - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; -#endif - // IRenderable void Draw(RNSVG::D2DDeviceContext const &deviceContext, Windows::Foundation::Size const &size); }; } // namespace winrt::RNSVG::implementation -#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct DefsView : DefsViewT {}; } // namespace winrt::RNSVG::factory_implementation -#endif \ No newline at end of file diff --git a/windows/RNSVG/EllipseView.cpp b/windows/RNSVG/EllipseView.cpp index 5ce4a38cc..cf37a1cc9 100644 --- a/windows/RNSVG/EllipseView.cpp +++ b/windows/RNSVG/EllipseView.cpp @@ -11,36 +11,7 @@ using namespace winrt; using namespace Microsoft::ReactNative; namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -EllipseProps::EllipseProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} -void EllipseProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - -void EllipseView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGEllipse", builder); -} - -void EllipseView::UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate, - bool invalidate) noexcept { - auto ellipseProps = props.try_as(); - if (ellipseProps) { - m_cx = ellipseProps->cx; - m_cy = ellipseProps->cy; - m_rx = ellipseProps->rx; - m_ry = ellipseProps->ry; - } - - base_type::UpdateProperties(props, oldProps, forceUpdate, invalidate); -} -#else void EllipseView::UpdateProperties(IJSValueReader const &reader, bool forceUpdate, bool invalidate) { const JSValueObject &propertyMap{JSValue::ReadObjectFrom(reader)}; @@ -61,7 +32,6 @@ void EllipseView::UpdateProperties(IJSValueReader const &reader, bool forceUpdat __super::UpdateProperties(reader, forceUpdate, invalidate); } -#endif void EllipseView::CreateGeometry(RNSVG::D2DDeviceContext const &context) { auto const root{SvgRoot()}; diff --git a/windows/RNSVG/EllipseView.h b/windows/RNSVG/EllipseView.h index 29415494b..acbc270c0 100644 --- a/windows/RNSVG/EllipseView.h +++ b/windows/RNSVG/EllipseView.h @@ -1,53 +1,16 @@ #pragma once -#ifdef USE_FABRIC -#include "EllipseProps.g.h" -#endif - #include "EllipseView.g.h" #include "RenderableView.h" namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -REACT_STRUCT(EllipseProps) -struct EllipseProps : EllipsePropsT { - EllipseProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - - REACT_FIELD(cx) - RNSVG::SVGLength cx{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(cy) - RNSVG::SVGLength cy{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(rx) - RNSVG::SVGLength rx{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(ry) - RNSVG::SVGLength ry{0, winrt::RNSVG::LengthType::Unknown}; -}; -#endif - struct EllipseView : EllipseViewT { public: EllipseView() = default; -#ifdef USE_FABRIC - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - - // IRenderableFabric - void UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate = true, - bool invalidate = true) noexcept override; -#else // IRenderablePaper void UpdateProperties(Microsoft::ReactNative::IJSValueReader const &reader, bool forceUpdate, bool invalidate); -#endif // IRenderable void CreateGeometry(RNSVG::D2DDeviceContext const &context); @@ -60,8 +23,6 @@ struct EllipseView : EllipseViewT {}; } // namespace winrt::RNSVG::factory_implementation -#endif diff --git a/windows/RNSVG/Fabric/ClipPathView.cpp b/windows/RNSVG/Fabric/ClipPathView.cpp index e71b63f5f..6af618d01 100644 --- a/windows/RNSVG/Fabric/ClipPathView.cpp +++ b/windows/RNSVG/Fabric/ClipPathView.cpp @@ -5,13 +5,13 @@ namespace winrt::RNSVG::implementation { REACT_STRUCT(ClipPathProps) struct ClipPathProps : winrt::implements { - ClipPathProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_GROUP_COMMON_PROPS_INIT {} + ClipPathProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT {} void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); } - REACT_SVG_GROUP_COMMON_PROPS; + REACT_SVG_RENDERABLE_COMMON_PROPS; }; struct ClipPathView : winrt::implements { diff --git a/windows/RNSVG/Fabric/D2DHelpers.h b/windows/RNSVG/Fabric/D2DHelpers.h new file mode 100644 index 000000000..8155827cd --- /dev/null +++ b/windows/RNSVG/Fabric/D2DHelpers.h @@ -0,0 +1,18 @@ +#pragma once + +namespace winrt::RNSVG { +struct D2DHelpers { + public: + static D2D1::ColorF AsD2DColor(winrt::Windows::UI::Color const &color) { + return { + color.R / 255.0f, + color.G / 255.0f, + color.B / 255.0f, + color.A / 255.0f}; + } + + static D2D1::Matrix3x2F AsD2DTransform(Numerics::float3x2 const &transform) { + return D2D1::Matrix3x2F(transform.m11, transform.m12, transform.m21, transform.m22, transform.m31, transform.m32); + } +}; +} // namespace winrt::RNSVG diff --git a/windows/RNSVG/Fabric/DefsView.cpp b/windows/RNSVG/Fabric/DefsView.cpp index f88143aa1..00e3c6ee3 100644 --- a/windows/RNSVG/Fabric/DefsView.cpp +++ b/windows/RNSVG/Fabric/DefsView.cpp @@ -5,13 +5,13 @@ namespace winrt::RNSVG::implementation { REACT_STRUCT(DefsProps) struct DefsProps : winrt::implements { - DefsProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_GROUP_COMMON_PROPS_INIT {} + DefsProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT {} void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); } - REACT_SVG_GROUP_COMMON_PROPS; + REACT_SVG_RENDERABLE_COMMON_PROPS; }; struct DefsView : winrt::implements { diff --git a/windows/RNSVG/Fabric/GroupView.cpp b/windows/RNSVG/Fabric/GroupView.cpp index fcfcb3128..557be20e0 100644 --- a/windows/RNSVG/Fabric/GroupView.cpp +++ b/windows/RNSVG/Fabric/GroupView.cpp @@ -2,17 +2,19 @@ #include "GroupView.h" +#include "RenderableView.h" + namespace winrt::RNSVG::implementation { REACT_STRUCT(SvgGroupProps) struct SvgGroupProps : winrt::implements { - SvgGroupProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_GROUP_COMMON_PROPS_INIT {} + SvgGroupProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT {} void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); } - REACT_SVG_GROUP_COMMON_PROPS; + REACT_SVG_RENDERABLE_COMMON_PROPS; }; struct GroupView : winrt::implements { diff --git a/windows/RNSVG/Fabric/GroupView.h b/windows/RNSVG/Fabric/GroupView.h index dc96c2d3e..35261592d 100644 --- a/windows/RNSVG/Fabric/GroupView.h +++ b/windows/RNSVG/Fabric/GroupView.h @@ -3,69 +3,6 @@ namespace winrt::RNSVG::implementation { -REACT_STRUCT(FontObject) -struct FontObject { - REACT_FIELD(fontStyle) - std::optional fontStyle; - REACT_FIELD(fontVariant) - std::optional fontVariant; - REACT_FIELD(fontWeight) - std::optional fontWeight; - REACT_FIELD(fontStretch) - std::optional fontStretch; - REACT_FIELD(fontSize) - std::optional fontSize; - REACT_FIELD(fontFamily) - std::optional fontFamily; - REACT_FIELD(textAnchor) - std::optional textAnchor; - REACT_FIELD(textDecoration) - std::optional textDecoration; - REACT_FIELD(letterSpacing) - std::optional letterSpacing; - REACT_FIELD(wordSpacing) - std::optional wordSpacing; - REACT_FIELD(kerning) - std::optional kerning; - REACT_FIELD(fontFeatureSettings) - std::optional fontFeatureSettings; - REACT_FIELD(fontVariantLigatures) - std::optional fontVariantLigatures; - REACT_FIELD(fontVariationSettings) - std::optional fontVariationSettings; - - bool operator==(const FontObject &rhs) const { - return fontStyle == rhs.fontStyle && fontVariant == rhs.fontVariant && - fontWeight == rhs.fontWeight && fontStretch == rhs.fontStretch && - fontSize == rhs.fontSize && fontFamily == rhs.fontFamily && - textAnchor == rhs.textAnchor && textDecoration == rhs.textDecoration && - letterSpacing == rhs.letterSpacing && wordSpacing == rhs.wordSpacing && - kerning == rhs.kerning && - fontFeatureSettings == rhs.fontFeatureSettings && - fontVariantLigatures == rhs.fontVariantLigatures && - fontVariationSettings == rhs.fontVariationSettings; - } - - bool operator!=(const FontObject &rhs) const { - return !(*this == rhs); - } -}; - -#define REACT_SVG_GROUP_COMMON_PROPS \ - REACT_SVG_RENDERABLE_COMMON_PROPS \ - REACT_FIELD(fontSize) \ - std::string fontSize; \ - REACT_FIELD(fontWeight) \ - std::string fontWeight; \ - REACT_FIELD(font) \ - FontObject font; \ - -#define REACT_SVG_GROUP_COMMON_PROPS_INIT \ - : m_props(props) - - - void RegisterGroupComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/Fabric/ImageView.cpp b/windows/RNSVG/Fabric/ImageView.cpp index 0080da8af..fb4f80daa 100644 --- a/windows/RNSVG/Fabric/ImageView.cpp +++ b/windows/RNSVG/Fabric/ImageView.cpp @@ -44,7 +44,7 @@ struct ImageProps : winrt::implements align{""}; REACT_FIELD(meetOrSlice) - std::optional meetOrSlice; + std::optional meetOrSlice; }; struct ImageView : winrt::implements { diff --git a/windows/RNSVG/Fabric/LinearGradientView.cpp b/windows/RNSVG/Fabric/LinearGradientView.cpp index b9e080a38..8ee8756eb 100644 --- a/windows/RNSVG/Fabric/LinearGradientView.cpp +++ b/windows/RNSVG/Fabric/LinearGradientView.cpp @@ -11,13 +11,13 @@ struct SvgLinearGradientStop { REACT_STRUCT(LinearGradientProps) struct LinearGradientProps : winrt::implements { - LinearGradientProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_GROUP_COMMON_PROPS_INIT {} + LinearGradientProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT {} void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); } - REACT_SVG_GROUP_COMMON_PROPS; + REACT_SVG_RENDERABLE_COMMON_PROPS; REACT_FIELD(x1) std::optional x1; diff --git a/windows/RNSVG/Fabric/RadialGradientView.cpp b/windows/RNSVG/Fabric/RadialGradientView.cpp index b04a72efd..89099684d 100644 --- a/windows/RNSVG/Fabric/RadialGradientView.cpp +++ b/windows/RNSVG/Fabric/RadialGradientView.cpp @@ -11,13 +11,13 @@ struct SvgRadialGradientStop { REACT_STRUCT(RadialGradientProps) struct RadialGradientProps : winrt::implements { - RadialGradientProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_GROUP_COMMON_PROPS_INIT {} + RadialGradientProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT {} void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); } - REACT_SVG_GROUP_COMMON_PROPS; + REACT_SVG_RENDERABLE_COMMON_PROPS; REACT_FIELD(fx) std::optional fx; diff --git a/windows/RNSVG/Fabric/RenderableView.cpp b/windows/RNSVG/Fabric/RenderableView.cpp index 8a0002ae0..fb6a70ceb 100644 --- a/windows/RNSVG/Fabric/RenderableView.cpp +++ b/windows/RNSVG/Fabric/RenderableView.cpp @@ -2,7 +2,7 @@ #include "RenderableView.h" #include "SvgView.h" -#include "../D2DHelpers.h" +#include "D2DHelpers.h" namespace winrt::Microsoft::ReactNative { diff --git a/windows/RNSVG/Fabric/RenderableView.h b/windows/RNSVG/Fabric/RenderableView.h index 73a5dcc67..e921461ed 100644 --- a/windows/RNSVG/Fabric/RenderableView.h +++ b/windows/RNSVG/Fabric/RenderableView.h @@ -3,7 +3,7 @@ #include #include -#include "../D2DHelpers.h" +#include "D2DHelpers.h" #include "SvgStrings.h" #include "SvgView.h" diff --git a/windows/RNSVG/Fabric/SvgView.cpp b/windows/RNSVG/Fabric/SvgView.cpp index f88b8cc4c..f4243da44 100644 --- a/windows/RNSVG/Fabric/SvgView.cpp +++ b/windows/RNSVG/Fabric/SvgView.cpp @@ -6,9 +6,7 @@ #include #include -#include "../D2DDevice.h" -#include "../D2DDeviceContext.h" -#include "../D2DHelpers.h" +#include "D2DHelpers.h" #include "GroupView.h" #include diff --git a/windows/RNSVG/Fabric/SvgView.h b/windows/RNSVG/Fabric/SvgView.h index 4ba7ae711..f57fd3a30 100644 --- a/windows/RNSVG/Fabric/SvgView.h +++ b/windows/RNSVG/Fabric/SvgView.h @@ -4,24 +4,21 @@ #include #include "NativeModules.h" -#include "../SVGLength.h" - namespace winrt::RNSVG::implementation { D2D1_SVG_ASPECT_ALIGN AlignToAspectAlign(const std::string &align) noexcept; +enum class MeetOrSlice { + Meet = 0, + Slice = 1, +}; + REACT_STRUCT(SvgViewProps) struct SvgViewProps : winrt::implements { SvgViewProps(const winrt::Microsoft::ReactNative::ViewProps &props); void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept; - REACT_FIELD(bbWidth) - winrt::RNSVG::SVGLength bbWidth{0.0, winrt::RNSVG::LengthType::Unknown}; - - REACT_FIELD(bbHeight) - winrt::RNSVG::SVGLength bbHeight{0.0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(minX) std::optional minX; REACT_FIELD(minY) @@ -33,7 +30,7 @@ struct SvgViewProps : winrt::implements align; REACT_FIELD(meetOrSlice) - std::optional meetOrSlice; + std::optional meetOrSlice; REACT_FIELD(color) winrt::Microsoft::ReactNative::Color color{nullptr}; private: diff --git a/windows/RNSVG/GroupView.cpp b/windows/RNSVG/GroupView.cpp index fd66de9b2..7f0725e2e 100644 --- a/windows/RNSVG/GroupView.cpp +++ b/windows/RNSVG/GroupView.cpp @@ -14,78 +14,7 @@ using namespace winrt; using namespace Microsoft::ReactNative; namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -SvgGroupCommonProps::SvgGroupCommonProps( - const winrt::Microsoft::ReactNative::ViewProps &props) - : base_type(props) {} - -void SvgGroupCommonProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - -void GroupView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGGroup", builder); -} - -void GroupView::UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate, - bool invalidate) noexcept { - auto groupProps = props.as(); - auto oldGroupProps = oldProps ? oldProps.as() : nullptr; - - auto const &parent{SvgParent().try_as()}; - - if (!oldGroupProps || groupProps->font != oldGroupProps->font) { - if (forceUpdate || !m_fontPropMap[RNSVG::FontProp::FontSize]) { - if (groupProps->font.fontSize) { - m_fontSize = groupProps->font.fontSize != std::nullopt - ? *groupProps->font.fontSize - : (parent ? parent.FontSize() : 12.0f); - } - - m_fontPropMap[RNSVG::FontProp::FontSize] = !!groupProps->font.fontSize; - } - - if (forceUpdate || !m_fontPropMap[RNSVG::FontProp::FontFamily]) { - if (groupProps->font.fontFamily) { - m_fontFamily = !(*groupProps->font.fontFamily).empty() - ? winrt::to_hstring(*groupProps->font.fontFamily) - : (parent ? parent.FontFamily() : L"Segoe UI"); - - m_fontPropMap[RNSVG::FontProp::FontFamily] = !(*groupProps->font.fontFamily).empty(); - } - } - - if (forceUpdate || !m_fontPropMap[RNSVG::FontProp::FontWeight]) { - if (groupProps->font.fontWeight) { - m_fontWeight = !(*groupProps->font.fontWeight).empty() - ? winrt::to_hstring(*groupProps->font.fontWeight) - : (parent ? parent.FontWeight() : L"auto"); - m_fontPropMap[RNSVG::FontProp::FontWeight] = !(*groupProps->font.fontWeight).empty(); - } - } - } - - base_type::UpdateProperties(props, oldProps, forceUpdate, false); - - /* - for (auto const &child : Children()) { - //auto rchild = winrt::get_self(child); - child.as().UpdateProperties(props, oldProps, false, false); - } - */ - - if (invalidate && SvgParent()) { - SvgRoot().Invalidate(); - } -} -#else void GroupView::UpdateProperties(IJSValueReader const &reader, bool forceUpdate, bool invalidate) { const JSValueObject &propertyMap{JSValue::ReadObjectFrom(reader)}; @@ -171,7 +100,6 @@ void GroupView::UpdateProperties(IJSValueReader const &reader, bool forceUpdate, SvgRoot().Invalidate(); } } -#endif void GroupView::CreateGeometry(RNSVG::D2DDeviceContext const &context) { std::vector geometries; @@ -267,9 +195,7 @@ void GroupView::Unload() { m_fontPropMap.clear(); -#ifndef USE_FABRIC m_children.Clear(); -#endif __super::Unload(); } diff --git a/windows/RNSVG/GroupView.h b/windows/RNSVG/GroupView.h index 34590eae2..5af9c76e7 100644 --- a/windows/RNSVG/GroupView.h +++ b/windows/RNSVG/GroupView.h @@ -2,107 +2,19 @@ #include "GroupView.g.h" #include "RenderableView.h" -#ifdef USE_FABRIC -#include "SvgGroupCommonProps.g.h" -#endif - namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -REACT_STRUCT(FontObject) -struct FontObject { - REACT_FIELD(fontStyle) - std::optional fontStyle; - REACT_FIELD(fontVariant) - std::optional fontVariant; - REACT_FIELD(fontWeight) - std::optional fontWeight; - REACT_FIELD(fontStretch) - std::optional fontStretch; - REACT_FIELD(fontSize) - std::optional fontSize; - REACT_FIELD(fontFamily) - std::optional fontFamily; - REACT_FIELD(textAnchor) - std::optional textAnchor; - REACT_FIELD(textDecoration) - std::optional textDecoration; - REACT_FIELD(letterSpacing) - std::optional letterSpacing; - REACT_FIELD(wordSpacing) - std::optional wordSpacing; - REACT_FIELD(kerning) - std::optional kerning; - REACT_FIELD(fontFeatureSettings) - std::optional fontFeatureSettings; - REACT_FIELD(fontVariantLigatures) - std::optional fontVariantLigatures; - REACT_FIELD(fontVariationSettings) - std::optional fontVariationSettings; - - bool operator==(const FontObject &rhs) const { - return fontStyle == rhs.fontStyle && fontVariant == rhs.fontVariant && - fontWeight == rhs.fontWeight && fontStretch == rhs.fontStretch && - fontSize == rhs.fontSize && fontFamily == rhs.fontFamily && - textAnchor == rhs.textAnchor && textDecoration == rhs.textDecoration && - letterSpacing == rhs.letterSpacing && wordSpacing == rhs.wordSpacing && - kerning == rhs.kerning && - fontFeatureSettings == rhs.fontFeatureSettings && - fontVariantLigatures == rhs.fontVariantLigatures && - fontVariationSettings == rhs.fontVariationSettings; - } - - bool operator!=(const FontObject &rhs) const { - return !(*this == rhs); - } -}; - -#define REACT_SVG_GROUP_COMMON_PROPS \ - REACT_FIELD(fontSize) \ - REACT_FIELD(fontWeight) \ - REACT_FIELD(font) - -REACT_STRUCT(SvgGroupCommonProps) -struct SvgGroupCommonProps - : SvgGroupCommonPropsT { - SvgGroupCommonProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - REACT_SVG_GROUP_COMMON_PROPS; - - std::string fontSize; - std::string fontWeight; - FontObject font; -}; -#endif struct GroupView : GroupViewT { public: GroupView() = default; -#ifdef USE_FABRIC - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - - // IRenderableFabric - void UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate = true, - bool invalidate = true) noexcept override; -#else GroupView(Microsoft::ReactNative::IReactContext const & /*context*/) {} Windows::Foundation::Collections::IVector Children() { return m_children; } // IRenderablePaper virtual void UpdateProperties(Microsoft::ReactNative::IJSValueReader const &reader, bool forceUpdate, bool invalidate); -#endif hstring FontFamily() { return m_fontFamily; } void FontFamily(hstring const &value) { m_fontFamily = value; } @@ -126,10 +38,8 @@ struct GroupView private: -#ifndef USE_FABRIC Windows::Foundation::Collections::IVector m_children{ winrt::single_threaded_vector()}; -#endif float m_fontSize{12.0f}; hstring m_fontFamily{L"Segoe UI"}; @@ -143,8 +53,6 @@ struct GroupView }; } // namespace winrt::RNSVG::implementation -#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct GroupView : GroupViewT {}; } // namespace winrt::RNSVG::factory_implementation -#endif diff --git a/windows/RNSVG/ImageView.cpp b/windows/RNSVG/ImageView.cpp index 43577ae25..42d4c6d41 100644 --- a/windows/RNSVG/ImageView.cpp +++ b/windows/RNSVG/ImageView.cpp @@ -14,9 +14,7 @@ #include #include -#ifndef USE_FABRIC #include -#endif using namespace winrt::Microsoft::ReactNative; using namespace winrt::Windows::Security::Cryptography; @@ -25,52 +23,6 @@ using namespace winrt::Windows::Web::Http; namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -ImageProps::ImageProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} - -void ImageProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - -void ImageView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGImage", builder); -} - -void ImageView::UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate, - bool invalidate) noexcept { - auto imageProps = props.try_as(); - auto oldImageProps = oldProps.try_as(); - if (imageProps) { - m_x = imageProps->x; - m_y = imageProps->y; - m_width = imageProps->width; - m_height = imageProps->height; - - // preserveAspectRatio - m_align = imageProps->align; - m_meetOrSlice = imageProps->meetOrSlice; - - // IamgeSource - m_source.uri = imageProps->src.uri; - m_source.method = imageProps->src.method; - m_source.width = imageProps->src.width; - m_source.height = imageProps->src.height; - m_source.scale = imageProps->src.scale; - - if (!oldImageProps || (oldImageProps->src.uri != imageProps->src.uri)) { - LoadImageSourceAsync(true); - } - } - - base_type::UpdateProperties(props, oldProps, forceUpdate, invalidate); -} -#else void ImageView::UpdateProperties(IJSValueReader const &reader, bool forceUpdate, bool invalidate) { const JSValueObject &propertyMap{JSValue::ReadObjectFrom(reader)}; @@ -129,7 +81,6 @@ void ImageView::UpdateProperties(IJSValueReader const &reader, bool forceUpdate, __super::UpdateProperties(reader, forceUpdate, invalidate); } -#endif void ImageView::Draw(RNSVG::D2DDeviceContext const &context, Size const &size) { if (!m_wicbitmap) { @@ -290,7 +241,6 @@ IAsyncOperation ImageView::GetImageStreamAsync( Uri uri{winrt::to_hstring(source.uri)}; HttpRequestMessage request{httpMethod, uri}; -#ifndef USE_FABRIC if (!source.headers.empty()) { for (auto const &header : source.headers) { if (_stricmp(to_string(header.first).c_str(), "authorization") == 0) { @@ -300,7 +250,6 @@ IAsyncOperation ImageView::GetImageStreamAsync( } } } -#endif HttpClient httpClient; HttpResponseMessage response{co_await httpClient.SendRequestAsync(request)}; diff --git a/windows/RNSVG/ImageView.h b/windows/RNSVG/ImageView.h index a68096740..e1a2c9a9c 100644 --- a/windows/RNSVG/ImageView.h +++ b/windows/RNSVG/ImageView.h @@ -1,9 +1,5 @@ #pragma once -#ifdef USE_FABRIC -#include "ImageProps.g.h" -#endif - #include "ImageView.g.h" #include "RenderableView.h" @@ -13,65 +9,6 @@ namespace winrt::RNSVG::implementation { enum class ImageSourceType { Uri = 0, Download = 1, InlineData = 2 }; enum class ImageSourceFormat { Bitmap = 0, Svg = 1 }; -#ifdef USE_FABRIC -REACT_STRUCT(ImageSource) -struct ImageSource { - REACT_FIELD(uri) - std::string uri{""}; - REACT_FIELD(method) - std::string method{""}; - //REACT_FIELD(headers) - //std::vector headers; - REACT_FIELD(body) - std::string body{""}; - REACT_FIELD(width) - float width{0.0f}; - REACT_FIELD(height) - float height{0.0f}; - REACT_FIELD(scale) - float scale{1.0f}; - /*REACT_FIELD(packagerAsset) - bool packagerAsset{false}; - REACT_FIELD(type) - ImageSourceType type{ImageSourceType::Uri}; - REACT_FIELD(format) - ImageSourceFormat format{ImageSourceFormat::Bitmap};*/ - - bool operator==(const ImageSource &rhs) const { - return uri == rhs.uri && method == rhs.method && width == rhs.width && height == rhs.height && scale == rhs.scale; - } - - bool operator!=(const ImageSource &rhs) const { - return !(*this == rhs); - } -}; - -REACT_STRUCT(ImageProps) -struct ImageProps : ImagePropsT { - ImageProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - - REACT_FIELD(x) - RNSVG::SVGLength x{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(y) - RNSVG::SVGLength y{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(width) - RNSVG::SVGLength width{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(height) - RNSVG::SVGLength height{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(src) - ImageSource src; - REACT_FIELD(align) - std::string align{""}; - REACT_FIELD(meetOrSlice) - RNSVG::MeetOrSlice meetOrSlice{RNSVG::MeetOrSlice::Meet}; -}; -#else struct ImageSource { std::string uri{""}; std::string method{""}; @@ -83,25 +20,13 @@ struct ImageSource { ImageSourceType type{ImageSourceType::Uri}; ImageSourceFormat format{ImageSourceFormat::Bitmap}; }; -#endif struct ImageView : ImageViewT { public: ImageView() = default; -#ifdef USE_FABRIC - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - - // IRenderableFabric - void UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate = true, - bool invalidate = true) noexcept override; -#else // IRenderablePaper void UpdateProperties(Microsoft::ReactNative::IJSValueReader const &reader, bool forceUpdate, bool invalidate); -#endif // IRenderable void Draw(RNSVG::D2DDeviceContext const &deviceContext, Windows::Foundation::Size const &size); @@ -137,8 +62,6 @@ struct ImageView : ImageViewT }; } // namespace winrt::RNSVG::implementation -#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct ImageView : ImageViewT {}; } // namespace winrt::RNSVG::factory_implementation -#endif \ No newline at end of file diff --git a/windows/RNSVG/LineView.cpp b/windows/RNSVG/LineView.cpp index 8050305b8..a784808cf 100644 --- a/windows/RNSVG/LineView.cpp +++ b/windows/RNSVG/LineView.cpp @@ -12,36 +12,6 @@ using namespace Microsoft::ReactNative; namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -LineProps::LineProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} - -void LineProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - -void LineView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGLine", builder); -} - -void LineView::UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate, - bool invalidate) noexcept { - auto lineProps = props.try_as(); - if (lineProps) { - m_x1 = lineProps->x1; - m_y1 = lineProps->y1; - m_x2 = lineProps->x2; - m_y2 = lineProps->y2; - } - - base_type::UpdateProperties(props, oldProps, forceUpdate, invalidate); -} -#else void LineView::UpdateProperties(IJSValueReader const &reader, bool forceUpdate, bool invalidate) { const JSValueObject &propertyMap{JSValue::ReadObjectFrom(reader)}; @@ -62,7 +32,6 @@ void LineView::UpdateProperties(IJSValueReader const &reader, bool forceUpdate, __super::UpdateProperties(reader, forceUpdate, invalidate); } -#endif void LineView::CreateGeometry(RNSVG::D2DDeviceContext const &context) { auto const &root{SvgRoot()}; diff --git a/windows/RNSVG/LineView.h b/windows/RNSVG/LineView.h index b3298c687..4edc95ce3 100644 --- a/windows/RNSVG/LineView.h +++ b/windows/RNSVG/LineView.h @@ -1,53 +1,16 @@ #pragma once -#ifdef USE_FABRIC -#include "LineProps.g.h" -#endif - #include "LineView.g.h" #include "RenderableView.h" namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -REACT_STRUCT(LineProps) -struct LineProps : LinePropsT { - LineProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - - REACT_FIELD(x1) - RNSVG::SVGLength x1{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(y1) - RNSVG::SVGLength y1{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(x2) - RNSVG::SVGLength x2{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(y2) - RNSVG::SVGLength y2{0, winrt::RNSVG::LengthType::Unknown}; -}; -#endif - struct LineView : LineViewT { public: LineView() = default; -#ifdef USE_FABRIC - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - - // IRenderableFabric - void UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate = true, - bool invalidate = true) noexcept override; -#else // IRenderablePaper void UpdateProperties(Microsoft::ReactNative::IJSValueReader const &reader, bool forceUpdate, bool invalidate); -#endif // IRenderable void CreateGeometry(RNSVG::D2DDeviceContext const &context); @@ -60,8 +23,6 @@ struct LineView : LineViewT { }; } // namespace winrt::RNSVG::implementation -#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct LineView : LineViewT {}; } // namespace winrt::RNSVG::factory_implementation -#endif \ No newline at end of file diff --git a/windows/RNSVG/LinearGradientView.cpp b/windows/RNSVG/LinearGradientView.cpp index 06ea02588..9a04d72af 100644 --- a/windows/RNSVG/LinearGradientView.cpp +++ b/windows/RNSVG/LinearGradientView.cpp @@ -11,43 +11,6 @@ using namespace Microsoft::ReactNative; namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -LinearGradientProps::LinearGradientProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} - -void LinearGradientProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - -void LinearGradientView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent( - L"RNSVGLinearGradient", builder); -} - -void LinearGradientView::UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate, - bool invalidate) noexcept { - auto linearGradientProps = props.try_as(); - if (linearGradientProps) { - m_x1 = linearGradientProps->x1; - m_y1 = linearGradientProps->y1; - m_x2 = linearGradientProps->x2; - m_y2 = linearGradientProps->y2; - - m_stops = Utils::JSValueAsGradientStops(linearGradientProps->gradient); - m_gradientUnits = Utils::JSValueAsBrushUnits(linearGradientProps->gradientUnits); - m_transform = Utils::JSValueAsD2DTransform(linearGradientProps->gradientTransform); - } - - base_type::UpdateProperties(props, oldProps, forceUpdate, invalidate); - - SaveDefinition(); -} -#else void LinearGradientView::UpdateProperties(IJSValueReader const &reader, bool forceUpdate, bool invalidate) { const JSValueObject &propertyMap{JSValue::ReadObjectFrom(reader)}; @@ -80,7 +43,6 @@ void LinearGradientView::UpdateProperties(IJSValueReader const &reader, bool for SaveDefinition(); } -#endif void LinearGradientView::Unload() { m_stops.clear(); diff --git a/windows/RNSVG/LinearGradientView.h b/windows/RNSVG/LinearGradientView.h index 6a9871eb1..59420b8d4 100644 --- a/windows/RNSVG/LinearGradientView.h +++ b/windows/RNSVG/LinearGradientView.h @@ -1,60 +1,16 @@ #pragma once -#ifdef USE_FABRIC -#include "LinearGradientProps.g.h" -#endif - #include "LinearGradientView.g.h" #include "BrushView.h" namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -REACT_STRUCT(LinearGradientProps) -struct LinearGradientProps : LinearGradientPropsT { - LinearGradientProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - REACT_SVG_GROUP_COMMON_PROPS; - - REACT_FIELD(x1) - RNSVG::SVGLength x1{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(y1) - RNSVG::SVGLength y1{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(x2) - RNSVG::SVGLength x2{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(y2) - RNSVG::SVGLength y2{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(gradient) - std::optional> gradient{}; - REACT_FIELD(gradientUnits) - std::optional gradientUnits; - REACT_FIELD(gradientTransform) - std::optional> gradientTransform; -}; -#endif - struct LinearGradientView : LinearGradientViewT { public: LinearGradientView() = default; -#ifdef USE_FABRIC - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - - // IRenderableFabric - void UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate = true, - bool invalidate = true) noexcept override; -#else // IRenderablePaper void UpdateProperties(Microsoft::ReactNative::IJSValueReader const &reader, bool forceUpdate, bool invalidate); -#endif // IRenderable void Unload(); @@ -74,8 +30,6 @@ struct LinearGradientView : LinearGradientViewT {}; } // namespace winrt::RNSVG::factory_implementation -#endif diff --git a/windows/RNSVG/MarkerView.cpp b/windows/RNSVG/MarkerView.cpp index 9d34e2ba7..683407d75 100644 --- a/windows/RNSVG/MarkerView.cpp +++ b/windows/RNSVG/MarkerView.cpp @@ -8,32 +8,5 @@ using namespace winrt; namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -MarkerProps::MarkerProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} - -void MarkerProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - -void MarkerView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGMarker", builder); -} - -void MarkerView::UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate, - bool invalidate) noexcept { - auto markerProps = props.try_as(); - if (markerProps) { - } - - base_type::UpdateProperties(props, oldProps, forceUpdate, invalidate); -} -#else -#endif } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/MarkerView.h b/windows/RNSVG/MarkerView.h index 9ea2beb57..fa78510aa 100644 --- a/windows/RNSVG/MarkerView.h +++ b/windows/RNSVG/MarkerView.h @@ -1,67 +1,14 @@ #pragma once -#ifdef USE_FABRIC -#include "MarkerProps.g.h" -#endif - #include "MarkerView.g.h" #include "GroupView.h" namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -REACT_STRUCT(MarkerProps) -struct MarkerProps : MarkerPropsT { - MarkerProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - - REACT_FIELD(refX) - RNSVG::SVGLength refX{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(refY) - RNSVG::SVGLength refY{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(markerHeight) - RNSVG::SVGLength markerHeight{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(markerWidth) - RNSVG::SVGLength markerWidth{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(markerUnits) - std::string markerUnits{""}; - REACT_FIELD(orient) - std::string orient{""}; - REACT_FIELD(minX) - float minX{0.0f}; - REACT_FIELD(minY) - float minY{0.0f}; - REACT_FIELD(vbWidth) - float vbWidth{0.0f}; - REACT_FIELD(vbHeight) - float vbHeight{0.0f}; - REACT_FIELD(align) - std::string align{""}; - REACT_FIELD(meetOrSlice) - RNSVG::MeetOrSlice meetOrSlice{RNSVG::MeetOrSlice::Meet}; -}; -#endif - struct MarkerView : MarkerViewT { public: MarkerView() = default; -#ifdef USE_FABRIC - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - - // IRenderableFabric - void UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate = true, - bool invalidate = true) noexcept override; -#endif - // IRenderable void Draw(RNSVG::D2DDeviceContext const & /*deviceContext*/, Windows::Foundation::Size const & /*size*/){}; @@ -69,8 +16,6 @@ struct MarkerView : MarkerViewT { }; } // namespace winrt::RNSVG::implementation -#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct MarkerView : MarkerViewT {}; } // namespace winrt::RNSVG::factory_implementation -#endif \ No newline at end of file diff --git a/windows/RNSVG/MaskView.cpp b/windows/RNSVG/MaskView.cpp index 2b72ec584..ee0127246 100644 --- a/windows/RNSVG/MaskView.cpp +++ b/windows/RNSVG/MaskView.cpp @@ -8,32 +8,4 @@ using namespace winrt; namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -MaskProps::MaskProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} - -void MaskProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - -void MaskView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGMask", builder); -} - -void MaskView::UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate, - bool invalidate) noexcept { - auto maskProps = props.try_as(); - if (maskProps) { - } - - base_type::UpdateProperties(props, oldProps, forceUpdate, invalidate); -} -#else -#endif - } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/MaskView.h b/windows/RNSVG/MaskView.h index ba1a58bc3..dc3f9078f 100644 --- a/windows/RNSVG/MaskView.h +++ b/windows/RNSVG/MaskView.h @@ -1,55 +1,14 @@ #pragma once -#ifdef USE_FABRIC -#include "MaskProps.g.h" -#endif - #include "MaskView.g.h" #include "GroupView.h" namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -REACT_STRUCT(MaskProps) -struct MaskProps : MaskPropsT { - MaskProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - - REACT_FIELD(x) - RNSVG::SVGLength x{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(y) - RNSVG::SVGLength y{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(height) - RNSVG::SVGLength height{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(width) - RNSVG::SVGLength width{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(maskUnits) - uint32_t maskUnits{0}; - REACT_FIELD(maskContentUnits) - uint32_t maskContentUnits{0}; -}; -#endif - struct MaskView : MaskViewT { public: MaskView() = default; -#ifdef USE_FABRIC - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - - // IRenderableFabric - void UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate = true, - bool invalidate = true) noexcept override; -#endif - // IRenderable void Draw(RNSVG::D2DDeviceContext const & /*deviceContext*/, Windows::Foundation::Size const & /*size*/){}; @@ -57,8 +16,6 @@ struct MaskView : MaskViewT { }; } // namespace winrt::RNSVG::implementation -#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct MaskView : MaskViewT {}; } // namespace winrt::RNSVG::factory_implementation -#endif diff --git a/windows/RNSVG/PathView.cpp b/windows/RNSVG/PathView.cpp index cc739aacf..2f0f7e44b 100644 --- a/windows/RNSVG/PathView.cpp +++ b/windows/RNSVG/PathView.cpp @@ -15,37 +15,6 @@ using namespace Microsoft::ReactNative; namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -PathProps::PathProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} - -void PathProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - -void PathView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGPath", builder); -} - -void PathView::UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate, - bool invalidate) noexcept { - - auto pathProps = props.try_as(); - if (pathProps) { - m_d = pathProps->d; - m_commands.clear(); - m_segmentData.clear(); - ParsePath(); - } - - base_type::UpdateProperties(props, oldProps, forceUpdate, invalidate); -} -#else void PathView::UpdateProperties(IJSValueReader const &reader, bool forceUpdate, bool invalidate) { const JSValueObject &propertyMap{JSValue::ReadObjectFrom(reader)}; @@ -69,7 +38,6 @@ void PathView::UpdateProperties(IJSValueReader const &reader, bool forceUpdate, __super::UpdateProperties(reader, forceUpdate, invalidate); } -#endif void PathView::CreateGeometry(RNSVG::D2DDeviceContext const &context) { auto const &root{SvgRoot()}; diff --git a/windows/RNSVG/PathView.h b/windows/RNSVG/PathView.h index 3c9ae8340..fc1eb06ca 100644 --- a/windows/RNSVG/PathView.h +++ b/windows/RNSVG/PathView.h @@ -1,47 +1,16 @@ #pragma once -#ifdef USE_FABRIC -#include "PathProps.g.h" -#endif - #include "PathView.g.h" #include "RenderableView.h" namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -REACT_STRUCT(PathProps) -struct PathProps : PathPropsT { - PathProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - - REACT_FIELD(d) - std::string d; -}; -#endif - struct PathView : PathViewT { public: PathView() = default; -#ifdef USE_FABRIC - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - - // IRenderableFabric - void UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate = true, - bool invalidate = true) noexcept override; -#else // IRenderablePaper void UpdateProperties(Microsoft::ReactNative::IJSValueReader const &reader, bool forceUpdate, bool invalidate); -#endif // IRenderable void CreateGeometry(RNSVG::D2DDeviceContext const &context); @@ -91,8 +60,6 @@ struct PathView : PathViewT { }; } // namespace winrt::RNSVG::implementation -#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct PathView : PathViewT {}; } // namespace winrt::RNSVG::factory_implementation -#endif diff --git a/windows/RNSVG/PatternView.cpp b/windows/RNSVG/PatternView.cpp index acfbd4c64..db3a607e7 100644 --- a/windows/RNSVG/PatternView.cpp +++ b/windows/RNSVG/PatternView.cpp @@ -12,55 +12,6 @@ using namespace Microsoft::ReactNative; namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -PatternProps::PatternProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} - -void PatternProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - -void PatternView::RegisterComponent( - const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGPattern", builder); -} - -void PatternView::UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate, - bool invalidate) noexcept { - auto patternProps = props.try_as(); - if (patternProps) { - m_x = patternProps->x; - m_y = patternProps->y; - m_width = patternProps->width; - m_height = patternProps->height; - - m_minX = patternProps->minX; - m_minY = patternProps->minY; - m_vbWidth = patternProps->vbWidth; - m_vbHeight = patternProps->vbHeight; - m_align = patternProps->align; - m_meetOrSlice = patternProps->meetOrSlice; - - m_patternUnits = Utils::JSValueAsBrushUnits(patternProps->patternUnits); - m_patternContentUnits = Utils::JSValueAsBrushUnits(patternProps->patternContentUnits, "userSpaceOnUse"); - - m_transform = Utils::JSValueAsD2DTransform(patternProps->patternTransform); - } - - base_type::UpdateProperties(props, oldProps, forceUpdate, invalidate); - - SaveDefinition(); - - if (auto const &root{SvgRoot()}) { - root.Invalidate(); - } -} -#else void PatternView::UpdateProperties(IJSValueReader const &reader, bool forceUpdate, bool invalidate) { const JSValueObject &propertyMap{JSValue::ReadObjectFrom(reader)}; @@ -109,7 +60,6 @@ void PatternView::UpdateProperties(IJSValueReader const &reader, bool forceUpdat root.Invalidate(); } } -#endif void PatternView::UpdateBounds() { if (m_patternUnits == "objectBoundingBox") { diff --git a/windows/RNSVG/PatternView.h b/windows/RNSVG/PatternView.h index eb61a3d2c..8b20b3eda 100644 --- a/windows/RNSVG/PatternView.h +++ b/windows/RNSVG/PatternView.h @@ -1,73 +1,16 @@ #pragma once -#ifdef USE_FABRIC -#include "PatternProps.g.h" -#endif - #include "PatternView.g.h" #include "BrushView.h" namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -REACT_STRUCT(PatternProps) -struct PatternProps : PatternPropsT { - PatternProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - REACT_SVG_GROUP_COMMON_PROPS; - - REACT_FIELD(x) - RNSVG::SVGLength x{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(y) - RNSVG::SVGLength y{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(width) - RNSVG::SVGLength width{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(height) - RNSVG::SVGLength height{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(patternUnits) - std::optional patternUnits; - REACT_FIELD(patternContentUnits) - std::optional patternContentUnits; - REACT_FIELD(patternTransform) - std::optional> patternTransform; - - REACT_FIELD(minX) - float minX{0.0f}; - REACT_FIELD(minY) - float minY{0.0f}; - REACT_FIELD(vbWidth) - float vbWidth{0.0f}; - REACT_FIELD(vbHeight) - float vbHeight{0.0f}; - REACT_FIELD(align) - std::string align{""}; - REACT_FIELD(meetOrSlice) - RNSVG::MeetOrSlice meetOrSlice{RNSVG::MeetOrSlice::Meet}; -}; -#endif - struct PatternView : PatternViewT { public: PatternView() = default; -#ifdef USE_FABRIC - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - - // IRenderableFabric - void UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate = true, - bool invalidate = true) noexcept override; -#else // IRenderablePaper void UpdateProperties(Microsoft::ReactNative::IJSValueReader const &reader, bool forceUpdate, bool invalidate); -#endif // IRenderable void Draw(RNSVG::D2DDeviceContext const & /*deviceContext*/, Windows::Foundation::Size const & /*size*/){}; @@ -99,9 +42,6 @@ struct PatternView : PatternViewT }; } // namespace winrt::RNSVG::implementation -#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct PatternView : PatternViewT {}; } // namespace winrt::RNSVG::factory_implementation -#endif - diff --git a/windows/RNSVG/RNSVG.vcxproj b/windows/RNSVG/RNSVG.vcxproj index 358793bbc..b3786c813 100644 --- a/windows/RNSVG/RNSVG.vcxproj +++ b/windows/RNSVG/RNSVG.vcxproj @@ -195,10 +195,6 @@ - - - - Create @@ -206,7 +202,6 @@ ReactPackageProvider.idl - @@ -226,6 +221,11 @@ + + + + + @@ -271,7 +271,7 @@ - + diff --git a/windows/RNSVG/RadialGradientView.cpp b/windows/RNSVG/RadialGradientView.cpp index b474aeeb1..b3993e1b9 100644 --- a/windows/RNSVG/RadialGradientView.cpp +++ b/windows/RNSVG/RadialGradientView.cpp @@ -11,46 +11,6 @@ using namespace Microsoft::ReactNative; namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -RadialGradientProps::RadialGradientProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} - -void RadialGradientProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - -void RadialGradientView::RegisterComponent( - const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent( - L"RNSVGRadialGradient", builder); -} - -void RadialGradientView::UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate, - bool invalidate) noexcept { - auto radialGradientProps = props.try_as(); - if (radialGradientProps) { - m_rx = radialGradientProps->rx; - m_ry = radialGradientProps->ry; - m_fx = radialGradientProps->fx; - m_fy = radialGradientProps->fy; - m_cx = radialGradientProps->cx; - m_cy = radialGradientProps->cy; - - m_stops = Utils::JSValueAsGradientStops(radialGradientProps->gradient); - m_gradientUnits = Utils::JSValueAsBrushUnits(radialGradientProps->gradientUnits); - m_transform = Utils::JSValueAsD2DTransform(radialGradientProps->gradientTransform); - } - - base_type::UpdateProperties(props, oldProps, forceUpdate, invalidate); - - SaveDefinition(); -} -#else void RadialGradientView::UpdateProperties(IJSValueReader const &reader, bool forceUpdate, bool invalidate) { const JSValueObject &propertyMap{JSValue::ReadObjectFrom(reader)}; @@ -87,7 +47,6 @@ void RadialGradientView::UpdateProperties(IJSValueReader const &reader, bool for SaveDefinition(); } -#endif void RadialGradientView::Unload() { m_stops.clear(); diff --git a/windows/RNSVG/RadialGradientView.h b/windows/RNSVG/RadialGradientView.h index c9b12b43f..a2462c9b8 100644 --- a/windows/RNSVG/RadialGradientView.h +++ b/windows/RNSVG/RadialGradientView.h @@ -1,64 +1,16 @@ #pragma once -#ifdef USE_FABRIC -#include "RadialGradientProps.g.h" -#endif - #include "RadialGradientView.g.h" #include "BrushView.h" namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -REACT_STRUCT(RadialGradientProps) -struct RadialGradientProps : RadialGradientPropsT { - RadialGradientProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - REACT_SVG_GROUP_COMMON_PROPS; - - REACT_FIELD(fx) - RNSVG::SVGLength fx{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(fy) - RNSVG::SVGLength fy{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(cx) - RNSVG::SVGLength cx{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(cy) - RNSVG::SVGLength cy{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(rx) - RNSVG::SVGLength rx{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(ry) - RNSVG::SVGLength ry{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(gradient) - std::optional> gradient{}; - REACT_FIELD(gradientUnits) - std::optional gradientUnits; - REACT_FIELD(gradientTransform) - std::optional> gradientTransform; -}; -#endif - struct RadialGradientView : RadialGradientViewT { public: RadialGradientView() = default; -#ifdef USE_FABRIC - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - - // IRenderableFabric - void UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate = true, - bool invalidate = true) noexcept override; -#else // IRenderablePaper void UpdateProperties(Microsoft::ReactNative::IJSValueReader const &reader, bool forceUpdate, bool invalidate); -#endif // IRenderable void Unload(); @@ -80,9 +32,6 @@ struct RadialGradientView : RadialGradientViewT {}; } // namespace winrt::RNSVG::factory_implementation -#endif - diff --git a/windows/RNSVG/RectView.h b/windows/RNSVG/RectView.h index 295a38e59..90c13668e 100644 --- a/windows/RNSVG/RectView.h +++ b/windows/RNSVG/RectView.h @@ -1,57 +1,16 @@ #pragma once -#ifdef USE_FABRIC -#include "RectProps.g.h" -#endif - #include "RectView.g.h" #include "RenderableView.h" namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -REACT_STRUCT(RectProps) -struct RectProps : RectPropsT { - RectProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - - REACT_FIELD(x) - RNSVG::SVGLength x{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(y) - RNSVG::SVGLength y{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(height) - RNSVG::SVGLength height{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(width) - RNSVG::SVGLength width{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(rx) - RNSVG::SVGLength rx{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(ry) - RNSVG::SVGLength ry{0, winrt::RNSVG::LengthType::Unknown}; -}; -#endif - struct RectView : RectViewT { public: RectView() = default; -#ifdef USE_FABRIC - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - - // IRenderableFabric - void UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate = true, - bool invalidate = true) noexcept override; -#else // IRenderablePaper void UpdateProperties(Microsoft::ReactNative::IJSValueReader const &reader, bool forceUpdate, bool invalidate); -#endif // IRenderable void CreateGeometry(RNSVG::D2DDeviceContext const &context); @@ -66,8 +25,6 @@ struct RectView : RectViewT { }; } // namespace winrt::RNSVG::implementation -#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct RectView : RectViewT {}; } // namespace winrt::RNSVG::factory_implementation -#endif \ No newline at end of file diff --git a/windows/RNSVG/RenderableView.h b/windows/RNSVG/RenderableView.h index da99da849..a8eed7b24 100644 --- a/windows/RNSVG/RenderableView.h +++ b/windows/RNSVG/RenderableView.h @@ -5,167 +5,14 @@ #include "D2DDeviceContext.h" #include "D2DGeometry.h" -#ifdef USE_FABRIC -#include "SvgNodeCommonProps.g.h" -#include "SvgRenderableCommonProps.g.h" - -#include -#endif - #include namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -REACT_STRUCT(ColorStruct) -struct ColorStruct { - REACT_FIELD(type) - int32_t type{-1}; - - REACT_FIELD(payload) - winrt::Microsoft::ReactNative::Color payload{nullptr}; - - REACT_FIELD(brushRef) - std::string brushRef; - - bool operator==(const ColorStruct &rhs) const { - if (type != rhs.type || brushRef != rhs.brushRef) - return false; - - // When we move to a RNW version that provides Color::Equals switch to that for the payload comparison - auto writer = winrt::Microsoft::ReactNative::MakeJSValueTreeWriter(); - winrt::Microsoft::ReactNative::WriteValue(writer, payload); - auto rhsWriter = winrt::Microsoft::ReactNative::MakeJSValueTreeWriter(); - winrt::Microsoft::ReactNative::WriteValue(rhsWriter, rhs.payload); - return winrt::Microsoft::ReactNative::TakeJSValue(writer).Equals(winrt::Microsoft::ReactNative::TakeJSValue(rhsWriter)); - } - - bool operator!=(const ColorStruct &rhs) const { - return !(*this == rhs); - } -}; - -// Currently no good way to do inheritance in REACT_STRUCTS -#define REACT_SVG_NODE_COMMON_PROPS \ - REACT_FIELD(name) \ - REACT_FIELD(opacity) \ - REACT_FIELD(matrix) \ - REACT_FIELD(mask) \ - REACT_FIELD(markerStart) \ - REACT_FIELD(markerMid) \ - REACT_FIELD(markerEnd) \ - REACT_FIELD(clipPath) \ - REACT_FIELD(clipRule) \ - REACT_FIELD(responsible) \ - REACT_FIELD(display) \ - REACT_FIELD(pointerEvents) - -REACT_STRUCT(SvgNodeCommonProps) -struct SvgNodeCommonProps : SvgNodeCommonPropsT { - SvgNodeCommonProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - virtual void SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept; - - REACT_SVG_NODE_COMMON_PROPS; - - std::optional name; - std::optional opacity; // 1.0f - std::optional> matrix; - std::optional mask; - std::optional markerStart; - std::optional markerMid; - std::optional markerEnd; - std::optional clipPath; - std::optional clipRule; // RNSVG::FillRule::EvenOdd - std::optional responsible; - std::optional display; - std::optional pointerEvents; - - private: - winrt::Microsoft::ReactNative::ViewProps m_props{nullptr}; -}; - -// Currently no good way to do inheritance in REACT_STRUCTS -#define REACT_SVG_RENDERABLE_COMMON_PROPS \ - REACT_FIELD(fill) \ - REACT_FIELD(fillOpacity) \ - REACT_FIELD(fillRule) \ - REACT_FIELD(stroke) \ - REACT_FIELD(strokeOpacity) \ - REACT_FIELD(strokeWidth) \ - REACT_FIELD(strokeLinecap) \ - REACT_FIELD(strokeLinejoin) \ - REACT_FIELD(strokeDasharray) \ - REACT_FIELD(strokeDashoffset) \ - REACT_FIELD(strokeMiterlimit) \ - REACT_FIELD(vectorEffect) \ - REACT_FIELD(propList) - -REACT_STRUCT(SvgRenderableCommonProps) -struct SvgRenderableCommonProps - : SvgRenderableCommonPropsT { - SvgRenderableCommonProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - - std::optional fill; - std::optional fillOpacity; // 1.0f - std::optional fillRule; // RNSVG::FillRule::NonZero - std::optional stroke; - std::optional strokeOpacity; // 1.0f - std::optional strokeWidth; - std::optional strokeLinecap; // RNSVG::LineCap::Butt - std::optional strokeLinejoin; // RNSVG::LineJoin::Miter - std::optional> strokeDasharray; - std::optional strokeDashoffset; - std::optional strokeMiterlimit; - std::optional vectorEffect; // 0 - std::optional> propList; -}; -#endif struct RenderableView : RenderableViewT { public: RenderableView() = default; -#ifdef USE_FABRIC - // IRenderableFabric - IRenderableFabric SvgParent() { return m_parent; } - void SvgParent(IRenderableFabric const &value) { m_parent = value; } - - winrt::Microsoft::ReactNative::Color Fill() { return m_fill; } - winrt::Microsoft::ReactNative::Color Stroke() { return m_stroke; } - - // ComponentView - void MountChildComponentView( - const winrt::Microsoft::ReactNative::ComponentView &view, - const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept; - void UnmountChildComponentView( - const winrt::Microsoft::ReactNative::ComponentView &view, - const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept; - - virtual void UpdateProps( - const winrt::Microsoft::ReactNative::ComponentView & /*view*/, - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept; - - // IRenderableFabric - virtual void UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate = true, - bool invalidate = true) noexcept; - - const winrt::Windows::Foundation::Collections::IVector &Children() const noexcept; -#else RenderableView(Microsoft::ReactNative::IReactContext const &context) : m_reactContext(context) {} // IRenderablePaper @@ -176,7 +23,6 @@ struct RenderableView : RenderableViewT { Windows::UI::Color Stroke() { return m_stroke; } virtual void UpdateProperties(Microsoft::ReactNative::IJSValueReader const &reader, bool forceUpdate = true, bool invalidate = true); -#endif RNSVG::SvgView SvgRoot(); @@ -214,9 +60,7 @@ struct RenderableView : RenderableViewT { virtual RNSVG::IRenderable HitTest(Windows::Foundation::Point const &point); protected: -#ifndef USE_FABRIC std::vector m_propList{}; -#endif float m_opacity{1.0f}; std::map m_propSetMap{ @@ -235,23 +79,11 @@ struct RenderableView : RenderableViewT { }; private: -#ifdef USE_FABRIC - IRenderableFabric m_parent{nullptr}; - winrt::Microsoft::ReactNative::Color m_fill{winrt::Microsoft::ReactNative::Color::Black()}; - winrt::Microsoft::ReactNative::Color m_stroke{winrt::Microsoft::ReactNative::Color::Transparent()}; - - void SetColor( - std::optional &propValue, - winrt::Microsoft::ReactNative::Color const &fallbackColor, - std::string propName); - winrt::Windows::Foundation::Collections::IVector m_children{ winrt::single_threaded_vector() }; -#else xaml::FrameworkElement m_parent{nullptr}; Windows::UI::Color m_fill{Colors::Black()}; Windows::UI::Color m_stroke{Colors::Transparent()}; void SetColor(const Microsoft::ReactNative::JSValueObject &propValue, Windows::UI::Color const &fallbackColor, std::string propName); -#endif Microsoft::ReactNative::IReactContext m_reactContext{nullptr}; RNSVG::D2DGeometry m_geometry{nullptr}; @@ -278,42 +110,6 @@ struct RenderableView : RenderableViewT { }; } // namespace winrt::RNSVG::implementation -#ifdef USE_FABRIC -template -void RegisterRenderableComponent(const winrt::hstring& name, const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - builder.AddViewComponent( - name, [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { - builder.SetComponentViewInitializer([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept { - auto userData = winrt::make_self(); - view.UserData(*userData); - }); - builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props) noexcept { - return winrt::make(props); - }); - builder.SetUpdatePropsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view, - const winrt::Microsoft::ReactNative::IComponentProps &newProps, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept { - auto userData = view.UserData().as(); - userData->UpdateProps(view, newProps, oldProps); - }); - builder.SetMountChildComponentViewHandler( - [](const winrt::Microsoft::ReactNative::ComponentView &view, - const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept { - auto userData = view.UserData().as(); - return userData->MountChildComponentView(view, args); - }); - builder.SetUnmountChildComponentViewHandler( - [](const winrt::Microsoft::ReactNative::ComponentView &view, - const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept { - auto userData = view.UserData().as(); - return userData->UnmountChildComponentView(view, args); - }); - }); -} -#endif - -#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct RenderableView : RenderableViewT {}; } // namespace winrt::RNSVG::factory_implementation -#endif \ No newline at end of file diff --git a/windows/RNSVG/SVGLength.h b/windows/RNSVG/SVGLength.h index 046a5a811..920f3fee7 100644 --- a/windows/RNSVG/SVGLength.h +++ b/windows/RNSVG/SVGLength.h @@ -2,9 +2,7 @@ #include -#ifndef USE_FABRIC #include "JSValueXaml.h" -#endif namespace winrt::Microsoft::ReactNative { void WriteValue(IJSValueWriter const &writer, const winrt::RNSVG::SVGLength &value) noexcept; diff --git a/windows/RNSVG/SvgView.cpp b/windows/RNSVG/SvgView.cpp index 468a7c0c6..9100caa7a 100644 --- a/windows/RNSVG/SvgView.cpp +++ b/windows/RNSVG/SvgView.cpp @@ -18,213 +18,12 @@ #include "D2DDeviceContext.h" #include "GroupView.h" -#ifdef USE_FABRIC -#include -#include -#include -#endif - #include using namespace winrt; namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -SvgViewProps::SvgViewProps( - const winrt::Microsoft::ReactNative::ViewProps &props) - : m_props(props) {} - -void SvgViewProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - -SvgView::SvgView(const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext) - : m_compContext(compContext) - {} - -winrt::Microsoft::ReactNative::Composition::Experimental::IVisual SvgView::CreateInternalVisual() { - m_visual = m_compContext.CreateSpriteVisual(); - m_visual.Comment(L"SVGRoot"); - return m_visual; -} - -void SvgView::MountChildComponentView( - const winrt::Microsoft::ReactNative::ComponentView&, - const winrt::Microsoft::ReactNative::MountChildComponentViewArgs& args) noexcept -{ - auto childUserData = args.Child().UserData(); - childUserData.as().SvgParent(*this); - - if (childUserData) { - auto const &group{childUserData.try_as()}; - if (group) { - // Every SvgView has exactly one child - a Group that gets - // all of Svg's children piped through. - Group(group); - } - } -} - -void SvgView::UnmountChildComponentView( - const winrt::Microsoft::ReactNative::ComponentView&, - const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs& args) noexcept -{ - auto userData = args.Child().UserData(); - userData.as().SvgParent(nullptr); - - if (Group()) { - Group().Unload(); - } - Group(nullptr); -} - -void SvgView::OnThemeChanged() noexcept { - Invalidate(); -} - -void SvgView::UpdateProps( - const winrt::Microsoft::ReactNative::ComponentView& /*view*/, - const winrt::Microsoft::ReactNative::IComponentProps &newProps, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept { - UpdateProperties(newProps, oldProps); -} - -void SvgView::Initialize(const winrt::Microsoft::ReactNative::ComponentView &sender) noexcept { - auto view = sender.as(); - m_wkView = view; - - sender.as() - .CreateInternalVisualHandler([wkThis = get_weak()](const winrt::Microsoft::ReactNative::ComponentView &) { - return wkThis.get()->CreateInternalVisual(); - }); - - sender.LayoutMetricsChanged( - [wkThis = get_weak()]( - const winrt::IInspectable &, const winrt::Microsoft::ReactNative::LayoutMetricsChangedArgs &args) { - if (auto strongThis = wkThis.get()) { - strongThis->UpdateLayoutMetrics(args.NewLayoutMetrics(), args.OldLayoutMetrics()); - } - }); - - view.ThemeChanged( - [wkThis = get_weak()](const winrt::IInspectable & /*sender*/, const winrt::IInspectable & /*args*/) { - if (auto strongThis = wkThis.get()) { - strongThis->OnThemeChanged(); - } - }); -} - -void SvgView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - builder.AddViewComponent(L"RNSVGSvgView", [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { - builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props) noexcept { - return winrt::make(props); - }); - auto compBuilder = - builder.as(); - - compBuilder.SetViewComponentViewInitializer( - [](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept { - auto userData = winrt::make_self( - view.as() - .CompositionContext()); - userData->Initialize(view); - view.UserData(*userData); - }); - - builder.SetUpdatePropsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view, - const winrt::Microsoft::ReactNative::IComponentProps &newProps, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept { - auto userData = view.UserData().as(); - userData->UpdateProps(view, newProps, oldProps); - }); - - builder.SetMountChildComponentViewHandler( - [](const winrt::Microsoft::ReactNative::ComponentView &view, - const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept { - auto userData = view.UserData().as(); - return userData->MountChildComponentView(view, args); - }); - - builder.SetUnmountChildComponentViewHandler( - [](const winrt::Microsoft::ReactNative::ComponentView &view, - const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept { - auto userData = view.UserData().as(); - return userData->UnmountChildComponentView(view, args); - }); - - }); - - // TODO how to remove featureflag Background? -} - -void SvgView::UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate, - bool invalidate) { - auto svgProps = props.try_as(); - auto oldSvgProps = oldProps ? oldProps.try_as() : nullptr; - - // If forceUpdate is false, that means this is a nested Svg - // and we're inheriting props. Pass those along to the group. - if (!forceUpdate && m_group) { - m_group.UpdateProperties(props, oldProps, forceUpdate, invalidate); - return; - } - - if (!oldSvgProps || svgProps->bbWidth != oldSvgProps->bbWidth) { - m_bbWidth = svgProps->bbWidth; - } - if (!oldSvgProps || svgProps->bbHeight != oldSvgProps->bbHeight) { - m_bbHeight = svgProps->bbHeight; - } - if (!oldSvgProps || svgProps->vbWidth != oldSvgProps->vbWidth) { - m_vbWidth = svgProps->vbWidth; - } - if (!oldSvgProps || svgProps->vbHeight != oldSvgProps->vbHeight) { - m_vbHeight = svgProps->vbHeight; - } - if (!oldSvgProps || svgProps->minX != oldSvgProps->minX) { - m_minX = svgProps->minX; - } - if (!oldSvgProps || svgProps->minY != oldSvgProps->minY) { - m_minY = svgProps->minY; - } - if (!oldSvgProps || svgProps->align != oldSvgProps->align) { - m_align = svgProps->align; - } - if (!oldSvgProps || svgProps->meetOrSlice != oldSvgProps->meetOrSlice) { - m_meetOrSlice = svgProps->meetOrSlice; - } - if (!oldSvgProps || svgProps->color != oldSvgProps->color) { - m_currentColor = svgProps->color; - } - - Invalidate(); -} - -void SvgView::UpdateLayoutMetrics( - const LayoutMetrics &metrics, - const LayoutMetrics &oldMetrics) { - m_layoutMetrics = metrics; - - if (metrics != oldMetrics) { - Invalidate(); - } -} - -winrt::Microsoft::ReactNative::Composition::Theme SvgView::Theme() const noexcept { - if (auto view = m_wkView.get()) { - return view.Theme(); - } - return nullptr; -} - -#else SvgView::SvgView(IReactContext const &context) : m_reactContext(context) { uint32_t creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT; @@ -355,14 +154,9 @@ void SvgView::Panel_Unloaded(IInspectable const &sender, xaml::RoutedEventArgs c svgView.Unload(); } } -#endif winrt::Windows::Foundation::Size SvgView::CanvasSize() noexcept { -#ifdef USE_FABRIC - return winrt::Windows::Foundation::Size{m_layoutMetrics.Frame.Width, m_layoutMetrics.Frame.Height}; -#else return ActualSize(); -#endif } void SvgView::SaveDefinition() { @@ -422,12 +216,10 @@ void SvgView::CreateResources() { Invalidate(); -#ifndef USE_FABRIC m_image.Width(ActualWidth()); m_image.Height(ActualHeight()); m_image.Stretch(xaml::Media::Stretch::UniformToFill); Children().Append(m_image); -#endif } void SvgView::Unload() { @@ -444,48 +236,6 @@ void SvgView::Invalidate() { m_brushes.Clear(); m_templates.Clear(); -#ifdef USE_FABRIC - Size size = CanvasSize(); - - if (size.Height == 0 || size.Width == 0) { - return; - } - - if (Theme().IsEmpty()) { - return; - } - - auto drawingSurface = m_compContext.CreateDrawingSurfaceBrush( - size, - winrt::Windows::Graphics::DirectX::DirectXPixelFormat::B8G8R8A8UIntNormalized, - winrt::Windows::Graphics::DirectX::DirectXAlphaMode::Premultiplied); - - POINT offset; - { - ::Microsoft::ReactNative::Composition::AutoDrawDrawingSurface autoDraw(drawingSurface, 1.0, &offset); - if (auto deviceContext = autoDraw.GetRenderTarget()) { - auto transform = Numerics::make_float3x2_translation({static_cast(offset.x), static_cast(offset.y)}); - deviceContext->SetTransform(D2DHelpers::AsD2DTransform(transform)); - - deviceContext->Clear(D2D1::ColorF(D2D1::ColorF::Black, 0.0f)); - - com_ptr spDeviceContext; - spDeviceContext.copy_from(deviceContext); - - m_deviceContext = winrt::make(spDeviceContext); - - com_ptr spDevice; - spDeviceContext->GetDevice(spDevice.put()); - - m_device = winrt::make(spDevice); - - Draw(m_deviceContext, size); - } - } - - m_visual.Brush(drawingSurface); - -#else if (!m_loaded) { return; } @@ -530,6 +280,5 @@ void SvgView::Invalidate() { sisNativeWithD2D->EndDraw(); m_image.Source(surfaceImageSource); -#endif } } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/SvgView.h b/windows/RNSVG/SvgView.h index 145af4a2d..251851d7e 100644 --- a/windows/RNSVG/SvgView.h +++ b/windows/RNSVG/SvgView.h @@ -2,101 +2,15 @@ #include "SvgView.g.h" -#ifdef USE_FABRIC -#include "SvgViewProps.g.h" - -#include -#include -#include "NativeModules.h" -#endif - #include "SVGLength.h" #include "Utils.h" namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -REACT_STRUCT(SvgViewProps) -struct SvgViewProps : SvgViewPropsT { - SvgViewProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept; - - REACT_FIELD(bbWidth) - winrt::RNSVG::SVGLength bbWidth{0.0, winrt::RNSVG::LengthType::Unknown}; - - REACT_FIELD(bbHeight) - winrt::RNSVG::SVGLength bbHeight{0.0, winrt::RNSVG::LengthType::Unknown}; - - REACT_FIELD(minX) - float minX; - REACT_FIELD(minY) - float minY; - REACT_FIELD(vbWidth) - float vbWidth; - REACT_FIELD(vbHeight) - float vbHeight; - REACT_FIELD(align) - std::string align; - REACT_FIELD(meetOrSlice) - RNSVG::MeetOrSlice meetOrSlice{RNSVG::MeetOrSlice::Meet}; - REACT_FIELD(tintColor) - winrt::Microsoft::ReactNative::Color tintColor{nullptr}; - REACT_FIELD(color) - winrt::Microsoft::ReactNative::Color color{nullptr}; - - private: - winrt::Microsoft::ReactNative::ViewProps m_props{nullptr}; -}; -#endif - struct SvgView : SvgViewT { public: -#ifndef USE_FABRIC SvgView() = default; -#endif - -#ifdef USE_FABRIC - SvgView(const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext); - IRenderableFabric SvgParent() { return m_parent; } - void SvgParent(IRenderableFabric const &value) { m_parent = value; } - winrt::Microsoft::ReactNative::Color CurrentColor() { return m_currentColor; } - - // IRenderableFabric - void UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate = true, - bool invalidate = true); - - // Overrides - // IInternalCreateVisual - winrt::Microsoft::ReactNative::Composition::Experimental::IVisual CreateInternalVisual(); - - // ComponentView - void UpdateProps( - const winrt::Microsoft::ReactNative::ComponentView & /*view*/, - const winrt::Microsoft::ReactNative::IComponentProps &newProps, - const winrt::Microsoft::ReactNative::IComponentProps & /*oldProps*/) noexcept; - void UpdateLayoutMetrics( - const winrt::Microsoft::ReactNative::LayoutMetrics &metrics, - const winrt::Microsoft::ReactNative::LayoutMetrics &oldMetrics); - void MountChildComponentView( - const winrt::Microsoft::ReactNative::ComponentView& view, - const winrt::Microsoft::ReactNative::MountChildComponentViewArgs& args) noexcept; - void UnmountChildComponentView( - const winrt::Microsoft::ReactNative::ComponentView& view, - const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs& args) noexcept; - - void OnThemeChanged() noexcept; - - void Initialize(const winrt::Microsoft::ReactNative::ComponentView & /*view*/) noexcept; - - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - - winrt::Microsoft::ReactNative::Composition::Theme Theme() const noexcept; -#else SvgView(winrt::Microsoft::ReactNative::IReactContext const &context); xaml::FrameworkElement SvgParent() { return m_parent; } @@ -113,7 +27,6 @@ struct SvgView : SvgViewT { void Panel_Loaded(winrt::Windows::Foundation::IInspectable const &sender, xaml::RoutedEventArgs const &args); void Panel_Unloaded(winrt::Windows::Foundation::IInspectable const &sender, xaml::RoutedEventArgs const &args); -#endif winrt::Windows::Foundation::Size CanvasSize() noexcept; @@ -149,14 +62,6 @@ struct SvgView : SvgViewT { void Invalidate(); private: -#ifdef USE_FABRIC - IRenderableFabric m_parent{nullptr}; - winrt::Microsoft::ReactNative::Composition::Experimental::ISpriteVisual m_visual{nullptr}; - winrt::Microsoft::ReactNative::Color m_currentColor{nullptr}; - winrt::Microsoft::ReactNative::LayoutMetrics m_layoutMetrics{{0, 0, 0, 0}, 1.0}; - winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext m_compContext{nullptr}; - winrt::weak_ref m_wkView; -#else bool m_loaded{false}; xaml::FrameworkElement m_parent{nullptr}; xaml::Controls::Image m_image; @@ -164,7 +69,6 @@ struct SvgView : SvgViewT { xaml::FrameworkElement::Loaded_revoker m_panelLoadedRevoker{}; xaml::FrameworkElement::Unloaded_revoker m_panelUnloadedRevoker{}; -#endif // Shared Microsoft::ReactNative::IReactContext m_reactContext{nullptr}; @@ -192,8 +96,6 @@ struct SvgView : SvgViewT { }; } // namespace winrt::RNSVG::implementation -#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct SvgView : SvgViewT {}; } // namespace winrt::RNSVG::factory_implementation -#endif diff --git a/windows/RNSVG/SymbolView.cpp b/windows/RNSVG/SymbolView.cpp index af6c7877e..d1143c3a6 100644 --- a/windows/RNSVG/SymbolView.cpp +++ b/windows/RNSVG/SymbolView.cpp @@ -10,38 +10,6 @@ using namespace winrt; namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -SymbolProps::SymbolProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} - -void SymbolProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - -void SymbolView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGSymbol", builder); -} - -void SymbolView::UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate, - bool invalidate) noexcept { - auto symbolProps = props.try_as(); - if (symbolProps) { - m_minX = symbolProps->minX; - m_minY = symbolProps->minY; - m_vbWidth = symbolProps->vbWidth; - m_vbHeight = symbolProps->vbHeight; - m_align = symbolProps->align; - m_meetOrSlice = symbolProps->meetOrSlice; - } - - base_type::UpdateProperties(props, oldProps, forceUpdate, invalidate); -} -#else void SymbolView::UpdateProperties(IJSValueReader const &reader, bool forceUpdate, bool invalidate) { const JSValueObject &propertyMap{JSValue::ReadObjectFrom(reader)}; @@ -66,5 +34,5 @@ void SymbolView::UpdateProperties(IJSValueReader const &reader, bool forceUpdate __super::UpdateProperties(reader, forceUpdate, invalidate); } -#endif + } // namespace winrt::RNSVG::implementation diff --git a/windows/RNSVG/SymbolView.h b/windows/RNSVG/SymbolView.h index 07a4aa536..5f864e2fd 100644 --- a/windows/RNSVG/SymbolView.h +++ b/windows/RNSVG/SymbolView.h @@ -1,58 +1,16 @@ #pragma once -#ifdef USE_FABRIC -#include "SymbolProps.g.h" -#endif - #include "SymbolView.g.h" #include "GroupView.h" namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -REACT_STRUCT(SymbolProps) -struct SymbolProps : SymbolPropsT { - SymbolProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - REACT_SVG_GROUP_COMMON_PROPS; - - REACT_FIELD(minX) - float minX{0.0f}; - REACT_FIELD(minY) - float minY{0.0f}; - REACT_FIELD(vbWidth) - float vbWidth{0.0f}; - REACT_FIELD(vbHeight) - float vbHeight{0.0f}; - REACT_FIELD(align) - std::string align{""}; - REACT_FIELD(meetOrSlice) - RNSVG::MeetOrSlice meetOrSlice{RNSVG::MeetOrSlice::Meet}; -}; -#endif - struct SymbolView : SymbolViewT { public: SymbolView() = default; -#ifdef USE_FABRIC - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - - // IRenderableFabric - void UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate = true, - bool invalidate = true) noexcept override; -#else // IRenderablePaper void UpdateProperties(Microsoft::ReactNative::IJSValueReader const &reader, bool forceUpdate, bool invalidate); -#endif float MinX() { return m_minX; } float MinY() { return m_minY; } @@ -74,8 +32,6 @@ struct SymbolView : SymbolViewT { }; } // namespace winrt::RNSVG::implementation -#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct SymbolView : SymbolViewT {}; } // namespace winrt::RNSVG::factory_implementation -#endif diff --git a/windows/RNSVG/TSpanView.cpp b/windows/RNSVG/TSpanView.cpp index 25601cf07..580679b8c 100644 --- a/windows/RNSVG/TSpanView.cpp +++ b/windows/RNSVG/TSpanView.cpp @@ -13,33 +13,6 @@ using namespace Microsoft::ReactNative; namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -TSpanProps::TSpanProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} - -void TSpanProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - -void TSpanView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGTSpan", builder); -} - -void TSpanView::UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate, - bool invalidate) noexcept { - auto tspanProps = props.try_as(); - if (tspanProps) { - m_content = tspanProps->content; - } - - base_type::UpdateProperties(props, oldProps, forceUpdate, invalidate); -} -#else void TSpanView::UpdateProperties(IJSValueReader const &reader, bool forceUpdate, bool invalidate) { const JSValueObject &propertyMap{JSValue::ReadObjectFrom(reader)}; @@ -54,7 +27,6 @@ void TSpanView::UpdateProperties(IJSValueReader const &reader, bool forceUpdate, __super::UpdateProperties(reader, forceUpdate, invalidate); } -#endif void TSpanView::Draw(RNSVG::D2DDeviceContext const &context, Size const &size) { com_ptr deviceContext{get_self(context)->Get()}; diff --git a/windows/RNSVG/TSpanView.h b/windows/RNSVG/TSpanView.h index eb4f0dbb3..2d2188cce 100644 --- a/windows/RNSVG/TSpanView.h +++ b/windows/RNSVG/TSpanView.h @@ -1,49 +1,16 @@ #pragma once -#ifdef USE_FABRIC -#include "TSpanProps.g.h" -#endif - #include "TSpanView.g.h" #include "TextView.h" namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -REACT_STRUCT(TSpanProps) -struct TSpanProps : TSpanPropsT { - TSpanProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - REACT_SVG_GROUP_COMMON_PROPS; - REACT_SVG_TEXT_COMMON_PROPS; - - REACT_FIELD(content) - std::string content{""}; -}; -#endif - struct TSpanView : TSpanViewT { public: TSpanView() = default; -#ifdef USE_FABRIC - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - - // IRenderableFabric - void UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate = true, - bool invalidate = true) noexcept override; -#else // IRenderablePaper void UpdateProperties(Microsoft::ReactNative::IJSValueReader const &reader, bool forceUpdate, bool invalidate); -#endif // IRenderable virtual void Draw(RNSVG::D2DDeviceContext const &deviceContext, Windows::Foundation::Size const &size); @@ -53,9 +20,6 @@ struct TSpanView : TSpanViewT { }; } // namespace winrt::RNSVG::implementation -#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct TSpanView : TSpanViewT {}; } // namespace winrt::RNSVG::factory_implementation -#endif - diff --git a/windows/RNSVG/TextView.cpp b/windows/RNSVG/TextView.cpp index bbfdd397e..29fdd8d78 100644 --- a/windows/RNSVG/TextView.cpp +++ b/windows/RNSVG/TextView.cpp @@ -11,71 +11,6 @@ using namespace Microsoft::ReactNative; namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -SvgTextCommonProps::SvgTextCommonProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} - -void SvgTextCommonProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - -void TextView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGText", builder); -} - -void TextView::UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate, - bool invalidate) noexcept { - auto textProps = props.try_as(); - if (textProps) { - if (textProps->x != std::nullopt) { - m_x.Clear(); - - for (auto const &item : *textProps->x) { - m_x.Append(item); - } - } - - if (textProps->y != std::nullopt) { - m_y.Clear(); - - for (auto const &item : *textProps->y) { - m_y.Append(item); - } - } - - if (textProps->dx != std::nullopt) { - m_dx.Clear(); - - for (auto const &item : *textProps->dx) { - m_dx.Append(item); - } - } - - if (textProps->dy != std::nullopt) { - m_dy.Clear(); - - for (auto const &item : *textProps->dy) { - m_dy.Append(item); - } - } - - if (textProps->rotate != std::nullopt) { - m_rotate.Clear(); - - for (auto const &item : *textProps->rotate) { - m_rotate.Append(item); - } - } - } - - base_type::UpdateProperties(props, oldProps, forceUpdate, invalidate); -} -#else void TextView::UpdateProperties(IJSValueReader const &reader, bool forceUpdate, bool invalidate) { const JSValueObject &propertyMap{JSValue::ReadObjectFrom(reader)}; @@ -113,7 +48,6 @@ void TextView::UpdateProperties(IJSValueReader const &reader, bool forceUpdate, __super::UpdateProperties(reader, forceUpdate, invalidate); } -#endif void TextView::DrawGroup(RNSVG::D2DDeviceContext const &context, Size const &size) { com_ptr deviceContext{get_self(context)->Get()}; diff --git a/windows/RNSVG/TextView.h b/windows/RNSVG/TextView.h index f8cd07fd3..293135876 100644 --- a/windows/RNSVG/TextView.h +++ b/windows/RNSVG/TextView.h @@ -1,71 +1,16 @@ #pragma once -#ifdef USE_FABRIC -#include "SvgTextCommonProps.g.h" -#endif - #include "TextView.g.h" #include "GroupView.h" namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -#define REACT_SVG_TEXT_COMMON_PROPS \ - REACT_FIELD(dx) \ - REACT_FIELD(dy) \ - REACT_FIELD(x) \ - REACT_FIELD(y) \ - REACT_FIELD(rotate) \ - REACT_FIELD(inlineSize) \ - REACT_FIELD(textLength) \ - REACT_FIELD(baselineShift) \ - REACT_FIELD(lengthAdjust) \ - REACT_FIELD(alignmentBaseline) \ - REACT_FIELD(verticalAlign) - -REACT_STRUCT(SvgTextCommonProps) -struct SvgTextCommonProps : SvgTextCommonPropsT { - SvgTextCommonProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - REACT_SVG_GROUP_COMMON_PROPS; - REACT_SVG_TEXT_COMMON_PROPS; - - std::optional> dx; - std::optional> dy; - std::optional> x; - std::optional> y; - std::optional> rotate; - RNSVG::SVGLength inlineSize{0, winrt::RNSVG::LengthType::Unknown}; - RNSVG::SVGLength textLength{0, winrt::RNSVG::LengthType::Unknown}; - RNSVG::SVGLength baselineShift{0, winrt::RNSVG::LengthType::Unknown}; - std::string lengthAdjust; - std::string alignmentBaseline; - RNSVG::SVGLength verticalAlign{0, winrt::RNSVG::LengthType::Unknown}; -}; -#endif - struct TextView : TextViewT { public: TextView() = default; -#ifdef USE_FABRIC - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; - - // IRenderableFabric - virtual void UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate = true, - bool invalidate = true) noexcept; -#else // IRenderablePaper virtual void UpdateProperties(Microsoft::ReactNative::IJSValueReader const &reader, bool forceUpdate, bool invalidate); -#endif Windows::Foundation::Collections::IVector X() { return m_x; } Windows::Foundation::Collections::IVector Y() { return m_y; } @@ -85,8 +30,6 @@ struct TextView : TextViewT { }; } // namespace winrt::RNSVG::implementation -#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct TextView : TextViewT {}; } // namespace winrt::RNSVG::factory_implementation -#endif diff --git a/windows/RNSVG/UseView.cpp b/windows/RNSVG/UseView.cpp index 879e53acd..8a0449726 100644 --- a/windows/RNSVG/UseView.cpp +++ b/windows/RNSVG/UseView.cpp @@ -11,37 +11,6 @@ using namespace Microsoft::ReactNative; namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -UseProps::UseProps(const winrt::Microsoft::ReactNative::ViewProps &props) : base_type(props) {} - -void UseProps::SetProp( - uint32_t hash, - winrt::hstring propName, - winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); -} - -void UseView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { - RegisterRenderableComponent(L"RNSVGUse", builder); -} - -void UseView::UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate, - bool invalidate) noexcept { - auto useProps = props.try_as(); - if (useProps) { - m_href = winrt::to_hstring(useProps->href); - m_x = useProps->x; - m_y = useProps->y; - m_width = useProps->width; - m_height = useProps->height; - } - - base_type::UpdateProperties(props, oldProps, forceUpdate, invalidate); -} -#else void UseView::UpdateProperties(IJSValueReader const &reader, bool forceUpdate, bool invalidate) { const JSValueObject &propertyMap{JSValue::ReadObjectFrom(reader)}; @@ -64,7 +33,6 @@ void UseView::UpdateProperties(IJSValueReader const &reader, bool forceUpdate, b __super::UpdateProperties(reader, forceUpdate, invalidate); } -#endif void UseView::Draw(RNSVG::D2DDeviceContext const &context, Size const &size) { if (auto const &view{GetRenderableTemplate()}) { @@ -117,11 +85,7 @@ void UseView::Draw(RNSVG::D2DDeviceContext const &context, Size const &size) { deviceContext->PopLayer(); // Restore original template props -#ifdef USE_FABRIC - auto renderable{view.try_as()}; -#else auto renderable{view.try_as()}; -#endif if (renderable) { if (auto const &parent{renderable.SvgParent().try_as()}) { view.MergeProperties(parent); diff --git a/windows/RNSVG/UseView.h b/windows/RNSVG/UseView.h index 0cc3a7726..40aa52bcd 100644 --- a/windows/RNSVG/UseView.h +++ b/windows/RNSVG/UseView.h @@ -1,55 +1,16 @@ #pragma once -#ifdef USE_FABRIC -#include "UseProps.g.h" -#endif - #include "UseView.g.h" #include "RenderableView.h" namespace winrt::RNSVG::implementation { -#ifdef USE_FABRIC -REACT_STRUCT(UseProps) -struct UseProps : UsePropsT { - UseProps(const winrt::Microsoft::ReactNative::ViewProps &props); - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept - override; - - REACT_SVG_NODE_COMMON_PROPS; - REACT_SVG_RENDERABLE_COMMON_PROPS; - - REACT_FIELD(href) - std::string href; - REACT_FIELD(x) - RNSVG::SVGLength x{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(y) - RNSVG::SVGLength y{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(width) - RNSVG::SVGLength width{0, winrt::RNSVG::LengthType::Unknown}; - REACT_FIELD(height) - RNSVG::SVGLength height{0, winrt::RNSVG::LengthType::Unknown}; -}; -#endif - struct UseView : UseViewT { public: UseView() = default; -#ifdef USE_FABRIC - // IRenderableFabric - void UpdateProperties( - const winrt::Microsoft::ReactNative::IComponentProps &props, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps, - bool forceUpdate = true, - bool invalidate = true) noexcept override; - - static void RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept; -#else // IRenderablePaper void UpdateProperties(Microsoft::ReactNative::IJSValueReader const &reader, bool forceUpdate, bool invalidate); -#endif // RenderableView void Draw(RNSVG::D2DDeviceContext const &deviceContext, Windows::Foundation::Size const &size); @@ -65,8 +26,6 @@ struct UseView : UseViewT { }; } // namespace winrt::RNSVG::implementation -#ifndef USE_FABRIC namespace winrt::RNSVG::factory_implementation { struct UseView : UseViewT {}; } // namespace winrt::RNSVG::factory_implementation -#endif diff --git a/windows/RNSVG/Utils.h b/windows/RNSVG/Utils.h index 72be64ea6..34f684e25 100644 --- a/windows/RNSVG/Utils.h +++ b/windows/RNSVG/Utils.h @@ -2,11 +2,6 @@ #include "pch.h" -#ifdef USE_FABRIC -#include -#include -#endif - #include #include #include "JSValueReader.h" @@ -171,54 +166,6 @@ struct Utils { } } -#ifdef USE_FABRIC - static std::string JSValueAsBrushUnits( - std::optional const &value, - std::string defaultValue = "objectBoundingBox") { - return (value.has_value() && *value == 1) ? "userSpaceOnUse" : defaultValue; - } - - static float JSValueAsFloat(std::optional const &value, float defaultValue = 0.0f) { - return value.has_value() ? *value : defaultValue; - } - - static std::string JSValueAsString(std::optional const &value, std::string defaultValue = "") { - return value.has_value() ? *value : defaultValue; - } - - static D2D1::Matrix3x2F JSValueAsD2DTransform(std::optional> const &value) { - if (value.has_value()) { - auto matrix{value.value()}; - return D2D1::Matrix3x2F( - matrix.at(0), - matrix.at(1), - matrix.at(2), - matrix.at(3), - matrix.at(4), - matrix.at(5)); - } - - return D2D1::Matrix3x2F::Identity(); - } - - static std::vector JSValueAsGradientStops(std::optional> const &value) { - if (value.has_value()) { - auto gradient = value.value(); - std::vector gradientStops; - - for (size_t i = 0; i < gradient.size(); ++i) { - D2D1_GRADIENT_STOP stop{}; - stop.position = Utils::JSValueAsFloat(gradient.at(i)); - stop.color = D2DHelpers::AsD2DColor(Utils::JSValueAsD2DColor(gradient.at(++i))); - gradientStops.emplace_back(stop); - } - - return gradientStops; - } - - return {}; - } -#else static std::string JSValueAsBrushUnits(JSValue const &value, std::string defaultValue = "objectBoundingBox") { if (value.IsNull()) { return defaultValue; @@ -306,7 +253,6 @@ struct Utils { return gradientStops; } -#endif static winrt::Windows::UI::Color JSValueAsD2DColor(float value) { auto color = static_cast(value); From 27309537a5501205d4a81e1120797a298601012e Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Mon, 4 Nov 2024 12:16:15 -0800 Subject: [PATCH 07/13] code cleanup --- windows/RNSVG/Fabric/CircleView.cpp | 2 +- windows/RNSVG/Fabric/ClipPathView.cpp | 2 +- windows/RNSVG/Fabric/D2DHelpers.h | 2 +- windows/RNSVG/Fabric/DefsView.cpp | 2 +- windows/RNSVG/Fabric/EllipseView.cpp | 2 +- windows/RNSVG/Fabric/GroupView.cpp | 2 +- windows/RNSVG/Fabric/ImageView.cpp | 2 +- windows/RNSVG/Fabric/LineView.cpp | 2 +- windows/RNSVG/Fabric/LinearGradientView.cpp | 2 +- windows/RNSVG/Fabric/PathView.cpp | 2 +- windows/RNSVG/Fabric/RadialGradientView.cpp | 2 +- windows/RNSVG/Fabric/RectView.cpp | 2 +- windows/RNSVG/Fabric/RenderableView.h | 4 ++-- windows/RNSVG/Fabric/SvgStrings.h | 25 --------------------- windows/RNSVG/Fabric/SvgView.cpp | 19 +++++++--------- windows/RNSVG/Fabric/SvgView.h | 10 ++++++--- windows/RNSVG/Fabric/UnsupportedSvgView.cpp | 2 +- windows/RNSVG/Fabric/UseView.cpp | 2 +- 18 files changed, 31 insertions(+), 55 deletions(-) diff --git a/windows/RNSVG/Fabric/CircleView.cpp b/windows/RNSVG/Fabric/CircleView.cpp index d376cd567..5092253a1 100644 --- a/windows/RNSVG/Fabric/CircleView.cpp +++ b/windows/RNSVG/Fabric/CircleView.cpp @@ -21,7 +21,7 @@ struct CircleProps : public winrt::implements { +struct CircleView : winrt::implements { public: CircleView() = default; diff --git a/windows/RNSVG/Fabric/ClipPathView.cpp b/windows/RNSVG/Fabric/ClipPathView.cpp index 6af618d01..63a77e733 100644 --- a/windows/RNSVG/Fabric/ClipPathView.cpp +++ b/windows/RNSVG/Fabric/ClipPathView.cpp @@ -14,7 +14,7 @@ struct ClipPathProps : winrt::implements { +struct ClipPathView : winrt::implements { public: ClipPathView() = default; diff --git a/windows/RNSVG/Fabric/D2DHelpers.h b/windows/RNSVG/Fabric/D2DHelpers.h index 8155827cd..e95feb927 100644 --- a/windows/RNSVG/Fabric/D2DHelpers.h +++ b/windows/RNSVG/Fabric/D2DHelpers.h @@ -11,7 +11,7 @@ struct D2DHelpers { color.A / 255.0f}; } - static D2D1::Matrix3x2F AsD2DTransform(Numerics::float3x2 const &transform) { + static D2D1::Matrix3x2F AsD2DTransform(winrt::Windows::Foundation::Numerics::float3x2 const &transform) { return D2D1::Matrix3x2F(transform.m11, transform.m12, transform.m21, transform.m22, transform.m31, transform.m32); } }; diff --git a/windows/RNSVG/Fabric/DefsView.cpp b/windows/RNSVG/Fabric/DefsView.cpp index 00e3c6ee3..5785e4b81 100644 --- a/windows/RNSVG/Fabric/DefsView.cpp +++ b/windows/RNSVG/Fabric/DefsView.cpp @@ -14,7 +14,7 @@ struct DefsProps : winrt::implements { +struct DefsView : winrt::implements { public: DefsView() = default; diff --git a/windows/RNSVG/Fabric/EllipseView.cpp b/windows/RNSVG/Fabric/EllipseView.cpp index 8dbebde7e..326f492d8 100644 --- a/windows/RNSVG/Fabric/EllipseView.cpp +++ b/windows/RNSVG/Fabric/EllipseView.cpp @@ -23,7 +23,7 @@ struct EllipseProps : winrt::implements { +struct EllipseView : winrt::implements { public: EllipseView() = default; diff --git a/windows/RNSVG/Fabric/GroupView.cpp b/windows/RNSVG/Fabric/GroupView.cpp index 557be20e0..74e8ff30e 100644 --- a/windows/RNSVG/Fabric/GroupView.cpp +++ b/windows/RNSVG/Fabric/GroupView.cpp @@ -17,7 +17,7 @@ struct SvgGroupProps : winrt::implements { +struct GroupView : winrt::implements { public: GroupView() = default; diff --git a/windows/RNSVG/Fabric/ImageView.cpp b/windows/RNSVG/Fabric/ImageView.cpp index fb4f80daa..e06bdf251 100644 --- a/windows/RNSVG/Fabric/ImageView.cpp +++ b/windows/RNSVG/Fabric/ImageView.cpp @@ -47,7 +47,7 @@ struct ImageProps : winrt::implements meetOrSlice; }; -struct ImageView : winrt::implements { +struct ImageView : winrt::implements { public: ImageView() = default; diff --git a/windows/RNSVG/Fabric/LineView.cpp b/windows/RNSVG/Fabric/LineView.cpp index f2f1456aa..2db1f7184 100644 --- a/windows/RNSVG/Fabric/LineView.cpp +++ b/windows/RNSVG/Fabric/LineView.cpp @@ -23,7 +23,7 @@ struct LineProps : winrt::implements { +struct LineView : winrt::implements { public: LineView() = default; diff --git a/windows/RNSVG/Fabric/LinearGradientView.cpp b/windows/RNSVG/Fabric/LinearGradientView.cpp index 8ee8756eb..bf83c003c 100644 --- a/windows/RNSVG/Fabric/LinearGradientView.cpp +++ b/windows/RNSVG/Fabric/LinearGradientView.cpp @@ -35,7 +35,7 @@ struct LinearGradientProps : winrt::implements> gradientTransform; }; -struct LinearGradientView : winrt::implements { +struct LinearGradientView : winrt::implements { public: LinearGradientView() = default; diff --git a/windows/RNSVG/Fabric/PathView.cpp b/windows/RNSVG/Fabric/PathView.cpp index 28a56e8f9..a7640bfcb 100644 --- a/windows/RNSVG/Fabric/PathView.cpp +++ b/windows/RNSVG/Fabric/PathView.cpp @@ -19,7 +19,7 @@ struct PathProps : winrt::implements { +struct PathView : winrt::implements { public: PathView() = default; diff --git a/windows/RNSVG/Fabric/RadialGradientView.cpp b/windows/RNSVG/Fabric/RadialGradientView.cpp index 89099684d..b8dbd02b7 100644 --- a/windows/RNSVG/Fabric/RadialGradientView.cpp +++ b/windows/RNSVG/Fabric/RadialGradientView.cpp @@ -39,7 +39,7 @@ struct RadialGradientProps : winrt::implements> gradientTransform; }; -struct RadialGradientView : winrt::implements { +struct RadialGradientView : winrt::implements { public: RadialGradientView() = default; diff --git a/windows/RNSVG/Fabric/RectView.cpp b/windows/RNSVG/Fabric/RectView.cpp index eb527fa23..4e2585846 100644 --- a/windows/RNSVG/Fabric/RectView.cpp +++ b/windows/RNSVG/Fabric/RectView.cpp @@ -27,7 +27,7 @@ struct RectProps : winrt::implements { +struct RectView : winrt::implements { public: RectView() = default; diff --git a/windows/RNSVG/Fabric/RenderableView.h b/windows/RNSVG/Fabric/RenderableView.h index e921461ed..788f8385e 100644 --- a/windows/RNSVG/Fabric/RenderableView.h +++ b/windows/RNSVG/Fabric/RenderableView.h @@ -1,11 +1,11 @@ #pragma once -#include +#include "SvgView.h" +#include #include #include "D2DHelpers.h" #include "SvgStrings.h" -#include "SvgView.h" namespace winrt::Microsoft::ReactNative { void WriteValue(IJSValueWriter const &writer, const D2D1_SVG_LENGTH &value) noexcept; diff --git a/windows/RNSVG/Fabric/SvgStrings.h b/windows/RNSVG/Fabric/SvgStrings.h index bb7962428..4f426d661 100644 --- a/windows/RNSVG/Fabric/SvgStrings.h +++ b/windows/RNSVG/Fabric/SvgStrings.h @@ -5,11 +5,8 @@ namespace winrt::RNSVG::SvgStrings { constexpr wchar_t clipPathAttributeName[] = L"clip-path"; constexpr wchar_t clipRuleAttributeName[] = L"clip-rule"; constexpr wchar_t fillRuleAttributeName[] = L"fill-rule"; - constexpr wchar_t EvenOddValue[] = L"evenodd"; - constexpr wchar_t NonZeroValue[] = L"nonzero"; constexpr wchar_t colorAttributeName[] = L"color"; - constexpr wchar_t currentColorAttributeName[] = L"currentColor"; constexpr wchar_t opacityAttributeName[] = L"opacity"; constexpr wchar_t fillOpacityAttributeName[] = L"fill-opacity"; constexpr wchar_t stopOpacityAttributeName[] = L"stop-opacity"; @@ -44,39 +41,17 @@ namespace winrt::RNSVG::SvgStrings { constexpr wchar_t x2AttributeName[] = L"x2"; constexpr wchar_t y2AttributeName[] = L"y2"; - constexpr wchar_t gradientAttributeName[] = L"gradient"; constexpr wchar_t gradientUnitsAttributeName[] = L"gradientUnits"; constexpr wchar_t gradientTransformAttributeName[] = L"gradientTransform"; constexpr wchar_t offsetAttributeName[] = L"offset"; constexpr wchar_t stopColorAttributeName[] = L"stop-color"; constexpr wchar_t stopAttributeName[] = L"stop"; - constexpr wchar_t userSpaceOnUseAttributeName[] = L"userSpaceOnUse"; - constexpr wchar_t objectBoundingBoxAttributeName[] = L"objectBoundingBox"; - constexpr wchar_t hrefAttributeName[] = L"href"; constexpr wchar_t xlinkhrefAttributeName[] = L"xlink:href"; constexpr wchar_t dAttributeName[] = L"d"; - constexpr wchar_t buttAttributeValue[] = L"butt"; - constexpr wchar_t squareAttributeValue[] = L"square"; - constexpr wchar_t roundAttributeValue[] = L"round"; - - constexpr wchar_t bevelAttributeValue[] = L"bevel"; - constexpr wchar_t miterAttributeValue[] = L"miter"; - - constexpr wchar_t sliceAttributeValue[] = L"slice"; - constexpr wchar_t meetAttributeValue[] = L"meet"; constexpr wchar_t noneAttributeValue[] = L"none"; - constexpr wchar_t xMinYMinAttributeValue[] = L"xMinYMin"; - constexpr wchar_t xMidYMinAttributeValue[] = L"xMidYMin"; - constexpr wchar_t xMaxYMinAttributeValue[] = L"xMaxYMin"; - constexpr wchar_t xMinYMidAttributeValue[] = L"xMinYMid"; - constexpr wchar_t xMidYMidAttributeValue[] = L"xMidYMid"; - constexpr wchar_t xMaxYMidAttributeValue[] = L"xMaxYMid"; - constexpr wchar_t xMinYMaxAttributeValue[] = L"xMinYMax"; - constexpr wchar_t xMidYMaxAttributeValue[] = L"xMidYMax"; - constexpr wchar_t xMaxYMaxAttributeValue[] = L"xMaxYMax"; constexpr wchar_t viewBoxAttributeName[] = L"viewBox"; constexpr wchar_t preserveAspectRatioAttributeName[] = L"preserveAspectRatio"; diff --git a/windows/RNSVG/Fabric/SvgView.cpp b/windows/RNSVG/Fabric/SvgView.cpp index f4243da44..71f288b35 100644 --- a/windows/RNSVG/Fabric/SvgView.cpp +++ b/windows/RNSVG/Fabric/SvgView.cpp @@ -2,16 +2,13 @@ #include "SvgView.h" -#include -#include -#include - #include "D2DHelpers.h" #include "GroupView.h" #include #include #include +#include #include @@ -116,28 +113,28 @@ void SvgView::Initialize(const winrt::Microsoft::ReactNative::ComponentView &sen sender.LayoutMetricsChanged( [wkThis = get_weak()]( - const winrt::IInspectable &, const winrt::Microsoft::ReactNative::LayoutMetricsChangedArgs &args) { + const winrt::Windows::Foundation::IInspectable &, const winrt::Microsoft::ReactNative::LayoutMetricsChangedArgs &args) { if (auto strongThis = wkThis.get()) { strongThis->UpdateLayoutMetrics(args.NewLayoutMetrics(), args.OldLayoutMetrics()); } }); view.ThemeChanged( - [wkThis = get_weak()](const winrt::IInspectable & /*sender*/, const winrt::IInspectable & /*args*/) { + [wkThis = get_weak()](const winrt::Windows::Foundation::IInspectable & /*sender*/, const winrt::Windows::Foundation::IInspectable & /*args*/) { if (auto strongThis = wkThis.get()) { strongThis->OnThemeChanged(); } }); view.Mounted([wkThis = get_weak()]( - const winrt::IInspectable & /*sender*/, const winrt::Microsoft::ReactNative::ComponentView &) { + const winrt::Windows::Foundation::IInspectable & /*sender*/, const winrt::Microsoft::ReactNative::ComponentView &) { if (auto strongThis = wkThis.get()) { strongThis->OnMounted(); } }); view.Unmounted([wkThis = get_weak()]( - const winrt::IInspectable & /*sender*/, const winrt::Microsoft::ReactNative::ComponentView &) { + const winrt::Windows::Foundation::IInspectable & /*sender*/, const winrt::Microsoft::ReactNative::ComponentView &) { if (auto strongThis = wkThis.get()) { strongThis->OnUnmounted(); } @@ -223,7 +220,7 @@ void RecurseRenderNode( void SvgView::Draw( const winrt::Microsoft::ReactNative::Composition::ViewComponentView &view, ID2D1DeviceContext &context, - Size const &size) noexcept { + winrt::Windows::Foundation::Size const &size) noexcept { com_ptr deviceContext; deviceContext.copy_from(&context); @@ -304,7 +301,7 @@ winrt::Microsoft::ReactNative::Composition::Theme SvgView::Theme() const noexcep void SvgView::Invalidate() { if (auto view = m_wkView.get()) { - Size size = winrt::Windows::Foundation::Size{m_layoutMetrics.Frame.Width, m_layoutMetrics.Frame.Height}; + auto size = winrt::Windows::Foundation::Size{m_layoutMetrics.Frame.Width, m_layoutMetrics.Frame.Height}; if (!m_isMounted) { return; @@ -324,7 +321,7 @@ void SvgView::Invalidate() { ::Microsoft::ReactNative::Composition::AutoDrawDrawingSurface autoDraw(drawingSurface, 1.0, &offset); if (auto deviceContext = autoDraw.GetRenderTarget()) { auto transform = - Numerics::make_float3x2_translation({static_cast(offset.x), static_cast(offset.y)}); + winrt::Windows::Foundation::Numerics::make_float3x2_translation({static_cast(offset.x), static_cast(offset.y)}); deviceContext->SetTransform(D2DHelpers::AsD2DTransform(transform)); deviceContext->Clear(D2D1::ColorF(D2D1::ColorF::Black, 0.0f)); diff --git a/windows/RNSVG/Fabric/SvgView.h b/windows/RNSVG/Fabric/SvgView.h index f57fd3a30..ef7941585 100644 --- a/windows/RNSVG/Fabric/SvgView.h +++ b/windows/RNSVG/Fabric/SvgView.h @@ -1,8 +1,12 @@ #pragma once +#include + +#include +#include #include +#include #include -#include "NativeModules.h" namespace winrt::RNSVG::implementation { @@ -41,7 +45,7 @@ struct __declspec(uuid("ed381ffa-461a-48Bf-a3c0-5d9a42eecd30")) ISvgView : publi virtual void Invalidate() = 0; }; -struct SvgView : winrt::implements { +struct SvgView : winrt::implements { //struct SvgView : SvgViewT { public: @@ -85,7 +89,7 @@ struct SvgView : winrt::implements { void Draw( const winrt::Microsoft::ReactNative::Composition::ViewComponentView &view, ID2D1DeviceContext &context, - Windows::Foundation::Size const &size) noexcept; + winrt::Windows::Foundation::Size const &size) noexcept; bool m_isMounted{false}; winrt::Microsoft::ReactNative::Composition::Experimental::ISpriteVisual m_visual{nullptr}; diff --git a/windows/RNSVG/Fabric/UnsupportedSvgView.cpp b/windows/RNSVG/Fabric/UnsupportedSvgView.cpp index 0723b667f..53fcbb805 100644 --- a/windows/RNSVG/Fabric/UnsupportedSvgView.cpp +++ b/windows/RNSVG/Fabric/UnsupportedSvgView.cpp @@ -12,7 +12,7 @@ struct UnsupportedProps : public winrt::implements { +struct UnsupportedSvgView : winrt::implements { public: UnsupportedSvgView() = default; diff --git a/windows/RNSVG/Fabric/UseView.cpp b/windows/RNSVG/Fabric/UseView.cpp index 3212df6d1..53725c7ac 100644 --- a/windows/RNSVG/Fabric/UseView.cpp +++ b/windows/RNSVG/Fabric/UseView.cpp @@ -25,7 +25,7 @@ struct UseProps : winrt::implements { +struct UseView : winrt::implements { public: UseView() = default; From e381bc77b5b4e3a6a7e335377077637da13bbcf9 Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Fri, 8 Nov 2024 09:35:00 -0800 Subject: [PATCH 08/13] Remove local testing code from nonNavApp --- apps/common/noNavigationApp.tsx | 259 -------------------------------- 1 file changed, 259 deletions(-) diff --git a/apps/common/noNavigationApp.tsx b/apps/common/noNavigationApp.tsx index acf133074..baa0ed858 100644 --- a/apps/common/noNavigationApp.tsx +++ b/apps/common/noNavigationApp.tsx @@ -38,266 +38,7 @@ const ExampleBlock = ({example, index}: {example: Example; index: number}) => { throw new Error('Unhandled Example type'); }; -import { - Svg, - Defs, - SvgXml, - LinearGradient, - RadialGradient, - Stop, - Rect, - Text as TextS, - G, - Path, - Circle, - Use, -} from 'react-native-svg'; -import {useState, useEffect} from 'react'; - -//const fill = 'purple'; - export default function App() { - /* - const [fill, setFill] = useState('yellow'); - - useEffect(() => { - let mounted = true; - - const timer = setTimeout(() => { - if (mounted) { - setFill('green'); - } - }, 4000); - - return () => { - mounted = false; - clearTimeout(timer); - }; - }, []); - - return ( - - - - - - ); -*/ - /* - return ( - - - - - - - - ); - */ - /* - return ( - - - - ); -*/ - /* - const svgXml = ` - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - `; - -return ( - ); -*/ - /* -return ( - - - - - - - -) -*/ - /* -return ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ); - */ - /* -return ( - -); -*/ - /* - return ( - - ) - */ - /* -return ( - - - -) -*/ - /* - return ( - - - - - - - - - - - - FILL TEXT - - - ); - - */ - /* - return ( - - - - - - - - - - - - - - B - - - - - ) -*/ return ( {Object.values(examples).map((example, index) => { From 872e68c61783d182ad141413eb779701ec88c9a5 Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Fri, 8 Nov 2024 11:52:41 -0800 Subject: [PATCH 09/13] feedback --- windows/RNSVG/Fabric/RenderableView.cpp | 2 ++ windows/RNSVG/Fabric/SvgView.cpp | 14 -------------- windows/RNSVG/Fabric/SvgView.h | 4 ++-- windows/RNSVG/ReactPackageProvider.cpp | 2 ++ 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/windows/RNSVG/Fabric/RenderableView.cpp b/windows/RNSVG/Fabric/RenderableView.cpp index fb6a70ceb..34a6ad655 100644 --- a/windows/RNSVG/Fabric/RenderableView.cpp +++ b/windows/RNSVG/Fabric/RenderableView.cpp @@ -32,6 +32,8 @@ void ReadValue(IJSValueReader const &reader, /*out*/ D2D1_SVG_LENGTH &value) noe auto end{strLength - 2}; auto lastTwo{str.substr(end)}; + // D2D svg rendering does not yet support these additional unit types + // Just using them as number for now. if (lastTwo == "px") { value.units = D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER; } else if (lastTwo == "em") { diff --git a/windows/RNSVG/Fabric/SvgView.cpp b/windows/RNSVG/Fabric/SvgView.cpp index 71f288b35..e574f0128 100644 --- a/windows/RNSVG/Fabric/SvgView.cpp +++ b/windows/RNSVG/Fabric/SvgView.cpp @@ -276,20 +276,6 @@ void SvgView::Draw( } deviceContext5->DrawSvgDocument(spSvgDocument.get()); - - /* - winrt::com_ptr textHighlightBrush; - winrt::check_hresult( - deviceContext5->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::Black, 1.0f), textHighlightBrush.put())); - - const D2D1_RECT_F rect = { - 10, - 10, - 50, - 50}; - - deviceContext5->FillRectangle(rect, textHighlightBrush.get()); - */ } winrt::Microsoft::ReactNative::Composition::Theme SvgView::Theme() const noexcept { diff --git a/windows/RNSVG/Fabric/SvgView.h b/windows/RNSVG/Fabric/SvgView.h index ef7941585..306df97bc 100644 --- a/windows/RNSVG/Fabric/SvgView.h +++ b/windows/RNSVG/Fabric/SvgView.h @@ -63,7 +63,7 @@ struct SvgView : winrt::implements m_wkView; // Do we have the view passed into all the methods that we need this? + winrt::weak_ref m_wkView; D2D1_SVG_ASPECT_ALIGN m_aspectAlign; winrt::com_ptr m_props; diff --git a/windows/RNSVG/ReactPackageProvider.cpp b/windows/RNSVG/ReactPackageProvider.cpp index 8777d1050..36dba15c1 100644 --- a/windows/RNSVG/ReactPackageProvider.cpp +++ b/windows/RNSVG/ReactPackageProvider.cpp @@ -58,6 +58,8 @@ namespace winrt::RNSVG::implementation RegisterRectComponent(fabricPackageBuilder); RegisterCircleComponent(fabricPackageBuilder); RegisterEllipseComponent(fabricPackageBuilder); + RegisterUnsupportedSvgComponent(L"RNSVGFilter", fabricPackageBuilder); + RegisterUnsupportedSvgComponent(L"RNSVGForeignObject", fabricPackageBuilder); RegisterLineComponent(fabricPackageBuilder); RegisterPathComponent(fabricPackageBuilder); RegisterImageComponent(fabricPackageBuilder); From b3bc22f92aece88c757b070ba0b30f71654d6b2e Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Fri, 8 Nov 2024 13:13:54 -0800 Subject: [PATCH 10/13] removing commented out code --- windows/RNSVG/Fabric/SvgView.h | 1 - 1 file changed, 1 deletion(-) diff --git a/windows/RNSVG/Fabric/SvgView.h b/windows/RNSVG/Fabric/SvgView.h index 306df97bc..949ad1c79 100644 --- a/windows/RNSVG/Fabric/SvgView.h +++ b/windows/RNSVG/Fabric/SvgView.h @@ -46,7 +46,6 @@ struct __declspec(uuid("ed381ffa-461a-48Bf-a3c0-5d9a42eecd30")) ISvgView : publi }; struct SvgView : winrt::implements { - //struct SvgView : SvgViewT { public: SvgView(const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext); From 3aa2a9e1e297d9f32a9e3c02f4b02696f84bf28b Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Wed, 13 Nov 2024 09:08:48 -0800 Subject: [PATCH 11/13] Build fix --- windows/RNSVG/Fabric/SvgView.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/windows/RNSVG/Fabric/SvgView.h b/windows/RNSVG/Fabric/SvgView.h index 949ad1c79..374172329 100644 --- a/windows/RNSVG/Fabric/SvgView.h +++ b/windows/RNSVG/Fabric/SvgView.h @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include #include From eb778f335a9ad8fe7b5f5450da5606315e2fcdbf Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Wed, 13 Nov 2024 09:10:26 -0800 Subject: [PATCH 12/13] Add additional unsupported components --- windows/RNSVG/ReactPackageProvider.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/windows/RNSVG/ReactPackageProvider.cpp b/windows/RNSVG/ReactPackageProvider.cpp index 36dba15c1..b8715e5cd 100644 --- a/windows/RNSVG/ReactPackageProvider.cpp +++ b/windows/RNSVG/ReactPackageProvider.cpp @@ -59,6 +59,13 @@ namespace winrt::RNSVG::implementation RegisterCircleComponent(fabricPackageBuilder); RegisterEllipseComponent(fabricPackageBuilder); RegisterUnsupportedSvgComponent(L"RNSVGFilter", fabricPackageBuilder); + RegisterUnsupportedSvgComponent(L"RNSVGFeBlend", fabricPackageBuilder); + RegisterUnsupportedSvgComponent(L"RNSVGFeColorMatrix", fabricPackageBuilder); + RegisterUnsupportedSvgComponent(L"RNSVGFeComposite", fabricPackageBuilder); + RegisterUnsupportedSvgComponent(L"RNSVGFeFlood", fabricPackageBuilder); + RegisterUnsupportedSvgComponent(L"RNSVGFeGaussianBlur", fabricPackageBuilder); + RegisterUnsupportedSvgComponent(L"RNSVGFeMerge", fabricPackageBuilder); + RegisterUnsupportedSvgComponent(L"RNSVGFeOffset", fabricPackageBuilder); RegisterUnsupportedSvgComponent(L"RNSVGForeignObject", fabricPackageBuilder); RegisterLineComponent(fabricPackageBuilder); RegisterPathComponent(fabricPackageBuilder); From 725e6a440460e33b5b56797972a4db84bee1699b Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Wed, 13 Nov 2024 09:55:29 -0800 Subject: [PATCH 13/13] Update to RNW 0.74.24 --- apps/fabric-windows-example/package.json | 2 +- apps/fabric-windows-example/yarn.lock | 28 +++++++------- apps/paper-windows-example/package.json | 2 +- apps/paper-windows-example/yarn.lock | 28 +++++++------- windows/RNSVG/Fabric/CircleView.cpp | 9 ++++- windows/RNSVG/Fabric/ClipPathView.cpp | 5 ++- windows/RNSVG/Fabric/DefsView.cpp | 6 ++- windows/RNSVG/Fabric/EllipseView.cpp | 10 ++++- windows/RNSVG/Fabric/GroupView.cpp | 6 ++- windows/RNSVG/Fabric/ImageView.cpp | 13 ++++++- windows/RNSVG/Fabric/LineView.cpp | 10 ++++- windows/RNSVG/Fabric/LinearGradientView.cpp | 19 ++++++++-- windows/RNSVG/Fabric/PathView.cpp | 7 +++- windows/RNSVG/Fabric/RadialGradientView.cpp | 21 +++++++++-- windows/RNSVG/Fabric/RectView.cpp | 12 +++++- windows/RNSVG/Fabric/RenderableView.cpp | 2 - windows/RNSVG/Fabric/RenderableView.h | 42 ++++++++++++--------- windows/RNSVG/Fabric/SvgView.cpp | 27 ++++++++++--- windows/RNSVG/Fabric/SvgView.h | 5 ++- windows/RNSVG/Fabric/UnsupportedSvgView.cpp | 2 +- windows/RNSVG/Fabric/UseView.cpp | 11 +++++- 21 files changed, 193 insertions(+), 74 deletions(-) diff --git a/apps/fabric-windows-example/package.json b/apps/fabric-windows-example/package.json index 17f0eeee3..5c3487265 100644 --- a/apps/fabric-windows-example/package.json +++ b/apps/fabric-windows-example/package.json @@ -11,7 +11,7 @@ "dependencies": { "react": "18.2.0", "react-native": "0.74.2", - "react-native-windows": "0.74.23", + "react-native-windows": "0.74.24", "react-native-svg": "link:../../" }, "devDependencies": { diff --git a/apps/fabric-windows-example/yarn.lock b/apps/fabric-windows-example/yarn.lock index 561bc40db..51cebf412 100644 --- a/apps/fabric-windows-example/yarn.lock +++ b/apps/fabric-windows-example/yarn.lock @@ -2803,12 +2803,12 @@ prompts "^2.4.2" semver "^7.5.2" -"@react-native-windows/cli@0.74.7": - version "0.74.7" - resolved "https://registry.yarnpkg.com/@react-native-windows/cli/-/cli-0.74.7.tgz#a9d9e75af3aca9a30a5092a2059c097a813b51c1" - integrity sha512-QcMBxMRH9rutS24PvxMuWNB0V5sULNBMFXo62jYnLtU7mHcEW8lB5CsPrVc1JK5kb7pNFlKs9uHrkPMDn52c+g== +"@react-native-windows/cli@0.74.8": + version "0.74.8" + resolved "https://registry.yarnpkg.com/@react-native-windows/cli/-/cli-0.74.8.tgz#747b6d4de9fa5e3e837b643fc1a48600d756d2d2" + integrity sha512-XUqoXiGDlD4BCYcEweujpV3tUYr5pGijX3mNrP1DWzY8gKXVgcmzLs6fng/EK6VsWD7H8bRraYAu9pccGLN4fw== dependencies: - "@react-native-windows/codegen" "0.74.4" + "@react-native-windows/codegen" "0.74.5" "@react-native-windows/fs" "0.74.1" "@react-native-windows/package-utils" "0.74.1" "@react-native-windows/telemetry" "0.74.2" @@ -2830,10 +2830,10 @@ xml-parser "^1.2.1" xpath "^0.0.27" -"@react-native-windows/codegen@0.74.4": - version "0.74.4" - resolved "https://registry.yarnpkg.com/@react-native-windows/codegen/-/codegen-0.74.4.tgz#b191985af9784e4041d76762fe3188f50b1413c7" - integrity sha512-yiUHJweF1VY87x4MrdYfy/sFJpjcog1V5ZsCGqPYBtp7L1F2/aLvqTDoth8c5VK+5JB1lkRF4aJNAmRPQ9xnDg== +"@react-native-windows/codegen@0.74.5": + version "0.74.5" + resolved "https://registry.yarnpkg.com/@react-native-windows/codegen/-/codegen-0.74.5.tgz#a90d6caa0c1664ce25f43457bdb72bf424918f48" + integrity sha512-7v2QBQH7wBBYe+OUlbEsDEEOhsRAM4th55F8r9RtyEvMc+2W79up0se3+xYdBgwjYIPHsDp+g5XwDVjBJC4m7A== dependencies: "@react-native-windows/fs" "0.74.1" chalk "^4.1.0" @@ -7631,17 +7631,17 @@ react-is@^17.0.1: version "0.0.0" uid "" -react-native-windows@0.74.23: - version "0.74.23" - resolved "https://registry.yarnpkg.com/react-native-windows/-/react-native-windows-0.74.23.tgz#50eb9494413e5efdf58045e9e573d2af398c1b25" - integrity sha512-r8YXuLff4fIxL8HNKquV4BYS5VZNWQzIuoRJUgsECSUCYwzd1z0oY0/cxifzNwf5c9XBVHuQZlSDjl3HMbWUgw== +react-native-windows@0.74.24: + version "0.74.24" + resolved "https://registry.yarnpkg.com/react-native-windows/-/react-native-windows-0.74.24.tgz#1dfbf992d377663da0578adf7507934c363c27b2" + integrity sha512-Vdpmpr9JDHdZUQFfr7rPeYNkcAaP0BRR1gLd4hz80pShIOuxuVUKmccN3mtr1S4y8VF+hEnhXdMHRjk64OE4GQ== dependencies: "@babel/runtime" "^7.0.0" "@jest/create-cache-key-function" "^29.6.3" "@react-native-community/cli" "13.6.9" "@react-native-community/cli-platform-android" "13.6.9" "@react-native-community/cli-platform-ios" "13.6.9" - "@react-native-windows/cli" "0.74.7" + "@react-native-windows/cli" "0.74.8" "@react-native/assets" "1.0.0" "@react-native/assets-registry" "0.74.87" "@react-native/codegen" "0.74.87" diff --git a/apps/paper-windows-example/package.json b/apps/paper-windows-example/package.json index e9c1e8ec1..48facc96b 100644 --- a/apps/paper-windows-example/package.json +++ b/apps/paper-windows-example/package.json @@ -15,7 +15,7 @@ "react-dom": "^18.2.0", "react-native": "0.74.2", "react-native-svg": "link:../../", - "react-native-windows": "0.74.23" + "react-native-windows": "0.74.24" }, "devDependencies": { "@babel/core": "^7.20.0", diff --git a/apps/paper-windows-example/yarn.lock b/apps/paper-windows-example/yarn.lock index 403d1fa9d..bbb52fd35 100644 --- a/apps/paper-windows-example/yarn.lock +++ b/apps/paper-windows-example/yarn.lock @@ -1946,12 +1946,12 @@ prompts "^2.4.2" semver "^7.5.2" -"@react-native-windows/cli@0.74.7": - version "0.74.7" - resolved "https://registry.yarnpkg.com/@react-native-windows/cli/-/cli-0.74.7.tgz#a9d9e75af3aca9a30a5092a2059c097a813b51c1" - integrity sha512-QcMBxMRH9rutS24PvxMuWNB0V5sULNBMFXo62jYnLtU7mHcEW8lB5CsPrVc1JK5kb7pNFlKs9uHrkPMDn52c+g== +"@react-native-windows/cli@0.74.8": + version "0.74.8" + resolved "https://registry.yarnpkg.com/@react-native-windows/cli/-/cli-0.74.8.tgz#747b6d4de9fa5e3e837b643fc1a48600d756d2d2" + integrity sha512-XUqoXiGDlD4BCYcEweujpV3tUYr5pGijX3mNrP1DWzY8gKXVgcmzLs6fng/EK6VsWD7H8bRraYAu9pccGLN4fw== dependencies: - "@react-native-windows/codegen" "0.74.4" + "@react-native-windows/codegen" "0.74.5" "@react-native-windows/fs" "0.74.1" "@react-native-windows/package-utils" "0.74.1" "@react-native-windows/telemetry" "0.74.2" @@ -1973,10 +1973,10 @@ xml-parser "^1.2.1" xpath "^0.0.27" -"@react-native-windows/codegen@0.74.4": - version "0.74.4" - resolved "https://registry.yarnpkg.com/@react-native-windows/codegen/-/codegen-0.74.4.tgz#b191985af9784e4041d76762fe3188f50b1413c7" - integrity sha512-yiUHJweF1VY87x4MrdYfy/sFJpjcog1V5ZsCGqPYBtp7L1F2/aLvqTDoth8c5VK+5JB1lkRF4aJNAmRPQ9xnDg== +"@react-native-windows/codegen@0.74.5": + version "0.74.5" + resolved "https://registry.yarnpkg.com/@react-native-windows/codegen/-/codegen-0.74.5.tgz#a90d6caa0c1664ce25f43457bdb72bf424918f48" + integrity sha512-7v2QBQH7wBBYe+OUlbEsDEEOhsRAM4th55F8r9RtyEvMc+2W79up0se3+xYdBgwjYIPHsDp+g5XwDVjBJC4m7A== dependencies: "@react-native-windows/fs" "0.74.1" chalk "^4.1.0" @@ -6852,17 +6852,17 @@ react-is@^17.0.1: version "0.0.0" uid "" -react-native-windows@0.74.23: - version "0.74.23" - resolved "https://registry.yarnpkg.com/react-native-windows/-/react-native-windows-0.74.23.tgz#50eb9494413e5efdf58045e9e573d2af398c1b25" - integrity sha512-r8YXuLff4fIxL8HNKquV4BYS5VZNWQzIuoRJUgsECSUCYwzd1z0oY0/cxifzNwf5c9XBVHuQZlSDjl3HMbWUgw== +react-native-windows@0.74.24: + version "0.74.24" + resolved "https://registry.yarnpkg.com/react-native-windows/-/react-native-windows-0.74.24.tgz#1dfbf992d377663da0578adf7507934c363c27b2" + integrity sha512-Vdpmpr9JDHdZUQFfr7rPeYNkcAaP0BRR1gLd4hz80pShIOuxuVUKmccN3mtr1S4y8VF+hEnhXdMHRjk64OE4GQ== dependencies: "@babel/runtime" "^7.0.0" "@jest/create-cache-key-function" "^29.6.3" "@react-native-community/cli" "13.6.9" "@react-native-community/cli-platform-android" "13.6.9" "@react-native-community/cli-platform-ios" "13.6.9" - "@react-native-windows/cli" "0.74.7" + "@react-native-windows/cli" "0.74.8" "@react-native/assets" "1.0.0" "@react-native/assets-registry" "0.74.87" "@react-native/codegen" "0.74.87" diff --git a/windows/RNSVG/Fabric/CircleView.cpp b/windows/RNSVG/Fabric/CircleView.cpp index 5092253a1..60b007ebe 100644 --- a/windows/RNSVG/Fabric/CircleView.cpp +++ b/windows/RNSVG/Fabric/CircleView.cpp @@ -5,7 +5,14 @@ namespace winrt::RNSVG::implementation { REACT_STRUCT(CircleProps) struct CircleProps : public winrt::implements { - CircleProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT {} + CircleProps(const winrt::Microsoft::ReactNative::ViewProps &props, const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT + { + REACT_BEGIN_SVG_RENDERABLE_COMMON_PROPS_CLONE(CircleProps) + r = cloneFromProps->r; + cx = cloneFromProps->cx; + cy = cloneFromProps->cy; + REACT_END_SVG_RENDERABLE_COMMON_PROPS_CLONE + } void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); diff --git a/windows/RNSVG/Fabric/ClipPathView.cpp b/windows/RNSVG/Fabric/ClipPathView.cpp index 63a77e733..25ea3e6ab 100644 --- a/windows/RNSVG/Fabric/ClipPathView.cpp +++ b/windows/RNSVG/Fabric/ClipPathView.cpp @@ -5,7 +5,10 @@ namespace winrt::RNSVG::implementation { REACT_STRUCT(ClipPathProps) struct ClipPathProps : winrt::implements { - ClipPathProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT {} + ClipPathProps(const winrt::Microsoft::ReactNative::ViewProps &props, const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT { + REACT_BEGIN_SVG_RENDERABLE_COMMON_PROPS_CLONE(ClipPathProps) + REACT_END_SVG_RENDERABLE_COMMON_PROPS_CLONE + } void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); diff --git a/windows/RNSVG/Fabric/DefsView.cpp b/windows/RNSVG/Fabric/DefsView.cpp index 5785e4b81..a41e75fe2 100644 --- a/windows/RNSVG/Fabric/DefsView.cpp +++ b/windows/RNSVG/Fabric/DefsView.cpp @@ -5,7 +5,11 @@ namespace winrt::RNSVG::implementation { REACT_STRUCT(DefsProps) struct DefsProps : winrt::implements { - DefsProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT {} + DefsProps(const winrt::Microsoft::ReactNative::ViewProps &props, const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT + { + REACT_BEGIN_SVG_RENDERABLE_COMMON_PROPS_CLONE(DefsProps) + REACT_END_SVG_RENDERABLE_COMMON_PROPS_CLONE + } void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); diff --git a/windows/RNSVG/Fabric/EllipseView.cpp b/windows/RNSVG/Fabric/EllipseView.cpp index 326f492d8..612520c69 100644 --- a/windows/RNSVG/Fabric/EllipseView.cpp +++ b/windows/RNSVG/Fabric/EllipseView.cpp @@ -5,7 +5,15 @@ namespace winrt::RNSVG::implementation { REACT_STRUCT(EllipseProps) struct EllipseProps : winrt::implements { - EllipseProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT {} + EllipseProps(const winrt::Microsoft::ReactNative::ViewProps &props, const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT + { + REACT_BEGIN_SVG_RENDERABLE_COMMON_PROPS_CLONE(EllipseProps) + cx = cloneFromProps->cx; + cy = cloneFromProps->cy; + rx = cloneFromProps->rx; + ry = cloneFromProps->ry; + REACT_END_SVG_RENDERABLE_COMMON_PROPS_CLONE + } void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); diff --git a/windows/RNSVG/Fabric/GroupView.cpp b/windows/RNSVG/Fabric/GroupView.cpp index 74e8ff30e..da595810a 100644 --- a/windows/RNSVG/Fabric/GroupView.cpp +++ b/windows/RNSVG/Fabric/GroupView.cpp @@ -8,7 +8,11 @@ namespace winrt::RNSVG::implementation { REACT_STRUCT(SvgGroupProps) struct SvgGroupProps : winrt::implements { - SvgGroupProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT {} + SvgGroupProps(const winrt::Microsoft::ReactNative::ViewProps &props, const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT + { + REACT_BEGIN_SVG_RENDERABLE_COMMON_PROPS_CLONE(SvgGroupProps) + REACT_END_SVG_RENDERABLE_COMMON_PROPS_CLONE + } void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); diff --git a/windows/RNSVG/Fabric/ImageView.cpp b/windows/RNSVG/Fabric/ImageView.cpp index e06bdf251..0d8279d1d 100644 --- a/windows/RNSVG/Fabric/ImageView.cpp +++ b/windows/RNSVG/Fabric/ImageView.cpp @@ -23,7 +23,18 @@ struct ImageSource { REACT_STRUCT(ImageProps) struct ImageProps : winrt::implements { - ImageProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT {} + ImageProps(const winrt::Microsoft::ReactNative::ViewProps &props, const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT + { + REACT_BEGIN_SVG_RENDERABLE_COMMON_PROPS_CLONE(ImageProps) + x = cloneFromProps->x; + y = cloneFromProps->y; + width = cloneFromProps->width; + height = cloneFromProps->height; + src = cloneFromProps->src; + align = cloneFromProps->align; + meetOrSlice = cloneFromProps->meetOrSlice; + REACT_END_SVG_RENDERABLE_COMMON_PROPS_CLONE + } void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); diff --git a/windows/RNSVG/Fabric/LineView.cpp b/windows/RNSVG/Fabric/LineView.cpp index 2db1f7184..542a623cf 100644 --- a/windows/RNSVG/Fabric/LineView.cpp +++ b/windows/RNSVG/Fabric/LineView.cpp @@ -5,7 +5,15 @@ namespace winrt::RNSVG::implementation { REACT_STRUCT(LineProps) struct LineProps : winrt::implements { - LineProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT {} + LineProps(const winrt::Microsoft::ReactNative::ViewProps &props, const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT + { + REACT_BEGIN_SVG_RENDERABLE_COMMON_PROPS_CLONE(LineProps) + x1 = cloneFromProps->x1; + y1 = cloneFromProps->y1; + x2 = cloneFromProps->x2; + y2 = cloneFromProps->y2; + REACT_END_SVG_RENDERABLE_COMMON_PROPS_CLONE + } void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); diff --git a/windows/RNSVG/Fabric/LinearGradientView.cpp b/windows/RNSVG/Fabric/LinearGradientView.cpp index bf83c003c..6b0c62186 100644 --- a/windows/RNSVG/Fabric/LinearGradientView.cpp +++ b/windows/RNSVG/Fabric/LinearGradientView.cpp @@ -11,7 +11,18 @@ struct SvgLinearGradientStop { REACT_STRUCT(LinearGradientProps) struct LinearGradientProps : winrt::implements { - LinearGradientProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT {} + LinearGradientProps(const winrt::Microsoft::ReactNative::ViewProps &props, const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT + { + REACT_BEGIN_SVG_RENDERABLE_COMMON_PROPS_CLONE(LinearGradientProps) + x1 = cloneFromProps->x1; + y1 = cloneFromProps->y1; + x2 = cloneFromProps->x2; + y2 = cloneFromProps->y2; + gradient = cloneFromProps->gradient; + gradientUnits = cloneFromProps->gradientUnits; + gradientTransform = cloneFromProps->gradientTransform; + REACT_END_SVG_RENDERABLE_COMMON_PROPS_CLONE + } void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); @@ -28,7 +39,7 @@ struct LinearGradientProps : winrt::implements y2; REACT_FIELD(gradient) - std::optional> gradient{}; + std::optional> gradient{}; REACT_FIELD(gradientUnits) std::optional gradientUnits; REACT_FIELD(gradientTransform) @@ -51,9 +62,9 @@ struct LinearGradientView : winrt::implementsgradient->end()) { SvgLinearGradientStop stop; - stop.offset = it->AsSingle(); + stop.offset = *it; ++it; - auto clr = it->AsUInt32(); + auto clr = static_cast(*it); stop.color = D2D1_COLOR_F{ ((clr & 0x00FF0000) >> 16) / 255.0f, ((clr & 0x0000FF00) >> 8) / 255.0f, diff --git a/windows/RNSVG/Fabric/PathView.cpp b/windows/RNSVG/Fabric/PathView.cpp index a7640bfcb..fd2e8bc32 100644 --- a/windows/RNSVG/Fabric/PathView.cpp +++ b/windows/RNSVG/Fabric/PathView.cpp @@ -7,7 +7,12 @@ namespace winrt::RNSVG::implementation { REACT_STRUCT(PathProps) struct PathProps : winrt::implements { - PathProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT {} + PathProps(const winrt::Microsoft::ReactNative::ViewProps &props, const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT + { + REACT_BEGIN_SVG_RENDERABLE_COMMON_PROPS_CLONE(PathProps) + d = cloneFromProps->d; + REACT_END_SVG_RENDERABLE_COMMON_PROPS_CLONE + } void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); diff --git a/windows/RNSVG/Fabric/RadialGradientView.cpp b/windows/RNSVG/Fabric/RadialGradientView.cpp index b8dbd02b7..10ae9b1b1 100644 --- a/windows/RNSVG/Fabric/RadialGradientView.cpp +++ b/windows/RNSVG/Fabric/RadialGradientView.cpp @@ -11,7 +11,20 @@ struct SvgRadialGradientStop { REACT_STRUCT(RadialGradientProps) struct RadialGradientProps : winrt::implements { - RadialGradientProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT {} + RadialGradientProps(const winrt::Microsoft::ReactNative::ViewProps &props, const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT + { + REACT_BEGIN_SVG_RENDERABLE_COMMON_PROPS_CLONE(RadialGradientProps) + fx = cloneFromProps->fx; + fy = cloneFromProps->fy; + cx = cloneFromProps->cx; + cy = cloneFromProps->cy; + rx = cloneFromProps->rx; + ry = cloneFromProps->ry; + gradient = cloneFromProps->gradient; + gradientUnits = cloneFromProps->gradientUnits; + gradientTransform = cloneFromProps->gradientTransform; + REACT_END_SVG_RENDERABLE_COMMON_PROPS_CLONE + } void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); @@ -32,7 +45,7 @@ struct RadialGradientProps : winrt::implements ry; REACT_FIELD(gradient) - std::optional> gradient{}; + std::optional> gradient{}; REACT_FIELD(gradientUnits) std::optional gradientUnits; REACT_FIELD(gradientTransform) @@ -55,9 +68,9 @@ struct RadialGradientView : winrt::implementsgradient->end()) { SvgRadialGradientStop stop; - stop.offset = it->AsSingle(); + stop.offset = *it; ++it; - auto clr = it->AsUInt32(); + auto clr = static_cast(*it); stop.color = D2D1_COLOR_F{ ((clr & 0x00FF0000) >> 16) / 255.0f, ((clr & 0x0000FF00) >> 8) / 255.0f, diff --git a/windows/RNSVG/Fabric/RectView.cpp b/windows/RNSVG/Fabric/RectView.cpp index 4e2585846..8972129e4 100644 --- a/windows/RNSVG/Fabric/RectView.cpp +++ b/windows/RNSVG/Fabric/RectView.cpp @@ -5,7 +5,17 @@ namespace winrt::RNSVG::implementation { REACT_STRUCT(RectProps) struct RectProps : winrt::implements { - RectProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT {} + RectProps(const winrt::Microsoft::ReactNative::ViewProps &props, const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT + { + REACT_BEGIN_SVG_RENDERABLE_COMMON_PROPS_CLONE(RectProps) + x = cloneFromProps->x; + y = cloneFromProps->y; + height = cloneFromProps->height; + width = cloneFromProps->width; + rx = cloneFromProps->rx; + ry = cloneFromProps->ry; + REACT_END_SVG_RENDERABLE_COMMON_PROPS_CLONE + } void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); diff --git a/windows/RNSVG/Fabric/RenderableView.cpp b/windows/RNSVG/Fabric/RenderableView.cpp index 34a6ad655..fb6a70ceb 100644 --- a/windows/RNSVG/Fabric/RenderableView.cpp +++ b/windows/RNSVG/Fabric/RenderableView.cpp @@ -32,8 +32,6 @@ void ReadValue(IJSValueReader const &reader, /*out*/ D2D1_SVG_LENGTH &value) noe auto end{strLength - 2}; auto lastTwo{str.substr(end)}; - // D2D svg rendering does not yet support these additional unit types - // Just using them as number for now. if (lastTwo == "px") { value.units = D2D1_SVG_LENGTH_UNITS::D2D1_SVG_LENGTH_UNITS_NUMBER; } else if (lastTwo == "em") { diff --git a/windows/RNSVG/Fabric/RenderableView.h b/windows/RNSVG/Fabric/RenderableView.h index 788f8385e..f48326cef 100644 --- a/windows/RNSVG/Fabric/RenderableView.h +++ b/windows/RNSVG/Fabric/RenderableView.h @@ -57,24 +57,10 @@ HRESULT SetColorMode( std::optional opacity; \ REACT_FIELD(matrix) \ std::optional> matrix; \ - REACT_FIELD(mask) \ - std::optional mask; \ - REACT_FIELD(markerStart) \ - std::optional markerStart; \ - REACT_FIELD(markerMid) \ - std::optional markerMid; \ - REACT_FIELD(markerEnd) \ - std::optional markerEnd; \ REACT_FIELD(clipPath) \ std::optional clipPath; \ REACT_FIELD(clipRule) \ std::optional clipRule; \ - REACT_FIELD(responsible) \ - std::optional responsible; \ - REACT_FIELD(display) \ - std::optional display; \ - REACT_FIELD(pointerEvents) \ - std::optional pointerEvents; \ REACT_FIELD(fill) \ std::optional fill; \ REACT_FIELD(fillOpacity) \ @@ -97,8 +83,6 @@ HRESULT SetColorMode( std::optional strokeDashoffset; \ REACT_FIELD(strokeMiterlimit) \ std::optional strokeMiterlimit; \ - REACT_FIELD(vectorEffect) \ - std::optional vectorEffect; \ REACT_FIELD(propList) \ std::optional> propList; \ std::optional color; \ @@ -107,6 +91,30 @@ HRESULT SetColorMode( #define REACT_SVG_RENDERABLE_COMMON_PROPS_INIT \ : m_props(props) +#define REACT_BEGIN_SVG_RENDERABLE_COMMON_PROPS_CLONE(TProps) \ + if (cloneFrom) { \ + auto cloneFromProps = cloneFrom.as(); \ + name = cloneFromProps->name; \ + opacity = cloneFromProps->opacity; \ + matrix = cloneFromProps->matrix; \ + clipPath = cloneFromProps->clipPath; \ + clipRule = cloneFromProps->clipRule; \ + fill = cloneFromProps->fill; \ + fillOpacity = cloneFromProps->fillOpacity; \ + fillRule = cloneFromProps->fillRule; \ + stroke = cloneFromProps->stroke; \ + strokeOpacity = cloneFromProps->strokeOpacity; \ + strokeWidth = cloneFromProps->strokeWidth; \ + strokeLinecap = cloneFromProps->strokeLinecap; \ + strokeLinejoin = cloneFromProps->strokeLinejoin; \ + strokeDasharray = cloneFromProps->strokeDasharray; \ + strokeMiterlimit = cloneFromProps->strokeMiterlimit; \ + propList = cloneFromProps->propList; \ + color = cloneFromProps->color; + +#define REACT_END_SVG_RENDERABLE_COMMON_PROPS_CLONE \ + } + struct __declspec(uuid("a03986c0-b06e-4fb8-a86e-16fcc47b2f31")) RenderableView : public ::IUnknown { public: RenderableView() = default; @@ -266,7 +274,7 @@ void RegisterRenderableComponent( view.UserData(*userData); }); builder.SetCreateProps( - [](winrt::Microsoft::ReactNative::ViewProps props) noexcept { return winrt::make(props); }); + [](winrt::Microsoft::ReactNative::ViewProps props, const winrt::Microsoft::ReactNative::IComponentProps &cloneFrom) noexcept { return winrt::make(props, cloneFrom); }); builder.SetUpdatePropsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view, const winrt::Microsoft::ReactNative::IComponentProps &newProps, const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept { diff --git a/windows/RNSVG/Fabric/SvgView.cpp b/windows/RNSVG/Fabric/SvgView.cpp index e574f0128..2877093fc 100644 --- a/windows/RNSVG/Fabric/SvgView.cpp +++ b/windows/RNSVG/Fabric/SvgView.cpp @@ -14,7 +14,20 @@ namespace winrt::RNSVG::implementation { -SvgViewProps::SvgViewProps(const winrt::Microsoft::ReactNative::ViewProps &props) : m_props(props) {} +SvgViewProps::SvgViewProps(const winrt::Microsoft::ReactNative::ViewProps& props, const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom) + : m_props(props) +{ + if (cloneFrom) { + auto cloneFromProps = cloneFrom.as(); + minX = cloneFromProps->minX; + minY = cloneFromProps->minY; + vbWidth = cloneFromProps->vbWidth; + vbHeight = cloneFromProps->vbHeight; + align = cloneFromProps->align; + meetOrSlice = cloneFromProps->meetOrSlice; + color = cloneFromProps->color; + } +} void SvgViewProps::SetProp( uint32_t hash, @@ -144,8 +157,10 @@ void SvgView::Initialize(const winrt::Microsoft::ReactNative::ComponentView &sen void SvgView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPackageBuilderFabric &builder) noexcept { builder.AddViewComponent( L"RNSVGSvgView", [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { - builder.SetCreateProps( - [](winrt::Microsoft::ReactNative::ViewProps props) noexcept { return winrt::make(props); }); + builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props, + const winrt::Microsoft::ReactNative::IComponentProps &cloneFrom) noexcept { + return winrt::make(props, cloneFrom); + }); auto compBuilder = builder.as(); @@ -158,6 +173,10 @@ void SvgView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPacka view.UserData(*userData); }); + compBuilder.SetViewFeatures( + winrt::Microsoft::ReactNative::Composition::ComponentViewFeatures::Default & + ~winrt::Microsoft::ReactNative::Composition::ComponentViewFeatures::Background); + builder.SetUpdatePropsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view, const winrt::Microsoft::ReactNative::IComponentProps &newProps, const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept { @@ -186,8 +205,6 @@ void SvgView::RegisterComponent(const winrt::Microsoft::ReactNative::IReactPacka return userData->UnmountChildComponentView(view, args); }); }); - - // TODO how to remove featureflag Background? } void SvgView::UpdateLayoutMetrics( diff --git a/windows/RNSVG/Fabric/SvgView.h b/windows/RNSVG/Fabric/SvgView.h index 374172329..f9ba7c651 100644 --- a/windows/RNSVG/Fabric/SvgView.h +++ b/windows/RNSVG/Fabric/SvgView.h @@ -4,9 +4,12 @@ #include #include +#pragma push_macro("X86") +#undef X86 #include #include #include +#pragma pop_macro("X86") namespace winrt::RNSVG::implementation { @@ -19,7 +22,7 @@ enum class MeetOrSlice { REACT_STRUCT(SvgViewProps) struct SvgViewProps : winrt::implements { - SvgViewProps(const winrt::Microsoft::ReactNative::ViewProps &props); + SvgViewProps(const winrt::Microsoft::ReactNative::ViewProps &props, const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom); void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept; diff --git a/windows/RNSVG/Fabric/UnsupportedSvgView.cpp b/windows/RNSVG/Fabric/UnsupportedSvgView.cpp index 53fcbb805..7f62c8e23 100644 --- a/windows/RNSVG/Fabric/UnsupportedSvgView.cpp +++ b/windows/RNSVG/Fabric/UnsupportedSvgView.cpp @@ -5,7 +5,7 @@ namespace winrt::RNSVG::implementation { REACT_STRUCT(UnsupportedProps) struct UnsupportedProps : public winrt::implements { - UnsupportedProps(const winrt::Microsoft::ReactNative::ViewProps &/*props*/) {} + UnsupportedProps(const winrt::Microsoft::ReactNative::ViewProps &/*props*/, const winrt::Microsoft::ReactNative::IComponentProps& /*cloneFrom*/) {} void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); diff --git a/windows/RNSVG/Fabric/UseView.cpp b/windows/RNSVG/Fabric/UseView.cpp index 53725c7ac..696bf39e5 100644 --- a/windows/RNSVG/Fabric/UseView.cpp +++ b/windows/RNSVG/Fabric/UseView.cpp @@ -5,7 +5,16 @@ namespace winrt::RNSVG::implementation { REACT_STRUCT(UseProps) struct UseProps : winrt::implements { - UseProps(const winrt::Microsoft::ReactNative::ViewProps &props) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT {} + UseProps(const winrt::Microsoft::ReactNative::ViewProps &props, const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom) REACT_SVG_RENDERABLE_COMMON_PROPS_INIT + { + REACT_BEGIN_SVG_RENDERABLE_COMMON_PROPS_CLONE(UseProps) + href = cloneFromProps->href; + x = cloneFromProps->x; + y = cloneFromProps->y; + width = cloneFromProps->width; + height = cloneFromProps->height; + REACT_END_SVG_RENDERABLE_COMMON_PROPS_CLONE + } void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this);