@player-tools/devtools-client 0.5.3-next.0 → 0.6.0-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.
@@ -1,36 +0,0 @@
1
- import { type AsyncThunk, createAsyncThunk } from "@reduxjs/toolkit";
2
- import {
3
- Runtime,
4
- createLogger,
5
- BACKGROUND_SOURCE,
6
- } from "@player-tools/devtools-common";
7
- import type { RuntimeRPCRequestHandlers } from "../rpc";
8
-
9
- const logger = createLogger(BACKGROUND_SOURCE);
10
-
11
- export type AsyncRPCActions = {
12
- [key in Runtime.RuntimeRPCTypes]: AsyncThunk<
13
- Extract<Runtime.RuntimeRPC, { type: key }>["result"],
14
- Extract<Runtime.RuntimeRPC, { type: key }>["params"],
15
- any
16
- >;
17
- };
18
-
19
- export const buildRPCActions = (
20
- handlers: RuntimeRPCRequestHandlers
21
- ): AsyncRPCActions =>
22
- Runtime.RuntimeRPCTypes.reduce((acc, rpcType) => {
23
- acc[rpcType] = createAsyncThunk<
24
- Extract<Runtime.RuntimeRPC, { type: typeof rpcType }>["result"],
25
- Extract<Runtime.RuntimeRPC, { type: typeof rpcType }>["params"]
26
- >(rpcType, async (params) => {
27
- logger.log(`Requesting ${rpcType}`, params);
28
- const data = (await handlers[rpcType].call(params)) as Extract<
29
- Runtime.RuntimeRPC,
30
- { type: typeof rpcType }
31
- >["result"];
32
- logger.log(`Response from ${rpcType}`, data);
33
- return data;
34
- }) as any;
35
- return acc;
36
- }, {} as AsyncRPCActions);
@@ -1,45 +0,0 @@
1
- import type {
2
- AliasAction,
3
- ConfigAction,
4
- DataBindingAction,
5
- ExpressionAction,
6
- StartProfilerAction,
7
- StopProfilerAction,
8
- } from "@player-tools/devtools-common";
9
- import type { AsyncRPCActions } from "./actions";
10
-
11
- export const GET_INFO_DETAILS = "GET_INFO_DETAILS";
12
- export const GET_CONFIG_DETAILS = "GET_CONFIG_DETAILS";
13
- export const GET_VIEW_DETAILS = "GET_VIEW_DETAILS";
14
- export const GET_DATA_BINDING_DETAILS = "GET_DATA_BINDING_DETAILS";
15
- export const GET_CONSOLE_EVAL = "GET_CONSOLE_EVAL";
16
- export const START_PROFILER = "START_PROFILER";
17
- export const STOP_PROFILER = "STOP_PROFILER";
18
-
19
- const _alias = (aliases: any) => () => (next: any) => (action: any) => {
20
- const alias = aliases[action.type];
21
-
22
- if (alias) {
23
- return next(alias(action));
24
- }
25
-
26
- return next(action);
27
- };
28
-
29
- export const buildAliases = (actions: AsyncRPCActions) =>
30
- _alias({
31
- GET_INFO_DETAILS: (action: AliasAction) =>
32
- actions["player-runtime-info-request"](action.payload),
33
- GET_CONFIG_DETAILS: (action: ConfigAction) =>
34
- actions["player-config-request"](action.payload),
35
- GET_VIEW_DETAILS: (action: AliasAction) =>
36
- actions["player-view-details-request"](action.payload),
37
- GET_DATA_BINDING_DETAILS: (action: DataBindingAction) =>
38
- actions["player-data-binding-details"](action.payload),
39
- GET_CONSOLE_EVAL: (action: ExpressionAction) =>
40
- actions["player-execute-expression"](action.payload),
41
- START_PROFILER: (action: StartProfilerAction) =>
42
- actions["player-start-profiler-request"](action.payload),
43
- STOP_PROFILER: (action: StopProfilerAction) =>
44
- actions["player-stop-profiler-request"](action.payload),
45
- });
@@ -1,70 +0,0 @@
1
- import {
2
- type Message,
3
- clearStore,
4
- playerFlowStartAction,
5
- playerInitAction,
6
- playerRemoveAction,
7
- playerTimelineAction,
8
- playerViewUpdateAction,
9
- selectedPlayerAction,
10
- } from "@player-tools/devtools-common";
11
- import type { Store } from "redux";
12
- import { GET_DATA_BINDING_DETAILS } from "./aliases";
13
-
14
- export * from "./actions";
15
- export * from "./aliases";
16
- export * from "./reducers";
17
-
18
- export function handleMessage(store: Store, message: Message) {
19
- switch (message.type) {
20
- case "runtime-init":
21
- store.dispatch(clearStore());
22
- break;
23
- case "player-init":
24
- store.dispatch(playerInitAction(message));
25
- store.dispatch(selectedPlayerAction());
26
- break;
27
- case "player-removed":
28
- store.dispatch(playerRemoveAction(message.playerID));
29
- store.dispatch(selectedPlayerAction());
30
- break;
31
- case "player-flow-start":
32
- store.dispatch(playerFlowStartAction(message));
33
- store.dispatch(playerTimelineAction(message));
34
- store.dispatch({
35
- type: GET_DATA_BINDING_DETAILS,
36
- payload: { playerID: message.playerID, binding: "" },
37
- });
38
- break;
39
- case "player-log-event":
40
- store.dispatch(playerTimelineAction(message));
41
- break;
42
- case "player-view-update-event":
43
- store.dispatch(playerViewUpdateAction(message));
44
- break;
45
- case "player-data-change-event": {
46
- const { players } = store.getState();
47
-
48
- if (
49
- players.activePlayers[message.playerID] &&
50
- players.activePlayers[message.playerID].dataState.selectedBinding
51
- ) {
52
- store.dispatch({
53
- type: GET_DATA_BINDING_DETAILS,
54
- payload: message,
55
- });
56
- }
57
-
58
- store.dispatch({
59
- type: GET_DATA_BINDING_DETAILS,
60
- payload: { playerID: message.playerID, binding: "" },
61
- });
62
- store.dispatch(playerTimelineAction(message));
63
- break;
64
- }
65
-
66
- default:
67
- console.warn(`Unhandled event: ${JSON.stringify(message)}`);
68
- break;
69
- }
70
- }
@@ -1,118 +0,0 @@
1
- import type { ActionReducerMapBuilder } from "@reduxjs/toolkit";
2
- import type { PlayersState } from "@player-tools/devtools-common";
3
- import type { AsyncRPCActions } from "./actions";
4
-
5
- /**
6
- * Callback function that adds cases for async actions for the player.
7
- * @param playerReducerCallback
8
- * @returns
9
- */
10
- export const buildPlayerReducerCallback =
11
- (actions: AsyncRPCActions) =>
12
- (builder: ActionReducerMapBuilder<PlayersState>) => {
13
- builder.addCase(
14
- actions["player-runtime-info-request"].fulfilled,
15
- (state, action) => {
16
- const { activePlayers, selectedPlayerId } = state;
17
-
18
- if (!selectedPlayerId) {
19
- return;
20
- }
21
-
22
- const data =
23
- action.payload && Object.keys(action.payload).length > 0
24
- ? action.payload
25
- : null;
26
- activePlayers[selectedPlayerId].flowInfo = data;
27
- }
28
- );
29
-
30
- builder.addCase(
31
- actions["player-config-request"].fulfilled,
32
- (state, action) => {
33
- const { activePlayers, selectedPlayerId } = state;
34
-
35
- if (!selectedPlayerId) {
36
- return;
37
- }
38
-
39
- activePlayers[selectedPlayerId].configState = action.payload;
40
- }
41
- );
42
-
43
- builder.addCase(
44
- actions["player-view-details-request"].fulfilled,
45
- (state, action) => {
46
- const { activePlayers, selectedPlayerId } = state;
47
-
48
- if (!selectedPlayerId) {
49
- return;
50
- }
51
-
52
- activePlayers[selectedPlayerId].view = action.payload?.lastViewUpdate;
53
- }
54
- );
55
-
56
- builder.addCase(
57
- actions["player-data-binding-details"].fulfilled,
58
- (state, action) => {
59
- const {
60
- meta: {
61
- arg: { binding, playerID },
62
- },
63
- payload,
64
- } = action;
65
- const { activePlayers } = state;
66
-
67
- if (!playerID || !activePlayers[playerID]) {
68
- return;
69
- }
70
-
71
- if (binding === "") {
72
- activePlayers[playerID].dataState.allBindings = payload;
73
- return;
74
- }
75
-
76
- activePlayers[playerID].dataState.selectedBinding = payload;
77
- }
78
- );
79
-
80
- builder.addCase(
81
- actions["player-execute-expression"].fulfilled,
82
- (state, action) => {
83
- const { activePlayers, selectedPlayerId } = state;
84
-
85
- if (!selectedPlayerId) {
86
- return;
87
- }
88
-
89
- activePlayers[selectedPlayerId].consoleState?.history?.push({
90
- id: action.meta.requestId,
91
- result: action.payload,
92
- expression: action.payload?.exp ?? "",
93
- });
94
- }
95
- );
96
-
97
- builder.addCase(
98
- actions["player-start-profiler-request"].fulfilled,
99
- (state, action) => {
100
- const { activePlayers, selectedPlayerId } = state;
101
-
102
- if (!selectedPlayerId) return;
103
-
104
- activePlayers[selectedPlayerId].profilerInfo = action.payload?.data;
105
- }
106
- );
107
-
108
- builder.addCase(
109
- actions["player-stop-profiler-request"].fulfilled,
110
- (state, action) => {
111
- const { activePlayers, selectedPlayerId } = state;
112
-
113
- if (!selectedPlayerId) return;
114
-
115
- activePlayers[selectedPlayerId].profilerInfo = action.payload?.data;
116
- }
117
- );
118
- };
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);
@@ -1,12 +0,0 @@
1
- import { type AsyncThunk } from "@reduxjs/toolkit";
2
- import { Runtime } from "@player-tools/devtools-common";
3
- import type { RuntimeRPCRequestHandlers } from "../rpc";
4
- export type AsyncRPCActions = {
5
- [key in Runtime.RuntimeRPCTypes]: AsyncThunk<Extract<Runtime.RuntimeRPC, {
6
- type: key;
7
- }>["result"], Extract<Runtime.RuntimeRPC, {
8
- type: key;
9
- }>["params"], any>;
10
- };
11
- export declare const buildRPCActions: (handlers: RuntimeRPCRequestHandlers) => AsyncRPCActions;
12
- //# sourceMappingURL=actions.d.ts.map
@@ -1,10 +0,0 @@
1
- import type { AsyncRPCActions } from "./actions";
2
- export declare const GET_INFO_DETAILS = "GET_INFO_DETAILS";
3
- export declare const GET_CONFIG_DETAILS = "GET_CONFIG_DETAILS";
4
- export declare const GET_VIEW_DETAILS = "GET_VIEW_DETAILS";
5
- export declare const GET_DATA_BINDING_DETAILS = "GET_DATA_BINDING_DETAILS";
6
- export declare const GET_CONSOLE_EVAL = "GET_CONSOLE_EVAL";
7
- export declare const START_PROFILER = "START_PROFILER";
8
- export declare const STOP_PROFILER = "STOP_PROFILER";
9
- export declare const buildAliases: (actions: AsyncRPCActions) => () => (next: any) => (action: any) => any;
10
- //# sourceMappingURL=aliases.d.ts.map
@@ -1,7 +0,0 @@
1
- import { type Message } from "@player-tools/devtools-common";
2
- import type { Store } from "redux";
3
- export * from "./actions";
4
- export * from "./aliases";
5
- export * from "./reducers";
6
- export declare function handleMessage(store: Store, message: Message): void;
7
- //# sourceMappingURL=index.d.ts.map
@@ -1,10 +0,0 @@
1
- import type { ActionReducerMapBuilder } from "@reduxjs/toolkit";
2
- import type { PlayersState } from "@player-tools/devtools-common";
3
- import type { AsyncRPCActions } from "./actions";
4
- /**
5
- * Callback function that adds cases for async actions for the player.
6
- * @param playerReducerCallback
7
- * @returns
8
- */
9
- export declare const buildPlayerReducerCallback: (actions: AsyncRPCActions) => (builder: ActionReducerMapBuilder<PlayersState>) => void;
10
- //# sourceMappingURL=reducers.d.ts.map
@@ -1,6 +0,0 @@
1
- import { type RPCRequestMessageEvent, type RPCRequestHandler, Runtime } from "@player-tools/devtools-common";
2
- export type RuntimeRPCRequestHandlers = {
3
- [key in Runtime.RuntimeRPCTypes]: RPCRequestHandler<any>;
4
- };
5
- export declare const buildRPCRequests: (onRequestMessage: (message: RPCRequestMessageEvent<Runtime.RuntimeRPC>) => void) => RuntimeRPCRequestHandlers;
6
- //# sourceMappingURL=index.d.ts.map