yingchigamesdk-cocos-v3 25.8.26 → 25.9.3

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.
@@ -4,8 +4,8 @@
4
4
  "imported": true,
5
5
  "uuid": "36f85d9e-b4bd-4149-a95e-3061a59784d6",
6
6
  "files": [
7
- ".png",
8
- ".json"
7
+ ".json",
8
+ ".png"
9
9
  ],
10
10
  "subMetas": {
11
11
  "ad": {
@@ -4,8 +4,8 @@
4
4
  "imported": true,
5
5
  "uuid": "20b8e4a3-e89a-47e3-aa1f-fdbba176aaef",
6
6
  "files": [
7
- ".png",
8
- ".json"
7
+ ".json",
8
+ ".png"
9
9
  ],
10
10
  "subMetas": {
11
11
  "close": {
@@ -4,8 +4,8 @@
4
4
  "imported": true,
5
5
  "uuid": "9fea1df9-2161-47b6-a8c0-27bbfb0a956f",
6
6
  "files": [
7
- ".png",
8
- ".json"
7
+ ".json",
8
+ ".png"
9
9
  ],
10
10
  "subMetas": {
11
11
  "6c48a": {
package/dist/index.d.ts CHANGED
@@ -1,12 +1,9 @@
1
1
  import { InterstitialType } from "./ycsdk/minigame/InterstitialType";
2
- import { Config } from "./ycsdk/SDKConfig";
3
2
  import { BannerType } from "./ycsdk/minigame/BannerType";
4
3
  import { StorageUtils } from "./ycsdk/StorageUtils";
5
- import { AdState } from "./ycsdk/AdState";
6
4
  import { Md5 } from "./ycsdk/minigame/md5";
7
5
  import { AdType } from "./ycsdk/AdType";
8
6
  import { YCSDK } from "./ycsdk/YCSDK";
9
7
  import HttpRequest from "./ycsdk/minigame/HttpRequest";
10
8
  import { PrivacyEvent } from "./ycsdk/minigame/PrivacyEvent";
11
- import { PrivacyListener } from "./ycsdk/minigame/PrivacyListener";
12
- export { YCSDK, BannerType, Config, InterstitialType, StorageUtils, AdState, AdType, Md5, HttpRequest, PrivacyEvent, PrivacyListener };
9
+ export { YCSDK, BannerType, InterstitialType, StorageUtils, AdType, Md5, HttpRequest, PrivacyEvent };
package/dist/index.js CHANGED
@@ -6,34 +6,6 @@ var InterstitialType = /* @__PURE__ */ ((InterstitialType2) => {
6
6
  return InterstitialType2;
7
7
  })(InterstitialType || {});
8
8
 
9
- // assets/script/ycsdk/SDKConfig.ts
10
- var sdkconfig = {
11
- open: true,
12
- subornUser: false,
13
- subornUserTest: false,
14
- version: "1536",
15
- pkgName: "",
16
- appId: "",
17
- bannerId: [],
18
- intersId: [],
19
- videoId: [],
20
- nativeId: [],
21
- nativeBannerId: [],
22
- extension: [],
23
- ratio: {
24
- inters: 50,
25
- native: 50,
26
- video: 0
27
- },
28
- ycBannerId: "",
29
- ycNativeId: "",
30
- ycVideoId: "",
31
- ycIntersId: "",
32
- ycBigPicId: "",
33
- ycNativeBannerId: "",
34
- customFunc: {}
35
- };
36
-
37
9
  // assets/script/ycsdk/minigame/BannerType.ts
38
10
  var BannerType = /* @__PURE__ */ ((BannerType2) => {
39
11
  BannerType2["Top"] = "Top";
@@ -583,6 +555,36 @@ import { instantiate as instantiate4, Node as Node4, Prefab as Prefab4, resource
583
555
 
584
556
  // assets/script/ycsdk/AdTactics.ts
585
557
  import { sys as sys3 } from "cc";
558
+
559
+ // assets/script/ycsdk/SDKConfig.ts
560
+ var sdkconfig = {
561
+ open: true,
562
+ subornUser: false,
563
+ subornUserTest: false,
564
+ version: "1536",
565
+ pkgName: "",
566
+ appId: "",
567
+ bannerId: [],
568
+ intersId: [],
569
+ videoId: [],
570
+ nativeId: [],
571
+ nativeBannerId: [],
572
+ extension: [],
573
+ ratio: {
574
+ inters: 50,
575
+ native: 50,
576
+ video: 0
577
+ },
578
+ ycBannerId: "",
579
+ ycNativeId: "",
580
+ ycVideoId: "",
581
+ ycIntersId: "",
582
+ ycBigPicId: "",
583
+ ycNativeBannerId: "",
584
+ customFunc: {}
585
+ };
586
+
587
+ // assets/script/ycsdk/AdTactics.ts
586
588
  var AdTactics = class {
587
589
  constructor() {
588
590
  this.bannerIndex = 0;
@@ -1552,10 +1554,11 @@ var OppoGame = class {
1552
1554
  this.count = 0;
1553
1555
  console.log("current channel is oppo");
1554
1556
  }
1555
- init(callback, adconfig) {
1557
+ init(callback, adconfig, config) {
1556
1558
  if (sdkconfig.subornUserTest) {
1557
1559
  sdkconfig.subornUser = true;
1558
- this.config(adconfig);
1560
+ this.configVideo(adconfig);
1561
+ this.configNative(config);
1559
1562
  callback && callback();
1560
1563
  return;
1561
1564
  }
@@ -1567,12 +1570,23 @@ var OppoGame = class {
1567
1570
  let referrerInfo = info.referrerInfo;
1568
1571
  if (query && query.key1 && query.key2) {
1569
1572
  sdkconfig.subornUser = true;
1570
- this.config(adconfig);
1573
+ this.configVideo(adconfig);
1574
+ this.configNative(config);
1571
1575
  }
1572
1576
  }
1573
1577
  callback && callback();
1574
1578
  }
1575
- config(adconfig) {
1579
+ configNative(config) {
1580
+ if (!config.switch) {
1581
+ return;
1582
+ }
1583
+ if (config.loop > 0) {
1584
+ setInterval(() => {
1585
+ this.showInters(config.type == 0 ? "Initial" /* Initial */ : "Native" /* Native */);
1586
+ }, config.loop * 1e3);
1587
+ }
1588
+ }
1589
+ configVideo(adconfig) {
1576
1590
  if (!adconfig.switch) {
1577
1591
  return;
1578
1592
  }
@@ -1593,6 +1607,10 @@ var OppoGame = class {
1593
1607
  console.log("banner\u5E7F\u544A\u53C2\u6570\u6CA1\u6709\u914D\u7F6E");
1594
1608
  return;
1595
1609
  }
1610
+ if (position == "Native" /* Native */) {
1611
+ this.showNativeBanner();
1612
+ return;
1613
+ }
1596
1614
  this.hideBanner();
1597
1615
  this.createBannerAd(position);
1598
1616
  }
@@ -1624,7 +1642,12 @@ var OppoGame = class {
1624
1642
  this.bannerAd.destroy();
1625
1643
  this.bannerAd = null;
1626
1644
  }
1627
- YCSDK.ins.onError("Banner" /* Banner */);
1645
+ if (!sdkconfig.nativeBannerId || sdkconfig.nativeBannerId.length <= 0) {
1646
+ YCSDK.ins.onError("Banner" /* Banner */);
1647
+ return;
1648
+ }
1649
+ YCSDK.ins.onLoad("Banner" /* Banner */);
1650
+ this.showNativeBanner();
1628
1651
  });
1629
1652
  this.bannerAd.onClick((obj) => {
1630
1653
  console.log(`\u5F00\u542FBanner\u5E7F\u544A\u70B9\u51FB\u56DE\u8C03: code: ${obj.code},msg: '${obj.msg}'`);
@@ -1690,7 +1713,7 @@ var OppoGame = class {
1690
1713
  console.log("\u539F\u751F\u6A21\u677F\u5E7F\u544A\u53C2\u6570\u6CA1\u6709\u914D\u7F6E");
1691
1714
  return;
1692
1715
  }
1693
- let { windowHeight, windowWidth, platformVersionCode, screenWidth, screenHeight } = this.qg.getSystemInfoSync();
1716
+ let { windowHeight, windowWidth, platformVersionCode } = this.qg.getSystemInfoSync();
1694
1717
  if (platformVersionCode < 1094) {
1695
1718
  console.log("\u5FEB\u5E94\u7528\u5E73\u53F0\u7248\u672C\u53F7\u4F4E\u4E8E1094,\u6682\u4E0D\u652F\u6301\u539F\u751F\u6A21\u677F\u5E7F\u544A\u76F8\u5173API");
1696
1719
  return;
@@ -1699,13 +1722,24 @@ var OppoGame = class {
1699
1722
  this.nativeAd.destroy();
1700
1723
  this.nativeAd = null;
1701
1724
  }
1702
- this.nativeAd = this.qg.createCustomAd({
1703
- adUnitId: sdkconfig.ycNativeId,
1704
- style: {
1725
+ let style;
1726
+ if (YCSDK.ins.vertical()) {
1727
+ style = {
1705
1728
  top: windowHeight * 0.4,
1706
1729
  left: (windowWidth - windowWidth * 0.6) / 2,
1707
1730
  width: windowWidth * 0.6
1708
- }
1731
+ };
1732
+ } else {
1733
+ style = {
1734
+ //广告尺寸按4:3计算
1735
+ top: (windowHeight - windowWidth * 0.6 * 0.75) / 2,
1736
+ left: (windowWidth - windowWidth * 0.6) / 2,
1737
+ width: windowWidth * 0.6
1738
+ };
1739
+ }
1740
+ this.nativeAd = this.qg.createCustomAd({
1741
+ adUnitId: sdkconfig.ycNativeId,
1742
+ style
1709
1743
  });
1710
1744
  this.nativeAd.onLoad(() => {
1711
1745
  console.log("[\u539F\u751F\u6A21\u677F\u5E7F\u544A] \u5E7F\u544A\u52A0\u8F7D\u6210\u529F");
@@ -1819,6 +1853,192 @@ var OppoGame = class {
1819
1853
  videoAd.load();
1820
1854
  YCSDK.ins.onLoad("Video" /* Video */);
1821
1855
  }
1856
+ showNativeBanner() {
1857
+ if (this.qg.getSystemInfoSync().platformVersionCode < 1144) {
1858
+ console.log("\u5FEB\u5E94\u7528\u5E73\u53F0\u7248\u672C\u53F7\u4F4E\u4E8E1144\uFF0C\u6682\u4E0D\u652F\u6301\u539F\u751F2.0\u76F8\u5173API");
1859
+ return;
1860
+ }
1861
+ let { windowHeight, windowWidth } = this.qg.getSystemInfoSync();
1862
+ let style = null;
1863
+ let bannerHeight = null;
1864
+ if (YCSDK.ins.vertical()) {
1865
+ bannerHeight = windowWidth / 5;
1866
+ style = {
1867
+ top: windowHeight - bannerHeight,
1868
+ left: 0,
1869
+ width: windowWidth,
1870
+ height: bannerHeight
1871
+ };
1872
+ } else {
1873
+ bannerHeight = windowHeight / 5;
1874
+ style = {
1875
+ top: windowHeight - bannerHeight,
1876
+ left: (windowWidth - windowHeight) / 2,
1877
+ width: windowHeight,
1878
+ height: bannerHeight
1879
+ };
1880
+ }
1881
+ let nativeAdvanceAd = this.qg.createNativeAdvanceAd({
1882
+ adUnitId: sdkconfig.ycNativeBannerId,
1883
+ style
1884
+ });
1885
+ nativeAdvanceAd.load().then(() => {
1886
+ console.log("promise \u56DE\u8C03\uFF1A\u52A0\u8F7D\u6210\u529F");
1887
+ }).catch((err) => {
1888
+ console.log(`promise \u56DE\u8C03\uFF1A\u52A0\u8F7D\u5931\u8D25 ${JSON.stringify(err)}`);
1889
+ });
1890
+ nativeAdvanceAd.onLoad(function(res) {
1891
+ console.log(`\u539F\u751F\u5E7F\u544A2.0\u52A0\u8F7D\u56DE\u8C03, code: ${res.code}, msg: ${res.msg}, adList:${JSON.stringify(res.adList)}`);
1892
+ YCSDK.ins.onLoad("NativeBanner" /* NativeBanner */);
1893
+ if (res.code === 0 && res.adList && res.adList.length > 0) {
1894
+ let _adId = res.adList[0].adId;
1895
+ console.log("\u83B7\u53D6\u5E7F\u544Aid: " + _adId);
1896
+ if (_adId) {
1897
+ try {
1898
+ let nativeAdvanceAdRect = nativeAdvanceAd.createComponent({
1899
+ adId: _adId,
1900
+ componentType: "Rect",
1901
+ style: {
1902
+ color: "#FFFFFFFF",
1903
+ borderRadius: 20,
1904
+ borderWidth: 4,
1905
+ borderColor: "#89FFFFFF",
1906
+ opacity: 1,
1907
+ left: 0,
1908
+ top: 0,
1909
+ width: windowWidth,
1910
+ height: bannerHeight
1911
+ }
1912
+ });
1913
+ console.log(
1914
+ "\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 Rect, \u83B7\u53D6\u7EC4\u4EF6ID\uFF1A ",
1915
+ nativeAdvanceAdRect.getComponentId()
1916
+ );
1917
+ } catch (error) {
1918
+ console.log("\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 Rect \u5F02\u5E38,\u8BF7\u68C0\u67E5\u53C2\u6570");
1919
+ }
1920
+ try {
1921
+ let nativeAdvanceAdImage = nativeAdvanceAd.createComponent({
1922
+ adId: _adId,
1923
+ componentType: "AdImage",
1924
+ style: {
1925
+ imageStyle: "icon",
1926
+ width: windowWidth / 5 - 30,
1927
+ height: bannerHeight - 30,
1928
+ borderRadius: 20,
1929
+ left: 15,
1930
+ top: 15
1931
+ }
1932
+ });
1933
+ console.log("\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 AdImage, \u83B7\u53D6\u7EC4\u4EF6ID\uFF1A ", nativeAdvanceAdImage.getComponentId());
1934
+ } catch (error) {
1935
+ console.log("\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 AdImage \u5F02\u5E38,\u8BF7\u68C0\u67E5\u53C2\u6570");
1936
+ }
1937
+ try {
1938
+ let adTextComponent = nativeAdvanceAd.createComponent({
1939
+ adId: _adId,
1940
+ componentType: "AdText",
1941
+ style: {
1942
+ textStyle: "title",
1943
+ color: "#000000",
1944
+ fontSize: 18,
1945
+ top: bannerHeight / 4,
1946
+ left: windowWidth / 5 + 20,
1947
+ width: windowWidth / 2,
1948
+ height: bannerHeight / 2
1949
+ }
1950
+ });
1951
+ console.log("\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 AdText, \u83B7\u53D6\u7EC4\u4EF6ID\uFF1A ", adTextComponent.getComponentId());
1952
+ } catch {
1953
+ console.log("\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 AdText \u5F02\u5E38,\u8BF7\u68C0\u67E5\u53C2\u6570");
1954
+ }
1955
+ try {
1956
+ let nativeAdvanceAdButton = nativeAdvanceAd.createComponent({
1957
+ adId: _adId,
1958
+ componentType: "AdButton",
1959
+ style: {
1960
+ left: windowWidth - windowWidth / 3,
1961
+ top: bannerHeight / 3,
1962
+ opacity: 1
1963
+ }
1964
+ });
1965
+ console.log(
1966
+ "\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 AdButton, \u83B7\u53D6\u7EC4\u4EF6ID\uFF1A ",
1967
+ nativeAdvanceAdButton.getComponentId()
1968
+ );
1969
+ } catch (error) {
1970
+ console.log("\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 AdButton \u5F02\u5E38,\u8BF7\u68C0\u67E5\u53C2\u6570");
1971
+ }
1972
+ try {
1973
+ let nativeAdvanceAdCloseButton = nativeAdvanceAd.createComponent({
1974
+ adId: _adId,
1975
+ componentType: "AdCloseButton",
1976
+ style: {
1977
+ closeStyle: "topRight"
1978
+ }
1979
+ });
1980
+ console.log(
1981
+ "\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 AdCloseButton, \u83B7\u53D6\u7EC4\u4EF6ID\uFF1A ",
1982
+ nativeAdvanceAdCloseButton.getComponentId()
1983
+ );
1984
+ } catch (error) {
1985
+ console.log("\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 AdCloseButton \u5F02\u5E38,\u8BF7\u68C0\u67E5\u53C2\u6570");
1986
+ }
1987
+ try {
1988
+ let nativeAdvanceAdLogo = nativeAdvanceAd.createComponent({
1989
+ adId: _adId,
1990
+ componentType: "AdLogo",
1991
+ style: {
1992
+ left: windowWidth - 80,
1993
+ top: bannerHeight - 30
1994
+ }
1995
+ });
1996
+ console.log(
1997
+ "\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 AdLogo, \u83B7\u53D6\u7EC4\u4EF6ID\uFF1A ",
1998
+ nativeAdvanceAdLogo.getComponentId()
1999
+ );
2000
+ } catch (error) {
2001
+ console.log("\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 AdLogo \u5F02\u5E38,\u8BF7\u68C0\u67E5\u53C2\u6570");
2002
+ }
2003
+ try {
2004
+ let nativeAdvanceAdPrivacy = nativeAdvanceAd.createComponent({
2005
+ adId: _adId,
2006
+ componentType: "AdPrivacy",
2007
+ style: {
2008
+ privacyStyle: "light",
2009
+ fontSize: 12
2010
+ }
2011
+ });
2012
+ console.log("\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 AdPrivacy, \u83B7\u53D6\u7EC4\u4EF6ID\uFF1A ", nativeAdvanceAdPrivacy.getComponentId());
2013
+ } catch (error) {
2014
+ console.log("\u5C1D\u8BD5\u521B\u5EFA\u7EC4\u4EF6 AdPrivacy \u5F02\u5E38,\u8BF7\u68C0\u67E5\u53C2\u6570");
2015
+ }
2016
+ nativeAdvanceAd.show({ adId: _adId }).then(() => {
2017
+ console.log("promise \u56DE\u8C03\uFF1A\u5C55\u793A\u6210\u529F");
2018
+ }).catch((err) => {
2019
+ console.log(`promise \u56DE\u8C03\uFF1A\u5C55\u793A\u5931\u8D25 ${JSON.stringify(err)}`);
2020
+ nativeAdvanceAd.destroy();
2021
+ });
2022
+ }
2023
+ }
2024
+ });
2025
+ nativeAdvanceAd.onCreateComponentSucc(function(res) {
2026
+ console.log(`\u521B\u5EFA\u539F\u751F\u5E7F\u544A2.0\u7EC4\u4EF6\u6210\u529F\u56DE\u8C03, code: ${res.code}, msg: ${res.msg},adId: ${res.adId}, \u7EC4\u4EF6ID: ${res.componentId}`);
2027
+ });
2028
+ nativeAdvanceAd.onShow(function(res) {
2029
+ console.log(`\u539F\u751F\u5E7F\u544A2.0\u5C55\u793A\u56DE\u8C03, code: ${res.code}, msg: ${res.msg}`);
2030
+ YCSDK.ins.onShow("NativeBanner" /* NativeBanner */);
2031
+ });
2032
+ nativeAdvanceAd.onError(function(err) {
2033
+ console.log(`\u539F\u751F\u5E7F\u544A2.0\u9519\u8BEF\u56DE\u8C03 : ${JSON.stringify(err)}`);
2034
+ YCSDK.ins.onError("NativeBanner" /* NativeBanner */);
2035
+ });
2036
+ nativeAdvanceAd.onClose((res) => {
2037
+ console.log(`\u539F\u751F\u5E7F\u544A2.0\u5173\u95ED\u56DE\u8C03, code: ${res.code}, msg: ${res.msg}`);
2038
+ YCSDK.ins.onClose("NativeBanner" /* NativeBanner */);
2039
+ nativeAdvanceAd.destroy();
2040
+ });
2041
+ }
1822
2042
  customFunc(methodName, params, callBack) {
1823
2043
  console.log("oppo custom function name:", methodName);
1824
2044
  }
@@ -2454,12 +2674,12 @@ var MiniGame = class {
2454
2674
  jsonToKeyValue(json) {
2455
2675
  return Object.entries(json).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join("&");
2456
2676
  }
2457
- init(callBack, adconfig) {
2677
+ init(callBack, adconfig, config) {
2458
2678
  if (!adconfig) adconfig = { switch: false, count: 0, delay: 0 };
2679
+ if (!config) config = { switch: false, type: 0, loop: 0 };
2459
2680
  if (!YCSDK.ins.isRun(sys6.Platform.OPPO_MINI_GAME)) {
2460
2681
  this.setAdStateListener();
2461
- adconfig.switch = false;
2462
- this.channel.init(callBack, adconfig);
2682
+ this.channel.init(callBack, adconfig, config);
2463
2683
  return;
2464
2684
  }
2465
2685
  const url = "https://iaa.rhino-times.com/api/game/query-match-config";
@@ -2469,8 +2689,7 @@ var MiniGame = class {
2469
2689
  HttpRequest.get().requestPostjson(url, data, (success, result) => {
2470
2690
  if (!success || !result) {
2471
2691
  this.setAdStateListener();
2472
- adconfig.switch = false;
2473
- this.channel.init(callBack, adconfig);
2692
+ this.channel.init(callBack, adconfig, config);
2474
2693
  return;
2475
2694
  }
2476
2695
  const res = result.oexts;
@@ -2480,8 +2699,11 @@ var MiniGame = class {
2480
2699
  if (res.subornVideoConfig) {
2481
2700
  adconfig = res.subornVideoConfig;
2482
2701
  }
2702
+ if (res.subornNativeConfig) {
2703
+ config = res.subornNativeConfig;
2704
+ }
2483
2705
  this.setAdStateListener();
2484
- this.channel.init(callBack, adconfig);
2706
+ this.channel.init(callBack, adconfig, config);
2485
2707
  });
2486
2708
  }
2487
2709
  setAdStateListener() {
@@ -2648,7 +2870,7 @@ var YCSDK = class _YCSDK {
2648
2870
  isRun(platform) {
2649
2871
  return sys7.platform == platform;
2650
2872
  }
2651
- init(config, callBack, adconfig) {
2873
+ init(config, callBack, adconfig, cf) {
2652
2874
  console.log("ycsdk init");
2653
2875
  if (!config) {
2654
2876
  console.log("ycsdk init fail, config is null");
@@ -2663,7 +2885,7 @@ var YCSDK = class _YCSDK {
2663
2885
  sdkconfig.videoId = config.videoId;
2664
2886
  sdkconfig.nativeBannerId = config.nativeBannerId;
2665
2887
  sdkconfig.extension = config.extension;
2666
- this.platform.init(callBack, adconfig);
2888
+ this.platform.init(callBack, adconfig, cf);
2667
2889
  }
2668
2890
  agreePrivacy() {
2669
2891
  if (this.isRun(sys7.Platform.ANDROID)) {