rivia 0.0.64 → 0.0.66

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 +123 -211
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -197,10 +197,10 @@ function Onboarding(topTitle = "Get Started", subtitle, completion = 0, checklis
197
197
  }
198
198
  if (storedVisited2 && storedVisited2.length >= checklistItems.length) {
199
199
  if (sessionStorage.getItem("CompletedAll") != "true") return;
200
- const label = document.createElement("div");
201
- label.id = "route-label";
202
- label.innerText = "\u{1F389} Congrats! You've completed all items!";
203
- Object.assign(label.style, {
200
+ const label2 = document.createElement("div");
201
+ label2.id = "route-label";
202
+ label2.innerText = "\u{1F389} Congrats! You've completed all items!";
203
+ Object.assign(label2.style, {
204
204
  position: "fixed",
205
205
  bottom: "20px",
206
206
  left: "20px",
@@ -215,13 +215,13 @@ function Onboarding(topTitle = "Get Started", subtitle, completion = 0, checklis
215
215
  opacity: 0,
216
216
  transition: "opacity 0.5s ease"
217
217
  });
218
- document.body.appendChild(label);
218
+ document.body.appendChild(label2);
219
219
  requestAnimationFrame(() => {
220
- label.style.opacity = 1;
220
+ label2.style.opacity = 1;
221
221
  });
222
222
  setTimeout(() => {
223
- label.style.opacity = 0;
224
- setTimeout(() => label.remove(), 500);
223
+ label2.style.opacity = 0;
224
+ setTimeout(() => label2.remove(), 500);
225
225
  }, 3e3);
226
226
  sessionStorage.setItem("CompletedAll", "false ");
227
227
  return;
@@ -475,24 +475,24 @@ transform: translateY(-20%);
475
475
  document.head.appendChild(style2);
476
476
  console.log("inside injectChecklistBaseCSS");
477
477
  }
478
- let label = document.getElementById("route-label");
479
- if (!label) {
480
- label = document.createElement("div");
481
- label.id = "route-label";
482
- label.innerHTML = labelHTML;
478
+ let label2 = document.getElementById("route-label");
479
+ if (!label2) {
480
+ label2 = document.createElement("div");
481
+ label2.id = "route-label";
482
+ label2.innerHTML = labelHTML;
483
483
  }
484
- const closeElement = label.querySelector(`#checklistCloseBtn`);
484
+ const closeElement = label2.querySelector(`#checklistCloseBtn`);
485
485
  closeElement.addEventListener("click", (e) => {
486
486
  e.stopPropagation();
487
- label.style.opacity = "0";
488
- label.style.pointerEvents = "none";
487
+ label2.style.opacity = "0";
488
+ label2.style.pointerEvents = "none";
489
489
  sessionStorage.setItem("onboardingVisible", "false");
490
490
  closeBtn.style.display = "none";
491
- showBtn.style.display = "block";
491
+ showBtn2.style.display = "block";
492
492
  });
493
- const dismissElement = label.querySelector(`#dismissChecklist`);
493
+ const dismissElement = label2.querySelector(`#dismissChecklist`);
494
494
  dismissElement.addEventListener("click", (e) => {
495
- label.style.display = "none";
495
+ label2.style.display = "none";
496
496
  e.stopPropagation();
497
497
  const confirmDiv = document.createElement("div");
498
498
  confirmDiv.innerHTML = `
@@ -510,20 +510,20 @@ transform: translateY(-20%);
510
510
  const yesBtn = confirmDiv.querySelector("#confirmYes");
511
511
  const noBtn = confirmDiv.querySelector("#confirmNo");
512
512
  yesBtn.addEventListener("click", () => {
513
- label.style.display = "none";
514
- label.style.pointerEvents = "none";
513
+ label2.style.display = "none";
514
+ label2.style.pointerEvents = "none";
515
515
  closeBtn.style.display = "none";
516
- showBtn.style.display = "none";
516
+ showBtn2.style.display = "none";
517
517
  sessionStorage.setItem("dismissedChecklist", "true");
518
518
  document.body.removeChild(confirmDiv);
519
519
  });
520
520
  noBtn.addEventListener("click", () => {
521
521
  document.body.removeChild(confirmDiv);
522
- showBtn.style.display = "block";
522
+ showBtn2.style.display = "block";
523
523
  });
524
524
  });
525
525
  function createSlabs(n) {
526
- const container = label.querySelector("#progressContainer");
526
+ const container = label2.querySelector("#progressContainer");
527
527
  if (!container) return;
528
528
  container.innerHTML = "";
529
529
  for (let i2 = 0; i2 < n; i2++) {
@@ -549,20 +549,20 @@ transform: translateY(-20%);
549
549
  height: 5px;
550
550
  }
551
551
  `;
552
- label.appendChild(style);
552
+ label2.appendChild(style);
553
553
  function updateProgress(completed) {
554
- const slabs = label.querySelectorAll(".slab");
554
+ const slabs = label2.querySelectorAll(".slab");
555
555
  slabs.forEach((slab, index) => {
556
556
  slab.classList.toggle("active", index < completed);
557
557
  });
558
- const fraction = label.querySelector("#progressFraction");
558
+ const fraction = label2.querySelector("#progressFraction");
559
559
  if (fraction) {
560
560
  fraction.textContent = `${completed}/${slabs.length}`;
561
561
  }
562
562
  }
563
563
  createSlabs(items.length);
564
564
  if (storedVisited2) updateProgress(storedVisited2.length);
565
- Object.assign(label.style, {
565
+ Object.assign(label2.style, {
566
566
  position: "fixed",
567
567
  bottom: "80px",
568
568
  left: "20px",
@@ -585,13 +585,13 @@ transform: translateY(-20%);
585
585
  display: "none",
586
586
  pointerEvents: "none"
587
587
  });
588
- let showBtn = document.getElementById("show-tooltip-btn");
589
- if (!showBtn) {
590
- showBtn = document.createElement("button");
591
- showBtn.id = "show-tooltip-btn";
588
+ let showBtn2 = document.getElementById("show-tooltip-btn");
589
+ if (!showBtn2) {
590
+ showBtn2 = document.createElement("button");
591
+ showBtn2.id = "show-tooltip-btn";
592
592
  }
593
593
  function createS(n) {
594
- const container2 = showBtn.querySelector("#progressContainerBtn");
594
+ const container2 = showBtn2.querySelector("#progressContainerBtn");
595
595
  if (!container2) return;
596
596
  container2.innerHTML = "";
597
597
  for (let i2 = 0; i2 < n; i2++) {
@@ -601,7 +601,7 @@ transform: translateY(-20%);
601
601
  }
602
602
  }
603
603
  function updateProgress2(completed) {
604
- const slab2 = showBtn.querySelectorAll("#progressContainerBtn .slab");
604
+ const slab2 = showBtn2.querySelectorAll("#progressContainerBtn .slab");
605
605
  slab2.forEach((slab, index) => {
606
606
  if (index < completed) {
607
607
  slab.classList.add("active");
@@ -610,8 +610,8 @@ transform: translateY(-20%);
610
610
  }
611
611
  });
612
612
  }
613
- showBtn.id = "show-tooltip-btn";
614
- showBtn.className = "rivia-launcher";
613
+ showBtn2.id = "show-tooltip-btn";
614
+ showBtn2.className = "rivia-launcher";
615
615
  const translateStyle = cssConfig.launcherProgressBar ? 'style="transform: translateY(10px);"' : "";
616
616
  const isRight = cssConfig.launcherPosition === "right";
617
617
  const iconHTML = cssConfig.launcherShowIcon ? `<svg class="launcher-icon" width="24" height="24" ${translateStyle} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -623,9 +623,9 @@ transform: translateY(-20%);
623
623
  </svg>` : "";
624
624
  const textTranslateStyle = !cssConfig.launcherProgressBar ? " translateY(50%);" : "";
625
625
  if (!cssConfig.launcherProgressBar) {
626
- showBtn.classList.add("no-progress");
626
+ showBtn2.classList.add("no-progress");
627
627
  }
628
- showBtn.innerHTML = `
628
+ showBtn2.innerHTML = `
629
629
  <div class="launcher-root">
630
630
  <div class="launcher-left">
631
631
 
@@ -669,7 +669,7 @@ transform: translateY(-20%);
669
669
  root.style.setProperty("--body-color", cssConfig2.lowerBodyColor);
670
670
  }
671
671
  injectChecklistBaseCSS();
672
- Object.assign(showBtn.style, {
672
+ Object.assign(showBtn2.style, {
673
673
  bottom: cssConfig.launcherSpacingBottom || "20px",
674
674
  left: isRight ? "auto" : cssConfig.launcherSpacingLeft || "20px",
675
675
  right: isRight ? cssConfig.launcherSpacingRight || "20px" : "auto",
@@ -678,16 +678,16 @@ transform: translateY(-20%);
678
678
  borderRadius: `${cssConfig.launcherBorderRadius || 6}px`
679
679
  /* CSS variables */
680
680
  });
681
- showBtn.style.setProperty("--launcher-bg", cssConfig.launcherBackgroundColor || "#f78f07");
682
- showBtn.style.setProperty("--launcher-text", cssConfig.launcherTextColor || "#ffffff");
683
- showBtn.style.setProperty("--font-size", cssConfig.fontSize || "14px");
684
- applyChecklistTheme(label, cssConfig);
681
+ showBtn2.style.setProperty("--launcher-bg", cssConfig.launcherBackgroundColor || "#f78f07");
682
+ showBtn2.style.setProperty("--launcher-text", cssConfig.launcherTextColor || "#ffffff");
683
+ showBtn2.style.setProperty("--font-size", cssConfig.fontSize || "14px");
684
+ applyChecklistTheme(label2, cssConfig);
685
685
  injectChecklistBaseCSS();
686
- if (!document.contains(showBtn))
687
- document.body.appendChild(showBtn);
686
+ if (!document.contains(showBtn2))
687
+ document.body.appendChild(showBtn2);
688
688
  console.log("after applyChecklistTheme");
689
- if (!document.contains(label))
690
- document.body.appendChild(label);
689
+ if (!document.contains(label2))
690
+ document.body.appendChild(label2);
691
691
  if (!cssConfig.launcherProgressBar) {
692
692
  const progressContainerBtn = document.getElementById("progressContainerBtn");
693
693
  if (progressContainerBtn) {
@@ -705,8 +705,8 @@ transform: translateY(-20%);
705
705
  window.storedVisited = storedVisited2;
706
706
  window.uploadVisitedPagesInBackground = uploadVisitedPagesInBackground;
707
707
  window.items = items;
708
- window.label = label;
709
- window.showBtn = showBtn;
708
+ window.label = label2;
709
+ window.showBtn = showBtn2;
710
710
  const closeBtn = document.createElement("button");
711
711
  closeBtn.id = "tooltip-close-btn";
712
712
  closeBtn.innerHTML = "\u2715";
@@ -727,7 +727,7 @@ transform: translateY(-20%);
727
727
  zIndex: 1e4
728
728
  });
729
729
  function positionCloseBtn() {
730
- const rect = label.getBoundingClientRect();
730
+ const rect = label2.getBoundingClientRect();
731
731
  closeBtn.style.left = `${Math.max(8, rect.left + rect.width / 2 - 170)}px`;
732
732
  closeBtn.style.top = `${rect.bottom + 10}px`;
733
733
  }
@@ -792,12 +792,12 @@ transform: translateY(-20%);
792
792
  const cleanUrl = path.startsWith("/") ? path.slice(1) : path;
793
793
  if (storedVisited2.length >= checklistItems.length) {
794
794
  (() => {
795
- if (label2 && label2.parentNode) label2.remove();
796
- if (showBtn && showBtn.parentNode) showBtn.remove();
797
- const label2 = document.createElement("div");
798
- label2.id = "route-label";
799
- label2.innerText = "\u{1F389} Congrats! You've completed all items!";
800
- Object.assign(label2.style, {
795
+ if (label22 && label22.parentNode) label22.remove();
796
+ if (showBtn2 && showBtn2.parentNode) showBtn2.remove();
797
+ const label22 = document.createElement("div");
798
+ label22.id = "route-label";
799
+ label22.innerText = "\u{1F389} Congrats! You've completed all items!";
800
+ Object.assign(label22.style, {
801
801
  position: "fixed",
802
802
  bottom: "20px",
803
803
  left: "20px",
@@ -812,14 +812,14 @@ transform: translateY(-20%);
812
812
  opacity: 0,
813
813
  transition: "opacity 0.5s ease"
814
814
  });
815
- document.body.appendChild(label2);
815
+ document.body.appendChild(label22);
816
816
  })();
817
817
  }
818
818
  handleVisit(cleanUrl, { source: "click" });
819
819
  if (storedVisited2.length >= checklistItems.length) {
820
820
  (() => {
821
- if (label && label.parentNode) label.remove();
822
- if (showBtn && showBtn.parentNode) showBtn.remove();
821
+ if (label2 && label2.parentNode) label2.remove();
822
+ if (showBtn2 && showBtn2.parentNode) showBtn2.remove();
823
823
  const label3 = document.createElement("div");
824
824
  label3.id = "route-label";
825
825
  label3.innerText = "\u{1F389} Congrats! You've completed all items!";
@@ -933,7 +933,7 @@ transform: translateY(-20%);
933
933
  let completed2 = progressData2.completedPages;
934
934
  completed2.forEach((path2) => {
935
935
  const stepId = visitedPages[path2];
936
- const stepElement = label.querySelector(`#${stepId}`);
936
+ const stepElement = label2.querySelector(`#${stepId}`);
937
937
  if (!stepElement) return;
938
938
  const circle = stepElement.querySelector(".onboard-circle");
939
939
  if (circle) {
@@ -971,15 +971,15 @@ transform: translateY(-20%);
971
971
  Math.round(completed2.length / items.length * 100)
972
972
  );
973
973
  const percentText2 = `${progress2}%`;
974
- const labelPercent2 = label.querySelector("#progressFraction");
975
- const btnPercent2 = showBtn.querySelector("#progressFraction");
974
+ const labelPercent2 = label2.querySelector("#progressFraction");
975
+ const btnPercent2 = showBtn2.querySelector("#progressFraction");
976
976
  if (labelPercent2) labelPercent2.textContent = percentText2;
977
977
  if (btnPercent2) btnPercent2.textContent = percentText2;
978
- const progressFraction2 = label.querySelector("#progressFraction");
978
+ const progressFraction2 = label2.querySelector("#progressFraction");
979
979
  if (progressFraction2) {
980
980
  progressFraction2.textContent = `${completed2.length}/${items.length}`;
981
981
  }
982
- const btnFraction2 = showBtn.querySelector("#progressFraction");
982
+ const btnFraction2 = showBtn2.querySelector("#progressFraction");
983
983
  if (btnFraction2) {
984
984
  btnFraction2.textContent = `${completed2.length}/${items.length}`;
985
985
  }
@@ -1002,7 +1002,7 @@ transform: translateY(-20%);
1002
1002
  completed2.forEach((path2) => {
1003
1003
  let activeStepId2 = sessionStorage.getItem("activeStepId") || null;
1004
1004
  const stepId = visitedPages[path2];
1005
- const stepElement = label.querySelector(`#${stepId}`);
1005
+ const stepElement = label2.querySelector(`#${stepId}`);
1006
1006
  if (!stepElement) return;
1007
1007
  const circle = stepElement.querySelector(".onboard-circle");
1008
1008
  if (circle) {
@@ -1040,15 +1040,15 @@ transform: translateY(-20%);
1040
1040
  Math.round(completed2.length / items.length * 100)
1041
1041
  );
1042
1042
  const percentText2 = `${progress2}%`;
1043
- const labelPercent2 = label.querySelector("#progressFraction");
1044
- const btnPercent2 = showBtn.querySelector("#progressFraction");
1043
+ const labelPercent2 = label2.querySelector("#progressFraction");
1044
+ const btnPercent2 = showBtn2.querySelector("#progressFraction");
1045
1045
  if (labelPercent2) labelPercent2.textContent = percentText2;
1046
1046
  if (btnPercent2) btnPercent2.textContent = percentText2;
1047
- const progressFraction2 = label.querySelector("#progressFraction");
1047
+ const progressFraction2 = label2.querySelector("#progressFraction");
1048
1048
  if (progressFraction2) {
1049
1049
  progressFraction2.textContent = `${completed2.length}/${items.length}`;
1050
1050
  }
1051
- const btnFraction2 = showBtn.querySelector("#progressFraction");
1051
+ const btnFraction2 = showBtn2.querySelector("#progressFraction");
1052
1052
  if (btnFraction2) {
1053
1053
  btnFraction2.textContent = `${completed2.length}/${items.length} `;
1054
1054
  }
@@ -1060,14 +1060,14 @@ transform: translateY(-20%);
1060
1060
  }
1061
1061
  if (completion == 0) {
1062
1062
  items.forEach((it) => {
1063
- const stepEl = label.querySelector(`#${it.id}`);
1063
+ const stepEl = label2.querySelector(`#${it.id}`);
1064
1064
  if (!stepEl) return;
1065
1065
  const startSelect = stepEl.querySelector(".start-select");
1066
1066
  startSelect.style.display = "none";
1067
1067
  stepEl.addEventListener("click", () => {
1068
1068
  if (it.event_name == "click" && it.button_name == "") {
1069
1069
  items.forEach((inner) => {
1070
- const el = label.querySelector(`#${inner.id}`);
1070
+ const el = label2.querySelector(`#${inner.id}`);
1071
1071
  if (el) {
1072
1072
  const sel = el.querySelector(".start-select");
1073
1073
  if (sel) sel.style.display = "none";
@@ -1117,7 +1117,7 @@ transform: translateY(-20%);
1117
1117
  if (!sessionStorage.getItem("c")) sessionStorage.setItem("c", 1);
1118
1118
  let c = parseInt(sessionStorage.getItem("c") || "1");
1119
1119
  items.forEach((it, index) => {
1120
- const stepEl = label.querySelector(`#${it.id}`);
1120
+ const stepEl = label2.querySelector(`#${it.id}`);
1121
1121
  if (!stepEl) return;
1122
1122
  const startSelect = stepEl.querySelector(".start-select");
1123
1123
  startSelect.style.display = "none";
@@ -1132,7 +1132,7 @@ transform: translateY(-20%);
1132
1132
  }
1133
1133
  sessionStorage.setItem("c", c + 1);
1134
1134
  items.forEach((inner) => {
1135
- const el = label.querySelector(`#${inner.id}`);
1135
+ const el = label2.querySelector(`#${inner.id}`);
1136
1136
  if (el) {
1137
1137
  const sel = el.querySelector(".start-select");
1138
1138
  if (sel) sel.style.display = "none";
@@ -1161,52 +1161,52 @@ transform: translateY(-20%);
1161
1161
  });
1162
1162
  });
1163
1163
  }
1164
- showBtn.addEventListener("click", (e) => {
1164
+ showBtn2.addEventListener("click", (e) => {
1165
1165
  e.stopPropagation();
1166
- label.style.display = "block";
1167
- label.style.pointerEvents = "auto";
1166
+ label2.style.display = "block";
1167
+ label2.style.pointerEvents = "auto";
1168
1168
  closeBtn.style.display = "flex";
1169
- showBtn.style.display = "none";
1169
+ showBtn2.style.display = "none";
1170
1170
  sessionStorage.setItem("onboardingVisible", "true");
1171
1171
  positionCloseBtn();
1172
1172
  requestAnimationFrame(() => {
1173
- label.style.opacity = "1";
1173
+ label2.style.opacity = "1";
1174
1174
  });
1175
1175
  });
1176
1176
  closeBtn.addEventListener("click", (ev) => {
1177
1177
  ev.stopPropagation();
1178
- label.style.opacity = "0";
1179
- label.style.pointerEvents = "none";
1178
+ label2.style.opacity = "0";
1179
+ label2.style.pointerEvents = "none";
1180
1180
  closeBtn.style.display = "none";
1181
- showBtn.style.display = "block";
1181
+ showBtn2.style.display = "block";
1182
1182
  });
1183
- label.addEventListener(
1183
+ label2.addEventListener(
1184
1184
  "mouseenter",
1185
- () => label.style.transform = "scale(1.02)"
1185
+ () => label2.style.transform = "scale(1.02)"
1186
1186
  );
1187
- label.addEventListener(
1187
+ label2.addEventListener(
1188
1188
  "mouseleave",
1189
- () => label.style.transform = "scale(1)"
1189
+ () => label2.style.transform = "scale(1)"
1190
1190
  );
1191
- label.addEventListener("click", () => {
1191
+ label2.addEventListener("click", () => {
1192
1192
  const getStarted = document.querySelector("button#get-started");
1193
1193
  if (getStarted) getStarted.click();
1194
1194
  });
1195
1195
  if (sessionStorage.getItem("onboardingVisible") === "true") {
1196
- label.style.display = "block";
1197
- label.style.pointerEvents = "auto";
1196
+ label2.style.display = "block";
1197
+ label2.style.pointerEvents = "auto";
1198
1198
  closeBtn.style.display = "flex";
1199
- showBtn.style.display = "none";
1199
+ showBtn2.style.display = "none";
1200
1200
  sessionStorage.setItem("onboardingVisible", "true");
1201
1201
  positionCloseBtn();
1202
1202
  } else {
1203
- showBtn.style.display = "block";
1204
- label.style.display = "none";
1203
+ showBtn2.style.display = "block";
1204
+ label2.style.display = "none";
1205
1205
  }
1206
- label.style.opacity = "1";
1206
+ label2.style.opacity = "1";
1207
1207
  updateUIFromVisited();
1208
1208
  window.addEventListener("resize", () => {
1209
- if (label.style.display !== "none") positionCloseBtn();
1209
+ if (label2.style.display !== "none") positionCloseBtn();
1210
1210
  });
1211
1211
  }
1212
1212
  function evaluateRule(rule, context) {
@@ -1281,16 +1281,16 @@ function evaluateRules(rules, context) {
1281
1281
  return finalResult;
1282
1282
  }
1283
1283
  async function Checklist(workspace_id, obj) {
1284
- window.addEventListener("popstate", async () => {
1284
+ window.addEventListener("locationchange", async () => {
1285
1285
  window.workspace_id = workspace_id;
1286
1286
  window.userid = obj.userid;
1287
- let user_var2 = obj.userid;
1287
+ let user_var = obj.userid;
1288
1288
  window.sign_up_at = obj.sign_up_at;
1289
1289
  window.role = obj.role;
1290
1290
  window.email = obj.email;
1291
1291
  console.log("");
1292
1292
  try {
1293
- let doesRouteMatch3 = function(routes) {
1293
+ let doesRouteMatch2 = function(routes) {
1294
1294
  if (!Array.isArray(routes)) return true;
1295
1295
  const currentPath2 = window.location.pathname.toLowerCase();
1296
1296
  console.log("Current Path:", currentPath2);
@@ -1301,15 +1301,15 @@ async function Checklist(workspace_id, obj) {
1301
1301
  if (normalizedRoute.includes("[dynamic]")) {
1302
1302
  const base = normalizedRoute.split("[dynamic]")[0].replace(/\/$/, "");
1303
1303
  console.log("Base:", base);
1304
- pattern = new RegExp(`^${escapeRegex3(base)}(/.*)?$`);
1304
+ pattern = new RegExp(`^${escapeRegex2(base)}(/.*)?$`);
1305
1305
  } else {
1306
- pattern = new RegExp(`^${escapeRegex3(normalizedRoute)}$`);
1306
+ pattern = new RegExp(`^${escapeRegex2(normalizedRoute)}$`);
1307
1307
  }
1308
1308
  return pattern.test(currentPath2);
1309
1309
  });
1310
- }, escapeRegex3 = function(str) {
1310
+ }, escapeRegex2 = function(str) {
1311
1311
  return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1312
- }, buildContext3 = function(obj2) {
1312
+ }, buildContext2 = function(obj2) {
1313
1313
  return {
1314
1314
  userid: obj2.userid,
1315
1315
  role: obj2.role,
@@ -1319,7 +1319,7 @@ async function Checklist(workspace_id, obj) {
1319
1319
  last_name: obj2.last_name
1320
1320
  };
1321
1321
  };
1322
- var doesRouteMatch2 = doesRouteMatch3, escapeRegex2 = escapeRegex3, buildContext2 = buildContext3;
1322
+ var doesRouteMatch = doesRouteMatch2, escapeRegex = escapeRegex2, buildContext = buildContext2;
1323
1323
  const res = await fetch(
1324
1324
  `https://demoapi.rivia.ai/checklist_by_workspace2/${workspace_id}`,
1325
1325
  {
@@ -1340,9 +1340,9 @@ async function Checklist(workspace_id, obj) {
1340
1340
  if (!chk?.publish)
1341
1341
  return false;
1342
1342
  if (!chk?.targeting_data?.display)
1343
- return !doesRouteMatch3(routes, currentPath);
1343
+ return !doesRouteMatch2(routes, currentPath);
1344
1344
  else
1345
- return doesRouteMatch3(routes, currentPath);
1345
+ return doesRouteMatch2(routes, currentPath);
1346
1346
  });
1347
1347
  if (!matchedChecklist) {
1348
1348
  console.log("No checklist applicable for this route");
@@ -1352,7 +1352,7 @@ async function Checklist(workspace_id, obj) {
1352
1352
  console.log("matched ch", matchedChecklist);
1353
1353
  const rules = matchedChecklist?.targeting_data?.custom_rules || [];
1354
1354
  console.log("rules", rules);
1355
- const context = buildContext3(obj);
1355
+ const context = buildContext2(obj);
1356
1356
  const shouldShow = evaluateRules(rules, context);
1357
1357
  if (!shouldShow) {
1358
1358
  return;
@@ -1382,7 +1382,7 @@ async function Checklist(workspace_id, obj) {
1382
1382
  cssConfig,
1383
1383
  targetingData,
1384
1384
  customCSS,
1385
- user_var2,
1385
+ user_var,
1386
1386
  checklist_id
1387
1387
  );
1388
1388
  return matchedChecklist;
@@ -1391,114 +1391,26 @@ async function Checklist(workspace_id, obj) {
1391
1391
  throw err;
1392
1392
  }
1393
1393
  });
1394
- window.workspace_id = workspace_id;
1395
- window.userid = obj.userid;
1396
- let user_var = obj.userid;
1397
- window.sign_up_at = obj.sign_up_at;
1398
- window.role = obj.role;
1399
- window.email = obj.email;
1400
- console.log("");
1401
- try {
1402
- let doesRouteMatch2 = function(routes) {
1403
- if (!Array.isArray(routes)) return true;
1404
- const currentPath2 = window.location.pathname.toLowerCase();
1405
- console.log("Current Path:", currentPath2);
1406
- return routes.some((route) => {
1407
- if (!route) return false;
1408
- let pattern;
1409
- const normalizedRoute = route.toLowerCase().replace(/\/$/, "");
1410
- if (normalizedRoute.includes("[dynamic]")) {
1411
- const base = normalizedRoute.split("[dynamic]")[0].replace(/\/$/, "");
1412
- console.log("Base:", base);
1413
- pattern = new RegExp(`^${escapeRegex2(base)}(/.*)?$`);
1414
- } else {
1415
- pattern = new RegExp(`^${escapeRegex2(normalizedRoute)}$`);
1416
- }
1417
- return pattern.test(currentPath2);
1418
- });
1419
- }, escapeRegex2 = function(str) {
1420
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1421
- }, buildContext2 = function(obj2) {
1422
- return {
1423
- userid: obj2.userid,
1424
- role: obj2.role,
1425
- sign_up_at: obj2.sign_up_at,
1426
- email: obj2.email,
1427
- first_name: obj2.first_name,
1428
- last_name: obj2.last_name
1429
- };
1394
+ (function() {
1395
+ if (label)
1396
+ label.remove();
1397
+ if (showBtn)
1398
+ showBtn.remove();
1399
+ const pushState = history.pushState;
1400
+ const replaceState = history.replaceState;
1401
+ history.pushState = function() {
1402
+ pushState.apply(history, arguments);
1403
+ window.dispatchEvent(new Event("locationchange"));
1430
1404
  };
1431
- var doesRouteMatch = doesRouteMatch2, escapeRegex = escapeRegex2, buildContext = buildContext2;
1432
- const res = await fetch(
1433
- `https://demoapi.rivia.ai/checklist_by_workspace2/${workspace_id}`,
1434
- {
1435
- method: "GET",
1436
- headers: { "Content-Type": "application/json" }
1437
- }
1438
- );
1439
- if (!res.ok) {
1440
- console.warn("\u274C Failed to fetch checklist");
1441
- return;
1442
- }
1443
- const data = await res.json();
1444
- const checklists = data.checklist || [];
1445
- if (!Array.isArray(checklists) || checklists.length === 0) return;
1446
- const currentPath = window.location.pathname;
1447
- const matchedChecklist = checklists.find((chk) => {
1448
- const routes = chk?.targeting_data?.routes;
1449
- if (!chk?.publish)
1450
- return false;
1451
- if (!chk?.targeting_data?.display)
1452
- return !doesRouteMatch2(routes, currentPath);
1453
- else
1454
- return doesRouteMatch2(routes, currentPath);
1455
- });
1456
- if (!matchedChecklist) {
1457
- console.log("No checklist applicable for this route");
1458
- return;
1459
- }
1460
- console.log("userid", obj.userid);
1461
- console.log("matched ch", matchedChecklist);
1462
- const rules = matchedChecklist?.targeting_data?.custom_rules || [];
1463
- console.log("rules", rules);
1464
- const context = buildContext2(obj);
1465
- const shouldShow = evaluateRules(rules, context);
1466
- if (!shouldShow) {
1467
- return;
1468
- }
1469
- const {
1470
- checklist_id,
1471
- title = "Untitled Checklist",
1472
- subtitle = "Describe the purpose of this checklist...",
1473
- items = [],
1474
- completion = 0,
1475
- branding_data: cssConfig = {},
1476
- targeting_data: targetingData = {},
1477
- customCSS = ""
1478
- } = matchedChecklist;
1479
- const fullData = {
1480
- checklist: matchedChecklist,
1481
- cssConfig,
1482
- targetingData,
1483
- customCSS
1405
+ history.replaceState = function() {
1406
+ replaceState.apply(history, arguments);
1407
+ window.dispatchEvent(new Event("locationchange"));
1484
1408
  };
1485
- sessionStorage.removeItem("onboardingVisited");
1486
- Onboarding(
1487
- title,
1488
- subtitle,
1489
- completion,
1490
- items,
1491
- cssConfig,
1492
- targetingData,
1493
- customCSS,
1494
- user_var,
1495
- checklist_id
1496
- );
1497
- return matchedChecklist;
1498
- } catch (err) {
1499
- console.warn("Checklist error:", err.message);
1500
- throw err;
1501
- }
1409
+ window.addEventListener("popstate", () => {
1410
+ window.dispatchEvent(new Event("locationchange"));
1411
+ });
1412
+ window.dispatchEvent(new Event("locationchange"));
1413
+ })();
1502
1414
  }
1503
1415
  var rivia_default = Checklist;
1504
1416
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rivia",
3
- "version": "0.0.64",
3
+ "version": "0.0.66",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",