Device plugin management (5/n): Docs
Summary: Updated docs to mention the new way of specifying device plugins compatibility metadata. Reviewed By: mweststrate Differential Revision: D26424203 fbshipit-source-id: 313e15ee54a8877c95850a37a13c5684b3c165f0
This commit is contained in:
committed by
Facebook GitHub Bot
parent
68248a7c63
commit
1c898bd2da
@@ -44,6 +44,7 @@ After scaffolding a new plugin has finished, you should have files `package.json
|
||||
"$schema": "https://fbflipper.com/schemas/plugin-package/v2.json",
|
||||
"name": "flipper-plugin-myplugin",
|
||||
"id": "myplugin",
|
||||
"pluginType": "client",
|
||||
"version": "1.0.0",
|
||||
"main": "dist/bundle.js",
|
||||
"flipperBundlerEntry": "src/index.tsx",
|
||||
@@ -80,6 +81,8 @@ Important attributes of `package.json`:
|
||||
|
||||
- `id` Used as the plugin native identifier and **must match the mobile plugin identifier**, e.g. returned by `getId` method of your Java plugin.
|
||||
|
||||
- `pluginType` Specifies type of the plugin - client or device. See section [Anatomy of a Desktop plugin](#anatomy-of-a-desktop-plugin) for details.
|
||||
|
||||
- `main` Points to the plugin bundle which will be loaded by Flipper. The "flipper-pkg" utility uses this field to determine output location during plugin bundling.
|
||||
|
||||
- `flipperBundlerEntry` Points to the source entry point which will be used for plugin code bundling. "flipper-pkg" takes the path specified in `flipperBundlerEntry` as source, transpiles and bundles it, and saves the output to the path specified in `main`.
|
||||
@@ -144,12 +147,6 @@ Their entry module anatomy is:
|
||||
```typescript
|
||||
import {DevicePluginClient} from 'flipper-plugin';
|
||||
|
||||
export function supportsDevice(device: Device) {
|
||||
// based on the device meta-data,
|
||||
// determine whether this plugin should be enabled
|
||||
return true;
|
||||
}
|
||||
|
||||
export function devicePlugin(client: DevicePluginClient) {
|
||||
return {}; // API exposed from this plugin
|
||||
}
|
||||
@@ -160,6 +157,25 @@ export function Component() {
|
||||
}
|
||||
```
|
||||
|
||||
Desktop plugins must have the property `pluginType` set to `device` in their package.json. They should also specify supported devices using property `supportedDevices`
|
||||
in package.json. The property should contain an array of supported devices each defined as conjunction of device properties in the following format:
|
||||
`{ "os": <"Android" | "iOS" | "Metro">, "type": <"physical" | "emulator">, "archived": <true | false> }`. For example: `{ "os": "Android", "type": "emulator" }` means
|
||||
that device must work on Android AND must be an emulator in order to debug it using the plugin.
|
||||
To specify that plugin supports all types of Android devices, and physical iOS devices, and does not support imported (archived) data, the plugin package.json should look like that:
|
||||
```json
|
||||
{
|
||||
"$schema": "https://fbflipper.com/schemas/plugin-package/v2.json",
|
||||
"name": "flipper-plugin-mydeviceplugin",
|
||||
"id": "mydeviceplugin",
|
||||
"pluginType": "device",
|
||||
"supportedDevices": [
|
||||
{"os": "Android", "archived": false},
|
||||
{"os": "iOS", "type": "physical", "archived": false}
|
||||
]
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Device plugins work in general similar to normal client plugins, so aren't worked out in detail in this document.
|
||||
The available APIs for device plugins are listed [here](./flipper-plugin#devicepluginclient).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user