diff --git a/React/Inspector/RCTInspector.h b/React/Inspector/RCTInspector.h index 1fcba088e..41bd146e0 100644 --- a/React/Inspector/RCTInspector.h +++ b/React/Inspector/RCTInspector.h @@ -15,6 +15,7 @@ @interface RCTInspectorPage : NSObject @property (nonatomic, readonly) NSInteger id; @property (nonatomic, readonly) NSString *title; +@property (nonatomic, readonly) NSString *vm; @end @interface RCTInspector : NSObject diff --git a/React/Inspector/RCTInspector.mm b/React/Inspector/RCTInspector.mm index 1cc3d1d3a..0bb83db45 100644 --- a/React/Inspector/RCTInspector.mm +++ b/React/Inspector/RCTInspector.mm @@ -38,9 +38,11 @@ private: @interface RCTInspectorPage () { NSInteger _id; NSString *_title; + NSString *_vm; } - (instancetype)initWithId:(NSInteger)id - title:(NSString *)title; + title:(NSString *)title + vm:(NSString *)vm; @end @interface RCTInspectorLocalConnection () { @@ -64,7 +66,8 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) NSMutableArray *array = [NSMutableArray arrayWithCapacity:pages.size()]; for (size_t i = 0; i < pages.size(); i++) { RCTInspectorPage *pageWrapper = [[RCTInspectorPage alloc] initWithId:pages[i].id - title:@(pages[i].title.c_str())]; + title:@(pages[i].title.c_str()) + vm:@(pages[i].vm.c_str())]; [array addObject:pageWrapper]; } @@ -86,10 +89,12 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) - (instancetype)initWithId:(NSInteger)id title:(NSString *)title + vm:(NSString *)vm { if (self = [super init]) { _id = id; _title = title; + _vm = vm; } return self; } diff --git a/React/Inspector/RCTInspectorPackagerConnection.m b/React/Inspector/RCTInspectorPackagerConnection.m index cf1cd2abf..1b2663403 100644 --- a/React/Inspector/RCTInspectorPackagerConnection.m +++ b/React/Inspector/RCTInspectorPackagerConnection.m @@ -155,6 +155,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) @"id": [@(page.id) stringValue], @"title": page.title, @"app": [[NSBundle mainBundle] bundleIdentifier], + @"vm": page.vm, @"isLastBundleDownloadSuccess": bundleStatus == nil ? [NSNull null] : @(bundleStatus.isLastBundleDownloadSuccess), diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/Inspector.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/Inspector.java index 372b9ad90..9aebad6c7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/Inspector.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/Inspector.java @@ -51,6 +51,7 @@ public class Inspector { public static class Page { private final int mId; private final String mTitle; + private final String mVM; public int getId() { return mId; @@ -60,6 +61,10 @@ public class Inspector { return mTitle; } + public String getVM() { + return mVM; + } + @Override public String toString() { return "Page{" + @@ -69,9 +74,10 @@ public class Inspector { } @DoNotStrip - private Page(int id, String title) { + private Page(int id, String title, String vm) { mId = id; mTitle = title; + mVM = vm; } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java index 1176d38ca..8df47d9d3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java @@ -154,6 +154,7 @@ public class InspectorPackagerConnection { jsonPage.put("id", String.valueOf(page.getId())); jsonPage.put("title", page.getTitle()); jsonPage.put("app", mPackageName); + jsonPage.put("vm", page.getVM()); jsonPage.put("isLastBundleDownloadSuccess", bundleStatus.isLastDownloadSucess); jsonPage.put("bundleUpdateTimestamp", bundleStatus.updateTimestamp); array.put(jsonPage); diff --git a/ReactAndroid/src/main/jni/react/jni/JInspector.cpp b/ReactAndroid/src/main/jni/react/jni/JInspector.cpp index 8e64ce1ad..470002794 100644 --- a/ReactAndroid/src/main/jni/react/jni/JInspector.cpp +++ b/ReactAndroid/src/main/jni/react/jni/JInspector.cpp @@ -28,9 +28,9 @@ private: } -jni::local_ref JPage::create(int id, const std::string& title) { - static auto constructor = javaClassStatic()->getConstructor)>(); - return javaClassStatic()->newObject(constructor, id, jni::make_jstring(title)); +jni::local_ref JPage::create(int id, const std::string& title, const std::string& vm) { + static auto constructor = javaClassStatic()->getConstructor, jni::local_ref)>(); + return javaClassStatic()->newObject(constructor, id, jni::make_jstring(title), jni::make_jstring(vm)); } void JRemoteConnection::onMessage(const std::string& message) const { @@ -70,7 +70,7 @@ jni::local_ref> JInspector::getPages() { std::vector pages = inspector_->getPages(); auto array = jni::JArrayClass::newArray(pages.size()); for (size_t i = 0; i < pages.size(); i++) { - (*array)[i] = JPage::create(pages[i].id, pages[i].title); + (*array)[i] = JPage::create(pages[i].id, pages[i].title, pages[i].vm); } return array; } diff --git a/ReactAndroid/src/main/jni/react/jni/JInspector.h b/ReactAndroid/src/main/jni/react/jni/JInspector.h index c170fe59d..9e089687e 100644 --- a/ReactAndroid/src/main/jni/react/jni/JInspector.h +++ b/ReactAndroid/src/main/jni/react/jni/JInspector.h @@ -16,7 +16,7 @@ class JPage : public jni::JavaClass { public: static constexpr auto kJavaDescriptor = "Lcom/facebook/react/bridge/Inspector$Page;"; - static jni::local_ref create(int id, const std::string& title); + static jni::local_ref create(int id, const std::string& title, const std::string& vm); }; class JRemoteConnection : public jni::JavaClass { diff --git a/ReactCommon/jsinspector/InspectorInterfaces.cpp b/ReactCommon/jsinspector/InspectorInterfaces.cpp index f1fa2ed57..bb20b8ad6 100644 --- a/ReactCommon/jsinspector/InspectorInterfaces.cpp +++ b/ReactCommon/jsinspector/InspectorInterfaces.cpp @@ -11,6 +11,7 @@ #include #include +#include namespace facebook { namespace react { @@ -27,7 +28,7 @@ namespace { class InspectorImpl : public IInspector { public: - int addPage(const std::string& title, ConnectFunc connectFunc) override; + int addPage(const std::string& title, const std::string& vm, ConnectFunc connectFunc) override; void removePage(int pageId) override; std::vector getPages() const override; @@ -38,15 +39,15 @@ class InspectorImpl : public IInspector { private: mutable std::mutex mutex_; int nextPageId_{1}; - std::unordered_map titles_; + std::unordered_map> titles_; std::unordered_map connectFuncs_; }; -int InspectorImpl::addPage(const std::string& title, ConnectFunc connectFunc) { +int InspectorImpl::addPage(const std::string& title, const std::string& vm, ConnectFunc connectFunc) { std::lock_guard lock(mutex_); int pageId = nextPageId_++; - titles_[pageId] = title; + titles_[pageId] = std::make_tuple(title, vm); connectFuncs_[pageId] = std::move(connectFunc); return pageId; @@ -64,7 +65,7 @@ std::vector InspectorImpl::getPages() const { std::vector inspectorPages; for (auto& it : titles_) { - inspectorPages.push_back(InspectorPage{it.first, it.second}); + inspectorPages.push_back(InspectorPage{it.first, std::get<0>(it.second), std::get<1>(it.second)}); } return inspectorPages; diff --git a/ReactCommon/jsinspector/InspectorInterfaces.h b/ReactCommon/jsinspector/InspectorInterfaces.h index 0222501f3..d62eab401 100644 --- a/ReactCommon/jsinspector/InspectorInterfaces.h +++ b/ReactCommon/jsinspector/InspectorInterfaces.h @@ -25,6 +25,7 @@ class IDestructible { struct InspectorPage { const int id; const std::string title; + const std::string vm; }; /// IRemoteConnection allows the VM to send debugger messages to the client. @@ -52,7 +53,7 @@ class IInspector : public IDestructible { virtual ~IInspector() = 0; /// addPage is called by the VM to add a page to the list of debuggable pages. - virtual int addPage(const std::string& title, ConnectFunc connectFunc) = 0; + virtual int addPage(const std::string& title, const std::string& vm, ConnectFunc connectFunc) = 0; /// removePage is called by the VM to remove a page from the list of /// debuggable pages.