@dotcms/analytics 1.2.1-next.1 → 1.2.1-next.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.
@@ -11,8 +11,7 @@ class v {
11
11
  updateActivityTime() {
12
12
  this.lastActivityTime = Date.now(), this.inactivityTimer && clearTimeout(this.inactivityTimer), this.inactivityTimer = setTimeout(
13
13
  () => {
14
- var i;
15
- (i = this.config) != null && i.debug && console.warn("DotCMS Analytics [Activity]: User became inactive after timeout"), this.inactivityTimer = null;
14
+ this.config?.debug && console.warn("DotCMS Analytics [Activity]: User became inactive after timeout"), this.inactivityTimer = null;
16
15
  },
17
16
  r * 60 * 1e3
18
17
  );
@@ -3,20 +3,20 @@ import v from "@analytics/router-utils";
3
3
  import { DEFAULT_QUEUE_CONFIG as y } from "../constants/dot-analytics.constants.js";
4
4
  import { sendAnalyticsEvent as b } from "../http/dot-analytics.http.js";
5
5
  import { createPluginLogger as w } from "../utils/dot-analytics.utils.js";
6
- const L = (o) => {
7
- const i = w("Queue", o);
8
- let e = null, n = null, u = !1, d = !1, f = typeof window < "u" ? window.location.pathname : "";
6
+ const L = (u) => {
7
+ const i = w("Queue", u);
8
+ let t = null, n = null, o = !1, d = !1, f = typeof window < "u" ? window.location.pathname : "";
9
9
  const a = {
10
10
  ...y,
11
- ...typeof o.queue == "object" ? o.queue : {}
12
- }, g = (t, s) => {
11
+ ...typeof u.queue == "object" ? u.queue : {}
12
+ }, g = (e, s) => {
13
13
  if (!n) return;
14
- i.debug(`Sending batch of ${t.length} event(s)`, {
15
- events: t,
16
- keepalive: u
17
- }), b({ context: n, events: t }, o, u);
14
+ i.debug(`Sending batch of ${e.length} event(s)`, {
15
+ events: e,
16
+ keepalive: o
17
+ }), b({ context: n, events: e }, u, o);
18
18
  }, l = () => {
19
- !e || e.size() === 0 || !n || (i.info(`Flushing ${e.size()} events (page hidden/unload)`), u = !0, e.flush(!0));
19
+ !t || t.size() === 0 || !n || (i.info(`Flushing ${t.size()} events (page hidden/unload)`), o = !0, t.flush(!0));
20
20
  }, c = () => {
21
21
  if (i.debug("handleVisibilityChange", document.visibilityState), document.visibilityState === "hidden") {
22
22
  if (d) {
@@ -31,9 +31,9 @@ const L = (o) => {
31
31
  * Initialize the queue with smart batching
32
32
  */
33
33
  initialize: () => {
34
- e = m(
35
- (t, s) => {
36
- g(t);
34
+ t = m(
35
+ (e, s) => {
36
+ g(e);
37
37
  },
38
38
  {
39
39
  max: a.eventBatchSize,
@@ -41,8 +41,8 @@ const L = (o) => {
41
41
  throttle: !1
42
42
  // Always false - enables both batch size and interval triggers
43
43
  }
44
- ), typeof window < "u" && typeof document < "u" && (document.addEventListener("visibilitychange", c), window.addEventListener("pagehide", l), v((t) => {
45
- d = !0, f = t, i.debug(`SPA navigation detected (${f})`), setTimeout(() => {
44
+ ), typeof window < "u" && typeof document < "u" && (document.addEventListener("visibilitychange", c), window.addEventListener("pagehide", l), v((e) => {
45
+ d = !0, f = e, i.debug(`SPA navigation detected (${f})`), setTimeout(() => {
46
46
  d = !1;
47
47
  }, 100);
48
48
  }));
@@ -53,25 +53,25 @@ const L = (o) => {
53
53
  * - Sends immediately when eventBatchSize reached (with throttle: false)
54
54
  * - Sends pending events every flushInterval
55
55
  */
56
- enqueue: (t, s) => {
57
- if (n = s, !e) return;
58
- const r = e.size() + 1, p = a.eventBatchSize, h = r >= p;
56
+ enqueue: (e, s) => {
57
+ if (n = s, !t) return;
58
+ const r = t.size() + 1, p = a.eventBatchSize, h = r >= p;
59
59
  i.debug(
60
60
  `Event added. Queue size: ${r}/${p}${h ? " (full, sending...)" : ""}`,
61
- { eventType: t.event_type, event: t }
62
- ), e.push(t);
61
+ { eventType: e.event_type, event: e }
62
+ ), t.push(e);
63
63
  },
64
64
  /**
65
65
  * Get queue size for debugging
66
66
  * Returns the number of events in smartQueue
67
67
  */
68
- size: () => (e == null ? void 0 : e.size()) ?? 0,
68
+ size: () => t?.size() ?? 0,
69
69
  /**
70
70
  * Clean up queue resources
71
71
  * Flushes remaining events and cleans up listeners
72
72
  */
73
73
  cleanup: () => {
74
- l(), typeof window < "u" && typeof document < "u" && (document.removeEventListener("visibilitychange", c), window.removeEventListener("pagehide", l)), e = null, n = null, u = !1;
74
+ l(), typeof window < "u" && typeof document < "u" && (document.removeEventListener("visibilitychange", c), window.removeEventListener("pagehide", l)), t = null, n = null, o = !1;
75
75
  }
76
76
  };
77
77
  };
@@ -1,16 +1,15 @@
1
- import { ANALYTICS_JS_DEFAULT_PROPERTIES as T, SESSION_STORAGE_KEY as h, DEFAULT_SESSION_TIMEOUT_MINUTES as y, USER_ID_KEY as w, DEFAULT_IMPRESSION_MUTATION_OBSERVER_DEBOUNCE_MS as I, EXPECTED_UTM_KEYS as D, ANALYTICS_CONTENTLET_CLASS as S } from "../constants/dot-analytics.constants.js";
2
- import { DotLogger as E } from "../dot-analytics.logger.js";
1
+ import { ANALYTICS_JS_DEFAULT_PROPERTIES as _, SESSION_STORAGE_KEY as g, DEFAULT_SESSION_TIMEOUT_MINUTES as p, USER_ID_KEY as m, DEFAULT_IMPRESSION_MUTATION_OBSERVER_DEBOUNCE_MS as T, EXPECTED_UTM_KEYS as y, ANALYTICS_CONTENTLET_CLASS as h } from "../constants/dot-analytics.constants.js";
2
+ import { DotLogger as I } from "../dot-analytics.logger.js";
3
3
  import "../../../../uve/src/internal/constants.js";
4
- function Y(t) {
5
- var n, s;
4
+ function P(t) {
6
5
  const e = [];
7
- return (n = t.siteAuth) != null && n.trim() || e.push('"siteAuth"'), (s = t.server) != null && s.trim() || e.push('"server"'), e.length > 0 ? e : null;
6
+ return t.siteAuth?.trim() || e.push('"siteAuth"'), t.server?.trim() || e.push('"server"'), e.length > 0 ? e : null;
8
7
  }
9
- let u = null, l = null;
10
- const g = (t) => {
8
+ let d = null, u = null;
9
+ const l = (t) => {
11
10
  const e = Date.now(), n = Math.random().toString(36).substr(2, 9), s = Math.random().toString(36).substr(2, 9);
12
11
  return `${t}_${e}_${n}${s}`;
13
- }, _ = {
12
+ }, f = {
14
13
  getItem: (t) => {
15
14
  try {
16
15
  return localStorage.getItem(t);
@@ -25,27 +24,27 @@ const g = (t) => {
25
24
  console.warn(`DotCMS Analytics [Core]: Could not save ${t} to localStorage`);
26
25
  }
27
26
  }
28
- }, A = () => {
29
- let t = _.getItem(w);
30
- return t || (t = g("user"), _.setItem(w, t)), t;
31
- }, C = (t) => {
27
+ }, D = () => {
28
+ let t = f.getItem(m);
29
+ return t || (t = l("user"), f.setItem(m, t)), t;
30
+ }, E = (t) => {
32
31
  const e = new Date(t), n = /* @__PURE__ */ new Date(), s = new Date(
33
32
  e.getUTCFullYear(),
34
33
  e.getUTCMonth(),
35
34
  e.getUTCDate()
36
35
  ), r = new Date(n.getUTCFullYear(), n.getUTCMonth(), n.getUTCDate());
37
36
  return s.getTime() !== r.getTime();
38
- }, v = () => {
37
+ }, A = () => {
39
38
  const t = Date.now();
40
39
  if (typeof window > "u")
41
- return g("session_fallback");
40
+ return l("session_fallback");
42
41
  try {
43
- const e = sessionStorage.getItem(h);
42
+ const e = sessionStorage.getItem(g);
44
43
  if (e) {
45
- const { sessionId: r, startTime: o, lastActivity: a } = JSON.parse(e), i = !C(o), c = t - a < y * 60 * 1e3;
44
+ const { sessionId: r, startTime: o, lastActivity: a } = JSON.parse(e), i = !E(o), c = t - a < p * 60 * 1e3;
46
45
  if (i && c)
47
46
  return sessionStorage.setItem(
48
- h,
47
+ g,
49
48
  JSON.stringify({
50
49
  sessionId: r,
51
50
  startTime: o,
@@ -53,65 +52,65 @@ const g = (t) => {
53
52
  })
54
53
  ), r;
55
54
  }
56
- const n = g("session"), s = {
55
+ const n = l("session"), s = {
57
56
  sessionId: n,
58
57
  startTime: t,
59
58
  lastActivity: t
60
59
  };
61
- return sessionStorage.setItem(h, JSON.stringify(s)), n;
60
+ return sessionStorage.setItem(g, JSON.stringify(s)), n;
62
61
  } catch {
63
- return g("session_fallback");
62
+ return l("session_fallback");
64
63
  }
65
- }, x = (t) => {
66
- const e = v(), n = A(), s = O();
64
+ }, R = (t) => {
65
+ const e = A(), n = D(), s = C();
67
66
  return {
68
67
  site_auth: t.siteAuth,
69
68
  session_id: e,
70
69
  user_id: n,
71
70
  device: s
72
71
  };
73
- }, p = () => u || (u = {
72
+ }, w = () => d || (d = {
74
73
  user_language: navigator.language,
75
74
  doc_encoding: document.characterSet || document.charset,
76
75
  screen_resolution: typeof screen < "u" && screen.width && screen.height ? `${screen.width}x${screen.height}` : ""
77
- }, u), O = () => {
78
- const t = p(), e = window.innerWidth || document.documentElement.clientWidth || 0, n = window.innerHeight || document.documentElement.clientHeight || 0;
76
+ }, d), C = () => {
77
+ const t = w(), e = window.innerWidth || document.documentElement.clientWidth || 0, n = window.innerHeight || document.documentElement.clientHeight || 0;
79
78
  return {
80
79
  screen_resolution: t.screen_resolution ?? "",
81
80
  language: t.user_language ?? "",
82
81
  viewport_width: String(e),
83
82
  viewport_height: String(n)
84
83
  };
85
- }, N = (t) => {
84
+ }, v = (t) => {
86
85
  const e = t.search;
87
- if (l && l.search === e)
88
- return l.params;
86
+ if (u && u.search === e)
87
+ return u.params;
89
88
  const n = new URLSearchParams(e), s = {};
90
- return D.forEach((r) => {
89
+ return y.forEach((r) => {
91
90
  const o = n.get(r);
92
91
  if (o) {
93
92
  const a = r.replace("utm_", "");
94
93
  s[a] = o;
95
94
  }
96
- }), l = { search: e, params: s }, s;
97
- }, b = () => {
95
+ }), u = { search: e, params: s }, s;
96
+ }, O = () => {
98
97
  try {
99
98
  const t = (/* @__PURE__ */ new Date()).getTimezoneOffset(), e = t > 0 ? "-" : "+", n = Math.abs(t), s = Math.floor(n / 60), r = n % 60;
100
99
  return `${e}${s.toString().padStart(2, "0")}:${r.toString().padStart(2, "0")}`;
101
100
  } catch {
102
101
  return "+00:00";
103
102
  }
104
- }, M = () => {
103
+ }, N = () => {
105
104
  try {
106
- const t = /* @__PURE__ */ new Date(), e = b(), n = t.getFullYear(), s = (t.getMonth() + 1).toString().padStart(2, "0"), r = t.getDate().toString().padStart(2, "0"), o = t.getHours().toString().padStart(2, "0"), a = t.getMinutes().toString().padStart(2, "0"), i = t.getSeconds().toString().padStart(2, "0");
105
+ const t = /* @__PURE__ */ new Date(), e = O(), n = t.getFullYear(), s = (t.getMonth() + 1).toString().padStart(2, "0"), r = t.getDate().toString().padStart(2, "0"), o = t.getHours().toString().padStart(2, "0"), a = t.getMinutes().toString().padStart(2, "0"), i = t.getSeconds().toString().padStart(2, "0");
107
106
  return `${n}-${s}-${r}T${o}:${a}:${i}${e}`;
108
107
  } catch {
109
108
  return (/* @__PURE__ */ new Date()).toISOString();
110
109
  }
111
- }, B = (t, e = typeof window < "u" ? window.location : {}) => {
112
- const n = M(), s = p(), { properties: r } = t, o = {};
110
+ }, Y = (t, e = typeof window < "u" ? window.location : {}) => {
111
+ const n = N(), s = w(), { properties: r } = t, o = {};
113
112
  Object.keys(r).forEach((c) => {
114
- T.includes(c) || (o[c] = r[c]);
113
+ _.includes(c) || (o[c] = r[c]);
115
114
  });
116
115
  const a = {
117
116
  url: e.href,
@@ -121,8 +120,8 @@ const g = (t) => {
121
120
  doc_search: e.search,
122
121
  doc_host: e.hostname,
123
122
  doc_path: e.pathname,
124
- title: r.title ?? (document == null ? void 0 : document.title)
125
- }, i = N(e);
123
+ title: r.title ?? document?.title
124
+ }, i = v(e);
126
125
  return {
127
126
  ...t,
128
127
  page: a,
@@ -132,17 +131,17 @@ const g = (t) => {
132
131
  local_time: n
133
132
  };
134
133
  };
135
- function L(t, e) {
134
+ function b(t, e) {
136
135
  let n = 0;
137
136
  return (...s) => {
138
137
  const r = Date.now();
139
138
  r - n >= e && (t(...s), n = r);
140
139
  };
141
140
  }
142
- function F(t) {
141
+ function x(t) {
143
142
  return t.dataset.dotAnalyticsIdentifier || null;
144
143
  }
145
- function k(t) {
144
+ function B(t) {
146
145
  return {
147
146
  identifier: t.dataset.dotAnalyticsIdentifier || "",
148
147
  inode: t.dataset.dotAnalyticsInode || "",
@@ -151,17 +150,16 @@ function k(t) {
151
150
  baseType: t.dataset.dotAnalyticsBasetype || ""
152
151
  };
153
152
  }
154
- const z = 100, U = () => typeof window < "u" && typeof document < "u", H = () => Array.from(document.querySelectorAll(`.${S}`)), J = (t, e = I) => {
155
- const n = L(t, e), s = new MutationObserver((r) => {
153
+ const F = 100, M = () => typeof window < "u" && typeof document < "u", k = () => Array.from(document.querySelectorAll(`.${h}`)), z = (t, e = T) => {
154
+ const n = b(t, e), s = new MutationObserver((r) => {
156
155
  r.some((a) => a.addedNodes.length === 0 && a.removedNodes.length === 0 ? !1 : [
157
156
  ...Array.from(a.addedNodes),
158
157
  ...Array.from(a.removedNodes)
159
158
  ].some((c) => {
160
- var f, m;
161
159
  if (c.nodeType !== Node.ELEMENT_NODE)
162
160
  return !1;
163
- const d = c;
164
- return (f = d.classList) != null && f.contains(S) ? !0 : ((m = d.querySelector) == null ? void 0 : m.call(d, `.${S}`)) !== null;
161
+ const S = c;
162
+ return S.classList?.contains(h) ? !0 : S.querySelector?.(`.${h}`) !== null;
165
163
  })) && n();
166
164
  });
167
165
  return s.observe(document.body, {
@@ -170,33 +168,33 @@ const z = 100, U = () => typeof window < "u" && typeof document < "u", H = () =>
170
168
  attributes: !1,
171
169
  characterData: !1
172
170
  }), s;
173
- }, K = (t) => {
174
- U() && (window.addEventListener("beforeunload", t), window.addEventListener("pagehide", t));
175
- }, j = (t, e) => {
171
+ }, H = (t) => {
172
+ M() && (window.addEventListener("beforeunload", t), window.addEventListener("pagehide", t));
173
+ }, J = (t, e) => {
176
174
  const n = e.logLevel ?? (e.debug ? "debug" : "warn");
177
- return new E("Analytics", t, n);
178
- }, W = (t, e, n) => [
175
+ return new I("Analytics", t, n);
176
+ }, K = (t, e, n) => [
179
177
  t.impressions && e(t),
180
178
  t.clicks && n(t)
181
179
  ].filter(Boolean);
182
180
  export {
183
- z as INITIAL_SCAN_DELAY_MS,
184
- J as createContentletObserver,
185
- j as createPluginLogger,
186
- L as createThrottle,
187
- B as enrichPagePayloadOptimized,
188
- k as extractContentletData,
189
- F as extractContentletIdentifier,
190
- N as extractUTMParameters,
191
- H as findContentlets,
192
- g as generateSecureId,
193
- x as getAnalyticsContext,
194
- O as getDeviceDataForContext,
195
- W as getEnhancedTrackingPlugins,
196
- M as getLocalTime,
197
- v as getSessionId,
198
- A as getUserId,
199
- U as isBrowser,
200
- K as setupPluginCleanup,
201
- Y as validateAnalyticsConfig
181
+ F as INITIAL_SCAN_DELAY_MS,
182
+ z as createContentletObserver,
183
+ J as createPluginLogger,
184
+ b as createThrottle,
185
+ Y as enrichPagePayloadOptimized,
186
+ B as extractContentletData,
187
+ x as extractContentletIdentifier,
188
+ v as extractUTMParameters,
189
+ k as findContentlets,
190
+ l as generateSecureId,
191
+ R as getAnalyticsContext,
192
+ C as getDeviceDataForContext,
193
+ K as getEnhancedTrackingPlugins,
194
+ N as getLocalTime,
195
+ A as getSessionId,
196
+ D as getUserId,
197
+ M as isBrowser,
198
+ H as setupPluginCleanup,
199
+ P as validateAnalyticsConfig
202
200
  };
@@ -1,18 +1,18 @@
1
- import { usePathname as u, useSearchParams as c } from "next/navigation";
2
- import { useRef as p, useEffect as m } from "react";
3
- import { getUVEState as s } from "../../../uve/src/lib/core/core.utils.js";
1
+ import { usePathname as s, useSearchParams as u } from "next/navigation";
2
+ import { useRef as c, useEffect as a } from "react";
3
+ import { getUVEState as m } from "../../../uve/src/lib/core/core.utils.js";
4
4
  import "../../../uve/src/internal/constants.js";
5
- const g = (e, t) => `${e}${t != null && t.toString() ? "?" + t.toString() : ""}`;
6
- function A(e, t = !1) {
7
- const o = p(null), n = u(), r = c();
8
- m(() => {
9
- if (!e) return;
5
+ const p = (t, e) => `${t}${e?.toString() ? "?" + e.toString() : ""}`;
6
+ function l(t, e = !1) {
7
+ const r = c(null), o = s(), n = u();
8
+ a(() => {
9
+ if (!t) return;
10
10
  const i = (f) => {
11
- s() || f !== o.current && (o.current = f, e.pageView());
11
+ m() || f !== r.current && (r.current = f, t.pageView());
12
12
  };
13
- t && console.info("DotCMS Analytics [React]: using Next.js App Router tracking"), i(g(n, r));
14
- }, [e, n, r, t]);
13
+ e && console.info("DotCMS Analytics [React]: using Next.js App Router tracking"), i(p(o, n));
14
+ }, [t, o, n, e]);
15
15
  }
16
16
  export {
17
- A as useRouterTracker
17
+ l as useRouterTracker
18
18
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotcms/analytics",
3
- "version": "1.2.1-next.1",
3
+ "version": "1.2.1-next.3",
4
4
  "description": "Official JavaScript library for Content Analytics with DotCMS.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,7 +1,7 @@
1
1
  import { UVEEventType as a } from "../../../types/src/lib/editor/public.js";
2
2
  import { __DOTCMS_UVE_EVENT__ as s } from "../../../types/src/lib/events/internal.js";
3
- import { findDotCMSElement as M, findDotCMSVTLData as p, getClosestDotCMSContainerData as w, getDotCMSPageBounds as S } from "../lib/dom/dom.utils.js";
4
- function U(o) {
3
+ import { findDotCMSElement as u, findDotCMSVTLData as C, getClosestDotCMSContainerData as g, getDotCMSPageBounds as v } from "../lib/dom/dom.utils.js";
4
+ function O(o) {
5
5
  const t = (n) => {
6
6
  n.data.name === s.UVE_SET_PAGE_DATA && o(n.data.payload);
7
7
  };
@@ -12,7 +12,7 @@ function U(o) {
12
12
  event: a.CONTENT_CHANGES
13
13
  };
14
14
  }
15
- function V(o) {
15
+ function b(o) {
16
16
  const t = (n) => {
17
17
  n.data.name === s.UVE_RELOAD_PAGE && o();
18
18
  };
@@ -23,12 +23,12 @@ function V(o) {
23
23
  event: a.PAGE_RELOAD
24
24
  };
25
25
  }
26
- function I(o) {
26
+ function M(o) {
27
27
  const t = (n) => {
28
28
  if (n.data.name === s.UVE_REQUEST_BOUNDS) {
29
29
  const e = Array.from(
30
30
  document.querySelectorAll('[data-dot-object="container"]')
31
- ), i = S(e);
31
+ ), i = v(e);
32
32
  o(i);
33
33
  }
34
34
  };
@@ -39,7 +39,7 @@ function I(o) {
39
39
  event: a.REQUEST_BOUNDS
40
40
  };
41
41
  }
42
- function Y(o) {
42
+ function p(o) {
43
43
  const t = (n) => {
44
44
  if (n.data.name === s.UVE_SCROLL_INSIDE_IFRAME) {
45
45
  const e = n.data.direction;
@@ -53,12 +53,11 @@ function Y(o) {
53
53
  event: a.IFRAME_SCROLL
54
54
  };
55
55
  }
56
- function B(o) {
56
+ function w(o) {
57
57
  const t = (n) => {
58
- var d, r, E, c, T, l, m, _, u, C;
59
- const e = M(n.target);
58
+ const e = u(n.target);
60
59
  if (!e) return;
61
- const { x: i, y: g, width: v, height: N } = e.getBoundingClientRect(), f = ((d = e.dataset) == null ? void 0 : d.dotObject) === "container", L = {
60
+ const { x: i, y: d, width: r, height: E } = e.getBoundingClientRect(), c = e.dataset?.dotObject === "container", T = {
62
61
  identifier: "TEMP_EMPTY_CONTENTLET",
63
62
  title: "TEMP_EMPTY_CONTENTLET",
64
63
  contentType: "TEMP_EMPTY_CONTENTLET_TYPE",
@@ -66,29 +65,29 @@ function B(o) {
66
65
  widgetTitle: "TEMP_EMPTY_CONTENTLET",
67
66
  baseType: "TEMP_EMPTY_CONTENTLET",
68
67
  onNumberOfPages: 1
69
- }, P = {
70
- identifier: (r = e.dataset) == null ? void 0 : r.dotIdentifier,
71
- title: (E = e.dataset) == null ? void 0 : E.dotTitle,
72
- inode: (c = e.dataset) == null ? void 0 : c.dotInode,
73
- contentType: (T = e.dataset) == null ? void 0 : T.dotType,
74
- baseType: (l = e.dataset) == null ? void 0 : l.dotBasetype,
75
- widgetTitle: (m = e.dataset) == null ? void 0 : m.dotWidgetTitle,
76
- onNumberOfPages: (_ = e.dataset) == null ? void 0 : _.dotOnNumberOfPages
77
- }, O = p(e), b = {
68
+ }, l = {
69
+ identifier: e.dataset?.dotIdentifier,
70
+ title: e.dataset?.dotTitle,
71
+ inode: e.dataset?.dotInode,
72
+ contentType: e.dataset?.dotType,
73
+ baseType: e.dataset?.dotBasetype,
74
+ widgetTitle: e.dataset?.dotWidgetTitle,
75
+ onNumberOfPages: e.dataset?.dotOnNumberOfPages
76
+ }, m = C(e), _ = {
78
77
  container: (
79
78
  // Here extract dot-container from contentlet if it is Headless
80
79
  // or search in parent container if it is VTL
81
- (u = e.dataset) != null && u.dotContainer ? JSON.parse((C = e.dataset) == null ? void 0 : C.dotContainer) : w(e)
80
+ e.dataset?.dotContainer ? JSON.parse(e.dataset?.dotContainer) : g(e)
82
81
  ),
83
- contentlet: f ? L : P,
84
- vtlFiles: O
82
+ contentlet: c ? T : l,
83
+ vtlFiles: m
85
84
  };
86
85
  o({
87
86
  x: i,
88
- y: g,
89
- width: v,
90
- height: N,
91
- payload: b
87
+ y: d,
88
+ width: r,
89
+ height: E,
90
+ payload: _
92
91
  });
93
92
  };
94
93
  return document.addEventListener("pointermove", t), {
@@ -99,9 +98,9 @@ function B(o) {
99
98
  };
100
99
  }
101
100
  export {
102
- U as onContentChanges,
103
- B as onContentletHovered,
104
- Y as onIframeScroll,
105
- V as onPageReload,
106
- I as onRequestBounds
101
+ O as onContentChanges,
102
+ w as onContentletHovered,
103
+ p as onIframeScroll,
104
+ b as onPageReload,
105
+ M as onRequestBounds
107
106
  };
@@ -1,80 +1,74 @@
1
1
  import "../../internal/constants.js";
2
- function C(t) {
3
- return t.map((a) => {
4
- const o = a.getBoundingClientRect(), n = Array.from(
5
- a.querySelectorAll('[data-dot-object="contentlet"]')
2
+ function c(t) {
3
+ return t.map((n) => {
4
+ const e = n.getBoundingClientRect(), o = Array.from(
5
+ n.querySelectorAll('[data-dot-object="contentlet"]')
6
6
  );
7
7
  return {
8
- x: o.x,
9
- y: o.y,
10
- width: o.width,
11
- height: o.height,
8
+ x: e.x,
9
+ y: e.y,
10
+ width: e.width,
11
+ height: e.height,
12
12
  payload: JSON.stringify({
13
- container: u(a)
13
+ container: a(n)
14
14
  }),
15
- contentlets: f(o, n)
15
+ contentlets: d(e, o)
16
16
  };
17
17
  });
18
18
  }
19
- function f(t, a) {
20
- return a.map((o) => {
21
- var d, r, i, e, s, c;
22
- const n = o.getBoundingClientRect();
19
+ function d(t, n) {
20
+ return n.map((e) => {
21
+ const o = e.getBoundingClientRect();
23
22
  return {
24
23
  x: 0,
25
- y: n.y - t.y,
26
- width: n.width,
27
- height: n.height,
24
+ y: o.y - t.y,
25
+ width: o.width,
26
+ height: o.height,
28
27
  payload: JSON.stringify({
29
- container: (d = o.dataset) != null && d.dotContainer ? JSON.parse((r = o.dataset) == null ? void 0 : r.dotContainer) : y(o),
28
+ container: e.dataset?.dotContainer ? JSON.parse(e.dataset?.dotContainer) : r(e),
30
29
  contentlet: {
31
- identifier: (i = o.dataset) == null ? void 0 : i.dotIdentifier,
32
- title: (e = o.dataset) == null ? void 0 : e.dotTitle,
33
- inode: (s = o.dataset) == null ? void 0 : s.dotInode,
34
- contentType: (c = o.dataset) == null ? void 0 : c.dotType
30
+ identifier: e.dataset?.dotIdentifier,
31
+ title: e.dataset?.dotTitle,
32
+ inode: e.dataset?.dotInode,
33
+ contentType: e.dataset?.dotType
35
34
  }
36
35
  })
37
36
  };
38
37
  });
39
38
  }
40
- function u(t) {
41
- var a, o, n, d;
39
+ function a(t) {
42
40
  return {
43
- acceptTypes: ((a = t.dataset) == null ? void 0 : a.dotAcceptTypes) || "",
44
- identifier: ((o = t.dataset) == null ? void 0 : o.dotIdentifier) || "",
45
- maxContentlets: ((n = t.dataset) == null ? void 0 : n.maxContentlets) || "",
46
- uuid: ((d = t.dataset) == null ? void 0 : d.dotUuid) || ""
41
+ acceptTypes: t.dataset?.dotAcceptTypes || "",
42
+ identifier: t.dataset?.dotIdentifier || "",
43
+ maxContentlets: t.dataset?.maxContentlets || "",
44
+ uuid: t.dataset?.dotUuid || ""
47
45
  };
48
46
  }
49
- function y(t) {
50
- const a = t.closest('[data-dot-object="container"]');
51
- return a ? u(a) : (console.warn("No container found for the contentlet"), null);
47
+ function r(t) {
48
+ const n = t.closest('[data-dot-object="container"]');
49
+ return n ? a(n) : (console.warn("No container found for the contentlet"), null);
52
50
  }
53
- function g(t) {
54
- var o, n, d;
51
+ function i(t) {
55
52
  if (!t) return null;
56
- const a = t.querySelector('[data-dot-object="empty-content"]');
57
- return ((o = t == null ? void 0 : t.dataset) == null ? void 0 : o.dotObject) === "contentlet" || // The container inside Headless components have a span with the data-dot-object="container" attribute
58
- ((n = t == null ? void 0 : t.dataset) == null ? void 0 : n.dotObject) === "container" && a || // The container inside Traditional have no content inside
59
- ((d = t == null ? void 0 : t.dataset) == null ? void 0 : d.dotObject) === "container" && t.children.length === 0 ? t : g(t == null ? void 0 : t.parentElement);
53
+ const n = t.querySelector('[data-dot-object="empty-content"]');
54
+ return t?.dataset?.dotObject === "contentlet" || // The container inside Headless components have a span with the data-dot-object="container" attribute
55
+ t?.dataset?.dotObject === "container" && n || // The container inside Traditional have no content inside
56
+ t?.dataset?.dotObject === "container" && t.children.length === 0 ? t : i(t?.parentElement);
60
57
  }
61
- function h(t) {
62
- const a = t.querySelectorAll(
58
+ function u(t) {
59
+ const n = t.querySelectorAll(
63
60
  '[data-dot-object="vtl-file"]'
64
61
  );
65
- return a.length ? Array.from(a).map((o) => {
66
- var n, d;
67
- return {
68
- inode: (n = o.dataset) == null ? void 0 : n.dotInode,
69
- name: (d = o.dataset) == null ? void 0 : d.dotUrl
70
- };
71
- }) : null;
62
+ return n.length ? Array.from(n).map((e) => ({
63
+ inode: e.dataset?.dotInode,
64
+ name: e.dataset?.dotUrl
65
+ })) : null;
72
66
  }
73
67
  export {
74
- g as findDotCMSElement,
75
- h as findDotCMSVTLData,
76
- y as getClosestDotCMSContainerData,
77
- u as getDotCMSContainerData,
78
- f as getDotCMSContentletsBound,
79
- C as getDotCMSPageBounds
68
+ i as findDotCMSElement,
69
+ u as findDotCMSVTLData,
70
+ r as getClosestDotCMSContainerData,
71
+ a as getDotCMSContainerData,
72
+ d as getDotCMSContentletsBound,
73
+ c as getDotCMSPageBounds
80
74
  };