@vnejs/plugins.views.scenario.interface.fastforward 0.1.2 → 0.1.4

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.
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ import { regPlugin } from "@vnejs/shared";
2
+ import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/plugins.views.scenario.interface.fastforward.contract";
3
+ import { InterfaceFastForwardController } from "./modules/controller.js";
4
+ import { InterfaceFastForwardView } from "./modules/view.js";
5
+ regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS }, [InterfaceFastForwardController, InterfaceFastForwardView]);
@@ -0,0 +1,29 @@
1
+ import { ModuleController } from "@vnejs/module.components";
2
+ import type { InterfaceFastforwardPluginConstants, InterfaceFastforwardPluginEvents, InterfaceFastforwardPluginParams, InterfaceFastforwardPluginSettings } from "../types.js";
3
+ import type { FastforwardChangedPayload, InterfaceFastforwardDisableAnimationPayload, InterfaceFastforwardForcePayload, InterfaceFastforwardPluginState } from "../utils/interface.fastforward.js";
4
+ export declare class InterfaceFastForwardController extends ModuleController<InterfaceFastforwardPluginEvents, InterfaceFastforwardPluginConstants, InterfaceFastforwardPluginSettings, InterfaceFastforwardPluginParams, InterfaceFastforwardPluginState> {
5
+ name: string;
6
+ updateEvent: "vne:interface_fastforward:update";
7
+ controls: {
8
+ abstract_fastforward_toggle: () => undefined;
9
+ abstract_fastforward_start: () => undefined;
10
+ abstract_fastforward_finish: () => undefined;
11
+ };
12
+ controlsUnvisible: {};
13
+ controlsCheckNext: boolean;
14
+ controlsIndex: number;
15
+ subscribe: () => void;
16
+ beforeShow: () => Promise<void>;
17
+ onClick: () => false | Promise<unknown[]> | undefined;
18
+ onShowChanged: ({ isForce }?: InterfaceFastforwardForcePayload) => Promise<unknown[]> | undefined;
19
+ onViewChanged: ({ isForce }?: InterfaceFastforwardForcePayload) => Promise<unknown[]> | undefined;
20
+ onVisibleChanged: ({ isForce }?: InterfaceFastforwardForcePayload) => Promise<unknown[]> | undefined;
21
+ onStateChanged: () => Promise<unknown[]> | undefined;
22
+ onFastForward: ({ value }?: FastforwardChangedPayload) => false | Promise<unknown[]> | undefined;
23
+ onDisableAnimation: ({ isDisabled }?: InterfaceFastforwardDisableAnimationPayload) => Promise<unknown[]> | undefined;
24
+ onMemoryCleared: () => Promise<unknown[] | undefined>;
25
+ toggleUnvisibleControls: (isVisible: boolean) => Promise<unknown[]> | undefined;
26
+ emitFastforwardEvent: (event: string) => Promise<unknown[]> | undefined;
27
+ getIconSrc: () => Promise<string>;
28
+ getDefaultState: () => InterfaceFastforwardPluginState;
29
+ }
@@ -0,0 +1,64 @@
1
+ import { ModuleController } from "@vnejs/module.components";
2
+ export class InterfaceFastForwardController extends ModuleController {
3
+ name = "interface.fastforward.controller";
4
+ updateEvent = this.EVENTS.INTERFACE_FASTFORWARD_VIEW.UPDATE;
5
+ controls = {
6
+ [this.CONST.CONTROLS.BUTTONS.FASTFORWARD_TOGGLE]: () => void this.emitFastforwardEvent(this.EVENTS.FASTFORWARD.TOGGLE),
7
+ [this.CONST.CONTROLS.BUTTONS.FASTFORWARD_START]: () => void this.emitFastforwardEvent(this.EVENTS.FASTFORWARD.START),
8
+ [this.CONST.CONTROLS.BUTTONS.FASTFORWARD_FINISH]: () => void this.emitFastforwardEvent(this.EVENTS.FASTFORWARD.STOP),
9
+ };
10
+ controlsUnvisible = {};
11
+ controlsCheckNext = true;
12
+ controlsIndex = this.PARAMS.INTERFACE.ZINDEX + 200;
13
+ subscribe = () => {
14
+ this.on(this.EVENTS.INTERFACE_FASTFORWARD_VIEW.SHOW, this.onShow);
15
+ this.on(this.EVENTS.INTERFACE_FASTFORWARD_VIEW.HIDE, this.onHide);
16
+ this.on(this.EVENTS.INTERFACE_FASTFORWARD_VIEW.CLICK, this.onClick);
17
+ this.on(this.EVENTS.INTERFACE_FASTFORWARD_VIEW.DISABLE_ANIMATION, this.onDisableAnimation);
18
+ this.on(this.EVENTS.INTERFACE.SHOW_CHANGED, this.onShowChanged);
19
+ this.on(this.EVENTS.INTERFACE.VIEW_CHANGED, this.onViewChanged);
20
+ this.on(this.EVENTS.INTERFACE.STATE_CHANGED, this.onStateChanged);
21
+ this.on(this.EVENTS.INTERFACE.VISIBLE_CHANGED, this.onVisibleChanged);
22
+ this.on(this.EVENTS.FASTFORWARD.CHANGED, this.onFastForward);
23
+ this.on(this.EVENTS.SYSTEM.STARTED, this.getIconSrc);
24
+ this.on(this.EVENTS.MEMORY.CLEARED, this.onMemoryCleared);
25
+ };
26
+ beforeShow = async () => this.updateState({ iconSrc: await this.getIconSrc() });
27
+ onClick = () => {
28
+ const { isShow = false, isVisible = false } = this.globalState.interface;
29
+ return isShow && isVisible && this.emitFastforwardEvent(this.EVENTS.FASTFORWARD.TOGGLE);
30
+ };
31
+ onShowChanged = ({ isForce = false } = {}) => {
32
+ const { isShow = false } = this.globalState.interface;
33
+ const event = isShow ? this.EVENTS.INTERFACE_FASTFORWARD_VIEW.SHOW : this.EVENTS.INTERFACE_FASTFORWARD_VIEW.HIDE;
34
+ if (this.state.isShow !== isShow)
35
+ return this.emit(event, { isForce });
36
+ };
37
+ onViewChanged = ({ isForce = false } = {}) => {
38
+ const { view = "" } = this.globalState.interface;
39
+ if (this.state.view !== view)
40
+ return this.updateStateAndView({ view }, isForce, !isForce);
41
+ };
42
+ onVisibleChanged = ({ isForce = false } = {}) => {
43
+ const { isVisible = false } = this.globalState.interface;
44
+ this.toggleUnvisibleControls(isVisible);
45
+ if (this.state.isVisible !== isVisible)
46
+ return this.updateStateAndView({ isVisible }, isForce, !isForce);
47
+ };
48
+ onStateChanged = () => {
49
+ const { isShow = false, isVisible = false, view = "" } = this.globalState.interface;
50
+ this.toggleUnvisibleControls(isVisible);
51
+ return this.updateStateAndViewForce({ isVisible, isShow, view });
52
+ };
53
+ onFastForward = ({ value } = {}) => this.isReady && this.updateStateAndViewFast({ isActive: value });
54
+ onDisableAnimation = ({ isDisabled = false } = {}) => this.updateStateAndViewFast({ isAnimationDisabled: isDisabled });
55
+ onMemoryCleared = async () => this.updateStateAndViewFast({ iconSrc: await this.getIconSrc() });
56
+ toggleUnvisibleControls = (isVisible) => {
57
+ if (isVisible)
58
+ return this.emit(this.EVENTS.CONTROLS.POP, { key: `${this.name}-unvisible` });
59
+ return this.emit(this.EVENTS.CONTROLS.PUSH, { key: `${this.name}-unvisible`, controls: this.controlsUnvisible, index: this.controlsIndex + 500 });
60
+ };
61
+ emitFastforwardEvent = (event) => this.emit(this.globalState.interface.isVisible ? event : this.EVENTS.INTERFACE.VISIBLE);
62
+ getIconSrc = async () => (await this.loadImageMedia("interface/fastforward", "icons", this.shared.settings[this.SETTINGS.LAYER.QUALITY])).src;
63
+ getDefaultState = () => ({ isActive: false, isVisible: false, isShow: false, isAnimationDisabled: false, isForce: false });
64
+ }
@@ -0,0 +1,10 @@
1
+ import { ModuleView } from "@vnejs/module.components";
2
+ import type { InterfaceFastforwardPluginConstants, InterfaceFastforwardPluginEvents, InterfaceFastforwardPluginParams, InterfaceFastforwardPluginSettings } from "../types.js";
3
+ import type { InterfaceFastforwardPluginState } from "../utils/interface.fastforward.js";
4
+ export declare class InterfaceFastForwardView extends ModuleView<InterfaceFastforwardPluginEvents, InterfaceFastforwardPluginConstants, InterfaceFastforwardPluginSettings, InterfaceFastforwardPluginParams, InterfaceFastforwardPluginState> {
5
+ name: string;
6
+ animationTime: number;
7
+ updateEvent: "vne:interface_fastforward:update";
8
+ renderFunc: import("@vnejs/module.components").ViewRenderFunc<InterfaceFastforwardPluginState>;
9
+ updateHandler: (state?: InterfaceFastforwardPluginState | undefined) => Promise<void>;
10
+ }
@@ -0,0 +1,9 @@
1
+ import { ModuleView } from "@vnejs/module.components";
2
+ import { render } from "../view/index.js";
3
+ export class InterfaceFastForwardView extends ModuleView {
4
+ name = "interface.fastforward.view";
5
+ animationTime = this.PARAMS.INTERFACE.TRANSITION;
6
+ updateEvent = this.EVENTS.INTERFACE_FASTFORWARD_VIEW.UPDATE;
7
+ renderFunc = render;
8
+ updateHandler = this.onUpdateStoreComponent;
9
+ }
@@ -0,0 +1,12 @@
1
+ import type { ModuleComponentsConstants, ModuleComponentsEvents, ModuleComponentsParams, ModuleComponentsSettings } from "@vnejs/module.components";
2
+ import type { SettingsKeys as LayerSettingsKeys, PluginName as LayerPluginName } from "@vnejs/plugins.canvas.layer.contract";
3
+ import type { Constants as ControlsConstants, PluginName as ControlsPluginName, SubscribeEvents as ControlsSubscribeEvents } from "@vnejs/plugins.controls.contract";
4
+ import type { PluginName as MemoryPluginName, SubscribeEvents as MemorySubscribeEvents } from "@vnejs/plugins.core.memory.contract";
5
+ import type { PluginName as SystemPluginName, SubscribeEvents as SystemSubscribeEvents } from "@vnejs/plugins.core.system.contract";
6
+ import type { PluginName as FastforwardPluginName, SubscribeEvents as FastforwardSubscribeEvents } from "@vnejs/plugins.scenario.fastforward.contract";
7
+ import type { Params as InterfaceParams, PluginName as InterfacePluginName, SubscribeEvents as InterfaceSubscribeEvents } from "@vnejs/plugins.views.scenario.interface.contract";
8
+ import type { Params, PluginName, SubscribeEvents } from "@vnejs/plugins.views.scenario.interface.fastforward.contract";
9
+ export type InterfaceFastforwardPluginEvents = ModuleComponentsEvents & Record<PluginName, SubscribeEvents> & Record<InterfacePluginName, InterfaceSubscribeEvents> & Record<FastforwardPluginName, FastforwardSubscribeEvents> & Record<ControlsPluginName, ControlsSubscribeEvents> & Record<SystemPluginName, Pick<SystemSubscribeEvents, "STARTED">> & Record<MemoryPluginName, MemorySubscribeEvents>;
10
+ export type InterfaceFastforwardPluginConstants = ModuleComponentsConstants & Record<ControlsPluginName, ControlsConstants>;
11
+ export type InterfaceFastforwardPluginSettings = ModuleComponentsSettings & Record<LayerPluginName, LayerSettingsKeys>;
12
+ export type InterfaceFastforwardPluginParams = ModuleComponentsParams & Record<PluginName, Params> & Record<InterfacePluginName, InterfaceParams>;
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ import type { FastforwardChangedPayload } from "@vnejs/plugins.scenario.fastforward.contract";
2
+ export type InterfaceFastforwardPluginState = {
3
+ isActive: boolean;
4
+ isVisible: boolean;
5
+ isShow: boolean;
6
+ isAnimationDisabled: boolean;
7
+ isForce: boolean;
8
+ view?: string;
9
+ iconSrc?: string;
10
+ };
11
+ export type InterfaceFastforwardForcePayload = {
12
+ isForce?: boolean;
13
+ };
14
+ export type InterfaceFastforwardDisableAnimationPayload = {
15
+ isDisabled?: boolean;
16
+ };
17
+ export type { FastforwardChangedPayload };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { ViewRenderFunc } from "@vnejs/module.components";
2
+ import type { InterfaceFastforwardPluginState } from "../utils/interface.fastforward.js";
3
+ export declare const render: ViewRenderFunc<InterfaceFastforwardPluginState>;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Icon, View, createRenderFunc, useCallback, useIsForceHook, useMemo, useStoreState } from "@vnejs/uis.react";
3
+ import { b } from "./index.styles.js";
4
+ const InterfaceFastForward = ({ store, onMount, emit, EVENTS, PARAMS }) => {
5
+ const { isShow = false, isVisible = false, isForce = false, isActive = false, isAnimationDisabled = false, view = "", iconSrc = "", } = useStoreState(store, onMount);
6
+ const onClick = useCallback(() => emit(EVENTS.INTERFACE_FASTFORWARD_VIEW.CLICK), [emit, EVENTS.INTERFACE_FASTFORWARD_VIEW.CLICK]);
7
+ const isRealForce = useIsForceHook(isForce);
8
+ const transition = isRealForce ? 0 : PARAMS.INTERFACE.TRANSITION;
9
+ const propsByView = useMemo(() => PARAMS.INTERFACE_FASTFORWARD_VIEW.VIEW_PROPS[view], [view, PARAMS.INTERFACE_FASTFORWARD_VIEW.VIEW_PROPS]);
10
+ const propsIcon = useMemo(() => ({ ...propsByView?.icon, src: iconSrc, transition }), [propsByView, iconSrc, transition]);
11
+ const propsView = useMemo(() => ({ ...propsByView?.view, isShow, isForce: isRealForce, transition, onClick }), [propsByView, isShow, isRealForce, transition, onClick]);
12
+ return (_jsx(View, { ...propsView, className: b({ isAnimated: isActive && !isAnimationDisabled }), isHidden: !isVisible, zIndex: PARAMS.INTERFACE.ZINDEX + 200, children: _jsx(Icon, { ...propsIcon }) }));
13
+ };
14
+ export const render = createRenderFunc(InterfaceFastForward);
@@ -0,0 +1 @@
1
+ export declare const b: import("@bem-react/classname").ClassNameFormatter;
@@ -0,0 +1,25 @@
1
+ import { cn, injectStyles, sel } from "@vnejs/uis.utils";
2
+ export const b = cn("InterfaceFastForward");
3
+ const CSS = `
4
+ @keyframes fastforward {
5
+ from {
6
+ transform: scale(1.1);
7
+ }
8
+
9
+ 50% {
10
+ transform: scale(0.9);
11
+ }
12
+
13
+ to {
14
+ transform: scale(1.1);
15
+ }
16
+ }
17
+
18
+ ${sel(b({ isAnimated: true }))} {
19
+ animation-duration: 500ms;
20
+ animation-name: fastforward;
21
+ animation-iteration-count: infinite;
22
+ animation-timing-function: ease-in-out;
23
+ }
24
+ `;
25
+ injectStyles(CSS);
package/package.json CHANGED
@@ -1,17 +1,52 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.views.scenario.interface.fastforward",
3
- "version": "0.1.2",
4
- "main": "index.js",
3
+ "version": "0.1.4",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "src",
18
+ "tsconfig.json"
19
+ ],
5
20
  "scripts": {
6
21
  "test": "echo \"Error: no test specified\" && exit 1",
22
+ "build": "npx @vnejs/monorepo package",
7
23
  "publish:major:plugin": "npm run publish:major",
8
24
  "publish:minor:plugin": "npm run publish:minor",
9
25
  "publish:patch:plugin": "npm run publish:patch",
10
- "publish:major": "npm version major && npm publish --access public",
11
- "publish:minor": "npm version minor && npm publish --access public",
12
- "publish:patch": "npm version patch && npm publish --access public"
26
+ "publish:major": "npx @vnejs/monorepo publish major --access public",
27
+ "publish:minor": "npx @vnejs/monorepo publish minor --access public",
28
+ "publish:patch": "npx @vnejs/monorepo publish patch --access public"
13
29
  },
14
30
  "author": "",
15
31
  "license": "ISC",
16
- "description": ""
32
+ "dependencies": {
33
+ "@vnejs/plugins.views.scenario.interface.fastforward.contract": "~0.0.1",
34
+ "@vnejs/plugins.views.scenario.interface.contract": "~0.0.1"
35
+ },
36
+ "peerDependencies": {
37
+ "@vnejs/helpers": "~0.1.0",
38
+ "@vnejs/module": "~0.0.1",
39
+ "@vnejs/module.components": "~0.0.1",
40
+ "@vnejs/plugins.canvas.layer.contract": "~0.0.1",
41
+ "@vnejs/plugins.controls.contract": "~0.0.1",
42
+ "@vnejs/plugins.core.memory.contract": "~0.0.1",
43
+ "@vnejs/plugins.core.system.contract": "~0.0.1",
44
+ "@vnejs/plugins.scenario.fastforward.contract": "~0.0.1",
45
+ "@vnejs/shared": "~0.0.9",
46
+ "@vnejs/uis.react": "~0.1.0",
47
+ "@vnejs/uis.utils": "~0.1.0"
48
+ },
49
+ "devDependencies": {
50
+ "@vnejs/configs.ts-common": "~0.0.1"
51
+ }
17
52
  }
package/src/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { regPlugin } from "@vnejs/shared";
2
+ import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/plugins.views.scenario.interface.fastforward.contract";
3
+
4
+ import { InterfaceFastForwardController } from "./modules/controller.js";
5
+ import { InterfaceFastForwardView } from "./modules/view.js";
6
+
7
+ regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS }, [InterfaceFastForwardController, InterfaceFastForwardView]);
@@ -0,0 +1,110 @@
1
+ import { ModuleController } from "@vnejs/module.components";
2
+ import type { ControlsPopPayload, ControlsPushPayload } from "@vnejs/plugins.controls.contract";
3
+
4
+ import type {
5
+ InterfaceFastforwardPluginConstants,
6
+ InterfaceFastforwardPluginEvents,
7
+ InterfaceFastforwardPluginParams,
8
+ InterfaceFastforwardPluginSettings,
9
+ } from "../types.js";
10
+ import type {
11
+ FastforwardChangedPayload,
12
+ InterfaceFastforwardDisableAnimationPayload,
13
+ InterfaceFastforwardForcePayload,
14
+ InterfaceFastforwardPluginState,
15
+ } from "../utils/interface.fastforward.js";
16
+
17
+ export class InterfaceFastForwardController extends ModuleController<
18
+ InterfaceFastforwardPluginEvents,
19
+ InterfaceFastforwardPluginConstants,
20
+ InterfaceFastforwardPluginSettings,
21
+ InterfaceFastforwardPluginParams,
22
+ InterfaceFastforwardPluginState
23
+ > {
24
+ name = "interface.fastforward.controller";
25
+
26
+ updateEvent = this.EVENTS.INTERFACE_FASTFORWARD_VIEW.UPDATE;
27
+
28
+ controls = {
29
+ [this.CONST.CONTROLS.BUTTONS.FASTFORWARD_TOGGLE]: () => void this.emitFastforwardEvent(this.EVENTS.FASTFORWARD.TOGGLE),
30
+ [this.CONST.CONTROLS.BUTTONS.FASTFORWARD_START]: () => void this.emitFastforwardEvent(this.EVENTS.FASTFORWARD.START),
31
+ [this.CONST.CONTROLS.BUTTONS.FASTFORWARD_FINISH]: () => void this.emitFastforwardEvent(this.EVENTS.FASTFORWARD.STOP),
32
+ };
33
+ controlsUnvisible = {};
34
+ controlsCheckNext = true;
35
+ controlsIndex = this.PARAMS.INTERFACE.ZINDEX + 200;
36
+
37
+ subscribe = () => {
38
+ this.on(this.EVENTS.INTERFACE_FASTFORWARD_VIEW.SHOW, this.onShow);
39
+ this.on(this.EVENTS.INTERFACE_FASTFORWARD_VIEW.HIDE, this.onHide);
40
+ this.on(this.EVENTS.INTERFACE_FASTFORWARD_VIEW.CLICK, this.onClick);
41
+ this.on(this.EVENTS.INTERFACE_FASTFORWARD_VIEW.DISABLE_ANIMATION, this.onDisableAnimation);
42
+
43
+ this.on(this.EVENTS.INTERFACE.SHOW_CHANGED, this.onShowChanged);
44
+ this.on(this.EVENTS.INTERFACE.VIEW_CHANGED, this.onViewChanged);
45
+ this.on(this.EVENTS.INTERFACE.STATE_CHANGED, this.onStateChanged);
46
+ this.on(this.EVENTS.INTERFACE.VISIBLE_CHANGED, this.onVisibleChanged);
47
+
48
+ this.on(this.EVENTS.FASTFORWARD.CHANGED, this.onFastForward);
49
+
50
+ this.on(this.EVENTS.SYSTEM.STARTED, this.getIconSrc);
51
+ this.on(this.EVENTS.MEMORY.CLEARED, this.onMemoryCleared);
52
+ };
53
+
54
+ beforeShow = async () => this.updateState({ iconSrc: await this.getIconSrc() });
55
+
56
+ onClick = () => {
57
+ const { isShow = false, isVisible = false } = this.globalState.interface;
58
+
59
+ return isShow && isVisible && this.emitFastforwardEvent(this.EVENTS.FASTFORWARD.TOGGLE);
60
+ };
61
+
62
+ onShowChanged = ({ isForce = false }: InterfaceFastforwardForcePayload = {}) => {
63
+ const { isShow = false } = this.globalState.interface;
64
+ const event = isShow ? this.EVENTS.INTERFACE_FASTFORWARD_VIEW.SHOW : this.EVENTS.INTERFACE_FASTFORWARD_VIEW.HIDE;
65
+
66
+ if (this.state.isShow !== isShow) return this.emit(event, { isForce });
67
+ };
68
+
69
+ onViewChanged = ({ isForce = false }: InterfaceFastforwardForcePayload = {}) => {
70
+ const { view = "" } = this.globalState.interface;
71
+
72
+ if (this.state.view !== view) return this.updateStateAndView({ view }, isForce, !isForce);
73
+ };
74
+
75
+ onVisibleChanged = ({ isForce = false }: InterfaceFastforwardForcePayload = {}) => {
76
+ const { isVisible = false } = this.globalState.interface;
77
+
78
+ this.toggleUnvisibleControls(isVisible);
79
+
80
+ if (this.state.isVisible !== isVisible) return this.updateStateAndView({ isVisible }, isForce, !isForce);
81
+ };
82
+
83
+ onStateChanged = () => {
84
+ const { isShow = false, isVisible = false, view = "" } = this.globalState.interface;
85
+
86
+ this.toggleUnvisibleControls(isVisible);
87
+
88
+ return this.updateStateAndViewForce({ isVisible, isShow, view });
89
+ };
90
+
91
+ onFastForward = ({ value }: FastforwardChangedPayload = {}) => this.isReady && this.updateStateAndViewFast({ isActive: value });
92
+
93
+ onDisableAnimation = ({ isDisabled = false }: InterfaceFastforwardDisableAnimationPayload = {}) =>
94
+ this.updateStateAndViewFast({ isAnimationDisabled: isDisabled });
95
+
96
+ onMemoryCleared = async () => this.updateStateAndViewFast({ iconSrc: await this.getIconSrc() });
97
+
98
+ toggleUnvisibleControls = (isVisible: boolean) => {
99
+ if (isVisible) return this.emit(this.EVENTS.CONTROLS.POP, { key: `${this.name}-unvisible` });
100
+
101
+ return this.emit(this.EVENTS.CONTROLS.PUSH, { key: `${this.name}-unvisible`, controls: this.controlsUnvisible, index: this.controlsIndex + 500 });
102
+ };
103
+
104
+ emitFastforwardEvent = (event: string) => this.emit(this.globalState.interface.isVisible ? event : this.EVENTS.INTERFACE.VISIBLE);
105
+
106
+ getIconSrc = async () =>
107
+ (await this.loadImageMedia("interface/fastforward", "icons", this.shared.settings[this.SETTINGS.LAYER.QUALITY])).src;
108
+
109
+ getDefaultState = (): InterfaceFastforwardPluginState => ({ isActive: false, isVisible: false, isShow: false, isAnimationDisabled: false, isForce: false });
110
+ }
@@ -0,0 +1,21 @@
1
+ import { ModuleView } from "@vnejs/module.components";
2
+
3
+ import { render } from "../view/index.js";
4
+ import type { InterfaceFastforwardPluginConstants, InterfaceFastforwardPluginEvents, InterfaceFastforwardPluginParams, InterfaceFastforwardPluginSettings } from "../types.js";
5
+ import type { InterfaceFastforwardPluginState } from "../utils/interface.fastforward.js";
6
+
7
+ export class InterfaceFastForwardView extends ModuleView<
8
+ InterfaceFastforwardPluginEvents,
9
+ InterfaceFastforwardPluginConstants,
10
+ InterfaceFastforwardPluginSettings,
11
+ InterfaceFastforwardPluginParams,
12
+ InterfaceFastforwardPluginState
13
+ > {
14
+ name = "interface.fastforward.view";
15
+
16
+ animationTime = this.PARAMS.INTERFACE.TRANSITION;
17
+ updateEvent = this.EVENTS.INTERFACE_FASTFORWARD_VIEW.UPDATE;
18
+
19
+ renderFunc = render;
20
+ updateHandler = this.onUpdateStoreComponent;
21
+ }
package/src/types.ts ADDED
@@ -0,0 +1,24 @@
1
+ import type { ModuleComponentsConstants, ModuleComponentsEvents, ModuleComponentsParams, ModuleComponentsSettings } from "@vnejs/module.components";
2
+ import type { SettingsKeys as LayerSettingsKeys, PluginName as LayerPluginName } from "@vnejs/plugins.canvas.layer.contract";
3
+ import type { Constants as ControlsConstants, PluginName as ControlsPluginName, SubscribeEvents as ControlsSubscribeEvents } from "@vnejs/plugins.controls.contract";
4
+ import type { PluginName as MemoryPluginName, SubscribeEvents as MemorySubscribeEvents } from "@vnejs/plugins.core.memory.contract";
5
+ import type { PluginName as SystemPluginName, SubscribeEvents as SystemSubscribeEvents } from "@vnejs/plugins.core.system.contract";
6
+ import type { PluginName as FastforwardPluginName, SubscribeEvents as FastforwardSubscribeEvents } from "@vnejs/plugins.scenario.fastforward.contract";
7
+ import type { Params as InterfaceParams, PluginName as InterfacePluginName, SubscribeEvents as InterfaceSubscribeEvents } from "@vnejs/plugins.views.scenario.interface.contract";
8
+ import type { Params, PluginName, SubscribeEvents } from "@vnejs/plugins.views.scenario.interface.fastforward.contract";
9
+
10
+ export type InterfaceFastforwardPluginEvents = ModuleComponentsEvents &
11
+ Record<PluginName, SubscribeEvents> &
12
+ Record<InterfacePluginName, InterfaceSubscribeEvents> &
13
+ Record<FastforwardPluginName, FastforwardSubscribeEvents> &
14
+ Record<ControlsPluginName, ControlsSubscribeEvents> &
15
+ Record<SystemPluginName, Pick<SystemSubscribeEvents, "STARTED">> &
16
+ Record<MemoryPluginName, MemorySubscribeEvents>;
17
+
18
+ export type InterfaceFastforwardPluginConstants = ModuleComponentsConstants & Record<ControlsPluginName, ControlsConstants>;
19
+
20
+ export type InterfaceFastforwardPluginSettings = ModuleComponentsSettings & Record<LayerPluginName, LayerSettingsKeys>;
21
+
22
+ export type InterfaceFastforwardPluginParams = ModuleComponentsParams &
23
+ Record<PluginName, Params> &
24
+ Record<InterfacePluginName, InterfaceParams>;
@@ -0,0 +1,21 @@
1
+ import type { FastforwardChangedPayload } from "@vnejs/plugins.scenario.fastforward.contract";
2
+
3
+ export type InterfaceFastforwardPluginState = {
4
+ isActive: boolean;
5
+ isVisible: boolean;
6
+ isShow: boolean;
7
+ isAnimationDisabled: boolean;
8
+ isForce: boolean;
9
+ view?: string;
10
+ iconSrc?: string;
11
+ };
12
+
13
+ export type InterfaceFastforwardForcePayload = {
14
+ isForce?: boolean;
15
+ };
16
+
17
+ export type InterfaceFastforwardDisableAnimationPayload = {
18
+ isDisabled?: boolean;
19
+ };
20
+
21
+ export type { FastforwardChangedPayload };
@@ -0,0 +1,28 @@
1
+ import { cn, injectStyles, sel } from "@vnejs/uis.utils";
2
+
3
+ export const b = cn("InterfaceFastForward");
4
+
5
+ const CSS = `
6
+ @keyframes fastforward {
7
+ from {
8
+ transform: scale(1.1);
9
+ }
10
+
11
+ 50% {
12
+ transform: scale(0.9);
13
+ }
14
+
15
+ to {
16
+ transform: scale(1.1);
17
+ }
18
+ }
19
+
20
+ ${sel(b({ isAnimated: true }))} {
21
+ animation-duration: 500ms;
22
+ animation-name: fastforward;
23
+ animation-iteration-count: infinite;
24
+ animation-timing-function: ease-in-out;
25
+ }
26
+ `;
27
+
28
+ injectStyles(CSS);
@@ -0,0 +1,56 @@
1
+ import type { ViewRenderFunc } from "@vnejs/module.components";
2
+ import type { ReactComponentProps } from "@vnejs/uis.react";
3
+ import { Icon, View, createRenderFunc, useCallback, useIsForceHook, useMemo, useStoreState } from "@vnejs/uis.react";
4
+
5
+ import type { InterfaceFastforwardPluginConstants, InterfaceFastforwardPluginEvents, InterfaceFastforwardPluginParams, InterfaceFastforwardPluginSettings } from "../types.js";
6
+ import type { InterfaceFastforwardPluginState } from "../utils/interface.fastforward.js";
7
+ import { b } from "./index.styles.js";
8
+
9
+ type InterfaceFastforwardComponentProps = ReactComponentProps<
10
+ InterfaceFastforwardPluginEvents,
11
+ InterfaceFastforwardPluginConstants,
12
+ InterfaceFastforwardPluginSettings,
13
+ InterfaceFastforwardPluginParams,
14
+ InterfaceFastforwardPluginState
15
+ >;
16
+
17
+ const InterfaceFastForward = ({ store, onMount, emit, EVENTS, PARAMS }: InterfaceFastforwardComponentProps) => {
18
+ const {
19
+ isShow = false,
20
+ isVisible = false,
21
+ isForce = false,
22
+ isActive = false,
23
+ isAnimationDisabled = false,
24
+ view = "",
25
+ iconSrc = "",
26
+ } = useStoreState<InterfaceFastforwardPluginState>(store, onMount);
27
+
28
+ const onClick = useCallback(() => emit(EVENTS.INTERFACE_FASTFORWARD_VIEW.CLICK), [emit, EVENTS.INTERFACE_FASTFORWARD_VIEW.CLICK]);
29
+
30
+ const isRealForce = useIsForceHook(isForce);
31
+
32
+ const transition = isRealForce ? 0 : PARAMS.INTERFACE.TRANSITION;
33
+
34
+ const propsByView = useMemo(
35
+ () => PARAMS.INTERFACE_FASTFORWARD_VIEW.VIEW_PROPS[view as keyof typeof PARAMS.INTERFACE_FASTFORWARD_VIEW.VIEW_PROPS],
36
+ [view, PARAMS.INTERFACE_FASTFORWARD_VIEW.VIEW_PROPS],
37
+ );
38
+ const propsIcon = useMemo(() => ({ ...propsByView?.icon, src: iconSrc, transition }), [propsByView, iconSrc, transition]);
39
+ const propsView = useMemo(
40
+ () => ({ ...propsByView?.view, isShow, isForce: isRealForce, transition, onClick }),
41
+ [propsByView, isShow, isRealForce, transition, onClick],
42
+ );
43
+
44
+ return (
45
+ <View
46
+ {...propsView}
47
+ className={b({ isAnimated: isActive && !isAnimationDisabled })}
48
+ isHidden={!isVisible}
49
+ zIndex={PARAMS.INTERFACE.ZINDEX + 200}
50
+ >
51
+ <Icon {...propsIcon} />
52
+ </View>
53
+ );
54
+ };
55
+
56
+ export const render: ViewRenderFunc<InterfaceFastforwardPluginState> = createRenderFunc(InterfaceFastForward);
package/tsconfig.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "@vnejs/configs.ts-common/tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": "src",
5
+ "outDir": "dist",
6
+ "jsx": "react-jsx"
7
+ },
8
+ "include": ["src/**/*.ts", "src/**/*.tsx"],
9
+ "exclude": ["dist", "node_modules"]
10
+ }
package/const/events.js DELETED
@@ -1,6 +0,0 @@
1
- export const SUBSCRIBE_EVENTS = {
2
- SHOW: "vne:interface_fastforward:show",
3
- HIDE: "vne:interface_fastforward:hide",
4
- CLICK: "vne:interface_fastforward:click",
5
- UPDATE: "vne:interface_fastforward:update",
6
- };
package/const/params.js DELETED
@@ -1,17 +0,0 @@
1
- import { getVneLength } from "@vnejs/uis.utils";
2
-
3
- const createView = (x, y, tX, tY) => ({
4
- bottom: 0,
5
- right: 0,
6
- translateX: getVneLength(-x),
7
- translateY: getVneLength(-y),
8
- transformOriginX: tX,
9
- transformOriginY: tY,
10
- });
11
- const createIcon = (scale) => ({ width: 384, height: 384, isOpacityOnHover: true, scale, transformOriginX: "100%", transformOriginY: "100%" });
12
-
13
- export const VIEW_PROPS = {
14
- adv: { view: createView(96, 96, "50%", "50%"), icon: createIcon(1) },
15
- line: { view: createView(360, 24, "87.5%", "87.5%"), icon: createIcon(0.25) },
16
- wall: { view: createView(144, 144, "87.5%", "87.5%"), icon: createIcon(0.25) },
17
- };
package/index.js DELETED
@@ -1,9 +0,0 @@
1
- import { regPlugin } from "@vnejs/shared";
2
-
3
- import { SUBSCRIBE_EVENTS } from "./const/events";
4
- import * as params from "./const/params";
5
-
6
- import { InterfaceFastForwardController } from "./modules/controller";
7
- import { InterfaceFastForwardView } from "./modules/view";
8
-
9
- regPlugin("INTERFACE_FASTFORWARD_VIEW", { events: SUBSCRIBE_EVENTS, params }, [InterfaceFastForwardController, InterfaceFastForwardView]);
@@ -1,91 +0,0 @@
1
- import { ModuleController } from "@vnejs/module.components";
2
-
3
- export class InterfaceFastForwardController extends ModuleController {
4
- name = "interface.fastforward.controller";
5
-
6
- updateEvent = this.EVENTS.INTERFACE_FASTFORWARD_VIEW.UPDATE;
7
-
8
- controls = {
9
- [this.CONST.CONTROLS.BUTTONS.FASTFORWARD_TOGGLE]: () => this.emitFastforwardEvent(this.EVENTS.FASTFORWARD.TOGGLE),
10
- [this.CONST.CONTROLS.BUTTONS.FASTFORWARD_START]: () => this.emitFastforwardEvent(this.EVENTS.FASTFORWARD.START),
11
- [this.CONST.CONTROLS.BUTTONS.FASTFORWARD_FINISH]: () => this.emitFastforwardEvent(this.EVENTS.FASTFORWARD.STOP),
12
- };
13
- controlsUnvisible = {};
14
- controlsCheckNext = true;
15
- controlsIndex = this.PARAMS.INTERFACE.ZINDEX + 200;
16
-
17
- subscribe = () => {
18
- this.on(this.EVENTS.INTERFACE_FASTFORWARD_VIEW.SHOW, this.onShow);
19
- this.on(this.EVENTS.INTERFACE_FASTFORWARD_VIEW.HIDE, this.onHide);
20
- this.on(this.EVENTS.INTERFACE_FASTFORWARD_VIEW.CLICK, this.onClick);
21
-
22
- this.on(this.EVENTS.INTERFACE.SHOW_CHANGED, this.onShowChanged);
23
- this.on(this.EVENTS.INTERFACE.VIEW_CHANGED, this.onViewChanged);
24
- this.on(this.EVENTS.INTERFACE.STATE_CHANGED, this.onStateChanged);
25
- this.on(this.EVENTS.INTERFACE.VISIBLE_CHANGED, this.onVisibleChanged);
26
-
27
- this.on(this.EVENTS.CHOOSE.SHOW, this.onChooseShow);
28
- this.on(this.EVENTS.CHOOSE.HIDE, this.onChooseHide);
29
-
30
- this.on(this.EVENTS.FASTFORWARD.CHANGED, this.onFastForward);
31
-
32
- this.on(this.EVENTS.SYSTEM.STARTED, this.getIconSrc);
33
- this.on(this.EVENTS.MEMORY.CLEARED, this.onMemoryCleared);
34
- };
35
-
36
- beforeShow = async () => this.updateState({ iconSrc: await this.getIconSrc() });
37
-
38
- onClick = () => {
39
- const { isShow = false, isVisible = false } = this.globalState.interface;
40
-
41
- return isShow && isVisible && this.emitFastforwardEvent(this.EVENTS.FASTFORWARD.TOGGLE);
42
- };
43
-
44
- onShowChanged = ({ isForce = false } = {}) => {
45
- const { isShow = false } = this.globalState.interface;
46
- const event = isShow ? this.EVENTS.INTERFACE_FASTFORWARD_VIEW.SHOW : this.EVENTS.INTERFACE_FASTFORWARD_VIEW.HIDE;
47
-
48
- if (this.state.isShow !== isShow) return this.emit(event, { isForce });
49
- };
50
-
51
- onViewChanged = ({ isForce = false } = {}) => {
52
- const { view = "" } = this.globalState.interface;
53
-
54
- if (this.state.view !== view) return this.updateStateAndView({ view }, isForce, !isForce);
55
- };
56
-
57
- onVisibleChanged = ({ isForce = false } = {}) => {
58
- const { isVisible = false } = this.globalState.interface;
59
-
60
- this.toggleUnvisibleControls(isVisible);
61
-
62
- if (this.state.isVisible !== isVisible) return this.updateStateAndView({ isVisible }, isForce, !isForce);
63
- };
64
-
65
- onStateChanged = () => {
66
- const { isShow = false, isVisible = false, view = "" } = this.globalState.interface;
67
-
68
- this.toggleUnvisibleControls(isVisible);
69
-
70
- return this.updateStateAndViewForce({ isVisible, isShow, view });
71
- };
72
-
73
- onFastForward = ({ value } = {}) => this.isReady && this.updateStateAndViewFast({ isActive: value });
74
-
75
- onChooseShow = () => this.updateStateAndViewFast({ isChooseShow: true });
76
- onChooseHide = () => this.updateStateAndViewFast({ isChooseShow: false });
77
-
78
- onMemoryCleared = async () => this.updateStateAndViewFast({ iconSrc: await this.getIconSrc() });
79
-
80
- toggleUnvisibleControls = (isVisible) => {
81
- const args = { key: `${this.name}-unvisible`, controls: this.controlsUnvisible, index: this.controlsIndex + 500 };
82
-
83
- return this.emit(isVisible ? this.EVENTS.CONTROLS.POP : this.EVENTS.CONTROLS.PUSH, args);
84
- };
85
-
86
- emitFastforwardEvent = (event) => this.emit(this.globalState.interface.isVisible ? event : this.EVENTS.INTERFACE.VISIBLE);
87
-
88
- getIconSrc = async () => (await this.loadImageMedia(`interface/fastforward`, "icons", this.shared.settings[this.SETTINGS.LAYER.QUALITY])).src;
89
-
90
- getDefaultState = () => ({ isActive: false, isVisible: false, isShow: false, isChooseShow: false });
91
- }
package/modules/view.js DELETED
@@ -1,13 +0,0 @@
1
- import { ModuleView } from "@vnejs/module.components";
2
-
3
- import { render } from "../view";
4
-
5
- export class InterfaceFastForwardView extends ModuleView {
6
- name = "interface.fastforward.view";
7
-
8
- animationTime = this.PARAMS.INTERFACE.TRANSITION;
9
- updateEvent = this.EVENTS.INTERFACE_FASTFORWARD_VIEW.UPDATE;
10
-
11
- renderFunc = render;
12
- updateHandler = this.onUpdateStoreComponent;
13
- }
package/view/index.jsx DELETED
@@ -1,42 +0,0 @@
1
- import { useCallback, useEffect, useMemo, useState } from "react";
2
- import { createRoot } from "react-dom/client";
3
-
4
- import { cn } from "@bem-react/classname";
5
-
6
- import { Icon, useIsForceHook, View } from "@vnejs/uis.react";
7
-
8
- import "./index.styl";
9
-
10
- const b = cn("InterfaceFastForward");
11
-
12
- const InterfaceFastForward = ({ store, onMount, ...props } = {}) => {
13
- const [state, setState] = useState({});
14
-
15
- const { isShow = false, isVisible = false, isForce = false, isActive = false, isChooseShow = false, view = "", iconSrc = "" } = state;
16
-
17
- useEffect(() => store.subscribe(setState), []);
18
- useEffect(() => void onMount(), []);
19
-
20
- const onClick = useCallback(() => props.emit(props.EVENTS.INTERFACE_FASTFORWARD_VIEW.CLICK));
21
-
22
- const isRealForce = useIsForceHook(isForce);
23
-
24
- const transition = isRealForce ? 0 : props.PARAMS.INTERFACE.TRANSITION;
25
-
26
- const propsByView = useMemo(() => props.PARAMS.INTERFACE_FASTFORWARD_VIEW.VIEW_PROPS[view], [view]);
27
- const propsIcon = useMemo(() => ({ ...propsByView?.icon, src: iconSrc, transition }), [view, iconSrc, transition]);
28
- const propsView = useMemo(() => ({ ...propsByView?.view, isShow, isForce: isRealForce, transition, onClick }), [view, isShow, isRealForce, transition]);
29
-
30
- return (
31
- <View
32
- {...propsView}
33
- className={b({ isAnimated: isActive && !isChooseShow })}
34
- isHidden={!isVisible}
35
- zIndex={props.PARAMS.INTERFACE.ZINDEX + 200}
36
- >
37
- <Icon {...propsIcon} />
38
- </View>
39
- );
40
- };
41
-
42
- export const render = (props, root) => createRoot(root).render(<InterfaceFastForward {...props} />);
package/view/index.styl DELETED
@@ -1,19 +0,0 @@
1
- @keyframes fastforward
2
- from
3
- transform: scale(1.1)
4
-
5
- 50%
6
- transform: scale(0.9)
7
-
8
- to
9
- transform: scale(1.1)
10
-
11
- .InterfaceFastForward
12
- &_isAnimated
13
- animation-duration: 500ms
14
- animation-name: fastforward
15
- animation-iteration-count: infinite
16
- animation-timing-function: ease-in-out
17
-
18
-
19
-