@player-tools/devtools-client 0.4.2-next.1 → 0.5.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.
package/dist/index.cjs.js DELETED
@@ -1,203 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var devtoolsCommon = require('@player-tools/devtools-common');
6
- var toolkit = require('@reduxjs/toolkit');
7
-
8
- const GET_INFO_DETAILS = "GET_INFO_DETAILS";
9
- const GET_CONFIG_DETAILS = "GET_CONFIG_DETAILS";
10
- const GET_VIEW_DETAILS = "GET_VIEW_DETAILS";
11
- const GET_DATA_BINDING_DETAILS = "GET_DATA_BINDING_DETAILS";
12
- const GET_CONSOLE_EVAL = "GET_CONSOLE_EVAL";
13
- const START_PROFILER = "START_PROFILER";
14
- const STOP_PROFILER = "STOP_PROFILER";
15
- const _alias = (aliases) => () => (next) => (action) => {
16
- const alias = aliases[action.type];
17
- if (alias) {
18
- return next(alias(action));
19
- }
20
- return next(action);
21
- };
22
- const buildAliases = (actions) => _alias({
23
- GET_INFO_DETAILS: (action) => actions["player-runtime-info-request"](action.payload),
24
- GET_CONFIG_DETAILS: (action) => actions["player-config-request"](action.payload),
25
- GET_VIEW_DETAILS: (action) => actions["player-view-details-request"](action.payload),
26
- GET_DATA_BINDING_DETAILS: (action) => actions["player-data-binding-details"](action.payload),
27
- GET_CONSOLE_EVAL: (action) => actions["player-execute-expression"](action.payload),
28
- START_PROFILER: (action) => actions["player-start-profiler-request"](action.payload),
29
- STOP_PROFILER: (action) => actions["player-stop-profiler-request"](action.payload)
30
- });
31
-
32
- var __async = (__this, __arguments, generator) => {
33
- return new Promise((resolve, reject) => {
34
- var fulfilled = (value) => {
35
- try {
36
- step(generator.next(value));
37
- } catch (e) {
38
- reject(e);
39
- }
40
- };
41
- var rejected = (value) => {
42
- try {
43
- step(generator.throw(value));
44
- } catch (e) {
45
- reject(e);
46
- }
47
- };
48
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
49
- step((generator = generator.apply(__this, __arguments)).next());
50
- });
51
- };
52
- const logger = devtoolsCommon.createLogger(devtoolsCommon.BACKGROUND_SOURCE);
53
- const buildRPCActions = (handlers) => devtoolsCommon.Runtime.RuntimeRPCTypes.reduce((acc, rpcType) => {
54
- acc[rpcType] = toolkit.createAsyncThunk(rpcType, (params) => __async(undefined, null, function* () {
55
- logger.log(`Requesting ${rpcType}`, params);
56
- const data = yield handlers[rpcType].call(params);
57
- logger.log(`Response from ${rpcType}`, data);
58
- return data;
59
- }));
60
- return acc;
61
- }, {});
62
-
63
- const buildPlayerReducerCallback = (actions) => (builder) => {
64
- builder.addCase(actions["player-runtime-info-request"].fulfilled, (state, action) => {
65
- const { activePlayers, selectedPlayerId } = state;
66
- if (!selectedPlayerId) {
67
- return;
68
- }
69
- const data = action.payload && Object.keys(action.payload).length > 0 ? action.payload : null;
70
- activePlayers[selectedPlayerId].flowInfo = data;
71
- });
72
- builder.addCase(actions["player-config-request"].fulfilled, (state, action) => {
73
- const { activePlayers, selectedPlayerId } = state;
74
- if (!selectedPlayerId) {
75
- return;
76
- }
77
- activePlayers[selectedPlayerId].configState = action.payload;
78
- });
79
- builder.addCase(actions["player-view-details-request"].fulfilled, (state, action) => {
80
- var _a;
81
- const { activePlayers, selectedPlayerId } = state;
82
- if (!selectedPlayerId) {
83
- return;
84
- }
85
- activePlayers[selectedPlayerId].view = (_a = action.payload) == null ? void 0 : _a.lastViewUpdate;
86
- });
87
- builder.addCase(actions["player-data-binding-details"].fulfilled, (state, action) => {
88
- const {
89
- meta: {
90
- arg: { binding, playerID }
91
- },
92
- payload
93
- } = action;
94
- const { activePlayers } = state;
95
- if (!playerID || !activePlayers[playerID]) {
96
- return;
97
- }
98
- if (binding === "") {
99
- activePlayers[playerID].dataState.allBindings = payload;
100
- return;
101
- }
102
- activePlayers[playerID].dataState.selectedBinding = payload;
103
- });
104
- builder.addCase(actions["player-execute-expression"].fulfilled, (state, action) => {
105
- var _a, _b, _c, _d;
106
- const { activePlayers, selectedPlayerId } = state;
107
- if (!selectedPlayerId) {
108
- return;
109
- }
110
- (_d = (_a = activePlayers[selectedPlayerId].consoleState) == null ? void 0 : _a.history) == null ? void 0 : _d.push({
111
- id: action.meta.requestId,
112
- result: action.payload,
113
- expression: (_c = (_b = action.payload) == null ? void 0 : _b.exp) != null ? _c : ""
114
- });
115
- });
116
- builder.addCase(actions["player-start-profiler-request"].fulfilled, (state, action) => {
117
- var _a;
118
- const { activePlayers, selectedPlayerId } = state;
119
- if (!selectedPlayerId)
120
- return;
121
- activePlayers[selectedPlayerId].profilerInfo = (_a = action.payload) == null ? void 0 : _a.data;
122
- });
123
- builder.addCase(actions["player-stop-profiler-request"].fulfilled, (state, action) => {
124
- var _a;
125
- const { activePlayers, selectedPlayerId } = state;
126
- if (!selectedPlayerId)
127
- return;
128
- activePlayers[selectedPlayerId].profilerInfo = (_a = action.payload) == null ? void 0 : _a.data;
129
- });
130
- };
131
-
132
- function handleMessage(store, message) {
133
- switch (message.type) {
134
- case "runtime-init":
135
- store.dispatch(devtoolsCommon.clearStore());
136
- break;
137
- case "player-init":
138
- store.dispatch(devtoolsCommon.playerInitAction(message));
139
- store.dispatch(devtoolsCommon.selectedPlayerAction());
140
- break;
141
- case "player-removed":
142
- store.dispatch(devtoolsCommon.playerRemoveAction(message.playerID));
143
- store.dispatch(devtoolsCommon.selectedPlayerAction());
144
- break;
145
- case "player-flow-start":
146
- store.dispatch(devtoolsCommon.playerFlowStartAction(message));
147
- store.dispatch(devtoolsCommon.playerTimelineAction(message));
148
- store.dispatch({
149
- type: GET_DATA_BINDING_DETAILS,
150
- payload: { playerID: message.playerID, binding: "" }
151
- });
152
- break;
153
- case "player-log-event":
154
- store.dispatch(devtoolsCommon.playerTimelineAction(message));
155
- break;
156
- case "player-view-update-event":
157
- store.dispatch(devtoolsCommon.playerViewUpdateAction(message));
158
- break;
159
- case "player-data-change-event": {
160
- const { players } = store.getState();
161
- if (players.activePlayers[message.playerID] && players.activePlayers[message.playerID].dataState.selectedBinding) {
162
- store.dispatch({
163
- type: GET_DATA_BINDING_DETAILS,
164
- payload: message
165
- });
166
- }
167
- store.dispatch({
168
- type: GET_DATA_BINDING_DETAILS,
169
- payload: { playerID: message.playerID, binding: "" }
170
- });
171
- store.dispatch(devtoolsCommon.playerTimelineAction(message));
172
- break;
173
- }
174
- default:
175
- console.warn(`Unhandled event: ${JSON.stringify(message)}`);
176
- break;
177
- }
178
- }
179
-
180
- const buildRPCRequests = (onRequestMessage) => devtoolsCommon.Runtime.RuntimeRPCTypes.reduce((acc, rpcType) => {
181
- acc[rpcType] = devtoolsCommon.createRPCRequest(rpcType, devtoolsCommon.PANEL_SOURCE, onRequestMessage);
182
- return acc;
183
- }, {});
184
-
185
- exports.GET_CONFIG_DETAILS = GET_CONFIG_DETAILS;
186
- exports.GET_CONSOLE_EVAL = GET_CONSOLE_EVAL;
187
- exports.GET_DATA_BINDING_DETAILS = GET_DATA_BINDING_DETAILS;
188
- exports.GET_INFO_DETAILS = GET_INFO_DETAILS;
189
- exports.GET_VIEW_DETAILS = GET_VIEW_DETAILS;
190
- exports.START_PROFILER = START_PROFILER;
191
- exports.STOP_PROFILER = STOP_PROFILER;
192
- exports.buildAliases = buildAliases;
193
- exports.buildPlayerReducerCallback = buildPlayerReducerCallback;
194
- exports.buildRPCActions = buildRPCActions;
195
- exports.buildRPCRequests = buildRPCRequests;
196
- exports.handleMessage = handleMessage;
197
- Object.keys(devtoolsCommon).forEach(function (k) {
198
- if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
199
- enumerable: true,
200
- get: function () { return devtoolsCommon[k]; }
201
- });
202
- });
203
- //# sourceMappingURL=index.cjs.js.map
package/dist/index.d.ts DELETED
@@ -1,38 +0,0 @@
1
- import { Runtime, RPCRequestHandler, RPCRequestMessageEvent, PlayersState, Message } from '@player-tools/devtools-common';
2
- export * from '@player-tools/devtools-common';
3
- import { Store } from 'redux';
4
- import { AsyncThunk, ActionReducerMapBuilder } from '@reduxjs/toolkit';
5
-
6
- declare type RuntimeRPCRequestHandlers = {
7
- [key in Runtime.RuntimeRPCTypes]: RPCRequestHandler<any>;
8
- };
9
- declare const buildRPCRequests: (onRequestMessage: (message: RPCRequestMessageEvent<Runtime.RuntimeRPC>) => void) => RuntimeRPCRequestHandlers;
10
-
11
- declare type AsyncRPCActions = {
12
- [key in Runtime.RuntimeRPCTypes]: AsyncThunk<Extract<Runtime.RuntimeRPC, {
13
- type: key;
14
- }>['result'], Extract<Runtime.RuntimeRPC, {
15
- type: key;
16
- }>['params'], any>;
17
- };
18
- declare const buildRPCActions: (handlers: RuntimeRPCRequestHandlers) => AsyncRPCActions;
19
-
20
- declare const GET_INFO_DETAILS = "GET_INFO_DETAILS";
21
- declare const GET_CONFIG_DETAILS = "GET_CONFIG_DETAILS";
22
- declare const GET_VIEW_DETAILS = "GET_VIEW_DETAILS";
23
- declare const GET_DATA_BINDING_DETAILS = "GET_DATA_BINDING_DETAILS";
24
- declare const GET_CONSOLE_EVAL = "GET_CONSOLE_EVAL";
25
- declare const START_PROFILER = "START_PROFILER";
26
- declare const STOP_PROFILER = "STOP_PROFILER";
27
- declare const buildAliases: (actions: AsyncRPCActions) => () => (next: any) => (action: any) => any;
28
-
29
- /**
30
- * Callback function that adds cases for async actions for the player.
31
- * @param playerReducerCallback
32
- * @returns
33
- */
34
- declare const buildPlayerReducerCallback: (actions: AsyncRPCActions) => (builder: ActionReducerMapBuilder<PlayersState>) => void;
35
-
36
- declare function handleMessage(store: Store, message: Message): void;
37
-
38
- export { AsyncRPCActions, GET_CONFIG_DETAILS, GET_CONSOLE_EVAL, GET_DATA_BINDING_DETAILS, GET_INFO_DETAILS, GET_VIEW_DETAILS, RuntimeRPCRequestHandlers, START_PROFILER, STOP_PROFILER, buildAliases, buildPlayerReducerCallback, buildRPCActions, buildRPCRequests, handleMessage };
package/dist/index.esm.js DELETED
@@ -1,183 +0,0 @@
1
- import { createLogger, BACKGROUND_SOURCE, Runtime, playerTimelineAction, playerViewUpdateAction, playerFlowStartAction, playerRemoveAction, selectedPlayerAction, playerInitAction, clearStore, createRPCRequest, PANEL_SOURCE } from '@player-tools/devtools-common';
2
- export * from '@player-tools/devtools-common';
3
- import { createAsyncThunk } from '@reduxjs/toolkit';
4
-
5
- const GET_INFO_DETAILS = "GET_INFO_DETAILS";
6
- const GET_CONFIG_DETAILS = "GET_CONFIG_DETAILS";
7
- const GET_VIEW_DETAILS = "GET_VIEW_DETAILS";
8
- const GET_DATA_BINDING_DETAILS = "GET_DATA_BINDING_DETAILS";
9
- const GET_CONSOLE_EVAL = "GET_CONSOLE_EVAL";
10
- const START_PROFILER = "START_PROFILER";
11
- const STOP_PROFILER = "STOP_PROFILER";
12
- const _alias = (aliases) => () => (next) => (action) => {
13
- const alias = aliases[action.type];
14
- if (alias) {
15
- return next(alias(action));
16
- }
17
- return next(action);
18
- };
19
- const buildAliases = (actions) => _alias({
20
- GET_INFO_DETAILS: (action) => actions["player-runtime-info-request"](action.payload),
21
- GET_CONFIG_DETAILS: (action) => actions["player-config-request"](action.payload),
22
- GET_VIEW_DETAILS: (action) => actions["player-view-details-request"](action.payload),
23
- GET_DATA_BINDING_DETAILS: (action) => actions["player-data-binding-details"](action.payload),
24
- GET_CONSOLE_EVAL: (action) => actions["player-execute-expression"](action.payload),
25
- START_PROFILER: (action) => actions["player-start-profiler-request"](action.payload),
26
- STOP_PROFILER: (action) => actions["player-stop-profiler-request"](action.payload)
27
- });
28
-
29
- var __async = (__this, __arguments, generator) => {
30
- return new Promise((resolve, reject) => {
31
- var fulfilled = (value) => {
32
- try {
33
- step(generator.next(value));
34
- } catch (e) {
35
- reject(e);
36
- }
37
- };
38
- var rejected = (value) => {
39
- try {
40
- step(generator.throw(value));
41
- } catch (e) {
42
- reject(e);
43
- }
44
- };
45
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
46
- step((generator = generator.apply(__this, __arguments)).next());
47
- });
48
- };
49
- const logger = createLogger(BACKGROUND_SOURCE);
50
- const buildRPCActions = (handlers) => Runtime.RuntimeRPCTypes.reduce((acc, rpcType) => {
51
- acc[rpcType] = createAsyncThunk(rpcType, (params) => __async(undefined, null, function* () {
52
- logger.log(`Requesting ${rpcType}`, params);
53
- const data = yield handlers[rpcType].call(params);
54
- logger.log(`Response from ${rpcType}`, data);
55
- return data;
56
- }));
57
- return acc;
58
- }, {});
59
-
60
- const buildPlayerReducerCallback = (actions) => (builder) => {
61
- builder.addCase(actions["player-runtime-info-request"].fulfilled, (state, action) => {
62
- const { activePlayers, selectedPlayerId } = state;
63
- if (!selectedPlayerId) {
64
- return;
65
- }
66
- const data = action.payload && Object.keys(action.payload).length > 0 ? action.payload : null;
67
- activePlayers[selectedPlayerId].flowInfo = data;
68
- });
69
- builder.addCase(actions["player-config-request"].fulfilled, (state, action) => {
70
- const { activePlayers, selectedPlayerId } = state;
71
- if (!selectedPlayerId) {
72
- return;
73
- }
74
- activePlayers[selectedPlayerId].configState = action.payload;
75
- });
76
- builder.addCase(actions["player-view-details-request"].fulfilled, (state, action) => {
77
- var _a;
78
- const { activePlayers, selectedPlayerId } = state;
79
- if (!selectedPlayerId) {
80
- return;
81
- }
82
- activePlayers[selectedPlayerId].view = (_a = action.payload) == null ? void 0 : _a.lastViewUpdate;
83
- });
84
- builder.addCase(actions["player-data-binding-details"].fulfilled, (state, action) => {
85
- const {
86
- meta: {
87
- arg: { binding, playerID }
88
- },
89
- payload
90
- } = action;
91
- const { activePlayers } = state;
92
- if (!playerID || !activePlayers[playerID]) {
93
- return;
94
- }
95
- if (binding === "") {
96
- activePlayers[playerID].dataState.allBindings = payload;
97
- return;
98
- }
99
- activePlayers[playerID].dataState.selectedBinding = payload;
100
- });
101
- builder.addCase(actions["player-execute-expression"].fulfilled, (state, action) => {
102
- var _a, _b, _c, _d;
103
- const { activePlayers, selectedPlayerId } = state;
104
- if (!selectedPlayerId) {
105
- return;
106
- }
107
- (_d = (_a = activePlayers[selectedPlayerId].consoleState) == null ? void 0 : _a.history) == null ? void 0 : _d.push({
108
- id: action.meta.requestId,
109
- result: action.payload,
110
- expression: (_c = (_b = action.payload) == null ? void 0 : _b.exp) != null ? _c : ""
111
- });
112
- });
113
- builder.addCase(actions["player-start-profiler-request"].fulfilled, (state, action) => {
114
- var _a;
115
- const { activePlayers, selectedPlayerId } = state;
116
- if (!selectedPlayerId)
117
- return;
118
- activePlayers[selectedPlayerId].profilerInfo = (_a = action.payload) == null ? void 0 : _a.data;
119
- });
120
- builder.addCase(actions["player-stop-profiler-request"].fulfilled, (state, action) => {
121
- var _a;
122
- const { activePlayers, selectedPlayerId } = state;
123
- if (!selectedPlayerId)
124
- return;
125
- activePlayers[selectedPlayerId].profilerInfo = (_a = action.payload) == null ? void 0 : _a.data;
126
- });
127
- };
128
-
129
- function handleMessage(store, message) {
130
- switch (message.type) {
131
- case "runtime-init":
132
- store.dispatch(clearStore());
133
- break;
134
- case "player-init":
135
- store.dispatch(playerInitAction(message));
136
- store.dispatch(selectedPlayerAction());
137
- break;
138
- case "player-removed":
139
- store.dispatch(playerRemoveAction(message.playerID));
140
- store.dispatch(selectedPlayerAction());
141
- break;
142
- case "player-flow-start":
143
- store.dispatch(playerFlowStartAction(message));
144
- store.dispatch(playerTimelineAction(message));
145
- store.dispatch({
146
- type: GET_DATA_BINDING_DETAILS,
147
- payload: { playerID: message.playerID, binding: "" }
148
- });
149
- break;
150
- case "player-log-event":
151
- store.dispatch(playerTimelineAction(message));
152
- break;
153
- case "player-view-update-event":
154
- store.dispatch(playerViewUpdateAction(message));
155
- break;
156
- case "player-data-change-event": {
157
- const { players } = store.getState();
158
- if (players.activePlayers[message.playerID] && players.activePlayers[message.playerID].dataState.selectedBinding) {
159
- store.dispatch({
160
- type: GET_DATA_BINDING_DETAILS,
161
- payload: message
162
- });
163
- }
164
- store.dispatch({
165
- type: GET_DATA_BINDING_DETAILS,
166
- payload: { playerID: message.playerID, binding: "" }
167
- });
168
- store.dispatch(playerTimelineAction(message));
169
- break;
170
- }
171
- default:
172
- console.warn(`Unhandled event: ${JSON.stringify(message)}`);
173
- break;
174
- }
175
- }
176
-
177
- const buildRPCRequests = (onRequestMessage) => Runtime.RuntimeRPCTypes.reduce((acc, rpcType) => {
178
- acc[rpcType] = createRPCRequest(rpcType, PANEL_SOURCE, onRequestMessage);
179
- return acc;
180
- }, {});
181
-
182
- export { GET_CONFIG_DETAILS, GET_CONSOLE_EVAL, GET_DATA_BINDING_DETAILS, GET_INFO_DETAILS, GET_VIEW_DETAILS, START_PROFILER, STOP_PROFILER, buildAliases, buildPlayerReducerCallback, buildRPCActions, buildRPCRequests, handleMessage };
183
- //# sourceMappingURL=index.esm.js.map