@player-devtools/basic-plugin-react 0.0.2-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/cjs/index.cjs +87 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/index.legacy-esm.js +52 -0
- package/dist/index.mjs +52 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +37 -0
- package/src/index.tsx +81 -0
- package/types/index.d.ts +18 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// ../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/plugins/basic/react/src/index.tsx
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
BasicReactDevtoolsPlugin: () => BasicReactDevtoolsPlugin
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(src_exports);
|
|
36
|
+
var import_react = __toESM(require("react"));
|
|
37
|
+
var import_plugin_react = require("@player-devtools/plugin-react");
|
|
38
|
+
var import_basic_plugin = require("@player-devtools/basic-plugin");
|
|
39
|
+
var BasicDevtoolsWrapper = ({
|
|
40
|
+
state,
|
|
41
|
+
playerID,
|
|
42
|
+
children
|
|
43
|
+
}) => {
|
|
44
|
+
const [highlight, setHighlight] = (0, import_react.useState)(false);
|
|
45
|
+
(0, import_react.useEffect)(() => {
|
|
46
|
+
if (playerID === state.currentPlayer) {
|
|
47
|
+
setHighlight(true);
|
|
48
|
+
const timer = setTimeout(() => {
|
|
49
|
+
setHighlight(false);
|
|
50
|
+
}, 1e3);
|
|
51
|
+
return () => clearTimeout(timer);
|
|
52
|
+
}
|
|
53
|
+
}, [playerID, state.currentPlayer]);
|
|
54
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { id: playerID, style: highlight ? { border: "2px solid blue" } : {} }, children);
|
|
55
|
+
};
|
|
56
|
+
var BasicReactDevtoolsPlugin = class extends import_plugin_react.ReactDevtoolsPlugin {
|
|
57
|
+
constructor(id, wrapper) {
|
|
58
|
+
super();
|
|
59
|
+
this.name = "BasicReactDevtoolsPlugin";
|
|
60
|
+
this.wrapper = wrapper ?? BasicDevtoolsWrapper;
|
|
61
|
+
this.corePlugin = new import_basic_plugin.BasicDevtoolsPlugin({
|
|
62
|
+
playerID: id ?? "default-id",
|
|
63
|
+
handler: this
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
applyReact(reactPlayer) {
|
|
67
|
+
if (!this.checkIfDevtoolsIsActive()) return;
|
|
68
|
+
super.applyReact(reactPlayer);
|
|
69
|
+
reactPlayer.hooks.webComponent.tap(this.name, (Component) => {
|
|
70
|
+
const DevtoolsContainer = () => {
|
|
71
|
+
const Wrapper = this.wrapper;
|
|
72
|
+
const [state, setState] = (0, import_react.useState)(this.store.getState());
|
|
73
|
+
(0, import_react.useEffect)(() => this.store.subscribe(setState), [setState]);
|
|
74
|
+
return /* @__PURE__ */ import_react.default.createElement(Wrapper, { state, playerID: this.playerID }, /* @__PURE__ */ import_react.default.createElement(Component, null));
|
|
75
|
+
};
|
|
76
|
+
return DevtoolsContainer;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
processInteraction(interaction) {
|
|
80
|
+
super.processInteraction(interaction);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
84
|
+
0 && (module.exports = {
|
|
85
|
+
BasicReactDevtoolsPlugin
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/plugins/basic/react/src/index.tsx"],"sourcesContent":["import React, { useEffect, useState } from \"react\";\nimport { ReactPlayer } from \"@player-ui/react\";\nimport { ReactDevtoolsPlugin } from \"@player-devtools/plugin-react\";\nimport { BasicDevtoolsPlugin } from \"@player-devtools/basic-plugin\";\nimport type {\n DevtoolsPluginInteractionEvent,\n DevtoolsPluginsStore,\n} from \"@player-devtools/types\";\n\nexport type DevtoolsWrapperProps = React.PropsWithChildren<{\n state: DevtoolsPluginsStore;\n playerID: string;\n}>;\n\nconst BasicDevtoolsWrapper = ({\n state,\n playerID,\n children,\n}: DevtoolsWrapperProps) => {\n const [highlight, setHighlight] = useState(false);\n useEffect(() => {\n if (playerID === state.currentPlayer) {\n setHighlight(true);\n const timer = setTimeout(() => {\n setHighlight(false);\n }, 1000);\n return () => clearTimeout(timer);\n }\n }, [playerID, state.currentPlayer]);\n\n return (\n <div id={playerID} style={highlight ? { border: \"2px solid blue\" } : {}}>\n {children}\n </div>\n );\n};\n\nexport class BasicReactDevtoolsPlugin extends ReactDevtoolsPlugin<BasicDevtoolsPlugin> {\n name = \"BasicReactDevtoolsPlugin\";\n\n corePlugin: BasicDevtoolsPlugin;\n\n private wrapper: React.ComponentType<DevtoolsWrapperProps>;\n\n constructor(\n id?: string,\n wrapper?: React.ComponentType<DevtoolsWrapperProps>,\n ) {\n super();\n\n this.wrapper = wrapper ?? BasicDevtoolsWrapper;\n this.corePlugin = new BasicDevtoolsPlugin({\n playerID: id ?? \"default-id\",\n handler: this,\n });\n }\n\n applyReact(reactPlayer: ReactPlayer): void {\n if (!this.checkIfDevtoolsIsActive()) return;\n\n super.applyReact(reactPlayer);\n\n reactPlayer.hooks.webComponent.tap(this.name, (Component) => {\n const DevtoolsContainer = () => {\n const Wrapper = this.wrapper;\n const [state, setState] = useState(this.store.getState());\n useEffect(() => this.store.subscribe(setState), [setState]);\n return (\n <Wrapper state={state} playerID={this.playerID}>\n <Component />\n </Wrapper>\n );\n };\n return DevtoolsContainer;\n });\n }\n\n processInteraction(interaction: DevtoolsPluginInteractionEvent): void {\n super.processInteraction(interaction);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2C;AAE3C,0BAAoC;AACpC,0BAAoC;AAWpC,IAAM,uBAAuB,CAAC;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AACF,MAA4B;AAC1B,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAS,KAAK;AAChD,8BAAU,MAAM;AACd,QAAI,aAAa,MAAM,eAAe;AACpC,mBAAa,IAAI;AACjB,YAAM,QAAQ,WAAW,MAAM;AAC7B,qBAAa,KAAK;AAAA,MACpB,GAAG,GAAI;AACP,aAAO,MAAM,aAAa,KAAK;AAAA,IACjC;AAAA,EACF,GAAG,CAAC,UAAU,MAAM,aAAa,CAAC;AAElC,SACE,6BAAAA,QAAA,cAAC,SAAI,IAAI,UAAU,OAAO,YAAY,EAAE,QAAQ,iBAAiB,IAAI,CAAC,KACnE,QACH;AAEJ;AAEO,IAAM,2BAAN,cAAuC,wCAAyC;AAAA,EAOrF,YACE,IACA,SACA;AACA,UAAM;AAVR,gBAAO;AAYL,SAAK,UAAU,WAAW;AAC1B,SAAK,aAAa,IAAI,wCAAoB;AAAA,MACxC,UAAU,MAAM;AAAA,MAChB,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAAA,EAEA,WAAW,aAAgC;AACzC,QAAI,CAAC,KAAK,wBAAwB,EAAG;AAErC,UAAM,WAAW,WAAW;AAE5B,gBAAY,MAAM,aAAa,IAAI,KAAK,MAAM,CAAC,cAAc;AAC3D,YAAM,oBAAoB,MAAM;AAC9B,cAAM,UAAU,KAAK;AACrB,cAAM,CAAC,OAAO,QAAQ,QAAI,uBAAS,KAAK,MAAM,SAAS,CAAC;AACxD,oCAAU,MAAM,KAAK,MAAM,UAAU,QAAQ,GAAG,CAAC,QAAQ,CAAC;AAC1D,eACE,6BAAAA,QAAA,cAAC,WAAQ,OAAc,UAAU,KAAK,YACpC,6BAAAA,QAAA,cAAC,eAAU,CACb;AAAA,MAEJ;AACA,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AAAA,EAEA,mBAAmB,aAAmD;AACpE,UAAM,mBAAmB,WAAW;AAAA,EACtC;AACF;","names":["React"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// ../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/plugins/basic/react/src/index.tsx
|
|
2
|
+
import React, { useEffect, useState } from "react";
|
|
3
|
+
import { ReactDevtoolsPlugin } from "@player-devtools/plugin-react";
|
|
4
|
+
import { BasicDevtoolsPlugin } from "@player-devtools/basic-plugin";
|
|
5
|
+
var BasicDevtoolsWrapper = ({
|
|
6
|
+
state,
|
|
7
|
+
playerID,
|
|
8
|
+
children
|
|
9
|
+
}) => {
|
|
10
|
+
const [highlight, setHighlight] = useState(false);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (playerID === state.currentPlayer) {
|
|
13
|
+
setHighlight(true);
|
|
14
|
+
const timer = setTimeout(() => {
|
|
15
|
+
setHighlight(false);
|
|
16
|
+
}, 1e3);
|
|
17
|
+
return () => clearTimeout(timer);
|
|
18
|
+
}
|
|
19
|
+
}, [playerID, state.currentPlayer]);
|
|
20
|
+
return /* @__PURE__ */ React.createElement("div", { id: playerID, style: highlight ? { border: "2px solid blue" } : {} }, children);
|
|
21
|
+
};
|
|
22
|
+
var BasicReactDevtoolsPlugin = class extends ReactDevtoolsPlugin {
|
|
23
|
+
constructor(id, wrapper) {
|
|
24
|
+
super();
|
|
25
|
+
this.name = "BasicReactDevtoolsPlugin";
|
|
26
|
+
this.wrapper = wrapper ?? BasicDevtoolsWrapper;
|
|
27
|
+
this.corePlugin = new BasicDevtoolsPlugin({
|
|
28
|
+
playerID: id ?? "default-id",
|
|
29
|
+
handler: this
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
applyReact(reactPlayer) {
|
|
33
|
+
if (!this.checkIfDevtoolsIsActive()) return;
|
|
34
|
+
super.applyReact(reactPlayer);
|
|
35
|
+
reactPlayer.hooks.webComponent.tap(this.name, (Component) => {
|
|
36
|
+
const DevtoolsContainer = () => {
|
|
37
|
+
const Wrapper = this.wrapper;
|
|
38
|
+
const [state, setState] = useState(this.store.getState());
|
|
39
|
+
useEffect(() => this.store.subscribe(setState), [setState]);
|
|
40
|
+
return /* @__PURE__ */ React.createElement(Wrapper, { state, playerID: this.playerID }, /* @__PURE__ */ React.createElement(Component, null));
|
|
41
|
+
};
|
|
42
|
+
return DevtoolsContainer;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
processInteraction(interaction) {
|
|
46
|
+
super.processInteraction(interaction);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
export {
|
|
50
|
+
BasicReactDevtoolsPlugin
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// ../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/plugins/basic/react/src/index.tsx
|
|
2
|
+
import React, { useEffect, useState } from "react";
|
|
3
|
+
import { ReactDevtoolsPlugin } from "@player-devtools/plugin-react";
|
|
4
|
+
import { BasicDevtoolsPlugin } from "@player-devtools/basic-plugin";
|
|
5
|
+
var BasicDevtoolsWrapper = ({
|
|
6
|
+
state,
|
|
7
|
+
playerID,
|
|
8
|
+
children
|
|
9
|
+
}) => {
|
|
10
|
+
const [highlight, setHighlight] = useState(false);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (playerID === state.currentPlayer) {
|
|
13
|
+
setHighlight(true);
|
|
14
|
+
const timer = setTimeout(() => {
|
|
15
|
+
setHighlight(false);
|
|
16
|
+
}, 1e3);
|
|
17
|
+
return () => clearTimeout(timer);
|
|
18
|
+
}
|
|
19
|
+
}, [playerID, state.currentPlayer]);
|
|
20
|
+
return /* @__PURE__ */ React.createElement("div", { id: playerID, style: highlight ? { border: "2px solid blue" } : {} }, children);
|
|
21
|
+
};
|
|
22
|
+
var BasicReactDevtoolsPlugin = class extends ReactDevtoolsPlugin {
|
|
23
|
+
constructor(id, wrapper) {
|
|
24
|
+
super();
|
|
25
|
+
this.name = "BasicReactDevtoolsPlugin";
|
|
26
|
+
this.wrapper = wrapper ?? BasicDevtoolsWrapper;
|
|
27
|
+
this.corePlugin = new BasicDevtoolsPlugin({
|
|
28
|
+
playerID: id ?? "default-id",
|
|
29
|
+
handler: this
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
applyReact(reactPlayer) {
|
|
33
|
+
if (!this.checkIfDevtoolsIsActive()) return;
|
|
34
|
+
super.applyReact(reactPlayer);
|
|
35
|
+
reactPlayer.hooks.webComponent.tap(this.name, (Component) => {
|
|
36
|
+
const DevtoolsContainer = () => {
|
|
37
|
+
const Wrapper = this.wrapper;
|
|
38
|
+
const [state, setState] = useState(this.store.getState());
|
|
39
|
+
useEffect(() => this.store.subscribe(setState), [setState]);
|
|
40
|
+
return /* @__PURE__ */ React.createElement(Wrapper, { state, playerID: this.playerID }, /* @__PURE__ */ React.createElement(Component, null));
|
|
41
|
+
};
|
|
42
|
+
return DevtoolsContainer;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
processInteraction(interaction) {
|
|
46
|
+
super.processInteraction(interaction);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
export {
|
|
50
|
+
BasicReactDevtoolsPlugin
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/plugins/basic/react/src/index.tsx"],"sourcesContent":["import React, { useEffect, useState } from \"react\";\nimport { ReactPlayer } from \"@player-ui/react\";\nimport { ReactDevtoolsPlugin } from \"@player-devtools/plugin-react\";\nimport { BasicDevtoolsPlugin } from \"@player-devtools/basic-plugin\";\nimport type {\n DevtoolsPluginInteractionEvent,\n DevtoolsPluginsStore,\n} from \"@player-devtools/types\";\n\nexport type DevtoolsWrapperProps = React.PropsWithChildren<{\n state: DevtoolsPluginsStore;\n playerID: string;\n}>;\n\nconst BasicDevtoolsWrapper = ({\n state,\n playerID,\n children,\n}: DevtoolsWrapperProps) => {\n const [highlight, setHighlight] = useState(false);\n useEffect(() => {\n if (playerID === state.currentPlayer) {\n setHighlight(true);\n const timer = setTimeout(() => {\n setHighlight(false);\n }, 1000);\n return () => clearTimeout(timer);\n }\n }, [playerID, state.currentPlayer]);\n\n return (\n <div id={playerID} style={highlight ? { border: \"2px solid blue\" } : {}}>\n {children}\n </div>\n );\n};\n\nexport class BasicReactDevtoolsPlugin extends ReactDevtoolsPlugin<BasicDevtoolsPlugin> {\n name = \"BasicReactDevtoolsPlugin\";\n\n corePlugin: BasicDevtoolsPlugin;\n\n private wrapper: React.ComponentType<DevtoolsWrapperProps>;\n\n constructor(\n id?: string,\n wrapper?: React.ComponentType<DevtoolsWrapperProps>,\n ) {\n super();\n\n this.wrapper = wrapper ?? BasicDevtoolsWrapper;\n this.corePlugin = new BasicDevtoolsPlugin({\n playerID: id ?? \"default-id\",\n handler: this,\n });\n }\n\n applyReact(reactPlayer: ReactPlayer): void {\n if (!this.checkIfDevtoolsIsActive()) return;\n\n super.applyReact(reactPlayer);\n\n reactPlayer.hooks.webComponent.tap(this.name, (Component) => {\n const DevtoolsContainer = () => {\n const Wrapper = this.wrapper;\n const [state, setState] = useState(this.store.getState());\n useEffect(() => this.store.subscribe(setState), [setState]);\n return (\n <Wrapper state={state} playerID={this.playerID}>\n <Component />\n </Wrapper>\n );\n };\n return DevtoolsContainer;\n });\n }\n\n processInteraction(interaction: DevtoolsPluginInteractionEvent): void {\n super.processInteraction(interaction);\n }\n}\n"],"mappings":";AAAA,OAAO,SAAS,WAAW,gBAAgB;AAE3C,SAAS,2BAA2B;AACpC,SAAS,2BAA2B;AAWpC,IAAM,uBAAuB,CAAC;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AACF,MAA4B;AAC1B,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,YAAU,MAAM;AACd,QAAI,aAAa,MAAM,eAAe;AACpC,mBAAa,IAAI;AACjB,YAAM,QAAQ,WAAW,MAAM;AAC7B,qBAAa,KAAK;AAAA,MACpB,GAAG,GAAI;AACP,aAAO,MAAM,aAAa,KAAK;AAAA,IACjC;AAAA,EACF,GAAG,CAAC,UAAU,MAAM,aAAa,CAAC;AAElC,SACE,oCAAC,SAAI,IAAI,UAAU,OAAO,YAAY,EAAE,QAAQ,iBAAiB,IAAI,CAAC,KACnE,QACH;AAEJ;AAEO,IAAM,2BAAN,cAAuC,oBAAyC;AAAA,EAOrF,YACE,IACA,SACA;AACA,UAAM;AAVR,gBAAO;AAYL,SAAK,UAAU,WAAW;AAC1B,SAAK,aAAa,IAAI,oBAAoB;AAAA,MACxC,UAAU,MAAM;AAAA,MAChB,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAAA,EAEA,WAAW,aAAgC;AACzC,QAAI,CAAC,KAAK,wBAAwB,EAAG;AAErC,UAAM,WAAW,WAAW;AAE5B,gBAAY,MAAM,aAAa,IAAI,KAAK,MAAM,CAAC,cAAc;AAC3D,YAAM,oBAAoB,MAAM;AAC9B,cAAM,UAAU,KAAK;AACrB,cAAM,CAAC,OAAO,QAAQ,IAAI,SAAS,KAAK,MAAM,SAAS,CAAC;AACxD,kBAAU,MAAM,KAAK,MAAM,UAAU,QAAQ,GAAG,CAAC,QAAQ,CAAC;AAC1D,eACE,oCAAC,WAAQ,OAAc,UAAU,KAAK,YACpC,oCAAC,eAAU,CACb;AAAA,MAEJ;AACA,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AAAA,EAEA,mBAAmB,aAAmD;AACpE,UAAM,mBAAmB,WAAW;AAAA,EACtC;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"sideEffects": false,
|
|
3
|
+
"files": [
|
|
4
|
+
"dist",
|
|
5
|
+
"src",
|
|
6
|
+
"types"
|
|
7
|
+
],
|
|
8
|
+
"name": "@player-devtools/basic-plugin-react",
|
|
9
|
+
"version": "0.0.2-next.0",
|
|
10
|
+
"main": "dist/cjs/index.cjs",
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@player-devtools/basic-plugin": "0.0.2-next.0",
|
|
13
|
+
"@player-devtools/plugin-react": "0.0.2-next.0",
|
|
14
|
+
"@player-devtools/types": "0.0.2-next.0",
|
|
15
|
+
"@devtools-ui/plugin": "0.4.0",
|
|
16
|
+
"@player-ui/react": "0.12.0-next.1",
|
|
17
|
+
"@types/react": "^18.2.51",
|
|
18
|
+
"@types/uuid": "^8.3.4",
|
|
19
|
+
"dequal": "^2.0.2",
|
|
20
|
+
"dset": "^3.1.3",
|
|
21
|
+
"immer": "^10.0.3",
|
|
22
|
+
"uuid": "^8.3.2",
|
|
23
|
+
"tslib": "^2.6.2"
|
|
24
|
+
},
|
|
25
|
+
"module": "dist/index.legacy-esm.js",
|
|
26
|
+
"types": "types/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
"./package.json": "./package.json",
|
|
29
|
+
"./dist/index.css": "./dist/index.css",
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./types/index.d.ts",
|
|
32
|
+
"import": "./dist/index.mjs",
|
|
33
|
+
"default": "./dist/cjs/index.cjs"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {}
|
|
37
|
+
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
import { ReactPlayer } from "@player-ui/react";
|
|
3
|
+
import { ReactDevtoolsPlugin } from "@player-devtools/plugin-react";
|
|
4
|
+
import { BasicDevtoolsPlugin } from "@player-devtools/basic-plugin";
|
|
5
|
+
import type {
|
|
6
|
+
DevtoolsPluginInteractionEvent,
|
|
7
|
+
DevtoolsPluginsStore,
|
|
8
|
+
} from "@player-devtools/types";
|
|
9
|
+
|
|
10
|
+
export type DevtoolsWrapperProps = React.PropsWithChildren<{
|
|
11
|
+
state: DevtoolsPluginsStore;
|
|
12
|
+
playerID: string;
|
|
13
|
+
}>;
|
|
14
|
+
|
|
15
|
+
const BasicDevtoolsWrapper = ({
|
|
16
|
+
state,
|
|
17
|
+
playerID,
|
|
18
|
+
children,
|
|
19
|
+
}: DevtoolsWrapperProps) => {
|
|
20
|
+
const [highlight, setHighlight] = useState(false);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (playerID === state.currentPlayer) {
|
|
23
|
+
setHighlight(true);
|
|
24
|
+
const timer = setTimeout(() => {
|
|
25
|
+
setHighlight(false);
|
|
26
|
+
}, 1000);
|
|
27
|
+
return () => clearTimeout(timer);
|
|
28
|
+
}
|
|
29
|
+
}, [playerID, state.currentPlayer]);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div id={playerID} style={highlight ? { border: "2px solid blue" } : {}}>
|
|
33
|
+
{children}
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export class BasicReactDevtoolsPlugin extends ReactDevtoolsPlugin<BasicDevtoolsPlugin> {
|
|
39
|
+
name = "BasicReactDevtoolsPlugin";
|
|
40
|
+
|
|
41
|
+
corePlugin: BasicDevtoolsPlugin;
|
|
42
|
+
|
|
43
|
+
private wrapper: React.ComponentType<DevtoolsWrapperProps>;
|
|
44
|
+
|
|
45
|
+
constructor(
|
|
46
|
+
id?: string,
|
|
47
|
+
wrapper?: React.ComponentType<DevtoolsWrapperProps>,
|
|
48
|
+
) {
|
|
49
|
+
super();
|
|
50
|
+
|
|
51
|
+
this.wrapper = wrapper ?? BasicDevtoolsWrapper;
|
|
52
|
+
this.corePlugin = new BasicDevtoolsPlugin({
|
|
53
|
+
playerID: id ?? "default-id",
|
|
54
|
+
handler: this,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
applyReact(reactPlayer: ReactPlayer): void {
|
|
59
|
+
if (!this.checkIfDevtoolsIsActive()) return;
|
|
60
|
+
|
|
61
|
+
super.applyReact(reactPlayer);
|
|
62
|
+
|
|
63
|
+
reactPlayer.hooks.webComponent.tap(this.name, (Component) => {
|
|
64
|
+
const DevtoolsContainer = () => {
|
|
65
|
+
const Wrapper = this.wrapper;
|
|
66
|
+
const [state, setState] = useState(this.store.getState());
|
|
67
|
+
useEffect(() => this.store.subscribe(setState), [setState]);
|
|
68
|
+
return (
|
|
69
|
+
<Wrapper state={state} playerID={this.playerID}>
|
|
70
|
+
<Component />
|
|
71
|
+
</Wrapper>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
return DevtoolsContainer;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
processInteraction(interaction: DevtoolsPluginInteractionEvent): void {
|
|
79
|
+
super.processInteraction(interaction);
|
|
80
|
+
}
|
|
81
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ReactPlayer } from "@player-ui/react";
|
|
3
|
+
import { ReactDevtoolsPlugin } from "@player-devtools/plugin-react";
|
|
4
|
+
import { BasicDevtoolsPlugin } from "@player-devtools/basic-plugin";
|
|
5
|
+
import type { DevtoolsPluginInteractionEvent, DevtoolsPluginsStore } from "@player-devtools/types";
|
|
6
|
+
export type DevtoolsWrapperProps = React.PropsWithChildren<{
|
|
7
|
+
state: DevtoolsPluginsStore;
|
|
8
|
+
playerID: string;
|
|
9
|
+
}>;
|
|
10
|
+
export declare class BasicReactDevtoolsPlugin extends ReactDevtoolsPlugin<BasicDevtoolsPlugin> {
|
|
11
|
+
name: string;
|
|
12
|
+
corePlugin: BasicDevtoolsPlugin;
|
|
13
|
+
private wrapper;
|
|
14
|
+
constructor(id?: string, wrapper?: React.ComponentType<DevtoolsWrapperProps>);
|
|
15
|
+
applyReact(reactPlayer: ReactPlayer): void;
|
|
16
|
+
processInteraction(interaction: DevtoolsPluginInteractionEvent): void;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|