dh-mini-sdk-for-wx-2.0.0.d.ts 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. declare module "dh-mini-sdk-for-wx-2.0.1" {
  2. type Callback = (result: any) => void;
  3. type SuccessCallback = (response: Response) => void;
  4. type FailCallback = (error: Error) => void;
  5. type CompleteCallback = (result: Result) => void;
  6. interface Response {
  7. code: string | number | undefined;
  8. data: any;
  9. message: string
  10. }
  11. interface Error {
  12. code: string | number | undefined;
  13. data: any;
  14. message: string
  15. }
  16. interface Result {
  17. code: string | number | undefined;
  18. data: any;
  19. message: string
  20. }
  21. interface Options {
  22. requests: Requests;
  23. gameAppId: string | number;
  24. appId: string | number;
  25. appVersion: string;
  26. packageName: string;
  27. channel: string | number;
  28. mainChannel: string | number;
  29. secondChannel: string | number;
  30. heartbeatEnable?: boolean;
  31. reyunAppKey?: string;
  32. gravityEngineAccessToken?: string;
  33. gravityEngineDebug?: boolean;
  34. gravityEnginePayEventEnable?: boolean;
  35. tencentUserActionId: number;
  36. tencentSecretKey: string;
  37. tencentDebug?: boolean;
  38. }
  39. interface Requests {
  40. login: string | string[];
  41. pay: string | string[];
  42. midas: string | string[];
  43. survey: string | string[];
  44. customerService: string | string[];
  45. gameClub: string | string[];
  46. log: string | string[];
  47. errorLog: string | string[];
  48. }
  49. interface UserInfo {
  50. accountId: number;
  51. accountName: string;
  52. accountView: string;
  53. expireTimestamp: number;
  54. loginTimestamp: number;
  55. loginType: number;
  56. region: number;
  57. sign: string;
  58. token: string;
  59. isFirstLogin: boolean;
  60. userExtraInfo: UserExtraInfo;
  61. }
  62. interface UserExtraInfo {
  63. openId: string;
  64. userName: string;
  65. avatar: string;
  66. nickName: string;
  67. }
  68. interface UserRoleInfo {
  69. type: "LOGIN_GAME" | "CREATE_ROLE" | "LEVEL_UP" | "PAY_SUCCESS";
  70. areaId?: string | number;
  71. areaName?: string;
  72. roleId?: string | number;
  73. roleName?: string;
  74. roleLevel?: number;
  75. roleVipLevel?: number;
  76. itemId?: string;
  77. itemName?: string;
  78. orderId?: string | number;
  79. orderPrice?: number;
  80. currency?: string;
  81. payType?: string;
  82. }
  83. interface LoginOptions {
  84. success?: SuccessCallback;
  85. fail?: FailCallback;
  86. complete?: CompleteCallback;
  87. }
  88. interface UploadRoleInfoOptions {
  89. type: "LOGIN_GAME" | "CREATE_ROLE" | "LEVEL_UP" | "PAY_SUCCESS";
  90. areaId?: string | number;
  91. areaName?: string;
  92. roleId?: string | number;
  93. roleName?: string;
  94. roleLevel?: number;
  95. roleVipLevel?: number;
  96. itemId?: string;
  97. itemName?: string;
  98. orderId?: string | number;
  99. orderPrice?: number;
  100. currency?: string;
  101. payType?: string;
  102. }
  103. interface CreateUserInfoButtonOptions {
  104. type: "text" | "image";
  105. text?: string;
  106. image?: string;
  107. style: {
  108. top: number;
  109. left: number;
  110. width: number;
  111. height: number;
  112. borderWidth?: number;
  113. borderRadius?: number;
  114. borderColor?: string;
  115. backgroundColor?: string;
  116. color?: string;
  117. fontSize?: number;
  118. textAlign?: string;
  119. lineHeight?: number;
  120. };
  121. withCredentials?: boolean;
  122. lang?: "en" | "zh_CN" | "zh_TW";
  123. }
  124. interface UserInfoButton {
  125. show: () => void;
  126. hide: () => void;
  127. destroy: () => void;
  128. onTap: (listener: Callback) => void;
  129. offTap: (listener: Callback) => void;
  130. }
  131. interface GetUserInfoOptions {
  132. withCredentials?: boolean;
  133. lang?: "en" | "zh_CN" | "zh_TW";
  134. success?: SuccessCallback;
  135. fail?: FailCallback;
  136. complete?: CompleteCallback;
  137. }
  138. interface PayOptions {
  139. cardMessageTitle?: string;
  140. cardMessageImage?: string;
  141. areaId?: string | number;
  142. areaName?: string;
  143. roleId?: string | number;
  144. roleName?: string;
  145. roleLevel?: number;
  146. itemId: string;
  147. itemName: string;
  148. itemNum?: number;
  149. itemPrice: number;
  150. currency?: string;
  151. rate: number;
  152. memo?: string;
  153. remark?: string;
  154. success?: SuccessCallback;
  155. fail?: FailCallback;
  156. complete?: CompleteCallback;
  157. }
  158. interface PaySettings {
  159. android?: "h5" | "midas";
  160. ios?: "h5";
  161. windows?: "h5" | "midas";
  162. mac?: "h5";
  163. devtools?: "h5" | "midas";
  164. }
  165. interface CreateRewardedVideoAdOptions {
  166. adUnitId: string;
  167. adMultiton?: boolean;
  168. adPlatform?: string;
  169. adPosition?: string;
  170. onLoad?: (response: Response) => void;
  171. onClose?: (result: Result) => void;
  172. onError?: (error: Error) => void;
  173. }
  174. interface RewardedVideoAd {
  175. load: (callback?: Callback) => void;
  176. show: (options?: RewardedVideoAdShowOptions | Callback, callback?: Callback) => void;
  177. destroy: () => void;
  178. }
  179. interface RewardedVideoAdShowOptions {
  180. adPosition?: string;
  181. }
  182. interface OpenSurveyOptions {
  183. areaId?: string | number;
  184. roleId?: string | number;
  185. roleName?: string;
  186. roleLevel?: number;
  187. surveyId: number;
  188. success?: SuccessCallback;
  189. fail?: FailCallback;
  190. complete?: CompleteCallback;
  191. }
  192. interface OpenCustomerServiceOptions {
  193. areaId?: string | number;
  194. roleId?: string | number;
  195. roleName?: string;
  196. roleLevel?: number;
  197. success?: SuccessCallback;
  198. fail?: FailCallback;
  199. complete?: CompleteCallback;
  200. }
  201. interface CreateFeedbackButtonOptions {
  202. type: "text" | "image";
  203. text?: string;
  204. image?: string;
  205. style: {
  206. top: number;
  207. left: number;
  208. width: number;
  209. height: number;
  210. borderWidth?: number;
  211. borderRadius?: number;
  212. borderColor?: string;
  213. backgroundColor?: string;
  214. color?: string;
  215. fontSize?: number;
  216. textAlign?: string;
  217. lineHeight?: number;
  218. }
  219. }
  220. interface FeedbackButton {
  221. show: () => void;
  222. hide: () => void;
  223. destroy: () => void;
  224. onTap: (listener: Callback) => void;
  225. offTap: (listener: Callback) => void;
  226. }
  227. interface OpenChannelsUserProfileOptions {
  228. finderUserName: string;
  229. success?: SuccessCallback;
  230. fail?: FailCallback;
  231. complete?: CompleteCallback;
  232. }
  233. interface OpenChannelsEventOptions {
  234. finderUserName: string;
  235. eventId: string;
  236. success?: SuccessCallback;
  237. fail?: FailCallback;
  238. complete?: CompleteCallback;
  239. }
  240. interface OpenChannelsActivityOptions {
  241. finderUserName: string;
  242. feedId: string;
  243. success?: SuccessCallback;
  244. fail?: FailCallback;
  245. complete?: CompleteCallback;
  246. }
  247. interface OpenChannelsLiveOptions {
  248. finderUserName: string;
  249. feedId?: string;
  250. noticeId?: string;
  251. success?: SuccessCallback;
  252. fail?: FailCallback;
  253. complete?: CompleteCallback;
  254. }
  255. interface ReserveChannelsLiveOptions {
  256. noticeId: string;
  257. }
  258. interface GetChannelsLiveNoticeInfoOptions {
  259. finderUserName: string;
  260. success?: SuccessCallback;
  261. fail?: FailCallback;
  262. complete?: CompleteCallback;
  263. }
  264. interface GetChannelsLiveInfoOptions {
  265. finderUserName: string;
  266. startTime?: number;
  267. endTime?: number;
  268. success?: SuccessCallback;
  269. fail?: FailCallback;
  270. complete?: CompleteCallback;
  271. }
  272. interface CreateGameClubButtonOptions {
  273. type: "text" | "image";
  274. text?: string;
  275. icon?: "green" | "white" | "dark" | "light";
  276. image?: string;
  277. style: {
  278. top: number;
  279. left: number;
  280. width: number;
  281. height: number;
  282. borderWidth?: number;
  283. borderRadius?: number;
  284. borderColor?: string;
  285. backgroundColor?: string;
  286. color?: string;
  287. fontSize?: number;
  288. textAlign?: string;
  289. lineHeight?: number;
  290. };
  291. openlink?: string;
  292. hasRedDot?: boolean;
  293. }
  294. interface GameClubButton {
  295. show: () => void;
  296. hide: () => void;
  297. destroy: () => void;
  298. onTap: (listener: Callback) => void;
  299. offTap: (listener: Callback) => void;
  300. }
  301. interface ShareImageToGameClubOptions {
  302. title: string;
  303. content: string;
  304. url?: string;
  305. success?: SuccessCallback;
  306. fail?: FailCallback;
  307. complete?: CompleteCallback;
  308. }
  309. interface ShareCanvasToGameClubOptions {
  310. title: string;
  311. content: string;
  312. x?: number;
  313. y?: number;
  314. width?: number;
  315. height?: number;
  316. destWidth?: number;
  317. destHeight?: number;
  318. fileType?: "png" | "jpg";
  319. quality?: number;
  320. success?: SuccessCallback;
  321. fail?: FailCallback;
  322. complete?: CompleteCallback;
  323. }
  324. interface GetGameClubDataOptions {
  325. dataTypeList: GameClubDataType[];
  326. success?: SuccessCallback;
  327. fail?: FailCallback;
  328. complete?: CompleteCallback;
  329. }
  330. interface GameClubDataType {
  331. type: number;
  332. subKey?: string;
  333. }
  334. interface GameRecorder {
  335. isFrameSupported(): boolean;
  336. isSoundSupported(): boolean;
  337. isVolumeSupported(): boolean;
  338. isAtempoSupported(): boolean;
  339. on(event: string, callback: Callback): void;
  340. off(event: string, callback: Callback): void;
  341. start(options?: GameRecorderStartOptions): Promise<any>;
  342. pause(): Promise<any>;
  343. resume(): Promise<any>;
  344. stop(): Promise<any>;
  345. abort(): Promise<any>;
  346. }
  347. interface GameRecorderStartOptions {
  348. fps?: number;
  349. bitrate?: number;
  350. gop?: number;
  351. duration?: number;
  352. hookBgm?: boolean
  353. }
  354. interface ShareGameRecorderVideoOptions {
  355. title?: string;
  356. desc?: string;
  357. path?: string;
  358. query?: string;
  359. timeRange?: number[][];
  360. bgm?: string;
  361. volume?: number;
  362. atempo?: number;
  363. audioMix?: boolean;
  364. success?: SuccessCallback;
  365. fail?: FailCallback;
  366. complete?: CompleteCallback;
  367. }
  368. interface CreateGameRecorderShareButtonOptions {
  369. icon?: string;
  370. image?: string;
  371. text?: string;
  372. style?: {
  373. top?: number;
  374. left?: number;
  375. height?: number;
  376. paddingLeft?: number;
  377. paddingRight?: number;
  378. color?: string;
  379. fontSize?: number;
  380. iconMarginRight?: number;
  381. };
  382. share?: {
  383. path?: string;
  384. query?: string;
  385. timeRange?: number[][];
  386. bgm?: string;
  387. volume?: number;
  388. atempo?: number;
  389. audioMix?: boolean;
  390. }
  391. }
  392. interface GameRecorderShareButton {
  393. show: () => void;
  394. hide: () => void;
  395. destroy: () => void;
  396. onTap: (listener: Callback) => void;
  397. offTap: (listener: Callback) => void;
  398. }
  399. interface SetShareOptions {
  400. title?: string;
  401. imageUrl?: string;
  402. imageUrlId?: string;
  403. imagePreviewUrl?: string;
  404. imagePreviewUrlId?: string;
  405. path?: string;
  406. query?: Record<string, unknown>;
  407. }
  408. interface ShareOptions {
  409. title?: string;
  410. imageUrl?: string;
  411. imageUrlId?: string;
  412. path?: string;
  413. query?: Record<string, unknown>;
  414. }
  415. interface ShowShareImageMenuOptions {
  416. path: string;
  417. success?: SuccessCallback;
  418. fail?: FailCallback;
  419. complete?: CompleteCallback;
  420. }
  421. interface SubscribeMessageOptions {
  422. tmplIds: string[];
  423. success?: SuccessCallback;
  424. fail?: FailCallback;
  425. complete?: CompleteCallback;
  426. }
  427. interface SubscribeSystemMessageOptions {
  428. msgTypeList: string[];
  429. success?: SuccessCallback;
  430. fail?: FailCallback;
  431. complete?: CompleteCallback;
  432. }
  433. interface OpenSettingOptions {
  434. withSubscriptions?: boolean;
  435. success?: SuccessCallback;
  436. fail?: FailCallback;
  437. complete?: CompleteCallback;
  438. }
  439. interface GetSettingOptions {
  440. withSubscriptions?: boolean;
  441. success?: SuccessCallback;
  442. fail?: FailCallback;
  443. complete?: CompleteCallback;
  444. }
  445. interface TrackEventEventParams {
  446. [key: string]: any;
  447. }
  448. interface ModalConfirmOptions {
  449. title: string;
  450. content: string;
  451. cancelText?: string;
  452. confirmText?: string;
  453. success?: Callback;
  454. fail?: Callback;
  455. complete?: Callback;
  456. }
  457. interface AnalyticsRoleOptions {
  458. areaId?: string | number;
  459. roleId?: string | number;
  460. roleName?: string;
  461. roleGender?: number;
  462. soles?: number;
  463. }
  464. interface AnalyticsPayOptions {
  465. areaId?: string | number;
  466. roleId?: string | number;
  467. roleLevel?: number;
  468. roleVipLevel?: number;
  469. channel?: number;
  470. orderId: string;
  471. orderPrice: number;
  472. itemId: string;
  473. payType?: string;
  474. currency?: string;
  475. }
  476. interface AnalyticsAdOptions {
  477. adUnitId?: string;
  478. adType?: number;
  479. adPlatform?: string;
  480. adPosition?: string;
  481. adEventName: "ad_play" | "ad_inclick" | "ad_close" | "ad_error";
  482. adEventResult?: 0 | 1 | 2;
  483. adEventMessage?: string;
  484. adPlayDuration?: number;
  485. }
  486. interface AnalyticsShareOptions {
  487. shareType: 1 | 2 | 3;
  488. }
  489. interface AnalyticsEventOptions {
  490. areaId?: string | number;
  491. roleId?: string | number;
  492. eventName: string;
  493. eventObj?: string;
  494. eventResult?: string;
  495. eventCode?: string;
  496. statMode?: 1 | 2;
  497. extendParamJson?: string;
  498. }
  499. interface AnalyticsLogOptions {
  500. eventId: string;
  501. subEventId?: string;
  502. logLevel?: "d" | "e";
  503. logContent: string;
  504. accountId?: string | number;
  505. }
  506. export default class DHMiniSDK {
  507. constructor(options: Options);
  508. readonly version: string;
  509. readonly requests: Requests;
  510. readonly env: "develop" | "trial" | "release";
  511. readonly isShow: boolean;
  512. readonly system: any;
  513. readonly networkType: string;
  514. readonly deviceId: string;
  515. readonly deviceOS: string;
  516. readonly launchOptions: any;
  517. readonly gameAppId: string | number;
  518. readonly appId: string | number;
  519. readonly appVersion: string;
  520. readonly packageName: string;
  521. readonly channel: string | number;
  522. readonly mainChannel: string | number;
  523. readonly secondChannel: string | number;
  524. readonly userInfo: UserInfo | null;
  525. readonly userRoleInfo: UserRoleInfo | null;
  526. readonly heartbeatEnable: boolean;
  527. readonly reyunAppKey?: string;
  528. readonly gravityEngineAccessToken?: string;
  529. readonly gravityEngineDebug?: boolean;
  530. readonly gravityEnginePayEventEnable?: boolean;
  531. readonly tencentUserActionId: number;
  532. readonly tencentSecretKey: string;
  533. readonly tencentDebug?: boolean;
  534. readonly login: (options: LoginOptions) => void;
  535. readonly uploadRoleInfo: (options: UploadRoleInfoOptions, callback?: Callback) => void;
  536. readonly createUserInfoButton: (options: CreateUserInfoButtonOptions) => UserInfoButton;
  537. readonly getUserInfo: (options: GetUserInfoOptions) => void;
  538. readonly pay: (options: PayOptions, settings?: PaySettings) => void;
  539. readonly createRewardedVideoAd: (options: CreateRewardedVideoAdOptions) => RewardedVideoAd;
  540. readonly openSurvey: (options: OpenSurveyOptions) => void;
  541. readonly openCustomerService: (options: OpenCustomerServiceOptions) => void;
  542. readonly createFeedbackButton: (options: CreateFeedbackButtonOptions) => FeedbackButton;
  543. readonly openChannelsUserProfile: (options: OpenChannelsUserProfileOptions) => void;
  544. readonly openChannelsEvent: (options: OpenChannelsEventOptions) => void;
  545. readonly openChannelsActivity: (options: OpenChannelsActivityOptions) => void;
  546. readonly openChannelsLive: (options: OpenChannelsLiveOptions) => void;
  547. readonly reserveChannelsLive: (options: ReserveChannelsLiveOptions) => void;
  548. readonly getChannelsLiveNoticeInfo: (options: GetChannelsLiveNoticeInfoOptions) => void;
  549. readonly getChannelsLiveInfo: (options: GetChannelsLiveInfoOptions) => void;
  550. readonly createGameClubButton: (options: CreateGameClubButtonOptions) => GameClubButton;
  551. readonly shareImageToGameClub: (options: ShareImageToGameClubOptions) => void;
  552. readonly shareCanvasToGameClub: (options: ShareCanvasToGameClubOptions) => void;
  553. readonly getGameClubData: (options: GetGameClubDataOptions) => void;
  554. readonly getGameRecorder: () => GameRecorder;
  555. readonly shareGameRecorderVideo: (options: ShareGameRecorderVideoOptions) => void;
  556. readonly createGameRecorderShareButton: (options: CreateGameRecorderShareButtonOptions) => GameRecorderShareButton;
  557. readonly setShare: (options: SetShareOptions) => void;
  558. readonly share: (options: ShareOptions) => void;
  559. readonly showShareImageMenu: (options: ShowShareImageMenuOptions) => void;
  560. readonly subscribeMessage: (options: SubscribeMessageOptions) => void;
  561. readonly subscribeSystemMessage: (options: SubscribeSystemMessageOptions) => void;
  562. readonly openSetting: (options: OpenSettingOptions) => void;
  563. readonly getSetting: (options: GetSettingOptions) => void;
  564. readonly getAccountId: () => string | number | void;
  565. readonly getOpenId: () => string | number | void;
  566. readonly isRegister: () => boolean;
  567. readonly showUpgradeMessage: (message?: string) => void;
  568. readonly modal: {
  569. loading: (message: string) => void;
  570. message: (message: string) => void;
  571. success: (message: string) => void;
  572. error: (message: string) => void;
  573. confirm: (options: ModalConfirmOptions) => void;
  574. };
  575. readonly trackEvent: (eventId: string, eventParams: TrackEventEventParams, callback?: Callback) => void;
  576. readonly analytics: {
  577. loaded: (callback?: Callback) => void;
  578. register: (callback?: Callback) => void;
  579. logged: (callback?: Callback) => void;
  580. role: (options: AnalyticsRoleOptions, callback?: Callback) => void;
  581. pay: (options: AnalyticsPayOptions, callback?: Callback) => void;
  582. ad: (options: AnalyticsAdOptions, callback?: Callback) => void;
  583. share: (options: AnalyticsShareOptions, callback?: Callback) => void;
  584. event: (options: AnalyticsEventOptions, callback?: Callback) => void;
  585. log: (options: AnalyticsLogOptions, callback?: Callback) => void;
  586. };
  587. }
  588. }