@dotcms/analytics 1.4.0-next.1 → 1.4.0-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotcms/analytics",
3
- "version": "1.4.0-next.1",
3
+ "version": "1.4.0-next.3",
4
4
  "description": "Official JavaScript library for Content Analytics with DotCMS.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,5 +1,5 @@
1
- var N = /* @__PURE__ */ ((r) => (r.EDIT = "EDIT_MODE", r.PREVIEW = "PREVIEW_MODE", r.LIVE = "LIVE", r.UNKNOWN = "UNKNOWN", r))(N || {}), E = /* @__PURE__ */ ((r) => (r.CONTENT_CHANGES = "changes", r.PAGE_RELOAD = "page-reload", r.REQUEST_BOUNDS = "request-bounds", r.IFRAME_SCROLL = "iframe-scroll", r.CONTENTLET_HOVERED = "contentlet-hovered", r))(E || {});
1
+ var N = /* @__PURE__ */ ((r) => (r.EDIT = "EDIT_MODE", r.PREVIEW = "PREVIEW_MODE", r.LIVE = "LIVE", r.UNKNOWN = "UNKNOWN", r))(N || {}), O = /* @__PURE__ */ ((r) => (r.CONTENT_CHANGES = "changes", r.PAGE_RELOAD = "page-reload", r.REQUEST_BOUNDS = "request-bounds", r.IFRAME_SCROLL = "iframe-scroll", r.CONTENTLET_HOVERED = "contentlet-hovered", r.SCROLL_TO_SECTION = "scroll-to-section", r))(O || {});
2
2
  export {
3
- E as UVEEventType,
3
+ O as UVEEventType,
4
4
  N as UVE_MODE
5
5
  };
@@ -1,4 +1,4 @@
1
- var t = /* @__PURE__ */ ((e) => (e.UVE_RELOAD_PAGE = "uve-reload-page", e.UVE_REQUEST_BOUNDS = "uve-request-bounds", e.UVE_EDITOR_PONG = "uve-editor-pong", e.UVE_SCROLL_INSIDE_IFRAME = "uve-scroll-inside-iframe", e.UVE_SET_PAGE_DATA = "uve-set-page-data", e.UVE_COPY_CONTENTLET_INLINE_EDITING_SUCCESS = "uve-copy-contentlet-inline-editing-success", e))(t || {});
1
+ var t = /* @__PURE__ */ ((e) => (e.UVE_RELOAD_PAGE = "uve-reload-page", e.UVE_REQUEST_BOUNDS = "uve-request-bounds", e.UVE_EDITOR_PONG = "uve-editor-pong", e.UVE_SCROLL_INSIDE_IFRAME = "uve-scroll-inside-iframe", e.UVE_SET_PAGE_DATA = "uve-set-page-data", e.UVE_COPY_CONTENTLET_INLINE_EDITING_SUCCESS = "uve-copy-contentlet-inline-editing-success", e.UVE_SCROLL_TO_SECTION = "uve-scroll-to-section", e))(t || {});
2
2
  export {
3
3
  t as __DOTCMS_UVE_EVENT__
4
4
  };
@@ -1,3 +1,7 @@
1
- import { UVEEventType as n } from "../../../types/src/lib/editor/public.js";
2
- import { onContentletHovered as r, onIframeScroll as o, onRequestBounds as t, onPageReload as E, onContentChanges as u } from "./events.js";
3
- n.CONTENT_CHANGES + "", n.PAGE_RELOAD + "", n.REQUEST_BOUNDS + "", n.IFRAME_SCROLL + "", n.CONTENTLET_HOVERED + "";
1
+ import { UVEEventType as e } from "../../../types/src/lib/editor/public.js";
2
+ import { onScrollToSection as n, onContentletHovered as r, onIframeScroll as t, onRequestBounds as E, onPageReload as T, onContentChanges as O } from "./events.js";
3
+ e.CONTENT_CHANGES + "", e.PAGE_RELOAD + "", e.REQUEST_BOUNDS + "", e.IFRAME_SCROLL + "", e.CONTENTLET_HOVERED + "", e.SCROLL_TO_SECTION + "";
4
+ const _ = "dot-section-";
5
+ export {
6
+ _ as DOT_SECTION_ID_PREFIX
7
+ };
@@ -1,47 +1,48 @@
1
- import { UVEEventType as a } from "../../../types/src/lib/editor/public.js";
2
- import { __DOTCMS_UVE_EVENT__ as s } from "../../../types/src/lib/events/internal.js";
3
- import { findDotCMSElement as u, findDotCMSVTLData as C, getClosestDotCMSContainerData as g, getDotCMSPageBounds as N } from "../lib/dom/dom.utils.js";
4
- function O(o) {
1
+ import { UVEEventType as s } from "../../../types/src/lib/editor/public.js";
2
+ import { __DOTCMS_UVE_EVENT__ as i } from "../../../types/src/lib/events/internal.js";
3
+ import { DOT_SECTION_ID_PREFIX as _ } from "./constants.js";
4
+ import { findDotCMSElement as C, findDotCMSVTLData as f, getClosestDotCMSContainerData as O, getDotCMSPageBounds as g } from "../lib/dom/dom.utils.js";
5
+ function p(o) {
5
6
  const t = (n) => {
6
- n.data.name === s.UVE_SET_PAGE_DATA && o(n.data.payload);
7
+ n.data.name === i.UVE_SET_PAGE_DATA && o(n.data.payload);
7
8
  };
8
9
  return window.addEventListener("message", t), {
9
10
  unsubscribe: () => {
10
11
  window.removeEventListener("message", t);
11
12
  },
12
- event: a.CONTENT_CHANGES
13
+ event: s.CONTENT_CHANGES
13
14
  };
14
15
  }
15
- function p(o) {
16
+ function b(o) {
16
17
  const t = (n) => {
17
- n.data.name === s.UVE_RELOAD_PAGE && o();
18
+ n.data.name === i.UVE_RELOAD_PAGE && o();
18
19
  };
19
20
  return window.addEventListener("message", t), {
20
21
  unsubscribe: () => {
21
22
  window.removeEventListener("message", t);
22
23
  },
23
- event: a.PAGE_RELOAD
24
+ event: s.PAGE_RELOAD
24
25
  };
25
26
  }
26
- function b(o) {
27
+ function w(o) {
27
28
  const t = (n) => {
28
- if (n.data.name === s.UVE_REQUEST_BOUNDS) {
29
+ if (n.data.name === i.UVE_REQUEST_BOUNDS) {
29
30
  const e = Array.from(
30
31
  document.querySelectorAll('[data-dot-object="container"]')
31
- ), i = N(e);
32
- o(i);
32
+ ), a = g(e);
33
+ o(a);
33
34
  }
34
35
  };
35
36
  return window.addEventListener("message", t), {
36
37
  unsubscribe: () => {
37
38
  window.removeEventListener("message", t);
38
39
  },
39
- event: a.REQUEST_BOUNDS
40
+ event: s.REQUEST_BOUNDS
40
41
  };
41
42
  }
42
- function S(o) {
43
+ function y(o) {
43
44
  const t = (n) => {
44
- if (n.data.name === s.UVE_SCROLL_INSIDE_IFRAME) {
45
+ if (n.data.name === i.UVE_SCROLL_INSIDE_IFRAME) {
45
46
  const e = n.data.direction;
46
47
  o(e);
47
48
  }
@@ -50,14 +51,28 @@ function S(o) {
50
51
  unsubscribe: () => {
51
52
  window.removeEventListener("message", t);
52
53
  },
53
- event: a.IFRAME_SCROLL
54
+ event: s.IFRAME_SCROLL
54
55
  };
55
56
  }
56
57
  function M(o) {
57
58
  const t = (n) => {
58
- const e = u(n.target);
59
+ if (n.data.name !== i.UVE_SCROLL_TO_SECTION)
60
+ return;
61
+ const e = n.data.sectionIndex, a = document.querySelector(`#${_}${e}`) ?? document.querySelector(`#section-${e}`);
62
+ a && o({ sectionIndex: e, offsetTop: a.offsetTop });
63
+ };
64
+ return window.addEventListener("message", t), {
65
+ unsubscribe: () => {
66
+ window.removeEventListener("message", t);
67
+ },
68
+ event: s.SCROLL_TO_SECTION
69
+ };
70
+ }
71
+ function D(o) {
72
+ const t = (n) => {
73
+ const e = C(n.target);
59
74
  if (!e) return;
60
- const { x: i, y: d, width: r, height: E } = e.getBoundingClientRect(), c = e.dataset?.dotObject === "container", T = {
75
+ const { x: a, y: r, width: d, height: E } = e.getBoundingClientRect(), c = e.dataset?.dotObject === "container", T = {
61
76
  identifier: "TEMP_EMPTY_CONTENTLET",
62
77
  title: "TEMP_EMPTY_CONTENTLET",
63
78
  contentType: "TEMP_EMPTY_CONTENTLET_TYPE",
@@ -76,34 +91,35 @@ function M(o) {
76
91
  ...e.dataset?.dotStyleProperties && {
77
92
  dotStyleProperties: JSON.parse(e.dataset.dotStyleProperties)
78
93
  }
79
- }, m = C(e), _ = {
94
+ }, m = f(e), u = {
80
95
  container: (
81
96
  // Here extract dot-container from contentlet if it is Headless
82
97
  // or search in parent container if it is VTL
83
- e.dataset?.dotContainer ? JSON.parse(e.dataset?.dotContainer) : g(e)
98
+ e.dataset?.dotContainer ? JSON.parse(e.dataset?.dotContainer) : O(e)
84
99
  ),
85
100
  contentlet: c ? T : l,
86
101
  vtlFiles: m
87
102
  };
88
103
  o({
89
- x: i,
90
- y: d,
91
- width: r,
104
+ x: a,
105
+ y: r,
106
+ width: d,
92
107
  height: E,
93
- payload: _
108
+ payload: u
94
109
  });
95
110
  };
96
111
  return document.addEventListener("pointermove", t), {
97
112
  unsubscribe: () => {
98
113
  document.removeEventListener("pointermove", t);
99
114
  },
100
- event: a.CONTENTLET_HOVERED
115
+ event: s.CONTENTLET_HOVERED
101
116
  };
102
117
  }
103
118
  export {
104
- O as onContentChanges,
105
- M as onContentletHovered,
106
- S as onIframeScroll,
107
- p as onPageReload,
108
- b as onRequestBounds
119
+ p as onContentChanges,
120
+ D as onContentletHovered,
121
+ y as onIframeScroll,
122
+ b as onPageReload,
123
+ w as onRequestBounds,
124
+ M as onScrollToSection
109
125
  };