@logora/debate 0.4.101 → 0.4.102

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.
@@ -1,42 +1,86 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- import { useEffect as m } from "react";
3
- import r from "./AdUnit.module.scss.js";
4
- const v = ({
5
- id: n,
6
- adPath: s,
7
- sizes: a = [],
8
- targeting: l,
9
- enableDidomi: g = !1
1
+ import { jsx as g } from "react/jsx-runtime";
2
+ import { useRef as w, useEffect as R } from "react";
3
+ import v from "./AdUnit.module.scss.js";
4
+ const E = 3e4, x = ({
5
+ id: c,
6
+ adPath: a,
7
+ sizes: L = [],
8
+ targeting: N,
9
+ enableDidomi: I = !1,
10
+ refresh: f = !1,
11
+ refreshInterval: m = E
10
12
  }) => {
11
- if (!n || !s)
12
- return null;
13
- const e = `div-gpt-ad-${n}`;
14
- return m(() => {
15
- if (typeof window < "u" && e && s) {
16
- const o = window.googletag || (window.googletag = { cmd: [] });
17
- let i;
18
- return o.cmd.push(() => {
19
- i = o.defineSlot(s, a, e).setTargeting("origine", ["logora"]).addService(o.pubads());
20
- for (const [d, c] of Object.entries(l || {}))
21
- i.setTargeting(d, c);
22
- o.display(e), o.pubads().refresh([i]);
23
- }), () => {
24
- const d = window.googletag || { cmd: [] };
25
- d.cmd.push(() => {
26
- d.destroySlots([i]);
27
- });
28
- };
29
- }
30
- }, []), g === !0 ? /* @__PURE__ */ t(
13
+ const r = `div-gpt-ad-${c}`, o = w(null), s = w(null), p = w(!1), h = w(null);
14
+ return R(() => {
15
+ if (typeof window > "u" || !c || !a)
16
+ return;
17
+ const t = window.googletag || (window.googletag = { cmd: [] });
18
+ let b = !1;
19
+ return t.cmd.push(() => {
20
+ if (b)
21
+ return;
22
+ const n = t.pubads(), l = n.getSlots().filter((e) => e.getSlotElementId() === r);
23
+ l.length > 0 && t.destroySlots(l);
24
+ const i = t.defineSlot(a, L, r);
25
+ if (i) {
26
+ i.setTargeting("origine", ["logora"]);
27
+ for (const [e, u] of Object.entries(N || {}))
28
+ i.setTargeting(e, u);
29
+ i.setConfig({ collapseDiv: "ON_NO_FILL" }), i.addService(n), o.current = i, t.display(r), n.isInitialLoadDisabled() && n.refresh([i]);
30
+ }
31
+ }), () => {
32
+ b = !0;
33
+ const n = o.current;
34
+ o.current = null, !(typeof window > "u" || !window.googletag || !n) && window.googletag.cmd.push(() => {
35
+ window.googletag.destroySlots([n]);
36
+ });
37
+ };
38
+ }, [c, a]), R(() => {
39
+ const t = h.current, n = t !== null && t.divId === r && f === !0 && (t.refresh !== !0 || t.refreshInterval !== m);
40
+ if (h.current = { refresh: f, refreshInterval: m, divId: r }, typeof window > "u" || f !== !0 || !c || !a)
41
+ return;
42
+ const l = window.googletag || (window.googletag = { cmd: [] }), i = Math.max(m, E);
43
+ let e = !1, u = null;
44
+ const T = () => {
45
+ const d = o.current;
46
+ e || !d || l.cmd.push(() => {
47
+ e || l.pubads().refresh([d]);
48
+ });
49
+ }, y = () => {
50
+ e || s.current || (s.current = setTimeout(() => {
51
+ if (s.current = null, !(e || !o.current)) {
52
+ if (document.visibilityState !== "visible") {
53
+ p.current = !0;
54
+ return;
55
+ }
56
+ T();
57
+ }
58
+ }, i));
59
+ }, S = () => {
60
+ document.visibilityState === "visible" && p.current && !e && (p.current = !1, y());
61
+ };
62
+ return l.cmd.push(() => {
63
+ e || !o.current || (u = (d) => {
64
+ d.slot !== o.current || s.current || y();
65
+ }, l.pubads().addEventListener("impressionViewable", u), n && document.visibilityState === "visible" && y());
66
+ }), document.addEventListener("visibilitychange", S), () => {
67
+ e = !0, s.current && (clearTimeout(s.current), s.current = null), p.current = !1;
68
+ const d = u;
69
+ u = null, document.removeEventListener("visibilitychange", S), !(typeof window > "u" || !window.googletag || !d) && window.googletag.cmd.push(() => {
70
+ window.googletag.pubads().removeEventListener("impressionViewable", d);
71
+ });
72
+ };
73
+ }, [f, m, r]), !c || !a ? null : I === !0 ? /* @__PURE__ */ g(
31
74
  "script",
32
75
  {
33
76
  type: "didomi/html",
34
77
  "data-vendor": "didomi:google",
35
78
  "data-purposes": "cookies",
36
- children: /* @__PURE__ */ t("div", { className: r.adContainer, children: /* @__PURE__ */ t("div", { className: r.adUnit, id: e }) })
79
+ children: /* @__PURE__ */ g("div", { className: v.adContainer, children: /* @__PURE__ */ g("div", { className: v.adUnit, id: r }) })
37
80
  }
38
- ) : /* @__PURE__ */ t("div", { className: r.adContainer, children: /* @__PURE__ */ t("div", { className: r.adUnit, id: e }) });
81
+ ) : /* @__PURE__ */ g("div", { className: v.adContainer, children: /* @__PURE__ */ g("div", { className: v.adUnit, id: r }) });
39
82
  };
40
83
  export {
41
- v as AdUnit
84
+ x as AdUnit,
85
+ E as MIN_REFRESH_INTERVAL
42
86
  };
@@ -1,22 +1,30 @@
1
- import { useEffect as i } from "react";
2
- const n = (o = !0, s = !1, d = 8e3) => (i(() => {
3
- if (o === !0 && typeof window < "u") {
4
- if (!window.googletag?.apiReady) {
5
- const e = document.createElement("script");
6
- e.src = "https://securepubads.g.doubleclick.net/tag/js/gpt.js", e.async = !0, s === !0 && (e.type = "didomi/javascript", e.setAttribute("data-vendor-raw", "didomi:google"), e.setAttribute("data-purposes", "cookies")), document.body.appendChild(e);
7
- }
8
- const t = window.googletag || (window.googletag = { cmd: [] });
9
- t.cmd.push(() => {
10
- t.pubads().enableSingleRequest(), t.pubads().disableInitialLoad(), t.enableServices(), t.pubads().addEventListener("impressionViewable", (e) => {
11
- setTimeout(() => {
12
- t.cmd.push(() => {
13
- t.pubads().refresh([e.slot]);
14
- });
15
- }, d);
16
- });
17
- });
18
- }
1
+ import { useLayoutEffect as r, useEffect as n } from "react";
2
+ const s = "https://securepubads.g.doubleclick.net/tag/js/gpt.js", i = () => {
3
+ if (typeof window > "u" || typeof document > "u" || window.googletag && window.googletag.apiReady)
4
+ return !0;
5
+ const t = document.querySelectorAll("script[src]");
6
+ for (const e of t)
7
+ if (/\/gpt\.js(\?|$)/.test(e.src))
8
+ return !0;
9
+ return !1;
10
+ }, u = (t = !1) => {
11
+ if (i())
12
+ return !1;
13
+ const e = document.createElement("script");
14
+ return e.src = s, e.async = !0, t === !0 && (e.type = "didomi/javascript", e.setAttribute("data-vendor-raw", "didomi:google"), e.setAttribute("data-purposes", "cookies")), document.body.appendChild(e), !0;
15
+ };
16
+ let o = !1;
17
+ const c = () => {
18
+ if (typeof window > "u" || o)
19
+ return;
20
+ const t = window.googletag || (window.googletag = { cmd: [] });
21
+ o = !0, t.cmd.push(() => {
22
+ t.enableServices();
23
+ });
24
+ }, d = typeof window < "u" ? r : n, a = (t = !0, e = !1) => (d(() => {
25
+ t !== !0 || typeof window > "u" || u(e) && c();
19
26
  }, []), null);
20
27
  export {
21
- n as useGoogleAdManager
28
+ s as GPT_SRC,
29
+ a as useGoogleAdManager
22
30
  };
@@ -1,29 +1,33 @@
1
- import { jsxs as l, Fragment as p, jsx as i } from "react/jsx-runtime";
2
- import j from "react";
3
- import { AdUnit as A } from "../ad_unit/AdUnit.js";
4
- const h = ({
1
+ import { jsxs as i, Fragment as a, jsx as j } from "react/jsx-runtime";
2
+ import A from "react";
3
+ import { AdUnit as $ } from "../ad_unit/AdUnit.js";
4
+ const x = ({
5
5
  id: r,
6
6
  adPath: o,
7
- targeting: m,
8
- sizes: e,
7
+ targeting: e,
8
+ sizes: m,
9
9
  index: t,
10
- frequency: n = 3,
11
- enableDidomi: s = !1,
10
+ frequency: s = 3,
11
+ enableDidomi: f = !1,
12
+ refresh: l = !1,
13
+ refreshInterval: n,
12
14
  children: c,
13
- ...f
14
- }) => /* @__PURE__ */ l(p, { children: [
15
- j.cloneElement(c, f),
16
- r && o && (t + 1) % n === 1 && /* @__PURE__ */ i(
17
- A,
15
+ ...p
16
+ }) => /* @__PURE__ */ i(a, { children: [
17
+ A.cloneElement(c, p),
18
+ r && o && (t + 1) % s === 1 && /* @__PURE__ */ j(
19
+ $,
18
20
  {
19
21
  id: t ? `${r}-${t}` : r,
20
22
  adPath: o,
21
- targeting: m,
22
- sizes: e,
23
- enableDidomi: s
23
+ targeting: e,
24
+ sizes: m,
25
+ enableDidomi: f,
26
+ refresh: l,
27
+ refreshInterval: n
24
28
  }
25
29
  )
26
30
  ] });
27
31
  export {
28
- h as WithAd
32
+ x as WithAd
29
33
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logora/debate",
3
- "version": "0.4.101",
3
+ "version": "0.4.102",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0",
6
6
  "description": "Design system of @Logora made with React",