@player-tools/devtools-basic-web-plugin 0.8.0-next.0 → 0.8.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/cjs/index.cjs +55 -26
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.legacy-esm.js +56 -27
- package/dist/index.mjs +56 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -11
- package/src/WrapperComponent.tsx +54 -25
- package/src/constants/index.ts +1 -0
- package/src/index.tsx +7 -0
- package/src/types.ts +2 -0
- package/types/WrapperComponent.d.ts +1 -1
- package/types/constants/index.d.ts +1 -0
- package/types/index.d.ts +2 -0
- package/types/types.d.ts +2 -0
package/dist/index.legacy-esm.js
CHANGED
|
@@ -8,7 +8,7 @@ import { usePluginState } from "@player-tools/devtools-desktop-plugins-common";
|
|
|
8
8
|
import { dequal } from "dequal";
|
|
9
9
|
import { produce } from "immer";
|
|
10
10
|
import set from "lodash.set";
|
|
11
|
-
import React, { useCallback, useEffect } from "react";
|
|
11
|
+
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
12
12
|
|
|
13
13
|
// ../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/plugins/desktop/basic/src/constants/index.ts
|
|
14
14
|
var PLUGIN_ID = "player-ui-basic-devtools-plugin";
|
|
@@ -17,7 +17,8 @@ var PLUGIN_DESCRIPTION = "Standard Player UI Devtools";
|
|
|
17
17
|
var PLUGIN_VERSION = "0.0.1";
|
|
18
18
|
var INTERACTIONS = {
|
|
19
19
|
EVALUATE_EXPRESSION: "evaluate-expression",
|
|
20
|
-
OVERRIDE_FLOW: "override-flow"
|
|
20
|
+
OVERRIDE_FLOW: "override-flow",
|
|
21
|
+
PLAYER_SELECTED: "player-selected"
|
|
21
22
|
};
|
|
22
23
|
var BASE_PLUGIN_DATA = {
|
|
23
24
|
id: PLUGIN_ID,
|
|
@@ -892,14 +893,16 @@ var WrapperComponent = ({
|
|
|
892
893
|
logs,
|
|
893
894
|
flow,
|
|
894
895
|
expressionEvaluator,
|
|
895
|
-
overrideFlow
|
|
896
|
+
overrideFlow,
|
|
897
|
+
id: playerID
|
|
896
898
|
}) => {
|
|
897
|
-
const [state,
|
|
898
|
-
const
|
|
899
|
+
const [state, dispatch] = usePluginState({ playerID });
|
|
900
|
+
const [highlight, setHighlight] = useState(false);
|
|
901
|
+
const lastProcessedInteraction = useRef(0);
|
|
899
902
|
const expEvaluator = useCallback(getEvaluateExpression(expressionEvaluator), [
|
|
900
903
|
expressionEvaluator
|
|
901
904
|
]);
|
|
902
|
-
const
|
|
905
|
+
const pluginID = pluginData.id;
|
|
903
906
|
const processInteraction = useCallback(
|
|
904
907
|
(interaction) => {
|
|
905
908
|
const {
|
|
@@ -908,10 +911,10 @@ var WrapperComponent = ({
|
|
|
908
911
|
if (type === INTERACTIONS.EVALUATE_EXPRESSION && expressionEvaluator && payload) {
|
|
909
912
|
const result = expEvaluator(payload);
|
|
910
913
|
const newState = produce(state, (draft) => {
|
|
911
|
-
const current = state?.plugins?.[
|
|
914
|
+
const current = state?.plugins?.[pluginID]?.flow?.data?.history || [];
|
|
912
915
|
set(
|
|
913
916
|
draft,
|
|
914
|
-
["plugins",
|
|
917
|
+
["plugins", pluginID, "flow", "data", "history"],
|
|
915
918
|
[...current, result]
|
|
916
919
|
);
|
|
917
920
|
});
|
|
@@ -919,12 +922,12 @@ var WrapperComponent = ({
|
|
|
919
922
|
id: -1,
|
|
920
923
|
type: "PLAYER_DEVTOOLS_PLUGIN_DATA_CHANGE",
|
|
921
924
|
payload: {
|
|
922
|
-
pluginID
|
|
923
|
-
data: newState.plugins[
|
|
925
|
+
pluginID,
|
|
926
|
+
data: newState.plugins[pluginID].flow.data
|
|
924
927
|
},
|
|
925
928
|
sender: playerID,
|
|
926
929
|
context: "player",
|
|
927
|
-
target:
|
|
930
|
+
target: playerID,
|
|
928
931
|
timestamp: Date.now(),
|
|
929
932
|
_messenger_: true
|
|
930
933
|
});
|
|
@@ -939,9 +942,30 @@ var WrapperComponent = ({
|
|
|
939
942
|
}
|
|
940
943
|
newFlow && overrideFlow(newFlow);
|
|
941
944
|
}
|
|
945
|
+
if (type === INTERACTIONS.PLAYER_SELECTED && payload) {
|
|
946
|
+
dispatch({
|
|
947
|
+
id: -1,
|
|
948
|
+
type: "PLAYER_DEVTOOLS_SELECTED_PLAYER_CHANGE",
|
|
949
|
+
payload: { playerID: payload },
|
|
950
|
+
sender: playerID,
|
|
951
|
+
context: "player",
|
|
952
|
+
target: playerID,
|
|
953
|
+
timestamp: Date.now(),
|
|
954
|
+
_messenger_: true
|
|
955
|
+
});
|
|
956
|
+
}
|
|
942
957
|
},
|
|
943
|
-
[dispatch, expressionEvaluator,
|
|
958
|
+
[dispatch, expressionEvaluator, pluginID, state]
|
|
944
959
|
);
|
|
960
|
+
useEffect(() => {
|
|
961
|
+
if (playerID === state.currentPlayer) {
|
|
962
|
+
setHighlight(true);
|
|
963
|
+
const timer = setTimeout(() => {
|
|
964
|
+
setHighlight(false);
|
|
965
|
+
}, 1e3);
|
|
966
|
+
return () => clearTimeout(timer);
|
|
967
|
+
}
|
|
968
|
+
}, [playerID, state.currentPlayer]);
|
|
945
969
|
const pluginDataWithPlayerConfig = produce(pluginData, (draft) => {
|
|
946
970
|
set(draft, ["flow", "data", "playerConfig"], playerConfig);
|
|
947
971
|
});
|
|
@@ -951,7 +975,7 @@ var WrapperComponent = ({
|
|
|
951
975
|
type: "PLAYER_DEVTOOLS_PLAYER_INIT",
|
|
952
976
|
payload: {
|
|
953
977
|
plugins: {
|
|
954
|
-
[
|
|
978
|
+
[pluginID]: pluginDataWithPlayerConfig
|
|
955
979
|
}
|
|
956
980
|
},
|
|
957
981
|
sender: playerID,
|
|
@@ -968,46 +992,50 @@ var WrapperComponent = ({
|
|
|
968
992
|
}
|
|
969
993
|
}, [state.interactions.length]);
|
|
970
994
|
useEffect(() => {
|
|
971
|
-
if (dequal(state.plugins[
|
|
995
|
+
if (dequal(state.plugins[pluginID]?.flow?.data?.data, data)) return;
|
|
972
996
|
const newState = produce(state, (draft) => {
|
|
973
|
-
set(draft, ["plugins",
|
|
997
|
+
set(draft, ["plugins", pluginID, "flow", "data", "data"], data);
|
|
974
998
|
});
|
|
975
999
|
const transaction = genDataChangeTransaction({
|
|
976
1000
|
playerID,
|
|
977
|
-
data: newState.plugins[
|
|
978
|
-
pluginID
|
|
1001
|
+
data: newState.plugins[pluginID].flow.data,
|
|
1002
|
+
pluginID
|
|
979
1003
|
});
|
|
980
1004
|
dispatch(transaction);
|
|
981
1005
|
}, [data]);
|
|
982
1006
|
useEffect(() => {
|
|
983
|
-
if (dequal(state.plugins[
|
|
1007
|
+
if (dequal(state.plugins[pluginID]?.flow?.data?.logs, logs)) return;
|
|
984
1008
|
const newState = produce(state, (draft) => {
|
|
985
|
-
set(draft, ["plugins",
|
|
1009
|
+
set(draft, ["plugins", pluginID, "flow", "data", "logs"], logs);
|
|
986
1010
|
});
|
|
987
1011
|
const transaction = genDataChangeTransaction({
|
|
988
1012
|
playerID,
|
|
989
|
-
data: newState.plugins[
|
|
990
|
-
pluginID
|
|
1013
|
+
data: newState.plugins[pluginID].flow.data,
|
|
1014
|
+
pluginID
|
|
991
1015
|
});
|
|
992
1016
|
dispatch(transaction);
|
|
993
1017
|
}, [logs]);
|
|
994
1018
|
useEffect(() => {
|
|
995
|
-
if (dequal(state.plugins[
|
|
1019
|
+
if (dequal(state.plugins[pluginID]?.flow?.data?.flow, flow)) return;
|
|
996
1020
|
const newState = produce(state, (draft) => {
|
|
997
|
-
set(draft, ["plugins",
|
|
1021
|
+
set(draft, ["plugins", pluginID, "flow", "data", "flow"], flow);
|
|
998
1022
|
});
|
|
999
1023
|
const transaction = genDataChangeTransaction({
|
|
1000
1024
|
playerID,
|
|
1001
|
-
data: newState.plugins[
|
|
1002
|
-
pluginID
|
|
1025
|
+
data: newState.plugins[pluginID].flow.data,
|
|
1026
|
+
pluginID
|
|
1003
1027
|
});
|
|
1004
1028
|
dispatch(transaction);
|
|
1005
1029
|
}, [flow]);
|
|
1006
|
-
return children;
|
|
1030
|
+
return /* @__PURE__ */ React.createElement("div", { id: playerID, style: highlight ? { border: "2px solid blue" } : {} }, children);
|
|
1007
1031
|
};
|
|
1008
1032
|
|
|
1009
1033
|
// ../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/plugins/desktop/basic/src/index.tsx
|
|
1010
1034
|
var BasicWevDevtoolsPlugin = class {
|
|
1035
|
+
id;
|
|
1036
|
+
constructor(id) {
|
|
1037
|
+
this.id = id ?? "default-id";
|
|
1038
|
+
}
|
|
1011
1039
|
name = PLUGIN_ID;
|
|
1012
1040
|
data = {};
|
|
1013
1041
|
playerConfig = {};
|
|
@@ -1068,7 +1096,8 @@ var BasicWevDevtoolsPlugin = class {
|
|
|
1068
1096
|
flow: this.flow,
|
|
1069
1097
|
view: this.view,
|
|
1070
1098
|
overrideFlow: this.overrideFlow,
|
|
1071
|
-
expressionEvaluator: this.expressionEvaluator
|
|
1099
|
+
expressionEvaluator: this.expressionEvaluator,
|
|
1100
|
+
id: this.id
|
|
1072
1101
|
},
|
|
1073
1102
|
/* @__PURE__ */ React2.createElement(Component, null)
|
|
1074
1103
|
);
|
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { usePluginState } from "@player-tools/devtools-desktop-plugins-common";
|
|
|
8
8
|
import { dequal } from "dequal";
|
|
9
9
|
import { produce } from "immer";
|
|
10
10
|
import set from "lodash.set";
|
|
11
|
-
import React, { useCallback, useEffect } from "react";
|
|
11
|
+
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
12
12
|
|
|
13
13
|
// ../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/plugins/desktop/basic/src/constants/index.ts
|
|
14
14
|
var PLUGIN_ID = "player-ui-basic-devtools-plugin";
|
|
@@ -17,7 +17,8 @@ var PLUGIN_DESCRIPTION = "Standard Player UI Devtools";
|
|
|
17
17
|
var PLUGIN_VERSION = "0.0.1";
|
|
18
18
|
var INTERACTIONS = {
|
|
19
19
|
EVALUATE_EXPRESSION: "evaluate-expression",
|
|
20
|
-
OVERRIDE_FLOW: "override-flow"
|
|
20
|
+
OVERRIDE_FLOW: "override-flow",
|
|
21
|
+
PLAYER_SELECTED: "player-selected"
|
|
21
22
|
};
|
|
22
23
|
var BASE_PLUGIN_DATA = {
|
|
23
24
|
id: PLUGIN_ID,
|
|
@@ -892,14 +893,16 @@ var WrapperComponent = ({
|
|
|
892
893
|
logs,
|
|
893
894
|
flow,
|
|
894
895
|
expressionEvaluator,
|
|
895
|
-
overrideFlow
|
|
896
|
+
overrideFlow,
|
|
897
|
+
id: playerID
|
|
896
898
|
}) => {
|
|
897
|
-
const [state,
|
|
898
|
-
const
|
|
899
|
+
const [state, dispatch] = usePluginState({ playerID });
|
|
900
|
+
const [highlight, setHighlight] = useState(false);
|
|
901
|
+
const lastProcessedInteraction = useRef(0);
|
|
899
902
|
const expEvaluator = useCallback(getEvaluateExpression(expressionEvaluator), [
|
|
900
903
|
expressionEvaluator
|
|
901
904
|
]);
|
|
902
|
-
const
|
|
905
|
+
const pluginID = pluginData.id;
|
|
903
906
|
const processInteraction = useCallback(
|
|
904
907
|
(interaction) => {
|
|
905
908
|
const {
|
|
@@ -908,10 +911,10 @@ var WrapperComponent = ({
|
|
|
908
911
|
if (type === INTERACTIONS.EVALUATE_EXPRESSION && expressionEvaluator && payload) {
|
|
909
912
|
const result = expEvaluator(payload);
|
|
910
913
|
const newState = produce(state, (draft) => {
|
|
911
|
-
const current = state?.plugins?.[
|
|
914
|
+
const current = state?.plugins?.[pluginID]?.flow?.data?.history || [];
|
|
912
915
|
set(
|
|
913
916
|
draft,
|
|
914
|
-
["plugins",
|
|
917
|
+
["plugins", pluginID, "flow", "data", "history"],
|
|
915
918
|
[...current, result]
|
|
916
919
|
);
|
|
917
920
|
});
|
|
@@ -919,12 +922,12 @@ var WrapperComponent = ({
|
|
|
919
922
|
id: -1,
|
|
920
923
|
type: "PLAYER_DEVTOOLS_PLUGIN_DATA_CHANGE",
|
|
921
924
|
payload: {
|
|
922
|
-
pluginID
|
|
923
|
-
data: newState.plugins[
|
|
925
|
+
pluginID,
|
|
926
|
+
data: newState.plugins[pluginID].flow.data
|
|
924
927
|
},
|
|
925
928
|
sender: playerID,
|
|
926
929
|
context: "player",
|
|
927
|
-
target:
|
|
930
|
+
target: playerID,
|
|
928
931
|
timestamp: Date.now(),
|
|
929
932
|
_messenger_: true
|
|
930
933
|
});
|
|
@@ -939,9 +942,30 @@ var WrapperComponent = ({
|
|
|
939
942
|
}
|
|
940
943
|
newFlow && overrideFlow(newFlow);
|
|
941
944
|
}
|
|
945
|
+
if (type === INTERACTIONS.PLAYER_SELECTED && payload) {
|
|
946
|
+
dispatch({
|
|
947
|
+
id: -1,
|
|
948
|
+
type: "PLAYER_DEVTOOLS_SELECTED_PLAYER_CHANGE",
|
|
949
|
+
payload: { playerID: payload },
|
|
950
|
+
sender: playerID,
|
|
951
|
+
context: "player",
|
|
952
|
+
target: playerID,
|
|
953
|
+
timestamp: Date.now(),
|
|
954
|
+
_messenger_: true
|
|
955
|
+
});
|
|
956
|
+
}
|
|
942
957
|
},
|
|
943
|
-
[dispatch, expressionEvaluator,
|
|
958
|
+
[dispatch, expressionEvaluator, pluginID, state]
|
|
944
959
|
);
|
|
960
|
+
useEffect(() => {
|
|
961
|
+
if (playerID === state.currentPlayer) {
|
|
962
|
+
setHighlight(true);
|
|
963
|
+
const timer = setTimeout(() => {
|
|
964
|
+
setHighlight(false);
|
|
965
|
+
}, 1e3);
|
|
966
|
+
return () => clearTimeout(timer);
|
|
967
|
+
}
|
|
968
|
+
}, [playerID, state.currentPlayer]);
|
|
945
969
|
const pluginDataWithPlayerConfig = produce(pluginData, (draft) => {
|
|
946
970
|
set(draft, ["flow", "data", "playerConfig"], playerConfig);
|
|
947
971
|
});
|
|
@@ -951,7 +975,7 @@ var WrapperComponent = ({
|
|
|
951
975
|
type: "PLAYER_DEVTOOLS_PLAYER_INIT",
|
|
952
976
|
payload: {
|
|
953
977
|
plugins: {
|
|
954
|
-
[
|
|
978
|
+
[pluginID]: pluginDataWithPlayerConfig
|
|
955
979
|
}
|
|
956
980
|
},
|
|
957
981
|
sender: playerID,
|
|
@@ -968,46 +992,50 @@ var WrapperComponent = ({
|
|
|
968
992
|
}
|
|
969
993
|
}, [state.interactions.length]);
|
|
970
994
|
useEffect(() => {
|
|
971
|
-
if (dequal(state.plugins[
|
|
995
|
+
if (dequal(state.plugins[pluginID]?.flow?.data?.data, data)) return;
|
|
972
996
|
const newState = produce(state, (draft) => {
|
|
973
|
-
set(draft, ["plugins",
|
|
997
|
+
set(draft, ["plugins", pluginID, "flow", "data", "data"], data);
|
|
974
998
|
});
|
|
975
999
|
const transaction = genDataChangeTransaction({
|
|
976
1000
|
playerID,
|
|
977
|
-
data: newState.plugins[
|
|
978
|
-
pluginID
|
|
1001
|
+
data: newState.plugins[pluginID].flow.data,
|
|
1002
|
+
pluginID
|
|
979
1003
|
});
|
|
980
1004
|
dispatch(transaction);
|
|
981
1005
|
}, [data]);
|
|
982
1006
|
useEffect(() => {
|
|
983
|
-
if (dequal(state.plugins[
|
|
1007
|
+
if (dequal(state.plugins[pluginID]?.flow?.data?.logs, logs)) return;
|
|
984
1008
|
const newState = produce(state, (draft) => {
|
|
985
|
-
set(draft, ["plugins",
|
|
1009
|
+
set(draft, ["plugins", pluginID, "flow", "data", "logs"], logs);
|
|
986
1010
|
});
|
|
987
1011
|
const transaction = genDataChangeTransaction({
|
|
988
1012
|
playerID,
|
|
989
|
-
data: newState.plugins[
|
|
990
|
-
pluginID
|
|
1013
|
+
data: newState.plugins[pluginID].flow.data,
|
|
1014
|
+
pluginID
|
|
991
1015
|
});
|
|
992
1016
|
dispatch(transaction);
|
|
993
1017
|
}, [logs]);
|
|
994
1018
|
useEffect(() => {
|
|
995
|
-
if (dequal(state.plugins[
|
|
1019
|
+
if (dequal(state.plugins[pluginID]?.flow?.data?.flow, flow)) return;
|
|
996
1020
|
const newState = produce(state, (draft) => {
|
|
997
|
-
set(draft, ["plugins",
|
|
1021
|
+
set(draft, ["plugins", pluginID, "flow", "data", "flow"], flow);
|
|
998
1022
|
});
|
|
999
1023
|
const transaction = genDataChangeTransaction({
|
|
1000
1024
|
playerID,
|
|
1001
|
-
data: newState.plugins[
|
|
1002
|
-
pluginID
|
|
1025
|
+
data: newState.plugins[pluginID].flow.data,
|
|
1026
|
+
pluginID
|
|
1003
1027
|
});
|
|
1004
1028
|
dispatch(transaction);
|
|
1005
1029
|
}, [flow]);
|
|
1006
|
-
return children;
|
|
1030
|
+
return /* @__PURE__ */ React.createElement("div", { id: playerID, style: highlight ? { border: "2px solid blue" } : {} }, children);
|
|
1007
1031
|
};
|
|
1008
1032
|
|
|
1009
1033
|
// ../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/plugins/desktop/basic/src/index.tsx
|
|
1010
1034
|
var BasicWevDevtoolsPlugin = class {
|
|
1035
|
+
id;
|
|
1036
|
+
constructor(id) {
|
|
1037
|
+
this.id = id ?? "default-id";
|
|
1038
|
+
}
|
|
1011
1039
|
name = PLUGIN_ID;
|
|
1012
1040
|
data = {};
|
|
1013
1041
|
playerConfig = {};
|
|
@@ -1068,7 +1096,8 @@ var BasicWevDevtoolsPlugin = class {
|
|
|
1068
1096
|
flow: this.flow,
|
|
1069
1097
|
view: this.view,
|
|
1070
1098
|
overrideFlow: this.overrideFlow,
|
|
1071
|
-
expressionEvaluator: this.expressionEvaluator
|
|
1099
|
+
expressionEvaluator: this.expressionEvaluator,
|
|
1100
|
+
id: this.id
|
|
1072
1101
|
},
|
|
1073
1102
|
/* @__PURE__ */ React2.createElement(Component, null)
|
|
1074
1103
|
);
|