@wexio/messenger-widget-react 1.7.5 → 1.7.7

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/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @wexio/messenger-widget-react
2
2
 
3
+ ## 1.7.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 519cdc7: News and help previews (home featured card, news tab, help lists, article lead) show plain text: HTML and Markdown are stripped, the text is cut on a word boundary with an ellipsis (also when the BE already cut it), and the cards are line-clamped. A news card or article without a cover image renders no cover block, and a cover that fails to load is hidden. An article lead that only repeats the start of the body is dropped, and mixed text-then-HTML bodies render as HTML.
8
+ - 340e1a5: Quick-action named icons: 8 more social brands (`youtube`, `x`, `threads`, `pinterest`, `snapchat`, `twitch`, `github`, `spotify`), 2 messengers (`signal`, `wechat`) and 7 action icons (`globe`, `calendar`, `map-pin`, `shopping-cart`, `download`, `gift`, `file-text`). Unknown names still fall back to the chat bubble.
9
+
10
+ ## 1.7.6
11
+
12
+ ### Patch Changes
13
+
14
+ - f4adfa6: Greeting variables `page.title` and `page.path`: the widget sends the host page the session starts on (`pageTitle`, `pagePath`) so the backend can render them; the playground preview knows both
15
+ - cba72e6: One long-lived SSE stream per tab: sound and notifications now come from the threads stream, and the per-chat stream opens only while a conversation is on screen
16
+ - f89e688: The conversation shows the AI "thinking" bubble right after the visitor's send, before the first realtime frame (not when an operator is connected or the queue is pending, with the AI agent off, or for a send queued offline). A deleted last message (`lastMessageDeletedId` on the threads stream) refreshes the thread list, the launcher peek and the unread count. The thread list now queries `lastMessageId`, so this release needs a BE that serves `VisitorThread.lastMessageId` (BE 1.8.0 or later).
17
+
3
18
  ## 1.7.5
4
19
 
5
20
  ### Patch Changes
@@ -0,0 +1,2 @@
1
+ globalThis.process===void 0&&(globalThis.process={env:{},nextTick:function(e){setTimeout(e,0)},emit:function(){return!1}});import"react";import"react-dom";import"react/jsx-runtime";import"react-dom/client";import{S as e,b as t,n}from"./widget-react-DIvxQOfe.js";import{A as r,Dt as i,O as a,Q as o,Rt as s,c,d as l,f as u,j as d,l as f,m as p,nt as m,u as h,w as g}from"./widget-react-BbMhq_D0.js";import{_,f as v,g as y,i as ee,n as te,r as ne}from"./widget-react-PNvF_UGi.js";import{i as re,n as ie,o as b,r as x,s as S,t as ae}from"./widget-react-C6zJ0C4y.js";import{useEffect as C,useMemo as w,useRef as T,useState as E}from"react";import{jsx as D,jsxs as O}from"react/jsx-runtime";var k=3;function oe(e,t,n=k){let r=e.find(e=>e.id===t),i=new Set((r?.tags??[]).map(e=>e.slug)),a=r?.category?.slug;return e.filter(e=>e.id!==t).map(e=>({n:e,score:(a&&e.category?.slug===a?1:0)+(e.tags??[]).filter(e=>i.has(e.slug)).length})).sort((e,t)=>t.score-e.score||t.n.publishedAt.localeCompare(e.n.publishedAt)).slice(0,n).map(({n:e})=>({id:e.id,title:e.title,coverImageUrl:e.coverImageUrl}))}function se(e){if(!e||typeof e!=`object`)return null;let t=e,n=String(t._id??t.id??``);if(!n)return null;let r=t.coverImageUrl?.url,i=t.externalCoverImageUrl,a=typeof r==`string`?r:typeof i==`string`?i:void 0,o=Array.isArray(t.tags)?t.tags.map(e=>{if(!e||typeof e!=`object`)return null;let t=e.slug,n=e.label;return typeof t!=`string`||typeof n!=`string`?null:{slug:t,label:n}}).filter(e=>!!e):void 0,s=e=>{if(!Array.isArray(e))return;let t=[];for(let n of e)if(n){if(typeof n==`string`)t.push(n);else if(typeof n==`object`){let e=n._id??n.id;typeof e==`string`&&t.push(e)}}return t.length>0?t:void 0},c=Array.isArray(t.translations)?t.translations.map(e=>{if(!e||typeof e!=`object`)return null;let t=String(e._id??e.id??``),n=e.locale;return!t||typeof n!=`string`?null:{id:t,locale:n}}).filter(e=>!!e):void 0,l=Array.isArray(t.authors)?t.authors.map(e=>{if(!e||typeof e!=`object`)return null;let t=e.name;if(typeof t!=`string`)return null;let n=e._id,r=e.photo?.url;return{_id:String(n??t),name:t,photo:{url:typeof r==`string`?r:``}}}).filter(e=>!!e):void 0;return{id:n,title:typeof t.title==`string`?t.title:``,excerpt:typeof t.excerpt==`string`?t.excerpt:``,contentMarkdown:typeof t.contentMarkdown==`string`?t.contentMarkdown:void 0,bodyFormat:typeof t.bodyFormat==`string`?t.bodyFormat:void 0,coverImageUrl:a,publishedAt:typeof t.publishedAt==`string`?t.publishedAt:new Date().toISOString(),upstreamUpdatedAt:typeof t.upstreamUpdatedAt==`string`?t.upstreamUpdatedAt:void 0,sourceUrl:typeof t.sourceUrl==`string`?t.sourceUrl:void 0,reactionCounts:t.reactionCounts??null,viewerReaction:typeof t.viewerReaction==`number`?t.viewerReaction:null,tags:o,authors:l,categoryIds:s(t.categories),tagIds:s(t.tags),locale:typeof t.locale==`string`?t.locale:void 0,translations:c}}function A({currentId:e,currentCategoryIds:n,currentTagIds:r,previewPostsById:i,visitorRelatedRaw:a,isDummy:o,demoItems:s,onOpen:c}){let l=t(`news`),u=(()=>{if(o)return s??[];if(Array.isArray(a)&&a.length>0)return a.filter(e=>!!e&&typeof e==`object`).map(e=>{let t=e.coverImageUrl?.url??e.externalCoverImageUrl;return{id:String(e._id??e.id??``),title:typeof e.title==`string`?e.title:``,coverImageUrl:typeof t==`string`?t:void 0}}).filter(e=>e.id&&e.title);if(i&&Object.keys(i).length>0&&(n.length>0||r.length>0)){let t=new Set(n),a=new Set(r),o=[];for(let[n,r]of Object.entries(i)){if(n===e||!r||typeof r!=`object`)continue;let i=r,s=Array.isArray(i.categories)?i.categories:[],c=Array.isArray(i.tags)?i.tags:[],l=e=>{let t=new Set;for(let n of e)if(n&&typeof n==`object`){let e=n._id??n.id;typeof e==`string`&&t.add(e)}return t},u=l(s),d=l(c),f=0;for(let e of u)t.has(e)&&f++;for(let e of d)a.has(e)&&f++;if(f===0)continue;let p=i.coverImageUrl?.url??i.externalCoverImageUrl;o.push({id:n,title:typeof i.title==`string`?i.title:``,coverImageUrl:typeof p==`string`?p:void 0,overlap:f,publishedAt:typeof i.publishedAt==`string`?i.publishedAt:``})}return o.sort((e,t)=>t.overlap===e.overlap?t.publishedAt.localeCompare(e.publishedAt):t.overlap-e.overlap),o.slice(0,5).map(({id:e,title:t,coverImageUrl:n})=>({id:e,title:t,coverImageUrl:n}))}return[]})();return u.length===0?null:O(`section`,{className:`mt-6`,children:[D(`p`,{className:`mb-2 text-xs font-semibold tracking-wide text-wx-fg-muted uppercase`,children:l(`relatedTitle`)}),D(`ul`,{className:`flex flex-col gap-2`,children:u.map(e=>D(`li`,{children:O(`button`,{type:`button`,onClick:()=>c(e.id),className:`flex w-full items-center gap-3 rounded-wx-lg bg-wx-bg-elevated px-3 py-2 text-start transition-colors hover:bg-wx-bg-elevated/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-wx-primary`,children:[D(`span`,{className:`aspect-square w-12 shrink-0 rounded-wx-sm bg-cover bg-center`,style:e.coverImageUrl?{backgroundImage:`url(${e.coverImageUrl})`}:{background:`linear-gradient(135deg, #1e1f21, #121314)`},"aria-hidden":`true`}),D(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-wx-fg`,children:e.title})]})},e.id))})]})}function j({id:n,isDummy:k,onOpenRelated:j,onTitleResolved:N}){let P=t(`news`),F=r(),I=h(),L=e(),R=o(),{config:z}=g(),B=z.messenger?.showRelatedNews??!0,V=z.messenger?.showReactionCounts??!0,{trackLinkClick:H}=c(),U=T(null),W=e=>{j?.(e)},[G,ce]=E(L),K=d(G,F),q=k?null:R.previewData?.newsPostsById?.[n],J=!!q,{data:le,loading:ue}=y({variables:{args:{id:n,locale:L}},skip:k||J||!n}),Y=s().publicKey,de=f(Y&&!k&&!J&&n?m.newsPost(Y,n,L):null,le),{data:fe}=_({variables:{postId:n,limit:5,locale:L},skip:k||J||!n||!B}),X=k?i(K).find(e=>e.id===n)??null:null,pe=w(()=>k?oe(i(K),n):void 0,[k,K,n]),Z=X?{id:X.id,title:X.title,excerpt:X.excerpt,contentMarkdown:X.contentMarkdown,bodyFormat:`markdown`,coverImageUrl:X.coverImageUrl,coverGradient:X.coverGradient,publishedAt:X.publishedAt,upstreamUpdatedAt:X.upstreamUpdatedAt,tags:X.tags,authors:X.authors,category:X.category,locale:G}:se(J?q:de?.visitorNewsPost);if(re(Z?.title,N),C(()=>{k||J||!Z?.id||U.current!==Z.id&&(U.current=Z.id,H({url:`/news/${Z.id}`,targetType:`NEWS_POST`,targetRefId:Z.id}))},[Z?.id,k,J,H]),!Z)return ue?D(M,{}):D(`div`,{className:`flex flex-1 items-center justify-center px-6 py-12 text-center`,children:D(`p`,{className:`text-sm text-wx-fg-muted`,children:P(`articleNotFound`)})});let me=L.split(`-`)[0].toLowerCase(),Q=Z.locale?Z.locale.split(`-`)[0].toLowerCase():null;if(!k&&!J&&!z.contentLocaleFallback&&Q!==null&&Q!==me)return D(`div`,{className:`flex flex-1 items-center justify-center px-6 py-12 text-center`,children:D(`p`,{className:`text-sm text-wx-fg-muted`,children:P(`articleNotTranslated`)})});let $=l(Z.excerpt,Z.contentMarkdown)?``:u(Z.excerpt,400);return D(p,{followDirection:!0,className:`flex-1`,viewportRef:I,children:O(`div`,{className:`flex flex-col`,children:[D(ee,{url:Z.coverImageUrl,className:`aspect-[16/9]`}),O(`div`,{className:`flex flex-col gap-3 px-5 pt-5 pb-12 [overflow-wrap:anywhere]`,children:[Z.category&&D(`p`,{className:`text-[11px] font-semibold tracking-[0.14em] text-wx-primary uppercase`,children:Z.category.label}),O(`p`,{className:`flex items-center gap-2 text-xs text-wx-fg-subtle`,children:[D(`span`,{children:new Date(Z.publishedAt).toLocaleDateString(L,{month:`long`,day:`numeric`,year:`numeric`})}),ne(Z)&&Z.upstreamUpdatedAt&&D(`span`,{className:`rounded-full bg-wx-bg-elevated px-1.5 py-0.5 text-[10px] font-medium text-wx-fg-muted`,title:new Date(Z.upstreamUpdatedAt).toLocaleString(L),children:P(`editedAt`,{when:te(Z.upstreamUpdatedAt)})})]}),D(`h2`,{className:`text-2xl leading-tight font-bold text-wx-fg`,children:Z.title}),Z.authors&&Z.authors.length>0&&O(`p`,{className:`flex items-center gap-2 text-xs text-wx-fg-muted`,children:[D(`span`,{className:`flex -space-x-1.5`,children:Z.authors.slice(0,3).map(e=>D(`span`,{className:`h-5 w-5 overflow-hidden rounded-full bg-wx-bg-elevated ring-1 ring-wx-bg`,"aria-hidden":`true`,children:D(`img`,{src:e.photo.url,alt:``,className:`h-full w-full object-cover`})},e._id))}),D(`span`,{children:P(`writtenBy`,{names:Z.authors.map(e=>e.name).join(`, `)})})]}),Z.tags&&Z.tags.length>0&&D(`div`,{className:`flex flex-wrap gap-1`,children:Z.tags.map(e=>D(`span`,{className:`rounded-full bg-wx-bg-elevated px-2 py-0.5 text-[11px] font-medium text-wx-fg-muted`,children:e.label},e.slug))}),$&&D(`p`,{className:`text-base leading-relaxed text-wx-fg-muted`,children:$}),Z.contentMarkdown&&D(x,{content:Z.contentMarkdown,isHtml:Z.bodyFormat===`html`||S(Z.contentMarkdown),markdownMarginClass:`mt-3`}),Z.sourceUrl&&O(`a`,{href:Z.sourceUrl,target:`_blank`,rel:`noopener noreferrer`,className:`mt-4 flex items-center justify-center gap-1.5 text-xs text-wx-primary underline underline-offset-2 transition-opacity hover:opacity-80`,children:[D(v,{size:12}),D(`span`,{children:P(`readOriginal`)})]}),B&&D(A,{currentId:Z.id,currentCategoryIds:Z.categoryIds??[],currentTagIds:Z.tagIds??[],previewPostsById:k?void 0:R.previewData?.newsPostsById,visitorRelatedRaw:fe?.visitorNewsRelated,isDummy:k,demoItems:pe,onOpen:W}),Z.id&&D(ae,{surface:b.NEWS,itemId:Z.id,reactionCounts:Z.reactionCounts??null,viewerReaction:Z.viewerReaction??null,groupItemIds:[Z.id,...(Z.translations??[]).map(e=>e.id)],isDummy:k,showCounts:V,className:`mt-6`}),D(ie,{currentLocale:k?G:Z.locale??L,locales:k?[...a]:(Z.translations??[]).map(e=>e.locale),allowedLocales:k?void 0:z.supportedLocales,onSelect:k?e=>ce(e):e=>{let t=(Z.translations??[]).find(t=>t.locale===e);t&&W(t.id)},className:`mt-6`})]})]})})}function M(){return D(p,{followDirection:!0,className:`flex-1`,viewportRef:h(),children:O(`div`,{className:`flex flex-col`,"aria-busy":`true`,"aria-live":`polite`,children:[D(`div`,{className:`w-full animate-pulse bg-wx-bg-elevated`,style:{aspectRatio:`16 / 9`}}),O(`div`,{className:`px-5 pt-5 pb-12`,children:[O(`div`,{className:`animate-pulse space-y-2.5`,children:[D(`div`,{className:`h-5 w-3/4 rounded-md bg-wx-bg-elevated`}),D(`div`,{className:`h-5 w-1/2 rounded-md bg-wx-bg-elevated`})]}),D(`div`,{className:`mt-4 flex items-center gap-2 animate-pulse`,children:D(`div`,{className:`h-3 w-24 rounded-md bg-wx-bg-elevated`})}),D(`div`,{className:`mt-6 space-y-2.5 animate-pulse`,children:[`w-full`,`w-11/12`,`w-10/12`,`w-full`,`w-9/12`,`w-7/12`].map((e,t)=>D(`div`,{className:n(`h-3 rounded-md bg-wx-bg-elevated`,e)},t))})]})]})})}export{j as NewsArticleView};
2
+ //# sourceMappingURL=widget-react-BI1zRae2.js.map