From 3337c288937a9332961aa2b307a877022d22a039 Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Fri, 25 Aug 2023 04:53:34 -0700 Subject: [PATCH 01/54] Don't break the build if the reactdevtools patching fails (#5070) Summary: [flipper] Don't break the build if the reactdevtools patching fails There seems to be a bug in yarn workspaces on Windows: ``` Error: Cannot find module 'D:\\a\\flipper\\flipper\\desktop\\plugins\\public\\node_modules\\node_modules\\ts-node\\dist\\bin.js ``` Pull Request resolved: https://github.com/facebook/flipper/pull/5070 Test Plan: Let's see if CI will be happy again. Reviewed By: lblasa Differential Revision: D48681388 Pulled By: passy fbshipit-source-id: d41f21be09c9d060e3c68e36466cfc54b3272325 --- desktop/plugins/public/reactdevtools/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop/plugins/public/reactdevtools/package.json b/desktop/plugins/public/reactdevtools/package.json index bc8e843951b..32139443acb 100644 --- a/desktop/plugins/public/reactdevtools/package.json +++ b/desktop/plugins/public/reactdevtools/package.json @@ -39,6 +39,6 @@ "flipper-plugin": "*" }, "scripts": { - "postinstall": "ts-node scripts/remove-sourcemap-reference.tsx" + "postinstall": "ts-node scripts/remove-sourcemap-reference.tsx || true" } } From ffae44f4468ead03ddb31f01b64faee18bb2edb3 Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Fri, 25 Aug 2023 07:05:30 -0700 Subject: [PATCH 02/54] Remove '$' prefix Summary: Fixes the following issue: {F1076395349} Reviewed By: passy Differential Revision: D48681839 fbshipit-source-id: b11475ef58c872eacee0bb513b5ad15423fccdf6 --- desktop/flipper-ui-core/src/dispatcher/flipperServer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop/flipper-ui-core/src/dispatcher/flipperServer.tsx b/desktop/flipper-ui-core/src/dispatcher/flipperServer.tsx index a9692b4df49..4e06d880880 100644 --- a/desktop/flipper-ui-core/src/dispatcher/flipperServer.tsx +++ b/desktop/flipper-ui-core/src/dispatcher/flipperServer.tsx @@ -306,7 +306,7 @@ function showConnectivityTroubleshootNotification( message, description: ( -

${description}

+

{description}

)) From 554d2f9b83395d10c1fee54952607b4a51edfd45 Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Tue, 29 Aug 2023 05:06:18 -0700 Subject: [PATCH 10/54] Bump ES level to 2021 Summary: Updating the remaining tsconfigs to build for an ES2021 target. Reviewed By: antonk52 Differential Revision: D48687661 fbshipit-source-id: 2761704d251f701594ca5d362a17731f287088ed --- desktop/app/tsconfig.json | 2 +- desktop/flipper-common/tsconfig.json | 2 +- desktop/flipper-frontend-core/tsconfig.json | 2 +- desktop/flipper-plugin-core/tsconfig.json | 2 +- desktop/flipper-server-client/tsconfig.json | 2 +- desktop/flipper-server/tsconfig.json | 2 +- desktop/flipper-ui-browser/tsconfig.json | 2 +- desktop/scripts/tsconfig.json | 2 +- desktop/tsconfig.base.json | 4 ++-- desktop/tsconfig.json | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/desktop/app/tsconfig.json b/desktop/app/tsconfig.json index 985549b3508..3936800f6fa 100644 --- a/desktop/app/tsconfig.json +++ b/desktop/app/tsconfig.json @@ -5,7 +5,7 @@ "rootDir": "src", "esModuleInterop": true, "emitDeclarationOnly": true, - "lib": ["DOM", "ES2019"], + "lib": ["DOM", "ES2021"], "types": [ "../types/flipperGlobals" ] diff --git a/desktop/flipper-common/tsconfig.json b/desktop/flipper-common/tsconfig.json index b13b1421c6a..b075abb87b8 100644 --- a/desktop/flipper-common/tsconfig.json +++ b/desktop/flipper-common/tsconfig.json @@ -3,7 +3,7 @@ "compilerOptions": { "outDir": "lib", "rootDir": "src", - "lib": ["dom", "ES2019"] + "lib": ["dom", "ES2021"] }, "references": [] } diff --git a/desktop/flipper-frontend-core/tsconfig.json b/desktop/flipper-frontend-core/tsconfig.json index 7d648e3d01f..fb0fd791582 100644 --- a/desktop/flipper-frontend-core/tsconfig.json +++ b/desktop/flipper-frontend-core/tsconfig.json @@ -3,7 +3,7 @@ "compilerOptions": { "outDir": "lib", "rootDir": "src", - "lib": ["dom", "ES2019"], + "lib": ["dom", "ES2021"], "types": ["../types/flipperGlobals"] }, "references": [ diff --git a/desktop/flipper-plugin-core/tsconfig.json b/desktop/flipper-plugin-core/tsconfig.json index f9a26ecc1b6..677da4a8481 100644 --- a/desktop/flipper-plugin-core/tsconfig.json +++ b/desktop/flipper-plugin-core/tsconfig.json @@ -3,7 +3,7 @@ "compilerOptions": { "outDir": "lib", "rootDir": "src", - "lib": ["dom", "ES2019"], + "lib": ["dom", "ES2021"], "types": ["jest", "../types/jest-extensions", "react/next", "react-dom/next"] }, "references": [ diff --git a/desktop/flipper-server-client/tsconfig.json b/desktop/flipper-server-client/tsconfig.json index 90d3a90a006..352a4bb469e 100644 --- a/desktop/flipper-server-client/tsconfig.json +++ b/desktop/flipper-server-client/tsconfig.json @@ -3,7 +3,7 @@ "compilerOptions": { "outDir": "lib", "rootDir": "src", - "lib": ["dom", "ES2019"] + "lib": ["dom", "ES2021"] }, "references": [ { diff --git a/desktop/flipper-server/tsconfig.json b/desktop/flipper-server/tsconfig.json index 1ba68669e06..4c526ac8be8 100644 --- a/desktop/flipper-server/tsconfig.json +++ b/desktop/flipper-server/tsconfig.json @@ -3,7 +3,7 @@ "compilerOptions": { "outDir": "lib", "rootDir": "src", - "lib": ["DOM", "ES2019"], + "lib": ["DOM", "ES2021"], "types": ["../types/flipperGlobals", "../types/metro-resolver", "../types/metro"] }, "include": ["./src/*"], diff --git a/desktop/flipper-ui-browser/tsconfig.json b/desktop/flipper-ui-browser/tsconfig.json index 84faf876b13..666b09f0344 100644 --- a/desktop/flipper-ui-browser/tsconfig.json +++ b/desktop/flipper-ui-browser/tsconfig.json @@ -3,7 +3,7 @@ "compilerOptions": { "outDir": "lib", "rootDir": "src", - "lib": ["dom", "ES2019"], + "lib": ["dom", "ES2021"], "types": ["../types/flipperGlobals", "react/next", "react-dom/next"] }, "references": [ diff --git a/desktop/scripts/tsconfig.json b/desktop/scripts/tsconfig.json index d8dad301594..06fdd1ba842 100644 --- a/desktop/scripts/tsconfig.json +++ b/desktop/scripts/tsconfig.json @@ -3,7 +3,7 @@ "compilerOptions": { "outDir": "lib", "rootDir": ".", - "lib": ["ES2019"], + "lib": ["ES2021"], "noEmit": true, "esModuleInterop": true, "types": ["jest"] diff --git a/desktop/tsconfig.base.json b/desktop/tsconfig.base.json index 28f308cde4e..bd5657288a9 100644 --- a/desktop/tsconfig.base.json +++ b/desktop/tsconfig.base.json @@ -1,9 +1,9 @@ { "compilerOptions": { "module": "commonjs", - "lib": ["ES2019"], + "lib": ["ES2021"], "esModuleInterop": true, - "target": "ES2019", + "target": "ES2021", "removeComments": false, "preserveConstEnums": true, "sourceMap": true, diff --git a/desktop/tsconfig.json b/desktop/tsconfig.json index 367048c4ea4..312af20c716 100644 --- a/desktop/tsconfig.json +++ b/desktop/tsconfig.json @@ -6,7 +6,7 @@ "composite": false, "allowJs": false, // for unit tests: - "lib": ["DOM", "ES2019"], + "lib": ["DOM", "ES2021"], "types": ["jest"] }, "exclude": [ From c91652d5de86915c19d0d274f715550e6590e0b6 Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Tue, 29 Aug 2023 09:49:56 -0700 Subject: [PATCH 11/54] Don't throw errors for Watchman not found Summary: Changelog: Don't throw an error if Watchman was not found Reviewed By: aigoncharov Differential Revision: D48778121 fbshipit-source-id: bfe3599e41d8c6fbe4ea89393ace5213914a2611 --- desktop/flipper-common/src/utils/LoggerTailer.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/desktop/flipper-common/src/utils/LoggerTailer.tsx b/desktop/flipper-common/src/utils/LoggerTailer.tsx index 98d50816bd0..258eeaa9b4e 100644 --- a/desktop/flipper-common/src/utils/LoggerTailer.tsx +++ b/desktop/flipper-common/src/utils/LoggerTailer.tsx @@ -70,6 +70,10 @@ function transformLogLevel(level: LoggerTypes, message: string) { if (message.endsWith('Network Error')) { return 'warn'; } + + if (message.includes('Watchman was not found in PATH')) { + return 'warn'; + } } return level; From f658b5c362a5cb3d0fd04f47153a53cb4cc80e47 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Aug 2023 09:56:20 -0700 Subject: [PATCH 12/54] Bump serde from 1.0.185 to 1.0.188 in /packer (#5090) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Bumps [serde](https://github.com/serde-rs/serde) from 1.0.185 to 1.0.188.
Release notes

Sourced from serde's releases.

v1.0.188

v1.0.187

v1.0.186

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=serde&package-manager=cargo&previous-version=1.0.185&new-version=1.0.188)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `dependabot rebase` will rebase this PR - `dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `dependabot merge` will merge this PR after your CI passes on it - `dependabot squash and merge` will squash and merge this PR after your CI passes on it - `dependabot cancel merge` will cancel a previously requested merge and block automerging - `dependabot reopen` will reopen this PR if it is closed - `dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Pull Request resolved: https://github.com/facebook/flipper/pull/5090 Reviewed By: aigoncharov Differential Revision: D48778219 Pulled By: passy fbshipit-source-id: fdf558152f45ad2e1961b660de19ce4abe94812d --- packer/Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packer/Cargo.lock b/packer/Cargo.lock index 36d105fa042..a967e87289f 100644 --- a/packer/Cargo.lock +++ b/packer/Cargo.lock @@ -700,18 +700,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.185" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be9b6f69f1dfd54c3b568ffa45c310d6973a5e5148fd40cf515acaf38cf5bc31" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.185" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc59dfdcbad1437773485e0367fea4b090a2e0a16d9ffc46af47764536a298ec" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", From 981a0ed6c8a382264a9f597b12533d4845ed7eb6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 29 Aug 2023 09:58:41 -0700 Subject: [PATCH 13/54] Automated: Update Podfile.lock (#5078) Summary: This is an automated PR to update the Podfile.lock. - Make sure that the Podfile.lock contains latest FlipperKit and Flipper pod versions. - Also make sure that all the dependencies are updated to the latest one. - This is auto-generated by [create-pull-request](https://github.com/peter-evans/create-pull-request) Pull Request resolved: https://github.com/facebook/flipper/pull/5078 Reviewed By: aigoncharov Differential Revision: D48778220 Pulled By: passy fbshipit-source-id: 31f63b9f129f3d0c9914d9c4aba499e8cc7455dc --- Flipper.podspec | 2 +- FlipperKit.podspec | 2 +- docs/getting-started/ios-native.mdx | 2 +- iOS/Sample/Podfile.lock | 46 ++++++------ iOS/SampleSwift/Podfile.lock | 42 +++++------ iOS/Tutorial/Podfile | 2 +- iOS/Tutorial/Podfile.lock | 52 +++++++------- .../ReactNativeFlipperExample/ios/Podfile | 2 +- .../ios/Podfile.lock | 72 +++++++++---------- 9 files changed, 111 insertions(+), 111 deletions(-) diff --git a/Flipper.podspec b/Flipper.podspec index 14518f7f082..7c0f1a1c2e0 100644 --- a/Flipper.podspec +++ b/Flipper.podspec @@ -3,7 +3,7 @@ # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. -flipperkit_version = '0.212.0' +flipperkit_version = '0.213.0' Pod::Spec.new do |spec| spec.name = 'Flipper' spec.cocoapods_version = '>= 1.10' diff --git a/FlipperKit.podspec b/FlipperKit.podspec index 02c43dce0e6..3826305ef50 100644 --- a/FlipperKit.podspec +++ b/FlipperKit.podspec @@ -4,7 +4,7 @@ # LICENSE file in the root directory of this source tree. folly_compiler_flags = '-DDEBUG=1 -DFLIPPER_OSS=1 -DFB_SONARKIT_ENABLED=1 -DFOLLY_HAVE_BACKTRACE=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_LIBGFLAGS=0 -DFOLLY_HAVE_LIBJEMALLOC=0 -DFOLLY_HAVE_PREADV=0 -DFOLLY_HAVE_PWRITEV=0 -DFOLLY_HAVE_TFO=0 -DFOLLY_USE_SYMBOLIZER=0' -flipperkit_version = '0.212.0' +flipperkit_version = '0.213.0' Pod::Spec.new do |spec| spec.name = 'FlipperKit' spec.version = flipperkit_version diff --git a/docs/getting-started/ios-native.mdx b/docs/getting-started/ios-native.mdx index 4f662aaecc1..0d16811110c 100644 --- a/docs/getting-started/ios-native.mdx +++ b/docs/getting-started/ios-native.mdx @@ -19,7 +19,7 @@ The following configuration assumes CocoaPods 1.9+: ```ruby project 'MyApp.xcodeproj' -flipperkit_version = '0.212.0' +flipperkit_version = '0.213.0' target 'MyApp' do platform :ios, '10.0' diff --git a/iOS/Sample/Podfile.lock b/iOS/Sample/Podfile.lock index 92508a794d7..2a9af58b693 100644 --- a/iOS/Sample/Podfile.lock +++ b/iOS/Sample/Podfile.lock @@ -1,6 +1,6 @@ PODS: - CocoaAsyncSocket (7.6.5) - - Flipper (0.212.0): + - Flipper (0.213.0): - Flipper-Folly (~> 2.6) - Flipper-Boost-iOSX (1.76.0.1.11) - Flipper-DoubleConversion (3.2.0.1) @@ -14,50 +14,50 @@ PODS: - OpenSSL-Universal (= 1.1.1100) - Flipper-Glog (0.5.0.5) - Flipper-PeerTalk (0.0.4) - - FlipperKit (0.212.0): - - FlipperKit/Core (= 0.212.0) - - FlipperKit/Core (0.212.0): - - Flipper (~> 0.212.0) + - FlipperKit (0.213.0): + - FlipperKit/Core (= 0.213.0) + - FlipperKit/Core (0.213.0): + - Flipper (~> 0.213.0) - FlipperKit/CppBridge - FlipperKit/FBCxxFollyDynamicConvert - FlipperKit/FBDefines - FlipperKit/FKPortForwarding - SocketRocket (~> 0.7.0) - - FlipperKit/CppBridge (0.212.0): - - Flipper (~> 0.212.0) - - FlipperKit/FBCxxFollyDynamicConvert (0.212.0): + - FlipperKit/CppBridge (0.213.0): + - Flipper (~> 0.213.0) + - FlipperKit/FBCxxFollyDynamicConvert (0.213.0): - Flipper-Folly (~> 2.6) - - FlipperKit/FBDefines (0.212.0) - - FlipperKit/FKPortForwarding (0.212.0): + - FlipperKit/FBDefines (0.213.0) + - FlipperKit/FKPortForwarding (0.213.0): - CocoaAsyncSocket (~> 7.6) - Flipper-PeerTalk (~> 0.0.4) - - FlipperKit/FlipperKitExamplePlugin (0.212.0): + - FlipperKit/FlipperKitExamplePlugin (0.213.0): - FlipperKit/Core - - FlipperKit/FlipperKitHighlightOverlay (0.212.0) - - FlipperKit/FlipperKitLayoutHelpers (0.212.0): + - FlipperKit/FlipperKitHighlightOverlay (0.213.0) + - FlipperKit/FlipperKitLayoutHelpers (0.213.0): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutIOSDescriptors (0.212.0): + - FlipperKit/FlipperKitLayoutIOSDescriptors (0.213.0): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutHelpers - - FlipperKit/FlipperKitLayoutPlugin (0.212.0): + - FlipperKit/FlipperKitLayoutPlugin (0.213.0): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutHelpers - FlipperKit/FlipperKitLayoutIOSDescriptors - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutTextSearchable (0.212.0) - - FlipperKit/FlipperKitNetworkPlugin (0.212.0): + - FlipperKit/FlipperKitLayoutTextSearchable (0.213.0) + - FlipperKit/FlipperKitNetworkPlugin (0.213.0): - FlipperKit/Core - - FlipperKit/FlipperKitReactPlugin (0.212.0): + - FlipperKit/FlipperKitReactPlugin (0.213.0): - FlipperKit/Core - - FlipperKit/FlipperKitUIDebuggerPlugin (0.212.0): + - FlipperKit/FlipperKitUIDebuggerPlugin (0.213.0): - FlipperKit/Core - - FlipperKit/FlipperKitUserDefaultsPlugin (0.212.0): + - FlipperKit/FlipperKitUserDefaultsPlugin (0.213.0): - FlipperKit/Core - - FlipperKit/SKIOSNetworkPlugin (0.212.0): + - FlipperKit/SKIOSNetworkPlugin (0.213.0): - FlipperKit/Core - FlipperKit/FlipperKitNetworkPlugin - libevent (2.1.12) @@ -104,14 +104,14 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 - Flipper: b7a3d90634c855fece9d491ca69f682f1244984f + Flipper: a7da258b85c9df7103e5f8aeff4f0f90a9ec2c46 Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c Flipper-DoubleConversion: 2dc99b02f658daf147069aad9dbd29d8feb06d30 Flipper-Fmt: 60cbdd92fc254826e61d669a5d87ef7015396a9b Flipper-Folly: 584845625005ff068a6ebf41f857f468decd26b3 Flipper-Glog: 70c50ce58ddaf67dc35180db05f191692570f446 Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 - FlipperKit: 73b2e0c1ed75801151dab992313b6b1951b67446 + FlipperKit: 1e62027a910f6dd1c722858eeb7967b3d6531ae3 libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d diff --git a/iOS/SampleSwift/Podfile.lock b/iOS/SampleSwift/Podfile.lock index 56fb3b378a7..82e6cab39fd 100644 --- a/iOS/SampleSwift/Podfile.lock +++ b/iOS/SampleSwift/Podfile.lock @@ -1,7 +1,7 @@ PODS: - boost-for-react-native (1.63.0) - CocoaAsyncSocket (7.6.5) - - Flipper (0.212.0): + - Flipper (0.213.0): - Flipper-Folly (~> 2.6) - Flipper-Boost-iOSX (1.76.0.1.11) - Flipper-DoubleConversion (3.2.0.1) @@ -15,46 +15,46 @@ PODS: - OpenSSL-Universal (= 1.1.1100) - Flipper-Glog (0.5.0.5) - Flipper-PeerTalk (0.0.4) - - FlipperKit (0.212.0): - - FlipperKit/Core (= 0.212.0) - - FlipperKit/Core (0.212.0): - - Flipper (~> 0.212.0) + - FlipperKit (0.213.0): + - FlipperKit/Core (= 0.213.0) + - FlipperKit/Core (0.213.0): + - Flipper (~> 0.213.0) - FlipperKit/CppBridge - FlipperKit/FBCxxFollyDynamicConvert - FlipperKit/FBDefines - FlipperKit/FKPortForwarding - SocketRocket (~> 0.7.0) - - FlipperKit/CppBridge (0.212.0): - - Flipper (~> 0.212.0) - - FlipperKit/FBCxxFollyDynamicConvert (0.212.0): + - FlipperKit/CppBridge (0.213.0): + - Flipper (~> 0.213.0) + - FlipperKit/FBCxxFollyDynamicConvert (0.213.0): - Flipper-Folly (~> 2.6) - - FlipperKit/FBDefines (0.212.0) - - FlipperKit/FKPortForwarding (0.212.0): + - FlipperKit/FBDefines (0.213.0) + - FlipperKit/FKPortForwarding (0.213.0): - CocoaAsyncSocket (~> 7.6) - Flipper-PeerTalk (~> 0.0.4) - - FlipperKit/FlipperKitExamplePlugin (0.212.0): + - FlipperKit/FlipperKitExamplePlugin (0.213.0): - FlipperKit/Core - - FlipperKit/FlipperKitHighlightOverlay (0.212.0) - - FlipperKit/FlipperKitLayoutHelpers (0.212.0): + - FlipperKit/FlipperKitHighlightOverlay (0.213.0) + - FlipperKit/FlipperKitLayoutHelpers (0.213.0): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutIOSDescriptors (0.212.0): + - FlipperKit/FlipperKitLayoutIOSDescriptors (0.213.0): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutHelpers - - FlipperKit/FlipperKitLayoutPlugin (0.212.0): + - FlipperKit/FlipperKitLayoutPlugin (0.213.0): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutHelpers - FlipperKit/FlipperKitLayoutIOSDescriptors - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutTextSearchable (0.212.0) - - FlipperKit/FlipperKitNetworkPlugin (0.212.0): + - FlipperKit/FlipperKitLayoutTextSearchable (0.213.0) + - FlipperKit/FlipperKitNetworkPlugin (0.213.0): - FlipperKit/Core - - FlipperKit/FlipperKitUserDefaultsPlugin (0.212.0): + - FlipperKit/FlipperKitUserDefaultsPlugin (0.213.0): - FlipperKit/Core - - FlipperKit/SKIOSNetworkPlugin (0.212.0): + - FlipperKit/SKIOSNetworkPlugin (0.213.0): - FlipperKit/Core - FlipperKit/FlipperKitNetworkPlugin - libevent (2.1.12) @@ -100,14 +100,14 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 - Flipper: b7a3d90634c855fece9d491ca69f682f1244984f + Flipper: a7da258b85c9df7103e5f8aeff4f0f90a9ec2c46 Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c Flipper-DoubleConversion: 2dc99b02f658daf147069aad9dbd29d8feb06d30 Flipper-Fmt: 60cbdd92fc254826e61d669a5d87ef7015396a9b Flipper-Folly: 584845625005ff068a6ebf41f857f468decd26b3 Flipper-Glog: 70c50ce58ddaf67dc35180db05f191692570f446 Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 - FlipperKit: 73b2e0c1ed75801151dab992313b6b1951b67446 + FlipperKit: 1e62027a910f6dd1c722858eeb7967b3d6531ae3 libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d diff --git a/iOS/Tutorial/Podfile b/iOS/Tutorial/Podfile index 8486dc07e24..c0fe8d8ec04 100644 --- a/iOS/Tutorial/Podfile +++ b/iOS/Tutorial/Podfile @@ -1,6 +1,6 @@ project 'Tutorial.xcodeproj' swift_version = "4.1" -flipperkit_version = '0.212.0' +flipperkit_version = '0.213.0' use_frameworks! target 'Tutorial' do diff --git a/iOS/Tutorial/Podfile.lock b/iOS/Tutorial/Podfile.lock index 3861b280fcd..798996ec6ec 100644 --- a/iOS/Tutorial/Podfile.lock +++ b/iOS/Tutorial/Podfile.lock @@ -3,7 +3,7 @@ PODS: - ComponentKit (0.31): - RenderCore (= 0.31) - Yoga (~> 1.14) - - Flipper (0.212.0): + - Flipper (0.213.0): - Flipper-Folly (~> 2.6) - Flipper-Boost-iOSX (1.76.0.1.11) - Flipper-DoubleConversion (3.2.0.1) @@ -17,25 +17,25 @@ PODS: - OpenSSL-Universal (= 1.1.1100) - Flipper-Glog (0.5.0.5) - Flipper-PeerTalk (0.0.4) - - FlipperKit (0.212.0): - - FlipperKit/Core (= 0.212.0) - - FlipperKit/Core (0.212.0): - - Flipper (~> 0.212.0) + - FlipperKit (0.213.0): + - FlipperKit/Core (= 0.213.0) + - FlipperKit/Core (0.213.0): + - Flipper (~> 0.213.0) - FlipperKit/CppBridge - FlipperKit/FBCxxFollyDynamicConvert - FlipperKit/FBDefines - FlipperKit/FKPortForwarding - SocketRocket (~> 0.7.0) - - FlipperKit/CppBridge (0.212.0): - - Flipper (~> 0.212.0) - - FlipperKit/FBCxxFollyDynamicConvert (0.212.0): + - FlipperKit/CppBridge (0.213.0): + - Flipper (~> 0.213.0) + - FlipperKit/FBCxxFollyDynamicConvert (0.213.0): - Flipper-Folly (~> 2.6) - - FlipperKit/FBDefines (0.212.0) - - FlipperKit/FKPortForwarding (0.212.0): + - FlipperKit/FBDefines (0.213.0) + - FlipperKit/FKPortForwarding (0.213.0): - CocoaAsyncSocket (~> 7.6) - Flipper-PeerTalk (~> 0.0.4) - - FlipperKit/FlipperKitHighlightOverlay (0.212.0) - - FlipperKit/FlipperKitLayoutComponentKitSupport (0.212.0): + - FlipperKit/FlipperKitHighlightOverlay (0.213.0) + - FlipperKit/FlipperKitLayoutComponentKitSupport (0.213.0): - ComponentKit (= 0.31) - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay @@ -43,26 +43,26 @@ PODS: - FlipperKit/FlipperKitLayoutPlugin - FlipperKit/FlipperKitLayoutTextSearchable - RenderCore (= 0.31) - - FlipperKit/FlipperKitLayoutHelpers (0.212.0): + - FlipperKit/FlipperKitLayoutHelpers (0.213.0): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutIOSDescriptors (0.212.0): + - FlipperKit/FlipperKitLayoutIOSDescriptors (0.213.0): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutHelpers - - FlipperKit/FlipperKitLayoutPlugin (0.212.0): + - FlipperKit/FlipperKitLayoutPlugin (0.213.0): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutHelpers - FlipperKit/FlipperKitLayoutIOSDescriptors - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutTextSearchable (0.212.0) - - FlipperKit/FlipperKitNetworkPlugin (0.212.0): + - FlipperKit/FlipperKitLayoutTextSearchable (0.213.0) + - FlipperKit/FlipperKitNetworkPlugin (0.213.0): - FlipperKit/Core - - FlipperKit/FlipperKitUserDefaultsPlugin (0.212.0): + - FlipperKit/FlipperKitUserDefaultsPlugin (0.213.0): - FlipperKit/Core - - FlipperKit/SKIOSNetworkPlugin (0.212.0): + - FlipperKit/SKIOSNetworkPlugin (0.213.0): - FlipperKit/Core - FlipperKit/FlipperKitNetworkPlugin - libevent (2.1.12) @@ -72,10 +72,10 @@ PODS: - Yoga (1.14.0) DEPENDENCIES: - - FlipperKit (~> 0.212.0) - - FlipperKit/FlipperKitLayoutComponentKitSupport (~> 0.212.0) - - FlipperKit/FlipperKitUserDefaultsPlugin (~> 0.212.0) - - FlipperKit/SKIOSNetworkPlugin (~> 0.212.0) + - FlipperKit (~> 0.213.0) + - FlipperKit/FlipperKitLayoutComponentKitSupport (~> 0.213.0) + - FlipperKit/FlipperKitUserDefaultsPlugin (~> 0.213.0) + - FlipperKit/SKIOSNetworkPlugin (~> 0.213.0) SPEC REPOS: trunk: @@ -98,20 +98,20 @@ SPEC REPOS: SPEC CHECKSUMS: CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 ComponentKit: 7bf7048b9814afc6b6641645a14177f95fd9b9ae - Flipper: b7a3d90634c855fece9d491ca69f682f1244984f + Flipper: a7da258b85c9df7103e5f8aeff4f0f90a9ec2c46 Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c Flipper-DoubleConversion: 2dc99b02f658daf147069aad9dbd29d8feb06d30 Flipper-Fmt: 60cbdd92fc254826e61d669a5d87ef7015396a9b Flipper-Folly: 584845625005ff068a6ebf41f857f468decd26b3 Flipper-Glog: 70c50ce58ddaf67dc35180db05f191692570f446 Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 - FlipperKit: 73b2e0c1ed75801151dab992313b6b1951b67446 + FlipperKit: 1e62027a910f6dd1c722858eeb7967b3d6531ae3 libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c RenderCore: 090beb17b5bff80b86929a7ceb49df789923d23a SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d Yoga: cff67a400f6b74dc38eb0bad4f156673d9aa980c -PODFILE CHECKSUM: c6cb86baae89a95f90a831dc0a3f0451b2e2ee28 +PODFILE CHECKSUM: 26a0039d0962e972b7bdad9c874f3456b99cb388 COCOAPODS: 1.12.1 diff --git a/react-native/ReactNativeFlipperExample/ios/Podfile b/react-native/ReactNativeFlipperExample/ios/Podfile index e630ed2176c..f505bae5955 100644 --- a/react-native/ReactNativeFlipperExample/ios/Podfile +++ b/react-native/ReactNativeFlipperExample/ios/Podfile @@ -5,7 +5,7 @@ source 'https://github.com/CocoaPods/Specs' platform :ios, '12.4' # used for automatic bumping -flipperkit_version = '0.212.0' +flipperkit_version = '0.213.0' target 'ReactNativeFlipperExample' do config = use_native_modules! diff --git a/react-native/ReactNativeFlipperExample/ios/Podfile.lock b/react-native/ReactNativeFlipperExample/ios/Podfile.lock index 7a543fe4564..8f40ce72d83 100644 --- a/react-native/ReactNativeFlipperExample/ios/Podfile.lock +++ b/react-native/ReactNativeFlipperExample/ios/Podfile.lock @@ -10,7 +10,7 @@ PODS: - React-Core (= 0.69.7) - React-jsi (= 0.69.7) - ReactCommon/turbomodule/core (= 0.69.7) - - Flipper (0.212.0): + - Flipper (0.213.0): - Flipper-Folly (~> 2.6) - Flipper-Boost-iOSX (1.76.0.1.11) - Flipper-DoubleConversion (3.2.0) @@ -26,46 +26,46 @@ PODS: - Flipper-PeerTalk (0.0.4) - Flipper-RSocket (1.4.3): - Flipper-Folly (~> 2.6) - - FlipperKit (0.212.0): - - FlipperKit/Core (= 0.212.0) - - FlipperKit/Core (0.212.0): - - Flipper (~> 0.212.0) + - FlipperKit (0.213.0): + - FlipperKit/Core (= 0.213.0) + - FlipperKit/Core (0.213.0): + - Flipper (~> 0.213.0) - FlipperKit/CppBridge - FlipperKit/FBCxxFollyDynamicConvert - FlipperKit/FBDefines - FlipperKit/FKPortForwarding - SocketRocket (~> 0.7.0) - - FlipperKit/CppBridge (0.212.0): - - Flipper (~> 0.212.0) - - FlipperKit/FBCxxFollyDynamicConvert (0.212.0): + - FlipperKit/CppBridge (0.213.0): + - Flipper (~> 0.213.0) + - FlipperKit/FBCxxFollyDynamicConvert (0.213.0): - Flipper-Folly (~> 2.6) - - FlipperKit/FBDefines (0.212.0) - - FlipperKit/FKPortForwarding (0.212.0): + - FlipperKit/FBDefines (0.213.0) + - FlipperKit/FKPortForwarding (0.213.0): - CocoaAsyncSocket (~> 7.6) - Flipper-PeerTalk (~> 0.0.4) - - FlipperKit/FlipperKitHighlightOverlay (0.212.0) - - FlipperKit/FlipperKitLayoutHelpers (0.212.0): + - FlipperKit/FlipperKitHighlightOverlay (0.213.0) + - FlipperKit/FlipperKitLayoutHelpers (0.213.0): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutIOSDescriptors (0.212.0): + - FlipperKit/FlipperKitLayoutIOSDescriptors (0.213.0): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutHelpers - - FlipperKit/FlipperKitLayoutPlugin (0.212.0): + - FlipperKit/FlipperKitLayoutPlugin (0.213.0): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutHelpers - FlipperKit/FlipperKitLayoutIOSDescriptors - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutTextSearchable (0.212.0) - - FlipperKit/FlipperKitNetworkPlugin (0.212.0): + - FlipperKit/FlipperKitLayoutTextSearchable (0.213.0) + - FlipperKit/FlipperKitNetworkPlugin (0.213.0): - FlipperKit/Core - - FlipperKit/FlipperKitReactPlugin (0.212.0): + - FlipperKit/FlipperKitReactPlugin (0.213.0): - FlipperKit/Core - - FlipperKit/FlipperKitUserDefaultsPlugin (0.212.0): + - FlipperKit/FlipperKitUserDefaultsPlugin (0.213.0): - FlipperKit/Core - - FlipperKit/SKIOSNetworkPlugin (0.212.0): + - FlipperKit/SKIOSNetworkPlugin (0.213.0): - FlipperKit/Core - FlipperKit/FlipperKitNetworkPlugin - fmt (6.2.1) @@ -375,7 +375,7 @@ DEPENDENCIES: - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`) - FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`) - FBReactNativeSpec (from `../node_modules/react-native/React/FBReactNativeSpec`) - - Flipper (= 0.212.0) + - Flipper (= 0.213.0) - Flipper-Boost-iOSX (= 1.76.0.1.11) - Flipper-DoubleConversion (= 3.2.0) - Flipper-Fmt (= 7.1.7) @@ -383,19 +383,19 @@ DEPENDENCIES: - Flipper-Glog (= 0.5.0.3) - Flipper-PeerTalk (= 0.0.4) - Flipper-RSocket (= 1.4.3) - - FlipperKit (= 0.212.0) - - FlipperKit/Core (= 0.212.0) - - FlipperKit/CppBridge (= 0.212.0) - - FlipperKit/FBCxxFollyDynamicConvert (= 0.212.0) - - FlipperKit/FBDefines (= 0.212.0) - - FlipperKit/FKPortForwarding (= 0.212.0) - - FlipperKit/FlipperKitHighlightOverlay (= 0.212.0) - - FlipperKit/FlipperKitLayoutPlugin (= 0.212.0) - - FlipperKit/FlipperKitLayoutTextSearchable (= 0.212.0) - - FlipperKit/FlipperKitNetworkPlugin (= 0.212.0) - - FlipperKit/FlipperKitReactPlugin (= 0.212.0) - - FlipperKit/FlipperKitUserDefaultsPlugin (= 0.212.0) - - FlipperKit/SKIOSNetworkPlugin (= 0.212.0) + - FlipperKit (= 0.213.0) + - FlipperKit/Core (= 0.213.0) + - FlipperKit/CppBridge (= 0.213.0) + - FlipperKit/FBCxxFollyDynamicConvert (= 0.213.0) + - FlipperKit/FBDefines (= 0.213.0) + - FlipperKit/FKPortForwarding (= 0.213.0) + - FlipperKit/FlipperKitHighlightOverlay (= 0.213.0) + - FlipperKit/FlipperKitLayoutPlugin (= 0.213.0) + - FlipperKit/FlipperKitLayoutTextSearchable (= 0.213.0) + - FlipperKit/FlipperKitNetworkPlugin (= 0.213.0) + - FlipperKit/FlipperKitReactPlugin (= 0.213.0) + - FlipperKit/FlipperKitUserDefaultsPlugin (= 0.213.0) + - FlipperKit/SKIOSNetworkPlugin (= 0.213.0) - glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`) - hermes-engine (from `../node_modules/react-native/sdks/hermes/hermes-engine.podspec`) - libevent (~> 2.1.12) @@ -527,7 +527,7 @@ SPEC CHECKSUMS: DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54 FBLazyVector: 6b7f5692909b4300d50e7359cdefbcd09dd30faa FBReactNativeSpec: affcf71d996f6b0c01f68883482588297b9d5e6e - Flipper: b7a3d90634c855fece9d491ca69f682f1244984f + Flipper: a7da258b85c9df7103e5f8aeff4f0f90a9ec2c46 Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c Flipper-DoubleConversion: 3d3d04a078d4f3a1b6c6916587f159dc11f232c4 Flipper-Fmt: 60cbdd92fc254826e61d669a5d87ef7015396a9b @@ -535,7 +535,7 @@ SPEC CHECKSUMS: Flipper-Glog: 7761f5362d23ead28c19afc2dd1d819f00e40df9 Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 Flipper-RSocket: d9d9ade67cbecf6ac10730304bf5607266dd2541 - FlipperKit: 73b2e0c1ed75801151dab992313b6b1951b67446 + FlipperKit: 1e62027a910f6dd1c722858eeb7967b3d6531ae3 fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 glog: 3d02b25ca00c2d456734d0bcff864cbc62f6ae1a hermes-engine: 51aaceb1f6dc1aed44b8bbf866f52ec146c00a89 @@ -572,6 +572,6 @@ SPEC CHECKSUMS: SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d Yoga: 0b84a956f7393ef1f37f3bb213c516184e4a689d -PODFILE CHECKSUM: 57d44f577e4f420511a2427799645b075948962c +PODFILE CHECKSUM: f2586a744538f9df2eb86ead3a4500a0e47fea5f COCOAPODS: 1.12.1 From 50d31cb1f75fdc8a8eb568874eab23c5c06bbf79 Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Wed, 30 Aug 2023 03:15:44 -0700 Subject: [PATCH 14/54] Demote "Document not focused" error from Electron Summary: Comes from Electron. Will go away with PWA. Reviewed By: lblasa Differential Revision: D48778132 fbshipit-source-id: 0cecdc38e76b663315434aec995635afca2959dc --- desktop/flipper-common/src/utils/LoggerTailer.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/desktop/flipper-common/src/utils/LoggerTailer.tsx b/desktop/flipper-common/src/utils/LoggerTailer.tsx index 258eeaa9b4e..ef2ce9c4252 100644 --- a/desktop/flipper-common/src/utils/LoggerTailer.tsx +++ b/desktop/flipper-common/src/utils/LoggerTailer.tsx @@ -74,6 +74,11 @@ function transformLogLevel(level: LoggerTypes, message: string) { if (message.includes('Watchman was not found in PATH')) { return 'warn'; } + + // Random Electron error, not actionable. + if (message.includes('Document is not focused')) { + return 'warn'; + } } return level; From 03c0874f306941dc132b0a8fcbcd838b7ca74261 Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Wed, 30 Aug 2023 04:24:05 -0700 Subject: [PATCH 15/54] Query devices should be async Summary: ^ Reviewed By: aigoncharov Differential Revision: D48781102 fbshipit-source-id: c987be90c7bca7dbab40a89b389ee86ef2230393 --- .../src/devices/ios/iOSDeviceManager.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/desktop/flipper-server-core/src/devices/ios/iOSDeviceManager.tsx b/desktop/flipper-server-core/src/devices/ios/iOSDeviceManager.tsx index fbd3e498bc4..68c9cc840f9 100644 --- a/desktop/flipper-server-core/src/devices/ios/iOSDeviceManager.tsx +++ b/desktop/flipper-server-core/src/devices/ios/iOSDeviceManager.tsx @@ -97,10 +97,9 @@ export class IOSDeviceManager { ]; } - queryDevices(bridge: IOSBridge): Promise { - return bridge - .getActiveDevices(true) - .then((devices) => this.processDevices(bridge, devices)); + async queryDevices(bridge: IOSBridge): Promise { + const devices = await bridge.getActiveDevices(true); + return this.processDevices(bridge, devices); } private processDevices(bridge: IOSBridge, activeDevices: IOSDeviceParams[]) { From 0045f15e2a29b3a368d57235097ce1b905297112 Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Wed, 30 Aug 2023 04:24:05 -0700 Subject: [PATCH 16/54] isAvailable to isIdbAvailable Summary: Make it more clear what are we checking about. Reviewed By: aigoncharov Differential Revision: D48781145 fbshipit-source-id: c3c03b407dc7f47730a3fb80de769243768b34ec --- desktop/flipper-server-core/src/devices/ios/IOSBridge.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/desktop/flipper-server-core/src/devices/ios/IOSBridge.tsx b/desktop/flipper-server-core/src/devices/ios/IOSBridge.tsx index 566e9b4aa1c..4bb7c98bc46 100644 --- a/desktop/flipper-server-core/src/devices/ios/IOSBridge.tsx +++ b/desktop/flipper-server-core/src/devices/ios/IOSBridge.tsx @@ -330,7 +330,7 @@ function isSimulatorAvailable(simulator: iOSSimulatorDevice): boolean { ); } -async function isAvailable(idbPath: string): Promise { +async function isIdbAvailable(idbPath: string): Promise { if (!idbPath) { return false; } @@ -389,9 +389,9 @@ export async function makeIOSBridge( idbPath: string, isXcodeDetected: boolean, enablePhysicalDevices: boolean, - isAvailableFn: (idbPath: string) => Promise = isAvailable, + isAvailable: (idbPath: string) => Promise = isIdbAvailable, ): Promise { - if (await isAvailableFn(idbPath)) { + if (await isAvailable(idbPath)) { return new IDBBridge(idbPath, enablePhysicalDevices); } From 3e8f94cedaca357e540135c9a979a1a4e552ad8e Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Wed, 30 Aug 2023 04:24:05 -0700 Subject: [PATCH 17/54] iOS get devices/targets/simulators cleanup Summary: ^ Reviewed By: passy Differential Revision: D48781211 fbshipit-source-id: 71133c07d15ca6a380d85e582d55cbdb192b5a19 --- desktop/flipper-common/src/PluginDetails.tsx | 13 +- desktop/flipper-common/src/server-types.tsx | 20 ++- .../src/FlipperServerImpl.tsx | 2 +- .../src/devices/ios/IOSBridge.tsx | 88 +++------- .../devices/ios/__tests__/iOSDevice.node.tsx | 8 +- .../devices/ios/iOSCertificateProvider.tsx | 1 + .../src/devices/ios/iOSContainerUtility.tsx | 159 ++++++++++-------- .../src/devices/ios/iOSDeviceManager.tsx | 43 +++-- .../appinspect/LaunchEmulator.tsx | 12 +- 9 files changed, 168 insertions(+), 178 deletions(-) diff --git a/desktop/flipper-common/src/PluginDetails.tsx b/desktop/flipper-common/src/PluginDetails.tsx index 41443c4757c..c7a400e9c50 100644 --- a/desktop/flipper-common/src/PluginDetails.tsx +++ b/desktop/flipper-common/src/PluginDetails.tsx @@ -7,6 +7,8 @@ * @format */ +import {DeviceType, OS} from './server-types'; + export interface PluginDetails { name: string; specVersion: number; @@ -57,17 +59,6 @@ export interface SupportedApp { readonly type?: DeviceType; } -export type OS = - | 'iOS' - | 'Android' - | 'Metro' - | 'Windows' - | 'MacOS' - | 'Browser' - | 'Linux'; - -export type DeviceType = 'emulator' | 'physical' | 'dummy'; - export type PluginType = 'client' | 'device'; export type DeviceSpec = 'KaiOS'; diff --git a/desktop/flipper-common/src/server-types.tsx b/desktop/flipper-common/src/server-types.tsx index 55d7f821aa0..b8fd38c8972 100644 --- a/desktop/flipper-common/src/server-types.tsx +++ b/desktop/flipper-common/src/server-types.tsx @@ -10,11 +10,9 @@ import {FlipperDoctor} from './doctor'; import { DeviceSpec, - DeviceType, DownloadablePluginDetails, InstalledPluginDetails, MarketplacePluginDetails, - OS as PluginOS, UpdatablePluginDetails, } from './PluginDetails'; import {ServerAddOnStartDetails} from './ServerAddOn'; @@ -39,7 +37,7 @@ export type FlipperServerState = | 'error' | 'closed'; -export type DeviceOS = PluginOS; +export type DeviceOS = OS; export type DeviceDescription = { readonly os: DeviceOS; @@ -172,12 +170,22 @@ export type FlipperServerEvents = { 'server-log': LoggerInfo; }; -export type IOSDeviceParams = { +export type OS = + | 'iOS' + | 'Android' + | 'Metro' + | 'Windows' + | 'MacOS' + | 'Browser' + | 'Linux'; + +export type DeviceType = 'physical' | 'emulator' | 'dummy'; + +export type DeviceTarget = { udid: string; type: DeviceType; name: string; osVersion?: string; - deviceTypeIdentifier?: string; state?: string; }; @@ -298,7 +306,7 @@ export type FlipperServerCommands = { 'android-get-emulators': () => Promise; 'android-launch-emulator': (name: string, coldboot: boolean) => Promise; 'android-adb-kill': () => Promise; - 'ios-get-simulators': (bootedOnly: boolean) => Promise; + 'ios-get-simulators': (bootedOnly: boolean) => Promise; 'ios-launch-simulator': (udid: string) => Promise; 'ios-idb-kill': () => Promise; 'persist-settings': (settings: Settings) => Promise; diff --git a/desktop/flipper-server-core/src/FlipperServerImpl.tsx b/desktop/flipper-server-core/src/FlipperServerImpl.tsx index 23f41af1401..c3f7615c685 100644 --- a/desktop/flipper-server-core/src/FlipperServerImpl.tsx +++ b/desktop/flipper-server-core/src/FlipperServerImpl.tsx @@ -496,7 +496,7 @@ export class FlipperServerImpl implements FlipperServer { }, 'ios-launch-simulator': async (udid) => { assertNotNull(this.ios); - return this.ios.simctlBridge.launchSimulator(udid); + return this.ios.launchSimulator(udid); }, 'ios-idb-kill': async () => { assertNotNull(this.ios); diff --git a/desktop/flipper-server-core/src/devices/ios/IOSBridge.tsx b/desktop/flipper-server-core/src/devices/ios/IOSBridge.tsx index 4bb7c98bc46..51f5230f711 100644 --- a/desktop/flipper-server-core/src/devices/ios/IOSBridge.tsx +++ b/desktop/flipper-server-core/src/devices/ios/IOSBridge.tsx @@ -8,10 +8,14 @@ */ import fs from 'fs-extra'; -import iosUtil from './iOSContainerUtility'; +import iosUtil, { + getDeviceSetPath, + isIdbAvailable, + queryTargetsWithXcode, +} from './iOSContainerUtility'; import child_process from 'child_process'; -import type {IOSDeviceParams} from 'flipper-common'; +import type {DeviceTarget} from 'flipper-common'; import {DeviceType, uuid} from 'flipper-common'; import path from 'path'; import {ChildProcessPromise, exec, execFile} from 'promisify-child-process'; @@ -42,16 +46,6 @@ interface IOSInstalledAppDescriptor { debuggableStatus: boolean; } -function getOSVersionFromXCRunOutput(s: string): string | undefined { - // E.g. 'com.apple.CoreSimulator.SimRuntime.iOS-16-1' - const match = s.match( - /com\.apple\.CoreSimulator\.SimRuntime\.iOS-(\d+)-(\d+)/, - ); - if (match) { - return `${match[1]}.${match[2]}`; - } -} - export interface IOSBridge { startLogListener: ( udid: string, @@ -63,7 +57,7 @@ export interface IOSBridge { serial: string, outputFile: string, ) => child_process.ChildProcess; - getActiveDevices: (bootedOnly: boolean) => Promise>; + getActiveDevices: (bootedOnly: boolean) => Promise>; installApp: ( serial: string, ipaPath: string, @@ -77,6 +71,7 @@ export interface IOSBridge { bundleId: string, dst: string, ) => Promise; + launchSimulator(udid: string): Promise; } export class IDBBridge implements IOSBridge { @@ -84,6 +79,10 @@ export class IDBBridge implements IOSBridge { private idbPath: string, private enablePhysicalDevices: boolean, ) {} + async launchSimulator(udid: string): Promise { + await this._execIdb(`boot --udid ${udid}`); + await execFile('open', ['-a', 'simulator']); + } async getInstalledApps(serial: string): Promise { const {stdout} = await this._execIdb(`list-apps --udid ${serial}`); @@ -150,9 +149,9 @@ export class IDBBridge implements IOSBridge { await this._execIdb(`install ${ipaPath} --udid ${serial}`); } - async getActiveDevices(_bootedOnly: boolean): Promise { + async getActiveDevices(bootedOnly: boolean): Promise { return iosUtil - .targets(this.idbPath, this.enablePhysicalDevices) + .targets(this.idbPath, this.enablePhysicalDevices, bootedOnly) .catch((e) => { console.warn('Failed to get active iOS devices:', e.message); return []; @@ -285,32 +284,11 @@ export class SimctlBridge implements IOSBridge { ); } - async getActiveDevices(bootedOnly: boolean): Promise> { - return execFile('xcrun', [ - 'simctl', - ...getDeviceSetPath(), - 'list', - 'devices', - '--json', - ]) - .then(({stdout}) => JSON.parse(stdout!.toString()).devices) - .then((simulatorDevices: {[key: string]: Array}) => - Object.keys(simulatorDevices).flatMap((key: string) => - simulatorDevices[key] - .filter( - (simulator: iOSSimulatorDevice) => - (!bootedOnly || simulator.state === 'Booted') && - isSimulatorAvailable(simulator), - ) - .map((simulator: iOSSimulatorDevice) => { - return { - ...simulator, - type: 'emulator', - osVersion: getOSVersionFromXCRunOutput(key), - } as IOSDeviceParams; - }), - ), - ); + async getActiveDevices(bootedOnly: boolean): Promise> { + const devices = await queryTargetsWithXcode(); + return devices.filter( + (target) => !bootedOnly || (bootedOnly && target.state === 'booted'), + ); } async launchSimulator(udid: string): Promise { @@ -319,27 +297,6 @@ export class SimctlBridge implements IOSBridge { } } -function isSimulatorAvailable(simulator: iOSSimulatorDevice): boolean { - // For some users "availability" is set, for others it's "isAvailable" - // It's not clear which key is set, so we are checking both. - // We've also seen isAvailable return "YES" and true, depending on version. - return ( - simulator.availability === '(available)' || - simulator.isAvailable === 'YES' || - simulator.isAvailable === true - ); -} - -async function isIdbAvailable(idbPath: string): Promise { - if (!idbPath) { - return false; - } - return fs.promises - .access(idbPath, fs.constants.X_OK) - .then((_) => true) - .catch((_) => false); -} - function getLogExtraArgs(deviceType: DeviceType) { if (deviceType === 'physical') { return [ @@ -364,7 +321,6 @@ function makeTempScreenshotFilePath() { } async function unzip(filePath: string, destination: string): Promise { - // TODO: probably shouldn't involve shelling out. await exec(`unzip -qq -o ${filePath} -d ${destination}`); if (!(await fs.pathExists(path.join(destination, 'Payload')))) { throw new Error( @@ -379,12 +335,6 @@ async function readScreenshotIntoBuffer(imagePath: string): Promise { return buffer; } -export function getDeviceSetPath() { - return process.env.DEVICE_SET_PATH - ? ['--set', process.env.DEVICE_SET_PATH] - : []; -} - export async function makeIOSBridge( idbPath: string, isXcodeDetected: boolean, diff --git a/desktop/flipper-server-core/src/devices/ios/__tests__/iOSDevice.node.tsx b/desktop/flipper-server-core/src/devices/ios/__tests__/iOSDevice.node.tsx index 9311657af32..6db146a505f 100644 --- a/desktop/flipper-server-core/src/devices/ios/__tests__/iOSDevice.node.tsx +++ b/desktop/flipper-server-core/src/devices/ios/__tests__/iOSDevice.node.tsx @@ -14,12 +14,12 @@ import { getFlipperServerConfig, setFlipperServerConfig, } from '../../../FlipperServerConfig'; -import {IOSDeviceParams} from 'flipper-common'; +import {DeviceTarget} from 'flipper-common'; let fakeSimctlBridge: any; let fakeIDBBridge: any; let fakeFlipperServer: any; -const fakeDevices: IOSDeviceParams[] = [ +const fakeDevices: DeviceTarget[] = [ { udid: 'luke', type: 'emulator', @@ -122,7 +122,7 @@ test('test queryDevices when simctl used', async () => { fakeFlipperServer, getFlipperServerConfig().settings, ); - ios.simctlBridge = fakeSimctlBridge; + ios.ctlBridge = fakeSimctlBridge; await ios.queryDevices(fakeSimctlBridge); @@ -145,7 +145,7 @@ test('test queryDevices when idb used', async () => { fakeFlipperServer, getFlipperServerConfig().settings, ); - ios.simctlBridge = fakeSimctlBridge; + ios.ctlBridge = fakeSimctlBridge; await ios.queryDevices(fakeIDBBridge); diff --git a/desktop/flipper-server-core/src/devices/ios/iOSCertificateProvider.tsx b/desktop/flipper-server-core/src/devices/ios/iOSCertificateProvider.tsx index f3b9d8a58cd..5e8b01c4a0a 100644 --- a/desktop/flipper-server-core/src/devices/ios/iOSCertificateProvider.tsx +++ b/desktop/flipper-server-core/src/devices/ios/iOSCertificateProvider.tsx @@ -48,6 +48,7 @@ export default class iOSCertificateProvider extends CertificateProvider { const targets = await iosUtil.targets( this.idbConfig.idbPath, this.idbConfig.enablePhysicalIOS, + true, clientQuery, ); if (targets.length === 0) { diff --git a/desktop/flipper-server-core/src/devices/ios/iOSContainerUtility.tsx b/desktop/flipper-server-core/src/devices/ios/iOSContainerUtility.tsx index 56a8f559ce9..fb9a3a9bb10 100644 --- a/desktop/flipper-server-core/src/devices/ios/iOSContainerUtility.tsx +++ b/desktop/flipper-server-core/src/devices/ios/iOSContainerUtility.tsx @@ -8,11 +8,10 @@ */ import {Mutex} from 'async-mutex'; -import {exec as unsafeExec, Output} from 'promisify-child-process'; -import {reportPlatformFailures} from 'flipper-common'; +import {exec as unsafeExec, Output, execFile} from 'promisify-child-process'; +import {DeviceTarget, DeviceType, reportPlatformFailures} from 'flipper-common'; import {promises, constants} from 'fs'; import memoize from 'lodash.memoize'; -import {notNull} from '../../utils/typeUtils'; import {promisify} from 'util'; import child_process from 'child_process'; import fs from 'fs-extra'; @@ -25,37 +24,37 @@ export type IdbConfig = { enablePhysicalIOS: boolean; }; -// Use debug to get helpful logs when idb fails -const IDB_LOG_LEVEL = 'DEBUG'; -const LOG_TAG = 'iOSContainerUtility'; -const CMD_RECORD_THROTTLE_COUNT = 10; - -const mutex = new Mutex(); - -type IdbTarget = { - name: string; +export type IdbTarget = { udid: string; - state: 'Booted' | 'Shutdown'; - type: string | DeviceType; - target_type?: string | DeviceType; + type: string; + name: string; os_version: string; architecture: string; + state?: string; + target_type?: string | DeviceType; }; -export type DeviceType = 'physical' | 'emulator'; - -export type DeviceTarget = { - udid: string; - type: DeviceType; +export type XcodeTarget = { + state: 'Booted' | 'Shutdown' | 'Shutting Down'; + availability?: string; + isAvailable?: 'YES' | 'NO' | true | false; name: string; osVersion?: string; + udid: string; }; +// Use debug to get helpful logs when idb fails +const IDB_LOG_LEVEL = 'DEBUG'; +const LOG_TAG = 'iOSContainerUtility'; +const CMD_RECORD_THROTTLE_COUNT = 10; + +const mutex = new Mutex(); + let idbDeviceListing = 0; let idbCompanionDeviceListing = 0; let xcodeDeviceListing = 0; -async function isAvailable(idbPath: string): Promise { +export async function isIdbAvailable(idbPath: string): Promise { if (!idbPath) { return false; } @@ -74,16 +73,50 @@ async function safeExec( return await unsafeExec(command).finally(release); } -async function queryTargetsWithXcode( - context: any, +export function getDeviceSetPath() { + return process.env.DEVICE_SET_PATH + ? ['--set', process.env.DEVICE_SET_PATH] + : []; +} + +export function isSimulatorAvailable(simulator: XcodeTarget): boolean { + // For some users "availability" is set, for others it's "isAvailable" + // It's not clear which key is set, so we are checking both. + // We've also seen isAvailable return "YES" and true, depending on version. + return ( + simulator.availability === '(available)' || + simulator.isAvailable === 'YES' || + simulator.isAvailable === true + ); +} + +function getOSVersionFromXCRunOutput(s: string): string | undefined { + // E.g. 'com.apple.CoreSimulator.SimRuntime.iOS-16-1' + const match = s.match( + /com\.apple\.CoreSimulator\.SimRuntime\.iOS-(\d+)-(\d+)/, + ); + if (match) { + return `${match[1]}.${match[2]}`; + } +} + +export async function queryTargetsWithXcode( + context?: any, ): Promise> { - const cmd = 'xcrun xctrace list devices'; + const cmd = 'xcrun simctl list devices --json'; const description = 'Query available devices with Xcode'; const troubleshoot = `Xcode command line tools are not installed. Run 'xcode-select --install' from terminal.`; try { - const {stdout} = await safeExec(cmd); + const {stdout} = await execFile('xcrun', [ + 'simctl', + ...getDeviceSetPath(), + 'list', + 'devices', + '--json', + ]); + if (!stdout) { recorder.event('cmd', { cmd, @@ -105,17 +138,22 @@ async function queryTargetsWithXcode( }); } - return stdout - .toString() - .split('\n') - .map((line) => line.trim()) - .filter(Boolean) - .map((line) => /(.+) \([^(]+\) \[(.*)\]( \(Simulator\))?/.exec(line)) - .filter(notNull) - .filter(([_match, _name, _udid, isSim]) => !isSim) - .map(([_match, name, udid]) => { - return {udid, type: 'physical', name}; - }); + const devices = JSON.parse(stdout.toString()).devices as { + [key: string]: Array; + }; + + return Object.keys(devices).flatMap((key: string) => + devices[key] + .filter((simulator: XcodeTarget) => isSimulatorAvailable(simulator)) + .map((simulator: XcodeTarget) => { + return { + ...simulator, + type: 'emulator', + state: simulator.state.toLowerCase(), + osVersion: getOSVersionFromXCRunOutput(key), + } as DeviceTarget; + }), + ); } catch (e) { recorder.event('cmd', { cmd, @@ -176,7 +214,7 @@ async function queryTargetsWithIdb( } } -async function queryTargetsWithIdbCompanion( +async function _queryTargetsWithIdbCompanion( idbCompanionPath: string, isPhysicalDeviceEnabled: boolean, context: any, @@ -187,7 +225,7 @@ async function queryTargetsWithIdbCompanion( const troubleshoot = `Unable to locate idb_companion in '${idbCompanionPath}'. Try running sudo yum install -y fb-idb`; - if (await isAvailable(idbCompanionPath)) { + if (await isIdbAvailable(idbCompanionPath)) { try { const {stdout} = await safeExec(cmd); if (!stdout) { @@ -244,9 +282,6 @@ async function queryTargetsWithIdbCompanion( function parseIdbTarget(line: string): DeviceTarget | undefined { const parsed: IdbTarget = JSON.parse(line); - if (parsed.state.toLocaleLowerCase() !== 'booted') { - return; - } return { udid: parsed.udid, type: @@ -255,6 +290,7 @@ function parseIdbTarget(line: string): DeviceTarget | undefined { : ('physical' as DeviceType), name: parsed.name, osVersion: parsed.os_version, + state: parsed.state?.toLocaleLowerCase(), }; } @@ -331,45 +367,36 @@ async function idbDescribeTarget( async function targets( idbPath: string, isPhysicalDeviceEnabled: boolean, + bootedOnly: boolean = false, context?: any, ): Promise> { if (process.platform !== 'darwin') { return []; } + const bootedFilter = (targets: DeviceTarget[] | undefined) => { + return targets + ? targets.filter( + (target) => !bootedOnly || (bootedOnly && target.state === 'booted'), + ) + : []; + }; + // If companion is started by some external process and its path // is provided to Flipper via IDB_COMPANION environment variable, // use that instead and do not query other devices. // See stack of D36315576 for details if (process.env.IDB_COMPANION) { const target = await idbDescribeTarget(idbPath, context); - return target ? [target] : []; - } - - const isXcodeInstalled = await isXcodeDetected(); - if (!isXcodeInstalled) { - if (!isPhysicalDeviceEnabled) { - recorder.rawError( - 'You are trying to connect a physical device. Please enable the toggle "Enable physical iOS device" from the setting screen.', - ); - } - const idbCompanionPath = path.dirname(idbPath) + '/idb_companion'; - return queryTargetsWithIdbCompanion( - idbCompanionPath, - isPhysicalDeviceEnabled, - context, - ); + return bootedFilter(target ? [target] : []); } - // Not all users have idb installed because you can still use - // Flipper with Simulators without it. - // But idb is MUCH more CPU efficient than xcrun, so - // when installed, use it. This still holds true - // with the move from instruments to xcrun. - if (await memoize(isAvailable)(idbPath)) { - return await queryTargetsWithIdb(idbPath, context); + if (await memoize(isIdbAvailable)(idbPath)) { + const targets = await queryTargetsWithIdb(idbPath, context); + return bootedFilter(targets); } else { - return queryTargetsWithXcode(context); + const targets = await queryTargetsWithXcode(context); + return bootedFilter(targets); } } @@ -459,7 +486,7 @@ async function pull( } async function checkIdbIsInstalled(idbPath: string): Promise { - const isInstalled = await isAvailable(idbPath); + const isInstalled = await isIdbAvailable(idbPath); if (!isInstalled) { throw new Error( `idb is required to use iOS devices. Install it with instructions diff --git a/desktop/flipper-server-core/src/devices/ios/iOSDeviceManager.tsx b/desktop/flipper-server-core/src/devices/ios/iOSDeviceManager.tsx index 68c9cc840f9..d9458649b25 100644 --- a/desktop/flipper-server-core/src/devices/ios/iOSDeviceManager.tsx +++ b/desktop/flipper-server-core/src/devices/ios/iOSDeviceManager.tsx @@ -8,7 +8,7 @@ */ import {ChildProcess} from 'child_process'; -import type {IOSDeviceParams} from 'flipper-common'; +import type {DeviceTarget} from 'flipper-common'; import path from 'path'; import childProcess from 'child_process'; import {exec} from 'promisify-child-process'; @@ -18,7 +18,6 @@ import { ERR_NO_IDB_OR_XCODE_AVAILABLE, IOSBridge, makeIOSBridge, - SimctlBridge, } from './IOSBridge'; import {FlipperServerImpl} from '../../FlipperServerImpl'; import {getFlipperServerConfig} from '../../FlipperServerConfig'; @@ -34,7 +33,7 @@ export class IOSDeviceManager { 'MacOS', 'PortForwardingMacApp', ); - simctlBridge: SimctlBridge = new SimctlBridge(); + ctlBridge: IOSBridge | undefined; readonly certificateProvider: iOSCertificateProvider; @@ -102,7 +101,7 @@ export class IOSDeviceManager { return this.processDevices(bridge, devices); } - private processDevices(bridge: IOSBridge, activeDevices: IOSDeviceParams[]) { + private processDevices(bridge: IOSBridge, activeDevices: DeviceTarget[]) { const currentDeviceIDs = new Set( this.flipperServer .getDevices() @@ -134,9 +133,23 @@ export class IOSDeviceManager { }); } + async getBridge(): Promise { + if (this.ctlBridge !== undefined) { + return this.ctlBridge; + } + + const isDetected = await iosUtil.isXcodeDetected(); + this.ctlBridge = await makeIOSBridge( + this.idbConfig.idbPath, + isDetected, + this.idbConfig.enablePhysicalIOS, + ); + + return this.ctlBridge; + } + public async watchIOSDevices() { try { - const isDetected = await iosUtil.isXcodeDetected(); if (this.idbConfig.enablePhysicalIOS) { this.startDevicePortForwarders(); } @@ -144,11 +157,7 @@ export class IOSDeviceManager { // Check for version mismatch now for immediate error handling. await this.checkXcodeVersionMismatch(); // Awaiting the promise here to trigger immediate error handling. - const bridge = await makeIOSBridge( - this.idbConfig.idbPath, - isDetected, - this.idbConfig.enablePhysicalIOS, - ); + const bridge = await this.getBridge(); await this.queryDevicesForever(bridge); } catch (err) { // This case is expected if both Xcode and idb are missing. @@ -166,9 +175,10 @@ export class IOSDeviceManager { } } - async getSimulators(bootedOnly: boolean): Promise> { + async getSimulators(bootedOnly: boolean): Promise> { try { - return await this.simctlBridge.getActiveDevices(bootedOnly); + const bridge = await this.getBridge(); + return await bridge.getActiveDevices(bootedOnly); } catch (e) { console.warn('Failed to query simulators:', e); if (e.message.includes('Xcode license agreements')) { @@ -183,6 +193,15 @@ export class IOSDeviceManager { } } + async launchSimulator(udid: string) { + try { + const bridge = await this.getBridge(); + await bridge.launchSimulator(udid); + } catch (e) { + console.warn('Failed to launch simulator:', e); + } + } + private async queryDevicesForever(bridge: IOSBridge) { try { await this.queryDevices(bridge); diff --git a/desktop/flipper-ui-core/src/sandy-chrome/appinspect/LaunchEmulator.tsx b/desktop/flipper-ui-core/src/sandy-chrome/appinspect/LaunchEmulator.tsx index bf52d69ee1d..f149ca6d2a5 100644 --- a/desktop/flipper-ui-core/src/sandy-chrome/appinspect/LaunchEmulator.tsx +++ b/desktop/flipper-ui-core/src/sandy-chrome/appinspect/LaunchEmulator.tsx @@ -26,7 +26,7 @@ import { theme, } from 'flipper-plugin'; import {Provider} from 'react-redux'; -import {IOSDeviceParams} from 'flipper-common'; +import {DeviceTarget} from 'flipper-common'; import {getRenderHostInstance} from 'flipper-frontend-core'; import SettingsSheet from '../../chrome/SettingsSheet'; import {Link} from '../../ui'; @@ -88,7 +88,7 @@ export const LaunchEmulatorDialog = withTrackingScope( (state) => state.settingsState.enableAndroid, ); - const [iosEmulators, setIosEmulators] = useState([]); + const [iosEmulators, setIosEmulators] = useState([]); const [androidEmulators, setAndroidEmulators] = useState([]); const [waitingForIos, setWaitingForIos] = useState(iosEnabled); const [waitingForAndroid, setWaitingForAndroid] = useState(androidEnabled); @@ -113,13 +113,7 @@ export const LaunchEmulatorDialog = withTrackingScope( .flipperServer.exec('ios-get-simulators', false) .then((emulators) => { setWaitingForIos(false); - setIosEmulators( - emulators.filter( - (device) => - device.state === 'Shutdown' && - device.deviceTypeIdentifier?.match(/iPhone|iPad/i), - ), - ); + setIosEmulators(emulators); }) .catch((e) => { console.warn('Failed to find simulators', e); From 2858259497d7f5560ff278bfd7f23045b00ba680 Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Wed, 30 Aug 2023 05:08:26 -0700 Subject: [PATCH 18/54] Launch early, even if not ready Summary: Flipper Launcher downloads, unpacks, launches Flipper, and closes itself. This is fine except for the fact that Flipper may be initiating and thus there's a gap of a few seconds until engineers see the main Flipper UI. This change improves this by launching earlier, even if just showing a loading page until Flipper is actually ready. Reviewed By: passy, aigoncharov Differential Revision: D48824479 fbshipit-source-id: aa6147a09f313d80592c9b08d089660ba73773a4 --- .../src/server/startServer.tsx | 18 +++-- desktop/flipper-server/src/index.tsx | 5 +- desktop/static/loading.html | 68 +++++++++++++++++++ 3 files changed, 84 insertions(+), 7 deletions(-) create mode 100644 desktop/static/loading.html diff --git a/desktop/flipper-server-core/src/server/startServer.tsx b/desktop/flipper-server-core/src/server/startServer.tsx index 00db40d1e86..8d89945c8e9 100644 --- a/desktop/flipper-server-core/src/server/startServer.tsx +++ b/desktop/flipper-server-core/src/server/startServer.tsx @@ -72,6 +72,8 @@ const verifyAuthToken = (req: http.IncomingMessage): boolean => { return true; }; +let isReady = false; + /** * Orchestrates the creation of the HTTP server, proxy, and WS server. * @param config Server configuration. @@ -108,7 +110,10 @@ async function startHTTPServer(config: Config): Promise<{ }); app.get('/', (_req, res) => { - fs.readFile(path.join(config.staticPath, config.entry), (_err, content) => { + const resource = isReady + ? path.join(config.staticPath, config.entry) + : path.join(config.staticPath, 'loading.html'); + fs.readFile(resource, (_err, content) => { res.end(content); }); }); @@ -127,6 +132,8 @@ async function startHTTPServer(config: Config): Promise<{ server.close(); }); + server.listen(config.port); + return new Promise((resolve) => { console.log(`Starting server on http://localhost:${config.port}`); const readyForIncomingConnections = ( @@ -134,13 +141,12 @@ async function startHTTPServer(config: Config): Promise<{ companionEnv: FlipperServerCompanionEnv, ): Promise => { attachSocketServer(socket, serverImpl, companionEnv); + isReady = true; return new Promise((resolve) => { - server.listen(config.port, undefined, () => { - tracker.track('server-started', { - port: config.port, - }); - resolve(); + tracker.track('server-started', { + port: config.port, }); + resolve(); }); }; resolve({app, server, socket, readyForIncomingConnections}); diff --git a/desktop/flipper-server/src/index.tsx b/desktop/flipper-server/src/index.tsx index 5a2ba8ceba7..17f5935aa2d 100644 --- a/desktop/flipper-server/src/index.tsx +++ b/desktop/flipper-server/src/index.tsx @@ -215,6 +215,9 @@ async function start() { `[flipper-server][bootstrap] HTTP server started (${httpServerStartedMS} ms)`, ); + // At this point, the HTTP server is ready and listening. + launch(); + const flipperServer = await startFlipperServer( rootPath, staticPath, @@ -342,7 +345,7 @@ process.on('unhandledRejection', (reason, promise) => { }); start() - .then(launch) + .then(() => {}) .catch((e) => { console.error(chalk.red('Server startup error: '), e); process.exit(1); diff --git a/desktop/static/loading.html b/desktop/static/loading.html new file mode 100644 index 00000000000..e16e5f65283 --- /dev/null +++ b/desktop/static/loading.html @@ -0,0 +1,68 @@ + + + + + + + + + Loading... + + + + + + +
+
+ Loading... +
+ +
+ + + + From 3bfe9a1f98fb6b96a5178bbc0523042e55a459d5 Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Wed, 30 Aug 2023 06:47:48 -0700 Subject: [PATCH 19/54] Remove not needed 'then' clause Summary: ^ Reviewed By: antonk52 Differential Revision: D48826887 fbshipit-source-id: 3ecc77d326bd7ddfa5e9f125012d6854f1692010 --- desktop/flipper-server/src/index.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/desktop/flipper-server/src/index.tsx b/desktop/flipper-server/src/index.tsx index 17f5935aa2d..afb38316328 100644 --- a/desktop/flipper-server/src/index.tsx +++ b/desktop/flipper-server/src/index.tsx @@ -344,9 +344,7 @@ process.on('unhandledRejection', (reason, promise) => { ); }); -start() - .then(() => {}) - .catch((e) => { - console.error(chalk.red('Server startup error: '), e); - process.exit(1); - }); +start().catch((e) => { + console.error(chalk.red('Server startup error: '), e); + process.exit(1); +}); From d54bd8938a591fdc9ad01524490b8fc5bd001086 Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Wed, 30 Aug 2023 07:26:35 -0700 Subject: [PATCH 20/54] Add PowerSearch basic types Summary: Project doc: https://docs.google.com/document/d/1miofxds9DJgWScj0zFyBbdpRH5Rj0T9FqiCapof5-vU Reviewed By: lblasa Differential Revision: D48467956 fbshipit-source-id: 7f5303d981831c261bf5e4fe0027883fd1e7d873 --- .../src/ui/PowerSearch/PowerSearchTypes.tsx | 92 +++++++++++++++++++ .../src/ui/PowerSearch/index.tsx | 14 +++ 2 files changed, 106 insertions(+) create mode 100644 desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTypes.tsx create mode 100644 desktop/flipper-plugin/src/ui/PowerSearch/index.tsx diff --git a/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTypes.tsx b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTypes.tsx new file mode 100644 index 00000000000..aaacd75229e --- /dev/null +++ b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTypes.tsx @@ -0,0 +1,92 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +// Mostly mateches https://www.internalfb.com/code/www/html/intern/js/ui/PowerSearch/PowerSearchExampleConfig.js + +export type SimpleFilterValueType = 'NESTED' | 'NO_VALUE' | 'INTEGER' | 'FLOAT'; + +export type StringFilterValueType = 'STRING_SET' | 'STRING'; + +export type EnumFilterValueType = 'ENUM_SET' | 'ENUM'; + +export type RelativeDateFilterValueType = 'RELATIVE_DATE'; + +export type AbsoluteDateFilterValueType = 'ABSOLUTE_DATE'; + +export type TimeFilterValueType = 'TIME'; + +export type SimpleOperatorConfig = { + valueType: SimpleFilterValueType; + key: string; + label: string; +}; + +export type StringOperatorConfig = { + valueType: StringFilterValueType; + key: string; + label: string; +}; + +export type EnumOperatorConfig = { + valueType: EnumFilterValueType; + key: string; + label: string; + enumLabels: {[key: string]: string}; +}; + +export type InternPowerSearchRelativeDateAllowableTensesType = + | 'PAST_ONLY' + | 'FUTURE_ONLY' + | 'PAST_AND_FUTURE'; + +export type RelativeDateOperatorConfig = { + valueType: RelativeDateFilterValueType; + key: string; + label: string; + allowableTenses: InternPowerSearchRelativeDateAllowableTensesType; +}; + +export type AbsoluteDateOperatorConfig = { + valueType: AbsoluteDateFilterValueType; + key: string; + label: string; + dateOnly?: boolean; + minValue?: Date; + maxValue?: Date; +}; + +export type TimeOperatorConfig = { + valueType: TimeFilterValueType; + key: string; + label: string; + minValue?: Date; + maxValue?: Date; +}; + +export type OperatorConfig = + | SimpleOperatorConfig + | StringOperatorConfig + | EnumOperatorConfig + | AbsoluteDateOperatorConfig + | RelativeDateOperatorConfig + | TimeOperatorConfig; + +export type FieldConfig = { + key: string; + label: string; + operators: {[key: string]: OperatorConfig}; + operatorMenuDisplayOrder: string[]; + typeaheadOperators: string[]; +}; + +export type PowerSearchConfig = { + name: string; + fields: {[key: string]: FieldConfig}; + fieldKeyTypeaheadOrder?: string[]; +}; diff --git a/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx b/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx new file mode 100644 index 00000000000..d703423d65b --- /dev/null +++ b/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx @@ -0,0 +1,14 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +import * as React from 'react'; + +export const PowerSearch: React.FC = () => { + return <>; +}; From 839653c8fa9eb6cd8190c157798bad669aee7038 Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Wed, 30 Aug 2023 07:26:35 -0700 Subject: [PATCH 21/54] Add PowerSearch example config Summary: Project doc: https://docs.google.com/document/d/1miofxds9DJgWScj0zFyBbdpRH5Rj0T9FqiCapof5-vU Reviewed By: lblasa Differential Revision: D48468962 fbshipit-source-id: e86be373be324b44656f2ed0d9f66bf969d47a6b --- .../PowerSearch/PowerSearchExampleConfig.tsx | 318 ++++++++++++++++++ .../src/ui/PowerSearch/PowerSearchTypes.tsx | 5 +- 2 files changed, 322 insertions(+), 1 deletion(-) create mode 100644 desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchExampleConfig.tsx diff --git a/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchExampleConfig.tsx b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchExampleConfig.tsx new file mode 100644 index 00000000000..1befe010bd3 --- /dev/null +++ b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchExampleConfig.tsx @@ -0,0 +1,318 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +import {OperatorConfig, PowerSearchConfig} from './PowerSearchTypes'; + +const MyStatusEnum = { + NEEDS_REVIEW: 'Needs review', + NEEDS_REVISION: 'Waiting for author', + ACCEPTED: 'Accepted', + CLOSED: 'Closed', + ABANDONED: 'Abandoned', + CHANGES_PLANNED: 'Changes planned', + IN_PREPARATION: 'Unpublished', +}; + +const MyMacroEnum = { + SURE_WHY_NOT: 'surewhynot', + DOGSCIENCE: 'dogscience', + TEST_IN_PROD: 'testinproduction', + '': '', +}; + +const operators = { + in: { + label: 'is any of', + key: 'in', + valueType: 'STRING_SET', + }, + not_in: { + label: 'is none of', + key: 'not_in', + valueType: 'STRING_SET', + }, + contain: { + label: 'contains', + key: 'contain', + valueType: 'STRING', + }, + not_contain: { + label: 'does not contain', + key: 'not_contain', + valueType: 'STRING', + }, + greater_than: { + label: '>', + key: 'greater_than', + valueType: 'INTEGER', + }, + greater_than_float: { + label: '>', + key: 'greater_than_float', + valueType: 'FLOAT', + }, + less_than: { + label: '<', + key: 'less_than', + valueType: 'INTEGER', + }, + less_than_float: { + label: '<', + key: 'less_than_float', + valueType: 'FLOAT', + }, + status_any: { + label: 'is any of', + key: 'status_any', + valueType: 'ENUM_SET', + enumLabels: MyStatusEnum, + }, + status_not_any: { + label: 'is not any of', + key: 'status_not_any', + valueType: 'ENUM_SET', + enumLabels: MyStatusEnum, + }, + ent_class_any_with_arbitrary_strings: { + label: 'is any of (arbitrary allowed)', + key: 'ent_class_any_with_arbitrary_strings', + valueType: 'STRING_SET', + allowArbitraryEntries: true, + }, + caller_is: { + label: 'is', + key: 'caller_is', + valueType: 'STRING', + }, + macro_is: { + label: 'is', + key: 'macro_is', + valueType: 'ENUM', + enumLabels: MyMacroEnum, + }, + macro_is_not: { + label: 'is not', + key: 'macro_is_not', + valueType: 'ENUM', + enumLabels: MyMacroEnum, + }, + predictive_contain: { + label: 'contains', + key: 'predictive_contain', + valueType: 'STRING', + }, + predictive_not_contain: { + label: 'does not contain', + key: 'predictive_not_contain', + valueType: 'STRING', + allowArbitraryEntries: true, + }, + newer_than_relative_date: { + key: 'newer_than_relative_date', + label: 'is newer than', + isNegative: false, + valueType: 'RELATIVE_DATE', + allowableTenses: 'PAST_AND_FUTURE', + }, + newer_than_absolute_date: { + key: 'newer_than_absolute_date', + label: 'is after', + isNegative: false, + valueType: 'ABSOLUTE_DATE', + dateOnly: false, + }, + newer_than_absolute_date_no_time: { + key: 'newer_than_absolute_date_no_time', + label: 'is after the day', + isNegative: false, + valueType: 'ABSOLUTE_DATE', + dateOnly: true, + }, + time_after: { + label: 'is after', + key: 'time_after', + valueType: 'TIME', + }, + filtered_time_after: { + label: 'is after', + key: 'filtered_time_after', + valueType: 'TIME', + // TODO: Fix me + // Only show times between 4 - 11:59PM + minValue: undefined, + maxValue: undefined, + }, + unread: { + key: 'unread', + label: '', + valueType: 'NO_VALUE', + }, +} satisfies {[key: string]: OperatorConfig}; + +export const config: PowerSearchConfig = { + name: 'FlipperPowerSearchExampleConfig', + fields: { + id: { + key: 'id', + label: 'ID', + operators: { + in: operators.in, + not_in: operators.not_in, + }, + operatorMenuDisplayOrder: ['in', 'not_in'], + }, + title: { + key: 'title', + label: 'Title', + operators: { + contain: operators.contain, + not_contain: operators.not_contain, + }, + operatorMenuDisplayOrder: ['contain', 'not_contain'], + }, + description: { + key: 'description', + label: 'Description', + operators: { + contain: operators.contain, + not_contain: operators.not_contain, + }, + operatorMenuDisplayOrder: ['contain', 'not_contain'], + }, + placeholder: { + key: 'placeholder', + label: 'Placeholder', + operators: { + predictive_contain: operators.predictive_contain, + predictive_not_contain: operators.predictive_not_contain, + }, + operatorMenuDisplayOrder: [ + 'predictive_contain', + 'predictive_not_contain', + ], + }, + lines: { + key: 'lines', + label: 'Line count', + operators: { + greater_than: operators.greater_than, + less_than: operators.less_than, + }, + operatorMenuDisplayOrder: ['greater_than', 'less_than'], + }, + cost: { + key: 'cost', + label: 'Cost', + operators: { + greater_than_float: operators.greater_than_float, + less_than_float: operators.less_than_float, + }, + operatorMenuDisplayOrder: ['greater_than_float', 'less_than_float'], + }, + status: { + key: 'status', + label: 'Status', + operators: { + status_any: operators.status_any, + status_not_any: operators.status_not_any, + }, + operatorMenuDisplayOrder: ['status_any', 'status_not_any'], + }, + caller: { + key: 'caller', + label: 'Caller', + operators: { + caller_is: operators.caller_is, + }, + operatorMenuDisplayOrder: ['caller_is'], + }, + macro: { + key: 'macro', + label: 'Macro', + operators: { + macro_is: operators.macro_is, + macro_is_not: operators.macro_is_not, + }, + operatorMenuDisplayOrder: ['macro_is', 'macro_is_not'], + }, + time: { + key: 'time', + label: 'Time', + operators: { + time_after: operators.time_after, + }, + operatorMenuDisplayOrder: ['time_after'], + }, + filtered_time: { + key: 'filtered_time', + label: 'Time After 4PM', + operators: { + filtered_time_after: operators.filtered_time_after, + }, + operatorMenuDisplayOrder: ['filtered_time_after'], + }, + last_update: { + key: 'last_update', + label: 'Last Update', + operators: { + newer_than_relative_date: operators.newer_than_relative_date, + newer_than_absolute_date: operators.newer_than_absolute_date, + newer_than_absolute_date_no_time: + operators.newer_than_absolute_date_no_time, + }, + operatorMenuDisplayOrder: [ + 'newer_than_relative_date', + 'newer_than_absolute_date', + 'newer_than_absolute_date_no_time', + ], + }, + unread_only: { + key: 'unread_only', + label: 'Unread Only', + operators: { + unread: operators.unread, + }, + operatorMenuDisplayOrder: ['unread_only'], + }, + NESTED_FIELD: { + key: 'NESTED_FIELD', + label: '', + operators: { + AND: { + key: 'AND', + label: 'All of', + valueType: 'NESTED', + }, + NOT: { + key: 'NOT', + label: 'None of', + valueType: 'NESTED', + }, + OR: { + key: 'OR', + label: 'Any of', + valueType: 'NESTED', + }, + }, + operatorMenuDisplayOrder: ['AND', 'NOT', 'OR'], + }, + CONTEXT_TOKEN: { + key: 'CONTEXT_TOKEN', + label: 'Context Token', + operators: { + CONTEXT_TOKEN: { + key: 'CONTEXT_TOKEN', + label: '', + valueType: 'NO_VALUE', + }, + }, + operatorMenuDisplayOrder: [], + }, + }, +}; diff --git a/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTypes.tsx b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTypes.tsx index aaacd75229e..f69e3782fa0 100644 --- a/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTypes.tsx +++ b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTypes.tsx @@ -31,6 +31,7 @@ export type StringOperatorConfig = { valueType: StringFilterValueType; key: string; label: string; + allowArbitraryEntries?: boolean; }; export type EnumOperatorConfig = { @@ -50,6 +51,7 @@ export type RelativeDateOperatorConfig = { key: string; label: string; allowableTenses: InternPowerSearchRelativeDateAllowableTensesType; + isNegative?: boolean; }; export type AbsoluteDateOperatorConfig = { @@ -59,6 +61,7 @@ export type AbsoluteDateOperatorConfig = { dateOnly?: boolean; minValue?: Date; maxValue?: Date; + isNegative?: boolean; }; export type TimeOperatorConfig = { @@ -67,6 +70,7 @@ export type TimeOperatorConfig = { label: string; minValue?: Date; maxValue?: Date; + isNegative?: boolean; }; export type OperatorConfig = @@ -82,7 +86,6 @@ export type FieldConfig = { label: string; operators: {[key: string]: OperatorConfig}; operatorMenuDisplayOrder: string[]; - typeaheadOperators: string[]; }; export type PowerSearchConfig = { From b780dc0598360ce9b8e17ac46e9e8626d853e174 Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Wed, 30 Aug 2023 07:26:35 -0700 Subject: [PATCH 22/54] Add basic Autocomplete Summary: Project doc: https://docs.google.com/document/d/1miofxds9DJgWScj0zFyBbdpRH5Rj0T9FqiCapof5-vU Reviewed By: lblasa Differential Revision: D48517919 fbshipit-source-id: ec6e723a595862b61722db9c5afd96138264dfdc --- .../flipper-plugin/src/__tests__/api.node.tsx | 2 + desktop/flipper-plugin/src/index.tsx | 1 + .../src/ui/PowerSearch/index.tsx | 44 ++++++++++++++++++- docs/extending/flipper-plugin.mdx | 2 + 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/desktop/flipper-plugin/src/__tests__/api.node.tsx b/desktop/flipper-plugin/src/__tests__/api.node.tsx index 9c348c87f7f..8d36234797a 100644 --- a/desktop/flipper-plugin/src/__tests__/api.node.tsx +++ b/desktop/flipper-plugin/src/__tests__/api.node.tsx @@ -46,6 +46,7 @@ test('Correct top level API exposed', () => { "MasterDetail", "NUX", "Panel", + "PowerSearch", "Spinner", "Tab", "Tabs", @@ -129,6 +130,7 @@ test('Correct top level API exposed', () => { "NormalizedMenuEntry", "Notification", "PluginClient", + "PowerSearchConfig", "RemoteServerContext", "ServerAddOn", "ServerAddOnPluginConnection", diff --git a/desktop/flipper-plugin/src/index.tsx b/desktop/flipper-plugin/src/index.tsx index 7016dd0fd78..8749e961d20 100644 --- a/desktop/flipper-plugin/src/index.tsx +++ b/desktop/flipper-plugin/src/index.tsx @@ -60,6 +60,7 @@ export {DataTable, DataTableColumn} from './ui/data-table/DataTable'; export {DataTableManager} from './ui/data-table/DataTableManager'; export {DataList} from './ui/DataList'; export {Spinner} from './ui/Spinner'; +export * from './ui/PowerSearch'; export {DataSourceVirtualizer} from './data-source/DataSourceRendererVirtual'; diff --git a/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx b/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx index d703423d65b..94ea5df8ea4 100644 --- a/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx +++ b/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx @@ -8,7 +8,47 @@ */ import * as React from 'react'; +import {AutoComplete, Input} from 'antd'; +import {PowerSearchConfig} from './PowerSearchTypes'; -export const PowerSearch: React.FC = () => { - return <>; +export {PowerSearchConfig}; + +type PowerSearchProps = { + config: PowerSearchConfig; +}; + +export const PowerSearch: React.FC = () => { + return ( + + + + ); }; diff --git a/docs/extending/flipper-plugin.mdx b/docs/extending/flipper-plugin.mdx index 69e651a0912..66f22899e79 100644 --- a/docs/extending/flipper-plugin.mdx +++ b/docs/extending/flipper-plugin.mdx @@ -950,6 +950,8 @@ function HighlightedText(props: {text: string}) { } ``` +### PowerSearch + ### DataTable ### DataFormatter From 9cdf9447166eb48539e61cc0cefe328208867e5a Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Wed, 30 Aug 2023 07:26:35 -0700 Subject: [PATCH 23/54] Compute Autocomplete options from config Summary: Project doc: https://docs.google.com/document/d/1miofxds9DJgWScj0zFyBbdpRH5Rj0T9FqiCapof5-vU Reviewed By: lblasa Differential Revision: D48518324 fbshipit-source-id: 5abee77cca10f03b2d9fa5b62802a5000152248e --- .../PowerSearch/PowerSearchExampleConfig.tsx | 2 +- .../src/ui/PowerSearch/index.tsx | 64 ++++++++++--------- 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchExampleConfig.tsx b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchExampleConfig.tsx index 1befe010bd3..b2a58bf80fc 100644 --- a/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchExampleConfig.tsx +++ b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchExampleConfig.tsx @@ -155,7 +155,7 @@ const operators = { }, } satisfies {[key: string]: OperatorConfig}; -export const config: PowerSearchConfig = { +export const powerSearchExampleConfig: PowerSearchConfig = { name: 'FlipperPowerSearchExampleConfig', fields: { id: { diff --git a/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx b/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx index 94ea5df8ea4..c4cb8898226 100644 --- a/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx +++ b/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx @@ -17,37 +17,41 @@ type PowerSearchProps = { config: PowerSearchConfig; }; -export const PowerSearch: React.FC = () => { +type AutocompleteOption = {label: string; value: string}; +type AutocompleteOptionGroup = { + label: string; + options: AutocompleteOption[]; +}; + +const OPTION_KEY_DELIMITER = '::'; + +export const PowerSearch: React.FC = ({config}) => { + const options: AutocompleteOptionGroup[] = React.useMemo(() => { + const groupedOptions: AutocompleteOptionGroup[] = []; + + console.log('config.fields', config.fields); + + for (const field of Object.values(config.fields)) { + const group: AutocompleteOptionGroup = { + label: field.label, + options: [], + }; + + for (const operator of Object.values(field.operators)) { + const option: AutocompleteOption = { + label: operator.label, + value: `${field.key}${OPTION_KEY_DELIMITER}${operator.key}`, + }; + group.options.push(option); + } + + groupedOptions.push(group); + } + + return groupedOptions; + }, [config.fields]); return ( - + ); From c746a11dc6ecacb2194859f47d15856db1912e60 Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Wed, 30 Aug 2023 07:26:35 -0700 Subject: [PATCH 24/54] Allow multiple search terms Summary: Project doc: https://docs.google.com/document/d/1miofxds9DJgWScj0zFyBbdpRH5Rj0T9FqiCapof5-vU Reviewed By: lblasa Differential Revision: D48519758 fbshipit-source-id: d691a26ebed9f7797516386b8fb9d4457b870a3e --- .../src/ui/PowerSearch/index.tsx | 36 +++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx b/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx index c4cb8898226..8cdcc5a1ea4 100644 --- a/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx +++ b/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx @@ -8,7 +8,7 @@ */ import * as React from 'react'; -import {AutoComplete, Input} from 'antd'; +import {AutoComplete, Space, Tag} from 'antd'; import {PowerSearchConfig} from './PowerSearchTypes'; export {PowerSearchConfig}; @@ -21,25 +21,29 @@ type AutocompleteOption = {label: string; value: string}; type AutocompleteOptionGroup = { label: string; options: AutocompleteOption[]; + value: string; }; const OPTION_KEY_DELIMITER = '::'; export const PowerSearch: React.FC = ({config}) => { + const [searchExpression, setSearchExpression] = React.useState< + AutocompleteOption[] + >([]); + const options: AutocompleteOptionGroup[] = React.useMemo(() => { const groupedOptions: AutocompleteOptionGroup[] = []; - console.log('config.fields', config.fields); - for (const field of Object.values(config.fields)) { const group: AutocompleteOptionGroup = { label: field.label, options: [], + value: field.key, }; for (const operator of Object.values(field.operators)) { const option: AutocompleteOption = { - label: operator.label, + label: `${field.label} ${operator.label}`, value: `${field.key}${OPTION_KEY_DELIMITER}${operator.key}`, }; group.options.push(option); @@ -50,9 +54,27 @@ export const PowerSearch: React.FC = ({config}) => { return groupedOptions; }, [config.fields]); + return ( - - - +
+ + {searchExpression.map((searchTerm) => ( + {searchTerm.label} + ))} + + { + console.log('selectedOption', selectedOption); + setSearchExpression((prevSearchExpression) => [ + ...prevSearchExpression, + selectedOption, + ]); + }} + value={null} + /> +
); }; From 795d02d00c640a8f299575fcbfbeb507dc8686a3 Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Wed, 30 Aug 2023 07:26:35 -0700 Subject: [PATCH 25/54] Separate search term parts Summary: Project doc: https://docs.google.com/document/d/1miofxds9DJgWScj0zFyBbdpRH5Rj0T9FqiCapof5-vU Reviewed By: lblasa Differential Revision: D48520106 fbshipit-source-id: 2a544230f182bd82023310ea88742fab44e2df9b --- .../src/ui/PowerSearch/index.tsx | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx b/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx index 8cdcc5a1ea4..b9ffdb9dabb 100644 --- a/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx +++ b/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx @@ -8,8 +8,12 @@ */ import * as React from 'react'; -import {AutoComplete, Space, Tag} from 'antd'; -import {PowerSearchConfig} from './PowerSearchTypes'; +import {AutoComplete, Button, Space} from 'antd'; +import { + PowerSearchConfig, + FieldConfig, + OperatorConfig, +} from './PowerSearchTypes'; export {PowerSearchConfig}; @@ -26,9 +30,15 @@ type AutocompleteOptionGroup = { const OPTION_KEY_DELIMITER = '::'; +type SearchExpressionTerm = { + field: FieldConfig; + operator: OperatorConfig; + searchValue?: string; +}; + export const PowerSearch: React.FC = ({config}) => { const [searchExpression, setSearchExpression] = React.useState< - AutocompleteOption[] + SearchExpressionTerm[] >([]); const options: AutocompleteOptionGroup[] = React.useMemo(() => { @@ -58,8 +68,12 @@ export const PowerSearch: React.FC = ({config}) => { return (
- {searchExpression.map((searchTerm) => ( - {searchTerm.label} + {searchExpression.map((searchTerm, i) => ( + + + + + ))} = ({config}) => { options={options} bordered={false} onSelect={(_: string, selectedOption: AutocompleteOption) => { - console.log('selectedOption', selectedOption); + const [fieldKey, operatorKey] = + selectedOption.value.split(OPTION_KEY_DELIMITER); + const fieldConfig = config.fields[fieldKey]; + const operatorConfig = fieldConfig.operators[operatorKey]; + setSearchExpression((prevSearchExpression) => [ ...prevSearchExpression, - selectedOption, + { + field: fieldConfig, + operator: operatorConfig, + }, ]); }} value={null} From c09106790252bc20ef13bd4d747ba6e1133d25dc Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Wed, 30 Aug 2023 07:26:35 -0700 Subject: [PATCH 26/54] Update antd Summary: Project doc: https://docs.google.com/document/d/1miofxds9DJgWScj0zFyBbdpRH5Rj0T9FqiCapof5-vU Required to get `Space.Compact` allow-large-files Reviewed By: passy Differential Revision: D48520383 fbshipit-source-id: 000a5c16c00541455dc4a31c4fddb2c4c252a89e --- desktop/flipper-plugin/package.json | 2 +- .../src/ui/PowerSearch/index.tsx | 2 +- .../src/ui/__tests__/DataFormatter.node.tsx | 20 +- desktop/flipper-ui-core/package.json | 2 +- .../ShareSheetPendingDialog.node.tsx.snap | 8 +- .../__tests__/LaunchEmulator.spec.tsx | 2 +- .../{antd+4.19.2.patch => antd+4.24.13.patch} | 38 +- desktop/patches/rc-collapse+3.1.0.patch | 24 - desktop/patches/rc-collapse+3.4.2.patch | 18 + ...bs+11.10.5.patch => rc-tabs+12.5.10.patch} | 12 +- desktop/plugins/package.json | 2 +- desktop/yarn.lock | 470 ++++++++++-------- 12 files changed, 334 insertions(+), 266 deletions(-) rename desktop/patches/{antd+4.19.2.patch => antd+4.24.13.patch} (56%) delete mode 100644 desktop/patches/rc-collapse+3.1.0.patch create mode 100644 desktop/patches/rc-collapse+3.4.2.patch rename desktop/patches/{rc-tabs+11.10.5.patch => rc-tabs+12.5.10.patch} (77%) diff --git a/desktop/flipper-plugin/package.json b/desktop/flipper-plugin/package.json index 5a59360d10f..8fbd7ef0a03 100644 --- a/desktop/flipper-plugin/package.json +++ b/desktop/flipper-plugin/package.json @@ -34,7 +34,7 @@ "peerDependencies": { "@ant-design/icons": "^4.2.2", "@testing-library/dom": "^7.26.3", - "antd": "^4.23.4" + "antd": "^4.24" }, "scripts": { "reset": "rimraf lib *.tsbuildinfo", diff --git a/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx b/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx index b9ffdb9dabb..f9bef612686 100644 --- a/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx +++ b/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx @@ -94,7 +94,7 @@ export const PowerSearch: React.FC = ({config}) => { }, ]); }} - value={null} + value={''} />
); diff --git a/desktop/flipper-plugin/src/ui/__tests__/DataFormatter.node.tsx b/desktop/flipper-plugin/src/ui/__tests__/DataFormatter.node.tsx index b78acbdf60f..d52574492dc 100644 --- a/desktop/flipper-plugin/src/ui/__tests__/DataFormatter.node.tsx +++ b/desktop/flipper-plugin/src/ui/__tests__/DataFormatter.node.tsx @@ -92,11 +92,11 @@ test('linkify formatter', () => { expect(linkify('https://www.google.com')).toMatchInlineSnapshot(` - https://www.google.com - + `); @@ -107,11 +107,11 @@ test('linkify formatter', () => { expect(linkify('test https://www.google.com test')).toMatchInlineSnapshot(` test - https://www.google.com - + test `); @@ -119,17 +119,17 @@ test('linkify formatter', () => { .toMatchInlineSnapshot(` - https://www.google.com - + test - http://fb.com - + `); @@ -162,11 +162,11 @@ test('jsonify formatter', () => { { "hello": " - http://facebook.com - + " } diff --git a/desktop/flipper-ui-core/package.json b/desktop/flipper-ui-core/package.json index 70e3060eeb7..ac4c127f04b 100644 --- a/desktop/flipper-ui-core/package.json +++ b/desktop/flipper-ui-core/package.json @@ -15,7 +15,7 @@ "@emotion/react": "^11.8.2", "@emotion/styled": "^11.10.4", "@tanishiking/aho-corasick": "^0.0.1", - "antd": "4.19.2", + "antd": "^4.24", "cbuffer": "^2.2.0", "deep-equal": "^2.2.2", "@nicksrandall/console-feed": "^3.5.0", diff --git a/desktop/flipper-ui-core/src/chrome/__tests__/__snapshots__/ShareSheetPendingDialog.node.tsx.snap b/desktop/flipper-ui-core/src/chrome/__tests__/__snapshots__/ShareSheetPendingDialog.node.tsx.snap index dc41860cfc2..1aff655f7d9 100644 --- a/desktop/flipper-ui-core/src/chrome/__tests__/__snapshots__/ShareSheetPendingDialog.node.tsx.snap +++ b/desktop/flipper-ui-core/src/chrome/__tests__/__snapshots__/ShareSheetPendingDialog.node.tsx.snap @@ -11,6 +11,8 @@ exports[`ShareSheetPendingDialog is rendered with status update 1`] = ` } >
- - - - ))} + {searchExpression.map((searchTerm, i) => { + const isLastTerm = i === searchExpression.length - 1; + + return ( + + + + {lastSearchTermHasSearchValue || !isLastTerm ? ( + + ) : ( + // TODO: Fix width + { + const newValue = event.target.value; + + if (!newValue) { + setSearchExpression((prevSearchExpression) => { + return prevSearchExpression.slice(0, -1); + }); + return; + } + + setSearchExpression((prevSearchExpression) => { + return [ + ...prevSearchExpression.slice(0, -1), + { + ...prevSearchExpression[ + prevSearchExpression.length - 1 + ], + searchValue: newValue, + }, + ]; + }); + }} + onKeyUp={(event) => { + if (event.key === 'Enter') { + event.currentTarget.blur(); + } + }} + /> + )} + + ); + })} - style={{flex: '1'}} options={options} bordered={false} From 44c3f53905279461772da2bc4612175fca332fd2 Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Wed, 30 Aug 2023 07:26:35 -0700 Subject: [PATCH 28/54] Support removing search terms Summary: Project doc: https://docs.google.com/document/d/1miofxds9DJgWScj0zFyBbdpRH5Rj0T9FqiCapof5-vU Reviewed By: lblasa Differential Revision: D48557277 fbshipit-source-id: edaa5e8806538fa308d43c364e4f68967c1bf2ac --- .../flipper-plugin/src/ui/PowerSearch/index.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx b/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx index 3caeeb1c3a9..70bc9b47581 100644 --- a/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx +++ b/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx @@ -14,6 +14,7 @@ import { FieldConfig, OperatorConfig, } from './PowerSearchTypes'; +import {CloseOutlined} from '@ant-design/icons'; export {PowerSearchConfig}; @@ -117,6 +118,20 @@ export const PowerSearch: React.FC = ({config}) => { }} /> )} +
); From 194c08a12ca122573137ba69b02f021b0178695c Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Wed, 30 Aug 2023 07:26:35 -0700 Subject: [PATCH 30/54] Support keyboard Summary: Project doc: https://docs.google.com/document/d/1miofxds9DJgWScj0zFyBbdpRH5Rj0T9FqiCapof5-vU Reviewed By: lblasa Differential Revision: D48559580 fbshipit-source-id: 683969879c213b869faadc60c6caab8f716b8688 --- .../src/ui/PowerSearch/index.tsx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx b/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx index 9bdcc7212e7..38108fe6c5a 100644 --- a/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx +++ b/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx @@ -71,6 +71,10 @@ export const PowerSearch: React.FC = ({config}) => { ? searchExpression[searchExpression.length - 1].searchValue !== undefined : false; + const [searchTermFinderValue, setSearchTermFinderValue] = React.useState< + string | null + >(null); + return (
@@ -111,8 +115,8 @@ export const PowerSearch: React.FC = ({config}) => { ]; }); }} - onKeyUp={(event) => { - if (event.key === 'Enter') { + onKeyDown={(event) => { + if (event.key === 'Enter' || event.key === 'Escape') { event.currentTarget.blur(); } }} @@ -153,12 +157,23 @@ export const PowerSearch: React.FC = ({config}) => { operator: operatorConfig, }, ]); + setSearchTermFinderValue(null); }} filterOption={(inputValue, option) => { return !!option?.label .toLowerCase() .includes(inputValue.toLowerCase()); }} + value={searchTermFinderValue} + onChange={setSearchTermFinderValue} + onBlur={() => { + setSearchTermFinderValue(null); + }} + onInputKeyDown={(event) => { + if (event.key === 'Enter') { + setSearchTermFinderValue(null); + } + }} />
); From 729c60f711f12271ba02bc72a1ce8032410957f0 Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Wed, 30 Aug 2023 07:26:35 -0700 Subject: [PATCH 31/54] Shift focus to entering next search term when finish editing the curretn one Summary: Project doc: https://docs.google.com/document/d/1miofxds9DJgWScj0zFyBbdpRH5Rj0T9FqiCapof5-vU Reviewed By: lblasa Differential Revision: D48559678 fbshipit-source-id: 88075c473f8296a6d734116e9f2b02e941b3d7c7 --- desktop/flipper-plugin/src/ui/PowerSearch/index.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx b/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx index 38108fe6c5a..4904af564b6 100644 --- a/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx +++ b/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx @@ -71,6 +71,11 @@ export const PowerSearch: React.FC = ({config}) => { ? searchExpression[searchExpression.length - 1].searchValue !== undefined : false; + const searchTermFinderRef = React.useRef<{ + focus: () => void; + blur: () => void; + scrollTo: () => void; + }>(null); const [searchTermFinderValue, setSearchTermFinderValue] = React.useState< string | null >(null); @@ -114,6 +119,7 @@ export const PowerSearch: React.FC = ({config}) => { }, ]; }); + searchTermFinderRef.current?.focus(); }} onKeyDown={(event) => { if (event.key === 'Enter' || event.key === 'Escape') { @@ -141,6 +147,7 @@ export const PowerSearch: React.FC = ({config}) => { })} + ref={searchTermFinderRef} style={{flex: '1'}} options={options} bordered={false} From 2c5bcb373dedf3b57a659b03e1484e5eb4f6c1b8 Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Wed, 30 Aug 2023 07:26:35 -0700 Subject: [PATCH 32/54] Extract container Summary: Project doc: https://docs.google.com/document/d/1miofxds9DJgWScj0zFyBbdpRH5Rj0T9FqiCapof5-vU Reviewed By: LukeDefeo Differential Revision: D48560381 fbshipit-source-id: ecdc6bb95514faf913b23239bbd40113b8e0f57b --- .../ui/PowerSearch/PowerSearchContainer.tsx | 30 +++++++++++++++++++ .../src/ui/PowerSearch/index.tsx | 5 ++-- desktop/flipper-plugin/src/ui/theme.tsx | 1 + desktop/themes/base.less | 1 + 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchContainer.tsx diff --git a/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchContainer.tsx b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchContainer.tsx new file mode 100644 index 00000000000..d1a3ff9c172 --- /dev/null +++ b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchContainer.tsx @@ -0,0 +1,30 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +import * as React from 'react'; +import {css} from '@emotion/css'; +import {theme} from '../theme'; + +const containerStyle = css` + display: flex; + flex-direction: row; + border-radius: ${theme.borderRadius}; + border: 1px solid ${theme.borderColor}; + transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1); + + &:focus-within, + &:hover { + border-color: ${theme.primaryColor}; + box-shadow: 0 0 0 2px rgba(114, 46, 209, 0.2); + } +`; + +export const PowerSearchContainer: React.FC = ({children}) => { + return
{children}
; +}; diff --git a/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx b/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx index 4904af564b6..ccb23bbd3cf 100644 --- a/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx +++ b/desktop/flipper-plugin/src/ui/PowerSearch/index.tsx @@ -15,6 +15,7 @@ import { OperatorConfig, } from './PowerSearchTypes'; import {CloseOutlined} from '@ant-design/icons'; +import {PowerSearchContainer} from './PowerSearchContainer'; export {PowerSearchConfig}; @@ -81,7 +82,7 @@ export const PowerSearch: React.FC = ({config}) => { >(null); return ( -
+ {searchExpression.map((searchTerm, i) => { const isLastTerm = i === searchExpression.length - 1; @@ -182,6 +183,6 @@ export const PowerSearch: React.FC = ({config}) => { } }} /> -
+ ); }; diff --git a/desktop/flipper-plugin/src/ui/theme.tsx b/desktop/flipper-plugin/src/ui/theme.tsx index de6bb0de00e..061d9b4d09f 100644 --- a/desktop/flipper-plugin/src/ui/theme.tsx +++ b/desktop/flipper-plugin/src/ui/theme.tsx @@ -34,6 +34,7 @@ export const theme = { buttonDefaultBackground: 'var(--flipper-button-default-background)', backgroundTransparentHover: 'var(--flipper-background-transparent-hover)', dividerColor: 'var(--flipper-divider-color)', + borderColor: 'var(--flipper-border-color)', borderRadius: 'var(--flipper-border-radius)', containerBorderRadius: 8, inlinePaddingV: 6, // vertical padding on inline elements like buttons diff --git a/desktop/themes/base.less b/desktop/themes/base.less index 55aaab574db..0cc2ed857c7 100644 --- a/desktop/themes/base.less +++ b/desktop/themes/base.less @@ -61,4 +61,5 @@ --flipper-diff-added-background: @diff-added-background; --flipper-diff-removed-background: @diff-removed-background; --flipper-border-radius: @border-radius-base; + --flipper-border-color: @normal-color; } From c9ab951e849fc790af1c8b4095e6c9be9bd017e5 Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Wed, 30 Aug 2023 07:26:35 -0700 Subject: [PATCH 33/54] Extract PowerSearchTerm Summary: Project doc: https://docs.google.com/document/d/1miofxds9DJgWScj0zFyBbdpRH5Rj0T9FqiCapof5-vU Reviewed By: lblasa Differential Revision: D48599166 fbshipit-source-id: 13b447b55408a8673928489312c4d22cf864c232 --- ...rSearchTypes.tsx => PowerSearchConfig.tsx} | 0 .../PowerSearch/PowerSearchExampleConfig.tsx | 2 +- .../src/ui/PowerSearch/PowerSearchTerm.tsx | 74 ++++++++++++++ .../src/ui/PowerSearch/index.tsx | 99 ++++++------------- 4 files changed, 105 insertions(+), 70 deletions(-) rename desktop/flipper-plugin/src/ui/PowerSearch/{PowerSearchTypes.tsx => PowerSearchConfig.tsx} (100%) create mode 100644 desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTerm.tsx diff --git a/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTypes.tsx b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchConfig.tsx similarity index 100% rename from desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTypes.tsx rename to desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchConfig.tsx diff --git a/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchExampleConfig.tsx b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchExampleConfig.tsx index b2a58bf80fc..851e97f01c5 100644 --- a/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchExampleConfig.tsx +++ b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchExampleConfig.tsx @@ -7,7 +7,7 @@ * @format */ -import {OperatorConfig, PowerSearchConfig} from './PowerSearchTypes'; +import {OperatorConfig, PowerSearchConfig} from './PowerSearchConfig'; const MyStatusEnum = { NEEDS_REVIEW: 'Needs review', diff --git a/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTerm.tsx b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTerm.tsx new file mode 100644 index 00000000000..8b403b9cac2 --- /dev/null +++ b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTerm.tsx @@ -0,0 +1,74 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +import {CloseOutlined} from '@ant-design/icons'; +import {Button, Input, Space} from 'antd'; +import * as React from 'react'; +import {FieldConfig, OperatorConfig} from './PowerSearchConfig'; + +export type SearchExpressionTerm = { + field: FieldConfig; + operator: OperatorConfig; + searchValue?: string; +}; + +type PowerSearchTermProps = { + searchTerm: SearchExpressionTerm; + searchValueRenderer: 'input' | 'button'; + onCancel: () => void; + onFinalize: (completeSearchTerm: Required) => void; +}; + +export const PowerSearchTerm: React.FC = ({ + searchTerm, + searchValueRenderer, + onCancel, + onFinalize, +}) => { + return ( + + + + {searchValueRenderer === 'button' ? ( + + ) : ( + // TODO: Fix width + { + const newValue = event.target.value; + + if (!newValue) { + onCancel(); + return; + } + + onFinalize({ + ...searchTerm, + searchValue: newValue, + }); + }} + onKeyDown={(event) => { + if (event.key === 'Enter' || event.key === 'Escape') { + event.currentTarget.blur(); + } + }} + /> + )} + - - {lastSearchTermHasSearchValue || !isLastTerm ? ( - - ) : ( - // TODO: Fix width - { - const newValue = event.target.value; - - if (!newValue) { - setSearchExpression((prevSearchExpression) => { - return prevSearchExpression.slice(0, -1); - }); - return; - } - - setSearchExpression((prevSearchExpression) => { - return [ - ...prevSearchExpression.slice(0, -1), - { - ...prevSearchExpression[ - prevSearchExpression.length - 1 - ], - searchValue: newValue, - }, - ]; - }); - searchTermFinderRef.current?.focus(); - }} - onKeyDown={(event) => { - if (event.key === 'Enter' || event.key === 'Escape') { - event.currentTarget.blur(); - } - }} - /> - )} - ) : ( - // TODO: Fix width - { - const newValue = event.target.value; - - if (!newValue) { - onCancel(); - return; - } - + { onFinalize({ ...searchTerm, searchValue: newValue, }); }} - onKeyDown={(event) => { - if (event.key === 'Enter' || event.key === 'Escape') { - event.currentTarget.blur(); - } - }} /> )} - - {searchValueRenderer === 'button' ? ( - - ) : ( + let searchValueInputComponent: React.ReactNode = null; + switch (searchTerm.operator.valueType) { + case 'STRING': { + searchValueInputComponent = ( { @@ -49,6 +47,40 @@ export const PowerSearchTerm: React.FC = ({ }); }} /> + ); + break; + } + case 'INTEGER': { + searchValueInputComponent = ( + { + onFinalize({ + ...searchTerm, + searchValue: newValue, + }); + }} + /> + ); + break; + } + default: { + console.error( + 'PowerSearchTerm -> unknownoperator.valueType', + searchTerm.operator.valueType, + searchTerm, + ); + } + } + + return ( + + + + {searchValueRenderer === 'button' ? ( + + ) : ( + searchValueInputComponent )} From 857e2d2ead8a7901e5b91df756564828732f267c Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Wed, 30 Aug 2023 07:26:35 -0700 Subject: [PATCH 43/54] Support enum operator type Summary: Project doc: https://docs.google.com/document/d/1miofxds9DJgWScj0zFyBbdpRH5Rj0T9FqiCapof5-vU Reviewed By: lblasa Differential Revision: D48605906 fbshipit-source-id: d81243fbc8b33e366e9207f282ba42808cfab533 --- .../ui/PowerSearch/PowerSearchEnumTerm.tsx | 56 +++++++++++++++++++ .../src/ui/PowerSearch/PowerSearchTerm.tsx | 16 ++++++ 2 files changed, 72 insertions(+) create mode 100644 desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchEnumTerm.tsx diff --git a/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchEnumTerm.tsx b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchEnumTerm.tsx new file mode 100644 index 00000000000..91e60fcc843 --- /dev/null +++ b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchEnumTerm.tsx @@ -0,0 +1,56 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +import {Select} from 'antd'; +import React from 'react'; + +type PowerSearchEnumTermProps = { + onCancel: () => void; + onChange: (value: string) => void; + enumLabels: {[key: string]: string}; +}; + +export const PowerSearchEnumTerm: React.FC = ({ + onCancel, + onChange, + enumLabels, +}) => { + const options = React.useMemo(() => { + return Object.entries(enumLabels).map(([key, label]) => ({ + label, + value: key, + })); + }, [enumLabels]); + + const selectValueRef = React.useRef(); + + return ( + { + if (!selectValueRef.current?.length) { + onCancel(); + } + }} + onChange={(value) => { + if (!value.length) { + onCancel(); + return; + } + selectValueRef.current = value; + onChange(value); + }} + onClear={onCancel} + onKeyDown={(event) => { + if (event.key === 'Enter' || event.key === 'Escape') { + event.currentTarget.blur(); + } + }} + /> + ); +}; diff --git a/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchExampleConfig.tsx b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchExampleConfig.tsx index c33da7570ab..ad0ac53cde8 100644 --- a/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchExampleConfig.tsx +++ b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchExampleConfig.tsx @@ -13,7 +13,6 @@ const MyMacroEnum = { SURE_WHY_NOT: 'surewhynot', DOGSCIENCE: 'dogscience', TEST_IN_PROD: 'testinproduction', - '': '', }; const operators = { @@ -64,6 +63,12 @@ const operators = { valueType: 'ENUM', enumLabels: MyMacroEnum, }, + macro_is_any_of: { + label: 'is any of', + key: 'macro_is_any_of', + valueType: 'ENUM_SET', + enumLabels: MyMacroEnum, + }, predictive_contain: { label: 'contains', key: 'predictive_contain', @@ -158,6 +163,7 @@ export const powerSearchExampleConfig: PowerSearchConfig = { operators: { macro_is: operators.macro_is, macro_is_not: operators.macro_is_not, + macro_is_any_of: operators.macro_is_any_of, }, }, unread_only: { diff --git a/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTerm.tsx b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTerm.tsx index 5f38f068002..783c0261751 100644 --- a/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTerm.tsx +++ b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTerm.tsx @@ -17,6 +17,7 @@ import { PowerSearchAbsoluteDateTerm, } from './PowerSearchAbsoluteDateTerm'; import {FieldConfig, OperatorConfig} from './PowerSearchConfig'; +import {PowerSearchEnumSetTerm} from './PowerSearchEnumSetTerm'; import {PowerSearchEnumTerm} from './PowerSearchEnumTerm'; import {PowerSearchFloatTerm} from './PowerSearchFloatTerm'; import {PowerSearchIntegerTerm} from './PowerSearchIntegerTerm'; @@ -107,6 +108,21 @@ export const PowerSearchTerm: React.FC = ({ ); break; } + case 'ENUM_SET': { + searchValueComponent = ( + { + onFinalize({ + ...searchTerm, + searchValue: newValue, + }); + }} + enumLabels={searchTerm.operator.enumLabels} + /> + ); + break; + } case 'ABSOLUTE_DATE': { searchValueComponent = ( = ({ ); break; } + case 'ENUM_SET': { + searchValueComponent = ( + { + onFinalize({ + ...searchTerm, + searchValue: newValue, + }); + }} + enumLabels={searchTerm.operator.enumLabels} + /> + ); + break; + } case 'ABSOLUTE_DATE': { searchValueComponent = (