@xpert-ai/chatkit-ui5 0.4.2 → 0.7.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 +109 -8
- package/dist/chatkit.cjs.map +1 -1
- package/dist/chatkit.ui5.js +109 -8
- package/dist/chatkit.ui5.js.map +1 -1
- package/dist/index.js +109 -8
- 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, _setThreadId_dec, _setRuntimeCapabilities_dec, _setComposerValue_dec, _sendUserMessage_dec, _fetchUpdates_dec, _focusComposer_dec, _c, _opts, _frameUrl, _frame, _wrapper, _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, _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 {
|
|
@@ -896,6 +896,59 @@ const getCapabilities = (profile) => {
|
|
|
896
896
|
}
|
|
897
897
|
return { commands, events, backend, threadItems, errors, widgets };
|
|
898
898
|
};
|
|
899
|
+
function parseWindowDragRegions(value) {
|
|
900
|
+
if (!value || typeof value !== "object" || !("width" in value) || typeof value.width !== "number" || !Number.isFinite(value.width) || value.width <= 0 || !("height" in value) || typeof value.height !== "number" || !Number.isFinite(value.height) || value.height <= 0 || !("regions" in value) || !Array.isArray(value.regions) || value.regions.length > 128)
|
|
901
|
+
return null;
|
|
902
|
+
const regions = [];
|
|
903
|
+
for (const rect of value.regions) {
|
|
904
|
+
if (!rect || typeof rect !== "object" || typeof rect.x !== "number" || !Number.isFinite(rect.x) || rect.x < 0 || typeof rect.y !== "number" || !Number.isFinite(rect.y) || rect.y < 0 || typeof rect.width !== "number" || !Number.isFinite(rect.width) || rect.width <= 0 || typeof rect.height !== "number" || !Number.isFinite(rect.height) || rect.height <= 0 || rect.x + rect.width > value.width + 1 || rect.y + rect.height > Math.min(value.height, 96) + 1)
|
|
905
|
+
return null;
|
|
906
|
+
regions.push({
|
|
907
|
+
x: rect.x,
|
|
908
|
+
y: rect.y,
|
|
909
|
+
width: rect.width,
|
|
910
|
+
height: rect.height
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
return { width: value.width, height: value.height, regions };
|
|
914
|
+
}
|
|
915
|
+
class WindowDragOverlay {
|
|
916
|
+
constructor(wrapper, enabled) {
|
|
917
|
+
this.wrapper = wrapper;
|
|
918
|
+
this.enabled = enabled;
|
|
919
|
+
this.size = { width: 0, height: 0 };
|
|
920
|
+
this.layer = document.createElement("div");
|
|
921
|
+
this.layer.setAttribute("aria-hidden", "true");
|
|
922
|
+
this.layer.dataset.slot = "chatkit-window-drag";
|
|
923
|
+
this.layer.style.cssText = "position:absolute;inset:0;pointer-events:none;overflow:hidden;";
|
|
924
|
+
wrapper.append(this.layer);
|
|
925
|
+
this.observer = new ResizeObserver(() => {
|
|
926
|
+
if (this.wrapper.clientWidth !== this.size.width || this.wrapper.clientHeight !== this.size.height)
|
|
927
|
+
this.clear();
|
|
928
|
+
});
|
|
929
|
+
this.observer.observe(wrapper);
|
|
930
|
+
}
|
|
931
|
+
update(input) {
|
|
932
|
+
this.clear();
|
|
933
|
+
if (!this.enabled()) return;
|
|
934
|
+
const value = parseWindowDragRegions(input);
|
|
935
|
+
if (!value || Math.abs(value.width - this.wrapper.clientWidth) > 1 || Math.abs(value.height - this.wrapper.clientHeight) > 1)
|
|
936
|
+
return;
|
|
937
|
+
this.size = { width: value.width, height: value.height };
|
|
938
|
+
for (const rect of value.regions) {
|
|
939
|
+
const region = document.createElement("div");
|
|
940
|
+
region.style.cssText = `position:absolute;left:${rect.x}px;top:${rect.y}px;width:${rect.width}px;height:${rect.height}px;pointer-events:auto;user-select:none;-webkit-app-region:drag;`;
|
|
941
|
+
this.layer.append(region);
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
clear() {
|
|
945
|
+
this.layer.replaceChildren();
|
|
946
|
+
}
|
|
947
|
+
destroy() {
|
|
948
|
+
this.observer.disconnect();
|
|
949
|
+
this.layer.remove();
|
|
950
|
+
}
|
|
951
|
+
}
|
|
899
952
|
class ChatFrameMessenger extends BaseMessenger {
|
|
900
953
|
// Messenger running in outer can always handle commands coming from inner
|
|
901
954
|
canReceiveCommand(_) {
|
|
@@ -2438,6 +2491,7 @@ class ChatKitElementBase extends (_c = HTMLElement, _focusComposer_dec = [requir
|
|
|
2438
2491
|
__privateAdd(this, _frameUrl);
|
|
2439
2492
|
__privateAdd(this, _frame);
|
|
2440
2493
|
__privateAdd(this, _wrapper);
|
|
2494
|
+
__privateAdd(this, _windowDrag);
|
|
2441
2495
|
__privateAdd(this, _launcherCloseButton);
|
|
2442
2496
|
__privateAdd(this, _launcherOpen, false);
|
|
2443
2497
|
__privateAdd(this, _chatMinimizedToPet, false);
|
|
@@ -2488,6 +2542,24 @@ class ChatKitElementBase extends (_c = HTMLElement, _focusComposer_dec = [requir
|
|
|
2488
2542
|
input.click();
|
|
2489
2543
|
});
|
|
2490
2544
|
},
|
|
2545
|
+
onApprovalDecision: async (input) => {
|
|
2546
|
+
var _a2, _b2;
|
|
2547
|
+
const handler = (_b2 = (_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.approvals) == null ? void 0 : _b2.onDecision;
|
|
2548
|
+
if (!handler)
|
|
2549
|
+
throw new IntegrationError2(
|
|
2550
|
+
"Add approvals.onDecision to handle host approvals."
|
|
2551
|
+
);
|
|
2552
|
+
return handler(input);
|
|
2553
|
+
},
|
|
2554
|
+
onApprovalAction: async (input) => {
|
|
2555
|
+
var _a2, _b2;
|
|
2556
|
+
const handler = (_b2 = (_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.approvals) == null ? void 0 : _b2.onAction;
|
|
2557
|
+
if (!handler)
|
|
2558
|
+
throw new IntegrationError2(
|
|
2559
|
+
"Add approvals.onAction to handle approval actions."
|
|
2560
|
+
);
|
|
2561
|
+
return handler(input);
|
|
2562
|
+
},
|
|
2491
2563
|
onClientToolCall: async ({
|
|
2492
2564
|
name,
|
|
2493
2565
|
params,
|
|
@@ -2513,6 +2585,16 @@ class ChatKitElementBase extends (_c = HTMLElement, _focusComposer_dec = [requir
|
|
|
2513
2585
|
}
|
|
2514
2586
|
return onRequestPreview(request);
|
|
2515
2587
|
},
|
|
2588
|
+
onConnectWorkspaceConnector: async (request) => {
|
|
2589
|
+
var _a2, _b2, _c2;
|
|
2590
|
+
const connect = (_c2 = (_b2 = (_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.composer) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.onConnect;
|
|
2591
|
+
if (!connect) {
|
|
2592
|
+
__privateMethod(this, _ChatKitElementBase_instances, emitAndThrow_fn).call(this, new IntegrationError2(
|
|
2593
|
+
"Add composer.resources.onConnect to handle workspace Connector connections."
|
|
2594
|
+
));
|
|
2595
|
+
}
|
|
2596
|
+
return connect(request);
|
|
2597
|
+
},
|
|
2516
2598
|
onWorkbenchClientCommand: async ({
|
|
2517
2599
|
commandKey,
|
|
2518
2600
|
payload,
|
|
@@ -2523,9 +2605,7 @@ class ChatKitElementBase extends (_c = HTMLElement, _focusComposer_dec = [requir
|
|
|
2523
2605
|
var _a2, _b2;
|
|
2524
2606
|
const onClientCommand = (_b2 = (_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.workbench) == null ? void 0 : _b2.onClientCommand;
|
|
2525
2607
|
if (!onClientCommand) {
|
|
2526
|
-
|
|
2527
|
-
`No handler for workbench client command "${commandKey}". Add workbench.onClientCommand to your ChatKit options.`
|
|
2528
|
-
));
|
|
2608
|
+
return { success: false, code: "unsupported", commandKey };
|
|
2529
2609
|
}
|
|
2530
2610
|
return onClientCommand({
|
|
2531
2611
|
commandKey,
|
|
@@ -2767,6 +2847,20 @@ class ChatKitElementBase extends (_c = HTMLElement, _focusComposer_dec = [requir
|
|
|
2767
2847
|
closeButton.addEventListener("click", __privateGet(this, _handleLauncherClose));
|
|
2768
2848
|
wrapper.appendChild(closeButton);
|
|
2769
2849
|
__privateSet(this, _launcherCloseButton, closeButton);
|
|
2850
|
+
__privateSet(this, _windowDrag, new WindowDragOverlay(
|
|
2851
|
+
wrapper,
|
|
2852
|
+
() => {
|
|
2853
|
+
var _a2, _b2;
|
|
2854
|
+
return ((_b2 = (_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.header) == null ? void 0 : _b2.windowDrag) === true;
|
|
2855
|
+
}
|
|
2856
|
+
));
|
|
2857
|
+
__privateGet(this, _messenger).on(
|
|
2858
|
+
"window_drag_regions",
|
|
2859
|
+
(data) => {
|
|
2860
|
+
var _a2;
|
|
2861
|
+
return (_a2 = __privateGet(this, _windowDrag)) == null ? void 0 : _a2.update(data);
|
|
2862
|
+
}
|
|
2863
|
+
);
|
|
2770
2864
|
__privateGet(this, _shadow).append(style);
|
|
2771
2865
|
__privateGet(this, _messenger).on("left_header_icon_click", () => {
|
|
2772
2866
|
var _a2, _b2, _c2;
|
|
@@ -2829,6 +2923,8 @@ class ChatKitElementBase extends (_c = HTMLElement, _focusComposer_dec = [requir
|
|
|
2829
2923
|
}
|
|
2830
2924
|
});
|
|
2831
2925
|
__privateGet(this, _messenger).on("unmount", () => {
|
|
2926
|
+
var _a2;
|
|
2927
|
+
(_a2 = __privateGet(this, _windowDrag)) == null ? void 0 : _a2.destroy();
|
|
2832
2928
|
if (__privateGet(this, _wrapper) && __privateGet(this, _shadow).contains(__privateGet(this, _wrapper))) {
|
|
2833
2929
|
__privateGet(this, _shadow).removeChild(__privateGet(this, _wrapper));
|
|
2834
2930
|
__privateSet(this, _wrapper, void 0);
|
|
@@ -2850,9 +2946,10 @@ class ChatKitElementBase extends (_c = HTMLElement, _focusComposer_dec = [requir
|
|
|
2850
2946
|
}
|
|
2851
2947
|
}
|
|
2852
2948
|
disconnectedCallback() {
|
|
2853
|
-
var _a2, _b2;
|
|
2854
|
-
(_a2 = __privateGet(this,
|
|
2855
|
-
(_b2 = __privateGet(this,
|
|
2949
|
+
var _a2, _b2, _c2;
|
|
2950
|
+
(_a2 = __privateGet(this, _windowDrag)) == null ? void 0 : _a2.destroy();
|
|
2951
|
+
(_b2 = __privateGet(this, _frame)) == null ? void 0 : _b2.removeEventListener("load", __privateGet(this, _handleFrameLoad));
|
|
2952
|
+
(_c2 = __privateGet(this, _launcherCloseButton)) == null ? void 0 : _c2.removeEventListener(
|
|
2856
2953
|
"click",
|
|
2857
2954
|
__privateGet(this, _handleLauncherClose)
|
|
2858
2955
|
);
|
|
@@ -2860,7 +2957,9 @@ class ChatKitElementBase extends (_c = HTMLElement, _focusComposer_dec = [requir
|
|
|
2860
2957
|
__privateGet(this, _petOverlay).destroy();
|
|
2861
2958
|
}
|
|
2862
2959
|
applySanitizedOptions(newOptions) {
|
|
2960
|
+
var _a2, _b2;
|
|
2863
2961
|
__privateSet(this, _opts, newOptions);
|
|
2962
|
+
if (!((_a2 = newOptions.header) == null ? void 0 : _a2.windowDrag)) (_b2 = __privateGet(this, _windowDrag)) == null ? void 0 : _b2.clear();
|
|
2864
2963
|
__privateSet(this, _petClosedByContextMenu, false);
|
|
2865
2964
|
__privateGet(this, _petOverlay).setLocale(newOptions.locale);
|
|
2866
2965
|
__privateMethod(this, _ChatKitElementBase_instances, syncPetOverlayOptions_fn).call(this);
|
|
@@ -2946,6 +3045,7 @@ _opts = new WeakMap();
|
|
|
2946
3045
|
_frameUrl = new WeakMap();
|
|
2947
3046
|
_frame = new WeakMap();
|
|
2948
3047
|
_wrapper = new WeakMap();
|
|
3048
|
+
_windowDrag = new WeakMap();
|
|
2949
3049
|
_launcherCloseButton = new WeakMap();
|
|
2950
3050
|
_launcherOpen = new WeakMap();
|
|
2951
3051
|
_chatMinimizedToPet = new WeakMap();
|
|
@@ -3009,7 +3109,8 @@ mergeConfiguredPetPositionDefaults_fn = function(pet) {
|
|
|
3009
3109
|
};
|
|
3010
3110
|
};
|
|
3011
3111
|
getOverlayPetOptions_fn = function() {
|
|
3012
|
-
|
|
3112
|
+
var _a2;
|
|
3113
|
+
if (__privateGet(this, _petClosedByContextMenu) || ((_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.pet) === false && __privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) !== "pet") {
|
|
3013
3114
|
return null;
|
|
3014
3115
|
}
|
|
3015
3116
|
let pet;
|