react-native-windows 0.66.2 → 0.66.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +73 -1
- package/CHANGELOG.md +42 -8
- package/Chakra/Chakra.vcxitems +0 -1
- package/Chakra/Chakra.vcxitems.filters +0 -3
- package/Chakra/ChakraHelpers.cpp +0 -267
- package/Chakra/ChakraInstanceArgs.h +0 -5
- package/Chakra/ChakraPlatform.h +0 -4
- package/Chakra/ChakraTracing.cpp +0 -33
- package/Chakra/ChakraValue.h +0 -4
- package/Chakra/Utf8DebugExtensions.cpp +0 -5
- package/Chakra/Utf8DebugExtensions.h +0 -6
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +0 -2
- package/Microsoft.ReactNative/Modules/CreateModules.cpp +2 -2
- package/Microsoft.ReactNative/Modules/NativeUIManager.cpp +3 -5
- package/Microsoft.ReactNative/ReactRootView.cpp +28 -3
- package/Microsoft.ReactNative/ReactRootView.h +6 -0
- package/Microsoft.ReactNative/Version.rc +1 -1
- package/Microsoft.ReactNative/Views/RootViewManager.cpp +8 -9
- package/Microsoft.ReactNative.Managed.CodeGen/CodeGenerator.Module.cs +12 -16
- package/Microsoft.ReactNative.Managed.CodeGen/SyntaxHelpers.cs +12 -4
- package/PropertySheets/React.Cpp.props +2 -0
- package/Shared/IWebSocketResource.h +6 -6
- package/Shared/InspectorPackagerConnection.cpp +2 -3
- package/Shared/JSI/ChakraApi.cpp +1 -37
- package/Shared/JSI/ChakraApi.h +0 -4
- package/Shared/JSI/ChakraJsiRuntime_edgemode.cpp +1 -5
- package/Shared/JSI/ChakraRuntime.cpp +0 -12
- package/Shared/JSI/ChakraRuntimeFactory.h +0 -2
- package/Shared/Modules/WebSocketModule.cpp +133 -120
- package/Shared/Modules/WebSocketModule.h +22 -12
- package/Shared/OInstance.cpp +6 -19
- package/Shared/Shared.vcxitems +0 -1
- package/Shared/Shared.vcxitems.filters +0 -3
- package/Shared/WinRTWebSocketResource.cpp +55 -46
- package/Shared/WinRTWebSocketResource.h +2 -9
- package/package.json +2 -2
- package/Chakra/ChakraCoreDebugger.h +0 -147
- package/Scripts/Microsoft.ChakraCore.ARM64.nuspec +0 -50
- package/Scripts/Microsoft.ChakraCore.ARM64.targets +0 -15
- package/Shared/JSI/ChakraCoreRuntime.h +0 -59
|
@@ -337,9 +337,6 @@ void ReactRootView::ShowInstanceLoading() noexcept {
|
|
|
337
337
|
|
|
338
338
|
void ReactRootView::EnsureFocusSafeHarbor() noexcept {
|
|
339
339
|
if (!m_focusSafeHarbor) {
|
|
340
|
-
// focus safe harbor is delayed to be inserted to the visual tree
|
|
341
|
-
VerifyElseCrash(Children().Size() == 1);
|
|
342
|
-
|
|
343
340
|
m_focusSafeHarbor = xaml::Controls::ContentControl{};
|
|
344
341
|
m_focusSafeHarbor.Width(0.0);
|
|
345
342
|
m_focusSafeHarbor.IsTabStop(false);
|
|
@@ -526,4 +523,32 @@ Windows::Foundation::Size ReactRootView::ArrangeOverride(Windows::Foundation::Si
|
|
|
526
523
|
return finalSize;
|
|
527
524
|
}
|
|
528
525
|
|
|
526
|
+
// Maps react-native's view of the root view to the actual UI
|
|
527
|
+
// react-native is unaware that there are non-RN elements within the ReactRootView
|
|
528
|
+
uint32_t ReactRootView::RNIndexToXamlIndex(uint32_t index) noexcept {
|
|
529
|
+
// If m_focusSafeHarbor exists, it should be at index 0
|
|
530
|
+
// m_xamlRootView is the next element, followed by any RN content.
|
|
531
|
+
#if DEBUG
|
|
532
|
+
uint32_t findIndex{0};
|
|
533
|
+
Assert(!m_focusSafeHarbor || Children().IndexOf(m_focusSafeHarbor, findIndex) && findIndex == 0);
|
|
534
|
+
Assert(Children().IndexOf(m_xamlRootView, findIndex) && findIndex == (m_focusSafeHarbor ? 1 : 0));
|
|
535
|
+
#endif
|
|
536
|
+
|
|
537
|
+
return index + (m_focusSafeHarbor ? 2 : 1);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
void ReactRootView::AddView(uint32_t index, xaml::UIElement child) {
|
|
541
|
+
Children().InsertAt(RNIndexToXamlIndex(index), child);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
void ReactRootView::RemoveAllChildren() {
|
|
545
|
+
const uint32_t numLeft = m_focusSafeHarbor ? 2 : 1;
|
|
546
|
+
while (Children().Size() > numLeft)
|
|
547
|
+
Children().RemoveAt(numLeft);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
void ReactRootView::RemoveChildAt(uint32_t index) {
|
|
551
|
+
Children().RemoveAt(RNIndexToXamlIndex(index));
|
|
552
|
+
}
|
|
553
|
+
|
|
529
554
|
} // namespace winrt::Microsoft::ReactNative::implementation
|
|
@@ -42,6 +42,11 @@ struct ReactRootView : ReactRootViewT<ReactRootView>, ::Microsoft::ReactNative::
|
|
|
42
42
|
|
|
43
43
|
void ReloadView() noexcept;
|
|
44
44
|
|
|
45
|
+
// Used by RootViewManager
|
|
46
|
+
void AddView(uint32_t index, xaml::UIElement child);
|
|
47
|
+
void RemoveAllChildren();
|
|
48
|
+
void RemoveChildAt(uint32_t index);
|
|
49
|
+
|
|
45
50
|
public: // IXamlRootView
|
|
46
51
|
::Microsoft::ReactNative::XamlView GetXamlView() const noexcept override;
|
|
47
52
|
|
|
@@ -98,6 +103,7 @@ struct ReactRootView : ReactRootViewT<ReactRootView>, ::Microsoft::ReactNative::
|
|
|
98
103
|
// JS created children
|
|
99
104
|
winrt::Grid m_xamlRootView{nullptr};
|
|
100
105
|
|
|
106
|
+
uint32_t RNIndexToXamlIndex(uint32_t index) noexcept;
|
|
101
107
|
void UpdatePerspective();
|
|
102
108
|
void UpdateRootViewInternal() noexcept;
|
|
103
109
|
void ClearLoadingUI() noexcept;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
#include "RootViewManager.h"
|
|
7
7
|
|
|
8
8
|
#include <IXamlRootView.h>
|
|
9
|
+
#include <ReactRootView.h>
|
|
9
10
|
#include <UI.Xaml.Controls.h>
|
|
10
11
|
|
|
11
12
|
namespace winrt {
|
|
@@ -29,21 +30,19 @@ XamlView RootViewManager::CreateViewCore(int64_t /*tag*/, const winrt::Microsoft
|
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
void RootViewManager::AddView(const XamlView &parent, const XamlView &child, int64_t index) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
panel.Children().InsertAt(static_cast<uint32_t>(index), child.as<xaml::UIElement>());
|
|
33
|
+
// Goes through RootShadowNode::AddView instead of here
|
|
34
|
+
assert(false);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
void RootViewManager::RemoveAllChildren(const XamlView &parent) {
|
|
38
|
-
auto panel(parent.as<winrt::
|
|
39
|
-
|
|
40
|
-
panel.Children().Clear();
|
|
38
|
+
auto panel(parent.as<winrt::Microsoft::ReactNative::ReactRootView>());
|
|
39
|
+
winrt::get_self<winrt::Microsoft::ReactNative::implementation::ReactRootView>(panel)->RemoveAllChildren();
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
void RootViewManager::RemoveChildAt(const XamlView &parent, int64_t index) {
|
|
44
|
-
auto panel(parent.as<winrt::
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
auto panel(parent.as<winrt::Microsoft::ReactNative::ReactRootView>());
|
|
44
|
+
winrt::get_self<winrt::Microsoft::ReactNative::implementation::ReactRootView>(panel)->RemoveChildAt(
|
|
45
|
+
static_cast<uint32_t>(index));
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
void RootViewManager::SetLayoutProps(
|
|
@@ -375,7 +375,7 @@ namespace Microsoft.ReactNative.Managed.CodeGen
|
|
|
375
375
|
{
|
|
376
376
|
// generates:
|
|
377
377
|
// moduleBuilder.AddInitializer((IReactContext reactContext) =>
|
|
378
|
-
// module.MyEvent = (ArgType0 arg0, ArgType1 arg1, ...) => reactContext.EmitJsEvent("eventEmitterName", "eventName", arg0, arg1, ...);
|
|
378
|
+
// module.MyEvent = (ArgType0 arg0, ArgType1 arg1, ...) => new ReactContext(reactContext).EmitJsEvent("eventEmitterName", "eventName", arg0, arg1, ...);
|
|
379
379
|
return InvocationStatement(
|
|
380
380
|
MemberAccessExpression(ReactNativeNames.ModuleBuilder, ReactNativeNames.AddInitializer),
|
|
381
381
|
ParenthesizedLambdaExpression(
|
|
@@ -389,7 +389,7 @@ namespace Microsoft.ReactNative.Managed.CodeGen
|
|
|
389
389
|
{
|
|
390
390
|
// generates:
|
|
391
391
|
// moduleBuilder.AddInitializer((IReactContext reactContext) =>
|
|
392
|
-
// module.MyEvent = (ArgType0 arg0, ArgType1 arg1, ...) => reactContext.EmitJsFunction("moduleName", "eventName", arg0, arg1, ...);
|
|
392
|
+
// module.MyEvent = (ArgType0 arg0, ArgType1 arg1, ...) => new ReactContext(reactContext).EmitJsFunction("moduleName", "eventName", arg0, arg1, ...);
|
|
393
393
|
return InvocationStatement(
|
|
394
394
|
MemberAccessExpression(ReactNativeNames.ModuleBuilder, ReactNativeNames.AddInitializer),
|
|
395
395
|
ParenthesizedLambdaExpression(
|
|
@@ -411,7 +411,7 @@ namespace Microsoft.ReactNative.Managed.CodeGen
|
|
|
411
411
|
block: null,
|
|
412
412
|
expressionBody: InvocationExpression(
|
|
413
413
|
MemberAccessExpression(ReactNativeNames.Module, Identifier(initializer.Method.Name)),
|
|
414
|
-
ObjectCreationExpression(ReactTypes.ReactContext, IdentifierName(
|
|
414
|
+
ObjectCreationExpression(ReactTypes.ReactContext, IdentifierName(ReactNativeNames.ReactContextLocalName))
|
|
415
415
|
)));
|
|
416
416
|
}
|
|
417
417
|
|
|
@@ -420,7 +420,8 @@ namespace Microsoft.ReactNative.Managed.CodeGen
|
|
|
420
420
|
|
|
421
421
|
var lambdaParams = new List<ParameterSyntax>(callback.CallbackParameters.Length);
|
|
422
422
|
var arguments = new List<ArgumentSyntax>(callback.CallbackParameters.Length);
|
|
423
|
-
arguments.Add(Argument(
|
|
423
|
+
arguments.Add(Argument(LiteralExpression(callback.CallbackContextName)));
|
|
424
|
+
arguments.Add(Argument(LiteralExpression(callback.Name)));
|
|
424
425
|
|
|
425
426
|
for (int i = 0; i < callback.CallbackParameters.Length; i++)
|
|
426
427
|
{
|
|
@@ -433,10 +434,10 @@ namespace Microsoft.ReactNative.Managed.CodeGen
|
|
|
433
434
|
|
|
434
435
|
// generates:
|
|
435
436
|
// module.<callackName> = (ArgType0 arg0, ArgType1 arg0, ...) =>
|
|
436
|
-
// reactContext.<contextCallbackMethod>(
|
|
437
|
+
// new ReactContext(reactContext).<contextCallbackMethod>(
|
|
437
438
|
// eventEmitterName,
|
|
438
439
|
// eventName,
|
|
439
|
-
//
|
|
440
|
+
// arg0, arg1, ...
|
|
440
441
|
// )
|
|
441
442
|
return
|
|
442
443
|
AssignmentExpression(
|
|
@@ -446,16 +447,11 @@ namespace Microsoft.ReactNative.Managed.CodeGen
|
|
|
446
447
|
parameterList: ParameterList(lambdaParams.ToArray()),
|
|
447
448
|
block: null,
|
|
448
449
|
expressionBody: InvocationExpression(
|
|
449
|
-
MemberAccessExpression(
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
block: null,
|
|
455
|
-
expressionBody: InvocationExpression(
|
|
456
|
-
MemberAccessExpression(ReactTypes.JSValueWriter, ReactNativeNames.WriteArgsMethodName),
|
|
457
|
-
arguments
|
|
458
|
-
)))));
|
|
450
|
+
MemberAccessExpression(
|
|
451
|
+
ObjectCreationExpression(ReactTypes.ReactContext, IdentifierName(ReactNativeNames.ReactContextLocalName)),
|
|
452
|
+
contextCallbackMethod),
|
|
453
|
+
arguments
|
|
454
|
+
)));
|
|
459
455
|
}
|
|
460
456
|
|
|
461
457
|
private string GetMethodReturnTypeFromStyle(ReactMethod.MethodReturnStyle returnStyle)
|
|
@@ -38,20 +38,28 @@ namespace Microsoft.ReactNative.Managed.CodeGen
|
|
|
38
38
|
return InvocationStatement(SyntaxFactory.IdentifierName(methodName), arguments);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
internal static ExpressionSyntax MemberAccessExpression(
|
|
41
|
+
internal static ExpressionSyntax MemberAccessExpression(ExpressionSyntax instance, SyntaxToken member)
|
|
42
|
+
{
|
|
43
|
+
return SyntaxFactory.MemberAccessExpression(
|
|
44
|
+
SyntaxKind.SimpleMemberAccessExpression,
|
|
45
|
+
instance,
|
|
46
|
+
SyntaxFactory.IdentifierName(member));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
internal static ExpressionSyntax MemberAccessExpression(SyntaxToken instance, SyntaxToken member)
|
|
42
50
|
{
|
|
43
51
|
return SyntaxFactory.MemberAccessExpression(
|
|
44
52
|
SyntaxKind.SimpleMemberAccessExpression,
|
|
45
53
|
SyntaxFactory.IdentifierName(instance),
|
|
46
|
-
SyntaxFactory.IdentifierName(
|
|
54
|
+
SyntaxFactory.IdentifierName(member));
|
|
47
55
|
}
|
|
48
56
|
|
|
49
|
-
internal static ExpressionSyntax MemberAccessExpression(ISymbol type, SyntaxToken
|
|
57
|
+
internal static ExpressionSyntax MemberAccessExpression(ISymbol type, SyntaxToken member)
|
|
50
58
|
{
|
|
51
59
|
return SyntaxFactory.MemberAccessExpression(
|
|
52
60
|
SyntaxKind.SimpleMemberAccessExpression,
|
|
53
61
|
type.ToTypeSyntax(),
|
|
54
|
-
SyntaxFactory.IdentifierName(
|
|
62
|
+
SyntaxFactory.IdentifierName(member));
|
|
55
63
|
}
|
|
56
64
|
|
|
57
65
|
internal static StatementSyntax LocalDeclarationStatement(ISymbol type, SyntaxToken variableName, ExpressionSyntax initializer)
|
|
@@ -85,6 +85,7 @@
|
|
|
85
85
|
BOOST_NO_TYPEID - Configure boost not to check typeid (not to use RTTI)
|
|
86
86
|
BOOST_SYSTEM_SOURCE - Build boost::system symbols from sources (drop dependency on boost_system.lib).
|
|
87
87
|
GTEST_HAS_RTTI - Let GTest know not to use RTTI
|
|
88
|
+
USE_EDGEMODE_JSRT When using Chakra, enforce System Chakra instead of JS9.
|
|
88
89
|
WIN32_LEAN_AND_MEAN - Reduce the Windows API included surface.
|
|
89
90
|
WINRT_LEAN_AND_MEAN - Disable rarely used cppwinrt templates that impact compile-time/PCH size.
|
|
90
91
|
-->
|
|
@@ -96,6 +97,7 @@
|
|
|
96
97
|
BOOST_NO_TYPEID;
|
|
97
98
|
BOOST_SYSTEM_SOURCE;
|
|
98
99
|
GTEST_HAS_RTTI=0;
|
|
100
|
+
USE_EDGEMODE_JSRT;
|
|
99
101
|
WIN32_LEAN_AND_MEAN;
|
|
100
102
|
%(PreprocessorDefinitions)
|
|
101
103
|
</PreprocessorDefinitions>
|
|
@@ -79,17 +79,17 @@ struct IWebSocketResource {
|
|
|
79
79
|
/// <summary>
|
|
80
80
|
/// Creates an <c>IWebSocketResource</c> instance.
|
|
81
81
|
/// </summary>
|
|
82
|
-
|
|
83
|
-
/// WebSocket URL address the instance will connect to.
|
|
84
|
-
/// The address's scheme can be either ws:// or wss://.
|
|
85
|
-
/// </param>
|
|
86
|
-
static std::shared_ptr<IWebSocketResource> Make(std::string &&url);
|
|
82
|
+
static std::shared_ptr<IWebSocketResource> Make();
|
|
87
83
|
|
|
88
84
|
virtual ~IWebSocketResource() noexcept {}
|
|
89
85
|
|
|
90
86
|
/// <summary>
|
|
91
87
|
/// Establishes a continuous connection with the remote endpoint.
|
|
92
88
|
/// </summary>
|
|
89
|
+
/// <param name="url">
|
|
90
|
+
/// WebSocket URL address the instance will connect to.
|
|
91
|
+
/// The address's scheme can be either ws:// or wss://.
|
|
92
|
+
/// </param>
|
|
93
93
|
/// <param name="protocols">
|
|
94
94
|
/// Currently unused
|
|
95
95
|
/// </param>
|
|
@@ -97,7 +97,7 @@ struct IWebSocketResource {
|
|
|
97
97
|
/// HTTP header fields passed by the remote endpoint, to be used in the
|
|
98
98
|
/// handshake process.
|
|
99
99
|
/// </param>
|
|
100
|
-
virtual void Connect(const Protocols &protocols = {}, const Options &options = {}) noexcept = 0;
|
|
100
|
+
virtual void Connect(std::string &&url, const Protocols &protocols = {}, const Options &options = {}) noexcept = 0;
|
|
101
101
|
|
|
102
102
|
/// <summary>
|
|
103
103
|
/// Sends a ping frame to the remote endpoint.
|
|
@@ -204,8 +204,7 @@ winrt::fire_and_forget InspectorPackagerConnection::connectAsync() {
|
|
|
204
204
|
co_await winrt::resume_background();
|
|
205
205
|
|
|
206
206
|
std::vector<winrt::Windows::Security::Cryptography::Certificates::ChainValidationResult> certExceptions;
|
|
207
|
-
m_packagerWebSocketConnection =
|
|
208
|
-
std::make_shared<Microsoft::React::WinRTWebSocketResource>(m_url, std::move(certExceptions));
|
|
207
|
+
m_packagerWebSocketConnection = std::make_shared<Microsoft::React::WinRTWebSocketResource>(std::move(certExceptions));
|
|
209
208
|
|
|
210
209
|
m_packagerWebSocketConnection->SetOnError([](const Microsoft::React::IWebSocketResource::Error &err) {
|
|
211
210
|
facebook::react::tracing::error(err.Message.c_str());
|
|
@@ -270,7 +269,7 @@ winrt::fire_and_forget InspectorPackagerConnection::connectAsync() {
|
|
|
270
269
|
|
|
271
270
|
Microsoft::React::IWebSocketResource::Protocols protocols;
|
|
272
271
|
Microsoft::React::IWebSocketResource::Options options;
|
|
273
|
-
m_packagerWebSocketConnection->Connect(protocols, options);
|
|
272
|
+
m_packagerWebSocketConnection->Connect(std::string{m_url}, protocols, options);
|
|
274
273
|
|
|
275
274
|
co_return;
|
|
276
275
|
}
|
package/Shared/JSI/ChakraApi.cpp
CHANGED
|
@@ -144,17 +144,9 @@ ChakraApi::JsRefHolder::~JsRefHolder() noexcept {
|
|
|
144
144
|
JsPropertyIdRef propertyId{JS_INVALID_REFERENCE};
|
|
145
145
|
// We use a #ifdef here because we can avoid a UTF-8 to UTF-16 conversion
|
|
146
146
|
// using ChakraCore's JsCreatePropertyId API.
|
|
147
|
-
#ifdef CHAKRACORE
|
|
148
|
-
if (React::GetRuntimeOptionBool("JSI.ForceSystemChakra")) {
|
|
149
|
-
std::wstring utf16 = Common::Unicode::Utf8ToUtf16(name.data(), name.length());
|
|
150
|
-
ChakraVerifyJsErrorElseThrow(JsGetPropertyIdFromName(utf16.data(), &propertyId));
|
|
151
|
-
} else {
|
|
152
|
-
ChakraVerifyJsErrorElseThrow(JsCreatePropertyId(name.data(), name.length(), &propertyId));
|
|
153
|
-
}
|
|
154
|
-
#else
|
|
155
147
|
std::wstring utf16 = Common::Unicode::Utf8ToUtf16(name.data(), name.length());
|
|
156
148
|
ChakraVerifyJsErrorElseThrow(JsGetPropertyIdFromName(utf16.data(), &propertyId));
|
|
157
|
-
|
|
149
|
+
|
|
158
150
|
return propertyId;
|
|
159
151
|
}
|
|
160
152
|
|
|
@@ -275,18 +267,7 @@ ChakraApi::JsRefHolder::~JsRefHolder() noexcept {
|
|
|
275
267
|
/*static*/ JsValueRef ChakraApi::PointerToString(std::string_view value) {
|
|
276
268
|
ChakraVerifyElseThrow(value.data(), "Cannot convert a nullptr to a JS string.");
|
|
277
269
|
|
|
278
|
-
// ChakraCore API helps to reduce cost of UTF-8 to UTF-16 conversion.
|
|
279
|
-
#ifdef CHAKRACORE
|
|
280
|
-
if (React::GetRuntimeOptionBool("JSI.ForceSystemChakra")) {
|
|
281
|
-
return PointerToString(Common::Unicode::Utf8ToUtf16(value));
|
|
282
|
-
} else {
|
|
283
|
-
JsValueRef result{JS_INVALID_REFERENCE};
|
|
284
|
-
ChakraVerifyJsErrorElseThrow(JsCreateString(value.data(), value.length(), &result));
|
|
285
|
-
return result;
|
|
286
|
-
}
|
|
287
|
-
#else
|
|
288
270
|
return PointerToString(Common::Unicode::Utf8ToUtf16(value));
|
|
289
|
-
#endif
|
|
290
271
|
}
|
|
291
272
|
|
|
292
273
|
/*static*/ std::wstring_view ChakraApi::StringToPointer(JsValueRef string) {
|
|
@@ -300,24 +281,7 @@ ChakraApi::JsRefHolder::~JsRefHolder() noexcept {
|
|
|
300
281
|
ChakraVerifyElseThrow(
|
|
301
282
|
GetValueType(string) == JsString, "Cannot convert a non JS string ChakraObjectRef to a std::string.");
|
|
302
283
|
|
|
303
|
-
// We use a #ifdef here because we can avoid a UTF-8 to UTF-16 conversion
|
|
304
|
-
// using ChakraCore's JsCopyString API.
|
|
305
|
-
#ifdef CHAKRACORE
|
|
306
|
-
if (React::GetRuntimeOptionBool("JSI.ForceSystemChakra")) {
|
|
307
|
-
return Common::Unicode::Utf16ToUtf8(StringToPointer(string));
|
|
308
|
-
} else {
|
|
309
|
-
size_t length{0};
|
|
310
|
-
ChakraVerifyJsErrorElseThrow(JsCopyString(string, nullptr, 0, &length));
|
|
311
|
-
|
|
312
|
-
std::string result(length, 'a');
|
|
313
|
-
ChakraVerifyJsErrorElseThrow(JsCopyString(string, result.data(), result.length(), &length));
|
|
314
|
-
|
|
315
|
-
ChakraVerifyElseThrow(length == result.length(), "Failed to convert a JS string to a std::string.");
|
|
316
|
-
return result;
|
|
317
|
-
}
|
|
318
|
-
#else
|
|
319
284
|
return Common::Unicode::Utf16ToUtf8(StringToPointer(string));
|
|
320
|
-
#endif
|
|
321
285
|
}
|
|
322
286
|
|
|
323
287
|
/*static*/ JsValueRef ChakraApi::ConvertValueToString(JsValueRef value) {
|
package/Shared/JSI/ChakraApi.h
CHANGED
|
@@ -15,7 +15,7 @@ JsStartDebugging();
|
|
|
15
15
|
|
|
16
16
|
namespace Microsoft::JSI {
|
|
17
17
|
|
|
18
|
-
#if defined(USE_EDGEMODE_JSRT)
|
|
18
|
+
#if defined(USE_EDGEMODE_JSRT)
|
|
19
19
|
/*static*/ void ChakraRuntime::initRuntimeVersion() noexcept {}
|
|
20
20
|
#endif
|
|
21
21
|
|
|
@@ -42,11 +42,7 @@ std::unique_ptr<const facebook::jsi::Buffer> SystemChakraRuntime::generatePrepar
|
|
|
42
42
|
const std::wstring scriptUTF16 =
|
|
43
43
|
Microsoft::Common::Unicode::Utf8ToUtf16(reinterpret_cast<const char *>(sourceBuffer.data()), sourceBuffer.size());
|
|
44
44
|
|
|
45
|
-
#ifdef CHAKRACORE
|
|
46
|
-
unsigned int bytecodeSize = 0;
|
|
47
|
-
#else
|
|
48
45
|
unsigned long bytecodeSize = 0;
|
|
49
|
-
#endif
|
|
50
46
|
if (JsSerializeScript(scriptUTF16.c_str(), nullptr, &bytecodeSize) == JsNoError) {
|
|
51
47
|
std::unique_ptr<ByteArrayBuffer> bytecodeBuffer(std::make_unique<ByteArrayBuffer>(bytecodeSize));
|
|
52
48
|
if (JsSerializeScript(scriptUTF16.c_str(), bytecodeBuffer->data(), &bytecodeSize) == JsNoError) {
|
|
@@ -16,14 +16,10 @@
|
|
|
16
16
|
#include <sstream>
|
|
17
17
|
#include <unordered_set>
|
|
18
18
|
|
|
19
|
-
#ifdef CHAKRACORE
|
|
20
|
-
#include <ChakraCore.h>
|
|
21
|
-
#else
|
|
22
19
|
#ifndef USE_EDGEMODE_JSRT
|
|
23
20
|
#define USE_EDGEMODE_JSRT
|
|
24
21
|
#endif
|
|
25
22
|
#include <jsrt.h>
|
|
26
|
-
#endif
|
|
27
23
|
|
|
28
24
|
namespace Microsoft::JSI {
|
|
29
25
|
|
|
@@ -1011,15 +1007,7 @@ std::once_flag ChakraRuntime::s_runtimeVersionInitFlag;
|
|
|
1011
1007
|
uint64_t ChakraRuntime::s_runtimeVersion = 0;
|
|
1012
1008
|
|
|
1013
1009
|
std::unique_ptr<facebook::jsi::Runtime> makeChakraRuntime(ChakraRuntimeArgs &&args) noexcept {
|
|
1014
|
-
#ifdef CHAKRACORE
|
|
1015
|
-
if (React::GetRuntimeOptionBool("JSI.ForceSystemChakra")) {
|
|
1016
|
-
return MakeSystemChakraRuntime(std::move(args));
|
|
1017
|
-
} else {
|
|
1018
|
-
return MakeChakraCoreRuntime(std::move(args));
|
|
1019
|
-
}
|
|
1020
|
-
#else
|
|
1021
1010
|
return MakeSystemChakraRuntime(std::move(args));
|
|
1022
|
-
#endif // CHAKRACORE
|
|
1023
1011
|
}
|
|
1024
1012
|
|
|
1025
1013
|
} // namespace Microsoft::JSI
|
|
@@ -11,7 +11,5 @@ struct ChakraRuntimeArgs;
|
|
|
11
11
|
|
|
12
12
|
std::unique_ptr<facebook::jsi::Runtime> makeChakraRuntime(ChakraRuntimeArgs &&args) noexcept;
|
|
13
13
|
|
|
14
|
-
std::unique_ptr<facebook::jsi::Runtime> MakeChakraCoreRuntime(ChakraRuntimeArgs &&args) noexcept;
|
|
15
|
-
|
|
16
14
|
std::unique_ptr<facebook::jsi::Runtime> MakeSystemChakraRuntime(ChakraRuntimeArgs &&args) noexcept;
|
|
17
15
|
} // namespace Microsoft::JSI
|