@shenyin/embedded-call-widget 2.3.0 → 2.6.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/README.md +20 -37
- package/checksums.txt +5 -5
- package/embedded-call-widget-runtime.iife.js +38 -31
- package/embedded-call-widget-runtime.js +2080 -1847
- package/embedded-call-widget.iife.js +4 -4
- package/embedded-call-widget.js +18 -16
- package/manifest.json +20 -21
- package/package.json +1 -10
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var EmbeddedCallWidget=(function(
|
|
1
|
+
var EmbeddedCallWidget=(function(l){"use strict";const w=`
|
|
2
2
|
:host { all: initial; }
|
|
3
3
|
.shell { font-family: "Noto Sans SC", "PingFang SC", sans-serif; }
|
|
4
4
|
.launch-btn {
|
|
@@ -14,9 +14,9 @@ var EmbeddedCallWidget=(function(d){"use strict";const m=`
|
|
|
14
14
|
box-shadow: 0 10px 24px rgba(17, 100, 102, 0.22);
|
|
15
15
|
}
|
|
16
16
|
.launch-btn[disabled] { cursor: wait; opacity: 0.72; }
|
|
17
|
-
`,
|
|
18
|
-
<style>${
|
|
17
|
+
`,y="embedded-call-widget-runtime.iife.js",m=typeof document<"u"&&document.currentScript?.src||"";function b(t){if(t instanceof HTMLElement)return t;if(typeof t=="string"){const e=document.querySelector(t);if(e instanceof HTMLElement)return e}throw new Error("createCallButton 需要有效的挂载节点或选择器")}function p(t){return t.shadowRoot||t.attachShadow({mode:"open"})}function h(t){if(t.runtimeUrl)return String(t.runtimeUrl);if(m)return new URL(y,m).href;throw new Error("当前接入方式无法自动推断运行时地址,请显式传入 runtimeUrl")}async function C(t,e={}){return typeof e.runtimeModuleLoader=="function"?await e.runtimeModuleLoader():(window.__EmbeddedCallWidgetRuntime__||await new Promise((c,u)=>{const o=document.createElement("script");o.src=t,o.async=!0,o.onload=()=>c(),o.onerror=()=>u(new Error(`运行时脚本加载失败:${t}`)),document.head.appendChild(o)}),window.__EmbeddedCallWidgetRuntime__)}function g(t={}){const e={text:"联系管理员",...t},c=e.mode!=="outbound",u=e.mode==="outbound"&&e.autoStart!==!1,o=b(e.mount),d=p(o);let a=null,s=null;d.innerHTML=`
|
|
18
|
+
<style>${w}</style>
|
|
19
19
|
<div class="shell">
|
|
20
20
|
<button class="launch-btn" type="button">${e.text}</button>
|
|
21
21
|
</div>
|
|
22
|
-
`;const
|
|
22
|
+
`;const r=d.querySelector(".launch-btn");async function i(){return a||(s||(r.disabled=!0,r.textContent="正在加载通话组件",s=(async()=>{const n=typeof e.runtimeModuleLoader=="function"?"":h(e),f=(await C(n,e))?.createEmbeddedCallWidgetRuntime;if(typeof f!="function")throw new Error("运行时入口无效,缺少 createEmbeddedCallWidgetRuntime");return a=f({mount:o,shadowRoot:d,options:e}),await a.mount(),a})()),await s)}return r.addEventListener("click",async()=>{try{const n=await i();if(n.open(),c){await n.startStandby();return}u&&await n.connectAndCall()}catch(n){r.disabled=!1,r.textContent="加载失败,请重试",console.error("[embedded-call-widget] 运行时加载失败",n)}}),c&&queueMicrotask(async()=>{try{const n=await i();n.open(),await n.startStandby()}catch(n){r.disabled=!1,r.textContent="待机初始化失败,请重试",console.error("[embedded-call-widget] 待机自动注册失败",n)}}),{async open(){(await i()).open()},async startStandby(){const n=await i();n.open(),await n.startStandby()},async connectAndCall(){const n=await i();n.open(),await n.connectAndCall()},async answerIncomingCall(){const n=await i();n.open(),await n.answerIncomingCall()},async declineIncomingCall(){const n=await i();n.open(),await n.declineIncomingCall()},async destroy(){a&&await a.destroy(),d.innerHTML=""}}}return l.createCallButton=g,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"}),l})({});
|
package/embedded-call-widget.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const f = `
|
|
2
2
|
:host { all: initial; }
|
|
3
3
|
.shell { font-family: "Noto Sans SC", "PingFang SC", sans-serif; }
|
|
4
4
|
.launch-btn {
|
|
@@ -16,7 +16,7 @@ const u = `
|
|
|
16
16
|
.launch-btn[disabled] { cursor: wait; opacity: 0.72; }
|
|
17
17
|
`;
|
|
18
18
|
typeof document < "u" && document.currentScript?.src;
|
|
19
|
-
function
|
|
19
|
+
function m(e) {
|
|
20
20
|
if (e instanceof HTMLElement)
|
|
21
21
|
return e;
|
|
22
22
|
if (typeof e == "string") {
|
|
@@ -26,30 +26,28 @@ function d(e) {
|
|
|
26
26
|
}
|
|
27
27
|
throw new Error("createCallButton 需要有效的挂载节点或选择器");
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function w(e) {
|
|
30
30
|
return e.shadowRoot || e.attachShadow({ mode: "open" });
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function y(e) {
|
|
33
33
|
if (e.runtimeUrl)
|
|
34
34
|
return String(e.runtimeUrl);
|
|
35
35
|
throw new Error("当前接入方式无法自动推断运行时地址,请显式传入 runtimeUrl");
|
|
36
36
|
}
|
|
37
|
-
async function
|
|
37
|
+
async function p(e, t = {}) {
|
|
38
38
|
return typeof t.runtimeModuleLoader == "function" ? await t.runtimeModuleLoader() : await import(
|
|
39
39
|
/* @vite-ignore */
|
|
40
40
|
e
|
|
41
41
|
);
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function h(e = {}) {
|
|
44
44
|
const t = {
|
|
45
45
|
text: "联系管理员",
|
|
46
|
-
mode: "outbound",
|
|
47
|
-
autoStart: !0,
|
|
48
46
|
...e
|
|
49
|
-
}, s =
|
|
47
|
+
}, l = t.mode !== "outbound", d = t.mode === "outbound" && t.autoStart !== !1, s = m(t.mount), i = w(s);
|
|
50
48
|
let a = null, c = null;
|
|
51
49
|
i.innerHTML = `
|
|
52
|
-
<style>${
|
|
50
|
+
<style>${f}</style>
|
|
53
51
|
<div class="shell">
|
|
54
52
|
<button class="launch-btn" type="button">${t.text}</button>
|
|
55
53
|
</div>
|
|
@@ -57,20 +55,24 @@ function p(e = {}) {
|
|
|
57
55
|
const o = i.querySelector(".launch-btn");
|
|
58
56
|
async function r() {
|
|
59
57
|
return a || (c || (o.disabled = !0, o.textContent = "正在加载通话组件", c = (async () => {
|
|
60
|
-
const n = typeof t.runtimeModuleLoader == "function" ? "" :
|
|
61
|
-
if (typeof
|
|
58
|
+
const n = typeof t.runtimeModuleLoader == "function" ? "" : y(t), u = (await p(n, t))?.createEmbeddedCallWidgetRuntime;
|
|
59
|
+
if (typeof u != "function")
|
|
62
60
|
throw new Error("运行时入口无效,缺少 createEmbeddedCallWidgetRuntime");
|
|
63
|
-
return a =
|
|
61
|
+
return a = u({ mount: s, shadowRoot: i, options: t }), await a.mount(), a;
|
|
64
62
|
})()), await c);
|
|
65
63
|
}
|
|
66
64
|
return o.addEventListener("click", async () => {
|
|
67
65
|
try {
|
|
68
66
|
const n = await r();
|
|
69
|
-
n.open(),
|
|
67
|
+
if (n.open(), l) {
|
|
68
|
+
await n.startStandby();
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
d && await n.connectAndCall();
|
|
70
72
|
} catch (n) {
|
|
71
73
|
o.disabled = !1, o.textContent = "加载失败,请重试", console.error("[embedded-call-widget] 运行时加载失败", n);
|
|
72
74
|
}
|
|
73
|
-
}),
|
|
75
|
+
}), l && queueMicrotask(async () => {
|
|
74
76
|
try {
|
|
75
77
|
const n = await r();
|
|
76
78
|
n.open(), await n.startStandby();
|
|
@@ -103,5 +105,5 @@ function p(e = {}) {
|
|
|
103
105
|
};
|
|
104
106
|
}
|
|
105
107
|
export {
|
|
106
|
-
|
|
108
|
+
h as createCallButton
|
|
107
109
|
};
|
package/manifest.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"package_name": "@shenyin/embedded-call-widget",
|
|
3
|
-
"source_package_version": "2.
|
|
4
|
-
"built_at": "2026-04-
|
|
3
|
+
"source_package_version": "2.6.1",
|
|
4
|
+
"built_at": "2026-04-03T02:59:56.891Z",
|
|
5
5
|
"outputs": {
|
|
6
6
|
"esm_shell": "embedded-call-widget.js",
|
|
7
7
|
"esm_runtime": "embedded-call-widget-runtime.js",
|
|
@@ -20,15 +20,14 @@
|
|
|
20
20
|
"required_options": [
|
|
21
21
|
"mount",
|
|
22
22
|
"apiBaseUrl",
|
|
23
|
-
"siteKey"
|
|
24
|
-
"businessKey"
|
|
23
|
+
"siteKey"
|
|
25
24
|
],
|
|
26
25
|
"optional_options": [
|
|
27
26
|
"text",
|
|
28
|
-
"
|
|
27
|
+
"businessKey",
|
|
29
28
|
"displayName",
|
|
30
|
-
"autoStart",
|
|
31
29
|
"runtimeUrl",
|
|
30
|
+
"transportBaseUrl",
|
|
32
31
|
"accessToken",
|
|
33
32
|
"onStateChange",
|
|
34
33
|
"onStandbyReady",
|
|
@@ -53,36 +52,36 @@
|
|
|
53
52
|
},
|
|
54
53
|
"release_metadata": {
|
|
55
54
|
"npm_package_name": "@shenyin/embedded-call-widget",
|
|
56
|
-
"git_tag": "embedded-call-widget-v2.
|
|
57
|
-
"git_tag_alias": "v2.
|
|
58
|
-
"cdn_version_path": "embedded-call-widget/2.
|
|
55
|
+
"git_tag": "embedded-call-widget-v2.6.1",
|
|
56
|
+
"git_tag_alias": "v2.6.1",
|
|
57
|
+
"cdn_version_path": "embedded-call-widget/2.6.1/",
|
|
59
58
|
"cdn_latest_path": "embedded-call-widget/latest/",
|
|
60
59
|
"semver_channel": "stable"
|
|
61
60
|
},
|
|
62
61
|
"asset_metadata": {
|
|
63
62
|
"esm_shell": {
|
|
64
63
|
"file": "embedded-call-widget.js",
|
|
65
|
-
"size_bytes":
|
|
66
|
-
"sha256": "
|
|
67
|
-
"sri_sha384": "sha384-
|
|
64
|
+
"size_bytes": 3321,
|
|
65
|
+
"sha256": "69cdd0a3334992efd6cf570233e1cd2d0aacab04360546b4fd95e776e0a499d2",
|
|
66
|
+
"sri_sha384": "sha384-Hw8YTsmGFwdKYVe11y0uuLPx+wzBkoBOuU6ZPW5d+SGoPaJCMaDuFt3hSXxBe5mr"
|
|
68
67
|
},
|
|
69
68
|
"esm_runtime": {
|
|
70
69
|
"file": "embedded-call-widget-runtime.js",
|
|
71
|
-
"size_bytes":
|
|
72
|
-
"sha256": "
|
|
73
|
-
"sri_sha384": "sha384-
|
|
70
|
+
"size_bytes": 500266,
|
|
71
|
+
"sha256": "42f083a46e2ec546e16da23e57009419bd41e17857c0b3882b9e32672dbdef8d",
|
|
72
|
+
"sri_sha384": "sha384-wq3ZNBDouooeMhvCSE7PDNsOWqZCo9vAC7mQJjKRVobv07Od4hrpoabnDph0XXwi"
|
|
74
73
|
},
|
|
75
74
|
"iife_shell": {
|
|
76
75
|
"file": "embedded-call-widget.iife.js",
|
|
77
|
-
"size_bytes":
|
|
78
|
-
"sha256": "
|
|
79
|
-
"sri_sha384": "sha384-
|
|
76
|
+
"size_bytes": 3162,
|
|
77
|
+
"sha256": "f4664df394b9287ba012c49a4423439bd103eccffd9e8a212c72fbeffc589054",
|
|
78
|
+
"sri_sha384": "sha384-m6vho+wEOvrSk3C9G8osLB7hQlBI+iDM3MWA1JymL2VdQhoMTQh/XQ+ltM6N789m"
|
|
80
79
|
},
|
|
81
80
|
"iife_runtime": {
|
|
82
81
|
"file": "embedded-call-widget-runtime.iife.js",
|
|
83
|
-
"size_bytes":
|
|
84
|
-
"sha256": "
|
|
85
|
-
"sri_sha384": "sha384-
|
|
82
|
+
"size_bytes": 319758,
|
|
83
|
+
"sha256": "712b57f1fac0cfc87a29defc4bac23e5089388d8d304faeeeb4a821cf2fc662d",
|
|
84
|
+
"sri_sha384": "sha384-nVNmoWRg8naDjA9Td6VrrWd8SsA49MULUyYWCZJ5PTWlVoYS6RrThd/FyapfcNbP"
|
|
86
85
|
}
|
|
87
86
|
}
|
|
88
87
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shenyin/embedded-call-widget",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "Embedded call button SDK for website integration",
|
|
3
|
+
"version": "2.6.1",
|
|
5
4
|
"type": "module",
|
|
6
5
|
"sideEffects": false,
|
|
7
|
-
"license": "UNLICENSED",
|
|
8
|
-
"homepage": "https://sdk.shenyin.eu/embedded-call-widget/latest/embedded-call-widget.iife.js",
|
|
9
6
|
"files": [
|
|
10
7
|
"embedded-call-widget.js",
|
|
11
8
|
"embedded-call-widget-runtime.js",
|
|
@@ -28,11 +25,5 @@
|
|
|
28
25
|
},
|
|
29
26
|
"./checksums.txt": "./checksums.txt",
|
|
30
27
|
"./manifest.json": "./manifest.json"
|
|
31
|
-
},
|
|
32
|
-
"publishConfig": {
|
|
33
|
-
"access": "public"
|
|
34
|
-
},
|
|
35
|
-
"scripts": {
|
|
36
|
-
"validate-release": "node scripts/validate-release.mjs"
|
|
37
28
|
}
|
|
38
29
|
}
|