@hgt-weprotalk/mira-client 0.1.21 → 0.1.22
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/assets/{launcher-D5gmlTx-.js → launcher-BaqU_YNU.js} +44 -26
- package/dist/components/chat-widget/layoutTokens.d.ts +1 -1
- package/dist/embed/assets/{frame-BBn9Hafa.js → frame-VdmCXt0d.js} +2 -2
- package/dist/embed/assets/{lib-C56vNTpU.js → lib-kYkoLnAC.js} +1 -1
- package/dist/embed/assets/{style-DiPXQIiL.css → style-ejd9bFYf.css} +1 -1
- package/dist/embed/chat-widget.js +44 -26
- package/dist/embed/frame.html +2 -2
- package/dist/hooks/useChatWidgetMobile.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/mira-client.css +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){var e=`mira-chat-widget`,t=e=>!!e&&typeof e==`object`&&`source`in e,n=e=>{if(!t(e)||e.source!==`mira-chat-widget`)return!1;let n=e;return n.type===`resize`?typeof n.width==`number`&&typeof n.height==`number`&&n.width>0&&n.height>0:n.type===`event`?typeof n.name==`string`:n.type===`response`&&typeof n.requestId==`string`&&typeof n.ok==`boolean`},r=(e=>e.replace(/<!--[\s\S]*?-->/g,``).replace(/\sclass="[^"]*"/g,``).trim())(`<!-- @license lucide-static v1.34.0 - ISC --> <svg class="lucide lucide-chevron-down" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="m6 9 6 6 6-6" /> </svg>`).replace(`<svg `,`<svg class="mira-chat-launcher-chevron" `),i=e=>/^https?:\/\//.test(e)||e.startsWith(`/`)||e.startsWith(`data:`),a={panelWidthPx:520,panelHeightPx:740,panelViewportTopInsetPx:16,panelLauncherReservedBlockPx:92,assistantBubbleMaxWidthPx:445,assistantBodyMaxWidthPx:415,productCardWidthPx:202,mobileBreakpointPx:
|
|
1
|
+
(function(){var e=`mira-chat-widget`,t=e=>!!e&&typeof e==`object`&&`source`in e,n=e=>{if(!t(e)||e.source!==`mira-chat-widget`)return!1;let n=e;return n.type===`resize`?typeof n.width==`number`&&typeof n.height==`number`&&n.width>0&&n.height>0:n.type===`event`?typeof n.name==`string`:n.type===`response`&&typeof n.requestId==`string`&&typeof n.ok==`boolean`},r=(e=>e.replace(/<!--[\s\S]*?-->/g,``).replace(/\sclass="[^"]*"/g,``).trim())(`<!-- @license lucide-static v1.34.0 - ISC --> <svg class="lucide lucide-chevron-down" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="m6 9 6 6 6-6" /> </svg>`).replace(`<svg `,`<svg class="mira-chat-launcher-chevron" `),i=e=>/^https?:\/\//.test(e)||e.startsWith(`/`)||e.startsWith(`data:`),a={panelWidthPx:520,panelHeightPx:740,panelViewportTopInsetPx:16,panelLauncherReservedBlockPx:92,assistantBubbleMaxWidthPx:445,assistantBodyMaxWidthPx:415,productCardWidthPx:202,mobileBreakpointPx:768,mobilePanelHorizontalInsetPx:16,mobilePanelVerticalReservedPx:84,mobileAssistantBubbleMaxWidth:`98%`,mobileAssistantBodyMaxWidth:`calc(100vw - 44px)`};a.panelLauncherReservedBlockPx;var o={right:`--mira-chat-widget-window-right`,bottom:`--mira-chat-widget-window-bottom`,left:`--mira-chat-widget-window-left`,top:`--mira-chat-widget-window-top`,width:`--mira-chat-widget-window-width`,maxWidth:`--mira-chat-widget-window-max-width`,height:`--mira-chat-widget-window-height`,maxHeight:`--mira-chat-widget-window-max-height`,borderRadius:`--mira-chat-widget-window-border-radius`},s={windowRightPx:20,buttonBottomPx:20,buttonHeightPx:56,gapPx:16,widthPx:a.panelWidthPx,heightPx:a.panelHeightPx,borderRadiusPx:18},c=s.buttonBottomPx+s.buttonHeightPx+s.gapPx,l=e=>`${e}px`,u=`min(${l(a.panelHeightPx)}, calc(100dvh - ${a.panelViewportTopInsetPx}px - ${c}px))`,d=`
|
|
2
2
|
${o.right}: ${l(s.windowRightPx)};
|
|
3
3
|
${o.bottom}: ${l(c)};
|
|
4
4
|
${o.left}: unset;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
${o.height}: ${l(s.heightPx)};
|
|
9
9
|
${o.maxHeight}: ${u};
|
|
10
10
|
${o.borderRadius}: ${l(s.borderRadiusPx)};
|
|
11
|
-
`;`${o.right}${l(s.windowRightPx)}${o.bottom}${l(c)}${o.width}${l(s.widthPx)}${o.height}${l(s.heightPx)}${o.maxHeight}${u}${o.borderRadius}${l(s.borderRadiusPx)}`;var f=(e,t=16)=>{let n=e.trim();return!n||n===`unset`||n===`auto`?0:n.endsWith(`rem`)?Number.parseFloat(n)*t:n.endsWith(`px`)?Number.parseFloat(n):Number.parseFloat(n)||0},p=(e,t=document.documentElement)=>{let n=getComputedStyle(t),r=Number.parseFloat(n.fontSize)||16;return f(n.getPropertyValue(e),r)},m=`mira-chat-widget-button`,
|
|
11
|
+
`;`${o.right}${l(s.windowRightPx)}${o.bottom}${l(c)}${o.width}${l(s.widthPx)}${o.height}${l(s.heightPx)}${o.maxHeight}${u}${o.borderRadius}${l(s.borderRadiusPx)}`;var f=(e,t=16)=>{let n=e.trim();return!n||n===`unset`||n===`auto`?0:n.endsWith(`rem`)?Number.parseFloat(n)*t:n.endsWith(`px`)?Number.parseFloat(n):Number.parseFloat(n)||0},p=(e,t=document.documentElement)=>{let n=getComputedStyle(t),r=Number.parseFloat(n.fontSize)||16;return f(n.getPropertyValue(e),r)},m=a.mobileBreakpointPx,h=()=>typeof window>`u`?!1:window.innerWidth<=m,g=`(max-width: ${m}px)`,_=`mira-chat-widget-button`,v=`mira-chat-widget-window`,y=`mira-chat-widget-control`,b=`mira-chat-widget-style`,x=320,S=`cubic-bezier(0.22, 1, 0.36, 1)`,C=`
|
|
12
12
|
right: var(${o.right});
|
|
13
13
|
bottom: var(${o.bottom});
|
|
14
14
|
left: var(${o.left});
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
height: var(${o.height});
|
|
19
19
|
max-height: var(${o.maxHeight});
|
|
20
20
|
border-radius: var(${o.borderRadius});
|
|
21
|
-
`,
|
|
21
|
+
`,w=()=>{if(document.getElementById(b))return;let e=document.createElement(`style`);e.id=b,e.textContent=`
|
|
22
22
|
:root {
|
|
23
23
|
--mira-chat-widget-button-right: ${s.windowRightPx}px;
|
|
24
24
|
--mira-chat-widget-button-bottom: ${s.buttonBottomPx}px;
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
${d}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
#${
|
|
42
|
+
#${_} {
|
|
43
43
|
position: fixed;
|
|
44
44
|
right: var(--mira-chat-widget-button-right);
|
|
45
45
|
bottom: var(--mira-chat-widget-button-bottom);
|
|
@@ -54,18 +54,18 @@
|
|
|
54
54
|
color: var(--mira-chat-widget-button-color);
|
|
55
55
|
line-height: 1;
|
|
56
56
|
cursor: pointer;
|
|
57
|
-
z-index:
|
|
57
|
+
z-index: 2147483645;
|
|
58
58
|
display: grid;
|
|
59
59
|
place-items: center;
|
|
60
60
|
padding: 0;
|
|
61
61
|
overflow: hidden;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
#${
|
|
64
|
+
#${_}.is-below-iframe {
|
|
65
65
|
z-index: 2147483645;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
#${
|
|
68
|
+
#${_} .mira-chat-launcher-avatar {
|
|
69
69
|
position: absolute;
|
|
70
70
|
inset: 0;
|
|
71
71
|
width: 100%;
|
|
@@ -78,26 +78,26 @@
|
|
|
78
78
|
pointer-events: none;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
#${
|
|
81
|
+
#${_} .mira-chat-launcher-avatar.is-visible {
|
|
82
82
|
opacity: 1;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
#${
|
|
85
|
+
#${_} svg {
|
|
86
86
|
width: 26px;
|
|
87
87
|
height: 26px;
|
|
88
88
|
display: block;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
#${
|
|
92
|
-
transition: transform 220ms ${
|
|
91
|
+
#${_} .mira-chat-launcher-chevron {
|
|
92
|
+
transition: transform 220ms ${S};
|
|
93
93
|
transform-origin: center;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
#${
|
|
97
|
-
transform: rotate(
|
|
96
|
+
#${_}.is-open .mira-chat-launcher-chevron {
|
|
97
|
+
transform: rotate(0deg);
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
#${
|
|
100
|
+
#${v} {
|
|
101
101
|
position: fixed;
|
|
102
102
|
inset: 0;
|
|
103
103
|
width: 100%;
|
|
@@ -112,18 +112,18 @@
|
|
|
112
112
|
transform: translateY(14px) scale(0.97);
|
|
113
113
|
transform-origin: bottom right;
|
|
114
114
|
transition:
|
|
115
|
-
opacity ${
|
|
116
|
-
transform ${
|
|
115
|
+
opacity ${x}ms ${S},
|
|
116
|
+
transform ${x}ms ${S};
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
#${
|
|
119
|
+
#${v}.is-open {
|
|
120
120
|
opacity: 1;
|
|
121
121
|
transform: translateY(0) scale(1);
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
#${
|
|
124
|
+
#${y} {
|
|
125
125
|
position: fixed;
|
|
126
|
-
${
|
|
126
|
+
${C}
|
|
127
127
|
z-index: 2147483645;
|
|
128
128
|
display: none;
|
|
129
129
|
background: transparent;
|
|
@@ -132,20 +132,38 @@
|
|
|
132
132
|
transform: translateY(14px) scale(0.97);
|
|
133
133
|
transform-origin: bottom right;
|
|
134
134
|
transition:
|
|
135
|
-
opacity ${
|
|
136
|
-
transform ${
|
|
135
|
+
opacity ${x}ms ${S},
|
|
136
|
+
transform ${x}ms ${S};
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
#${
|
|
139
|
+
#${y}.is-open {
|
|
140
140
|
opacity: 1;
|
|
141
141
|
transform: translateY(0) scale(1);
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
@media ${g} {
|
|
145
|
+
#${y} {
|
|
146
|
+
display: none !important;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
#${v} {
|
|
150
|
+
pointer-events: auto;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
#${v}.is-open {
|
|
154
|
+
z-index: 2147483647;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
#${_}.is-open {
|
|
158
|
+
z-index: 2147483646;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
144
162
|
@media (prefers-reduced-motion: reduce) {
|
|
145
|
-
#${
|
|
146
|
-
#${
|
|
147
|
-
#${
|
|
163
|
+
#${_} .mira-chat-launcher-chevron,
|
|
164
|
+
#${v},
|
|
165
|
+
#${y} {
|
|
148
166
|
transition-duration: 0.01ms !important;
|
|
149
167
|
}
|
|
150
168
|
}
|
|
151
|
-
`,document.head.appendChild(e)},
|
|
169
|
+
`,document.head.appendChild(e)},T=()=>{let e=document.currentScript;return e instanceof HTMLScriptElement?e:document.querySelector(`script[data-agent-name]`)},E=e=>{let t=new URL(e.src,window.location.href),n=t.pathname.replace(/\/[^/]+$/,``);return new URL(`${n}/`,t.origin)},D=e=>{let t=new URL(`frame.html`,E(e)),{agentName:n,site:r,locale:i,apiBaseUrl:a,launcherAvatar:o}=e.dataset;return n?.trim()&&t.searchParams.set(`agentName`,n.trim()),r?.trim()&&t.searchParams.set(`site`,r.trim()),i?.trim()&&t.searchParams.set(`locale`,i.trim()),a?.trim()&&t.searchParams.set(`apiBaseUrl`,a.trim()),o?.trim()&&t.searchParams.set(`launcherAvatar`,o.trim()),t.searchParams.set(`layout`,`inline`),t.searchParams.set(`parentOrigin`,window.location.origin),t};(()=>{if(document.getElementById(_))return;let t=T();if(!t){console.error(`[mira-chat] launcher script tag not found`);return}w();let a=D(t),l=a.origin,u=t.dataset.launcherAvatar?.trim()??``,d=i(u)?u:``,f=!1,m=document.createElement(`button`);m.id=_,m.type=`button`,m.title=`Open chat`,m.setAttribute(`aria-label`,`Open chat`),m.style.display=`none`;let g=e=>{if(m.innerHTML=r,e||!d||f)return;let t=document.createElement(`img`);t.className=`mira-chat-launcher-avatar`,t.src=d,t.alt=``,t.setAttribute(`aria-hidden`,`true`),t.addEventListener(`load`,()=>{t.classList.add(`is-visible`)},{once:!0}),t.addEventListener(`error`,()=>{f=!0,g(e)},{once:!0}),m.appendChild(t)};g(!1);let b=document.createElement(`iframe`);b.id=v,b.title=`Mira Chat Widget`,b.setAttribute(`allow`,`clipboard-write`),b.setAttribute(`allowtransparency`,`true`),b.style.backgroundColor=`transparent`,b.src=a.toString();let S=null,C=!1,E=null;document.body.appendChild(b),document.body.appendChild(m);let O=()=>{E!==null&&(clearTimeout(E),E=null)},k=()=>{S!==null&&(b.style.pointerEvents=`none`,S.style.pointerEvents=`auto`)},A=()=>{S!==null&&(b.style.pointerEvents=`auto`,S.style.pointerEvents=`none`)};h()||(S=document.createElement(`div`),S.id=y,S.setAttribute(`aria-hidden`,`true`),S.addEventListener(`mouseenter`,()=>{C&&A()}),document.body.appendChild(S));let j=()=>{if(S===null)return{width:s.widthPx,height:s.heightPx,right:s.windowRightPx,bottom:c,borderRadius:s.borderRadiusPx};let e=S.getBoundingClientRect(),t=window.getComputedStyle(S),n=Number.parseFloat(t.borderRadius)||s.borderRadiusPx;return{width:e.width,height:e.height,right:p(o.right),bottom:p(o.bottom),borderRadius:n}},M=()=>{if(!C||b.contentWindow===null||h())return;let t={source:e,type:`command`,name:`set-dialog-layout`,payload:j()};b.contentWindow.postMessage(t,l)},N=()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{M()})})},P=()=>{let e=document.documentElement;for(let t of Object.values(o))e.style.removeProperty(t)},F=e=>{m.classList.toggle(`is-below-iframe`,e)},I=e=>{m.classList.toggle(`is-open`,e),m.title=e?`Close chat`:`Open chat`,m.setAttribute(`aria-label`,e?`Close chat`:`Open chat`),g(e)},L=()=>{if(b.contentWindow===null)return;let t={source:e,type:`command`,name:`panel-open`};b.contentWindow.postMessage(t,l)};window.addEventListener(`message`,e=>{if(e.origin===l&&!(!n(e.data)||e.data.type!==`event`)){if(e.data.name===`ready`){m.style.display=`grid`,N();return}if(e.data.name===`dialog-pointer-leave`){h()||k();return}if(e.data.name===`photo-preview-open`){F(!0);return}if(e.data.name===`photo-preview-close`){F(!1);return}if(e.data.name===`launcher-avatar`){if(u)return;let t=e.data.payload?.url?.trim()??``;if(!i(t))return;d=t,f=!1,C||g(!1)}}});let R=()=>{if(O(),C=!0,I(!0),b.style.display=`block`,h()){requestAnimationFrame(()=>{b.classList.add(`is-open`)}),L();return}S!==null&&(S.style.display=`block`),requestAnimationFrame(()=>{b.classList.add(`is-open`),S?.classList.add(`is-open`)}),N(),L()},z=()=>{if(C){if(O(),C=!1,I(!1),h()){b.classList.remove(`is-open`),b.style.display=`none`,F(!1);return}b.classList.remove(`is-open`),S?.classList.remove(`is-open`),k(),E=setTimeout(()=>{E=null,b.style.display=`none`,S!==null&&(S.style.display=`none`),P(),F(!1)},x)}};m.addEventListener(`click`,()=>{if(C){z();return}R()}),window.addEventListener(`resize`,()=>{h()||N()}),window.__MIRA_CHAT_WIDGET__={iframe:b,frameOrigin:l,mode:`launcher`,open:R,close:z},window.dispatchEvent(new CustomEvent(`mira-chat-widget-mounted`))})()})();
|
|
@@ -12,7 +12,7 @@ export declare const CHAT_WIDGET_LAYOUT: {
|
|
|
12
12
|
readonly assistantBodyMaxWidthPx: 415;
|
|
13
13
|
/** 商品卡片固定宽度(单卡 / 多卡共用,Swiper slidesPerView auto) */
|
|
14
14
|
readonly productCardWidthPx: 202;
|
|
15
|
-
readonly mobileBreakpointPx:
|
|
15
|
+
readonly mobileBreakpointPx: 768;
|
|
16
16
|
readonly mobilePanelHorizontalInsetPx: 16;
|
|
17
17
|
readonly mobilePanelVerticalReservedPx: 84;
|
|
18
18
|
readonly mobileAssistantBubbleMaxWidth: "98%";
|