flipper-plugin-player-ui-devtools 0.0.2-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "sideEffects": false,
3
+ "files": [
4
+ "dist",
5
+ "src",
6
+ "types"
7
+ ],
8
+ "$schema": "https://fbflipper.com/schemas/plugin-package/v2.json",
9
+ "name": "flipper-plugin-player-ui-devtools",
10
+ "id": "player-ui-devtools",
11
+ "pluginType": "client",
12
+ "version": "0.0.2-next.0",
13
+ "main": "dist/index.js",
14
+ "dependencies": {
15
+ "@player-devtools/client": "0.0.2-next.0",
16
+ "@player-devtools/types": "0.0.2-next.0",
17
+ "dlv": "^1.1.3",
18
+ "@chakra-ui/anatomy": "2.3.4",
19
+ "@types/react": "^18.2.51"
20
+ },
21
+ "flipperBundlerEntry": "src/index.tsx",
22
+ "keywords": [
23
+ "flipper-plugin",
24
+ "@flipper-plugin/player-ui",
25
+ "player-ui-devtools"
26
+ ],
27
+ "icon": "apps",
28
+ "title": "Player UI Devtools",
29
+ "description": "A Flipper plugin able to interact with an active Player instance",
30
+ "peerDependencies": {
31
+ "flipper-plugin": "^0.212.0",
32
+ "react": "^18.2.0",
33
+ "@chakra-ui/react": "2.8.2",
34
+ "@emotion/styled": "^11"
35
+ }
36
+ }
package/src/index.tsx ADDED
@@ -0,0 +1,109 @@
1
+ import React, { Suspense, useEffect, useState } from "react";
2
+ import {
3
+ type PluginClient,
4
+ Layout,
5
+ usePlugin,
6
+ theme as baseTheme,
7
+ } from "flipper-plugin";
8
+ import type {
9
+ CommunicationLayerMethods,
10
+ ExtensionSupportedEvents,
11
+ MessengerEvent,
12
+ TransactionMetadata,
13
+ } from "@player-devtools/types";
14
+ import { Panel } from "@player-devtools/client";
15
+ import {
16
+ Button,
17
+ ChakraProvider,
18
+ ColorModeScript,
19
+ DarkMode,
20
+ defineStyle,
21
+ defineStyleConfig,
22
+ extendTheme,
23
+ Input,
24
+ LightMode,
25
+ ThemeConfig,
26
+ useBoolean,
27
+ useColorMode,
28
+ theme as ChakraTheme,
29
+ Box,
30
+ Spinner,
31
+ } from "@chakra-ui/react";
32
+ import { ThemeProvider, useDarkMode } from "@devtools-ds/themes";
33
+ import { Select } from "./theme/select";
34
+ import { Table } from "./theme/table";
35
+
36
+ const ID = "flipper-plugin-player-ui-devtools";
37
+
38
+ type Events = {
39
+ /** message received */
40
+ "message::plugin": MessengerEvent<ExtensionSupportedEvents> &
41
+ TransactionMetadata;
42
+ };
43
+
44
+ type Methods = {
45
+ /** message sent */
46
+ "message::flipper": (
47
+ message: MessengerEvent<ExtensionSupportedEvents>,
48
+ ) => Promise<void>;
49
+ };
50
+
51
+ /** Flipper desktop plugin */
52
+ export function plugin(
53
+ client: PluginClient<Events, Methods>,
54
+ ): CommunicationLayerMethods {
55
+ const listeners: Array<
56
+ (
57
+ message: MessengerEvent<ExtensionSupportedEvents> & TransactionMetadata,
58
+ ) => void
59
+ > = [];
60
+
61
+ client.onConnect(() => {
62
+ client.onMessage("message::plugin", (message) => {
63
+ listeners.forEach((listener) => listener(message));
64
+ });
65
+ });
66
+
67
+ return {
68
+ sendMessage: async (message: MessengerEvent<ExtensionSupportedEvents>) => {
69
+ client.send("message::flipper", message);
70
+ },
71
+ addListener: (
72
+ listener: (
73
+ message: MessengerEvent<ExtensionSupportedEvents> & TransactionMetadata,
74
+ ) => void,
75
+ ) => {
76
+ listeners.push(listener);
77
+ },
78
+ removeListener: (
79
+ listener: (
80
+ message: MessengerEvent<ExtensionSupportedEvents> & TransactionMetadata,
81
+ ) => void,
82
+ ) => {
83
+ const index = listeners.indexOf(listener);
84
+ if (index > -1) {
85
+ listeners.splice(index, 1);
86
+ }
87
+ },
88
+ };
89
+ }
90
+
91
+ /** Flipper desktop plugin component */
92
+ export const Component: React.FC = () => {
93
+ const communicationLayer = usePlugin(plugin);
94
+
95
+ return (
96
+ <Suspense fallback={<Spinner size="xl" />}>
97
+ <Layout.Container id={ID} pad="medium">
98
+ <Box
99
+ sx={{
100
+ // Scoped style fixes for our devtools client
101
+ p: { margin: 0 },
102
+ }}
103
+ >
104
+ <Panel communicationLayer={communicationLayer} />
105
+ </Box>
106
+ </Layout.Container>
107
+ </Suspense>
108
+ );
109
+ };
@@ -0,0 +1,18 @@
1
+ import { selectAnatomy } from "@chakra-ui/anatomy";
2
+ import { createMultiStyleConfigHelpers } from "@chakra-ui/react";
3
+ import { theme } from "flipper-plugin";
4
+
5
+ const { definePartsStyle, defineMultiStyleConfig } =
6
+ createMultiStyleConfigHelpers(selectAnatomy.keys);
7
+
8
+ export const Select = defineMultiStyleConfig({
9
+ baseStyle: definePartsStyle({
10
+ field: {
11
+ background: theme.buttonDefaultBackground,
12
+ color: theme.textColorPrimary,
13
+ },
14
+ icon: {
15
+ color: theme.textColorPrimary,
16
+ },
17
+ }),
18
+ });
@@ -0,0 +1,22 @@
1
+ import { tableAnatomy } from "@chakra-ui/anatomy";
2
+ import { createMultiStyleConfigHelpers } from "@chakra-ui/react";
3
+ import { theme } from "flipper-plugin";
4
+
5
+ const { definePartsStyle, defineMultiStyleConfig } =
6
+ createMultiStyleConfigHelpers(tableAnatomy.keys);
7
+
8
+ export const Table = defineMultiStyleConfig({
9
+ baseStyle: definePartsStyle({
10
+ table: {
11
+ lineHeight: 1,
12
+ },
13
+ td: {
14
+ lineHeight: 1,
15
+ color: theme.textColorPrimary,
16
+ },
17
+ th: {
18
+ lineHeight: 1,
19
+ color: theme.textColorSecondary,
20
+ },
21
+ }),
22
+ });