From 0fdd9012972f98b3fccfa961533e379d2ae39714 Mon Sep 17 00:00:00 2001 From: Hamdullah Shah Date: Tue, 8 Aug 2023 09:50:08 -0700 Subject: [PATCH 01/98] DataDescriptor BigInt Summary: The `DataDescriptionType` accepts the `BigInt` type but it doesn't render. Added the `case` for that and reuse the `NumberValue` tag for it. Reviewed By: aigoncharov Differential Revision: D48152012 fbshipit-source-id: 32ebc8a37df34d57b40c7ecdad331c547415b335 --- .../flipper-plugin/src/ui/data-inspector/DataDescription.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/desktop/flipper-plugin/src/ui/data-inspector/DataDescription.tsx b/desktop/flipper-plugin/src/ui/data-inspector/DataDescription.tsx index f72d3cb12a7..d284aa3c94d 100644 --- a/desktop/flipper-plugin/src/ui/data-inspector/DataDescription.tsx +++ b/desktop/flipper-plugin/src/ui/data-inspector/DataDescription.tsx @@ -573,7 +573,8 @@ class DataDescriptionContainer extends PureComponent<{ case 'number': return {+val}; - + case 'bigint': + return {val.toString()}; case 'color': { const colorInfo = parseColor(val); if (typeof val === 'number' && val === 0) { From b30f7492cdfc74c9783b85c20b9ef94a440764b8 Mon Sep 17 00:00:00 2001 From: Luke De Feo Date: Tue, 8 Aug 2023 11:43:05 -0700 Subject: [PATCH 02/98] Add connection listeners and framework events Summary: Infra that will be used to capture litho framework events Reviewed By: lblasa Differential Revision: D47951601 fbshipit-source-id: 1dd756dc872d474f2872ff8cac1fd6aa3697e42b --- .../uidebugger/UIDebuggerFlipperPlugin.kt | 4 +++ .../plugins/uidebugger/core/UIDContext.kt | 34 +++++++++++++++++-- .../uidebugger/model/FrameworkEvents.kt | 1 + .../observers/TreeObserverManager.kt | 2 +- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/android/src/main/java/com/facebook/flipper/plugins/uidebugger/UIDebuggerFlipperPlugin.kt b/android/src/main/java/com/facebook/flipper/plugins/uidebugger/UIDebuggerFlipperPlugin.kt index 76dc8331953..003c51d8b09 100644 --- a/android/src/main/java/com/facebook/flipper/plugins/uidebugger/UIDebuggerFlipperPlugin.kt +++ b/android/src/main/java/com/facebook/flipper/plugins/uidebugger/UIDebuggerFlipperPlugin.kt @@ -49,6 +49,8 @@ class UIDebuggerFlipperPlugin(val context: UIDContext) : FlipperPlugin { MetadataUpdateEvent(MetadataRegister.extractPendingMetadata()))) context.treeObserverManager.start() + + context.connectionListeners.forEach { it.onConnect() } } @Throws(Exception::class) @@ -59,6 +61,8 @@ class UIDebuggerFlipperPlugin(val context: UIDContext) : FlipperPlugin { context.treeObserverManager.stop() context.bitmapPool.recycleAll() + context.connectionListeners.forEach { it.onDisconnect() } + context.clearFrameworkEvents() } override fun runInBackground(): Boolean { diff --git a/android/src/main/java/com/facebook/flipper/plugins/uidebugger/core/UIDContext.kt b/android/src/main/java/com/facebook/flipper/plugins/uidebugger/core/UIDContext.kt index 3142b019339..83ed3f111fd 100644 --- a/android/src/main/java/com/facebook/flipper/plugins/uidebugger/core/UIDContext.kt +++ b/android/src/main/java/com/facebook/flipper/plugins/uidebugger/core/UIDContext.kt @@ -11,19 +11,29 @@ import android.app.Application import com.facebook.flipper.core.FlipperConnection import com.facebook.flipper.plugins.uidebugger.common.BitmapPool import com.facebook.flipper.plugins.uidebugger.descriptors.DescriptorRegister +import com.facebook.flipper.plugins.uidebugger.model.FrameworkEvent import com.facebook.flipper.plugins.uidebugger.model.FrameworkEventMetadata import com.facebook.flipper.plugins.uidebugger.observers.TreeObserverFactory import com.facebook.flipper.plugins.uidebugger.observers.TreeObserverManager import com.facebook.flipper.plugins.uidebugger.scheduler.SharedThrottle import com.facebook.flipper.plugins.uidebugger.traversal.PartialLayoutTraversal -data class UIDContext( +interface ConnectionListener { + fun onConnect() + + fun onDisconnect() +} + +class UIDContext( val applicationRef: ApplicationRef, val connectionRef: ConnectionRef, val descriptorRegister: DescriptorRegister, val observerFactory: TreeObserverFactory, - val frameworkEventMetadata: MutableList + val frameworkEventMetadata: MutableList, + val connectionListeners: MutableList, + private val pendingFrameworkEvents: MutableList ) { + val layoutTraversal: PartialLayoutTraversal = PartialLayoutTraversal(descriptorRegister, observerFactory) @@ -31,6 +41,22 @@ data class UIDContext( val sharedThrottle: SharedThrottle = SharedThrottle() val bitmapPool = BitmapPool() + fun addFrameworkEvent(frameworkEvent: FrameworkEvent) { + synchronized(pendingFrameworkEvents) { pendingFrameworkEvents.add(frameworkEvent) } + } + + fun extractPendingFrameworkEvents(): List { + synchronized(pendingFrameworkEvents) { + val copy = pendingFrameworkEvents.toList() + pendingFrameworkEvents.clear() + return copy + } + } + + fun clearFrameworkEvents() { + synchronized(pendingFrameworkEvents) { pendingFrameworkEvents.clear() } + } + companion object { fun create(application: Application): UIDContext { return UIDContext( @@ -38,7 +64,9 @@ data class UIDContext( ConnectionRef(null), descriptorRegister = DescriptorRegister.withDefaults(), observerFactory = TreeObserverFactory.withDefaults(), - frameworkEventMetadata = mutableListOf()) + frameworkEventMetadata = mutableListOf(), + connectionListeners = mutableListOf(), + pendingFrameworkEvents = mutableListOf()) } } } diff --git a/android/src/main/java/com/facebook/flipper/plugins/uidebugger/model/FrameworkEvents.kt b/android/src/main/java/com/facebook/flipper/plugins/uidebugger/model/FrameworkEvents.kt index 76ebbea0474..c23bd078229 100644 --- a/android/src/main/java/com/facebook/flipper/plugins/uidebugger/model/FrameworkEvents.kt +++ b/android/src/main/java/com/facebook/flipper/plugins/uidebugger/model/FrameworkEvents.kt @@ -20,4 +20,5 @@ data class FrameworkEvent( val nodeId: Id, val type: String, val timestamp: Long, + val thread: String ) diff --git a/android/src/main/java/com/facebook/flipper/plugins/uidebugger/observers/TreeObserverManager.kt b/android/src/main/java/com/facebook/flipper/plugins/uidebugger/observers/TreeObserverManager.kt index 0d372226781..141adbb36ac 100644 --- a/android/src/main/java/com/facebook/flipper/plugins/uidebugger/observers/TreeObserverManager.kt +++ b/android/src/main/java/com/facebook/flipper/plugins/uidebugger/observers/TreeObserverManager.kt @@ -108,7 +108,7 @@ class TreeObserverManager(val context: UIDContext) { val workerThreadStartTimestamp = System.currentTimeMillis() val nodes = batchedUpdate.updates.flatMap { it.deferredNodes.map { it.value() } } - val frameworkEvents = batchedUpdate.updates.flatMap { it.frameworkEvents ?: listOf() } + val frameworkEvents = context.extractPendingFrameworkEvents() val snapshotUpdate = batchedUpdate.updates.find { it.snapshot != null } val deferredComputationEndTimestamp = System.currentTimeMillis() From 2834d3300a77fdedf3f0d2b9dca371ecfa7e815e Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Wed, 9 Aug 2023 08:01:44 -0700 Subject: [PATCH 03/98] Track filtering and searching for data table Reviewed By: mweststrate Differential Revision: D48116067 fbshipit-source-id: 2dee2cfd68a23e1153b3f10ff229009777e936da --- .../flipper-plugin/src/ui/data-table/DataTableManager.tsx | 5 ++++- .../src/ui/data-table/__tests__/DataTable.node.tsx | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/desktop/flipper-plugin/src/ui/data-table/DataTableManager.tsx b/desktop/flipper-plugin/src/ui/data-table/DataTableManager.tsx index 853552bce68..90b5fd8fbda 100644 --- a/desktop/flipper-plugin/src/ui/data-table/DataTableManager.tsx +++ b/desktop/flipper-plugin/src/ui/data-table/DataTableManager.tsx @@ -13,7 +13,7 @@ import {MutableRefObject, Reducer, RefObject} from 'react'; import {DataSourceVirtualizer} from '../../data-source/index'; import produce, {castDraft, immerable, original} from 'immer'; import {theme} from '../theme'; -import {DataSource, _DataSourceView} from 'flipper-plugin-core'; +import {DataSource, getFlipperLib, _DataSourceView} from 'flipper-plugin-core'; export type OnColumnResize = (id: string, size: number | Percentage) => void; export type Sorting = { @@ -485,6 +485,7 @@ export function createDataTableManager( dispatch({type: 'sortColumn', column, direction}); }, setSearchValue(value, addToHistory = false) { + getFlipperLib().logger.track('usage', 'data-table:filter:search'); dispatch({type: 'setSearchValue', value, addToHistory}); }, toggleSearchValue() { @@ -506,9 +507,11 @@ export function createDataTableManager( dispatch({type: 'setShowNumberedHistory', showNumberedHistory}); }, addColumnFilter(column, value, options = {}) { + getFlipperLib().logger.track('usage', 'data-table:filter:add-column'); dispatch({type: 'addColumnFilter', column, value, options}); }, removeColumnFilter(column, label) { + getFlipperLib().logger.track('usage', 'data-table:filter:remove-column'); dispatch({type: 'removeColumnFilter', column, label}); }, setFilterExceptions(exceptions: string[] | undefined) { diff --git a/desktop/flipper-plugin/src/ui/data-table/__tests__/DataTable.node.tsx b/desktop/flipper-plugin/src/ui/data-table/__tests__/DataTable.node.tsx index aff5bf3740e..9b7012cba98 100644 --- a/desktop/flipper-plugin/src/ui/data-table/__tests__/DataTable.node.tsx +++ b/desktop/flipper-plugin/src/ui/data-table/__tests__/DataTable.node.tsx @@ -14,12 +14,15 @@ import {createDataSource} from 'flipper-plugin-core'; import {computeDataTableFilter, DataTableManager} from '../DataTableManager'; import {Button} from 'antd'; import {sleep} from 'flipper-common'; +import {TestUtils, _setFlipperLibImplementation} from 'flipper-plugin-core'; type Todo = { title: string; done: boolean; }; +_setFlipperLibImplementation(TestUtils.createMockFlipperLib()); + function createTestDataSource() { return createDataSource([ { From 22f67e389fa5a6ca72f79ea24dc398d62b0f6731 Mon Sep 17 00:00:00 2001 From: generatedunixname89002005306973 Date: Wed, 9 Aug 2023 09:23:44 -0700 Subject: [PATCH 04/98] Flipper Release: v0.211.0 Summary: Releasing version 0.211.0 Reviewed By: ivanmisuno Differential Revision: D48185752 fbshipit-source-id: 9e81f1e869e86194e8d90d83a3a988c778bb22e4 --- desktop/package.json | 2 +- desktop/plugins/public/layout/docs/setup.mdx | 2 +- desktop/plugins/public/leak_canary/docs/setup.mdx | 2 +- desktop/plugins/public/network/docs/setup.mdx | 2 +- docs/getting-started/android-native.mdx | 4 ++-- docs/getting-started/react-native-ios.mdx | 2 +- docs/getting-started/react-native.mdx | 4 ++-- gradle.properties | 2 +- js/js-flipper/package.json | 2 +- react-native/react-native-flipper/package.json | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/desktop/package.json b/desktop/package.json index 7364b0e6359..ec957ba0d86 100644 --- a/desktop/package.json +++ b/desktop/package.json @@ -169,7 +169,7 @@ "npm": "use yarn instead", "yarn": "^1.16" }, - "version": "0.210.1", + "version": "0.211.0", "workspaces": { "packages": [ "scripts", diff --git a/desktop/plugins/public/layout/docs/setup.mdx b/desktop/plugins/public/layout/docs/setup.mdx index 2abb3ced710..168138c6744 100644 --- a/desktop/plugins/public/layout/docs/setup.mdx +++ b/desktop/plugins/public/layout/docs/setup.mdx @@ -27,7 +27,7 @@ You also need to compile in the `litho-annotations` package, as Flipper reflects ```groovy dependencies { - debugImplementation 'com.facebook.flipper:flipper-litho-plugin:0.210.1' + debugImplementation 'com.facebook.flipper:flipper-litho-plugin:0.211.0' debugImplementation 'com.facebook.litho:litho-annotations:0.19.0' // ... } diff --git a/desktop/plugins/public/leak_canary/docs/setup.mdx b/desktop/plugins/public/leak_canary/docs/setup.mdx index 63f574f00ea..bbf4b386ae9 100644 --- a/desktop/plugins/public/leak_canary/docs/setup.mdx +++ b/desktop/plugins/public/leak_canary/docs/setup.mdx @@ -8,7 +8,7 @@ To setup the LeakCan ```groovy dependencies { - debugImplementation 'com.facebook.flipper:flipper-leakcanary2-plugin:0.210.1' + debugImplementation 'com.facebook.flipper:flipper-leakcanary2-plugin:0.211.0' debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8.1' } ``` diff --git a/desktop/plugins/public/network/docs/setup.mdx b/desktop/plugins/public/network/docs/setup.mdx index bdb911a909c..40d40e5fc55 100644 --- a/desktop/plugins/public/network/docs/setup.mdx +++ b/desktop/plugins/public/network/docs/setup.mdx @@ -12,7 +12,7 @@ The network plugin is shipped as a separate Maven artifact, as follows: ```groovy dependencies { - debugImplementation 'com.facebook.flipper:flipper-network-plugin:0.210.1' + debugImplementation 'com.facebook.flipper:flipper-network-plugin:0.211.0' } ``` diff --git a/docs/getting-started/android-native.mdx b/docs/getting-started/android-native.mdx index 97fcda2915b..b03fd00d535 100644 --- a/docs/getting-started/android-native.mdx +++ b/docs/getting-started/android-native.mdx @@ -24,10 +24,10 @@ repositories { } dependencies { - debugImplementation 'com.facebook.flipper:flipper:0.210.1' + debugImplementation 'com.facebook.flipper:flipper:0.211.0' debugImplementation 'com.facebook.soloader:soloader:0.10.5' - releaseImplementation 'com.facebook.flipper:flipper-noop:0.210.1' + releaseImplementation 'com.facebook.flipper:flipper-noop:0.211.0' } ``` diff --git a/docs/getting-started/react-native-ios.mdx b/docs/getting-started/react-native-ios.mdx index 442b3a236e2..3d104a17548 100644 --- a/docs/getting-started/react-native-ios.mdx +++ b/docs/getting-started/react-native-ios.mdx @@ -51,7 +51,7 @@ Add all of the code below to your `ios/Podfile`: platform :ios, '9.0' def flipper_pods() - flipperkit_version = '0.210.1' # should match the version of your Flipper client app + flipperkit_version = '0.211.0' # should match the version of your Flipper client app pod 'FlipperKit', '~>' + flipperkit_version, :configuration => 'Debug' pod 'FlipperKit/FlipperKitLayoutPlugin', '~>' + flipperkit_version, :configuration => 'Debug' pod 'FlipperKit/SKIOSNetworkPlugin', '~>' + flipperkit_version, :configuration => 'Debug' diff --git a/docs/getting-started/react-native.mdx b/docs/getting-started/react-native.mdx index 200e30c441a..b28879294bc 100644 --- a/docs/getting-started/react-native.mdx +++ b/docs/getting-started/react-native.mdx @@ -34,7 +34,7 @@ Latest version of Flipper requires react-native 0.69+! If you use react-native < Android: -1. Bump the `FLIPPER_VERSION` variable in `android/gradle.properties`, for example: `FLIPPER_VERSION=0.210.1`. +1. Bump the `FLIPPER_VERSION` variable in `android/gradle.properties`, for example: `FLIPPER_VERSION=0.211.0`. 2. Run `./gradlew clean` in the `android` directory. iOS: @@ -44,7 +44,7 @@ react-native version => 0.69.0 2. Run `pod install --repo-update` in the `ios` directory. react-native version < 0.69.0 -1. Call `use_flipper` with a specific version in `ios/Podfile`, for example: `use_flipper!({ 'Flipper' => '0.210.1' })`. +1. Call `use_flipper` with a specific version in `ios/Podfile`, for example: `use_flipper!({ 'Flipper' => '0.211.0' })`. 2. Run `pod install --repo-update` in the `ios` directory. ## Manual Setup diff --git a/gradle.properties b/gradle.properties index 11ce7f4957d..59ebf6c8d74 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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. # POM publishing constants -VERSION_NAME=0.210.2-SNAPSHOT +VERSION_NAME=0.211.0 GROUP=com.facebook.flipper SONATYPE_STAGING_PROFILE=comfacebook POM_URL=https://github.com/facebook/flipper diff --git a/js/js-flipper/package.json b/js/js-flipper/package.json index 29440aee5da..317152c3685 100644 --- a/js/js-flipper/package.json +++ b/js/js-flipper/package.json @@ -1,7 +1,7 @@ { "name": "js-flipper", "title": "JS Flipper Bindings for Web-Socket based clients", - "version": "0.210.1", + "version": "0.211.0", "main": "lib/index.js", "browser": { "os": false diff --git a/react-native/react-native-flipper/package.json b/react-native/react-native-flipper/package.json index f9daa596359..bd4e43c4641 100644 --- a/react-native/react-native-flipper/package.json +++ b/react-native/react-native-flipper/package.json @@ -1,7 +1,7 @@ { "name": "react-native-flipper", "title": "React Native Flipper Bindings", - "version": "0.210.1", + "version": "0.211.0", "description": "Flipper bindings for React Native", "main": "index.js", "types": "index.d.ts", From 8749145664f8f9101286ce8f98e4fd979f0cd713 Mon Sep 17 00:00:00 2001 From: generatedunixname89002005306973 Date: Wed, 9 Aug 2023 09:23:44 -0700 Subject: [PATCH 05/98] Flipper Snapshot Bump: v0.211.1-SNAPSHOT Summary: Releasing snapshot version 0.211.1-SNAPSHOT Reviewed By: ivanmisuno Differential Revision: D48185751 fbshipit-source-id: 4190086bd4545ff09dd278c61c5b152cb3a65a80 --- docs/getting-started/android-native.mdx | 4 ++-- gradle.properties | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/getting-started/android-native.mdx b/docs/getting-started/android-native.mdx index b03fd00d535..d88c066d074 100644 --- a/docs/getting-started/android-native.mdx +++ b/docs/getting-started/android-native.mdx @@ -124,10 +124,10 @@ repositories { } dependencies { - debugImplementation 'com.facebook.flipper:flipper:0.210.2-SNAPSHOT' + debugImplementation 'com.facebook.flipper:flipper:0.211.1-SNAPSHOT' debugImplementation 'com.facebook.soloader:soloader:0.10.5' - releaseImplementation 'com.facebook.flipper:flipper-noop:0.210.2-SNAPSHOT' + releaseImplementation 'com.facebook.flipper:flipper-noop:0.211.1-SNAPSHOT' } ``` diff --git a/gradle.properties b/gradle.properties index 59ebf6c8d74..49351b0a3ce 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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. # POM publishing constants -VERSION_NAME=0.211.0 +VERSION_NAME=0.211.1-SNAPSHOT GROUP=com.facebook.flipper SONATYPE_STAGING_PROFILE=comfacebook POM_URL=https://github.com/facebook/flipper From 3b99e386a2ca7dab304365894edd9ec908a49489 Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Wed, 9 Aug 2023 14:15:33 -0700 Subject: [PATCH 06/98] Fix comment Reviewed By: LukeDefeo Differential Revision: D48191671 fbshipit-source-id: 6978e831f48ffe4e8a8c6e71b819205cb3868966 --- desktop/flipper-server-core/src/server/attachSocketServer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop/flipper-server-core/src/server/attachSocketServer.tsx b/desktop/flipper-server-core/src/server/attachSocketServer.tsx index 4fffdf41c3c..99f29331640 100644 --- a/desktop/flipper-server-core/src/server/attachSocketServer.tsx +++ b/desktop/flipper-server-core/src/server/attachSocketServer.tsx @@ -240,7 +240,7 @@ export function attachSocketServer( clearTimeout(disconnectTimeout); } /** - * If, after 15 min, there are no more connected clients, we exit the process. + * If, after 30 seconds, there are no more connected clients, we exit the process. */ disconnectTimeout = setTimeout(() => { if (numberOfConnectedClients === 0 && isProduction()) { From f93da44ee5c9131ce4904258e30d1d93e6aa188b Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Fri, 11 Aug 2023 08:19:51 -0700 Subject: [PATCH 07/98] Remove idb device polling record Summary: If listing devices is successful, then don't record the event as this is triggered every X amount of seconds. Reviewed By: antonk52 Differential Revision: D47995681 fbshipit-source-id: 2d0fa68fd7b9c4ce74bad9e8cc0296691d9b8880 --- .../src/devices/ios/iOSContainerUtility.tsx | 52 ++++++++++++------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/desktop/flipper-server-core/src/devices/ios/iOSContainerUtility.tsx b/desktop/flipper-server-core/src/devices/ios/iOSContainerUtility.tsx index beeddcde8da..935f36d60ee 100644 --- a/desktop/flipper-server-core/src/devices/ios/iOSContainerUtility.tsx +++ b/desktop/flipper-server-core/src/devices/ios/iOSContainerUtility.tsx @@ -28,6 +28,7 @@ export type IdbConfig = { // 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(); @@ -49,6 +50,10 @@ export type DeviceTarget = { name: string; }; +let idbDeviceListing = 0; +let idbCompanionDeviceListing = 0; +let xcodeDeviceListing = 0; + async function isAvailable(idbPath: string): Promise { if (!idbPath) { return false; @@ -88,12 +93,17 @@ async function queryTargetsWithXcode( }); throw new Error('No output from command'); } - recorder.event('cmd', { - cmd, - description, - success: true, - context, - }); + + xcodeDeviceListing++; + if (xcodeDeviceListing % CMD_RECORD_THROTTLE_COUNT === 0) { + recorder.event('cmd', { + cmd, + description, + success: true, + context, + }); + } + return stdout .toString() .split('\n') @@ -141,12 +151,15 @@ async function queryTargetsWithIdb( throw new Error('No output from command'); } - recorder.event('cmd', { - cmd, - description, - success: true, - context, - }); + idbDeviceListing++; + if (idbDeviceListing % CMD_RECORD_THROTTLE_COUNT === 0) { + recorder.event('cmd', { + cmd, + description, + success: true, + context, + }); + } return parseIdbTargets(stdout.toString()); } catch (e) { @@ -187,12 +200,15 @@ async function queryTargetsWithIdbCompanion( throw new Error('No output from command'); } - recorder.event('cmd', { - cmd, - description, - success: true, - context, - }); + idbCompanionDeviceListing++; + if (idbCompanionDeviceListing % CMD_RECORD_THROTTLE_COUNT === 0) { + recorder.event('cmd', { + cmd, + description, + success: true, + context, + }); + } const devices = parseIdbTargets(stdout.toString()); if (devices.length > 0 && !isPhysicalDeviceEnabled) { From bdc2d5f6ebcbd6cf066eba27ae285c98a1a795b7 Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Fri, 11 Aug 2023 08:19:51 -0700 Subject: [PATCH 08/98] If there are no connected clients, shutdown immediately Summary: Instead of delaying the shutdown by a set timer, immediately shutdown. Reviewed By: antonk52 Differential Revision: D48264571 fbshipit-source-id: 5e6556f2ecafb7cf9a19b3075e72f2be1abf9f95 --- .../src/server/attachSocketServer.tsx | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/desktop/flipper-server-core/src/server/attachSocketServer.tsx b/desktop/flipper-server-core/src/server/attachSocketServer.tsx index 99f29331640..fbcada23a9a 100644 --- a/desktop/flipper-server-core/src/server/attachSocketServer.tsx +++ b/desktop/flipper-server-core/src/server/attachSocketServer.tsx @@ -17,7 +17,6 @@ import { SystemError, getLogger, CompanionEventWebSocketMessage, - isProduction, } from 'flipper-common'; import {FlipperServerImpl} from '../FlipperServerImpl'; import {RawData, WebSocketServer} from 'ws'; @@ -39,7 +38,6 @@ const safe = (f: () => void) => { }; let numberOfConnectedClients = 0; -let disconnectTimeout: NodeJS.Timeout | undefined; /** * Attach and handle incoming messages from clients. @@ -235,24 +233,17 @@ export function attachSocketServer( } numberOfConnectedClients--; - if (getFlipperServerConfig().environmentInfo.isHeadlessBuild) { - if (disconnectTimeout) { - clearTimeout(disconnectTimeout); - } - /** - * If, after 30 seconds, there are no more connected clients, we exit the process. - */ - disconnectTimeout = setTimeout(() => { - if (numberOfConnectedClients === 0 && isProduction()) { - console.info('Shutdown as no clients are currently connected'); - process.exit(0); - } - }, 30 * 1000); - } connected = false; server.offAny(onServerEvent); flipperServerCompanion?.destroyAll(); + + if (getFlipperServerConfig().environmentInfo.isHeadlessBuild) { + if (numberOfConnectedClients === 0) { + console.info('Shutdown as no clients are currently connected'); + process.exit(0); + } + } } client.on('close', () => { From 47b718d1040e7ae5d9bc0e6f7c76ce423a091f08 Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Fri, 11 Aug 2023 08:19:51 -0700 Subject: [PATCH 09/98] Remove TCP option as it will be the only option Summary: UDS will be removed. The first step would be to remove the TCP optionality. Reviewed By: passy Differential Revision: D48264741 fbshipit-source-id: ca9e1b68be61e99240e95bcd4f26f2db63a64005 --- desktop/flipper-server/src/index.tsx | 12 +------ .../scripts/build-flipper-server-release.tsx | 35 +++++-------------- desktop/scripts/build-utils.tsx | 7 +--- desktop/scripts/start-flipper-server-dev.tsx | 7 +--- 4 files changed, 12 insertions(+), 49 deletions(-) diff --git a/desktop/flipper-server/src/index.tsx b/desktop/flipper-server/src/index.tsx index 482ffc81a42..01c8f0aa190 100644 --- a/desktop/flipper-server/src/index.tsx +++ b/desktop/flipper-server/src/index.tsx @@ -74,12 +74,6 @@ const argv = yargs type: 'boolean', default: true, }, - tcp: { - describe: - 'Open a TCP port (--no-tcp can be specified as to use unix-domain-socket exclusively)', - type: 'boolean', - default: true, - }, replace: { describe: 'Replaces any running instance, if any.', type: 'boolean', @@ -214,7 +208,7 @@ async function start() { staticPath, entry: `index.web${argv.bundler ? '.dev' : ''}.html`, port: argv.port, - tcp: argv.tcp, + tcp: true, }); const t4 = performance.now(); @@ -308,10 +302,6 @@ async function start() { } async function launch() { - if (!argv.tcp) { - return; - } - let token: string | undefined; if (await hasAuthToken()) { token = await getAuthToken(); diff --git a/desktop/scripts/build-flipper-server-release.tsx b/desktop/scripts/build-flipper-server-release.tsx index 897083f0b80..09530343f8b 100644 --- a/desktop/scripts/build-flipper-server-release.tsx +++ b/desktop/scripts/build-flipper-server-release.tsx @@ -90,11 +90,6 @@ const argv = yargs type: 'boolean', default: false, }, - tcp: { - describe: 'Enable TCP connections on flipper-server.', - type: 'boolean', - default: true, - }, 'rebuild-plugins': { describe: 'Enables rebuilding of default plugins on Flipper build. Only make sense in conjunction with "--no-bundled-plugins". Enabled by default, but if disabled using "--no-plugin-rebuild", then plugins are just released as is without rebuilding. This can save some time if you know plugin bundles are already up-to-date.', @@ -356,29 +351,17 @@ async function runPostBuildAction(archive: string, dir: string) { // didn't change console.log(`⚙️ Installing flipper-server.tgz using npx`); await fs.remove(path.join(homedir(), '.npm', '_npx')); - await spawn( - 'npx', - [ - archive, - argv.open ? '--open' : '--no-open', - argv.tcp ? '--tcp' : '--no-tcp', - ], - { - stdio: 'inherit', - shell: true, - }, - ); + await spawn('npx', [archive, argv.open ? '--open' : '--no-open'], { + stdio: 'inherit', + shell: true, + }); } else if (argv.start) { console.log(`⚙️ Starting flipper-server from build dir`); - await spawn( - './server.js', - [argv.open ? '--open' : '--no-open', argv.tcp ? '--tcp' : '--no-tcp'], - { - cwd: dir, - stdio: 'inherit', - shell: true, - }, - ); + await spawn('./server.js', [argv.open ? '--open' : '--no-open'], { + cwd: dir, + stdio: 'inherit', + shell: true, + }); } } diff --git a/desktop/scripts/build-utils.tsx b/desktop/scripts/build-utils.tsx index 44975e0cf80..314e3cc5e71 100644 --- a/desktop/scripts/build-utils.tsx +++ b/desktop/scripts/build-utils.tsx @@ -384,11 +384,7 @@ export function sleep(ms: number) { let proc: child.ChildProcess | undefined; -export async function launchServer( - startBundler: boolean, - open: boolean, - tcp: boolean, -) { +export async function launchServer(startBundler: boolean, open: boolean) { if (proc) { console.log('⚙️ Killing old flipper-server...'); proc.kill(9); @@ -401,7 +397,6 @@ export async function launchServer( `../flipper-server/server.js`, startBundler ? `--bundler` : `--no-bundler`, open ? `--open` : `--no-open`, - tcp ? `--tcp` : `--no-tcp`, ], { cwd: serverDir, diff --git a/desktop/scripts/start-flipper-server-dev.tsx b/desktop/scripts/start-flipper-server-dev.tsx index fd407495d9c..aae4740e560 100644 --- a/desktop/scripts/start-flipper-server-dev.tsx +++ b/desktop/scripts/start-flipper-server-dev.tsx @@ -44,11 +44,6 @@ const argv = yargs '[FB-internal only] Will force using public sources only, to be able to iterate quickly on the public version. If sources are checked out from GitHub this is already the default. Setting env var "FLIPPER_FORCE_PUBLIC_BUILD" is equivalent.', type: 'boolean', }, - tcp: { - describe: 'Enable TCP connections on flipper-server.', - type: 'boolean', - default: true, - }, channel: { description: 'Release channel for the build', choices: ['stable', 'insiders'], @@ -108,7 +103,7 @@ async function copyStaticResources() { async function restartServer() { try { await compileServerMain(true); - await launchServer(true, ++startCount === 1, argv.tcp); // only open on the first time + await launchServer(true, ++startCount === 1); // only open on the first time } catch (e) { console.error( chalk.red( From 7f3f1c0507ed38f120c2e442687b82fd2ec5e8cd Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Fri, 11 Aug 2023 08:19:51 -0700 Subject: [PATCH 10/98] TCP is the only option so remove unused branches Summary: As TCP is the only option, remove all branches. Reviewed By: passy Differential Revision: D48265093 fbshipit-source-id: 174527f05d8a841797fd95256e77fdeb9b2e6ad5 --- desktop/app/src/init.tsx | 1 - .../src/server/startServer.tsx | 25 +++++-------------- desktop/flipper-server-core/src/tracker.tsx | 2 +- desktop/flipper-server/src/index.tsx | 1 - 4 files changed, 7 insertions(+), 22 deletions(-) diff --git a/desktop/app/src/init.tsx b/desktop/app/src/init.tsx index 1bb6f7c37ae..77a2124ee1d 100644 --- a/desktop/app/src/init.tsx +++ b/desktop/app/src/init.tsx @@ -206,7 +206,6 @@ async function getFlipperServer( const {readyForIncomingConnections} = await startServer({ staticPath, entry: 'index.web.dev.html', - tcp: false, port, }); diff --git a/desktop/flipper-server-core/src/server/startServer.tsx b/desktop/flipper-server-core/src/server/startServer.tsx index 95554ded0c8..a9b8a0796a4 100644 --- a/desktop/flipper-server-core/src/server/startServer.tsx +++ b/desktop/flipper-server-core/src/server/startServer.tsx @@ -30,7 +30,6 @@ type Config = { port: number; staticPath: string; entry: string; - tcp: boolean; }; type ReadyForConnections = ( @@ -151,11 +150,6 @@ async function startProxyServer( // On Windows, a proxy is not created and the server starts // listening at the specified port. if (os.platform() === 'win32') { - if (!config.tcp) { - console.warn( - 'No port was supplied and domain socket access is not available for non-POSIX systems, falling back to TCP', - ); - } return new Promise((resolve) => { console.log(`Starting server on http://localhost:${config.port}`); const readyForIncomingConnections = ( @@ -182,13 +176,11 @@ async function startProxyServer( await fs.rm(socketPath, {force: true}); } - const proxyServer: proxy | undefined = config.tcp - ? proxy.createProxyServer({ - target: {host: 'localhost', port: 0, socketPath}, - autoRewrite: true, - ws: true, - }) - : undefined; + const proxyServer: proxy | undefined = proxy.createProxyServer({ + target: {host: 'localhost', port: 0, socketPath}, + autoRewrite: true, + ws: true, + }); console.log('Starting socket server on ', socketPath); if (proxyServer) { @@ -230,7 +222,6 @@ async function startProxyServer( server.listen(socketPath, undefined, () => { tracker.track('server-started', { port: config.port, - tcp: config.tcp, }); resolve(); }); @@ -275,8 +266,6 @@ function addWebsocket(server: http.Server, config: Config) { // No origin header? The request is not originating from a browser, so should be OK to pass through // If origin matches our own address, it means we are serving the page. - // Need the token or know that is UDS. - return process.env.SKIP_TOKEN_VERIFICATION ? true : verifyAuthToken(req); } else { // For now we don't allow cross origin request, so that an arbitrary website cannot try to @@ -299,10 +288,8 @@ function addWebsocket(server: http.Server, config: Config) { const options: ServerOptions = { noServer: true, maxPayload: WEBSOCKET_MAX_MESSAGE_SIZE, + verifyClient, }; - if (config.tcp) { - options.verifyClient = verifyClient; - } const wss = new WebSocketServer(options); server.on('upgrade', function upgrade(request, socket, head) { diff --git a/desktop/flipper-server-core/src/tracker.tsx b/desktop/flipper-server-core/src/tracker.tsx index 72e43eaf3ef..f694cec536e 100644 --- a/desktop/flipper-server-core/src/tracker.tsx +++ b/desktop/flipper-server-core/src/tracker.tsx @@ -36,7 +36,7 @@ type ServerBootstrapPerformancePayload = { type TrackerEvents = { 'server-bootstrap-performance': ServerBootstrapPerformancePayload; - 'server-started': {port: number; tcp: boolean}; + 'server-started': {port: number}; 'server-auth-token-verification': { successful: boolean; present: boolean; diff --git a/desktop/flipper-server/src/index.tsx b/desktop/flipper-server/src/index.tsx index 01c8f0aa190..93dbf3eccd2 100644 --- a/desktop/flipper-server/src/index.tsx +++ b/desktop/flipper-server/src/index.tsx @@ -208,7 +208,6 @@ async function start() { staticPath, entry: `index.web${argv.bundler ? '.dev' : ''}.html`, port: argv.port, - tcp: true, }); const t4 = performance.now(); From b5ed57b7d0fb97e5dba86cf0e4a0c919c79d602a Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Fri, 11 Aug 2023 08:19:51 -0700 Subject: [PATCH 11/98] Remove UDS and thus the need for a proxy server Summary: This change removes the UDS support and thus the need for having a proxy server. Reviewed By: antonk52 Differential Revision: D48265244 fbshipit-source-id: c76bb4afba63959ddd17901b3887aa278b000beb --- desktop/app/src/init.tsx | 13 +-- desktop/flipper-server-core/package.json | 2 - .../src/server/startServer.tsx | 94 +------------------ .../src/server/utilities.tsx | 60 ------------ 4 files changed, 6 insertions(+), 163 deletions(-) diff --git a/desktop/app/src/init.tsx b/desktop/app/src/init.tsx index 77a2124ee1d..fcc51d68414 100644 --- a/desktop/app/src/init.tsx +++ b/desktop/app/src/init.tsx @@ -47,7 +47,6 @@ import path from 'path'; import fs from 'fs-extra'; import os from 'os'; import {ElectronIpcClientRenderer} from './electronIpc'; -import {checkSocketInUse, makeSocketPath} from 'flipper-server-core'; import {KeytarModule} from 'flipper-server-core/src/utils/keytar'; import {initCompanionEnv} from 'flipper-server-companion'; import ReconnectingWebSocket from 'reconnecting-websocket'; @@ -118,8 +117,6 @@ async function getFlipperServer( const serverUsageEnabled = gatekeepers['flipper_desktop_use_server']; const settings = await loadSettings(); - - const socketPath = await makeSocketPath(); const port = 52342; /** * Only attempt to use the auth token if one is available. Otherwise, @@ -134,7 +131,6 @@ async function getFlipperServer( // check first with the actual TCP socket const searchParams = new URLSearchParams(token ? {token} : {}); const TCPconnectionURL = new URL(`ws://localhost:${port}?${searchParams}`); - const UDSconnectionURL = new URL(`ws+unix://${socketPath}`); /** * Attempt to shutdown a running instance of Flipper server. @@ -159,12 +155,7 @@ async function getFlipperServer( */ if (await checkPortInUse(port)) { console.warn(`[flipper-server] TCP port ${port} is already in use.`); - await shutdown(TCPconnectionURL); - } else if (await checkSocketInUse(socketPath)) { - console.warn(`[flipper-server] UDS socket is already in use.`); - - await shutdown(UDSconnectionURL); } const [homePath, tempPath, desktopPath] = await Promise.all([ @@ -223,9 +214,7 @@ async function getFlipperServer( await server.connect(); await readyForIncomingConnections(server, companionEnv); - return getExternalServer( - os.platform() === 'win32' ? TCPconnectionURL : UDSconnectionURL, - ); + return getExternalServer(TCPconnectionURL); } return getEmbeddedServer(); } diff --git a/desktop/flipper-server-core/package.json b/desktop/flipper-server-core/package.json index a37668370f3..e9a468e8ebb 100644 --- a/desktop/flipper-server-core/package.json +++ b/desktop/flipper-server-core/package.json @@ -25,7 +25,6 @@ "flipper-server-companion": "0.0.0", "form-data": "^4.0.0", "fs-extra": "^11.1.0", - "http-proxy": "^1.18.1", "invariant": "^2.2.4", "js-base64": "^3.7.5", "jsonwebtoken": "^9.0.0", @@ -52,7 +51,6 @@ "devDependencies": { "@types/archiver": "^5.3.1", "@types/express": "^4.17.13", - "@types/http-proxy": "^1.17.8", "@types/invariant": "^2.2.35", "@types/jsonwebtoken": "^9.0.1", "@types/memorystream": "^0.3.0", diff --git a/desktop/flipper-server-core/src/server/startServer.tsx b/desktop/flipper-server-core/src/server/startServer.tsx index a9b8a0796a4..00db40d1e86 100644 --- a/desktop/flipper-server-core/src/server/startServer.tsx +++ b/desktop/flipper-server-core/src/server/startServer.tsx @@ -7,18 +7,13 @@ * @format */ -import os from 'os'; - import express, {Express} from 'express'; -import http, {ServerResponse} from 'http'; +import http from 'http'; import path from 'path'; import fs from 'fs-extra'; import {ServerOptions, VerifyClientCallbackSync, WebSocketServer} from 'ws'; import {WEBSOCKET_MAX_MESSAGE_SIZE} from '../app-connectivity/ServerWebSocket'; import {parse} from 'url'; -import {makeSocketPath, checkSocketInUse} from './utilities'; - -import proxy from 'http-proxy'; import exitHook from 'exit-hook'; import {attachSocketServer} from './attachSocketServer'; import {FlipperServerImpl} from '../FlipperServerImpl'; @@ -124,102 +119,23 @@ async function startHTTPServer(config: Config): Promise<{ app.use(express.static(config.staticPath)); - return startProxyServer(config, app); -} - -/** - * Creates and starts the HTTP and proxy servers. - * @param config Server configuration. - * @param app Express app. - * @returns Returns both the app and server configured and - * listening. - */ -async function startProxyServer( - config: Config, - app: Express, -): Promise<{ - app: Express; - server: http.Server; - socket: WebSocketServer; - readyForIncomingConnections: ReadyForConnections; -}> { const server = http.createServer(app); - const socket = addWebsocket(server, config); - - // For now, we only support domain socket access on POSIX-like systems. - // On Windows, a proxy is not created and the server starts - // listening at the specified port. - if (os.platform() === 'win32') { - return new Promise((resolve) => { - console.log(`Starting server on http://localhost:${config.port}`); - const readyForIncomingConnections = ( - serverImpl: FlipperServerImpl, - companionEnv: FlipperServerCompanionEnv, - ): Promise => { - attachSocketServer(socket, serverImpl, companionEnv); - return new Promise((resolve) => { - server.listen(config.port, undefined, () => resolve()); - }); - }; - resolve({app, server, socket, readyForIncomingConnections}); - }); - } - - const socketPath = await makeSocketPath(); - if (await checkSocketInUse(socketPath)) { - console.warn( - `Cannot start flipper-server because socket ${socketPath} is in use.`, - ); - tracker.track('server-socket-already-in-use', {}); - } else { - console.info(`Cleaning up stale socket ${socketPath}`); - await fs.rm(socketPath, {force: true}); - } - - const proxyServer: proxy | undefined = proxy.createProxyServer({ - target: {host: 'localhost', port: 0, socketPath}, - autoRewrite: true, - ws: true, - }); - - console.log('Starting socket server on ', socketPath); - if (proxyServer) { - console.log(`Starting proxy server on http://localhost:${config.port}`); - } + const socket = attachWS(server, config); exitHook(() => { console.log('Shutdown server'); - proxyServer?.close(); server.close(); - - console.log('Cleaning up socket on exit:', socketPath); - // This *must* run synchronously and we're not blocking any UI loop by definition. - // eslint-disable-next-line node/no-sync - fs.rmSync(socketPath, {force: true}); - }); - - proxyServer?.on('error', (err, _req, _res) => { - console.warn('Error in proxy server:', err); - tracker.track('server-proxy-error', {error: err.message}); - - // As it stands, if the proxy fails, which is the one - // listening on the supplied TCP port, then we should exit. - // Otherwise we risk staying in an invalid state, unable - // to recover, and thus preventing us to serve incoming requests. - // Bear in mind that exiting the process will trigger the exit hook - // defined above which will clean and close the sockets. - process.exit(0); }); return new Promise((resolve) => { + console.log(`Starting server on http://localhost:${config.port}`); const readyForIncomingConnections = ( serverImpl: FlipperServerImpl, companionEnv: FlipperServerCompanionEnv, ): Promise => { attachSocketServer(socket, serverImpl, companionEnv); return new Promise((resolve) => { - proxyServer?.listen(config.port); - server.listen(socketPath, undefined, () => { + server.listen(config.port, undefined, () => { tracker.track('server-started', { port: config.port, }); @@ -238,7 +154,7 @@ async function startProxyServer( * incoming connections origin. * @returns Returns the created WS. */ -function addWebsocket(server: http.Server, config: Config) { +function attachWS(server: http.Server, config: Config) { const localhost = 'localhost'; const localhostIPV4 = `localhost:${config.port}`; const localhostIPV6 = `[::1]:${config.port}`; diff --git a/desktop/flipper-server-core/src/server/utilities.tsx b/desktop/flipper-server-core/src/server/utilities.tsx index 3ef9822f391..2ff26024cbd 100644 --- a/desktop/flipper-server-core/src/server/utilities.tsx +++ b/desktop/flipper-server-core/src/server/utilities.tsx @@ -39,63 +39,3 @@ export async function checkPortInUse(port: number): Promise { .listen(port); }); } - -/** - * Checks if a socket is in used for given path. - * If the path doesn't exist then is not in use. If it does, - * create a socket client and attempt to connect to it. - * If the connection is established, then there's a process - * already listening. Otherwise, it kind of indicates the - * contrary. - * @param path Path used instead of port number. - * @returns True or false dependning on whether the socket is in - * use or not. - */ -export async function checkSocketInUse(path: string): Promise { - if (!(await fs.pathExists(path))) { - return false; - } - return new Promise((resolve, _reject) => { - const client = net - .createConnection(path, () => { - resolve(true); - client.destroy(); - }) - .on('error', (e) => { - if (e.message.includes('ECONNREFUSED')) { - resolve(false); - } else { - console.warn( - `[conn] Socket ${path} is in use, but we don't know why.`, - e, - ); - resolve(false); - } - client.destroy(); - }); - }); -} - -/** - * Creates a socket path. Used to open the socket at location. - * Format: flipper-server-${userInfo}.sock - * @returns The created socket path. - */ -export async function makeSocketPath(): Promise { - const runtimeDir = xdgBasedir.runtime || '/tmp'; - await fs.mkdirp(runtimeDir); - const filename = `flipper-server-${os.userInfo().uid}.sock`; - const path = `${runtimeDir}/${filename}`; - - // Depending on the OS this is between 104 and 108: - // https://unix.stackexchange.com/a/367012/10198 - if (path.length >= 104) { - console.warn( - 'Ignoring XDG_RUNTIME_DIR as it would exceed the total limit for domain socket paths. See man 7 unix.', - ); - // Even with the INT32_MAX userid, we should have plenty of room. - return `/tmp/${filename}`; - } - - return path; -} From 359392a44c968532ca96834f64558367c2fe43cb Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Fri, 11 Aug 2023 10:56:38 -0700 Subject: [PATCH 12/98] Match isProduction definitions Summary: Match isProduction definition in flipper-common and flipper-server/src/index.tsx. Without it, PWA never quits after all clients disconnect because Flipper Launcher does not set NODE_ENV to production currently (changed in the next diff) Reviewed By: LukeDefeo, lblasa Differential Revision: D48265768 fbshipit-source-id: 59e4660cb57da20b606562144c47c65276999d6c --- desktop/flipper-common/src/utils/isProduction.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/desktop/flipper-common/src/utils/isProduction.tsx b/desktop/flipper-common/src/utils/isProduction.tsx index 0fe3e17e8b1..d2b1c556f70 100644 --- a/desktop/flipper-common/src/utils/isProduction.tsx +++ b/desktop/flipper-common/src/utils/isProduction.tsx @@ -13,6 +13,7 @@ declare const process: any; // this one, and one provided by the RenderHostConfig. Ideally they should be unified export function isProduction(): boolean { return ( - typeof process === 'undefined' || process.env.NODE_ENV === 'production' + typeof process === 'undefined' || + (process.env.NODE_ENV !== 'development' && process.env.NODE_ENV !== 'test') ); } From 84987b888bbfb7fcc451eab23252a96b38223daa Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 11 Aug 2023 12:08:42 -0700 Subject: [PATCH 13/98] Automated: Update Podfile.lock (#5000) 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/5000 Reviewed By: lblasa Differential Revision: D48268231 Pulled By: passy fbshipit-source-id: 9f28d68aeeca2c921a9298cbfad7c13e261b6900 --- 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 d9da51b9577..3dada981e40 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.210.0' +flipperkit_version = '0.211.0' Pod::Spec.new do |spec| spec.name = 'Flipper' spec.cocoapods_version = '>= 1.10' diff --git a/FlipperKit.podspec b/FlipperKit.podspec index 9adbb35e6cf..dc39eae3936 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.210.0' +flipperkit_version = '0.211.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 12fc19a4442..ed65a24faac 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.210.0' +flipperkit_version = '0.211.0' target 'MyApp' do platform :ios, '10.0' diff --git a/iOS/Sample/Podfile.lock b/iOS/Sample/Podfile.lock index 51c4d4a2182..99ae6e4e23b 100644 --- a/iOS/Sample/Podfile.lock +++ b/iOS/Sample/Podfile.lock @@ -1,6 +1,6 @@ PODS: - CocoaAsyncSocket (7.6.5) - - Flipper (0.210.0): + - Flipper (0.211.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.210.0): - - FlipperKit/Core (= 0.210.0) - - FlipperKit/Core (0.210.0): - - Flipper (~> 0.210.0) + - FlipperKit (0.211.0): + - FlipperKit/Core (= 0.211.0) + - FlipperKit/Core (0.211.0): + - Flipper (~> 0.211.0) - FlipperKit/CppBridge - FlipperKit/FBCxxFollyDynamicConvert - FlipperKit/FBDefines - FlipperKit/FKPortForwarding - SocketRocket (~> 0.7.0) - - FlipperKit/CppBridge (0.210.0): - - Flipper (~> 0.210.0) - - FlipperKit/FBCxxFollyDynamicConvert (0.210.0): + - FlipperKit/CppBridge (0.211.0): + - Flipper (~> 0.211.0) + - FlipperKit/FBCxxFollyDynamicConvert (0.211.0): - Flipper-Folly (~> 2.6) - - FlipperKit/FBDefines (0.210.0) - - FlipperKit/FKPortForwarding (0.210.0): + - FlipperKit/FBDefines (0.211.0) + - FlipperKit/FKPortForwarding (0.211.0): - CocoaAsyncSocket (~> 7.6) - Flipper-PeerTalk (~> 0.0.4) - - FlipperKit/FlipperKitExamplePlugin (0.210.0): + - FlipperKit/FlipperKitExamplePlugin (0.211.0): - FlipperKit/Core - - FlipperKit/FlipperKitHighlightOverlay (0.210.0) - - FlipperKit/FlipperKitLayoutHelpers (0.210.0): + - FlipperKit/FlipperKitHighlightOverlay (0.211.0) + - FlipperKit/FlipperKitLayoutHelpers (0.211.0): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutIOSDescriptors (0.210.0): + - FlipperKit/FlipperKitLayoutIOSDescriptors (0.211.0): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutHelpers - - FlipperKit/FlipperKitLayoutPlugin (0.210.0): + - FlipperKit/FlipperKitLayoutPlugin (0.211.0): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutHelpers - FlipperKit/FlipperKitLayoutIOSDescriptors - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutTextSearchable (0.210.0) - - FlipperKit/FlipperKitNetworkPlugin (0.210.0): + - FlipperKit/FlipperKitLayoutTextSearchable (0.211.0) + - FlipperKit/FlipperKitNetworkPlugin (0.211.0): - FlipperKit/Core - - FlipperKit/FlipperKitReactPlugin (0.210.0): + - FlipperKit/FlipperKitReactPlugin (0.211.0): - FlipperKit/Core - - FlipperKit/FlipperKitUIDebuggerPlugin (0.210.0): + - FlipperKit/FlipperKitUIDebuggerPlugin (0.211.0): - FlipperKit/Core - - FlipperKit/FlipperKitUserDefaultsPlugin (0.210.0): + - FlipperKit/FlipperKitUserDefaultsPlugin (0.211.0): - FlipperKit/Core - - FlipperKit/SKIOSNetworkPlugin (0.210.0): + - FlipperKit/SKIOSNetworkPlugin (0.211.0): - FlipperKit/Core - FlipperKit/FlipperKitNetworkPlugin - libevent (2.1.12) @@ -104,14 +104,14 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 - Flipper: 4a5b2c2c6ac926d6881ead86c1b5411fc79da46e + Flipper: 320474526dd9b03509ffe2d0eecf21f47c2de363 Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c Flipper-DoubleConversion: 2dc99b02f658daf147069aad9dbd29d8feb06d30 Flipper-Fmt: 60cbdd92fc254826e61d669a5d87ef7015396a9b Flipper-Folly: 584845625005ff068a6ebf41f857f468decd26b3 Flipper-Glog: 70c50ce58ddaf67dc35180db05f191692570f446 Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 - FlipperKit: c2aabe903823302c655ebbc33e1cc59d275fdcaa + FlipperKit: f485471423b8b89870e9b4657d44e94a36ee80cf libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d diff --git a/iOS/SampleSwift/Podfile.lock b/iOS/SampleSwift/Podfile.lock index 7d1b5d0dc85..184ecabea65 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.210.0): + - Flipper (0.211.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.210.0): - - FlipperKit/Core (= 0.210.0) - - FlipperKit/Core (0.210.0): - - Flipper (~> 0.210.0) + - FlipperKit (0.211.0): + - FlipperKit/Core (= 0.211.0) + - FlipperKit/Core (0.211.0): + - Flipper (~> 0.211.0) - FlipperKit/CppBridge - FlipperKit/FBCxxFollyDynamicConvert - FlipperKit/FBDefines - FlipperKit/FKPortForwarding - SocketRocket (~> 0.7.0) - - FlipperKit/CppBridge (0.210.0): - - Flipper (~> 0.210.0) - - FlipperKit/FBCxxFollyDynamicConvert (0.210.0): + - FlipperKit/CppBridge (0.211.0): + - Flipper (~> 0.211.0) + - FlipperKit/FBCxxFollyDynamicConvert (0.211.0): - Flipper-Folly (~> 2.6) - - FlipperKit/FBDefines (0.210.0) - - FlipperKit/FKPortForwarding (0.210.0): + - FlipperKit/FBDefines (0.211.0) + - FlipperKit/FKPortForwarding (0.211.0): - CocoaAsyncSocket (~> 7.6) - Flipper-PeerTalk (~> 0.0.4) - - FlipperKit/FlipperKitExamplePlugin (0.210.0): + - FlipperKit/FlipperKitExamplePlugin (0.211.0): - FlipperKit/Core - - FlipperKit/FlipperKitHighlightOverlay (0.210.0) - - FlipperKit/FlipperKitLayoutHelpers (0.210.0): + - FlipperKit/FlipperKitHighlightOverlay (0.211.0) + - FlipperKit/FlipperKitLayoutHelpers (0.211.0): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutIOSDescriptors (0.210.0): + - FlipperKit/FlipperKitLayoutIOSDescriptors (0.211.0): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutHelpers - - FlipperKit/FlipperKitLayoutPlugin (0.210.0): + - FlipperKit/FlipperKitLayoutPlugin (0.211.0): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutHelpers - FlipperKit/FlipperKitLayoutIOSDescriptors - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutTextSearchable (0.210.0) - - FlipperKit/FlipperKitNetworkPlugin (0.210.0): + - FlipperKit/FlipperKitLayoutTextSearchable (0.211.0) + - FlipperKit/FlipperKitNetworkPlugin (0.211.0): - FlipperKit/Core - - FlipperKit/FlipperKitUserDefaultsPlugin (0.210.0): + - FlipperKit/FlipperKitUserDefaultsPlugin (0.211.0): - FlipperKit/Core - - FlipperKit/SKIOSNetworkPlugin (0.210.0): + - FlipperKit/SKIOSNetworkPlugin (0.211.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: 4a5b2c2c6ac926d6881ead86c1b5411fc79da46e + Flipper: 320474526dd9b03509ffe2d0eecf21f47c2de363 Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c Flipper-DoubleConversion: 2dc99b02f658daf147069aad9dbd29d8feb06d30 Flipper-Fmt: 60cbdd92fc254826e61d669a5d87ef7015396a9b Flipper-Folly: 584845625005ff068a6ebf41f857f468decd26b3 Flipper-Glog: 70c50ce58ddaf67dc35180db05f191692570f446 Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 - FlipperKit: c2aabe903823302c655ebbc33e1cc59d275fdcaa + FlipperKit: f485471423b8b89870e9b4657d44e94a36ee80cf libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d diff --git a/iOS/Tutorial/Podfile b/iOS/Tutorial/Podfile index 0711000481d..fb2e9f5c01f 100644 --- a/iOS/Tutorial/Podfile +++ b/iOS/Tutorial/Podfile @@ -1,6 +1,6 @@ project 'Tutorial.xcodeproj' swift_version = "4.1" -flipperkit_version = '0.210.0' +flipperkit_version = '0.211.0' use_frameworks! target 'Tutorial' do diff --git a/iOS/Tutorial/Podfile.lock b/iOS/Tutorial/Podfile.lock index 8e6ca565be9..4175b98b658 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.210.0): + - Flipper (0.211.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.210.0): - - FlipperKit/Core (= 0.210.0) - - FlipperKit/Core (0.210.0): - - Flipper (~> 0.210.0) + - FlipperKit (0.211.0): + - FlipperKit/Core (= 0.211.0) + - FlipperKit/Core (0.211.0): + - Flipper (~> 0.211.0) - FlipperKit/CppBridge - FlipperKit/FBCxxFollyDynamicConvert - FlipperKit/FBDefines - FlipperKit/FKPortForwarding - SocketRocket (~> 0.7.0) - - FlipperKit/CppBridge (0.210.0): - - Flipper (~> 0.210.0) - - FlipperKit/FBCxxFollyDynamicConvert (0.210.0): + - FlipperKit/CppBridge (0.211.0): + - Flipper (~> 0.211.0) + - FlipperKit/FBCxxFollyDynamicConvert (0.211.0): - Flipper-Folly (~> 2.6) - - FlipperKit/FBDefines (0.210.0) - - FlipperKit/FKPortForwarding (0.210.0): + - FlipperKit/FBDefines (0.211.0) + - FlipperKit/FKPortForwarding (0.211.0): - CocoaAsyncSocket (~> 7.6) - Flipper-PeerTalk (~> 0.0.4) - - FlipperKit/FlipperKitHighlightOverlay (0.210.0) - - FlipperKit/FlipperKitLayoutComponentKitSupport (0.210.0): + - FlipperKit/FlipperKitHighlightOverlay (0.211.0) + - FlipperKit/FlipperKitLayoutComponentKitSupport (0.211.0): - ComponentKit (= 0.31) - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay @@ -43,26 +43,26 @@ PODS: - FlipperKit/FlipperKitLayoutPlugin - FlipperKit/FlipperKitLayoutTextSearchable - RenderCore (= 0.31) - - FlipperKit/FlipperKitLayoutHelpers (0.210.0): + - FlipperKit/FlipperKitLayoutHelpers (0.211.0): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutIOSDescriptors (0.210.0): + - FlipperKit/FlipperKitLayoutIOSDescriptors (0.211.0): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutHelpers - - FlipperKit/FlipperKitLayoutPlugin (0.210.0): + - FlipperKit/FlipperKitLayoutPlugin (0.211.0): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutHelpers - FlipperKit/FlipperKitLayoutIOSDescriptors - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutTextSearchable (0.210.0) - - FlipperKit/FlipperKitNetworkPlugin (0.210.0): + - FlipperKit/FlipperKitLayoutTextSearchable (0.211.0) + - FlipperKit/FlipperKitNetworkPlugin (0.211.0): - FlipperKit/Core - - FlipperKit/FlipperKitUserDefaultsPlugin (0.210.0): + - FlipperKit/FlipperKitUserDefaultsPlugin (0.211.0): - FlipperKit/Core - - FlipperKit/SKIOSNetworkPlugin (0.210.0): + - FlipperKit/SKIOSNetworkPlugin (0.211.0): - FlipperKit/Core - FlipperKit/FlipperKitNetworkPlugin - libevent (2.1.12) @@ -72,10 +72,10 @@ PODS: - Yoga (1.14.0) DEPENDENCIES: - - FlipperKit (~> 0.210.0) - - FlipperKit/FlipperKitLayoutComponentKitSupport (~> 0.210.0) - - FlipperKit/FlipperKitUserDefaultsPlugin (~> 0.210.0) - - FlipperKit/SKIOSNetworkPlugin (~> 0.210.0) + - FlipperKit (~> 0.211.0) + - FlipperKit/FlipperKitLayoutComponentKitSupport (~> 0.211.0) + - FlipperKit/FlipperKitUserDefaultsPlugin (~> 0.211.0) + - FlipperKit/SKIOSNetworkPlugin (~> 0.211.0) SPEC REPOS: trunk: @@ -98,20 +98,20 @@ SPEC REPOS: SPEC CHECKSUMS: CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 ComponentKit: 7bf7048b9814afc6b6641645a14177f95fd9b9ae - Flipper: 4a5b2c2c6ac926d6881ead86c1b5411fc79da46e + Flipper: 320474526dd9b03509ffe2d0eecf21f47c2de363 Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c Flipper-DoubleConversion: 2dc99b02f658daf147069aad9dbd29d8feb06d30 Flipper-Fmt: 60cbdd92fc254826e61d669a5d87ef7015396a9b Flipper-Folly: 584845625005ff068a6ebf41f857f468decd26b3 Flipper-Glog: 70c50ce58ddaf67dc35180db05f191692570f446 Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 - FlipperKit: c2aabe903823302c655ebbc33e1cc59d275fdcaa + FlipperKit: f485471423b8b89870e9b4657d44e94a36ee80cf libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c RenderCore: 090beb17b5bff80b86929a7ceb49df789923d23a SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d Yoga: cff67a400f6b74dc38eb0bad4f156673d9aa980c -PODFILE CHECKSUM: 1c66a17eebb0e2f5caefa9b800082c6656cdfdf2 +PODFILE CHECKSUM: 70f4a89e4f6f79da5f5ae5f8bd0d91dbd1cbf334 COCOAPODS: 1.12.1 diff --git a/react-native/ReactNativeFlipperExample/ios/Podfile b/react-native/ReactNativeFlipperExample/ios/Podfile index f3583474f62..706b33a3a79 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.210.0' +flipperkit_version = '0.211.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 c6b29d2f566..80313ec2638 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.210.0): + - Flipper (0.211.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.210.0): - - FlipperKit/Core (= 0.210.0) - - FlipperKit/Core (0.210.0): - - Flipper (~> 0.210.0) + - FlipperKit (0.211.0): + - FlipperKit/Core (= 0.211.0) + - FlipperKit/Core (0.211.0): + - Flipper (~> 0.211.0) - FlipperKit/CppBridge - FlipperKit/FBCxxFollyDynamicConvert - FlipperKit/FBDefines - FlipperKit/FKPortForwarding - SocketRocket (~> 0.7.0) - - FlipperKit/CppBridge (0.210.0): - - Flipper (~> 0.210.0) - - FlipperKit/FBCxxFollyDynamicConvert (0.210.0): + - FlipperKit/CppBridge (0.211.0): + - Flipper (~> 0.211.0) + - FlipperKit/FBCxxFollyDynamicConvert (0.211.0): - Flipper-Folly (~> 2.6) - - FlipperKit/FBDefines (0.210.0) - - FlipperKit/FKPortForwarding (0.210.0): + - FlipperKit/FBDefines (0.211.0) + - FlipperKit/FKPortForwarding (0.211.0): - CocoaAsyncSocket (~> 7.6) - Flipper-PeerTalk (~> 0.0.4) - - FlipperKit/FlipperKitHighlightOverlay (0.210.0) - - FlipperKit/FlipperKitLayoutHelpers (0.210.0): + - FlipperKit/FlipperKitHighlightOverlay (0.211.0) + - FlipperKit/FlipperKitLayoutHelpers (0.211.0): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutIOSDescriptors (0.210.0): + - FlipperKit/FlipperKitLayoutIOSDescriptors (0.211.0): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutHelpers - - FlipperKit/FlipperKitLayoutPlugin (0.210.0): + - FlipperKit/FlipperKitLayoutPlugin (0.211.0): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutHelpers - FlipperKit/FlipperKitLayoutIOSDescriptors - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutTextSearchable (0.210.0) - - FlipperKit/FlipperKitNetworkPlugin (0.210.0): + - FlipperKit/FlipperKitLayoutTextSearchable (0.211.0) + - FlipperKit/FlipperKitNetworkPlugin (0.211.0): - FlipperKit/Core - - FlipperKit/FlipperKitReactPlugin (0.210.0): + - FlipperKit/FlipperKitReactPlugin (0.211.0): - FlipperKit/Core - - FlipperKit/FlipperKitUserDefaultsPlugin (0.210.0): + - FlipperKit/FlipperKitUserDefaultsPlugin (0.211.0): - FlipperKit/Core - - FlipperKit/SKIOSNetworkPlugin (0.210.0): + - FlipperKit/SKIOSNetworkPlugin (0.211.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.210.0) + - Flipper (= 0.211.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.210.0) - - FlipperKit/Core (= 0.210.0) - - FlipperKit/CppBridge (= 0.210.0) - - FlipperKit/FBCxxFollyDynamicConvert (= 0.210.0) - - FlipperKit/FBDefines (= 0.210.0) - - FlipperKit/FKPortForwarding (= 0.210.0) - - FlipperKit/FlipperKitHighlightOverlay (= 0.210.0) - - FlipperKit/FlipperKitLayoutPlugin (= 0.210.0) - - FlipperKit/FlipperKitLayoutTextSearchable (= 0.210.0) - - FlipperKit/FlipperKitNetworkPlugin (= 0.210.0) - - FlipperKit/FlipperKitReactPlugin (= 0.210.0) - - FlipperKit/FlipperKitUserDefaultsPlugin (= 0.210.0) - - FlipperKit/SKIOSNetworkPlugin (= 0.210.0) + - FlipperKit (= 0.211.0) + - FlipperKit/Core (= 0.211.0) + - FlipperKit/CppBridge (= 0.211.0) + - FlipperKit/FBCxxFollyDynamicConvert (= 0.211.0) + - FlipperKit/FBDefines (= 0.211.0) + - FlipperKit/FKPortForwarding (= 0.211.0) + - FlipperKit/FlipperKitHighlightOverlay (= 0.211.0) + - FlipperKit/FlipperKitLayoutPlugin (= 0.211.0) + - FlipperKit/FlipperKitLayoutTextSearchable (= 0.211.0) + - FlipperKit/FlipperKitNetworkPlugin (= 0.211.0) + - FlipperKit/FlipperKitReactPlugin (= 0.211.0) + - FlipperKit/FlipperKitUserDefaultsPlugin (= 0.211.0) + - FlipperKit/SKIOSNetworkPlugin (= 0.211.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: 4a5b2c2c6ac926d6881ead86c1b5411fc79da46e + Flipper: 320474526dd9b03509ffe2d0eecf21f47c2de363 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: c2aabe903823302c655ebbc33e1cc59d275fdcaa + FlipperKit: f485471423b8b89870e9b4657d44e94a36ee80cf fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 glog: 3d02b25ca00c2d456734d0bcff864cbc62f6ae1a hermes-engine: 51aaceb1f6dc1aed44b8bbf866f52ec146c00a89 @@ -572,6 +572,6 @@ SPEC CHECKSUMS: SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d Yoga: 0b84a956f7393ef1f37f3bb213c516184e4a689d -PODFILE CHECKSUM: 0380499299dd3960bad2a88e0e7bbb01418fcf95 +PODFILE CHECKSUM: 5d389a4102f2d7739d79675fa1522efcc4501d17 COCOAPODS: 1.12.1 From 9e2615cd8052aaa64613b75460b0a9820ce5c83e Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Fri, 11 Aug 2023 14:16:21 -0700 Subject: [PATCH 14/98] Better troubleshoot guide to kill existing running instance Summary: Combine the two used commands as will make things easier for our users. Reviewed By: passy Differential Revision: D48266474 fbshipit-source-id: 1ee5c568ff001dc5ba3f11e21b09a2a6ab430ac7 --- desktop/flipper-server-client/src/FlipperServerClient.tsx | 2 +- desktop/flipper-ui-core/src/chrome/SettingsSheet.tsx | 6 +----- desktop/flipper-ui-core/src/dispatcher/flipperServer.tsx | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/desktop/flipper-server-client/src/FlipperServerClient.tsx b/desktop/flipper-server-client/src/FlipperServerClient.tsx index 834e91fce48..0993bd0e7a4 100644 --- a/desktop/flipper-server-client/src/FlipperServerClient.tsx +++ b/desktop/flipper-server-client/src/FlipperServerClient.tsx @@ -50,7 +50,7 @@ export function createFlipperServerWithSocket( new Error( `Failed to connect to the server in a timely manner. It may be unresponsive. Run the following from the terminal - 'sudo lsof -i :52342' and kill the listed process, if any.`, + 'sudo kill $(lsof -t -i :52342)' as to kill any existing running instance, if any.`, ), ); }, CONNECTION_TIMEOUT); diff --git a/desktop/flipper-ui-core/src/chrome/SettingsSheet.tsx b/desktop/flipper-ui-core/src/chrome/SettingsSheet.tsx index a4719734723..b75e23bc2ed 100644 --- a/desktop/flipper-ui-core/src/chrome/SettingsSheet.tsx +++ b/desktop/flipper-ui-core/src/chrome/SettingsSheet.tsx @@ -432,11 +432,7 @@ class SettingsSheet extends Component { process listening at port 52342. See below:
- - sudo lsof -i :52342 -
- sudo kill <PID> -
+ sudo kill $(lsof -t -i :52342) ) : ( <> diff --git a/desktop/flipper-ui-core/src/dispatcher/flipperServer.tsx b/desktop/flipper-ui-core/src/dispatcher/flipperServer.tsx index 0afb35618bc..8be37720528 100644 --- a/desktop/flipper-ui-core/src/dispatcher/flipperServer.tsx +++ b/desktop/flipper-ui-core/src/dispatcher/flipperServer.tsx @@ -210,7 +210,7 @@ function handeEADDRINUSE(errorMessage: string) {

Please try to kill the offending process by running{' '} - kill $(lsof -ti:PORTNUMBER) and restart flipper. + sudo kill $(lsof -ti:PORTNUMBER) and restart flipper.

{errorMessage} From bdbf5794eefc65c12b77d9727c1b8f84815fb79a Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Fri, 11 Aug 2023 14:16:21 -0700 Subject: [PATCH 15/98] Remove [conn] from log Summary: Not really a connectivity related log, so removed [conn] from it. Reviewed By: passy Differential Revision: D48266546 fbshipit-source-id: e384301d6301940366b594b4bc612349cc2264ce --- .../src/AbstractClient.tsx | 2 +- .../src/dispatcher/flipperServer.tsx | 20 +++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/desktop/flipper-frontend-core/src/AbstractClient.tsx b/desktop/flipper-frontend-core/src/AbstractClient.tsx index 57b4a7a91dd..6e533b39735 100644 --- a/desktop/flipper-frontend-core/src/AbstractClient.tsx +++ b/desktop/flipper-frontend-core/src/AbstractClient.tsx @@ -134,7 +134,7 @@ export default abstract class AbstractClient extends EventEmitter { 'Fetch plugin timeout. Unresponsive client?', ); } catch (e) { - console.warn('[conn] Fetch plugin error', e); + console.warn('Failed to fetch plugin', e); } this.plugins = new Set(response?.plugins ?? []); console.info('AbstractClient.loadPlugins', this.query, [...this.plugins]); diff --git a/desktop/flipper-ui-core/src/dispatcher/flipperServer.tsx b/desktop/flipper-ui-core/src/dispatcher/flipperServer.tsx index 8be37720528..a9692b4df49 100644 --- a/desktop/flipper-ui-core/src/dispatcher/flipperServer.tsx +++ b/desktop/flipper-ui-core/src/dispatcher/flipperServer.tsx @@ -182,7 +182,7 @@ function handleServerStateChange({ error?: string; }) { if (state === 'error') { - console.warn(`[conn] Flipper server state -> ${state}`, error); + console.warn(`Flipper server state -> ${state}`, error); if (error?.includes('EADDRINUSE')) { handeEADDRINUSE(error); } else { @@ -194,7 +194,7 @@ function handleServerStateChange({ }); } } else { - console.info(`[conn] Flipper server state -> ${state}`); + console.info(`Flipper server state -> ${state}`); } } @@ -348,14 +348,14 @@ export async function handleClientConnected( } console.log( - `[conn] Searching matching device ${query.device_id} for client ${query.app}...`, + `Searching matching device ${query.device_id} for client ${query.app}...`, ); const device = getDeviceBySerial(store.getState(), query.device_id) ?? (await findDeviceForConnection(store, query.app, query.device_id).catch( (e) => { console.warn( - `[conn] Failed to find device '${query.device_id}' while connection app '${query.app}'`, + `Failed to find device '${query.device_id}' while connection app '${query.app}'`, e, ); const key = `device-find-failure-${query.device_id}`; @@ -408,19 +408,17 @@ export async function handleClientConnected( await timeout( 30 * 1000, client.init(), - `[conn] Failed to initialize client ${query.app} on ${query.device_id} in a timely manner`, - ); - console.log( - `[conn] ${query.app} on ${query.device_id} connected and ready.`, + `Failed to initialize client ${query.app} on ${query.device_id} in a timely manner`, ); + console.log(`${query.app} on ${query.device_id} connected and ready.`); } catch (e) { if (e instanceof NoLongerConnectedToClientError) { console.warn( - `[conn] Client ${query.app} on ${query.device_id} disconnected while initialising`, + `Client ${query.app} on ${query.device_id} disconnected while initialising`, ); return; } - console.warn(`[conn] Failed to handle client connected: ${e}`); + console.warn(`Failed to handle client connected: ${e}`); } } @@ -465,7 +463,7 @@ async function findDeviceForConnection( (device) => device.serial === serial, ); if (matchingDevice) { - console.log(`[conn] Found device for: ${clientId} on ${serial}.`); + console.log(`Found device for: ${clientId} on ${serial}.`); clearTimeout(timeout); resolve(matchingDevice); unsubscribe(); From 29f072fc759fb70b069f5d4a96bbfb1bd1a4e686 Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Mon, 14 Aug 2023 06:34:51 -0700 Subject: [PATCH 16/98] ACTUALLY disable dokka builds (#5005) Summary: This should hopefully unblock our Android builds for real this time. I didn't realise that the AGP itself seems to ship with a version of Dokka, so just removing the import didn't actually address the problem we were seeing. Pull Request resolved: https://github.com/facebook/flipper/pull/5005 Test Plan: ``` ./gradlew publishToMavenLocal -PRELEASE_SIGNING_ENABLED=false ``` This now succeeds. Reviewed By: jknoxville Differential Revision: D48312784 Pulled By: passy fbshipit-source-id: f049e089a511726857f544386fe13dcb50fb2971 --- android/plugins/jetpack-compose/build.gradle | 8 +------- build.gradle | 4 ++++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/android/plugins/jetpack-compose/build.gradle b/android/plugins/jetpack-compose/build.gradle index 2a095f13c3b..a4e32371285 100644 --- a/android/plugins/jetpack-compose/build.gradle +++ b/android/plugins/jetpack-compose/build.gradle @@ -31,11 +31,5 @@ android { } } -apply plugin: 'com.vanniktech.maven.publish' - -import com.vanniktech.maven.publish.SonatypeHost -mavenPublishing { - // Disable javadoc publishing - publishToMavenCentral(SonatypeHost.DEFAULT, false) -} +apply plugin: 'com.vanniktech.maven.publish' diff --git a/build.gradle b/build.gradle index a9f47471288..326d81a22d2 100644 --- a/build.gradle +++ b/build.gradle @@ -41,6 +41,10 @@ subprojects { tasks.withType(Javadoc).all { enabled = false } + + tasks.withType(com.android.build.gradle.tasks.JavaDocGenerationTask).all { + enabled = false + } } ext { From 76341a0215e6695aaf5575b0fc9da70df7d7d6cf Mon Sep 17 00:00:00 2001 From: David Vacca Date: Mon, 14 Aug 2023 09:54:54 -0700 Subject: [PATCH 17/98] Fix NoSuchMethodError when calling FbReactApplicationBaseSonarUtil.startSonarClient Summary: This diff is fixing a NoSuchMethodError when calling FbReactApplicationBaseSonarUtil.startSonarClient. This is causing catalyst Android app to not start. This was caused by D47468613, which changed the signature of the method Reviewed By: cortinico Differential Revision: D48275730 fbshipit-source-id: 4693c299dbd3b6a9ad58a1439bddd9e4bfb8bdf5 --- .../com/facebook/flipper/plugins/react/ReactFlipperPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/main/java/com/facebook/flipper/plugins/react/ReactFlipperPlugin.java b/android/src/main/java/com/facebook/flipper/plugins/react/ReactFlipperPlugin.java index ac75701f6fc..ec2fd35a554 100644 --- a/android/src/main/java/com/facebook/flipper/plugins/react/ReactFlipperPlugin.java +++ b/android/src/main/java/com/facebook/flipper/plugins/react/ReactFlipperPlugin.java @@ -10,7 +10,7 @@ import com.facebook.flipper.core.FlipperConnection; import com.facebook.flipper.core.FlipperPlugin; -// This plugin is not needed, but kept here for backward compatilibty +// This plugin is not needed, but kept here for backward compatibility @Deprecated public class ReactFlipperPlugin implements FlipperPlugin { From 3003330067efd4a93e2fd839f6b18121eb6ec577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=BAlvio=20Abrah=C3=A3o=20de=20Paula?= Date: Mon, 14 Aug 2023 11:07:07 -0700 Subject: [PATCH 18/98] Create initial databases plugin structure. Reviewed By: lblasa Differential Revision: D48172580 fbshipit-source-id: d000329c2fe8ebc12f59e3165861b1e8033ddbbe --- .../FlipperKitDatabasesPlugin.h | 15 +++ .../FlipperKitDatabasesPlugin.mm | 102 ++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.h create mode 100644 iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.mm diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.h new file mode 100644 index 00000000000..db09070de4b --- /dev/null +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.h @@ -0,0 +1,15 @@ +/* + * 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. + */ + +#import +#import + +@interface FlipperKitDatabasesPlugin : NSObject +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)sharedInstance; + +@end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.mm b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.mm new file mode 100644 index 00000000000..a5cfaf72dae --- /dev/null +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.mm @@ -0,0 +1,102 @@ +/* + * 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. + */ + +#if FB_SONARKIT_ENABLED +#import "FlipperKitDatabasesPlugin.h" +#import +#import +#import + +@interface FlipperKitDatabasesPlugin () +@property(strong, nonatomic) id connection; + +@end + +@implementation FlipperKitDatabasesPlugin + +- (instancetype)init { + if (self = [super init]) { + } + return self; +} + ++ (instancetype)sharedInstance { + static FlipperKitDatabasesPlugin* sInstance = nil; + + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + sInstance = [FlipperKitDatabasesPlugin new]; + }); + + return sInstance; +} + +- (void)didConnect:(id)connection { + self.connection = connection; + + // Define connection event handlers + + // databaseList + [connection + receive:@"databaseList" + withBlock:^(NSDictionary* params, id responder) { + NSMutableDictionary* response = [NSMutableDictionary dictionary]; + + response[@1] = @{ + @"id" : @1, + @"name" : @"Provider1", + @"tables" : @[ @"Table1_1", @"Table1_2", @"Table1_3" ] + }; + response[@2] = @{ + @"id" : @2, + @"name" : @"Provider2", + @"tables" : @[ @"Table2_1", @"Table2_2" ] + }; + response[@3] = + @{@"id" : @3, + @"name" : @"Provider3", + @"tables" : @[ @"Table3_1" ]}; + [responder success:response]; + }]; + + // getTableData + [connection receive:@"getTableData" + withBlock:^(NSDictionary* params, id responder){ + + }]; + + // getTableStructure + [connection receive:@"getTableStructure" + withBlock:^(NSDictionary* params, id responder){ + }]; + + // getTableInfo + [connection receive:@"getTableInfo" + withBlock:^(NSDictionary* params, id responder){ + }]; + + // execute + [connection receive:@"execute" + withBlock:^(NSDictionary*, id responder){ + }]; +} + +- (void)didDisconnect { + self.connection = nil; +} + +- (NSString*)identifier { + return @"Databases"; +} + +- (BOOL)runInBackground { + return YES; +} + +@end + +#endif From fea326be79581a9915514ebc6bab4046969b3c19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=BAlvio=20Abrah=C3=A3o=20de=20Paula?= Date: Mon, 14 Aug 2023 11:07:07 -0700 Subject: [PATCH 19/98] Implement similar structure we have in Java plugin. Reviewed By: lblasa Differential Revision: D48172579 fbshipit-source-id: b2127507b04cdb85f426313e71405a81103e42bd --- .../DatabaseDescriptor.h | 10 ++ .../DatabaseDriver.h | 19 +++ .../DatabasesManager.h | 83 +++++++++++ .../DatabasesManager.mm | 136 ++++++++++++++++++ .../FlipperKitDatabasesPlugin.h | 4 + .../FlipperKitDatabasesPlugin.mm | 56 ++------ 6 files changed, 260 insertions(+), 48 deletions(-) create mode 100644 iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDescriptor.h create mode 100644 iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDriver.h create mode 100644 iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.h create mode 100644 iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.mm diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDescriptor.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDescriptor.h new file mode 100644 index 00000000000..e6509a6829c --- /dev/null +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDescriptor.h @@ -0,0 +1,10 @@ +/* + * 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. + */ + +@protocol DatabaseDescriptor +- (NSString*)name; +@end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDriver.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDriver.h new file mode 100644 index 00000000000..873d5f6bf64 --- /dev/null +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDriver.h @@ -0,0 +1,19 @@ +/* + * 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. + */ + +#import + +@protocol DatabaseDescriptor; + +@protocol DatabaseDriver +@property(nonatomic, strong, readonly) id + databaseDescriptor; + +- (NSArray>*)getDatabases; +- (NSArray*)getTableNames:(id)databaseDescriptor; + +@end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.h new file mode 100644 index 00000000000..ec850e11be8 --- /dev/null +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.h @@ -0,0 +1,83 @@ +/* + * 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. + */ + +#import + +@protocol DatabaseDriver; +@protocol DatabaseDescriptor; +@protocol FlipperConnection; + +@interface DatabasesManager : NSObject + +@property(nonatomic, strong) id connection; +@property(nonatomic, strong, readonly) + NSArray>* databaseDrivers; + +- (instancetype)initWithDatabaseDrivers: + (NSArray>*)databaseDrivers; +- (void)setConnection:(id)connection; +- (BOOL)isConnected; + +@end + +@interface DatabaseDescriptorHolder : NSObject + +@property(nonatomic, assign, readonly) NSInteger identifier; +@property(nonatomic, strong, readonly) id databaseDriver; +@property(nonatomic, strong, readonly) id + databaseDescriptor; + +- (instancetype)initWithIdentifier:(NSInteger)identifier + databaseDriver:(id)databaseDriver + databaseDescriptor:(id)databaseDescriptor; + +@end + +@interface ExecuteSqlRequest : NSObject + +@property(nonatomic, assign, readonly) NSInteger databaseId; +@property(nonatomic, copy, readonly) NSString* value; + +- (instancetype)initWithDatabaseId:(NSInteger)databaseId value:(NSString*)value; + +@end + +@interface GetTableDataRequest : NSObject + +@property(nonatomic, assign, readonly) NSInteger databaseId; +@property(nonatomic, copy, readonly) NSString* table; +@property(nonatomic, copy, readonly) NSString* order; +@property(nonatomic, assign, readonly) BOOL reverse; +@property(nonatomic, assign, readonly) NSInteger start; +@property(nonatomic, assign, readonly) NSInteger count; + +- (instancetype)initWithDatabaseId:(NSInteger)databaseId + table:(NSString*)table + order:(NSString*)order + reverse:(BOOL)reverse + start:(NSInteger)start + count:(NSInteger)count; + +@end + +@interface GetTableStructureRequest : NSObject + +@property(nonatomic, assign, readonly) NSInteger databaseId; +@property(nonatomic, copy, readonly) NSString* table; + +- (instancetype)initWithDatabaseId:(NSInteger)databaseId table:(NSString*)table; + +@end + +@interface GetTableInfoRequest : NSObject + +@property(nonatomic, assign, readonly) NSInteger databaseId; +@property(nonatomic, copy, readonly) NSString* table; + +- (instancetype)initWithDatabaseId:(NSInteger)databaseId table:(NSString*)table; + +@end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.mm b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.mm new file mode 100644 index 00000000000..3e1b64f0095 --- /dev/null +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.mm @@ -0,0 +1,136 @@ +/* + * 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. + */ + +#import "DatabasesManager.h" +#import +#import +#import +#import "DatabaseDriver.h" + +@interface DatabasesManager () + +@property(nonatomic, strong) + NSMutableDictionary* + databaseDescriptorHolders; +@property(nonatomic, strong) + NSMutableSet* databaseDescriptorHolderSet; + +@end + +@implementation DatabasesManager + +- (instancetype)initWithDatabaseDrivers: + (NSArray>*)databaseDrivers { + self = [super init]; + if (self) { + _databaseDrivers = [databaseDrivers copy]; + _databaseDescriptorHolders = [[NSMutableDictionary alloc] init]; + _databaseDescriptorHolderSet = [[NSMutableSet alloc] init]; + } + return self; +} + +- (void)setConnection:(id)connection { + _connection = connection; + if (connection) { + [self listenForCommands]; + } +} + +- (BOOL)isConnected { + return _connection != nil; +} + +- (void)listenForCommands { + // TODO(fulvioabrahao) implement commands. + [self.connection + receive:@"databaseList" + withBlock:^(NSDictionary* params, id responder){ + }]; +} + +@end + +@implementation DatabaseDescriptorHolder + +- (instancetype)initWithIdentifier:(NSInteger)identifier + databaseDriver:(id)databaseDriver + databaseDescriptor:(id)databaseDescriptor { + self = [super init]; + if (self) { + _identifier = identifier; + _databaseDriver = databaseDriver; + _databaseDescriptor = databaseDescriptor; + } + return self; +} + +@end + +@implementation ExecuteSqlRequest + +- (instancetype)initWithDatabaseId:(NSInteger)databaseId + value:(NSString*)value { + self = [super init]; + if (self) { + _databaseId = databaseId; + _value = [value copy]; + } + return self; +} + +@end + +@implementation GetTableDataRequest + +- (instancetype)initWithDatabaseId:(NSInteger)databaseId + table:(NSString*)table + order:(NSString*)order + reverse:(BOOL)reverse + start:(NSInteger)start + count:(NSInteger)count { + self = [super init]; + if (self) { + _databaseId = databaseId; + _table = [table copy]; + _order = [order copy]; + _reverse = reverse; + _start = start; + _count = count; + } + return self; +} + +@end + +@implementation GetTableStructureRequest + +- (instancetype)initWithDatabaseId:(NSInteger)databaseId + table:(NSString*)table { + self = [super init]; + if (self) { + _databaseId = databaseId; + _table = [table copy]; + } + return self; +} + +@end + +@implementation GetTableInfoRequest + +- (instancetype)initWithDatabaseId:(NSInteger)databaseId + table:(NSString*)table { + self = [super init]; + if (self) { + _databaseId = databaseId; + _table = [table copy]; + } + return self; +} + +@end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.h index db09070de4b..41f563b2728 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.h +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.h @@ -8,7 +8,11 @@ #import #import +@class DatabasesManager; + @interface FlipperKitDatabasesPlugin : NSObject +@property(nonatomic, strong) DatabasesManager* databasesManager; + - (instancetype)init NS_UNAVAILABLE; + (instancetype)sharedInstance; diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.mm b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.mm index a5cfaf72dae..53316e8df6c 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.mm +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.mm @@ -10,6 +10,8 @@ #import #import #import +#import "DatabaseDriver.h" +#import "DatabasesManager.h" @interface FlipperKitDatabasesPlugin () @property(strong, nonatomic) id connection; @@ -20,6 +22,9 @@ @implementation FlipperKitDatabasesPlugin - (instancetype)init { if (self = [super init]) { + NSArray>* databaseDrivers = @[]; + _databasesManager = + [[DatabasesManager alloc] initWithDatabaseDrivers:databaseDrivers]; } return self; } @@ -37,56 +42,11 @@ + (instancetype)sharedInstance { - (void)didConnect:(id)connection { self.connection = connection; - - // Define connection event handlers - - // databaseList - [connection - receive:@"databaseList" - withBlock:^(NSDictionary* params, id responder) { - NSMutableDictionary* response = [NSMutableDictionary dictionary]; - - response[@1] = @{ - @"id" : @1, - @"name" : @"Provider1", - @"tables" : @[ @"Table1_1", @"Table1_2", @"Table1_3" ] - }; - response[@2] = @{ - @"id" : @2, - @"name" : @"Provider2", - @"tables" : @[ @"Table2_1", @"Table2_2" ] - }; - response[@3] = - @{@"id" : @3, - @"name" : @"Provider3", - @"tables" : @[ @"Table3_1" ]}; - [responder success:response]; - }]; - - // getTableData - [connection receive:@"getTableData" - withBlock:^(NSDictionary* params, id responder){ - - }]; - - // getTableStructure - [connection receive:@"getTableStructure" - withBlock:^(NSDictionary* params, id responder){ - }]; - - // getTableInfo - [connection receive:@"getTableInfo" - withBlock:^(NSDictionary* params, id responder){ - }]; - - // execute - [connection receive:@"execute" - withBlock:^(NSDictionary*, id responder){ - }]; + [self.databasesManager setConnection:connection]; } - (void)didDisconnect { - self.connection = nil; + [self.databasesManager setConnection:nil]; } - (NSString*)identifier { @@ -94,7 +54,7 @@ - (NSString*)identifier { } - (BOOL)runInBackground { - return YES; + return NO; } @end From 9db2c746320a60d86d3eec72244d8ca3c7e70fd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=BAlvio=20Abrah=C3=A3o=20de=20Paula?= Date: Mon, 14 Aug 2023 11:07:07 -0700 Subject: [PATCH 20/98] Implement databaseList command and Add MockDatabaseDriver. Reviewed By: lblasa Differential Revision: D48172577 fbshipit-source-id: 10d6301041b3a4b3ab83b19e9afd3eac7ad7004c --- .../DatabasesManager.mm | 71 ++++++++++++++++++- .../FlipperKitDatabasesPlugin.mm | 4 +- .../MockDatabaseDescriptor.h | 13 ++++ .../MockDatabaseDescriptor.m | 16 +++++ .../MockDatabaseDriver.h | 13 ++++ .../MockDatabaseDriver.m | 26 +++++++ 6 files changed, 141 insertions(+), 2 deletions(-) create mode 100644 iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/MockDatabaseDescriptor.h create mode 100644 iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/MockDatabaseDescriptor.m create mode 100644 iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/MockDatabaseDriver.h create mode 100644 iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/MockDatabaseDriver.m diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.mm b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.mm index 3e1b64f0095..7447aa551f7 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.mm +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.mm @@ -9,6 +9,8 @@ #import #import #import +#include +#import "DatabaseDescriptor.h" #import "DatabaseDriver.h" @interface DatabasesManager () @@ -46,11 +48,78 @@ - (BOOL)isConnected { } - (void)listenForCommands { - // TODO(fulvioabrahao) implement commands. [self.connection receive:@"databaseList" + withBlock:^(NSDictionary* params, id responder) { + NSInteger databaseId = 1; + [self.databaseDescriptorHolders removeAllObjects]; + [self.databaseDescriptorHolderSet removeAllObjects]; + + for (id databaseDriver in self.databaseDrivers) { + NSArray>* databaseDescriptorList = + [databaseDriver getDatabases]; + for (id databaseDescriptor in + databaseDescriptorList) { + DatabaseDescriptorHolder* databaseDescriptorHolder = + [[DatabaseDescriptorHolder alloc] + initWithIdentifier:databaseId + databaseDriver:databaseDriver + databaseDescriptor:databaseDescriptor]; + self.databaseDescriptorHolders[@(databaseId)] = + databaseDescriptorHolder; + [self.databaseDescriptorHolderSet + addObject:databaseDescriptorHolder]; + databaseId++; + } + } + + NSDictionary* result = [DatabasesManager + databaseListToDictionary:self.databaseDescriptorHolderSet]; + [responder success:result]; + }]; + + [self.connection + receive:@"getTableData" + withBlock:^(NSDictionary* params, id responder){ + }]; + + [self.connection + receive:@"getTableStructure" withBlock:^(NSDictionary* params, id responder){ }]; + + [self.connection + receive:@"getTableInfo" + withBlock:^(NSDictionary* params, id responder){ + }]; + + [self.connection + receive:@"execute" + withBlock:^(NSDictionary* params, id responder){ + }]; +} + ++ (NSDictionary*)databaseListToDictionary: + (NSSet*)databaseDescriptorHolderSet { + NSMutableDictionary* resultDict = [NSMutableDictionary new]; + + for (DatabaseDescriptorHolder* descriptorHolder in + databaseDescriptorHolderSet) { + NSArray* tableNameList = [descriptorHolder.databaseDriver + getTableNames:descriptorHolder.databaseDescriptor]; + NSArray* sortedTableNames = + [tableNameList sortedArrayUsingSelector:@selector(compare:)]; + NSString* idString = + [NSString stringWithFormat:@"%ld", descriptorHolder.identifier]; + NSDictionary* databaseDict = @{ + @"id" : idString, + @"name" : descriptorHolder.databaseDescriptor.name, + @"tables" : sortedTableNames + }; + [resultDict setObject:databaseDict forKey:idString]; + } + + return resultDict; } @end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.mm b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.mm index 53316e8df6c..7f6c4da2058 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.mm +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.mm @@ -12,6 +12,7 @@ #import #import "DatabaseDriver.h" #import "DatabasesManager.h" +#import "MockDatabaseDriver.h" @interface FlipperKitDatabasesPlugin () @property(strong, nonatomic) id connection; @@ -22,7 +23,8 @@ @implementation FlipperKitDatabasesPlugin - (instancetype)init { if (self = [super init]) { - NSArray>* databaseDrivers = @[]; + NSArray>* databaseDrivers = + @[ [MockDatabaseDriver new] ]; _databasesManager = [[DatabasesManager alloc] initWithDatabaseDrivers:databaseDrivers]; } diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/MockDatabaseDescriptor.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/MockDatabaseDescriptor.h new file mode 100644 index 00000000000..763c8e0924f --- /dev/null +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/MockDatabaseDescriptor.h @@ -0,0 +1,13 @@ +/* + * 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. + */ + +#import +#import "DatabaseDescriptor.h" + +@interface MockDatabaseDescriptor : NSObject + +@end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/MockDatabaseDescriptor.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/MockDatabaseDescriptor.m new file mode 100644 index 00000000000..4dc3d7a0b53 --- /dev/null +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/MockDatabaseDescriptor.m @@ -0,0 +1,16 @@ +/* + * 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. + */ + +#import "MockDatabaseDescriptor.h" + +@implementation MockDatabaseDescriptor + +- (NSString*)name { + return @"MockDatabase"; +} + +@end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/MockDatabaseDriver.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/MockDatabaseDriver.h new file mode 100644 index 00000000000..bd62e981246 --- /dev/null +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/MockDatabaseDriver.h @@ -0,0 +1,13 @@ +/* + * 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. + */ + +#import +#import "DatabaseDriver.h" + +@interface MockDatabaseDriver : NSObject + +@end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/MockDatabaseDriver.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/MockDatabaseDriver.m new file mode 100644 index 00000000000..d8b8ae32489 --- /dev/null +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/MockDatabaseDriver.m @@ -0,0 +1,26 @@ +/* + * 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. + */ + +#import "MockDatabaseDriver.h" +#import "MockDatabaseDescriptor.h" + +@implementation MockDatabaseDriver + +- (NSArray>*)getDatabases { + MockDatabaseDescriptor* mockDescriptor = + [[MockDatabaseDescriptor alloc] init]; + return @[ mockDescriptor ]; +} + +- (NSArray*)getTableNames: + (id)databaseDescriptor { + return @[ @"MockTable1", @"MockTable2" ]; +} + +@synthesize databaseDescriptor; + +@end From ce85f44a3357a6f039e425aa573a7a68e4c40ea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=BAlvio=20Abrah=C3=A3o=20de=20Paula?= Date: Mon, 14 Aug 2023 11:07:07 -0700 Subject: [PATCH 21/98] Create commands data models and add ObjectMapper. Reviewed By: lblasa Differential Revision: D48188172 fbshipit-source-id: 10c99250f993c71976c693a691586385d111a4fd --- .../Commands/DatabaseExecuteSql.h | 27 +++++ .../Commands/DatabaseExecuteSql.m | 42 +++++++ .../Commands/DatabaseGetTableData.h | 42 +++++++ .../Commands/DatabaseGetTableData.m | 50 ++++++++ .../Commands/DatabaseGetTableInfo.h | 25 ++++ .../Commands/DatabaseGetTableInfo.m | 34 ++++++ .../Commands/DatabaseGetTableStructure.h | 34 ++++++ .../Commands/DatabaseGetTableStructure.m | 41 +++++++ .../DatabaseDescriptorHolder.h | 23 ++++ .../DatabaseDescriptorHolder.m | 24 ++++ .../DatabaseErrorCodes.h | 21 ++++ .../DatabasesManager.h | 58 --------- ...DatabasesManager.mm => DatabasesManager.m} | 111 +----------------- ...sPlugin.mm => FlipperKitDatabasesPlugin.m} | 0 .../FlipperKitDatabasesPlugin/ObjectMapper.h | 30 +++++ .../FlipperKitDatabasesPlugin/ObjectMapper.m | 63 ++++++++++ 16 files changed, 462 insertions(+), 163 deletions(-) create mode 100644 iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseExecuteSql.h create mode 100644 iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseExecuteSql.m create mode 100644 iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableData.h create mode 100644 iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableData.m create mode 100644 iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableInfo.h create mode 100644 iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableInfo.m create mode 100644 iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableStructure.h create mode 100644 iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableStructure.m create mode 100644 iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDescriptorHolder.h create mode 100644 iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDescriptorHolder.m create mode 100644 iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseErrorCodes.h rename iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/{DatabasesManager.mm => DatabasesManager.m} (52%) rename iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/{FlipperKitDatabasesPlugin.mm => FlipperKitDatabasesPlugin.m} (100%) create mode 100644 iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.h create mode 100644 iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseExecuteSql.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseExecuteSql.h new file mode 100644 index 00000000000..9d1e1eb0268 --- /dev/null +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseExecuteSql.h @@ -0,0 +1,27 @@ +/* + * 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. + */ + +#import + +@interface DatabaseExecuteSqlResponse : NSObject + +@property(nonatomic, strong) NSString* type; +@property(nonatomic, strong) NSArray* columns; +@property(nonatomic, strong) NSArray* values; +@property(nonatomic, strong) NSNumber* insertedId; +@property(nonatomic, assign) NSInteger affectedCount; + +@end + +@interface DatabaseExecuteSqlRequest : NSObject + +@property(nonatomic, assign, readonly) NSInteger databaseId; +@property(nonatomic, copy, readonly) NSString* value; + +- (instancetype)initWithDatabaseId:(NSInteger)databaseId value:(NSString*)value; + +@end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseExecuteSql.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseExecuteSql.m new file mode 100644 index 00000000000..96494e8d51f --- /dev/null +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseExecuteSql.m @@ -0,0 +1,42 @@ +/* + * 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. + */ + +#include "DatabaseExecuteSql.h" + +@implementation DatabaseExecuteSqlResponse + +- (instancetype)initWithType:(NSString*)type + columns:(NSArray*)columns + values:(NSArray*)values + insertedId:(NSNumber*)insertedId + affectedCount:(NSInteger)affectedCount { + self = [super init]; + if (self) { + _type = type; + _columns = [columns copy]; + _values = [values copy]; + _insertedId = insertedId; + _affectedCount = affectedCount; + } + return self; +} + +@end + +@implementation DatabaseExecuteSqlRequest + +- (instancetype)initWithDatabaseId:(NSInteger)databaseId + value:(NSString*)value { + self = [super init]; + if (self) { + _databaseId = databaseId; + _value = [value copy]; + } + return self; +} + +@end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableData.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableData.h new file mode 100644 index 00000000000..2cc3f850b86 --- /dev/null +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableData.h @@ -0,0 +1,42 @@ +/* + * 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. + */ + +#import + +@interface DatabaseGetTableDataResponse : NSObject + +@property(nonatomic, strong, readonly) NSArray* columns; +@property(nonatomic, strong, readonly) NSArray* values; +@property(nonatomic, assign, readonly) NSInteger start; +@property(nonatomic, assign, readonly) NSInteger count; +@property(nonatomic, assign, readonly) NSInteger total; + +- (instancetype)initWithColumns:(NSArray*)columns + values:(NSArray*)values + start:(NSInteger)start + count:(NSInteger)count + total:(NSInteger)total; + +@end + +@interface DatabaseGetTableDataRequest : NSObject + +@property(nonatomic, assign, readonly) NSInteger databaseId; +@property(nonatomic, copy, readonly) NSString* table; +@property(nonatomic, copy, readonly) NSString* order; +@property(nonatomic, assign, readonly) BOOL reverse; +@property(nonatomic, assign, readonly) NSInteger start; +@property(nonatomic, assign, readonly) NSInteger count; + +- (instancetype)initWithDatabaseId:(NSInteger)databaseId + table:(NSString*)table + order:(NSString*)order + reverse:(BOOL)reverse + start:(NSInteger)start + count:(NSInteger)count; + +@end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableData.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableData.m new file mode 100644 index 00000000000..632142a018d --- /dev/null +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableData.m @@ -0,0 +1,50 @@ +/* + * 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. + */ + +#import "DatabaseGetTableData.h" + +@implementation DatabaseGetTableDataResponse + +- (instancetype)initWithColumns:(NSArray*)columns + values:(NSArray*)values + start:(NSInteger)start + count:(NSInteger)count + total:(NSInteger)total { + self = [super init]; + if (self) { + _columns = [columns copy]; + _values = [values copy]; + _start = start; + _count = count; + _total = total; + } + return self; +} + +@end + +@implementation DatabaseGetTableDataRequest + +- (instancetype)initWithDatabaseId:(NSInteger)databaseId + table:(NSString*)table + order:(NSString*)order + reverse:(BOOL)reverse + start:(NSInteger)start + count:(NSInteger)count { + self = [super init]; + if (self) { + _databaseId = databaseId; + _table = [table copy]; + _order = [order copy]; + _reverse = reverse; + _start = start; + _count = count; + } + return self; +} + +@end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableInfo.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableInfo.h new file mode 100644 index 00000000000..2163854a5fa --- /dev/null +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableInfo.h @@ -0,0 +1,25 @@ +/* + * 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. + */ + +#import + +@interface DatabaseGetTableInfoResponse : NSObject + +@property(nonatomic, strong) NSString* definition; + +- (instancetype)initWithDefinition:(NSString*)definition; + +@end + +@interface DatabaseGetTableInfoRequest : NSObject + +@property(nonatomic, assign, readonly) NSInteger databaseId; +@property(nonatomic, copy, readonly) NSString* table; + +- (instancetype)initWithDatabaseId:(NSInteger)databaseId table:(NSString*)table; + +@end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableInfo.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableInfo.m new file mode 100644 index 00000000000..b86fd8b7f87 --- /dev/null +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableInfo.m @@ -0,0 +1,34 @@ +/* + * 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. + */ + +#import "DatabaseGetTableInfo.h" + +@implementation DatabaseGetTableInfoResponse + +- (instancetype)initWithDefinition:(NSString*)definition { + self = [super init]; + if (self) { + _definition = definition; + } + return self; +} + +@end + +@implementation DatabaseGetTableInfoRequest + +- (instancetype)initWithDatabaseId:(NSInteger)databaseId + table:(NSString*)table { + self = [super init]; + if (self) { + _databaseId = databaseId; + _table = [table copy]; + } + return self; +} + +@end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableStructure.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableStructure.h new file mode 100644 index 00000000000..6d2335d9fef --- /dev/null +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableStructure.h @@ -0,0 +1,34 @@ +/* + * 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. + */ + +#import + +@interface DatabaseGetTableStructureResponse : NSObject + +@property(nonatomic, strong, readonly) NSArray* structureColumns; +@property(nonatomic, strong, readonly) + NSArray*>* structureValues; +@property(nonatomic, strong, readonly) NSArray* indexesColumns; +@property(nonatomic, strong, readonly) + NSArray*>* indexesValues; + +- (instancetype) + initWithStructureColumns:(NSArray*)structureColumns + structureValues:(NSArray*>*)structureValues + indexesColumns:(NSArray*)indexesColumns + indexesValues:(NSArray*>*)indexesValues; + +@end + +@interface DatabaseGetTableStructureRequest : NSObject + +@property(nonatomic, assign, readonly) NSInteger databaseId; +@property(nonatomic, copy, readonly) NSString* table; + +- (instancetype)initWithDatabaseId:(NSInteger)databaseId table:(NSString*)table; + +@end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableStructure.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableStructure.m new file mode 100644 index 00000000000..6e24cfaf291 --- /dev/null +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableStructure.m @@ -0,0 +1,41 @@ +/* + * 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. + */ + +#import "DatabaseGetTableStructure.h" + +@implementation DatabaseGetTableStructureResponse + +- (instancetype) + initWithStructureColumns:(NSArray*)structureColumns + structureValues:(NSArray*>*)structureValues + indexesColumns:(NSArray*)indexesColumns + indexesValues:(NSArray*>*)indexesValues { + self = [super init]; + if (self) { + _structureColumns = [structureColumns copy]; + _structureValues = [structureValues copy]; + _indexesColumns = [indexesColumns copy]; + _indexesValues = [indexesValues copy]; + } + return self; +} + +@end + +@implementation DatabaseGetTableStructureRequest + +- (instancetype)initWithDatabaseId:(NSInteger)databaseId + table:(NSString*)table { + self = [super init]; + if (self) { + _databaseId = databaseId; + _table = [table copy]; + } + return self; +} + +@end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDescriptorHolder.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDescriptorHolder.h new file mode 100644 index 00000000000..109d3c98a7d --- /dev/null +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDescriptorHolder.h @@ -0,0 +1,23 @@ +/* + * 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. + */ + +#import +#import "DatabaseDescriptor.h" +#import "DatabaseDriver.h" + +@interface DatabaseDescriptorHolder : NSObject + +@property(nonatomic, assign, readonly) NSInteger identifier; +@property(nonatomic, strong, readonly) id databaseDriver; +@property(nonatomic, strong, readonly) id + databaseDescriptor; + +- (instancetype)initWithIdentifier:(NSInteger)identifier + databaseDriver:(id)databaseDriver + databaseDescriptor:(id)databaseDescriptor; + +@end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDescriptorHolder.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDescriptorHolder.m new file mode 100644 index 00000000000..467f340ae96 --- /dev/null +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDescriptorHolder.m @@ -0,0 +1,24 @@ +/* + * 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. + */ + +#import "DatabaseDescriptorHolder.h" + +@implementation DatabaseDescriptorHolder + +- (instancetype)initWithIdentifier:(NSInteger)identifier + databaseDriver:(id)databaseDriver + databaseDescriptor:(id)databaseDescriptor { + self = [super init]; + if (self) { + _identifier = identifier; + _databaseDriver = databaseDriver; + _databaseDescriptor = databaseDescriptor; + } + return self; +} + +@end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseErrorCodes.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseErrorCodes.h new file mode 100644 index 00000000000..e97a7e43175 --- /dev/null +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseErrorCodes.h @@ -0,0 +1,21 @@ +/* + * 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. + */ + +#import + +typedef NS_ENUM(NSInteger, DatabasesErrorCodes) { + DatabasesErrorCodesInvalidRequest = 1, + DatabasesErrorCodesDatabaseInvalid = 2, + DatabasesErrorCodesSqlExecutionException = 3, +}; + +static NSString* const kDatabasesErrorCodesInvalidRequestMessage = + @"The request received was invalid"; +static NSString* const kDatabasesErrorCodesDatabaseInvalidMessage = + @"Could not access database"; +static NSString* const kDatabasesErrorCodesSqlExecutionExceptionMessage = + @"SQL execution exception: "; diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.h index ec850e11be8..0907f01f3ce 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.h +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.h @@ -23,61 +23,3 @@ - (BOOL)isConnected; @end - -@interface DatabaseDescriptorHolder : NSObject - -@property(nonatomic, assign, readonly) NSInteger identifier; -@property(nonatomic, strong, readonly) id databaseDriver; -@property(nonatomic, strong, readonly) id - databaseDescriptor; - -- (instancetype)initWithIdentifier:(NSInteger)identifier - databaseDriver:(id)databaseDriver - databaseDescriptor:(id)databaseDescriptor; - -@end - -@interface ExecuteSqlRequest : NSObject - -@property(nonatomic, assign, readonly) NSInteger databaseId; -@property(nonatomic, copy, readonly) NSString* value; - -- (instancetype)initWithDatabaseId:(NSInteger)databaseId value:(NSString*)value; - -@end - -@interface GetTableDataRequest : NSObject - -@property(nonatomic, assign, readonly) NSInteger databaseId; -@property(nonatomic, copy, readonly) NSString* table; -@property(nonatomic, copy, readonly) NSString* order; -@property(nonatomic, assign, readonly) BOOL reverse; -@property(nonatomic, assign, readonly) NSInteger start; -@property(nonatomic, assign, readonly) NSInteger count; - -- (instancetype)initWithDatabaseId:(NSInteger)databaseId - table:(NSString*)table - order:(NSString*)order - reverse:(BOOL)reverse - start:(NSInteger)start - count:(NSInteger)count; - -@end - -@interface GetTableStructureRequest : NSObject - -@property(nonatomic, assign, readonly) NSInteger databaseId; -@property(nonatomic, copy, readonly) NSString* table; - -- (instancetype)initWithDatabaseId:(NSInteger)databaseId table:(NSString*)table; - -@end - -@interface GetTableInfoRequest : NSObject - -@property(nonatomic, assign, readonly) NSInteger databaseId; -@property(nonatomic, copy, readonly) NSString* table; - -- (instancetype)initWithDatabaseId:(NSInteger)databaseId table:(NSString*)table; - -@end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.mm b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m similarity index 52% rename from iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.mm rename to iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m index 7447aa551f7..5bebe3bfc49 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.mm +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m @@ -11,7 +11,11 @@ #import #include #import "DatabaseDescriptor.h" +#import "DatabaseDescriptorHolder.h" #import "DatabaseDriver.h" +#import "DatabaseErrorCodes.h" +#import "DatabaseGetTableStructure.h" +#import "ObjectMapper.h" @interface DatabasesManager () @@ -73,7 +77,7 @@ - (void)listenForCommands { } } - NSDictionary* result = [DatabasesManager + NSDictionary* result = [ObjectMapper databaseListToDictionary:self.databaseDescriptorHolderSet]; [responder success:result]; }]; @@ -89,7 +93,7 @@ - (void)listenForCommands { }]; [self.connection - receive:@"getTableInfo" + receive:@"getTableStructure" withBlock:^(NSDictionary* params, id responder){ }]; @@ -99,107 +103,4 @@ - (void)listenForCommands { }]; } -+ (NSDictionary*)databaseListToDictionary: - (NSSet*)databaseDescriptorHolderSet { - NSMutableDictionary* resultDict = [NSMutableDictionary new]; - - for (DatabaseDescriptorHolder* descriptorHolder in - databaseDescriptorHolderSet) { - NSArray* tableNameList = [descriptorHolder.databaseDriver - getTableNames:descriptorHolder.databaseDescriptor]; - NSArray* sortedTableNames = - [tableNameList sortedArrayUsingSelector:@selector(compare:)]; - NSString* idString = - [NSString stringWithFormat:@"%ld", descriptorHolder.identifier]; - NSDictionary* databaseDict = @{ - @"id" : idString, - @"name" : descriptorHolder.databaseDescriptor.name, - @"tables" : sortedTableNames - }; - [resultDict setObject:databaseDict forKey:idString]; - } - - return resultDict; -} - -@end - -@implementation DatabaseDescriptorHolder - -- (instancetype)initWithIdentifier:(NSInteger)identifier - databaseDriver:(id)databaseDriver - databaseDescriptor:(id)databaseDescriptor { - self = [super init]; - if (self) { - _identifier = identifier; - _databaseDriver = databaseDriver; - _databaseDescriptor = databaseDescriptor; - } - return self; -} - -@end - -@implementation ExecuteSqlRequest - -- (instancetype)initWithDatabaseId:(NSInteger)databaseId - value:(NSString*)value { - self = [super init]; - if (self) { - _databaseId = databaseId; - _value = [value copy]; - } - return self; -} - -@end - -@implementation GetTableDataRequest - -- (instancetype)initWithDatabaseId:(NSInteger)databaseId - table:(NSString*)table - order:(NSString*)order - reverse:(BOOL)reverse - start:(NSInteger)start - count:(NSInteger)count { - self = [super init]; - if (self) { - _databaseId = databaseId; - _table = [table copy]; - _order = [order copy]; - _reverse = reverse; - _start = start; - _count = count; - } - return self; -} - -@end - -@implementation GetTableStructureRequest - -- (instancetype)initWithDatabaseId:(NSInteger)databaseId - table:(NSString*)table { - self = [super init]; - if (self) { - _databaseId = databaseId; - _table = [table copy]; - } - return self; -} - -@end - -@implementation GetTableInfoRequest - -- (instancetype)initWithDatabaseId:(NSInteger)databaseId - table:(NSString*)table { - self = [super init]; - if (self) { - _databaseId = databaseId; - _table = [table copy]; - } - return self; -} - @end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.mm b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.m similarity index 100% rename from iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.mm rename to iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.m diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.h new file mode 100644 index 00000000000..a67d7761184 --- /dev/null +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.h @@ -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. + */ + +#import + +@class DatabaseDescriptorHolder; +@class DatabaseExecuteSqlResponse; +@class DatabaseGetTableDataResponse; +@class DatabaseGetTableInfoResponse; +@class DatabaseGetTableStructureResponse; + +@interface ObjectMapper : NSObject + ++ (NSDictionary*)databaseListToDictionary: + (NSMutableSet*)databaseDescriptorHolderSet; ++ (NSDictionary*)databaseGetTableDataResponseToDictionary: + (DatabaseGetTableDataResponse*)response; ++ (NSDictionary*)databaseGetTableStructureResponseToDictionary: + (DatabaseGetTableStructureResponse*)response; ++ (NSDictionary*)databaseGetTableInfoResponseToDictionary: + (DatabaseGetTableInfoResponse*)response; ++ (NSDictionary*)databaseExecuteSqlResponseToDictionary: + (DatabaseExecuteSqlResponse*)response; ++ (NSDictionary*)errorWithCode:(NSInteger)code message:(NSString*)message; + +@end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m new file mode 100644 index 00000000000..fd9d080a039 --- /dev/null +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m @@ -0,0 +1,63 @@ +/* + * 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. + */ + +#import "ObjectMapper.h" +#include +#import "DatabaseDescriptorHolder.h" +#import "DatabaseExecuteSql.h" +#import "DatabaseGetTableData.h" +#import "DatabaseGetTableInfo.h" +#import "DatabaseGetTableStructure.h" + +@implementation ObjectMapper + ++ (NSDictionary*)databaseListToDictionary: + (NSMutableSet*)databaseDescriptorHolderSet { + NSMutableDictionary* result = [NSMutableDictionary new]; + + for (DatabaseDescriptorHolder* holder in databaseDescriptorHolderSet) { + NSArray* tables = + [holder.databaseDriver getTableNames:holder.databaseDescriptor]; + NSArray* sortedTableNames = + [tables sortedArrayUsingSelector:@selector(compare:)]; + NSString* idString = [NSString stringWithFormat:@"%ld", holder.identifier]; + NSDictionary* databaseInfo = @{ + @"id" : idString, + @"name" : holder.databaseDescriptor.name, + @"tables" : sortedTableNames + }; + [result setObject:databaseInfo forKey:idString]; + } + + return result; +} + ++ (NSDictionary*)databaseGetTableDataResponseToDictionary: + (DatabaseGetTableDataResponse*)response { + return @{}; +} + ++ (NSDictionary*)errorWithCode:(NSInteger)code message:(NSString*)message { + return @{@"code" : @(code), @"message" : message}; +} + ++ (NSDictionary*)databaseGetTableStructureResponseToDictionary: + (DatabaseGetTableStructureResponse*)response { + return @{}; +} + ++ (NSDictionary*)databaseGetTableInfoResponseToDictionary: + (DatabaseGetTableInfoResponse*)response { + return @{}; +} + ++ (NSDictionary*)databaseExecuteSqlResponseToDictionary: + (DatabaseExecuteSqlResponse*)response { + return @{}; +} + +@end From 453b8f7b96e6d3e5e35bd1f3e14c8592bc84f9b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=BAlvio=20Abrah=C3=A3o=20de=20Paula?= Date: Mon, 14 Aug 2023 11:07:07 -0700 Subject: [PATCH 22/98] Implement getTableStructure command. Reviewed By: lblasa Differential Revision: D48191484 fbshipit-source-id: 6838590f4e10b4613074e9e9d112a62d4688f739 --- .../Commands/DatabaseGetTableStructure.h | 2 + .../Commands/DatabaseGetTableStructure.m | 11 +++++ .../DatabaseDriver.h | 10 ++-- .../DatabasesManager.m | 45 +++++++++++++++-- .../{ => Mock}/MockDatabaseDescriptor.h | 0 .../{ => Mock}/MockDatabaseDescriptor.m | 0 .../{ => Mock}/MockDatabaseDriver.h | 0 .../Mock/MockDatabaseDriver.m | 49 +++++++++++++++++++ .../MockDatabaseDriver.m | 26 ---------- .../FlipperKitDatabasesPlugin/ObjectMapper.h | 2 +- .../FlipperKitDatabasesPlugin/ObjectMapper.m | 14 ++++-- 11 files changed, 121 insertions(+), 38 deletions(-) rename iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/{ => Mock}/MockDatabaseDescriptor.h (100%) rename iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/{ => Mock}/MockDatabaseDescriptor.m (100%) rename iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/{ => Mock}/MockDatabaseDriver.h (100%) create mode 100644 iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDriver.m delete mode 100644 iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/MockDatabaseDriver.m diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableStructure.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableStructure.h index 6d2335d9fef..82309b1c55a 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableStructure.h +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableStructure.h @@ -30,5 +30,7 @@ @property(nonatomic, copy, readonly) NSString* table; - (instancetype)initWithDatabaseId:(NSInteger)databaseId table:(NSString*)table; ++ (DatabaseGetTableStructureRequest*)getTableStructureRequestFromDictionary: + (NSDictionary*)dictionary; @end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableStructure.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableStructure.m index 6e24cfaf291..715b616a0d5 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableStructure.m +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableStructure.m @@ -38,4 +38,15 @@ - (instancetype)initWithDatabaseId:(NSInteger)databaseId return self; } ++ (DatabaseGetTableStructureRequest*)getTableStructureRequestFromDictionary: + (NSDictionary*)params { + int databaseId = [params[@"databaseId"] integerValue]; + NSString* table = params[@"table"]; + if (databaseId <= 0 || !table) { + return nil; + } + return [[DatabaseGetTableStructureRequest alloc] initWithDatabaseId:databaseId + table:table]; +} + @end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDriver.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDriver.h index 873d5f6bf64..929ed29a248 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDriver.h +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDriver.h @@ -8,12 +8,14 @@ #import @protocol DatabaseDescriptor; +@class DatabaseGetTableStructureRequest; +@class DatabaseGetTableStructureResponse; @protocol DatabaseDriver -@property(nonatomic, strong, readonly) id - databaseDescriptor; - - (NSArray>*)getDatabases; - (NSArray*)getTableNames:(id)databaseDescriptor; - +- (DatabaseGetTableStructureResponse*) + getTableStructureWithDatabaseDescriptor: + (id)databaseDescriptor + forTable:(NSString*)tableName; @end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m index 5bebe3bfc49..13a11b53bcf 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m @@ -77,19 +77,58 @@ - (void)listenForCommands { } } - NSDictionary* result = [ObjectMapper - databaseListToDictionary:self.databaseDescriptorHolderSet]; + id result = [ObjectMapper + databaseListToFlipperArray:self.databaseDescriptorHolderSet]; [responder success:result]; }]; [self.connection receive:@"getTableData" withBlock:^(NSDictionary* params, id responder){ + }]; [self.connection receive:@"getTableStructure" - withBlock:^(NSDictionary* params, id responder){ + withBlock:^(NSDictionary* params, id responder) { + DatabaseGetTableStructureRequest* request = + [DatabaseGetTableStructureRequest + getTableStructureRequestFromDictionary:params]; + + if (!request) { + NSDictionary* errorResponse = [ObjectMapper + errorWithCode:DatabasesErrorCodesInvalidRequest + message:kDatabasesErrorCodesInvalidRequestMessage]; + [responder error:errorResponse]; + return; + } + + DatabaseDescriptorHolder* descriptorHolder = + self.databaseDescriptorHolders[@(request.databaseId)]; + if (!descriptorHolder) { + NSDictionary* errorResponse = [ObjectMapper + errorWithCode:DatabasesErrorCodesDatabaseInvalid + message:kDatabasesErrorCodesDatabaseInvalidMessage]; + [responder error:errorResponse]; + return; + } + + @try { + DatabaseGetTableStructureResponse* tableStructure = + [descriptorHolder.databaseDriver + getTableStructureWithDatabaseDescriptor: + descriptorHolder.databaseDescriptor + forTable:request.table]; + NSDictionary* response = [ObjectMapper + databaseGetTableStructureResponseToDictionary:tableStructure]; + [responder success:response]; + } @catch (NSException* exception) { + NSDictionary* errorResponse = [ObjectMapper + errorWithCode:DatabasesErrorCodesSqlExecutionException + message:[kDatabasesErrorCodesSqlExecutionExceptionMessage + stringByAppendingString:exception.reason]]; + [responder error:errorResponse]; + } }]; [self.connection diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/MockDatabaseDescriptor.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDescriptor.h similarity index 100% rename from iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/MockDatabaseDescriptor.h rename to iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDescriptor.h diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/MockDatabaseDescriptor.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDescriptor.m similarity index 100% rename from iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/MockDatabaseDescriptor.m rename to iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDescriptor.m diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/MockDatabaseDriver.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDriver.h similarity index 100% rename from iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/MockDatabaseDriver.h rename to iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDriver.h diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDriver.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDriver.m new file mode 100644 index 00000000000..3d8fb69aef6 --- /dev/null +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDriver.m @@ -0,0 +1,49 @@ +/* + * 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. + */ + +#import "MockDatabaseDriver.h" +#import "DatabaseGetTableStructure.h" +#import "MockDatabaseDescriptor.h" + +@implementation MockDatabaseDriver + +- (NSArray>*)getDatabases { + MockDatabaseDescriptor* mockDescriptor = + [[MockDatabaseDescriptor alloc] init]; + return @[ mockDescriptor ]; +} + +- (NSArray*)getTableNames: + (id)databaseDescriptor { + return @[ @"MockTable1", @"MockTable2" ]; +} + +- (DatabaseGetTableStructureResponse*) + getTableStructureWithDatabaseDescriptor: + (id)databaseDescriptor + forTable:(NSString*)tableName { + NSMutableArray* structureColumns = + [NSMutableArray arrayWithObjects:@"id", @"name", @"age", nil]; + NSMutableArray*>* structureValues = + [NSMutableArray arrayWithObjects:@[ @"1", @"John", @"25" ], + @[ @"2", @"Jane", @"30" ], + nil]; + NSMutableArray* indexesColumns = [NSMutableArray + arrayWithObjects:@"index_name", @"unique", @"indexed_column_name", nil]; + NSMutableArray*>* indexesValues = [NSMutableArray + arrayWithObjects:@[ @"index_name1", @"false", @"id,name" ], + @[ @"index_name2", @"true", @"age" ], + nil]; + + return [[DatabaseGetTableStructureResponse alloc] + initWithStructureColumns:[structureColumns copy] + structureValues:[structureValues copy] + indexesColumns:[indexesColumns copy] + indexesValues:[indexesValues copy]]; +} + +@end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/MockDatabaseDriver.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/MockDatabaseDriver.m deleted file mode 100644 index d8b8ae32489..00000000000 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/MockDatabaseDriver.m +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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. - */ - -#import "MockDatabaseDriver.h" -#import "MockDatabaseDescriptor.h" - -@implementation MockDatabaseDriver - -- (NSArray>*)getDatabases { - MockDatabaseDescriptor* mockDescriptor = - [[MockDatabaseDescriptor alloc] init]; - return @[ mockDescriptor ]; -} - -- (NSArray*)getTableNames: - (id)databaseDescriptor { - return @[ @"MockTable1", @"MockTable2" ]; -} - -@synthesize databaseDescriptor; - -@end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.h index a67d7761184..5e083986dea 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.h +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.h @@ -15,7 +15,7 @@ @interface ObjectMapper : NSObject -+ (NSDictionary*)databaseListToDictionary: ++ (NSMutableArray*)databaseListToFlipperArray: (NSMutableSet*)databaseDescriptorHolderSet; + (NSDictionary*)databaseGetTableDataResponseToDictionary: (DatabaseGetTableDataResponse*)response; diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m index fd9d080a039..f63c8f99ea4 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m @@ -15,9 +15,9 @@ @implementation ObjectMapper -+ (NSDictionary*)databaseListToDictionary: ++ (NSMutableArray*)databaseListToFlipperArray: (NSMutableSet*)databaseDescriptorHolderSet { - NSMutableDictionary* result = [NSMutableDictionary new]; + NSMutableArray* result = [NSMutableArray new]; for (DatabaseDescriptorHolder* holder in databaseDescriptorHolderSet) { NSArray* tables = @@ -25,12 +25,13 @@ + (NSDictionary*)databaseListToDictionary: NSArray* sortedTableNames = [tables sortedArrayUsingSelector:@selector(compare:)]; NSString* idString = [NSString stringWithFormat:@"%ld", holder.identifier]; + NSDictionary* databaseInfo = @{ @"id" : idString, @"name" : holder.databaseDescriptor.name, @"tables" : sortedTableNames }; - [result setObject:databaseInfo forKey:idString]; + [result addObject:databaseInfo]; } return result; @@ -47,7 +48,12 @@ + (NSDictionary*)errorWithCode:(NSInteger)code message:(NSString*)message { + (NSDictionary*)databaseGetTableStructureResponseToDictionary: (DatabaseGetTableStructureResponse*)response { - return @{}; + return @{ + @"structureColumns" : response.structureColumns, + @"structureValues" : response.structureValues, + @"indexesColumns" : response.indexesColumns, + @"indexesValues" : response.indexesValues + }; } + (NSDictionary*)databaseGetTableInfoResponseToDictionary: From a0510ad1bf50c9e741c550c3f57afc7d4b0f2d5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=BAlvio=20Abrah=C3=A3o=20de=20Paula?= Date: Mon, 14 Aug 2023 11:07:07 -0700 Subject: [PATCH 23/98] Implement getTableInfo command. Reviewed By: lblasa Differential Revision: D48266744 fbshipit-source-id: 79f2fd3c4718d6bf7be4a0538ec0d1eb92503eb7 --- .../Commands/DatabaseGetTableInfo.h | 2 + .../Commands/DatabaseGetTableInfo.m | 12 ++++++ .../DatabaseDriver.h | 6 ++- .../DatabasesManager.m | 40 ++++++++++++++++++- .../Mock/MockDatabaseDriver.m | 9 +++++ .../FlipperKitDatabasesPlugin/ObjectMapper.m | 4 +- 6 files changed, 69 insertions(+), 4 deletions(-) diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableInfo.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableInfo.h index 2163854a5fa..9103c40be24 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableInfo.h +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableInfo.h @@ -21,5 +21,7 @@ @property(nonatomic, copy, readonly) NSString* table; - (instancetype)initWithDatabaseId:(NSInteger)databaseId table:(NSString*)table; ++ (DatabaseGetTableInfoRequest*)getTableInfoRequestFromDictionary: + (NSDictionary*)dictionary; @end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableInfo.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableInfo.m index b86fd8b7f87..e7e7b962982 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableInfo.m +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableInfo.m @@ -31,4 +31,16 @@ - (instancetype)initWithDatabaseId:(NSInteger)databaseId return self; } ++ (DatabaseGetTableInfoRequest*)getTableInfoRequestFromDictionary: + (NSDictionary*)dictionary { + NSNumber* databaseId = @([dictionary[@"databaseId"] integerValue]); + NSString* table = dictionary[@"table"]; + if (databaseId == nil || table == nil) { + return nil; + } + return [[DatabaseGetTableInfoRequest alloc] + initWithDatabaseId:databaseId.intValue + table:table]; +} + @end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDriver.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDriver.h index 929ed29a248..a275162d010 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDriver.h +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDriver.h @@ -8,7 +8,7 @@ #import @protocol DatabaseDescriptor; -@class DatabaseGetTableStructureRequest; +@class DatabaseGetTableInfoResponse; @class DatabaseGetTableStructureResponse; @protocol DatabaseDriver @@ -18,4 +18,8 @@ getTableStructureWithDatabaseDescriptor: (id)databaseDescriptor forTable:(NSString*)tableName; +- (DatabaseGetTableInfoResponse*) + getTableInfoWithDatabaseDescriptor: + (id)databaseDescriptor + forTable:(NSString*)tableName; @end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m index 13a11b53bcf..9cfd0f1c6c9 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m @@ -14,6 +14,7 @@ #import "DatabaseDescriptorHolder.h" #import "DatabaseDriver.h" #import "DatabaseErrorCodes.h" +#import "DatabaseGetTableInfo.h" #import "DatabaseGetTableStructure.h" #import "ObjectMapper.h" @@ -132,8 +133,43 @@ - (void)listenForCommands { }]; [self.connection - receive:@"getTableStructure" - withBlock:^(NSDictionary* params, id responder){ + receive:@"getTableInfo" + withBlock:^(NSDictionary* params, id responder) { + DatabaseGetTableInfoRequest* request = [DatabaseGetTableInfoRequest + getTableInfoRequestFromDictionary:params]; + if (!request) { + NSDictionary* errorResponse = [ObjectMapper + errorWithCode:DatabasesErrorCodesInvalidRequest + message:kDatabasesErrorCodesInvalidRequestMessage]; + [responder error:errorResponse]; + return; + } + DatabaseDescriptorHolder* descriptorHolder = + self.databaseDescriptorHolders[@(request.databaseId)]; + if (!descriptorHolder) { + NSDictionary* errorResponse = [ObjectMapper + errorWithCode:DatabasesErrorCodesDatabaseInvalid + message:kDatabasesErrorCodesDatabaseInvalidMessage]; + [responder error:errorResponse]; + return; + } + + @try { + DatabaseGetTableInfoResponse* tableInfo = + [descriptorHolder.databaseDriver + getTableInfoWithDatabaseDescriptor:descriptorHolder + .databaseDescriptor + forTable:request.table]; + NSDictionary* response = + [ObjectMapper databaseGetTableInfoResponseToDictionary:tableInfo]; + [responder success:response]; + } @catch (NSException* exception) { + NSDictionary* errorResponse = [ObjectMapper + errorWithCode:DatabasesErrorCodesSqlExecutionException + message:[kDatabasesErrorCodesSqlExecutionExceptionMessage + stringByAppendingString:exception.reason]]; + [responder error:errorResponse]; + } }]; [self.connection diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDriver.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDriver.m index 3d8fb69aef6..7124098887b 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDriver.m +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDriver.m @@ -6,6 +6,7 @@ */ #import "MockDatabaseDriver.h" +#import "DatabaseGetTableInfo.h" #import "DatabaseGetTableStructure.h" #import "MockDatabaseDescriptor.h" @@ -46,4 +47,12 @@ @implementation MockDatabaseDriver indexesValues:[indexesValues copy]]; } +- (DatabaseGetTableInfoResponse*) + getTableInfoWithDatabaseDescriptor: + (id)databaseDescriptor + forTable:(NSString*)tableName { + return [[DatabaseGetTableInfoResponse alloc] + initWithDefinition:@"This is mocked table definition"]; +} + @end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m index f63c8f99ea4..faf30e24b2e 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m @@ -58,7 +58,9 @@ + (NSDictionary*)databaseGetTableStructureResponseToDictionary: + (NSDictionary*)databaseGetTableInfoResponseToDictionary: (DatabaseGetTableInfoResponse*)response { - return @{}; + return @{ + @"definition" : response.definition, + }; } + (NSDictionary*)databaseExecuteSqlResponseToDictionary: From 42fb6f09f79011f31fac8d8d17b1f9efb4ec401e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=BAlvio=20Abrah=C3=A3o=20de=20Paula?= Date: Mon, 14 Aug 2023 11:07:07 -0700 Subject: [PATCH 24/98] Implement getTableData command. Reviewed By: lblasa Differential Revision: D48267029 fbshipit-source-id: a2ee02d3d0c465c83acd99fd7093e0abb5c7c2de --- .../Commands/DatabaseGetTableData.h | 3 + .../Commands/DatabaseGetTableData.m | 19 ++++ .../DatabaseDriver.h | 12 ++- .../DatabasesManager.m | 41 ++++++++- .../Mock/MockDatabaseDriver.m | 25 ++++++ .../FlipperKitDatabasesPlugin/ObjectMapper.m | 88 ++++++++++++++++++- 6 files changed, 185 insertions(+), 3 deletions(-) diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableData.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableData.h index 2cc3f850b86..e8417befd53 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableData.h +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableData.h @@ -39,4 +39,7 @@ start:(NSInteger)start count:(NSInteger)count; ++ (DatabaseGetTableDataRequest*)getTableDataRequestFromDictionary: + (NSDictionary*)dictionary; + @end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableData.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableData.m index 632142a018d..d5666614fd5 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableData.m +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseGetTableData.m @@ -47,4 +47,23 @@ - (instancetype)initWithDatabaseId:(NSInteger)databaseId return self; } ++ (DatabaseGetTableDataRequest*)getTableDataRequestFromDictionary: + (NSDictionary*)dictionary { + NSInteger databaseId = [dictionary[@"databaseId"] integerValue]; + NSString* table = dictionary[@"table"]; + NSString* order = dictionary[@"order"]; + BOOL reverse = [dictionary[@"reverse"] boolValue]; + NSInteger start = [dictionary[@"start"] integerValue]; + NSInteger count = [dictionary[@"count"] integerValue]; + if (databaseId <= 0 || table.length == 0) { + return nil; + } + return [[DatabaseGetTableDataRequest alloc] initWithDatabaseId:databaseId + table:table + order:order + reverse:reverse + start:start + count:count]; +} + @end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDriver.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDriver.h index a275162d010..0d227761ec6 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDriver.h +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDriver.h @@ -8,8 +8,9 @@ #import @protocol DatabaseDescriptor; -@class DatabaseGetTableInfoResponse; @class DatabaseGetTableStructureResponse; +@class DatabaseGetTableInfoResponse; +@class DatabaseGetTableDataResponse; @protocol DatabaseDriver - (NSArray>*)getDatabases; @@ -22,4 +23,13 @@ getTableInfoWithDatabaseDescriptor: (id)databaseDescriptor forTable:(NSString*)tableName; + +- (DatabaseGetTableDataResponse*) + getTableDataWithDatabaseDescriptor: + (id)databaseDescriptor + forTable:(NSString*)tableName + order:(NSString*)order + reverse:(BOOL)reverse + start:(NSInteger)start + count:(NSInteger)count; @end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m index 9cfd0f1c6c9..0fbc0f4ffe0 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m @@ -14,6 +14,7 @@ #import "DatabaseDescriptorHolder.h" #import "DatabaseDriver.h" #import "DatabaseErrorCodes.h" +#import "DatabaseGetTableData.h" #import "DatabaseGetTableInfo.h" #import "DatabaseGetTableStructure.h" #import "ObjectMapper.h" @@ -85,8 +86,46 @@ - (void)listenForCommands { [self.connection receive:@"getTableData" - withBlock:^(NSDictionary* params, id responder){ + withBlock:^(NSDictionary* params, id responder) { + DatabaseGetTableDataRequest* request = [DatabaseGetTableDataRequest + getTableDataRequestFromDictionary:params]; + if (!request) { + NSDictionary* errorResponse = [ObjectMapper + errorWithCode:DatabasesErrorCodesInvalidRequest + message:kDatabasesErrorCodesInvalidRequestMessage]; + [responder error:errorResponse]; + return; + } + DatabaseDescriptorHolder* descriptorHolder = + self.databaseDescriptorHolders[@(request.databaseId)]; + if (!descriptorHolder) { + NSDictionary* errorResponse = [ObjectMapper + errorWithCode:DatabasesErrorCodesDatabaseInvalid + message:kDatabasesErrorCodesDatabaseInvalidMessage]; + [responder error:errorResponse]; + return; + } + @try { + DatabaseGetTableDataResponse* tableDataResponse = + [descriptorHolder.databaseDriver + getTableDataWithDatabaseDescriptor:descriptorHolder + .databaseDescriptor + forTable:request.table + order:request.order + reverse:request.reverse + start:request.start + count:request.count]; + NSDictionary* response = [ObjectMapper + databaseGetTableDataResponseToDictionary:tableDataResponse]; + [responder success:response]; + } @catch (NSException* exception) { + NSDictionary* errorResponse = [ObjectMapper + errorWithCode:DatabasesErrorCodesSqlExecutionException + message:[kDatabasesErrorCodesSqlExecutionExceptionMessage + stringByAppendingString:exception.reason]]; + [responder error:errorResponse]; + } }]; [self.connection diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDriver.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDriver.m index 7124098887b..0f7563b8e58 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDriver.m +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDriver.m @@ -6,6 +6,7 @@ */ #import "MockDatabaseDriver.h" +#import "DatabaseGetTableData.h" #import "DatabaseGetTableInfo.h" #import "DatabaseGetTableStructure.h" #import "MockDatabaseDescriptor.h" @@ -55,4 +56,28 @@ @implementation MockDatabaseDriver initWithDefinition:@"This is mocked table definition"]; } +- (DatabaseGetTableDataResponse*) + getTableDataWithDatabaseDescriptor: + (id)databaseDescriptor + forTable:(NSString*)tableName + order:(NSString*)order + reverse:(BOOL)reverse + start:(NSInteger)start + count:(NSInteger)count { + NSMutableArray* columns = [NSMutableArray array]; + NSMutableArray* values = [NSMutableArray array]; + for (int i = 0; i < 100; i++) { + NSString* columnName = [NSString stringWithFormat:@"column%d", i + 1]; + [columns addObject:columnName]; + NSArray* valueRow = @[ @"value1", @"value2", @"value3" ]; + [values addObject:valueRow]; + } + + return [[DatabaseGetTableDataResponse alloc] initWithColumns:[columns copy] + values:[values copy] + start:0 + count:100 + total:100]; +} + @end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m index faf30e24b2e..16e007f4e5a 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m @@ -15,6 +15,9 @@ @implementation ObjectMapper +static const int MAX_BLOB_LENGTH = 100 * 1024; +static NSString* const UNKNOWN_BLOB_LABEL_FORMAT = @"{%d-byte %@ blob}"; + + (NSMutableArray*)databaseListToFlipperArray: (NSMutableSet*)databaseDescriptorHolderSet { NSMutableArray* result = [NSMutableArray new]; @@ -39,7 +42,22 @@ + (NSMutableArray*)databaseListToFlipperArray: + (NSDictionary*)databaseGetTableDataResponseToDictionary: (DatabaseGetTableDataResponse*)response { - return @{}; + NSMutableArray* rows = [NSMutableArray array]; + for (NSArray* row in response.values) { + NSMutableArray* rowValues = [NSMutableArray array]; + for (id item in row) { + [rowValues addObject:[self objectAndTypeToFlipperObject:item]]; + } + [rows addObject:rowValues]; + } + + return @{ + @"columns" : response.columns, + @"values" : rows, + @"start" : @(response.start), + @"count" : @(response.count), + @"total" : @(response.total) + }; } + (NSDictionary*)errorWithCode:(NSInteger)code message:(NSString*)message { @@ -68,4 +86,72 @@ + (NSDictionary*)databaseExecuteSqlResponseToDictionary: return @{}; } ++ (NSDictionary*)objectAndTypeToFlipperObject:(id)object { + if (!object) { + return @{@"type" : @"null"}; + } else if ([object isKindOfClass:[NSNumber class]]) { + NSNumber* number = (NSNumber*)object; + NSString* type = [NSString stringWithCString:[number objCType]]; + + if ([type isEqualToString:@"i"]) { + return @{@"type" : @"integer", @"value" : number}; + } else if ([type isEqualToString:@"f"] || [type isEqualToString:@"d"]) { + return @{@"type" : @"float", @"value" : number}; + } else if ([type isEqualToString:@"B"]) { + return @{@"type" : @"boolean", @"value" : number}; + } else { + return @{@"type" : @"integer", @"value" : @([number integerValue])}; + } + + return @{@"type" : @"integer", @"value" : object}; + } else if ([object isKindOfClass:[NSDecimalNumber class]]) { + return @{@"type" : @"float", @"value" : object}; + } else if ([object isKindOfClass:[NSString class]]) { + return @{@"type" : @"string", @"value" : object}; + } else if ([object isKindOfClass:[NSData class]]) { + NSString* blobString = [self blobToString:(NSData*)object]; + return @{@"type" : @"blob", @"value" : blobString}; + } else if ([object isKindOfClass:[NSValue class]]) { + return @{@"type" : @"boolean", @"value" : object}; + } else { + @throw [NSException exceptionWithName:@"InvalidArgumentException" + reason:@"type of Object is invalid" + userInfo:nil]; + } +} + ++ (NSString*)blobToString:(NSData*)data { + const uint8_t* bytes = data.bytes; + uint length = data.length; + + if (length <= MAX_BLOB_LENGTH) { + if ([self fastIsAscii:bytes length:length]) { + NSStringEncoding encoding = NSASCIIStringEncoding; + return [[NSString alloc] initWithBytesNoCopy:(void*)bytes + length:length + encoding:encoding + freeWhenDone:NO]; + } else { + // try UTF-8 + NSStringEncoding encoding = NSUTF8StringEncoding; + return [[NSString alloc] initWithBytesNoCopy:(void*)bytes + length:length + encoding:encoding + freeWhenDone:NO]; + } + } + return + [NSString stringWithFormat:UNKNOWN_BLOB_LABEL_FORMAT, length, @"binary"]; +} + ++ (BOOL)fastIsAscii:(const uint8_t*)bytes length:(NSUInteger)length { + for (int i = 0; i < length; i++) { + uint8_t b = bytes[i]; + if ((b & ~0x7f) != 0) { + return NO; + } + } + return YES; +} + @end From 7ba548d6e7753ae9701dbb845c7b5f88c934c192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=BAlvio=20Abrah=C3=A3o=20de=20Paula?= Date: Mon, 14 Aug 2023 11:07:07 -0700 Subject: [PATCH 25/98] Implement executeSql command. Reviewed By: lblasa Differential Revision: D48310925 fbshipit-source-id: 136b7f09a3a1b886111b6e3cb0e377b73b126e59 --- .../Commands/DatabaseExecuteSql.h | 9 +++++ .../Commands/DatabaseExecuteSql.m | 12 +++++++ .../DatabaseDriver.h | 2 ++ .../DatabasesManager.m | 34 +++++++++++++++++- .../Mock/MockDatabaseDriver.m | 36 +++++++++++++++++++ .../FlipperKitDatabasesPlugin/ObjectMapper.m | 24 ++++++++++++- 6 files changed, 115 insertions(+), 2 deletions(-) diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseExecuteSql.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseExecuteSql.h index 9d1e1eb0268..d1b80c4e54d 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseExecuteSql.h +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseExecuteSql.h @@ -6,6 +6,7 @@ */ #import +#include @interface DatabaseExecuteSqlResponse : NSObject @@ -15,6 +16,12 @@ @property(nonatomic, strong) NSNumber* insertedId; @property(nonatomic, assign) NSInteger affectedCount; +- (instancetype)initWithType:(NSString*)type + columns:(NSArray*)columns + values:(NSArray*)values + insertedId:(NSNumber*)insertedId + affectedCount:(NSInteger)affectedCount; + @end @interface DatabaseExecuteSqlRequest : NSObject @@ -23,5 +30,7 @@ @property(nonatomic, copy, readonly) NSString* value; - (instancetype)initWithDatabaseId:(NSInteger)databaseId value:(NSString*)value; ++ (DatabaseExecuteSqlRequest*)getExecuteSqlRequestFromDictionary: + (NSDictionary*)dictionary; @end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseExecuteSql.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseExecuteSql.m index 96494e8d51f..a63981717a4 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseExecuteSql.m +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Commands/DatabaseExecuteSql.m @@ -6,6 +6,7 @@ */ #include "DatabaseExecuteSql.h" +#include @implementation DatabaseExecuteSqlResponse @@ -39,4 +40,15 @@ - (instancetype)initWithDatabaseId:(NSInteger)databaseId return self; } ++ (DatabaseExecuteSqlRequest*)getExecuteSqlRequestFromDictionary: + (NSDictionary*)dictionary { + NSInteger databaseId = [dictionary[@"databaseId"] integerValue]; + NSString* value = dictionary[@"value"]; + if (databaseId <= 0 || value.length == 0) { + return nil; + } + return [[DatabaseExecuteSqlRequest alloc] initWithDatabaseId:databaseId + value:value]; +} + @end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDriver.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDriver.h index 0d227761ec6..140ba33872a 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDriver.h +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDriver.h @@ -11,6 +11,7 @@ @class DatabaseGetTableStructureResponse; @class DatabaseGetTableInfoResponse; @class DatabaseGetTableDataResponse; +@class DatabaseExecuteSqlResponse; @protocol DatabaseDriver - (NSArray>*)getDatabases; @@ -32,4 +33,5 @@ reverse:(BOOL)reverse start:(NSInteger)start count:(NSInteger)count; +- (DatabaseExecuteSqlResponse*)executeSQL:(NSString*)sql; @end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m index 0fbc0f4ffe0..939969251da 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m @@ -14,6 +14,7 @@ #import "DatabaseDescriptorHolder.h" #import "DatabaseDriver.h" #import "DatabaseErrorCodes.h" +#import "DatabaseExecuteSql.h" #import "DatabaseGetTableData.h" #import "DatabaseGetTableInfo.h" #import "DatabaseGetTableStructure.h" @@ -213,7 +214,38 @@ - (void)listenForCommands { [self.connection receive:@"execute" - withBlock:^(NSDictionary* params, id responder){ + withBlock:^(NSDictionary* params, id responder) { + DatabaseExecuteSqlRequest* request = [DatabaseExecuteSqlRequest + getExecuteSqlRequestFromDictionary:params]; + if (!request) { + NSDictionary* errorResponse = [ObjectMapper + errorWithCode:DatabasesErrorCodesInvalidRequest + message:kDatabasesErrorCodesInvalidRequestMessage]; + [responder error:errorResponse]; + return; + } + DatabaseDescriptorHolder* descriptorHolder = + self.databaseDescriptorHolders[@(request.databaseId)]; + if (!descriptorHolder) { + NSDictionary* errorResponse = [ObjectMapper + errorWithCode:DatabasesErrorCodesDatabaseInvalid + message:kDatabasesErrorCodesDatabaseInvalidMessage]; + [responder error:errorResponse]; + return; + } + @try { + DatabaseExecuteSqlResponse* sqlResponse = + [descriptorHolder.databaseDriver executeSQL:request.value]; + NSDictionary* response = + [ObjectMapper databaseExecuteSqlResponseToDictionary:sqlResponse]; + [responder success:response]; + } @catch (NSException* exception) { + NSDictionary* errorResponse = [ObjectMapper + errorWithCode:DatabasesErrorCodesSqlExecutionException + message:[kDatabasesErrorCodesSqlExecutionExceptionMessage + stringByAppendingString:exception.reason]]; + [responder error:errorResponse]; + } }]; } diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDriver.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDriver.m index 0f7563b8e58..8a153059fa3 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDriver.m +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDriver.m @@ -6,6 +6,7 @@ */ #import "MockDatabaseDriver.h" +#import "DatabaseExecuteSql.h" #import "DatabaseGetTableData.h" #import "DatabaseGetTableInfo.h" #import "DatabaseGetTableStructure.h" @@ -80,4 +81,39 @@ @implementation MockDatabaseDriver total:100]; } +- (DatabaseExecuteSqlResponse*)executeSQL:(NSString*)sql { + // Generate a mock response with a random type + NSString* type; + NSArray* columns = @[ @"id", @"name" ]; + NSMutableArray* values = [NSMutableArray array]; + for (int i = 0; i < 100; i++) { + [values addObject:@[ @(i), [NSString stringWithFormat:@"Name %d", i] ]]; + } + + // Randomly select a type + NSArray* types = @[ @"SELECT", @"INSERT", @"UPDATE", @"DELETE" ]; + int index = arc4random_uniform((u_int32_t)types.count); + type = types[index]; + + // Set affectedCount and insertedId based on type + NSInteger affectedCount = 0; + NSNumber* insertedId = nil; + if ([type isEqualToString:@"INSERT"]) { + affectedCount = 1; + insertedId = @(15); + } else if ( + [type isEqualToString:@"UPDATE"] || [type isEqualToString:@"DELETE"]) { + affectedCount = values.count; + } + + DatabaseExecuteSqlResponse* response = + [[DatabaseExecuteSqlResponse alloc] initWithType:type + columns:columns + values:[values copy] + insertedId:insertedId + affectedCount:affectedCount]; + + return response; +} + @end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m index 16e007f4e5a..5b3f134097d 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m @@ -83,7 +83,29 @@ + (NSDictionary*)databaseGetTableInfoResponseToDictionary: + (NSDictionary*)databaseExecuteSqlResponseToDictionary: (DatabaseExecuteSqlResponse*)response { - return @{}; + NSMutableArray* rows = [NSMutableArray array]; + if (response.values) { + for (NSArray* row in response.values) { + NSMutableArray* rowValues = [NSMutableArray array]; + for (id item in row) { + [rowValues addObject:[self objectAndTypeToFlipperObject:item]]; + } + [rows addObject:rowValues]; + } + } + + NSMutableDictionary* result = [NSMutableDictionary dictionaryWithDictionary:@{ + @"type" : response.type, + @"columns" : response.columns, + @"values" : rows, + @"affectedCount" : @(response.affectedCount) + }]; + + if (response.insertedId) { + result[@"insertedId"] = response.insertedId; + } + + return result; } + (NSDictionary*)objectAndTypeToFlipperObject:(id)object { From d9b34e7880e9bf29ff8c9fba55def0a27108527f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=BAlvio=20Abrah=C3=A3o=20de=20Paula?= Date: Mon, 14 Aug 2023 11:07:07 -0700 Subject: [PATCH 26/98] Return right format for databaseGetTableStructureResponseToDictionary method. Reviewed By: lblasa Differential Revision: D48315431 fbshipit-source-id: fc4ca1bc20e691162dfbe61a90a5ab9bf8df2466 --- .../FlipperKitDatabasesPlugin/ObjectMapper.m | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m index 5b3f134097d..14fa42d5b5e 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m @@ -66,11 +66,29 @@ + (NSDictionary*)errorWithCode:(NSInteger)code message:(NSString*)message { + (NSDictionary*)databaseGetTableStructureResponseToDictionary: (DatabaseGetTableStructureResponse*)response { + NSMutableArray* structureValues = [NSMutableArray array]; + for (NSArray* row in response.structureValues) { + NSMutableArray* rowValues = [NSMutableArray array]; + for (id item in row) { + [rowValues addObject:[self objectAndTypeToFlipperObject:item]]; + } + [structureValues addObject:rowValues]; + } + + NSMutableArray* indexesValues = [NSMutableArray array]; + for (NSArray* row in response.indexesValues) { + NSMutableArray* rowValues = [NSMutableArray array]; + for (id item in row) { + [rowValues addObject:[self objectAndTypeToFlipperObject:item]]; + } + [indexesValues addObject:rowValues]; + } + return @{ @"structureColumns" : response.structureColumns, - @"structureValues" : response.structureValues, + @"structureValues" : structureValues, @"indexesColumns" : response.indexesColumns, - @"indexesValues" : response.indexesValues + @"indexesValues" : indexesValues }; } From d102ae263cf3cc7cc4afae135cafcf09235a061b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=BAlvio=20Abrah=C3=A3o=20de=20Paula?= Date: Mon, 14 Aug 2023 11:07:07 -0700 Subject: [PATCH 27/98] Fix mocks to return correct expected results. Reviewed By: lblasa Differential Revision: D48315430 fbshipit-source-id: 3a9210b6c4ce8192ff5489d2616e6a37264309b2 --- .../Mock/MockDatabaseDriver.m | 37 +++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDriver.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDriver.m index 8a153059fa3..a13b601e5b8 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDriver.m +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDriver.m @@ -6,6 +6,8 @@ */ #import "MockDatabaseDriver.h" +#include +#include #import "DatabaseExecuteSql.h" #import "DatabaseGetTableData.h" #import "DatabaseGetTableInfo.h" @@ -67,42 +69,55 @@ @implementation MockDatabaseDriver count:(NSInteger)count { NSMutableArray* columns = [NSMutableArray array]; NSMutableArray* values = [NSMutableArray array]; - for (int i = 0; i < 100; i++) { + NSUInteger numColums = 10; + NSUInteger numRows = 100; + for (int i = 0; i < numColums; i++) { NSString* columnName = [NSString stringWithFormat:@"column%d", i + 1]; [columns addObject:columnName]; - NSArray* valueRow = @[ @"value1", @"value2", @"value3" ]; + } + + for (int i = 0; i < numRows; i++) { + NSMutableArray* valueRow = [NSMutableArray array]; + for (int j = 0; j < numColums; j++) { + [valueRow addObject:[NSString stringWithFormat:@"value%d", j]]; + } [values addObject:valueRow]; } return [[DatabaseGetTableDataResponse alloc] initWithColumns:[columns copy] values:[values copy] start:0 - count:100 - total:100]; + count:numRows + total:numRows]; } - (DatabaseExecuteSqlResponse*)executeSQL:(NSString*)sql { // Generate a mock response with a random type NSString* type; - NSArray* columns = @[ @"id", @"name" ]; + NSArray* columns = @[ @"id", @"name", @"age" ]; NSMutableArray* values = [NSMutableArray array]; - for (int i = 0; i < 100; i++) { - [values addObject:@[ @(i), [NSString stringWithFormat:@"Name %d", i] ]]; + NSUInteger numRows = 100; + for (int i = 0; i < numRows; i++) { + NSUInteger randomAge = arc4random_uniform(40); + [values addObject:@[ + @(i), + [NSString stringWithFormat:@"Name %d", i], + @(randomAge) + ]]; } // Randomly select a type - NSArray* types = @[ @"SELECT", @"INSERT", @"UPDATE", @"DELETE" ]; + NSArray* types = @[ @"select", @"insert", @"update_delete" ]; int index = arc4random_uniform((u_int32_t)types.count); type = types[index]; // Set affectedCount and insertedId based on type NSInteger affectedCount = 0; NSNumber* insertedId = nil; - if ([type isEqualToString:@"INSERT"]) { + if ([type isEqualToString:@"insert"]) { affectedCount = 1; insertedId = @(15); - } else if ( - [type isEqualToString:@"UPDATE"] || [type isEqualToString:@"DELETE"]) { + } else if ([type isEqualToString:@"update_delete"]) { affectedCount = values.count; } From 661ed9eb44aba86a5b3ef86c9f8c68ad179b4b04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=BAlvio=20Abrah=C3=A3o=20de=20Paula?= Date: Mon, 14 Aug 2023 11:07:07 -0700 Subject: [PATCH 28/98] Isolate duplicated code in DatabasesManager. Reviewed By: lblasa Differential Revision: D48316900 fbshipit-source-id: 2ae984f0d6f10b9cb843a74f335c77428d2229ef --- .../DatabasesManager.m | 55 ++++++++----------- 1 file changed, 22 insertions(+), 33 deletions(-) diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m index 939969251da..b97a3cf0553 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m @@ -91,19 +91,13 @@ - (void)listenForCommands { DatabaseGetTableDataRequest* request = [DatabaseGetTableDataRequest getTableDataRequestFromDictionary:params]; if (!request) { - NSDictionary* errorResponse = [ObjectMapper - errorWithCode:DatabasesErrorCodesInvalidRequest - message:kDatabasesErrorCodesInvalidRequestMessage]; - [responder error:errorResponse]; + [DatabasesManager raiseInvalidRequestError:responder]; return; } DatabaseDescriptorHolder* descriptorHolder = self.databaseDescriptorHolders[@(request.databaseId)]; if (!descriptorHolder) { - NSDictionary* errorResponse = [ObjectMapper - errorWithCode:DatabasesErrorCodesDatabaseInvalid - message:kDatabasesErrorCodesDatabaseInvalidMessage]; - [responder error:errorResponse]; + [DatabasesManager raiseDatabaseInvalidError:responder]; return; } @@ -137,20 +131,13 @@ - (void)listenForCommands { getTableStructureRequestFromDictionary:params]; if (!request) { - NSDictionary* errorResponse = [ObjectMapper - errorWithCode:DatabasesErrorCodesInvalidRequest - message:kDatabasesErrorCodesInvalidRequestMessage]; - [responder error:errorResponse]; + [DatabasesManager raiseInvalidRequestError:responder]; return; } - DatabaseDescriptorHolder* descriptorHolder = self.databaseDescriptorHolders[@(request.databaseId)]; if (!descriptorHolder) { - NSDictionary* errorResponse = [ObjectMapper - errorWithCode:DatabasesErrorCodesDatabaseInvalid - message:kDatabasesErrorCodesDatabaseInvalidMessage]; - [responder error:errorResponse]; + [DatabasesManager raiseDatabaseInvalidError:responder]; return; } @@ -178,19 +165,13 @@ - (void)listenForCommands { DatabaseGetTableInfoRequest* request = [DatabaseGetTableInfoRequest getTableInfoRequestFromDictionary:params]; if (!request) { - NSDictionary* errorResponse = [ObjectMapper - errorWithCode:DatabasesErrorCodesInvalidRequest - message:kDatabasesErrorCodesInvalidRequestMessage]; - [responder error:errorResponse]; + [DatabasesManager raiseInvalidRequestError:responder]; return; } DatabaseDescriptorHolder* descriptorHolder = self.databaseDescriptorHolders[@(request.databaseId)]; if (!descriptorHolder) { - NSDictionary* errorResponse = [ObjectMapper - errorWithCode:DatabasesErrorCodesDatabaseInvalid - message:kDatabasesErrorCodesDatabaseInvalidMessage]; - [responder error:errorResponse]; + [DatabasesManager raiseDatabaseInvalidError:responder]; return; } @@ -218,19 +199,13 @@ - (void)listenForCommands { DatabaseExecuteSqlRequest* request = [DatabaseExecuteSqlRequest getExecuteSqlRequestFromDictionary:params]; if (!request) { - NSDictionary* errorResponse = [ObjectMapper - errorWithCode:DatabasesErrorCodesInvalidRequest - message:kDatabasesErrorCodesInvalidRequestMessage]; - [responder error:errorResponse]; + [DatabasesManager raiseInvalidRequestError:responder]; return; } DatabaseDescriptorHolder* descriptorHolder = self.databaseDescriptorHolders[@(request.databaseId)]; if (!descriptorHolder) { - NSDictionary* errorResponse = [ObjectMapper - errorWithCode:DatabasesErrorCodesDatabaseInvalid - message:kDatabasesErrorCodesDatabaseInvalidMessage]; - [responder error:errorResponse]; + [DatabasesManager raiseDatabaseInvalidError:responder]; return; } @try { @@ -249,4 +224,18 @@ - (void)listenForCommands { }]; } ++ (void)raiseInvalidRequestError:(id)responder { + NSDictionary* errorResponse = + [ObjectMapper errorWithCode:DatabasesErrorCodesInvalidRequest + message:kDatabasesErrorCodesInvalidRequestMessage]; + [responder error:errorResponse]; +} + ++ (void)raiseDatabaseInvalidError:(id)responder { + NSDictionary* errorResponse = + [ObjectMapper errorWithCode:DatabasesErrorCodesDatabaseInvalid + message:kDatabasesErrorCodesDatabaseInvalidMessage]; + [responder error:errorResponse]; +} + @end From 2f5f4911e5afb2368f798558c6ab23e8dcdef1b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=BAlvio=20Abrah=C3=A3o=20de=20Paula?= Date: Mon, 14 Aug 2023 11:07:07 -0700 Subject: [PATCH 29/98] Refactor FlipperKitDatabasePlugin to accept multiple database drivers. Reviewed By: lblasa Differential Revision: D48316901 fbshipit-source-id: 0eb7b93f53ce115a0a031a58ecef3db963b35f09 --- .../DatabasesManager.h | 7 +++--- .../DatabasesManager.m | 24 +++++++++++++++---- .../FlipperKitDatabasesPlugin.h | 3 +++ .../FlipperKitDatabasesPlugin.m | 13 ++++++---- .../Mock/MockDatabaseDriver.h | 2 +- 5 files changed, 35 insertions(+), 14 deletions(-) diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.h index 0907f01f3ce..693aac5f633 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.h +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.h @@ -14,12 +14,11 @@ @interface DatabasesManager : NSObject @property(nonatomic, strong) id connection; -@property(nonatomic, strong, readonly) - NSArray>* databaseDrivers; -- (instancetype)initWithDatabaseDrivers: - (NSArray>*)databaseDrivers; +- (instancetype)init; - (void)setConnection:(id)connection; - (BOOL)isConnected; +- (void)addDatabaseDriver:(id)driver; +- (void)removeDatabaseDriver:(id)driver; @end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m index b97a3cf0553..428ab34f476 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m @@ -27,18 +27,18 @@ @interface DatabasesManager () databaseDescriptorHolders; @property(nonatomic, strong) NSMutableSet* databaseDescriptorHolderSet; +@property(nonatomic, strong) NSMutableSet>* databaseDrivers; @end @implementation DatabasesManager -- (instancetype)initWithDatabaseDrivers: - (NSArray>*)databaseDrivers { +- (instancetype)init { self = [super init]; if (self) { - _databaseDrivers = [databaseDrivers copy]; - _databaseDescriptorHolders = [[NSMutableDictionary alloc] init]; - _databaseDescriptorHolderSet = [[NSMutableSet alloc] init]; + _databaseDrivers = [NSMutableSet new]; + _databaseDescriptorHolders = [NSMutableDictionary new]; + _databaseDescriptorHolderSet = [NSMutableSet new]; } return self; } @@ -224,6 +224,20 @@ - (void)listenForCommands { }]; } +- (void)addDatabaseDriver:(id)driver { + if ([self.databaseDrivers containsObject:driver]) { + return; + } + [self.databaseDrivers addObject:driver]; +} + +- (void)removeDatabaseDriver:(id)driver { + if (![self.databaseDrivers containsObject:driver]) { + return; + } + [self.databaseDrivers removeObject:driver]; +} + + (void)raiseInvalidRequestError:(id)responder { NSDictionary* errorResponse = [ObjectMapper errorWithCode:DatabasesErrorCodesInvalidRequest diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.h index 41f563b2728..67be40da551 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.h +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.h @@ -7,6 +7,7 @@ #import #import +#import "DatabaseDriver.h" @class DatabasesManager; @@ -15,5 +16,7 @@ - (instancetype)init NS_UNAVAILABLE; + (instancetype)sharedInstance; +- (void)addDatabaseDriver:(id)driver; +- (void)removeDatabaseDriver:(id)driver; @end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.m index 7f6c4da2058..8ca0dd3b6ec 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.m +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin.m @@ -23,10 +23,7 @@ @implementation FlipperKitDatabasesPlugin - (instancetype)init { if (self = [super init]) { - NSArray>* databaseDrivers = - @[ [MockDatabaseDriver new] ]; - _databasesManager = - [[DatabasesManager alloc] initWithDatabaseDrivers:databaseDrivers]; + _databasesManager = [DatabasesManager new]; } return self; } @@ -59,6 +56,14 @@ - (BOOL)runInBackground { return NO; } +- (void)addDatabaseDriver:(id)driver { + [self.databasesManager addDatabaseDriver:driver]; +} + +- (void)removeDatabaseDriver:(id)driver { + [self.databasesManager addDatabaseDriver:driver]; +} + @end #endif diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDriver.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDriver.h index bd62e981246..c78aa89e0bf 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDriver.h +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/Mock/MockDatabaseDriver.h @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +#import #import -#import "DatabaseDriver.h" @interface MockDatabaseDriver : NSObject From ff6f98fc0dd5be6a70191e2423f29c8fb4a6a05c Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Mon, 14 Aug 2023 11:33:06 -0700 Subject: [PATCH 30/98] Import File implementation Summary: Implementation was missing for the browser. This provides a default implementation. Reviewed By: aigoncharov Differential Revision: D48311198 fbshipit-source-id: fd067600f571234e0fbccfb90853b62f175ff8fb --- .../app/src/electron/initializeElectron.tsx | 1 - desktop/flipper-common/src/server-types.tsx | 4 +- .../src/plugin/FlipperLib.tsx | 6 +- .../flipper-plugin/src/ui/FileSelector.tsx | 21 +++--- .../src/FlipperServerImpl.tsx | 7 +- .../src/plugins/PluginManager.tsx | 6 +- desktop/flipper-ui-browser/package.json | 1 + .../src/initializeRenderHost.tsx | 72 ++++++++++++++++++- .../plugin-manager/PluginPackageInstaller.tsx | 19 ++--- desktop/plugin-lib/src/pluginInstaller.tsx | 4 +- .../request-mocking/NetworkRouteManager.tsx | 3 + .../public/shared_preferences/src/index.tsx | 40 ++++++----- 12 files changed, 130 insertions(+), 54 deletions(-) diff --git a/desktop/app/src/electron/initializeElectron.tsx b/desktop/app/src/electron/initializeElectron.tsx index 55974125bab..c2e4311ca86 100644 --- a/desktop/app/src/electron/initializeElectron.tsx +++ b/desktop/app/src/electron/initializeElectron.tsx @@ -134,7 +134,6 @@ export async function initializeElectron( return { data, name: fileName, - path: filePath, }; }), ); diff --git a/desktop/flipper-common/src/server-types.tsx b/desktop/flipper-common/src/server-types.tsx index a3b94e467af..7596c0f6da9 100644 --- a/desktop/flipper-common/src/server-types.tsx +++ b/desktop/flipper-common/src/server-types.tsx @@ -319,8 +319,8 @@ export type FlipperServerCommands = { name: string, ) => Promise; 'plugins-install-from-npm': (name: string) => Promise; - 'plugins-install-from-file': ( - path: string, + 'plugins-install-from-content': ( + contents: string, ) => Promise; 'plugins-remove-plugins': (names: string[]) => Promise; 'plugins-server-add-on-start': ( diff --git a/desktop/flipper-plugin-core/src/plugin/FlipperLib.tsx b/desktop/flipper-plugin-core/src/plugin/FlipperLib.tsx index 98dd2975741..db28db2e84a 100644 --- a/desktop/flipper-plugin-core/src/plugin/FlipperLib.tsx +++ b/desktop/flipper-plugin-core/src/plugin/FlipperLib.tsx @@ -32,12 +32,12 @@ import { import {CreatePasteArgs, CreatePasteResult} from './Paste'; import {Atom} from '../state/atom'; -export type FileEncoding = 'utf-8' | 'base64'; +export type FileEncoding = 'utf-8' | 'base64' | 'binary'; export interface FileDescriptor { - data: string; + data: string | Uint8Array | undefined; name: string; - path?: string; + encoding: FileEncoding; } export interface DownloadFileResponse extends DownloadFileStartResponse { diff --git a/desktop/flipper-plugin/src/ui/FileSelector.tsx b/desktop/flipper-plugin/src/ui/FileSelector.tsx index 3b70cf6ef9c..2842f864cf2 100644 --- a/desktop/flipper-plugin/src/ui/FileSelector.tsx +++ b/desktop/flipper-plugin/src/ui/FileSelector.tsx @@ -56,7 +56,7 @@ export type FileSelectorProps = { ); const formatFileDescriptor = (fileDescriptor?: FileDescriptor) => - fileDescriptor?.path || fileDescriptor?.name; + fileDescriptor?.name; export function FileSelector({ onChange, @@ -74,14 +74,8 @@ export function FileSelector({ const onSetFiles = async () => { setLoading(true); - let defaultPath: string | undefined = files[0]?.path ?? files[0]?.name; - if (multi) { - defaultPath = files[0]?.path; - } - try { const newFileSelection = await getFlipperLib().importFile?.({ - defaultPath, extensions, title: label, encoding, @@ -126,7 +120,7 @@ export function FileSelector({ droppedFiles.map(async (droppedFile) => { const raw = await droppedFile.arrayBuffer(); - let data: string; + let data: string | Uint8Array | undefined; switch (encoding) { case 'utf-8': { data = new TextDecoder().decode(raw); @@ -136,18 +130,19 @@ export function FileSelector({ data = fromUint8Array(new Uint8Array(raw)); break; } + case 'binary': + data = new Uint8Array(raw); + break; default: { assertNever(encoding); } } - const droppedFileDescriptor: FileDescriptor = { - data: data!, + return { + data, name: droppedFile.name, - // Electron "File" has "path" attribute - path: (droppedFile as any).path, + encoding, }; - return droppedFileDescriptor; }), ); diff --git a/desktop/flipper-server-core/src/FlipperServerImpl.tsx b/desktop/flipper-server-core/src/FlipperServerImpl.tsx index 511cd200370..23f41af1401 100644 --- a/desktop/flipper-server-core/src/FlipperServerImpl.tsx +++ b/desktop/flipper-server-core/src/FlipperServerImpl.tsx @@ -521,8 +521,11 @@ export class FlipperServerImpl implements FlipperServer { this.pluginManager.downloadPlugin(details), 'plugins-get-updatable-plugins': (query) => this.pluginManager.getUpdatablePlugins(query), - 'plugins-install-from-file': (path) => - this.pluginManager.installPluginFromFile(path), + 'plugins-install-from-content': (contents) => { + const bytes = Base64.toUint8Array(contents); + const buffer = Buffer.from(bytes); + return this.pluginManager.installPluginFromFileOrBuffer(buffer); + }, 'plugins-install-from-marketplace': (name: string) => this.pluginManager.installPluginForMarketplace(name), 'plugins-install-from-npm': (name) => diff --git a/desktop/flipper-server-core/src/plugins/PluginManager.tsx b/desktop/flipper-server-core/src/plugins/PluginManager.tsx index 8ba356436ca..7baa08deec6 100644 --- a/desktop/flipper-server-core/src/plugins/PluginManager.tsx +++ b/desktop/flipper-server-core/src/plugins/PluginManager.tsx @@ -28,7 +28,7 @@ import { getInstalledPlugins, getPluginVersionInstallationDir, getPluginDirNameFromPackageName, - installPluginFromFile, + installPluginFromFileOrBuffer, removePlugins, getUpdatablePlugins, getInstalledPlugin, @@ -71,7 +71,7 @@ export class PluginManager { removePlugins = removePlugins; getUpdatablePlugins = getUpdatablePlugins; getInstalledPlugin = getInstalledPlugin; - installPluginFromFile = installPluginFromFile; + installPluginFromFileOrBuffer = installPluginFromFileOrBuffer; installPluginFromNpm = installPluginFromNpm; async loadSource(path: string): Promise { @@ -186,7 +186,7 @@ export class PluginManager { await new Promise((resolve, reject) => writeStream.once('finish', resolve).once('error', reject), ); - return await installPluginFromFile(tmpFile); + return await installPluginFromFileOrBuffer(tmpFile); } } catch (error) { console.warn( diff --git a/desktop/flipper-ui-browser/package.json b/desktop/flipper-ui-browser/package.json index 70e146da5e0..6e25ac516fc 100644 --- a/desktop/flipper-ui-browser/package.json +++ b/desktop/flipper-ui-browser/package.json @@ -11,6 +11,7 @@ "bugs": "https://github.com/facebook/flipper/issues", "dependencies": { "file-saver": "^2.0.5", + "js-base64": "^3.7.5", "reconnecting-websocket": "^4.4.0" }, "devDependencies": { diff --git a/desktop/flipper-ui-browser/src/initializeRenderHost.tsx b/desktop/flipper-ui-browser/src/initializeRenderHost.tsx index 1f576144269..e09d34468ec 100644 --- a/desktop/flipper-ui-browser/src/initializeRenderHost.tsx +++ b/desktop/flipper-ui-browser/src/initializeRenderHost.tsx @@ -16,6 +16,8 @@ import { import type {RenderHost} from 'flipper-ui-core'; import FileSaver from 'file-saver'; +import {Base64} from 'js-base64'; + declare module globalThis { let require: any; } @@ -31,6 +33,13 @@ globalThis.require = wrapRequire((module: string) => { ); }); +type FileEncoding = 'utf-8' | 'base64' | 'binary'; +interface FileDescriptor { + data: string | Uint8Array | undefined; + name: string; + encoding: FileEncoding; +} + export function initializeRenderHost( flipperServer: FlipperServer, flipperServerConfig: FlipperServerConfig, @@ -42,8 +51,67 @@ export function initializeRenderHost( writeTextToClipboard(text: string) { return navigator.clipboard.writeText(text); }, - async importFile() { - throw new Error('Not implemented'); + async importFile(options?: { + defaultPath?: string; + extensions?: string[]; + title?: string; + encoding?: FileEncoding; + multi?: false; + }) { + return new Promise( + (resolve, reject) => { + try { + const fileInput = document.createElement('input'); + fileInput.type = 'file'; + if (options?.extensions) { + fileInput.accept = options?.extensions.join(', '); + } + fileInput.multiple = options?.multi ?? false; + + fileInput.addEventListener('change', async (event) => { + const target = event.target as HTMLInputElement | undefined; + if (!target || !target.files) { + resolve(undefined); + return; + } + + const files: File[] = Array.from(target.files); + const descriptors: FileDescriptor[] = await Promise.all( + files.map(async (file) => { + switch (options?.encoding) { + case 'base64': { + const bytes = new Uint8Array(await file.arrayBuffer()); + const base64Content = Base64.fromUint8Array(bytes); + return { + data: base64Content, + name: file.name, + encoding: 'base64', + }; + } + case 'binary': + return { + data: new Uint8Array(await file.arrayBuffer()), + name: file.name, + encoding: 'binary', + }; + default: + return { + data: await file.text(), + name: file.name, + encoding: 'utf-8', + }; + } + }), + ); + resolve(options?.multi ? descriptors : descriptors[0]); + }); + + fileInput.click(); + } catch (error) { + reject(error); + } + }, + ); }, async exportFile(data: string, {defaultPath}: {defaultPath?: string}) { const file = new File([data], defaultPath ?? 'unknown', { diff --git a/desktop/flipper-ui-core/src/chrome/plugin-manager/PluginPackageInstaller.tsx b/desktop/flipper-ui-core/src/chrome/plugin-manager/PluginPackageInstaller.tsx index 7295494e3a0..d76133d8e6b 100644 --- a/desktop/flipper-ui-core/src/chrome/plugin-manager/PluginPackageInstaller.tsx +++ b/desktop/flipper-ui-core/src/chrome/plugin-manager/PluginPackageInstaller.tsx @@ -43,17 +43,20 @@ export default function PluginPackageInstaller({ }: { onInstall: () => Promise; }) { - const [path, setPath] = useState(''); + const [content, setContent] = useState(); const [isPathValid, setIsPathValid] = useState(false); const [error, setError] = useState(); const [inProgress, setInProgress] = useState(false); const onClick = async () => { + if (!content) { + return; + } setError(undefined); setInProgress(true); try { - await getRenderHostInstance().flipperServer!.exec( - 'plugins-install-from-file', - path, + await getRenderHostInstance().flipperServer?.exec( + 'plugins-install-from-content', + content, ); await onInstall(); } catch (e) { @@ -83,13 +86,13 @@ export default function PluginPackageInstaller({ { + encoding="base64" + onChange={async (newFile) => { if (newFile) { - // TODO: Fix me before implementing Browser Flipper. "path" is only availbale in Electron! - setPath(newFile.path!); + setContent(newFile.data as string); setIsPathValid(true); } else { - setPath(''); + setContent(undefined); setIsPathValid(false); } setError(undefined); diff --git a/desktop/plugin-lib/src/pluginInstaller.tsx b/desktop/plugin-lib/src/pluginInstaller.tsx index eaa0bf16f06..365a44d6d86 100644 --- a/desktop/plugin-lib/src/pluginInstaller.tsx +++ b/desktop/plugin-lib/src/pluginInstaller.tsx @@ -108,8 +108,8 @@ export async function installPluginFromNpm(name: string) { } } -export async function installPluginFromFile( - packagePath: string, +export async function installPluginFromFileOrBuffer( + packagePath: string | Buffer, ): Promise { const tmpDir = await promisify(tmp.dir)(); try { diff --git a/desktop/plugins/public/network/request-mocking/NetworkRouteManager.tsx b/desktop/plugins/public/network/request-mocking/NetworkRouteManager.tsx index 24f0a2bd694..9322d0bc840 100644 --- a/desktop/plugins/public/network/request-mocking/NetworkRouteManager.tsx +++ b/desktop/plugins/public/network/request-mocking/NetworkRouteManager.tsx @@ -139,6 +139,9 @@ export function createNetworkManager( }) .then((res) => { if (res) { + if (res.encoding !== 'utf-8' || typeof res.data !== 'string') { + return; + } const importedRoutes = JSON.parse(res.data); importedRoutes?.forEach((importedRoute: Route) => { if (importedRoute != null) { diff --git a/desktop/plugins/public/shared_preferences/src/index.tsx b/desktop/plugins/public/shared_preferences/src/index.tsx index 4e898569dff..a60dbd2b546 100644 --- a/desktop/plugins/public/shared_preferences/src/index.tsx +++ b/desktop/plugins/public/shared_preferences/src/index.tsx @@ -123,27 +123,31 @@ export function plugin(client: PluginClient) { } async function loadFromFile() { const file = await getFlipperLib().importFile(); - if (file?.path != undefined) { - const data = await getFlipperLib().remoteServerContext.fs.readFile( - file.path, - {encoding: 'utf-8'}, - ); - const preferences = JSON.parse(data) as SharedPreferencesEntry; - const name = selectedPreferences.get(); - if (name != null) { - updateSharedPreferences({ - name: name, - preferences: preferences.preferences, - }); - - for (const key in preferences.preferences) { - await client.send('setSharedPreference', { - sharedPreferencesName: name, - preferenceName: key, - preferenceValue: preferences.preferences[key], + if (file && file.encoding === 'utf-8' && typeof file.data === 'string') { + try { + const preferences = JSON.parse(file.data) as SharedPreferencesEntry; + const name = selectedPreferences.get(); + if (name != null) { + updateSharedPreferences({ + name: name, + preferences: preferences.preferences, }); + + for (const key in preferences.preferences) { + await client.send('setSharedPreference', { + sharedPreferencesName: name, + preferenceName: key, + preferenceValue: preferences.preferences[key], + }); + } } + } catch (e) { + console.warn('Unable to import shared preferences', e); } + } else { + console.warn( + 'The loaded file either has wrong encoding or is not a valid json file', + ); } } From 007cdfee760fb986612d34a8da17c0630e665169 Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Mon, 14 Aug 2023 11:33:06 -0700 Subject: [PATCH 31/98] Enable flipper import/export Summary: These two functions were not enabled for the browser experience. Reviewed By: antonk52 Differential Revision: D48315991 fbshipit-source-id: 2944a386d9de8a06b043305e7ceb8a6c41e11209 --- .../src/chrome/ShareSheetExportFile.tsx | 30 ++++++------- .../src/sandy-chrome/Navbar.tsx | 24 ++++------ .../flipper-ui-core/src/utils/exportData.tsx | 45 +++++-------------- 3 files changed, 34 insertions(+), 65 deletions(-) diff --git a/desktop/flipper-ui-core/src/chrome/ShareSheetExportFile.tsx b/desktop/flipper-ui-core/src/chrome/ShareSheetExportFile.tsx index ded73c4acaf..0e997469e4a 100644 --- a/desktop/flipper-ui-core/src/chrome/ShareSheetExportFile.tsx +++ b/desktop/flipper-ui-core/src/chrome/ShareSheetExportFile.tsx @@ -13,15 +13,16 @@ import {reportPlatformFailures} from 'flipper-common'; import {Logger} from 'flipper-common'; import {IdlerImpl} from '../utils/Idler'; import { - exportStoreToFile, EXPORT_FLIPPER_TRACE_EVENT, displayFetchMetadataErrors, + exportStore, } from '../utils/exportData'; import ShareSheetErrorList from './ShareSheetErrorList'; import ShareSheetPendingDialog from './ShareSheetPendingDialog'; import {ReactReduxContext, ReactReduxContextValue} from 'react-redux'; import {MiddlewareAPI} from '../reducers/index'; import {Modal} from 'antd'; +import {getRenderHostInstance} from 'flipper-frontend-core'; const Container = styled(FlexColumn)({ padding: 20, @@ -47,7 +48,6 @@ const InfoText = styled(Text)({ type Props = { onHide: () => void; - file: string; logger: Logger; }; @@ -88,27 +88,25 @@ export default class ShareSheetExportFile extends Component { const mark = 'shareSheetExportFile'; performance.mark(mark); try { - if (!this.props.file) { - return; - } - const {fetchMetaDataErrors} = await reportPlatformFailures( - exportStoreToFile( - this.props.file, - this.store, - false, - this.idler, - (msg: string) => { + const {serializedString, fetchMetaDataErrors} = + await reportPlatformFailures( + exportStore(this.store, false, this.idler, (msg: string) => { this.setState({statusUpdate: msg}); - }, - ), - `${EXPORT_FLIPPER_TRACE_EVENT}:UI_FILE`, - ); + }), + `${EXPORT_FLIPPER_TRACE_EVENT}:UI_FILE`, + ); this.setState({ fetchMetaDataErrors, result: fetchMetaDataErrors ? {error: JSON.stringify(fetchMetaDataErrors) as any, kind: 'error'} : {kind: 'success'}, }); + + await getRenderHostInstance().exportFile(serializedString, { + defaultPath: 'export.flipper', + encoding: 'utf-8', + }); + this.props.logger.trackTimeSince(mark, 'export:file-success'); } catch (err) { const result: { diff --git a/desktop/flipper-ui-core/src/sandy-chrome/Navbar.tsx b/desktop/flipper-ui-core/src/sandy-chrome/Navbar.tsx index df30c244450..e84aff56fb1 100644 --- a/desktop/flipper-ui-core/src/sandy-chrome/Navbar.tsx +++ b/desktop/flipper-ui-core/src/sandy-chrome/Navbar.tsx @@ -45,11 +45,9 @@ import NetworkGraph from '../chrome/NetworkGraph'; import {errorCounterAtom} from '../chrome/ConsoleLogs'; import {filterNotifications} from './notification/notificationUtils'; import { - canFileExport, - canOpenDialog, exportEverythingEverywhereAllAtOnce, ExportEverythingEverywhereAllAtOnceStatus, - showOpenDialog, + startFileImport, startFileExport, startLinkExport, } from '../utils/exportData'; @@ -591,9 +589,9 @@ function ExtrasMenu() { () => startLinkExport(store.dispatch), [store.dispatch], ); - const startImportTracked = useTrackedCallback( + const startFileImportTracked = useTrackedCallback( 'File import', - () => showOpenDialog(store), + () => startFileImport(store), [store], ); @@ -627,16 +625,12 @@ function ExtrasMenu() { }}> Add Plugins - {canOpenDialog() ? ( - - Import Flipper file - - ) : null} - {canFileExport() ? ( - - Export Flipper file - - ) : null} + + Import Flipper file + + + Export Flipper file + {constants.ENABLE_SHAREABLE_LINK ? ( { } }; -export function canOpenDialog() { - return !!getRenderHostInstance().showOpenDialog; -} - -export function showOpenDialog(store: Store) { - return getRenderHostInstance() - .showOpenDialog?.({ - filter: {extensions: ['flipper', 'json', 'txt'], name: 'Flipper files'}, - }) - .then((filePath) => { - if (filePath) { - tryCatchReportPlatformFailures(() => { - importFileToStore(filePath, store); - }, `${IMPORT_FLIPPER_TRACE_EVENT}:UI`); - } - }); -} - -export function canFileExport() { - return !!getRenderHostInstance().showSaveDialog; +export async function startFileImport(store: Store) { + const file = await getRenderHostInstance().importFile({ + extensions: ['flipper', 'json', 'txt'], + }); + if (!file || typeof file.data !== 'string') { + return; + } + importDataToStore(file.name, file.data as string, store); } async function startDeviceFlipperFolderExport() { @@ -765,25 +752,15 @@ export async function exportEverythingEverywhereAllAtOnce( } export async function startFileExport(dispatch: Store['dispatch']) { - const file = await getRenderHostInstance().showSaveDialog?.({ - title: 'FlipperExport', - defaultPath: path.join( - getRenderHostInstance().serverConfig.paths.homePath, - 'FlipperExport.flipper', - ), - }); - if (!file) { - return; - } const plugins = await selectPlugins(); if (plugins === false) { - return; // cancelled + return; } // TODO: no need to put this in the store, - // need to be cleaned up later in combination with SupportForm + // need to be cleaned up later in combination with SupportForm. dispatch(selectedPlugins(plugins)); Dialog.showModal((onHide) => ( - + )); } From 7ef7b9a2486867fee50c6f3f50e3cf6ff7b9582f Mon Sep 17 00:00:00 2001 From: generatedunixname89002005306973 Date: Tue, 15 Aug 2023 06:56:48 -0700 Subject: [PATCH 32/98] Flipper Release: v0.211.1 Summary: Releasing version 0.211.1 Reviewed By: passy Differential Revision: D48349388 fbshipit-source-id: 7e152acb6009148bfbade2ee282bc681e12b110f --- desktop/package.json | 2 +- desktop/plugins/public/layout/docs/setup.mdx | 2 +- desktop/plugins/public/leak_canary/docs/setup.mdx | 2 +- desktop/plugins/public/network/docs/setup.mdx | 2 +- docs/getting-started/android-native.mdx | 4 ++-- docs/getting-started/react-native-ios.mdx | 2 +- docs/getting-started/react-native.mdx | 4 ++-- gradle.properties | 2 +- js/js-flipper/package.json | 2 +- react-native/react-native-flipper/package.json | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/desktop/package.json b/desktop/package.json index ec957ba0d86..566182173a5 100644 --- a/desktop/package.json +++ b/desktop/package.json @@ -169,7 +169,7 @@ "npm": "use yarn instead", "yarn": "^1.16" }, - "version": "0.211.0", + "version": "0.211.1", "workspaces": { "packages": [ "scripts", diff --git a/desktop/plugins/public/layout/docs/setup.mdx b/desktop/plugins/public/layout/docs/setup.mdx index 168138c6744..398da818d64 100644 --- a/desktop/plugins/public/layout/docs/setup.mdx +++ b/desktop/plugins/public/layout/docs/setup.mdx @@ -27,7 +27,7 @@ You also need to compile in the `litho-annotations` package, as Flipper reflects ```groovy dependencies { - debugImplementation 'com.facebook.flipper:flipper-litho-plugin:0.211.0' + debugImplementation 'com.facebook.flipper:flipper-litho-plugin:0.211.1' debugImplementation 'com.facebook.litho:litho-annotations:0.19.0' // ... } diff --git a/desktop/plugins/public/leak_canary/docs/setup.mdx b/desktop/plugins/public/leak_canary/docs/setup.mdx index bbf4b386ae9..856bae5bf10 100644 --- a/desktop/plugins/public/leak_canary/docs/setup.mdx +++ b/desktop/plugins/public/leak_canary/docs/setup.mdx @@ -8,7 +8,7 @@ To setup the LeakCan ```groovy dependencies { - debugImplementation 'com.facebook.flipper:flipper-leakcanary2-plugin:0.211.0' + debugImplementation 'com.facebook.flipper:flipper-leakcanary2-plugin:0.211.1' debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8.1' } ``` diff --git a/desktop/plugins/public/network/docs/setup.mdx b/desktop/plugins/public/network/docs/setup.mdx index 40d40e5fc55..bd55f12ad46 100644 --- a/desktop/plugins/public/network/docs/setup.mdx +++ b/desktop/plugins/public/network/docs/setup.mdx @@ -12,7 +12,7 @@ The network plugin is shipped as a separate Maven artifact, as follows: ```groovy dependencies { - debugImplementation 'com.facebook.flipper:flipper-network-plugin:0.211.0' + debugImplementation 'com.facebook.flipper:flipper-network-plugin:0.211.1' } ``` diff --git a/docs/getting-started/android-native.mdx b/docs/getting-started/android-native.mdx index d88c066d074..d7e2740e1ca 100644 --- a/docs/getting-started/android-native.mdx +++ b/docs/getting-started/android-native.mdx @@ -24,10 +24,10 @@ repositories { } dependencies { - debugImplementation 'com.facebook.flipper:flipper:0.211.0' + debugImplementation 'com.facebook.flipper:flipper:0.211.1' debugImplementation 'com.facebook.soloader:soloader:0.10.5' - releaseImplementation 'com.facebook.flipper:flipper-noop:0.211.0' + releaseImplementation 'com.facebook.flipper:flipper-noop:0.211.1' } ``` diff --git a/docs/getting-started/react-native-ios.mdx b/docs/getting-started/react-native-ios.mdx index 3d104a17548..646ce8f29a2 100644 --- a/docs/getting-started/react-native-ios.mdx +++ b/docs/getting-started/react-native-ios.mdx @@ -51,7 +51,7 @@ Add all of the code below to your `ios/Podfile`: platform :ios, '9.0' def flipper_pods() - flipperkit_version = '0.211.0' # should match the version of your Flipper client app + flipperkit_version = '0.211.1' # should match the version of your Flipper client app pod 'FlipperKit', '~>' + flipperkit_version, :configuration => 'Debug' pod 'FlipperKit/FlipperKitLayoutPlugin', '~>' + flipperkit_version, :configuration => 'Debug' pod 'FlipperKit/SKIOSNetworkPlugin', '~>' + flipperkit_version, :configuration => 'Debug' diff --git a/docs/getting-started/react-native.mdx b/docs/getting-started/react-native.mdx index b28879294bc..fec787f0590 100644 --- a/docs/getting-started/react-native.mdx +++ b/docs/getting-started/react-native.mdx @@ -34,7 +34,7 @@ Latest version of Flipper requires react-native 0.69+! If you use react-native < Android: -1. Bump the `FLIPPER_VERSION` variable in `android/gradle.properties`, for example: `FLIPPER_VERSION=0.211.0`. +1. Bump the `FLIPPER_VERSION` variable in `android/gradle.properties`, for example: `FLIPPER_VERSION=0.211.1`. 2. Run `./gradlew clean` in the `android` directory. iOS: @@ -44,7 +44,7 @@ react-native version => 0.69.0 2. Run `pod install --repo-update` in the `ios` directory. react-native version < 0.69.0 -1. Call `use_flipper` with a specific version in `ios/Podfile`, for example: `use_flipper!({ 'Flipper' => '0.211.0' })`. +1. Call `use_flipper` with a specific version in `ios/Podfile`, for example: `use_flipper!({ 'Flipper' => '0.211.1' })`. 2. Run `pod install --repo-update` in the `ios` directory. ## Manual Setup diff --git a/gradle.properties b/gradle.properties index 49351b0a3ce..ef61c0f6741 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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. # POM publishing constants -VERSION_NAME=0.211.1-SNAPSHOT +VERSION_NAME=0.211.1 GROUP=com.facebook.flipper SONATYPE_STAGING_PROFILE=comfacebook POM_URL=https://github.com/facebook/flipper diff --git a/js/js-flipper/package.json b/js/js-flipper/package.json index 317152c3685..5aad96fec8f 100644 --- a/js/js-flipper/package.json +++ b/js/js-flipper/package.json @@ -1,7 +1,7 @@ { "name": "js-flipper", "title": "JS Flipper Bindings for Web-Socket based clients", - "version": "0.211.0", + "version": "0.211.1", "main": "lib/index.js", "browser": { "os": false diff --git a/react-native/react-native-flipper/package.json b/react-native/react-native-flipper/package.json index bd4e43c4641..cac1a2d5df8 100644 --- a/react-native/react-native-flipper/package.json +++ b/react-native/react-native-flipper/package.json @@ -1,7 +1,7 @@ { "name": "react-native-flipper", "title": "React Native Flipper Bindings", - "version": "0.211.0", + "version": "0.211.1", "description": "Flipper bindings for React Native", "main": "index.js", "types": "index.d.ts", From 8094370aba2fbef44296c33298adae30c8278eb3 Mon Sep 17 00:00:00 2001 From: generatedunixname89002005306973 Date: Tue, 15 Aug 2023 06:56:48 -0700 Subject: [PATCH 33/98] Flipper Snapshot Bump: v0.211.2-SNAPSHOT Summary: Releasing snapshot version 0.211.2-SNAPSHOT Reviewed By: passy Differential Revision: D48349387 fbshipit-source-id: 121bf5516809f1b719be130379949de76895d944 --- docs/getting-started/android-native.mdx | 4 ++-- gradle.properties | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/getting-started/android-native.mdx b/docs/getting-started/android-native.mdx index d7e2740e1ca..10189fd27d5 100644 --- a/docs/getting-started/android-native.mdx +++ b/docs/getting-started/android-native.mdx @@ -124,10 +124,10 @@ repositories { } dependencies { - debugImplementation 'com.facebook.flipper:flipper:0.211.1-SNAPSHOT' + debugImplementation 'com.facebook.flipper:flipper:0.211.2-SNAPSHOT' debugImplementation 'com.facebook.soloader:soloader:0.10.5' - releaseImplementation 'com.facebook.flipper:flipper-noop:0.211.1-SNAPSHOT' + releaseImplementation 'com.facebook.flipper:flipper-noop:0.211.2-SNAPSHOT' } ``` diff --git a/gradle.properties b/gradle.properties index ef61c0f6741..03d3d439cb4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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. # POM publishing constants -VERSION_NAME=0.211.1 +VERSION_NAME=0.211.2-SNAPSHOT GROUP=com.facebook.flipper SONATYPE_STAGING_PROFILE=comfacebook POM_URL=https://github.com/facebook/flipper From 65603771a9877dea62089106711ed08388c538a4 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Tue, 15 Aug 2023 12:26:12 -0700 Subject: [PATCH 34/98] Refactor all usages of import NetworkingModule.setCustomClientBuilder Summary: Refactor all usages of import NetworkingModule.setCustomClientBuilder to use CustomClientBuilder instead of NetworkModule.CustomClientBuilder changelog: [internal] internal Reviewed By: cortinico Differential Revision: D48280921 fbshipit-source-id: ffa979defb34ecaac9d327eaafee33598ea22b5d --- .../java/com/reactnativeflipperexample/ReactNativeFlipper.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/react-native/ReactNativeFlipperExample/android/app/src/debug/java/com/reactnativeflipperexample/ReactNativeFlipper.java b/react-native/ReactNativeFlipperExample/android/app/src/debug/java/com/reactnativeflipperexample/ReactNativeFlipper.java index d030fa7c10c..28ee0db7203 100644 --- a/react-native/ReactNativeFlipperExample/android/app/src/debug/java/com/reactnativeflipperexample/ReactNativeFlipper.java +++ b/react-native/ReactNativeFlipperExample/android/app/src/debug/java/com/reactnativeflipperexample/ReactNativeFlipper.java @@ -22,6 +22,7 @@ import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; import com.facebook.react.ReactInstanceManager; import com.facebook.react.bridge.ReactContext; +import com.facebook.react.modules.network.CustomClientBuilder; import com.facebook.react.modules.network.NetworkingModule; import okhttp3.OkHttpClient; @@ -38,7 +39,7 @@ public static void initializeFlipper(Context context, ReactInstanceManager react NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin(); NetworkingModule.setCustomClientBuilder( - new NetworkingModule.CustomClientBuilder() { + new CustomClientBuilder() { @Override public void apply(OkHttpClient.Builder builder) { builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin)); From 84e0eaa00499175cb7e88d85c385b42690ba23ef Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 17 Aug 2023 08:15:18 -0700 Subject: [PATCH 35/98] Automated: Update Podfile.lock (#5048) 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/5048 Reviewed By: ivanmisuno Differential Revision: D48397521 Pulled By: passy fbshipit-source-id: 2333aa312f982b2ceff1dd2a2f8dfe9d0e63c893 --- 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 3dada981e40..872c9e574e5 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.211.0' +flipperkit_version = '0.211.1' Pod::Spec.new do |spec| spec.name = 'Flipper' spec.cocoapods_version = '>= 1.10' diff --git a/FlipperKit.podspec b/FlipperKit.podspec index dc39eae3936..85f29a35543 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.211.0' +flipperkit_version = '0.211.1' 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 ed65a24faac..d6320432713 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.211.0' +flipperkit_version = '0.211.1' target 'MyApp' do platform :ios, '10.0' diff --git a/iOS/Sample/Podfile.lock b/iOS/Sample/Podfile.lock index 99ae6e4e23b..95d793740e0 100644 --- a/iOS/Sample/Podfile.lock +++ b/iOS/Sample/Podfile.lock @@ -1,6 +1,6 @@ PODS: - CocoaAsyncSocket (7.6.5) - - Flipper (0.211.0): + - Flipper (0.211.1): - 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.211.0): - - FlipperKit/Core (= 0.211.0) - - FlipperKit/Core (0.211.0): - - Flipper (~> 0.211.0) + - FlipperKit (0.211.1): + - FlipperKit/Core (= 0.211.1) + - FlipperKit/Core (0.211.1): + - Flipper (~> 0.211.1) - FlipperKit/CppBridge - FlipperKit/FBCxxFollyDynamicConvert - FlipperKit/FBDefines - FlipperKit/FKPortForwarding - SocketRocket (~> 0.7.0) - - FlipperKit/CppBridge (0.211.0): - - Flipper (~> 0.211.0) - - FlipperKit/FBCxxFollyDynamicConvert (0.211.0): + - FlipperKit/CppBridge (0.211.1): + - Flipper (~> 0.211.1) + - FlipperKit/FBCxxFollyDynamicConvert (0.211.1): - Flipper-Folly (~> 2.6) - - FlipperKit/FBDefines (0.211.0) - - FlipperKit/FKPortForwarding (0.211.0): + - FlipperKit/FBDefines (0.211.1) + - FlipperKit/FKPortForwarding (0.211.1): - CocoaAsyncSocket (~> 7.6) - Flipper-PeerTalk (~> 0.0.4) - - FlipperKit/FlipperKitExamplePlugin (0.211.0): + - FlipperKit/FlipperKitExamplePlugin (0.211.1): - FlipperKit/Core - - FlipperKit/FlipperKitHighlightOverlay (0.211.0) - - FlipperKit/FlipperKitLayoutHelpers (0.211.0): + - FlipperKit/FlipperKitHighlightOverlay (0.211.1) + - FlipperKit/FlipperKitLayoutHelpers (0.211.1): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutIOSDescriptors (0.211.0): + - FlipperKit/FlipperKitLayoutIOSDescriptors (0.211.1): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutHelpers - - FlipperKit/FlipperKitLayoutPlugin (0.211.0): + - FlipperKit/FlipperKitLayoutPlugin (0.211.1): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutHelpers - FlipperKit/FlipperKitLayoutIOSDescriptors - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutTextSearchable (0.211.0) - - FlipperKit/FlipperKitNetworkPlugin (0.211.0): + - FlipperKit/FlipperKitLayoutTextSearchable (0.211.1) + - FlipperKit/FlipperKitNetworkPlugin (0.211.1): - FlipperKit/Core - - FlipperKit/FlipperKitReactPlugin (0.211.0): + - FlipperKit/FlipperKitReactPlugin (0.211.1): - FlipperKit/Core - - FlipperKit/FlipperKitUIDebuggerPlugin (0.211.0): + - FlipperKit/FlipperKitUIDebuggerPlugin (0.211.1): - FlipperKit/Core - - FlipperKit/FlipperKitUserDefaultsPlugin (0.211.0): + - FlipperKit/FlipperKitUserDefaultsPlugin (0.211.1): - FlipperKit/Core - - FlipperKit/SKIOSNetworkPlugin (0.211.0): + - FlipperKit/SKIOSNetworkPlugin (0.211.1): - FlipperKit/Core - FlipperKit/FlipperKitNetworkPlugin - libevent (2.1.12) @@ -104,14 +104,14 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 - Flipper: 320474526dd9b03509ffe2d0eecf21f47c2de363 + Flipper: 1e6dd91229c7d5715a3d0789eb44d473c9e30189 Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c Flipper-DoubleConversion: 2dc99b02f658daf147069aad9dbd29d8feb06d30 Flipper-Fmt: 60cbdd92fc254826e61d669a5d87ef7015396a9b Flipper-Folly: 584845625005ff068a6ebf41f857f468decd26b3 Flipper-Glog: 70c50ce58ddaf67dc35180db05f191692570f446 Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 - FlipperKit: f485471423b8b89870e9b4657d44e94a36ee80cf + FlipperKit: 7241594391e6c44666d7072b81dd739405b99f6d libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d diff --git a/iOS/SampleSwift/Podfile.lock b/iOS/SampleSwift/Podfile.lock index 184ecabea65..ff3996eb028 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.211.0): + - Flipper (0.211.1): - 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.211.0): - - FlipperKit/Core (= 0.211.0) - - FlipperKit/Core (0.211.0): - - Flipper (~> 0.211.0) + - FlipperKit (0.211.1): + - FlipperKit/Core (= 0.211.1) + - FlipperKit/Core (0.211.1): + - Flipper (~> 0.211.1) - FlipperKit/CppBridge - FlipperKit/FBCxxFollyDynamicConvert - FlipperKit/FBDefines - FlipperKit/FKPortForwarding - SocketRocket (~> 0.7.0) - - FlipperKit/CppBridge (0.211.0): - - Flipper (~> 0.211.0) - - FlipperKit/FBCxxFollyDynamicConvert (0.211.0): + - FlipperKit/CppBridge (0.211.1): + - Flipper (~> 0.211.1) + - FlipperKit/FBCxxFollyDynamicConvert (0.211.1): - Flipper-Folly (~> 2.6) - - FlipperKit/FBDefines (0.211.0) - - FlipperKit/FKPortForwarding (0.211.0): + - FlipperKit/FBDefines (0.211.1) + - FlipperKit/FKPortForwarding (0.211.1): - CocoaAsyncSocket (~> 7.6) - Flipper-PeerTalk (~> 0.0.4) - - FlipperKit/FlipperKitExamplePlugin (0.211.0): + - FlipperKit/FlipperKitExamplePlugin (0.211.1): - FlipperKit/Core - - FlipperKit/FlipperKitHighlightOverlay (0.211.0) - - FlipperKit/FlipperKitLayoutHelpers (0.211.0): + - FlipperKit/FlipperKitHighlightOverlay (0.211.1) + - FlipperKit/FlipperKitLayoutHelpers (0.211.1): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutIOSDescriptors (0.211.0): + - FlipperKit/FlipperKitLayoutIOSDescriptors (0.211.1): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutHelpers - - FlipperKit/FlipperKitLayoutPlugin (0.211.0): + - FlipperKit/FlipperKitLayoutPlugin (0.211.1): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutHelpers - FlipperKit/FlipperKitLayoutIOSDescriptors - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutTextSearchable (0.211.0) - - FlipperKit/FlipperKitNetworkPlugin (0.211.0): + - FlipperKit/FlipperKitLayoutTextSearchable (0.211.1) + - FlipperKit/FlipperKitNetworkPlugin (0.211.1): - FlipperKit/Core - - FlipperKit/FlipperKitUserDefaultsPlugin (0.211.0): + - FlipperKit/FlipperKitUserDefaultsPlugin (0.211.1): - FlipperKit/Core - - FlipperKit/SKIOSNetworkPlugin (0.211.0): + - FlipperKit/SKIOSNetworkPlugin (0.211.1): - FlipperKit/Core - FlipperKit/FlipperKitNetworkPlugin - libevent (2.1.12) @@ -100,14 +100,14 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 - Flipper: 320474526dd9b03509ffe2d0eecf21f47c2de363 + Flipper: 1e6dd91229c7d5715a3d0789eb44d473c9e30189 Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c Flipper-DoubleConversion: 2dc99b02f658daf147069aad9dbd29d8feb06d30 Flipper-Fmt: 60cbdd92fc254826e61d669a5d87ef7015396a9b Flipper-Folly: 584845625005ff068a6ebf41f857f468decd26b3 Flipper-Glog: 70c50ce58ddaf67dc35180db05f191692570f446 Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 - FlipperKit: f485471423b8b89870e9b4657d44e94a36ee80cf + FlipperKit: 7241594391e6c44666d7072b81dd739405b99f6d libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d diff --git a/iOS/Tutorial/Podfile b/iOS/Tutorial/Podfile index fb2e9f5c01f..cd3af4a2a09 100644 --- a/iOS/Tutorial/Podfile +++ b/iOS/Tutorial/Podfile @@ -1,6 +1,6 @@ project 'Tutorial.xcodeproj' swift_version = "4.1" -flipperkit_version = '0.211.0' +flipperkit_version = '0.211.1' use_frameworks! target 'Tutorial' do diff --git a/iOS/Tutorial/Podfile.lock b/iOS/Tutorial/Podfile.lock index 4175b98b658..1f0f17adb8e 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.211.0): + - Flipper (0.211.1): - 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.211.0): - - FlipperKit/Core (= 0.211.0) - - FlipperKit/Core (0.211.0): - - Flipper (~> 0.211.0) + - FlipperKit (0.211.1): + - FlipperKit/Core (= 0.211.1) + - FlipperKit/Core (0.211.1): + - Flipper (~> 0.211.1) - FlipperKit/CppBridge - FlipperKit/FBCxxFollyDynamicConvert - FlipperKit/FBDefines - FlipperKit/FKPortForwarding - SocketRocket (~> 0.7.0) - - FlipperKit/CppBridge (0.211.0): - - Flipper (~> 0.211.0) - - FlipperKit/FBCxxFollyDynamicConvert (0.211.0): + - FlipperKit/CppBridge (0.211.1): + - Flipper (~> 0.211.1) + - FlipperKit/FBCxxFollyDynamicConvert (0.211.1): - Flipper-Folly (~> 2.6) - - FlipperKit/FBDefines (0.211.0) - - FlipperKit/FKPortForwarding (0.211.0): + - FlipperKit/FBDefines (0.211.1) + - FlipperKit/FKPortForwarding (0.211.1): - CocoaAsyncSocket (~> 7.6) - Flipper-PeerTalk (~> 0.0.4) - - FlipperKit/FlipperKitHighlightOverlay (0.211.0) - - FlipperKit/FlipperKitLayoutComponentKitSupport (0.211.0): + - FlipperKit/FlipperKitHighlightOverlay (0.211.1) + - FlipperKit/FlipperKitLayoutComponentKitSupport (0.211.1): - ComponentKit (= 0.31) - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay @@ -43,26 +43,26 @@ PODS: - FlipperKit/FlipperKitLayoutPlugin - FlipperKit/FlipperKitLayoutTextSearchable - RenderCore (= 0.31) - - FlipperKit/FlipperKitLayoutHelpers (0.211.0): + - FlipperKit/FlipperKitLayoutHelpers (0.211.1): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutIOSDescriptors (0.211.0): + - FlipperKit/FlipperKitLayoutIOSDescriptors (0.211.1): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutHelpers - - FlipperKit/FlipperKitLayoutPlugin (0.211.0): + - FlipperKit/FlipperKitLayoutPlugin (0.211.1): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutHelpers - FlipperKit/FlipperKitLayoutIOSDescriptors - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutTextSearchable (0.211.0) - - FlipperKit/FlipperKitNetworkPlugin (0.211.0): + - FlipperKit/FlipperKitLayoutTextSearchable (0.211.1) + - FlipperKit/FlipperKitNetworkPlugin (0.211.1): - FlipperKit/Core - - FlipperKit/FlipperKitUserDefaultsPlugin (0.211.0): + - FlipperKit/FlipperKitUserDefaultsPlugin (0.211.1): - FlipperKit/Core - - FlipperKit/SKIOSNetworkPlugin (0.211.0): + - FlipperKit/SKIOSNetworkPlugin (0.211.1): - FlipperKit/Core - FlipperKit/FlipperKitNetworkPlugin - libevent (2.1.12) @@ -72,10 +72,10 @@ PODS: - Yoga (1.14.0) DEPENDENCIES: - - FlipperKit (~> 0.211.0) - - FlipperKit/FlipperKitLayoutComponentKitSupport (~> 0.211.0) - - FlipperKit/FlipperKitUserDefaultsPlugin (~> 0.211.0) - - FlipperKit/SKIOSNetworkPlugin (~> 0.211.0) + - FlipperKit (~> 0.211.1) + - FlipperKit/FlipperKitLayoutComponentKitSupport (~> 0.211.1) + - FlipperKit/FlipperKitUserDefaultsPlugin (~> 0.211.1) + - FlipperKit/SKIOSNetworkPlugin (~> 0.211.1) SPEC REPOS: trunk: @@ -98,20 +98,20 @@ SPEC REPOS: SPEC CHECKSUMS: CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 ComponentKit: 7bf7048b9814afc6b6641645a14177f95fd9b9ae - Flipper: 320474526dd9b03509ffe2d0eecf21f47c2de363 + Flipper: 1e6dd91229c7d5715a3d0789eb44d473c9e30189 Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c Flipper-DoubleConversion: 2dc99b02f658daf147069aad9dbd29d8feb06d30 Flipper-Fmt: 60cbdd92fc254826e61d669a5d87ef7015396a9b Flipper-Folly: 584845625005ff068a6ebf41f857f468decd26b3 Flipper-Glog: 70c50ce58ddaf67dc35180db05f191692570f446 Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 - FlipperKit: f485471423b8b89870e9b4657d44e94a36ee80cf + FlipperKit: 7241594391e6c44666d7072b81dd739405b99f6d libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c RenderCore: 090beb17b5bff80b86929a7ceb49df789923d23a SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d Yoga: cff67a400f6b74dc38eb0bad4f156673d9aa980c -PODFILE CHECKSUM: 70f4a89e4f6f79da5f5ae5f8bd0d91dbd1cbf334 +PODFILE CHECKSUM: 8a74634ef1c7fddeeba5364f45da2b36af0c5bc6 COCOAPODS: 1.12.1 diff --git a/react-native/ReactNativeFlipperExample/ios/Podfile b/react-native/ReactNativeFlipperExample/ios/Podfile index 706b33a3a79..4c0d1198d4d 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.211.0' +flipperkit_version = '0.211.1' target 'ReactNativeFlipperExample' do config = use_native_modules! diff --git a/react-native/ReactNativeFlipperExample/ios/Podfile.lock b/react-native/ReactNativeFlipperExample/ios/Podfile.lock index 80313ec2638..567128f36a8 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.211.0): + - Flipper (0.211.1): - 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.211.0): - - FlipperKit/Core (= 0.211.0) - - FlipperKit/Core (0.211.0): - - Flipper (~> 0.211.0) + - FlipperKit (0.211.1): + - FlipperKit/Core (= 0.211.1) + - FlipperKit/Core (0.211.1): + - Flipper (~> 0.211.1) - FlipperKit/CppBridge - FlipperKit/FBCxxFollyDynamicConvert - FlipperKit/FBDefines - FlipperKit/FKPortForwarding - SocketRocket (~> 0.7.0) - - FlipperKit/CppBridge (0.211.0): - - Flipper (~> 0.211.0) - - FlipperKit/FBCxxFollyDynamicConvert (0.211.0): + - FlipperKit/CppBridge (0.211.1): + - Flipper (~> 0.211.1) + - FlipperKit/FBCxxFollyDynamicConvert (0.211.1): - Flipper-Folly (~> 2.6) - - FlipperKit/FBDefines (0.211.0) - - FlipperKit/FKPortForwarding (0.211.0): + - FlipperKit/FBDefines (0.211.1) + - FlipperKit/FKPortForwarding (0.211.1): - CocoaAsyncSocket (~> 7.6) - Flipper-PeerTalk (~> 0.0.4) - - FlipperKit/FlipperKitHighlightOverlay (0.211.0) - - FlipperKit/FlipperKitLayoutHelpers (0.211.0): + - FlipperKit/FlipperKitHighlightOverlay (0.211.1) + - FlipperKit/FlipperKitLayoutHelpers (0.211.1): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutIOSDescriptors (0.211.0): + - FlipperKit/FlipperKitLayoutIOSDescriptors (0.211.1): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutHelpers - - FlipperKit/FlipperKitLayoutPlugin (0.211.0): + - FlipperKit/FlipperKitLayoutPlugin (0.211.1): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutHelpers - FlipperKit/FlipperKitLayoutIOSDescriptors - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutTextSearchable (0.211.0) - - FlipperKit/FlipperKitNetworkPlugin (0.211.0): + - FlipperKit/FlipperKitLayoutTextSearchable (0.211.1) + - FlipperKit/FlipperKitNetworkPlugin (0.211.1): - FlipperKit/Core - - FlipperKit/FlipperKitReactPlugin (0.211.0): + - FlipperKit/FlipperKitReactPlugin (0.211.1): - FlipperKit/Core - - FlipperKit/FlipperKitUserDefaultsPlugin (0.211.0): + - FlipperKit/FlipperKitUserDefaultsPlugin (0.211.1): - FlipperKit/Core - - FlipperKit/SKIOSNetworkPlugin (0.211.0): + - FlipperKit/SKIOSNetworkPlugin (0.211.1): - 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.211.0) + - Flipper (= 0.211.1) - 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.211.0) - - FlipperKit/Core (= 0.211.0) - - FlipperKit/CppBridge (= 0.211.0) - - FlipperKit/FBCxxFollyDynamicConvert (= 0.211.0) - - FlipperKit/FBDefines (= 0.211.0) - - FlipperKit/FKPortForwarding (= 0.211.0) - - FlipperKit/FlipperKitHighlightOverlay (= 0.211.0) - - FlipperKit/FlipperKitLayoutPlugin (= 0.211.0) - - FlipperKit/FlipperKitLayoutTextSearchable (= 0.211.0) - - FlipperKit/FlipperKitNetworkPlugin (= 0.211.0) - - FlipperKit/FlipperKitReactPlugin (= 0.211.0) - - FlipperKit/FlipperKitUserDefaultsPlugin (= 0.211.0) - - FlipperKit/SKIOSNetworkPlugin (= 0.211.0) + - FlipperKit (= 0.211.1) + - FlipperKit/Core (= 0.211.1) + - FlipperKit/CppBridge (= 0.211.1) + - FlipperKit/FBCxxFollyDynamicConvert (= 0.211.1) + - FlipperKit/FBDefines (= 0.211.1) + - FlipperKit/FKPortForwarding (= 0.211.1) + - FlipperKit/FlipperKitHighlightOverlay (= 0.211.1) + - FlipperKit/FlipperKitLayoutPlugin (= 0.211.1) + - FlipperKit/FlipperKitLayoutTextSearchable (= 0.211.1) + - FlipperKit/FlipperKitNetworkPlugin (= 0.211.1) + - FlipperKit/FlipperKitReactPlugin (= 0.211.1) + - FlipperKit/FlipperKitUserDefaultsPlugin (= 0.211.1) + - FlipperKit/SKIOSNetworkPlugin (= 0.211.1) - 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: 320474526dd9b03509ffe2d0eecf21f47c2de363 + Flipper: 1e6dd91229c7d5715a3d0789eb44d473c9e30189 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: f485471423b8b89870e9b4657d44e94a36ee80cf + FlipperKit: 7241594391e6c44666d7072b81dd739405b99f6d fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 glog: 3d02b25ca00c2d456734d0bcff864cbc62f6ae1a hermes-engine: 51aaceb1f6dc1aed44b8bbf866f52ec146c00a89 @@ -572,6 +572,6 @@ SPEC CHECKSUMS: SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d Yoga: 0b84a956f7393ef1f37f3bb213c516184e4a689d -PODFILE CHECKSUM: 5d389a4102f2d7739d79675fa1522efcc4501d17 +PODFILE CHECKSUM: 528106f29ff09cea7bc30cd3d1eda97fcce12eae COCOAPODS: 1.12.1 From b45eed0e9a87b7349c08e8d253f513df500ce2a2 Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Thu, 17 Aug 2023 08:57:55 -0700 Subject: [PATCH 36/98] 'Capture' cancel on file import Summary: There's no explicit way of knowing if the file selection dialog was dismissed/canceled without a selection. Instead, subscribe once to the windows focus event, as it will the event will be received when this happens. Reviewed By: antonk52 Differential Revision: D48434187 fbshipit-source-id: dd20c55885bb3ef6bef423e17a2606d71ede288d --- .../src/initializeRenderHost.tsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/desktop/flipper-ui-browser/src/initializeRenderHost.tsx b/desktop/flipper-ui-browser/src/initializeRenderHost.tsx index e09d34468ec..97d0c580c72 100644 --- a/desktop/flipper-ui-browser/src/initializeRenderHost.tsx +++ b/desktop/flipper-ui-browser/src/initializeRenderHost.tsx @@ -11,6 +11,7 @@ import { FlipperServer, FlipperServerConfig, isProduction, + uuid, wrapRequire, } from 'flipper-common'; import type {RenderHost} from 'flipper-ui-core'; @@ -61,14 +62,18 @@ export function initializeRenderHost( return new Promise( (resolve, reject) => { try { + let selectionMade = false; + const fileInput = document.createElement('input'); fileInput.type = 'file'; + fileInput.id = uuid(); if (options?.extensions) { fileInput.accept = options?.extensions.join(', '); } fileInput.multiple = options?.multi ?? false; fileInput.addEventListener('change', async (event) => { + selectionMade = true; const target = event.target as HTMLInputElement | undefined; if (!target || !target.files) { resolve(undefined); @@ -106,6 +111,18 @@ export function initializeRenderHost( resolve(options?.multi ? descriptors : descriptors[0]); }); + window.addEventListener( + 'focus', + () => { + setTimeout(() => { + if (!selectionMade) { + resolve(undefined); + } + }, 300); + }, + {once: true}, + ); + fileInput.click(); } catch (error) { reject(error); From fb47b70d36f515e0d94a579d8519b1b275143248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=BAlvio=20Abrah=C3=A3o=20de=20Paula?= Date: Thu, 17 Aug 2023 11:19:50 -0700 Subject: [PATCH 37/98] Parse NSDictionary in ObjectMapper. Summary: Some objects returned from sqlite in json blob is a NSDictionary, we need to parse data at this case. Differential Revision: D48394361 fbshipit-source-id: c977ebdd33c392fca77741cdacdeb0c975e2ca36 --- .../FlipperKitDatabasesPlugin/ObjectMapper.m | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m index 14fa42d5b5e..9129714567c 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m @@ -151,6 +151,25 @@ + (NSDictionary*)objectAndTypeToFlipperObject:(id)object { } else if ([object isKindOfClass:[NSData class]]) { NSString* blobString = [self blobToString:(NSData*)object]; return @{@"type" : @"blob", @"value" : blobString}; + } else if ([object isKindOfClass:[NSDictionary class]]) { + // Usualy the dictionary is a Json blob, and we can parse it as string. + NSError* error; + NSData* jsonData = [NSJSONSerialization dataWithJSONObject:object + options:0 + error:&error]; + if (!jsonData) { + NSString* reason = [NSString + stringWithFormat:@"NSDictionary is not in a json format: %@", + [error localizedDescription]]; + @throw [NSException exceptionWithName:@"InvalidArgumentException" + reason:reason + userInfo:nil]; + } + + NSString* jsonString = [[NSString alloc] initWithData:jsonData + encoding:NSUTF8StringEncoding]; + return @{@"type" : @"blob", @"value" : jsonString}; + } else if ([object isKindOfClass:[NSValue class]]) { return @{@"type" : @"boolean", @"value" : object}; } else { From 9728155cbf865e08e551fe1eb606f48f96a4073a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=BAlvio=20Abrah=C3=A3o=20de=20Paula?= Date: Thu, 17 Aug 2023 11:19:50 -0700 Subject: [PATCH 38/98] Consider NSNull object as type=null in ObjectMapper. Summary: nil objects from sqlite is NSNull object, so we need to consider this case in the ObjectMapper as well. Differential Revision: D48394360 fbshipit-source-id: 61bcdb03cb4cbf17a2fef000a5a61ac2f2c035dd --- .../FlipperKitDatabasesPlugin/ObjectMapper.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m index 9129714567c..ffb2e54710e 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/ObjectMapper.m @@ -127,7 +127,7 @@ + (NSDictionary*)databaseExecuteSqlResponseToDictionary: } + (NSDictionary*)objectAndTypeToFlipperObject:(id)object { - if (!object) { + if (!object || [object isKindOfClass:[NSNull class]]) { return @{@"type" : @"null"}; } else if ([object isKindOfClass:[NSNumber class]]) { NSNumber* number = (NSNumber*)object; From ce13ee426ff2127b2c35b20a8dd168b5fb074f26 Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Thu, 17 Aug 2023 13:46:08 -0700 Subject: [PATCH 39/98] Open file import Summary: This change only adds the PWA as capable of handling files with the ".flipper" extension. Reviewed By: aigoncharov Differential Revision: D48353437 fbshipit-source-id: fd78942ac4dffb7d26d5ca5be826290018465b93 --- .../flipper-frontend-core/src/RenderHost.tsx | 4 +- desktop/flipper-ui-browser/src/index.tsx | 72 +++++++++++++++++++ .../src/initializeRenderHost.tsx | 10 +-- .../src/dispatcher/application.tsx | 6 +- .../flipper-ui-core/src/dispatcher/index.tsx | 16 +++-- .../src/sandy-chrome/SandyApp.tsx | 1 - .../src/startFlipperDesktop.tsx | 23 +++--- .../flipper-ui-core/src/utils/exportData.tsx | 5 +- desktop/static/index.web.dev.html | 19 ----- desktop/static/index.web.html | 21 +----- desktop/static/main.tsx | 63 ++++++++-------- desktop/static/manifest.template.json | 10 +++ desktop/static/service-worker.js | 6 +- 13 files changed, 150 insertions(+), 106 deletions(-) diff --git a/desktop/flipper-frontend-core/src/RenderHost.tsx b/desktop/flipper-frontend-core/src/RenderHost.tsx index 27a4a057701..1662b40dd1e 100644 --- a/desktop/flipper-frontend-core/src/RenderHost.tsx +++ b/desktop/flipper-frontend-core/src/RenderHost.tsx @@ -67,7 +67,7 @@ interface NotificationConstructorOptions { // Events that are emitted from the main.ts ovr the IPC process bridge in Electron type MainProcessEvents = { 'flipper-protocol-handler': [query: string]; - 'open-flipper-file': [url: string]; + 'open-flipper-file': [name: string, data: string]; notificationEvent: [ eventName: NotificationEvents, pluginNotification: PluginNotification, @@ -88,7 +88,7 @@ type ChildProcessEvents = { }, ]; getLaunchTime: []; - componentDidMount: []; + storeRehydrated: []; }; /** diff --git a/desktop/flipper-ui-browser/src/index.tsx b/desktop/flipper-ui-browser/src/index.tsx index 06b79d61b7f..f836700b561 100644 --- a/desktop/flipper-ui-browser/src/index.tsx +++ b/desktop/flipper-ui-browser/src/index.tsx @@ -71,6 +71,7 @@ async function start() { const flipperServerConfig = await flipperServer.exec('get-config'); initializeRenderHost(flipperServer, flipperServerConfig); + initializePWA(); // By turning this in a require, we force the JS that the body of this module (init) has completed (initializeElectron), // before starting the rest of the Flipper process. @@ -78,6 +79,7 @@ async function start() { // but not set yet, which might happen when using normal imports. // TODO: remove window.flipperShowError?.('Connected to Flipper Server successfully'); + // @ts-ignore // eslint-disable-next-line import/no-commonjs require('flipper-ui-core').startFlipperDesktop(flipperServer); @@ -89,6 +91,76 @@ start().catch((e) => { window.flipperShowError?.('Failed to start flipper-ui-browser: ' + e); }); +async function initializePWA() { + console.log('[PWA] Initialization'); + + let cachedFile: {name: string; data: string} | undefined; + let rehydrated = false; + const openFileIfAny = () => { + if (!cachedFile || !rehydrated) { + return; + } + window.dispatchEvent( + new CustomEvent('open-flipper-file', { + detail: [cachedFile.name, cachedFile.data], + }), + ); + cachedFile = undefined; + }; + + if ('serviceWorker' in navigator) { + navigator.serviceWorker + .register('/service-worker.js') + .then(() => { + console.log('[PWA] Service Worker has been registered'); + }) + .catch((e) => { + console.error('[PWA] failed to register Service Worker', e); + }); + } + + if ('launchQueue' in window) { + console.log('[PWA] File Handling API is supported'); + + // @ts-ignore + window.launchQueue.setConsumer(async (launchParams) => { + if (!launchParams || !launchParams.files) { + return; + } + console.log('[PWA] Attempt to to open a file'); + for (const file of launchParams.files) { + const blob = await file.getFile(); + blob.handle = file; + + const data = await blob.text(); + const name = file.name; + + cachedFile = {name, data}; + + openFileIfAny(); + } + }); + } else { + console.warn('[PWA] File Handling API is not supported'); + } + + console.log('[PWA] Add before install prompt listener'); + window.addEventListener('beforeinstallprompt', (e) => { + // Prevent Chrome 67 and earlier from automatically showing the prompt. + e.preventDefault(); + // Stash the event so it can be triggered later. + // @ts-ignore + global.PWAppInstallationEvent = e; + console.log('[PWA] Installation event has been captured'); + }); + + window.addEventListener('storeRehydrated', () => { + console.info('[PWA] Store is rehydrated'); + rehydrated = true; + openFileIfAny(); + }); +} + // getLogger() is not yet created when the electron app starts. // we can't create it here yet, as the real logger is wired up to // the redux store and the rest of the world. So we create a delegating logger diff --git a/desktop/flipper-ui-browser/src/initializeRenderHost.tsx b/desktop/flipper-ui-browser/src/initializeRenderHost.tsx index 97d0c580c72..4decaff5f81 100644 --- a/desktop/flipper-ui-browser/src/initializeRenderHost.tsx +++ b/desktop/flipper-ui-browser/src/initializeRenderHost.tsx @@ -153,11 +153,13 @@ export function initializeRenderHost( hasFocus() { return document.hasFocus(); }, - onIpcEvent(_event) { - // no-op + onIpcEvent(event, cb) { + window.addEventListener(event as string, (ev) => { + cb(...((ev as CustomEvent).detail as any)); + }); }, - sendIpcEvent(_event, ..._args: any[]) { - // no-op + sendIpcEvent(event, ...args: any[]) { + window.dispatchEvent(new CustomEvent(event, {detail: args})); }, shouldUseDarkColors() { return !!( diff --git a/desktop/flipper-ui-core/src/dispatcher/application.tsx b/desktop/flipper-ui-core/src/dispatcher/application.tsx index 903443ca2fc..936b23e6178 100644 --- a/desktop/flipper-ui-core/src/dispatcher/application.tsx +++ b/desktop/flipper-ui-core/src/dispatcher/application.tsx @@ -10,7 +10,7 @@ import {Store} from '../reducers/index'; import {Logger} from 'flipper-common'; import { - importFileToStore, + importDataToStore, IMPORT_FLIPPER_TRACE_EVENT, } from '../utils/exportData'; import {tryCatchReportPlatformFailures} from 'flipper-common'; @@ -67,9 +67,9 @@ export default (store: Store, logger: Logger) => { }); }); - renderHost.onIpcEvent('open-flipper-file', (url: string) => { + renderHost.onIpcEvent('open-flipper-file', (name: string, data: string) => { tryCatchReportPlatformFailures(() => { - return importFileToStore(url, store); + return importDataToStore(name, data, store); }, `${IMPORT_FLIPPER_TRACE_EVENT}:Deeplink`); }); }; diff --git a/desktop/flipper-ui-core/src/dispatcher/index.tsx b/desktop/flipper-ui-core/src/dispatcher/index.tsx index 1e9090b38b4..ebd445f2f96 100644 --- a/desktop/flipper-ui-core/src/dispatcher/index.tsx +++ b/desktop/flipper-ui-core/src/dispatcher/index.tsx @@ -26,7 +26,10 @@ import {Store} from '../reducers/index'; import {Dispatcher} from './types'; import {notNull} from '../utils/typeUtils'; -export default function (store: Store, logger: Logger): () => Promise { +export default async function ( + store: Store, + logger: Logger, +): Promise<() => Promise> { // This only runs in development as when the reload // kicks in it doesn't unregister the shortcuts const dispatchers: Array = [ @@ -43,10 +46,11 @@ export default function (store: Store, logger: Logger): () => Promise { pluginChangeListener, pluginsSourceUpdateListener, ].filter(notNull); - const globalCleanup = dispatchers - .map((dispatcher) => dispatcher(store, logger)) - .filter(Boolean); - return () => { - return Promise.all(globalCleanup).then(() => {}); + const globalCleanup = await Promise.all( + dispatchers.map((dispatcher) => dispatcher(store, logger)).filter(Boolean), + ); + + return async () => { + await Promise.all(globalCleanup); }; } diff --git a/desktop/flipper-ui-core/src/sandy-chrome/SandyApp.tsx b/desktop/flipper-ui-core/src/sandy-chrome/SandyApp.tsx index 543f738d64c..dfdb3356806 100644 --- a/desktop/flipper-ui-core/src/sandy-chrome/SandyApp.tsx +++ b/desktop/flipper-ui-core/src/sandy-chrome/SandyApp.tsx @@ -196,5 +196,4 @@ function registerStartupTime(logger: Logger) { }); renderHost.sendIpcEvent('getLaunchTime'); - renderHost.sendIpcEvent('componentDidMount'); } diff --git a/desktop/flipper-ui-core/src/startFlipperDesktop.tsx b/desktop/flipper-ui-core/src/startFlipperDesktop.tsx index 2e4a9edc3c3..b19f9b5faf6 100644 --- a/desktop/flipper-ui-core/src/startFlipperDesktop.tsx +++ b/desktop/flipper-ui-core/src/startFlipperDesktop.tsx @@ -149,9 +149,10 @@ function init(flipperServer: FlipperServer) { loadTheme(settings.darkMode); // rehydrate app state before exposing init - const persistor = persistStore(store, undefined, () => { + const persistor = persistStore(store, undefined, async () => { // Make sure process state is set before dispatchers run - dispatcher(store, logger); + await dispatcher(store, logger); + getRenderHostInstance().sendIpcEvent('storeRehydrated'); }); setPersistor(persistor); @@ -168,17 +169,17 @@ function init(flipperServer: FlipperServer) { connectFlipperServerToStore(flipperServer, store, logger); + enableConsoleHook(); + enableConnectivityHook(flipperServer); + // TODO T116224873: Return the following code back instead of ReactDOM.react when the following issue is fixed: https://github.com/react-component/trigger/issues/288 // const root = createRoot(document.getElementById('root')!); // root.render(); - ReactDOM.render( - , - document.getElementById('root')!, - ); - - enableConsoleHook(); - enableConnectivityHook(flipperServer); + const root = document.getElementById('root'); + if (root) { + ReactDOM.render(, root); + } const launcherMessage = getRenderHostInstance().serverConfig.processConfig.launcherMsg; @@ -193,8 +194,8 @@ function init(flipperServer: FlipperServer) { } } -export async function startFlipperDesktop(flipperServer: FlipperServer) { - getRenderHostInstance(); // renderHost instance should be set at this point! +export function startFlipperDesktop(flipperServer: FlipperServer) { + getRenderHostInstance(); init(flipperServer); } diff --git a/desktop/flipper-ui-core/src/utils/exportData.tsx b/desktop/flipper-ui-core/src/utils/exportData.tsx index 2bcfb4356b7..f2de950a44d 100644 --- a/desktop/flipper-ui-core/src/utils/exportData.tsx +++ b/desktop/flipper-ui-core/src/utils/exportData.tsx @@ -30,7 +30,7 @@ import {TestIdler} from './Idler'; import {processMessageQueue} from './messageQueue'; import {getPluginTitle} from './pluginUtils'; import {capture} from './screenshot'; -import {Dialog, getFlipperLib, Idler, path} from 'flipper-plugin'; +import {Dialog, getFlipperLib, Idler} from 'flipper-plugin'; import {ClientQuery} from 'flipper-common'; import ShareSheetExportUrl from '../chrome/ShareSheetExportUrl'; import ShareSheetExportFile from '../chrome/ShareSheetExportFile'; @@ -43,6 +43,7 @@ import {safeFilename} from './safeFilename'; import {getExportablePlugins} from '../selectors/connections'; import {notification} from 'antd'; import openSupportRequestForm from '../fb-stubs/openSupportRequestForm'; +import {getStore} from '../store'; export const IMPORT_FLIPPER_TRACE_EVENT = 'import-flipper-trace'; export const EXPORT_FLIPPER_TRACE_EVENT = 'export-flipper-trace'; @@ -526,7 +527,7 @@ export const exportStoreToFile = ( export async function importDataToStore( source: string, data: string, - store: Store, + store: Store = getStore(), ) { getLogger().track('usage', IMPORT_FLIPPER_TRACE_EVENT); const json: ExportType = JSON.parse(data); diff --git a/desktop/static/index.web.dev.html b/desktop/static/index.web.dev.html index 64f8808e539..8d27031d5f1 100644 --- a/desktop/static/index.web.dev.html +++ b/desktop/static/index.web.dev.html @@ -138,25 +138,6 @@ document.body.appendChild(script); } - if ('serviceWorker' in navigator) { - navigator.serviceWorker - .register('/service-worker.js') - .then(() => { - console.log('Flipper Service Worker has been registered'); - }) - .catch((e) => { - console.error('Flipper failed to register Service Worker', e); - }); - } - - window.addEventListener('beforeinstallprompt', (e) => { - console.log('Flipper PWA before install prompt with event', e); - // Prevent Chrome 67 and earlier from automatically showing the prompt. - e.preventDefault(); - // Stash the event so it can be triggered later. - global.PWAppInstallationEvent = e; - }); - init(); })(); diff --git a/desktop/static/index.web.html b/desktop/static/index.web.html index 9095cb6d128..3a1e68d9ff5 100644 --- a/desktop/static/index.web.html +++ b/desktop/static/index.web.html @@ -59,7 +59,7 @@ -