@player-tools/devtools-basic-web-plugin 0.5.3--canary.90.2515
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 +919 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/index.legacy-esm.js +884 -0
- package/dist/index.mjs +884 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +41 -0
- package/src/WrapperComponent.tsx +169 -0
- package/src/constants/index.ts +27 -0
- package/src/content/common/Screen.tsx +35 -0
- package/src/content/common/index.ts +1 -0
- package/src/content/index.ts +18 -0
- package/src/content/navigation/index.ts +27 -0
- package/src/content/schema/index.ts +39 -0
- package/src/content/views/ConfigView.tsx +16 -0
- package/src/content/views/ConsoleView.tsx +20 -0
- package/src/content/views/FlowView.tsx +23 -0
- package/src/content/views/LogsView.tsx +9 -0
- package/src/content/views/index.ts +6 -0
- package/src/helpers/genDataChangeTransaction.ts +29 -0
- package/src/helpers/getEvaluateExpression.ts +50 -0
- package/src/helpers/index.ts +2 -0
- package/src/index.tsx +96 -0
- package/src/types.ts +35 -0
- package/types/WrapperComponent.d.ts +4 -0
- package/types/constants/index.d.ts +16 -0
- package/types/content/common/Screen.d.ts +7 -0
- package/types/content/common/index.d.ts +2 -0
- package/types/content/index.d.ts +33 -0
- package/types/content/navigation/index.d.ts +7 -0
- package/types/content/schema/index.d.ts +29 -0
- package/types/content/views/ConfigView.d.ts +3 -0
- package/types/content/views/ConsoleView.d.ts +3 -0
- package/types/content/views/FlowView.d.ts +3 -0
- package/types/content/views/LogsView.d.ts +3 -0
- package/types/content/views/index.d.ts +3 -0
- package/types/helpers/genDataChangeTransaction.d.ts +8 -0
- package/types/helpers/getEvaluateExpression.d.ts +4 -0
- package/types/helpers/index.d.ts +3 -0
- package/types/index.d.ts +18 -0
- package/types/types.d.ts +35 -0
package/src/index.tsx
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
DataController,
|
|
3
|
+
ExpressionEvaluator,
|
|
4
|
+
Flow,
|
|
5
|
+
Player,
|
|
6
|
+
ReactPlayer,
|
|
7
|
+
ReactPlayerPlugin,
|
|
8
|
+
ViewInstance,
|
|
9
|
+
} from "@player-ui/react";
|
|
10
|
+
import { dset } from "dset/merge";
|
|
11
|
+
import { produce } from "immer";
|
|
12
|
+
import React from "react";
|
|
13
|
+
import { WrapperComponent } from "./WrapperComponent";
|
|
14
|
+
|
|
15
|
+
/** Basic Web Devtools Plugin */
|
|
16
|
+
export class BasicWevDevtoolsPlugin implements ReactPlayerPlugin {
|
|
17
|
+
name = "player_ui_basic_devtools_plugin";
|
|
18
|
+
|
|
19
|
+
data: Record<string, unknown> = {};
|
|
20
|
+
|
|
21
|
+
playerConfig: Record<string, unknown> = {};
|
|
22
|
+
|
|
23
|
+
logs: {
|
|
24
|
+
severity: string;
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
message: any;
|
|
27
|
+
}[] = [];
|
|
28
|
+
|
|
29
|
+
flow?: Flow;
|
|
30
|
+
|
|
31
|
+
expressionEvaluator?: WeakRef<ExpressionEvaluator>;
|
|
32
|
+
|
|
33
|
+
view?: WeakRef<ViewInstance>;
|
|
34
|
+
|
|
35
|
+
dataController?: WeakRef<DataController>;
|
|
36
|
+
|
|
37
|
+
apply(player: Player) {
|
|
38
|
+
// Config
|
|
39
|
+
this.playerConfig = {
|
|
40
|
+
version: player.getVersion(),
|
|
41
|
+
plugins: player.getPlugins().map((plugin) => plugin.name),
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// Data
|
|
45
|
+
player.hooks.dataController.tap(this.name, (dataController) => {
|
|
46
|
+
dataController.hooks.onUpdate.tap(this.name, (updates) => {
|
|
47
|
+
const newPlayerState = produce(this.data, (draft) => {
|
|
48
|
+
updates.forEach(({ binding, newValue }) => {
|
|
49
|
+
dset(draft, ["data", ...binding.asArray()], newValue);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
this.data = newPlayerState;
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Logs
|
|
57
|
+
player.logger.hooks.log.tap(this.name, (severity, message) => {
|
|
58
|
+
this.logs = [...this.logs, { severity, message }];
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Flow
|
|
62
|
+
player.hooks.onStart.tap(this.name, (f) => {
|
|
63
|
+
this.flow = f;
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// View
|
|
67
|
+
player.hooks.view.tap(this.name, (view) => {
|
|
68
|
+
this.view = new WeakRef(view);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// Expression evaluator
|
|
72
|
+
player.hooks.expressionEvaluator.tap(this.name, (evaluator) => {
|
|
73
|
+
this.expressionEvaluator = new WeakRef(evaluator);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
applyReact(reactPlayer: ReactPlayer) {
|
|
78
|
+
// eslint-disable-next-line react/display-name
|
|
79
|
+
reactPlayer.hooks.webComponent.tap(this.name, (Comp) => () => {
|
|
80
|
+
const Component = Comp as React.FC;
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<WrapperComponent
|
|
84
|
+
playerConfig={this.playerConfig}
|
|
85
|
+
data={this.data}
|
|
86
|
+
logs={this.logs}
|
|
87
|
+
flow={this.flow}
|
|
88
|
+
view={this.view}
|
|
89
|
+
expressionEvaluator={this.expressionEvaluator}
|
|
90
|
+
>
|
|
91
|
+
<Component />
|
|
92
|
+
</WrapperComponent>
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ExpressionEvaluator, ViewInstance } from "@player-ui/react";
|
|
2
|
+
import { Flow } from "@player-ui/types";
|
|
3
|
+
|
|
4
|
+
export interface Evaluation {
|
|
5
|
+
/** A unique key for this expression */
|
|
6
|
+
id: string;
|
|
7
|
+
/** The expression itself */
|
|
8
|
+
expression: string;
|
|
9
|
+
/** The result for a given expression */
|
|
10
|
+
result?: unknown;
|
|
11
|
+
/** Whether there were any errors with the result */
|
|
12
|
+
severity?: "error" | "warning";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface WrapperComponentProps {
|
|
16
|
+
/** component's children */
|
|
17
|
+
readonly children: React.ReactNode;
|
|
18
|
+
/** Inspected player data */
|
|
19
|
+
data: Record<string, unknown>;
|
|
20
|
+
/** Inspected player config */
|
|
21
|
+
playerConfig: Record<string, unknown>;
|
|
22
|
+
/** Inspected player logs */
|
|
23
|
+
logs: {
|
|
24
|
+
/** Log severity */
|
|
25
|
+
severity: string;
|
|
26
|
+
/** Log message */
|
|
27
|
+
message: string;
|
|
28
|
+
}[];
|
|
29
|
+
/** Inspected player flow */
|
|
30
|
+
flow?: Flow;
|
|
31
|
+
/** expression evaluator */
|
|
32
|
+
expressionEvaluator?: WeakRef<ExpressionEvaluator>;
|
|
33
|
+
/** view instace */
|
|
34
|
+
view?: WeakRef<ViewInstance>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { WrapperComponentProps } from "./types";
|
|
2
|
+
/** Tap into the ReactPlayer hooks and create the content to be rendered into the extension Player UI */
|
|
3
|
+
export declare const WrapperComponent: ({ children, data, playerConfig, logs, flow, expressionEvaluator, }: WrapperComponentProps) => JSX.Element;
|
|
4
|
+
//# sourceMappingURL=WrapperComponent.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PluginData } from "@player-tools/devtools-types";
|
|
2
|
+
export declare const PLUGIN_ID = "player-ui-basic-devtools-plugin";
|
|
3
|
+
export declare const PLUGIN_NAME = "Standard Devtools";
|
|
4
|
+
export declare const PLUGIN_DESCRIPTION = "Standard Player UI Devtools";
|
|
5
|
+
export declare const PLUGIN_VERSION = "0.0.1";
|
|
6
|
+
export declare const VIEWS_IDS: {
|
|
7
|
+
CONFIG: string;
|
|
8
|
+
FLOW: string;
|
|
9
|
+
LOGS: string;
|
|
10
|
+
CONSOLE: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const INTERACTIONS: {
|
|
13
|
+
EVALUATE_EXPRESSION: string;
|
|
14
|
+
};
|
|
15
|
+
export declare const BASE_PLUGIN_DATA: Omit<PluginData, "flow">;
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare const _default: {
|
|
3
|
+
id: string;
|
|
4
|
+
views: import("react").JSX.Element[];
|
|
5
|
+
navigation: {
|
|
6
|
+
BEGIN: string;
|
|
7
|
+
Plugin: {
|
|
8
|
+
startState: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
schema: {
|
|
12
|
+
playerConfig: import("@player-ui/types").Schema.DataType<Record<string, unknown>>;
|
|
13
|
+
flow: import("@player-ui/types").Schema.DataType<Record<string, unknown>>;
|
|
14
|
+
expression: import("@player-ui/types").Schema.DataType<string>;
|
|
15
|
+
history: [import("@player-tools/dsl").DSLSchema<Omit<import("@player-ui/types").Schema.DataType<unknown>, "type" | "validation"> & {
|
|
16
|
+
type: string | number;
|
|
17
|
+
validation?: import("@player-ui/types").Validation.Reference[] | undefined;
|
|
18
|
+
}>];
|
|
19
|
+
logs: [import("@player-tools/dsl").DSLSchema<Omit<import("@player-ui/types").Schema.DataType<unknown>, "type" | "validation"> & {
|
|
20
|
+
type: string | number;
|
|
21
|
+
validation?: import("@player-ui/types").Validation.Reference[] | undefined;
|
|
22
|
+
}>];
|
|
23
|
+
};
|
|
24
|
+
data: {
|
|
25
|
+
expression: string;
|
|
26
|
+
flow: {};
|
|
27
|
+
history: never[];
|
|
28
|
+
logs: never[];
|
|
29
|
+
playerConfig: {};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export default _default;
|
|
33
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Schema } from "@player-ui/types";
|
|
2
|
+
import { DSLSchema } from "@player-tools/dsl";
|
|
3
|
+
export declare const schema: {
|
|
4
|
+
playerConfig: Schema.DataType<Record<string, unknown>>;
|
|
5
|
+
flow: Schema.DataType<Record<string, unknown>>;
|
|
6
|
+
expression: Schema.DataType<string>;
|
|
7
|
+
history: [DSLSchema<Omit<Schema.DataType<unknown>, "type" | "validation"> & {
|
|
8
|
+
type: string | number;
|
|
9
|
+
validation?: import("@player-ui/types").Validation.Reference[] | undefined;
|
|
10
|
+
}>];
|
|
11
|
+
logs: [DSLSchema<Omit<Schema.DataType<unknown>, "type" | "validation"> & {
|
|
12
|
+
type: string | number;
|
|
13
|
+
validation?: import("@player-ui/types").Validation.Reference[] | undefined;
|
|
14
|
+
}>];
|
|
15
|
+
};
|
|
16
|
+
export declare const bindings: import("@player-tools/dsl").MakeBindingRefable<{
|
|
17
|
+
playerConfig: Schema.DataType<Record<string, unknown>>;
|
|
18
|
+
flow: Schema.DataType<Record<string, unknown>>;
|
|
19
|
+
expression: Schema.DataType<string>;
|
|
20
|
+
history: [DSLSchema<Omit<Schema.DataType<unknown>, "type" | "validation"> & {
|
|
21
|
+
type: string | number;
|
|
22
|
+
validation?: import("@player-ui/types").Validation.Reference[] | undefined;
|
|
23
|
+
}>];
|
|
24
|
+
logs: [DSLSchema<Omit<Schema.DataType<unknown>, "type" | "validation"> & {
|
|
25
|
+
type: string | number;
|
|
26
|
+
validation?: import("@player-ui/types").Validation.Reference[] | undefined;
|
|
27
|
+
}>];
|
|
28
|
+
}>;
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DevtoolsDataChangeEvent, Transaction } from "@player-tools/devtools-types";
|
|
2
|
+
import type { Flow } from "@player-ui/react";
|
|
3
|
+
export declare const genDataChangeTransaction: ({ playerID, data, pluginID, }: {
|
|
4
|
+
playerID: string;
|
|
5
|
+
data: Flow["data"];
|
|
6
|
+
pluginID: string;
|
|
7
|
+
}) => Transaction<DevtoolsDataChangeEvent>;
|
|
8
|
+
//# sourceMappingURL=genDataChangeTransaction.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ExpressionEvaluator } from "@player-ui/react";
|
|
2
|
+
import { Evaluation } from "../types";
|
|
3
|
+
export declare const getEvaluateExpression: (expressionEvaluator?: WeakRef<ExpressionEvaluator>) => (expression: string) => Evaluation;
|
|
4
|
+
//# sourceMappingURL=getEvaluateExpression.d.ts.map
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { DataController, ExpressionEvaluator, Flow, Player, ReactPlayer, ReactPlayerPlugin, ViewInstance } from "@player-ui/react";
|
|
2
|
+
/** Basic Web Devtools Plugin */
|
|
3
|
+
export declare class BasicWevDevtoolsPlugin implements ReactPlayerPlugin {
|
|
4
|
+
name: string;
|
|
5
|
+
data: Record<string, unknown>;
|
|
6
|
+
playerConfig: Record<string, unknown>;
|
|
7
|
+
logs: {
|
|
8
|
+
severity: string;
|
|
9
|
+
message: any;
|
|
10
|
+
}[];
|
|
11
|
+
flow?: Flow;
|
|
12
|
+
expressionEvaluator?: WeakRef<ExpressionEvaluator>;
|
|
13
|
+
view?: WeakRef<ViewInstance>;
|
|
14
|
+
dataController?: WeakRef<DataController>;
|
|
15
|
+
apply(player: Player): void;
|
|
16
|
+
applyReact(reactPlayer: ReactPlayer): void;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
package/types/types.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ExpressionEvaluator, ViewInstance } from "@player-ui/react";
|
|
3
|
+
import { Flow } from "@player-ui/types";
|
|
4
|
+
export interface Evaluation {
|
|
5
|
+
/** A unique key for this expression */
|
|
6
|
+
id: string;
|
|
7
|
+
/** The expression itself */
|
|
8
|
+
expression: string;
|
|
9
|
+
/** The result for a given expression */
|
|
10
|
+
result?: unknown;
|
|
11
|
+
/** Whether there were any errors with the result */
|
|
12
|
+
severity?: "error" | "warning";
|
|
13
|
+
}
|
|
14
|
+
export interface WrapperComponentProps {
|
|
15
|
+
/** component's children */
|
|
16
|
+
readonly children: React.ReactNode;
|
|
17
|
+
/** Inspected player data */
|
|
18
|
+
data: Record<string, unknown>;
|
|
19
|
+
/** Inspected player config */
|
|
20
|
+
playerConfig: Record<string, unknown>;
|
|
21
|
+
/** Inspected player logs */
|
|
22
|
+
logs: {
|
|
23
|
+
/** Log severity */
|
|
24
|
+
severity: string;
|
|
25
|
+
/** Log message */
|
|
26
|
+
message: string;
|
|
27
|
+
}[];
|
|
28
|
+
/** Inspected player flow */
|
|
29
|
+
flow?: Flow;
|
|
30
|
+
/** expression evaluator */
|
|
31
|
+
expressionEvaluator?: WeakRef<ExpressionEvaluator>;
|
|
32
|
+
/** view instace */
|
|
33
|
+
view?: WeakRef<ViewInstance>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=types.d.ts.map
|