kenobi-js 0.1.36 → 0.1.37
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/browser/dist.js +50 -0
- package/browser/dist.js.map +2 -2
- package/browser/dist.min.js +5 -5
- package/package.json +1 -1
package/browser/dist.js
CHANGED
|
@@ -2434,6 +2434,7 @@ var KenobiLib = (() => {
|
|
|
2434
2434
|
__publicField(this, "currentUrl");
|
|
2435
2435
|
__publicField(this, "navTicking", false);
|
|
2436
2436
|
__publicField(this, "transitionDefaults");
|
|
2437
|
+
__publicField(this, "cueCardPaths");
|
|
2437
2438
|
__publicField(this, "startAutoTransform", /* @__PURE__ */ __name(async () => {
|
|
2438
2439
|
try {
|
|
2439
2440
|
this.syncChangeStack();
|
|
@@ -2566,6 +2567,23 @@ var KenobiLib = (() => {
|
|
|
2566
2567
|
__publicField(this, "getDurationInMilliseconds", /* @__PURE__ */ __name((start, end) => +end - +start, "getDurationInMilliseconds"));
|
|
2567
2568
|
__publicField(this, "formatThousands", /* @__PURE__ */ __name((number) => new Intl.NumberFormat("en-US").format(number), "formatThousands"));
|
|
2568
2569
|
__publicField(this, "setDebug", /* @__PURE__ */ __name((value) => this.config.debug = value, "setDebug"));
|
|
2570
|
+
/**
|
|
2571
|
+
* Checks if a path matches a pattern.
|
|
2572
|
+
* Supports exact matches ("/pricing") and wildcard suffixes ("/blog/*").
|
|
2573
|
+
*/
|
|
2574
|
+
__publicField(this, "matchesPathPattern", /* @__PURE__ */ __name((path, pattern) => {
|
|
2575
|
+
const normalizedPath = path === "/" ? "/" : path.replace(/\/$/, "");
|
|
2576
|
+
const normalizedPattern = pattern === "/" ? "/" : pattern.replace(/\/$/, "");
|
|
2577
|
+
if (normalizedPattern.endsWith("/*")) {
|
|
2578
|
+
const base = normalizedPattern.slice(0, -2);
|
|
2579
|
+
return normalizedPath === base || normalizedPath.startsWith(base + "/");
|
|
2580
|
+
}
|
|
2581
|
+
return normalizedPath === normalizedPattern;
|
|
2582
|
+
}, "matchesPathPattern"));
|
|
2583
|
+
/**
|
|
2584
|
+
* Checks if the given path matches any of the configured cueCardPaths.
|
|
2585
|
+
*/
|
|
2586
|
+
__publicField(this, "isPathAllowedForCueCard", /* @__PURE__ */ __name((path) => this.cueCardPaths.some((pattern) => this.matchesPathPattern(path, pattern)), "isPathAllowedForCueCard"));
|
|
2569
2587
|
__publicField(this, "isInputElement", /* @__PURE__ */ __name((el) => {
|
|
2570
2588
|
if (!(el instanceof HTMLInputElement) && !(el instanceof HTMLTextAreaElement) && !(el instanceof HTMLSelectElement))
|
|
2571
2589
|
return false;
|
|
@@ -2675,6 +2693,7 @@ var KenobiLib = (() => {
|
|
|
2675
2693
|
this.undoAll();
|
|
2676
2694
|
void this.startAutoTransform();
|
|
2677
2695
|
}
|
|
2696
|
+
this.syncCueCardVisibility();
|
|
2678
2697
|
}
|
|
2679
2698
|
});
|
|
2680
2699
|
}, "schedule");
|
|
@@ -3048,6 +3067,13 @@ var KenobiLib = (() => {
|
|
|
3048
3067
|
this.log("warn", "CueCard already initialized, skipping...");
|
|
3049
3068
|
return;
|
|
3050
3069
|
}
|
|
3070
|
+
if (!this.isPathAllowedForCueCard(this.currentPath)) {
|
|
3071
|
+
this.log(
|
|
3072
|
+
"debug",
|
|
3073
|
+
`CueCard not mounted: path "${this.currentPath}" not in allowed paths`
|
|
3074
|
+
);
|
|
3075
|
+
return;
|
|
3076
|
+
}
|
|
3051
3077
|
this.cueCardInstance = new CueCard({
|
|
3052
3078
|
theme: "light",
|
|
3053
3079
|
position: "top-center",
|
|
@@ -3080,6 +3106,29 @@ var KenobiLib = (() => {
|
|
|
3080
3106
|
this.cueCardInstance.mount();
|
|
3081
3107
|
this.log("debug", "CueCard mounted successfully");
|
|
3082
3108
|
}, "initCueCard"));
|
|
3109
|
+
/**
|
|
3110
|
+
* Syncs CueCard visibility based on the current path.
|
|
3111
|
+
* Mounts CueCard if on an allowed path, unmounts if not.
|
|
3112
|
+
* Called after navigation changes.
|
|
3113
|
+
*/
|
|
3114
|
+
__publicField(this, "syncCueCardVisibility", /* @__PURE__ */ __name(() => {
|
|
3115
|
+
if (!this.config.publicKey) return;
|
|
3116
|
+
const isAllowed = this.isPathAllowedForCueCard(this.currentPath);
|
|
3117
|
+
if (isAllowed && !this.cueCardInstance) {
|
|
3118
|
+
this.log(
|
|
3119
|
+
"debug",
|
|
3120
|
+
`Navigated to allowed path "${this.currentPath}", mounting CueCard`
|
|
3121
|
+
);
|
|
3122
|
+
this.initCueCard();
|
|
3123
|
+
} else if (!isAllowed && this.cueCardInstance) {
|
|
3124
|
+
this.log(
|
|
3125
|
+
"debug",
|
|
3126
|
+
`Navigated away from allowed paths to "${this.currentPath}", unmounting CueCard`
|
|
3127
|
+
);
|
|
3128
|
+
this.cueCardInstance.unmount();
|
|
3129
|
+
this.cueCardInstance = null;
|
|
3130
|
+
}
|
|
3131
|
+
}, "syncCueCardVisibility"));
|
|
3083
3132
|
/**
|
|
3084
3133
|
* Triggers personalization by calling the API with the provided input.
|
|
3085
3134
|
* Updates CueCard status during the flow and applies transformations.
|
|
@@ -3158,6 +3207,7 @@ var KenobiLib = (() => {
|
|
|
3158
3207
|
this.config.transitionDefaults
|
|
3159
3208
|
);
|
|
3160
3209
|
this.orchestrator = new TransitionOrchestrator();
|
|
3210
|
+
this.cueCardPaths = this.config.cueCardPaths ?? ["/"];
|
|
3161
3211
|
this.syncVisitorKey();
|
|
3162
3212
|
this.currentPath = this.getCurrentPath();
|
|
3163
3213
|
this.currentUrl = this.getCurrentUrl();
|