@shenyin/embedded-call-widget 2.6.12 → 3.0.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.
@@ -1,22 +1,60 @@
1
1
  var EmbeddedCallWidget=(function(l){"use strict";const w=`
2
+ <svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
3
+ <path d="M6.84 4.28c.3-.72 1.15-1.1 1.89-.85l2.24.75c.77.26 1.18 1.09.91 1.85l-.64 1.82a1.6 1.6 0 0 1-1.9.99l-.63-.16a12.8 12.8 0 0 0 6.62 6.62l-.16-.63a1.6 1.6 0 0 1 .99-1.9l1.82-.64c.76-.27 1.59.14 1.85.91l.75 2.24c.25.74-.13 1.59-.85 1.89l-1.74.72c-.72.3-1.54.26-2.23-.1A17.94 17.94 0 0 1 4.48 7.23c-.36-.69-.4-1.51-.1-2.23z" fill="currentColor"/>
4
+ </svg>
5
+ `,g=`
2
6
  :host { all: initial; }
3
7
  .shell { font-family: "Noto Sans SC", "PingFang SC", sans-serif; }
4
- .launch-btn {
5
- appearance: none;
8
+ .boot-trigger {
9
+ position: relative;
10
+ display: inline-flex;
11
+ align-items: center;
12
+ justify-content: center;
13
+ width: 60px;
14
+ height: 60px;
6
15
  border: 0;
7
16
  border-radius: 999px;
8
- background: linear-gradient(135deg, #116466, #2c7873);
9
- color: #f7f3e9;
10
- padding: 12px 18px;
11
- font-size: 14px;
12
- line-height: 1;
17
+ background: linear-gradient(135deg, #0f766e, #0b5b63);
18
+ color: #f8faf8;
19
+ box-shadow: 0 18px 36px rgba(11, 91, 99, 0.28);
13
20
  cursor: pointer;
14
- box-shadow: 0 10px 24px rgba(17, 100, 102, 0.22);
15
21
  }
16
- .launch-btn[disabled] { cursor: wait; opacity: 0.72; }
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>
22
+ .boot-trigger[disabled] {
23
+ cursor: wait;
24
+ opacity: 0.82;
25
+ }
26
+ .boot-trigger svg {
27
+ width: 24px;
28
+ height: 24px;
29
+ }
30
+ .boot-badge {
31
+ position: absolute;
32
+ top: 8px;
33
+ right: 8px;
34
+ width: 10px;
35
+ height: 10px;
36
+ border-radius: 999px;
37
+ background: #e11d48;
38
+ box-shadow: 0 0 0 3px rgba(248, 250, 248, 0.9);
39
+ }
40
+ .sr-only {
41
+ position: absolute;
42
+ width: 1px;
43
+ height: 1px;
44
+ padding: 0;
45
+ margin: -1px;
46
+ overflow: hidden;
47
+ clip: rect(0, 0, 0, 0);
48
+ white-space: nowrap;
49
+ border: 0;
50
+ }
51
+ `,m="embedded-call-widget-runtime.iife.js",u=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(u)return new URL(m,u).href;throw new Error("当前接入方式无法自动推断运行时地址,请显式传入 runtimeUrl")}async function y(t,e={}){return typeof e.runtimeModuleLoader=="function"?await e.runtimeModuleLoader():(window.__EmbeddedCallWidgetRuntime__||await new Promise((d,i)=>{const a=document.createElement("script");a.src=t,a.async=!0,a.onload=()=>d(),a.onerror=()=>i(new Error(`运行时脚本加载失败:${t}`)),document.head.appendChild(a)}),window.__EmbeddedCallWidgetRuntime__)}function C(t={}){const e={text:"联系管理员",debug:!1,...t},d=e.mode!=="outbound";e.mode==="outbound"&&e.autoStart;const i=b(e.mount),a=p(i);let o=null,s=null;a.innerHTML=`
52
+ <style>${g}</style>
19
53
  <div class="shell">
20
- <button class="launch-btn" type="button">${e.text}</button>
54
+ <button class="boot-trigger" data-role="boot-trigger" type="button" aria-label="${e.text}">
55
+ ${w}
56
+ <span class="boot-badge" aria-hidden="true"></span>
57
+ <span class="sr-only">${e.text}</span>
58
+ </button>
21
59
  </div>
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})({});
60
+ `;const c=a.querySelector('[data-role="boot-trigger"]');async function r(){return o||(s||(c.disabled=!0,s=(async()=>{const n=typeof e.runtimeModuleLoader=="function"?"":h(e),f=(await y(n,e))?.createEmbeddedCallWidgetRuntime;if(typeof f!="function")throw new Error("运行时入口无效,缺少 createEmbeddedCallWidgetRuntime");return o=f({mount:i,shadowRoot:a,options:e}),await o.mount(),o})()),await s)}return c.addEventListener("click",async()=>{try{const n=await r();if(typeof n.handleTriggerClick=="function"){await n.handleTriggerClick();return}await n.connectAndCall()}catch(n){c.disabled=!1,console.error("[embedded-call-widget] 运行时加载失败",n)}}),d&&queueMicrotask(async()=>{try{await(await r()).startStandby()}catch(n){c.disabled=!1,console.error("[embedded-call-widget] 待机自动注册失败",n)}}),{async open(){(await r()).open()},async startStandby(){await(await r()).startStandby()},async connectAndCall(){await(await r()).connectAndCall()},async answerIncomingCall(){await(await r()).answerIncomingCall()},async declineIncomingCall(){await(await r()).declineIncomingCall()},async destroy(){o&&await o.destroy(),a.innerHTML=""}}}return l.createCallButton=C,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"}),l})({});
@@ -1,106 +1,142 @@
1
- const f = `
1
+ const u = `
2
+ <svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
3
+ <path d="M6.84 4.28c.3-.72 1.15-1.1 1.89-.85l2.24.75c.77.26 1.18 1.09.91 1.85l-.64 1.82a1.6 1.6 0 0 1-1.9.99l-.63-.16a12.8 12.8 0 0 0 6.62 6.62l-.16-.63a1.6 1.6 0 0 1 .99-1.9l1.82-.64c.76-.27 1.59.14 1.85.91l.75 2.24c.25.74-.13 1.59-.85 1.89l-1.74.72c-.72.3-1.54.26-2.23-.1A17.94 17.94 0 0 1 4.48 7.23c-.36-.69-.4-1.51-.1-2.23z" fill="currentColor"/>
4
+ </svg>
5
+ `, f = `
2
6
  :host { all: initial; }
3
7
  .shell { font-family: "Noto Sans SC", "PingFang SC", sans-serif; }
4
- .launch-btn {
5
- appearance: none;
8
+ .boot-trigger {
9
+ position: relative;
10
+ display: inline-flex;
11
+ align-items: center;
12
+ justify-content: center;
13
+ width: 60px;
14
+ height: 60px;
6
15
  border: 0;
7
16
  border-radius: 999px;
8
- background: linear-gradient(135deg, #116466, #2c7873);
9
- color: #f7f3e9;
10
- padding: 12px 18px;
11
- font-size: 14px;
12
- line-height: 1;
17
+ background: linear-gradient(135deg, #0f766e, #0b5b63);
18
+ color: #f8faf8;
19
+ box-shadow: 0 18px 36px rgba(11, 91, 99, 0.28);
13
20
  cursor: pointer;
14
- box-shadow: 0 10px 24px rgba(17, 100, 102, 0.22);
15
21
  }
16
- .launch-btn[disabled] { cursor: wait; opacity: 0.72; }
22
+ .boot-trigger[disabled] {
23
+ cursor: wait;
24
+ opacity: 0.82;
25
+ }
26
+ .boot-trigger svg {
27
+ width: 24px;
28
+ height: 24px;
29
+ }
30
+ .boot-badge {
31
+ position: absolute;
32
+ top: 8px;
33
+ right: 8px;
34
+ width: 10px;
35
+ height: 10px;
36
+ border-radius: 999px;
37
+ background: #e11d48;
38
+ box-shadow: 0 0 0 3px rgba(248, 250, 248, 0.9);
39
+ }
40
+ .sr-only {
41
+ position: absolute;
42
+ width: 1px;
43
+ height: 1px;
44
+ padding: 0;
45
+ margin: -1px;
46
+ overflow: hidden;
47
+ clip: rect(0, 0, 0, 0);
48
+ white-space: nowrap;
49
+ border: 0;
50
+ }
17
51
  `;
18
52
  typeof document < "u" && document.currentScript?.src;
19
- function m(e) {
20
- if (e instanceof HTMLElement)
21
- return e;
22
- if (typeof e == "string") {
23
- const t = document.querySelector(e);
53
+ function g(n) {
54
+ if (n instanceof HTMLElement)
55
+ return n;
56
+ if (typeof n == "string") {
57
+ const t = document.querySelector(n);
24
58
  if (t instanceof HTMLElement)
25
59
  return t;
26
60
  }
27
61
  throw new Error("createCallButton 需要有效的挂载节点或选择器");
28
62
  }
29
- function w(e) {
30
- return e.shadowRoot || e.attachShadow({ mode: "open" });
63
+ function w(n) {
64
+ return n.shadowRoot || n.attachShadow({ mode: "open" });
31
65
  }
32
- function y(e) {
33
- if (e.runtimeUrl)
34
- return String(e.runtimeUrl);
66
+ function p(n) {
67
+ if (n.runtimeUrl)
68
+ return String(n.runtimeUrl);
35
69
  throw new Error("当前接入方式无法自动推断运行时地址,请显式传入 runtimeUrl");
36
70
  }
37
- async function p(e, t = {}) {
71
+ async function b(n, t = {}) {
38
72
  return typeof t.runtimeModuleLoader == "function" ? await t.runtimeModuleLoader() : await import(
39
73
  /* @vite-ignore */
40
- e
74
+ n
41
75
  );
42
76
  }
43
- function h(e = {}) {
77
+ function h(n = {}) {
44
78
  const t = {
45
79
  text: "联系管理员",
46
- ...e
47
- }, l = t.mode !== "outbound", d = t.mode === "outbound" && t.autoStart !== !1, s = m(t.mount), i = w(s);
80
+ debug: !1,
81
+ ...n
82
+ }, d = t.mode !== "outbound";
83
+ t.mode === "outbound" && t.autoStart;
84
+ const s = g(t.mount), r = w(s);
48
85
  let a = null, c = null;
49
- i.innerHTML = `
86
+ r.innerHTML = `
50
87
  <style>${f}</style>
51
88
  <div class="shell">
52
- <button class="launch-btn" type="button">${t.text}</button>
89
+ <button class="boot-trigger" data-role="boot-trigger" type="button" aria-label="${t.text}">
90
+ ${u}
91
+ <span class="boot-badge" aria-hidden="true"></span>
92
+ <span class="sr-only">${t.text}</span>
93
+ </button>
53
94
  </div>
54
95
  `;
55
- const o = i.querySelector(".launch-btn");
56
- async function r() {
57
- return a || (c || (o.disabled = !0, o.textContent = "正在加载通话组件", c = (async () => {
58
- const n = typeof t.runtimeModuleLoader == "function" ? "" : y(t), u = (await p(n, t))?.createEmbeddedCallWidgetRuntime;
59
- if (typeof u != "function")
96
+ const i = r.querySelector('[data-role="boot-trigger"]');
97
+ async function o() {
98
+ return a || (c || (i.disabled = !0, c = (async () => {
99
+ const e = typeof t.runtimeModuleLoader == "function" ? "" : p(t), l = (await b(e, t))?.createEmbeddedCallWidgetRuntime;
100
+ if (typeof l != "function")
60
101
  throw new Error("运行时入口无效,缺少 createEmbeddedCallWidgetRuntime");
61
- return a = u({ mount: s, shadowRoot: i, options: t }), await a.mount(), a;
102
+ return a = l({ mount: s, shadowRoot: r, options: t }), await a.mount(), a;
62
103
  })()), await c);
63
104
  }
64
- return o.addEventListener("click", async () => {
105
+ return i.addEventListener("click", async () => {
65
106
  try {
66
- const n = await r();
67
- if (n.open(), l) {
68
- await n.startStandby();
107
+ const e = await o();
108
+ if (typeof e.handleTriggerClick == "function") {
109
+ await e.handleTriggerClick();
69
110
  return;
70
111
  }
71
- d && await n.connectAndCall();
72
- } catch (n) {
73
- o.disabled = !1, o.textContent = "加载失败,请重试", console.error("[embedded-call-widget] 运行时加载失败", n);
112
+ await e.connectAndCall();
113
+ } catch (e) {
114
+ i.disabled = !1, console.error("[embedded-call-widget] 运行时加载失败", e);
74
115
  }
75
- }), l && queueMicrotask(async () => {
116
+ }), d && queueMicrotask(async () => {
76
117
  try {
77
- const n = await r();
78
- n.open(), await n.startStandby();
79
- } catch (n) {
80
- o.disabled = !1, o.textContent = "待机初始化失败,请重试", console.error("[embedded-call-widget] 待机自动注册失败", n);
118
+ await (await o()).startStandby();
119
+ } catch (e) {
120
+ i.disabled = !1, console.error("[embedded-call-widget] 待机自动注册失败", e);
81
121
  }
82
122
  }), {
83
123
  async open() {
84
- (await r()).open();
124
+ (await o()).open();
85
125
  },
86
126
  async startStandby() {
87
- const n = await r();
88
- n.open(), await n.startStandby();
127
+ await (await o()).startStandby();
89
128
  },
90
129
  async connectAndCall() {
91
- const n = await r();
92
- n.open(), await n.connectAndCall();
130
+ await (await o()).connectAndCall();
93
131
  },
94
132
  async answerIncomingCall() {
95
- const n = await r();
96
- n.open(), await n.answerIncomingCall();
133
+ await (await o()).answerIncomingCall();
97
134
  },
98
135
  async declineIncomingCall() {
99
- const n = await r();
100
- n.open(), await n.declineIncomingCall();
136
+ await (await o()).declineIncomingCall();
101
137
  },
102
138
  async destroy() {
103
- a && await a.destroy(), i.innerHTML = "";
139
+ a && await a.destroy(), r.innerHTML = "";
104
140
  }
105
141
  };
106
142
  }
package/manifest.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "package_name": "@shenyin/embedded-call-widget",
3
- "source_package_version": "2.6.12",
4
- "built_at": "2026-04-08T16:48:08.291Z",
3
+ "source_package_version": "3.0.1",
4
+ "built_at": "2026-04-09T01:03:56.397Z",
5
5
  "outputs": {
6
6
  "esm_shell": "embedded-call-widget.js",
7
7
  "esm_runtime": "embedded-call-widget-runtime.js",
@@ -31,6 +31,7 @@
31
31
  "runtimeUrl",
32
32
  "transportBaseUrl",
33
33
  "accessToken",
34
+ "debug",
34
35
  "onStateChange",
35
36
  "onStandbyReady",
36
37
  "onIncomingCall",
@@ -54,36 +55,36 @@
54
55
  },
55
56
  "release_metadata": {
56
57
  "npm_package_name": "@shenyin/embedded-call-widget",
57
- "git_tag": "embedded-call-widget-v2.6.12",
58
- "git_tag_alias": "v2.6.12",
59
- "cdn_version_path": "embedded-call-widget/2.6.12/",
58
+ "git_tag": "embedded-call-widget-v3.0.1",
59
+ "git_tag_alias": "v3.0.1",
60
+ "cdn_version_path": "embedded-call-widget/3.0.1/",
60
61
  "cdn_latest_path": "embedded-call-widget/latest/",
61
62
  "semver_channel": "stable"
62
63
  },
63
64
  "asset_metadata": {
64
65
  "esm_shell": {
65
66
  "file": "embedded-call-widget.js",
66
- "size_bytes": 3321,
67
- "sha256": "69cdd0a3334992efd6cf570233e1cd2d0aacab04360546b4fd95e776e0a499d2",
68
- "sri_sha384": "sha384-Hw8YTsmGFwdKYVe11y0uuLPx+wzBkoBOuU6ZPW5d+SGoPaJCMaDuFt3hSXxBe5mr"
67
+ "size_bytes": 4180,
68
+ "sha256": "742604b728025e5eab204cc78821d3504487f9b355c395db21c99d9f50b0da93",
69
+ "sri_sha384": "sha384-A/mvItNXpbefVRLl6Dc3vFW4/iSX8vf0C2SWzsJOTXlkzMoplEODPCqLdii+R929"
69
70
  },
70
71
  "esm_runtime": {
71
72
  "file": "embedded-call-widget-runtime.js",
72
- "size_bytes": 525861,
73
- "sha256": "52052963fe606645e47a1d9898f9b12d3336af40d8ddc83b4b0e20b1aec14d93",
74
- "sri_sha384": "sha384-V2ZY6aI0DQ5hIK4I/5aZY3PW6iEuwosLCP5craWMiNibqyvlncd0N8wMQCXRlqkr"
73
+ "size_bytes": 536519,
74
+ "sha256": "8ef265e594383cce14b511cecfc3611508a187cc6d133dbb66a3c84330720db5",
75
+ "sri_sha384": "sha384-Y88gMCdP7x5XrNjJRruLHW1YG5RkwKrVFQH9gr+cSMB9OSpK5OvEmb9DfG3Y9Chm"
75
76
  },
76
77
  "iife_shell": {
77
78
  "file": "embedded-call-widget.iife.js",
78
- "size_bytes": 3162,
79
- "sha256": "f4664df394b9287ba012c49a4423439bd103eccffd9e8a212c72fbeffc589054",
80
- "sri_sha384": "sha384-m6vho+wEOvrSk3C9G8osLB7hQlBI+iDM3MWA1JymL2VdQhoMTQh/XQ+ltM6N789m"
79
+ "size_bytes": 4067,
80
+ "sha256": "410eabc93a3c197059dafc571928046daddc88066b0263c3ce9e071885a8d242",
81
+ "sri_sha384": "sha384-B83qy8cs+Xj+wg+4gQPyommOG23xd4JsDs40Q7UWKchAjPo+Hj0Vf8yl067d0fU+"
81
82
  },
82
83
  "iife_runtime": {
83
84
  "file": "embedded-call-widget-runtime.iife.js",
84
- "size_bytes": 340879,
85
- "sha256": "7af6f4c17dcaf13aa37740f1e17b70261c363224daaef6d6b00428f906c729c5",
86
- "sri_sha384": "sha384-9PEXwOa54vrKsUX0bNa3KeLnjR3pbV/4YYocoBmdwva1RX/Xwd4asxVb0jQZ8Ktt"
85
+ "size_bytes": 350752,
86
+ "sha256": "203b997a290a0c7a01d3e4a30f9f941148ff9b95c3c8f2b5729fc599c061f0fd",
87
+ "sri_sha384": "sha384-+fypdWEKc3W42EGbtYbxsCIoE+XE282pnYglPUjjmVzp0AGBKVl1cT72mqaic+CX"
87
88
  }
88
89
  }
89
90
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shenyin/embedded-call-widget",
3
- "version": "2.6.12",
3
+ "version": "3.0.1",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "files": [