@player-tools/devtools-client 0.2.1 → 0.2.2--canary.17.363

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.
@@ -0,0 +1,105 @@
1
+ import { Flow, View } from '@player-ui/types';
2
+ import { Methods, Events, ProfilerNode } from '@player-tools/devtools-common';
3
+
4
+ export type ActivePlayerState = {
5
+ /**
6
+ * state associated with player config
7
+ */
8
+ configState?: Methods.PlayerConfigMethod['result'] | null;
9
+ /**
10
+ * Flow related Information of the player.
11
+ */
12
+ flowInfo?: Methods.PlayerRuntimeInfoMethod['result'] | null;
13
+ /**
14
+ * A collection of all the events associated with the running player instance.
15
+ */
16
+ timelineEvents: Array<Events.TimelineEvents>;
17
+ /**
18
+ * View related information of the player.
19
+ */
20
+ view?: View | undefined;
21
+ /**
22
+ * State assocaited with the data of the player
23
+ */
24
+ dataState: DataState;
25
+ /**
26
+ * State associated with the console evaluations.
27
+ */
28
+ consoleState: ConsoleState;
29
+ /**
30
+ * profiler related information of the player
31
+ */
32
+ profilerInfo?: ProfilerNode | null;
33
+ };
34
+
35
+ export type PlayersState = {
36
+ /**
37
+ * This represents the currently selected player id.
38
+ */
39
+ selectedPlayerId: string | null;
40
+ /**
41
+ * Collection of all the players active on the web page.
42
+ */
43
+ activePlayers: Record<string, ActivePlayerState>;
44
+ /**
45
+ * Web Player version
46
+ */
47
+ version: string;
48
+ };
49
+
50
+ export type StoreState = {
51
+ /**
52
+ * State related to all the players on the web page.
53
+ */
54
+ players: PlayersState;
55
+ };
56
+
57
+ export type FlowInfoState = {
58
+ /**
59
+ * Current Flow Id.
60
+ */
61
+ currentFlowID?: string;
62
+ /**
63
+ * Current Flow State
64
+ */
65
+ currentFlowState?: string;
66
+ /**
67
+ * Current View Id.
68
+ */
69
+ currentViewID?: string;
70
+ /**
71
+ * Current FLow
72
+ */
73
+ currentFlow?: Flow;
74
+ };
75
+
76
+ export type DataState = {
77
+ /**
78
+ * The binding selected on the Data panel.
79
+ */
80
+ selectedBinding?: Methods.PlayerDataBindingMethod['result'];
81
+ /**
82
+ * All the bindings in the data state.
83
+ */
84
+ allBindings?: Methods.PlayerDataBindingMethod['result'];
85
+ };
86
+
87
+ export interface ConsoleState {
88
+ /**
89
+ * History of all the console evaluations
90
+ */
91
+ history: Array<{
92
+ /**
93
+ * Unique Id representing a Console evaluation.
94
+ */
95
+ id: string;
96
+ /**
97
+ * Expression being evaluated.
98
+ */
99
+ expression: string;
100
+ /**
101
+ * Result of the console evaluation.
102
+ */
103
+ result: Methods.PlayerExpressionMethod['result'];
104
+ }>;
105
+ }
@@ -0,0 +1,49 @@
1
+ import {
2
+ type AnyAction,
3
+ type Dispatch,
4
+ type Middleware,
5
+ type MiddlewareArray,
6
+ type ActionReducerMapBuilder,
7
+ type EnhancedStore,
8
+ configureStore,
9
+ createReducer,
10
+ combineReducers,
11
+ createAsyncThunk,
12
+ } from '@reduxjs/toolkit';
13
+ import { Message } from '@player-tools/devtools-common';
14
+ import { PlayersState, StoreState } from './state';
15
+ import { Methods } from './actions';
16
+ import { playersReducer } from './reducers';
17
+ import { listenerMiddleware } from './middleware';
18
+
19
+ /**
20
+ * This function returns the players store. Accepts optional middleware and callback to enhance the store.
21
+ * @param middleware : Middleware to be added to the store. Optional.
22
+ * @param additionalReducers Additional reducers to be added to the store. Optional
23
+ * @returns
24
+ */
25
+ export const createDevtoolsStore = (
26
+ onMethodRequest: Methods.MethodHandler,
27
+ middleware?: Middleware<any, StoreState, Dispatch<AnyAction>>,
28
+ additionalReducers?: any,
29
+ ): EnhancedStore<
30
+ StoreState,
31
+ any,
32
+ Middleware<any, StoreState, Dispatch<AnyAction>>[]
33
+ > =>
34
+ configureStore({
35
+ reducer: {
36
+ // TODO: Look into slices
37
+ players: playersReducer(Methods.buildAsyncThunks(onMethodRequest)),
38
+ ...additionalReducers,
39
+ },
40
+ middleware: (getDefaultMiddleware) => {
41
+ // TODO: Potentially hook up our own middleware for dispatching additional actions from event actions
42
+ const m = getDefaultMiddleware()
43
+ .concat(listenerMiddleware.middleware)
44
+
45
+ if (middleware) m.prepend(middleware)
46
+
47
+ return m
48
+ }
49
+ });
package/src/rpc/index.ts DELETED
@@ -1,21 +0,0 @@
1
- import {
2
- type RPCRequestMessageEvent,
3
- type RPCRequestHandler,
4
- createRPCRequest,
5
- Runtime,
6
- PANEL_SOURCE,
7
- } from '@player-tools/devtools-common';
8
-
9
- export type RuntimeRPCRequestHandlers = {
10
- [key in Runtime.RuntimeRPCTypes]: RPCRequestHandler<any>;
11
- };
12
-
13
- export const buildRPCRequests = (
14
- onRequestMessage: (
15
- message: RPCRequestMessageEvent<Runtime.RuntimeRPC>
16
- ) => void
17
- ): RuntimeRPCRequestHandlers =>
18
- Runtime.RuntimeRPCTypes.reduce((acc, rpcType) => {
19
- acc[rpcType] = createRPCRequest(rpcType, PANEL_SOURCE, onRequestMessage);
20
- return acc;
21
- }, {} as RuntimeRPCRequestHandlers);