@ruan-cat/utils 3.0.0 → 3.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/dist/index.d.ts CHANGED
@@ -1,96 +1,3 @@
1
- import { OptionalKeysOf } from 'type-fest';
2
-
3
- /**
4
- * rmmv特征基类
5
- * @description
6
- * 全部的rmmv类都具有 `initialize` 函数
7
- *
8
- * 此类型用于描述此
9
- */
10
- declare abstract class RmmvClass {
11
- initialize: (...args: any[]) => void;
12
- }
13
- /**
14
- * 获取对象的全部函数key名称
15
- * @description
16
- * 从一个类型内,获取值为函数的key名称
17
- */
18
- type FunctionKeys<T> = {
19
- [K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;
20
- }[keyof T];
21
- /**
22
- * 属性提示工具
23
- * @description
24
- * 对继承的类进行属性提示
25
- *
26
- * 对自己新增的属性和函数做属性提示
27
- *
28
- * 对全部涉及到的函数,其this全部做判定
29
- */
30
- type AttributePromptTool<SourceCode extends RmmvClass, UserCode> = ThisType<SourceCode & UserCode> & Partial<SourceCode> & UserCode;
31
- /**
32
- * 默认处理策略
33
- * @description
34
- * 先回调rmmv源码 再加上用户代码
35
- */
36
- declare const defaultHandleStrategy: "source-first";
37
- /**
38
- * 处理策略
39
- * @description
40
- * 用户代码相对于rmmv源码的处理策略
41
- */
42
- declare const handleStrategy: readonly ["userCode-cover-source", "source-first", "userCode-first"];
43
- /**
44
- * 处理策略
45
- * @description
46
- * 用户代码相对于rmmv源码的处理策略
47
- */
48
- type HandleStrategy = (typeof handleStrategy)[number];
49
- /**
50
- * 被默认执行默认处理策略的函数名
51
- * @description
52
- * 初始化函数默认使用固定的处理策略。
53
- */
54
- type defaultHandleStrategy_FuncationName = FunctionKeys<RmmvClass>;
55
- /** 全部可选字段组成的对象 且该对象的全部字段必填 */
56
- type AllOptionalFieldObj<T extends object> = Required<Pick<T, OptionalKeysOf<T>>>;
57
- /** 给一个对象排除 init 字段 */
58
- type NoInit<T> = Omit<T, defaultHandleStrategy_FuncationName>;
59
- type AllOptionalFieldObj_noInit<T extends object> = NoInit<AllOptionalFieldObj<T>>;
60
- /** 处理策略配置的 全部有意义的配置键名 */
61
- type HandleStrategyConfigKeys<T extends object> = FunctionKeys<AllOptionalFieldObj_noInit<T>>;
62
- /**
63
- * 全部有意义函数的 处理策略配置
64
- * @description
65
- * 只有可能去覆盖,拓展的函数名,才值得去配置
66
- */
67
- type HandleStrategyConfig<T extends object> = Record<HandleStrategyConfigKeys<T>, HandleStrategy>;
68
- /** rmmv类拓展工具函数配置 */
69
- type RmmvClassExpandTools<SourceCode extends new (...args: any[]) => RmmvClass, UserCode extends object> = {
70
- /** 源码 一般是被拓展的类,往往是rmmv的源码类 */
71
- source: SourceCode;
72
- /** 用户代码 插件开发者编写的一个内部完备的对象 */
73
- userCode: UserCode;
74
- /**
75
- * 拓展配置 按照要求拓展
76
- * @description
77
- * 用户可以不提供配置 就默认按照标准的方式处理
78
- */
79
- config?: Partial<HandleStrategyConfig<UserCode>>;
80
- };
81
- /**
82
- * rmmv类拓展工具函数
83
- * @description
84
- * 预期处理5种情况
85
- *
86
- * - 1. 用户代码覆盖掉rmmv源码
87
- * - 2. 默认处理策略
88
- * - 3. 先执行用户代码 再回调rmmv源码
89
- * - 4. 初始化函数默认使用固定的处理策略
90
- * - 5. 继承对象没有这个属性时 说明是新的函数 直接添加到原型链上
91
- */
92
- declare function rmmvClassExpandTools<SourceCode extends new (...args: any[]) => RmmvClass, UserCode extends object = any>(params: RmmvClassExpandTools<SourceCode, UserCode>): void;
93
-
94
1
  type Condition = (...args: unknown[]) => boolean;
95
2
  /** @deprecated 没必要 */
96
3
  type Conditions = Condition[];
@@ -200,4 +107,4 @@ type Prettify<T> = {
200
107
  */
201
108
  type ToNumberLike<T extends number> = T | `${T}`;
202
109
 
203
- export { type AttributePromptTool, type BaseTask, type Condition, type Conditions, type FunctionKeys, type HandleStrategy, type ParallelTasks, type PnpmWorkspace, type Prettify, type PromiseTasksConfig, type QueueTasks, RmmvClass, type SimpleAsyncTask, type SingleTasks, type Task, type TaskType, type TasksConfig, type ToNumberLike, defaultHandleStrategy, type defaultHandleStrategy_FuncationName, definePromiseTasks, executePromiseTasks, generateSimpleAsyncTask, initFlag, isConditionsEvery, isConditionsSome, rmmvClassExpandTools, runPromiseByConcurrency, runPromiseByQueue, taskTypes };
110
+ export { type BaseTask, type Condition, type Conditions, type ParallelTasks, type PnpmWorkspace, type Prettify, type PromiseTasksConfig, type QueueTasks, type SimpleAsyncTask, type SingleTasks, type Task, type TaskType, type TasksConfig, type ToNumberLike, definePromiseTasks, executePromiseTasks, generateSimpleAsyncTask, initFlag, isConditionsEvery, isConditionsSome, runPromiseByConcurrency, runPromiseByQueue, taskTypes };