react-native-windows 0.74.0-preview.2 → 0.74.0-preview.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/Libraries/Core/ReactNativeVersion.js +1 -1
  2. package/Libraries/Image/AssetSourceResolver.windows.js +186 -0
  3. package/Libraries/Image/assetPaths.js +36 -0
  4. package/Microsoft.ReactNative/CompositionComponentView.idl +18 -3
  5. package/Microsoft.ReactNative/CompositionContext.idl +5 -5
  6. package/Microsoft.ReactNative/CompositionRootView.idl +22 -8
  7. package/Microsoft.ReactNative/CompositionSwitcher.idl +2 -2
  8. package/Microsoft.ReactNative/CompositionUIService.idl +8 -6
  9. package/Microsoft.ReactNative/Fabric/AbiViewProps.cpp +8 -1
  10. package/Microsoft.ReactNative/Fabric/AbiViewProps.h +7 -2
  11. package/Microsoft.ReactNative/Fabric/Composition/ActivityIndicatorComponentView.cpp +4 -3
  12. package/Microsoft.ReactNative/Fabric/Composition/ActivityIndicatorComponentView.h +5 -5
  13. package/Microsoft.ReactNative/Fabric/Composition/ComponentViewRegistry.cpp +1 -1
  14. package/Microsoft.ReactNative/Fabric/Composition/ComponentViewRegistry.h +2 -1
  15. package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp +173 -152
  16. package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.h +8 -8
  17. package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper_emptyimpl.cpp +13 -13
  18. package/Microsoft.ReactNative/Fabric/Composition/CompositionHelpers.h +1 -1
  19. package/Microsoft.ReactNative/Fabric/Composition/CompositionHwndHost.cpp +14 -11
  20. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView.cpp +24 -11
  21. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView.h +15 -10
  22. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView_emptyimpl.cpp +15 -4
  23. package/Microsoft.ReactNative/Fabric/Composition/CompositionUIService.cpp +20 -9
  24. package/Microsoft.ReactNative/Fabric/Composition/CompositionUIService.h +6 -4
  25. package/Microsoft.ReactNative/Fabric/Composition/CompositionUIService_emptyimpl.cpp +5 -2
  26. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +104 -54
  27. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +25 -19
  28. package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.cpp +2 -2
  29. package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.h +2 -2
  30. package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp +9 -8
  31. package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.h +5 -5
  32. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +7 -5
  33. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.h +5 -5
  34. package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +4 -4
  35. package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.h +5 -5
  36. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.cpp +1 -1
  37. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +5 -2
  38. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +2 -2
  39. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.h +2 -2
  40. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +34 -27
  41. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.h +6 -6
  42. package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.cpp +9 -9
  43. package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.h +6 -6
  44. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +5 -4
  45. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +6 -6
  46. package/Microsoft.ReactNative/Fabric/Composition/Theme.cpp +13 -3
  47. package/Microsoft.ReactNative/Fabric/Composition/Theme.h +16 -8
  48. package/Microsoft.ReactNative/Fabric/Composition/Theme_emptyimpl.cpp +3 -3
  49. package/Microsoft.ReactNative/Fabric/Composition/UnimplementedNativeViewComponentView.cpp +3 -3
  50. package/Microsoft.ReactNative/Fabric/Composition/UnimplementedNativeViewComponentView.h +3 -3
  51. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.h +1 -1
  52. package/Microsoft.ReactNative/Fabric/IComponentViewRegistry.h +1 -1
  53. package/Microsoft.ReactNative/Modules/Animated/NativeAnimatedNodeManager.cpp +2 -1
  54. package/Microsoft.ReactNative/Modules/Animated/PropsAnimatedNode.cpp +7 -5
  55. package/Microsoft.ReactNative/Theme.idl +12 -1
  56. package/Microsoft.ReactNative/ViewProps.idl +11 -1
  57. package/Microsoft.ReactNative/packages.lock.json +70 -42
  58. package/Microsoft.ReactNative.Cxx/AutoDraw.h +3 -3
  59. package/Microsoft.ReactNative.Cxx/{CompositionSwitcher.interop.h → CompositionSwitcher.Experimental.interop.h} +2 -2
  60. package/Microsoft.ReactNative.Cxx/DesktopWindowBridge.h +2 -0
  61. package/Microsoft.ReactNative.Managed/Microsoft.ReactNative.Managed.csproj +2 -11
  62. package/PropertySheets/External/Microsoft.ReactNative.Composition.CppApp.props +1 -1
  63. package/PropertySheets/External/Microsoft.ReactNative.WindowsSdk.Default.props +5 -3
  64. package/PropertySheets/Generated/PackageVersion.g.props +2 -2
  65. package/package.json +11 -11
  66. package/templates/cpp-app/windows/MyApp/MyApp.cpp +2 -7
@@ -17,7 +17,7 @@ const version: $ReadOnly<{
17
17
  major: 0,
18
18
  minor: 74,
19
19
  patch: 0,
20
- prerelease: 'rc.6',
20
+ prerelease: 'rc.9',
21
21
  };
22
22
 
23
23
  module.exports = {version};
@@ -0,0 +1,186 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ export type ResolvedAssetSource = {|
14
+ +__packager_asset: boolean,
15
+ +width: ?number,
16
+ +height: ?number,
17
+ +uri: string,
18
+ +scale: number,
19
+ |};
20
+
21
+ import type {PackagerAsset} from '@react-native/assets-registry/registry';
22
+
23
+ const PixelRatio = require('../Utilities/PixelRatio').default;
24
+ const Platform = require('../Utilities/Platform');
25
+ const {pickScale} = require('./AssetUtils');
26
+ const {
27
+ getAndroidResourceFolderName,
28
+ getAndroidResourceIdentifier,
29
+ } = require('@react-native/assets-registry/path-support');
30
+ const invariant = require('invariant');
31
+ // $FlowFixMe[untyped-import]
32
+ const ensureShortPath = require('./assetPaths.js'); // [Windows]
33
+
34
+ // [Windows - instead of using basePath from @react-native/assets-registry/path-support]
35
+ function getBasePath(asset: PackagerAsset, local: boolean) {
36
+ let basePath = asset.httpServerLocation;
37
+ if (basePath[0] === '/') {
38
+ basePath = basePath.substr(1);
39
+ }
40
+
41
+ if (local) {
42
+ const safePath = basePath.replace(/\.\.\//g, '_');
43
+ // If this asset was created with saveAssetPlugin, then we should shorten the path
44
+ // This conditional allow compat of bundles which might have been created without the saveAssetPlugin
45
+ // $FlowFixMe: __useShortPath not part of public type
46
+ if (asset.__useShortPath) {
47
+ return ensureShortPath(safePath);
48
+ }
49
+ return safePath;
50
+ }
51
+
52
+ return basePath;
53
+ }
54
+
55
+ /**
56
+ * Returns a path like 'assets/AwesomeModule/icon@2x.png'
57
+ */
58
+ function getScaledAssetPath(asset: PackagerAsset, local: boolean): string {
59
+ const scale = pickScale(asset.scales, PixelRatio.get());
60
+ const scaleSuffix = scale === 1 ? '' : '@' + scale + 'x';
61
+ const assetDir = getBasePath(asset, local);
62
+ return assetDir + '/' + asset.name + scaleSuffix + '.' + asset.type;
63
+ }
64
+
65
+ /**
66
+ * Returns a path like 'drawable-mdpi/icon.png'
67
+ */
68
+ function getAssetPathInDrawableFolder(asset: PackagerAsset): string {
69
+ const scale = pickScale(asset.scales, PixelRatio.get());
70
+ const drawableFolder = getAndroidResourceFolderName(asset, scale);
71
+ const fileName = getAndroidResourceIdentifier(asset);
72
+ return drawableFolder + '/' + fileName + '.' + asset.type;
73
+ }
74
+
75
+ class AssetSourceResolver {
76
+ serverUrl: ?string;
77
+ // where the jsbundle is being run from
78
+ jsbundleUrl: ?string;
79
+ // the asset to resolve
80
+ asset: PackagerAsset;
81
+
82
+ constructor(serverUrl: ?string, jsbundleUrl: ?string, asset: PackagerAsset) {
83
+ this.serverUrl = serverUrl;
84
+ this.jsbundleUrl = jsbundleUrl;
85
+ this.asset = asset;
86
+ }
87
+
88
+ isLoadedFromServer(): boolean {
89
+ return !!this.serverUrl;
90
+ }
91
+
92
+ isLoadedFromFileSystem(): boolean {
93
+ return this.jsbundleUrl != null && this.jsbundleUrl?.startsWith('file://');
94
+ }
95
+
96
+ defaultAsset(): ResolvedAssetSource {
97
+ if (this.isLoadedFromServer()) {
98
+ return this.assetServerURL();
99
+ }
100
+
101
+ if (Platform.OS === 'android') {
102
+ return this.isLoadedFromFileSystem()
103
+ ? this.drawableFolderInBundle()
104
+ : this.resourceIdentifierWithoutScale();
105
+ } else {
106
+ return this.scaledAssetURLNearBundle();
107
+ }
108
+ }
109
+
110
+ /**
111
+ * Returns an absolute URL which can be used to fetch the asset
112
+ * from the devserver
113
+ */
114
+ assetServerURL(): ResolvedAssetSource {
115
+ invariant(this.serverUrl != null, 'need server to load from');
116
+ return this.fromSource(
117
+ this.serverUrl +
118
+ getScaledAssetPath(this.asset, false) +
119
+ '?platform=' +
120
+ Platform.OS +
121
+ '&hash=' +
122
+ this.asset.hash,
123
+ );
124
+ }
125
+
126
+ /**
127
+ * Resolves to just the scaled asset filename
128
+ * E.g. 'assets/AwesomeModule/icon@2x.png'
129
+ */
130
+ scaledAssetPath(local: boolean): ResolvedAssetSource {
131
+ return this.fromSource(getScaledAssetPath(this.asset, local));
132
+ }
133
+
134
+ /**
135
+ * Resolves to where the bundle is running from, with a scaled asset filename
136
+ * E.g. 'file:///sdcard/bundle/assets/AwesomeModule/icon@2x.png'
137
+ */
138
+ scaledAssetURLNearBundle(): ResolvedAssetSource {
139
+ const path = this.jsbundleUrl ?? 'file://';
140
+ return this.fromSource(
141
+ // Assets can have relative paths outside of the project root.
142
+ // When bundling them we replace `../` with `_` to make sure they
143
+ // don't end up outside of the expected assets directory.
144
+ path + getScaledAssetPath(this.asset, true).replace(/\.\.\//g, '_'),
145
+ );
146
+ }
147
+
148
+ /**
149
+ * The default location of assets bundled with the app, located by
150
+ * resource identifier
151
+ * The Android resource system picks the correct scale.
152
+ * E.g. 'assets_awesomemodule_icon'
153
+ */
154
+ resourceIdentifierWithoutScale(): ResolvedAssetSource {
155
+ invariant(
156
+ Platform.OS === 'android',
157
+ 'resource identifiers work on Android',
158
+ );
159
+ return this.fromSource(getAndroidResourceIdentifier(this.asset));
160
+ }
161
+
162
+ /**
163
+ * If the jsbundle is running from a sideload location, this resolves assets
164
+ * relative to its location
165
+ * E.g. 'file:///sdcard/AwesomeModule/drawable-mdpi/icon.png'
166
+ */
167
+ drawableFolderInBundle(): ResolvedAssetSource {
168
+ const path = this.jsbundleUrl ?? 'file://';
169
+ return this.fromSource(path + getAssetPathInDrawableFolder(this.asset));
170
+ }
171
+
172
+ fromSource(source: string): ResolvedAssetSource {
173
+ return {
174
+ __packager_asset: true,
175
+ width: this.asset.width,
176
+ height: this.asset.height,
177
+ uri: source,
178
+ scale: pickScale(this.asset.scales, PixelRatio.get()),
179
+ };
180
+ }
181
+
182
+ static pickScale: (scales: Array<number>, deviceScale?: number) => number =
183
+ pickScale;
184
+ }
185
+
186
+ module.exports = AssetSourceResolver;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ *
5
+ * Dont use flow here, since this file is used by saveAssetPlugin.js which will run without flow transform
6
+ * @format
7
+ */
8
+
9
+ 'use strict';
10
+
11
+ // Some windows machines may not have long paths enabled
12
+ // https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation
13
+ // Assets in nested node_modules (common when using pnpm) - end up creating very long paths
14
+ // Using this function we shorten longer paths to prevent paths from hitting the path limit
15
+ function ensureShortPath(str) {
16
+ if (str.length < 40) return str;
17
+
18
+ const assetsPrefix = 'assets/';
19
+
20
+ if (!str.startsWith(assetsPrefix)) {
21
+ console.warn(`Unexpected asset uri - ${str} may not load correctly.`);
22
+ }
23
+
24
+ const postStr = str.slice(assetsPrefix.length);
25
+ var hash = 0,
26
+ i,
27
+ chr;
28
+ for (i = 0; i < postStr.length; i++) {
29
+ chr = postStr.charCodeAt(i);
30
+ hash = (hash << 5) - hash + chr;
31
+ hash |= 0; // Convert to 32bit integer
32
+ }
33
+ return assetsPrefix + hash.toString();
34
+ }
35
+
36
+ module.exports = ensureShortPath;
@@ -6,6 +6,7 @@ import "Theme.idl";
6
6
  import "ViewProps.idl";
7
7
  import "Composition.Input.idl";
8
8
  import "CompositionSwitcher.idl";
9
+ import "IReactContext.idl";
9
10
 
10
11
  #include "DocString.h"
11
12
 
@@ -28,7 +29,7 @@ namespace Microsoft.ReactNative.Composition
28
29
  [experimental]
29
30
  [webhosthidden]
30
31
  runtimeclass CreateCompositionComponentViewArgs : Microsoft.ReactNative.CreateComponentViewArgs {
31
- ICompositionContext CompositionContext { get; };
32
+ Microsoft.UI.Composition.Compositor Compositor { get; };
32
33
  ComponentViewFeatures Features;
33
34
  };
34
35
 
@@ -37,13 +38,27 @@ namespace Microsoft.ReactNative.Composition
37
38
  unsealed runtimeclass ComponentView : Microsoft.ReactNative.ComponentView {
38
39
  ComponentView(CreateCompositionComponentViewArgs args);
39
40
 
40
- ICompositionContext CompositionContext { get; };
41
+ Microsoft.UI.Composition.Compositor Compositor { get; };
41
42
  Theme Theme;
42
43
  overridable void OnThemeChanged();
43
44
  Boolean CapturePointer(Microsoft.ReactNative.Composition.Input.Pointer pointer);
44
45
  void ReleasePointerCapture(Microsoft.ReactNative.Composition.Input.Pointer pointer);
45
46
  };
46
47
 
48
+ namespace Experimental {
49
+ [webhosthidden]
50
+ [experimental]
51
+ DOC_STRING("Custom ViewComponents need to implement this interface to be able to provide a custom"
52
+ " visual using the composition context that allows custom compositors. This is only required for"
53
+ " custom components that need to support running in RNW instances with custom compositors. Most"
54
+ " custom components can just override CreateVisual on ViewComponentView."
55
+ " This will be removed in a future version")
56
+ interface IInternalCreateVisual
57
+ {
58
+ Microsoft.ReactNative.Composition.Experimental.IVisual CreateInternalVisual();
59
+ }
60
+ }
61
+
47
62
  [experimental]
48
63
  [webhosthidden]
49
64
  unsealed runtimeclass ViewComponentView : ComponentView {
@@ -51,7 +66,7 @@ namespace Microsoft.ReactNative.Composition
51
66
 
52
67
  Microsoft.ReactNative.ViewProps ViewProps { get; };
53
68
 
54
- overridable IVisual CreateVisual();
69
+ overridable Microsoft.UI.Composition.Visual CreateVisual();
55
70
  };
56
71
 
57
72
  [experimental]
@@ -5,17 +5,17 @@
5
5
  #include "DocString.h"
6
6
  import "CompositionSwitcher.idl";
7
7
 
8
- namespace Microsoft.ReactNative.Composition
8
+ namespace Microsoft.ReactNative.Composition.Experimental
9
9
  {
10
10
  [webhosthidden]
11
11
  [default_interface]
12
12
  [experimental]
13
- DOC_STRING("A helper static class for to create a @ICompositionContext based on Windows.Composition Visuals. And to access the underlying Windows.Composition objects from the abstraction.")
13
+ DOC_STRING("A helper static class to create a @ICompositionContext based on Windows.Composition Visuals. This is not for general consumption and is expected to be removed in a future release.")
14
14
  static runtimeclass SystemCompositionContextHelper
15
15
  {
16
16
  DOC_STRING(
17
17
  "Creates a @ICompositionContext from a Compositor")
18
- static ICompositionContext CreateContext(Windows.UI.Composition.Compositor compositor);
18
+ static Microsoft.ReactNative.Composition.Experimental.ICompositionContext CreateContext(Windows.UI.Composition.Compositor compositor);
19
19
 
20
20
  DOC_STRING(
21
21
  "Creates a @IVisual from a Visual")
@@ -32,12 +32,12 @@ namespace Microsoft.ReactNative.Composition
32
32
  [webhosthidden]
33
33
  [default_interface]
34
34
  [experimental]
35
- DOC_STRING("A helper static class for to create a @ICompositionContext based on Microsoft.Composition Visuals. And to access the underlying Microsoft.Composition objects from the abstraction.")
35
+ DOC_STRING("A helper static class to create a @ICompositionContext based on Microsoft.Composition Visuals. Generally it should not be required to call this directly. Instead you should call @CompositionUIService.SetCompositor. This is not for general consumption and is expected to be removed in a future release.")
36
36
  static runtimeclass MicrosoftCompositionContextHelper
37
37
  {
38
38
  DOC_STRING(
39
39
  "Creates a @ICompositionContext from a Compositor")
40
- static ICompositionContext CreateContext(Microsoft.UI.Composition.Compositor compositor);
40
+ static Microsoft.ReactNative.Composition.Experimental.ICompositionContext CreateContext(Microsoft.UI.Composition.Compositor compositor);
41
41
 
42
42
  DOC_STRING(
43
43
  "Creates a @IVisual from a Visual")
@@ -1,7 +1,6 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
3
 
4
- import "CompositionContext.idl";
5
4
  import "IJSValueWriter.idl";
6
5
  import "ReactCoreInjection.idl";
7
6
  import "ReactNativeHost.idl";
@@ -41,6 +40,27 @@ namespace Microsoft.ReactNative
41
40
  Boolean WasFocusMoved {get;};
42
41
  };
43
42
 
43
+ namespace Composition.Experimental {
44
+ [webhosthidden]
45
+ [experimental]
46
+ DOC_STRING("Custom ViewComponents need to implement this interface to be able to provide a custom"
47
+ " visual using the composition context that allows custom compositors. This is only required for"
48
+ " custom components that need to support running in RNW instances with custom compositors. Most"
49
+ " custom components can just override CreateVisual on ViewComponentView. This interface will be removed"
50
+ " in future versions")
51
+ interface IInternalCompositionRootView
52
+ {
53
+ DOC_STRING("The RootVisual associated with the @CompositionRootView. It must be set to show any React UI elements.")
54
+ Microsoft.ReactNative.Composition.Experimental.IVisual InternalRootVisual { get; set; };
55
+
56
+ DOC_STRING("Hosting Window that input is coming from. Only required when not using ContentIslands")
57
+ void SetWindow(UInt64 hwnd);
58
+
59
+ DOC_STRING("Forward input to the RootView. Only required when not using ContentIslands")
60
+ Int64 SendMessage(UInt32 Msg, UInt64 WParam, Int64 LParam);
61
+ }
62
+ }
63
+
44
64
  [default_interface]
45
65
  [webhosthidden]
46
66
  [experimental]
@@ -60,7 +80,7 @@ namespace Microsoft.ReactNative
60
80
  IReactViewHost ReactViewHost { get; set; };
61
81
 
62
82
  DOC_STRING("The RootVisual associated with the @CompositionRootView. It must be set to show any React UI elements.")
63
- Microsoft.ReactNative.Composition.IVisual RootVisual { get; set; };
83
+ Microsoft.UI.Composition.Visual RootVisual { get; };
64
84
 
65
85
  Windows.Foundation.Size Size {get; set; };
66
86
 
@@ -73,12 +93,6 @@ namespace Microsoft.ReactNative
73
93
  Windows.Foundation.Size Measure(Windows.Foundation.Size availableSize);
74
94
  Windows.Foundation.Size Arrange(Windows.Foundation.Size availableSize);
75
95
 
76
- DOC_STRING("Hosting Window that input is coming from. Only required when not using ContentIslands")
77
- void SetWindow(UInt64 hwnd);
78
-
79
- DOC_STRING("Forward input to the RootView. Only required when not using ContentIslands")
80
- Int64 SendMessage(UInt32 Msg, UInt64 WParam, Int64 LParam);
81
-
82
96
  Object GetUiaProvider();
83
97
 
84
98
  DOC_STRING("Theme used for Platform colors within this RootView")
@@ -4,7 +4,7 @@
4
4
  #include "NamespaceRedirect.h"
5
5
  #include "DocString.h"
6
6
 
7
- namespace Microsoft.ReactNative.Composition
7
+ namespace Microsoft.ReactNative.Composition.Experimental
8
8
  {
9
9
  enum CompositionStretch
10
10
  {
@@ -161,4 +161,4 @@ namespace Microsoft.ReactNative.Composition
161
161
  // event Windows.Foundation.EventHandler<RenderingDeviceReplacedArgs> RenderingDeviceReplaced;
162
162
  }
163
163
 
164
- } // namespace Microsoft.ReactNative.Composition
164
+ } // namespace Microsoft.ReactNative.Composition.Experimental
@@ -1,11 +1,8 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
3
 
4
- import "IReactContext.idl";
5
- import "IReactPropertyBag.idl";
6
- import "CompositionContext.idl";
4
+ import "ReactInstanceSettings.idl";
7
5
 
8
- #include "NamespaceRedirect.h"
9
6
  #include "DocString.h"
10
7
 
11
8
  namespace Microsoft.ReactNative.Composition
@@ -18,7 +15,12 @@ namespace Microsoft.ReactNative.Composition
18
15
  runtimeclass CompositionUIService
19
16
  {
20
17
  DOC_STRING(
21
- "Sets the CompositionContext for this react instance. This can be created using @CompositionContextHelper.CreateContext")
22
- static void SetCompositionContext(Microsoft.ReactNative.IReactPropertyBag properties, ICompositionContext compositionContext);
18
+ "Configures the react instance to use the provided Compositor. Setting this will opt into using the new architecture")
19
+ static void SetCompositor(Microsoft.ReactNative.ReactInstanceSettings settings, Microsoft.UI.Composition.Compositor compositor);
20
+
21
+ DOC_STRING(
22
+ "Gets the Compositor used by this ReactNative instance.")
23
+ static Microsoft.UI.Composition.Compositor GetCompositor(Microsoft.ReactNative.IReactPropertyBag properties);
24
+
23
25
  }
24
26
  } // namespace Microsoft.ReactNative.Composition
@@ -51,7 +51,14 @@ winrt::Windows::UI::Color Color::AsWindowsColor(
51
51
  const winrt::Microsoft::ReactNative::Composition::Theme &theme) noexcept {
52
52
  return winrt::get_self<winrt::Microsoft::ReactNative::Composition::implementation::Theme>(theme)->Color(*m_color);
53
53
  }
54
- winrt::Microsoft::ReactNative::Composition::IBrush Color::AsBrush(
54
+ #ifdef USE_WINUI3
55
+ winrt::Microsoft::UI::Composition::CompositionBrush Color::AsBrush(
56
+ const winrt::Microsoft::ReactNative::Composition::Theme theme) noexcept {
57
+ return winrt::Microsoft::ReactNative::Composition::Experimental::MicrosoftCompositionContextHelper::InnerBrush(
58
+ winrt::get_self<winrt::Microsoft::ReactNative::Composition::implementation::Theme>(theme)->Brush(*m_color));
59
+ }
60
+ #endif
61
+ winrt::Microsoft::ReactNative::Composition::Experimental::IBrush Color::AsInternalBrush(
55
62
  const winrt::Microsoft::ReactNative::Composition::Theme theme) noexcept {
56
63
  return winrt::get_self<winrt::Microsoft::ReactNative::Composition::implementation::Theme>(theme)->Brush(*m_color);
57
64
  }
@@ -7,6 +7,7 @@
7
7
  #include "ViewProps.g.h"
8
8
 
9
9
  #include <react/renderer/components/view/ViewProps.h>
10
+ #include "winrt/Microsoft.ReactNative.Composition.Experimental.h"
10
11
  #include "winrt/Microsoft.ReactNative.h"
11
12
 
12
13
  namespace Microsoft::ReactNative {
@@ -35,11 +36,15 @@ class AbiViewProps final : public facebook::react::ViewProps {
35
36
 
36
37
  namespace winrt::Microsoft::ReactNative::implementation {
37
38
 
38
- struct Color : ColorT<Color> {
39
+ struct Color : ColorT<Color, Composition::Experimental::IInternalColor> {
39
40
  Color(facebook::react::SharedColor color);
40
41
 
41
42
  winrt::Windows::UI::Color AsWindowsColor(const winrt::Microsoft::ReactNative::Composition::Theme &theme) noexcept;
42
- winrt::Microsoft::ReactNative::Composition::IBrush AsBrush(
43
+ #ifdef USE_WINUI3
44
+ winrt::Microsoft::UI::Composition::CompositionBrush AsBrush(
45
+ const winrt::Microsoft::ReactNative::Composition::Theme theme) noexcept;
46
+ #endif
47
+ winrt::Microsoft::ReactNative::Composition::Experimental::IBrush AsInternalBrush(
43
48
  const winrt::Microsoft::ReactNative::Composition::Theme theme) noexcept;
44
49
 
45
50
  static winrt::Microsoft::ReactNative::Color ReadValue(
@@ -14,14 +14,14 @@
14
14
  namespace winrt::Microsoft::ReactNative::Composition::implementation {
15
15
 
16
16
  winrt::Microsoft::ReactNative::ComponentView ActivityIndicatorComponentView::Create(
17
- const winrt::Microsoft::ReactNative::Composition::ICompositionContext &compContext,
17
+ const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
18
18
  facebook::react::Tag tag,
19
19
  winrt::Microsoft::ReactNative::ReactContext const &reactContext) noexcept {
20
20
  return winrt::make<ActivityIndicatorComponentView>(compContext, tag, reactContext);
21
21
  }
22
22
 
23
23
  ActivityIndicatorComponentView::ActivityIndicatorComponentView(
24
- const winrt::Microsoft::ReactNative::Composition::ICompositionContext &compContext,
24
+ const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
25
25
  facebook::react::Tag tag,
26
26
  winrt::Microsoft::ReactNative::ReactContext const &reactContext)
27
27
  : Super(compContext, tag, reactContext, ComponentViewFeatures::Default, false) {
@@ -141,7 +141,8 @@ facebook::react::Tag ActivityIndicatorComponentView::hitTest(
141
141
  return -1;
142
142
  }
143
143
 
144
- winrt::Microsoft::ReactNative::Composition::IVisual ActivityIndicatorComponentView::Visual() const noexcept {
144
+ winrt::Microsoft::ReactNative::Composition::Experimental::IVisual ActivityIndicatorComponentView::Visual()
145
+ const noexcept {
145
146
  return m_visual;
146
147
  }
147
148
 
@@ -17,7 +17,7 @@ struct ActivityIndicatorComponentView : ActivityIndicatorComponentViewT<Activity
17
17
  using Super = ActivityIndicatorComponentViewT<ActivityIndicatorComponentView, ComponentView>;
18
18
 
19
19
  [[nodiscard]] static winrt::Microsoft::ReactNative::ComponentView Create(
20
- const winrt::Microsoft::ReactNative::Composition::ICompositionContext &compContext,
20
+ const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
21
21
  facebook::react::Tag tag,
22
22
  winrt::Microsoft::ReactNative::ReactContext const &reactContext) noexcept;
23
23
 
@@ -42,11 +42,11 @@ struct ActivityIndicatorComponentView : ActivityIndicatorComponentViewT<Activity
42
42
 
43
43
  facebook::react::Tag hitTest(facebook::react::Point pt, facebook::react::Point &localPt, bool ignorePointerEvents)
44
44
  const noexcept override;
45
- winrt::Microsoft::ReactNative::Composition::IVisual Visual() const noexcept override;
45
+ winrt::Microsoft::ReactNative::Composition::Experimental::IVisual Visual() const noexcept override;
46
46
  virtual std::string DefaultControlType() const noexcept;
47
47
 
48
48
  ActivityIndicatorComponentView(
49
- const winrt::Microsoft::ReactNative::Composition::ICompositionContext &compContext,
49
+ const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
50
50
  facebook::react::Tag tag,
51
51
  winrt::Microsoft::ReactNative::ReactContext const &reactContext);
52
52
 
@@ -55,8 +55,8 @@ struct ActivityIndicatorComponentView : ActivityIndicatorComponentViewT<Activity
55
55
  void updateVisualSize() noexcept;
56
56
  void updateProgressColor(const facebook::react::SharedColor &color) noexcept;
57
57
 
58
- winrt::Microsoft::ReactNative::Composition::ISpriteVisual m_visual{nullptr};
59
- winrt::Microsoft::ReactNative::Composition::IActivityVisual m_ActivityIndicatorVisual{nullptr};
58
+ winrt::Microsoft::ReactNative::Composition::Experimental::ISpriteVisual m_visual{nullptr};
59
+ winrt::Microsoft::ReactNative::Composition::Experimental::IActivityVisual m_ActivityIndicatorVisual{nullptr};
60
60
  facebook::react::SharedViewProps m_props;
61
61
  };
62
62
 
@@ -42,7 +42,7 @@ void ComponentViewRegistry::Initialize(winrt::Microsoft::ReactNative::ReactConte
42
42
  ComponentViewDescriptor const &ComponentViewRegistry::dequeueComponentViewWithComponentHandle(
43
43
  facebook::react::ComponentHandle componentHandle,
44
44
  facebook::react::Tag tag,
45
- const winrt::Microsoft::ReactNative::Composition::ICompositionContext &compContext) noexcept {
45
+ const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext) noexcept {
46
46
  // TODO implement recycled components like core does
47
47
 
48
48
  winrt::Microsoft::ReactNative::ComponentView view{nullptr};
@@ -19,7 +19,8 @@ class ComponentViewRegistry final : public IComponentViewRegistry {
19
19
  ComponentViewDescriptor const &dequeueComponentViewWithComponentHandle(
20
20
  facebook::react::ComponentHandle componentHandle,
21
21
  facebook::react::Tag tag,
22
- const winrt::Microsoft::ReactNative::Composition::ICompositionContext &compContext) noexcept override;
22
+ const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext) noexcept
23
+ override;
23
24
  ComponentViewDescriptor const &componentViewDescriptorWithTag(facebook::react::Tag tag) const noexcept override;
24
25
  winrt::Microsoft::ReactNative::ComponentView findComponentViewWithTag(
25
26
  facebook::react::Tag tag) const noexcept override;