@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.
- package/lib/core/plugin/identity/dot-analytics.identity.activity-tracker.js +1 -2
- package/lib/core/shared/queue/dot-analytics.queue.utils.js +22 -22
- package/lib/core/shared/utils/dot-analytics.utils.js +68 -70
- package/lib/react/hook/useRouterTracker.js +12 -12
- package/package.json +1 -1
- package/uve/src/internal/events.js +30 -31
- package/uve/src/lib/dom/dom.utils.js +46 -52
|
@@ -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
|
-
|
|
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 = (
|
|
7
|
-
const i = w("Queue",
|
|
8
|
-
let
|
|
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
|
|
12
|
-
}, g = (
|
|
11
|
+
...typeof u.queue == "object" ? u.queue : {}
|
|
12
|
+
}, g = (e, s) => {
|
|
13
13
|
if (!n) return;
|
|
14
|
-
i.debug(`Sending batch of ${
|
|
15
|
-
events:
|
|
16
|
-
keepalive:
|
|
17
|
-
}), b({ context: n, events:
|
|
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
|
-
!
|
|
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
|
-
|
|
35
|
-
(
|
|
36
|
-
g(
|
|
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((
|
|
45
|
-
d = !0, f =
|
|
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: (
|
|
57
|
-
if (n = s, !
|
|
58
|
-
const r =
|
|
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:
|
|
62
|
-
),
|
|
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: () =>
|
|
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)),
|
|
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
|
|
2
|
-
import { DotLogger as
|
|
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
|
|
5
|
-
var n, s;
|
|
4
|
+
function P(t) {
|
|
6
5
|
const e = [];
|
|
7
|
-
return
|
|
6
|
+
return t.siteAuth?.trim() || e.push('"siteAuth"'), t.server?.trim() || e.push('"server"'), e.length > 0 ? e : null;
|
|
8
7
|
}
|
|
9
|
-
let
|
|
10
|
-
const
|
|
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
|
-
},
|
|
29
|
-
let t =
|
|
30
|
-
return t || (t =
|
|
31
|
-
},
|
|
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
|
-
},
|
|
37
|
+
}, A = () => {
|
|
39
38
|
const t = Date.now();
|
|
40
39
|
if (typeof window > "u")
|
|
41
|
-
return
|
|
40
|
+
return l("session_fallback");
|
|
42
41
|
try {
|
|
43
|
-
const e = sessionStorage.getItem(
|
|
42
|
+
const e = sessionStorage.getItem(g);
|
|
44
43
|
if (e) {
|
|
45
|
-
const { sessionId: r, startTime: o, lastActivity: a } = JSON.parse(e), i = !
|
|
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
|
-
|
|
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 =
|
|
55
|
+
const n = l("session"), s = {
|
|
57
56
|
sessionId: n,
|
|
58
57
|
startTime: t,
|
|
59
58
|
lastActivity: t
|
|
60
59
|
};
|
|
61
|
-
return sessionStorage.setItem(
|
|
60
|
+
return sessionStorage.setItem(g, JSON.stringify(s)), n;
|
|
62
61
|
} catch {
|
|
63
|
-
return
|
|
62
|
+
return l("session_fallback");
|
|
64
63
|
}
|
|
65
|
-
},
|
|
66
|
-
const e =
|
|
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
|
-
},
|
|
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
|
-
},
|
|
78
|
-
const t =
|
|
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
|
-
},
|
|
84
|
+
}, v = (t) => {
|
|
86
85
|
const e = t.search;
|
|
87
|
-
if (
|
|
88
|
-
return
|
|
86
|
+
if (u && u.search === e)
|
|
87
|
+
return u.params;
|
|
89
88
|
const n = new URLSearchParams(e), s = {};
|
|
90
|
-
return
|
|
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
|
-
}),
|
|
97
|
-
},
|
|
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
|
-
},
|
|
103
|
+
}, N = () => {
|
|
105
104
|
try {
|
|
106
|
-
const t = /* @__PURE__ */ new Date(), e =
|
|
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
|
-
},
|
|
112
|
-
const n =
|
|
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
|
-
|
|
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 ??
|
|
125
|
-
}, i =
|
|
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
|
|
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
|
|
141
|
+
function x(t) {
|
|
143
142
|
return t.dataset.dotAnalyticsIdentifier || null;
|
|
144
143
|
}
|
|
145
|
-
function
|
|
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
|
|
155
|
-
const n =
|
|
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
|
|
164
|
-
return
|
|
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
|
-
},
|
|
174
|
-
|
|
175
|
-
},
|
|
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
|
|
178
|
-
},
|
|
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
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { getUVEState as
|
|
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
|
|
6
|
-
function
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
if (!
|
|
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
|
-
|
|
11
|
+
m() || f !== r.current && (r.current = f, t.pageView());
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
}, [
|
|
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
|
-
|
|
17
|
+
l as useRouterTracker
|
|
18
18
|
};
|
package/package.json
CHANGED
|
@@ -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
|
|
4
|
-
function
|
|
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
|
|
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
|
|
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 =
|
|
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
|
|
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
|
|
56
|
+
function w(o) {
|
|
57
57
|
const t = (n) => {
|
|
58
|
-
|
|
59
|
-
const e = M(n.target);
|
|
58
|
+
const e = u(n.target);
|
|
60
59
|
if (!e) return;
|
|
61
|
-
const { x: i, y:
|
|
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
|
-
},
|
|
70
|
-
identifier:
|
|
71
|
-
title:
|
|
72
|
-
inode:
|
|
73
|
-
contentType:
|
|
74
|
-
baseType:
|
|
75
|
-
widgetTitle:
|
|
76
|
-
onNumberOfPages:
|
|
77
|
-
},
|
|
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
|
-
|
|
80
|
+
e.dataset?.dotContainer ? JSON.parse(e.dataset?.dotContainer) : g(e)
|
|
82
81
|
),
|
|
83
|
-
contentlet:
|
|
84
|
-
vtlFiles:
|
|
82
|
+
contentlet: c ? T : l,
|
|
83
|
+
vtlFiles: m
|
|
85
84
|
};
|
|
86
85
|
o({
|
|
87
86
|
x: i,
|
|
88
|
-
y:
|
|
89
|
-
width:
|
|
90
|
-
height:
|
|
91
|
-
payload:
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
|
3
|
-
return t.map((
|
|
4
|
-
const
|
|
5
|
-
|
|
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:
|
|
9
|
-
y:
|
|
10
|
-
width:
|
|
11
|
-
height:
|
|
8
|
+
x: e.x,
|
|
9
|
+
y: e.y,
|
|
10
|
+
width: e.width,
|
|
11
|
+
height: e.height,
|
|
12
12
|
payload: JSON.stringify({
|
|
13
|
-
container:
|
|
13
|
+
container: a(n)
|
|
14
14
|
}),
|
|
15
|
-
contentlets:
|
|
15
|
+
contentlets: d(e, o)
|
|
16
16
|
};
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
return
|
|
21
|
-
|
|
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:
|
|
26
|
-
width:
|
|
27
|
-
height:
|
|
24
|
+
y: o.y - t.y,
|
|
25
|
+
width: o.width,
|
|
26
|
+
height: o.height,
|
|
28
27
|
payload: JSON.stringify({
|
|
29
|
-
container:
|
|
28
|
+
container: e.dataset?.dotContainer ? JSON.parse(e.dataset?.dotContainer) : r(e),
|
|
30
29
|
contentlet: {
|
|
31
|
-
identifier:
|
|
32
|
-
title:
|
|
33
|
-
inode:
|
|
34
|
-
contentType:
|
|
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
|
|
41
|
-
var a, o, n, d;
|
|
39
|
+
function a(t) {
|
|
42
40
|
return {
|
|
43
|
-
acceptTypes:
|
|
44
|
-
identifier:
|
|
45
|
-
maxContentlets:
|
|
46
|
-
uuid:
|
|
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
|
|
50
|
-
const
|
|
51
|
-
return
|
|
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
|
|
54
|
-
var o, n, d;
|
|
51
|
+
function i(t) {
|
|
55
52
|
if (!t) return null;
|
|
56
|
-
const
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
-
|
|
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
|
|
62
|
-
const
|
|
58
|
+
function u(t) {
|
|
59
|
+
const n = t.querySelectorAll(
|
|
63
60
|
'[data-dot-object="vtl-file"]'
|
|
64
61
|
);
|
|
65
|
-
return
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
};
|