@vnejs/plugins.views.screens.loading 0.1.4 → 0.1.5
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 +13 -0
- package/dist/modules/controller.js +16 -0
- package/dist/modules/loading.d.ts +8 -0
- package/dist/modules/loading.js +14 -0
- package/dist/modules/view.d.ts +11 -0
- package/dist/modules/view.js +10 -0
- package/dist/types.d.ts +10 -0
- package/dist/types.js +1 -0
- package/dist/utils/loading.d.ts +17 -0
- package/dist/utils/loading.js +1 -0
- package/dist/view/index.d.ts +3 -0
- package/dist/view/index.js +9 -0
- package/package.json +37 -6
- package/src/index.ts +8 -0
- package/{modules/controller.js → src/modules/controller.ts} +10 -1
- package/src/modules/loading.ts +26 -0
- package/src/modules/view.ts +22 -0
- package/src/types.ts +19 -0
- package/src/utils/loading.ts +21 -0
- package/src/view/index.tsx +34 -0
- package/tsconfig.json +10 -0
- package/const/events.js +0 -6
- package/const/params.js +0 -13
- package/index.js +0 -10
- package/modules/loading.js +0 -17
- package/modules/view.js +0 -14
- package/view/index.jsx +0 -24
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { regPlugin } from "@vnejs/shared";
|
|
2
|
+
import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/plugins.views.screens.loading.contract";
|
|
3
|
+
import { LoadingController } from "./modules/controller.js";
|
|
4
|
+
import { Loading } from "./modules/loading.js";
|
|
5
|
+
import { LoadingView } from "./modules/view.js";
|
|
6
|
+
regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS }, [LoadingController, Loading, LoadingView]);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ModuleController } from "@vnejs/module.components";
|
|
2
|
+
import type { LoadingPluginConstants, LoadingPluginEvents, LoadingPluginParams, LoadingPluginSettings } from "../types.js";
|
|
3
|
+
import type { LoadingPluginState } from "../utils/loading.js";
|
|
4
|
+
export declare class LoadingController extends ModuleController<LoadingPluginEvents, LoadingPluginConstants, LoadingPluginSettings, LoadingPluginParams, LoadingPluginState> {
|
|
5
|
+
name: string;
|
|
6
|
+
bgName: string;
|
|
7
|
+
controls: {};
|
|
8
|
+
controlsIndex: number;
|
|
9
|
+
updateEvent: "vne:loading:update";
|
|
10
|
+
subscribe: () => void;
|
|
11
|
+
beforeShow: () => Promise<void>;
|
|
12
|
+
onMemoryCleared: () => Promise<unknown[] | undefined>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ModuleController } from "@vnejs/module.components";
|
|
2
|
+
export class LoadingController extends ModuleController {
|
|
3
|
+
name = "loading.controller";
|
|
4
|
+
bgName = this.PARAMS.LOADING.BACKGROUND;
|
|
5
|
+
controls = {};
|
|
6
|
+
controlsIndex = this.PARAMS.LOADING.ZINDEX;
|
|
7
|
+
updateEvent = this.EVENTS.LOADING.UPDATE;
|
|
8
|
+
subscribe = () => {
|
|
9
|
+
this.on(this.EVENTS.LOADING.SHOW, this.onShow);
|
|
10
|
+
this.on(this.EVENTS.LOADING.HIDE, this.onHide);
|
|
11
|
+
this.on(this.EVENTS.SYSTEM.STARTED, this.loadBgMedia);
|
|
12
|
+
this.on(this.EVENTS.MEMORY.CLEARED, this.onMemoryCleared);
|
|
13
|
+
};
|
|
14
|
+
beforeShow = async () => this.updateState({ bgSrc: (await this.loadBgMedia()).src });
|
|
15
|
+
onMemoryCleared = async () => this.updateStateAndViewFast({ bgSrc: (await this.loadBgMedia()).src });
|
|
16
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Module } from "@vnejs/module";
|
|
2
|
+
import type { LoadingPluginConstants, LoadingPluginEvents, LoadingPluginParams, LoadingPluginSettings } from "../types.js";
|
|
3
|
+
import type { LoadingEmitPayload, LoadingPluginState } from "../utils/loading.js";
|
|
4
|
+
export declare class Loading extends Module<LoadingPluginEvents, LoadingPluginConstants, LoadingPluginSettings, LoadingPluginParams, LoadingPluginState> {
|
|
5
|
+
name: string;
|
|
6
|
+
subscribe: () => void;
|
|
7
|
+
onLoadingEmit: ({ promiseFunc }?: LoadingEmitPayload) => Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Module } from "@vnejs/module";
|
|
2
|
+
export class Loading extends Module {
|
|
3
|
+
name = "loading";
|
|
4
|
+
subscribe = () => {
|
|
5
|
+
this.on(this.EVENTS.LOADING.EMIT, this.onLoadingEmit);
|
|
6
|
+
};
|
|
7
|
+
onLoadingEmit = async ({ promiseFunc } = {}) => {
|
|
8
|
+
this.emit(this.EVENTS.LOGS.EMIT, { module: this.name, value: { action: "start" } });
|
|
9
|
+
await this.emit(this.EVENTS.LOADING.SHOW);
|
|
10
|
+
await Promise.all([promiseFunc?.(), this.waitTimeout(this.PARAMS.LOADING.MIN_SHOW_TIME)]);
|
|
11
|
+
await this.emit(this.EVENTS.LOADING.HIDE);
|
|
12
|
+
this.emit(this.EVENTS.LOGS.EMIT, { module: this.name, value: { action: "finish" } });
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ModuleView } from "@vnejs/module.components";
|
|
2
|
+
import type { LoadingPluginConstants, LoadingPluginEvents, LoadingPluginParams, LoadingPluginSettings } from "../types.js";
|
|
3
|
+
import type { LoadingPluginState } from "../utils/loading.js";
|
|
4
|
+
export declare class LoadingView extends ModuleView<LoadingPluginEvents, LoadingPluginConstants, LoadingPluginSettings, LoadingPluginParams, LoadingPluginState> {
|
|
5
|
+
name: string;
|
|
6
|
+
locLabel: string;
|
|
7
|
+
animationTime: number;
|
|
8
|
+
updateEvent: "vne:loading:update";
|
|
9
|
+
renderFunc: import("@vnejs/module.components").ViewRenderFunc<LoadingPluginState>;
|
|
10
|
+
updateHandler: (state?: LoadingPluginState | undefined) => Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ModuleView } from "@vnejs/module.components";
|
|
2
|
+
import { render } from "../view/index.js";
|
|
3
|
+
export class LoadingView extends ModuleView {
|
|
4
|
+
name = "loading.view";
|
|
5
|
+
locLabel = this.PARAMS.LOADING.LOC_LABEL;
|
|
6
|
+
animationTime = this.PARAMS.LOADING.TRANSITION;
|
|
7
|
+
updateEvent = this.EVENTS.LOADING.UPDATE;
|
|
8
|
+
renderFunc = render;
|
|
9
|
+
updateHandler = this.onUpdateStoreComponent;
|
|
10
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ModuleComponentsConstants, ModuleComponentsEvents, ModuleComponentsParams, ModuleComponentsSettings } from "@vnejs/module.components";
|
|
2
|
+
import type { PluginName as LogsPluginName, SubscribeEvents as LogsSubscribeEvents } from "@vnejs/plugins.core.logs.contract";
|
|
3
|
+
import type { PluginName as MemoryPluginName, SubscribeEvents as MemorySubscribeEvents } from "@vnejs/plugins.core.memory.contract";
|
|
4
|
+
import type { PluginName as SystemPluginName, SubscribeEvents as SystemSubscribeEvents } from "@vnejs/plugins.core.system.contract";
|
|
5
|
+
import type { PluginName as LocsPluginName, SubscribeEvents as LocsSubscribeEvents } from "@vnejs/plugins.text.locs.contract";
|
|
6
|
+
import type { Params, PluginName, SubscribeEvents } from "@vnejs/plugins.views.screens.loading.contract";
|
|
7
|
+
export type LoadingPluginEvents = ModuleComponentsEvents & Record<PluginName, SubscribeEvents> & Record<LogsPluginName, LogsSubscribeEvents> & Record<MemoryPluginName, MemorySubscribeEvents> & Record<SystemPluginName, SystemSubscribeEvents> & Record<LocsPluginName, LocsSubscribeEvents>;
|
|
8
|
+
export type LoadingPluginConstants = ModuleComponentsConstants;
|
|
9
|
+
export type LoadingPluginSettings = ModuleComponentsSettings;
|
|
10
|
+
export type LoadingPluginParams = ModuleComponentsParams & Record<PluginName, Params>;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Module } from "@vnejs/module";
|
|
2
|
+
import type { LoadingPluginConstants, LoadingPluginEvents, LoadingPluginParams, LoadingPluginSettings } from "../types.js";
|
|
3
|
+
export type LoadingPluginState = {
|
|
4
|
+
isShow: boolean;
|
|
5
|
+
isForce: boolean;
|
|
6
|
+
bgSrc?: string;
|
|
7
|
+
locs?: Record<string, string>;
|
|
8
|
+
};
|
|
9
|
+
export type LoadingEmitPayload = {
|
|
10
|
+
promiseFunc?: () => void | Promise<void>;
|
|
11
|
+
source?: string;
|
|
12
|
+
};
|
|
13
|
+
export type LoadingViewContext = {
|
|
14
|
+
emit: Module<LoadingPluginEvents, LoadingPluginConstants, LoadingPluginSettings, LoadingPluginParams, LoadingPluginState>["emit"];
|
|
15
|
+
EVENTS: LoadingPluginEvents;
|
|
16
|
+
PARAMS: LoadingPluginParams;
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { PositionBox, Screen, Text, createRenderFunc, useMemo, useStoreState } from "@vnejs/uis.react";
|
|
3
|
+
const Loading = ({ store, onMount, PARAMS }) => {
|
|
4
|
+
const { isShow = false, isForce = false, bgSrc = "", locs = {} } = useStoreState(store, onMount);
|
|
5
|
+
const propsText = useMemo(() => ({ ...PARAMS.LOADING.VIEW_PROPS.text, text: locs.text }), [locs, PARAMS.LOADING.VIEW_PROPS.text]);
|
|
6
|
+
const propsScreen = useMemo(() => ({ ...PARAMS.LOADING.VIEW_PROPS.screen, bgSrc, isShow, isForce }), [bgSrc, isShow, isForce, PARAMS.LOADING.VIEW_PROPS.screen]);
|
|
7
|
+
return (_jsx(Screen, { ...propsScreen, children: _jsx(PositionBox, { ...PARAMS.LOADING.VIEW_PROPS.position, children: _jsx(Text, { ...propsText }) }) }));
|
|
8
|
+
};
|
|
9
|
+
export const render = createRenderFunc(Loading);
|
package/package.json
CHANGED
|
@@ -1,17 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vnejs/plugins.views.screens.loading",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.1.5",
|
|
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": "
|
|
11
|
-
"publish:minor": "
|
|
12
|
-
"publish:patch": "
|
|
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
|
-
"
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@vnejs/plugins.views.screens.loading.contract": "~0.0.1"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@vnejs/module": "~0.0.1",
|
|
37
|
+
"@vnejs/module.components": "~0.0.1",
|
|
38
|
+
"@vnejs/plugins.core.logs.contract": "~0.0.1",
|
|
39
|
+
"@vnejs/plugins.core.memory.contract": "~0.0.1",
|
|
40
|
+
"@vnejs/plugins.core.system.contract": "~0.0.1",
|
|
41
|
+
"@vnejs/plugins.text.locs.contract": "~0.0.1",
|
|
42
|
+
"@vnejs/shared": "~0.0.9",
|
|
43
|
+
"@vnejs/uis.react": "~0.1.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@vnejs/configs.ts-common": "~0.0.1"
|
|
47
|
+
}
|
|
17
48
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { regPlugin } from "@vnejs/shared";
|
|
2
|
+
import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/plugins.views.screens.loading.contract";
|
|
3
|
+
|
|
4
|
+
import { LoadingController } from "./modules/controller.js";
|
|
5
|
+
import { Loading } from "./modules/loading.js";
|
|
6
|
+
import { LoadingView } from "./modules/view.js";
|
|
7
|
+
|
|
8
|
+
regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS }, [LoadingController, Loading, LoadingView]);
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { ModuleController } from "@vnejs/module.components";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import type { LoadingPluginConstants, LoadingPluginEvents, LoadingPluginParams, LoadingPluginSettings } from "../types.js";
|
|
4
|
+
import type { LoadingPluginState } from "../utils/loading.js";
|
|
5
|
+
|
|
6
|
+
export class LoadingController extends ModuleController<
|
|
7
|
+
LoadingPluginEvents,
|
|
8
|
+
LoadingPluginConstants,
|
|
9
|
+
LoadingPluginSettings,
|
|
10
|
+
LoadingPluginParams,
|
|
11
|
+
LoadingPluginState
|
|
12
|
+
> {
|
|
4
13
|
name = "loading.controller";
|
|
5
14
|
|
|
6
15
|
bgName = this.PARAMS.LOADING.BACKGROUND;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Module } from "@vnejs/module";
|
|
2
|
+
|
|
3
|
+
import type { LoadingPluginConstants, LoadingPluginEvents, LoadingPluginParams, LoadingPluginSettings } from "../types.js";
|
|
4
|
+
import type { LoadingEmitPayload, LoadingPluginState } from "../utils/loading.js";
|
|
5
|
+
|
|
6
|
+
export class Loading extends Module<
|
|
7
|
+
LoadingPluginEvents,
|
|
8
|
+
LoadingPluginConstants,
|
|
9
|
+
LoadingPluginSettings,
|
|
10
|
+
LoadingPluginParams,
|
|
11
|
+
LoadingPluginState
|
|
12
|
+
> {
|
|
13
|
+
name = "loading";
|
|
14
|
+
|
|
15
|
+
subscribe = () => {
|
|
16
|
+
this.on(this.EVENTS.LOADING.EMIT, this.onLoadingEmit);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
onLoadingEmit = async ({ promiseFunc }: LoadingEmitPayload = {}) => {
|
|
20
|
+
this.emit(this.EVENTS.LOGS.EMIT, { module: this.name, value: { action: "start" } });
|
|
21
|
+
await this.emit(this.EVENTS.LOADING.SHOW);
|
|
22
|
+
await Promise.all([promiseFunc?.(), this.waitTimeout(this.PARAMS.LOADING.MIN_SHOW_TIME)]);
|
|
23
|
+
await this.emit(this.EVENTS.LOADING.HIDE);
|
|
24
|
+
this.emit(this.EVENTS.LOGS.EMIT, { module: this.name, value: { action: "finish" } });
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ModuleView } from "@vnejs/module.components";
|
|
2
|
+
|
|
3
|
+
import { render } from "../view/index.js";
|
|
4
|
+
import type { LoadingPluginConstants, LoadingPluginEvents, LoadingPluginParams, LoadingPluginSettings } from "../types.js";
|
|
5
|
+
import type { LoadingPluginState } from "../utils/loading.js";
|
|
6
|
+
|
|
7
|
+
export class LoadingView extends ModuleView<
|
|
8
|
+
LoadingPluginEvents,
|
|
9
|
+
LoadingPluginConstants,
|
|
10
|
+
LoadingPluginSettings,
|
|
11
|
+
LoadingPluginParams,
|
|
12
|
+
LoadingPluginState
|
|
13
|
+
> {
|
|
14
|
+
name = "loading.view";
|
|
15
|
+
|
|
16
|
+
locLabel = this.PARAMS.LOADING.LOC_LABEL;
|
|
17
|
+
animationTime = this.PARAMS.LOADING.TRANSITION;
|
|
18
|
+
updateEvent = this.EVENTS.LOADING.UPDATE;
|
|
19
|
+
|
|
20
|
+
renderFunc = render;
|
|
21
|
+
updateHandler = this.onUpdateStoreComponent;
|
|
22
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ModuleComponentsConstants, ModuleComponentsEvents, ModuleComponentsParams, ModuleComponentsSettings } from "@vnejs/module.components";
|
|
2
|
+
import type { PluginName as LogsPluginName, SubscribeEvents as LogsSubscribeEvents } from "@vnejs/plugins.core.logs.contract";
|
|
3
|
+
import type { PluginName as MemoryPluginName, SubscribeEvents as MemorySubscribeEvents } from "@vnejs/plugins.core.memory.contract";
|
|
4
|
+
import type { PluginName as SystemPluginName, SubscribeEvents as SystemSubscribeEvents } from "@vnejs/plugins.core.system.contract";
|
|
5
|
+
import type { PluginName as LocsPluginName, SubscribeEvents as LocsSubscribeEvents } from "@vnejs/plugins.text.locs.contract";
|
|
6
|
+
import type { Params, PluginName, SubscribeEvents } from "@vnejs/plugins.views.screens.loading.contract";
|
|
7
|
+
|
|
8
|
+
export type LoadingPluginEvents = ModuleComponentsEvents &
|
|
9
|
+
Record<PluginName, SubscribeEvents> &
|
|
10
|
+
Record<LogsPluginName, LogsSubscribeEvents> &
|
|
11
|
+
Record<MemoryPluginName, MemorySubscribeEvents> &
|
|
12
|
+
Record<SystemPluginName, SystemSubscribeEvents> &
|
|
13
|
+
Record<LocsPluginName, LocsSubscribeEvents>;
|
|
14
|
+
|
|
15
|
+
export type LoadingPluginConstants = ModuleComponentsConstants;
|
|
16
|
+
|
|
17
|
+
export type LoadingPluginSettings = ModuleComponentsSettings;
|
|
18
|
+
|
|
19
|
+
export type LoadingPluginParams = ModuleComponentsParams & Record<PluginName, Params>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Module } from "@vnejs/module";
|
|
2
|
+
|
|
3
|
+
import type { LoadingPluginConstants, LoadingPluginEvents, LoadingPluginParams, LoadingPluginSettings } from "../types.js";
|
|
4
|
+
|
|
5
|
+
export type LoadingPluginState = {
|
|
6
|
+
isShow: boolean;
|
|
7
|
+
isForce: boolean;
|
|
8
|
+
bgSrc?: string;
|
|
9
|
+
locs?: Record<string, string>;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type LoadingEmitPayload = {
|
|
13
|
+
promiseFunc?: () => void | Promise<void>;
|
|
14
|
+
source?: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type LoadingViewContext = {
|
|
18
|
+
emit: Module<LoadingPluginEvents, LoadingPluginConstants, LoadingPluginSettings, LoadingPluginParams, LoadingPluginState>["emit"];
|
|
19
|
+
EVENTS: LoadingPluginEvents;
|
|
20
|
+
PARAMS: LoadingPluginParams;
|
|
21
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ViewRenderFunc } from "@vnejs/module.components";
|
|
2
|
+
import type { ReactComponentProps } from "@vnejs/uis.react";
|
|
3
|
+
import { PositionBox, Screen, Text, createRenderFunc, useMemo, useStoreState } from "@vnejs/uis.react";
|
|
4
|
+
|
|
5
|
+
import type { LoadingPluginConstants, LoadingPluginEvents, LoadingPluginParams, LoadingPluginSettings } from "../types.js";
|
|
6
|
+
import type { LoadingPluginState } from "../utils/loading.js";
|
|
7
|
+
|
|
8
|
+
type LoadingComponentProps = ReactComponentProps<
|
|
9
|
+
LoadingPluginEvents,
|
|
10
|
+
LoadingPluginConstants,
|
|
11
|
+
LoadingPluginSettings,
|
|
12
|
+
LoadingPluginParams,
|
|
13
|
+
LoadingPluginState
|
|
14
|
+
>;
|
|
15
|
+
|
|
16
|
+
const Loading = ({ store, onMount, PARAMS }: LoadingComponentProps) => {
|
|
17
|
+
const { isShow = false, isForce = false, bgSrc = "", locs = {} } = useStoreState<LoadingPluginState>(store, onMount);
|
|
18
|
+
|
|
19
|
+
const propsText = useMemo(() => ({ ...PARAMS.LOADING.VIEW_PROPS.text, text: locs.text }), [locs, PARAMS.LOADING.VIEW_PROPS.text]);
|
|
20
|
+
const propsScreen = useMemo(
|
|
21
|
+
() => ({ ...PARAMS.LOADING.VIEW_PROPS.screen, bgSrc, isShow, isForce }),
|
|
22
|
+
[bgSrc, isShow, isForce, PARAMS.LOADING.VIEW_PROPS.screen],
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<Screen {...propsScreen}>
|
|
27
|
+
<PositionBox {...PARAMS.LOADING.VIEW_PROPS.position}>
|
|
28
|
+
<Text {...propsText} />
|
|
29
|
+
</PositionBox>
|
|
30
|
+
</Screen>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const render: ViewRenderFunc<LoadingPluginState> = createRenderFunc(Loading);
|
package/tsconfig.json
ADDED
package/const/events.js
DELETED
package/const/params.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export const MIN_SHOW_TIME = 200;
|
|
2
|
-
|
|
3
|
-
export const BACKGROUND = "loading";
|
|
4
|
-
|
|
5
|
-
export const TRANSITION = 500;
|
|
6
|
-
export const ZINDEX = 10000;
|
|
7
|
-
export const LOC_LABEL = "loading";
|
|
8
|
-
|
|
9
|
-
export const VIEW_PROPS = {
|
|
10
|
-
position: { bottom: 120, right: 120 },
|
|
11
|
-
text: { size: 144 },
|
|
12
|
-
screen: { transition: TRANSITION, zIndex: ZINDEX },
|
|
13
|
-
};
|
package/index.js
DELETED
|
@@ -1,10 +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 { LoadingController } from "./modules/controller";
|
|
7
|
-
import { Loading } from "./modules/loading";
|
|
8
|
-
import { LoadingView } from "./modules/view";
|
|
9
|
-
|
|
10
|
-
regPlugin("LOADING", { events: SUBSCRIBE_EVENTS, params }, [LoadingController, Loading, LoadingView]);
|
package/modules/loading.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Module } from "@vnejs/module";
|
|
2
|
-
|
|
3
|
-
export class Loading extends Module {
|
|
4
|
-
name = "loading";
|
|
5
|
-
|
|
6
|
-
subscribe = () => {
|
|
7
|
-
this.on(this.EVENTS.LOADING.EMIT, this.onLoadingEmit);
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
onLoadingEmit = async ({ promiseFunc } = {}) => {
|
|
11
|
-
this.emit(this.EVENTS.LOGS.EMIT, { module: this.name, value: { action: "start" } });
|
|
12
|
-
await this.emit(this.EVENTS.LOADING.SHOW);
|
|
13
|
-
await Promise.all([promiseFunc(), this.waitTimeout(this.PARAMS.LOADING.MIN_SHOW_TIME)]);
|
|
14
|
-
await this.emit(this.EVENTS.LOADING.HIDE);
|
|
15
|
-
this.emit(this.EVENTS.LOGS.EMIT, { module: this.name, value: { action: "finish" } });
|
|
16
|
-
};
|
|
17
|
-
}
|
package/modules/view.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ModuleView } from "@vnejs/module.components";
|
|
2
|
-
|
|
3
|
-
import { render } from "../view";
|
|
4
|
-
|
|
5
|
-
export class LoadingView extends ModuleView {
|
|
6
|
-
name = "loading.view";
|
|
7
|
-
|
|
8
|
-
locLabel = this.PARAMS.LOADING.LOC_LABEL;
|
|
9
|
-
animationTime = this.PARAMS.LOADING.TRANSITION;
|
|
10
|
-
updateEvent = this.EVENTS.LOADING.UPDATE;
|
|
11
|
-
|
|
12
|
-
renderFunc = render;
|
|
13
|
-
updateHandler = this.onUpdateStoreComponent;
|
|
14
|
-
}
|
package/view/index.jsx
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { useEffect, useMemo, useState } from "react";
|
|
2
|
-
import { createRoot } from "react-dom/client";
|
|
3
|
-
|
|
4
|
-
import { PositionBox, Screen, Text } from "@vnejs/uis.react";
|
|
5
|
-
|
|
6
|
-
const Loading = ({ store, onMount, ...props }) => {
|
|
7
|
-
const [{ isShow = false, isForce = false, bgSrc = "", locs = {} }, setState] = useState({});
|
|
8
|
-
|
|
9
|
-
useEffect(() => store.subscribe(setState), []);
|
|
10
|
-
useEffect(() => void onMount(), []);
|
|
11
|
-
|
|
12
|
-
const propsText = useMemo(() => ({ ...props.PARAMS.LOADING.VIEW_PROPS.text, text: locs.text }), [locs]);
|
|
13
|
-
const propsScreen = useMemo(() => ({ ...props.PARAMS.LOADING.VIEW_PROPS.screen, bgSrc, isShow, isForce }), [bgSrc, isShow, isForce]);
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<Screen {...propsScreen}>
|
|
17
|
-
<PositionBox {...props.PARAMS.LOADING.VIEW_PROPS.position}>
|
|
18
|
-
<Text {...propsText} />
|
|
19
|
-
</PositionBox>
|
|
20
|
-
</Screen>
|
|
21
|
-
);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const render = (props, root) => createRoot(root).render(<Loading {...props} />);
|