@cc-component/cc-core 1.2.8

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 (194) hide show
  1. package/.cc-ex-component.md +12 -0
  2. package/assets/core/config/CommonEnum.ts +94 -0
  3. package/assets/core/config/CommonEnum.ts.meta +9 -0
  4. package/assets/core/config/IConfig.ts +89 -0
  5. package/assets/core/config/IConfig.ts.meta +9 -0
  6. package/assets/core/config/LayerType.ts +44 -0
  7. package/assets/core/config/LayerType.ts.meta +9 -0
  8. package/assets/core/config/LayerUI.ts +113 -0
  9. package/assets/core/config/LayerUI.ts.meta +9 -0
  10. package/assets/core/config.meta +9 -0
  11. package/assets/core/editor/LanguageManager.ts +323 -0
  12. package/assets/core/editor/LanguageManager.ts.meta +9 -0
  13. package/assets/core/editor/SpineRunner.ts +39 -0
  14. package/assets/core/editor/SpineRunner.ts.meta +9 -0
  15. package/assets/core/editor/i18nEditorComponent.ts +137 -0
  16. package/assets/core/editor/i18nEditorComponent.ts.meta +9 -0
  17. package/assets/core/editor.meta +9 -0
  18. package/assets/core/home/AudioUtil.ts +164 -0
  19. package/assets/core/home/AudioUtil.ts.meta +9 -0
  20. package/assets/core/home/BaseBoxView.ts +60 -0
  21. package/assets/core/home/BaseBoxView.ts.meta +9 -0
  22. package/assets/core/home/BaseLaunchComponent.ts +9 -0
  23. package/assets/core/home/BaseLaunchComponent.ts.meta +9 -0
  24. package/assets/core/home/BaseLoading.ts +136 -0
  25. package/assets/core/home/BaseLoading.ts.meta +9 -0
  26. package/assets/core/home/BaseSkeleton.ts +39 -0
  27. package/assets/core/home/BaseSkeleton.ts.meta +9 -0
  28. package/assets/core/home/CameraAngel.ts +326 -0
  29. package/assets/core/home/CameraAngel.ts.meta +9 -0
  30. package/assets/core/home/DouYinShow.ts +27 -0
  31. package/assets/core/home/DouYinShow.ts.meta +9 -0
  32. package/assets/core/home/EventManager.ts +39 -0
  33. package/assets/core/home/EventManager.ts.meta +9 -0
  34. package/assets/core/home/ExView.ts +9 -0
  35. package/assets/core/home/ExView.ts.meta +9 -0
  36. package/assets/core/home/FollowCamera.ts +205 -0
  37. package/assets/core/home/FollowCamera.ts.meta +9 -0
  38. package/assets/core/home/InViewCenter.ts +52 -0
  39. package/assets/core/home/InViewCenter.ts.meta +9 -0
  40. package/assets/core/home/JsonUtil.ts +102 -0
  41. package/assets/core/home/JsonUtil.ts.meta +9 -0
  42. package/assets/core/home/LoadingWindow.ts +44 -0
  43. package/assets/core/home/LoadingWindow.ts.meta +9 -0
  44. package/assets/core/home/ParabolaTween.ts +110 -0
  45. package/assets/core/home/ParabolaTween.ts.meta +9 -0
  46. package/assets/core/home/ProgessView.ts +96 -0
  47. package/assets/core/home/ProgessView.ts.meta +9 -0
  48. package/assets/core/home/Quaternion.ts +237 -0
  49. package/assets/core/home/Quaternion.ts.meta +9 -0
  50. package/assets/core/home/ResUtil.ts +132 -0
  51. package/assets/core/home/ResUtil.ts.meta +9 -0
  52. package/assets/core/home/ResourceManager.ts +430 -0
  53. package/assets/core/home/ResourceManager.ts.meta +9 -0
  54. package/assets/core/home/StateMachine.ts +93 -0
  55. package/assets/core/home/StateMachine.ts.meta +9 -0
  56. package/assets/core/home/StorageManager.ts +161 -0
  57. package/assets/core/home/StorageManager.ts.meta +9 -0
  58. package/assets/core/home/ThirdFreeLookCamera.ts +201 -0
  59. package/assets/core/home/ThirdFreeLookCamera.ts.meta +9 -0
  60. package/assets/core/home/TimeManager.ts +486 -0
  61. package/assets/core/home/TimeManager.ts.meta +9 -0
  62. package/assets/core/home/Tools.ts +103 -0
  63. package/assets/core/home/Tools.ts.meta +9 -0
  64. package/assets/core/home/prefabs.meta +12 -0
  65. package/assets/core/home/util/EncryptUtil.ts +60 -0
  66. package/assets/core/home/util/EncryptUtil.ts.meta +11 -0
  67. package/assets/core/home/util/MathUtil.ts +22 -0
  68. package/assets/core/home/util/MathUtil.ts.meta +9 -0
  69. package/assets/core/home/util/Md5.ts +202 -0
  70. package/assets/core/home/util/Md5.ts.meta +11 -0
  71. package/assets/core/home/util/RandomUtil.ts +61 -0
  72. package/assets/core/home/util/RandomUtil.ts.meta +9 -0
  73. package/assets/core/home/util/ResUtil.ts +129 -0
  74. package/assets/core/home/util/ResUtil.ts.meta +9 -0
  75. package/assets/core/home/util/crypto-js.d.ts +30 -0
  76. package/assets/core/home/util/crypto-js.d.ts.meta +11 -0
  77. package/assets/core/home/util/crypto-js.js +6030 -0
  78. package/assets/core/home/util/crypto-js.js.meta +9 -0
  79. package/assets/core/home/util.meta +12 -0
  80. package/assets/core/home.meta +12 -0
  81. package/assets/core/interface/ISceneParam.ts +11 -0
  82. package/assets/core/interface/ISceneParam.ts.meta +9 -0
  83. package/assets/core/interface/Interface.ts +160 -0
  84. package/assets/core/interface/Interface.ts.meta +1 -0
  85. package/assets/core/interface/MainModule.ts +1019 -0
  86. package/assets/core/interface/MainModule.ts.meta +9 -0
  87. package/assets/core/interface.meta +9 -0
  88. package/assets/core/lib/Logger.ts +286 -0
  89. package/assets/core/lib/Logger.ts.meta +9 -0
  90. package/assets/core/lib/language/.language.md +1 -0
  91. package/assets/core/lib/language/Language.ts +133 -0
  92. package/assets/core/lib/language/Language.ts.meta +13 -0
  93. package/assets/core/lib/language/LanguageData.ts +114 -0
  94. package/assets/core/lib/language/LanguageData.ts.meta +9 -0
  95. package/assets/core/lib/language/LanguageLabel.ts +172 -0
  96. package/assets/core/lib/language/LanguageLabel.ts.meta +13 -0
  97. package/assets/core/lib/language/LanguagePack.ts +126 -0
  98. package/assets/core/lib/language/LanguagePack.ts.meta +13 -0
  99. package/assets/core/lib/language/LanguagePointLabel.ts.meta +16 -0
  100. package/assets/core/lib/language/LanguageSpine.ts +60 -0
  101. package/assets/core/lib/language/LanguageSpine.ts.meta +9 -0
  102. package/assets/core/lib/language/LanguageSprite.ts +138 -0
  103. package/assets/core/lib/language/LanguageSprite.ts.meta +13 -0
  104. package/assets/core/lib/language.meta +9 -0
  105. package/assets/core/lib/logger/ELoggerLevel.ts +16 -0
  106. package/assets/core/lib/logger/ELoggerLevel.ts.meta +9 -0
  107. package/assets/core/lib/logger/MLogger.ts +118 -0
  108. package/assets/core/lib/logger/MLogger.ts.meta +9 -0
  109. package/assets/core/lib/logger.meta +9 -0
  110. package/assets/core/lib/net/libs/proto/output/protobuf.d.ts +2729 -0
  111. package/assets/core/lib/net/libs/proto/output/protobuf.d.ts.meta +9 -0
  112. package/assets/core/lib/net/libs/proto/output/protobuf.min.js +8 -0
  113. package/assets/core/lib/net/libs/proto/output/protobuf.min.js.meta +9 -0
  114. package/assets/core/lib/net/libs/proto/output/protobuf_custom.d.ts +102 -0
  115. package/assets/core/lib/net/libs/proto/output/protobuf_custom.d.ts.meta +9 -0
  116. package/assets/core/lib/net/libs/proto/output/protobuf_custom.js +222 -0
  117. package/assets/core/lib/net/libs/proto/output/protobuf_custom.js.meta +9 -0
  118. package/assets/core/lib/net/libs/proto/output.meta +9 -0
  119. package/assets/core/lib/net/libs/proto/source/Cmd.proto +6 -0
  120. package/assets/core/lib/net/libs/proto/source/Cmd.proto.meta +11 -0
  121. package/assets/core/lib/net/libs/proto/source/UserLogin.proto +12 -0
  122. package/assets/core/lib/net/libs/proto/source/UserLogin.proto.meta +11 -0
  123. package/assets/core/lib/net/libs/proto/source/base.proto +24 -0
  124. package/assets/core/lib/net/libs/proto/source/base.proto.meta +11 -0
  125. package/assets/core/lib/net/libs/proto/source/command.proto +31 -0
  126. package/assets/core/lib/net/libs/proto/source/command.proto.meta +11 -0
  127. package/assets/core/lib/net/libs/proto/source/domain/boos_battle_info.proto +13 -0
  128. package/assets/core/lib/net/libs/proto/source/domain/boos_battle_info.proto.meta +11 -0
  129. package/assets/core/lib/net/libs/proto/source/domain/player_auth.proto +26 -0
  130. package/assets/core/lib/net/libs/proto/source/domain/player_auth.proto.meta +11 -0
  131. package/assets/core/lib/net/libs/proto/source/domain.meta +9 -0
  132. package/assets/core/lib/net/libs/proto/source/message/game_push.proto +23 -0
  133. package/assets/core/lib/net/libs/proto/source/message/game_push.proto.meta +11 -0
  134. package/assets/core/lib/net/libs/proto/source/message/game_request.proto +24 -0
  135. package/assets/core/lib/net/libs/proto/source/message/game_request.proto.meta +11 -0
  136. package/assets/core/lib/net/libs/proto/source/message/game_response.proto +24 -0
  137. package/assets/core/lib/net/libs/proto/source/message/game_response.proto.meta +11 -0
  138. package/assets/core/lib/net/libs/proto/source/message.meta +9 -0
  139. package/assets/core/lib/net/libs/proto/source/push/boss_battle_events.proto +43 -0
  140. package/assets/core/lib/net/libs/proto/source/push/boss_battle_events.proto.meta +11 -0
  141. package/assets/core/lib/net/libs/proto/source/push.meta +9 -0
  142. package/assets/core/lib/net/libs/proto/source.meta +12 -0
  143. package/assets/core/lib/net/libs/proto.meta +9 -0
  144. package/assets/core/lib/net/libs.meta +9 -0
  145. package/assets/core/lib/net/net/HttpManager.ts +307 -0
  146. package/assets/core/lib/net/net/HttpManager.ts.meta +9 -0
  147. package/assets/core/lib/net/net/NetInterface.ts +114 -0
  148. package/assets/core/lib/net/net/NetInterface.ts.meta +9 -0
  149. package/assets/core/lib/net/net/NetManager.ts +77 -0
  150. package/assets/core/lib/net/net/NetManager.ts.meta +9 -0
  151. package/assets/core/lib/net/net/NetNode.ts +471 -0
  152. package/assets/core/lib/net/net/NetNode.ts.meta +9 -0
  153. package/assets/core/lib/net/net/WebSock.ts +81 -0
  154. package/assets/core/lib/net/net/WebSock.ts.meta +9 -0
  155. package/assets/core/lib/net/net/custom/NetChannelManager.ts +41 -0
  156. package/assets/core/lib/net/net/custom/NetChannelManager.ts.meta +9 -0
  157. package/assets/core/lib/net/net/custom/NetConfig.ts +11 -0
  158. package/assets/core/lib/net/net/custom/NetConfig.ts.meta +9 -0
  159. package/assets/core/lib/net/net/custom/NetErrorCode.ts +4 -0
  160. package/assets/core/lib/net/net/custom/NetErrorCode.ts.meta +9 -0
  161. package/assets/core/lib/net/net/custom/NetGameTips.ts +53 -0
  162. package/assets/core/lib/net/net/custom/NetGameTips.ts.meta +9 -0
  163. package/assets/core/lib/net/net/custom/NetNodeGame.ts +105 -0
  164. package/assets/core/lib/net/net/custom/NetNodeGame.ts.meta +9 -0
  165. package/assets/core/lib/net/net/custom.meta +9 -0
  166. package/assets/core/lib/net/net/protocol/NetProtocolJson.ts +39 -0
  167. package/assets/core/lib/net/net/protocol/NetProtocolJson.ts.meta +9 -0
  168. package/assets/core/lib/net/net/protocol/NetProtocolProtobuf.ts +85 -0
  169. package/assets/core/lib/net/net/protocol/NetProtocolProtobuf.ts.meta +9 -0
  170. package/assets/core/lib/net/net/protocol.meta +9 -0
  171. package/assets/core/lib/net/net.meta +9 -0
  172. package/assets/core/lib/net/prompt.meta +9 -0
  173. package/assets/core/lib/net.meta +9 -0
  174. package/assets/core/lib/old/VM2.ts +619 -0
  175. package/assets/core/lib/old/VM2.ts.meta +9 -0
  176. package/assets/core/lib/old/ViewModel.ts +905 -0
  177. package/assets/core/lib/old/ViewModel.ts.meta +9 -0
  178. package/assets/core/lib/old/ViewSearch.ts +125 -0
  179. package/assets/core/lib/old/ViewSearch.ts.meta +9 -0
  180. package/assets/core/lib/old.meta +9 -0
  181. package/assets/core/lib/tabbar/TabBarComponent.ts +113 -0
  182. package/assets/core/lib/tabbar/TabBarComponent.ts.meta +9 -0
  183. package/assets/core/lib/tabbar/TabBarController.ts +86 -0
  184. package/assets/core/lib/tabbar/TabBarController.ts.meta +9 -0
  185. package/assets/core/lib/tabbar/TabBarItem.ts +52 -0
  186. package/assets/core/lib/tabbar/TabBarItem.ts.meta +9 -0
  187. package/assets/core/lib/tabbar.meta +9 -0
  188. package/assets/core/lib.meta +12 -0
  189. package/assets/core.meta +9 -0
  190. package/assets.meta +9 -0
  191. package/index.ts +3 -0
  192. package/index.ts.meta +9 -0
  193. package/package.json +19 -0
  194. package/package.json.meta +11 -0
@@ -0,0 +1,22 @@
1
+
2
+ /**
3
+ * 精确计算表达式结果(适用于浮点数),默认保留 10 位小数
4
+ */
5
+ export function preciseCalc(fn: () => number, precision: number = 10): number {
6
+ const factor = Math.pow(10, precision);
7
+ const rawResult = fn();
8
+ return Math.round(rawResult * factor) / factor;
9
+ }
10
+
11
+ /**
12
+ * 常用浮点运算封装,简洁调用
13
+ */
14
+ export const calc = {
15
+ add: (a: number, b: number, precision = 10) => preciseCalc(() => a + b, precision),
16
+ sub: (a: number, b: number, precision = 10) => preciseCalc(() => a - b, precision),
17
+ mul: (a: number, b: number, precision = 10) => preciseCalc(() => a * b, precision),
18
+ div: (a: number, b: number, precision = 10) => {
19
+ if (b === 0) throw new Error('Division by zero');
20
+ return preciseCalc(() => a / b, precision);
21
+ }
22
+ };
@@ -0,0 +1,9 @@
1
+ {
2
+ "ver": "4.0.24",
3
+ "importer": "typescript",
4
+ "imported": true,
5
+ "uuid": "fe43fb3e-c075-4b7d-81b9-759f9102019d",
6
+ "files": [],
7
+ "subMetas": {},
8
+ "userData": {}
9
+ }
@@ -0,0 +1,202 @@
1
+ export function md5(md5str: string) {
2
+ var createMD5String = function (string: string) {
3
+ var x = Array()
4
+ var k, AA, BB, CC, DD, a, b, c, d
5
+ var S11 = 7,
6
+ S12 = 12,
7
+ S13 = 17,
8
+ S14 = 22
9
+ var S21 = 5,
10
+ S22 = 9,
11
+ S23 = 14,
12
+ S24 = 20
13
+ var S31 = 4,
14
+ S32 = 11,
15
+ S33 = 16,
16
+ S34 = 23
17
+ var S41 = 6,
18
+ S42 = 10,
19
+ S43 = 15,
20
+ S44 = 21
21
+ string = uTF8Encode(string)
22
+ x = convertToWordArray(string)
23
+ a = 0x67452301
24
+ b = 0xEFCDAB89
25
+ c = 0x98BADCFE
26
+ d = 0x10325476
27
+ for (k = 0; k < x.length; k += 16) {
28
+ AA = a
29
+ BB = b
30
+ CC = c
31
+ DD = d
32
+ a = FF(a, b, c, d, x[k + 0], S11, 0xD76AA478)
33
+ d = FF(d, a, b, c, x[k + 1], S12, 0xE8C7B756)
34
+ c = FF(c, d, a, b, x[k + 2], S13, 0x242070DB)
35
+ b = FF(b, c, d, a, x[k + 3], S14, 0xC1BDCEEE)
36
+ a = FF(a, b, c, d, x[k + 4], S11, 0xF57C0FAF)
37
+ d = FF(d, a, b, c, x[k + 5], S12, 0x4787C62A)
38
+ c = FF(c, d, a, b, x[k + 6], S13, 0xA8304613)
39
+ b = FF(b, c, d, a, x[k + 7], S14, 0xFD469501)
40
+ a = FF(a, b, c, d, x[k + 8], S11, 0x698098D8)
41
+ d = FF(d, a, b, c, x[k + 9], S12, 0x8B44F7AF)
42
+ c = FF(c, d, a, b, x[k + 10], S13, 0xFFFF5BB1)
43
+ b = FF(b, c, d, a, x[k + 11], S14, 0x895CD7BE)
44
+ a = FF(a, b, c, d, x[k + 12], S11, 0x6B901122)
45
+ d = FF(d, a, b, c, x[k + 13], S12, 0xFD987193)
46
+ c = FF(c, d, a, b, x[k + 14], S13, 0xA679438E)
47
+ b = FF(b, c, d, a, x[k + 15], S14, 0x49B40821)
48
+ a = GG(a, b, c, d, x[k + 1], S21, 0xF61E2562)
49
+ d = GG(d, a, b, c, x[k + 6], S22, 0xC040B340)
50
+ c = GG(c, d, a, b, x[k + 11], S23, 0x265E5A51)
51
+ b = GG(b, c, d, a, x[k + 0], S24, 0xE9B6C7AA)
52
+ a = GG(a, b, c, d, x[k + 5], S21, 0xD62F105D)
53
+ d = GG(d, a, b, c, x[k + 10], S22, 0x2441453)
54
+ c = GG(c, d, a, b, x[k + 15], S23, 0xD8A1E681)
55
+ b = GG(b, c, d, a, x[k + 4], S24, 0xE7D3FBC8)
56
+ a = GG(a, b, c, d, x[k + 9], S21, 0x21E1CDE6)
57
+ d = GG(d, a, b, c, x[k + 14], S22, 0xC33707D6)
58
+ c = GG(c, d, a, b, x[k + 3], S23, 0xF4D50D87)
59
+ b = GG(b, c, d, a, x[k + 8], S24, 0x455A14ED)
60
+ a = GG(a, b, c, d, x[k + 13], S21, 0xA9E3E905)
61
+ d = GG(d, a, b, c, x[k + 2], S22, 0xFCEFA3F8)
62
+ c = GG(c, d, a, b, x[k + 7], S23, 0x676F02D9)
63
+ b = GG(b, c, d, a, x[k + 12], S24, 0x8D2A4C8A)
64
+ a = HH(a, b, c, d, x[k + 5], S31, 0xFFFA3942)
65
+ d = HH(d, a, b, c, x[k + 8], S32, 0x8771F681)
66
+ c = HH(c, d, a, b, x[k + 11], S33, 0x6D9D6122)
67
+ b = HH(b, c, d, a, x[k + 14], S34, 0xFDE5380C)
68
+ a = HH(a, b, c, d, x[k + 1], S31, 0xA4BEEA44)
69
+ d = HH(d, a, b, c, x[k + 4], S32, 0x4BDECFA9)
70
+ c = HH(c, d, a, b, x[k + 7], S33, 0xF6BB4B60)
71
+ b = HH(b, c, d, a, x[k + 10], S34, 0xBEBFBC70)
72
+ a = HH(a, b, c, d, x[k + 13], S31, 0x289B7EC6)
73
+ d = HH(d, a, b, c, x[k + 0], S32, 0xEAA127FA)
74
+ c = HH(c, d, a, b, x[k + 3], S33, 0xD4EF3085)
75
+ b = HH(b, c, d, a, x[k + 6], S34, 0x4881D05)
76
+ a = HH(a, b, c, d, x[k + 9], S31, 0xD9D4D039)
77
+ d = HH(d, a, b, c, x[k + 12], S32, 0xE6DB99E5)
78
+ c = HH(c, d, a, b, x[k + 15], S33, 0x1FA27CF8)
79
+ b = HH(b, c, d, a, x[k + 2], S34, 0xC4AC5665)
80
+ a = II(a, b, c, d, x[k + 0], S41, 0xF4292244)
81
+ d = II(d, a, b, c, x[k + 7], S42, 0x432AFF97)
82
+ c = II(c, d, a, b, x[k + 14], S43, 0xAB9423A7)
83
+ b = II(b, c, d, a, x[k + 5], S44, 0xFC93A039)
84
+ a = II(a, b, c, d, x[k + 12], S41, 0x655B59C3)
85
+ d = II(d, a, b, c, x[k + 3], S42, 0x8F0CCC92)
86
+ c = II(c, d, a, b, x[k + 10], S43, 0xFFEFF47D)
87
+ b = II(b, c, d, a, x[k + 1], S44, 0x85845DD1)
88
+ a = II(a, b, c, d, x[k + 8], S41, 0x6FA87E4F)
89
+ d = II(d, a, b, c, x[k + 15], S42, 0xFE2CE6E0)
90
+ c = II(c, d, a, b, x[k + 6], S43, 0xA3014314)
91
+ b = II(b, c, d, a, x[k + 13], S44, 0x4E0811A1)
92
+ a = II(a, b, c, d, x[k + 4], S41, 0xF7537E82)
93
+ d = II(d, a, b, c, x[k + 11], S42, 0xBD3AF235)
94
+ c = II(c, d, a, b, x[k + 2], S43, 0x2AD7D2BB)
95
+ b = II(b, c, d, a, x[k + 9], S44, 0xEB86D391)
96
+ a = addUnsigned(a, AA)
97
+ b = addUnsigned(b, BB)
98
+ c = addUnsigned(c, CC)
99
+ d = addUnsigned(d, DD)
100
+ }
101
+ var tempValue = wordToHex(a) + wordToHex(b) + wordToHex(c) + wordToHex(d)
102
+ return tempValue.toLowerCase()
103
+ }
104
+ var rotateLeft = function (lValue: number, iShiftBits: number) {
105
+ return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits))
106
+ }
107
+ var addUnsigned = function (lX: number, lY: number) {
108
+ var lX4, lY4, lX8, lY8, lResult
109
+ lX8 = (lX & 0x80000000)
110
+ lY8 = (lY & 0x80000000)
111
+ lX4 = (lX & 0x40000000)
112
+ lY4 = (lY & 0x40000000)
113
+ lResult = (lX & 0x3FFFFFFF) + (lY & 0x3FFFFFFF)
114
+ if (lX4 & lY4) return (lResult ^ 0x80000000 ^ lX8 ^ lY8)
115
+ if (lX4 | lY4) {
116
+ if (lResult & 0x40000000) return (lResult ^ 0xC0000000 ^ lX8 ^ lY8)
117
+ else return (lResult ^ 0x40000000 ^ lX8 ^ lY8)
118
+ } else {
119
+ return (lResult ^ lX8 ^ lY8)
120
+ }
121
+ }
122
+ var F = function (x: number, y: number, z: number) {
123
+ return (x & y) | ((~x) & z)
124
+ }
125
+ var G = function (x: number, y: number, z: number) {
126
+ return (x & z) | (y & (~z))
127
+ }
128
+ var H = function (x: number, y: number, z: number) {
129
+ return (x ^ y ^ z)
130
+ }
131
+ var I = function (x: number, y: number, z: number) {
132
+ return (y ^ (x | (~z)))
133
+ }
134
+ var FF = function (a: number, b: number, c: number, d: number, x: number, s: number, ac: number) {
135
+ a = addUnsigned(a, addUnsigned(addUnsigned(F(b, c, d), x), ac))
136
+ return addUnsigned(rotateLeft(a, s), b)
137
+ }
138
+ var GG = function (a: number, b: number, c: number, d: number, x: number, s: number, ac: number) {
139
+ a = addUnsigned(a, addUnsigned(addUnsigned(G(b, c, d), x), ac))
140
+ return addUnsigned(rotateLeft(a, s), b)
141
+ }
142
+ var HH = function (a: number, b: number, c: number, d: number, x: number, s: number, ac: number) {
143
+ a = addUnsigned(a, addUnsigned(addUnsigned(H(b, c, d), x), ac))
144
+ return addUnsigned(rotateLeft(a, s), b)
145
+ }
146
+ var II = function (a: number, b: number, c: number, d: number, x: number, s: number, ac: number) {
147
+ a = addUnsigned(a, addUnsigned(addUnsigned(I(b, c, d), x), ac))
148
+ return addUnsigned(rotateLeft(a, s), b)
149
+ }
150
+ var convertToWordArray = function (string: string) {
151
+ var lWordCount
152
+ var lMessageLength = string.length
153
+ var lNumberOfWordsTempOne = lMessageLength + 8
154
+ var lNumberOfWordsTempTwo = (lNumberOfWordsTempOne - (lNumberOfWordsTempOne % 64)) / 64
155
+ var lNumberOfWords = (lNumberOfWordsTempTwo + 1) * 16
156
+ var lWordArray = Array(lNumberOfWords - 1)
157
+ var lBytePosition = 0
158
+ var lByteCount = 0
159
+ while (lByteCount < lMessageLength) {
160
+ lWordCount = (lByteCount - (lByteCount % 4)) / 4
161
+ lBytePosition = (lByteCount % 4) * 8
162
+ lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount) << lBytePosition))
163
+ lByteCount++
164
+ }
165
+ lWordCount = (lByteCount - (lByteCount % 4)) / 4
166
+ lBytePosition = (lByteCount % 4) * 8
167
+ lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition)
168
+ lWordArray[lNumberOfWords - 2] = lMessageLength << 3
169
+ lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29
170
+ return lWordArray
171
+ }
172
+ var wordToHex = function (lValue: number) {
173
+ var WordToHexValue = '',
174
+ WordToHexValueTemp = '',
175
+ lByte, lCount
176
+ for (lCount = 0; lCount <= 3; lCount++) {
177
+ lByte = (lValue >>> (lCount * 8)) & 255
178
+ WordToHexValueTemp = '0' + lByte.toString(16)
179
+ WordToHexValue = WordToHexValue + WordToHexValueTemp.substr(WordToHexValueTemp.length - 2, 2)
180
+ }
181
+ return WordToHexValue
182
+ }
183
+ var uTF8Encode = function (string: string) {
184
+ string = string.toString().replace(/\x0d\x0a/g, '\x0a')
185
+ var output = ''
186
+ for (var n = 0; n < string.length; n++) {
187
+ var c = string.charCodeAt(n)
188
+ if (c < 128) {
189
+ output += String.fromCharCode(c)
190
+ } else if ((c > 127) && (c < 2048)) {
191
+ output += String.fromCharCode((c >> 6) | 192)
192
+ output += String.fromCharCode((c & 63) | 128)
193
+ } else {
194
+ output += String.fromCharCode((c >> 12) | 224)
195
+ output += String.fromCharCode(((c >> 6) & 63) | 128)
196
+ output += String.fromCharCode((c & 63) | 128)
197
+ }
198
+ }
199
+ return output
200
+ }
201
+ return createMD5String(md5str)
202
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "ver": "4.0.24",
3
+ "importer": "typescript",
4
+ "imported": true,
5
+ "uuid": "bfee116d-9f34-419f-92cb-376c770a8609",
6
+ "files": [],
7
+ "subMetas": {},
8
+ "userData": {
9
+ "simulateGlobals": []
10
+ }
11
+ }
@@ -0,0 +1,61 @@
1
+
2
+ /**
3
+ * Predefined variables
4
+ * Name = RandomUtil
5
+ * DateTime = Thu Jan 13 2022 22:20:53 GMT+0800 (中国标准时间)
6
+ * Author = dream93
7
+ * FileBasename = RandomUtil.ts
8
+ * FileBasenameNoExtension = RandomUtil
9
+ * URL = db://assets/libs/util/RandomUtil.ts
10
+ * ManualUrl = https://docs.cocos.com/creator/3.4/manual/zh/
11
+ *
12
+ */
13
+
14
+
15
+ /**
16
+ * 生成[0, max)的随机数
17
+ * @param max
18
+ * @returns
19
+ */
20
+ export function random(min: number, max?: number) {
21
+ if (!max) {
22
+ max = min;
23
+ min = 0;
24
+ }
25
+ return min + Math.random() * (max - min);
26
+ }
27
+
28
+ /**
29
+ * 生成[0, max)的随机整数
30
+ * @param max
31
+ * @returns
32
+ */
33
+ export function randomInt(min: number, max?: number) {
34
+ return Math.floor(random(min, max));
35
+ }
36
+ /**
37
+ * 从数组中随机取出不重复的元素
38
+ * @param array 原始数组
39
+ * @param count 要取的元素个数
40
+ * @returns 随机不重复的元素数组
41
+ */
42
+ export function randomUniqueElements<T>(array: T[], count: number): T[] {
43
+ // 如果请求的元素数量大于数组长度,则警告并限制为数组长度
44
+ if (count > array.length) {
45
+ console.warn('请求的元素数量大于数组长度,将返回全部元素');
46
+ count = array.length;
47
+ }
48
+
49
+ // 创建数组副本,避免修改原始数组
50
+ const copy = [...array];
51
+ const result: T[] = [];
52
+
53
+ // 使用 Fisher-Yates 洗牌算法打乱数组顺序
54
+ for (let i = copy.length - 1; i > 0; i--) {
55
+ const j = Math.floor(Math.random() * (i + 1));
56
+ [copy[i], copy[j]] = [copy[j], copy[i]];
57
+ }
58
+
59
+ // 返回打乱后的数组中前 count 个元素
60
+ return copy.slice(0, count);
61
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "ver": "4.0.24",
3
+ "importer": "typescript",
4
+ "imported": true,
5
+ "uuid": "a22df3fb-75ed-49d7-9d67-ea0c763d3f58",
6
+ "files": [],
7
+ "subMetas": {},
8
+ "userData": {}
9
+ }
@@ -0,0 +1,129 @@
1
+ /**
2
+ *
3
+ * @file ResUtil.ts
4
+ * @author yangfan
5
+ * @description Cocos方法整合,如果Cocos版本升级,造成API修改,仅需修改此处
6
+ *
7
+ */
8
+
9
+ import { Asset, assetManager, AssetManager, ImageAsset, resources, Texture2D } from "cc";
10
+
11
+ export type Constructor<T extends Asset> = new () => T;
12
+
13
+ export const headImgExt = ".head";
14
+
15
+ export module ResUtil {
16
+
17
+ /**
18
+ * @description 原生加载资源
19
+ * @param object {url: 远程地址 option: 参数类型}
20
+ * @returns
21
+ */
22
+ export function loadRemote<T extends Asset>(object: { url: string, option?: any }) {
23
+ if (null == object.option) {
24
+ object.option = {};
25
+ }
26
+ const { url, option } = object;
27
+ return new Promise((resolve, reject) => {
28
+ assetManager.loadRemote(url, option, (err: Error | null, asset: T) => {
29
+ resolve && resolve(err ? null : asset);
30
+ });
31
+ });
32
+
33
+ }
34
+
35
+ /**
36
+ * 加载bundle
37
+ * @param bundleName
38
+ * @returns
39
+ */
40
+ export function loadBundle(bundleName: string) {
41
+ return new Promise((resolve, reject) => {
42
+ assetManager.loadBundle(bundleName, (err, bundle) => {
43
+ resolve && resolve(err ? null : bundle);
44
+ });
45
+ });
46
+ }
47
+
48
+ function getBundle(bundleName?: string, bundle?: AssetManager.Bundle) {
49
+ if (!bundle) {
50
+ if (null == bundleName || '' === bundleName) {
51
+ bundle = resources;
52
+ } else {
53
+ bundle = assetManager.getBundle(bundleName)!;
54
+ }
55
+ }
56
+ return bundle;
57
+ }
58
+
59
+ /**
60
+ * 加载资源
61
+ * @param option
62
+ * @returns
63
+ */
64
+ export function loadAsset<T extends Asset>(option: { path: string, bundleName?: string, bundle?: AssetManager.Bundle, type: Constructor<T> }) {
65
+ const bundle = getBundle(option.bundleName, option.bundle);
66
+ const asset = bundle.get(option.path, option.type);
67
+ if (null != asset) {
68
+ return Promise.resolve(asset);
69
+ }
70
+ return new Promise((resolve, reject) => {
71
+ bundle.load(option.path, option.type, (err, asset: T) => {
72
+ resolve(err ? null : asset);
73
+ });
74
+ });
75
+ }
76
+
77
+ /**
78
+ * 自定义头像加载流程
79
+ * 加载头像使用 ResUtil.loadRemote({url, option:{ext:headImgExt}})
80
+ */
81
+ export function registerHeadImgLoader() {
82
+ assetManager.downloader.register(headImgExt, (content, options, onComplete) => {
83
+ onComplete(null, content);
84
+ });
85
+ assetManager.parser.register(headImgExt, downloadDomImage);
86
+ assetManager.factory.register(headImgExt, createTexture);
87
+ }
88
+
89
+ function createTexture(id: string, data: any, options: any, onComplete: Function) {
90
+ let out: Texture2D | null = null;
91
+ let err: Error | null = null;
92
+ try {
93
+ out = new Texture2D();
94
+ const imageAsset = new ImageAsset(data);
95
+ out.image = imageAsset;
96
+ } catch (e) {
97
+ err = e as any as Error;
98
+ }
99
+ onComplete && onComplete(err, out);
100
+ }
101
+
102
+ function downloadDomImage(url: string, options: any, onComplete: Function) {
103
+ const img = new Image();
104
+ if (window.location.protocol !== 'file:') {
105
+ img.crossOrigin = 'anonymous';
106
+ }
107
+ function loadCallback() {
108
+ img.removeEventListener('load', loadCallback);
109
+ img.removeEventListener('error', errorCallback);
110
+ if (onComplete) {
111
+ onComplete(null, img);
112
+ }
113
+ }
114
+
115
+ function errorCallback() {
116
+ img.removeEventListener('load', loadCallback);
117
+ img.removeEventListener('error', errorCallback);
118
+ if (onComplete) {
119
+ onComplete(new Error(url));
120
+ }
121
+ }
122
+
123
+ img.addEventListener('load', loadCallback);
124
+ img.addEventListener('error', errorCallback);
125
+ img.src = url;
126
+ return img;
127
+ }
128
+
129
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "ver": "4.0.24",
3
+ "importer": "typescript",
4
+ "imported": true,
5
+ "uuid": "ab0ad09c-33f5-4cd0-94b4-9f5698cc3fb4",
6
+ "files": [],
7
+ "subMetas": {},
8
+ "userData": {}
9
+ }
@@ -0,0 +1,30 @@
1
+ export let global: any;
2
+ declare global {
3
+
4
+ class WordArray { }
5
+
6
+ namespace CryptoJS {
7
+
8
+ namespace AES {
9
+ export function encrypt(message: string, key: string, cfg: { iv: string, mode: mode, padding: pad }): WordArray;
10
+
11
+ export function decrypt(text: string, key: string, cfg: { iv: string, mode: mode, padding: pad }): WordArray;
12
+ }
13
+
14
+ namespace enc {
15
+ namespace Utf8 {
16
+ export function parse(key: WordArray): string;
17
+ export function stringify(word: WordArray): string;
18
+ }
19
+ }
20
+
21
+ export enum mode {
22
+ CBC,
23
+ ECB,
24
+ }
25
+
26
+ export enum pad {
27
+ Pkcs7
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "ver": "4.0.24",
3
+ "importer": "typescript",
4
+ "imported": true,
5
+ "uuid": "d8b99ef1-3af7-44cf-a14b-f8888d3aa669",
6
+ "files": [],
7
+ "subMetas": {},
8
+ "userData": {
9
+ "simulateGlobals": []
10
+ }
11
+ }