@ad-execute-manager/core 2.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/dist/ad/InterstitialAdFather.d.ts +131 -0
- package/dist/ad/InterstitialAdNovel.d.ts +457 -0
- package/dist/ad/RewardAdFather.d.ts +131 -0
- package/dist/ad/RewardAdNovel.d.ts +464 -0
- package/dist/ad/index.d.ts +4 -0
- package/dist/const/const.d.ts +20 -0
- package/dist/core/AdExecuteManager.d.ts +129 -0
- package/dist/core/compose.d.ts +12 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/helper/AdAnalyticsJS.d.ts +132 -0
- package/dist/helper/CountRecorder.d.ts +59 -0
- package/dist/helper/EventEmitter.d.ts +15 -0
- package/dist/helper/Logger.d.ts +35 -0
- package/dist/helper/LovelUnlockManager.d.ts +233 -0
- package/dist/helper/PubSub.d.ts +9 -0
- package/dist/helper/RewardAdGlobalRecorder.d.ts +109 -0
- package/dist/helper/RewardAdSceneTriggerManager.d.ts +71 -0
- package/dist/helper/SerializableError.d.ts +9 -0
- package/dist/helper/Storage.d.ts +124 -0
- package/dist/helper/index.d.ts +10 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +1 -0
- package/dist/typings/ad.d.ts +188 -0
- package/dist/typings/common.d.ts +14 -0
- package/dist/typings/tracker.d.ts +1 -0
- package/dist/utils/functional.d.ts +13 -0
- package/package.json +24 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
export default AdExecuteManager;
|
|
2
|
+
export type AdTask = {
|
|
3
|
+
/**
|
|
4
|
+
* RewardAdFather的子类实例
|
|
5
|
+
*/
|
|
6
|
+
adInstance: import("../ad/RewardAdFather.js").default;
|
|
7
|
+
/**
|
|
8
|
+
* 广告执行选项
|
|
9
|
+
*/
|
|
10
|
+
options: import("../typings/ad.js").IRewordAdConfig;
|
|
11
|
+
/**
|
|
12
|
+
* 回调集合
|
|
13
|
+
*/
|
|
14
|
+
callbackCollection: import("../typings/ad.js").CallbackCollection;
|
|
15
|
+
/**
|
|
16
|
+
* 广告执行成功的回调函数
|
|
17
|
+
*/
|
|
18
|
+
resolve: Function;
|
|
19
|
+
/**
|
|
20
|
+
* 广告执行失败的回调函数
|
|
21
|
+
*/
|
|
22
|
+
reject: Function;
|
|
23
|
+
/**
|
|
24
|
+
* 广告任务的唯一标识符
|
|
25
|
+
*/
|
|
26
|
+
id: string;
|
|
27
|
+
/**
|
|
28
|
+
* 广告任务是否已成功解决
|
|
29
|
+
*/
|
|
30
|
+
_isResolved: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* 广告任务是否已被拒绝
|
|
33
|
+
*/
|
|
34
|
+
_isRejected: boolean;
|
|
35
|
+
};
|
|
36
|
+
export type IConstructArgs = {
|
|
37
|
+
/**
|
|
38
|
+
* 广告执行选项
|
|
39
|
+
*/
|
|
40
|
+
options?: object;
|
|
41
|
+
/**
|
|
42
|
+
* 是否打印日志
|
|
43
|
+
*/
|
|
44
|
+
log?: boolean;
|
|
45
|
+
};
|
|
46
|
+
declare class AdExecuteManager {
|
|
47
|
+
/**
|
|
48
|
+
* 单例实例
|
|
49
|
+
* @type {AdExecuteManager|null}
|
|
50
|
+
*/
|
|
51
|
+
static _instance: AdExecuteManager | null;
|
|
52
|
+
/**
|
|
53
|
+
* 获取单例实例
|
|
54
|
+
* @param {IConstructArgs} [args]
|
|
55
|
+
* @returns {AdExecuteManager}
|
|
56
|
+
*/
|
|
57
|
+
static getInstance(args?: IConstructArgs): AdExecuteManager;
|
|
58
|
+
/**
|
|
59
|
+
* 获取单例实例
|
|
60
|
+
* @returns {AdExecuteManager}
|
|
61
|
+
*/
|
|
62
|
+
static getSafeInstance(): AdExecuteManager;
|
|
63
|
+
/**
|
|
64
|
+
*
|
|
65
|
+
* @param {IConstructArgs} args
|
|
66
|
+
* @returns
|
|
67
|
+
*/
|
|
68
|
+
constructor(args: IConstructArgs);
|
|
69
|
+
/**
|
|
70
|
+
* @type {Array.<AdTask>}
|
|
71
|
+
*/
|
|
72
|
+
_taskStack: Array<AdTask>;
|
|
73
|
+
/**
|
|
74
|
+
* @type {Array.<AdTask>}
|
|
75
|
+
*/
|
|
76
|
+
_currentBatchTasks: Array<AdTask>;
|
|
77
|
+
/**
|
|
78
|
+
* @type {boolean}
|
|
79
|
+
*/
|
|
80
|
+
_isRunning: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* @type {AdTask|null}
|
|
83
|
+
*/
|
|
84
|
+
_currentTask: AdTask | null;
|
|
85
|
+
logger: Logger;
|
|
86
|
+
/**
|
|
87
|
+
* 添加广告任务
|
|
88
|
+
* @param {import('../ad/RewardAdFather.js').default} adInstance RewardAdFather的子类实例
|
|
89
|
+
* @param {Object} ctx 广告执行上下文
|
|
90
|
+
* @param {import('../typings/ad.js').IRewordAdConfig} ctx.options 广告执行选项
|
|
91
|
+
* @param {import('../typings/ad.js').CallbackCollection} ctx.collection 回调集合
|
|
92
|
+
* @returns {Promise} 广告执行结果的Promise
|
|
93
|
+
*/
|
|
94
|
+
addTask(adInstance: import("../ad/RewardAdFather.js").default, ctx: {
|
|
95
|
+
options: import("../typings/ad.js").IRewordAdConfig;
|
|
96
|
+
collection: import("../typings/ad.js").CallbackCollection;
|
|
97
|
+
}): Promise<any>;
|
|
98
|
+
/**
|
|
99
|
+
* 组合所有任务
|
|
100
|
+
* @private
|
|
101
|
+
*/
|
|
102
|
+
private _compose;
|
|
103
|
+
/**
|
|
104
|
+
* 清空任务栈并取消所有任务(包括正在执行的任务和middleware链中等待执行的任务)
|
|
105
|
+
*/
|
|
106
|
+
clearTasks(): void;
|
|
107
|
+
/**
|
|
108
|
+
* 获取当前未完成的任务总数
|
|
109
|
+
* 包括任务栈中待执行的任务和中间件链中未完成的任务
|
|
110
|
+
* @returns {number} 未完成的任务数量
|
|
111
|
+
*/
|
|
112
|
+
getTaskCount(): number;
|
|
113
|
+
/**
|
|
114
|
+
* 是否有任务正在运行
|
|
115
|
+
* @returns {boolean}
|
|
116
|
+
*/
|
|
117
|
+
isRunning(): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* 获取当前执行的任务ID
|
|
120
|
+
* @returns {string|null} 当前任务ID
|
|
121
|
+
*/
|
|
122
|
+
getCurrentTaskId(): string | null;
|
|
123
|
+
/**
|
|
124
|
+
* 返回一个Promise,当任务队列中的所有任务都完成时resolve
|
|
125
|
+
* @returns {Promise<void>} 当所有任务完成时resolve的Promise
|
|
126
|
+
*/
|
|
127
|
+
whenAllTasksComplete(): Promise<void>;
|
|
128
|
+
}
|
|
129
|
+
import { Logger } from '../helper/Logger';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default compose;
|
|
2
|
+
/**
|
|
3
|
+
* Koa中间件核心处理机制
|
|
4
|
+
* @see https://github.com/singcl/koa/blob/master/src/compose-es7.js
|
|
5
|
+
* @param {Array.<Function>} middlewares KOA中间件数组,每个中间件函数接收ctx和next参数
|
|
6
|
+
* @returns {Function} 返回一个组合后的中间件函数,接收ctx参数并按顺序执行所有中间件
|
|
7
|
+
* @version 0.0.1
|
|
8
|
+
* @since 0.0.1
|
|
9
|
+
* @author singcl 24661881@qq.com
|
|
10
|
+
* @description 将多个中间件函数组合成一个单一的中间件函数,形成洋葱模型的调用链
|
|
11
|
+
*/
|
|
12
|
+
declare function compose(middlewares: Array<Function>): Function;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
export default AdAnalyticsJS;
|
|
2
|
+
export type EventDict = {
|
|
3
|
+
[x: string]: any;
|
|
4
|
+
};
|
|
5
|
+
export type IConstructorArgs = {
|
|
6
|
+
/**
|
|
7
|
+
* 初始化标识
|
|
8
|
+
*/
|
|
9
|
+
sign: string;
|
|
10
|
+
/**
|
|
11
|
+
* 是否需要上报
|
|
12
|
+
*/
|
|
13
|
+
needReport?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* 公共用户信息
|
|
16
|
+
*/
|
|
17
|
+
commonConfig?: ICommonInfo;
|
|
18
|
+
};
|
|
19
|
+
export type ICommonInfo = {
|
|
20
|
+
[x: string]: any;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {Object.<string, object>} EventDict
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* @typedef {object} IConstructorArgs
|
|
27
|
+
* @property {string} sign 初始化标识
|
|
28
|
+
* @property {boolean} [needReport] 是否需要上报
|
|
29
|
+
* @property {ICommonInfo} [commonConfig] 公共用户信息
|
|
30
|
+
*
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* @typedef {Object.<string, object>} ICommonInfo
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
36
|
+
declare class AdAnalyticsJS {
|
|
37
|
+
static instance: any;
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @param {IConstructorArgs} args
|
|
41
|
+
* @returns {AdAnalyticsJS}
|
|
42
|
+
*/
|
|
43
|
+
static build(args: IConstructorArgs): AdAnalyticsJS;
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
* @returns {AdAnalyticsJS}
|
|
47
|
+
*/
|
|
48
|
+
static getInstance(): AdAnalyticsJS;
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @param {IConstructorArgs} args
|
|
52
|
+
* @returns {AdAnalyticsJS}
|
|
53
|
+
*/
|
|
54
|
+
static "new"(args: IConstructorArgs): AdAnalyticsJS;
|
|
55
|
+
/**
|
|
56
|
+
* @param {IConstructorArgs} args
|
|
57
|
+
*/
|
|
58
|
+
constructor(args: IConstructorArgs);
|
|
59
|
+
_initSign: string;
|
|
60
|
+
_needReport: boolean;
|
|
61
|
+
/** @type {ICommonInfo | null} */
|
|
62
|
+
_commonConfig: ICommonInfo | null;
|
|
63
|
+
/**
|
|
64
|
+
* 初始化 比如环境配置,api地址、日志等级等
|
|
65
|
+
* @param {IConstructorArgs} args
|
|
66
|
+
*/
|
|
67
|
+
initialize(args: IConstructorArgs): IConstructorArgs;
|
|
68
|
+
/**
|
|
69
|
+
* 追踪自定义事件
|
|
70
|
+
* 用户交互,如点击、提交
|
|
71
|
+
*
|
|
72
|
+
* @template {keyof EventDict} K
|
|
73
|
+
* @param {K} eventName - The name of the event to track.
|
|
74
|
+
* @param {EventDict[K]} properties - The properties associated with the event.
|
|
75
|
+
* @param {object} [debugParams] - The debug parameters.
|
|
76
|
+
* @param {string} [debugParams.sign] - Whether to enable debug mode.
|
|
77
|
+
*/
|
|
78
|
+
track<K extends keyof EventDict>(eventName: K, properties: EventDict[K], debugParams?: {
|
|
79
|
+
sign?: string;
|
|
80
|
+
}): void;
|
|
81
|
+
/**
|
|
82
|
+
* 获取公共用户信息
|
|
83
|
+
* @public
|
|
84
|
+
* @returns {ICommonInfo}
|
|
85
|
+
*/
|
|
86
|
+
public getCommonInfo(): ICommonInfo;
|
|
87
|
+
/**
|
|
88
|
+
* 获取埋点公共用户信息
|
|
89
|
+
* @protected
|
|
90
|
+
* @returns {ICommonInfo}
|
|
91
|
+
*/
|
|
92
|
+
protected getTrackCommonInfo(): ICommonInfo;
|
|
93
|
+
/**
|
|
94
|
+
* 识别用户身份
|
|
95
|
+
* 用户登录后,关联用户信息
|
|
96
|
+
* @param {string|number} user_id - 用户id
|
|
97
|
+
* @param {ICommonInfo} info - 用户信息
|
|
98
|
+
* @returns {AdAnalyticsJS} 返回实例本身,支持链式调用
|
|
99
|
+
*/
|
|
100
|
+
identify(user_id: string | number, info: ICommonInfo): AdAnalyticsJS;
|
|
101
|
+
/**
|
|
102
|
+
* 合并用户身份
|
|
103
|
+
* 匿名用户转为登录用户
|
|
104
|
+
* @returns
|
|
105
|
+
*/
|
|
106
|
+
alias(): any;
|
|
107
|
+
/**
|
|
108
|
+
* 追踪页面浏览
|
|
109
|
+
* SPA 路由切换,或手动触发页面事件
|
|
110
|
+
* @returns
|
|
111
|
+
*/
|
|
112
|
+
pages(): any;
|
|
113
|
+
/**
|
|
114
|
+
* 追踪页面浏览 进入页面
|
|
115
|
+
*
|
|
116
|
+
* @template {'cpage'} K
|
|
117
|
+
* @param {K} eventName - The name of the event to track.
|
|
118
|
+
* @param {EventDict[K]} properties - The properties associated with the event.
|
|
119
|
+
*/
|
|
120
|
+
page<K extends "cpage">(eventName: K, properties: EventDict[K]): void;
|
|
121
|
+
/**
|
|
122
|
+
*
|
|
123
|
+
* @param {EventDict['cpage']} properties
|
|
124
|
+
* @returns
|
|
125
|
+
*/
|
|
126
|
+
cpage(properties: EventDict["cpage"]): void;
|
|
127
|
+
/**
|
|
128
|
+
* 站位方法,没有任何左右
|
|
129
|
+
* @returns
|
|
130
|
+
*/
|
|
131
|
+
placeholder(): any;
|
|
132
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {object} IConstructorArgs
|
|
3
|
+
* @property {string} [sign] 初始化标识
|
|
4
|
+
* @property {string} local_sign 本地存储标识
|
|
5
|
+
* @property {number} [total] 总次数
|
|
6
|
+
* @property {number|'today'} [expire] 过期时间(毫秒)或'today'表示当天有效,可选
|
|
7
|
+
* @property {string | number} [userId] 用户ID
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
export class CountRecorder {
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param {IConstructorArgs} args
|
|
14
|
+
* @returns {CountRecorder}
|
|
15
|
+
*/
|
|
16
|
+
static "new"(args: IConstructorArgs): CountRecorder;
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param {IConstructorArgs} args
|
|
20
|
+
*/
|
|
21
|
+
constructor(args: IConstructorArgs);
|
|
22
|
+
_total: number;
|
|
23
|
+
_local_sign: string;
|
|
24
|
+
_expire: string;
|
|
25
|
+
storage: Storage;
|
|
26
|
+
_init(): void;
|
|
27
|
+
/**
|
|
28
|
+
* 获取次数
|
|
29
|
+
* @returns {number} 次数
|
|
30
|
+
*/
|
|
31
|
+
_adTimes(): number;
|
|
32
|
+
_safeLocalValue(v: any): any;
|
|
33
|
+
_initLocalTimes(): void;
|
|
34
|
+
updateToday(): void;
|
|
35
|
+
remain(): number;
|
|
36
|
+
}
|
|
37
|
+
export type IConstructorArgs = {
|
|
38
|
+
/**
|
|
39
|
+
* 初始化标识
|
|
40
|
+
*/
|
|
41
|
+
sign?: string;
|
|
42
|
+
/**
|
|
43
|
+
* 本地存储标识
|
|
44
|
+
*/
|
|
45
|
+
local_sign: string;
|
|
46
|
+
/**
|
|
47
|
+
* 总次数
|
|
48
|
+
*/
|
|
49
|
+
total?: number;
|
|
50
|
+
/**
|
|
51
|
+
* 过期时间(毫秒)或'today'表示当天有效,可选
|
|
52
|
+
*/
|
|
53
|
+
expire?: number | "today";
|
|
54
|
+
/**
|
|
55
|
+
* 用户ID
|
|
56
|
+
*/
|
|
57
|
+
userId?: string | number;
|
|
58
|
+
};
|
|
59
|
+
import Storage from './Storage';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class EventEmitter {
|
|
2
|
+
static geInstance(args: any): EventEmitter;
|
|
3
|
+
constructor(options?: {});
|
|
4
|
+
events: {};
|
|
5
|
+
queues: {};
|
|
6
|
+
onceEvents: {};
|
|
7
|
+
maxListeners: any;
|
|
8
|
+
maxQueueSize: any;
|
|
9
|
+
maxOnceEvents: any;
|
|
10
|
+
on(event: any, listener: any): void;
|
|
11
|
+
once(event: any, listener: any): void;
|
|
12
|
+
emit(event: any, ...args: any[]): void;
|
|
13
|
+
off(event: any, listenerToRemove: any): void;
|
|
14
|
+
removeAllListeners(event: any): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export class Logger {
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param {object} [options]
|
|
5
|
+
* @param {string} [options.prefix] - 日志前缀
|
|
6
|
+
* @param {'error'|'warn'|'info'|'log'|'debug'} [options.level] - 日志级别
|
|
7
|
+
* @param {boolean} [options.enabled] - 是否启用日志
|
|
8
|
+
*/
|
|
9
|
+
constructor(options?: {
|
|
10
|
+
prefix?: string;
|
|
11
|
+
level?: "error" | "warn" | "info" | "log" | "debug";
|
|
12
|
+
enabled?: boolean;
|
|
13
|
+
});
|
|
14
|
+
prefix: string;
|
|
15
|
+
enabled: boolean;
|
|
16
|
+
levels: {
|
|
17
|
+
error: number;
|
|
18
|
+
warn: number;
|
|
19
|
+
info: number;
|
|
20
|
+
log: number;
|
|
21
|
+
debug: number;
|
|
22
|
+
};
|
|
23
|
+
currentLevel: number;
|
|
24
|
+
enable(): void;
|
|
25
|
+
disable(): void;
|
|
26
|
+
isEnabled(): boolean;
|
|
27
|
+
setLevel(level: any): void;
|
|
28
|
+
formatMessage(level: any, message: any): string;
|
|
29
|
+
_log(level: any, message: any, ...args: any[]): void;
|
|
30
|
+
error(message: any, ...args: any[]): void;
|
|
31
|
+
warn(message: any, ...args: any[]): void;
|
|
32
|
+
info(message: any, ...args: any[]): void;
|
|
33
|
+
log(message: any, ...args: any[]): void;
|
|
34
|
+
debug(message: any, ...args: any[]): void;
|
|
35
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
export default LovelUnlockManager;
|
|
2
|
+
export type InitSign = "bookStore" | "reader" | "bookIntro";
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {'bookStore'|'reader'|'bookIntro'} InitSign
|
|
5
|
+
*/
|
|
6
|
+
declare class LovelUnlockManager {
|
|
7
|
+
static instance: any;
|
|
8
|
+
/**
|
|
9
|
+
* @static
|
|
10
|
+
* @param {object} args
|
|
11
|
+
* @param {InitSign} args.sign 初始化标识
|
|
12
|
+
* @param {number} args.unlockChapterThreshold 单次解锁章节阈值
|
|
13
|
+
* @param {number} args.unlockChapterNum 解锁章节数
|
|
14
|
+
* @param {number} args.unlockChapterWaterLevel 解锁章节水滴阈值
|
|
15
|
+
*/
|
|
16
|
+
static build(args: {
|
|
17
|
+
sign: InitSign;
|
|
18
|
+
unlockChapterThreshold: number;
|
|
19
|
+
unlockChapterNum: number;
|
|
20
|
+
unlockChapterWaterLevel: number;
|
|
21
|
+
}): any;
|
|
22
|
+
/**
|
|
23
|
+
* @static
|
|
24
|
+
* @returns {LovelUnlockManager}
|
|
25
|
+
*/
|
|
26
|
+
static getInstance(): LovelUnlockManager;
|
|
27
|
+
/**
|
|
28
|
+
* @param {object} args
|
|
29
|
+
* @param {InitSign} args.sign 初始化标识
|
|
30
|
+
* @param {number} args.unlockChapterThreshold 单次解锁章节阈值
|
|
31
|
+
* @param {number} args.unlockChapterNum 解锁章节数
|
|
32
|
+
* @param {number} args.unlockChapterWaterLevel 解锁章节水滴阈值
|
|
33
|
+
*/
|
|
34
|
+
static "new"(args: {
|
|
35
|
+
sign: InitSign;
|
|
36
|
+
unlockChapterThreshold: number;
|
|
37
|
+
unlockChapterNum: number;
|
|
38
|
+
unlockChapterWaterLevel: number;
|
|
39
|
+
}): LovelUnlockManager;
|
|
40
|
+
/**
|
|
41
|
+
* @param {object} args
|
|
42
|
+
* @param {InitSign} args.sign 初始化标识
|
|
43
|
+
* @param {number} args.unlockChapterThreshold 单次解锁章节阈值
|
|
44
|
+
* @param {number} args.unlockChapterNum 解锁章节数
|
|
45
|
+
* @param {number} args.unlockChapterWaterLevel 解锁章节水滴阈值
|
|
46
|
+
*/
|
|
47
|
+
constructor(args: {
|
|
48
|
+
sign: InitSign;
|
|
49
|
+
unlockChapterThreshold: number;
|
|
50
|
+
unlockChapterNum: number;
|
|
51
|
+
unlockChapterWaterLevel: number;
|
|
52
|
+
});
|
|
53
|
+
/**
|
|
54
|
+
* 初始化标识 'bookStore' | 'reader' | 'bookIntro'
|
|
55
|
+
* @access private
|
|
56
|
+
*/
|
|
57
|
+
_initSign: string;
|
|
58
|
+
/**
|
|
59
|
+
* 剧情详情数据
|
|
60
|
+
* @access private
|
|
61
|
+
* @type {Array.<DramaDetailRecord>}
|
|
62
|
+
*/
|
|
63
|
+
_dramaDetailData: Array<{
|
|
64
|
+
/**
|
|
65
|
+
* 章节id
|
|
66
|
+
*/
|
|
67
|
+
episodeId: string;
|
|
68
|
+
/**
|
|
69
|
+
* 1 已解锁 0 未解锁 null 未解锁
|
|
70
|
+
*/
|
|
71
|
+
flagTag: number | null;
|
|
72
|
+
/**
|
|
73
|
+
* 章节名称
|
|
74
|
+
*/
|
|
75
|
+
albumId: string;
|
|
76
|
+
}>;
|
|
77
|
+
/**
|
|
78
|
+
* 单次解锁章节阈值
|
|
79
|
+
* @access private
|
|
80
|
+
*/
|
|
81
|
+
_unlockChapterThreshold: number;
|
|
82
|
+
/**
|
|
83
|
+
* 解锁章节数
|
|
84
|
+
* @access private
|
|
85
|
+
*/
|
|
86
|
+
_unlockChapterNum: number;
|
|
87
|
+
/**
|
|
88
|
+
* 解锁章节水滴阈值
|
|
89
|
+
* @access private
|
|
90
|
+
*/
|
|
91
|
+
_unlockChapterWaterLevel: number;
|
|
92
|
+
/**
|
|
93
|
+
* 是否达到阈值
|
|
94
|
+
* @access private
|
|
95
|
+
*/
|
|
96
|
+
_isReachThreshold: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* 已经解锁的章节id数组
|
|
99
|
+
* @access private
|
|
100
|
+
* @type {Array.<string>}
|
|
101
|
+
*/
|
|
102
|
+
_unlockedIdArr: Array<string>;
|
|
103
|
+
/**
|
|
104
|
+
* 设置剧情详情数据
|
|
105
|
+
* @param {Array.<DramaDetailRecord>} value 剧情详情数据
|
|
106
|
+
*/
|
|
107
|
+
set drama(value: Array<{
|
|
108
|
+
/**
|
|
109
|
+
* 章节id
|
|
110
|
+
*/
|
|
111
|
+
episodeId: string;
|
|
112
|
+
/**
|
|
113
|
+
* 1 已解锁 0 未解锁 null 未解锁
|
|
114
|
+
*/
|
|
115
|
+
flagTag: number | null;
|
|
116
|
+
/**
|
|
117
|
+
* 章节名称
|
|
118
|
+
*/
|
|
119
|
+
albumId: string;
|
|
120
|
+
}>);
|
|
121
|
+
/**
|
|
122
|
+
* @typedef {object} DramaDetailRecord
|
|
123
|
+
* @property {string} episodeId 章节id
|
|
124
|
+
* @property {number | null} flagTag 1 已解锁 0 未解锁 null 未解锁
|
|
125
|
+
* @property {string} albumId 章节名称
|
|
126
|
+
*/
|
|
127
|
+
/**
|
|
128
|
+
* 获取剧情详情数据
|
|
129
|
+
* @returns {Array.<DramaDetailRecord>} 剧情详情数据
|
|
130
|
+
*/
|
|
131
|
+
get drama(): Array<{
|
|
132
|
+
/**
|
|
133
|
+
* 章节id
|
|
134
|
+
*/
|
|
135
|
+
episodeId: string;
|
|
136
|
+
/**
|
|
137
|
+
* 1 已解锁 0 未解锁 null 未解锁
|
|
138
|
+
*/
|
|
139
|
+
flagTag: number | null;
|
|
140
|
+
/**
|
|
141
|
+
* 章节名称
|
|
142
|
+
*/
|
|
143
|
+
albumId: string;
|
|
144
|
+
}>;
|
|
145
|
+
/**
|
|
146
|
+
* 设置是否达到阈值
|
|
147
|
+
* @access private
|
|
148
|
+
* @param {Array.<DramaDetailRecord>} value 剧情详情数据
|
|
149
|
+
*/
|
|
150
|
+
_checkReachThreshold(v?: any[]): void;
|
|
151
|
+
/**
|
|
152
|
+
* 判断达到阈值
|
|
153
|
+
* @access private
|
|
154
|
+
* @returns
|
|
155
|
+
*/
|
|
156
|
+
_isUnlockThreshold(): boolean;
|
|
157
|
+
/**
|
|
158
|
+
* 从指定chapterId开始解锁指定数量的章节,前后章节数量相等
|
|
159
|
+
* @access private
|
|
160
|
+
* @param {string} chapterId 章节id
|
|
161
|
+
* @param {number} count 解锁章节数量
|
|
162
|
+
* @returns {Array.<string>} 解锁的章节id数组
|
|
163
|
+
*/
|
|
164
|
+
_unlockChapterIds(chapterId: string, count?: number): Array<string>;
|
|
165
|
+
/**
|
|
166
|
+
* 从指定chapterId开始解锁指定数量的章节,增加水位
|
|
167
|
+
* @access private
|
|
168
|
+
* @param {string} chapterId 章节id
|
|
169
|
+
* @param {number} count 解锁章节数量
|
|
170
|
+
* @returns {Array.<string> | undefined} 解锁的章节id数组
|
|
171
|
+
*/
|
|
172
|
+
_unlockChapterIdsWithWater(chapterId: string, count?: number): Array<string> | undefined;
|
|
173
|
+
/**
|
|
174
|
+
* 判断是否达到解锁阈值,走不同的逻辑
|
|
175
|
+
* @access public
|
|
176
|
+
* @param {() => void} callback 原逻辑【达到阈值前】回调函数
|
|
177
|
+
* @param {(ids: Array.<string>) => void} [callbackThreshold] 新逻辑【达到阈值后】回调函数
|
|
178
|
+
* @param {string} [chapterId] 章节id
|
|
179
|
+
*/
|
|
180
|
+
ready(callback: () => void, callbackThreshold?: (ids: Array<string>) => void, chapterId?: string): void;
|
|
181
|
+
/**
|
|
182
|
+
* @typedef {object} ProcessUpdateResult
|
|
183
|
+
* @property {string} chapterId 章节id
|
|
184
|
+
* @property {number} percent 当前章节的阅读进度
|
|
185
|
+
*/
|
|
186
|
+
/**
|
|
187
|
+
* 章节阅读进度更新
|
|
188
|
+
* @access public
|
|
189
|
+
* @param {ProcessUpdateResult} r 当前章节的阅读进度
|
|
190
|
+
* @param {(ids: Array.<string>) => void} callback 达到阈值后回调函数
|
|
191
|
+
*/
|
|
192
|
+
onProcessUpdate(r: {
|
|
193
|
+
/**
|
|
194
|
+
* 章节id
|
|
195
|
+
*/
|
|
196
|
+
chapterId: string;
|
|
197
|
+
/**
|
|
198
|
+
* 当前章节的阅读进度
|
|
199
|
+
*/
|
|
200
|
+
percent: number;
|
|
201
|
+
}, callback: (ids: Array<string>) => void): void;
|
|
202
|
+
/**
|
|
203
|
+
* @typedef {object} ChapterChangeResult
|
|
204
|
+
* @property {string} currentChapterId 变化前的章节ID
|
|
205
|
+
* @property {string} nextChapterId 变化后的章节ID
|
|
206
|
+
* @property {string} [nextOutChapterId] 开发者自己的章节ID
|
|
207
|
+
*/
|
|
208
|
+
/**
|
|
209
|
+
* 章节变化
|
|
210
|
+
* @access public
|
|
211
|
+
* @param {ChapterChangeResult} r 当前章节的阅读进度
|
|
212
|
+
* @param {(ids: Array.<string>) => void} callback 达到阈值后回调函数
|
|
213
|
+
*/
|
|
214
|
+
onChapterChange(r: {
|
|
215
|
+
/**
|
|
216
|
+
* 变化前的章节ID
|
|
217
|
+
*/
|
|
218
|
+
currentChapterId: string;
|
|
219
|
+
/**
|
|
220
|
+
* 变化后的章节ID
|
|
221
|
+
*/
|
|
222
|
+
nextChapterId: string;
|
|
223
|
+
/**
|
|
224
|
+
* 开发者自己的章节ID
|
|
225
|
+
*/
|
|
226
|
+
nextOutChapterId?: string;
|
|
227
|
+
}, callback: (ids: Array<string>) => void): void;
|
|
228
|
+
/**
|
|
229
|
+
* 解锁所有章节
|
|
230
|
+
* @access public
|
|
231
|
+
*/
|
|
232
|
+
unlockAll(): void;
|
|
233
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export default class EventEmitter {
|
|
2
|
+
events: {};
|
|
3
|
+
on(eventName: any, callback: any): () => void;
|
|
4
|
+
off(eventName: any, callback: any): void;
|
|
5
|
+
emit(eventName: any, ...args: any[]): void;
|
|
6
|
+
once(eventName: any, callback: any): void;
|
|
7
|
+
listenerCount(eventName: any): any;
|
|
8
|
+
removeAllListeners(): void;
|
|
9
|
+
}
|