@xpert-ai/chatkit-ui5 0.17.1 → 0.18.1
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/dist/chatkit.cjs +55 -12
- package/dist/chatkit.cjs.map +1 -1
- package/dist/chatkit.ui5.js +55 -12
- package/dist/chatkit.ui5.js.map +1 -1
- package/dist/index.js +56 -13
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/chatkit.cjs
CHANGED
|
@@ -48,7 +48,7 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
|
|
|
48
48
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
49
49
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
50
50
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
51
|
-
var _a, _b, _setTrainingOptOut_dec, _hideHistory_dec, _showHistory_dec, _sendCustomAction_dec, _shareThread_dec, _focusMessage_dec, _setThreadId_dec, _setRuntimeCapabilities_dec, _setComposerValue_dec, _sendUserMessage_dec, _fetchUpdates_dec, _focusComposer_dec, _c, _opts, _frameUrl, _frame, _wrapper, _windowDrag, _launcherCloseButton, _launcherOpen, _chatMinimizedToPet, _framePetOptionsOverride, _petClosedByContextMenu, _shadow, _petOverlay, _resolveLoaded, _loaded, _channelId, _messenger, _ChatKitElementBase_instances, emitAndThrow_fn, setOptionsDataAttributes_fn, getDisplayMode_fn, getConfiguredPetOptions_fn, mergeConfiguredPetPositionDefaults_fn, getOverlayPetOptions_fn, resolvePetAssetUrl_fn, resolveOverlayPetOptions_fn, getFrameOptions_fn, setLauncherOpen_fn, setChatMinimizedToPet_fn, syncPetOverlayOptions_fn, handlePetActivate_fn, handlePetClose_fn, handlePetReply_fn, handlePetThreadSummaryActivate_fn, _handleLauncherClose, getFrameUrl_fn, setFrameUrl_fn, consumeFrameUrl_fn, _handleFrameLoad, _initialized, maybeInit_fn, _init;
|
|
51
|
+
var _a, _b, _setTrainingOptOut_dec, _hideHistory_dec, _showHistory_dec, _sendCustomAction_dec, _shareThread_dec, _focusMessage_dec, _prepareLeave_dec, _setThreadId_dec, _setRuntimeCapabilities_dec, _setComposerValue_dec, _sendUserMessage_dec, _fetchUpdates_dec, _focusComposer_dec, _c, _opts, _frameUrl, _frame, _wrapper, _windowDrag, _launcherCloseButton, _launcherOpen, _chatMinimizedToPet, _framePetOptionsOverride, _petClosedByContextMenu, _shadow, _petOverlay, _resolveLoaded, _loaded, _channelId, _messenger, _ChatKitElementBase_instances, emitAndThrow_fn, setOptionsDataAttributes_fn, getDisplayMode_fn, getConfiguredPetOptions_fn, mergeConfiguredPetPositionDefaults_fn, getOverlayPetOptions_fn, resolvePetAssetUrl_fn, resolveOverlayPetOptions_fn, getFrameOptions_fn, setLauncherOpen_fn, setChatMinimizedToPet_fn, syncPetOverlayOptions_fn, handlePetActivate_fn, handlePetClose_fn, handlePetReply_fn, handlePetThreadSummaryActivate_fn, _handleLauncherClose, getFrameUrl_fn, setFrameUrl_fn, consumeFrameUrl_fn, _handleFrameLoad, _initialized, maybeInit_fn, _init;
|
|
52
52
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
53
53
|
const chatkitTypes = require("@xpert-ai/chatkit-types");
|
|
54
54
|
class EventEmitter {
|
|
@@ -272,10 +272,12 @@ class HttpError extends Error {
|
|
|
272
272
|
super(message);
|
|
273
273
|
__publicField(this, "status");
|
|
274
274
|
__publicField(this, "statusText");
|
|
275
|
+
__publicField(this, "retryAfterMs");
|
|
275
276
|
__publicField(this, "metadata");
|
|
276
277
|
this.name = "HttpError";
|
|
277
278
|
this.statusText = res.statusText;
|
|
278
279
|
this.status = res.status;
|
|
280
|
+
this.retryAfterMs = res.retryAfterMs;
|
|
279
281
|
this.metadata = metadata;
|
|
280
282
|
}
|
|
281
283
|
static fromPossibleFrameSafeError(error) {
|
|
@@ -288,7 +290,8 @@ class HttpError extends Error {
|
|
|
288
290
|
safeError.message,
|
|
289
291
|
{
|
|
290
292
|
status: safeError.status,
|
|
291
|
-
statusText: safeError.statusText
|
|
293
|
+
statusText: safeError.statusText,
|
|
294
|
+
retryAfterMs: safeError.retryAfterMs
|
|
292
295
|
},
|
|
293
296
|
safeError.metadata
|
|
294
297
|
);
|
|
@@ -306,11 +309,13 @@ const _FrameSafeHttpError = class _FrameSafeHttpError {
|
|
|
306
309
|
__publicField(this, "stack");
|
|
307
310
|
__publicField(this, "status");
|
|
308
311
|
__publicField(this, "statusText");
|
|
312
|
+
__publicField(this, "retryAfterMs");
|
|
309
313
|
__publicField(this, "metadata");
|
|
310
314
|
this.message = message;
|
|
311
315
|
this.stack = new Error(message).stack;
|
|
312
316
|
this.status = res.status;
|
|
313
317
|
this.statusText = res.statusText;
|
|
318
|
+
this.retryAfterMs = res.retryAfterMs;
|
|
314
319
|
this.metadata = metadata;
|
|
315
320
|
}
|
|
316
321
|
static fromHttpError(error) {
|
|
@@ -318,7 +323,8 @@ const _FrameSafeHttpError = class _FrameSafeHttpError {
|
|
|
318
323
|
error.message,
|
|
319
324
|
{
|
|
320
325
|
status: error.status,
|
|
321
|
-
statusText: error.statusText
|
|
326
|
+
statusText: error.statusText,
|
|
327
|
+
retryAfterMs: error.retryAfterMs
|
|
322
328
|
},
|
|
323
329
|
error.metadata
|
|
324
330
|
);
|
|
@@ -440,19 +446,42 @@ class FrameSafeIntegrationError {
|
|
|
440
446
|
}
|
|
441
447
|
}
|
|
442
448
|
function serializeFrameError(error) {
|
|
449
|
+
if (error instanceof HttpError || error instanceof FrameSafeHttpError) {
|
|
450
|
+
try {
|
|
451
|
+
return structuredClone(
|
|
452
|
+
error instanceof HttpError ? FrameSafeHttpError.fromHttpError(error) : error
|
|
453
|
+
);
|
|
454
|
+
} catch {
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
if (error && typeof error === "object" && "status" in error && typeof error.status === "number") {
|
|
458
|
+
const message = "message" in error && typeof error.message === "string" ? error.message : "ChatKit host request failed";
|
|
459
|
+
return new FrameSafeHttpError(message, {
|
|
460
|
+
status: error.status,
|
|
461
|
+
statusText: "statusText" in error && typeof error.statusText === "string" ? error.statusText : void 0,
|
|
462
|
+
retryAfterMs: readRetryAfterMs(error)
|
|
463
|
+
});
|
|
464
|
+
}
|
|
443
465
|
try {
|
|
444
466
|
return structuredClone(error);
|
|
445
467
|
} catch {
|
|
446
468
|
const message = error && typeof error === "object" && "message" in error && typeof error.message === "string" ? error.message : "ChatKit host request failed";
|
|
447
|
-
if (error && typeof error === "object" && "status" in error && typeof error.status === "number") {
|
|
448
|
-
return new FrameSafeHttpError(message, {
|
|
449
|
-
status: error.status,
|
|
450
|
-
statusText: "statusText" in error && typeof error.statusText === "string" ? error.statusText : void 0
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
469
|
return new Error(message);
|
|
454
470
|
}
|
|
455
471
|
}
|
|
472
|
+
function readRetryAfterMs(error) {
|
|
473
|
+
if ("retryAfterMs" in error && typeof error.retryAfterMs === "number" && Number.isFinite(error.retryAfterMs)) {
|
|
474
|
+
return Math.max(0, error.retryAfterMs);
|
|
475
|
+
}
|
|
476
|
+
if (!("headers" in error) || !error.headers || typeof error.headers !== "object")
|
|
477
|
+
return;
|
|
478
|
+
const headers = error.headers;
|
|
479
|
+
if (!("get" in headers) || typeof headers.get !== "function") return;
|
|
480
|
+
const value = headers.get("Retry-After");
|
|
481
|
+
if (typeof value !== "string" || !value.trim()) return;
|
|
482
|
+
const duration = /^\d+(\.\d+)?$/.test(value.trim()) ? Number(value) * 1e3 : Date.parse(value) - Date.now();
|
|
483
|
+
return Number.isFinite(duration) ? Math.max(0, duration) : void 0;
|
|
484
|
+
}
|
|
456
485
|
class BaseMessenger {
|
|
457
486
|
constructor({
|
|
458
487
|
handlers,
|
|
@@ -755,6 +784,7 @@ const BASE_CAPABILITY_ALLOWLIST = [
|
|
|
755
784
|
"command.setThreadId",
|
|
756
785
|
"command.focusComposer",
|
|
757
786
|
"command.focusMessage",
|
|
787
|
+
"command.prepareLeave",
|
|
758
788
|
"command.fetchUpdates",
|
|
759
789
|
"command.sendCustomAction",
|
|
760
790
|
"command.showHistory",
|
|
@@ -2504,7 +2534,7 @@ function requireCommandCapability(value, context) {
|
|
|
2504
2534
|
return value.apply(this, args);
|
|
2505
2535
|
};
|
|
2506
2536
|
}
|
|
2507
|
-
class ChatKitElementBase extends (_c = HTMLElement, _focusComposer_dec = [requireCommandCapability], _fetchUpdates_dec = [requireCommandCapability], _sendUserMessage_dec = [requireCommandCapability], _setComposerValue_dec = [requireCommandCapability], _setRuntimeCapabilities_dec = [requireCommandCapability], _setThreadId_dec = [requireCommandCapability], _focusMessage_dec = [requireCommandCapability], _shareThread_dec = [requireCommandCapability], _sendCustomAction_dec = [requireCommandCapability], _showHistory_dec = [requireCommandCapability], _hideHistory_dec = [requireCommandCapability], _setTrainingOptOut_dec = [requireCommandCapability], _c) {
|
|
2537
|
+
class ChatKitElementBase extends (_c = HTMLElement, _focusComposer_dec = [requireCommandCapability], _fetchUpdates_dec = [requireCommandCapability], _sendUserMessage_dec = [requireCommandCapability], _setComposerValue_dec = [requireCommandCapability], _setRuntimeCapabilities_dec = [requireCommandCapability], _setThreadId_dec = [requireCommandCapability], _prepareLeave_dec = [requireCommandCapability], _focusMessage_dec = [requireCommandCapability], _shareThread_dec = [requireCommandCapability], _sendCustomAction_dec = [requireCommandCapability], _showHistory_dec = [requireCommandCapability], _hideHistory_dec = [requireCommandCapability], _setTrainingOptOut_dec = [requireCommandCapability], _c) {
|
|
2508
2538
|
constructor({ profile }) {
|
|
2509
2539
|
super();
|
|
2510
2540
|
__runInitializers(_init, 5, this);
|
|
@@ -3050,6 +3080,11 @@ class ChatKitElementBase extends (_c = HTMLElement, _focusComposer_dec = [requir
|
|
|
3050
3080
|
await __privateGet(this, _loaded);
|
|
3051
3081
|
await ((_a2 = __privateGet(this, _messenger)) == null ? void 0 : _a2.commands.setThreadId({ threadId }));
|
|
3052
3082
|
}
|
|
3083
|
+
async prepareLeave() {
|
|
3084
|
+
await __privateGet(this, _loaded);
|
|
3085
|
+
if (!__privateGet(this, _messenger)) return false;
|
|
3086
|
+
return __privateGet(this, _messenger).commands.prepareLeave();
|
|
3087
|
+
}
|
|
3053
3088
|
async focusMessage(request) {
|
|
3054
3089
|
await __privateGet(this, _loaded);
|
|
3055
3090
|
if (!__privateGet(this, _messenger)) return { success: false, code: "not_ready" };
|
|
@@ -3119,7 +3154,7 @@ getConfiguredPetOptions_fn = function(options = __privateGet(this, _opts)) {
|
|
|
3119
3154
|
return null;
|
|
3120
3155
|
}
|
|
3121
3156
|
if (__privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this, options) === "pet" && !chatkitTypes.normalizePetOptions(options.pet ?? null)) {
|
|
3122
|
-
return true;
|
|
3157
|
+
return typeof options.pet === "object" ? { ...options.pet, enabled: true } : true;
|
|
3123
3158
|
}
|
|
3124
3159
|
return options.pet ?? null;
|
|
3125
3160
|
};
|
|
@@ -3177,7 +3212,11 @@ resolvePetAssetUrl_fn = function(src) {
|
|
|
3177
3212
|
}
|
|
3178
3213
|
};
|
|
3179
3214
|
resolveOverlayPetOptions_fn = function(pet) {
|
|
3180
|
-
|
|
3215
|
+
var _a2;
|
|
3216
|
+
const assetsBaseUrl = chatkitTypes.getPetAssetsBaseUrl(pet ?? void 0) ?? chatkitTypes.getPetAssetsBaseUrl((_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.pet);
|
|
3217
|
+
const normalized = chatkitTypes.normalizePetOptions(
|
|
3218
|
+
pet ? { ...pet === true ? {} : pet, assetsBaseUrl } : null
|
|
3219
|
+
);
|
|
3181
3220
|
if (!normalized) {
|
|
3182
3221
|
return null;
|
|
3183
3222
|
}
|
|
@@ -3323,6 +3362,7 @@ __decorateElement(_init, 1, "sendUserMessage", _sendUserMessage_dec, ChatKitElem
|
|
|
3323
3362
|
__decorateElement(_init, 1, "setComposerValue", _setComposerValue_dec, ChatKitElementBase);
|
|
3324
3363
|
__decorateElement(_init, 1, "setRuntimeCapabilities", _setRuntimeCapabilities_dec, ChatKitElementBase);
|
|
3325
3364
|
__decorateElement(_init, 1, "setThreadId", _setThreadId_dec, ChatKitElementBase);
|
|
3365
|
+
__decorateElement(_init, 1, "prepareLeave", _prepareLeave_dec, ChatKitElementBase);
|
|
3326
3366
|
__decorateElement(_init, 1, "focusMessage", _focusMessage_dec, ChatKitElementBase);
|
|
3327
3367
|
__decorateElement(_init, 1, "shareThread", _shareThread_dec, ChatKitElementBase);
|
|
3328
3368
|
__decorateElement(_init, 1, "sendCustomAction", _sendCustomAction_dec, ChatKitElementBase);
|
|
@@ -3539,6 +3579,9 @@ const ChatKit = ControlBase.extend("xpertai.chatkit.ui5.ChatKit", {
|
|
|
3539
3579
|
}
|
|
3540
3580
|
return methodRef.apply(el, args);
|
|
3541
3581
|
},
|
|
3582
|
+
async prepareLeave() {
|
|
3583
|
+
return await this._callMethod("prepareLeave") === true;
|
|
3584
|
+
},
|
|
3542
3585
|
focusComposer(...args) {
|
|
3543
3586
|
return this._callMethod("focusComposer", ...args);
|
|
3544
3587
|
},
|