@vnejs/plugins.views.scenario.interface 0.1.14 → 0.1.15
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/modules/interface.d.ts +3 -3
- package/dist/modules/interface.js +4 -1
- package/dist/utils/interface.d.ts +0 -9
- package/dist/view/components/InterfaceViewWall.js +5 -5
- package/dist/view/index.js +2 -2
- package/package.json +1 -1
- package/src/modules/interface.ts +6 -3
- package/src/utils/interface.ts +0 -9
- package/src/view/components/InterfaceViewWall.tsx +18 -10
- package/src/view/index.tsx +6 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Module } from "@vnejs/module";
|
|
1
|
+
import { Module, type ModuleGlobalStateRegistry } from "@vnejs/module";
|
|
2
2
|
import type { InterfacePluginConstants, InterfacePluginEvents, InterfacePluginParams, InterfacePluginSettings } from "../types.js";
|
|
3
|
-
import type { InterfaceForcePayload, InterfaceLineExecPayload, InterfaceModuleState, InterfaceSpeakerChangedPayload,
|
|
3
|
+
import type { InterfaceForcePayload, InterfaceLineExecPayload, InterfaceModuleState, InterfaceSpeakerChangedPayload, InterfaceTextChangedPayload, InterfaceViewPayload } from "../utils/interface.js";
|
|
4
4
|
export declare class Interface extends Module<InterfacePluginEvents, InterfacePluginConstants, InterfacePluginSettings, InterfacePluginParams, InterfaceModuleState> {
|
|
5
5
|
name: string;
|
|
6
6
|
subscribe: () => void;
|
|
@@ -15,7 +15,7 @@ export declare class Interface extends Module<InterfacePluginEvents, InterfacePl
|
|
|
15
15
|
onTextEmitBefore: () => Promise<unknown[]> | undefined;
|
|
16
16
|
onTextHide: () => Promise<unknown[]> | undefined;
|
|
17
17
|
onView: ({ view, isForce }?: InterfaceViewPayload) => Promise<unknown[]> | undefined;
|
|
18
|
-
onStateSet: (
|
|
18
|
+
onStateSet: (payload: ModuleGlobalStateRegistry) => Promise<unknown[]> | undefined;
|
|
19
19
|
onStateClear: () => Promise<unknown[]> | undefined;
|
|
20
20
|
setView: (view?: string, isForce?: boolean) => Promise<unknown[]> | undefined;
|
|
21
21
|
setShow: (isShow: boolean, isForce?: boolean) => Promise<unknown[] | undefined>;
|
|
@@ -36,7 +36,10 @@ export class Interface extends Module {
|
|
|
36
36
|
onTextEmitBefore = () => this.emit(this.EVENTS.INTERFACE.SHOW);
|
|
37
37
|
onTextHide = () => this.setText([], [], "", 0);
|
|
38
38
|
onView = ({ view, isForce = false } = {}) => this.setView(view, isForce);
|
|
39
|
-
onStateSet = (
|
|
39
|
+
onStateSet = (payload) => {
|
|
40
|
+
const moduleState = this.getStateSlice(payload);
|
|
41
|
+
return this.setNewState(moduleState?.view, moduleState?.isVisible, moduleState?.isShow);
|
|
42
|
+
};
|
|
40
43
|
onStateClear = () => this.setNewState(this.PARAMS.INTERFACE.DEFAULT_VIEW, false, false);
|
|
41
44
|
setView = (view, isForce = false) => {
|
|
42
45
|
this.state.view = view ?? "";
|
|
@@ -2,14 +2,6 @@ import type { ModuleControllerState } from "@vnejs/module.components";
|
|
|
2
2
|
import type { TokenizedChar, WallElement } from "@vnejs/plugins.text.contract";
|
|
3
3
|
import type { InterfaceModuleState } from "@vnejs/plugins.views.scenario.interface.contract";
|
|
4
4
|
export type { InterfaceModuleState };
|
|
5
|
-
export type InterfaceSpeakerInfo = {
|
|
6
|
-
color?: string;
|
|
7
|
-
opacity?: number;
|
|
8
|
-
speakerColor?: string;
|
|
9
|
-
names?: Record<string, string[] | undefined> & {
|
|
10
|
-
default?: string[];
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
5
|
export type InterfacePluginState = ModuleControllerState & InterfaceModuleState & {
|
|
14
6
|
isFast?: boolean;
|
|
15
7
|
locs?: Record<string, string>;
|
|
@@ -41,4 +33,3 @@ export type InterfaceSpeakerChangedPayload = {
|
|
|
41
33
|
speaker?: string;
|
|
42
34
|
meet?: number;
|
|
43
35
|
};
|
|
44
|
-
export type InterfaceStateSetPayload = Record<string, Pick<InterfaceModuleState, "view" | "isVisible" | "isShow"> | undefined>;
|
|
@@ -2,13 +2,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Flex, PositionBox, Scrollbar, SmoothText, Text, useMemo } from "@vnejs/uis.react";
|
|
3
3
|
import { useTokensHook } from "./tokens.hook.js";
|
|
4
4
|
const renderOneText = (wallElement) => (_jsxs("div", { children: [wallElement.speakerName && (_jsx(Text, { ...wallElement.propsByView.text, isInlineBlock: true, color: wallElement.speakerColor, text: `${wallElement.speakerName}:`, marginRight: 12 })), _jsx(SmoothText, { ...wallElement.propsByView.text, isNoScrollBar: true, color: wallElement.color, opacity: wallElement.opacity, transition: wallElement.transition, tokens: wallElement.tokens, tokensVisibleForce: wallElement.tokensVisible })] }, wallElement.uid));
|
|
5
|
-
const mapWall = ({ uid = "", tokens = [], speaker = "", meet = 0, transition = 0, props }) => {
|
|
5
|
+
const mapWall = ({ uid = "", tokens = [], speaker = "", meet = 0, transition = 0, props, }) => {
|
|
6
6
|
const propsByView = props.PARAMS.INTERFACE.VIEW_PROPS.wall;
|
|
7
7
|
const speakersInfo = props.PARAMS.TEXT.SPEAKERS_INFO;
|
|
8
|
-
const speakerInfo = speakersInfo[speaker]
|
|
9
|
-
const { color, opacity = 1,
|
|
10
|
-
const
|
|
11
|
-
const speakerName =
|
|
8
|
+
const speakerInfo = speakersInfo[speaker] ?? speakersInfo[props.PARAMS.TEXT.DEFAULT_SPEAKER_NAME];
|
|
9
|
+
const { color, opacity = 1, speakerColor = "white" } = speakerInfo;
|
|
10
|
+
const locs = props.locs ?? {};
|
|
11
|
+
const speakerName = locs[`speaker.${speaker}.${meet ?? 0}`];
|
|
12
12
|
return { speakerName, speakerColor, uid, color, opacity, tokens, tokensVisible: tokens.length, transition, propsByView };
|
|
13
13
|
};
|
|
14
14
|
export const InterfaceViewWall = (props) => {
|
package/dist/view/index.js
CHANGED
|
@@ -12,9 +12,9 @@ const Interface = (props) => {
|
|
|
12
12
|
const speakerText = speakerName ? `${`${locs[`prefix.${prefix}`] ?? ""} `}${speakerName}${` ${locs[`postfix.${postfix}`] ?? ""}`}` : ".";
|
|
13
13
|
const transition = isRealForce ? 0 : PARAMS.INTERFACE.TRANSITION;
|
|
14
14
|
const speakersInfo = PARAMS.TEXT.SPEAKERS_INFO;
|
|
15
|
-
const speakerInfo = speakersInfo[speaker]
|
|
15
|
+
const speakerInfo = speakersInfo[speaker] ?? speakersInfo[PARAMS.TEXT.DEFAULT_SPEAKER_NAME];
|
|
16
16
|
const { color, opacity = 1, speakerColor = "white" } = speakerInfo;
|
|
17
|
-
const propsCommon = useMemo(() => ({ isForce: isRealForce, transition, tokensVisible, tokens, wall, uid }), [isRealForce, transition, tokensVisible, tokens, wall, uid]);
|
|
17
|
+
const propsCommon = useMemo(() => ({ isForce: isRealForce, transition, tokensVisible, tokens, wall, uid, locs }), [isRealForce, transition, tokensVisible, tokens, wall, uid, locs]);
|
|
18
18
|
const propsSpeaker = useMemo(() => ({ speakerText, speakerName, speakerColor }), [speakerText, speakerName, speakerColor]);
|
|
19
19
|
const propsText = useMemo(() => ({ opacity, color }), [opacity, color]);
|
|
20
20
|
const propsView = useMemo(() => ({ ...propsCommon, ...propsSpeaker, ...propsText }), [propsCommon, propsSpeaker, propsText]);
|
package/package.json
CHANGED
package/src/modules/interface.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Module } from "@vnejs/module";
|
|
1
|
+
import { Module, type ModuleGlobalStateRegistry } from "@vnejs/module";
|
|
2
2
|
import { tokenizeExecLine } from "@vnejs/helpers";
|
|
3
3
|
|
|
4
4
|
import type { InterfacePluginConstants, InterfacePluginEvents, InterfacePluginParams, InterfacePluginSettings } from "../types.js";
|
|
@@ -7,7 +7,6 @@ import type {
|
|
|
7
7
|
InterfaceLineExecPayload,
|
|
8
8
|
InterfaceModuleState,
|
|
9
9
|
InterfaceSpeakerChangedPayload,
|
|
10
|
-
InterfaceStateSetPayload,
|
|
11
10
|
InterfaceTextChangedPayload,
|
|
12
11
|
InterfaceViewPayload,
|
|
13
12
|
} from "../utils/interface.js";
|
|
@@ -54,7 +53,11 @@ export class Interface extends Module<InterfacePluginEvents, InterfacePluginCons
|
|
|
54
53
|
onTextEmitBefore = () => this.emit(this.EVENTS.INTERFACE.SHOW);
|
|
55
54
|
onTextHide = () => this.setText([], [], "", 0);
|
|
56
55
|
onView = ({ view, isForce = false }: InterfaceViewPayload = {}) => this.setView(view, isForce);
|
|
57
|
-
onStateSet = (
|
|
56
|
+
onStateSet = (payload: ModuleGlobalStateRegistry) => {
|
|
57
|
+
const moduleState = this.getStateSlice(payload);
|
|
58
|
+
|
|
59
|
+
return this.setNewState(moduleState?.view, moduleState?.isVisible, moduleState?.isShow);
|
|
60
|
+
};
|
|
58
61
|
onStateClear = () => this.setNewState(this.PARAMS.INTERFACE.DEFAULT_VIEW, false, false);
|
|
59
62
|
|
|
60
63
|
setView = (view?: string, isForce = false) => {
|
package/src/utils/interface.ts
CHANGED
|
@@ -4,13 +4,6 @@ import type { InterfaceModuleState } from "@vnejs/plugins.views.scenario.interfa
|
|
|
4
4
|
|
|
5
5
|
export type { InterfaceModuleState };
|
|
6
6
|
|
|
7
|
-
export type InterfaceSpeakerInfo = {
|
|
8
|
-
color?: string;
|
|
9
|
-
opacity?: number;
|
|
10
|
-
speakerColor?: string;
|
|
11
|
-
names?: Record<string, string[] | undefined> & { default?: string[] };
|
|
12
|
-
};
|
|
13
|
-
|
|
14
7
|
export type InterfacePluginState = ModuleControllerState &
|
|
15
8
|
InterfaceModuleState & {
|
|
16
9
|
isFast?: boolean;
|
|
@@ -48,5 +41,3 @@ export type InterfaceSpeakerChangedPayload = {
|
|
|
48
41
|
speaker?: string;
|
|
49
42
|
meet?: number;
|
|
50
43
|
};
|
|
51
|
-
|
|
52
|
-
export type InterfaceStateSetPayload = Record<string, Pick<InterfaceModuleState, "view" | "isVisible" | "isShow"> | undefined>;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type { TokenizedChar, WallElement } from "@vnejs/plugins.text.contract";
|
|
1
|
+
import type { TextSpeakerInfo, TokenizedChar, WallElement } from "@vnejs/plugins.text.contract";
|
|
2
2
|
import { Flex, PositionBox, Scrollbar, SmoothText, Text, useMemo } from "@vnejs/uis.react";
|
|
3
3
|
|
|
4
4
|
import type { Params as InterfaceContractParams } from "@vnejs/plugins.views.scenario.interface.contract";
|
|
5
5
|
|
|
6
6
|
import type { InterfaceViewProps } from "../../types.js";
|
|
7
|
-
import type { InterfaceSpeakerInfo } from "../../utils/interface.js";
|
|
8
7
|
import { useTokensHook } from "./tokens.hook.js";
|
|
9
8
|
|
|
10
9
|
type WallTextElement = {
|
|
@@ -42,14 +41,20 @@ const renderOneText = (wallElement: WallTextElement) => (
|
|
|
42
41
|
</div>
|
|
43
42
|
);
|
|
44
43
|
|
|
45
|
-
const mapWall = ({
|
|
44
|
+
const mapWall = ({
|
|
45
|
+
uid = "",
|
|
46
|
+
tokens = [],
|
|
47
|
+
speaker = "",
|
|
48
|
+
meet = 0,
|
|
49
|
+
transition = 0,
|
|
50
|
+
props,
|
|
51
|
+
}: WallElement & { transition?: number; props: InterfaceViewProps }) => {
|
|
46
52
|
const propsByView = props.PARAMS.INTERFACE.VIEW_PROPS.wall;
|
|
47
|
-
const speakersInfo = props.PARAMS.TEXT.SPEAKERS_INFO
|
|
48
|
-
const speakerInfo = speakersInfo[speaker]
|
|
49
|
-
const { color, opacity = 1,
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
const speakerName = langNames[meet] || langNames[langNames.length - 1];
|
|
53
|
+
const speakersInfo = props.PARAMS.TEXT.SPEAKERS_INFO;
|
|
54
|
+
const speakerInfo: TextSpeakerInfo = speakersInfo[speaker] ?? speakersInfo[props.PARAMS.TEXT.DEFAULT_SPEAKER_NAME];
|
|
55
|
+
const { color, opacity = 1, speakerColor = "white" } = speakerInfo;
|
|
56
|
+
const locs = props.locs ?? {};
|
|
57
|
+
const speakerName = locs[`speaker.${speaker}.${meet ?? 0}`];
|
|
53
58
|
|
|
54
59
|
return { speakerName, speakerColor, uid, color, opacity, tokens, tokensVisible: tokens.length, transition, propsByView };
|
|
55
60
|
};
|
|
@@ -71,7 +76,10 @@ export const InterfaceViewWall = (props: InterfaceViewProps) => {
|
|
|
71
76
|
|
|
72
77
|
const propsByView = PARAMS.INTERFACE.VIEW_PROPS.wall;
|
|
73
78
|
|
|
74
|
-
const propsPosition = useMemo(
|
|
79
|
+
const propsPosition = useMemo(
|
|
80
|
+
() => ({ ...propsByView.position, opacity: isViewActive ? 1 : 0, transition }),
|
|
81
|
+
[isViewActive, transition, propsByView.position],
|
|
82
|
+
);
|
|
75
83
|
const wallWithProps = useMemo(() => wall.map((item) => ({ ...item, transition, props })), [wall, transition, props]);
|
|
76
84
|
|
|
77
85
|
const { realTokens, realTokensVisible } = useTokensHook(isViewActive, tokens, tokensVisible, uid);
|
package/src/view/index.tsx
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { ViewRenderFunc } from "@vnejs/module.components";
|
|
2
|
+
import type { TextSpeakerInfo } from "@vnejs/plugins.text.contract";
|
|
2
3
|
import type { ReactComponentProps } from "@vnejs/uis.react";
|
|
3
4
|
import { Screen, createRenderFunc, useCallback, useIsForceHook, useMemo, useStoreState } from "@vnejs/uis.react";
|
|
4
5
|
|
|
5
6
|
import type { InterfacePluginConstants, InterfacePluginEvents, InterfacePluginParams, InterfacePluginSettings } from "../types.js";
|
|
6
|
-
import type { InterfacePluginState
|
|
7
|
+
import type { InterfacePluginState } from "../utils/interface.js";
|
|
7
8
|
import { InterfaceBackdrop, InterfaceViewDialog, InterfaceViewLine, InterfaceViewWall } from "./components/index.js";
|
|
8
9
|
|
|
9
10
|
type InterfaceComponentProps = ReactComponentProps<
|
|
@@ -28,14 +29,14 @@ const Interface = (props: InterfaceComponentProps) => {
|
|
|
28
29
|
const speakerName = locs[`speaker.${speaker}.${meet ?? 0}`];
|
|
29
30
|
const speakerText = speakerName ? `${`${locs[`prefix.${prefix}`] ?? ""} `}${speakerName}${` ${locs[`postfix.${postfix}`] ?? ""}`}` : ".";
|
|
30
31
|
const transition = isRealForce ? 0 : PARAMS.INTERFACE.TRANSITION;
|
|
31
|
-
const speakersInfo = PARAMS.TEXT.SPEAKERS_INFO
|
|
32
|
-
const speakerInfo = speakersInfo[speaker]
|
|
32
|
+
const speakersInfo = PARAMS.TEXT.SPEAKERS_INFO;
|
|
33
|
+
const speakerInfo: TextSpeakerInfo = speakersInfo[speaker] ?? speakersInfo[PARAMS.TEXT.DEFAULT_SPEAKER_NAME];
|
|
33
34
|
|
|
34
35
|
const { color, opacity = 1, speakerColor = "white" } = speakerInfo;
|
|
35
36
|
|
|
36
37
|
const propsCommon = useMemo(
|
|
37
|
-
() => ({ isForce: isRealForce, transition, tokensVisible, tokens, wall, uid }),
|
|
38
|
-
[isRealForce, transition, tokensVisible, tokens, wall, uid],
|
|
38
|
+
() => ({ isForce: isRealForce, transition, tokensVisible, tokens, wall, uid, locs }),
|
|
39
|
+
[isRealForce, transition, tokensVisible, tokens, wall, uid, locs],
|
|
39
40
|
);
|
|
40
41
|
const propsSpeaker = useMemo(() => ({ speakerText, speakerName, speakerColor }), [speakerText, speakerName, speakerColor]);
|
|
41
42
|
const propsText = useMemo(() => ({ opacity, color }), [opacity, color]);
|