customer-chat-sdk 1.3.6 → 1.3.8
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/customer-sdk.cjs.js +41 -19
- package/dist/customer-sdk.esm.js +41 -20
- package/dist/customer-sdk.min.js +4 -4
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/customer-sdk.cjs.js
CHANGED
|
@@ -29685,13 +29685,9 @@ class CustomerServiceSDK {
|
|
|
29685
29685
|
timestamp: Date.now()
|
|
29686
29686
|
};
|
|
29687
29687
|
// 处理图标管理器(优化:如果配置没变化,保留图标避免闪烁)
|
|
29688
|
-
//
|
|
29689
|
-
const iconPosition =
|
|
29690
|
-
|
|
29691
|
-
: (this.lastIconConfig?.position || undefined);
|
|
29692
|
-
const iconTarget = options?.target !== undefined
|
|
29693
|
-
? options.target
|
|
29694
|
-
: (this.lastIconConfig?.target || undefined);
|
|
29688
|
+
// target 和 iconPosition 只从 config 读取
|
|
29689
|
+
const iconPosition = config.iconPosition ?? this.lastIconConfig?.position;
|
|
29690
|
+
const iconTarget = config.target ?? this.lastIconConfig?.target;
|
|
29695
29691
|
// 检查图标配置是否变化
|
|
29696
29692
|
const iconConfigChanged = this.isIconConfigChanged(iconPosition, iconTarget);
|
|
29697
29693
|
if (iconConfigChanged) {
|
|
@@ -29704,12 +29700,12 @@ class CustomerServiceSDK {
|
|
|
29704
29700
|
}
|
|
29705
29701
|
}
|
|
29706
29702
|
this.iconManager = new IconManager(iconPosition, this.debug, iconTarget, {
|
|
29707
|
-
sideAttach:
|
|
29708
|
-
sideHideRatio:
|
|
29709
|
-
magnetic:
|
|
29710
|
-
magneticDirection:
|
|
29711
|
-
margin:
|
|
29712
|
-
autoAttachDelay:
|
|
29703
|
+
sideAttach: config.sideAttach ?? true,
|
|
29704
|
+
sideHideRatio: config.sideHideRatio ?? 0.5,
|
|
29705
|
+
magnetic: config.magnetic ?? true,
|
|
29706
|
+
magneticDirection: config.magneticDirection ?? 'x',
|
|
29707
|
+
margin: config.margin ?? 10,
|
|
29708
|
+
autoAttachDelay: config.autoAttachDelay ?? 3000
|
|
29713
29709
|
});
|
|
29714
29710
|
await this.iconManager.show();
|
|
29715
29711
|
// 保存新的配置
|
|
@@ -29720,12 +29716,12 @@ class CustomerServiceSDK {
|
|
|
29720
29716
|
if (!this.iconManager) {
|
|
29721
29717
|
// 如果不存在,创建新的
|
|
29722
29718
|
this.iconManager = new IconManager(iconPosition, this.debug, iconTarget, {
|
|
29723
|
-
sideAttach:
|
|
29724
|
-
sideHideRatio:
|
|
29725
|
-
magnetic:
|
|
29726
|
-
magneticDirection:
|
|
29727
|
-
margin:
|
|
29728
|
-
autoAttachDelay:
|
|
29719
|
+
sideAttach: config.sideAttach ?? true,
|
|
29720
|
+
sideHideRatio: config.sideHideRatio ?? 0.5,
|
|
29721
|
+
magnetic: config.magnetic ?? true,
|
|
29722
|
+
magneticDirection: config.magneticDirection ?? 'x',
|
|
29723
|
+
margin: config.margin ?? 10,
|
|
29724
|
+
autoAttachDelay: config.autoAttachDelay ?? 3000
|
|
29729
29725
|
});
|
|
29730
29726
|
await this.iconManager.show();
|
|
29731
29727
|
}
|
|
@@ -29922,6 +29918,22 @@ class CustomerServiceSDK {
|
|
|
29922
29918
|
console.log('📸 截图配置已更新:', options);
|
|
29923
29919
|
}
|
|
29924
29920
|
}
|
|
29921
|
+
/**
|
|
29922
|
+
* 触发截图配置(用于弹窗组件场景,替代之前的 iframe postMessage)
|
|
29923
|
+
* @param configJson 截图配置的 JSON 字符串(BinaryConfig 格式)
|
|
29924
|
+
*/
|
|
29925
|
+
triggerScreenshotConfig(configJson) {
|
|
29926
|
+
if (!this.screenshotManager) {
|
|
29927
|
+
if (this.debug) {
|
|
29928
|
+
console.warn('[CustomerServiceSDK] ScreenshotManager not initialized');
|
|
29929
|
+
}
|
|
29930
|
+
return;
|
|
29931
|
+
}
|
|
29932
|
+
this.screenshotManager.handleScreenshotConfig(configJson);
|
|
29933
|
+
if (this.debug) {
|
|
29934
|
+
console.log('[CustomerServiceSDK] Screenshot config triggered:', configJson);
|
|
29935
|
+
}
|
|
29936
|
+
}
|
|
29925
29937
|
/**
|
|
29926
29938
|
* 销毁 SDK
|
|
29927
29939
|
*/
|
|
@@ -30121,6 +30133,14 @@ const updateScreenshotOptions = (options) => {
|
|
|
30121
30133
|
const sdk = getInstance();
|
|
30122
30134
|
sdk.updateScreenshotOptions(options);
|
|
30123
30135
|
};
|
|
30136
|
+
/**
|
|
30137
|
+
* 触发截图配置(用于弹窗组件场景,替代之前的 iframe postMessage)
|
|
30138
|
+
* @param configJson 截图配置的 JSON 字符串(BinaryConfig 格式)
|
|
30139
|
+
*/
|
|
30140
|
+
const triggerScreenshotConfig = (configJson) => {
|
|
30141
|
+
const sdk = getInstance();
|
|
30142
|
+
sdk.triggerScreenshotConfig(configJson);
|
|
30143
|
+
};
|
|
30124
30144
|
// 默认导出
|
|
30125
30145
|
var index = {
|
|
30126
30146
|
init,
|
|
@@ -30140,6 +30160,7 @@ var index = {
|
|
|
30140
30160
|
enableScreenshot,
|
|
30141
30161
|
getScreenshotState,
|
|
30142
30162
|
updateScreenshotOptions,
|
|
30163
|
+
triggerScreenshotConfig,
|
|
30143
30164
|
destroy
|
|
30144
30165
|
};
|
|
30145
30166
|
|
|
@@ -30163,4 +30184,5 @@ exports.setIconStyle = setIconStyle;
|
|
|
30163
30184
|
exports.setScreenshotTarget = setScreenshotTarget;
|
|
30164
30185
|
exports.showIcon = showIcon;
|
|
30165
30186
|
exports.showNotification = showNotification;
|
|
30187
|
+
exports.triggerScreenshotConfig = triggerScreenshotConfig;
|
|
30166
30188
|
exports.updateScreenshotOptions = updateScreenshotOptions;
|
package/dist/customer-sdk.esm.js
CHANGED
|
@@ -29681,13 +29681,9 @@ class CustomerServiceSDK {
|
|
|
29681
29681
|
timestamp: Date.now()
|
|
29682
29682
|
};
|
|
29683
29683
|
// 处理图标管理器(优化:如果配置没变化,保留图标避免闪烁)
|
|
29684
|
-
//
|
|
29685
|
-
const iconPosition =
|
|
29686
|
-
|
|
29687
|
-
: (this.lastIconConfig?.position || undefined);
|
|
29688
|
-
const iconTarget = options?.target !== undefined
|
|
29689
|
-
? options.target
|
|
29690
|
-
: (this.lastIconConfig?.target || undefined);
|
|
29684
|
+
// target 和 iconPosition 只从 config 读取
|
|
29685
|
+
const iconPosition = config.iconPosition ?? this.lastIconConfig?.position;
|
|
29686
|
+
const iconTarget = config.target ?? this.lastIconConfig?.target;
|
|
29691
29687
|
// 检查图标配置是否变化
|
|
29692
29688
|
const iconConfigChanged = this.isIconConfigChanged(iconPosition, iconTarget);
|
|
29693
29689
|
if (iconConfigChanged) {
|
|
@@ -29700,12 +29696,12 @@ class CustomerServiceSDK {
|
|
|
29700
29696
|
}
|
|
29701
29697
|
}
|
|
29702
29698
|
this.iconManager = new IconManager(iconPosition, this.debug, iconTarget, {
|
|
29703
|
-
sideAttach:
|
|
29704
|
-
sideHideRatio:
|
|
29705
|
-
magnetic:
|
|
29706
|
-
magneticDirection:
|
|
29707
|
-
margin:
|
|
29708
|
-
autoAttachDelay:
|
|
29699
|
+
sideAttach: config.sideAttach ?? true,
|
|
29700
|
+
sideHideRatio: config.sideHideRatio ?? 0.5,
|
|
29701
|
+
magnetic: config.magnetic ?? true,
|
|
29702
|
+
magneticDirection: config.magneticDirection ?? 'x',
|
|
29703
|
+
margin: config.margin ?? 10,
|
|
29704
|
+
autoAttachDelay: config.autoAttachDelay ?? 3000
|
|
29709
29705
|
});
|
|
29710
29706
|
await this.iconManager.show();
|
|
29711
29707
|
// 保存新的配置
|
|
@@ -29716,12 +29712,12 @@ class CustomerServiceSDK {
|
|
|
29716
29712
|
if (!this.iconManager) {
|
|
29717
29713
|
// 如果不存在,创建新的
|
|
29718
29714
|
this.iconManager = new IconManager(iconPosition, this.debug, iconTarget, {
|
|
29719
|
-
sideAttach:
|
|
29720
|
-
sideHideRatio:
|
|
29721
|
-
magnetic:
|
|
29722
|
-
magneticDirection:
|
|
29723
|
-
margin:
|
|
29724
|
-
autoAttachDelay:
|
|
29715
|
+
sideAttach: config.sideAttach ?? true,
|
|
29716
|
+
sideHideRatio: config.sideHideRatio ?? 0.5,
|
|
29717
|
+
magnetic: config.magnetic ?? true,
|
|
29718
|
+
magneticDirection: config.magneticDirection ?? 'x',
|
|
29719
|
+
margin: config.margin ?? 10,
|
|
29720
|
+
autoAttachDelay: config.autoAttachDelay ?? 3000
|
|
29725
29721
|
});
|
|
29726
29722
|
await this.iconManager.show();
|
|
29727
29723
|
}
|
|
@@ -29918,6 +29914,22 @@ class CustomerServiceSDK {
|
|
|
29918
29914
|
console.log('📸 截图配置已更新:', options);
|
|
29919
29915
|
}
|
|
29920
29916
|
}
|
|
29917
|
+
/**
|
|
29918
|
+
* 触发截图配置(用于弹窗组件场景,替代之前的 iframe postMessage)
|
|
29919
|
+
* @param configJson 截图配置的 JSON 字符串(BinaryConfig 格式)
|
|
29920
|
+
*/
|
|
29921
|
+
triggerScreenshotConfig(configJson) {
|
|
29922
|
+
if (!this.screenshotManager) {
|
|
29923
|
+
if (this.debug) {
|
|
29924
|
+
console.warn('[CustomerServiceSDK] ScreenshotManager not initialized');
|
|
29925
|
+
}
|
|
29926
|
+
return;
|
|
29927
|
+
}
|
|
29928
|
+
this.screenshotManager.handleScreenshotConfig(configJson);
|
|
29929
|
+
if (this.debug) {
|
|
29930
|
+
console.log('[CustomerServiceSDK] Screenshot config triggered:', configJson);
|
|
29931
|
+
}
|
|
29932
|
+
}
|
|
29921
29933
|
/**
|
|
29922
29934
|
* 销毁 SDK
|
|
29923
29935
|
*/
|
|
@@ -30117,6 +30129,14 @@ const updateScreenshotOptions = (options) => {
|
|
|
30117
30129
|
const sdk = getInstance();
|
|
30118
30130
|
sdk.updateScreenshotOptions(options);
|
|
30119
30131
|
};
|
|
30132
|
+
/**
|
|
30133
|
+
* 触发截图配置(用于弹窗组件场景,替代之前的 iframe postMessage)
|
|
30134
|
+
* @param configJson 截图配置的 JSON 字符串(BinaryConfig 格式)
|
|
30135
|
+
*/
|
|
30136
|
+
const triggerScreenshotConfig = (configJson) => {
|
|
30137
|
+
const sdk = getInstance();
|
|
30138
|
+
sdk.triggerScreenshotConfig(configJson);
|
|
30139
|
+
};
|
|
30120
30140
|
// 默认导出
|
|
30121
30141
|
var index = {
|
|
30122
30142
|
init,
|
|
@@ -30136,7 +30156,8 @@ var index = {
|
|
|
30136
30156
|
enableScreenshot,
|
|
30137
30157
|
getScreenshotState,
|
|
30138
30158
|
updateScreenshotOptions,
|
|
30159
|
+
triggerScreenshotConfig,
|
|
30139
30160
|
destroy
|
|
30140
30161
|
};
|
|
30141
30162
|
|
|
30142
|
-
export { CustomerSDK, CustomerServiceSDK, captureScreenshot, clearNotification, index as default, destroy, enableScreenshot, getConnectionStatus, getInitResult, getInstance, getScreenshotState, hideIcon, init, onIconClick, setIconCoordinates, setIconPosition, setIconStyle, setScreenshotTarget, showIcon, showNotification, updateScreenshotOptions };
|
|
30163
|
+
export { CustomerSDK, CustomerServiceSDK, captureScreenshot, clearNotification, index as default, destroy, enableScreenshot, getConnectionStatus, getInitResult, getInstance, getScreenshotState, hideIcon, init, onIconClick, setIconCoordinates, setIconPosition, setIconStyle, setScreenshotTarget, showIcon, showNotification, triggerScreenshotConfig, updateScreenshotOptions };
|