@journeeze/sdk 0.0.0-stage → 0.1.0-rc.2

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.
Files changed (60) hide show
  1. package/AGENTS.md +67 -0
  2. package/CHANGELOG.md +30 -0
  3. package/LICENSE.md +27 -0
  4. package/README.md +164 -2
  5. package/dist/THIRD_PARTY_LICENSES.txt +246 -0
  6. package/dist/consent-CoKD33Rm.js +170 -0
  7. package/dist/context-UnG6_X61.js +17 -0
  8. package/dist/contract.js +10 -0
  9. package/dist/feedback-C4CYtS2A.js +196 -0
  10. package/dist/help-C1x-y2f9.js +878 -0
  11. package/dist/hook-BdG4UL4k.js +91 -0
  12. package/dist/index-B_nob8S0.js +2091 -0
  13. package/dist/index-CfCbJJXa.js +20 -0
  14. package/dist/index.js +10 -0
  15. package/dist/loader-Ba4X-WNl.js +95 -0
  16. package/dist/react.js +70 -0
  17. package/dist/resolve-BfWByuTp.js +97 -0
  18. package/dist/script.js +13 -0
  19. package/dist/signals-E3VEdmWH.js +477 -0
  20. package/dist/telemetry-Cik-cYzw.js +140 -0
  21. package/dist/transport-B5YJFQEF.js +60 -0
  22. package/dist/types/config.d.ts +17 -0
  23. package/dist/types/context.d.ts +6 -0
  24. package/dist/types/contract.d.ts +13 -0
  25. package/dist/types/help/core/client.d.ts +26 -0
  26. package/dist/types/help/core/controller.d.ts +175 -0
  27. package/dist/types/help/core/events.d.ts +8 -0
  28. package/dist/types/help/core/help.d.ts +24 -0
  29. package/dist/types/help/core/highlight.d.ts +38 -0
  30. package/dist/types/help/core/panel.d.ts +11 -0
  31. package/dist/types/help/core/search.d.ts +7 -0
  32. package/dist/types/help/ui/callout.d.ts +2 -0
  33. package/dist/types/help/ui/panel.d.ts +3 -0
  34. package/dist/types/help/ui/request.d.ts +2 -0
  35. package/dist/types/help/ui/styles.d.ts +1 -0
  36. package/dist/types/index.d.ts +7 -0
  37. package/dist/types/invite.d.ts +4 -0
  38. package/dist/types/loader.d.ts +57 -0
  39. package/dist/types/mask.d.ts +10 -0
  40. package/dist/types/react.d.ts +9 -0
  41. package/dist/types/resolve/resolve.d.ts +12 -0
  42. package/dist/types/script.d.ts +6 -0
  43. package/dist/types/signals/cel.d.ts +8 -0
  44. package/dist/types/signals/hook.d.ts +10 -0
  45. package/dist/types/signals/signals.conformance.d.ts +2 -0
  46. package/dist/types/signals/signals.d.ts +145 -0
  47. package/dist/types/telemetry/telemetry.d.ts +63 -0
  48. package/dist/types/transport.d.ts +30 -0
  49. package/dist/types/types.d.ts +391 -0
  50. package/dist/types/widget/anchor.d.ts +11 -0
  51. package/dist/types/widget/capture.d.ts +28 -0
  52. package/dist/types/widget/consent.d.ts +25 -0
  53. package/dist/types/widget/feedback.d.ts +36 -0
  54. package/dist/types/widget/icons.d.ts +14 -0
  55. package/dist/types/widget/outbox.d.ts +69 -0
  56. package/dist/types/widget/styles.d.ts +1 -0
  57. package/dist/types/widget.d.ts +27 -0
  58. package/dist/types/wire.d.ts +66 -0
  59. package/dist/widget-DQZm8sAC.js +1599 -0
  60. package/package.json +68 -4
@@ -0,0 +1,20 @@
1
+ import "./loader-Ba4X-WNl.js";
2
+ import "./context-UnG6_X61.js";
3
+ const n = "input, textarea, select, [data-jz-mask]";
4
+ function r(t) {
5
+ if (t.isContentEditable === !0) return !0;
6
+ const e = t.getAttribute("contenteditable");
7
+ return e !== null && e.trim().toLowerCase() !== "false";
8
+ }
9
+ function a(t) {
10
+ return t.matches(n) || r(t);
11
+ }
12
+ function o(t) {
13
+ for (let e = t; e; e = e.parentElement)
14
+ if (a(e)) return !0;
15
+ return !1;
16
+ }
17
+ export {
18
+ o as a,
19
+ a as i
20
+ };
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ import { c as t, t as o } from "./loader-Ba4X-WNl.js";
2
+ import { p as s, t as p } from "./context-UnG6_X61.js";
3
+ import { a as k } from "./index-CfCbJJXa.js";
4
+ export {
5
+ t as createJourneeze,
6
+ k as isMasked,
7
+ s as pagePath,
8
+ o as takeReviewerToken,
9
+ p as tflowIdAt
10
+ };
@@ -0,0 +1,95 @@
1
+ function C(e) {
2
+ const c = `jz:reviewer:${e}`;
3
+ let i;
4
+ try {
5
+ const t = new URL(location.href), o = t.searchParams.get("jz_invite");
6
+ o && (t.searchParams.delete("jz_invite"), history.replaceState(history.state, "", t.href), i = o, sessionStorage.setItem(c, o)), i ?? (i = sessionStorage.getItem(c) ?? void 0);
7
+ } catch {
8
+ }
9
+ return i;
10
+ }
11
+ function I(e) {
12
+ try {
13
+ sessionStorage.removeItem(`jz:reviewer:${e}`);
14
+ } catch {
15
+ }
16
+ }
17
+ const x = /^(?:[0-9a-f]{64}|[A-Za-z0-9_-]{43})$/, S = /^pk_[0-9a-f]{32}$/, T = () => import("./widget-DQZm8sAC.js"), z = () => import("./help-C1x-y2f9.js"), y = /* @__PURE__ */ new Set();
18
+ function h(e) {
19
+ y.has(e) || (y.add(e), console.warn(`[journeeze] ${e}`));
20
+ }
21
+ function w(e) {
22
+ if (e === void 0 || x.test(e)) return e;
23
+ h("invalid userId ignored");
24
+ }
25
+ function b(e, c, i) {
26
+ let t, o, a = 0, u = -1;
27
+ const f = {
28
+ on() {
29
+ if (t) return Promise.resolve();
30
+ if (o && u === a) return o;
31
+ const r = u = a, s = e().then((l) => {
32
+ r === a && !t && (t = c(l, () => f.off()), i?.(!0));
33
+ }).finally(() => {
34
+ o === s && (o = void 0);
35
+ });
36
+ return o = s, s;
37
+ },
38
+ off(r) {
39
+ a++;
40
+ const s = t;
41
+ s && (t = void 0, s.unmount(r), i?.(!1));
42
+ },
43
+ mounted: () => t
44
+ };
45
+ return f;
46
+ }
47
+ const m = (e, c) => (...i) => {
48
+ try {
49
+ c(...i);
50
+ } catch (t) {
51
+ h(`${e} failed: ${String(t)}`);
52
+ }
53
+ };
54
+ function E(e, c = T, i = z) {
55
+ const { siteKey: t } = e, o = S.test(t);
56
+ o || h("invalid siteKey");
57
+ let a = w(e.userId), u = { ...e.context };
58
+ const f = () => u, r = { ...e };
59
+ Object.defineProperty(r, "userId", { get: () => a, enumerable: !0 }), e.respectGlobalPrivacyControl !== !1 && navigator.globalPrivacyControl && (r.noTelemetry = !0);
60
+ const s = b(c, (n, d) => n.mount(r, f, d), (n) => r.onModeChange?.(n)), l = b(i, (n, d) => n.mount(r, f, d)), p = (n) => async () => {
61
+ if (!o) throw new Error("[journeeze] invalid siteKey");
62
+ return n.on();
63
+ }, g = {
64
+ enable: p(s),
65
+ disable: m("disable", () => s.off()),
66
+ isEnabled: () => !!s.mounted(),
67
+ enableHelp: p(l),
68
+ disableHelp: m("disableHelp", () => l.off()),
69
+ isHelpEnabled: () => !!l.mounted(),
70
+ setContext: m("setContext", (n) => {
71
+ u = { ...u, ...n }, s.mounted()?.contextChanged?.(), l.mounted()?.contextChanged?.();
72
+ }),
73
+ getContext: f,
74
+ setUser: m("setUser", (n, d) => {
75
+ const v = w(n);
76
+ a !== void 0 && v !== a && g.reset(), a = v, r.signature = v && d;
77
+ }),
78
+ reset: m("reset", () => {
79
+ const n = !!l.mounted(), d = { ...r, userId: a };
80
+ s.off(!0), l.off(!0), a = void 0, u = {}, delete r.reviewerToken, I(t), import("./feedback-C4CYtS2A.js").then((v) => v.logout(d)).catch(() => {
81
+ }).then(() => {
82
+ n && !l.mounted() && l.on().catch(() => {
83
+ });
84
+ });
85
+ })
86
+ };
87
+ return g;
88
+ }
89
+ export {
90
+ S,
91
+ x as U,
92
+ E as c,
93
+ C as t,
94
+ h as w
95
+ };
package/dist/react.js ADDED
@@ -0,0 +1,70 @@
1
+ import { jsx as I } from "react/jsx-runtime";
2
+ import { createContext as O, useRef as l, useMemo as j, useEffect as f, useContext as N } from "react";
3
+ import { t as M, c as R, w as U } from "./loader-Ba4X-WNl.js";
4
+ import { CONTEXT_FIELDS as H } from "./contract.js";
5
+ const T = O(null), a = () => {
6
+ }, $ = Object.freeze({
7
+ enable: () => Promise.resolve(),
8
+ disable: a,
9
+ isEnabled: () => !1,
10
+ enableHelp: () => Promise.resolve(),
11
+ disableHelp: a,
12
+ isHelpEnabled: () => !1,
13
+ setContext: a,
14
+ getContext: () => ({}),
15
+ setUser: a,
16
+ reset: a
17
+ }), J = ["maskSelectors", "maskAllText", "nonce", "respectGlobalPrivacyControl", "pagePath", "signals"], D = (o, v) => JSON.stringify(o) === JSON.stringify(v);
18
+ function G(o) {
19
+ const { children: v, siteKey: c, endpoint: p, apiHost: m, apiPath: g, reviewerToken: b, context: u, userId: n, userIdSig: h, userIdExp: k, onModeChange: C, onHelpStatus: E } = o, w = l(C);
20
+ w.current = C;
21
+ const y = l(E);
22
+ y.current = E;
23
+ const P = l({}), t = j(() => {
24
+ const e = {};
25
+ for (const r of J) o[r] !== void 0 && Object.assign(e, { [r]: o[r] });
26
+ if (P.current = e, c === void 0) return $;
27
+ const i = b ?? M(c);
28
+ return R({
29
+ siteKey: c,
30
+ ...p === void 0 ? {} : { endpoint: p },
31
+ ...m === void 0 ? {} : { apiHost: m },
32
+ ...g === void 0 ? {} : { apiPath: g },
33
+ ...i === void 0 ? {} : { reviewerToken: i },
34
+ ...e,
35
+ onModeChange: (r) => w.current?.(r),
36
+ onHelpStatus: (r) => y.current?.(r)
37
+ });
38
+ }, [c, p, m, g, b]);
39
+ for (const e of J)
40
+ D(o[e], P.current[e]) || U(`\`${e}\` changed after the provider mounted and is ignored; pass a stable value or remount with a \`key\``);
41
+ f(
42
+ () => () => {
43
+ t.disable(), t.disableHelp();
44
+ },
45
+ [t]
46
+ );
47
+ const s = h === void 0 || k === void 0 ? void 0 : { sig: h, exp: k }, d = s ? `${s.sig}:${s.exp}` : "", x = l(void 0), S = (e) => s ? t.setUser(e, s) : t.setUser(e);
48
+ f(() => {
49
+ if (n !== void 0)
50
+ return S(n), x.current = d, () => t.reset();
51
+ }, [t, n]), f(() => {
52
+ n === void 0 || x.current === d || (S(n), x.current = d);
53
+ }, [t, n, d]);
54
+ const z = u === void 0 ? void 0 : H.map((e) => u[e] ?? "").join("\0");
55
+ return f(() => {
56
+ if (u === void 0) return;
57
+ const e = {};
58
+ for (const i of H) e[i] = u[i];
59
+ t.setContext(e);
60
+ }, [t, z, n]), /* @__PURE__ */ I(T.Provider, { value: t, children: v });
61
+ }
62
+ function L() {
63
+ const o = N(T);
64
+ if (!o) throw new Error("useJourneeze must be used inside <JourneezeProvider>");
65
+ return o;
66
+ }
67
+ export {
68
+ G as JourneezeProvider,
69
+ L as useJourneeze
70
+ };
@@ -0,0 +1,97 @@
1
+ import { T as c } from "./context-UnG6_X61.js";
2
+ const p = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/, b = /^[a-z]{2,32}$/, m = "input:not([type]),input[type=text],input[type=email],input[type=tel],input[type=url],input[type=password]", f = {
3
+ button: "button,input[type=button],input[type=submit],input[type=reset],input[type=image],summary",
4
+ link: "a[href],area[href]",
5
+ textbox: `textarea,${m}`,
6
+ searchbox: "input[type=search]",
7
+ checkbox: "input[type=checkbox]",
8
+ radio: "input[type=radio]",
9
+ combobox: "select:not([multiple]):not([size]),input[list]",
10
+ listbox: "select[multiple],select[size],datalist",
11
+ option: "option",
12
+ slider: "input[type=range]",
13
+ spinbutton: "input[type=number]",
14
+ progressbar: "progress",
15
+ heading: "h1,h2,h3,h4,h5,h6",
16
+ img: "img[alt]:not([alt='']),svg[aria-label]",
17
+ list: "ul,ol,menu",
18
+ listitem: "li",
19
+ table: "table",
20
+ row: "tr",
21
+ cell: "td",
22
+ columnheader: "th",
23
+ navigation: "nav",
24
+ main: "main",
25
+ form: "form",
26
+ dialog: "dialog",
27
+ article: "article",
28
+ separator: "hr",
29
+ group: "fieldset,details,optgroup"
30
+ }, d = /* @__PURE__ */ new Set(["button", "link", "heading", "option", "cell", "columnheader", "row", "listitem", "tab", "menuitem", "checkbox", "radio", "switch", "treeitem", "tooltip"]), r = (t) => (t ?? "").replace(/\s+/g, " ").trim(), h = (t) => {
31
+ const o = t.getBoundingClientRect();
32
+ return o.width > 0 || o.height > 0;
33
+ };
34
+ function g(t) {
35
+ const o = t.ownerDocument, e = [], n = t.getAttribute("id");
36
+ if (n)
37
+ for (const s of o.querySelectorAll("label")) s.getAttribute("for") === n && e.push(s);
38
+ const a = t.parentElement?.closest("label");
39
+ return a && !e.includes(a) && e.push(a), e;
40
+ }
41
+ function y(t, o) {
42
+ const e = t.ownerDocument, n = t.getAttribute("aria-labelledby");
43
+ if (n) {
44
+ const i = r(
45
+ n.split(/\s+/).map((l) => e.getElementById(l)?.textContent ?? "").join(" ")
46
+ );
47
+ if (i) return i;
48
+ }
49
+ const a = r(t.getAttribute("aria-label"));
50
+ if (a) return a;
51
+ const s = r(g(t).map((i) => i.textContent).join(" "));
52
+ if (s) return s;
53
+ const u = r(t.getAttribute("alt"));
54
+ if (u) return u;
55
+ if (t instanceof HTMLInputElement && /^(button|submit|reset)$/.test(t.type)) {
56
+ const i = r(t.value);
57
+ if (i) return i;
58
+ }
59
+ if (d.has(o)) {
60
+ const i = r(t.textContent);
61
+ if (i) return i;
62
+ }
63
+ return r(t.getAttribute("title")) || r(t.getAttribute("placeholder"));
64
+ }
65
+ function v(t, o) {
66
+ const e = (n) => [...o.querySelectorAll(n)];
67
+ try {
68
+ switch (t.by) {
69
+ case "tflow":
70
+ return c.test(t.value) ? e(`[data-tflow-id="${t.value}"]`) : [];
71
+ case "testId":
72
+ return p.test(t.value) ? e(`[data-testid="${t.value}"]`) : [];
73
+ case "role": {
74
+ if (!b.test(t.value)) return [];
75
+ const n = f[t.value], a = e(n ? `[role="${t.value}"],${n}` : `[role="${t.value}"]`), s = r(t.name);
76
+ return a.filter((u) => {
77
+ const i = u.getAttribute("role");
78
+ return i && i.split(/\s+/)[0] !== t.value ? !1 : !s || y(u, t.value) === s;
79
+ });
80
+ }
81
+ case "css":
82
+ return e(t.value);
83
+ }
84
+ } catch {
85
+ }
86
+ return [];
87
+ }
88
+ function A(t, o = document) {
89
+ for (const e of t) {
90
+ const n = v(e, o).filter(h);
91
+ if (n.length === 1) return n[0];
92
+ }
93
+ }
94
+ export {
95
+ y as accessibleName,
96
+ A as resolveTarget
97
+ };
package/dist/script.js ADDED
@@ -0,0 +1,13 @@
1
+ import { t as c, c as d } from "./loader-Ba4X-WNl.js";
2
+ const o = document.querySelector("script[data-journeeze-site-key]"), t = o?.dataset.journeezeSiteKey;
3
+ if (t && !window.Journeeze) {
4
+ const n = c(t), e = o?.dataset ?? {}, a = e.journeezeEndpoint, i = e.journeezeApiHost, r = e.journeezeApiPath, s = d({
5
+ siteKey: t,
6
+ ...a ? { endpoint: a } : {},
7
+ ...i ? { apiHost: i } : {},
8
+ ...r ? { apiPath: r } : {},
9
+ ...n ? { reviewerToken: n } : {}
10
+ });
11
+ window.Journeeze = s, o?.hasAttribute("data-journeeze-help") && s.enableHelp().catch(() => {
12
+ });
13
+ }