@zjw-jszn/platform-imsdk 1.0.3 → 1.0.5
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/README.md +89 -16
- package/dist/platform-imsdk.es.js +164 -45
- package/dist/platform-imsdk.umd.cjs +205 -0
- package/index.cjs +3 -0
- package/index.js +2 -0
- package/package.json +10 -12
- package/dist/platform-imsdk.umd.js +0 -1
package/README.md
CHANGED
|
@@ -1,30 +1,103 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @zjw-jszn/platform-imsdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@zjw-jszn/platform-imsdk` 是平台侧接入包,在 `shared` 内核上固化平台模式并内置平台扩展 API。
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
- WebSocket controller:`Site`
|
|
7
|
-
- WebSocket platform:`site`
|
|
8
|
-
- 能力范围:基础会话能力 + 平台扩展接口(结束会话、客服会话、会话配置、AI 配置)
|
|
9
|
-
平台 API 文档:`docs/API/平台.md`
|
|
10
|
-
|
|
11
|
-
安装:
|
|
5
|
+
## 安装
|
|
12
6
|
|
|
13
7
|
```bash
|
|
14
8
|
pnpm add @zjw-jszn/platform-imsdk
|
|
15
9
|
```
|
|
16
10
|
|
|
17
|
-
|
|
11
|
+
## 导入
|
|
18
12
|
|
|
19
13
|
```ts
|
|
20
14
|
import { IMSDK } from '@zjw-jszn/platform-imsdk'
|
|
15
|
+
import type {
|
|
16
|
+
IMSDKConfig,
|
|
17
|
+
PlatformChatConfig,
|
|
18
|
+
PlatformCloseSessionParams,
|
|
19
|
+
PlatformPageResponse,
|
|
20
|
+
PlatformSession,
|
|
21
|
+
} from '@zjw-jszn/platform-imsdk'
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 平台模式默认值(自动注入)
|
|
25
|
+
|
|
26
|
+
| 配置项 | 固定值 |
|
|
27
|
+
| --- | --- |
|
|
28
|
+
| `api.prefix` | `/site/IM` |
|
|
29
|
+
| `api.userType` | `4` |
|
|
30
|
+
| `ws.controller` | `Site` |
|
|
31
|
+
| `ws.platform` | `site` |
|
|
32
|
+
|
|
33
|
+
> 以上字段以平台模式为准;外部覆盖会被忽略并打印告警。
|
|
34
|
+
|
|
35
|
+
## 初始化
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
type Controls = {
|
|
39
|
+
show: () => void
|
|
40
|
+
hide: () => void
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
declare function init(config: IMSDKConfig): Promise<Controls>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 最小接入示例
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { IMSDK } from '@zjw-jszn/platform-imsdk'
|
|
50
|
+
import type { IMSDKConfig } from '@zjw-jszn/platform-imsdk'
|
|
51
|
+
|
|
52
|
+
const config: IMSDKConfig = {
|
|
53
|
+
phone: '18888888888',
|
|
54
|
+
api: {
|
|
55
|
+
baseURL: 'https://aox.api.orchiport.asia',
|
|
56
|
+
siteId: '6',
|
|
57
|
+
},
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const controls = await IMSDK.init(config)
|
|
61
|
+
controls.show()
|
|
62
|
+
```
|
|
21
63
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
64
|
+
## 平台扩展 API
|
|
65
|
+
|
|
66
|
+
### `getChatConfig`
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
declare function getChatConfig(): Promise<PlatformChatConfig>
|
|
25
70
|
```
|
|
26
71
|
|
|
27
|
-
|
|
72
|
+
### `closeSession`
|
|
28
73
|
|
|
29
|
-
|
|
30
|
-
|
|
74
|
+
```ts
|
|
75
|
+
declare function closeSession(data: PlatformCloseSessionParams): Promise<boolean>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
约束:`uid` 与 `session_id` 至少传一个。
|
|
79
|
+
|
|
80
|
+
### `getCustomerChatList`
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
declare function getCustomerChatList(data: {
|
|
84
|
+
page: number
|
|
85
|
+
limit: number
|
|
86
|
+
phone?: string
|
|
87
|
+
}): Promise<PlatformPageResponse<PlatformSession>>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## 配置约束
|
|
91
|
+
|
|
92
|
+
- 可配置 shared 通用项:`api.baseURL`、`api.siteId`、`sound`、`auth` 等。
|
|
93
|
+
- 外部传入 `runtimeApi.getChatConfig/closeSession/getCustomerChatList` 会被忽略(平台内置实现优先)。
|
|
94
|
+
- 已初始化后若尝试切换到门店模式,会抛错并提示刷新页面。
|
|
95
|
+
|
|
96
|
+
## 样式
|
|
97
|
+
|
|
98
|
+
样式由依赖链中的 shared 包自动注入,通常不需要手动引入。
|
|
99
|
+
如需手动控制加载时机:
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
import '@zjw-jszn/platform-imsdk/style.css'
|
|
103
|
+
```
|
|
@@ -1,33 +1,151 @@
|
|
|
1
|
-
import { IMSDK as
|
|
1
|
+
import { IMSDK as IMSDK$1, applyModeDefaults, getUserInfo, http, initIM as initIM$1, warnModeOverrides } from "@zjw-jszn/shared-imsdk";
|
|
2
2
|
export * from "@zjw-jszn/shared-imsdk";
|
|
3
|
+
//#region \0@oxc-project+runtime@0.120.0/helpers/asyncToGenerator.js
|
|
4
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
5
|
+
try {
|
|
6
|
+
var i = n[a](c), u = i.value;
|
|
7
|
+
} catch (n) {
|
|
8
|
+
e(n);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
12
|
+
}
|
|
13
|
+
function _asyncToGenerator(n) {
|
|
14
|
+
return function() {
|
|
15
|
+
var t = this, e = arguments;
|
|
16
|
+
return new Promise(function(r, o) {
|
|
17
|
+
var a = n.apply(t, e);
|
|
18
|
+
function _next(n) {
|
|
19
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
20
|
+
}
|
|
21
|
+
function _throw(n) {
|
|
22
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
23
|
+
}
|
|
24
|
+
_next(void 0);
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
3
29
|
//#region src/runtime-api.ts
|
|
4
|
-
var
|
|
5
|
-
function
|
|
6
|
-
return `${
|
|
30
|
+
var PLATFORM_API_PREFIX = "/site/IM";
|
|
31
|
+
function buildPlatformApiPath(path) {
|
|
32
|
+
return `${PLATFORM_API_PREFIX}${path.startsWith("/") ? path : `/${path}`}`;
|
|
33
|
+
}
|
|
34
|
+
function ensureAuthorized(apiName) {
|
|
35
|
+
if (!http.getAuth()) throw new Error(`未登录,禁止请求 ${apiName},请先完成鉴权`);
|
|
36
|
+
}
|
|
37
|
+
function unwrapResult(response, apiName) {
|
|
38
|
+
if (response.result === void 0 || response.result === null) throw new Error(`${apiName} 接口返回 result 为空`);
|
|
39
|
+
return response.result;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 获取会话配置(平台扩展)
|
|
43
|
+
*/
|
|
44
|
+
function getChatConfig() {
|
|
45
|
+
return _getChatConfig.apply(this, arguments);
|
|
46
|
+
}
|
|
47
|
+
function _getChatConfig() {
|
|
48
|
+
_getChatConfig = _asyncToGenerator(function* () {
|
|
49
|
+
ensureAuthorized("getChatConfig");
|
|
50
|
+
return unwrapResult(yield http.post(buildPlatformApiPath("/chatConfig/getConfig")), "getChatConfig");
|
|
51
|
+
});
|
|
52
|
+
return _getChatConfig.apply(this, arguments);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 结束会话并清理缓存(平台扩展)
|
|
56
|
+
*/
|
|
57
|
+
function closeSession(_x) {
|
|
58
|
+
return _closeSession.apply(this, arguments);
|
|
59
|
+
}
|
|
60
|
+
function _closeSession() {
|
|
61
|
+
_closeSession = _asyncToGenerator(function* (data) {
|
|
62
|
+
ensureAuthorized("closeSession");
|
|
63
|
+
const hasUid = data.uid !== void 0 && data.uid !== null;
|
|
64
|
+
const hasSessionId = data.session_id !== void 0 && data.session_id !== null;
|
|
65
|
+
if (!hasUid && !hasSessionId) throw new Error("结束会话失败:uid 和 session_id 不能同时为空");
|
|
66
|
+
const payload = hasUid ? { uid: data.uid } : { session_id: data.session_id };
|
|
67
|
+
yield http.post(buildPlatformApiPath("/chat/closeSession"), payload);
|
|
68
|
+
return true;
|
|
69
|
+
});
|
|
70
|
+
return _closeSession.apply(this, arguments);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* 获取客服会话聊天列表(平台扩展)
|
|
74
|
+
*/
|
|
75
|
+
function getCustomerChatList(_x2) {
|
|
76
|
+
return _getCustomerChatList.apply(this, arguments);
|
|
77
|
+
}
|
|
78
|
+
function _getCustomerChatList() {
|
|
79
|
+
_getCustomerChatList = _asyncToGenerator(function* (data) {
|
|
80
|
+
ensureAuthorized("getCustomerChatList");
|
|
81
|
+
return unwrapResult(yield http.post(buildPlatformApiPath("/customer/getChatList"), data), "getCustomerChatList");
|
|
82
|
+
});
|
|
83
|
+
return _getCustomerChatList.apply(this, arguments);
|
|
7
84
|
}
|
|
8
|
-
|
|
9
|
-
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region \0@oxc-project+runtime@0.120.0/helpers/typeof.js
|
|
87
|
+
function _typeof(o) {
|
|
88
|
+
"@babel/helpers - typeof";
|
|
89
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
90
|
+
return typeof o;
|
|
91
|
+
} : function(o) {
|
|
92
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
93
|
+
}, _typeof(o);
|
|
10
94
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region \0@oxc-project+runtime@0.120.0/helpers/toPrimitive.js
|
|
97
|
+
function toPrimitive(t, r) {
|
|
98
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
99
|
+
var e = t[Symbol.toPrimitive];
|
|
100
|
+
if (void 0 !== e) {
|
|
101
|
+
var i = e.call(t, r || "default");
|
|
102
|
+
if ("object" != _typeof(i)) return i;
|
|
103
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
104
|
+
}
|
|
105
|
+
return ("string" === r ? String : Number)(t);
|
|
14
106
|
}
|
|
15
|
-
|
|
16
|
-
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region \0@oxc-project+runtime@0.120.0/helpers/toPropertyKey.js
|
|
109
|
+
function toPropertyKey(t) {
|
|
110
|
+
var i = toPrimitive(t, "string");
|
|
111
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
17
112
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
113
|
+
//#endregion
|
|
114
|
+
//#region \0@oxc-project+runtime@0.120.0/helpers/defineProperty.js
|
|
115
|
+
function _defineProperty(e, r, t) {
|
|
116
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
117
|
+
value: t,
|
|
118
|
+
enumerable: !0,
|
|
119
|
+
configurable: !0,
|
|
120
|
+
writable: !0
|
|
121
|
+
}) : e[r] = t, e;
|
|
24
122
|
}
|
|
25
|
-
|
|
26
|
-
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region \0@oxc-project+runtime@0.120.0/helpers/objectSpread2.js
|
|
125
|
+
function ownKeys(e, r) {
|
|
126
|
+
var t = Object.keys(e);
|
|
127
|
+
if (Object.getOwnPropertySymbols) {
|
|
128
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
129
|
+
r && (o = o.filter(function(r) {
|
|
130
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
131
|
+
})), t.push.apply(t, o);
|
|
132
|
+
}
|
|
133
|
+
return t;
|
|
134
|
+
}
|
|
135
|
+
function _objectSpread2(e) {
|
|
136
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
137
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
138
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
139
|
+
_defineProperty(e, r, t[r]);
|
|
140
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
141
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
return e;
|
|
27
145
|
}
|
|
28
146
|
//#endregion
|
|
29
147
|
//#region src/index.ts
|
|
30
|
-
var
|
|
148
|
+
var PLATFORM_DEFAULTS = {
|
|
31
149
|
api: {
|
|
32
150
|
prefix: "/site/IM",
|
|
33
151
|
userType: 4
|
|
@@ -37,31 +155,32 @@ var p = {
|
|
|
37
155
|
platform: "site"
|
|
38
156
|
}
|
|
39
157
|
};
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
(
|
|
44
|
-
}
|
|
45
|
-
function h(e = {}) {
|
|
46
|
-
m(e);
|
|
47
|
-
let n = e;
|
|
48
|
-
return {
|
|
49
|
-
...t(e, p),
|
|
50
|
-
runtimeApi: {
|
|
51
|
-
...n.runtimeApi || {},
|
|
52
|
-
getChatConfig: u,
|
|
53
|
-
closeSession: d,
|
|
54
|
-
getCustomerChatList: f
|
|
55
|
-
}
|
|
56
|
-
};
|
|
158
|
+
function warnIgnoredPlatformModeOverrides(config) {
|
|
159
|
+
warnModeOverrides("platform-imsdk", config, PLATFORM_DEFAULTS);
|
|
160
|
+
const runtimeApi = config.runtimeApi;
|
|
161
|
+
if ((runtimeApi === null || runtimeApi === void 0 ? void 0 : runtimeApi.getChatConfig) || (runtimeApi === null || runtimeApi === void 0 ? void 0 : runtimeApi.closeSession) || (runtimeApi === null || runtimeApi === void 0 ? void 0 : runtimeApi.getCustomerChatList)) console.warn("[platform-imsdk] 已忽略 runtimeApi 的平台扩展覆盖配置,平台扩展接口由内置实现提供");
|
|
57
162
|
}
|
|
58
|
-
|
|
59
|
-
|
|
163
|
+
function mergePlatformConfig(config = {}) {
|
|
164
|
+
warnIgnoredPlatformModeOverrides(config);
|
|
165
|
+
const platformConfig = config;
|
|
166
|
+
return _objectSpread2(_objectSpread2({}, applyModeDefaults(config, PLATFORM_DEFAULTS)), {}, { runtimeApi: _objectSpread2(_objectSpread2({}, platformConfig.runtimeApi || {}), {}, {
|
|
167
|
+
getChatConfig,
|
|
168
|
+
closeSession,
|
|
169
|
+
getCustomerChatList
|
|
170
|
+
}) });
|
|
60
171
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
172
|
+
function initIM() {
|
|
173
|
+
return _initIM.apply(this, arguments);
|
|
174
|
+
}
|
|
175
|
+
function _initIM() {
|
|
176
|
+
_initIM = _asyncToGenerator(function* (config = {}) {
|
|
177
|
+
return initIM$1(mergePlatformConfig(config));
|
|
178
|
+
});
|
|
179
|
+
return _initIM.apply(this, arguments);
|
|
180
|
+
}
|
|
181
|
+
var IMSDK = _objectSpread2(_objectSpread2({}, IMSDK$1), {}, {
|
|
182
|
+
init: initIM,
|
|
183
|
+
getUserInfo
|
|
184
|
+
});
|
|
66
185
|
//#endregion
|
|
67
|
-
export {
|
|
186
|
+
export { IMSDK, IMSDK as default, closeSession, getChatConfig, getCustomerChatList, initIM };
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
(function(global, factory) {
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@zjw-jszn/shared-imsdk")) : typeof define === "function" && define.amd ? define(["exports", "@zjw-jszn/shared-imsdk"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.PlatformIMSDK = {}, global.SharedIMSDK));
|
|
3
|
+
})(this, function(exports, _zjw_jszn_shared_imsdk) {
|
|
4
|
+
Object.defineProperties(exports, {
|
|
5
|
+
__esModule: { value: true },
|
|
6
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
7
|
+
});
|
|
8
|
+
//#region \0@oxc-project+runtime@0.120.0/helpers/asyncToGenerator.js
|
|
9
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
10
|
+
try {
|
|
11
|
+
var i = n[a](c), u = i.value;
|
|
12
|
+
} catch (n) {
|
|
13
|
+
e(n);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
17
|
+
}
|
|
18
|
+
function _asyncToGenerator(n) {
|
|
19
|
+
return function() {
|
|
20
|
+
var t = this, e = arguments;
|
|
21
|
+
return new Promise(function(r, o) {
|
|
22
|
+
var a = n.apply(t, e);
|
|
23
|
+
function _next(n) {
|
|
24
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
25
|
+
}
|
|
26
|
+
function _throw(n) {
|
|
27
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
28
|
+
}
|
|
29
|
+
_next(void 0);
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/runtime-api.ts
|
|
35
|
+
var PLATFORM_API_PREFIX = "/site/IM";
|
|
36
|
+
function buildPlatformApiPath(path) {
|
|
37
|
+
return `${PLATFORM_API_PREFIX}${path.startsWith("/") ? path : `/${path}`}`;
|
|
38
|
+
}
|
|
39
|
+
function ensureAuthorized(apiName) {
|
|
40
|
+
if (!_zjw_jszn_shared_imsdk.http.getAuth()) throw new Error(`未登录,禁止请求 ${apiName},请先完成鉴权`);
|
|
41
|
+
}
|
|
42
|
+
function unwrapResult(response, apiName) {
|
|
43
|
+
if (response.result === void 0 || response.result === null) throw new Error(`${apiName} 接口返回 result 为空`);
|
|
44
|
+
return response.result;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 获取会话配置(平台扩展)
|
|
48
|
+
*/
|
|
49
|
+
function getChatConfig() {
|
|
50
|
+
return _getChatConfig.apply(this, arguments);
|
|
51
|
+
}
|
|
52
|
+
function _getChatConfig() {
|
|
53
|
+
_getChatConfig = _asyncToGenerator(function* () {
|
|
54
|
+
ensureAuthorized("getChatConfig");
|
|
55
|
+
return unwrapResult(yield _zjw_jszn_shared_imsdk.http.post(buildPlatformApiPath("/chatConfig/getConfig")), "getChatConfig");
|
|
56
|
+
});
|
|
57
|
+
return _getChatConfig.apply(this, arguments);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* 结束会话并清理缓存(平台扩展)
|
|
61
|
+
*/
|
|
62
|
+
function closeSession(_x) {
|
|
63
|
+
return _closeSession.apply(this, arguments);
|
|
64
|
+
}
|
|
65
|
+
function _closeSession() {
|
|
66
|
+
_closeSession = _asyncToGenerator(function* (data) {
|
|
67
|
+
ensureAuthorized("closeSession");
|
|
68
|
+
const hasUid = data.uid !== void 0 && data.uid !== null;
|
|
69
|
+
const hasSessionId = data.session_id !== void 0 && data.session_id !== null;
|
|
70
|
+
if (!hasUid && !hasSessionId) throw new Error("结束会话失败:uid 和 session_id 不能同时为空");
|
|
71
|
+
const payload = hasUid ? { uid: data.uid } : { session_id: data.session_id };
|
|
72
|
+
yield _zjw_jszn_shared_imsdk.http.post(buildPlatformApiPath("/chat/closeSession"), payload);
|
|
73
|
+
return true;
|
|
74
|
+
});
|
|
75
|
+
return _closeSession.apply(this, arguments);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* 获取客服会话聊天列表(平台扩展)
|
|
79
|
+
*/
|
|
80
|
+
function getCustomerChatList(_x2) {
|
|
81
|
+
return _getCustomerChatList.apply(this, arguments);
|
|
82
|
+
}
|
|
83
|
+
function _getCustomerChatList() {
|
|
84
|
+
_getCustomerChatList = _asyncToGenerator(function* (data) {
|
|
85
|
+
ensureAuthorized("getCustomerChatList");
|
|
86
|
+
return unwrapResult(yield _zjw_jszn_shared_imsdk.http.post(buildPlatformApiPath("/customer/getChatList"), data), "getCustomerChatList");
|
|
87
|
+
});
|
|
88
|
+
return _getCustomerChatList.apply(this, arguments);
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region \0@oxc-project+runtime@0.120.0/helpers/typeof.js
|
|
92
|
+
function _typeof(o) {
|
|
93
|
+
"@babel/helpers - typeof";
|
|
94
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
95
|
+
return typeof o;
|
|
96
|
+
} : function(o) {
|
|
97
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
98
|
+
}, _typeof(o);
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region \0@oxc-project+runtime@0.120.0/helpers/toPrimitive.js
|
|
102
|
+
function toPrimitive(t, r) {
|
|
103
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
104
|
+
var e = t[Symbol.toPrimitive];
|
|
105
|
+
if (void 0 !== e) {
|
|
106
|
+
var i = e.call(t, r || "default");
|
|
107
|
+
if ("object" != _typeof(i)) return i;
|
|
108
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
109
|
+
}
|
|
110
|
+
return ("string" === r ? String : Number)(t);
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region \0@oxc-project+runtime@0.120.0/helpers/toPropertyKey.js
|
|
114
|
+
function toPropertyKey(t) {
|
|
115
|
+
var i = toPrimitive(t, "string");
|
|
116
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
117
|
+
}
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region \0@oxc-project+runtime@0.120.0/helpers/defineProperty.js
|
|
120
|
+
function _defineProperty(e, r, t) {
|
|
121
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
122
|
+
value: t,
|
|
123
|
+
enumerable: !0,
|
|
124
|
+
configurable: !0,
|
|
125
|
+
writable: !0
|
|
126
|
+
}) : e[r] = t, e;
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region \0@oxc-project+runtime@0.120.0/helpers/objectSpread2.js
|
|
130
|
+
function ownKeys(e, r) {
|
|
131
|
+
var t = Object.keys(e);
|
|
132
|
+
if (Object.getOwnPropertySymbols) {
|
|
133
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
134
|
+
r && (o = o.filter(function(r) {
|
|
135
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
136
|
+
})), t.push.apply(t, o);
|
|
137
|
+
}
|
|
138
|
+
return t;
|
|
139
|
+
}
|
|
140
|
+
function _objectSpread2(e) {
|
|
141
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
142
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
143
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
144
|
+
_defineProperty(e, r, t[r]);
|
|
145
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
146
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
return e;
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/index.ts
|
|
153
|
+
var PLATFORM_DEFAULTS = {
|
|
154
|
+
api: {
|
|
155
|
+
prefix: "/site/IM",
|
|
156
|
+
userType: 4
|
|
157
|
+
},
|
|
158
|
+
ws: {
|
|
159
|
+
controller: "Site",
|
|
160
|
+
platform: "site"
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
function warnIgnoredPlatformModeOverrides(config) {
|
|
164
|
+
(0, _zjw_jszn_shared_imsdk.warnModeOverrides)("platform-imsdk", config, PLATFORM_DEFAULTS);
|
|
165
|
+
const runtimeApi = config.runtimeApi;
|
|
166
|
+
if ((runtimeApi === null || runtimeApi === void 0 ? void 0 : runtimeApi.getChatConfig) || (runtimeApi === null || runtimeApi === void 0 ? void 0 : runtimeApi.closeSession) || (runtimeApi === null || runtimeApi === void 0 ? void 0 : runtimeApi.getCustomerChatList)) console.warn("[platform-imsdk] 已忽略 runtimeApi 的平台扩展覆盖配置,平台扩展接口由内置实现提供");
|
|
167
|
+
}
|
|
168
|
+
function mergePlatformConfig(config = {}) {
|
|
169
|
+
warnIgnoredPlatformModeOverrides(config);
|
|
170
|
+
const platformConfig = config;
|
|
171
|
+
return _objectSpread2(_objectSpread2({}, (0, _zjw_jszn_shared_imsdk.applyModeDefaults)(config, PLATFORM_DEFAULTS)), {}, { runtimeApi: _objectSpread2(_objectSpread2({}, platformConfig.runtimeApi || {}), {}, {
|
|
172
|
+
getChatConfig,
|
|
173
|
+
closeSession,
|
|
174
|
+
getCustomerChatList
|
|
175
|
+
}) });
|
|
176
|
+
}
|
|
177
|
+
function initIM() {
|
|
178
|
+
return _initIM.apply(this, arguments);
|
|
179
|
+
}
|
|
180
|
+
function _initIM() {
|
|
181
|
+
_initIM = _asyncToGenerator(function* (config = {}) {
|
|
182
|
+
return (0, _zjw_jszn_shared_imsdk.initIM)(mergePlatformConfig(config));
|
|
183
|
+
});
|
|
184
|
+
return _initIM.apply(this, arguments);
|
|
185
|
+
}
|
|
186
|
+
var IMSDK = _objectSpread2(_objectSpread2({}, _zjw_jszn_shared_imsdk.IMSDK), {}, {
|
|
187
|
+
init: initIM,
|
|
188
|
+
getUserInfo: _zjw_jszn_shared_imsdk.getUserInfo
|
|
189
|
+
});
|
|
190
|
+
//#endregion
|
|
191
|
+
exports.IMSDK = IMSDK;
|
|
192
|
+
exports.default = IMSDK;
|
|
193
|
+
exports.closeSession = closeSession;
|
|
194
|
+
exports.getChatConfig = getChatConfig;
|
|
195
|
+
exports.getCustomerChatList = getCustomerChatList;
|
|
196
|
+
exports.initIM = initIM;
|
|
197
|
+
Object.keys(_zjw_jszn_shared_imsdk).forEach(function(k) {
|
|
198
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
199
|
+
enumerable: true,
|
|
200
|
+
get: function() {
|
|
201
|
+
return _zjw_jszn_shared_imsdk[k];
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
});
|
package/index.cjs
ADDED
package/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zjw-jszn/platform-imsdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
5
|
-
"main": "./dist/platform-imsdk.umd.js",
|
|
6
|
-
"module": "./dist/platform-imsdk.es.js",
|
|
4
|
+
"version": "1.0.5",
|
|
7
5
|
"exports": {
|
|
8
6
|
".": {
|
|
9
|
-
"types":
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"import": {
|
|
14
|
-
"development": "./src/index.ts",
|
|
15
|
-
"default": "./dist/platform-imsdk.es.js"
|
|
16
|
-
}
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"import": "./index.js",
|
|
9
|
+
"require": "./index.cjs",
|
|
10
|
+
"default": "./index.js"
|
|
17
11
|
},
|
|
18
12
|
"./style.css": "./style.css"
|
|
19
13
|
},
|
|
14
|
+
"main": "./dist/platform-imsdk.umd.cjs",
|
|
15
|
+
"module": "./dist/platform-imsdk.es.js",
|
|
20
16
|
"types": "./dist/index.d.ts",
|
|
21
17
|
"files": [
|
|
22
18
|
"dist",
|
|
19
|
+
"index.js",
|
|
20
|
+
"index.cjs",
|
|
23
21
|
"style.css"
|
|
24
22
|
],
|
|
25
23
|
"publishConfig": {
|
|
@@ -27,7 +25,7 @@
|
|
|
27
25
|
"registry": "https://registry.npmjs.org/"
|
|
28
26
|
},
|
|
29
27
|
"dependencies": {
|
|
30
|
-
"@zjw-jszn/shared-imsdk": "1.0.
|
|
28
|
+
"@zjw-jszn/shared-imsdk": "1.0.5"
|
|
31
29
|
},
|
|
32
30
|
"devDependencies": {
|
|
33
31
|
"typescript": "~5.9.3",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@zjw-jszn/shared-imsdk`)):typeof define==`function`&&define.amd?define([`exports`,`@zjw-jszn/shared-imsdk`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.PlatformIMSDK={},e.SharedIMSDK))})(this,function(e,t){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var n=`/site/IM`;function r(e){return`${n}${e.startsWith(`/`)?e:`/${e}`}`}function i(e){if(!t.http.getAuth())throw Error(`未登录,禁止请求 ${e},请先完成鉴权`)}function a(e,t){if(e.result===void 0||e.result===null)throw Error(`${t} 接口返回 result 为空`);return e.result}async function o(){return i(`getChatConfig`),a(await t.http.post(r(`/chatConfig/getConfig`)),`getChatConfig`)}async function s(e){i(`closeSession`);let n=e.uid!==void 0&&e.uid!==null,a=e.session_id!==void 0&&e.session_id!==null;if(!n&&!a)throw Error(`结束会话失败:uid 和 session_id 不能同时为空`);let o=n?{uid:e.uid}:{session_id:e.session_id};return await t.http.post(r(`/chat/closeSession`),o),!0}async function c(e){return i(`getCustomerChatList`),a(await t.http.post(r(`/customer/getChatList`),e),`getCustomerChatList`)}var l={api:{prefix:`/site/IM`,userType:4},ws:{controller:`Site`,platform:`site`}};function u(e){(0,t.warnModeOverrides)(`platform-imsdk`,e,l);let n=e.runtimeApi;(n!=null&&n.getChatConfig||n!=null&&n.closeSession||n!=null&&n.getCustomerChatList)&&console.warn(`[platform-imsdk] 已忽略 runtimeApi 的平台扩展覆盖配置,平台扩展接口由内置实现提供`)}function d(e={}){u(e);let n=e;return{...(0,t.applyModeDefaults)(e,l),runtimeApi:{...n.runtimeApi||{},getChatConfig:o,closeSession:s,getCustomerChatList:c}}}async function f(e={}){return(0,t.initIM)(d(e))}var p={...t.IMSDK,init:f,getUserInfo:t.getUserInfo};e.IMSDK=p,e.default=p,e.closeSession=s,e.getChatConfig=o,e.getCustomerChatList=c,e.initIM=f,Object.keys(t).forEach(function(n){n!==`default`&&!Object.prototype.hasOwnProperty.call(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})});
|