kenobi-js 0.1.37 → 0.1.38
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 +70 -17
- 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.37
|
|
3
3
|
* (c) 2025 Kenobi.ai
|
|
4
4
|
*/
|
|
5
5
|
"use strict";
|
|
@@ -2398,6 +2398,11 @@ var KenobiLib = (() => {
|
|
|
2398
2398
|
};
|
|
2399
2399
|
__name(_TransitionOrchestrator, "TransitionOrchestrator");
|
|
2400
2400
|
var TransitionOrchestrator = _TransitionOrchestrator;
|
|
2401
|
+
var isCueCardConfigResponse = /* @__PURE__ */ __name((value) => {
|
|
2402
|
+
if (typeof value !== "object" || value === null) return false;
|
|
2403
|
+
const candidate = value;
|
|
2404
|
+
return typeof candidate.enabled === "boolean";
|
|
2405
|
+
}, "isCueCardConfigResponse");
|
|
2401
2406
|
var TRANSFORMATION_ACTIONS = /* @__PURE__ */ new Set(["Replace", "InsertBefore", "InsertAfter", "Delete", "SetFormField"]);
|
|
2402
2407
|
var isString = /* @__PURE__ */ __name((value) => typeof value === "string", "isString");
|
|
2403
2408
|
var isStringArray = /* @__PURE__ */ __name((value) => Array.isArray(value) && value.every((item) => isString(item)), "isStringArray");
|
|
@@ -3056,13 +3061,48 @@ var KenobiLib = (() => {
|
|
|
3056
3061
|
----
|
|
3057
3062
|
*/
|
|
3058
3063
|
/**
|
|
3059
|
-
*
|
|
3064
|
+
* Fetches the CueCard configuration from the API to check if an active
|
|
3065
|
+
* template exists for the given path.
|
|
3066
|
+
*
|
|
3067
|
+
* @param pagePath - The page path to check for active template
|
|
3068
|
+
* @returns The config response, or null if the request failed
|
|
3069
|
+
*/
|
|
3070
|
+
__publicField(this, "fetchCueCardConfig", /* @__PURE__ */ __name(async (pagePath) => {
|
|
3071
|
+
if (!this.config.publicKey) return null;
|
|
3072
|
+
try {
|
|
3073
|
+
const searchParams = new URLSearchParams({
|
|
3074
|
+
publicKey: this.config.publicKey,
|
|
3075
|
+
pagePath
|
|
3076
|
+
});
|
|
3077
|
+
const response = await fetch(
|
|
3078
|
+
`${this.config.apiHost}/v1/cue-card-config?${searchParams.toString()}`
|
|
3079
|
+
);
|
|
3080
|
+
if (!response.ok) {
|
|
3081
|
+
this.log(
|
|
3082
|
+
"warn",
|
|
3083
|
+
`CueCard config request failed with status ${response.status}`
|
|
3084
|
+
);
|
|
3085
|
+
return null;
|
|
3086
|
+
}
|
|
3087
|
+
const data = await response.json();
|
|
3088
|
+
if (!isCueCardConfigResponse(data)) {
|
|
3089
|
+
this.log("warn", "Invalid CueCard config response format");
|
|
3090
|
+
return null;
|
|
3091
|
+
}
|
|
3092
|
+
return data;
|
|
3093
|
+
} catch (error) {
|
|
3094
|
+
this.log("error", "Failed to fetch CueCard config:", error);
|
|
3095
|
+
return null;
|
|
3096
|
+
}
|
|
3097
|
+
}, "fetchCueCardConfig"));
|
|
3098
|
+
/**
|
|
3099
|
+
* Initializes and mounts a CueCard with configuration from the API.
|
|
3060
3100
|
* Called automatically when publicKey is provided.
|
|
3061
3101
|
*
|
|
3062
|
-
*
|
|
3063
|
-
*
|
|
3102
|
+
* The CueCard will only be mounted if an active template exists for
|
|
3103
|
+
* the current path on the server.
|
|
3064
3104
|
*/
|
|
3065
|
-
__publicField(this, "initCueCard", /* @__PURE__ */ __name(() => {
|
|
3105
|
+
__publicField(this, "initCueCard", /* @__PURE__ */ __name(async () => {
|
|
3066
3106
|
if (this.cueCardInstance) {
|
|
3067
3107
|
this.log("warn", "CueCard already initialized, skipping...");
|
|
3068
3108
|
return;
|
|
@@ -3074,10 +3114,21 @@ var KenobiLib = (() => {
|
|
|
3074
3114
|
);
|
|
3075
3115
|
return;
|
|
3076
3116
|
}
|
|
3117
|
+
const configResponse = await this.fetchCueCardConfig(this.currentPath);
|
|
3118
|
+
if (!configResponse || !configResponse.enabled) {
|
|
3119
|
+
this.log(
|
|
3120
|
+
"debug",
|
|
3121
|
+
`CueCard not mounted: no active template for path "${this.currentPath}"`
|
|
3122
|
+
);
|
|
3123
|
+
return;
|
|
3124
|
+
}
|
|
3125
|
+
this.log("debug", "Active template found, mounting CueCard...");
|
|
3126
|
+
const serverConfig = configResponse.config;
|
|
3077
3127
|
this.cueCardInstance = new CueCard({
|
|
3078
|
-
theme: "light",
|
|
3079
|
-
position: "top-center",
|
|
3080
|
-
|
|
3128
|
+
theme: serverConfig?.theme ?? "light",
|
|
3129
|
+
position: serverConfig?.position ?? "top-center",
|
|
3130
|
+
direction: serverConfig?.direction ?? "top-to-bottom",
|
|
3131
|
+
fields: serverConfig?.fields ?? [
|
|
3081
3132
|
{
|
|
3082
3133
|
name: "companyDomain",
|
|
3083
3134
|
label: "Company Name or Domain",
|
|
@@ -3088,10 +3139,12 @@ var KenobiLib = (() => {
|
|
|
3088
3139
|
}
|
|
3089
3140
|
],
|
|
3090
3141
|
isVisible: true,
|
|
3091
|
-
enableFocusMode: false,
|
|
3092
|
-
showWatermark: false,
|
|
3093
|
-
showKeyboardHints: true,
|
|
3094
|
-
enableLauncher: true,
|
|
3142
|
+
enableFocusMode: serverConfig?.enableFocusMode ?? false,
|
|
3143
|
+
showWatermark: serverConfig?.showWatermark ?? false,
|
|
3144
|
+
showKeyboardHints: serverConfig?.showKeyboardHints ?? true,
|
|
3145
|
+
enableLauncher: serverConfig?.enableLauncher ?? true,
|
|
3146
|
+
customTheme: serverConfig?.customTheme,
|
|
3147
|
+
textOverrides: serverConfig?.textOverrides,
|
|
3095
3148
|
onDismiss: /* @__PURE__ */ __name(() => {
|
|
3096
3149
|
this.log("debug", "CueCard dismissed by user");
|
|
3097
3150
|
}, "onDismiss"),
|
|
@@ -3108,7 +3161,7 @@ var KenobiLib = (() => {
|
|
|
3108
3161
|
}, "initCueCard"));
|
|
3109
3162
|
/**
|
|
3110
3163
|
* Syncs CueCard visibility based on the current path.
|
|
3111
|
-
* Mounts CueCard if on an allowed path, unmounts if not.
|
|
3164
|
+
* Mounts CueCard if on an allowed path and active template exists, unmounts if not.
|
|
3112
3165
|
* Called after navigation changes.
|
|
3113
3166
|
*/
|
|
3114
3167
|
__publicField(this, "syncCueCardVisibility", /* @__PURE__ */ __name(() => {
|
|
@@ -3117,9 +3170,9 @@ var KenobiLib = (() => {
|
|
|
3117
3170
|
if (isAllowed && !this.cueCardInstance) {
|
|
3118
3171
|
this.log(
|
|
3119
3172
|
"debug",
|
|
3120
|
-
`Navigated to allowed path "${this.currentPath}",
|
|
3173
|
+
`Navigated to allowed path "${this.currentPath}", checking for active template...`
|
|
3121
3174
|
);
|
|
3122
|
-
this.initCueCard();
|
|
3175
|
+
void this.initCueCard();
|
|
3123
3176
|
} else if (!isAllowed && this.cueCardInstance) {
|
|
3124
3177
|
this.log(
|
|
3125
3178
|
"debug",
|
|
@@ -3226,8 +3279,8 @@ var KenobiLib = (() => {
|
|
|
3226
3279
|
void this.startAutoTransform();
|
|
3227
3280
|
}
|
|
3228
3281
|
if (this.config.publicKey) {
|
|
3229
|
-
this.log("debug", "Public key provided,
|
|
3230
|
-
this.initCueCard();
|
|
3282
|
+
this.log("debug", "Public key provided, checking for active template...");
|
|
3283
|
+
void this.initCueCard();
|
|
3231
3284
|
}
|
|
3232
3285
|
}
|
|
3233
3286
|
};
|