Make getFlipperLib generally available, and use it to decouple opening links from Electron

Summary:
This stack reduces our direct dependency on Electron, for example by exposing our own API to open links.

Also exposing `getFlipperLib` as API from `flipper-plugin`, so that these utility methods are available outside plugin contexts as well.

Reviewed By: timur-valiev

Differential Revision: D29661689

fbshipit-source-id: 0c0523326eeb0d9d8fbe3e03c4609327bb53596b
This commit is contained in:
Michel Weststrate
2021-07-15 01:51:58 -07:00
committed by Facebook GitHub Bot
parent 2b236c6114
commit 5dbd3bd414
20 changed files with 60 additions and 54 deletions

View File

@@ -27,7 +27,6 @@ import {
EXPORT_FLIPPER_TRACE_EVENT,
displayFetchMetadataErrors,
} from '../utils/exportData';
import {clipboard} from 'electron';
import ShareSheetErrorList from './ShareSheetErrorList';
import {reportPlatformFailures} from '../utils/metrics';
import CancellableExportStatus from './CancellableExportStatus';
@@ -36,6 +35,7 @@ import ShareSheetPendingDialog from './ShareSheetPendingDialog';
import {getInstance as getLogger} from '../fb-stubs/Logger';
import {resetSupportFormV2State} from '../reducers/supportForm';
import {MiddlewareAPI} from '../reducers/index';
import {getFlipperLib} from 'flipper-plugin';
export const SHARE_FLIPPER_TRACE_EVENT = 'share-flipper-link';
@@ -148,7 +148,7 @@ export default class ShareSheetExportUrl extends Component<Props, State> {
if (flipperUrl) {
this.store.dispatch(setExportURL(flipperUrl));
if (this.state.runInBackground) {
clipboard.writeText(String(flipperUrl));
getFlipperLib().writeTextToClipboard(String(flipperUrl));
new Notification('Shareable Flipper Export created', {
body: 'URL copied to clipboard',
requireInteraction: true,