@vnejs/plugins.views.scenario.interface 0.1.16 → 0.1.18

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.
@@ -1,11 +1,12 @@
1
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, InterfaceTextChangedPayload, InterfaceViewPayload } from "../utils/interface.js";
3
+ import type { InterfaceForcePayload, InterfaceModuleState, InterfaceSpeakerChangedPayload, InterfaceTextChangedPayload, InterfaceViewPayload } from "../utils/interface.js";
4
+ import type { LineExecHandlerArg } from "@vnejs/plugins.core.scenario.contract";
4
5
  export declare class Interface extends Module<InterfacePluginEvents, InterfacePluginConstants, InterfacePluginSettings, InterfacePluginParams, InterfaceModuleState> {
5
6
  name: string;
6
7
  subscribe: () => void;
7
8
  init: () => Promise<unknown[]> | undefined;
8
- onLineExec: ({ line }?: InterfaceLineExecPayload) => Promise<void>;
9
+ onLineExec: ({ line }?: LineExecHandlerArg) => Promise<void>;
9
10
  onInteract: () => Promise<unknown[]> | undefined;
10
11
  onShow: ({ isForce }?: InterfaceForcePayload) => false | Promise<unknown[] | undefined>;
11
12
  onHide: ({ isForce }?: InterfaceForcePayload) => false | Promise<unknown[] | undefined>;
@@ -14,9 +14,6 @@ export type InterfacePluginState = ModuleControllerState & InterfaceModuleState
14
14
  color?: string;
15
15
  opacity?: number;
16
16
  };
17
- export type InterfaceLineExecPayload = {
18
- line?: string;
19
- };
20
17
  export type InterfaceForcePayload = {
21
18
  isForce?: boolean;
22
19
  };
@@ -6,7 +6,7 @@ export const useTokensHook = (isShow, tokens, tokensVisible, uid) => {
6
6
  useEffect(() => {
7
7
  if (isShow)
8
8
  setTokensWrong(tokens);
9
- }, [isShow, tokens]);
9
+ }, [isShow]);
10
10
  useEffect(() => {
11
11
  setTimeout(() => {
12
12
  if (savedUid === uid) {
@@ -22,7 +22,7 @@ export const useTokensHook = (isShow, tokens, tokensVisible, uid) => {
22
22
  setTokensSync(tokens);
23
23
  });
24
24
  }, 0);
25
- }, [tokens, savedUid, uid, isShow]);
25
+ }, [tokens]);
26
26
  const isShowTokens = useMemo(() => tokensSync !== tokensWrong, [tokensSync, tokensWrong]);
27
27
  const realTokensVisible = useMemo(() => (isShowTokens ? tokensVisible : 0), [isShowTokens, tokensVisible]);
28
28
  const realTokens = useMemo(() => (isShowTokens ? tokensSync : []), [isShowTokens, tokensSync]);
@@ -17,11 +17,11 @@ const Interface = (props) => {
17
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
- const propsView = useMemo(() => ({ ...propsCommon, ...propsSpeaker, ...propsText }), [propsCommon, propsSpeaker, propsText]);
20
+ const propsView = useMemo(() => ({ isShow, ...propsCommon, ...propsSpeaker, ...propsText }), [isShow, propsCommon, propsSpeaker, propsText]);
21
21
  const propsBackdrop = useMemo(() => ({ view, transition, ...props }), [view, transition, props]);
22
- const propsDialog = useMemo(() => ({ isViewActive: view === "adv", ...propsView, ...props }), [view, propsView, props]);
23
- const propsLine = useMemo(() => ({ isViewActive: view === "line", ...propsView, ...props }), [view, propsView, props]);
24
- const propsWall = useMemo(() => ({ isViewActive: view === "wall", ...propsView, ...props }), [view, propsView, props]);
22
+ const propsDialog = useMemo(() => ({ view, isViewActive: view === "adv", ...propsView, ...props }), [view, propsView, props]);
23
+ const propsLine = useMemo(() => ({ view, isViewActive: view === "line", ...propsView, ...props }), [view, propsView, props]);
24
+ const propsWall = useMemo(() => ({ view, isViewActive: view === "wall", ...propsView, ...props }), [view, propsView, props]);
25
25
  return (_jsxs(Screen, { isShow: isShow, isForce: isRealForce, isHidden: !isVisible, isDisableAutoread: false, isAllowAutoread: Boolean(isShow && isVisible), isIgnoreOnScreenshot: false, transition: transition, zIndex: PARAMS.INTERFACE.ZINDEX, onClick: onClick, children: [_jsx(InterfaceBackdrop, { ...propsBackdrop }), _jsx(InterfaceViewDialog, { ...propsDialog }), _jsx(InterfaceViewLine, { ...propsLine }), _jsx(InterfaceViewWall, { ...propsWall })] }));
26
26
  };
27
27
  export const render = createRenderFunc(Interface);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.views.scenario.interface",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -4,12 +4,12 @@ import { tokenizeExecLine } from "@vnejs/helpers";
4
4
  import type { InterfacePluginConstants, InterfacePluginEvents, InterfacePluginParams, InterfacePluginSettings } from "../types.js";
5
5
  import type {
6
6
  InterfaceForcePayload,
7
- InterfaceLineExecPayload,
8
7
  InterfaceModuleState,
9
8
  InterfaceSpeakerChangedPayload,
10
9
  InterfaceTextChangedPayload,
11
10
  InterfaceViewPayload,
12
11
  } from "../utils/interface.js";
12
+ import type { LineExecHandlerArg } from "@vnejs/plugins.core.scenario.contract";
13
13
 
14
14
  export class Interface extends Module<InterfacePluginEvents, InterfacePluginConstants, InterfacePluginSettings, InterfacePluginParams, InterfaceModuleState> {
15
15
  name = "interface";
@@ -32,7 +32,7 @@ export class Interface extends Module<InterfacePluginEvents, InterfacePluginCons
32
32
 
33
33
  init = () => this.emit(this.EVENTS.SCENARIO.LINE_EXEC_REG, { module: this.name, handler: this.onLineExec });
34
34
 
35
- onLineExec = async ({ line = "" }: InterfaceLineExecPayload = {}) => {
35
+ onLineExec = async ({ line = "" }: LineExecHandlerArg = {}) => {
36
36
  const isForce = Boolean(this.shared.viewForceAnimationSources.length);
37
37
 
38
38
  const [action = "", execArg = ""] = tokenizeExecLine(line);
@@ -18,10 +18,6 @@ export type InterfacePluginState = ModuleControllerState &
18
18
  opacity?: number;
19
19
  };
20
20
 
21
- export type InterfaceLineExecPayload = {
22
- line?: string;
23
- };
24
-
25
21
  export type InterfaceForcePayload = {
26
22
  isForce?: boolean;
27
23
  };
@@ -8,7 +8,7 @@ export const useTokensHook = (isShow: boolean, tokens: TokenizedChar[], tokensVi
8
8
 
9
9
  useEffect(() => {
10
10
  if (isShow) setTokensWrong(tokens);
11
- }, [isShow, tokens]);
11
+ }, [isShow]);
12
12
  useEffect(() => {
13
13
  setTimeout(() => {
14
14
  if (savedUid === uid) {
@@ -22,7 +22,7 @@ export const useTokensHook = (isShow: boolean, tokens: TokenizedChar[], tokensVi
22
22
  setTokensSync(tokens);
23
23
  });
24
24
  }, 0);
25
- }, [tokens, savedUid, uid, isShow]);
25
+ }, [tokens]);
26
26
 
27
27
  const isShowTokens = useMemo(() => tokensSync !== tokensWrong, [tokensSync, tokensWrong]);
28
28
  const realTokensVisible = useMemo(() => (isShowTokens ? tokensVisible : 0), [isShowTokens, tokensVisible]);
@@ -40,12 +40,12 @@ const Interface = (props: InterfaceComponentProps) => {
40
40
  );
41
41
  const propsSpeaker = useMemo(() => ({ speakerText, speakerName, speakerColor }), [speakerText, speakerName, speakerColor]);
42
42
  const propsText = useMemo(() => ({ opacity, color }), [opacity, color]);
43
- const propsView = useMemo(() => ({ ...propsCommon, ...propsSpeaker, ...propsText }), [propsCommon, propsSpeaker, propsText]);
43
+ const propsView = useMemo(() => ({ isShow, ...propsCommon, ...propsSpeaker, ...propsText }), [isShow, propsCommon, propsSpeaker, propsText]);
44
44
 
45
45
  const propsBackdrop = useMemo(() => ({ view, transition, ...props }), [view, transition, props]);
46
- const propsDialog = useMemo(() => ({ isViewActive: view === "adv", ...propsView, ...props }), [view, propsView, props]);
47
- const propsLine = useMemo(() => ({ isViewActive: view === "line", ...propsView, ...props }), [view, propsView, props]);
48
- const propsWall = useMemo(() => ({ isViewActive: view === "wall", ...propsView, ...props }), [view, propsView, props]);
46
+ const propsDialog = useMemo(() => ({ view, isViewActive: view === "adv", ...propsView, ...props }), [view, propsView, props]);
47
+ const propsLine = useMemo(() => ({ view, isViewActive: view === "line", ...propsView, ...props }), [view, propsView, props]);
48
+ const propsWall = useMemo(() => ({ view, isViewActive: view === "wall", ...propsView, ...props }), [view, propsView, props]);
49
49
 
50
50
  return (
51
51
  <Screen