@vnejs/plugins.views.scenario.interface 0.1.13 → 0.1.14
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.d.ts +1 -0
- package/dist/index.js +6 -0
- package/dist/modules/controller.d.ts +23 -0
- package/dist/modules/controller.js +77 -0
- package/dist/modules/interface.d.ts +27 -0
- package/dist/modules/interface.js +71 -0
- package/dist/modules/view.d.ts +11 -0
- package/dist/modules/view.js +10 -0
- package/dist/types.d.ts +17 -0
- package/dist/types.js +1 -0
- package/dist/utils/interface.d.ts +44 -0
- package/dist/utils/interface.js +1 -0
- package/dist/view/components/InterfaceBackdrop.d.ts +2 -0
- package/dist/view/components/InterfaceBackdrop.js +9 -0
- package/dist/view/components/InterfaceViewDialog.d.ts +2 -0
- package/dist/view/components/InterfaceViewDialog.js +19 -0
- package/dist/view/components/InterfaceViewLine.d.ts +2 -0
- package/dist/view/components/InterfaceViewLine.js +12 -0
- package/dist/view/components/InterfaceViewWall.d.ts +2 -0
- package/dist/view/components/InterfaceViewWall.js +24 -0
- package/dist/view/components/index.d.ts +4 -0
- package/dist/view/components/index.js +4 -0
- package/dist/view/components/tokens.hook.d.ts +6 -0
- package/dist/view/components/tokens.hook.js +30 -0
- package/dist/view/index.d.ts +3 -0
- package/dist/view/index.js +27 -0
- package/package.json +38 -6
- package/src/index.ts +8 -0
- package/{modules/controller.js → src/modules/controller.ts} +36 -10
- package/{modules/interface.js → src/modules/interface.ts} +29 -18
- package/src/modules/view.ts +22 -0
- package/src/types.ts +35 -0
- package/src/utils/interface.ts +52 -0
- package/src/view/components/InterfaceBackdrop.tsx +24 -0
- package/{view/components/InterfaceViewDialog.jsx → src/view/components/InterfaceViewDialog.tsx} +11 -11
- package/src/view/components/InterfaceViewLine.tsx +27 -0
- package/src/view/components/InterfaceViewWall.tsx +93 -0
- package/src/view/components/index.ts +4 -0
- package/{view/components/tokens.hook.jsx → src/view/components/tokens.hook.ts} +8 -10
- package/src/view/index.tsx +69 -0
- package/tsconfig.json +10 -0
- package/const/events.js +0 -31
- package/const/params.js +0 -37
- package/index.js +0 -10
- package/modules/view.js +0 -14
- package/view/components/InterfaceBackdrop.jsx +0 -22
- package/view/components/InterfaceViewLine.jsx +0 -25
- package/view/components/InterfaceViewWall.jsx +0 -65
- package/view/components/index.js +0 -4
- package/view/index.jsx +0 -65
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
2
|
-
|
|
3
|
-
import { Flex, PositionBox, SmoothText } from "@vnejs/uis.react";
|
|
4
|
-
|
|
5
|
-
import { useTokensHook } from "./tokens.hook";
|
|
6
|
-
|
|
7
|
-
export const InterfaceViewLine = (props = {}) => {
|
|
8
|
-
const { isShow = false, transition = 0, tokensVisible = 0, tokens = [], opacity, color, uid = "" } = props;
|
|
9
|
-
|
|
10
|
-
const propsByView = props.PARAMS.INTERFACE.VIEW_PROPS.line;
|
|
11
|
-
|
|
12
|
-
const { realTokens, realTokensVisible } = useTokensHook(isShow, tokens, tokensVisible, uid);
|
|
13
|
-
|
|
14
|
-
const propsTextTokens = useMemo(() => ({ tokens: realTokens, tokensVisibleForce: realTokensVisible }), [realTokens, realTokensVisible]);
|
|
15
|
-
const propsText = useMemo(() => ({ ...propsByView.text, opacity, color, transition, ...propsTextTokens }), [opacity, color, transition, propsTextTokens]);
|
|
16
|
-
const propsPosition = useMemo(() => ({ ...propsByView.position, opacity: isShow ? 1 : 0, transition }), [isShow, transition]);
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<PositionBox {...propsPosition}>
|
|
20
|
-
<Flex {...propsByView.flex}>
|
|
21
|
-
<SmoothText {...propsText} />
|
|
22
|
-
</Flex>
|
|
23
|
-
</PositionBox>
|
|
24
|
-
);
|
|
25
|
-
};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
2
|
-
|
|
3
|
-
import { Flex, PositionBox, Scrollbar, ScrollContent, SmoothText, Text } from "@vnejs/uis.react";
|
|
4
|
-
|
|
5
|
-
import { useTokensHook } from "./tokens.hook";
|
|
6
|
-
|
|
7
|
-
const renderOneText = (wallElement) => (
|
|
8
|
-
<div key={wallElement.uid}>
|
|
9
|
-
{wallElement.speakerName && (
|
|
10
|
-
<Text
|
|
11
|
-
{...wallElement.propsByView.text}
|
|
12
|
-
isInlineBlock={true}
|
|
13
|
-
color={wallElement.speakerColor}
|
|
14
|
-
text={`${wallElement.speakerName}:`}
|
|
15
|
-
marginRight={12}
|
|
16
|
-
/>
|
|
17
|
-
)}
|
|
18
|
-
<SmoothText
|
|
19
|
-
{...wallElement.propsByView.text}
|
|
20
|
-
isNoScrollBar={true}
|
|
21
|
-
color={wallElement.color}
|
|
22
|
-
opacity={wallElement.opacity}
|
|
23
|
-
transition={wallElement.transition}
|
|
24
|
-
tokens={wallElement.tokens}
|
|
25
|
-
tokensVisibleForce={wallElement.tokensVisible}
|
|
26
|
-
/>
|
|
27
|
-
</div>
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
const mapWall = ({ uid = "", tokens = [], speaker = "", meet = 0, transition = 0, props } = {}) => {
|
|
31
|
-
const propsByView = props.PARAMS.INTERFACE.VIEW_PROPS.wall;
|
|
32
|
-
const speakerInfo = props.PARAMS.TEXT.SPEAKERS_INFO[speaker] || props.PARAMS.TEXT.SPEAKERS_INFO.default || {};
|
|
33
|
-
const { color, opacity = 1, names = {}, speakerColor = "white" } = speakerInfo;
|
|
34
|
-
|
|
35
|
-
const langNames = names[props.shared.lang] || names.default || [];
|
|
36
|
-
const speakerName = langNames[meet] || langNames[langNames.length - 1];
|
|
37
|
-
|
|
38
|
-
return { speakerName, speakerColor, uid, color, opacity, tokens, tokensVisible: tokens.length, transition, propsByView };
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const InterfaceViewWall = (props = {}) => {
|
|
42
|
-
const { isShow = false, transition = 0, tokensVisible = 0, tokens = [], wall = [], uid = "", speakerName, speakerColor, color, opacity } = props;
|
|
43
|
-
|
|
44
|
-
const propsByView = props.PARAMS.INTERFACE.VIEW_PROPS.wall;
|
|
45
|
-
|
|
46
|
-
const propsPosition = useMemo(() => ({ ...propsByView.position, opacity: isShow ? 1 : 0, transition }), [isShow, transition]);
|
|
47
|
-
const wallWithProps = useMemo(() => wall.map((item) => ({ ...item, transition, props })), [wall, transition]);
|
|
48
|
-
|
|
49
|
-
const { realTokens, realTokensVisible } = useTokensHook(isShow, tokens, tokensVisible, uid);
|
|
50
|
-
|
|
51
|
-
const wallTexts = useMemo(() => wallWithProps.map(mapWall), [wallWithProps]);
|
|
52
|
-
const curText = useMemo(
|
|
53
|
-
() => ({ speakerName, speakerColor, uid, color, opacity, tokens: realTokens, tokensVisible: realTokensVisible, transition, propsByView }),
|
|
54
|
-
[uid, realTokens, realTokensVisible, transition],
|
|
55
|
-
);
|
|
56
|
-
const texts = useMemo(() => [...wallTexts, curText], [wallTexts, curText]);
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<PositionBox {...propsPosition}>
|
|
60
|
-
<Scrollbar {...propsByView.scrollBar}>
|
|
61
|
-
<Flex {...propsByView.flex}>{texts.map(renderOneText)}</Flex>
|
|
62
|
-
</Scrollbar>
|
|
63
|
-
</PositionBox>
|
|
64
|
-
);
|
|
65
|
-
};
|
package/view/components/index.js
DELETED
package/view/index.jsx
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
|
-
import { createRoot } from "react-dom/client";
|
|
3
|
-
|
|
4
|
-
import { Screen, useIsForceHook } from "@vnejs/uis.react";
|
|
5
|
-
|
|
6
|
-
import { InterfaceBackdrop, InterfaceViewDialog, InterfaceViewLine, InterfaceViewWall } from "./components";
|
|
7
|
-
|
|
8
|
-
const EMPTY_ARRAY = [];
|
|
9
|
-
|
|
10
|
-
const Interface = ({ store, onMount, ...props } = {}) => {
|
|
11
|
-
const [state, setState] = useState({});
|
|
12
|
-
|
|
13
|
-
const { isShow = false, isVisible = false, isForce = false, tokensVisible = 0, view = "", locs = {} } = state;
|
|
14
|
-
const { speaker, meet = 0, tokens = EMPTY_ARRAY, wall = [], postfix = "", prefix = "", uid = "" } = state;
|
|
15
|
-
|
|
16
|
-
const onClick = useCallback(() => props.emit(props.EVENTS.INTERFACE.INTERACT), []);
|
|
17
|
-
|
|
18
|
-
useEffect(() => store.subscribe(setState), []);
|
|
19
|
-
useEffect(() => void onMount(), []);
|
|
20
|
-
|
|
21
|
-
const isRealForce = useIsForceHook(isForce);
|
|
22
|
-
|
|
23
|
-
const speakerName = locs[`speaker.${speaker}.${meet ?? 0}`];
|
|
24
|
-
const speakerText = speakerName ? `${`${locs[`prefix.${prefix}`] ?? ""} `}${speakerName}${` ${locs[`postfix.${postfix}`] ?? ""}`}` : ".";
|
|
25
|
-
const transition = isRealForce ? 0 : props.PARAMS.INTERFACE.TRANSITION;
|
|
26
|
-
const speakerInfo = props.PARAMS.TEXT.SPEAKERS_INFO[speaker] || props.PARAMS.TEXT.SPEAKERS_INFO[props.PARAMS.TEXT.DEFAULT_SPEAKER_NAME];
|
|
27
|
-
|
|
28
|
-
console.log(99999999, speaker, speakerInfo, props.PARAMS.TEXT.DEFAULT_SPEAKER_NAME, props.PARAMS.TEXT.SPEAKERS_INFO);
|
|
29
|
-
|
|
30
|
-
const { color, opacity = 1, speakerColor = "white" } = speakerInfo;
|
|
31
|
-
|
|
32
|
-
const propsCommon = useMemo(
|
|
33
|
-
() => ({ isForce: isRealForce, transition, tokensVisible, tokens, wall, uid }),
|
|
34
|
-
[isRealForce, transition, tokensVisible, tokens, wall, uid],
|
|
35
|
-
);
|
|
36
|
-
const propsSpeaker = useMemo(() => ({ speakerText, speakerName, speakerColor }), [speakerText, speakerName, speakerColor]);
|
|
37
|
-
const propsText = useMemo(() => ({ opacity, color }), [opacity, color]);
|
|
38
|
-
const propsView = useMemo(() => ({ ...propsCommon, ...propsSpeaker, ...propsText }), [propsCommon, propsSpeaker, propsText]);
|
|
39
|
-
|
|
40
|
-
const propsBackdrop = useMemo(() => ({ view, transition, ...props }), [view, transition]);
|
|
41
|
-
const propsDialog = useMemo(() => ({ isShow: view === "adv", ...propsView, ...props }), [view, propsView]);
|
|
42
|
-
const propsLine = useMemo(() => ({ isShow: view === "line", ...propsView, ...props }), [view, propsView]);
|
|
43
|
-
const propsWall = useMemo(() => ({ isShow: view === "wall", ...propsView, ...props }), [view, propsView]);
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<Screen
|
|
47
|
-
isShow={isShow}
|
|
48
|
-
isForce={isRealForce}
|
|
49
|
-
isHidden={!isVisible}
|
|
50
|
-
isDisableAutoread={false}
|
|
51
|
-
isAllowAutoread={Boolean(isShow && isVisible)}
|
|
52
|
-
isIgnoreOnScreenshot={false}
|
|
53
|
-
transition={transition}
|
|
54
|
-
zIndex={props.PARAMS.INTERFACE.ZINDEX}
|
|
55
|
-
onClick={onClick}
|
|
56
|
-
>
|
|
57
|
-
<InterfaceBackdrop {...propsBackdrop} />
|
|
58
|
-
<InterfaceViewDialog {...propsDialog} />
|
|
59
|
-
<InterfaceViewLine {...propsLine} />
|
|
60
|
-
<InterfaceViewWall {...propsWall} />
|
|
61
|
-
</Screen>
|
|
62
|
-
);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export const render = (props, root) => createRoot(root).render(<Interface {...props} />);
|