@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.
@@ -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:680,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=`
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`,h=`mira-chat-widget-window`,g=`mira-chat-widget-control`,_=`mira-chat-widget-style`,v=320,y=`cubic-bezier(0.22, 1, 0.36, 1)`,b=`
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
- `,x=()=>{if(document.getElementById(_))return;let e=document.createElement(`style`);e.id=_,e.textContent=`
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
- #${m} {
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: 2147483647;
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
- #${m}.is-below-iframe {
64
+ #${_}.is-below-iframe {
65
65
  z-index: 2147483645;
66
66
  }
67
67
 
68
- #${m} .mira-chat-launcher-avatar {
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
- #${m} .mira-chat-launcher-avatar.is-visible {
81
+ #${_} .mira-chat-launcher-avatar.is-visible {
82
82
  opacity: 1;
83
83
  }
84
84
 
85
- #${m} svg {
85
+ #${_} svg {
86
86
  width: 26px;
87
87
  height: 26px;
88
88
  display: block;
89
89
  }
90
90
 
91
- #${m} .mira-chat-launcher-chevron {
92
- transition: transform 220ms ${y};
91
+ #${_} .mira-chat-launcher-chevron {
92
+ transition: transform 220ms ${S};
93
93
  transform-origin: center;
94
94
  }
95
95
 
96
- #${m}.is-open .mira-chat-launcher-chevron {
97
- transform: rotate(180deg);
96
+ #${_}.is-open .mira-chat-launcher-chevron {
97
+ transform: rotate(0deg);
98
98
  }
99
99
 
100
- #${h} {
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 ${v}ms ${y},
116
- transform ${v}ms ${y};
115
+ opacity ${x}ms ${S},
116
+ transform ${x}ms ${S};
117
117
  }
118
118
 
119
- #${h}.is-open {
119
+ #${v}.is-open {
120
120
  opacity: 1;
121
121
  transform: translateY(0) scale(1);
122
122
  }
123
123
 
124
- #${g} {
124
+ #${y} {
125
125
  position: fixed;
126
- ${b}
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 ${v}ms ${y},
136
- transform ${v}ms ${y};
135
+ opacity ${x}ms ${S},
136
+ transform ${x}ms ${S};
137
137
  }
138
138
 
139
- #${g}.is-open {
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
- #${m} .mira-chat-launcher-chevron,
146
- #${h},
147
- #${g} {
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)},S=()=>{let e=document.currentScript;return e instanceof HTMLScriptElement?e:document.querySelector(`script[data-agent-name]`)},C=e=>{let t=new URL(e.src,window.location.href),n=t.pathname.replace(/\/[^/]+$/,``);return new URL(`${n}/`,t.origin)},w=e=>{let t=new URL(`frame.html`,C(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(m))return;let t=S();if(!t){console.error(`[mira-chat] launcher script tag not found`);return}x();let a=w(t),c=a.origin,l=t.dataset.launcherAvatar?.trim()??``,u=i(l)?l:``,d=!1,f=document.createElement(`button`);f.id=m,f.type=`button`,f.title=`Open chat`,f.setAttribute(`aria-label`,`Open chat`),f.style.display=`none`;let _=e=>{if(f.innerHTML=r,e||!u||d)return;let t=document.createElement(`img`);t.className=`mira-chat-launcher-avatar`,t.src=u,t.alt=``,t.setAttribute(`aria-hidden`,`true`),t.addEventListener(`load`,()=>{t.classList.add(`is-visible`)},{once:!0}),t.addEventListener(`error`,()=>{d=!0,_(e)},{once:!0}),f.appendChild(t)};_(!1);let y=document.createElement(`iframe`);y.id=h,y.title=`Mira Chat Widget`,y.setAttribute(`allow`,`clipboard-write`),y.setAttribute(`allowtransparency`,`true`),y.style.backgroundColor=`transparent`,y.src=a.toString();let b=document.createElement(`div`);b.id=g,b.setAttribute(`aria-hidden`,`true`),document.body.appendChild(y),document.body.appendChild(b),document.body.appendChild(f);let C=!1,T=null,E=()=>{T!==null&&(clearTimeout(T),T=null)},D=()=>{y.style.pointerEvents=`none`,b.style.pointerEvents=`auto`},O=()=>{y.style.pointerEvents=`auto`,b.style.pointerEvents=`none`},k=()=>{let e=b.getBoundingClientRect(),t=window.getComputedStyle(b),n=Number.parseFloat(t.borderRadius)||s.borderRadiusPx;return{width:e.width,height:e.height,right:p(o.right),bottom:p(o.bottom),borderRadius:n}},A=()=>{if(!C||y.contentWindow===null)return;let t={source:e,type:`command`,name:`set-dialog-layout`,payload:k()};y.contentWindow.postMessage(t,c)},j=()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{A()})})},M=()=>{let e=document.documentElement;for(let t of Object.values(o))e.style.removeProperty(t)},N=e=>{f.classList.toggle(`is-below-iframe`,e)};window.addEventListener(`message`,e=>{if(e.origin===c&&!(!n(e.data)||e.data.type!==`event`)){if(e.data.name===`ready`){f.style.display=`grid`,j();return}if(e.data.name===`dialog-pointer-leave`){D();return}if(e.data.name===`photo-preview-open`){N(!0);return}if(e.data.name===`photo-preview-close`){N(!1);return}if(e.data.name===`launcher-avatar`){if(l)return;let t=e.data.payload?.url?.trim()??``;if(!i(t))return;u=t,d=!1,C||_(!1)}}}),b.addEventListener(`mouseenter`,()=>{C&&O()});let P=e=>{f.classList.toggle(`is-open`,e),f.title=e?`Close chat`:`Open chat`,f.setAttribute(`aria-label`,e?`Close chat`:`Open chat`),_(e)},F=()=>{if(y.contentWindow===null)return;let t={source:e,type:`command`,name:`panel-open`};y.contentWindow.postMessage(t,c)},I=()=>{E(),y.style.display=`block`,b.style.display=`block`,D(),C=!0,P(!0),requestAnimationFrame(()=>{y.classList.add(`is-open`),b.classList.add(`is-open`)}),j(),F()},L=()=>{C&&(E(),C=!1,P(!1),y.classList.remove(`is-open`),b.classList.remove(`is-open`),D(),T=setTimeout(()=>{T=null,y.style.display=`none`,b.style.display=`none`,M(),N(!1)},v))};f.addEventListener(`click`,()=>{if(C){L();return}I()}),window.addEventListener(`resize`,()=>{j()}),window.__MIRA_CHAT_WIDGET__={iframe:y,frameOrigin:c,mode:`launcher`,open:I,close:L},window.dispatchEvent(new CustomEvent(`mira-chat-widget-mounted`))})()})();
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: 680;
15
+ readonly mobileBreakpointPx: 768;
16
16
  readonly mobilePanelHorizontalInsetPx: 16;
17
17
  readonly mobilePanelVerticalReservedPx: 84;
18
18
  readonly mobileAssistantBubbleMaxWidth: "98%";