@xpert-ai/chatkit-ui5 0.17.0 → 0.18.0
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 +29 -5
- package/dist/chatkit.cjs.map +1 -1
- package/dist/chatkit.ui5.js +29 -5
- package/dist/chatkit.ui5.js.map +1 -1
- package/dist/index.js +30 -6
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -47,8 +47,8 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
|
|
|
47
47
|
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);
|
|
48
48
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
49
49
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
50
|
-
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
|
-
import { normalizePetOptions, DEFAULT_PET_STORAGE_KEY, resolvePetCharacter, normalizeBoundsPadding, getPinnedPetPosition, clampPetPosition } from "@xpert-ai/chatkit-types";
|
|
50
|
+
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;
|
|
51
|
+
import { normalizePetOptions, DEFAULT_PET_STORAGE_KEY, resolvePetCharacter, normalizeBoundsPadding, getPinnedPetPosition, clampPetPosition, getPetAssetsBaseUrl } from "@xpert-ai/chatkit-types";
|
|
52
52
|
class EventEmitter {
|
|
53
53
|
constructor() {
|
|
54
54
|
__publicField(this, "callbacks", /* @__PURE__ */ new Map());
|
|
@@ -382,7 +382,13 @@ function createSecureChannelId() {
|
|
|
382
382
|
return null;
|
|
383
383
|
}
|
|
384
384
|
function safeRandomUUID() {
|
|
385
|
-
|
|
385
|
+
const id = createSecureChannelId();
|
|
386
|
+
if (id === null) {
|
|
387
|
+
throw new Error(
|
|
388
|
+
"ChatKit requires crypto.randomUUID or crypto.getRandomValues to generate secure UUIDs."
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
return id;
|
|
386
392
|
}
|
|
387
393
|
function isTrustedChatKitMessageEvent(event, { channelId, expectedOrigin, expectedSource }) {
|
|
388
394
|
const payload = event.data;
|
|
@@ -747,6 +753,7 @@ const BASE_CAPABILITY_ALLOWLIST = [
|
|
|
747
753
|
"command.setThreadId",
|
|
748
754
|
"command.focusComposer",
|
|
749
755
|
"command.focusMessage",
|
|
756
|
+
"command.prepareLeave",
|
|
750
757
|
"command.fetchUpdates",
|
|
751
758
|
"command.sendCustomAction",
|
|
752
759
|
"command.showHistory",
|
|
@@ -2496,7 +2503,7 @@ function requireCommandCapability(value, context) {
|
|
|
2496
2503
|
return value.apply(this, args);
|
|
2497
2504
|
};
|
|
2498
2505
|
}
|
|
2499
|
-
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) {
|
|
2506
|
+
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) {
|
|
2500
2507
|
constructor({ profile }) {
|
|
2501
2508
|
super();
|
|
2502
2509
|
__runInitializers(_init, 5, this);
|
|
@@ -2616,6 +2623,10 @@ class ChatKitElementBase extends (_c = HTMLElement, _focusComposer_dec = [requir
|
|
|
2616
2623
|
}
|
|
2617
2624
|
return connect(request);
|
|
2618
2625
|
},
|
|
2626
|
+
onWorkbenchNavigationChange: async (navigation) => {
|
|
2627
|
+
var _a2, _b2, _c2;
|
|
2628
|
+
await ((_c2 = (_b2 = (_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.workbench) == null ? void 0 : _b2.onNavigationChange) == null ? void 0 : _c2.call(_b2, navigation));
|
|
2629
|
+
},
|
|
2619
2630
|
onWorkbenchClientCommand: async ({
|
|
2620
2631
|
commandKey,
|
|
2621
2632
|
payload,
|
|
@@ -3038,6 +3049,11 @@ class ChatKitElementBase extends (_c = HTMLElement, _focusComposer_dec = [requir
|
|
|
3038
3049
|
await __privateGet(this, _loaded);
|
|
3039
3050
|
await ((_a2 = __privateGet(this, _messenger)) == null ? void 0 : _a2.commands.setThreadId({ threadId }));
|
|
3040
3051
|
}
|
|
3052
|
+
async prepareLeave() {
|
|
3053
|
+
await __privateGet(this, _loaded);
|
|
3054
|
+
if (!__privateGet(this, _messenger)) return false;
|
|
3055
|
+
return __privateGet(this, _messenger).commands.prepareLeave();
|
|
3056
|
+
}
|
|
3041
3057
|
async focusMessage(request) {
|
|
3042
3058
|
await __privateGet(this, _loaded);
|
|
3043
3059
|
if (!__privateGet(this, _messenger)) return { success: false, code: "not_ready" };
|
|
@@ -3107,7 +3123,7 @@ getConfiguredPetOptions_fn = function(options = __privateGet(this, _opts)) {
|
|
|
3107
3123
|
return null;
|
|
3108
3124
|
}
|
|
3109
3125
|
if (__privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this, options) === "pet" && !normalizePetOptions(options.pet ?? null)) {
|
|
3110
|
-
return true;
|
|
3126
|
+
return typeof options.pet === "object" ? { ...options.pet, enabled: true } : true;
|
|
3111
3127
|
}
|
|
3112
3128
|
return options.pet ?? null;
|
|
3113
3129
|
};
|
|
@@ -3165,7 +3181,11 @@ resolvePetAssetUrl_fn = function(src) {
|
|
|
3165
3181
|
}
|
|
3166
3182
|
};
|
|
3167
3183
|
resolveOverlayPetOptions_fn = function(pet) {
|
|
3168
|
-
|
|
3184
|
+
var _a2;
|
|
3185
|
+
const assetsBaseUrl = getPetAssetsBaseUrl(pet ?? void 0) ?? getPetAssetsBaseUrl((_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.pet);
|
|
3186
|
+
const normalized = normalizePetOptions(
|
|
3187
|
+
pet ? { ...pet === true ? {} : pet, assetsBaseUrl } : null
|
|
3188
|
+
);
|
|
3169
3189
|
if (!normalized) {
|
|
3170
3190
|
return null;
|
|
3171
3191
|
}
|
|
@@ -3311,6 +3331,7 @@ __decorateElement(_init, 1, "sendUserMessage", _sendUserMessage_dec, ChatKitElem
|
|
|
3311
3331
|
__decorateElement(_init, 1, "setComposerValue", _setComposerValue_dec, ChatKitElementBase);
|
|
3312
3332
|
__decorateElement(_init, 1, "setRuntimeCapabilities", _setRuntimeCapabilities_dec, ChatKitElementBase);
|
|
3313
3333
|
__decorateElement(_init, 1, "setThreadId", _setThreadId_dec, ChatKitElementBase);
|
|
3334
|
+
__decorateElement(_init, 1, "prepareLeave", _prepareLeave_dec, ChatKitElementBase);
|
|
3314
3335
|
__decorateElement(_init, 1, "focusMessage", _focusMessage_dec, ChatKitElementBase);
|
|
3315
3336
|
__decorateElement(_init, 1, "shareThread", _shareThread_dec, ChatKitElementBase);
|
|
3316
3337
|
__decorateElement(_init, 1, "sendCustomAction", _sendCustomAction_dec, ChatKitElementBase);
|
|
@@ -3527,6 +3548,9 @@ const ChatKit = ControlBase.extend("xpertai.chatkit.ui5.ChatKit", {
|
|
|
3527
3548
|
}
|
|
3528
3549
|
return methodRef.apply(el, args);
|
|
3529
3550
|
},
|
|
3551
|
+
async prepareLeave() {
|
|
3552
|
+
return await this._callMethod("prepareLeave") === true;
|
|
3553
|
+
},
|
|
3530
3554
|
focusComposer(...args) {
|
|
3531
3555
|
return this._callMethod("focusComposer", ...args);
|
|
3532
3556
|
},
|