@singcl/ad-execute-manager 1.0.5 → 1.0.7

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,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,121 @@
1
+ export default RewardAdFather;
2
+ export type IRewordAdConfig = import("../typings/ad.js").IRewordAdConfig;
3
+ export type CallbackCollection = import("../typings/ad.js").CallbackCollection;
4
+ export type IConstructArgs = import("../typings/ad.js").IConstructArgs;
5
+ export type IRewardedVideoAd = {
6
+ /**
7
+ * 显示激励视频广告
8
+ */
9
+ show: () => Promise<void>;
10
+ };
11
+ /**
12
+ * @typedef IRewardedVideoAd
13
+ * @property {() => Promise.<void>} show 显示激励视频广告
14
+ */
15
+ declare class RewardAdFather {
16
+ /** @type {IRewordAdConfig | null} */
17
+ static args: IRewordAdConfig | null;
18
+ /**
19
+ * @param {IRewordAdConfig} args
20
+ */
21
+ static buildArgs(args: IRewordAdConfig): void;
22
+ /**
23
+ * 使用管理器执行广告
24
+ * @param {Object} adInstance 广告实例
25
+ * @param {Object} ctx 上下文对象,用于传递数据和状态
26
+ * @param {Object} ctx.options 广告执行选项
27
+ * @param {Object} ctx.options.log 是否打印日志
28
+ * @param {Object} ctx.collection 回调集合
29
+ * @returns {Promise} 广告执行结果的Promise
30
+ */
31
+ static executeWithManager(adInstance: any, ctx: {
32
+ options: {
33
+ log: any;
34
+ };
35
+ collection: any;
36
+ }): Promise<any>;
37
+ /**
38
+ * @param {IConstructArgs} args
39
+ */
40
+ constructor(args: IConstructArgs);
41
+ _initSign: string;
42
+ _preserveOnEnd: boolean;
43
+ _rewardAd: any;
44
+ _ttErrorMsgs: string[];
45
+ _ttErrorCodes: number[];
46
+ _adConfig: {};
47
+ /**
48
+ * 初始化
49
+ * 子类可以选择覆盖此方法,或使用默认实现
50
+ * @param {IRewordAdConfig} params
51
+ * @param {(v: IRewardedVideoAd) => void} [callback] 初始化成功回调
52
+ * @returns {this} 当前实例
53
+ */
54
+ initialize(params: IRewordAdConfig, callback?: (v: IRewardedVideoAd) => void): this;
55
+ initialized(): boolean;
56
+ /**
57
+ * 执行广告展示
58
+ * @abstract
59
+ * @param {Object} [ctx] 上下文对象,用于传递数据和状态
60
+ * @param {IRewordAdConfig} [ctx.options] 广告执行选项
61
+ * @param {CallbackCollection} [ctx.collection] 回调集合
62
+ * @param {Function} next 执行下一个任务的回调函数,在洋葱模型中手动调用以继续执行流程
63
+ * @returns {Promise<unknown>} 广告执行结果的Promise
64
+ * @throws {Error} 子类必须实现此方法
65
+ */
66
+ ad(ctx?: {
67
+ options?: IRewordAdConfig;
68
+ collection?: CallbackCollection;
69
+ }, next?: Function): Promise<unknown>;
70
+ /**
71
+ * 确保广告按顺序执行
72
+ * @param {Object} [ctx] 上下文对象,用于传递数据和状态
73
+ * @param {IRewordAdConfig} [ctx.options] 广告执行选项
74
+ * @param {CallbackCollection} [ctx.collection] 回调集合
75
+ * @returns {Promise.<unknown>} 广告执行结果的Promise
76
+ */
77
+ addExecuteManager(ctx?: {
78
+ options?: IRewordAdConfig;
79
+ collection?: CallbackCollection;
80
+ }): Promise<unknown>;
81
+ destroy(): void;
82
+ clear(): void;
83
+ /**
84
+ *
85
+ * @param {({isEnded: boolean, count: number}) => void} callback
86
+ */
87
+ onClose(callback: ({ isEnded: boolean, count: number }: any) => void): void;
88
+ /**
89
+ *
90
+ * @param {({isEnded: boolean, count: number}) => void} callback
91
+ */
92
+ offClose(callback: ({ isEnded: boolean, count: number }: any) => void): void;
93
+ /**
94
+ * show
95
+ * @returns { Promise.<void>}
96
+ * @params {{errMsg: string; errCode: number}} err
97
+ */
98
+ show(): Promise<void>;
99
+ /**
100
+ * show
101
+ * @returns { Promise.<void>}
102
+ */
103
+ load(): Promise<void>;
104
+ /**
105
+ *
106
+ * @param {({errMsg: string; errCode: number}) => void} callback
107
+ */
108
+ onError(callback: any): void;
109
+ /**
110
+ *
111
+ * @param {({errMsg: string; errCode: number}) => void} callback
112
+ */
113
+ offError(callback: any): void;
114
+ onLoad(callback: any): void;
115
+ offLoad(callback: any): void;
116
+ /**
117
+ * 站位方法,没有任何左右
118
+ * @returns
119
+ */
120
+ placeholder(): any;
121
+ }
@@ -0,0 +1,111 @@
1
+ export default RewardAdGlobalRecorder;
2
+ export type RecordType = "halfway" | "finished" | "completed";
3
+ /**
4
+ * @typedef {'halfway' | 'finished' | 'completed'} RecordType
5
+ */
6
+ declare class RewardAdGlobalRecorder {
7
+ static instance: any;
8
+ /**
9
+ *
10
+ * @param {object} args
11
+ * @param {string} args.sign 初始化标识
12
+ * @returns {RewardAdGlobalRecorder}
13
+ */
14
+ static build(args: {
15
+ sign: string;
16
+ }): RewardAdGlobalRecorder;
17
+ /**
18
+ *
19
+ * @returns {RewardAdGlobalRecorder}
20
+ */
21
+ static getInstance(): RewardAdGlobalRecorder;
22
+ /**
23
+ * @param {object} args
24
+ * @param {string} args.sign 初始化标识
25
+ */
26
+ constructor(args: {
27
+ sign: string;
28
+ });
29
+ _initSign: string;
30
+ _halfway: {
31
+ scene: 6;
32
+ count: number;
33
+ }[];
34
+ _finished: {
35
+ scene: 6;
36
+ count: number;
37
+ }[];
38
+ /**
39
+ * @param {object} args
40
+ * @param {string} args.sign 初始化标识
41
+ */
42
+ initialize(args: {
43
+ sign: string;
44
+ }): void;
45
+ /**
46
+ * 找到相同的场景值,如果没有则新增
47
+ * @param {object} args
48
+ * @param {RecordType} args.type
49
+ * @param {number} args.scene
50
+ */
51
+ _halfwayUpdate(args: {
52
+ type: RecordType;
53
+ scene: number;
54
+ }): void;
55
+ /**
56
+ * @param {object} args
57
+ * @param {number[]} args.scenes
58
+ * @returns
59
+ */
60
+ _halfwayGet(args: {
61
+ scenes: number[];
62
+ }): number;
63
+ _halfwayReset(): void;
64
+ /**
65
+ * 找到相同的场景值,如果没有则新增
66
+ * @param {object} args
67
+ * @param {RecordType} args.type
68
+ * @param {number} args.scene
69
+ */
70
+ _finishedUpdate(args: {
71
+ type: RecordType;
72
+ scene: number;
73
+ }): void;
74
+ /**
75
+ * @param {object} args
76
+ * @param {number[]} args.scenes
77
+ * @returns
78
+ */
79
+ _finishedGet(args: {
80
+ scenes: number[];
81
+ }): number;
82
+ _finishedReset(): void;
83
+ /**
84
+ * @param {object} args
85
+ * @param {RecordType} args.type
86
+ * @param {number} args.scene
87
+ */
88
+ record(args: {
89
+ type: RecordType;
90
+ scene: number;
91
+ }): void;
92
+ /**
93
+ *
94
+ * @param {RecordType} type
95
+ */
96
+ rest(type: RecordType): void;
97
+ /**
98
+ * @param {object} args
99
+ * @param {number[]} [args.scenes]
100
+ * @param {RecordType} args.type
101
+ */
102
+ get(args: {
103
+ scenes?: number[];
104
+ type: RecordType;
105
+ }): number;
106
+ /**
107
+ * 站位方法,没有任何左右
108
+ * @returns
109
+ */
110
+ placeholder(): any;
111
+ }
@@ -0,0 +1,91 @@
1
+ export default RewardAdLaunch;
2
+ export type IRewordAdConfig = import("../typings/ad.js").IRewordAdConfig;
3
+ export type IConstructArgs = import("../typings/ad.js").IConstructArgs;
4
+ /**
5
+ * @typedef {import('../typings/ad.js').IRewordAdConfig} IRewordAdConfig
6
+ */
7
+ /**
8
+ * @typedef {import('../typings/ad.js').IConstructArgs} IConstructArgs
9
+ */
10
+ declare class RewardAdLaunch extends RewardAdNovel {
11
+ /**
12
+ *
13
+ * @param {IConstructArgs} args
14
+ * @returns {RewardAdLaunch}
15
+ */
16
+ static build(args: IConstructArgs): RewardAdLaunch;
17
+ /**
18
+ *
19
+ * @returns {RewardAdLaunch}
20
+ */
21
+ static getInstance(): RewardAdLaunch;
22
+ /**
23
+ *
24
+ * @param {IConstructArgs} args
25
+ * @returns {RewardAdLaunch}
26
+ */
27
+ static "new"(args: IConstructArgs): RewardAdLaunch;
28
+ /**
29
+ *
30
+ * @type {Promise.<unknown>}
31
+ */
32
+ static ad: Promise<unknown>;
33
+ /**
34
+ *
35
+ * @param {object} options 启动参数
36
+ * @param {string} options.path 启动路径
37
+ * @param {object} options.query 启动参数
38
+ * @param {string} options.query.promotionid 推广参数
39
+ * @param {(args: { options: object } | null) => Promise.<void>} callback 回调
40
+ * @returns
41
+ */
42
+ static satisfy(options: {
43
+ path: string;
44
+ query: {
45
+ promotionid: string;
46
+ };
47
+ }, callback: (args: {
48
+ options: object;
49
+ } | null) => Promise<void>): Promise<void>;
50
+ /**
51
+ * @param {object} args
52
+ * @param {string} args.sign 初始化标识
53
+ */
54
+ constructor(args: {
55
+ sign: string;
56
+ });
57
+ _scene: 0;
58
+ launchSettings: RewardAdLaunchSettings;
59
+ }
60
+ import RewardAdNovel from './RewardAdNovel';
61
+ declare class RewardAdLaunchSettings {
62
+ /**
63
+ *
64
+ * @param {object} args
65
+ * @param {string} args.sign 初始化标识
66
+ * @returns {RewardAdLaunchSettings}
67
+ */
68
+ static "new"(args: {
69
+ sign: string;
70
+ }): RewardAdLaunchSettings;
71
+ _fixedFrequency: any;
72
+ frequency: {
73
+ total: number;
74
+ current: number;
75
+ };
76
+ commonSettings: CommonSettings;
77
+ countRecorder: CountRecorder;
78
+ /**
79
+ * 获取启动广告的展示次数
80
+ * @returns {number} 启动广告的展示次数配置,如果没有配置则返回0
81
+ */
82
+ _adTimes(): number;
83
+ updateToday(): void;
84
+ updateFrequency(): void;
85
+ remainFrequency(): number;
86
+ timesPerFrequency(): number;
87
+ _remain(): number;
88
+ condition(): boolean;
89
+ }
90
+ import CommonSettings from './CommonSettings';
91
+ import { CountRecorder } from './CountRecorder';
@@ -0,0 +1,63 @@
1
+ export default RewardAdLaunchAlone;
2
+ export type IRewordAdConfig = import("../typings/ad.js").IRewordAdConfig;
3
+ export type IConstructArgs = import("../typings/ad.js").IConstructArgs;
4
+ export type CallbackCollection = import("../typings/ad.js").CallbackCollection;
5
+ /**
6
+ * @typedef {import('../typings/ad.js').IRewordAdConfig} IRewordAdConfig
7
+ */
8
+ /**
9
+ * @typedef {import('../typings/ad.js').IConstructArgs} IConstructArgs
10
+ */
11
+ /**
12
+ * @typedef {import('../typings/ad.js').CallbackCollection} CallbackCollection
13
+ */
14
+ declare class RewardAdLaunchAlone extends RewardAdNovel {
15
+ /**
16
+ *
17
+ * @param {IConstructArgs} args
18
+ * @returns {RewardAdLaunchAlone}
19
+ */
20
+ static build(args: IConstructArgs): RewardAdLaunchAlone;
21
+ /**
22
+ *
23
+ * @returns {RewardAdLaunchAlone}
24
+ */
25
+ static getInstance(): RewardAdLaunchAlone;
26
+ /**
27
+ *
28
+ * @param {IConstructArgs} args
29
+ * @returns {RewardAdLaunchAlone}
30
+ */
31
+ static "new"(args: IConstructArgs): RewardAdLaunchAlone;
32
+ /**
33
+ *
34
+ * @type {Promise.<unknown>}
35
+ */
36
+ static ad: Promise<unknown>;
37
+ /**
38
+ *
39
+ * @param {object} options 启动参数
40
+ * @param {string} options.path 启动路径
41
+ * @param {object} options.query 启动参数
42
+ * @param {string} options.query.promotionid 推广参数
43
+ * @param {() => Promise.<void>} callback 回调
44
+ * @returns
45
+ */
46
+ static satisfy(options: {
47
+ path: string;
48
+ query: {
49
+ promotionid: string;
50
+ };
51
+ }, callback: () => Promise<void>): Promise<void>;
52
+ /**
53
+ * @param {object} args
54
+ * @param {string} args.sign 初始化标识
55
+ * @param {IRewordAdConfig=} args.adConfig 激励视频参数 (可选)
56
+ */
57
+ constructor(args: {
58
+ sign: string;
59
+ adConfig?: IRewordAdConfig | undefined;
60
+ });
61
+ _scene: 9;
62
+ }
63
+ import RewardAdNovel from './RewardAdNovel';