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,104 @@
1
+ import { Handler } from "../../../base/utils/Handler";
2
+ type JsonReviver = (key: string, value: any) => any;
3
+ type HttpSendParams = {
4
+ /**
5
+ * (default = null)发送的数据。
6
+ */
7
+ data?: any;
8
+ /**
9
+ * 用于请求的 HTTP 方法。值包括 "get"、"post"、"head"。
10
+ */
11
+ method?: string;
12
+ /**
13
+ * Web 服务器的响应类型,可设置为 "text"、"json"、"xml"、"arraybuffer"。
14
+ */
15
+ responseType?: "text" | "json" | "xml" | "arraybuffer";
16
+ /**
17
+ * HTTP 请求的头部信息。参数形如key-value数组:key是头部的名称,不应该包括空白、冒号或换行;value是头部的值,不应该包括换行。比如["Content-Type", "application/json"]。
18
+ */
19
+ headers?: any[] | null;
20
+ /**
21
+ * 超时时长
22
+ */
23
+ timeout?: number;
24
+ /**
25
+ * 请求失败后重试的次数
26
+ */
27
+ retryTimes?: number;
28
+ /**
29
+ * 请求完成后的响应Handler
30
+ */
31
+ onComplete?: Handler;
32
+ /**
33
+ * 请求过程中的响应Handler
34
+ */
35
+ onProgress?: Handler;
36
+ /**
37
+ * 请求发生错误时的响应Handler
38
+ */
39
+ onError?: Handler;
40
+ /**
41
+ * 响应数据的转化函数,responseType为json时有效。
42
+ */
43
+ jsonReviver?: JsonReviver | JsonReviver[];
44
+ };
45
+ /**
46
+ * Http节点,实现接口简化,request复用池
47
+ */
48
+ export declare class HttpNode {
49
+ private _pool;
50
+ /**
51
+ * 发送 Get 请求。
52
+ * @param url 请求的地址。大多数浏览器实施了一个同源安全策略,并且要求这个 URL 与包含脚本的文本具有相同的主机名和端口。
53
+ * @param data (default = null)发送的数据。
54
+ * @param method (default = "get")用于请求的 HTTP 方法。值包括 "get"、"post"、"head"。
55
+ * @param responseType (default = "text")Web 服务器的响应类型,可设置为 "text"、"json"、"xml"、"arraybuffer"。
56
+ * @param headers (default = null) HTTP 请求的头部信息。参数形如key-value数组:key是头部的名称,不应该包括空白、冒号或换行;value是头部的值,不应该包括换行。比如["Content-Type", "application/json"]。
57
+ * @param timeout (default = 10000) 超时时长
58
+ * @param retryTimes (default = 0) 请求失败后重试的次数
59
+ * @param onComplete (default = null) 请求完成后的响应Handler
60
+ * @param onProgress (default = null) 请求过程中的响应Handler
61
+ * @param onError (default = null) 请求发生错误时的响应Handler
62
+ * @param jsonReviver (default = null) 响应数据的转化函数,responseType为json时有效。
63
+ */
64
+ sendsync<T>(url: string, { data, method, responseType, headers, timeout, retryTimes, jsonReviver, }: HttpSendParams): Promise<T>;
65
+ /**
66
+ * 发送 Get 请求。
67
+ * @param url 请求的地址。大多数浏览器实施了一个同源安全策略,并且要求这个 URL 与包含脚本的文本具有相同的主机名和端口。
68
+ * @param data (default = null)发送的数据。
69
+ * @param method (default = "get")用于请求的 HTTP 方法。值包括 "get"、"post"、"head"。
70
+ * @param responseType (default = "text")Web 服务器的响应类型,可设置为 "text"、"json"、"xml"、"arraybuffer"。
71
+ * @param headers (default = null) HTTP 请求的头部信息。参数形如key-value数组:key是头部的名称,不应该包括空白、冒号或换行;value是头部的值,不应该包括换行。比如["Content-Type", "application/json"]。
72
+ * @param timeout (default = 10000) 超时时长
73
+ * @param retryTimes (default = 0) 请求失败后重试的次数
74
+ * @param onComplete (default = null) 请求完成后的响应Handler
75
+ * @param onProgress (default = null) 请求过程中的响应Handler
76
+ * @param onError (default = null) 请求发生错误时的响应Handler
77
+ */
78
+ send(url: string, { data, method, responseType, headers, timeout, retryTimes, onComplete, onProgress, onError, jsonReviver, }?: HttpSendParams): void;
79
+ /**
80
+ * 发送 Post 请求。
81
+ * @param url 请求的地址。大多数浏览器实施了一个同源安全策略,并且要求这个 URL 与包含脚本的文本具有相同的主机名和端口。
82
+ * @param data (default = null)发送的数据。
83
+ * @param responseType (default = "text")Web 服务器的响应类型,可设置为 "text"、"json"、"xml"、"arraybuffer"。
84
+ * @param headers (default = null) HTTP 请求的头部信息。参数形如key-value数组:key是头部的名称,不应该包括空白、冒号或换行;value是头部的值,不应该包括换行。比如["Content-Type", "application/json"]。
85
+ * @param timeout (default = 10000) 超时时长
86
+ * @param retryTimes (default = 0) 请求失败后重试的次数
87
+ * @param onComplete (default = null) 请求完成后的响应Handler
88
+ * @param onProgress (default = null) 请求过程中的响应Handler
89
+ * @param onError (default = null) 请求发生错误时的响应Handler
90
+ */
91
+ post(url: string, { data, responseType, headers, timeout, retryTimes, onComplete, onProgress, onError, jsonReviver }?: HttpSendParams): void;
92
+ /**
93
+ * 发送 Get 请求。
94
+ * @param url 请求的地址。大多数浏览器实施了一个同源安全策略,并且要求这个 URL 与包含脚本的文本具有相同的主机名和端口。
95
+ * @param data (default = null)发送的数据。
96
+ * @param responseType (default = "text")Web 服务器的响应类型,可设置为 "text"、"json"、"xml"、"arraybuffer"。
97
+ * @param headers (default = null) HTTP 请求的头部信息。参数形如key-value数组:key是头部的名称,不应该包括空白、冒号或换行;value是头部的值,不应该包括换行。比如["Content-Type", "application/json"]。
98
+ * @param onComplete (default = null) 请求完成后的响应Handler
99
+ * @param onProgress (default = null) 请求过程中的响应Handler
100
+ * @param onError (default = null) 请求发生错误时的响应Handler
101
+ */
102
+ get(url: string, { data, responseType, headers, timeout, retryTimes, onComplete, onProgress, onError, jsonReviver }?: HttpSendParams): void;
103
+ }
104
+ export {};
@@ -0,0 +1,104 @@
1
+ /**
2
+ * 请求进度改变时调度。
3
+ * @eventType Event.PROGRESS
4
+ * */
5
+ /**
6
+ * 请求结束后调度。
7
+ * @eventType Event.COMPLETE
8
+ * */
9
+ /**
10
+ * 请求出错时调度。
11
+ * @eventType Event.ERROR
12
+ * */
13
+ import { EventDispatcher } from "../../../base/event/EventDispatcher";
14
+ import { IRecoverable } from "../../../base/pool/IRecoverable";
15
+ declare enum Event {
16
+ PROGRESS = "HTTPREQUEST.EVENT.PROGRESS",
17
+ COMPLETE = "HTTPREQUEST.EVENT.COMPLETE",
18
+ ERROR = "HTTPREQUEST.EVENT.ERROR",
19
+ TIMEOUT = "HTTPREQUEST.EVENT.TIMEOUT"
20
+ }
21
+ type JsonReviver = (key: string, value: any) => any;
22
+ /**
23
+ * <p> <code>HttpRequest</code> 通过封装 HTML <code>XMLHttpRequest</code> 对象提供了对 HTTP 协议的完全的访问,包括做出 POST 和 HEAD 请求以及普通的 GET 请求的能力。 <code>HttpRequest</code> 只提供以异步的形式返回 Web 服务器的响应,并且能够以文本或者二进制的形式返回内容。</p>
24
+ * <p><b>注意:</b>建议每次请求都使用新的 <code>HttpRequest</code> 对象,因为每次调用该对象的send方法时,都会清空之前设置的数据,并重置 HTTP 请求的状态,这会导致之前还未返回响应的请求被重置,从而得不到之前请求的响应结果。</p>
25
+ */
26
+ export declare class HttpRequest extends EventDispatcher implements IRecoverable {
27
+ static Event: typeof Event;
28
+ /**@private */
29
+ protected _http: XMLHttpRequest;
30
+ /**@private */
31
+ private static _urlEncode;
32
+ /**@private */
33
+ protected _responseType: string;
34
+ /**@private */
35
+ protected _data: any;
36
+ /**@private */
37
+ protected _url: string;
38
+ protected _jsonReviver: JsonReviver | JsonReviver[];
39
+ /**
40
+ * 发送 HTTP 请求。
41
+ * @param url 请求的地址。大多数浏览器实施了一个同源安全策略,并且要求这个 URL 与包含脚本的文本具有相同的主机名和端口。
42
+ * @param data (default = null)发送的数据。
43
+ * @param method (default = "get")用于请求的 HTTP 方法。值包括 "get"、"post"、"head"。
44
+ * @param responseType (default = "text")Web 服务器的响应类型,可设置为 "text"、"json"、"xml"、"arraybuffer"。
45
+ * @param headers (default = null) HTTP 请求的头部信息。参数形如key-value数组:key是头部的名称,不应该包括空白、冒号或换行;value是头部的值,不应该包括换行。比如["Content-Type", "application/json"]。
46
+ * @param jsonRever (default = null) 请求结果JSON转化特殊处理,参考Json.xxxReviver
47
+ */
48
+ send(url: string, data?: any, method?: string, responseType?: "text" | "json" | "xml" | "arraybuffer", headers?: any[] | null, jsonRever?: JsonReviver | JsonReviver[]): void;
49
+ /**
50
+ * @private
51
+ * 请求进度的侦听处理函数。
52
+ * @param e 事件对象。
53
+ */
54
+ protected _onProgress(e: any): void;
55
+ /**
56
+ * @private
57
+ * 请求中断的侦听处理函数。
58
+ * @param e 事件对象。
59
+ */
60
+ protected _onAbort(e: any): void;
61
+ /**
62
+ * @private
63
+ * 请求出错侦的听处理函数。
64
+ * @param e 事件对象。
65
+ */
66
+ protected _onError(e: any): void;
67
+ /**
68
+ * @private
69
+ * 请求消息返回的侦听处理函数。
70
+ * @param e 事件对象。
71
+ */
72
+ protected _onLoad(e: any): void;
73
+ /**
74
+ * @private
75
+ * 请求错误的处理函数。
76
+ * @param message 错误信息。
77
+ */
78
+ protected error(message: string): void;
79
+ protected _onTimeout(e: any): void;
80
+ /**
81
+ * @private
82
+ * 请求成功完成的处理函数。
83
+ */
84
+ protected complete(): void;
85
+ protected parseJson(): boolean;
86
+ reset(): void;
87
+ destroy(): void;
88
+ /**
89
+ * @private
90
+ * 清除当前请求。
91
+ */
92
+ protected clear(): void;
93
+ /** 请求的地址。*/
94
+ get url(): string;
95
+ /** 返回的数据。*/
96
+ get data(): any;
97
+ /**
98
+ * 本对象所封装的原生 XMLHttpRequest 引用。
99
+ */
100
+ get http(): any;
101
+ get timeout(): number;
102
+ set timeout(value: number);
103
+ }
104
+ export {};
@@ -0,0 +1,20 @@
1
+ import { ConfigResolveMeta } from "../../analytics/AnalyticsAbleConst";
2
+ export interface OnlineConfig extends Record<string, any> {
3
+ }
4
+ export type ServerResponseStruct = {
5
+ timestamp?: number;
6
+ payloads?: Record<string, any>;
7
+ resolveMeta?: ConfigResolveMeta;
8
+ };
9
+ type BaseValueType = string | number | boolean;
10
+ export type ServerParamStruct = {
11
+ [key: string]: BaseValueType | BaseValueType[] | ServerParamStruct;
12
+ };
13
+ export interface IServer {
14
+ requestConfig(params: ServerParamStruct): Promise<ServerResponseStruct>;
15
+ }
16
+ export declare class NoRequestServer implements IServer {
17
+ static KEY: string;
18
+ requestConfig(params: ServerParamStruct): Promise<ServerResponseStruct>;
19
+ }
20
+ export {};
@@ -0,0 +1,9 @@
1
+ import { OnlineConfig } from "./IServer";
2
+ export declare class LevelOnlineConfig implements OnlineConfig {
3
+ static KEY: string;
4
+ info: {
5
+ id: string;
6
+ repeat: 0 | 1;
7
+ [key: string]: any;
8
+ };
9
+ }
@@ -0,0 +1,105 @@
1
+ import { ConfigResolveMeta } from "../../analytics/AnalyticsAbleConst";
2
+ import { ServerParamStruct } from "./IServer";
3
+ import { LevelOnlineConfig } from "./LevelOnlineConfig";
4
+ import { OnlineConfig } from "./IServer";
5
+ import { SystemOnlineConfig } from "./SystemOnlineConfig";
6
+ /**
7
+ * 内置 config、system、level 三个端口
8
+ */
9
+ export declare const INTERNAL_METHODS: {
10
+ readonly CONFIG: "config";
11
+ readonly SYSTEM: "system";
12
+ readonly LEVEL: "level";
13
+ };
14
+ /**
15
+ @name: Server
16
+ @desc: 服务器数据
17
+ @author: timoo
18
+ @date: 2022/11/30
19
+ */
20
+ export declare class Server {
21
+ static KEY: string;
22
+ private _configs;
23
+ private _loadedConfigKeys;
24
+ private _configContexts;
25
+ private _serverTime;
26
+ private _startedAppTime;
27
+ set time(time: number);
28
+ /**
29
+ * 服务器时间戳 毫秒
30
+ */
31
+ get time(): number;
32
+ /**
33
+ * 服务器日期对象
34
+ */
35
+ get date(): Date;
36
+ /**
37
+ * 一年中的第几天
38
+ */
39
+ get dateOfYear(): number;
40
+ private getConfigKey;
41
+ private getDefaultConfig;
42
+ /**
43
+ * 服务器配置数据
44
+ */
45
+ config<T extends OnlineConfig>(method?: string, gameFlag?: string): T;
46
+ get systemConfig(): SystemOnlineConfig;
47
+ /**
48
+ * 获取关卡配置数据
49
+ * @param gameFlag 游戏标识.默认为DEFAULT_GAME_FLAG
50
+ * @returns 关卡配置数据
51
+ */
52
+ levelConfig<T extends OnlineConfig>(gameFlag?: string): T;
53
+ getConfigContext(method?: string, gameFlag?: string): ConfigResolveMeta | undefined;
54
+ private applyAnalyticsContext;
55
+ /**
56
+ * 构建请求参数
57
+ * @param method 请求方法
58
+ * @param gameMetrics 关卡维度指标
59
+ * @param data 额外参数
60
+ * @param isDebug 是否为调试模式
61
+ * @returns 请求参数
62
+ */
63
+ private getRequestParams;
64
+ private joinUrl;
65
+ getSystemUrl(path?: string): string;
66
+ private getResolveUrl;
67
+ private normalizeResponse;
68
+ private updateServerTime;
69
+ /**
70
+ * 获取/请求系统配置
71
+ * @param refresh 是否强制刷新,默认为false
72
+ * @param isDebug 是否为调试模式,可选
73
+ * @returns
74
+ */
75
+ getSystemConfig(refresh?: boolean, isDebug?: boolean): Promise<SystemOnlineConfig>;
76
+ /**
77
+ * 获取/请求配置内容
78
+ * @param method 请求端口, 默认为config
79
+ * @param gameFlag 玩法标识, 默认为deafult
80
+ * @param data 额外参数, 可选为空
81
+ * @param refresh 是否强制刷新, 默认为false
82
+ * @param isDebug 是否为调试模式,可选
83
+ * @returns
84
+ */
85
+ getConfig<T extends OnlineConfig>(method?: string, gameFlag?: string, data?: ServerParamStruct, refresh?: boolean, isDebug?: boolean): Promise<T>;
86
+ /**
87
+ * 获取/请求关卡配置
88
+ * @param gameFlag 玩法标识
89
+ * @param levelid 关卡唯一ID
90
+ * @param data 额外参数, 可选为空
91
+ * @param refresh 是否强制刷新, 默认为false
92
+ * @param isDebug 是否为调试模式,可选
93
+ * @returns 关卡配置
94
+ */
95
+ getLevelConfig<T extends LevelOnlineConfig>(gameFlag: string, levelid: string, data?: ServerParamStruct, refresh?: boolean, isDebug?: boolean): Promise<T>;
96
+ private _updateConfig;
97
+ private mergeConfigField;
98
+ private sentRequest;
99
+ private _impl;
100
+ private get impl();
101
+ }
102
+ /**
103
+ * 基础的服务器接口
104
+ */
105
+ export declare const server: Server;
@@ -0,0 +1,34 @@
1
+ import type { AliAnalyticsConfig } from "../../analytics/ALiAnalyticsSender";
2
+ import type { KeytopsAnalyticsConfig } from "../../analytics/KeytopsAnalyticsSender";
3
+ import { ADConfig } from "../../publisher/IADAble";
4
+ import { OnlineConfig } from "./IServer";
5
+ export type RelayAnalyticsConfig = Partial<AliAnalyticsConfig> & KeytopsAnalyticsConfig;
6
+ /**
7
+ * system 端口默认配置,承载 SDK 基础运行时能力。
8
+ */
9
+ export declare class SystemOnlineConfig implements OnlineConfig {
10
+ static KEY: string;
11
+ private _timestampCall;
12
+ url: {
13
+ domain: string;
14
+ configAPI: string;
15
+ loginAPI: string;
16
+ saveStoreAPI: string;
17
+ getStoreAPI: string;
18
+ };
19
+ analytics: RelayAnalyticsConfig;
20
+ assignment: KeytopsAnalyticsConfig;
21
+ ad: ADConfig;
22
+ storage: {
23
+ cacheEnable: boolean;
24
+ cacheCD: number;
25
+ };
26
+ getAnalyticsConfig(): RelayAnalyticsConfig;
27
+ getAssignmentConfig(): KeytopsAnalyticsConfig;
28
+ setTimestampCall(timestampCall: () => number): void;
29
+ getStorageConfig(): {
30
+ cacheEnable: boolean;
31
+ cacheCD: number;
32
+ };
33
+ toString(): string;
34
+ }
@@ -0,0 +1,31 @@
1
+ import { ByteView } from "../byte/ByteView";
2
+ import { IProtocolHelper, ProtocolID, HeadDecoder, HeadEncoder, Protocol } from "../NetInterface";
3
+ /**
4
+ * socket response 处理装饰器
5
+ * @param id 协议号
6
+ * @returns
7
+ */
8
+ export declare function cmd(id: number): (target: any, propertyKey: string) => void;
9
+ /**
10
+ * 基础协议处理器,实现返回数据后的decode操作。
11
+ * 可以通过继承BaseProtocolHelper,自定义decode逻辑、心跳协议等
12
+ */
13
+ export declare class BaseProtocolHelper implements IProtocolHelper {
14
+ protected _heartbeatID: ProtocolID;
15
+ protected _parsers: Map<number, Function>;
16
+ protected _headDecoder: HeadDecoder;
17
+ protected _headEncoder: HeadEncoder;
18
+ constructor();
19
+ /**
20
+ * 初始化协议处理器
21
+ * @param heartbeat 心跳协议ID 取值范围 0-65535,注意避免与其他协议冲突
22
+ * @param headDecoder 协议头解析函数 类型:HeadDecoder,默认length(Uint16)、ProtocolID(Uint16)
23
+ * @param heartbeatID 心跳协议号,默认0
24
+ */
25
+ init(headDecoder?: HeadDecoder, headEncoder?: HeadEncoder, heartbeatID?: number): void;
26
+ decode(buffer: ByteView): Protocol;
27
+ heartbeat(): Protocol;
28
+ protected decodeHead(buffer: ByteView): Protocol;
29
+ protected flush(id: ProtocolID, params?: IArguments): boolean;
30
+ protected get output(): ByteView;
31
+ }
@@ -0,0 +1,145 @@
1
+ /**
2
+ * 连接建立成功后调度。
3
+ * @eventType Event.OPEN
4
+ * */
5
+ /**
6
+ * 接收到数据后调度。
7
+ * @eventType Event.MESSAGE
8
+ * */
9
+ /**
10
+ * 连接被关闭后调度。
11
+ * @eventType Event.CLOSE
12
+ * */
13
+ /**
14
+ * 出现异常后调度。
15
+ * @eventType Event.ERROR
16
+ * */
17
+ import { EventDispatcher } from "../../../base/event/EventDispatcher";
18
+ import { ByteView } from "../byte/ByteView";
19
+ import { NetData } from "../NetInterface";
20
+ /**
21
+ * <p> <code>Socket</code> 封装了 HTML5 WebSocket ,允许服务器端与客户端进行全双工(full-duplex)的实时通信,并且允许跨域通信。在建立连接后,服务器和 Browser/Client Agent 都能主动的向对方发送或接收文本和二进制数据。</p>
22
+ * <p>要使用 <code>Socket</code> 类的方法,请先使用构造函数 <code>new Socket</code> 创建一个 <code>Socket</code> 对象。 <code>Socket</code> 以异步方式传输和接收数据。</p>
23
+ */
24
+ export declare class Socket extends EventDispatcher {
25
+ /**
26
+ * <p>主机字节序,是 CPU 存放数据的两种不同顺序,包括小端字节序和大端字节序。</p>
27
+ * <p> LITTLE_ENDIAN :小端字节序,地址低位存储值的低位,地址高位存储值的高位。</p>
28
+ * <p> BIG_ENDIAN :大端字节序,地址低位存储值的高位,地址高位存储值的低位。有时也称之为网络字节序。</p>
29
+ */
30
+ static LITTLE_ENDIAN: string;
31
+ /**
32
+ * <p>主机字节序,是 CPU 存放数据的两种不同顺序,包括小端字节序和大端字节序。</p>
33
+ * <p> BIG_ENDIAN :大端字节序,地址低位存储值的高位,地址高位存储值的低位。有时也称之为网络字节序。</p>
34
+ * <p> LITTLE_ENDIAN :小端字节序,地址低位存储值的低位,地址高位存储值的高位。</p>
35
+ */
36
+ static BIG_ENDIAN: string;
37
+ /**@internal */
38
+ _endian: string;
39
+ /**@private */
40
+ protected _socket: WebSocket;
41
+ /**@private */
42
+ private _connected;
43
+ /**@private */
44
+ private _addInputPosition;
45
+ /**@private */
46
+ private _input;
47
+ /**@private */
48
+ private _output;
49
+ /**
50
+ * 不再缓存服务端发来的数据,如果传输的数据为字符串格式,建议设置为true,减少二进制转换消耗。
51
+ */
52
+ disableInput: boolean;
53
+ /**
54
+ * 用来发送和接收数据的 <code>Byte</code> 类。
55
+ */
56
+ private _byteClass;
57
+ /**
58
+ * <p>子协议名称。子协议名称字符串,或由多个子协议名称字符串构成的数组。必须在调用 connect 或者 connectByUrl 之前进行赋值,否则无效。</p>
59
+ * <p>指定后,只有当服务器选择了其中的某个子协议,连接才能建立成功,否则建立失败,派发 Event.ERROR 事件。</p>
60
+ * @see https://html.spec.whatwg.org/multipage/comms.html#dom-websocket
61
+ */
62
+ protocols: any;
63
+ /**
64
+ * 缓存的服务端发来的数据。
65
+ */
66
+ get input(): ByteView;
67
+ /**
68
+ * 表示需要发送至服务端的缓冲区中的数据。
69
+ */
70
+ get output(): ByteView;
71
+ /**
72
+ * 表示此 Socket 对象目前是否已连接。
73
+ */
74
+ get connected(): boolean;
75
+ /**
76
+ * <p>主机字节序,是 CPU 存放数据的两种不同顺序,包括小端字节序和大端字节序。</p>
77
+ * <p> LITTLE_ENDIAN :小端字节序,地址低位存储值的低位,地址高位存储值的高位。</p>
78
+ * <p> BIG_ENDIAN :大端字节序,地址低位存储值的高位,地址高位存储值的低位。</p>
79
+ */
80
+ get endian(): string;
81
+ set endian(value: string);
82
+ /**
83
+ * <p>创建新的 Socket 对象。默认字节序为 Socket.BIG_ENDIAN 。若未指定参数,将创建一个最初处于断开状态的套接字。若指定了有效参数,则尝试连接到指定的主机和端口。</p>
84
+ * @param host 服务器地址。
85
+ * @param port 服务器端口。
86
+ * @param byteClass 用于接收和发送数据的 ByteView 类。如果为 null ,则使用 ByteView 类,也可传入 ByteView 类的子类。
87
+ * @param protocols 子协议名称。子协议名称字符串,或由多个子协议名称字符串构成的数组
88
+ * @see laya.utils.Byte
89
+ */
90
+ constructor(host?: string | null, port?: number, byteClass?: new () => any, protocols?: any[] | null);
91
+ /**
92
+ * <p>连接到指定的主机和端口。</p>
93
+ * <p>连接成功派发 Event.OPEN 事件;连接失败派发 Event.ERROR 事件;连接被关闭派发 Event.CLOSE 事件;接收到数据派发 Event.MESSAGE 事件; 除了 Event.MESSAGE 事件参数为数据内容,其他事件参数都是原生的 HTML DOM Event 对象。</p>
94
+ * @param host 服务器地址。
95
+ * @param port 服务器端口。
96
+ */
97
+ connect(host: string, port: number, binaryType?: BinaryType): void;
98
+ /**
99
+ * <p>连接到指定的服务端 WebSocket URL。 URL 类似 ws://yourdomain:port。</p>
100
+ * <p>连接成功派发 Event.OPEN 事件;连接失败派发 Event.ERROR 事件;连接被关闭派发 Event.CLOSE 事件;接收到数据派发 Event.MESSAGE 事件; 除了 Event.MESSAGE 事件参数为数据内容,其他事件参数都是原生的 HTML DOM Event 对象。</p>
101
+ * @param url 要连接的服务端 WebSocket URL。 URL 类似 ws://yourdomain:port。
102
+ */
103
+ connectByUrl(url: string, binaryType?: BinaryType): void;
104
+ /**
105
+ * 清理Socket:关闭Socket链接,关闭事件监听,重置Socket
106
+ */
107
+ cleanSocket(): void;
108
+ /**
109
+ * 关闭连接。
110
+ */
111
+ close(code?: number, reason?: string): boolean;
112
+ /**
113
+ * @private
114
+ * 连接建立成功 。
115
+ */
116
+ protected _onOpen(e: any): void;
117
+ /**
118
+ * @private
119
+ * 接收到数据处理方法。
120
+ * @param msg 数据。
121
+ */
122
+ protected _onMessage(msg: any): void;
123
+ /**
124
+ * @private
125
+ * 连接被关闭处理方法。
126
+ */
127
+ protected _onClose(e: any): void;
128
+ /**
129
+ * @private
130
+ * 出现异常处理方法。
131
+ */
132
+ protected _onError(e: any): void;
133
+ /**
134
+ * 发送数据到服务器。
135
+ * @param data 需要发送的数据,可以是String或者ArrayBuffer。
136
+ */
137
+ send(data: NetData): boolean;
138
+ /**
139
+ * 发送缓冲区中的数据到服务器。
140
+ */
141
+ flush(): void;
142
+ get state(): number;
143
+ get url(): string;
144
+ get binaryType(): BinaryType;
145
+ }
@@ -0,0 +1,63 @@
1
+ import { ByteView } from "../byte/ByteView";
2
+ import { IProtocolHelper, INetworkTips, ProtocolID, Protocol } from "../NetInterface";
3
+ import { Socket } from "./Socket";
4
+ export declare enum SocketLogType {
5
+ Connected = "[C==S]",
6
+ C2S = "[C=>S]",
7
+ S2C = "[S=>C]",
8
+ S2xC = "[S=xC]",
9
+ CxS = "[CxS]"
10
+ }
11
+ /**
12
+ * Socket节点,实现断线重连、心跳等机制
13
+ */
14
+ export declare class SocketNode {
15
+ protected _socket: Socket;
16
+ protected _protocolHelper: IProtocolHelper;
17
+ protected _networkTips: INetworkTips;
18
+ protected _reconnectTimes: number;
19
+ protected _loger: Function;
20
+ private _reconnectCD;
21
+ private _reconnectCount;
22
+ private _reconnectHandler;
23
+ private _keepAliveHandler;
24
+ protected _heartbeatID: ProtocolID;
25
+ private _heartbeatCD;
26
+ init(socket: Socket, protocolHelper: IProtocolHelper, networkTips: INetworkTips): void;
27
+ private _addEvent;
28
+ private _removeEvent;
29
+ /**
30
+ * 连接服务器
31
+ * @param url 服务器地址 wss://localhost:80
32
+ * @param binaryType BinaryType "arraybuffer" | "blob"
33
+ * @param reconnectTimes 重连次数 -1: 一直尝试重连 0: 不重连 >0: 重连尝试次数
34
+ * @returns
35
+ */
36
+ connect(url: string, binaryType?: BinaryType, reconnectTimes?: number): void;
37
+ /**
38
+ * 发送数据
39
+ * @returns
40
+ */
41
+ flush(): boolean;
42
+ log(type: SocketLogType, data: Protocol | string): void;
43
+ /**
44
+ * 关闭连接
45
+ * @param code
46
+ * @param reason
47
+ */
48
+ close(code?: number, reason?: string): void;
49
+ protected _onConnected(event: any): void;
50
+ protected _onMessage(data: any): void;
51
+ protected _onError(event: any): void;
52
+ protected _onClosed(event: any): void;
53
+ protected _retry(): void;
54
+ protected _heartbeat(): void;
55
+ protected _cleanupTimeout(): void;
56
+ set logable(value: boolean);
57
+ get reconnectCD(): number;
58
+ set reconnectCD(value: number);
59
+ get heartbeatCD(): number;
60
+ set heartbeatCD(value: number);
61
+ get output(): ByteView;
62
+ get input(): ByteView;
63
+ }
@@ -0,0 +1,46 @@
1
+ import { AdFrom } from "../analytics/ad/ADBehaviorReporter";
2
+ export type ADConfig = {
3
+ bannerUnitIds: string[];
4
+ interstitialUnitIds: string[];
5
+ rewardVideoUnitIds: string[];
6
+ };
7
+ /**
8
+ * 广告能力
9
+ */
10
+ export declare class IADAble {
11
+ protected _type: string;
12
+ protected _config: ADConfig;
13
+ /**
14
+ * 初始化
15
+ * @param type 功能类型,如:wx;tt等
16
+ */
17
+ init(type: string, config: ADConfig): IADAble;
18
+ /**
19
+ * 加载Banner
20
+ */
21
+ loadBanner(from: AdFrom, ...args: any[]): Promise<void>;
22
+ /**
23
+ * 显示banner
24
+ */
25
+ showBanner(from: AdFrom, ...args: any[]): Promise<void>;
26
+ /**
27
+ * 隐藏banner
28
+ */
29
+ hideBanner(): Promise<void>;
30
+ /**
31
+ * 显示激励视频
32
+ * @param caller 可选参数,回调this
33
+ * @param from 可选参数,来源标识,会上报到统计分析
34
+ */
35
+ showRewardVideo(from: AdFrom, breakConfirm?: boolean, ...args: any[]): Promise<boolean>;
36
+ /**
37
+ * 加载插屏广告
38
+ * @param unitId
39
+ */
40
+ loadInterstitial(from: AdFrom, ...args: any[]): Promise<void>;
41
+ /**
42
+ * 显示插屏广告
43
+ * @param unitId
44
+ */
45
+ showInterstitial(from: AdFrom, ...args: any[]): Promise<void>;
46
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 平台额外功能统一接口
3
+ */
4
+ export interface IAbleHelper {
5
+ readonly can: boolean;
6
+ }