kenobi-js 0.1.38 → 0.1.40
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 +6 -41
- package/browser/dist.js.map +2 -2
- package/browser/dist.min.js +5 -5
- package/package.json +1 -1
package/browser/dist.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Kenobi SDK v0.1.
|
|
2
|
+
* Kenobi SDK v0.1.38
|
|
3
3
|
* (c) 2025 Kenobi.ai
|
|
4
4
|
*/
|
|
5
5
|
"use strict";
|
|
@@ -2439,7 +2439,6 @@ var KenobiLib = (() => {
|
|
|
2439
2439
|
__publicField(this, "currentUrl");
|
|
2440
2440
|
__publicField(this, "navTicking", false);
|
|
2441
2441
|
__publicField(this, "transitionDefaults");
|
|
2442
|
-
__publicField(this, "cueCardPaths");
|
|
2443
2442
|
__publicField(this, "startAutoTransform", /* @__PURE__ */ __name(async () => {
|
|
2444
2443
|
try {
|
|
2445
2444
|
this.syncChangeStack();
|
|
@@ -2572,23 +2571,6 @@ var KenobiLib = (() => {
|
|
|
2572
2571
|
__publicField(this, "getDurationInMilliseconds", /* @__PURE__ */ __name((start, end) => +end - +start, "getDurationInMilliseconds"));
|
|
2573
2572
|
__publicField(this, "formatThousands", /* @__PURE__ */ __name((number) => new Intl.NumberFormat("en-US").format(number), "formatThousands"));
|
|
2574
2573
|
__publicField(this, "setDebug", /* @__PURE__ */ __name((value) => this.config.debug = value, "setDebug"));
|
|
2575
|
-
/**
|
|
2576
|
-
* Checks if a path matches a pattern.
|
|
2577
|
-
* Supports exact matches ("/pricing") and wildcard suffixes ("/blog/*").
|
|
2578
|
-
*/
|
|
2579
|
-
__publicField(this, "matchesPathPattern", /* @__PURE__ */ __name((path, pattern) => {
|
|
2580
|
-
const normalizedPath = path === "/" ? "/" : path.replace(/\/$/, "");
|
|
2581
|
-
const normalizedPattern = pattern === "/" ? "/" : pattern.replace(/\/$/, "");
|
|
2582
|
-
if (normalizedPattern.endsWith("/*")) {
|
|
2583
|
-
const base = normalizedPattern.slice(0, -2);
|
|
2584
|
-
return normalizedPath === base || normalizedPath.startsWith(base + "/");
|
|
2585
|
-
}
|
|
2586
|
-
return normalizedPath === normalizedPattern;
|
|
2587
|
-
}, "matchesPathPattern"));
|
|
2588
|
-
/**
|
|
2589
|
-
* Checks if the given path matches any of the configured cueCardPaths.
|
|
2590
|
-
*/
|
|
2591
|
-
__publicField(this, "isPathAllowedForCueCard", /* @__PURE__ */ __name((path) => this.cueCardPaths.some((pattern) => this.matchesPathPattern(path, pattern)), "isPathAllowedForCueCard"));
|
|
2592
2574
|
__publicField(this, "isInputElement", /* @__PURE__ */ __name((el) => {
|
|
2593
2575
|
if (!(el instanceof HTMLInputElement) && !(el instanceof HTMLTextAreaElement) && !(el instanceof HTMLSelectElement))
|
|
2594
2576
|
return false;
|
|
@@ -3107,13 +3089,6 @@ var KenobiLib = (() => {
|
|
|
3107
3089
|
this.log("warn", "CueCard already initialized, skipping...");
|
|
3108
3090
|
return;
|
|
3109
3091
|
}
|
|
3110
|
-
if (!this.isPathAllowedForCueCard(this.currentPath)) {
|
|
3111
|
-
this.log(
|
|
3112
|
-
"debug",
|
|
3113
|
-
`CueCard not mounted: path "${this.currentPath}" not in allowed paths`
|
|
3114
|
-
);
|
|
3115
|
-
return;
|
|
3116
|
-
}
|
|
3117
3092
|
const configResponse = await this.fetchCueCardConfig(this.currentPath);
|
|
3118
3093
|
if (!configResponse || !configResponse.enabled) {
|
|
3119
3094
|
this.log(
|
|
@@ -3161,26 +3136,17 @@ var KenobiLib = (() => {
|
|
|
3161
3136
|
}, "initCueCard"));
|
|
3162
3137
|
/**
|
|
3163
3138
|
* Syncs CueCard visibility based on the current path.
|
|
3164
|
-
*
|
|
3139
|
+
* Checks with the server if an active template exists for the new path.
|
|
3165
3140
|
* Called after navigation changes.
|
|
3166
3141
|
*/
|
|
3167
|
-
__publicField(this, "syncCueCardVisibility", /* @__PURE__ */ __name(() => {
|
|
3142
|
+
__publicField(this, "syncCueCardVisibility", /* @__PURE__ */ __name(async () => {
|
|
3168
3143
|
if (!this.config.publicKey) return;
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
this.log(
|
|
3172
|
-
"debug",
|
|
3173
|
-
`Navigated to allowed path "${this.currentPath}", checking for active template...`
|
|
3174
|
-
);
|
|
3175
|
-
void this.initCueCard();
|
|
3176
|
-
} else if (!isAllowed && this.cueCardInstance) {
|
|
3177
|
-
this.log(
|
|
3178
|
-
"debug",
|
|
3179
|
-
`Navigated away from allowed paths to "${this.currentPath}", unmounting CueCard`
|
|
3180
|
-
);
|
|
3144
|
+
if (this.cueCardInstance) {
|
|
3145
|
+
this.log("debug", `Navigation detected, unmounting CueCard`);
|
|
3181
3146
|
this.cueCardInstance.unmount();
|
|
3182
3147
|
this.cueCardInstance = null;
|
|
3183
3148
|
}
|
|
3149
|
+
void this.initCueCard();
|
|
3184
3150
|
}, "syncCueCardVisibility"));
|
|
3185
3151
|
/**
|
|
3186
3152
|
* Triggers personalization by calling the API with the provided input.
|
|
@@ -3260,7 +3226,6 @@ var KenobiLib = (() => {
|
|
|
3260
3226
|
this.config.transitionDefaults
|
|
3261
3227
|
);
|
|
3262
3228
|
this.orchestrator = new TransitionOrchestrator();
|
|
3263
|
-
this.cueCardPaths = this.config.cueCardPaths ?? ["/"];
|
|
3264
3229
|
this.syncVisitorKey();
|
|
3265
3230
|
this.currentPath = this.getCurrentPath();
|
|
3266
3231
|
this.currentUrl = this.getCurrentUrl();
|