knight-web 2.0.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.
@@ -0,0 +1,316 @@
1
+ import { InterfaceUtility } from './InterfaceUtility';
2
+ /** 反射工具 */
3
+ export declare namespace ReflectionUtility {
4
+ /** 反射类 */
5
+ class Reflection {
6
+ /** 路由组件类型池 */
7
+ private static _typePool;
8
+ /** 组件装饰器(用于存储组件类型)
9
+ * @param _name 组件路径/路由节点
10
+ */
11
+ static Decorator<T extends object>(_name: string): Function;
12
+ /**
13
+ * 获取类型
14
+ * @param _name 类型名称
15
+ * @returns 对象类型
16
+ */
17
+ static Get<T extends object>(_name: string): InterfaceUtility.IType<T>;
18
+ /**
19
+ * 创建实例
20
+ * @param _name 类型名称
21
+ * @returns 对象实例
22
+ */
23
+ static Creat<T extends object>(_name: string, ...params: any[]): T;
24
+ /** 属性装饰器 */
25
+ static Property(_target: any, _key: string): void;
26
+ /**
27
+ * 获取对象的所有属性名称
28
+ * @param _target 对象实例
29
+ * @returns 属性名称列表
30
+ */
31
+ static GetPropertys(_target: any): Array<string>;
32
+ }
33
+ /**
34
+ * 以指定的对象作为this值,并以指定数组的元素作为参数调用函数
35
+ * @param target 要调用的函数
36
+ * @param thisArgument 要用作this对象的对象
37
+ * @param argumentsList 传递给函数的参数值数组
38
+ * @example
39
+ function sum(a, b) { return a + b }
40
+ const result = Reflect.apply(sum, null, [2, 3]); // result = 5
41
+ *
42
+ */
43
+ function Apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
44
+ /**
45
+ * 使用指定数组的元素作为参数构造目标和指定的构造函数作为new.target的值
46
+ * @param target 要调用的构造函数
47
+ * @param argumentsList 传递给构造函数的参数值数组
48
+ * @param newTarget 构造函数要用作new.target的对象
49
+ * @example
50
+ function Person(name) {this.name = name;}
51
+ const person = Reflect.construct(Person, ['Alice']); // person = { name: 'Alice' }
52
+ */
53
+ function Construct(target: Function, argumentsList: ArrayLike<any>, newTarget?: Function): any;
54
+ /**
55
+ * 获取目标的属性,当' receiver === target '时相当于' target[propertyKey] '
56
+ * @param target 目标对象,该对象在其自身或其原型链中包含该属性
57
+ * @param propertyKey 属性名
58
+ * @param receiver 如果' target[propertyKey] '是一个访问器属性,则在getter函数中用作' this '值的引用
59
+ * @example
60
+ const obj = { a: 1, b: 2 };
61
+ const value = Reflect.get(obj, 'a'); // value = 1
62
+ */
63
+ function Get<T extends object, P extends PropertyKey>(target: T, propertyKey: P, receiver?: unknown): P extends keyof T ? T[P] : any;
64
+ /**
65
+ * 设置目标的属性,当' receiver === target '时相当于' target[propertyKey] = value '
66
+ * @param target 目标对象,该对象在其自身或其原型链中包含该属性
67
+ * @param propertyKey 属性名称
68
+ * @param receiver 如果' target[propertyKey] '是一个访问器属性,则在setter函数中用作' this '值的引用
69
+ * @example
70
+ const obj = { a: 1 };
71
+ Reflect.set(obj, 'a', 2); // obj.a = 2
72
+ */
73
+ function Set(target: object, propertyKey: PropertyKey, value: any, receiver?: any): boolean;
74
+ /**
75
+ * 属性是否存在,相当于' propertyKey in target '
76
+ * @param target 目标对象,该对象在其自身或其原型链中包含该属性
77
+ * @param propertyKey 属性名称
78
+ * @example
79
+ const obj = { a: 1 };
80
+ const hasA = Reflect.has(obj, 'a'); // hasA = true
81
+ */
82
+ function Has(target: object, propertyKey: PropertyKey): boolean;
83
+ /**
84
+ * 向对象添加属性,或修改现有属性的属性
85
+ * @param target 目标对象,要在其上添加或修改属性。它可以是一个原生JavaScript对象*(即用户定义对象或内置对象)或DOM对象。
86
+ * @param propertyKey 属性名称
87
+ * @param attributes 属性的描述符。它可以用于数据属性或访问器属性
88
+ * @example
89
+ const obj = {};
90
+ Reflect.defineProperty(obj, 'a', { value: 1, writable: true });
91
+ */
92
+ function DefineProperty(target: object, propertyKey: PropertyKey, attributes: PropertyDescriptor & ThisType<any>): boolean;
93
+ /**
94
+ * 从对象中删除属性,相当于' delete target[propertyKey] ',除非' target[propertyKey] '不可配置,否则它不会抛出
95
+ * @param target 目标对象,从中删除自身属性
96
+ * @param propertyKey 属性名称
97
+ * @example
98
+ const obj = { a: 1 };
99
+ Reflect.deleteProperty(obj, 'a'); // obj = {}
100
+ */
101
+ function DeleteProperty(target: object, propertyKey: PropertyKey): boolean;
102
+ /**
103
+ * 获取指定对象的自己的属性描述符。自己的属性描述符是直接在对象上定义的,而不是从对象的原型继承的
104
+ * @param target 包含该属性的目标
105
+ * @param propertyKey 属性名称
106
+ * @example
107
+ const obj = { a: 1 };
108
+ const descriptor = Reflect.getOwnPropertyDescriptor(obj, 'a');
109
+ // descriptor = { value: 1, writable: true, enumerable: true, configurable: true }
110
+ */
111
+ function GetOwnPropertyDescriptor<T extends object, P extends PropertyKey>(target: T, propertyKey: P): TypedPropertyDescriptor<P extends keyof T ? T[P] : any> | undefined;
112
+ /**
113
+ * 返回对象的原型
114
+ * @param target 引用原型的对象
115
+ */
116
+ function GetPrototypeOf(target: object): object | null;
117
+ /**
118
+ * 返回对象自身属性的字符串键和符号键。对象自己的属性是那些直接在该对象上定义的属性,而不是从对象的原型继承的属性
119
+ * @param target 目标对象,该对象包含自己的属性
120
+ * @example
121
+ const obj = { a: 1, [Symbol('b')]: 2 };
122
+ const keys = Reflect.ownKeys(obj); // keys = ['a', Symbol(b)]
123
+ */
124
+ function OwnKeys(target: object): (string | symbol)[];
125
+ /**
126
+ * 返回一个值,该值指示是否可以向对象添加新属性
127
+ * @param target 要检测的对象
128
+ * @example
129
+ const obj = {};
130
+ const isExtensible = Reflect.isExtensible(obj); // isExtensible = true
131
+ */
132
+ function IsExtensible(target: object): boolean;
133
+ /**
134
+ * 防止向对象添加新属性
135
+ * @param target 对象使其不可扩展
136
+ * @return 对象是否被设置为不可扩展的
137
+ * @example
138
+ const obj = {};
139
+ Reflect.preventExtensions(obj);
140
+ */
141
+ function PreventExtensions(target: object): boolean;
142
+ /**
143
+ * 将指定对象的原型设置为object proto或null
144
+ * @param target 对象改变它的原型
145
+ * @param proto 新原型的值或null
146
+ * @return 原型设置是否成功
147
+ */
148
+ function SetPrototypeOf(target: object, proto: object | null): boolean;
149
+ /**
150
+ * 将一组装饰器应用于目标对象的属性
151
+ * @param decorators 一个装饰器数组
152
+ * @param target 目标对象
153
+ * @param propertyKey 属性键来装饰
154
+ * @param attributes 属性描述符
155
+ * @remarks 装饰器以相反的顺序应用
156
+ * @example
157
+ * class Example
158
+ * {
159
+ * // property declarations are not part of ES6, though they arevalid in TypeScript:
160
+ * // static staticProperty;
161
+ * // property;
162
+ * static staticMethod() { }
163
+ * method() { }
164
+ * }
165
+ *
166
+ * // property (on constructor)
167
+ * Reflect.decorate(decoratorsArray, Example, "staticProperty");
168
+ *
169
+ * // property (on prototype)
170
+ * Reflect.decorate(decoratorsArray, Example.prototype, "property");
171
+ *
172
+ * // method (on constructor)
173
+ * Object.defineProperty(Example, "staticMethod",
174
+ * Reflect.decorate(decoratorsArray, Example, "staticMethod",
175
+ * Object.getOwnPropertyDescriptor(Example, "staticMethod")));
176
+ *
177
+ * // method (on prototype)
178
+ * Object.defineProperty(Example.prototype, "method",
179
+ * Reflect.decorate(decoratorsArray, Example.prototype, "method",
180
+ * Object.getOwnPropertyDescriptor(Example.prototype,"method")));
181
+ */
182
+ function Decorate(decorators: (PropertyDecorator | MethodDecorator)[], target: Object, propertyKey: string | symbol, attributes?: PropertyDescriptor): PropertyDescriptor;
183
+ /**
184
+ * 可以在类、类成员或参数上使用的默认元数据装饰器工厂
185
+ * @param metadataKey 元数据条目的键
186
+ * @param metadataValue 元数据条目的值
187
+ * @returns 装饰器函数
188
+ * @remarks 如果' metadataKey '已经为目标和目标键定义,则该键的metadataValue将被覆盖。
189
+ * @example
190
+ * // constructor
191
+ * Reflect.metadata(key, value)
192
+ * class Example { }
193
+ * // property (on constructor, TypeScript only)
194
+ * class Example
195
+ * {
196
+ * Reflect.metadata(key, value)
197
+ * static staticProperty;
198
+ * }
199
+ *
200
+ * // property (on prototype, TypeScript only)
201
+ * class Example
202
+ * {
203
+ * Reflect.metadata(key, value)
204
+ * property;
205
+ * }
206
+ *
207
+ * // method (on constructor)
208
+ * class Example
209
+ * {
210
+ * Reflect.metadata(key, value)
211
+ * static staticMethod() { }
212
+ * }
213
+ *
214
+ * // method (on prototype)
215
+ * class Example
216
+ * {
217
+ * Reflect.metadata(key, value)
218
+ * method() { }
219
+ * }
220
+ */
221
+ function Metadata(metadataKey: any, metadataValue: any): {
222
+ (target: Function): void;
223
+ (target: Object, propertyKey: string | symbol): void;
224
+ };
225
+ /**
226
+ * 在目标上定义唯一的元数据项
227
+ * @param metadataKey 用于存储和检索元数据的键
228
+ * @param metadataValue 包含附加元数据的值
229
+ * @param target 在其上定义元数据的目标对象
230
+ * @example
231
+ * class Example { }
232
+ * // constructor
233
+ * Reflect.defineMetadata("custom:annotation", options, Example);
234
+ * // decorator factory as metadata-producing annotation.
235
+ * function MyAnnotation(options): ClassDecorator
236
+ * {
237
+ * return target => Reflect.defineMetadata("custom:annotation", options, target);
238
+ * }
239
+ */
240
+ function DefineMetadata(metadataKey: any, metadataValue: any, target: Object): void;
241
+ /**
242
+ * 获取一个值,该值指示目标对象或其原型链是否定义了提供的元数据键
243
+ * @param metadataKey 用于存储和检索元数据的键
244
+ * @param target 定义元数据的目标对象
245
+ * @returns 如果元数据键是在目标对象或其原型链上定义的,则为true;否则false
246
+ * @example
247
+ * class Example { }
248
+ * // constructor
249
+ * result = Reflect.hasMetadata("custom:annotation", Example);
250
+ */
251
+ function HasMetadata(metadataKey: any, target: Object): boolean;
252
+ /**
253
+ * 获取一个值,该值指示目标对象是否定义了提供的元数据键
254
+ * @param metadataKey 用于存储和检索元数据的键
255
+ * @param target 定义元数据的目标对象
256
+ * @returns 如果元数据键在目标对象上定义,则为true否则false
257
+ * @example
258
+ * class Example { }
259
+ * // constructor
260
+ * result = Reflect.hasOwnMetadata("custom:annotation", Example);
261
+ */
262
+ function HasOwnMetadata(metadataKey: any, target: Object): boolean;
263
+ /**
264
+ * 获取目标对象或其原型链上提供的元数据键的元数据值
265
+ * @param metadataKey 用于存储和检索元数据的键
266
+ * @param target 定义元数据的目标对象
267
+ * @returns 如果找到元数据键的元数据值;否则,'undefined'
268
+ * @example
269
+ * class Example { }
270
+ * // constructor
271
+ * result = Reflect.getMetadata("custom:annotation", Example);
272
+ */
273
+ function GetMetadata(metadataKey: any, target: Object): any;
274
+ /**
275
+ * 获取目标对象上提供的元数据键的元数据值
276
+ * @param metadataKey 用于存储和检索元数据的键
277
+ * @param target 定义元数据的目标对象
278
+ * @returns 如果找到元数据键的元数据值;否则`undefined`
279
+ * @example
280
+ * class Example { }
281
+ * // constructor
282
+ * result = Reflect.getOwnMetadata("custom:annotation", Example);
283
+ */
284
+ function GetOwnMetadata(metadataKey: any, target: Object): any;
285
+ /**
286
+ * 获取在目标对象或其原型链上定义的元数据键
287
+ * @param target 定义元数据的目标对象
288
+ * @returns 唯一元数据键的数组
289
+ * @example
290
+ * class Example { }
291
+ * // constructor
292
+ * result = Reflect.getMetadataKeys(Example);
293
+ */
294
+ function GetMetadataKeys(target: Object): any[];
295
+ /**
296
+ * 获取在目标对象上定义的唯一元数据键
297
+ * @param target 定义元数据的目标对象
298
+ * @returns 唯一元数据键的数组
299
+ * @example
300
+ * class Example { }
301
+ * // constructor
302
+ * result = Reflect.getOwnMetadataKeys(Example);
303
+ */
304
+ function GetOwnMetadataKeys(target: Object): any[];
305
+ /**
306
+ * 使用提供的键从目标对象中删除元数据项
307
+ * @param metadataKey 用于存储和检索元数据的键
308
+ * @param target 定义元数据的目标对象
309
+ * @returns 如果元数据条目被找到并删除,则为true否则false
310
+ * @example
311
+ * class Example { }
312
+ * // constructor
313
+ * result = Reflect.deleteMetadata("custom:annotation", Example);
314
+ */
315
+ function DeleteMetadata(metadataKey: any, target: Object): boolean;
316
+ }
@@ -0,0 +1,55 @@
1
+ /** 字符串工具 */
2
+ export declare namespace StringUtility {
3
+ /** 默认空字符串 */
4
+ const Empty: string;
5
+ /** 逗号=> , */
6
+ const Comma = ",";
7
+ /** 分号=> : */
8
+ const Semicolon = ":";
9
+ /** 左斜杠=> / */
10
+ const LeftSlash = "/";
11
+ /** 右斜杠=> \ */
12
+ const RightSlash = "\\";
13
+ /** 单边双引号 => " */
14
+ const DoubleQuotes: string;
15
+ /** 单边单引号 => ' */
16
+ const SingleQuotes: string;
17
+ /** 美元符号 */
18
+ const Dollar: string;
19
+ /** 字符串拼串 */
20
+ function SubString(_arrString: Array<string>, _startIndex?: number): string;
21
+ /** 检查路径字符串 */
22
+ function SubPath(_paths: Array<string>, _symble: string): string;
23
+ /** 检测字符串两边是否是指定相同的字符 */
24
+ function CheckDoubleSideSameChar(_str: string, _checkChar: string): Boolean;
25
+ /** 检测字符串两边是否是指定不同的字符 */
26
+ function CheckDoubleSideDiffChar(_str: string, _char1: string, _char2: string): Boolean;
27
+ /** 在字符串指定位置插入指定的字符串 */
28
+ function Insert(_str: string, _pos: number, _newStr: string): string;
29
+ /** 在字符串首位添加插入字符 */
30
+ function InsertDoubleSide(_str: string, _char1: string, _char2: string): string;
31
+ /** 删除首尾指定个数个字符 */
32
+ function DestoryDoubleSide(_str: string, _headCount?: number, _endCount?: number): string;
33
+ /** 删除字符串的头部指定个数个字符 */
34
+ function DestoryFirstChar(_str: string, _headCount?: number): string;
35
+ /** 删除字符串的尾部指定个数个字符 */
36
+ function DestoryLastChar(_str: string, _endCount?: number): string;
37
+ /** 根据传入的字符串数组或列表,每个元素中间插入指定的字符,串成一个字符串 EXP:aaa,bbb,ccc,ddd */
38
+ function JoinString(_arrStrings: Array<string>, _symble: string): string;
39
+ /** 检测字符串是否是空字符串(空串则返回true 不空则返回false) */
40
+ function IsNullOrEmpty(_str: string): Boolean;
41
+ /** 数字类型转字符串类型 */
42
+ function ToString(_any: number | {} | any): string;
43
+ /**
44
+ * 字符串替换 搜索字符串替换为指定的替换字符串,并返回替换后的新字符串
45
+ * @param originalString 原始字符串
46
+ * @param searchString 要搜索的字符串
47
+ * @param replacement 要替换的字符串
48
+ * @returns
49
+ */
50
+ function ReplaceString(originalString: string, searchString: string, replacement: string): string;
51
+ /** 仅保留数字 */
52
+ function KeepNumeric(_value: string): number;
53
+ /** 仅保留除数字外字符串 */
54
+ function RejectNumeric(_value: string): string;
55
+ }
@@ -0,0 +1,15 @@
1
+ export * from "./ConfigUtility";
2
+ export * from "./EnumUtility";
3
+ export * from "./FileUtility";
4
+ export * from "./BrowserUtility";
5
+ export * from "./InterfaceUtility";
6
+ export * from "./LogUtility";
7
+ export * from "./MathUtility";
8
+ export * from "./NetworkUtility";
9
+ export * from "./ObjectUtility";
10
+ export * from "./PromiseUtility";
11
+ export * from "./StringUtility";
12
+ export * from "./ProfilerUtility";
13
+ export * from "./InputUtility";
14
+ export * from "./CryptoUtility";
15
+ export * from "./ReflectionUtility";
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './frame';