plugin-tls 0.0.0 → 1.1.0
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/README.md +5 -5
- package/dist/extend/extend.d.ts +222 -0
- package/dist/extend/extend.d.ts.map +1 -0
- package/dist/extend/mixin.d.ts +105 -0
- package/dist/extend/mixin.d.ts.map +1 -0
- package/dist/index.d.ts +14 -4
- package/dist/index.d.ts.map +1 -0
- package/dist/options-manager/ModeOptions.d.ts +88 -0
- package/dist/options-manager/ModeOptions.d.ts.map +1 -0
- package/dist/options-manager/OptionsManager.d.ts +105 -0
- package/dist/options-manager/OptionsManager.d.ts.map +1 -0
- package/dist/options-manager/TierModeOptions.d.ts +69 -0
- package/dist/options-manager/TierModeOptions.d.ts.map +1 -0
- package/dist/options-manager/TierOptions.d.ts +48 -0
- package/dist/options-manager/TierOptions.d.ts.map +1 -0
- package/dist/{defaultOptions.d.ts → options-manager/defaultOptions.d.ts} +2 -1
- package/dist/options-manager/defaultOptions.d.ts.map +1 -0
- package/dist/options-manager/tools.d.ts +35 -0
- package/dist/options-manager/tools.d.ts.map +1 -0
- package/dist/plugin-host/PluginHost.d.ts +184 -0
- package/dist/plugin-host/PluginHost.d.ts.map +1 -0
- package/dist/plugin-host/TierModeOptionsPluginHost.d.ts +102 -0
- package/dist/plugin-host/TierModeOptionsPluginHost.d.ts.map +1 -0
- package/dist/plugin-host/TierOptionsPluginHost.d.ts +83 -0
- package/dist/plugin-host/TierOptionsPluginHost.d.ts.map +1 -0
- package/dist/plugin-manager/PluginManager.d.ts +119 -0
- package/dist/plugin-manager/PluginManager.d.ts.map +1 -0
- package/dist/plugin-manager/PluginManagerWithInit.d.ts +36 -0
- package/dist/plugin-manager/PluginManagerWithInit.d.ts.map +1 -0
- package/dist/plugin-tls.d.ts +1329 -0
- package/dist/plugin-tls.iife.js +1 -0
- package/dist/plugin-tls.mjs +1064 -0
- package/dist/plugin-tls.umd.js +1 -1
- package/dist/properties.d.ts +30 -0
- package/dist/properties.d.ts.map +1 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/doc/{plugin-tls.adddefaultoptions.md → api/plugin-tls.adddefaultoptions.md} +3 -3
- package/doc/{plugin-tls.addinstoptions.md → api/plugin-tls.addinstoptions.md} +2 -2
- package/doc/api/plugin-tls.allfunctionapply.md +26 -0
- package/doc/api/plugin-tls.becomepluginhost.md +15 -0
- package/doc/api/plugin-tls.becomepluginhost_extends.md +38 -0
- package/doc/api/plugin-tls.becomepluginhost_proxy.md +29 -0
- package/doc/api/plugin-tls.becometiermodeoptionshost.md +15 -0
- package/doc/api/plugin-tls.becometieroptionshost.md +15 -0
- package/doc/api/plugin-tls.classextender.md +15 -0
- package/doc/api/plugin-tls.classextenderprivatemember._constructors.md +13 -0
- package/doc/api/plugin-tls.classextenderprivatemember._destroys.md +13 -0
- package/doc/api/plugin-tls.classextenderprivatemember.md +21 -0
- package/doc/api/plugin-tls.classextenderprivatememberwithinit._inits.md +13 -0
- package/doc/api/plugin-tls.classextenderprivatememberwithinit.md +21 -0
- package/doc/api/plugin-tls.classextenderwithinit.md +15 -0
- package/doc/api/plugin-tls.classtype._new_.md +22 -0
- package/doc/api/plugin-tls.classtype.md +20 -0
- package/doc/api/plugin-tls.commonmodename.md +18 -0
- package/doc/api/plugin-tls.createcallerofprivatememberofextend.md +30 -0
- package/doc/api/plugin-tls.createdefinemixin.md +23 -0
- package/doc/api/plugin-tls.createextendtarget.md +30 -0
- package/doc/api/plugin-tls.createextendtargetwithinit.md +30 -0
- package/doc/api/plugin-tls.createmixintarget.md +30 -0
- package/doc/api/plugin-tls.createpluginhost.md +35 -0
- package/doc/api/plugin-tls.createpropertysetter.md +30 -0
- package/doc/api/plugin-tls.createtargetextend.md +30 -0
- package/doc/api/plugin-tls.createtargetextendwithinit.md +30 -0
- package/doc/api/plugin-tls.createtargetmixin.md +30 -0
- package/doc/api/plugin-tls.createtiermodeoptionspluginhost.md +32 -0
- package/doc/api/plugin-tls.createtieroptionspluginhost.md +30 -0
- package/doc/api/plugin-tls.defineextend.md +35 -0
- package/doc/api/plugin-tls.defineextendwithinit.md +35 -0
- package/doc/api/plugin-tls.definemixin.md +31 -0
- package/doc/api/plugin-tls.extendtarget.md +31 -0
- package/doc/api/plugin-tls.extendtargetwithinit.md +31 -0
- package/doc/api/plugin-tls.formatuseparameters.md +13 -0
- package/doc/api/plugin-tls.formatusepluginparameters.md +15 -0
- package/doc/api/plugin-tls.getnormalizepluginoptions.md +15 -0
- package/doc/api/plugin-tls.getpluginoptions.md +15 -0
- package/doc/api/plugin-tls.getpropertyvalue.md +26 -0
- package/doc/api/plugin-tls.getpropertyvaluebypath.md +26 -0
- package/doc/api/plugin-tls.gettargetproperties.md +26 -0
- package/doc/{plugin-tls.hostinst.md → api/plugin-tls.hostinst.md} +2 -2
- package/doc/{plugin-tls.idefaultoptionshost.defaultoptions.md → api/plugin-tls.idefaultoptionshost.defaultoptions.md} +1 -1
- package/doc/{plugin-tls.idefaultoptionshost.md → api/plugin-tls.idefaultoptionshost.md} +1 -1
- package/doc/{plugin-tls.iidefaultoptionshostconstructor.md → api/plugin-tls.iidefaultoptionshostconstructor.md} +1 -1
- package/doc/{plugin-tls.iplugin.created.md → api/plugin-tls.iplugin.created.md} +4 -4
- package/doc/api/plugin-tls.iplugin.destroyed.md +25 -0
- package/doc/{plugin-tls.iplugin.md → api/plugin-tls.iplugin.md} +4 -3
- package/doc/{plugin-tls.iplugin.used.md → api/plugin-tls.iplugin.used.md} +4 -4
- package/doc/{plugin-tls.ipluginhost.md → api/plugin-tls.ipluginhost.md} +2 -2
- package/doc/{plugin-tls.ipluginhost.use.md → api/plugin-tls.ipluginhost.use.md} +6 -6
- package/doc/{plugin-tls.ipluginhostconstructor.md → api/plugin-tls.ipluginhostconstructor.md} +2 -2
- package/doc/{plugin-tls.ipluginhostconstructor.use.md → api/plugin-tls.ipluginhostconstructor.use.md} +6 -6
- package/doc/api/plugin-tls.ipluginwithinit.inited.md +25 -0
- package/doc/api/plugin-tls.ipluginwithinit.md +21 -0
- package/doc/api/plugin-tls.itiermodeoptionshost.md +21 -0
- package/doc/api/plugin-tls.itiermodeoptionshost.mode.md +11 -0
- package/doc/api/plugin-tls.itiermodeoptionshost.modeoptions.md +11 -0
- package/doc/api/plugin-tls.itiermodeoptionshostconstructor.md +13 -0
- package/doc/api/plugin-tls.itiermodeoptionspluginhost.md +15 -0
- package/doc/api/plugin-tls.itiermodeoptionspluginhostconstructor.md +15 -0
- package/doc/api/plugin-tls.itieroptionshost.defaultoptions.md +11 -0
- package/doc/api/plugin-tls.itieroptionshost.md +20 -0
- package/doc/api/plugin-tls.itieroptionshostconstructor.md +13 -0
- package/doc/api/plugin-tls.itieroptionspluginhost.md +15 -0
- package/doc/api/plugin-tls.itieroptionspluginhostconstructor.md +15 -0
- package/doc/api/plugin-tls.md +121 -0
- package/doc/api/plugin-tls.mergeproperties.md +25 -0
- package/doc/api/plugin-tls.mixin_4.md +33 -0
- package/doc/api/plugin-tls.mixintarget.md +31 -0
- package/doc/api/plugin-tls.modeoptions._constructor_.md +20 -0
- package/doc/api/plugin-tls.modeoptions._constructor__1.md +21 -0
- package/doc/api/plugin-tls.modeoptions._mode.md +11 -0
- package/doc/api/plugin-tls.modeoptions._modenames.md +11 -0
- package/doc/api/plugin-tls.modeoptions._plainfulloption.md +11 -0
- package/doc/api/plugin-tls.modeoptions.getfullmodeoption.md +29 -0
- package/doc/api/plugin-tls.modeoptions.getmodenames.md +18 -0
- package/doc/api/plugin-tls.modeoptions.getmodeoption.md +29 -0
- package/doc/api/plugin-tls.modeoptions.hasmode.md +25 -0
- package/doc/api/plugin-tls.modeoptions.md +57 -0
- package/doc/api/plugin-tls.modeoptions.mode.md +15 -0
- package/doc/api/plugin-tls.modeoptions.modenames.md +13 -0
- package/doc/api/plugin-tls.modeoptions.modes.md +13 -0
- package/doc/api/plugin-tls.modeoptions.option.md +13 -0
- package/doc/api/plugin-tls.modeoptions.optionmanager.md +13 -0
- package/doc/api/plugin-tls.modeoptions.plainfulloption.md +11 -0
- package/doc/api/plugin-tls.modeoptions.setmodeoption.md +27 -0
- package/doc/api/plugin-tls.modeoptions.updatefulloption.md +17 -0
- package/doc/api/plugin-tls.normalizepluginoptions.md +18 -0
- package/doc/api/plugin-tls.parsepropertypath.md +25 -0
- package/doc/{plugin-tls.plugincreatedreturntype.md → api/plugin-tls.plugincreatedreturntype.md} +3 -3
- package/doc/{plugin-tls.pluginhost._pluginmanager.md → api/plugin-tls.pluginhost._pluginmanager.md} +2 -2
- package/doc/api/plugin-tls.pluginhost.destroy.md +18 -0
- package/doc/api/plugin-tls.pluginhost.md +38 -0
- package/doc/{plugin-tls.pluginhost.pluginmanager.md → api/plugin-tls.pluginhost.pluginmanager.md} +2 -2
- package/doc/{plugin-tls.pluginhost.use.md → api/plugin-tls.pluginhost.use.md} +5 -5
- package/doc/api/plugin-tls.pluginmanager._constructor_.md +20 -0
- package/doc/{plugin-tls.pluginmanager.created.md → api/plugin-tls.pluginmanager.created.md} +4 -4
- package/doc/api/plugin-tls.pluginmanager.destroyed.md +28 -0
- package/doc/{plugin-tls.pluginmanager.host.md → api/plugin-tls.pluginmanager.host.md} +2 -2
- package/doc/api/plugin-tls.pluginmanager.instuse.md +30 -0
- package/doc/{plugin-tls.pluginmanager.md → api/plugin-tls.pluginmanager.md} +12 -5
- package/doc/{plugin-tls.pluginmanager.pluginoptsmap.md → api/plugin-tls.pluginmanager.pluginoptsmap.md} +2 -2
- package/doc/{plugin-tls.pluginmanager.plugins.md → api/plugin-tls.pluginmanager.plugins.md} +2 -2
- package/doc/{plugin-tls.pluginmanager.use.md → api/plugin-tls.pluginmanager.use.md} +6 -6
- package/doc/api/plugin-tls.pluginmanagerwithinit.inited.md +28 -0
- package/doc/api/plugin-tls.pluginmanagerwithinit.md +25 -0
- package/doc/{plugin-tls.pluginusereturntype.md → api/plugin-tls.pluginusereturntype.md} +3 -3
- package/doc/api/plugin-tls.privatememberofextend._constructor.md +32 -0
- package/doc/api/plugin-tls.privatememberofextend._destroy.md +25 -0
- package/doc/api/plugin-tls.privatememberofextend.md +21 -0
- package/doc/api/plugin-tls.privatememberofextendwithinit._init.md +28 -0
- package/doc/api/plugin-tls.privatememberofextendwithinit.md +21 -0
- package/doc/api/plugin-tls.replaceconstructorparameters.md +13 -0
- package/doc/api/plugin-tls.replaceconstructorreturn.md +13 -0
- package/doc/api/plugin-tls.setpropertyvalue.md +27 -0
- package/doc/api/plugin-tls.setpropertyvaluebypath.md +27 -0
- package/doc/api/plugin-tls.targetextend.md +31 -0
- package/doc/api/plugin-tls.targetextendwithinit.md +31 -0
- package/doc/api/plugin-tls.targetmixin.md +31 -0
- package/doc/api/plugin-tls.tiermodeoptions._constructor_.md +20 -0
- package/doc/api/plugin-tls.tiermodeoptions._constructor__1.md +22 -0
- package/doc/api/plugin-tls.tiermodeoptions._extends.md +11 -0
- package/doc/api/plugin-tls.tiermodeoptions.extends.md +15 -0
- package/doc/api/plugin-tls.tiermodeoptions.getfullmodeoption.md +29 -0
- package/doc/api/plugin-tls.tiermodeoptions.getmember.md +25 -0
- package/doc/api/plugin-tls.tiermodeoptions.getmodenames.md +18 -0
- package/doc/api/plugin-tls.tiermodeoptions.getmodeoptionmanager.md +25 -0
- package/doc/api/plugin-tls.tiermodeoptions.getvalue.md +25 -0
- package/doc/api/plugin-tls.tiermodeoptions.hasmodeontier.md +25 -0
- package/doc/api/plugin-tls.tiermodeoptions.md +45 -0
- package/doc/api/plugin-tls.tiermodeoptions.optionmanager.md +13 -0
- package/doc/api/plugin-tls.tiermodeoptionsdecorator.md +30 -0
- package/doc/api/plugin-tls.tiermodeoptionspluginhost._constructor_.md +20 -0
- package/doc/api/plugin-tls.tiermodeoptionspluginhost._modeoptions.md +11 -0
- package/doc/api/plugin-tls.tiermodeoptionspluginhost.md +37 -0
- package/doc/api/plugin-tls.tiermodeoptionspluginhost.mode.md +13 -0
- package/doc/api/plugin-tls.tiermodeoptionspluginhost.modeoptions.md +13 -0
- package/doc/api/plugin-tls.tiermodeoptionspluginhost.options.md +11 -0
- package/doc/api/plugin-tls.tieroptions._constructor_.md +21 -0
- package/doc/api/plugin-tls.tieroptions._extends.md +11 -0
- package/doc/api/plugin-tls.tieroptions._plainfulloption.md +11 -0
- package/doc/api/plugin-tls.tieroptions.extends.md +15 -0
- package/doc/api/plugin-tls.tieroptions.getmember.md +25 -0
- package/doc/api/plugin-tls.tieroptions.getvalue.md +25 -0
- package/doc/api/plugin-tls.tieroptions.md +37 -0
- package/doc/api/plugin-tls.tieroptions.option.md +13 -0
- package/doc/api/plugin-tls.tieroptions.plainfulloption.md +18 -0
- package/doc/api/plugin-tls.tieroptions.updatefulloption.md +17 -0
- package/doc/api/plugin-tls.tieroptionsdecorator.md +30 -0
- package/doc/api/plugin-tls.tieroptionspluginhost._constructor_.md +20 -0
- package/doc/api/plugin-tls.tieroptionspluginhost._defaultoptions.md +11 -0
- package/doc/api/plugin-tls.tieroptionspluginhost.defaultoptions.md +13 -0
- package/doc/api/plugin-tls.tieroptionspluginhost.md +35 -0
- package/package.json +23 -15
- package/dist/OptionsPluginHost.d.ts +0 -49
- package/dist/PluginHost.d.ts +0 -96
- package/dist/PluginManager.d.ts +0 -76
- package/dist/plugin-tls.es.js +0 -170
- package/doc/plugin-tls.createoptionspluginhost.md +0 -29
- package/doc/plugin-tls.createpluginhost.md +0 -30
- package/doc/plugin-tls.ioptionspluginhost.defaultoptions.md +0 -11
- package/doc/plugin-tls.ioptionspluginhost.md +0 -21
- package/doc/plugin-tls.ioptionspluginhostconstructor.md +0 -15
- package/doc/plugin-tls.md +0 -53
- package/doc/plugin-tls.optionspluginhost._defaultoptions.md +0 -11
- package/doc/plugin-tls.optionspluginhost.defaultoptions.md +0 -13
- package/doc/plugin-tls.optionspluginhost.md +0 -21
- package/doc/plugin-tls.pluginhost._constructor_.md +0 -13
- package/doc/plugin-tls.pluginhost.md +0 -25
- package/doc/plugin-tls.pluginmanager.instuse.md +0 -30
- package/doc/plugin-tls.pluginoptions.md +0 -11
- /package/doc/{index.md → api/index.md} +0 -0
|
@@ -0,0 +1,1329 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 插件系统
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* 主要负责 SDK 的插件机制的实现
|
|
6
|
+
* 插件系统应该具备以下功能:
|
|
7
|
+
* - 注册插件
|
|
8
|
+
* - 可扩展类的静态级功能
|
|
9
|
+
* - 可扩展类的实例级功能
|
|
10
|
+
* - 可自定义暴露的功能
|
|
11
|
+
* - 可拥有私有自身的API
|
|
12
|
+
*
|
|
13
|
+
* 额外的也提供了其它的功能
|
|
14
|
+
* - 全局选项
|
|
15
|
+
* - 实例选项
|
|
16
|
+
*
|
|
17
|
+
* @packageDocumentation
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { AnyFunction } from 'type-tls';
|
|
21
|
+
import type { Optional } from 'type-tls';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 创建增加带有选项机制的装饰器
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* 类装饰器的工厂函数
|
|
28
|
+
*
|
|
29
|
+
* @param options - 选项内容
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
export declare function addDefaultOptions<Options>(options: Options, name?: Optional<string>): <Clas extends new (...args: any) => any>(target: Clas) => void;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 创建增加带有选项机制的装饰器
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* 静态属性装饰器
|
|
39
|
+
*
|
|
40
|
+
* @param options - 选项内容
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
export declare function addInstOptions<Clas extends new (...args: any) => any>(target: Clas, propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 对一组函数批量调用 apply
|
|
47
|
+
* @param funArr
|
|
48
|
+
* @param thisArg
|
|
49
|
+
* @param args
|
|
50
|
+
*/
|
|
51
|
+
export declare function allFunctionApply<T, A extends any[], R>(funArr: ((this: T, ...args: A) => void)[], thisArg: T, args: A): void;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 将 HOST 变成插件宿主类型
|
|
55
|
+
*/
|
|
56
|
+
export declare type BecomePluginHost<HOST extends new (...args: any) => any, Plugin extends IPlugin<HOST, any> = IPlugin<HOST, any>> = HOST & IPluginHostConstructor<HOST & IPluginHostConstructor<HOST, Plugin>, Plugin> & ReplaceConstructorReturn<HOST, InstanceType<HOST> & IPluginHost<HOST & IPluginHostConstructor<HOST & IPluginHostConstructor<HOST, Plugin>, Plugin>>>;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 变成插件宿主
|
|
60
|
+
* @remarks
|
|
61
|
+
* 也可作为装饰器
|
|
62
|
+
*
|
|
63
|
+
* 子类需要在构建函数中调用 `this.pluginManager.created(this);`
|
|
64
|
+
*
|
|
65
|
+
* 之所以没写在该类中的函数中,是因为 `this.pluginManager.created(this)` 通常会在构建函数执行的最后时才调用;
|
|
66
|
+
* 如果像下面写在该类的构建函数中,然后子类通过 `super()` 来调用,这样就会导致 `this.pluginManager.created(this)` 不是在最后的执行;
|
|
67
|
+
* @param target
|
|
68
|
+
* @param context
|
|
69
|
+
* @returns
|
|
70
|
+
*/
|
|
71
|
+
export declare function becomePluginHost<HOST extends new (...args: any) => any, Plugin extends IPlugin<HOST, any> = IPlugin<HOST, any>>(target: HOST): BecomePluginHost<HOST, Plugin>;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 插件缩主类的装饰器(继承版)
|
|
75
|
+
* @remarks
|
|
76
|
+
* 通过继承实现
|
|
77
|
+
*/
|
|
78
|
+
export declare function becomePluginHost_Extends<HOST extends new (...args: any) => any>(target: HOST): {
|
|
79
|
+
new (...args: any): {
|
|
80
|
+
[x: string]: any;
|
|
81
|
+
/**
|
|
82
|
+
* 插件管理器 {@link PluginHost.pluginManager}
|
|
83
|
+
*/
|
|
84
|
+
readonly pluginManager: PluginManager<any & HOST, IPlugin<any & HOST, any>>;
|
|
85
|
+
/**
|
|
86
|
+
* 实例的注册插件的方法
|
|
87
|
+
* @param plugin
|
|
88
|
+
* @param options
|
|
89
|
+
* @returns
|
|
90
|
+
*/
|
|
91
|
+
use<Plugin_1 extends IPlugin<any & HOST, any>>(plugin: Plugin_1, ...options: FormatUsePluginParameters<Plugin_1>): void | PluginCreatedReturnType<Plugin_1>;
|
|
92
|
+
/**
|
|
93
|
+
* 销毁实例
|
|
94
|
+
* @returns
|
|
95
|
+
*/
|
|
96
|
+
destroy(): void;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* 插件管理器
|
|
100
|
+
*/
|
|
101
|
+
readonly pluginManager: PluginManager<any & HOST, IPlugin<any & HOST, any>>;
|
|
102
|
+
_pluginManager: PluginManager<any & HOST, IPlugin<any & HOST, any>>;
|
|
103
|
+
/**
|
|
104
|
+
* {@inheritDoc PluginManager.use}
|
|
105
|
+
*/
|
|
106
|
+
use<Plugin_2 extends IPlugin<any & HOST, any>>(plugin: Plugin_2, ...options: FormatUsePluginParameters<Plugin_2>): void | ReturnType<Plugin_2["used"]>;
|
|
107
|
+
} & HOST;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* 变成插件宿主
|
|
111
|
+
* @remarks
|
|
112
|
+
* 也可作为装饰器
|
|
113
|
+
* @param target
|
|
114
|
+
* @param context
|
|
115
|
+
* @returns
|
|
116
|
+
*/
|
|
117
|
+
export declare function becomePluginHost_Proxy<HOST extends new (...args: any) => any, Plugin extends IPlugin<HOST, any> = IPlugin<HOST, any>>(target: HOST): HOST;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* 使 HOST 变成 层级选项的宿主类型
|
|
121
|
+
*/
|
|
122
|
+
export declare type BecomeTierModeOptionsHost<HOST extends new (...args: any) => any, Options extends {} = any, Mode extends string | number = string> = HOST & ITierModeOptionsHostConstructor<Options, Mode> & ReplaceConstructorReturn<HOST, InstanceType<HOST> & ITierModeOptionsHost<Options, Mode>>;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 使 host 变成 层级选项的宿主类型
|
|
126
|
+
* @param host
|
|
127
|
+
* @param context
|
|
128
|
+
* @returns
|
|
129
|
+
*/
|
|
130
|
+
export declare function becomeTierModeOptionsHost<HOST extends new (...args: any) => any, Mode extends string | number, Options extends {}>(host: HOST, mode: Mode, options?: Options): BecomeTierModeOptionsHost<HOST, Options, Mode>;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* 使 HOST 变成 层级选项的宿主类型
|
|
134
|
+
*/
|
|
135
|
+
export declare type BecomeTierOptionsHost<HOST extends new (...args: any) => any, Options extends {} = any> = HOST & ITierOptionsHostConstructor<Options> & ReplaceConstructorReturn<HOST, InstanceType<HOST> & ITierOptionsHost<Options>>;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* 使 host 变成 层级选项的宿主类型
|
|
139
|
+
* @param host
|
|
140
|
+
* @param context
|
|
141
|
+
* @returns
|
|
142
|
+
*/
|
|
143
|
+
export declare function becomeTierOptionsHost<HOST extends new (...args: any) => any, Options extends {} = any>(host: HOST, option?: Options): BecomeTierOptionsHost<HOST, any>;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* 类扩展者
|
|
147
|
+
*/
|
|
148
|
+
export declare type ClassExtender<C extends new (...args: any) => any> = C & ClassExtenderPrivateMember<C>;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* 类扩展者的私有方法
|
|
152
|
+
*/
|
|
153
|
+
export declare interface ClassExtenderPrivateMember<C extends new (...args: any) => any> {
|
|
154
|
+
/**
|
|
155
|
+
* 保存扩展类自定义的构建函数
|
|
156
|
+
*/
|
|
157
|
+
readonly _constructors: ((this: InstanceType<C>, ...args: ConstructorParameters<C>) => void)[];
|
|
158
|
+
/**
|
|
159
|
+
* 保存扩展类自定义的销毁函数
|
|
160
|
+
*/
|
|
161
|
+
readonly _destroys: ((this: InstanceType<C>) => void)[];
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* 类扩展者的私有方法
|
|
166
|
+
*/
|
|
167
|
+
export declare interface ClassExtenderPrivateMemberWithInit<C extends new (...args: any) => any, InitParams extends any[] = any> extends ClassExtenderPrivateMember<C> {
|
|
168
|
+
/**
|
|
169
|
+
* 保存扩展类中自定义的初始化方法
|
|
170
|
+
*/
|
|
171
|
+
readonly _inits: ((this: InstanceType<C>, ...args: InitParams) => void)[];
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 类扩展者
|
|
176
|
+
*/
|
|
177
|
+
export declare type ClassExtenderWithInit<C extends new (...args: any) => any, InitParams extends any[] = any> = C & ClassExtenderPrivateMemberWithInit<C, InitParams>;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* 类的类型、构造函数的类型
|
|
181
|
+
*
|
|
182
|
+
* @typeParam Arg - 构建函数的参数类型
|
|
183
|
+
* @typeParam Instance - 构建函数的返回的实例类型
|
|
184
|
+
*/
|
|
185
|
+
export declare interface ClassType<Arg extends any[] = any, Instance = any> {
|
|
186
|
+
new (...args: Arg): Instance;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* 一般模式的名字
|
|
191
|
+
* @remarks
|
|
192
|
+
* 一般模式,其它模式可以继承该模式
|
|
193
|
+
*/
|
|
194
|
+
export declare const commonModeName = "common";
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* 创建扩展的私有方法的调用者
|
|
198
|
+
* @param cla
|
|
199
|
+
* @returns constructed:执行所有 `_constructor` 的便利函数;initialized:执行所有 `_inits` 的便利函数
|
|
200
|
+
*/
|
|
201
|
+
export declare function createCallerOfPrivateMemberOfExtend<C extends ClassType>(cla: C): {
|
|
202
|
+
constructed: (thisArg: any, args: any[]) => void;
|
|
203
|
+
initialized: (thisArg: any, args: any[]) => void;
|
|
204
|
+
destroyed: (thisArg: any, args: any[]) => void;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* 创建定义混合的类型便利函数
|
|
209
|
+
*
|
|
210
|
+
* @remarks
|
|
211
|
+
* 它返回的便利函数的功能与 {@link defineMixin} 的功能一样,唯一区别是不再需要接收 target 参数了
|
|
212
|
+
*
|
|
213
|
+
* @returns 可以用于 定义混合的 类型便利函数
|
|
214
|
+
*/
|
|
215
|
+
export declare function createDefineMixin<T>(): <M>(target: T, mixin: M & ThisType<T & M>) => M & ThisType<T & M>;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* 创建用于扩展目标工具函数
|
|
219
|
+
*
|
|
220
|
+
* @remarks
|
|
221
|
+
* 它返回的便利函数的功能与 {@link extendTarget} 的功能一样,唯一区别是不再需要接收 cla 参数了
|
|
222
|
+
*
|
|
223
|
+
* @param cla - 扩展的目标,也用作 this 的类型
|
|
224
|
+
* @returns 可以用于 扩展目标 的便利函数
|
|
225
|
+
*/
|
|
226
|
+
export declare function createExtendTarget<C extends ClassType>(cla: C): <E>(ext: E & ThisType<InstanceType<C> & E> & PrivateMemberOfExtend<C>) => ClassType<ConstructorParameters<C>, E & ThisType<InstanceType<C> & E>>;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* 创建用于扩展目标工具函数
|
|
230
|
+
*
|
|
231
|
+
* @remarks
|
|
232
|
+
* 它返回的便利函数的功能与 {@link extendTargetWithInit} 的功能一样,唯一区别是不再需要接收 cla 参数了
|
|
233
|
+
*
|
|
234
|
+
* @param cla - 扩展的目标,也用作 this 的类型
|
|
235
|
+
* @returns 可以用于 扩展目标 的便利函数
|
|
236
|
+
*/
|
|
237
|
+
export declare function createExtendTargetWithInit<C extends ClassType>(cla: C): <E>(ext: E & ThisType<InstanceType<C> & E> & PrivateMemberOfExtendWithInit<C, any>) => ClassType<ConstructorParameters<C>, E & ThisType<InstanceType<C> & E>>;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* 创建用于混合目标工具函数
|
|
241
|
+
*
|
|
242
|
+
* @remarks
|
|
243
|
+
* 它返回的便利函数的功能与 {@link mixinTarget} 的功能一样,唯一区别是不再需要接收 target 参数了
|
|
244
|
+
*
|
|
245
|
+
* @returns 可以用于 混合目标 的便利函数
|
|
246
|
+
*/
|
|
247
|
+
export declare function createMixinTarget<T>(target: T): <M>(m: M & ThisType<T & M>) => M & ThisType<T & M> & T;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* 创建插件的缩主类
|
|
251
|
+
*
|
|
252
|
+
* @remarks
|
|
253
|
+
* 比 直接使用 PluginHost 提供了完善的类型推导
|
|
254
|
+
*
|
|
255
|
+
* 子类需要在构建函数中调用 `this.pluginManager.created(this);`
|
|
256
|
+
*
|
|
257
|
+
* 之所以没写在该类中的函数中,是因为 `this.pluginManager.created(this)` 通常会在构建函数执行的最后时才调用;
|
|
258
|
+
* 如果像下面写在该类的构建函数中,然后子类通过 `super()` 来调用,这样就会导致 `this.pluginManager.created(this)` 不是在最后的执行;
|
|
259
|
+
* @returns
|
|
260
|
+
*/
|
|
261
|
+
export declare function createPluginHost<HOST, Plugin extends IPlugin<HOST, any> = IPlugin<HOST, any>>(): {
|
|
262
|
+
new (): {
|
|
263
|
+
/**
|
|
264
|
+
* 插件管理器 {@link CEarth.pluginManager}
|
|
265
|
+
*/
|
|
266
|
+
readonly pluginManager: PluginManager<any, IPlugin<any, any>>;
|
|
267
|
+
/**
|
|
268
|
+
/**
|
|
269
|
+
* 实例的注册插件的方法
|
|
270
|
+
* @param plugin
|
|
271
|
+
* @param options
|
|
272
|
+
* @returns
|
|
273
|
+
*/
|
|
274
|
+
use<P extends Plugin>(plugin: P, ...options: FormatUsePluginParameters<P>): void | PluginCreatedReturnType<P>;
|
|
275
|
+
/**
|
|
276
|
+
* 销毁实例
|
|
277
|
+
* @returns
|
|
278
|
+
*/
|
|
279
|
+
destroy(): void;
|
|
280
|
+
};
|
|
281
|
+
/**
|
|
282
|
+
* PluginHost 的插件管理器
|
|
283
|
+
*/
|
|
284
|
+
readonly pluginManager: PluginManager<typeof PluginHost & HOST, Plugin>;
|
|
285
|
+
_pluginManager: PluginManager<typeof PluginHost & HOST, Plugin>;
|
|
286
|
+
/**
|
|
287
|
+
* {@inheritDoc PluginManager.use}
|
|
288
|
+
*/
|
|
289
|
+
use<P_1 extends Plugin>(plugin: P_1, ...options: FormatUsePluginParameters<P_1>): void | ReturnType<P_1["used"]>;
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* 创建属性设置器
|
|
294
|
+
*
|
|
295
|
+
* @param target
|
|
296
|
+
* @param props
|
|
297
|
+
* @returns 会返回一个 set 和 unset 方法,set 方法用户将 props 中描述的属性值设置到 target 中, unset 方法用于恢复成原来的值
|
|
298
|
+
*/
|
|
299
|
+
export declare function createPropertySetter(target: any, props: any): {
|
|
300
|
+
set: () => void;
|
|
301
|
+
unset: () => void;
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* 创建用于扩展目标的便捷函数
|
|
306
|
+
*
|
|
307
|
+
* @remarks
|
|
308
|
+
* 它返回的便利函数的功能与 {@link targetExtend} 的功能一样,唯一区别是不再需要接收 cla 参数了
|
|
309
|
+
*
|
|
310
|
+
* @param cla - 扩展的目标,也用作 this 的类型
|
|
311
|
+
* @returns 可以用于 扩展目标 的便利函数
|
|
312
|
+
*/
|
|
313
|
+
export declare function createTargetExtend<C extends ClassType>(cla: C): <E>(ext: E & ThisType<InstanceType<C> & E> & PrivateMemberOfExtend<C>) => E & ThisType<C & E>;
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* 创建用于扩展目标的便捷函数
|
|
317
|
+
*
|
|
318
|
+
* @remarks
|
|
319
|
+
* 它返回的便利函数的功能与 {@link targetExtendWithInit} 的功能一样,唯一区别是不再需要接收 cla 参数了
|
|
320
|
+
*
|
|
321
|
+
* @param cla - 扩展的目标,也用作 this 的类型
|
|
322
|
+
* @returns 可以用于 扩展目标 的便利函数
|
|
323
|
+
*/
|
|
324
|
+
export declare function createTargetExtendWithInit<C extends ClassType>(cla: C): <E>(ext: E & ThisType<InstanceType<C> & E> & PrivateMemberOfExtendWithInit<C, any>) => E & ThisType<C & E>;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* 创建用于混合目标的便捷函数
|
|
328
|
+
*
|
|
329
|
+
* @remarks
|
|
330
|
+
* 它返回的便利函数的功能与 {@link targetMixin} 的功能一样,唯一区别是不再需要接收 target 参数了
|
|
331
|
+
*
|
|
332
|
+
* @param target - 混合的目标,用作 this 的类型
|
|
333
|
+
* @returns 可以用于 混合目标 的便利函数
|
|
334
|
+
*/
|
|
335
|
+
export declare function createTargetMixin<T>(target: T): <M>(m: M & ThisType<T & M>) => M & ThisType<T & M>;
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* 创建带有选项机制的插件宿主类
|
|
339
|
+
* @remakers
|
|
340
|
+
* 比 直接使用 ModeOptionsPluginHost 提供了完善的类型推导
|
|
341
|
+
*
|
|
342
|
+
* @returns
|
|
343
|
+
*/
|
|
344
|
+
export declare function createTierModeOptionsPluginHost<HOST, Options extends {}, Mode extends string | number = string>(): {
|
|
345
|
+
new (options: Options): {
|
|
346
|
+
/**
|
|
347
|
+
* 实例级的默认选项
|
|
348
|
+
*/
|
|
349
|
+
readonly modeOptions: TierModeOptions<Mode, Options>;
|
|
350
|
+
_modeOptions: TierModeOptions<Mode, Options>;
|
|
351
|
+
mode: Mode;
|
|
352
|
+
readonly options: Options;
|
|
353
|
+
/**
|
|
354
|
+
* 使 host 变成 层级选项的宿主类型
|
|
355
|
+
* @param host
|
|
356
|
+
* @param context
|
|
357
|
+
* @returns
|
|
358
|
+
*/
|
|
359
|
+
readonly pluginManager: PluginManager<any, IPlugin<any, any>>;
|
|
360
|
+
use<P extends IPlugin<HOST, any>>(plugin: P, ...options: FormatUsePluginParameters<P>): void | PluginCreatedReturnType<P>;
|
|
361
|
+
destroy(): void;
|
|
362
|
+
};
|
|
363
|
+
/**
|
|
364
|
+
* 全局级别的默认选项
|
|
365
|
+
*/
|
|
366
|
+
readonly modeOptions: TierModeOptions<string, Options>;
|
|
367
|
+
readonly pluginManager: PluginManager<PluginHost & HOST, IPlugin<HOST, any>>;
|
|
368
|
+
_pluginManager: PluginManager<PluginHost & HOST, IPlugin<HOST, any>>;
|
|
369
|
+
use<P_1 extends IPlugin<HOST, any>>(plugin: P_1, ...options: FormatUsePluginParameters<P_1>): void | ReturnType<P_1["used"]>;
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* 创建带有选项机制的插件宿主类
|
|
374
|
+
* @remakers
|
|
375
|
+
* 比 直接使用 OptionsPluginHost 提供了完善的类型推导
|
|
376
|
+
*
|
|
377
|
+
* @returns
|
|
378
|
+
*/
|
|
379
|
+
export declare function createTierOptionsPluginHost<HOST, Options extends {}>(): {
|
|
380
|
+
new (options: Options): {
|
|
381
|
+
/**
|
|
382
|
+
* 实例级的默认选项
|
|
383
|
+
*/
|
|
384
|
+
readonly defaultOptions: TierOptions<Options>;
|
|
385
|
+
_defaultOptions: TierOptions<Options>;
|
|
386
|
+
readonly pluginManager: PluginManager<any, IPlugin<any, any>>;
|
|
387
|
+
use<P extends IPlugin<HOST, any>>(plugin: P, ...options: FormatUsePluginParameters<P>): void | PluginCreatedReturnType<P>;
|
|
388
|
+
destroy(): void;
|
|
389
|
+
};
|
|
390
|
+
/**
|
|
391
|
+
* 全局级别的默认选项
|
|
392
|
+
*/
|
|
393
|
+
readonly defaultOptions: TierOptions<Options>;
|
|
394
|
+
readonly pluginManager: PluginManager<PluginHost & HOST, IPlugin<HOST, any>>;
|
|
395
|
+
_pluginManager: PluginManager<PluginHost & HOST, IPlugin<HOST, any>>;
|
|
396
|
+
use<P_1 extends IPlugin<HOST, any>>(plugin: P_1, ...options: FormatUsePluginParameters<P_1>): void | ReturnType<P_1["used"]>;
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* 定义扩展的类型便利函数
|
|
401
|
+
*
|
|
402
|
+
* @remarks
|
|
403
|
+
* 它会更改 ext 中方法的this指向为 cla & ext,不会真的执行扩展操作。
|
|
404
|
+
*
|
|
405
|
+
* 其中 ext._constructor 会被保存在 cla._constructors 属性中,它是一个数组。
|
|
406
|
+
*
|
|
407
|
+
* cla 需要在自己的构建函数中逐个调用 cla._constructors 中的函数
|
|
408
|
+
*
|
|
409
|
+
* @param cla - 扩展的目标,用作 this 的类型
|
|
410
|
+
* @param ext - 描述扩展内容的对象,会自动更改其this的类型
|
|
411
|
+
* @returns 返回注入了 this 类型的 ext 对象本身
|
|
412
|
+
*/
|
|
413
|
+
export declare function defineExtend<C extends ClassType, E>(cla: C, ext: E & ThisType<InstanceType<C> & E> & PrivateMemberOfExtend<C>): E & ThisType<C & E>;
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* 定义扩展的类型便利函数
|
|
417
|
+
*
|
|
418
|
+
* @remarks
|
|
419
|
+
* 它会更改 ext 中方法的this指向为 cla & ext,不会真的执行扩展操作。
|
|
420
|
+
*
|
|
421
|
+
* 其中:
|
|
422
|
+
* - ext._constructor 会被保存在 cla._constructors 属性中,它是一个数组。
|
|
423
|
+
* - ext._init 会被保存在 cla._inits 属性中,它是一个数组。
|
|
424
|
+
*
|
|
425
|
+
* cla 需要:
|
|
426
|
+
* - 在自己的构建函数中逐个调用 cla._constructors 中的函数
|
|
427
|
+
* - 在自己的类似初始化`init()` 方法中逐个调用 cla._constructors 中的函数
|
|
428
|
+
*
|
|
429
|
+
* @param cla - 扩展的目标,用作 this 的类型
|
|
430
|
+
* @param ext - 描述扩展内容的对象,会自动更改其this的类型
|
|
431
|
+
* @returns 返回注入了 this 类型的 ext 对象本身
|
|
432
|
+
*/
|
|
433
|
+
export declare function defineExtendWithInit<C extends ClassType, E>(cla: C, ext: E & ThisType<InstanceType<C> & E> & PrivateMemberOfExtendWithInit<C>): E & ThisType<C & E>;
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* 定义混合的类型便利函数
|
|
437
|
+
*
|
|
438
|
+
* @remarks
|
|
439
|
+
* 它会更改 mixin 中方法的this指向为 target & mixin,不会真的执行混合操作
|
|
440
|
+
*
|
|
441
|
+
* @param target - 混合的目标,用作 this 的类型
|
|
442
|
+
* @param mixin - 混合对象,会自动更改其this的类型
|
|
443
|
+
* @returns 返回注入了 this 类型的 mixin 对象本身
|
|
444
|
+
*/
|
|
445
|
+
export declare function defineMixin<T, M>(target: T, mixin: M & ThisType<T & M>): M & ThisType<T & M>;
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* 扩展目标
|
|
449
|
+
*
|
|
450
|
+
* @remarks
|
|
451
|
+
* 会执行对 CEarth 类的扩展操作。
|
|
452
|
+
* 与 {@link targetExtend} 的区别仅仅是返回类型不一样。
|
|
453
|
+
*
|
|
454
|
+
* @param cla - 扩展的目标,也用作 this 的类型
|
|
455
|
+
* @param ext - 扩展对象,会自动更改其this的类型
|
|
456
|
+
* @returns 返回扩展后的 cla 对象
|
|
457
|
+
*/
|
|
458
|
+
export declare function extendTarget<C extends ClassType, E>(cla: C, ext: E & ThisType<InstanceType<C> & E> & PrivateMemberOfExtend<C>): ClassType<ConstructorParameters<C>, E & ThisType<InstanceType<C> & E>>;
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* 扩展目标
|
|
462
|
+
*
|
|
463
|
+
* @remarks
|
|
464
|
+
* 会执行对 CEarth 类的扩展操作。
|
|
465
|
+
* 与 {@link targetExtendWithInit} 的区别仅仅是返回类型不一样。
|
|
466
|
+
*
|
|
467
|
+
* @param cla - 扩展的目标,也用作 this 的类型
|
|
468
|
+
* @param ext - 扩展对象,会自动更改其this的类型
|
|
469
|
+
* @returns 返回扩展后的 cla 对象
|
|
470
|
+
*/
|
|
471
|
+
export declare function extendTargetWithInit<C extends ClassType, E>(cla: C, ext: E & ThisType<InstanceType<C> & E> & PrivateMemberOfExtendWithInit<C>): ClassType<ConstructorParameters<C>, E & ThisType<InstanceType<C> & E>>;
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* 格式化 use 方法的参数列表
|
|
475
|
+
*/
|
|
476
|
+
export declare type FormatUseParameters<Options> = Options extends never | void | undefined ? [] : [Options];
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* 格式化 use 方法的参数列表
|
|
480
|
+
*/
|
|
481
|
+
export declare type FormatUsePluginParameters<Plugin> = GetPluginOptions<Plugin> extends never | void | undefined ? [] : [GetPluginOptions<Plugin>];
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* 获取规范化的插件选项
|
|
485
|
+
*/
|
|
486
|
+
export declare type GetNormalizePluginOptions<Plugin> = NormalizePluginOptions<GetPluginOptions<Plugin>>;
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* 获取插件的选项类型
|
|
490
|
+
*/
|
|
491
|
+
export declare type GetPluginOptions<Plugin> = Plugin extends IPlugin<any, infer Options> ? Options : never;
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* 通过key列表获取对象中对应属性的值
|
|
495
|
+
* @param obj
|
|
496
|
+
* @param props
|
|
497
|
+
* @returns
|
|
498
|
+
*/
|
|
499
|
+
export declare function getPropertyValue(obj: any, props: string[]): any;
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* 获取对象的属性路径对应的属性值
|
|
503
|
+
* @param obj
|
|
504
|
+
* @param propPath
|
|
505
|
+
* @returns
|
|
506
|
+
*/
|
|
507
|
+
export declare function getPropertyValueByPath(obj: any, propPath: string): any;
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* 按照 props 的结构,获取 target 的 属性对象
|
|
511
|
+
* - props 中所有 纯对象 都会被作为 props 进行递归地获取
|
|
512
|
+
* @param target
|
|
513
|
+
* @param props
|
|
514
|
+
* @returns
|
|
515
|
+
*/
|
|
516
|
+
export declare function getTargetProperties<Props>(target: any, props: Props): Props;
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* 插件宿主的实例类型
|
|
520
|
+
*/
|
|
521
|
+
export declare type HostInst<H> = H extends new (...args: any) => any ? InstanceType<H> : H;
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* 默认选项宿主接口
|
|
525
|
+
*/
|
|
526
|
+
export declare interface IDefaultOptionsHost<Options> {
|
|
527
|
+
readonly defaultOptions: Options;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* 默认选项宿主的构建函数接口
|
|
532
|
+
*/
|
|
533
|
+
export declare interface IIDefaultOptionsHostConstructor<Options> {
|
|
534
|
+
get defaultOptions(): Options;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* 插件的接口
|
|
539
|
+
*
|
|
540
|
+
* @typeParam HOST - 插件宿主的类类型
|
|
541
|
+
* @typeParam Options - 插件的选项类型
|
|
542
|
+
*/
|
|
543
|
+
export declare interface IPlugin<HOST, Options = void> {
|
|
544
|
+
/**
|
|
545
|
+
* 当插件被注册时调用
|
|
546
|
+
* @param Host - 宿主的类型
|
|
547
|
+
* @param options - 注册插件时的选项
|
|
548
|
+
*/
|
|
549
|
+
used(Host: HOST, ...options: FormatUseParameters<Options>): any;
|
|
550
|
+
/**
|
|
551
|
+
* 当宿主实例被创建时调用
|
|
552
|
+
* @param host - 新建的宿主实例
|
|
553
|
+
* @param options - 注册插件时的选项
|
|
554
|
+
*/
|
|
555
|
+
created?(host: HostInst<HOST>, ...options: FormatUseParameters<Options>): any;
|
|
556
|
+
/**
|
|
557
|
+
* 当宿主实例被销毁时调用
|
|
558
|
+
* @param host - 被销毁的宿主实例
|
|
559
|
+
* @param options - 注册插件时的选项
|
|
560
|
+
*/
|
|
561
|
+
destroyed?(host: HostInst<HOST>, ...options: FormatUseParameters<Options>): any;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* 插件宿主的接口
|
|
566
|
+
*
|
|
567
|
+
* @typeParam HostClassType 插件宿主类的类型
|
|
568
|
+
*/
|
|
569
|
+
export declare interface IPluginHost<HostClassType extends IPluginHostConstructor<any, Plugin>, Plugin extends IPlugin<HostClassType, any> = IPlugin<HostClassType, any>> {
|
|
570
|
+
/**
|
|
571
|
+
* PluginHost 的插件管理器
|
|
572
|
+
*/
|
|
573
|
+
get pluginManager(): HostClassType["pluginManager"];
|
|
574
|
+
/**
|
|
575
|
+
* 实例的注册插件的方法
|
|
576
|
+
* @param plugin
|
|
577
|
+
* @param options
|
|
578
|
+
* @returns
|
|
579
|
+
*/
|
|
580
|
+
use<P extends Plugin>(plugin: P, options: GetNormalizePluginOptions<P>): PluginCreatedReturnType<P> | void;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* 插件宿主构造函数的接口
|
|
585
|
+
* @typeParam HostClassType 插件宿主类的类型
|
|
586
|
+
*/
|
|
587
|
+
export declare interface IPluginHostConstructor<HostClassType, Plugin extends IPlugin<HostClassType, any> = IPlugin<HostClassType, any>> {
|
|
588
|
+
/**
|
|
589
|
+
* PluginHost 的插件管理器
|
|
590
|
+
*/
|
|
591
|
+
get pluginManager(): PluginManager<HostClassType, Plugin>;
|
|
592
|
+
/**
|
|
593
|
+
* {@inheritDoc PluginManager.use}
|
|
594
|
+
*/
|
|
595
|
+
use<P extends Plugin>(plugin: P, options: GetNormalizePluginOptions<P>): PluginUseReturnType<P> | void;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* 插件的接口
|
|
600
|
+
*
|
|
601
|
+
* @typeParam HOST - 插件宿主的类类型
|
|
602
|
+
* @typeParam Options - 插件的选项类型
|
|
603
|
+
*/
|
|
604
|
+
export declare interface IPluginWithInit<HOST, Options = void> extends IPlugin<HOST, Options> {
|
|
605
|
+
/**
|
|
606
|
+
* 当宿主实例被初始化时调用
|
|
607
|
+
* @param host - 新建的宿主实例
|
|
608
|
+
* @param options - 注册插件时的选项
|
|
609
|
+
*/
|
|
610
|
+
inited?(host: HostInst<HOST>, ...options: FormatUseParameters<Options>): any;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* 选项宿主接口
|
|
615
|
+
*/
|
|
616
|
+
export declare interface ITierModeOptionsHost<Options extends {} = any, Mode extends string | number = string> {
|
|
617
|
+
readonly modeOptions: TierModeOptions<Mode, Options>;
|
|
618
|
+
mode: Mode;
|
|
619
|
+
get options(): Options;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* 选项宿主的构建函数接口
|
|
624
|
+
*/
|
|
625
|
+
export declare interface ITierModeOptionsHostConstructor<Options extends {} = any, Mode extends string | number = string> {
|
|
626
|
+
get modeOptions(): TierModeOptions<Mode, Options>;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* 选项插件宿主接口
|
|
631
|
+
*/
|
|
632
|
+
export declare type ITierModeOptionsPluginHost<HostClassType extends ITierModeOptionsPluginHostConstructor<any>, Options extends {} = any, Mode extends string | number = string> = IPluginHost<HostClassType> & ITierModeOptionsHost<Options, Mode>;
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* 选项插件宿主的构建函数接口
|
|
636
|
+
*/
|
|
637
|
+
export declare type ITierModeOptionsPluginHostConstructor<HostClassType, Options extends {} = any, Mode extends string | number = string> = IPluginHostConstructor<HostClassType> & ITierModeOptionsHostConstructor<Options, Mode>;
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* 选项插件宿主接口
|
|
641
|
+
*/
|
|
642
|
+
export declare interface ITierOptionsHost<Options extends {} = any> {
|
|
643
|
+
readonly defaultOptions: TierOptions<Options>;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* 选项插件宿主的构建函数接口
|
|
648
|
+
*/
|
|
649
|
+
export declare interface ITierOptionsHostConstructor<Options extends {} = any> {
|
|
650
|
+
get defaultOptions(): TierOptions<Options>;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* 选项插件宿主接口
|
|
655
|
+
*/
|
|
656
|
+
export declare type ITierOptionsPluginHost<HostClassType extends ITierOptionsPluginHostConstructor<any>, Options extends {} = any> = IPluginHost<HostClassType> & ITierOptionsHost<Options>;
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* 选项插件宿主的构建函数接口
|
|
660
|
+
*/
|
|
661
|
+
export declare type ITierOptionsPluginHostConstructor<HostClassType, Options extends {} = any> = IPluginHostConstructor<HostClassType> & ITierOptionsHostConstructor<Options>;
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* 合并属性
|
|
665
|
+
* 该方法会将 props 深度合并到 target 中,
|
|
666
|
+
* - 所有 纯对象 的属性值都会被作为 props 进行深度合并
|
|
667
|
+
* - 对于不是纯对象的属性,会将其视为属性值设置到到目标中对应的属性上
|
|
668
|
+
*
|
|
669
|
+
* @param target
|
|
670
|
+
* @param props
|
|
671
|
+
*/
|
|
672
|
+
export declare function mergeProperties(target: any, props: any): any;
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* 混合
|
|
676
|
+
* @internal
|
|
677
|
+
*/
|
|
678
|
+
export declare function mixin<T, S>(target: T, source: S): T & S;
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* 混合
|
|
682
|
+
* @internal
|
|
683
|
+
*/
|
|
684
|
+
export declare function mixin<T, S1, S2>(target: T, source1: S1, source2: S2): T & S1 & S2;
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* 混合
|
|
688
|
+
* @internal
|
|
689
|
+
*/
|
|
690
|
+
export declare function mixin<T, S1, S2, S3>(target: T, source1: S1, source2: S2, source3: S3): T & S1 & S2 & S3;
|
|
691
|
+
|
|
692
|
+
/**
|
|
693
|
+
* 混合
|
|
694
|
+
* @internal
|
|
695
|
+
*/
|
|
696
|
+
export declare function mixin<T, S1, S2, S3, S4>(target: T, source1: S1, source2: S2, source3: S3, source4: S3): T & S1 & S2 & S3 & S4;
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* 混合
|
|
700
|
+
*
|
|
701
|
+
* @remarks
|
|
702
|
+
* 将 source 的所有成员混入 target 对象中。
|
|
703
|
+
*
|
|
704
|
+
* 与 `Object.assign()` 的功能类似,不同的是 `mixin()` 会在 target 对象中 保持 source 对象属性的 PropertyDescriptors
|
|
705
|
+
*
|
|
706
|
+
* @param target - 目标对象,所有 源对象 的属性都要被混入进到 目标对象中
|
|
707
|
+
* @param sources - 源对象,所有 源对象 的属性都要被混入进到 目标对象中
|
|
708
|
+
* @returns 混入后的 target
|
|
709
|
+
*/
|
|
710
|
+
export declare function mixin(target: any, ...sources: any[]): any;
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* 混合目标
|
|
714
|
+
*
|
|
715
|
+
* @remarks
|
|
716
|
+
* 会执行对 CEarth 类的扩展操作。
|
|
717
|
+
* 与 {@link targetMixin} 的区别仅仅是返回类型不一样。
|
|
718
|
+
*
|
|
719
|
+
* @param target - 混合的目标,用作 this 的类型
|
|
720
|
+
* @param m - 混合对象,会自动更改其this的类型
|
|
721
|
+
* @returns 返回混合后的 target 对象
|
|
722
|
+
*/
|
|
723
|
+
export declare function mixinTarget<T, M>(target: T, m: M & ThisType<T & M>): M & ThisType<T & M> & T;
|
|
724
|
+
|
|
725
|
+
/**
|
|
726
|
+
* 模式选项
|
|
727
|
+
* @remarks
|
|
728
|
+
* 针对选项提供了模式和继承的功能;
|
|
729
|
+
*
|
|
730
|
+
* 适用以下场景:
|
|
731
|
+
* 你设计了一个支持许多选项的工具,不同场景下需要配置不同的选项值,比如有如下几个场景:
|
|
732
|
+
* - 性能模式:所有的配置项以性能为目标进行配置,关闭那些效果类的选项;
|
|
733
|
+
* - 特效模式:以高质量的渲染效果为目标进行配置,会开启所有的效果选项;
|
|
734
|
+
* - 平衡模式:兼顾性能和效果,取个折中;
|
|
735
|
+
*
|
|
736
|
+
* 并且这些模式也会一些共同的选项;
|
|
737
|
+
*
|
|
738
|
+
* 使用该类,你可以:
|
|
739
|
+
* - 设置一个基本模式:该模式提供的所有模式都会有的共用选项
|
|
740
|
+
* - 设置 性能模式、特效模式、平衡模式 继承 基本模式;
|
|
741
|
+
*/
|
|
742
|
+
export declare class ModeOptions<Mode extends string | number = string, Option extends {} = any> extends OptionsManager<Option> {
|
|
743
|
+
constructor(mode: Mode);
|
|
744
|
+
constructor(mode: Mode, options?: Option);
|
|
745
|
+
/**
|
|
746
|
+
* 模式的配置
|
|
747
|
+
*/
|
|
748
|
+
modes: Record<Mode, TierOptions<Option>>;
|
|
749
|
+
/**
|
|
750
|
+
* 当前模式
|
|
751
|
+
*/
|
|
752
|
+
get mode(): Mode;
|
|
753
|
+
set mode(value: Mode);
|
|
754
|
+
protected _mode?: Mode;
|
|
755
|
+
/**
|
|
756
|
+
* 所有的模式名字
|
|
757
|
+
*/
|
|
758
|
+
get modeNames(): Mode[];
|
|
759
|
+
protected _modeNames: Mode[] | null;
|
|
760
|
+
/**
|
|
761
|
+
* 获取所有的模式名字
|
|
762
|
+
* @returns
|
|
763
|
+
*/
|
|
764
|
+
getModeNames(): Mode[];
|
|
765
|
+
/**
|
|
766
|
+
* 判断是否有某个模式
|
|
767
|
+
* @param mode
|
|
768
|
+
* @returns
|
|
769
|
+
*/
|
|
770
|
+
hasMode(mode: string | number): boolean;
|
|
771
|
+
/**
|
|
772
|
+
* 当前模式的选项
|
|
773
|
+
*/
|
|
774
|
+
get optionManager(): TierOptions<Option>;
|
|
775
|
+
/**
|
|
776
|
+
* 当前模式对应的选项
|
|
777
|
+
*/
|
|
778
|
+
get option(): Option;
|
|
779
|
+
get plainFullOption(): Option;
|
|
780
|
+
protected _plainFullOption: Option | null;
|
|
781
|
+
/**
|
|
782
|
+
* 更新
|
|
783
|
+
*/
|
|
784
|
+
updateFullOption(): void;
|
|
785
|
+
/**
|
|
786
|
+
* 返回已合并继承选项的选项
|
|
787
|
+
* @remarks
|
|
788
|
+
* 与继承选项只是浅合并
|
|
789
|
+
* @param mode
|
|
790
|
+
* @returns
|
|
791
|
+
*/
|
|
792
|
+
getModeOption(mode: Mode): Option | null;
|
|
793
|
+
/**
|
|
794
|
+
* 返回已合并继承选项的完整选项
|
|
795
|
+
* @remarks
|
|
796
|
+
* 与继承选项合并
|
|
797
|
+
* @param mode
|
|
798
|
+
* @returns
|
|
799
|
+
*/
|
|
800
|
+
getFullModeOption(mode: Mode): Option | null;
|
|
801
|
+
/**
|
|
802
|
+
* 给模式设置选项
|
|
803
|
+
* @param mode
|
|
804
|
+
* @param option
|
|
805
|
+
* @param deep - 是否要进行深度合并
|
|
806
|
+
* @param extend - 继承哪个模式
|
|
807
|
+
*/
|
|
808
|
+
setModeOption(mode: Mode, option: Option, deep?: boolean, extend?: Mode): Record<Mode, TierOptions<Option>>[Mode];
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* 将选项格式成方法的参数类型
|
|
813
|
+
* @remarks
|
|
814
|
+
* 如果是 never|void|undefined 类型,则会被转为 void
|
|
815
|
+
*/
|
|
816
|
+
export declare type NormalizePluginOptions<Options> = Options extends never | void | undefined ? void : Options;
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* 选项管理器
|
|
820
|
+
*/
|
|
821
|
+
declare abstract class OptionsManager<Option extends {} = any> {
|
|
822
|
+
/**
|
|
823
|
+
* 选项
|
|
824
|
+
*/
|
|
825
|
+
abstract option: Option;
|
|
826
|
+
/**
|
|
827
|
+
* 是否要冻结 fullOption 的成员
|
|
828
|
+
* @remarks
|
|
829
|
+
* 只会冻结 fullOption 的直接成员的值,不会冻结 fullOption 孙子成员的值
|
|
830
|
+
*/
|
|
831
|
+
freezeMember: boolean;
|
|
832
|
+
/**
|
|
833
|
+
* 可更新顶级成员值的完整的选项
|
|
834
|
+
* @remarks
|
|
835
|
+
* 合并后的选项;
|
|
836
|
+
* plainFullOption 的代理对象,自动监听了顶层成员的屐;所以可以更改顶级成员的值,不可以更改非顶级成员的值;
|
|
837
|
+
*/
|
|
838
|
+
fullOption: Option;
|
|
839
|
+
/**
|
|
840
|
+
* 完整的选项
|
|
841
|
+
* @remarks
|
|
842
|
+
* 合并后的选项
|
|
843
|
+
*/
|
|
844
|
+
abstract readonly plainFullOption: Option;
|
|
845
|
+
/**
|
|
846
|
+
* 更新完整的选项
|
|
847
|
+
*/
|
|
848
|
+
abstract updateFullOption(): void;
|
|
849
|
+
/**
|
|
850
|
+
* 设置选项
|
|
851
|
+
* @remarks
|
|
852
|
+
* 会将被设置的选项浅合并进当前选项中
|
|
853
|
+
* @param option
|
|
854
|
+
* @param deep - 是否要进行深度合并
|
|
855
|
+
*/
|
|
856
|
+
setOption(option: Option, deep?: boolean): void | Option;
|
|
857
|
+
/**
|
|
858
|
+
* 未定义值的类型
|
|
859
|
+
*/
|
|
860
|
+
get undefinedValue(): UndefinedOptionValue;
|
|
861
|
+
set undefinedValue(value: UndefinedOptionValue);
|
|
862
|
+
protected _undefinedValue: UndefinedOptionValue;
|
|
863
|
+
/**
|
|
864
|
+
* 未定义值的判断函数
|
|
865
|
+
*/
|
|
866
|
+
isUndefined: (value: any) => boolean;
|
|
867
|
+
/**
|
|
868
|
+
* 获取选项成员
|
|
869
|
+
* @param key
|
|
870
|
+
* @returns
|
|
871
|
+
*/
|
|
872
|
+
getMember<Key extends keyof Option>(key: Key): Option[Key] | undefined | null;
|
|
873
|
+
/**
|
|
874
|
+
* 设置选项成员
|
|
875
|
+
* @param key
|
|
876
|
+
* @param value
|
|
877
|
+
* @param deep - 是否要进行深度合并
|
|
878
|
+
*/
|
|
879
|
+
setMember<Key extends keyof Option>(key: Key, value?: Option[Key] | null, deep?: boolean): void;
|
|
880
|
+
/**
|
|
881
|
+
* 获取属性路径对应的值
|
|
882
|
+
* @param propPath
|
|
883
|
+
* @returns
|
|
884
|
+
*/
|
|
885
|
+
getValue(propPath: string[]): any;
|
|
886
|
+
/**
|
|
887
|
+
* 设置属性路径对应的值
|
|
888
|
+
* @param propPath
|
|
889
|
+
* @param value
|
|
890
|
+
* @param deep - 是否要进行深度合并
|
|
891
|
+
* @returns
|
|
892
|
+
*/
|
|
893
|
+
setValue(propPath: string[], value: any, deep?: boolean): void;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
/**
|
|
897
|
+
* 解析属性路径为属性列表
|
|
898
|
+
* @param propPath
|
|
899
|
+
* @returns
|
|
900
|
+
*/
|
|
901
|
+
export declare function parsePropertyPath(propPath: string): string[];
|
|
902
|
+
|
|
903
|
+
/**
|
|
904
|
+
* 插件的 created 方法的返回值类型
|
|
905
|
+
*/
|
|
906
|
+
export declare type PluginCreatedReturnType<P extends IPlugin<any, any>> = P["created"] extends AnyFunction ? ReturnType<P["created"]> : void;
|
|
907
|
+
|
|
908
|
+
/**
|
|
909
|
+
* 插件的宿主
|
|
910
|
+
*
|
|
911
|
+
* @remarks
|
|
912
|
+
* 插件宿主 就是 拥有插件机制的宿主
|
|
913
|
+
*
|
|
914
|
+
* 子类需要在构建函数中调用 `this.pluginManager.created(this);`
|
|
915
|
+
*
|
|
916
|
+
* 之所以没写在该类中的函数中,是因为 `this.pluginManager.created(this)` 通常会在构建函数执行的最后时才调用;
|
|
917
|
+
* 如果像下面写在该类的构建函数中,然后子类通过 `super()` 来调用,这样就会导致 `this.pluginManager.created(this)` 不是在最后的执行;
|
|
918
|
+
*/
|
|
919
|
+
export declare class PluginHost<Plugin extends IPlugin<typeof PluginHost, any> = IPlugin<typeof PluginHost, any>> {
|
|
920
|
+
/**
|
|
921
|
+
* 插件管理器
|
|
922
|
+
*/
|
|
923
|
+
static get pluginManager(): PluginManager<any, IPlugin<any, any>>;
|
|
924
|
+
protected static _pluginManager: PluginManager<any>;
|
|
925
|
+
/**
|
|
926
|
+
* 插件管理器 {@link PluginHost.pluginManager}
|
|
927
|
+
*/
|
|
928
|
+
get pluginManager(): PluginManager<any, IPlugin<any, any>>;
|
|
929
|
+
/**
|
|
930
|
+
* {@inheritDoc PluginManager.use}
|
|
931
|
+
*/
|
|
932
|
+
static use<Plugin extends IPlugin<typeof PluginHost, any>>(plugin: Plugin, ...options: FormatUsePluginParameters<Plugin>): void | ReturnType<Plugin["used"]>;
|
|
933
|
+
/**
|
|
934
|
+
* 需要在子类中调用
|
|
935
|
+
*
|
|
936
|
+
* 之所以没写在该类中的函数中,是因为 `this.pluginManager.created(this)` 通常会在构建函数执行的最后时才调用;
|
|
937
|
+
* 如果像下面写在该类的构建函数中,然后子类通过 `super()` 来调用,这样就会导致 `this.pluginManager.created(this)` 不是在最后的执行;
|
|
938
|
+
*/
|
|
939
|
+
/**
|
|
940
|
+
* 实例的注册插件的方法
|
|
941
|
+
* @param plugin
|
|
942
|
+
* @param options
|
|
943
|
+
* @returns
|
|
944
|
+
*/
|
|
945
|
+
use<P extends Plugin>(plugin: P, ...options: FormatUsePluginParameters<P>): PluginCreatedReturnType<P> | void;
|
|
946
|
+
/**
|
|
947
|
+
* 销毁实例
|
|
948
|
+
* @returns
|
|
949
|
+
*/
|
|
950
|
+
destroy(): void;
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
/**
|
|
954
|
+
* 插件管理者
|
|
955
|
+
*
|
|
956
|
+
* @remarks
|
|
957
|
+
* 负责管理插件的注册、应用 等
|
|
958
|
+
*
|
|
959
|
+
* @typeParam HostClassType 插件宿主类的类型
|
|
960
|
+
*
|
|
961
|
+
*/
|
|
962
|
+
export declare class PluginManager<HostClassType, Plugin extends IPlugin<HostClassType, any> = IPlugin<HostClassType, any>> {
|
|
963
|
+
/**
|
|
964
|
+
* 插件的宿主
|
|
965
|
+
*/
|
|
966
|
+
host: HostClassType;
|
|
967
|
+
/**
|
|
968
|
+
* 插件与插件选项的映射
|
|
969
|
+
*/
|
|
970
|
+
readonly pluginOptsMap: Map<Plugin, any>;
|
|
971
|
+
/**
|
|
972
|
+
* 注册的插件
|
|
973
|
+
*/
|
|
974
|
+
readonly plugins: Plugin[];
|
|
975
|
+
/**
|
|
976
|
+
* @param host - 插件的宿主
|
|
977
|
+
*/
|
|
978
|
+
constructor(host?: HostClassType);
|
|
979
|
+
/**
|
|
980
|
+
* 使用插件、注册插件
|
|
981
|
+
* @param plugin - 插件
|
|
982
|
+
* @param options - 传递给插件的选项
|
|
983
|
+
*/
|
|
984
|
+
use<P extends Plugin>(plugin: P, ...options: FormatUsePluginParameters<P>): PluginUseReturnType<P> | void;
|
|
985
|
+
/**
|
|
986
|
+
* 插件宿主创建实例时调用
|
|
987
|
+
*
|
|
988
|
+
* @remarks
|
|
989
|
+
* 会调用每个插件的 {@link IPlugin.created} 方法
|
|
990
|
+
* @param hostInst - 插件宿主的新实例
|
|
991
|
+
*/
|
|
992
|
+
created(hostInst: HostInst<HostClassType>): void;
|
|
993
|
+
/**
|
|
994
|
+
* 插件宿主被销毁时调用
|
|
995
|
+
*
|
|
996
|
+
* @remarks
|
|
997
|
+
* 会调用每个插件的 {@link IPlugin.destroyed} 方法
|
|
998
|
+
* @param hostInst - 被销毁的插件实例
|
|
999
|
+
*/
|
|
1000
|
+
destroyed(hostInst: HostInst<HostClassType>): void;
|
|
1001
|
+
/**
|
|
1002
|
+
* 插件宿主实例的注册插件的方法
|
|
1003
|
+
*
|
|
1004
|
+
* @remarks
|
|
1005
|
+
* 会调用每个插件的 {@link IPlugin.use | IPlugin.created()} 方法
|
|
1006
|
+
* @param hostInst - 插件宿主的新实例
|
|
1007
|
+
*/
|
|
1008
|
+
instUse<P extends Plugin>(hostInst: HostInst<HostClassType>, plugin: P, ...options: FormatUsePluginParameters<P>): PluginCreatedReturnType<P> | void;
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
/**
|
|
1012
|
+
* 插件管理者
|
|
1013
|
+
*
|
|
1014
|
+
* @remarks
|
|
1015
|
+
* 负责管理插件的注册、应用 等
|
|
1016
|
+
*
|
|
1017
|
+
* @typeParam HostClassType 插件宿主类的类型
|
|
1018
|
+
*
|
|
1019
|
+
*/
|
|
1020
|
+
export declare class PluginManagerWithInit<HostClassType, Plugin extends IPluginWithInit<HostClassType, any> = IPluginWithInit<HostClassType, any>> extends PluginManager<HostClassType, Plugin> {
|
|
1021
|
+
/**
|
|
1022
|
+
* 插件宿主创建实例时调用
|
|
1023
|
+
*
|
|
1024
|
+
* @remarks
|
|
1025
|
+
* 会调用每个插件的 {@link IPlugin.created | IPlugin.created()} 方法
|
|
1026
|
+
* @param hostInst - 插件宿主的新实例
|
|
1027
|
+
*/
|
|
1028
|
+
inited(hostInst: HostInst<HostClassType>): void;
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
/**
|
|
1032
|
+
* 插件的 used 方法的返回值类型
|
|
1033
|
+
*/
|
|
1034
|
+
export declare type PluginUseReturnType<P extends IPlugin<any, any>> = ReturnType<P["used"]>;
|
|
1035
|
+
|
|
1036
|
+
/**
|
|
1037
|
+
* 用于定义扩展选项中的私有成员
|
|
1038
|
+
*/
|
|
1039
|
+
export declare interface PrivateMemberOfExtend<TargetType extends new (...args: any) => any> {
|
|
1040
|
+
/**
|
|
1041
|
+
* 扩展类中用于定义在创建实例时的初始化的方法
|
|
1042
|
+
* @remarks
|
|
1043
|
+
* 该方法会在创建实例时自动执行,并将构建函数接收到的参数透传给方方法。
|
|
1044
|
+
*
|
|
1045
|
+
* 注意:
|
|
1046
|
+
* _constructor 会被保存在 目标类中的 _constructors 属性中,它是一个数组。
|
|
1047
|
+
*
|
|
1048
|
+
* 目标类 需要在自己的构建函数中逐个调用 cla._constructors 中的函数
|
|
1049
|
+
*
|
|
1050
|
+
* @param args
|
|
1051
|
+
*/
|
|
1052
|
+
_constructor?(...args: (TargetType extends new (...args: infer A) => any ? A : never)): void;
|
|
1053
|
+
/**
|
|
1054
|
+
* 扩展类中用于定义在实例销毁时触发的销毁方法
|
|
1055
|
+
* @remarks
|
|
1056
|
+
* 该方法会在实例销毁时自动调用
|
|
1057
|
+
*
|
|
1058
|
+
* 注意:
|
|
1059
|
+
* _destroy 会被保存在 目标类中的 _destroys 属性中,它是一个数组。
|
|
1060
|
+
*
|
|
1061
|
+
* 如果目标类有销毁逻辑,则需要在自己的销毁函数中逐个调用 cla._destroys 中的函数
|
|
1062
|
+
*
|
|
1063
|
+
* @param args
|
|
1064
|
+
*/
|
|
1065
|
+
_destroy?(): void;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
/**
|
|
1069
|
+
* 用于定义扩展选项中的私有成员
|
|
1070
|
+
*/
|
|
1071
|
+
export declare interface PrivateMemberOfExtendWithInit<TargetType extends new (...args: any) => any, InitParams extends any[] = any> extends PrivateMemberOfExtend<TargetType> {
|
|
1072
|
+
/**
|
|
1073
|
+
* 扩展类中用于定义实例初始化逻辑的方法
|
|
1074
|
+
* @remarks
|
|
1075
|
+
* 该方法会在调用实例的 `init()` 方法时自动执行。
|
|
1076
|
+
* @param args
|
|
1077
|
+
*/
|
|
1078
|
+
_init?(...args: InitParams): void;
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
/**
|
|
1082
|
+
* 替换构建函数的参数
|
|
1083
|
+
*/
|
|
1084
|
+
export declare type ReplaceConstructorParameters<C extends new (...args: any) => any, NewParms extends any[]> = new (...args: NewParms) => InstanceType<C>;
|
|
1085
|
+
|
|
1086
|
+
/**
|
|
1087
|
+
* 替换构造函数的返回类型
|
|
1088
|
+
*/
|
|
1089
|
+
export declare type ReplaceConstructorReturn<C extends new (...args: any) => any, NewReturn> = new (...args: ConstructorParameters<C>) => NewReturn;
|
|
1090
|
+
|
|
1091
|
+
/**
|
|
1092
|
+
* 通过属性路径列表设置对象中对应属性的值
|
|
1093
|
+
* @param obj
|
|
1094
|
+
* @param props
|
|
1095
|
+
* @returns
|
|
1096
|
+
*/
|
|
1097
|
+
export declare function setPropertyValue(obj: any, props: string[], value: any): any;
|
|
1098
|
+
|
|
1099
|
+
/**
|
|
1100
|
+
* 获取对象的属性路径对应的属性值
|
|
1101
|
+
* @param obj
|
|
1102
|
+
* @param propPath
|
|
1103
|
+
* @returns
|
|
1104
|
+
*/
|
|
1105
|
+
export declare function setPropertyValueByPath(obj: any, propPath: string, value: any): any;
|
|
1106
|
+
|
|
1107
|
+
/**
|
|
1108
|
+
* 扩展目标
|
|
1109
|
+
*
|
|
1110
|
+
* @remarks
|
|
1111
|
+
* 与 {@link defineExtend} 的区别是:`targetExtend` 会执行对 cla 的扩展操作,而 {@link defineExtend} 不会
|
|
1112
|
+
*
|
|
1113
|
+
*
|
|
1114
|
+
* @param cla - 扩展的目标,也用作 this 的类型
|
|
1115
|
+
* @param ext - 扩展描述对象,会自动更改其this的类型
|
|
1116
|
+
* @returns 返回注入了 this 类型的 ext 对象本身
|
|
1117
|
+
*/
|
|
1118
|
+
export declare function targetExtend<C extends ClassType, E>(cla: C, ext: E & ThisType<InstanceType<C> & E> & PrivateMemberOfExtend<C>): E & ThisType<InstanceType<C> & E>;
|
|
1119
|
+
|
|
1120
|
+
/**
|
|
1121
|
+
* 扩展目标
|
|
1122
|
+
*
|
|
1123
|
+
* @remarks
|
|
1124
|
+
* 与 {@link defineExtendWithInit} 的区别是:`targetExtend` 会执行对 cla 的扩展操作,而 {@link defineExtendWithInit} 不会
|
|
1125
|
+
*
|
|
1126
|
+
*
|
|
1127
|
+
* @param cla - 扩展的目标,也用作 this 的类型
|
|
1128
|
+
* @param ext - 扩展描述对象,会自动更改其this的类型
|
|
1129
|
+
* @returns 返回注入了 this 类型的 ext 对象本身
|
|
1130
|
+
*/
|
|
1131
|
+
export declare function targetExtendWithInit<C extends ClassType, E>(cla: C, ext: E & ThisType<InstanceType<C> & E> & PrivateMemberOfExtendWithInit<C>): E & ThisType<InstanceType<C> & E>;
|
|
1132
|
+
|
|
1133
|
+
/**
|
|
1134
|
+
* 混合目标
|
|
1135
|
+
*
|
|
1136
|
+
* @remarks
|
|
1137
|
+
* 与 {@link defineMixin} 的区别是:`targetMixin` 会执行对 target 的混合操作,而 {@link defineMixin} 不会
|
|
1138
|
+
*
|
|
1139
|
+
*
|
|
1140
|
+
* @param target - 混合的目标,用作 this 的类型
|
|
1141
|
+
* @param m - 混合对象,会自动更改其this的类型
|
|
1142
|
+
* @returns 返回注入了 this 类型的 mixin 对象本身
|
|
1143
|
+
*/
|
|
1144
|
+
export declare function targetMixin<T, M>(target: T, m: M & ThisType<T & M>): M & ThisType<T & M>;
|
|
1145
|
+
|
|
1146
|
+
/**
|
|
1147
|
+
* 层级模式选项
|
|
1148
|
+
* @remarks
|
|
1149
|
+
* 即 ModeOptions 和 TierOptions 的结合
|
|
1150
|
+
*/
|
|
1151
|
+
export declare class TierModeOptions<Mode extends string | number = string, Option extends {} = any> extends ModeOptions<Mode, Option> {
|
|
1152
|
+
constructor(mode: Mode);
|
|
1153
|
+
constructor(mode: Mode, options?: Option, extend?: TierModeOptions<Mode, Option>);
|
|
1154
|
+
/**
|
|
1155
|
+
* 继承的选项
|
|
1156
|
+
*/
|
|
1157
|
+
get extends(): TierModeOptions<Mode, Option> | null;
|
|
1158
|
+
set extends(value: TierModeOptions<Mode, Option> | null);
|
|
1159
|
+
protected _extends: TierModeOptions<Mode, Option> | null;
|
|
1160
|
+
/**
|
|
1161
|
+
* 返回已合并继承选项的最终选项
|
|
1162
|
+
* @remarks
|
|
1163
|
+
* 与继承选项只是浅合并
|
|
1164
|
+
* @param mode
|
|
1165
|
+
* @returns
|
|
1166
|
+
*/
|
|
1167
|
+
getFullModeOption(mode: Mode): Option | null;
|
|
1168
|
+
/**
|
|
1169
|
+
* 获取所有的模式名字
|
|
1170
|
+
* @returns
|
|
1171
|
+
*/
|
|
1172
|
+
getModeNames(): Mode[];
|
|
1173
|
+
/**
|
|
1174
|
+
* 在整个层级上判断是否有某个模式
|
|
1175
|
+
* @param mode
|
|
1176
|
+
* @returns
|
|
1177
|
+
*/
|
|
1178
|
+
hasModeOnTier(mode: string | number): boolean;
|
|
1179
|
+
/**
|
|
1180
|
+
* 当前模式的选项
|
|
1181
|
+
*/
|
|
1182
|
+
get optionManager(): TierOptions<Option>;
|
|
1183
|
+
/**
|
|
1184
|
+
* 获取模式对应的选项管理器
|
|
1185
|
+
* @param mode
|
|
1186
|
+
* @returns
|
|
1187
|
+
*/
|
|
1188
|
+
getModeOptionManager(mode: Mode): TierOptions<Option> | null;
|
|
1189
|
+
/**
|
|
1190
|
+
* 获取选项成员
|
|
1191
|
+
* @param key
|
|
1192
|
+
* @returns
|
|
1193
|
+
*/
|
|
1194
|
+
getMember<Key extends keyof Option>(key: Key): Option[Key] | undefined | null;
|
|
1195
|
+
/**
|
|
1196
|
+
* 获取属性路径对应的值
|
|
1197
|
+
* @param propPath
|
|
1198
|
+
* @returns
|
|
1199
|
+
*/
|
|
1200
|
+
getValue(propPath: string[]): any;
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
/**
|
|
1204
|
+
* 层级模式选项主机装饰器
|
|
1205
|
+
* @remarks
|
|
1206
|
+
* 可让宿主具备层级模式选项;
|
|
1207
|
+
* 需要宿主有静态的同名属性;
|
|
1208
|
+
* @param target
|
|
1209
|
+
* @param context
|
|
1210
|
+
* @returns
|
|
1211
|
+
*/
|
|
1212
|
+
export declare function tierModeOptionsDecorator<This, Value>(value: ClassAccessorDecoratorTarget<This, Value>, context: ClassAccessorDecoratorContext<This, Value>): ClassAccessorDecoratorResult<This, Value>;
|
|
1213
|
+
|
|
1214
|
+
/**
|
|
1215
|
+
* 层级模式选项插件的宿主
|
|
1216
|
+
* @remarks
|
|
1217
|
+
*
|
|
1218
|
+
* 子类需要在构建函数中调用 `this.pluginManager.created(this);`
|
|
1219
|
+
*
|
|
1220
|
+
* 之所以没写在该类中的函数中,是因为 `this.pluginManager.created(this)` 通常会在构建函数执行的最后时才调用;
|
|
1221
|
+
* 如果像下面写在该类的构建函数中,然后子类通过 `super()` 来调用,这样就会导致 `this.pluginManager.created(this)` 不是在最后的执行;
|
|
1222
|
+
*/
|
|
1223
|
+
export declare class TierModeOptionsPluginHost<Options extends {} = any, Mode extends string | number = string> extends PluginHost {
|
|
1224
|
+
/**
|
|
1225
|
+
* 全局级别的默认选项
|
|
1226
|
+
*/
|
|
1227
|
+
static readonly modeOptions: TierModeOptions<string, any>;
|
|
1228
|
+
/**
|
|
1229
|
+
* 实例级的默认选项
|
|
1230
|
+
*/
|
|
1231
|
+
get modeOptions(): TierModeOptions<Mode, Options>;
|
|
1232
|
+
protected _modeOptions: TierModeOptions<Mode, Options>;
|
|
1233
|
+
get mode(): Mode;
|
|
1234
|
+
set mode(value: Mode);
|
|
1235
|
+
get options(): Options;
|
|
1236
|
+
constructor(options: Options);
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
export declare class TierOptions<Option extends {} = any> extends OptionsManager<Option> {
|
|
1240
|
+
constructor(option?: Option, extend?: TierOptions<Option>);
|
|
1241
|
+
/**
|
|
1242
|
+
* 继承的选项
|
|
1243
|
+
*/
|
|
1244
|
+
get extends(): TierOptions<Option> | null;
|
|
1245
|
+
set extends(value: TierOptions<Option> | null);
|
|
1246
|
+
protected _extends: TierOptions<Option> | null;
|
|
1247
|
+
/**
|
|
1248
|
+
* 选项
|
|
1249
|
+
*/
|
|
1250
|
+
option: Option;
|
|
1251
|
+
/**
|
|
1252
|
+
* 获取完整的选项
|
|
1253
|
+
* @remarks
|
|
1254
|
+
* 会与继承来的选项进行合并
|
|
1255
|
+
*/
|
|
1256
|
+
get plainFullOption(): Option;
|
|
1257
|
+
protected _plainFullOption: Option | null;
|
|
1258
|
+
/**
|
|
1259
|
+
* 更新
|
|
1260
|
+
*/
|
|
1261
|
+
updateFullOption(): void;
|
|
1262
|
+
/**
|
|
1263
|
+
* 获取选项成员
|
|
1264
|
+
* @param key
|
|
1265
|
+
* @returns
|
|
1266
|
+
*/
|
|
1267
|
+
getMember<Key extends keyof Option>(key: Key): Option[Key] | undefined | null;
|
|
1268
|
+
/**
|
|
1269
|
+
* 获取属性路径对应的值
|
|
1270
|
+
* @param propPath
|
|
1271
|
+
* @returns
|
|
1272
|
+
*/
|
|
1273
|
+
getValue(propPath: string[]): any;
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
/**
|
|
1277
|
+
* 层级选项主机装饰器
|
|
1278
|
+
* @remarks
|
|
1279
|
+
* 可让宿主具备层级选项;
|
|
1280
|
+
* 需要宿主有静态的同名属性;
|
|
1281
|
+
* @param target
|
|
1282
|
+
* @param context
|
|
1283
|
+
* @returns
|
|
1284
|
+
*/
|
|
1285
|
+
export declare function tierOptionsDecorator<This, Value>(value: ClassAccessorDecoratorTarget<This, Value>, context: ClassAccessorDecoratorContext<This, Value>): ClassAccessorDecoratorResult<This, Value>;
|
|
1286
|
+
|
|
1287
|
+
/**
|
|
1288
|
+
* 层级选项插件的宿主
|
|
1289
|
+
* @remarks
|
|
1290
|
+
*
|
|
1291
|
+
* 子类需要在构建函数中调用 `this.pluginManager.created(this);`
|
|
1292
|
+
*
|
|
1293
|
+
* 之所以没写在该类中的函数中,是因为 `this.pluginManager.created(this)` 通常会在构建函数执行的最后时才调用;
|
|
1294
|
+
* 如果像下面写在该类的构建函数中,然后子类通过 `super()` 来调用,这样就会导致 `this.pluginManager.created(this)` 不是在最后的执行;
|
|
1295
|
+
*/
|
|
1296
|
+
export declare class TierOptionsPluginHost<Options extends {} = any> extends PluginHost {
|
|
1297
|
+
/**
|
|
1298
|
+
* 全局级别的默认选项
|
|
1299
|
+
*/
|
|
1300
|
+
static readonly defaultOptions: TierOptions<any>;
|
|
1301
|
+
/**
|
|
1302
|
+
* 实例级的默认选项
|
|
1303
|
+
*/
|
|
1304
|
+
get defaultOptions(): TierOptions<Options>;
|
|
1305
|
+
protected _defaultOptions: TierOptions<Options>;
|
|
1306
|
+
constructor(options: Options);
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
/**
|
|
1310
|
+
* 视为未定义的选项值
|
|
1311
|
+
* @remarks
|
|
1312
|
+
* 当选项的值是未定义的值
|
|
1313
|
+
*/
|
|
1314
|
+
declare enum UndefinedOptionValue {
|
|
1315
|
+
/**
|
|
1316
|
+
* 将 undefined 和 null 都视为未定义的选项
|
|
1317
|
+
*/
|
|
1318
|
+
UndefinedAndNull = "UndefinedAndNull",
|
|
1319
|
+
/**
|
|
1320
|
+
* 只将 undefined 视为未定义的选项
|
|
1321
|
+
*/
|
|
1322
|
+
Undefined = "Undefined",
|
|
1323
|
+
/**
|
|
1324
|
+
* 只将 null 视为未定义的选项
|
|
1325
|
+
*/
|
|
1326
|
+
Null = "Null"
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
export { }
|