@player-tools/devtools-client 0.6.1-next.2 → 0.6.1-next.3
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/dist/cjs/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.legacy-esm.js +3 -5
- package/dist/index.mjs +3 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/panel/index.tsx +47 -43
package/dist/cjs/index.cjs
CHANGED
|
@@ -304,7 +304,7 @@ var Panel = ({
|
|
|
304
304
|
}
|
|
305
305
|
}, [reactPlayer, state]);
|
|
306
306
|
const Component = reactPlayer.Component;
|
|
307
|
-
return /* @__PURE__ */ import_react3.default.createElement(import_react6.ChakraProvider, { theme }, /* @__PURE__ */ import_react3.default.createElement(import_themes.ThemeProvider, { colorScheme: "dark" }, /* @__PURE__ */ import_react3.default.createElement(import_react_error_boundary.ErrorBoundary, { fallbackRender }, /* @__PURE__ */ import_react3.default.createElement(import_react6.
|
|
307
|
+
return /* @__PURE__ */ import_react3.default.createElement(import_react6.ChakraProvider, { theme }, /* @__PURE__ */ import_react3.default.createElement(import_themes.ThemeProvider, { colorScheme: "dark" }, /* @__PURE__ */ import_react3.default.createElement(import_react_error_boundary.ErrorBoundary, { fallbackRender }, /* @__PURE__ */ import_react3.default.createElement(import_react6.Flex, { direction: "column", w: "100vw", h: "100vh", alignItems: "normal" }, state.current.player ? /* @__PURE__ */ import_react3.default.createElement(import_react6.Container, { minWidth: "100%" }, /* @__PURE__ */ import_react3.default.createElement(import_react6.Flex, { direction: "column", marginTop: "4" }, /* @__PURE__ */ import_react3.default.createElement(import_react6.Flex, { gap: "8" }, /* @__PURE__ */ import_react3.default.createElement(import_react6.FormControl, null, /* @__PURE__ */ import_react3.default.createElement(import_react6.FormLabel, null, "Player"), /* @__PURE__ */ import_react3.default.createElement(
|
|
308
308
|
import_react6.Select,
|
|
309
309
|
{
|
|
310
310
|
id: "player",
|
|
@@ -322,7 +322,7 @@ var Panel = ({
|
|
|
322
322
|
Object.keys(
|
|
323
323
|
state.players[state.current.player].plugins
|
|
324
324
|
).map((pluginID) => /* @__PURE__ */ import_react3.default.createElement("option", { key: pluginID, value: pluginID }, pluginID))
|
|
325
|
-
))), /* @__PURE__ */ import_react3.default.createElement(import_react6.
|
|
325
|
+
))), /* @__PURE__ */ import_react3.default.createElement(import_react6.Flex, null, /* @__PURE__ */ import_react3.default.createElement(Component, null)), /* @__PURE__ */ import_react3.default.createElement("details", null, /* @__PURE__ */ import_react3.default.createElement("summary", null, "Debug"), /* @__PURE__ */ import_react3.default.createElement("pre", { style: { maxHeight: "30vh", overflow: "scroll" } }, JSON.stringify(state, null, 2))))) : /* @__PURE__ */ import_react3.default.createElement(import_react6.Flex, { justifyContent: "center", padding: "6" }, /* @__PURE__ */ import_react3.default.createElement(import_react6.Text, null, "No Player-UI instance or devtools plugin detected. Visit", " ", /* @__PURE__ */ import_react3.default.createElement("a", { href: "https://player-ui.github.io/" }, "https://player-ui.github.io/"), " ", "for more info."))))));
|
|
326
326
|
};
|
|
327
327
|
// Annotate the CommonJS export names for ESM import in node:
|
|
328
328
|
0 && (module.exports = {
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/panel/index.tsx","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/constants/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/plugins/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/state/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/state/reducer.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/helpers/flowDiff.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/panel/theme.ts"],"sourcesContent":["export { Panel } from \"./panel\";\n","import React, { useRef } from \"react\";\nimport type {\n MessengerOptions,\n ExtensionSupportedEvents,\n} from \"@player-tools/devtools-types\";\nimport { DataController, Flow, useReactPlayer } from \"@player-ui/react\";\nimport { useEffect } from \"react\";\nimport { ErrorBoundary } from \"react-error-boundary\";\nimport {\n Card,\n CardBody,\n CardHeader,\n ChakraProvider,\n Container,\n Flex,\n FormControl,\n FormLabel,\n Heading,\n HStack,\n Select,\n Text,\n VStack,\n} from \"@chakra-ui/react\";\nimport { ThemeProvider } from \"@devtools-ds/themes\";\n\nimport { INITIAL_FLOW } from \"../constants\";\nimport { PLAYER_PLUGINS, PUBSUB_PLUGIN } from \"../plugins\";\nimport { useExtensionState } from \"../state\";\nimport { flowDiff } from \"../helpers/flowDiff\";\nimport { theme } from \"./theme\";\n\nconst fallbackRender: ErrorBoundary[\"props\"][\"fallbackRender\"] = ({\n error,\n}) => {\n return (\n <Container centerContent>\n <Card>\n <CardHeader>\n <Heading>Ops, something went wrong.</Heading>\n </CardHeader>\n </Card>\n <CardBody>\n <Text as=\"pre\">{error.message}</Text>\n </CardBody>\n </Container>\n );\n};\n\n/**\n * Panel Component\n *\n * This component serves as the main container for the devtools plugin content defined by plugin authors using Player-UI DSL.\n *\n * Props:\n * - `communicationLayer`: An object that allows communication between the devtools and the Player-UI plugins,\n * enabling the exchange of data and events.\n *\n * Features:\n * - Error Handling: Utilizes the `ErrorBoundary` component from `react-error-boundary` to gracefully handle and display errors\n * that may occur during the rendering of the plugin's content.\n * - State Management: Integrates with custom hooks such as `useExtensionState` to manage the state of the plugin and its components.\n * - Player Integration: Uses the `useReactPlayer` hook from `player-ui/react` to render interactive player components based on the\n * DSL defined by the plugin authors.\n *\n * Example Usage:\n * ```tsx\n * <Panel communicationLayer={myCommunicationLayer} />\n * ```\n *\n * Note: The `communicationLayer` prop is essential for the proper functioning of the `Panel` component, as it enables the necessary\n * communication and data exchange with the player-ui/react library.\n */\nexport const Panel = ({\n communicationLayer,\n}: {\n /** the communication layer to use for the extension */\n readonly communicationLayer: Pick<\n MessengerOptions<ExtensionSupportedEvents>,\n \"sendMessage\" | \"addListener\" | \"removeListener\"\n >;\n}) => {\n const { state, selectPlayer, selectPlugin, handleInteraction } =\n useExtensionState({\n communicationLayer,\n });\n\n const { reactPlayer } = useReactPlayer({\n plugins: PLAYER_PLUGINS,\n });\n\n const dataController = useRef<WeakRef<DataController> | null>(null);\n\n const currentFlow = useRef<Flow | null>(null);\n\n useEffect(() => {\n reactPlayer.player.hooks.dataController.tap(\"devtools-panel\", (d) => {\n dataController.current = new WeakRef(d);\n });\n }, [reactPlayer]);\n\n useEffect(() => {\n // we subscribe to all messages from the devtools plugin\n // so the plugin author can define their own events\n PUBSUB_PLUGIN.subscribe(\"*\", (type: string, payload: string) => {\n handleInteraction({\n type,\n payload,\n });\n });\n }, []);\n\n useEffect(() => {\n const { player, plugin } = state.current;\n\n const flow =\n player && plugin\n ? state.players[player]?.plugins?.[plugin]?.flow || INITIAL_FLOW\n : INITIAL_FLOW;\n\n if (!currentFlow.current) {\n currentFlow.current = flow;\n reactPlayer.start(flow);\n return;\n }\n\n const diff = flowDiff({\n curr: currentFlow.current as Flow,\n next: flow,\n });\n\n if (diff) {\n const { change, value } = diff;\n\n if (change === \"flow\") {\n currentFlow.current = value;\n reactPlayer.start(value);\n } else if (change === \"data\") {\n dataController.current\n ? dataController.current\n .deref()\n ?.set(value as Record<string, unknown>)\n : reactPlayer.start(flow);\n }\n }\n }, [reactPlayer, state]);\n\n const Component = reactPlayer.Component as React.FC;\n\n return (\n <ChakraProvider theme={theme}>\n <ThemeProvider colorScheme=\"dark\">\n <ErrorBoundary fallbackRender={fallbackRender}>\n <VStack w=\"100vw\" h=\"100vh\">\n {state.current.player ? (\n <Flex direction=\"column\" marginTop=\"4\">\n <HStack spacing=\"4\">\n <FormControl>\n <FormLabel>Player</FormLabel>\n <Select\n id=\"player\"\n value={state.current.player || \"\"}\n onChange={(event) => selectPlayer(event.target.value)}\n >\n {Object.keys(state.players).map((playerID) => (\n <option key={playerID} value={playerID}>\n {playerID}\n </option>\n ))}\n </Select>\n </FormControl>\n <FormControl>\n <FormLabel>Plugin</FormLabel>\n <Select\n id=\"plugin\"\n value={state.current.plugin || \"\"}\n onChange={(event) => selectPlugin(event.target.value)}\n >\n {Object.keys(\n state.players[state.current.player].plugins\n ).map((pluginID) => (\n <option key={pluginID} value={pluginID}>\n {pluginID}\n </option>\n ))}\n </Select>\n </FormControl>\n </HStack>\n <Container marginY=\"6\">\n <Component />\n </Container>\n <details>\n <summary>Debug</summary>\n <pre>{JSON.stringify(state, null, 2)}</pre>\n </details>\n </Flex>\n ) : (\n <Flex justifyContent=\"center\" padding=\"6\">\n <Text>\n No Player-UI instance or devtools plugin detected. Visit{\" \"}\n <a href=\"https://player-ui.github.io/\">\n https://player-ui.github.io/\n </a>{\" \"}\n for more info.\n </Text>\n </Flex>\n )}\n </VStack>\n </ErrorBoundary>\n </ThemeProvider>\n </ChakraProvider>\n );\n};\n","import type { ExtensionState } from \"@player-tools/devtools-types\";\nimport type { Flow } from \"@player-ui/react\";\n\nexport const INITIAL_FLOW: Flow = {\n id: \"initial-flow\",\n views: [\n {\n id: \"view-1\",\n type: \"text\",\n value: \"connecting...\",\n },\n ],\n navigation: {\n BEGIN: \"FLOW_1\",\n FLOW_1: {\n startState: \"VIEW_1\",\n VIEW_1: {\n state_type: \"VIEW\",\n ref: \"view-1\",\n transitions: {},\n },\n },\n },\n};\n\nexport const INITIAL_EXTENSION_STATE: ExtensionState = {\n current: {\n player: null,\n plugin: null,\n },\n players: {},\n};\n","import DevtoolsUIAssetsPlugin from \"@devtools-ui/plugin\";\nimport { PubSubPlugin } from \"@player-ui/pubsub-plugin\";\nimport type { ReactPlayerPlugin } from \"@player-ui/react\";\n\nexport const PUBSUB_PLUGIN = new PubSubPlugin();\n\nexport const PLAYER_PLUGINS: ReactPlayerPlugin[] = [\n new DevtoolsUIAssetsPlugin(),\n PUBSUB_PLUGIN,\n];\n","import { Messenger } from \"@player-tools/devtools-messenger\";\nimport type {\n ExtensionSupportedEvents,\n MessengerOptions,\n} from \"@player-tools/devtools-types\";\nimport { useCallback, useEffect, useMemo, useReducer } from \"react\";\n\nimport { INITIAL_EXTENSION_STATE } from \"../constants\";\nimport { reducer } from \"./reducer\";\n\nconst NOOP_ID = -1;\n\n/**\n * Custom React hook for managing the state of the devtools extension.\n *\n * This hook initializes the extension's state and sets up a communication layer\n * using the `Messenger` class. It provides methods to select a player or plugin,\n * and handle interactions, which dispatch actions to update the state accordingly.\n *\n */\nexport const useExtensionState = ({\n communicationLayer,\n}: {\n /** the communication layer to use for the extension */\n communicationLayer: Pick<\n MessengerOptions<ExtensionSupportedEvents>,\n \"sendMessage\" | \"addListener\" | \"removeListener\"\n >;\n}) => {\n const [state, dispatch] = useReducer(reducer, INITIAL_EXTENSION_STATE);\n\n const messengerOptions = useMemo<MessengerOptions<ExtensionSupportedEvents>>(\n () => ({\n context: \"devtools\",\n target: \"player\",\n messageCallback: (message) => {\n dispatch(message);\n },\n ...communicationLayer,\n logger: console,\n }),\n [dispatch, communicationLayer]\n );\n\n const messenger = useMemo(\n () => new Messenger(messengerOptions),\n [messengerOptions]\n );\n\n useEffect(() => {\n return () => {\n messenger.destroy();\n };\n }, []);\n\n const selectPlayer = useCallback(\n (playerID: string) => {\n dispatch({\n id: NOOP_ID,\n sender: \"internal\",\n context: \"devtools\",\n _messenger_: false,\n timestamp: Date.now(),\n type: \"PLAYER_DEVTOOLS_PLAYER_SELECTED\",\n payload: {\n playerID,\n },\n });\n },\n [dispatch]\n );\n\n const selectPlugin = useCallback(\n (pluginID: string) => {\n dispatch({\n id: NOOP_ID,\n sender: \"internal\",\n context: \"devtools\",\n _messenger_: false,\n timestamp: Date.now(),\n type: \"PLAYER_DEVTOOLS_PLUGIN_SELECTED\",\n payload: {\n pluginID,\n },\n });\n },\n [dispatch]\n );\n\n /**\n * Plugin authors can add interactive elements to the Player-UI content by leveraging\n * the pub-sub plugin and having the handle interaction proxy the message to the inspected\n * Player-UI instance.\n */\n const handleInteraction = useCallback(\n ({\n type,\n payload,\n }: {\n /** interaction type */\n type: string;\n /** interaction payload */\n payload?: string;\n }) => {\n messenger.sendMessage({\n type: \"PLAYER_DEVTOOLS_PLUGIN_INTERACTION\",\n payload: {\n type,\n payload,\n },\n });\n },\n [messenger]\n );\n\n return { state, selectPlayer, selectPlugin, handleInteraction };\n};\n","import type {\n ExtensionState,\n ExtensionSupportedEvents,\n Transaction,\n} from \"@player-tools/devtools-types\";\nimport { dset } from \"dset/merge\";\nimport { produce } from \"immer\";\n\n/** Extension state reducer */\nexport const reducer = (\n state: ExtensionState,\n transaction: Transaction<ExtensionSupportedEvents>\n): ExtensionState => {\n switch (transaction.type) {\n case \"PLAYER_DEVTOOLS_PLAYER_INIT\":\n return produce(state, (draft) => {\n const {\n sender,\n payload: { plugins },\n } = transaction;\n dset(draft, [\"current\", \"player\"], sender);\n dset(draft, [\"current\", \"plugin\"], plugins[Object.keys(plugins)[0]].id);\n\n dset(draft, [\"players\", sender, \"plugins\"], plugins);\n dset(draft, [\"players\", sender, \"active\"], true);\n });\n case \"PLAYER_DEVTOOLS_PLUGIN_FLOW_CHANGE\":\n return produce(state, (draft) => {\n const {\n sender,\n payload: { flow, pluginID },\n } = transaction;\n\n dset(draft, [\"players\", sender, \"plugins\", pluginID, \"flow\"], flow);\n });\n case \"PLAYER_DEVTOOLS_PLUGIN_DATA_CHANGE\":\n return produce(state, (draft) => {\n const {\n sender,\n payload: { data, pluginID },\n } = transaction;\n dset(\n draft,\n [\"players\", sender, \"plugins\", pluginID, \"flow\", \"data\"],\n data\n );\n });\n case \"MESSENGER_EVENT_BATCH\":\n return produce(state, (draft) => {\n return transaction.payload.events.reduce(reducer, draft);\n });\n case \"PLAYER_DEVTOOLS_PLAYER_STOPPED\":\n return produce(state, (draft) => {\n const { sender } = transaction;\n\n dset(draft, [\"players\", sender, \"active\"], false);\n });\n case \"PLAYER_DEVTOOLS_PLAYER_SELECTED\":\n return produce(state, (draft) => {\n const { playerID } = transaction.payload;\n dset(draft, [\"current\", \"player\"], playerID);\n });\n case \"PLAYER_DEVTOOLS_PLUGIN_SELECTED\":\n return produce(state, (draft) => {\n const { pluginID } = transaction.payload;\n dset(draft, [\"current\", \"plugin\"], pluginID);\n });\n default:\n return state;\n }\n};\n","import type { Flow } from \"@player-ui/react\";\nimport { dequal } from \"dequal\";\n\n/**\n * Compares two Flow objects and identifies if there's a change in their structure or data.\n *\n * This function takes two Flow objects as input, `curr` (current) and `next` (next), and compares them\n * to determine if there's a change in the flow's structure or its data. If there's a change in the flow's\n * structure (excluding the `data` property), it returns an object indicating a \"flow\" change along with the\n * new flow. If there's a change in the `data` property, it returns an object indicating a \"data\" change along\n * with the new data. If there are no changes, it returns null.\n */\nexport const flowDiff = ({\n curr,\n next,\n}: {\n curr: Flow;\n next: Flow;\n}):\n | { change: \"data\"; value: Flow[\"data\"] }\n | { change: \"flow\"; value: Flow }\n | null => {\n // compare flows except for the `data` property\n const currCopy = { ...curr, data: null };\n const nextCopy = { ...next, data: null };\n\n const baseFlowIsEqual = dequal(currCopy, nextCopy);\n\n if (!baseFlowIsEqual) {\n return { change: \"flow\", value: next };\n }\n\n // compare data\n const currData = curr.data;\n const nextData = next.data;\n\n const dataIsEqual = dequal(currData, nextData);\n\n if (!dataIsEqual) {\n return { change: \"data\", value: nextData };\n }\n\n return null;\n};\n","import { extendTheme, type ThemeConfig } from \"@chakra-ui/react\";\n\nconst config: ThemeConfig = {\n initialColorMode: \"dark\",\n useSystemColorMode: false,\n};\n\nexport const theme = extendTheme({ config });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAA8B;AAK9B,IAAAA,gBAAqD;AACrD,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
+
{"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/panel/index.tsx","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/constants/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/plugins/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/state/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/state/reducer.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/helpers/flowDiff.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/panel/theme.ts"],"sourcesContent":["export { Panel } from \"./panel\";\n","import React, { useRef } from \"react\";\nimport type {\n MessengerOptions,\n ExtensionSupportedEvents,\n} from \"@player-tools/devtools-types\";\nimport { DataController, Flow, useReactPlayer } from \"@player-ui/react\";\nimport { useEffect } from \"react\";\nimport { ErrorBoundary } from \"react-error-boundary\";\nimport {\n Card,\n CardBody,\n CardHeader,\n ChakraProvider,\n Container,\n Flex,\n FormControl,\n FormLabel,\n Heading,\n HStack,\n Select,\n Text,\n VStack,\n} from \"@chakra-ui/react\";\nimport { ThemeProvider } from \"@devtools-ds/themes\";\n\nimport { INITIAL_FLOW } from \"../constants\";\nimport { PLAYER_PLUGINS, PUBSUB_PLUGIN } from \"../plugins\";\nimport { useExtensionState } from \"../state\";\nimport { flowDiff } from \"../helpers/flowDiff\";\nimport { theme } from \"./theme\";\n\nconst fallbackRender: ErrorBoundary[\"props\"][\"fallbackRender\"] = ({\n error,\n}) => {\n return (\n <Container centerContent>\n <Card>\n <CardHeader>\n <Heading>Ops, something went wrong.</Heading>\n </CardHeader>\n </Card>\n <CardBody>\n <Text as=\"pre\">{error.message}</Text>\n </CardBody>\n </Container>\n );\n};\n\n/**\n * Panel Component\n *\n * This component serves as the main container for the devtools plugin content defined by plugin authors using Player-UI DSL.\n *\n * Props:\n * - `communicationLayer`: An object that allows communication between the devtools and the Player-UI plugins,\n * enabling the exchange of data and events.\n *\n * Features:\n * - Error Handling: Utilizes the `ErrorBoundary` component from `react-error-boundary` to gracefully handle and display errors\n * that may occur during the rendering of the plugin's content.\n * - State Management: Integrates with custom hooks such as `useExtensionState` to manage the state of the plugin and its components.\n * - Player Integration: Uses the `useReactPlayer` hook from `player-ui/react` to render interactive player components based on the\n * DSL defined by the plugin authors.\n *\n * Example Usage:\n * ```tsx\n * <Panel communicationLayer={myCommunicationLayer} />\n * ```\n *\n * Note: The `communicationLayer` prop is essential for the proper functioning of the `Panel` component, as it enables the necessary\n * communication and data exchange with the player-ui/react library.\n */\nexport const Panel = ({\n communicationLayer,\n}: {\n /** the communication layer to use for the extension */\n readonly communicationLayer: Pick<\n MessengerOptions<ExtensionSupportedEvents>,\n \"sendMessage\" | \"addListener\" | \"removeListener\"\n >;\n}) => {\n const { state, selectPlayer, selectPlugin, handleInteraction } =\n useExtensionState({\n communicationLayer,\n });\n\n const { reactPlayer } = useReactPlayer({\n plugins: PLAYER_PLUGINS,\n });\n\n const dataController = useRef<WeakRef<DataController> | null>(null);\n\n const currentFlow = useRef<Flow | null>(null);\n\n useEffect(() => {\n reactPlayer.player.hooks.dataController.tap(\"devtools-panel\", (d) => {\n dataController.current = new WeakRef(d);\n });\n }, [reactPlayer]);\n\n useEffect(() => {\n // we subscribe to all messages from the devtools plugin\n // so the plugin author can define their own events\n PUBSUB_PLUGIN.subscribe(\"*\", (type: string, payload: string) => {\n handleInteraction({\n type,\n payload,\n });\n });\n }, []);\n\n useEffect(() => {\n const { player, plugin } = state.current;\n\n const flow =\n player && plugin\n ? state.players[player]?.plugins?.[plugin]?.flow || INITIAL_FLOW\n : INITIAL_FLOW;\n\n if (!currentFlow.current) {\n currentFlow.current = flow;\n reactPlayer.start(flow);\n return;\n }\n\n const diff = flowDiff({\n curr: currentFlow.current as Flow,\n next: flow,\n });\n\n if (diff) {\n const { change, value } = diff;\n\n if (change === \"flow\") {\n currentFlow.current = value;\n reactPlayer.start(value);\n } else if (change === \"data\") {\n dataController.current\n ? dataController.current\n .deref()\n ?.set(value as Record<string, unknown>)\n : reactPlayer.start(flow);\n }\n }\n }, [reactPlayer, state]);\n\n const Component = reactPlayer.Component as React.FC;\n\n return (\n <ChakraProvider theme={theme}>\n <ThemeProvider colorScheme=\"dark\">\n <ErrorBoundary fallbackRender={fallbackRender}>\n <Flex direction=\"column\" w=\"100vw\" h=\"100vh\" alignItems={\"normal\"}>\n {state.current.player ? (\n <Container minWidth={\"100%\"}>\n <Flex direction=\"column\" marginTop=\"4\">\n <Flex gap={\"8\"}>\n <FormControl>\n <FormLabel>Player</FormLabel>\n <Select\n id=\"player\"\n value={state.current.player || \"\"}\n onChange={(event) => selectPlayer(event.target.value)}\n >\n {Object.keys(state.players).map((playerID) => (\n <option key={playerID} value={playerID}>\n {playerID}\n </option>\n ))}\n </Select>\n </FormControl>\n <FormControl>\n <FormLabel>Plugin</FormLabel>\n <Select\n id=\"plugin\"\n value={state.current.plugin || \"\"}\n onChange={(event) => selectPlugin(event.target.value)}\n >\n {Object.keys(\n state.players[state.current.player].plugins\n ).map((pluginID) => (\n <option key={pluginID} value={pluginID}>\n {pluginID}\n </option>\n ))}\n </Select>\n </FormControl>\n </Flex>\n <Flex>\n <Component />\n </Flex>\n <details>\n <summary>Debug</summary>\n <pre style={{ maxHeight: \"30vh\", overflow: \"scroll\" }}>\n {JSON.stringify(state, null, 2)}\n </pre>\n </details>\n </Flex>\n </Container>\n ) : (\n <Flex justifyContent=\"center\" padding=\"6\">\n <Text>\n No Player-UI instance or devtools plugin detected. Visit{\" \"}\n <a href=\"https://player-ui.github.io/\">\n https://player-ui.github.io/\n </a>{\" \"}\n for more info.\n </Text>\n </Flex>\n )}\n </Flex>\n </ErrorBoundary>\n </ThemeProvider>\n </ChakraProvider>\n );\n};\n","import type { ExtensionState } from \"@player-tools/devtools-types\";\nimport type { Flow } from \"@player-ui/react\";\n\nexport const INITIAL_FLOW: Flow = {\n id: \"initial-flow\",\n views: [\n {\n id: \"view-1\",\n type: \"text\",\n value: \"connecting...\",\n },\n ],\n navigation: {\n BEGIN: \"FLOW_1\",\n FLOW_1: {\n startState: \"VIEW_1\",\n VIEW_1: {\n state_type: \"VIEW\",\n ref: \"view-1\",\n transitions: {},\n },\n },\n },\n};\n\nexport const INITIAL_EXTENSION_STATE: ExtensionState = {\n current: {\n player: null,\n plugin: null,\n },\n players: {},\n};\n","import DevtoolsUIAssetsPlugin from \"@devtools-ui/plugin\";\nimport { PubSubPlugin } from \"@player-ui/pubsub-plugin\";\nimport type { ReactPlayerPlugin } from \"@player-ui/react\";\n\nexport const PUBSUB_PLUGIN = new PubSubPlugin();\n\nexport const PLAYER_PLUGINS: ReactPlayerPlugin[] = [\n new DevtoolsUIAssetsPlugin(),\n PUBSUB_PLUGIN,\n];\n","import { Messenger } from \"@player-tools/devtools-messenger\";\nimport type {\n ExtensionSupportedEvents,\n MessengerOptions,\n} from \"@player-tools/devtools-types\";\nimport { useCallback, useEffect, useMemo, useReducer } from \"react\";\n\nimport { INITIAL_EXTENSION_STATE } from \"../constants\";\nimport { reducer } from \"./reducer\";\n\nconst NOOP_ID = -1;\n\n/**\n * Custom React hook for managing the state of the devtools extension.\n *\n * This hook initializes the extension's state and sets up a communication layer\n * using the `Messenger` class. It provides methods to select a player or plugin,\n * and handle interactions, which dispatch actions to update the state accordingly.\n *\n */\nexport const useExtensionState = ({\n communicationLayer,\n}: {\n /** the communication layer to use for the extension */\n communicationLayer: Pick<\n MessengerOptions<ExtensionSupportedEvents>,\n \"sendMessage\" | \"addListener\" | \"removeListener\"\n >;\n}) => {\n const [state, dispatch] = useReducer(reducer, INITIAL_EXTENSION_STATE);\n\n const messengerOptions = useMemo<MessengerOptions<ExtensionSupportedEvents>>(\n () => ({\n context: \"devtools\",\n target: \"player\",\n messageCallback: (message) => {\n dispatch(message);\n },\n ...communicationLayer,\n logger: console,\n }),\n [dispatch, communicationLayer]\n );\n\n const messenger = useMemo(\n () => new Messenger(messengerOptions),\n [messengerOptions]\n );\n\n useEffect(() => {\n return () => {\n messenger.destroy();\n };\n }, []);\n\n const selectPlayer = useCallback(\n (playerID: string) => {\n dispatch({\n id: NOOP_ID,\n sender: \"internal\",\n context: \"devtools\",\n _messenger_: false,\n timestamp: Date.now(),\n type: \"PLAYER_DEVTOOLS_PLAYER_SELECTED\",\n payload: {\n playerID,\n },\n });\n },\n [dispatch]\n );\n\n const selectPlugin = useCallback(\n (pluginID: string) => {\n dispatch({\n id: NOOP_ID,\n sender: \"internal\",\n context: \"devtools\",\n _messenger_: false,\n timestamp: Date.now(),\n type: \"PLAYER_DEVTOOLS_PLUGIN_SELECTED\",\n payload: {\n pluginID,\n },\n });\n },\n [dispatch]\n );\n\n /**\n * Plugin authors can add interactive elements to the Player-UI content by leveraging\n * the pub-sub plugin and having the handle interaction proxy the message to the inspected\n * Player-UI instance.\n */\n const handleInteraction = useCallback(\n ({\n type,\n payload,\n }: {\n /** interaction type */\n type: string;\n /** interaction payload */\n payload?: string;\n }) => {\n messenger.sendMessage({\n type: \"PLAYER_DEVTOOLS_PLUGIN_INTERACTION\",\n payload: {\n type,\n payload,\n },\n });\n },\n [messenger]\n );\n\n return { state, selectPlayer, selectPlugin, handleInteraction };\n};\n","import type {\n ExtensionState,\n ExtensionSupportedEvents,\n Transaction,\n} from \"@player-tools/devtools-types\";\nimport { dset } from \"dset/merge\";\nimport { produce } from \"immer\";\n\n/** Extension state reducer */\nexport const reducer = (\n state: ExtensionState,\n transaction: Transaction<ExtensionSupportedEvents>\n): ExtensionState => {\n switch (transaction.type) {\n case \"PLAYER_DEVTOOLS_PLAYER_INIT\":\n return produce(state, (draft) => {\n const {\n sender,\n payload: { plugins },\n } = transaction;\n dset(draft, [\"current\", \"player\"], sender);\n dset(draft, [\"current\", \"plugin\"], plugins[Object.keys(plugins)[0]].id);\n\n dset(draft, [\"players\", sender, \"plugins\"], plugins);\n dset(draft, [\"players\", sender, \"active\"], true);\n });\n case \"PLAYER_DEVTOOLS_PLUGIN_FLOW_CHANGE\":\n return produce(state, (draft) => {\n const {\n sender,\n payload: { flow, pluginID },\n } = transaction;\n\n dset(draft, [\"players\", sender, \"plugins\", pluginID, \"flow\"], flow);\n });\n case \"PLAYER_DEVTOOLS_PLUGIN_DATA_CHANGE\":\n return produce(state, (draft) => {\n const {\n sender,\n payload: { data, pluginID },\n } = transaction;\n dset(\n draft,\n [\"players\", sender, \"plugins\", pluginID, \"flow\", \"data\"],\n data\n );\n });\n case \"MESSENGER_EVENT_BATCH\":\n return produce(state, (draft) => {\n return transaction.payload.events.reduce(reducer, draft);\n });\n case \"PLAYER_DEVTOOLS_PLAYER_STOPPED\":\n return produce(state, (draft) => {\n const { sender } = transaction;\n\n dset(draft, [\"players\", sender, \"active\"], false);\n });\n case \"PLAYER_DEVTOOLS_PLAYER_SELECTED\":\n return produce(state, (draft) => {\n const { playerID } = transaction.payload;\n dset(draft, [\"current\", \"player\"], playerID);\n });\n case \"PLAYER_DEVTOOLS_PLUGIN_SELECTED\":\n return produce(state, (draft) => {\n const { pluginID } = transaction.payload;\n dset(draft, [\"current\", \"plugin\"], pluginID);\n });\n default:\n return state;\n }\n};\n","import type { Flow } from \"@player-ui/react\";\nimport { dequal } from \"dequal\";\n\n/**\n * Compares two Flow objects and identifies if there's a change in their structure or data.\n *\n * This function takes two Flow objects as input, `curr` (current) and `next` (next), and compares them\n * to determine if there's a change in the flow's structure or its data. If there's a change in the flow's\n * structure (excluding the `data` property), it returns an object indicating a \"flow\" change along with the\n * new flow. If there's a change in the `data` property, it returns an object indicating a \"data\" change along\n * with the new data. If there are no changes, it returns null.\n */\nexport const flowDiff = ({\n curr,\n next,\n}: {\n curr: Flow;\n next: Flow;\n}):\n | { change: \"data\"; value: Flow[\"data\"] }\n | { change: \"flow\"; value: Flow }\n | null => {\n // compare flows except for the `data` property\n const currCopy = { ...curr, data: null };\n const nextCopy = { ...next, data: null };\n\n const baseFlowIsEqual = dequal(currCopy, nextCopy);\n\n if (!baseFlowIsEqual) {\n return { change: \"flow\", value: next };\n }\n\n // compare data\n const currData = curr.data;\n const nextData = next.data;\n\n const dataIsEqual = dequal(currData, nextData);\n\n if (!dataIsEqual) {\n return { change: \"data\", value: nextData };\n }\n\n return null;\n};\n","import { extendTheme, type ThemeConfig } from \"@chakra-ui/react\";\n\nconst config: ThemeConfig = {\n initialColorMode: \"dark\",\n useSystemColorMode: false,\n};\n\nexport const theme = extendTheme({ config });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAA8B;AAK9B,IAAAA,gBAAqD;AACrD,IAAAA,gBAA0B;AAC1B,kCAA8B;AAC9B,IAAAA,gBAcO;AACP,oBAA8B;;;ACpBvB,IAAM,eAAqB;AAAA,EAChC,IAAI;AAAA,EACJ,OAAO;AAAA,IACL;AAAA,MACE,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EACA,YAAY;AAAA,IACV,OAAO;AAAA,IACP,QAAQ;AAAA,MACN,YAAY;AAAA,MACZ,QAAQ;AAAA,QACN,YAAY;AAAA,QACZ,KAAK;AAAA,QACL,aAAa,CAAC;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,0BAA0C;AAAA,EACrD,SAAS;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV;AAAA,EACA,SAAS,CAAC;AACZ;;;AC/BA,oBAAmC;AACnC,2BAA6B;AAGtB,IAAM,gBAAgB,IAAI,kCAAa;AAEvC,IAAM,iBAAsC;AAAA,EACjD,IAAI,cAAAC,QAAuB;AAAA,EAC3B;AACF;;;ACTA,gCAA0B;AAK1B,mBAA4D;;;ACA5D,mBAAqB;AACr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E;AAAA,IACtC,EAAE,IAAI,CAAC,aACL,8BAAAA,QAAA,cAAC,YAAO,KAAK,UAAU,OAAO,YAC3B,QACH,CACD;AAAA,EACH,CACF,CACF,GACA,8BAAAA,QAAA,cAAC,0BACC,8BAAAA,QAAA,cAAC,eAAU,CACb,GACA,8BAAAA,QAAA,cAAC,iBACC,8BAAAA,QAAA,cAAC,iBAAQ,OAAK,GACd,8BAAAA,QAAA,cAAC,SAAI,OAAO,EAAE,WAAW,QAAQ,UAAU,SAAS,KACjD,KAAK,UAAU,OAAO,MAAM,CAAC,CAChC,CACF,CACF,CACF,IAEA,8BAAAA,QAAA,cAAC,sBAAK,gBAAe,UAAS,SAAQ,OACpC,8BAAAA,QAAA,cAAC,0BAAK,4DACqD,KACzD,8BAAAA,QAAA,cAAC,OAAE,MAAK,kCAA+B,8BAEvC,GAAK,KAAI,gBAEX,CACF,CAEJ,CACF,CACF,CACF;AAEJ;","names":["import_react","DevtoolsUIAssetsPlugin","import_react","React"]}
|
package/dist/index.legacy-esm.js
CHANGED
|
@@ -13,10 +13,8 @@ import {
|
|
|
13
13
|
FormControl,
|
|
14
14
|
FormLabel,
|
|
15
15
|
Heading,
|
|
16
|
-
HStack,
|
|
17
16
|
Select,
|
|
18
|
-
Text
|
|
19
|
-
VStack
|
|
17
|
+
Text
|
|
20
18
|
} from "@chakra-ui/react";
|
|
21
19
|
import { ThemeProvider } from "@devtools-ds/themes";
|
|
22
20
|
|
|
@@ -282,7 +280,7 @@ var Panel = ({
|
|
|
282
280
|
}
|
|
283
281
|
}, [reactPlayer, state]);
|
|
284
282
|
const Component = reactPlayer.Component;
|
|
285
|
-
return /* @__PURE__ */ React.createElement(ChakraProvider, { theme }, /* @__PURE__ */ React.createElement(ThemeProvider, { colorScheme: "dark" }, /* @__PURE__ */ React.createElement(ErrorBoundary, { fallbackRender }, /* @__PURE__ */ React.createElement(
|
|
283
|
+
return /* @__PURE__ */ React.createElement(ChakraProvider, { theme }, /* @__PURE__ */ React.createElement(ThemeProvider, { colorScheme: "dark" }, /* @__PURE__ */ React.createElement(ErrorBoundary, { fallbackRender }, /* @__PURE__ */ React.createElement(Flex, { direction: "column", w: "100vw", h: "100vh", alignItems: "normal" }, state.current.player ? /* @__PURE__ */ React.createElement(Container, { minWidth: "100%" }, /* @__PURE__ */ React.createElement(Flex, { direction: "column", marginTop: "4" }, /* @__PURE__ */ React.createElement(Flex, { gap: "8" }, /* @__PURE__ */ React.createElement(FormControl, null, /* @__PURE__ */ React.createElement(FormLabel, null, "Player"), /* @__PURE__ */ React.createElement(
|
|
286
284
|
Select,
|
|
287
285
|
{
|
|
288
286
|
id: "player",
|
|
@@ -300,7 +298,7 @@ var Panel = ({
|
|
|
300
298
|
Object.keys(
|
|
301
299
|
state.players[state.current.player].plugins
|
|
302
300
|
).map((pluginID) => /* @__PURE__ */ React.createElement("option", { key: pluginID, value: pluginID }, pluginID))
|
|
303
|
-
))), /* @__PURE__ */ React.createElement(
|
|
301
|
+
))), /* @__PURE__ */ React.createElement(Flex, null, /* @__PURE__ */ React.createElement(Component, null)), /* @__PURE__ */ React.createElement("details", null, /* @__PURE__ */ React.createElement("summary", null, "Debug"), /* @__PURE__ */ React.createElement("pre", { style: { maxHeight: "30vh", overflow: "scroll" } }, JSON.stringify(state, null, 2))))) : /* @__PURE__ */ React.createElement(Flex, { justifyContent: "center", padding: "6" }, /* @__PURE__ */ React.createElement(Text, null, "No Player-UI instance or devtools plugin detected. Visit", " ", /* @__PURE__ */ React.createElement("a", { href: "https://player-ui.github.io/" }, "https://player-ui.github.io/"), " ", "for more info."))))));
|
|
304
302
|
};
|
|
305
303
|
export {
|
|
306
304
|
Panel
|
package/dist/index.mjs
CHANGED
|
@@ -13,10 +13,8 @@ import {
|
|
|
13
13
|
FormControl,
|
|
14
14
|
FormLabel,
|
|
15
15
|
Heading,
|
|
16
|
-
HStack,
|
|
17
16
|
Select,
|
|
18
|
-
Text
|
|
19
|
-
VStack
|
|
17
|
+
Text
|
|
20
18
|
} from "@chakra-ui/react";
|
|
21
19
|
import { ThemeProvider } from "@devtools-ds/themes";
|
|
22
20
|
|
|
@@ -282,7 +280,7 @@ var Panel = ({
|
|
|
282
280
|
}
|
|
283
281
|
}, [reactPlayer, state]);
|
|
284
282
|
const Component = reactPlayer.Component;
|
|
285
|
-
return /* @__PURE__ */ React.createElement(ChakraProvider, { theme }, /* @__PURE__ */ React.createElement(ThemeProvider, { colorScheme: "dark" }, /* @__PURE__ */ React.createElement(ErrorBoundary, { fallbackRender }, /* @__PURE__ */ React.createElement(
|
|
283
|
+
return /* @__PURE__ */ React.createElement(ChakraProvider, { theme }, /* @__PURE__ */ React.createElement(ThemeProvider, { colorScheme: "dark" }, /* @__PURE__ */ React.createElement(ErrorBoundary, { fallbackRender }, /* @__PURE__ */ React.createElement(Flex, { direction: "column", w: "100vw", h: "100vh", alignItems: "normal" }, state.current.player ? /* @__PURE__ */ React.createElement(Container, { minWidth: "100%" }, /* @__PURE__ */ React.createElement(Flex, { direction: "column", marginTop: "4" }, /* @__PURE__ */ React.createElement(Flex, { gap: "8" }, /* @__PURE__ */ React.createElement(FormControl, null, /* @__PURE__ */ React.createElement(FormLabel, null, "Player"), /* @__PURE__ */ React.createElement(
|
|
286
284
|
Select,
|
|
287
285
|
{
|
|
288
286
|
id: "player",
|
|
@@ -300,7 +298,7 @@ var Panel = ({
|
|
|
300
298
|
Object.keys(
|
|
301
299
|
state.players[state.current.player].plugins
|
|
302
300
|
).map((pluginID) => /* @__PURE__ */ React.createElement("option", { key: pluginID, value: pluginID }, pluginID))
|
|
303
|
-
))), /* @__PURE__ */ React.createElement(
|
|
301
|
+
))), /* @__PURE__ */ React.createElement(Flex, null, /* @__PURE__ */ React.createElement(Component, null)), /* @__PURE__ */ React.createElement("details", null, /* @__PURE__ */ React.createElement("summary", null, "Debug"), /* @__PURE__ */ React.createElement("pre", { style: { maxHeight: "30vh", overflow: "scroll" } }, JSON.stringify(state, null, 2))))) : /* @__PURE__ */ React.createElement(Flex, { justifyContent: "center", padding: "6" }, /* @__PURE__ */ React.createElement(Text, null, "No Player-UI instance or devtools plugin detected. Visit", " ", /* @__PURE__ */ React.createElement("a", { href: "https://player-ui.github.io/" }, "https://player-ui.github.io/"), " ", "for more info."))))));
|
|
304
302
|
};
|
|
305
303
|
export {
|
|
306
304
|
Panel
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/panel/index.tsx","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/constants/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/plugins/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/state/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/state/reducer.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/helpers/flowDiff.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/panel/theme.ts"],"sourcesContent":["import React, { useRef } from \"react\";\nimport type {\n MessengerOptions,\n ExtensionSupportedEvents,\n} from \"@player-tools/devtools-types\";\nimport { DataController, Flow, useReactPlayer } from \"@player-ui/react\";\nimport { useEffect } from \"react\";\nimport { ErrorBoundary } from \"react-error-boundary\";\nimport {\n Card,\n CardBody,\n CardHeader,\n ChakraProvider,\n Container,\n Flex,\n FormControl,\n FormLabel,\n Heading,\n HStack,\n Select,\n Text,\n VStack,\n} from \"@chakra-ui/react\";\nimport { ThemeProvider } from \"@devtools-ds/themes\";\n\nimport { INITIAL_FLOW } from \"../constants\";\nimport { PLAYER_PLUGINS, PUBSUB_PLUGIN } from \"../plugins\";\nimport { useExtensionState } from \"../state\";\nimport { flowDiff } from \"../helpers/flowDiff\";\nimport { theme } from \"./theme\";\n\nconst fallbackRender: ErrorBoundary[\"props\"][\"fallbackRender\"] = ({\n error,\n}) => {\n return (\n <Container centerContent>\n <Card>\n <CardHeader>\n <Heading>Ops, something went wrong.</Heading>\n </CardHeader>\n </Card>\n <CardBody>\n <Text as=\"pre\">{error.message}</Text>\n </CardBody>\n </Container>\n );\n};\n\n/**\n * Panel Component\n *\n * This component serves as the main container for the devtools plugin content defined by plugin authors using Player-UI DSL.\n *\n * Props:\n * - `communicationLayer`: An object that allows communication between the devtools and the Player-UI plugins,\n * enabling the exchange of data and events.\n *\n * Features:\n * - Error Handling: Utilizes the `ErrorBoundary` component from `react-error-boundary` to gracefully handle and display errors\n * that may occur during the rendering of the plugin's content.\n * - State Management: Integrates with custom hooks such as `useExtensionState` to manage the state of the plugin and its components.\n * - Player Integration: Uses the `useReactPlayer` hook from `player-ui/react` to render interactive player components based on the\n * DSL defined by the plugin authors.\n *\n * Example Usage:\n * ```tsx\n * <Panel communicationLayer={myCommunicationLayer} />\n * ```\n *\n * Note: The `communicationLayer` prop is essential for the proper functioning of the `Panel` component, as it enables the necessary\n * communication and data exchange with the player-ui/react library.\n */\nexport const Panel = ({\n communicationLayer,\n}: {\n /** the communication layer to use for the extension */\n readonly communicationLayer: Pick<\n MessengerOptions<ExtensionSupportedEvents>,\n \"sendMessage\" | \"addListener\" | \"removeListener\"\n >;\n}) => {\n const { state, selectPlayer, selectPlugin, handleInteraction } =\n useExtensionState({\n communicationLayer,\n });\n\n const { reactPlayer } = useReactPlayer({\n plugins: PLAYER_PLUGINS,\n });\n\n const dataController = useRef<WeakRef<DataController> | null>(null);\n\n const currentFlow = useRef<Flow | null>(null);\n\n useEffect(() => {\n reactPlayer.player.hooks.dataController.tap(\"devtools-panel\", (d) => {\n dataController.current = new WeakRef(d);\n });\n }, [reactPlayer]);\n\n useEffect(() => {\n // we subscribe to all messages from the devtools plugin\n // so the plugin author can define their own events\n PUBSUB_PLUGIN.subscribe(\"*\", (type: string, payload: string) => {\n handleInteraction({\n type,\n payload,\n });\n });\n }, []);\n\n useEffect(() => {\n const { player, plugin } = state.current;\n\n const flow =\n player && plugin\n ? state.players[player]?.plugins?.[plugin]?.flow || INITIAL_FLOW\n : INITIAL_FLOW;\n\n if (!currentFlow.current) {\n currentFlow.current = flow;\n reactPlayer.start(flow);\n return;\n }\n\n const diff = flowDiff({\n curr: currentFlow.current as Flow,\n next: flow,\n });\n\n if (diff) {\n const { change, value } = diff;\n\n if (change === \"flow\") {\n currentFlow.current = value;\n reactPlayer.start(value);\n } else if (change === \"data\") {\n dataController.current\n ? dataController.current\n .deref()\n ?.set(value as Record<string, unknown>)\n : reactPlayer.start(flow);\n }\n }\n }, [reactPlayer, state]);\n\n const Component = reactPlayer.Component as React.FC;\n\n return (\n <ChakraProvider theme={theme}>\n <ThemeProvider colorScheme=\"dark\">\n <ErrorBoundary fallbackRender={fallbackRender}>\n <VStack w=\"100vw\" h=\"100vh\">\n {state.current.player ? (\n <Flex direction=\"column\" marginTop=\"4\">\n <HStack spacing=\"4\">\n <FormControl>\n <FormLabel>Player</FormLabel>\n <Select\n id=\"player\"\n value={state.current.player || \"\"}\n onChange={(event) => selectPlayer(event.target.value)}\n >\n {Object.keys(state.players).map((playerID) => (\n <option key={playerID} value={playerID}>\n {playerID}\n </option>\n ))}\n </Select>\n </FormControl>\n <FormControl>\n <FormLabel>Plugin</FormLabel>\n <Select\n id=\"plugin\"\n value={state.current.plugin || \"\"}\n onChange={(event) => selectPlugin(event.target.value)}\n >\n {Object.keys(\n state.players[state.current.player].plugins\n ).map((pluginID) => (\n <option key={pluginID} value={pluginID}>\n {pluginID}\n </option>\n ))}\n </Select>\n </FormControl>\n </HStack>\n <Container marginY=\"6\">\n <Component />\n </Container>\n <details>\n <summary>Debug</summary>\n <pre>{JSON.stringify(state, null, 2)}</pre>\n </details>\n </Flex>\n ) : (\n <Flex justifyContent=\"center\" padding=\"6\">\n <Text>\n No Player-UI instance or devtools plugin detected. Visit{\" \"}\n <a href=\"https://player-ui.github.io/\">\n https://player-ui.github.io/\n </a>{\" \"}\n for more info.\n </Text>\n </Flex>\n )}\n </VStack>\n </ErrorBoundary>\n </ThemeProvider>\n </ChakraProvider>\n );\n};\n","import type { ExtensionState } from \"@player-tools/devtools-types\";\nimport type { Flow } from \"@player-ui/react\";\n\nexport const INITIAL_FLOW: Flow = {\n id: \"initial-flow\",\n views: [\n {\n id: \"view-1\",\n type: \"text\",\n value: \"connecting...\",\n },\n ],\n navigation: {\n BEGIN: \"FLOW_1\",\n FLOW_1: {\n startState: \"VIEW_1\",\n VIEW_1: {\n state_type: \"VIEW\",\n ref: \"view-1\",\n transitions: {},\n },\n },\n },\n};\n\nexport const INITIAL_EXTENSION_STATE: ExtensionState = {\n current: {\n player: null,\n plugin: null,\n },\n players: {},\n};\n","import DevtoolsUIAssetsPlugin from \"@devtools-ui/plugin\";\nimport { PubSubPlugin } from \"@player-ui/pubsub-plugin\";\nimport type { ReactPlayerPlugin } from \"@player-ui/react\";\n\nexport const PUBSUB_PLUGIN = new PubSubPlugin();\n\nexport const PLAYER_PLUGINS: ReactPlayerPlugin[] = [\n new DevtoolsUIAssetsPlugin(),\n PUBSUB_PLUGIN,\n];\n","import { Messenger } from \"@player-tools/devtools-messenger\";\nimport type {\n ExtensionSupportedEvents,\n MessengerOptions,\n} from \"@player-tools/devtools-types\";\nimport { useCallback, useEffect, useMemo, useReducer } from \"react\";\n\nimport { INITIAL_EXTENSION_STATE } from \"../constants\";\nimport { reducer } from \"./reducer\";\n\nconst NOOP_ID = -1;\n\n/**\n * Custom React hook for managing the state of the devtools extension.\n *\n * This hook initializes the extension's state and sets up a communication layer\n * using the `Messenger` class. It provides methods to select a player or plugin,\n * and handle interactions, which dispatch actions to update the state accordingly.\n *\n */\nexport const useExtensionState = ({\n communicationLayer,\n}: {\n /** the communication layer to use for the extension */\n communicationLayer: Pick<\n MessengerOptions<ExtensionSupportedEvents>,\n \"sendMessage\" | \"addListener\" | \"removeListener\"\n >;\n}) => {\n const [state, dispatch] = useReducer(reducer, INITIAL_EXTENSION_STATE);\n\n const messengerOptions = useMemo<MessengerOptions<ExtensionSupportedEvents>>(\n () => ({\n context: \"devtools\",\n target: \"player\",\n messageCallback: (message) => {\n dispatch(message);\n },\n ...communicationLayer,\n logger: console,\n }),\n [dispatch, communicationLayer]\n );\n\n const messenger = useMemo(\n () => new Messenger(messengerOptions),\n [messengerOptions]\n );\n\n useEffect(() => {\n return () => {\n messenger.destroy();\n };\n }, []);\n\n const selectPlayer = useCallback(\n (playerID: string) => {\n dispatch({\n id: NOOP_ID,\n sender: \"internal\",\n context: \"devtools\",\n _messenger_: false,\n timestamp: Date.now(),\n type: \"PLAYER_DEVTOOLS_PLAYER_SELECTED\",\n payload: {\n playerID,\n },\n });\n },\n [dispatch]\n );\n\n const selectPlugin = useCallback(\n (pluginID: string) => {\n dispatch({\n id: NOOP_ID,\n sender: \"internal\",\n context: \"devtools\",\n _messenger_: false,\n timestamp: Date.now(),\n type: \"PLAYER_DEVTOOLS_PLUGIN_SELECTED\",\n payload: {\n pluginID,\n },\n });\n },\n [dispatch]\n );\n\n /**\n * Plugin authors can add interactive elements to the Player-UI content by leveraging\n * the pub-sub plugin and having the handle interaction proxy the message to the inspected\n * Player-UI instance.\n */\n const handleInteraction = useCallback(\n ({\n type,\n payload,\n }: {\n /** interaction type */\n type: string;\n /** interaction payload */\n payload?: string;\n }) => {\n messenger.sendMessage({\n type: \"PLAYER_DEVTOOLS_PLUGIN_INTERACTION\",\n payload: {\n type,\n payload,\n },\n });\n },\n [messenger]\n );\n\n return { state, selectPlayer, selectPlugin, handleInteraction };\n};\n","import type {\n ExtensionState,\n ExtensionSupportedEvents,\n Transaction,\n} from \"@player-tools/devtools-types\";\nimport { dset } from \"dset/merge\";\nimport { produce } from \"immer\";\n\n/** Extension state reducer */\nexport const reducer = (\n state: ExtensionState,\n transaction: Transaction<ExtensionSupportedEvents>\n): ExtensionState => {\n switch (transaction.type) {\n case \"PLAYER_DEVTOOLS_PLAYER_INIT\":\n return produce(state, (draft) => {\n const {\n sender,\n payload: { plugins },\n } = transaction;\n dset(draft, [\"current\", \"player\"], sender);\n dset(draft, [\"current\", \"plugin\"], plugins[Object.keys(plugins)[0]].id);\n\n dset(draft, [\"players\", sender, \"plugins\"], plugins);\n dset(draft, [\"players\", sender, \"active\"], true);\n });\n case \"PLAYER_DEVTOOLS_PLUGIN_FLOW_CHANGE\":\n return produce(state, (draft) => {\n const {\n sender,\n payload: { flow, pluginID },\n } = transaction;\n\n dset(draft, [\"players\", sender, \"plugins\", pluginID, \"flow\"], flow);\n });\n case \"PLAYER_DEVTOOLS_PLUGIN_DATA_CHANGE\":\n return produce(state, (draft) => {\n const {\n sender,\n payload: { data, pluginID },\n } = transaction;\n dset(\n draft,\n [\"players\", sender, \"plugins\", pluginID, \"flow\", \"data\"],\n data\n );\n });\n case \"MESSENGER_EVENT_BATCH\":\n return produce(state, (draft) => {\n return transaction.payload.events.reduce(reducer, draft);\n });\n case \"PLAYER_DEVTOOLS_PLAYER_STOPPED\":\n return produce(state, (draft) => {\n const { sender } = transaction;\n\n dset(draft, [\"players\", sender, \"active\"], false);\n });\n case \"PLAYER_DEVTOOLS_PLAYER_SELECTED\":\n return produce(state, (draft) => {\n const { playerID } = transaction.payload;\n dset(draft, [\"current\", \"player\"], playerID);\n });\n case \"PLAYER_DEVTOOLS_PLUGIN_SELECTED\":\n return produce(state, (draft) => {\n const { pluginID } = transaction.payload;\n dset(draft, [\"current\", \"plugin\"], pluginID);\n });\n default:\n return state;\n }\n};\n","import type { Flow } from \"@player-ui/react\";\nimport { dequal } from \"dequal\";\n\n/**\n * Compares two Flow objects and identifies if there's a change in their structure or data.\n *\n * This function takes two Flow objects as input, `curr` (current) and `next` (next), and compares them\n * to determine if there's a change in the flow's structure or its data. If there's a change in the flow's\n * structure (excluding the `data` property), it returns an object indicating a \"flow\" change along with the\n * new flow. If there's a change in the `data` property, it returns an object indicating a \"data\" change along\n * with the new data. If there are no changes, it returns null.\n */\nexport const flowDiff = ({\n curr,\n next,\n}: {\n curr: Flow;\n next: Flow;\n}):\n | { change: \"data\"; value: Flow[\"data\"] }\n | { change: \"flow\"; value: Flow }\n | null => {\n // compare flows except for the `data` property\n const currCopy = { ...curr, data: null };\n const nextCopy = { ...next, data: null };\n\n const baseFlowIsEqual = dequal(currCopy, nextCopy);\n\n if (!baseFlowIsEqual) {\n return { change: \"flow\", value: next };\n }\n\n // compare data\n const currData = curr.data;\n const nextData = next.data;\n\n const dataIsEqual = dequal(currData, nextData);\n\n if (!dataIsEqual) {\n return { change: \"data\", value: nextData };\n }\n\n return null;\n};\n","import { extendTheme, type ThemeConfig } from \"@chakra-ui/react\";\n\nconst config: ThemeConfig = {\n initialColorMode: \"dark\",\n useSystemColorMode: false,\n};\n\nexport const theme = extendTheme({ config });\n"],"mappings":";AAAA,OAAO,SAAS,cAAc;AAK9B,SAA+B,sBAAsB;AACrD,SAAS,aAAAA,kBAAiB;AAC1B,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,qBAAqB;;;ACpBvB,IAAM,eAAqB;AAAA,EAChC,IAAI;AAAA,EACJ,OAAO;AAAA,IACL;AAAA,MACE,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EACA,YAAY;AAAA,IACV,OAAO;AAAA,IACP,QAAQ;AAAA,MACN,YAAY;AAAA,MACZ,QAAQ;AAAA,QACN,YAAY;AAAA,QACZ,KAAK;AAAA,QACL,aAAa,CAAC;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,0BAA0C;AAAA,EACrD,SAAS;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV;AAAA,EACA,SAAS,CAAC;AACZ;;;AC/BA,OAAO,4BAA4B;AACnC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C,eAAU,CACb,GACA,oCAAC,iBACC,oCAAC,iBAAQ,OAAK,GACd,oCAAC,aAAK,KAAK,UAAU,OAAO,MAAM,CAAC,CAAE,CACvC,CACF,IAEA,oCAAC,QAAK,gBAAe,UAAS,SAAQ,OACpC,oCAAC,YAAK,4DACqD,KACzD,oCAAC,OAAE,MAAK,kCAA+B,8BAEvC,GAAK,KAAI,gBAEX,CACF,CAEJ,CACF,CACF,CACF;AAEJ;","names":["useEffect","useEffect"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/panel/index.tsx","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/constants/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/plugins/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/state/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/state/reducer.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/helpers/flowDiff.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/client/src/panel/theme.ts"],"sourcesContent":["import React, { useRef } from \"react\";\nimport type {\n MessengerOptions,\n ExtensionSupportedEvents,\n} from \"@player-tools/devtools-types\";\nimport { DataController, Flow, useReactPlayer } from \"@player-ui/react\";\nimport { useEffect } from \"react\";\nimport { ErrorBoundary } from \"react-error-boundary\";\nimport {\n Card,\n CardBody,\n CardHeader,\n ChakraProvider,\n Container,\n Flex,\n FormControl,\n FormLabel,\n Heading,\n HStack,\n Select,\n Text,\n VStack,\n} from \"@chakra-ui/react\";\nimport { ThemeProvider } from \"@devtools-ds/themes\";\n\nimport { INITIAL_FLOW } from \"../constants\";\nimport { PLAYER_PLUGINS, PUBSUB_PLUGIN } from \"../plugins\";\nimport { useExtensionState } from \"../state\";\nimport { flowDiff } from \"../helpers/flowDiff\";\nimport { theme } from \"./theme\";\n\nconst fallbackRender: ErrorBoundary[\"props\"][\"fallbackRender\"] = ({\n error,\n}) => {\n return (\n <Container centerContent>\n <Card>\n <CardHeader>\n <Heading>Ops, something went wrong.</Heading>\n </CardHeader>\n </Card>\n <CardBody>\n <Text as=\"pre\">{error.message}</Text>\n </CardBody>\n </Container>\n );\n};\n\n/**\n * Panel Component\n *\n * This component serves as the main container for the devtools plugin content defined by plugin authors using Player-UI DSL.\n *\n * Props:\n * - `communicationLayer`: An object that allows communication between the devtools and the Player-UI plugins,\n * enabling the exchange of data and events.\n *\n * Features:\n * - Error Handling: Utilizes the `ErrorBoundary` component from `react-error-boundary` to gracefully handle and display errors\n * that may occur during the rendering of the plugin's content.\n * - State Management: Integrates with custom hooks such as `useExtensionState` to manage the state of the plugin and its components.\n * - Player Integration: Uses the `useReactPlayer` hook from `player-ui/react` to render interactive player components based on the\n * DSL defined by the plugin authors.\n *\n * Example Usage:\n * ```tsx\n * <Panel communicationLayer={myCommunicationLayer} />\n * ```\n *\n * Note: The `communicationLayer` prop is essential for the proper functioning of the `Panel` component, as it enables the necessary\n * communication and data exchange with the player-ui/react library.\n */\nexport const Panel = ({\n communicationLayer,\n}: {\n /** the communication layer to use for the extension */\n readonly communicationLayer: Pick<\n MessengerOptions<ExtensionSupportedEvents>,\n \"sendMessage\" | \"addListener\" | \"removeListener\"\n >;\n}) => {\n const { state, selectPlayer, selectPlugin, handleInteraction } =\n useExtensionState({\n communicationLayer,\n });\n\n const { reactPlayer } = useReactPlayer({\n plugins: PLAYER_PLUGINS,\n });\n\n const dataController = useRef<WeakRef<DataController> | null>(null);\n\n const currentFlow = useRef<Flow | null>(null);\n\n useEffect(() => {\n reactPlayer.player.hooks.dataController.tap(\"devtools-panel\", (d) => {\n dataController.current = new WeakRef(d);\n });\n }, [reactPlayer]);\n\n useEffect(() => {\n // we subscribe to all messages from the devtools plugin\n // so the plugin author can define their own events\n PUBSUB_PLUGIN.subscribe(\"*\", (type: string, payload: string) => {\n handleInteraction({\n type,\n payload,\n });\n });\n }, []);\n\n useEffect(() => {\n const { player, plugin } = state.current;\n\n const flow =\n player && plugin\n ? state.players[player]?.plugins?.[plugin]?.flow || INITIAL_FLOW\n : INITIAL_FLOW;\n\n if (!currentFlow.current) {\n currentFlow.current = flow;\n reactPlayer.start(flow);\n return;\n }\n\n const diff = flowDiff({\n curr: currentFlow.current as Flow,\n next: flow,\n });\n\n if (diff) {\n const { change, value } = diff;\n\n if (change === \"flow\") {\n currentFlow.current = value;\n reactPlayer.start(value);\n } else if (change === \"data\") {\n dataController.current\n ? dataController.current\n .deref()\n ?.set(value as Record<string, unknown>)\n : reactPlayer.start(flow);\n }\n }\n }, [reactPlayer, state]);\n\n const Component = reactPlayer.Component as React.FC;\n\n return (\n <ChakraProvider theme={theme}>\n <ThemeProvider colorScheme=\"dark\">\n <ErrorBoundary fallbackRender={fallbackRender}>\n <Flex direction=\"column\" w=\"100vw\" h=\"100vh\" alignItems={\"normal\"}>\n {state.current.player ? (\n <Container minWidth={\"100%\"}>\n <Flex direction=\"column\" marginTop=\"4\">\n <Flex gap={\"8\"}>\n <FormControl>\n <FormLabel>Player</FormLabel>\n <Select\n id=\"player\"\n value={state.current.player || \"\"}\n onChange={(event) => selectPlayer(event.target.value)}\n >\n {Object.keys(state.players).map((playerID) => (\n <option key={playerID} value={playerID}>\n {playerID}\n </option>\n ))}\n </Select>\n </FormControl>\n <FormControl>\n <FormLabel>Plugin</FormLabel>\n <Select\n id=\"plugin\"\n value={state.current.plugin || \"\"}\n onChange={(event) => selectPlugin(event.target.value)}\n >\n {Object.keys(\n state.players[state.current.player].plugins\n ).map((pluginID) => (\n <option key={pluginID} value={pluginID}>\n {pluginID}\n </option>\n ))}\n </Select>\n </FormControl>\n </Flex>\n <Flex>\n <Component />\n </Flex>\n <details>\n <summary>Debug</summary>\n <pre style={{ maxHeight: \"30vh\", overflow: \"scroll\" }}>\n {JSON.stringify(state, null, 2)}\n </pre>\n </details>\n </Flex>\n </Container>\n ) : (\n <Flex justifyContent=\"center\" padding=\"6\">\n <Text>\n No Player-UI instance or devtools plugin detected. Visit{\" \"}\n <a href=\"https://player-ui.github.io/\">\n https://player-ui.github.io/\n </a>{\" \"}\n for more info.\n </Text>\n </Flex>\n )}\n </Flex>\n </ErrorBoundary>\n </ThemeProvider>\n </ChakraProvider>\n );\n};\n","import type { ExtensionState } from \"@player-tools/devtools-types\";\nimport type { Flow } from \"@player-ui/react\";\n\nexport const INITIAL_FLOW: Flow = {\n id: \"initial-flow\",\n views: [\n {\n id: \"view-1\",\n type: \"text\",\n value: \"connecting...\",\n },\n ],\n navigation: {\n BEGIN: \"FLOW_1\",\n FLOW_1: {\n startState: \"VIEW_1\",\n VIEW_1: {\n state_type: \"VIEW\",\n ref: \"view-1\",\n transitions: {},\n },\n },\n },\n};\n\nexport const INITIAL_EXTENSION_STATE: ExtensionState = {\n current: {\n player: null,\n plugin: null,\n },\n players: {},\n};\n","import DevtoolsUIAssetsPlugin from \"@devtools-ui/plugin\";\nimport { PubSubPlugin } from \"@player-ui/pubsub-plugin\";\nimport type { ReactPlayerPlugin } from \"@player-ui/react\";\n\nexport const PUBSUB_PLUGIN = new PubSubPlugin();\n\nexport const PLAYER_PLUGINS: ReactPlayerPlugin[] = [\n new DevtoolsUIAssetsPlugin(),\n PUBSUB_PLUGIN,\n];\n","import { Messenger } from \"@player-tools/devtools-messenger\";\nimport type {\n ExtensionSupportedEvents,\n MessengerOptions,\n} from \"@player-tools/devtools-types\";\nimport { useCallback, useEffect, useMemo, useReducer } from \"react\";\n\nimport { INITIAL_EXTENSION_STATE } from \"../constants\";\nimport { reducer } from \"./reducer\";\n\nconst NOOP_ID = -1;\n\n/**\n * Custom React hook for managing the state of the devtools extension.\n *\n * This hook initializes the extension's state and sets up a communication layer\n * using the `Messenger` class. It provides methods to select a player or plugin,\n * and handle interactions, which dispatch actions to update the state accordingly.\n *\n */\nexport const useExtensionState = ({\n communicationLayer,\n}: {\n /** the communication layer to use for the extension */\n communicationLayer: Pick<\n MessengerOptions<ExtensionSupportedEvents>,\n \"sendMessage\" | \"addListener\" | \"removeListener\"\n >;\n}) => {\n const [state, dispatch] = useReducer(reducer, INITIAL_EXTENSION_STATE);\n\n const messengerOptions = useMemo<MessengerOptions<ExtensionSupportedEvents>>(\n () => ({\n context: \"devtools\",\n target: \"player\",\n messageCallback: (message) => {\n dispatch(message);\n },\n ...communicationLayer,\n logger: console,\n }),\n [dispatch, communicationLayer]\n );\n\n const messenger = useMemo(\n () => new Messenger(messengerOptions),\n [messengerOptions]\n );\n\n useEffect(() => {\n return () => {\n messenger.destroy();\n };\n }, []);\n\n const selectPlayer = useCallback(\n (playerID: string) => {\n dispatch({\n id: NOOP_ID,\n sender: \"internal\",\n context: \"devtools\",\n _messenger_: false,\n timestamp: Date.now(),\n type: \"PLAYER_DEVTOOLS_PLAYER_SELECTED\",\n payload: {\n playerID,\n },\n });\n },\n [dispatch]\n );\n\n const selectPlugin = useCallback(\n (pluginID: string) => {\n dispatch({\n id: NOOP_ID,\n sender: \"internal\",\n context: \"devtools\",\n _messenger_: false,\n timestamp: Date.now(),\n type: \"PLAYER_DEVTOOLS_PLUGIN_SELECTED\",\n payload: {\n pluginID,\n },\n });\n },\n [dispatch]\n );\n\n /**\n * Plugin authors can add interactive elements to the Player-UI content by leveraging\n * the pub-sub plugin and having the handle interaction proxy the message to the inspected\n * Player-UI instance.\n */\n const handleInteraction = useCallback(\n ({\n type,\n payload,\n }: {\n /** interaction type */\n type: string;\n /** interaction payload */\n payload?: string;\n }) => {\n messenger.sendMessage({\n type: \"PLAYER_DEVTOOLS_PLUGIN_INTERACTION\",\n payload: {\n type,\n payload,\n },\n });\n },\n [messenger]\n );\n\n return { state, selectPlayer, selectPlugin, handleInteraction };\n};\n","import type {\n ExtensionState,\n ExtensionSupportedEvents,\n Transaction,\n} from \"@player-tools/devtools-types\";\nimport { dset } from \"dset/merge\";\nimport { produce } from \"immer\";\n\n/** Extension state reducer */\nexport const reducer = (\n state: ExtensionState,\n transaction: Transaction<ExtensionSupportedEvents>\n): ExtensionState => {\n switch (transaction.type) {\n case \"PLAYER_DEVTOOLS_PLAYER_INIT\":\n return produce(state, (draft) => {\n const {\n sender,\n payload: { plugins },\n } = transaction;\n dset(draft, [\"current\", \"player\"], sender);\n dset(draft, [\"current\", \"plugin\"], plugins[Object.keys(plugins)[0]].id);\n\n dset(draft, [\"players\", sender, \"plugins\"], plugins);\n dset(draft, [\"players\", sender, \"active\"], true);\n });\n case \"PLAYER_DEVTOOLS_PLUGIN_FLOW_CHANGE\":\n return produce(state, (draft) => {\n const {\n sender,\n payload: { flow, pluginID },\n } = transaction;\n\n dset(draft, [\"players\", sender, \"plugins\", pluginID, \"flow\"], flow);\n });\n case \"PLAYER_DEVTOOLS_PLUGIN_DATA_CHANGE\":\n return produce(state, (draft) => {\n const {\n sender,\n payload: { data, pluginID },\n } = transaction;\n dset(\n draft,\n [\"players\", sender, \"plugins\", pluginID, \"flow\", \"data\"],\n data\n );\n });\n case \"MESSENGER_EVENT_BATCH\":\n return produce(state, (draft) => {\n return transaction.payload.events.reduce(reducer, draft);\n });\n case \"PLAYER_DEVTOOLS_PLAYER_STOPPED\":\n return produce(state, (draft) => {\n const { sender } = transaction;\n\n dset(draft, [\"players\", sender, \"active\"], false);\n });\n case \"PLAYER_DEVTOOLS_PLAYER_SELECTED\":\n return produce(state, (draft) => {\n const { playerID } = transaction.payload;\n dset(draft, [\"current\", \"player\"], playerID);\n });\n case \"PLAYER_DEVTOOLS_PLUGIN_SELECTED\":\n return produce(state, (draft) => {\n const { pluginID } = transaction.payload;\n dset(draft, [\"current\", \"plugin\"], pluginID);\n });\n default:\n return state;\n }\n};\n","import type { Flow } from \"@player-ui/react\";\nimport { dequal } from \"dequal\";\n\n/**\n * Compares two Flow objects and identifies if there's a change in their structure or data.\n *\n * This function takes two Flow objects as input, `curr` (current) and `next` (next), and compares them\n * to determine if there's a change in the flow's structure or its data. If there's a change in the flow's\n * structure (excluding the `data` property), it returns an object indicating a \"flow\" change along with the\n * new flow. If there's a change in the `data` property, it returns an object indicating a \"data\" change along\n * with the new data. If there are no changes, it returns null.\n */\nexport const flowDiff = ({\n curr,\n next,\n}: {\n curr: Flow;\n next: Flow;\n}):\n | { change: \"data\"; value: Flow[\"data\"] }\n | { change: \"flow\"; value: Flow }\n | null => {\n // compare flows except for the `data` property\n const currCopy = { ...curr, data: null };\n const nextCopy = { ...next, data: null };\n\n const baseFlowIsEqual = dequal(currCopy, nextCopy);\n\n if (!baseFlowIsEqual) {\n return { change: \"flow\", value: next };\n }\n\n // compare data\n const currData = curr.data;\n const nextData = next.data;\n\n const dataIsEqual = dequal(currData, nextData);\n\n if (!dataIsEqual) {\n return { change: \"data\", value: nextData };\n }\n\n return null;\n};\n","import { extendTheme, type ThemeConfig } from \"@chakra-ui/react\";\n\nconst config: ThemeConfig = {\n initialColorMode: \"dark\",\n useSystemColorMode: false,\n};\n\nexport const theme = extendTheme({ config });\n"],"mappings":";AAAA,OAAO,SAAS,cAAc;AAK9B,SAA+B,sBAAsB;AACrD,SAAS,aAAAA,kBAAiB;AAC1B,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,qBAAqB;;;ACpBvB,IAAM,eAAqB;AAAA,EAChC,IAAI;AAAA,EACJ,OAAO;AAAA,IACL;AAAA,MACE,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EACA,YAAY;AAAA,IACV,OAAO;AAAA,IACP,QAAQ;AAAA,MACN,YAAY;AAAA,MACZ,QAAQ;AAAA,QACN,YAAY;AAAA,QACZ,KAAK;AAAA,QACL,aAAa,CAAC;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,0BAA0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M,QAAQ,MAAM,QAAQ,MAAM,EAAE;AAAA,IACtC,EAAE,IAAI,CAAC,aACL,oCAAC,YAAO,KAAK,UAAU,OAAO,YAC3B,QACH,CACD;AAAA,EACH,CACF,CACF,GACA,oCAAC,YACC,oCAAC,eAAU,CACb,GACA,oCAAC,iBACC,oCAAC,iBAAQ,OAAK,GACd,oCAAC,SAAI,OAAO,EAAE,WAAW,QAAQ,UAAU,SAAS,KACjD,KAAK,UAAU,OAAO,MAAM,CAAC,CAChC,CACF,CACF,CACF,IAEA,oCAAC,QAAK,gBAAe,UAAS,SAAQ,OACpC,oCAAC,YAAK,4DACqD,KACzD,oCAAC,OAAE,MAAK,kCAA+B,8BAEvC,GAAK,KAAI,gBAEX,CACF,CAEJ,CACF,CACF,CACF;AAEJ;","names":["useEffect","useEffect"]}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@player-tools/devtools-client",
|
|
3
|
-
"version": "0.6.1-next.
|
|
3
|
+
"version": "0.6.1-next.3",
|
|
4
4
|
"main": "dist/cjs/index.cjs",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@player-tools/devtools-messenger": "0.6.1-next.
|
|
7
|
-
"@player-tools/devtools-types": "0.6.1-next.
|
|
6
|
+
"@player-tools/devtools-messenger": "0.6.1-next.3",
|
|
7
|
+
"@player-tools/devtools-types": "0.6.1-next.3",
|
|
8
8
|
"@chakra-ui/react": "2.8.2",
|
|
9
9
|
"@player-ui/pubsub-plugin": "0.7.3",
|
|
10
10
|
"@player-ui/react": "0.7.3",
|
|
11
|
-
"@devtools-ui/plugin": "0.
|
|
11
|
+
"@devtools-ui/plugin": "0.2.0-next.2",
|
|
12
12
|
"@types/react": "^18.2.51",
|
|
13
13
|
"dset": "^3.1.3",
|
|
14
14
|
"immer": "^10.0.3",
|
package/src/panel/index.tsx
CHANGED
|
@@ -150,49 +150,53 @@ export const Panel = ({
|
|
|
150
150
|
<ChakraProvider theme={theme}>
|
|
151
151
|
<ThemeProvider colorScheme="dark">
|
|
152
152
|
<ErrorBoundary fallbackRender={fallbackRender}>
|
|
153
|
-
<
|
|
153
|
+
<Flex direction="column" w="100vw" h="100vh" alignItems={"normal"}>
|
|
154
154
|
{state.current.player ? (
|
|
155
|
-
<
|
|
156
|
-
<
|
|
157
|
-
<
|
|
158
|
-
<
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
{playerID}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
<
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
{pluginID}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
<
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
<
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
155
|
+
<Container minWidth={"100%"}>
|
|
156
|
+
<Flex direction="column" marginTop="4">
|
|
157
|
+
<Flex gap={"8"}>
|
|
158
|
+
<FormControl>
|
|
159
|
+
<FormLabel>Player</FormLabel>
|
|
160
|
+
<Select
|
|
161
|
+
id="player"
|
|
162
|
+
value={state.current.player || ""}
|
|
163
|
+
onChange={(event) => selectPlayer(event.target.value)}
|
|
164
|
+
>
|
|
165
|
+
{Object.keys(state.players).map((playerID) => (
|
|
166
|
+
<option key={playerID} value={playerID}>
|
|
167
|
+
{playerID}
|
|
168
|
+
</option>
|
|
169
|
+
))}
|
|
170
|
+
</Select>
|
|
171
|
+
</FormControl>
|
|
172
|
+
<FormControl>
|
|
173
|
+
<FormLabel>Plugin</FormLabel>
|
|
174
|
+
<Select
|
|
175
|
+
id="plugin"
|
|
176
|
+
value={state.current.plugin || ""}
|
|
177
|
+
onChange={(event) => selectPlugin(event.target.value)}
|
|
178
|
+
>
|
|
179
|
+
{Object.keys(
|
|
180
|
+
state.players[state.current.player].plugins
|
|
181
|
+
).map((pluginID) => (
|
|
182
|
+
<option key={pluginID} value={pluginID}>
|
|
183
|
+
{pluginID}
|
|
184
|
+
</option>
|
|
185
|
+
))}
|
|
186
|
+
</Select>
|
|
187
|
+
</FormControl>
|
|
188
|
+
</Flex>
|
|
189
|
+
<Flex>
|
|
190
|
+
<Component />
|
|
191
|
+
</Flex>
|
|
192
|
+
<details>
|
|
193
|
+
<summary>Debug</summary>
|
|
194
|
+
<pre style={{ maxHeight: "30vh", overflow: "scroll" }}>
|
|
195
|
+
{JSON.stringify(state, null, 2)}
|
|
196
|
+
</pre>
|
|
197
|
+
</details>
|
|
198
|
+
</Flex>
|
|
199
|
+
</Container>
|
|
196
200
|
) : (
|
|
197
201
|
<Flex justifyContent="center" padding="6">
|
|
198
202
|
<Text>
|
|
@@ -204,7 +208,7 @@ export const Panel = ({
|
|
|
204
208
|
</Text>
|
|
205
209
|
</Flex>
|
|
206
210
|
)}
|
|
207
|
-
</
|
|
211
|
+
</Flex>
|
|
208
212
|
</ErrorBoundary>
|
|
209
213
|
</ThemeProvider>
|
|
210
214
|
</ChakraProvider>
|