react-native-windows 0.69.0-preview.2 → 0.69.0-preview.5

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 (64) hide show
  1. package/Directory.Build.props +4 -0
  2. package/Folly/Folly.vcxproj +4 -5
  3. package/Libraries/Core/ReactNativeVersion.js +1 -1
  4. package/Libraries/Network/RCTNetworkingWinShared.js +7 -0
  5. package/Libraries/Utilities/codegenNativeComponent.js +5 -6
  6. package/Libraries/Utilities/useColorScheme.js +9 -15
  7. package/Microsoft.ReactNative/Base/CoreNativeModules.cpp +3 -1
  8. package/Microsoft.ReactNative/IReactContext.cpp +17 -0
  9. package/Microsoft.ReactNative/IReactContext.h +2 -0
  10. package/Microsoft.ReactNative/IReactContext.idl +27 -0
  11. package/Microsoft.ReactNative/JsiApi.cpp +9 -0
  12. package/Microsoft.ReactNative/JsiApi.h +1 -0
  13. package/Microsoft.ReactNative/JsiApi.idl +1 -0
  14. package/Microsoft.ReactNative.Cxx/JSI/JsiAbiApi.cpp +3 -5
  15. package/Microsoft.ReactNative.Cxx/JSI/JsiAbiApi.h +1 -1
  16. package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.cpp +31 -9
  17. package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.h +48 -0
  18. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +2 -2
  19. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems.filters +1 -1
  20. package/Microsoft.ReactNative.Managed/packages.lock.json +57 -2
  21. package/PropertySheets/Generated/PackageVersion.g.props +1 -1
  22. package/PropertySheets/JSEngine.props +2 -2
  23. package/Scripts/Tfs/Layout-MSRN-Headers.ps1 +9 -5
  24. package/Shared/CreateModules.h +17 -2
  25. package/Shared/InspectorPackagerConnection.cpp +6 -7
  26. package/Shared/InspectorPackagerConnection.h +1 -1
  27. package/Shared/JSI/ChakraRuntime.cpp +5 -0
  28. package/Shared/JSI/ChakraRuntime.h +1 -0
  29. package/Shared/JSI/NapiJsiV8RuntimeHolder.cpp +72 -2
  30. package/Shared/JSI/NapiJsiV8RuntimeHolder.h +2 -0
  31. package/Shared/Modules/BlobModule.cpp +376 -0
  32. package/Shared/Modules/BlobModule.h +153 -0
  33. package/Shared/Modules/CxxModuleUtilities.cpp +19 -0
  34. package/Shared/Modules/CxxModuleUtilities.h +23 -0
  35. package/Shared/Modules/FileReaderModule.cpp +156 -0
  36. package/Shared/Modules/FileReaderModule.h +54 -0
  37. package/Shared/Modules/HttpModule.cpp +72 -69
  38. package/Shared/Modules/HttpModule.h +8 -1
  39. package/Shared/Modules/IBlobPersistor.h +30 -0
  40. package/Shared/Modules/IHttpModuleProxy.h +30 -0
  41. package/Shared/Modules/IRequestBodyHandler.h +52 -0
  42. package/Shared/Modules/IResponseHandler.h +27 -0
  43. package/Shared/Modules/IUriHandler.h +37 -0
  44. package/Shared/Modules/IWebSocketModuleContentHandler.h +26 -0
  45. package/Shared/Modules/IWebSocketModuleProxy.h +22 -0
  46. package/Shared/Modules/NetworkingModule.cpp +1 -1
  47. package/Shared/Modules/WebSocketModule.cpp +92 -22
  48. package/Shared/Modules/WebSocketModule.h +27 -1
  49. package/Shared/Networking/IHttpResource.h +50 -2
  50. package/Shared/Networking/WinRTHttpResource.cpp +169 -51
  51. package/Shared/Networking/WinRTHttpResource.h +27 -8
  52. package/Shared/Networking/WinRTTypes.h +5 -2
  53. package/Shared/OInstance.cpp +22 -5
  54. package/Shared/OInstance.h +8 -4
  55. package/Shared/RuntimeOptions.cpp +6 -3
  56. package/Shared/RuntimeOptions.h +14 -3
  57. package/Shared/Shared.vcxitems +13 -0
  58. package/Shared/Shared.vcxitems.filters +40 -1
  59. package/fmt/fmt.vcxproj +4 -5
  60. package/package.json +14 -12
  61. package/template/cs-app-WinAppSDK/proj/NuGet.Config +3 -1
  62. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/JSCRuntime.cpp +0 -1480
  63. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/decorator.h +0 -753
  64. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/jsi.h +0 -1331
@@ -15,8 +15,12 @@
15
15
  The PR (windows-vs-pr.yml) and CI (publish.yml() turn it back on.
16
16
  -->
17
17
  <EnableSourceLink Condition="'$(EnableSourceLink)' == ''">false</EnableSourceLink>
18
+ <!-- When bumping the Folly version, be sure to bump the git hash of that version's commit too. -->
18
19
  <FollyVersion>2021.06.28.00</FollyVersion>
20
+ <FollyCommitHash>f434460f8a98e85f3ddb75390ddd1cc330c8f658</FollyCommitHash>
21
+ <!-- When bumping the fmt version, be sure to bump the git hash of that version's commit too. -->
19
22
  <FmtVersion>7.1.3</FmtVersion>
23
+ <FmtCommitHash>7bdf0628b1276379886c7f6dda2cef2b3b374f0b</FmtCommitHash>
20
24
  </PropertyGroup>
21
25
 
22
26
  <PropertyGroup Label="Configuration">
@@ -289,11 +289,10 @@
289
289
  "Registrations": [
290
290
  {
291
291
  "Component": {
292
- "Type": "other",
293
- "Other": {
294
- "Name": "folly",
295
- "Version": "$(FollyVersion)",
296
- "DownloadUrl": "https://github.com/facebook/folly/archive/v$(FollyVersion).zip"
292
+ "Type": "git",
293
+ "Git": {
294
+ "RepositoryUrl": "https://github.com/facebook/folly",
295
+ "CommitHash": "$(FollyCommitHash)"
297
296
  }
298
297
  },
299
298
  "DevelopmentDependency": false
@@ -13,5 +13,5 @@ exports.version = {
13
13
  major: 0,
14
14
  minor: 69,
15
15
  patch: 0,
16
- prerelease: 'rc.0',
16
+ prerelease: 'rc.3',
17
17
  };
@@ -61,6 +61,11 @@ type RCTNetworkingEventDefinitions = $ReadOnly<{
61
61
  ],
62
62
  }>;
63
63
 
64
+ let _requestId = 1;
65
+ function generateRequestId(): number {
66
+ return _requestId++;
67
+ }
68
+
64
69
  const RCTNetworking = {
65
70
  addListener<K: $Keys<RCTNetworkingEventDefinitions>>(
66
71
  eventType: K,
@@ -82,11 +87,13 @@ const RCTNetworking = {
82
87
  callback: (requestId: number) => void,
83
88
  withCredentials: boolean,
84
89
  ) {
90
+ const requestId = generateRequestId();
85
91
  const body = convertRequestBody(data);
86
92
  RCTNetworkingNative.sendRequest(
87
93
  {
88
94
  method,
89
95
  url,
96
+ requestId,
90
97
  data: {...body, trackingName},
91
98
  headers,
92
99
  responseType,
@@ -34,15 +34,14 @@ function codegenNativeComponent<Props>(
34
34
  componentName: string,
35
35
  options?: Options,
36
36
  ): NativeComponentType<Props> {
37
- const errorMessage =
38
- "Native Component '" +
39
- componentName +
40
- "' that calls codegenNativeComponent was not code generated at build time. Please check its definition.";
41
37
  if (global.RN$Bridgeless === true) {
38
+ const errorMessage =
39
+ "Native Component '" +
40
+ componentName +
41
+ "' that calls codegenNativeComponent was not code generated at build time. Please check its definition.";
42
42
  console.error(errorMessage);
43
- } else {
44
- console.warn(errorMessage);
45
43
  }
44
+
46
45
  let componentNameInUse =
47
46
  options && options.paperComponentName != null
48
47
  ? options.paperComponentName
@@ -8,24 +8,18 @@
8
8
  * @flow strict-local
9
9
  */
10
10
 
11
- import {useMemo} from 'react';
12
- import {useSubscription} from 'use-subscription';
11
+ 'use strict';
12
+
13
+ import {useSyncExternalStore} from 'use-sync-external-store/shim';
13
14
  import Appearance from './Appearance';
14
15
  import type {ColorSchemeName} from './NativeAppearance';
15
16
 
16
17
  export default function useColorScheme(): ?ColorSchemeName {
17
- const subscription = useMemo(
18
- () => ({
19
- getCurrentValue: () => Appearance.getColorScheme(),
20
- subscribe: callback => {
21
- const appearanceSubscription = Appearance.addChangeListener(callback);
22
- return () => {
23
- appearanceSubscription.remove();
24
- };
25
- },
26
- }),
27
- [],
18
+ return useSyncExternalStore(
19
+ callback => {
20
+ const appearanceSubscription = Appearance.addChangeListener(callback);
21
+ return () => appearanceSubscription.remove();
22
+ },
23
+ () => Appearance.getColorScheme(),
28
24
  );
29
-
30
- return useSubscription(subscription);
31
25
  }
@@ -46,7 +46,9 @@ std::vector<facebook::react::NativeModuleDescription> GetCoreModules(
46
46
  std::vector<facebook::react::NativeModuleDescription> modules;
47
47
 
48
48
  modules.emplace_back(
49
- "Networking", []() { return Microsoft::React::CreateHttpModule(); }, jsMessageQueue);
49
+ "Networking",
50
+ [props = context->Properties()]() { return Microsoft::React::CreateHttpModule(props); },
51
+ jsMessageQueue);
50
52
 
51
53
  modules.emplace_back(
52
54
  "Timing",
@@ -96,6 +96,23 @@ Windows::Foundation::IInspectable ReactContext::JSRuntime() noexcept {
96
96
  return m_context->JsiRuntime();
97
97
  }
98
98
 
99
+ LoadingState ReactContext::LoadingState() noexcept {
100
+ switch (m_context->State()) {
101
+ case Mso::React::ReactInstanceState::Loading:
102
+ case Mso::React::ReactInstanceState::WaitingForDebugger:
103
+ return LoadingState::Loading;
104
+ case Mso::React::ReactInstanceState::Loaded:
105
+ return LoadingState::Loaded;
106
+ case Mso::React::ReactInstanceState::HasError:
107
+ return LoadingState::HasError;
108
+ case Mso::React::ReactInstanceState::Unloaded:
109
+ return LoadingState::Unloaded;
110
+ default:
111
+ assert(false);
112
+ return LoadingState::HasError;
113
+ };
114
+ }
115
+
99
116
  #ifndef CORE_ABI
100
117
  // Deprecated: Use XamlUIService directly.
101
118
  void ReactContext::DispatchEvent(
@@ -42,6 +42,8 @@ struct ReactContext : winrt::implements<ReactContext, IReactContext> {
42
42
  IReactDispatcher UIDispatcher() noexcept;
43
43
  IReactDispatcher JSDispatcher() noexcept;
44
44
  IInspectable JSRuntime() noexcept;
45
+ LoadingState LoadingState() noexcept;
46
+
45
47
  #ifndef CORE_ABI
46
48
  void DispatchEvent(
47
49
  xaml::FrameworkElement const &view,
@@ -13,6 +13,29 @@ import "IReactPropertyBag.idl";
13
13
 
14
14
  namespace Microsoft.ReactNative
15
15
  {
16
+
17
+ DOC_STRING(
18
+ "Used to represent the state of the React Native JavaScript instance")
19
+ enum LoadingState
20
+ {
21
+ DOC_STRING(
22
+ "The instance is loading the JavaScript bundle and initial instance setup. Calls to run JavaScript functions will be queued to run once the instance is fully loaded."
23
+ )
24
+ Loading = 0,
25
+ DOC_STRING(
26
+ "The instance is in a ready state. Calls to run JavaScript functions will be run as soon as they are posted to the JavaScript instance."
27
+ )
28
+ Loaded = 1,
29
+ DOC_STRING(
30
+ "The instance has hit an error. Calls to run JavaScript functions will not be run."
31
+ )
32
+ HasError = 2,
33
+ DOC_STRING(
34
+ "The instance has successfully unloaded. Calls to run JavaScript functions will not be run."
35
+ )
36
+ Unloaded = 3
37
+ };
38
+
16
39
  [webhosthidden]
17
40
  DOC_STRING("An immutable snapshot of the @ReactInstanceSettings used to create the current React instance.")
18
41
  interface IReactSettingsSnapshot
@@ -167,5 +190,9 @@ namespace Microsoft.ReactNative
167
190
  "The `paramsArgWriter` is a @JSValueArgWriter delegate that receives @IJSValueWriter to serialize "
168
191
  "the event parameters.")
169
192
  void EmitJSEvent(String eventEmitterName, String eventName, JSValueArgWriter paramsArgWriter);
193
+
194
+ DOC_STRING(
195
+ "Gets the state of the ReactNative instance.")
196
+ LoadingState LoadingState { get; };
170
197
  }
171
198
  } // namespace Microsoft.ReactNative
@@ -143,6 +143,7 @@ struct RuntimeAccessor : facebook::jsi::Runtime {
143
143
  using facebook::jsi::Runtime::createObject;
144
144
  using facebook::jsi::Runtime::createPropNameIDFromAscii;
145
145
  using facebook::jsi::Runtime::createPropNameIDFromString;
146
+ using facebook::jsi::Runtime::createPropNameIDFromSymbol;
146
147
  using facebook::jsi::Runtime::createPropNameIDFromUtf8;
147
148
  using facebook::jsi::Runtime::createStringFromUtf8;
148
149
  using facebook::jsi::Runtime::createValueFromJsonUtf8;
@@ -572,6 +573,14 @@ JsiPropertyIdRef JsiRuntime::CreatePropertyIdFromString(JsiStringRef str) try {
572
573
  throw;
573
574
  }
574
575
 
576
+ JsiPropertyIdRef JsiRuntime::CreatePropertyIdFromSymbol(JsiSymbolRef sym) try {
577
+ auto symPtr = RuntimeAccessor::AsPointerValue(sym);
578
+ return PointerAccessor::MakeJsiPropertyNameIdData(
579
+ m_runtimeAccessor->createPropNameIDFromSymbol(RuntimeAccessor::AsSymbol(&symPtr)));
580
+ } catch (JSI_SET_ERROR) {
581
+ throw;
582
+ }
583
+
575
584
  hstring JsiRuntime::PropertyIdToString(JsiPropertyIdRef propertyId) try {
576
585
  auto ptr = RuntimeAccessor::AsPointerValue(propertyId);
577
586
  std::string utf8 = m_runtimeAccessor->utf8(RuntimeAccessor::AsPropNameID(&ptr));
@@ -90,6 +90,7 @@ struct JsiRuntime : JsiRuntimeT<JsiRuntime> {
90
90
  JsiPropertyIdRef CreatePropertyIdFromAscii(array_view<uint8_t const> ascii);
91
91
  JsiPropertyIdRef CreatePropertyIdFromUtf8(array_view<uint8_t const> utf8);
92
92
  JsiPropertyIdRef CreatePropertyIdFromString(JsiStringRef str);
93
+ JsiPropertyIdRef CreatePropertyIdFromSymbol(JsiSymbolRef sym);
93
94
  hstring PropertyIdToString(JsiPropertyIdRef propertyId);
94
95
  void PropertyIdToUtf8(JsiPropertyIdRef propertyId, JsiByteArrayUser const &useUtf8String);
95
96
  bool PropertyIdEquals(JsiPropertyIdRef left, JsiPropertyIdRef right);
@@ -246,6 +246,7 @@ namespace Microsoft.ReactNative
246
246
  JsiPropertyIdRef CreatePropertyIdFromAscii(UInt8[] ascii);
247
247
  JsiPropertyIdRef CreatePropertyIdFromUtf8(UInt8[] utf8);
248
248
  JsiPropertyIdRef CreatePropertyIdFromString(JsiStringRef str);
249
+ JsiPropertyIdRef CreatePropertyIdFromSymbol(JsiSymbolRef sym);
249
250
  String PropertyIdToString(JsiPropertyIdRef propertyId);
250
251
  void PropertyIdToUtf8(JsiPropertyIdRef propertyId, JsiByteArrayUser useUtf8String);
251
252
  Boolean PropertyIdEquals(JsiPropertyIdRef left, JsiPropertyIdRef right);
@@ -306,11 +306,9 @@ PropNameID JsiAbiRuntime::createPropNameIDFromString(const String &str) try {
306
306
  throw;
307
307
  }
308
308
 
309
- PropNameID JsiAbiRuntime::createPropNameIDFromSymbol(const Symbol &sym) {
310
- // TODO: Support for symbols through the native API in JSC is very limited.
311
- // While we could construct a PropNameID here, we would not be able to get a
312
- // symbol property through the C++ API.
313
- UNREFERENCED_PARAMETER(sym);
309
+ PropNameID JsiAbiRuntime::createPropNameIDFromSymbol(const Symbol &sym) try {
310
+ return MakePropNameID(m_runtime.CreatePropertyIdFromSymbol(AsJsiSymbolRef(sym)));
311
+ } catch (hresult_error const &) {
314
312
  RethrowJsiError();
315
313
  throw;
316
314
  }
@@ -99,7 +99,7 @@ struct JsiAbiRuntime : facebook::jsi::Runtime {
99
99
  facebook::jsi::PropNameID createPropNameIDFromAscii(const char *str, size_t length) override;
100
100
  facebook::jsi::PropNameID createPropNameIDFromUtf8(const uint8_t *utf8, size_t length) override;
101
101
  facebook::jsi::PropNameID createPropNameIDFromString(const facebook::jsi::String &str) override;
102
- facebook::jsi::PropNameID createPropNameIDFromSymbol(const facebook::jsi::Symbol &sym);
102
+ facebook::jsi::PropNameID createPropNameIDFromSymbol(const facebook::jsi::Symbol &sym) override;
103
103
  std::string utf8(const facebook::jsi::PropNameID &propertyNameId) override;
104
104
  bool compare(const facebook::jsi::PropNameID &left, const facebook::jsi::PropNameID &right) override;
105
105
 
@@ -137,7 +137,7 @@ struct NapiJsiRuntime : facebook::jsi::Runtime {
137
137
  facebook::jsi::PropNameID createPropNameIDFromAscii(const char *str, size_t length) override;
138
138
  facebook::jsi::PropNameID createPropNameIDFromUtf8(const uint8_t *utf8, size_t length) override;
139
139
  facebook::jsi::PropNameID createPropNameIDFromString(const facebook::jsi::String &str) override;
140
- facebook::jsi::PropNameID createPropNameIDFromSymbol(const facebook::jsi::Symbol &sym);
140
+ facebook::jsi::PropNameID createPropNameIDFromSymbol(const facebook::jsi::Symbol &sym) override;
141
141
  std::string utf8(const facebook::jsi::PropNameID &id) override;
142
142
  bool compare(const facebook::jsi::PropNameID &lhs, const facebook::jsi::PropNameID &rhs) override;
143
143
 
@@ -441,6 +441,7 @@ struct NapiJsiRuntime : facebook::jsi::Runtime {
441
441
 
442
442
  private: // Shared NAPI call helpers
443
443
  napi_value RunScript(napi_value script, const char *sourceUrl);
444
+ napi_value RunScriptBuffer(const std::shared_ptr<const facebook::jsi::Buffer> &buffer, const char *sourceUrl);
444
445
  std::vector<uint8_t> SerializeScript(napi_value script, const char *sourceUrl);
445
446
  napi_value RunSerializedScript(span<const uint8_t> serialized, napi_value source, const char *sourceUrl);
446
447
  napi_ext_ref CreateReference(napi_value value) const;
@@ -463,6 +464,7 @@ struct NapiJsiRuntime : facebook::jsi::Runtime {
463
464
  napi_ext_ref GetPropertyIdFromName(std::string_view value) const;
464
465
  napi_ext_ref GetPropertyIdFromName(const uint8_t *data, size_t length) const;
465
466
  napi_ext_ref GetPropertyIdFromName(napi_value str) const;
467
+ napi_ext_ref GetPropertyIdFromSymbol(napi_value sym) const;
466
468
  std::string PropertyIdToStdString(napi_value propertyId);
467
469
  napi_value CreateSymbol(std::string_view symbolDescription) const;
468
470
  std::string SymbolToStdString(napi_value symbolValue);
@@ -621,9 +623,7 @@ NapiJsiRuntime::NapiJsiRuntime(napi_env env) noexcept : m_env{env} {
621
623
 
622
624
  Value NapiJsiRuntime::evaluateJavaScript(const shared_ptr<const Buffer> &buffer, const string &sourceUrl) {
623
625
  EnvScope envScope{m_env};
624
- napi_value script = CreateStringUtf8(buffer->data(), buffer->size());
625
- napi_value result = RunScript(script, sourceUrl.c_str());
626
-
626
+ napi_value result = RunScriptBuffer(buffer, sourceUrl.c_str());
627
627
  return ToJsiValue(result);
628
628
  }
629
629
 
@@ -713,11 +713,10 @@ PropNameID NapiJsiRuntime::createPropNameIDFromString(const String &str) {
713
713
  }
714
714
 
715
715
  PropNameID NapiJsiRuntime::createPropNameIDFromSymbol(const Symbol &sym) {
716
- // TODO: Support for symbols through the native API in JSC is very limited.
717
- // While we could construct a PropNameID here, we would not be able to get a
718
- // symbol property through the C++ API.
719
- UNREFERENCED_PARAMETER(sym);
720
- throw;
716
+ EnvScope envScope{m_env};
717
+ napi_ext_ref propSym = GetPropertyIdFromSymbol(GetNapiValue(sym));
718
+
719
+ return MakePointer<PropNameID>(propSym);
721
720
  }
722
721
 
723
722
  string NapiJsiRuntime::utf8(const PropNameID &id) {
@@ -1415,6 +1414,21 @@ napi_value NapiJsiRuntime::RunScript(napi_value script, const char *sourceUrl) {
1415
1414
  return result;
1416
1415
  }
1417
1416
 
1417
+ napi_value NapiJsiRuntime::RunScriptBuffer(
1418
+ const std::shared_ptr<const facebook::jsi::Buffer> &buffer,
1419
+ const char *sourceUrl) {
1420
+ napi_ext_buffer napiBuffer{};
1421
+ napiBuffer.buffer_object = NativeObjectWrapper<std::shared_ptr<const facebook::jsi::Buffer>>::Wrap(
1422
+ std::shared_ptr<const facebook::jsi::Buffer>{buffer});
1423
+ napiBuffer.data = buffer->data();
1424
+ napiBuffer.byte_size = buffer->size();
1425
+
1426
+ napi_value result{};
1427
+ CHECK_NAPI(napi_ext_run_script_buffer(m_env, &napiBuffer, sourceUrl, &result));
1428
+
1429
+ return result;
1430
+ }
1431
+
1418
1432
  // Serializes script with the sourceUrl origin.
1419
1433
  vector<uint8_t> NapiJsiRuntime::SerializeScript(napi_value script, const char *sourceUrl) {
1420
1434
  vector<uint8_t> result;
@@ -1600,6 +1614,14 @@ napi_ext_ref NapiJsiRuntime::GetPropertyIdFromName(napi_value str) const {
1600
1614
  return ref;
1601
1615
  }
1602
1616
 
1617
+ // Gets or creates a unique string value from napi_value string.
1618
+ napi_ext_ref NapiJsiRuntime::GetPropertyIdFromSymbol(napi_value sym) const {
1619
+ napi_ext_ref ref{};
1620
+ CHECK_NAPI(napi_ext_create_reference(m_env, sym, &ref));
1621
+
1622
+ return ref;
1623
+ }
1624
+
1603
1625
  // Converts property id value to std::string.
1604
1626
  string NapiJsiRuntime::PropertyIdToStdString(napi_value propertyId) {
1605
1627
  if (TypeOf(propertyId) == napi_symbol) {
@@ -20,6 +20,54 @@ namespace Microsoft::JSI {
20
20
  ///
21
21
  std::unique_ptr<facebook::jsi::Runtime> __cdecl MakeNodeApiJsiRuntime(napi_env env) noexcept;
22
22
 
23
+ template <typename T>
24
+ struct NativeObjectWrapper;
25
+
26
+ template <typename T>
27
+ struct NativeObjectWrapper<std::unique_ptr<T>> {
28
+ static napi_ext_native_data Wrap(std::unique_ptr<T> &&obj) noexcept {
29
+ napi_ext_native_data nativeData{};
30
+ nativeData.data = obj.release();
31
+ nativeData.finalize_cb = [](napi_env /*env*/, void *data, void * /*finalizeHint*/) {
32
+ std::unique_ptr<T> obj{reinterpret_cast<T *>(data)};
33
+ };
34
+ return nativeData;
35
+ }
36
+
37
+ static T *Unwrap(napi_ext_native_data &nativeData) noexcept {
38
+ return reinterpret_cast<T *>(nativeData.data);
39
+ }
40
+ };
41
+
42
+ template <typename T>
43
+ struct NativeObjectWrapper<std::shared_ptr<T>> {
44
+ static napi_ext_native_data Wrap(std::shared_ptr<T> &&obj) noexcept {
45
+ static_assert(
46
+ sizeof(SharedPtrHolder) == sizeof(std::shared_ptr<T>), "std::shared_ptr expected to have size of two pointers");
47
+ SharedPtrHolder ptrHolder;
48
+ new (std::addressof(ptrHolder)) std::shared_ptr(std::move(obj));
49
+ napi_ext_native_data nativeData{};
50
+ nativeData.data = ptrHolder.ptr1;
51
+ nativeData.finalize_hint = ptrHolder.ptr2;
52
+ nativeData.finalize_cb = [](napi_env /*env*/, void *data, void *finalizeHint) {
53
+ SharedPtrHolder ptrHolder{data, finalizeHint};
54
+ std::shared_ptr<T> obj(std::move(*reinterpret_cast<std::shared_ptr<T> *>(std::addressof(ptrHolder))));
55
+ };
56
+ return nativeData;
57
+ }
58
+
59
+ static std::shared_ptr<T> Unwrap(napi_ext_native_data &nativeData) noexcept {
60
+ SharedPtrHolder ptrHolder{nativeData.data, nativeData.finalize_hint};
61
+ return *reinterpret_cast<std::shared_ptr<T> *>(std::addressof(ptrHolder));
62
+ }
63
+
64
+ private:
65
+ struct SharedPtrHolder {
66
+ void *ptr1;
67
+ void *ptr2;
68
+ };
69
+ };
70
+
23
71
  } // namespace Microsoft::JSI
24
72
 
25
73
  #endif // MICROSOFT_REACTNATIVE_JSI_NODEAPIJSIRUNTIME
@@ -13,7 +13,7 @@
13
13
  <TurboModule_SourcePath Condition="'$(TurboModule_SourcePath)' == '' AND '$(ReactNativeDir)' != ''">$(ReactNativeDir)\ReactCommon\react\nativemodule\core</TurboModule_SourcePath>
14
14
  <TurboModule_SourcePath Condition="'$(TurboModule_SourcePath)' == '' AND Exists('$(MSBuildThisFileDirectory)ReactCommon\TurboModule.h')">$(MSBuildThisFileDirectory)</TurboModule_SourcePath>
15
15
  <Bridging_SourcePath Condition="'$(Bridging_SourcePath)' == '' AND '$(ReactNativeDir)' != ''">$(ReactNativeDir)\ReactCommon\react\bridging</Bridging_SourcePath>
16
- <Bridging_SourcePath Condition="'$(Bridging_SourcePath)' == '' AND Exists('$(MSBuildThisFileDirectory)ReactCommon\TurboModule.h')">$(MSBuildThisFileDirectory)</Bridging_SourcePath>
16
+ <Bridging_SourcePath Condition="'$(Bridging_SourcePath)' == '' AND Exists('$(MSBuildThisFileDirectory)ReactCommon\CallbackWrapper.h')">$(MSBuildThisFileDirectory)ReactCommon</Bridging_SourcePath>
17
17
  </PropertyGroup>
18
18
  <ItemDefinitionGroup>
19
19
  <ClCompile>
@@ -108,7 +108,7 @@
108
108
  <PrecompiledHeader>NotUsing</PrecompiledHeader>
109
109
  <DisableSpecificWarnings>%(DisableSpecificWarnings);4100</DisableSpecificWarnings>
110
110
  </ClCompile>
111
- <ClCompile Include="$(TurboModule_SourcePath)\..\..\bridging\LongLivedObject.cpp">
111
+ <ClCompile Include="$(Bridging_SourcePath)\LongLivedObject.cpp">
112
112
  <PrecompiledHeader>NotUsing</PrecompiledHeader>
113
113
  <DisableSpecificWarnings>%(DisableSpecificWarnings);4100</DisableSpecificWarnings>
114
114
  </ClCompile>
@@ -166,4 +166,4 @@
166
166
  <ItemGroup>
167
167
  <None Include="$(MSBuildThisFileDirectory)README.md" />
168
168
  </ItemGroup>
169
- </Project>
169
+ </Project>
@@ -24,6 +24,11 @@
24
24
  "Microsoft.SourceLink.Common": "1.0.0"
25
25
  }
26
26
  },
27
+ "boost": {
28
+ "type": "Transitive",
29
+ "resolved": "1.76.0",
30
+ "contentHash": "p+w3YvNdXL8Cu9Fzrmexssu0tZbWxuf6ywsQqHjDlKFE5ojXHof1HIyMC3zDLfLnh80dIeFcEUAuR2Asg/XHRA=="
31
+ },
27
32
  "Microsoft.Build.Tasks.Git": {
28
33
  "type": "Transitive",
29
34
  "resolved": "1.0.0",
@@ -60,14 +65,34 @@
60
65
  "resolved": "1.0.0",
61
66
  "contentHash": "G8DuQY8/DK5NN+3jm5wcMcd9QYD90UV7MiLmdljSJixi3U/vNaeBKmmXUqI4DJCOeWizIUEh4ALhSt58mR+5eg=="
62
67
  },
68
+ "Microsoft.UI.Xaml": {
69
+ "type": "Transitive",
70
+ "resolved": "2.7.0",
71
+ "contentHash": "dB4im13tfmMgL/V3Ei+3kD2rUF+/lTxAmR4gjJ45l577eljHfdo/KUrxpq/3I1Vp6e5GCDG1evDaEGuDxypLMg=="
72
+ },
73
+ "Microsoft.Windows.CppWinRT": {
74
+ "type": "Transitive",
75
+ "resolved": "2.0.211028.7",
76
+ "contentHash": "JBGI0c3WLoU6aYJRy9Qo0MLDQfObEp+d4nrhR95iyzf7+HOgjRunHDp/6eGFREd7xq3OI1mll9ecJrMfzBvlyg=="
77
+ },
78
+ "Microsoft.Windows.SDK.BuildTools": {
79
+ "type": "Transitive",
80
+ "resolved": "10.0.22000.194",
81
+ "contentHash": "4L0P3zqut466SIqT3VBeLTNUQTxCBDOrTRymRuROCRJKazcK7ibLz9yAO1nKWRt50ttCj39oAa2Iuz9ZTDmLlg=="
82
+ },
63
83
  "NETStandard.Library": {
64
84
  "type": "Transitive",
65
85
  "resolved": "2.0.3",
66
- "contentHash": "st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==",
86
+ "contentHash": "548M6mnBSJWxsIlkQHfbzoYxpiYFXZZSL00p4GHYv8PkiqFBnnT68mW5mGEsA/ch9fDO9GkPgkFQpWiXZN7mAQ==",
67
87
  "dependencies": {
68
88
  "Microsoft.NETCore.Platforms": "1.1.0"
69
89
  }
70
90
  },
91
+ "ReactNative.Hermes.Windows": {
92
+ "type": "Transitive",
93
+ "resolved": "0.11.0-ms.6",
94
+ "contentHash": "WAVLsSZBV4p/3hNC3W67su7xu3f/ZMSKxu0ON7g2GaKRbkJmH0Qyif1IlzcJwtvR48kuOdfgPu7Bgtz3AY+gqg=="
95
+ },
71
96
  "runtime.win10-arm.Microsoft.Net.Native.Compiler": {
72
97
  "type": "Transitive",
73
98
  "resolved": "2.2.7-rel-27913-00",
@@ -135,8 +160,38 @@
135
160
  "resolved": "2.2.9",
136
161
  "contentHash": "qF6RRZKaflI+LR1YODNyWYjq5YoX8IJ2wx5y8O+AW2xO+1t/Q6Mm+jQ38zJbWnmXbrcOqUYofn7Y3/KC6lTLBQ=="
137
162
  },
138
- "microsoft.reactnative": {
163
+ "common": {
139
164
  "type": "Project"
165
+ },
166
+ "fmt": {
167
+ "type": "Project"
168
+ },
169
+ "folly": {
170
+ "type": "Project",
171
+ "dependencies": {
172
+ "boost": "1.76.0",
173
+ "fmt": "1.0.0"
174
+ }
175
+ },
176
+ "microsoft.reactnative": {
177
+ "type": "Project",
178
+ "dependencies": {
179
+ "Common": "1.0.0",
180
+ "Folly": "1.0.0",
181
+ "Microsoft.UI.Xaml": "2.7.0",
182
+ "Microsoft.Windows.CppWinRT": "2.0.211028.7",
183
+ "Microsoft.Windows.SDK.BuildTools": "10.0.22000.194",
184
+ "ReactCommon": "1.0.0",
185
+ "ReactNative.Hermes.Windows": "0.11.0-ms.6",
186
+ "boost": "1.76.0"
187
+ }
188
+ },
189
+ "reactcommon": {
190
+ "type": "Project",
191
+ "dependencies": {
192
+ "Folly": "1.0.0",
193
+ "boost": "1.76.0"
194
+ }
140
195
  }
141
196
  },
142
197
  "UAP,Version=v10.0.16299/win10-arm": {
@@ -10,7 +10,7 @@
10
10
  -->
11
11
  <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
12
12
  <PropertyGroup>
13
- <ReactNativeWindowsVersion>0.69.0-preview.2</ReactNativeWindowsVersion>
13
+ <ReactNativeWindowsVersion>0.69.0-preview.5</ReactNativeWindowsVersion>
14
14
  <ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
15
15
  <ReactNativeWindowsMinor>69</ReactNativeWindowsMinor>
16
16
  <ReactNativeWindowsPatch>0</ReactNativeWindowsPatch>
@@ -8,7 +8,7 @@
8
8
  <!-- Enabling this will (1) Include hermes glues in the Microsoft.ReactNative binaries AND (2) Make hermes the default engine -->
9
9
  <UseHermes Condition="'$(UseHermes)' == ''">false</UseHermes>
10
10
  <!-- This will be true if (1) the client want to use hermes by setting UseHermes to true OR (2) We are building for UWP where dynamic switching is enabled -->
11
- <HermesVersion Condition="'$(HermesVersion)' == ''">0.11.0-ms.2</HermesVersion>
11
+ <HermesVersion Condition="'$(HermesVersion)' == ''">0.11.0-ms.6</HermesVersion>
12
12
  <HermesPackage Condition="'$(HermesPackage)' == '' And Exists('$(PkgReactNative_Hermes_Windows)')">$(PkgReactNative_Hermes_Windows)</HermesPackage>
13
13
  <HermesPackage Condition="'$(HermesPackage)' == ''">$(NuGetPackageRoot)\ReactNative.Hermes.Windows\$(HermesVersion)</HermesPackage>
14
14
  <EnableHermesInspectorInReleaseFlavor Condition="'$(EnableHermesInspectorInReleaseFlavor)' == ''">false</EnableHermesInspectorInReleaseFlavor>
@@ -18,7 +18,7 @@
18
18
  <EnableDevServerHBCBundles Condition="'$(EnableDevServerHBCBundles)' == ''">false</EnableDevServerHBCBundles>
19
19
 
20
20
  <UseV8 Condition="'$(UseV8)' == ''">false</UseV8>
21
- <V8Version Condition="'$(V8Version)' == ''">0.65.11</V8Version>
21
+ <V8Version Condition="'$(V8Version)' == ''">0.69.4</V8Version>
22
22
  <V8PackageName>ReactNative.V8Jsi.Windows</V8PackageName>
23
23
  <V8PackageName Condition="'$(V8AppPlatform)' != 'win32'">$(V8PackageName).UWP</V8PackageName>
24
24
  <V8Package>$(NuGetPackageRoot)\$(V8PackageName).$(V8Version)</V8Package>
@@ -5,19 +5,20 @@ param(
5
5
  [string] $SourceRoot = ($PSScriptRoot | Split-Path | Split-Path | Split-Path),
6
6
  [string] $TargetRoot = "$SourceRoot\vnext\target",
7
7
  [System.IO.DirectoryInfo] $ReactWindowsRoot = "$SourceRoot\vnext",
8
- [System.IO.DirectoryInfo] $ReactNativeRoot = "$SourceRoot\node_modules\react-native",
8
+ [System.IO.DirectoryInfo] $ReactNativeRoot = "$SourceRoot\node_modules\react-native",
9
+ [System.IO.DirectoryInfo] $ReactCommonOverrideRoot = "$ReactWindowsRoot\ReactCommon\TEMP_UntilReactCommonUpdate",
9
10
  [string[]] $Extensions = ('h', 'hpp')
10
11
  )
11
12
 
12
13
  Write-Host "Source root: [$SourceRoot]"
13
14
  Write-Host "Destination root: [$TargetRoot]"
14
15
  Write-Host "React Native root: [$ReactNativeRoot]"
16
+ Write-Host "ReactCommon Override root: [$ReactCommonOverrideRoot]"
15
17
 
16
18
  md -Force $TargetRoot
17
19
 
18
20
  $patterns = $Extensions| ForEach-Object {"*.$_"}
19
21
 
20
-
21
22
  # include headers
22
23
  Copy-Item -Force -Recurse -Path $ReactWindowsRoot\include -Destination $TargetRoot\inc
23
24
 
@@ -27,6 +28,9 @@ Copy-Item -Force -Recurse -Path $ReactWindowsRoot\Microsoft.ReactNative.Cxx -Des
27
28
  # Copy native module spec files
28
29
  Copy-Item -Force -Recurse -Path $ReactWindowsRoot\codegen -Destination $TargetRoot\inc
29
30
 
31
+ # Overwrite temporary ReactCommon files (since this script can runs on a different machine than where ReactCommon was built)
32
+ Copy-Item -Force -Recurse -Path $ReactCommonOverrideRoot\* -Destination $ReactNativeRoot\ReactCommon\
33
+
30
34
  # Microsoft.ReactNative.CXX project JSI files
31
35
  Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\jsi\jsi\decorator.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\jsi\
32
36
  Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\jsi\jsi\instrumentation.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\jsi\
@@ -36,11 +40,11 @@ Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\jsi\jsi\jsi-inl.h -Destinati
36
40
  Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\jsi\jsi\threadsafe.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\jsi\
37
41
 
38
42
  # Microsoft.ReactNative.CXX project TurboModule files
39
- New-Item -ItemType Directory -Path $TargetRoot\Microsoft.ReactNative.Cxx\ReactCommon
43
+ New-Item -ItemType Directory -Path $TargetRoot\Microsoft.ReactNative.Cxx\ReactCommon -Force
40
44
  Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\callinvoker\ReactCommon\CallInvoker.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ReactCommon\
41
- Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\react\bridging\LongLivedObject.cpp -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ReactCommon\
42
45
  Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\react\bridging\CallbackWrapper.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ReactCommon\
43
- Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\react\nativemodule\core\ReactCommon\LongLivedObject.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ReactCommon\
46
+ Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\react\bridging\LongLivedObject.cpp -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ReactCommon\
47
+ Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\react\bridging\LongLivedObject.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ReactCommon\
44
48
  Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\react\nativemodule\core\ReactCommon\TurboModule.cpp -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ReactCommon\
45
49
  Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\react\nativemodule\core\ReactCommon\TurboModule.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ReactCommon\
46
50
  Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\react\nativemodule\core\ReactCommon\TurboModuleUtils.cpp -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ReactCommon\
@@ -3,9 +3,14 @@
3
3
 
4
4
  #pragma once
5
5
 
6
+ // React Native
6
7
  #include <cxxreact/CxxModule.h>
7
8
  #include <smartPtr/cntPtr.h>
8
9
 
10
+ // Windows API
11
+ #include <winrt/Windows.Foundation.h>
12
+
13
+ // Standard Library
9
14
  #include <memory>
10
15
 
11
16
  // Forward declarations. Desktop projects can not access <React.h>
@@ -30,9 +35,19 @@ extern std::unique_ptr<facebook::xplat::module::CxxModule> CreateTimingModule(
30
35
  namespace Microsoft::React {
31
36
 
32
37
  extern const char *GetHttpModuleName() noexcept;
33
- extern std::unique_ptr<facebook::xplat::module::CxxModule> CreateHttpModule() noexcept;
38
+ extern std::unique_ptr<facebook::xplat::module::CxxModule> CreateHttpModule(
39
+ winrt::Windows::Foundation::IInspectable const &inspectableProperties) noexcept;
34
40
 
35
41
  extern const char *GetWebSocketModuleName() noexcept;
36
- extern std::unique_ptr<facebook::xplat::module::CxxModule> CreateWebSocketModule() noexcept;
42
+ extern std::unique_ptr<facebook::xplat::module::CxxModule> CreateWebSocketModule(
43
+ winrt::Windows::Foundation::IInspectable const &inspectableProperties) noexcept;
44
+
45
+ extern const char *GetBlobModuleName() noexcept;
46
+ extern std::unique_ptr<facebook::xplat::module::CxxModule> CreateBlobModule(
47
+ winrt::Windows::Foundation::IInspectable const &inspectableProperties) noexcept;
48
+
49
+ extern const char *GetFileReaderModuleName() noexcept;
50
+ extern std::unique_ptr<facebook::xplat::module::CxxModule> CreateFileReaderModule(
51
+ winrt::Windows::Foundation::IInspectable const &inspectableProperties) noexcept;
37
52
 
38
53
  } // namespace Microsoft::React