@jolibox/ads 1.1.39 → 1.1.41-beta.1

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.
@@ -18,6 +18,7 @@ export declare class InterstitialAdManager {
18
18
  private adsContext;
19
19
  private gamingInterstitialSlot;
20
20
  private readyEvent;
21
+ private isRetrying;
21
22
  constructor(adUnit: string, project: 'minigame-h5' | 'minidrama-h5' | 'minigame-app' | 'minidrama-app', keyValue?: Record<string, string>);
22
23
  withCommand: (...itmes: (() => void)[]) => void;
23
24
  /**
@@ -26,7 +27,7 @@ export declare class InterstitialAdManager {
26
27
  * The init function will potentially request an ad in the background.
27
28
  */
28
29
  private init;
29
- destroy: (endReason: EndReason) => void;
30
+ destroy: (endReason: EndReason, clearContext?: boolean) => void;
30
31
  /**
31
32
  * Destroy the interstitial ad and cleans up resources.
32
33
  *
@@ -35,7 +36,7 @@ export declare class InterstitialAdManager {
35
36
  *
36
37
  * @param endReason The reason for ending the ad.
37
38
  */
38
- reinit: (endReason: EndReason) => void;
39
+ reinit: (endReason: EndReason, clearContext?: boolean) => void;
39
40
  private handleSlotReady;
40
41
  private handleSlotClosed;
41
42
  /**
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ var bt = (t, e) => {
11
11
  };
12
12
  import { options as ue, Component as Ri, isValidElement as Oi } from "preact";
13
13
  import { useRef as Ti, useLayoutEffect as Ci, useEffect as Ve, useMemo as Di, useState as zt, useCallback as Li, render as re, createRef as _t } from "preact/compat";
14
- function B(t, e, i) {
14
+ function F(t, e, i) {
15
15
  return (e = Pi(e)) in t ? Object.defineProperty(t, e, { value: i, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = i, t;
16
16
  }
17
17
  function Pi(t) {
@@ -32,7 +32,7 @@ function Ni(t, e) {
32
32
  }
33
33
  class Mi {
34
34
  constructor(e) {
35
- B(this, "context", void 0), B(this, "continueCallback", void 0), B(this, "adIsShowingCallback", void 0), B(this, "isBeforeAdCalled", !1), B(this, "isBeforeRewardCalled", !1), B(this, "isAdDismissedCalled", !1), B(this, "isAdViewedCalled", !1), B(this, "isAfterAdCalled", !1), B(this, "currentProvider", void 0), B(this, "currentClientParams", void 0), B(this, "adsHasResponse", !1), B(this, "videoChecker", window.document.createElement("video")), B(this, "wrapShowAdFn", (i) => () => {
35
+ F(this, "context", void 0), F(this, "continueCallback", void 0), F(this, "adIsShowingCallback", void 0), F(this, "isBeforeAdCalled", !1), F(this, "isBeforeRewardCalled", !1), F(this, "isAdDismissedCalled", !1), F(this, "isAdViewedCalled", !1), F(this, "isAfterAdCalled", !1), F(this, "currentProvider", void 0), F(this, "currentClientParams", void 0), F(this, "adsHasResponse", !1), F(this, "videoChecker", window.document.createElement("video")), F(this, "wrapShowAdFn", (i) => () => {
36
36
  var r;
37
37
  this.adsHasResponse = !0;
38
38
  let n = !1;
@@ -965,7 +965,7 @@ function Te(t, e) {
965
965
  function Nn(t, e) {
966
966
  return t.map(e).join("");
967
967
  }
968
- var ze = 1, ce = 1, ii = 0, U = 0, R = 0, he = "";
968
+ var ze = 1, ce = 1, ii = 0, B = 0, R = 0, he = "";
969
969
  function qe(t, e, i, n, r, o, s) {
970
970
  return { value: t, root: e, parent: i, type: n, props: r, children: o, line: ze, column: ce, length: s, return: "" };
971
971
  }
@@ -976,16 +976,16 @@ function Mn() {
976
976
  return R;
977
977
  }
978
978
  function $n() {
979
- return R = U > 0 ? D(he, --U) : 0, ce--, R === 10 && (ce = 1, ze--), R;
979
+ return R = B > 0 ? D(he, --B) : 0, ce--, R === 10 && (ce = 1, ze--), R;
980
980
  }
981
981
  function G() {
982
- return R = U < ii ? D(he, U++) : 0, ce++, R === 10 && (ce = 1, ze++), R;
982
+ return R = B < ii ? D(he, B++) : 0, ce++, R === 10 && (ce = 1, ze++), R;
983
983
  }
984
984
  function Y() {
985
- return D(he, U);
985
+ return D(he, B);
986
986
  }
987
987
  function De() {
988
- return U;
988
+ return B;
989
989
  }
990
990
  function ke(t, e) {
991
991
  return Se(he, t, e);
@@ -1023,13 +1023,13 @@ function Ee(t) {
1023
1023
  return 0;
1024
1024
  }
1025
1025
  function ni(t) {
1026
- return ze = ce = 1, ii = J(he = t), U = 0, [];
1026
+ return ze = ce = 1, ii = J(he = t), B = 0, [];
1027
1027
  }
1028
1028
  function ri(t) {
1029
1029
  return he = "", t;
1030
1030
  }
1031
1031
  function Le(t) {
1032
- return ti(ke(U - 1, st(t === 91 ? t + 2 : t === 40 ? t + 1 : t)));
1032
+ return ti(ke(B - 1, st(t === 91 ? t + 2 : t === 40 ? t + 1 : t)));
1033
1033
  }
1034
1034
  function jn(t) {
1035
1035
  for (; (R = Y()) && R < 33; )
@@ -1045,7 +1045,7 @@ function st(t) {
1045
1045
  for (; G(); )
1046
1046
  switch (R) {
1047
1047
  case t:
1048
- return U;
1048
+ return B;
1049
1049
  case 34:
1050
1050
  case 39:
1051
1051
  t !== 34 && t !== 39 && st(R);
@@ -1057,18 +1057,18 @@ function st(t) {
1057
1057
  G();
1058
1058
  break;
1059
1059
  }
1060
- return U;
1060
+ return B;
1061
1061
  }
1062
1062
  function Bn(t, e) {
1063
1063
  for (; G() && t + R !== 57; )
1064
1064
  if (t + R === 84 && Y() === 47)
1065
1065
  break;
1066
- return "/*" + ke(e, U - 1) + "*" + Ge(t === 47 ? t : G());
1066
+ return "/*" + ke(e, B - 1) + "*" + Ge(t === 47 ? t : G());
1067
1067
  }
1068
1068
  function Fn(t) {
1069
1069
  for (; !Ee(Y()); )
1070
1070
  G();
1071
- return ke(t, U);
1071
+ return ke(t, B);
1072
1072
  }
1073
1073
  function Vn(t) {
1074
1074
  return ri(Pe("", null, null, null, [""], t = ni(t), 0, [0], t));
@@ -1218,13 +1218,13 @@ function Hn(t) {
1218
1218
  var Wn = function(e, i, n) {
1219
1219
  for (var r = 0, o = 0; r = o, o = Y(), r === 38 && o === 12 && (i[n] = 1), !Ee(o); )
1220
1220
  G();
1221
- return ke(e, U);
1221
+ return ke(e, B);
1222
1222
  }, Jn = function(e, i) {
1223
1223
  var n = -1, r = 44;
1224
1224
  do
1225
1225
  switch (Ee(r)) {
1226
1226
  case 0:
1227
- r === 38 && Y() === 12 && (i[n] = 1), e[n] += Wn(U - 1, i, n);
1227
+ r === 38 && Y() === 12 && (i[n] = 1), e[n] += Wn(B - 1, i, n);
1228
1228
  break;
1229
1229
  case 2:
1230
1230
  e[n] += Le(r);
@@ -3028,10 +3028,9 @@ class ki {
3028
3028
  });
3029
3029
  else {
3030
3030
  const o = (s) => {
3031
- var a, d;
3032
- s.slot === this.rewardedSlot && this.adsContext && (googletag.pubads().removeEventListener("rewardedSlotReady", o), this.readyEvent = s, (d = (a = this.adsContext).beforeAd) == null || d.call(a), this.adsContext.beforeReward(() => {
3033
- var l;
3034
- (l = this.readyEvent) == null || l.makeRewardedVisible();
3031
+ s.slot === this.rewardedSlot && this.adsContext && (googletag.pubads().removeEventListener("rewardedSlotReady", o), this.readyEvent = s, this.adsContext.beforeReward(() => {
3032
+ var a, d, l;
3033
+ (d = (a = this.adsContext) == null ? void 0 : a.beforeAd) == null || d.call(a), (l = this.readyEvent) == null || l.makeRewardedVisible();
3035
3034
  }));
3036
3035
  };
3037
3036
  googletag.pubads().addEventListener("rewardedSlotReady", o), window.setTimeout(() => {
@@ -3044,7 +3043,7 @@ class ki {
3044
3043
  });
3045
3044
  }
3046
3045
  }
3047
- function F(t, e, i) {
3046
+ function U(t, e, i) {
3048
3047
  return (e = Fr(e)) in t ? Object.defineProperty(t, e, { value: i, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = i, t;
3049
3048
  }
3050
3049
  function Fr(t) {
@@ -3065,34 +3064,40 @@ function Vr(t, e) {
3065
3064
  }
3066
3065
  class Gr {
3067
3066
  constructor(e, i, n) {
3068
- F(this, "adUnit", void 0), F(this, "project", void 0), F(this, "keyValue", void 0), F(this, "adsContext", null), F(this, "gamingInterstitialSlot", null), F(this, "readyEvent", null), F(this, "withCommand", function() {
3067
+ var r = this;
3068
+ U(this, "adUnit", void 0), U(this, "project", void 0), U(this, "keyValue", void 0), U(this, "adsContext", null), U(this, "gamingInterstitialSlot", null), U(this, "readyEvent", null), U(this, "isRetrying", !1), U(this, "withCommand", function() {
3069
3069
  googletag.cmd.push(...arguments);
3070
- }), F(this, "init", () => {
3071
- var r;
3072
- this.gamingInterstitialSlot = googletag.defineOutOfPageSlot(this.adUnit, googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL), this.gamingInterstitialSlot && (this.gamingInterstitialSlot.addService(googletag.pubads()), googletag.pubads().addEventListener("gameManualInterstitialSlotReady", this.handleSlotReady), googletag.pubads().addEventListener("gameManualInterstitialSlotClosed", this.handleSlotClosed), this.keyValue && (Object.keys(this.keyValue).forEach((o) => {
3073
- var s;
3074
- (s = this.gamingInterstitialSlot) == null || s.setTargeting(o, this.keyValue[o]);
3075
- }), Object.keys(this.keyValue).includes("project") || (r = this.gamingInterstitialSlot) == null || r.setTargeting("project", this.project)), googletag.display(this.gamingInterstitialSlot));
3076
- }), F(this, "destroy", (r) => {
3077
- var o, s;
3078
- (s = (o = this.adsContext) == null ? void 0 : o.onEnd) == null || s.call(o, r), this.adsContext = null, googletag.pubads().removeEventListener("gameManualInterstitialSlotReady", this.handleSlotReady), googletag.pubads().removeEventListener("gameManualInterstitialSlotClosed", this.handleSlotClosed), this.gamingInterstitialSlot && (googletag.destroySlots([this.gamingInterstitialSlot]), this.gamingInterstitialSlot = null, this.readyEvent = null);
3079
- }), F(this, "reinit", (r) => {
3080
- this.destroy(r), this.init();
3081
- }), F(this, "handleSlotReady", (r) => {
3082
- this.gamingInterstitialSlot === r.slot && (this.readyEvent = r);
3083
- }), F(this, "handleSlotClosed", (r) => {
3084
- var o, s;
3085
- this.adsContext && this.gamingInterstitialSlot === r.slot && ((s = (o = this.adsContext).afterAd) == null || s.call(o), this.withCommand(() => {
3070
+ }), U(this, "init", () => {
3071
+ var o;
3072
+ this.gamingInterstitialSlot = googletag.defineOutOfPageSlot(this.adUnit, googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL), this.gamingInterstitialSlot && (this.gamingInterstitialSlot.addService(googletag.pubads()), googletag.pubads().addEventListener("gameManualInterstitialSlotReady", this.handleSlotReady), googletag.pubads().addEventListener("gameManualInterstitialSlotClosed", this.handleSlotClosed), this.keyValue && (Object.keys(this.keyValue).forEach((s) => {
3073
+ var a;
3074
+ (a = this.gamingInterstitialSlot) == null || a.setTargeting(s, this.keyValue[s]);
3075
+ }), Object.keys(this.keyValue).includes("project") || (o = this.gamingInterstitialSlot) == null || o.setTargeting("project", this.project)), googletag.display(this.gamingInterstitialSlot));
3076
+ }), U(this, "destroy", function(o) {
3077
+ var a, d;
3078
+ (arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0) && ((d = (a = r.adsContext) == null ? void 0 : a.onEnd) == null || d.call(a, o), r.adsContext = null), googletag.pubads().removeEventListener("gameManualInterstitialSlotReady", r.handleSlotReady), googletag.pubads().removeEventListener("gameManualInterstitialSlotClosed", r.handleSlotClosed), r.gamingInterstitialSlot && (googletag.destroySlots([r.gamingInterstitialSlot]), r.gamingInterstitialSlot = null, r.readyEvent = null);
3079
+ }), U(this, "reinit", function(o) {
3080
+ let s = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0;
3081
+ r.destroy(o, s), r.init();
3082
+ }), U(this, "handleSlotReady", (o) => {
3083
+ this.gamingInterstitialSlot === o.slot && (this.readyEvent = o);
3084
+ }), U(this, "handleSlotClosed", (o) => {
3085
+ var s, a;
3086
+ this.adsContext && this.gamingInterstitialSlot === o.slot && ((a = (s = this.adsContext).afterAd) == null || a.call(s), this.withCommand(() => {
3086
3087
  this.reinit("viewed");
3087
3088
  }));
3088
- }), F(this, "requestAds", (r) => {
3089
+ }), U(this, "requestAds", (o) => {
3089
3090
  this.withCommand(() => {
3090
- var o, s, a;
3091
- if (this.adsContext && this.reinit("ignored"), this.gamingInterstitialSlot || this.init(), this.adsContext = r, !this.gamingInterstitialSlot) {
3091
+ var s, a, d;
3092
+ if (this.adsContext && this.reinit("ignored"), this.gamingInterstitialSlot || this.init(), this.adsContext = o, !this.gamingInterstitialSlot) {
3092
3093
  this.reinit("notReady");
3093
3094
  return;
3094
3095
  }
3095
- this.readyEvent ? ((o = r.beforeAd) == null || o.call(r), this.readyEvent.makeGameManualInterstitialVisible()) : ((a = (s = this.adsContext).onEnd) == null || a.call(s, "frequencyCapped"), this.adsContext = null, googletag.pubads().refresh([this.gamingInterstitialSlot]));
3096
+ this.readyEvent ? ((s = o.beforeAd) == null || s.call(o), this.readyEvent.makeGameManualInterstitialVisible()) : ((d = (a = this.adsContext).onEnd) == null || d.call(a, "frequencyCapped"), this.adsContext = null, this.isRetrying || (this.isRetrying = !0, window.setTimeout(() => {
3097
+ this.readyEvent || this.withCommand(() => {
3098
+ this.reinit("frequencyCapped", !1);
3099
+ }), this.isRetrying = !1;
3100
+ }, 31e3)));
3096
3101
  });
3097
3102
  }), Ei(), this.adUnit = e, this.project = i, this.keyValue = n, this.withCommand(() => {
3098
3103
  this.init();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jolibox/ads",
3
3
  "description": "This project is for integrating Jolibox ads providers",
4
- "version": "1.1.39",
4
+ "version": "1.1.41-beta.1",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
7
7
  "type": "module",
@@ -12,9 +12,9 @@
12
12
  ],
13
13
  "types": "./dist/index.d.ts",
14
14
  "dependencies": {
15
- "@jolibox/common": "1.1.39",
15
+ "@jolibox/common": "1.1.41-beta.1",
16
16
  "@emotion/css": "11.13.5",
17
- "@jolibox/types": "1.1.39",
17
+ "@jolibox/types": "1.1.41-beta.1",
18
18
  "preact": "10.26.4",
19
19
  "@preact/signals": "2.0.4"
20
20
  },