xpe 0.0.0-alpha.1
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/LICENSE +21 -0
- package/README.md +71 -0
- package/framework/es/core/Application.d.ts +126 -0
- package/framework/es/core/Command/Command.d.ts +7 -0
- package/framework/es/core/Container/Container.d.ts +80 -0
- package/framework/es/core/Contracts/AxiosAdapter.d.ts +12 -0
- package/framework/es/core/Helper/Helper.d.ts +43 -0
- package/framework/es/core/Helper/Storage/WebStorage.d.ts +71 -0
- package/framework/es/core/Libs/Exception.d.ts +24 -0
- package/framework/es/core/Libs/Lib.d.ts +72 -0
- package/framework/es/core/Provider/CommandProvider.d.ts +4 -0
- package/framework/es/core/Provider/HelperProvider.d.ts +4 -0
- package/framework/es/core/Provider/HttpProvider.d.ts +13 -0
- package/framework/es/core/Provider/ServiceProvider.d.ts +15 -0
- package/framework/es/core/Service/HttpService.d.ts +133 -0
- package/framework/es/core/Service/Service.d.ts +6 -0
- package/framework/es/core/Spanner/RESTful.d.ts +30 -0
- package/framework/es/core/Transformer/Transformer.d.ts +46 -0
- package/framework/es/core/Type/adapters.d.ts +25 -0
- package/framework/es/core/Type/types.d.ts +161 -0
- package/framework/es/core/TypeFunc/index.d.ts +6 -0
- package/framework/es/core/Wrenches/EventBus.d.ts +56 -0
- package/framework/es/core/Wrenches/is.d.ts +19 -0
- package/framework/es/ege.js +4 -0
- package/framework/es/ege.js.map +1 -0
- package/framework/es/index.d.ts +13 -0
- package/framework/es/pdd.js +4 -0
- package/framework/es/pdd.js.map +1 -0
- package/framework/es/src/core/Application.d.ts +127 -0
- package/framework/es/src/core/Application.d.ts.map +1 -0
- package/framework/es/src/core/Command/Command.d.ts +8 -0
- package/framework/es/src/core/Command/Command.d.ts.map +1 -0
- package/framework/es/src/core/Container/Container.d.ts +81 -0
- package/framework/es/src/core/Container/Container.d.ts.map +1 -0
- package/framework/es/src/core/Contracts/AxiosAdapter.d.ts +13 -0
- package/framework/es/src/core/Contracts/AxiosAdapter.d.ts.map +1 -0
- package/framework/es/src/core/Helper/Helper.d.ts +45 -0
- package/framework/es/src/core/Helper/Helper.d.ts.map +1 -0
- package/framework/es/src/core/Helper/Storage/WebStorage.d.ts +72 -0
- package/framework/es/src/core/Helper/Storage/WebStorage.d.ts.map +1 -0
- package/framework/es/src/core/Libs/Exception.d.ts +25 -0
- package/framework/es/src/core/Libs/Exception.d.ts.map +1 -0
- package/framework/es/src/core/Libs/Lib.d.ts +73 -0
- package/framework/es/src/core/Libs/Lib.d.ts.map +1 -0
- package/framework/es/src/core/Provider/CommandProvider.d.ts +5 -0
- package/framework/es/src/core/Provider/CommandProvider.d.ts.map +1 -0
- package/framework/es/src/core/Provider/HelperProvider.d.ts +5 -0
- package/framework/es/src/core/Provider/HelperProvider.d.ts.map +1 -0
- package/framework/es/src/core/Provider/HttpProvider.d.ts +14 -0
- package/framework/es/src/core/Provider/HttpProvider.d.ts.map +1 -0
- package/framework/es/src/core/Provider/ServiceProvider.d.ts +16 -0
- package/framework/es/src/core/Provider/ServiceProvider.d.ts.map +1 -0
- package/framework/es/src/core/Service/HttpService.d.ts +128 -0
- package/framework/es/src/core/Service/HttpService.d.ts.map +1 -0
- package/framework/es/src/core/Service/Service.d.ts +7 -0
- package/framework/es/src/core/Service/Service.d.ts.map +1 -0
- package/framework/es/src/core/Spanner/RESTful.d.ts +32 -0
- package/framework/es/src/core/Spanner/RESTful.d.ts.map +1 -0
- package/framework/es/src/core/Transformer/Transformer.d.ts +47 -0
- package/framework/es/src/core/Transformer/Transformer.d.ts.map +1 -0
- package/framework/es/src/core/Type/adapters.d.ts +26 -0
- package/framework/es/src/core/Type/adapters.d.ts.map +1 -0
- package/framework/es/src/core/Type/types.d.ts +186 -0
- package/framework/es/src/core/Type/types.d.ts.map +1 -0
- package/framework/es/src/core/TypeFunc/index.d.ts +8 -0
- package/framework/es/src/core/TypeFunc/index.d.ts.map +1 -0
- package/framework/es/src/core/Wrenches/EventBus.d.ts +57 -0
- package/framework/es/src/core/Wrenches/EventBus.d.ts.map +1 -0
- package/framework/es/src/core/Wrenches/is.d.ts +20 -0
- package/framework/es/src/core/Wrenches/is.d.ts.map +1 -0
- package/framework/es/src/index.d.ts +14 -0
- package/framework/es/src/index.d.ts.map +1 -0
- package/framework/es/src/utils.d.ts +17 -0
- package/framework/es/src/utils.d.ts.map +1 -0
- package/framework/es/utils.d.ts +16 -0
- package/framework/umd/core/Application.d.ts +126 -0
- package/framework/umd/core/Command/Command.d.ts +7 -0
- package/framework/umd/core/Container/Container.d.ts +80 -0
- package/framework/umd/core/Contracts/AxiosAdapter.d.ts +12 -0
- package/framework/umd/core/Helper/Helper.d.ts +43 -0
- package/framework/umd/core/Helper/Storage/WebStorage.d.ts +71 -0
- package/framework/umd/core/Libs/Exception.d.ts +24 -0
- package/framework/umd/core/Libs/Lib.d.ts +72 -0
- package/framework/umd/core/Provider/CommandProvider.d.ts +4 -0
- package/framework/umd/core/Provider/HelperProvider.d.ts +4 -0
- package/framework/umd/core/Provider/HttpProvider.d.ts +13 -0
- package/framework/umd/core/Provider/ServiceProvider.d.ts +15 -0
- package/framework/umd/core/Service/HttpService.d.ts +133 -0
- package/framework/umd/core/Service/Service.d.ts +6 -0
- package/framework/umd/core/Spanner/RESTful.d.ts +30 -0
- package/framework/umd/core/Transformer/Transformer.d.ts +46 -0
- package/framework/umd/core/Type/adapters.d.ts +25 -0
- package/framework/umd/core/Type/types.d.ts +161 -0
- package/framework/umd/core/TypeFunc/index.d.ts +6 -0
- package/framework/umd/core/Wrenches/EventBus.d.ts +56 -0
- package/framework/umd/core/Wrenches/is.d.ts +19 -0
- package/framework/umd/ege.js +4 -0
- package/framework/umd/ege.js.map +1 -0
- package/framework/umd/index.d.ts +13 -0
- package/framework/umd/pdd.js +4 -0
- package/framework/umd/pdd.js.map +1 -0
- package/framework/umd/src/core/Application.d.ts +127 -0
- package/framework/umd/src/core/Application.d.ts.map +1 -0
- package/framework/umd/src/core/Command/Command.d.ts +8 -0
- package/framework/umd/src/core/Command/Command.d.ts.map +1 -0
- package/framework/umd/src/core/Container/Container.d.ts +81 -0
- package/framework/umd/src/core/Container/Container.d.ts.map +1 -0
- package/framework/umd/src/core/Contracts/AxiosAdapter.d.ts +13 -0
- package/framework/umd/src/core/Contracts/AxiosAdapter.d.ts.map +1 -0
- package/framework/umd/src/core/Helper/Helper.d.ts +45 -0
- package/framework/umd/src/core/Helper/Helper.d.ts.map +1 -0
- package/framework/umd/src/core/Helper/Storage/WebStorage.d.ts +72 -0
- package/framework/umd/src/core/Helper/Storage/WebStorage.d.ts.map +1 -0
- package/framework/umd/src/core/Libs/Exception.d.ts +25 -0
- package/framework/umd/src/core/Libs/Exception.d.ts.map +1 -0
- package/framework/umd/src/core/Libs/Lib.d.ts +73 -0
- package/framework/umd/src/core/Libs/Lib.d.ts.map +1 -0
- package/framework/umd/src/core/Provider/CommandProvider.d.ts +5 -0
- package/framework/umd/src/core/Provider/CommandProvider.d.ts.map +1 -0
- package/framework/umd/src/core/Provider/HelperProvider.d.ts +5 -0
- package/framework/umd/src/core/Provider/HelperProvider.d.ts.map +1 -0
- package/framework/umd/src/core/Provider/HttpProvider.d.ts +14 -0
- package/framework/umd/src/core/Provider/HttpProvider.d.ts.map +1 -0
- package/framework/umd/src/core/Provider/ServiceProvider.d.ts +16 -0
- package/framework/umd/src/core/Provider/ServiceProvider.d.ts.map +1 -0
- package/framework/umd/src/core/Service/HttpService.d.ts +128 -0
- package/framework/umd/src/core/Service/HttpService.d.ts.map +1 -0
- package/framework/umd/src/core/Service/Service.d.ts +7 -0
- package/framework/umd/src/core/Service/Service.d.ts.map +1 -0
- package/framework/umd/src/core/Spanner/RESTful.d.ts +32 -0
- package/framework/umd/src/core/Spanner/RESTful.d.ts.map +1 -0
- package/framework/umd/src/core/Transformer/Transformer.d.ts +47 -0
- package/framework/umd/src/core/Transformer/Transformer.d.ts.map +1 -0
- package/framework/umd/src/core/Type/adapters.d.ts +26 -0
- package/framework/umd/src/core/Type/adapters.d.ts.map +1 -0
- package/framework/umd/src/core/Type/types.d.ts +186 -0
- package/framework/umd/src/core/Type/types.d.ts.map +1 -0
- package/framework/umd/src/core/TypeFunc/index.d.ts +8 -0
- package/framework/umd/src/core/TypeFunc/index.d.ts.map +1 -0
- package/framework/umd/src/core/Wrenches/EventBus.d.ts +57 -0
- package/framework/umd/src/core/Wrenches/EventBus.d.ts.map +1 -0
- package/framework/umd/src/core/Wrenches/is.d.ts +20 -0
- package/framework/umd/src/core/Wrenches/is.d.ts.map +1 -0
- package/framework/umd/src/index.d.ts +14 -0
- package/framework/umd/src/index.d.ts.map +1 -0
- package/framework/umd/src/utils.d.ts +17 -0
- package/framework/umd/src/utils.d.ts.map +1 -0
- package/framework/umd/utils.d.ts +16 -0
- package/index.d.ts +724 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 wangbo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# PDD Framework
|
|
2
|
+
|
|
3
|
+
> PDD⭐ - 是数企官方开发的纯前端容器框架,在Typescript赋能下基于IOC开发出的OOP框架,同时通过内置模块可快速实现AOP开发。
|
|
4
|
+
|
|
5
|
+
### PDD能带来什么:
|
|
6
|
+
|
|
7
|
+
- 统一代码,规范化。
|
|
8
|
+
- 更好的拓展、易于维护。
|
|
9
|
+
- 提升开发效率,开发只需考虑解决具体功能即可。
|
|
10
|
+
|
|
11
|
+
### 为什么要做PDD:
|
|
12
|
+
- 1.由于前端只有Vue/React/NG等MVVM框架,缺少像Spring、Laravel、Django这类架构更清晰、生态更完善的框架 [**当然现在有了像Nest.js、Midway.js这类Node.js服务端框架**] ,导致绝大多数纯前端对开发项目的认知不足。
|
|
13
|
+
- 2.前端缺少较为完整的开发方案,导致整体项目“乱”-高耦合、低聚合。PDD给前端项目开发整体规范化约束。
|
|
14
|
+
- 3.提升可维护性,目前PDD从整体配置到应用层面的拓展都有着明确的规定。大家都怕见到“宝藏代码”,“千人千面”这些给开发者造成的困扰无异乎抛出异常缺没有指出异常具体位置,很难维护。
|
|
15
|
+
|
|
16
|
+
### 如何使用:
|
|
17
|
+
```shell
|
|
18
|
+
# 通过npm方式安装
|
|
19
|
+
npm i pdd
|
|
20
|
+
# 通过cnpm方式安装
|
|
21
|
+
cnpm i pdd
|
|
22
|
+
# 通过yarn方式安装
|
|
23
|
+
yarn add pdd
|
|
24
|
+
# 通过pnpm方式安装,推荐
|
|
25
|
+
pnpm add pdd
|
|
26
|
+
```
|
|
27
|
+
> 集成到现有框架中,以Vue3+TS项目为模板来说
|
|
28
|
+
```typescript
|
|
29
|
+
// main.ts
|
|
30
|
+
/********** PDD Start **********/
|
|
31
|
+
import Application from 'pdd'
|
|
32
|
+
// PDD AppConfig 获取App配置文件
|
|
33
|
+
import AppConfig from './app/config/AppConfig'
|
|
34
|
+
// PDD Setting Config
|
|
35
|
+
Application.setAppConfig(AppConfig)
|
|
36
|
+
// PDD Run
|
|
37
|
+
Application.run()
|
|
38
|
+
// 如需使用日志系统
|
|
39
|
+
import { Log } from 'pdd'
|
|
40
|
+
// 日志初始化配置
|
|
41
|
+
Log.init({
|
|
42
|
+
// 使用web-sql方式存储
|
|
43
|
+
storage:'WEB_SQL',
|
|
44
|
+
// 存储的总条数,再超出范围后会将最先存储的日志给替换,请参照日志系统文档
|
|
45
|
+
total:10000,
|
|
46
|
+
// 控制台打印的级别,error及以下的级别在控制台打印,默认为debug级别,设置为false时则全部级别不在控制台打印
|
|
47
|
+
console:'error'
|
|
48
|
+
})
|
|
49
|
+
// 如需使用任务系统
|
|
50
|
+
import { Job } from 'pdd'
|
|
51
|
+
// 启动任务系统,具体细节请参照任务系统文档
|
|
52
|
+
Job.boot()
|
|
53
|
+
```
|
|
54
|
+
> 更多使用方法参照 [官方文档]: https://jxbse4s2oz1.feishu.cn/wiki/wikcnX8DSYtb1agME6mxb6NRfrQ
|
|
55
|
+
|
|
56
|
+
### ChangeLog:
|
|
57
|
+
> #### Version 0.3.20
|
|
58
|
+
> 1. 添加中间件上下文
|
|
59
|
+
> 2. http方法参数处理更新
|
|
60
|
+
> #### Version 0.3.15
|
|
61
|
+
> 1. 请求中间件和响应中间件添加上下文。
|
|
62
|
+
> 2. 请求方法添加fetch方法,返回为上下文。
|
|
63
|
+
> #### Version 0.3.14
|
|
64
|
+
> 1. $http.send方法处理自定义request headers会覆盖自动携带数据问题。
|
|
65
|
+
> #### Version 0.3.13
|
|
66
|
+
> 1. GET去除携带Content-Type
|
|
67
|
+
> #### Version 0.3.7
|
|
68
|
+
> 1. 启动BUG处理。
|
|
69
|
+
> #### Version 0.3.6
|
|
70
|
+
> 1. 对`Application`、`ServiceProvider`、`HttpService`、`Middleware`、`Container`等类型进行了深度优化。
|
|
71
|
+
> 2. 对`Pipeline`和`Log`部分代码重构,`Pipeline`做类似`Java lite-flow`组合式、并联、串联校验,`Log`使用三方`Dexie.js`处理SQL处理。
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import Container from './Container/Container';
|
|
2
|
+
import type { UtilityClass, UtilityObject } from './Type/utility';
|
|
3
|
+
import type { APP_CONFIG, IServiceProvider } from './Type/types';
|
|
4
|
+
/**
|
|
5
|
+
* Application 核心应用
|
|
6
|
+
* @extends Container
|
|
7
|
+
* @author SunnyXu <xy@ztes.com>
|
|
8
|
+
*/
|
|
9
|
+
export default class Application extends Container {
|
|
10
|
+
private static VERSION;
|
|
11
|
+
private adapters;
|
|
12
|
+
private providers;
|
|
13
|
+
/**
|
|
14
|
+
* lifecycle
|
|
15
|
+
* 生命周期
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
private static lifecycle;
|
|
19
|
+
/**
|
|
20
|
+
* getterProviders Providers 获取器
|
|
21
|
+
*/
|
|
22
|
+
getterProviders(): IServiceProvider[];
|
|
23
|
+
/**
|
|
24
|
+
* getProviders
|
|
25
|
+
* 获取
|
|
26
|
+
* @protected
|
|
27
|
+
*/
|
|
28
|
+
private static getProviders;
|
|
29
|
+
/**
|
|
30
|
+
* setterProviders Providers
|
|
31
|
+
* 设置器
|
|
32
|
+
* @param providers
|
|
33
|
+
*/
|
|
34
|
+
setterProviders(providers: IServiceProvider[]): void;
|
|
35
|
+
/**
|
|
36
|
+
* setProviders
|
|
37
|
+
* 设置
|
|
38
|
+
* @param providers
|
|
39
|
+
*/
|
|
40
|
+
static setProviders(providers: IServiceProvider[]): void;
|
|
41
|
+
/**
|
|
42
|
+
* registerProvider
|
|
43
|
+
* @description 注册服务提供者
|
|
44
|
+
* @param provider
|
|
45
|
+
*/
|
|
46
|
+
static registerProvider(provider: any): void;
|
|
47
|
+
/**
|
|
48
|
+
* registerProviders
|
|
49
|
+
* 批量注册
|
|
50
|
+
* @param providers
|
|
51
|
+
*/
|
|
52
|
+
static registerProviders(providers: IServiceProvider[]): void;
|
|
53
|
+
/**
|
|
54
|
+
* config
|
|
55
|
+
* 配置
|
|
56
|
+
* @param {Object} config
|
|
57
|
+
* @param {String} name
|
|
58
|
+
*/
|
|
59
|
+
static setConfig(name: string, config: UtilityObject): void;
|
|
60
|
+
/**
|
|
61
|
+
* getConfig
|
|
62
|
+
* 获取
|
|
63
|
+
* @param name
|
|
64
|
+
* @param {Object} def 默认值
|
|
65
|
+
*/
|
|
66
|
+
static getConfig(name: string, def?: any): UtilityObject;
|
|
67
|
+
/**
|
|
68
|
+
* setAppConfig
|
|
69
|
+
* 设置App配置
|
|
70
|
+
* @param config
|
|
71
|
+
*/
|
|
72
|
+
static setAppConfig(config: APP_CONFIG): void;
|
|
73
|
+
/**
|
|
74
|
+
* getAppConfig
|
|
75
|
+
* 获取App配置
|
|
76
|
+
* @param name
|
|
77
|
+
* @description 遵守getAppConfig中参数值和返回值的约定
|
|
78
|
+
*/
|
|
79
|
+
static getAppConfig<T extends keyof APP_CONFIG>(name: T): APP_CONFIG[T];
|
|
80
|
+
/**
|
|
81
|
+
* bindAdapter
|
|
82
|
+
* 绑定
|
|
83
|
+
* @param adapter
|
|
84
|
+
* @param payload
|
|
85
|
+
*/
|
|
86
|
+
static bindAdapter(adapter: UtilityClass, payload?: UtilityObject): void;
|
|
87
|
+
/**
|
|
88
|
+
* setAdapter
|
|
89
|
+
* 新增
|
|
90
|
+
* @param adapter
|
|
91
|
+
* @param instance
|
|
92
|
+
* @protected
|
|
93
|
+
*/
|
|
94
|
+
setterAdapter(adapter: UtilityClass, instance: UtilityObject): void;
|
|
95
|
+
/**
|
|
96
|
+
* static getAdapter
|
|
97
|
+
* 获取适配器
|
|
98
|
+
* @param adapter 必须是个类
|
|
99
|
+
* @return instance
|
|
100
|
+
*/
|
|
101
|
+
static getAdapter(adapter: UtilityClass): any;
|
|
102
|
+
/**
|
|
103
|
+
* static getAdapter
|
|
104
|
+
* 适配器 获取器
|
|
105
|
+
* @param adapter
|
|
106
|
+
*/
|
|
107
|
+
getterAdapter(adapter: UtilityClass): any;
|
|
108
|
+
/**
|
|
109
|
+
* getService
|
|
110
|
+
* 获取服务实例
|
|
111
|
+
* @param serviceName
|
|
112
|
+
*/
|
|
113
|
+
static getService<T>(serviceName: string): T;
|
|
114
|
+
/**
|
|
115
|
+
* Application instance
|
|
116
|
+
* 获取应用实例
|
|
117
|
+
* @description 应该使用Proxy进行拦截,目前先放行
|
|
118
|
+
*/
|
|
119
|
+
static getInstance(): InstanceType<typeof Application>;
|
|
120
|
+
/**
|
|
121
|
+
* App run
|
|
122
|
+
* 框架应用运行
|
|
123
|
+
* @param {CallableFunction} callback
|
|
124
|
+
*/
|
|
125
|
+
static run(callback?: CallableFunction): void;
|
|
126
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { ClassConstructor } from '../Type/utility';
|
|
2
|
+
import type { IContainer } from '../Type/types';
|
|
3
|
+
/**
|
|
4
|
+
* Class Container
|
|
5
|
+
* 容器类
|
|
6
|
+
* @author SunnyXu <xy@ztes.com>
|
|
7
|
+
*/
|
|
8
|
+
export default class Container implements IContainer {
|
|
9
|
+
protected static instance: unknown;
|
|
10
|
+
protected instances: Map<any, any>;
|
|
11
|
+
protected bindings: Record<string, any>;
|
|
12
|
+
protected aliases: Record<string, any>;
|
|
13
|
+
/**
|
|
14
|
+
* bind 绑定实体
|
|
15
|
+
* @param {String|Array} abstract
|
|
16
|
+
* @param {*} concrete
|
|
17
|
+
*/
|
|
18
|
+
bind(abstract: string | string[], concrete: any): void;
|
|
19
|
+
/**
|
|
20
|
+
* make 创建类的实例/获取对象 create instance/object
|
|
21
|
+
* @param abstract
|
|
22
|
+
* @param params
|
|
23
|
+
* @param shared
|
|
24
|
+
*/
|
|
25
|
+
make(abstract: string, params?: object | [], shared?: boolean): any;
|
|
26
|
+
/**
|
|
27
|
+
* makeClass 创建类
|
|
28
|
+
* @param name
|
|
29
|
+
* @param executor
|
|
30
|
+
* @param params
|
|
31
|
+
* @param shared
|
|
32
|
+
*/
|
|
33
|
+
protected makeClass(name: string, executor: ClassConstructor, params: unknown, shared?: boolean): any;
|
|
34
|
+
/**
|
|
35
|
+
* makeFunc 创建函数
|
|
36
|
+
* @param name
|
|
37
|
+
* @param executor
|
|
38
|
+
* @param params
|
|
39
|
+
* @param shared
|
|
40
|
+
* @protected
|
|
41
|
+
*/
|
|
42
|
+
protected makeFunc(name: string, executor: CallableFunction, params: unknown, shared?: boolean): any;
|
|
43
|
+
/**
|
|
44
|
+
* has as existence
|
|
45
|
+
* 是否存在标识 existence 的别名
|
|
46
|
+
* @param {String} name
|
|
47
|
+
*/
|
|
48
|
+
has(name: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* existence 存在标识
|
|
51
|
+
* @param {String} name
|
|
52
|
+
*/
|
|
53
|
+
existence(name: string): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* getAlias 获取别名
|
|
56
|
+
* @param abstract
|
|
57
|
+
*/
|
|
58
|
+
getAlias(abstract: string): any;
|
|
59
|
+
/**
|
|
60
|
+
* get 获取实例
|
|
61
|
+
* @param abstract
|
|
62
|
+
*/
|
|
63
|
+
get(abstract: string): any;
|
|
64
|
+
/**
|
|
65
|
+
* singleton 单例
|
|
66
|
+
* @param abstract
|
|
67
|
+
* @param concrete
|
|
68
|
+
*/
|
|
69
|
+
singleton(abstract: string, concrete: any): void;
|
|
70
|
+
/**
|
|
71
|
+
* getInstance 获取实例
|
|
72
|
+
*
|
|
73
|
+
*/
|
|
74
|
+
static getInstance<Instance>(): Container | Instance;
|
|
75
|
+
/**
|
|
76
|
+
* proxyInstance 代理实例
|
|
77
|
+
*
|
|
78
|
+
*/
|
|
79
|
+
protected proxyInstance(): this;
|
|
80
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HttpAdapterInterface } from '../Type/adapters';
|
|
2
|
+
/**
|
|
3
|
+
* Class AxiosAdapter
|
|
4
|
+
* @description axios适配器,适配器主要完成
|
|
5
|
+
*/
|
|
6
|
+
export default class AxiosAdapter extends HttpAdapterInterface<{}> {
|
|
7
|
+
/**
|
|
8
|
+
* Method request
|
|
9
|
+
* @returns Promise
|
|
10
|
+
*/
|
|
11
|
+
request(): Promise<unknown>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import Service from '../Service/Service';
|
|
2
|
+
import type { IResponseReturn, TResponseDataReturn, IHelper } from '../Type/types';
|
|
3
|
+
/**
|
|
4
|
+
* Class Helper
|
|
5
|
+
* @extends Service
|
|
6
|
+
*/
|
|
7
|
+
export default class Helper extends Service implements IHelper {
|
|
8
|
+
env(): Record<any, any>;
|
|
9
|
+
private webStorage;
|
|
10
|
+
/**
|
|
11
|
+
* Local storage
|
|
12
|
+
* @param name
|
|
13
|
+
* @param payload
|
|
14
|
+
*/
|
|
15
|
+
storage(name?: string, payload?: any): any | Record<any, any>;
|
|
16
|
+
cookie(): void;
|
|
17
|
+
/**
|
|
18
|
+
* Session storage
|
|
19
|
+
* @param name
|
|
20
|
+
* @param payload
|
|
21
|
+
*/
|
|
22
|
+
session(name?: string, payload?: any): any | Record<any, any>;
|
|
23
|
+
/**
|
|
24
|
+
* Method http
|
|
25
|
+
* 发起一个http请求
|
|
26
|
+
* @param api
|
|
27
|
+
* @param data
|
|
28
|
+
* @param handle
|
|
29
|
+
*/
|
|
30
|
+
http(api: any, data: any, handle: any): Promise<TResponseDataReturn | IResponseReturn | undefined>;
|
|
31
|
+
/**
|
|
32
|
+
* 发送一个Http请求
|
|
33
|
+
* @param api
|
|
34
|
+
* @param data
|
|
35
|
+
* @param handle
|
|
36
|
+
* @param config
|
|
37
|
+
* @param returnResponse
|
|
38
|
+
*/
|
|
39
|
+
send(api: any, data: any, handle: any, config: any, returnResponse?: boolean): Promise<TResponseDataReturn | IResponseReturn>;
|
|
40
|
+
checkAuth(): void;
|
|
41
|
+
cookies(name: string): Record<any, any>;
|
|
42
|
+
cookies(name: string, payload?: any): void;
|
|
43
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
declare type Type = "localStorage" | "sessionStorage";
|
|
2
|
+
/**
|
|
3
|
+
* Class WebStorage
|
|
4
|
+
* 浏览器存储
|
|
5
|
+
*/
|
|
6
|
+
export default class WebStorage {
|
|
7
|
+
type: Type;
|
|
8
|
+
storage: Storage;
|
|
9
|
+
/**
|
|
10
|
+
* constructor
|
|
11
|
+
* @param {String} type 存储类型
|
|
12
|
+
*/
|
|
13
|
+
constructor({ type }: {
|
|
14
|
+
type: Type;
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* get get|getAll storage
|
|
18
|
+
* @param key
|
|
19
|
+
*/
|
|
20
|
+
get(key?: string): string | any;
|
|
21
|
+
/**
|
|
22
|
+
* set
|
|
23
|
+
* Set storage 保持/设置数据
|
|
24
|
+
* @param key
|
|
25
|
+
* @param value
|
|
26
|
+
*/
|
|
27
|
+
set(key: string, value: string | any[] | Record<any, any>): void;
|
|
28
|
+
/**
|
|
29
|
+
* save
|
|
30
|
+
* Save storage as set set的别名
|
|
31
|
+
* @param key
|
|
32
|
+
* @param value
|
|
33
|
+
*/
|
|
34
|
+
save(key: string, value: string | any[] | Record<any, any>): void;
|
|
35
|
+
/**
|
|
36
|
+
* delete
|
|
37
|
+
* Delete storage 删除一个或数组内多个
|
|
38
|
+
* @param {String|Array<string>} key
|
|
39
|
+
*/
|
|
40
|
+
delete(key: string | string[]): void;
|
|
41
|
+
/**
|
|
42
|
+
* remove
|
|
43
|
+
* Remove storage as delete delete的别名
|
|
44
|
+
* @param key
|
|
45
|
+
*/
|
|
46
|
+
remove(key: string | string[]): void;
|
|
47
|
+
/**
|
|
48
|
+
* clear
|
|
49
|
+
* Clear storage 清空
|
|
50
|
+
*/
|
|
51
|
+
clear(): void;
|
|
52
|
+
/**
|
|
53
|
+
* keys
|
|
54
|
+
* Get storage keys 获取全部键
|
|
55
|
+
* @return keys
|
|
56
|
+
*/
|
|
57
|
+
keys(): string[];
|
|
58
|
+
/**
|
|
59
|
+
* getAll
|
|
60
|
+
* Get storage key & val 获取全部键值对
|
|
61
|
+
*/
|
|
62
|
+
getAll(): Record<any, any>;
|
|
63
|
+
/**
|
|
64
|
+
* setConfig
|
|
65
|
+
* @param type
|
|
66
|
+
*/
|
|
67
|
+
setConfig({ type }: {
|
|
68
|
+
type: Type;
|
|
69
|
+
}): void;
|
|
70
|
+
}
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exception Class
|
|
3
|
+
* 目前原生的错误类型
|
|
4
|
+
* Error [一般错误类型]
|
|
5
|
+
* SyntaxError [语法错误]
|
|
6
|
+
* ReferenceError [不存在的变量]
|
|
7
|
+
* RangeError [超出有效范围]
|
|
8
|
+
* TypeError [非预期类型]
|
|
9
|
+
* URIError [URI参数错误]
|
|
10
|
+
* EvalError [eval函数没有正确执行]
|
|
11
|
+
* Example: throw new Exception() catch(error) error.name,error.message,error.code,error.stack
|
|
12
|
+
*/
|
|
13
|
+
export default class Exception extends Error {
|
|
14
|
+
name: string;
|
|
15
|
+
message: string;
|
|
16
|
+
code: number;
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param {String} name 错误名称
|
|
20
|
+
* @param {String} message 错误提示
|
|
21
|
+
* @param {Number} code 错误码
|
|
22
|
+
*/
|
|
23
|
+
constructor(name: string, message: string, code?: number);
|
|
24
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
declare type variableType = "string" | "number" | "object" | "undefined" | "function" | "boolean" | "bigInt" | "symbol";
|
|
2
|
+
declare type TrimType = "R" | "L" | "";
|
|
3
|
+
/**
|
|
4
|
+
* Class Lib
|
|
5
|
+
* 基础函数库,Lodash、Underscore... So big
|
|
6
|
+
*/
|
|
7
|
+
export default class Lib {
|
|
8
|
+
/**
|
|
9
|
+
* typeOf 判断变量类型
|
|
10
|
+
* @param value
|
|
11
|
+
* @param type
|
|
12
|
+
*/
|
|
13
|
+
static typeOf<T>(value: unknown, type: variableType): value is T;
|
|
14
|
+
/**
|
|
15
|
+
* getTag 判断变量类型
|
|
16
|
+
* @param value
|
|
17
|
+
*/
|
|
18
|
+
static getTag(value: unknown): string;
|
|
19
|
+
/**
|
|
20
|
+
* isFunction 是否函数
|
|
21
|
+
* @param {Function} value
|
|
22
|
+
* @return {Boolean}
|
|
23
|
+
*/
|
|
24
|
+
static isFunction(value: unknown): value is typeof Function;
|
|
25
|
+
/**
|
|
26
|
+
* isString 是否字符串
|
|
27
|
+
* @param {String} value
|
|
28
|
+
* @return {Boolean}
|
|
29
|
+
*/
|
|
30
|
+
static isString(value: unknown): value is string;
|
|
31
|
+
/**
|
|
32
|
+
* isNumber 是否数字
|
|
33
|
+
* @param value
|
|
34
|
+
* @return {Boolean}
|
|
35
|
+
*/
|
|
36
|
+
static isNumber(value: unknown): value is number;
|
|
37
|
+
/**
|
|
38
|
+
* isObject 是否对象
|
|
39
|
+
* @param {Object} value
|
|
40
|
+
*/
|
|
41
|
+
static isObject(value: unknown): value is Record<any, any>;
|
|
42
|
+
/**
|
|
43
|
+
* isObject 是否Undefined
|
|
44
|
+
* @param {*} value
|
|
45
|
+
* @return boolean
|
|
46
|
+
*/
|
|
47
|
+
static isUndefined(value: unknown): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* isNull 是否Null
|
|
50
|
+
* @param value
|
|
51
|
+
*/
|
|
52
|
+
static isNull(value: unknown): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* isEmpty 是否空
|
|
55
|
+
* 目前只对 null undefined '' {} [] 做处理
|
|
56
|
+
* @param value
|
|
57
|
+
*/
|
|
58
|
+
static isEmpty(value: unknown): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* isClass 是否类
|
|
61
|
+
* @param value
|
|
62
|
+
*/
|
|
63
|
+
static isClass(value: unknown): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* 字符串去除首尾字符
|
|
66
|
+
* @param str 字符串
|
|
67
|
+
* @param char 字符
|
|
68
|
+
* @param type 类型
|
|
69
|
+
*/
|
|
70
|
+
static strTrim(str: string, char: string, type?: TrimType): string;
|
|
71
|
+
}
|
|
72
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import ServiceProvider from "./ServiceProvider";
|
|
2
|
+
/**
|
|
3
|
+
* @name HttpProvider
|
|
4
|
+
* @description HTTP服务提供者,对HTTP服务进行注册
|
|
5
|
+
*/
|
|
6
|
+
export default class HttpProvider extends ServiceProvider {
|
|
7
|
+
/**
|
|
8
|
+
* Method Register
|
|
9
|
+
* 注册服务
|
|
10
|
+
* @protected
|
|
11
|
+
*/
|
|
12
|
+
register(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IApplicationInstance } from '../Type/types';
|
|
2
|
+
export default abstract class ServiceProvider {
|
|
3
|
+
protected app: import("../Type/types").IApplication;
|
|
4
|
+
/**
|
|
5
|
+
* constructor
|
|
6
|
+
* @param app Application instance
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
constructor(app: IApplicationInstance);
|
|
10
|
+
/**
|
|
11
|
+
* register
|
|
12
|
+
* 注册 provider
|
|
13
|
+
*/
|
|
14
|
+
register(): void;
|
|
15
|
+
}
|