rivia 0.0.35 → 0.0.36

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 (2) hide show
  1. package/dist/index.js +35 -165
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -79,9 +79,9 @@ function Onboarding(topTitle = "Get Started", subtitle, completion = 0, checklis
79
79
  user_var1 = "User_" + Math.random().toString(36).substring(2, 8);
80
80
  sessionStorage.setItem(user_var, user_var1);
81
81
  }
82
- const backendUrl = `https://demoapi.rivia.ai/clients/${checklist_id}/${user_var1}`;
82
+ const backendUrl = `http://localhost:5000/clients/${checklist_id}/${user_var1}`;
83
83
  async function getUserProgress22() {
84
- const backendUrl2 = `https://demoapi.rivia.ai/clients/${checklist_id}/${user_var1}`;
84
+ const backendUrl2 = `http://localhost:5000/clients/${checklist_id}/${user_var1}`;
85
85
  try {
86
86
  const res = await fetch(backendUrl2, { credentials: "include" });
87
87
  if (!res.ok) console.warn(`GET failed: ${res.status}`);
@@ -119,7 +119,7 @@ function Onboarding(topTitle = "Get Started", subtitle, completion = 0, checklis
119
119
  }
120
120
  storedVisited = sessionStorage.getItem("onboardingVisited");
121
121
  async function getUserProgress22() {
122
- const backendUrl2 = `https://demoapi.rivia.ai/clients/${checklist_id}/${user_var1}`;
122
+ const backendUrl2 = `http://localhost:5000/clients/${checklist_id}/${user_var1}`;
123
123
  try {
124
124
  const res = await fetch(backendUrl2, { credentials: "include" });
125
125
  if (!res.ok) console.warn(`GET failed: ${res.status}`);
@@ -472,14 +472,18 @@ transform: translateY(-20%);
472
472
  document.head.appendChild(style2);
473
473
  console.log("inside injectChecklistBaseCSS");
474
474
  }
475
- const label = document.createElement("div");
476
- label.id = "route-label";
477
- label.innerHTML = labelHTML;
475
+ let label = document.getElementById("route-label");
476
+ if (!label) {
477
+ label = document.createElement("div");
478
+ label.id = "route-label";
479
+ label.innerHTML = labelHTML;
480
+ }
478
481
  const closeElement = label.querySelector(`#checklistCloseBtn`);
479
482
  closeElement.addEventListener("click", (e) => {
480
483
  e.stopPropagation();
481
484
  label.style.opacity = "0";
482
485
  label.style.pointerEvents = "none";
486
+ sessionStorage.setItem("onboardingVisible", "false");
483
487
  closeBtn.style.display = "none";
484
488
  showBtn.style.display = "block";
485
489
  });
@@ -578,7 +582,11 @@ transform: translateY(-20%);
578
582
  display: "none",
579
583
  pointerEvents: "none"
580
584
  });
581
- const showBtn = document.createElement("button");
585
+ let showBtn = document.getElementById("show-tooltip-btn");
586
+ if (!showBtn) {
587
+ showBtn = document.createElement("button");
588
+ showBtn.id = "show-tooltip-btn";
589
+ }
582
590
  function createS(n) {
583
591
  const container2 = showBtn.querySelector("#progressContainerBtn");
584
592
  if (!container2) return;
@@ -672,9 +680,11 @@ transform: translateY(-20%);
672
680
  showBtn.style.setProperty("--font-size", cssConfig.fontSize || "14px");
673
681
  applyChecklistTheme(label, cssConfig);
674
682
  injectChecklistBaseCSS();
675
- document.body.appendChild(showBtn);
683
+ if (!document.contains(showBtn))
684
+ document.body.appendChild(showBtn);
676
685
  console.log("after applyChecklistTheme");
677
- document.body.appendChild(label);
686
+ if (!document.contains(label))
687
+ document.body.appendChild(label);
678
688
  if (!cssConfig.launcherProgressBar) {
679
689
  const progressContainerBtn = document.getElementById("progressContainerBtn");
680
690
  if (progressContainerBtn) {
@@ -712,11 +722,6 @@ transform: translateY(-20%);
712
722
  }
713
723
  let check = 0;
714
724
  console.log("before");
715
- const EVENT_SRC_URL = "https://demoapi.rivia.ai/events";
716
- if (!window._onboardingEventSource) {
717
- window._onboardingEventSource = new EventSource(EVENT_SRC_URL);
718
- }
719
- const eventSource = window._onboardingEventSource;
720
725
  const STORAGE_KEY = "onboardingVisited";
721
726
  const visitedSet = new Set(
722
727
  JSON.parse(sessionStorage.getItem(STORAGE_KEY) || "[]")
@@ -751,70 +756,6 @@ transform: translateY(-20%);
751
756
  }
752
757
  return true;
753
758
  }
754
- eventSource.onopen = () => console.log("SSE connected");
755
- eventSource.onerror = (err) => console.log("SSE connection error:", err);
756
- eventSource.onmessage = (event) => {
757
- if (!event || !event.data) return;
758
- check = 1;
759
- let data;
760
- try {
761
- data = JSON.parse(event.data);
762
- } catch (err) {
763
- console.warn("Invalid SSE JSON:", event.data, err);
764
- return;
765
- }
766
- if (data.ping) {
767
- return;
768
- }
769
- const msg = data.message;
770
- if (!msg) return;
771
- if (processedMessages.has(msg)) {
772
- return;
773
- }
774
- processedMessages.add(msg);
775
- const it = items.find((i2) => i2.event_name && i2.event_name === msg);
776
- if (!it) {
777
- console.log("SSE message doesn't match any item:", msg);
778
- return;
779
- }
780
- try {
781
- const stepEl = label ? label.querySelector(`#${it.id}`) : null;
782
- if (stepEl) {
783
- const startSelect = stepEl.querySelector(".start-select");
784
- if (startSelect) startSelect.style.display = "none";
785
- }
786
- } catch (err) {
787
- }
788
- const path = it.url || "";
789
- const cleanUrl = path.startsWith("/") ? path.slice(1) : path;
790
- handleVisit(cleanUrl, { source: "sse" });
791
- if (storedVisited.length >= checklistItems.length) {
792
- console.log("All items completed via SSE");
793
- if (label && label.parentNode) label.remove();
794
- if (showBtn && showBtn.parentNode) showBtn.remove();
795
- const label3 = document.createElement("div");
796
- label3.id = "route-label";
797
- label3.innerText = "\u{1F389} Congrats! You've completed all items!";
798
- Object.assign(label3.style, {
799
- position: "fixed",
800
- bottom: "20px",
801
- left: "20px",
802
- backgroundColor: "#4CAF50",
803
- color: "white",
804
- padding: "10px 20px",
805
- borderRadius: "10px",
806
- boxShadow: "0 4px 6px rgba(0,0,0,0.2)",
807
- fontSize: "16px",
808
- fontWeight: "bold",
809
- zIndex: 9999,
810
- opacity: 0,
811
- transition: "opacity 0.5s ease"
812
- });
813
- document.body.appendChild(label3);
814
- }
815
- console.log("Received event (SSE):", msg);
816
- };
817
- console.log("after");
818
759
  function findButtonByText(buttonText) {
819
760
  if (!buttonText) return null;
820
761
  const needle = buttonText.trim().toLowerCase();
@@ -906,91 +847,11 @@ transform: translateY(-20%);
906
847
  updateProgress2(visitedSet.size);
907
848
  }
908
849
  });
909
- if (!window._onboardingEventSource) {
910
- window._onboardingEventSource = new EventSource(EVENT_SRC_URL);
911
- }
912
- eventSource.onopen = () => console.log("SSE connected");
913
- eventSource.onerror = (err) => console.log("SSE connection error:", err);
914
- eventSource.onmessage = (event) => {
915
- if (!event || !event.data) return;
916
- check = 1;
917
- let data;
918
- try {
919
- data = JSON.parse(event.data);
920
- } catch (err) {
921
- console.warn("Invalid SSE JSON:", event.data, err);
922
- return;
923
- }
924
- if (data.ping) {
925
- return;
926
- }
927
- const msg = data.message;
928
- console.log("SSE message received:", msg);
929
- if (!msg) return;
930
- if (processedMessages.has(msg)) {
931
- return;
932
- }
933
- processedMessages.add(msg);
934
- const it = items.find((i2) => i2.event_name && i2.event_name === msg);
935
- if (!it) {
936
- console.log("SSE message doesn't match any item:", msg);
937
- return;
938
- }
939
- const eventId = data.event_id;
940
- try {
941
- fetch("https://demoapi.rivia.ai/ack-event", {
942
- method: "POST",
943
- headers: { "Content-Type": "application/json" },
944
- body: JSON.stringify({ event_id: eventId })
945
- });
946
- console.log("ACK sent for", eventId);
947
- } catch (err) {
948
- console.warn("Failed to ACK", eventId, err);
949
- }
950
- try {
951
- const stepEl = label ? label.querySelector(`#${it.id}`) : null;
952
- if (stepEl) {
953
- const startSelect = stepEl.querySelector(".start-select");
954
- if (startSelect) startSelect.style.display = "none";
955
- }
956
- } catch (err) {
957
- }
958
- const path = it.url || "";
959
- const cleanUrl = path.startsWith("/") ? path.slice(1) : path;
960
- handleVisit(cleanUrl, { source: "sse" });
961
- if (storedVisited.length >= checklistItems.length) {
962
- console.log("All items completed via SSE");
963
- (() => {
964
- if (label && label.parentNode) label.remove();
965
- if (showBtn && showBtn.parentNode) showBtn.remove();
966
- const label3 = document.createElement("div");
967
- label3.id = "route-label";
968
- label3.innerText = "\u{1F389} Congrats! You've completed all items!";
969
- Object.assign(label3.style, {
970
- position: "fixed",
971
- bottom: "20px",
972
- left: "20px",
973
- backgroundColor: "#4CAF50",
974
- color: "white",
975
- padding: "10px 20px",
976
- borderRadius: "10px",
977
- boxShadow: "0 4px 6px rgba(0,0,0,0.2)",
978
- fontSize: "16px",
979
- fontWeight: "bold",
980
- zIndex: 9999,
981
- opacity: 0,
982
- transition: "opacity 0.5s ease"
983
- });
984
- document.body.appendChild(label3);
985
- })();
986
- }
987
- console.log("Received event (SSE):", msg);
988
- };
989
850
  let user_var2 = user_var;
990
851
  function uploadVisitedPagesInBackground(completed2, touched = false) {
991
852
  let activeStepId2 = sessionStorage.getItem("activeStepId") || null;
992
853
  let user_var22 = user_var;
993
- const backendUrl22 = `https://demoapi.rivia.ai/clients/${checklist_id}`;
854
+ const backendUrl22 = `http://localhost:5000/clients/${checklist_id}`;
994
855
  try {
995
856
  const payload = {
996
857
  name: user_var22,
@@ -1012,7 +873,6 @@ transform: translateY(-20%);
1012
873
  console.warn("\u274C Error preparing background upload:", err);
1013
874
  }
1014
875
  }
1015
- if (check == 0) uploadVisitedPagesInBackground(storedVisited, false);
1016
876
  let activeStepId = sessionStorage.getItem("activeStepId") || null;
1017
877
  function updateUIFromVisited() {
1018
878
  storedVisited = JSON.parse(
@@ -1022,7 +882,7 @@ transform: translateY(-20%);
1022
882
  storedVisited = sessionStorage.getItem("onboardingVisited");
1023
883
  if (!storedVisited || storedVisited == "[]") {
1024
884
  async function getUserProgress22() {
1025
- const backendUrl2 = `https://demoapi.rivia.ai/clients/${checklist_id}/${user_var}`;
885
+ const backendUrl2 = `http://localhost:5000/clients/${checklist_id}/${user_var}`;
1026
886
  try {
1027
887
  const res = await fetch(backendUrl2, { credentials: "include" });
1028
888
  if (!res.ok) console.warn(`GET failed: ${res.status}`);
@@ -1296,6 +1156,7 @@ transform: translateY(-20%);
1296
1156
  label.style.pointerEvents = "auto";
1297
1157
  closeBtn.style.display = "flex";
1298
1158
  showBtn.style.display = "none";
1159
+ sessionStorage.setItem("onboardingVisible", "true");
1299
1160
  positionCloseBtn();
1300
1161
  requestAnimationFrame(() => {
1301
1162
  label.style.opacity = "1";
@@ -1320,9 +1181,18 @@ transform: translateY(-20%);
1320
1181
  const getStarted = document.querySelector("button#get-started");
1321
1182
  if (getStarted) getStarted.click();
1322
1183
  });
1323
- showBtn.style.display = "block";
1324
- label.style.display = "none";
1325
- label.style.opacity = "0";
1184
+ if (sessionStorage.getItem("onboardingVisible") === "true") {
1185
+ label.style.display = "block";
1186
+ label.style.pointerEvents = "auto";
1187
+ closeBtn.style.display = "flex";
1188
+ showBtn.style.display = "none";
1189
+ sessionStorage.setItem("onboardingVisible", "true");
1190
+ positionCloseBtn();
1191
+ } else {
1192
+ showBtn.style.display = "block";
1193
+ label.style.display = "none";
1194
+ }
1195
+ label.style.opacity = "1";
1326
1196
  updateUIFromVisited();
1327
1197
  window.addEventListener("resize", () => {
1328
1198
  if (label.style.display !== "none") positionCloseBtn();
@@ -1526,7 +1396,7 @@ transform: translateY(-20%);
1526
1396
  return checklist2;
1527
1397
  }
1528
1398
  const res = await fetch(
1529
- `https://demoapi.rivia.ai/checklists2/${checklist_id}`,
1399
+ `http://localhost:5000/checklists2/${checklist_id}`,
1530
1400
  {
1531
1401
  method: "GET",
1532
1402
  headers: { "Content-Type": "application/json" }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rivia",
3
- "version": "0.0.35",
3
+ "version": "0.0.36",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",