keytops-game-framework 1.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.
Files changed (151) hide show
  1. package/README.md +214 -0
  2. package/dist/app/base/RuntimeApplicationImpl.d.ts +22 -0
  3. package/dist/app/base/base.d.ts +113 -0
  4. package/dist/app/base/event/Event.d.ts +12 -0
  5. package/dist/app/base/event/EventDispatcher.d.ts +66 -0
  6. package/dist/app/base/pool/IRecoverable.d.ts +13 -0
  7. package/dist/app/base/pool/Pool.d.ts +45 -0
  8. package/dist/app/base/utils/Handler.d.ts +69 -0
  9. package/dist/app/base/utils/Injector.d.ts +19 -0
  10. package/dist/app/base/utils/Json.d.ts +14 -0
  11. package/dist/app/base/utils/MathUtils.d.ts +74 -0
  12. package/dist/app/base/utils/NativeUtils.d.ts +4 -0
  13. package/dist/app/base/utils/PromiseUtils.d.ts +20 -0
  14. package/dist/app/base/utils/StringUtils.d.ts +66 -0
  15. package/dist/app/module/abTesting/ABTesting.d.ts +41 -0
  16. package/dist/app/module/analytics/ALiAnalyticsSender.d.ts +59 -0
  17. package/dist/app/module/analytics/AnalyticsAble.d.ts +191 -0
  18. package/dist/app/module/analytics/AnalyticsAbleConst.d.ts +20 -0
  19. package/dist/app/module/analytics/BaseDimension.d.ts +19 -0
  20. package/dist/app/module/analytics/KeytopsAnalyticsSender.d.ts +67 -0
  21. package/dist/app/module/analytics/ad/ADAnalyticsAble.d.ts +19 -0
  22. package/dist/app/module/analytics/ad/ADBehaviorReporter.d.ts +90 -0
  23. package/dist/app/module/analytics/ad/AdDimension.d.ts +34 -0
  24. package/dist/app/module/analytics/index.d.ts +65 -0
  25. package/dist/app/module/analytics/launch/LaunchAnalyticsAble.d.ts +11 -0
  26. package/dist/app/module/analytics/level/GameDimension.d.ts +39 -0
  27. package/dist/app/module/analytics/level/LevelAnalyticsAble.d.ts +86 -0
  28. package/dist/app/module/analytics/level/LevelBehaviorReporter.d.ts +29 -0
  29. package/dist/app/module/analytics/level/LevelStatsDimension.d.ts +70 -0
  30. package/dist/app/module/analytics/level/PlayerAbilityDimension.d.ts +147 -0
  31. package/dist/app/module/analytics/session/SessionAnalyticsAble.d.ts +9 -0
  32. package/dist/app/module/analytics/session/SessionDimension.d.ts +48 -0
  33. package/dist/app/module/analytics/social/SocialAnalyticsAble.d.ts +14 -0
  34. package/dist/app/module/analytics/social/SocialDimension.d.ts +14 -0
  35. package/dist/app/module/bidding/Bidding.d.ts +37 -0
  36. package/dist/app/module/business/BusinessCenter.d.ts +33 -0
  37. package/dist/app/module/business/IBusiness.d.ts +6 -0
  38. package/dist/app/module/business/RewardVideoMaskBusiness.d.ts +18 -0
  39. package/dist/app/module/config/ConfigHelper.d.ts +142 -0
  40. package/dist/app/module/ecs/Component.d.ts +125 -0
  41. package/dist/app/module/ecs/ECS.d.ts +162 -0
  42. package/dist/app/module/ecs/ECSManager.d.ts +56 -0
  43. package/dist/app/module/ecs/Entity.d.ts +1 -0
  44. package/dist/app/module/ecs/Mask.d.ts +12 -0
  45. package/dist/app/module/ecs/System.d.ts +54 -0
  46. package/dist/app/module/fsm/Fsm.d.ts +44 -0
  47. package/dist/app/module/fsm/FsmBase.d.ts +28 -0
  48. package/dist/app/module/fsm/FsmManager.d.ts +67 -0
  49. package/dist/app/module/fsm/IFsm.d.ts +67 -0
  50. package/dist/app/module/fsm/IFsmState.d.ts +38 -0
  51. package/dist/app/module/logger/Logger.d.ts +58 -0
  52. package/dist/app/module/native/INativeHelper.d.ts +6 -0
  53. package/dist/app/module/native/NativeHelper.d.ts +10 -0
  54. package/dist/app/module/net/NetInterface.d.ts +22 -0
  55. package/dist/app/module/net/NetManager.d.ts +24 -0
  56. package/dist/app/module/net/byte/ByteView.d.ts +391 -0
  57. package/dist/app/module/net/http/HttpNode.d.ts +104 -0
  58. package/dist/app/module/net/http/HttpRequest.d.ts +104 -0
  59. package/dist/app/module/net/server/IServer.d.ts +20 -0
  60. package/dist/app/module/net/server/LevelOnlineConfig.d.ts +9 -0
  61. package/dist/app/module/net/server/Server.d.ts +105 -0
  62. package/dist/app/module/net/server/SystemOnlineConfig.d.ts +34 -0
  63. package/dist/app/module/net/socket/BaseProtocolHelper.d.ts +31 -0
  64. package/dist/app/module/net/socket/Socket.d.ts +145 -0
  65. package/dist/app/module/net/socket/SocketNode.d.ts +63 -0
  66. package/dist/app/module/publisher/IADAble.d.ts +46 -0
  67. package/dist/app/module/publisher/IAble.d.ts +6 -0
  68. package/dist/app/module/publisher/IDevice.d.ts +42 -0
  69. package/dist/app/module/publisher/IGameUpdateAble.d.ts +21 -0
  70. package/dist/app/module/publisher/ILoginAble.d.ts +38 -0
  71. package/dist/app/module/publisher/IPayAble.d.ts +11 -0
  72. package/dist/app/module/publisher/IPublisher.d.ts +154 -0
  73. package/dist/app/module/publisher/IPublisherManager.d.ts +69 -0
  74. package/dist/app/module/publisher/IRecordAble.d.ts +16 -0
  75. package/dist/app/module/publisher/IShareAble.d.ts +39 -0
  76. package/dist/app/module/publisher/PublisherManager.d.ts +106 -0
  77. package/dist/app/module/publisher/PublisherManagerImpl.d.ts +24 -0
  78. package/dist/app/module/publisher/ks/KSAd.d.ts +7 -0
  79. package/dist/app/module/publisher/ks/KSDevice.d.ts +8 -0
  80. package/dist/app/module/publisher/ks/KSLogin.d.ts +7 -0
  81. package/dist/app/module/publisher/ks/KSPublisher.d.ts +34 -0
  82. package/dist/app/module/publisher/ks/KSRecorder.d.ts +13 -0
  83. package/dist/app/module/publisher/ks/KSShare.d.ts +32 -0
  84. package/dist/app/module/publisher/my/MYAd.d.ts +13 -0
  85. package/dist/app/module/publisher/my/MYDevice.d.ts +7 -0
  86. package/dist/app/module/publisher/my/MYLogin.d.ts +6 -0
  87. package/dist/app/module/publisher/my/MYPublisher.d.ts +6 -0
  88. package/dist/app/module/publisher/native/NativeAd.d.ts +22 -0
  89. package/dist/app/module/publisher/native/NativeAnalyticsSender.d.ts +9 -0
  90. package/dist/app/module/publisher/native/NativeDevice.d.ts +6 -0
  91. package/dist/app/module/publisher/native/NativeLogin.d.ts +27 -0
  92. package/dist/app/module/publisher/native/NativePay.d.ts +6 -0
  93. package/dist/app/module/publisher/native/NativePublisher.d.ts +21 -0
  94. package/dist/app/module/publisher/native/NativeRecord.d.ts +10 -0
  95. package/dist/app/module/publisher/native/NativeShare.d.ts +23 -0
  96. package/dist/app/module/publisher/tk/TKAd.d.ts +14 -0
  97. package/dist/app/module/publisher/tk/TKAnalyticsSender.d.ts +7 -0
  98. package/dist/app/module/publisher/tk/TKDevice.d.ts +9 -0
  99. package/dist/app/module/publisher/tk/TKLogin.d.ts +5 -0
  100. package/dist/app/module/publisher/tk/TKPublisher.d.ts +34 -0
  101. package/dist/app/module/publisher/tt/TTAd.d.ts +14 -0
  102. package/dist/app/module/publisher/tt/TTAnalyticsSender.d.ts +7 -0
  103. package/dist/app/module/publisher/tt/TTDevice.d.ts +9 -0
  104. package/dist/app/module/publisher/tt/TTLogin.d.ts +6 -0
  105. package/dist/app/module/publisher/tt/TTPay.d.ts +4 -0
  106. package/dist/app/module/publisher/tt/TTPublisher.d.ts +34 -0
  107. package/dist/app/module/publisher/tt/TTRecorder.d.ts +11 -0
  108. package/dist/app/module/publisher/tt/TTShare.d.ts +50 -0
  109. package/dist/app/module/publisher/tt/TTUpdateGameAble.d.ts +7 -0
  110. package/dist/app/module/publisher/wx/WXAd.d.ts +14 -0
  111. package/dist/app/module/publisher/wx/WXAnalyticsSender.d.ts +7 -0
  112. package/dist/app/module/publisher/wx/WXDevice.d.ts +8 -0
  113. package/dist/app/module/publisher/wx/WXLogin.d.ts +9 -0
  114. package/dist/app/module/publisher/wx/WXPay.d.ts +4 -0
  115. package/dist/app/module/publisher/wx/WXPublisher.d.ts +33 -0
  116. package/dist/app/module/publisher/wx/WXShare.d.ts +56 -0
  117. package/dist/app/module/publisher/wx/WXUpdateGameAble.d.ts +7 -0
  118. package/dist/app/module/storage/Storage.d.ts +123 -0
  119. package/dist/app/module/storage/StorageImpl.d.ts +13 -0
  120. package/dist/app/module/structure/Dictionary.d.ts +48 -0
  121. package/dist/app/module/structure/Link.d.ts +149 -0
  122. package/dist/app/module/structure/List.d.ts +93 -0
  123. package/dist/app/module/task/Task.d.ts +33 -0
  124. package/dist/app/module/task/TaskQueue.d.ts +17 -0
  125. package/dist/app/module/task/TaskSequence.d.ts +19 -0
  126. package/dist/app/module/timer/ITimer.d.ts +4 -0
  127. package/dist/app/module/timer/Timer.d.ts +133 -0
  128. package/dist/app/module/timer/TimerImpl.d.ts +10 -0
  129. package/dist/app/module/utils/md5.d.ts +3 -0
  130. package/dist/app/module/view/IView.d.ts +94 -0
  131. package/dist/app/module/view/IViewLoader.d.ts +48 -0
  132. package/dist/app/module/view/ViewManager.d.ts +242 -0
  133. package/dist/audio/AudioManager.d.ts +146 -0
  134. package/dist/business/AudioBusiness.d.ts +11 -0
  135. package/dist/cocos.d.ts +1 -0
  136. package/dist/index.d.ts +146 -0
  137. package/dist/index.js +14981 -0
  138. package/dist/native/CocosNativeHelper.d.ts +12 -0
  139. package/dist/resource/ResourceManager.d.ts +187 -0
  140. package/dist/utils/Async.d.ts +28 -0
  141. package/dist/utils/CocosStorageUtils.d.ts +10 -0
  142. package/dist/utils/GeometryUtils.d.ts +31 -0
  143. package/dist/view/CCPViewLoader.d.ts +95 -0
  144. package/dist/view/CCSceneLoader.d.ts +25 -0
  145. package/dist/view/CocosViewManager.d.ts +12 -0
  146. package/dist/view/Scene.d.ts +35 -0
  147. package/dist/view/View.d.ts +151 -0
  148. package/dist/view/ViewControl.d.ts +106 -0
  149. package/dist/view/tips/TipsView.d.ts +12 -0
  150. package/dist/vitest.config.d.ts +2 -0
  151. package/package.json +33 -0
@@ -0,0 +1,12 @@
1
+ import { INativeHelper } from "../app/module/native/INativeHelper";
2
+ /**
3
+ @name: NativeHelper
4
+ @desc: cocos 2.4.x 下nativeHelper
5
+ @author: timoo
6
+ @date: 2022/12/02
7
+ */
8
+ export declare class CocosNativeHelper extends INativeHelper {
9
+ callWithReturnType(className: string, methodName: string, returnType: string | number | boolean, ...args: any[]): string | number | boolean;
10
+ private getArgsSig;
11
+ private getValueTypeStr;
12
+ }
@@ -0,0 +1,187 @@
1
+ import { Task } from "../app/module/task/Task";
2
+ import * as cc from "cc";
3
+ export type ResourceInfo = {
4
+ /**
5
+ * 资源的完整原始路径
6
+ */
7
+ fullPath: string;
8
+ /**
9
+ * 资源所属的bundle下面的路径
10
+ */
11
+ path: string;
12
+ /**
13
+ * bundle资源所属bundle名称
14
+ */
15
+ bundle: string;
16
+ /**
17
+ * 是否为远程资源
18
+ */
19
+ isRemote: boolean;
20
+ /**
21
+ * 资源地址是否指向文件夹,通过最后的字符是否为"/"获得
22
+ */
23
+ isDir: boolean;
24
+ };
25
+ /**
26
+ * 资源管理
27
+ */
28
+ export declare class ResourceManager {
29
+ private _bundleVersionMap;
30
+ private _loadPromiseMap;
31
+ private _loadBunldePromiseMap;
32
+ private _waitToReleaseBundles;
33
+ private _startedGC;
34
+ /**
35
+ * 预加载资源
36
+ * @param cc.path - `bundleName://cc.path/to/asset`目标素材的资源地址
37
+ * @param task - `Task` 可选参数,任务回调
38
+ * @returns
39
+ *
40
+ * @example
41
+ *
42
+ * //预加载主包内的素材
43
+ * preload("main://cc.path/to/asset")
44
+ * //预加载动态资源中的素材
45
+ * preload("resource://cc.path/to/asset")
46
+ * //预加载其他包中的资源
47
+ * preload("bundleName://cc.path/to/asset")
48
+ * //预加载远程服务器上的资源
49
+ * preload("https://cc.path/to/sound.mp3")
50
+ * preload("https://cc.path/to/image.png")
51
+ * //预加载文件夹
52
+ * preload("bundleName://cc.path/to/dir/")
53
+ */
54
+ preload(path: string, task?: Task): Promise<string>;
55
+ preload(path: string[], task?: Task): Promise<string[]>;
56
+ preload(path: string | string[], task?: Task): Promise<string | string[]>;
57
+ /**
58
+ * 预加载场景
59
+ * @param cc.path - `bundleName://cc.path/to/sceneName` 目标场景的加载地址,
60
+ * @param task - `Task` 可选参数,任务回调
61
+ * @returns
62
+ *
63
+ * @example
64
+ * //加载主包中的场景
65
+ * preLoadScene("main://cc.path/to/sceneName")
66
+ * //加载动态包中的场景
67
+ * preLoadScene("resources://cc.path/to/sceneName")
68
+ * //加载其他bundle中的场景
69
+ * preLoadScene("bundleName://cc.path/to/sceneName")
70
+ */
71
+ preLoadScene(path: string, task?: Task): Promise<string>;
72
+ preLoadScene(path: string[], task?: Task): Promise<string[]>;
73
+ preLoadScene(path: string | string[], task?: Task): Promise<string | string[]>;
74
+ private _preLoadFromRemote;
75
+ private _preLoadFromBundle;
76
+ /**
77
+ * 加载资源
78
+ * @param cc.path - `bundleName://cc.path/to/asset`目标素材的资源地址
79
+ * @param assetType - 可选参数,cocos资源类型(Asset子类),当返回类型不是预期类型时,需要手动指定,如SpriteFrame
80
+ * @param task - `Task` 可选参数,任务回调
81
+ * @returns 全部失败后返回null
82
+ *
83
+ * @example
84
+ * //预加载主包内的素材
85
+ * load("main://cc.path/to/asset")
86
+ * //预加载动态资源中的素材
87
+ * load("resource://cc.path/to/asset")
88
+ * //预加载其他包中的资源
89
+ * load("bundleName://cc.path/to/image")
90
+ * //预加载远程服务器上的资源
91
+ * load("https://cc.path/to/asset.mp3")
92
+ * load("https://cc.path/to/image.png")
93
+ * //预加载文件夹
94
+ * load("bundleName://cc.path/to/dir/")
95
+ */
96
+ load<T extends cc.Asset>(path: string, assetType?: new () => T, task?: Task): Promise<T>;
97
+ load<T extends cc.Asset>(path: string[], assetType?: new () => T, task?: Task): Promise<T[]>;
98
+ load<T extends cc.Asset>(path: string | string[], assetType?: new () => T, task?: Task): Promise<T | T[]>;
99
+ private _loadFromBundle;
100
+ private _loadfromRemote;
101
+ /**
102
+ * 解析资源路径成PathInfo
103
+ * @param fullPath - 资源路径应该符合bundle://cc.path/to/resource格式
104
+ * @returns - `PathInfo` 资源信息
105
+ */
106
+ parsePath(fullPath: string): ResourceInfo;
107
+ /**
108
+ * 获取目标bundle的资源的完整路径
109
+ * @param bundleName - 资源所在bundle名称
110
+ * @param subPath - 可选参数, 相对子路径
111
+ * @returns
112
+ */
113
+ getPath(bundleName: string, subPath?: string): string;
114
+ /**
115
+ * 获取主包下资源的完整路径
116
+ * @param subPath 资源子路径
117
+ * @returns
118
+ */
119
+ getPathInMain(subPath: string): string;
120
+ /**
121
+ * 获取动态包下资源的完整路径
122
+ * @param subPath 资源子路径
123
+ * @returns
124
+ */
125
+ getPathInResources(subPath: string): string;
126
+ /**
127
+ * 加载Bundle
128
+ * @param bundleName Bundle名称
129
+ * @returns `Promise<cc.AssetManager.Bundle>`
130
+ */
131
+ getBundle(bundleName: string): Promise<cc.AssetManager.Bundle>;
132
+ /**
133
+ * bundle是否被加载过,且有效
134
+ * @param bundleName
135
+ * @returns
136
+ */
137
+ isBundleValid(bundleName: string): Promise<boolean>;
138
+ /**
139
+ * 移除并销毁bundle,以及bundle下所有资源。
140
+ * @param bundleName bundle名称
141
+ * @param delay 是否延后销毁,默认为true
142
+ * @returns
143
+ */
144
+ removeBundle(bundleName: string, delay?: boolean): Promise<boolean>;
145
+ /**
146
+ * 推送bundle到GC队列
147
+ * @param bundle
148
+ */
149
+ private _pushBundleToReleaseMap;
150
+ /**
151
+ * 删除等待销毁的bundle,如果有
152
+ * @param bundleName
153
+ * @returns
154
+ */
155
+ private _removeBundleFromReleaseMap;
156
+ /**
157
+ * 真正移除bundle
158
+ * @param bundle 目标bundle
159
+ * @returns
160
+ */
161
+ private _onRemoveBundle;
162
+ /**
163
+ * 开始Bundle GC,只执行一次
164
+ * @returns
165
+ */
166
+ private _startGC;
167
+ /**
168
+ * GC Bundle
169
+ * @returns
170
+ */
171
+ private _onGC;
172
+ /**
173
+ * 手动设置bundle的版本,可新增可以覆盖。
174
+ * @param map
175
+ */
176
+ setBundleVersion(map: Map<string, string>): void;
177
+ /**
178
+ * 获取bundle的版本
179
+ * @param bundleName
180
+ * @returns
181
+ */
182
+ private _getBundleVersion;
183
+ }
184
+ /**
185
+ * cocos资源加载和管理
186
+ */
187
+ export declare const res: ResourceManager;
@@ -0,0 +1,28 @@
1
+ import { CCObject } from "cc";
2
+ export declare class Async {
3
+ /**
4
+ * 等待多少次 update 帧
5
+ * @param count 次数,默认为1
6
+ * @param component 执行等待的组件,目的用于该组件被销毁时让此等待也随之失效
7
+ */
8
+ static waitUpdateFrame(count?: number, component?: CCObject): Promise<void>;
9
+ /**
10
+ * 等待多少次渲染帧(渲染帧只有在调用了 cc.game.pause() 方法后才会停止更新,所以即使调用
11
+ * 了 cc.director.pause() 方法此等待任然会执行)
12
+ * @param count 次数,默认为1
13
+ * @param component 执行等待的组件,目的用于该组件被销毁时让此等待也随之失效
14
+ */
15
+ static waitRenderFrame(count?: number, component?: CCObject): Promise<void>;
16
+ /**
17
+ * 等待多少秒
18
+ * @param second 秒
19
+ * @param component 执行等待的组件,目的用于该组件被销毁时让此等待也随之失效
20
+ */
21
+ static waitSecond(second: number, component?: CCObject): Promise<void>;
22
+ /**
23
+ * 等待条件满足
24
+ * @param condition 条件
25
+ * @param context 作用域(如果是CCObject则会跟随销毁而失效)
26
+ */
27
+ static waitUntil(condition: () => boolean, context?: Object): Promise<void>;
28
+ }
@@ -0,0 +1,10 @@
1
+ import { IStorage } from "../app/module/storage/Storage";
2
+ /**
3
+ * cocos下的本地持久化实现类
4
+ */
5
+ export declare class CocosStorageUtils implements IStorage {
6
+ removeValue(key: string): void;
7
+ setValue(key: string, value: string | number | boolean): void;
8
+ getValue<T>(key: string): T;
9
+ clear(): void;
10
+ }
@@ -0,0 +1,31 @@
1
+ import * as cc from "cc";
2
+ /**
3
+ * 几何工具(无优化)
4
+ * @author 陈皮皮 (ifaswind)
5
+ * @version 20220107
6
+ * @see GeometryUtil.ts https://gitee.com/ifaswind/eazax-ccc/blob/master/utils/GeometryUtil.ts
7
+ */
8
+ export declare class GeometryUtils {
9
+ /**
10
+ * 判断点是否在线段上
11
+ * @param p 目标点
12
+ * @param a 线段端点 a
13
+ * @param b 线段端点 b
14
+ */
15
+ static pointOnLine(p: cc.Vec3, a: cc.Vec3, b: cc.Vec3): boolean;
16
+ /**
17
+ * 判断点是否在三角形内(同向法)
18
+ * @param p 目标点
19
+ * @param a 三角形顶点 a
20
+ * @param b 三角形顶点 b
21
+ * @param c 三角形顶点 c
22
+ */
23
+ static pointInTriangle(p: cc.Vec3, a: cc.Vec3, b: cc.Vec3, c: cc.Vec3): boolean;
24
+ /**
25
+ * 获取点到线段的最短距离
26
+ * @param p 目标点
27
+ * @param a 线段端点 a
28
+ * @param b 线段端点 b
29
+ */
30
+ static pointLineDistance(p: cc.Vec3, a: cc.Vec3, b: cc.Vec3): number;
31
+ }
@@ -0,0 +1,95 @@
1
+ import { Task } from "../app/module/task/Task";
2
+ import { IView } from "../app/module/view/IView";
3
+ import { ViewConfig, IViewLoader } from "../app/module/view/IViewLoader";
4
+ import * as cc from "cc";
5
+ export type CCPViewConfig = {
6
+ /**
7
+ * 视图所需的附属资源,默认为空。
8
+ */
9
+ res?: string | string[];
10
+ /**
11
+ * 视图非必要的预加载资源,默认为空。只负责调起预加载,不保证加载成功。
12
+ */
13
+ preRes?: string | string[];
14
+ /**
15
+ * 挂载的View Class名称,默认为"View"。
16
+ */
17
+ viewClassName?: string;
18
+ /**
19
+ * 挂载的View Class。
20
+ */
21
+ viewClass?: {
22
+ prototype: IView;
23
+ };
24
+ } & ViewConfig;
25
+ /**
26
+ * 注册View配置的装饰器(CCPViewLoader)
27
+ * @param data 视图配置 CCPViewConfig=
28
+ * @{
29
+ * @ path 视图预制体路径
30
+ * @ [name] 可选,视图名称, 默认为ViewClassName, 默认和视图预制体同名
31
+ * @ [zIndex] 可选,视图显示层级, 默认为ViewLevel.UI
32
+ * @ [viewClassName] 可选,视图根所挂载的ViewClass, 默认和视图预制体同名
33
+ * @ [cache] 可选,界面是否缓存
34
+ * @ [res] 可选,视图依赖的资源列表,默认为空
35
+ * @ [preRes] 可选,视图加载完后发起的预加载资源列表,默认为空
36
+ * @}
37
+ *
38
+ * @example
39
+ * ```
40
+ * //通过装饰器注册视图
41
+ * [@]viewClass({
42
+ path: "Lv1://Prefab/Lv", cache: false, zIndex: ViewLevel.UI, viewClassName: "Lv1",
43
+ //加载视图时,同时加载的依赖资源
44
+ //res:[],
45
+ //加载视图后,发起的预加载资源
46
+ //preRes:[]
47
+ })
48
+ export class Lv1 extends View {
49
+ }
50
+
51
+ //注册Lv1的class(同一个class)到Lv101视图
52
+ viewClass({path: "Lv101://Prefab/Lv", cache: false, zIndex: ViewLevel.UI, viewClassName: "Lv1", name: "Lv101"})(Lv1);
53
+ //注册Lv1的class(同一个class)到Lv102视图
54
+ viewClass({path: "Lv102://Prefab/Lv", cache: false, zIndex: ViewLevel.UI, viewClassName: "Lv1", name: "Lv102"})(Lv1);
55
+ * ```
56
+ */
57
+ export declare function viewClass(data: CCPViewConfig): any;
58
+ /**
59
+ * cocos 默认视图加载器(Prefab)
60
+ */
61
+ export declare class CCPViewLoader extends IViewLoader {
62
+ static TYPE: string;
63
+ /**
64
+ * 创建CCPViewLoader的View配置
65
+ * @param data 视图配置 CCPViewConfig=
66
+ * @{
67
+ * @ path 视图预制体路径
68
+ * @ [name] 可选,视图名称, 默认为ViewClassName, 默认和视图预制体同名
69
+ * @ [zIndex] 可选,视图显示层级, 默认为ViewLevel.UI
70
+ * @ [viewClassName] 可选,视图根所挂载的ViewClass, 默认和视图预制体同名
71
+ * @ [res] 可选,视图依赖的资源列表,默认为空
72
+ * @ [preRes] 可选,视图加载完后发起的预加载资源列表,默认为空
73
+ * @ [cache] 可选,界面是否缓存
74
+ * @}
75
+ */
76
+ static createConfig(data: CCPViewConfig): CCPViewConfig;
77
+ protected _config: CCPViewConfig;
78
+ protected _viewBundle: cc.AssetManager.Bundle;
79
+ init(config: CCPViewConfig): CCPViewLoader;
80
+ /**
81
+ * 加载视图预制体
82
+ * @param task
83
+ * @param config
84
+ */
85
+ protected _loadView(task: Task, config: CCPViewConfig): void;
86
+ /**
87
+ * 加载视图所需的附属资源
88
+ * @param task
89
+ * @param config
90
+ */
91
+ protected _loadRes(task: Task, config: CCPViewConfig): void;
92
+ initView<T extends IView>(viewName: string, recoverLoader?: boolean): T;
93
+ reset(): void;
94
+ destroy(): void;
95
+ }
@@ -0,0 +1,25 @@
1
+ import { Task } from "../app/module/task/Task";
2
+ import { IView } from "../app/module/view/IView";
3
+ import { CCPViewLoader, CCPViewConfig } from "./CCPViewLoader";
4
+ /**
5
+ * cocos 默认视图加载器(Scene)
6
+ */
7
+ export declare class CCSceneLoader extends CCPViewLoader {
8
+ static TYPE: string;
9
+ /**
10
+ * 创建CCSceneLoader的View配置
11
+ * @param data 视图配置 CCPViewConfig=
12
+ * @{
13
+ * @ path 视图预制体路径
14
+ * @ [name] 可选,视图名称, 默认为ViewClassName, 默认和视图预制体同名
15
+ * @ [zIndex] 可选,视图显示层级, 默认为ViewLevel.UI
16
+ * @ [viewClassName] 可选,视图根所挂载的ViewClass, 默认和视图预制体同名
17
+ * @ [res] 可选,视图依赖的资源列表,默认为空
18
+ * @ [preRes] 可选,视图加载完后发起的预加载资源列表,默认为空
19
+ * @ [cache] 可选,界面是否缓存
20
+ * @}
21
+ */
22
+ static createConfig(data: CCPViewConfig): CCPViewConfig;
23
+ protected _loadView(task: Task, config: CCPViewConfig): void;
24
+ initView<T extends IView>(viewName: string, recoverLoader?: boolean): T;
25
+ }
@@ -0,0 +1,12 @@
1
+ import { IViewLoader, ViewConfig } from "../app/module/view/IViewLoader";
2
+ import { IViewManager } from "../app/module/view/ViewManager";
3
+ export declare class CocosViewManager implements IViewManager {
4
+ private _loaderPoolMap;
5
+ /**
6
+ * 从loader池中获取loader
7
+ * @param loaderType
8
+ * @returns
9
+ */
10
+ getLoader(config: ViewConfig): IViewLoader;
11
+ private _getLoaderPool;
12
+ }
@@ -0,0 +1,35 @@
1
+ import { IScene, TipsType } from "../app/module/view/IView";
2
+ import { View } from "./View";
3
+ import { ViewControl } from "./ViewControl";
4
+ export declare class Scene extends View implements IScene {
5
+ sceneName: string;
6
+ private _tipsViewLoader;
7
+ setControl(control: ViewControl): void;
8
+ addView(view: View, index?: number): void;
9
+ /**
10
+ * 显示正常提示
11
+ * @param message 提示文本内容
12
+ * @param stay 停留时长,秒
13
+ */
14
+ tips(message: string, stay?: number): void;
15
+ /**
16
+ * 显示警告提示
17
+ * @param message 警告文本内容
18
+ * @param stay 停留时长,秒
19
+ */
20
+ warn(message: string, stay?: number): void;
21
+ /**
22
+ * 显示错误提示
23
+ * @param message 错误文本内容
24
+ * @param stay 停留时长,秒
25
+ */
26
+ error(message: string, stay?: number): void;
27
+ protected _tips(tipContent: string, type: TipsType, stay?: number): Promise<void>;
28
+ protected onDestroy(): void;
29
+ addToTopup(view: View): void;
30
+ addToNet(view: View): void;
31
+ addToTutorial(view: View): void;
32
+ addToAlert(view: View): void;
33
+ addToUI(view: View): void;
34
+ addToBG(view: View): void;
35
+ }
@@ -0,0 +1,151 @@
1
+ import { AnalyticsData } from "../app/module/analytics/index";
2
+ import { IView } from "../app/module/view/IView";
3
+ import { ViewAnalyticsInfo } from "../app/module/view/ViewManager";
4
+ import * as cc from "cc";
5
+ import { CCPViewConfig } from "./CCPViewLoader";
6
+ import { ViewControl } from "./ViewControl";
7
+ export declare enum ViewLevel {
8
+ TOPUP = 500,
9
+ NET = 400,
10
+ TUTORIAL = 300,
11
+ ALERT = 200,
12
+ UI = 100,
13
+ BG = 1
14
+ }
15
+ export declare class View extends cc.Component implements IView {
16
+ /**
17
+ * View类的Class名称
18
+ */
19
+ static type: string;
20
+ /**
21
+ * 视图名称,加载View时自动赋值。
22
+ */
23
+ /**
24
+ * 视图配置,加载View时自动赋值。
25
+ */
26
+ config: CCPViewConfig;
27
+ /**
28
+ * 视图统计信息
29
+ */
30
+ analyticsInfo: ViewAnalyticsInfo;
31
+ /**
32
+ * 视图所在bundle,加载View时自动赋值。
33
+ */
34
+ bundle: cc.AssetManager.Bundle;
35
+ /**
36
+ * 视图的控制器,在Scene中创建。
37
+ */
38
+ protected _control: ViewControl;
39
+ /**
40
+ * 视图顶层的遮罩,辅助touchEnabled完成当前视图的可交互性。
41
+ */
42
+ private _mask;
43
+ /**
44
+ * 是否可以交互
45
+ */
46
+ private _touchEnabled;
47
+ /**
48
+ * 是否在舞台中显示着
49
+ */
50
+ get inStage(): boolean;
51
+ /**
52
+ * 视图是否响应交互
53
+ */
54
+ get touchEnabled(): boolean;
55
+ /**
56
+ * 视图是否响应交互
57
+ */
58
+ set touchEnabled(value: boolean);
59
+ /**
60
+ * 添加其他视图
61
+ * @param view 其他视图
62
+ * @param index 视图索引
63
+ */
64
+ addView(view: View, index?: number): void;
65
+ /**
66
+ * 移除子视图
67
+ * @param view 子视图
68
+ * @param destroy 是否销毁,默认为true
69
+ * @param closeEventParams 视图close事件的参数
70
+ */
71
+ removeView(view: View, destroy?: boolean, ...closeEventParams: any[]): void;
72
+ /**
73
+ * 设置主场景所创建的Control
74
+ * @param control
75
+ */
76
+ setControl(control: ViewControl): void;
77
+ protected control<T extends ViewControl>(): T;
78
+ /**
79
+ * 实例化后显示到舞台之后调用,缓存视图重新显示时也会调用。
80
+ * @param data
81
+ */
82
+ setData(...data: any[]): void;
83
+ /**
84
+ * 上报当前视图统计数据
85
+ * @param event open和close以外的统计名称,名称必须为全小写,无下划线之外的其他特殊字符。
86
+ * @param data 上报附带信息,可选参数,为空时会尝试从getAnalyticsDataOnViewEvent获取附带信息。
87
+ */
88
+ protected _report(event: string, data?: AnalyticsData): void;
89
+ /**
90
+ * 播放BG音乐
91
+ * @param path 路径 - `bundleName://path/to/asset` 目标音频地址。
92
+ * @param fade 是否渐进式播放,默认为true
93
+ * @param loop 是否循环 默认为true
94
+ * @param onFinishCallBack 单次播放结束后的回调箭头函数(cocos的锅)
95
+ * @returns 背景音乐的audioId
96
+ *
97
+ * @example
98
+ * _playBG("https://server.com/game/music.mp3")
99
+ * _playBG("main://path/to/music")
100
+ * _playBG("resources://path/to/music")
101
+ */
102
+ playBG(path: string, fade?: boolean, loop?: boolean, onFinishCallBack?: () => void, volume?: number): Promise<void>;
103
+ /**
104
+ * 播放音效
105
+ * @param path 路径 - `bundleName://path/to/asset` 目标音频地址。
106
+ * @param onFinishCallBack 单次播放结束后的回调箭头函数(cocos的锅)
107
+ * @returns 音效的audioId
108
+ */
109
+ playEffect(path: string, onFinishCallBack?: () => void, volume?: number): Promise<void>;
110
+ /**
111
+ * 播放激励视频的快捷方式。
112
+ * @param from 可选参数,可以附带广告行为的来源,以及其他需要统计的信息
113
+ * @param stopRecorder 可选参数,是否暂停录屏, 默认为true
114
+ */
115
+ showRewardVideo(from?: {
116
+ action?: string;
117
+ [key: string]: string | boolean | number;
118
+ }, stopRecorder?: boolean): Promise<boolean>;
119
+ /**
120
+ * 分享录屏视频
121
+ * @param analyticsName 玩法发起分享的动作来源,用于统计。
122
+ * @param title 视频标题
123
+ * @param topics 视频话题列表
124
+ */
125
+ shareRecord(analyticsName: string, title: string, topics: string[]): Promise<boolean>;
126
+ /**
127
+ * 子项重写时,必须要调用super.onDestroy()。
128
+ *
129
+ */
130
+ protected onDestroy(): void;
131
+ /**
132
+ * 父级视图
133
+ */
134
+ get parentView(): View;
135
+ /**
136
+ * 关闭视图,根据视图是否缓存选择是否销毁视图
137
+ * @param closeEventParams 视图close事件的参数
138
+ */
139
+ close(...closeEventParams: any[]): void;
140
+ /**
141
+ * 从父级移除视图
142
+ * @param destroy 是否销毁,默认为true
143
+ * @param closeEventParams 视图close事件的参数
144
+ */
145
+ removeFromParent(destroy?: boolean, ...closeEventParams: any[]): void;
146
+ /**
147
+ * 直接销毁
148
+ */
149
+ allDestroy(): void;
150
+ getAnalyticsDataOnViewEvent(event: "open" | "close" | string): AnalyticsData;
151
+ }