k2-im 0.1.0
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 +81 -0
- package/dist/browser-BKCNJDKR.js +2 -0
- package/dist/chat-kit-pinia.d.ts +7753 -0
- package/dist/chat-kit-pinia.js +1 -0
- package/dist/chat-kit-vue.d.ts +1557 -0
- package/dist/chat-kit-vue.js +1 -0
- package/dist/chat-kit.d.ts +7674 -0
- package/dist/chat-kit.js +1 -0
- package/dist/chunk-BRHUZPIB.js +1 -0
- package/dist/chunk-I6FUD7EW.js +1 -0
- package/dist/chunk-IDECJJXC.js +0 -0
- package/dist/chunk-RZFMPR6C.js +1 -0
- package/dist/chunk-SXY56EVC.js +0 -0
- package/dist/chunk-UWQHGBMV.js +1 -0
- package/dist/chunk-VKSMKG6Q.js +7 -0
- package/dist/chunk-WOT6VMZA.js +1 -0
- package/dist/chunk-YMH6LM5Q.js +2 -0
- package/dist/i18n.d.ts +1095 -0
- package/dist/i18n.js +1 -0
- package/dist/index.d.ts +8577 -0
- package/dist/index.js +1 -0
- package/dist/sdk.d.ts +4943 -0
- package/dist/sdk.js +1 -0
- package/dist/speex-runtime.txt +1 -0
- package/dist/vendor/crypto/index_bg.wasm +0 -0
- package/package.json +69 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var d=Object.defineProperty;var e=(c,a)=>{for(var b in a)d(c,b,{get:a[b],enumerable:true});};export{e as a};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {p as p$1}from'./chunk-UWQHGBMV.js';import {e,a as a$1}from'./chunk-I6FUD7EW.js';import {j,h}from'./chunk-RZFMPR6C.js';import {T as T$1}from'./chunk-BRHUZPIB.js';import {a}from'./chunk-WOT6VMZA.js';var N=p$1();function H(e$1,n){let t=n.suppressDraft===true?null:e$1.draft,i=t?.text.trim()??"",r,a="",s="";return t!==null?r=i===""?[]:G(e$1,i,n.locale):$(e$1)?r=y(K(e$1,n)):e$1.lastMessageSummary?.kind==="channel-moderation-deleted"||e$1.lastMessageDeletedForEveryone!==void 0?r=y(x(e$1,e$1.lastMessageSummary?.kind==="channel-moderation-deleted"?e$1.lastMessageSummary:{kind:"channel-moderation-deleted",by:e$1.lastMessageDeletedForEveryone?.by??""},n)):e$1.lastMessageSummary?.kind==="recalled"||e$1.lastMessageRecalled!==void 0?r=y(x(e$1,e$1.lastMessageSummary?.kind==="recalled"?e$1.lastMessageSummary:{kind:"recalled",by:e$1.lastMessageRecalled?.by??""},n)):(a=z(e$1,n),s=e$1.mentionUnreadCount>0?n.labels.mentionBadge:"",r=W(e$1,n)),{preview:`${s}${a}${r.map(l=>l.text).join("")}`||(t===null?n.labels.emptyPreview:""),previewSegments:r,senderPrefix:a,mentionBadge:s,time:e(a$1(t?.updatedAt,e$1.timestamp),{locale:n.locale,...n.now===void 0?{}:{now:n.now}}),hasDraft:t!==null}}function y(e){return [{kind:"text",text:e}]}function O(e){return e.map(n=>n.kind==="emoji"?{kind:"emoji",text:n.text,code:n.code}:{kind:n.kind,text:n.text})}function G(e,n,t){let i=e.draft?.mentions??[],r=[],a={},s=false;for(let l of i){if(l.userId==="0"){s=true;continue}r.includes(l.userId)||r.push(l.userId),l.displayName.trim()!==""&&(a[l.userId]=l.displayName);}let o=s||r.length>0?{atAll:s,atUserIds:r,...Object.keys(a).length===0?{}:{atUsersName:a}}:void 0;return O(T$1(n,{mention:o,resolveName:l=>a[l]??l,atAllDisplay:j(t),matchers:[N]}))}function W(e,n){let t=e.lastMessageSummary;if(t!==void 0&&t.kind!=="text")return y(x(e,t,n));let i=(t?.kind==="text"?t.text:e.lastMessagePreview).trim();if(i==="")return y(n.labels.emptyPreview);let r=e.lastMessageMention?.atUsersName;return O(T$1(i,{mention:e.lastMessageMention===void 0?void 0:{...e.lastMessageMention,atUserIds:[...e.lastMessageMention.atUserIds]},resolveName:a=>n.resolveName(e.ref,a,r?.[a]),selfId:n.accountId,atAllDisplay:j(n.locale),matchers:[N]}))}function x(e,n,t){return h(q(n),{locale:t.locale,selfId:t.accountId,resolveName:i=>t.resolveName(e.ref,i)})}function $(e){return e.lastMessageSummary?.kind==="system"||e.lastMessageSenderId==="system"||e.lastMessageSystemEvent!==void 0}function K(e,n){return e.lastMessageSummary?.kind==="system"?x(e,e.lastMessageSummary,n):e.lastMessageSystemEvent===void 0?e.lastMessagePreview.trim()||n.labels.emptyPreview:x(e,{kind:"system",system:{eventType:e.lastMessageSystemEvent,...e.lastMessageSystemTargetsSelf===true?{targetUserIds:[n.accountId]}:{},...e.lastMessagePreview.trim()===""?{}:{fallbackText:e.lastMessagePreview.trim()}}},n)}function z(e,n){let t=e.lastMessageSenderId;return e.ref.conversationType!=="group"&&e.ref.conversationType!=="channel"||t===void 0||t===""||t==="system"?"":`${t===n.accountId?n.labels.selfSender:n.resolveName(e.ref,t)}: `}function q(e){return e.kind!=="system"?e:{kind:"system",system:{eventType:e.system.eventType,...e.system.operatorId===void 0?{}:{operatorId:e.system.operatorId},...e.system.targetUserIds===void 0?{}:{targetUserIds:[...e.system.targetUserIds]},...e.system.fallbackText===void 0?{}:{fallbackText:e.system.fallbackText}}}}var J=160,Q=220;function Y(e){let n=Math.max(0,e.showDelayMs??160),t=Math.max(0,e.minimumVisibleMs??220),i=e.now??Date.now,r=e.setTimer??((d,M)=>setTimeout(d,M)),a=e.clearTimer??(d=>clearTimeout(d)),s="",o=false,l=false,v=0,c,u,f=false;function g(){c!==void 0&&a(c),c=void 0;}function m(){u!==void 0&&a(u),u=void 0;}function h(d){l!==d&&(l=d,v=d?i():0,e.onVisibleChange(d));}function I(d){g(),c=r(()=>{c=void 0,!(f||!o||s!==d)&&h(true);},n);}function j(){if(g(),!l)return;let d=t-Math.max(0,i()-v);if(d<=0){h(false);return}m(),u=r(()=>{u=void 0,!(f||o)&&h(false);},d);}return {update(d,M){if(f)return;if(s!==M){s=M,o=d,g(),m(),h(false),d&&I(M);return}if(o=d,d){m(),!l&&c===void 0&&I(M);return}j();},dispose(){f||(f=true,o=false,g(),m(),h(false));}}}var S={placeholder:0,thumbnail:1,local:2,original:3};function X(e){let n;for(let t of e)t.value!==void 0&&(n===void 0||S[t.quality]>S[n.quality])&&(n=t);return n}function Z(e,n){return S[n]>=S[e]}function ee(e){let n=e.getGeneration();return Object.freeze({isCurrent:()=>e.getGeneration()===n})}function T(e){let n=e.getClient();if(n===null)return null;let t=e.getGeneration();return Object.freeze({client:n,isCurrent:()=>e.getGeneration()===t&&e.getClient()===n})}var _={};a(_,{acquireMediaBlob:()=>te,detectImageMime:()=>D,detectVideoMime:()=>F,loadCachedImageObjectUrl:()=>ae,loadCachedVideoObjectUrl:()=>ie,loadFileObjectUrl:()=>se,loadImageObjectUrl:()=>oe,loadVideoObjectUrl:()=>re,loadVoiceBytes:()=>ne});function A(e){if(e.conversationType!=="supergroup")return {conversation:{conversationType:e.conversationType,conversationId:e.conversationId},messageId:e.id}}async function C(e,n,t){let i=e.getClient(),r=A(n);if(i===null||r===void 0)throw new Error("media download unavailable");let a=t===void 0?void 0:i.media.subscribe(s=>{let o=s.find(l=>l.direction==="download"&&l.messageId===r.messageId&&l.ref.conversationType===r.conversation.conversationType&&l.ref.conversationId===r.conversation.conversationId);o!==void 0&&t(o.percent);});try{return await i.media.download(r)}finally{a?.();}}function D(e){return e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255?"image/jpeg":e.length>=8&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71?"image/png":e.length>=6&&e[0]===71&&e[1]===73&&e[2]===70?"image/gif":e.length>=12&&e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80?"image/webp":null}async function U(e){let n=new Uint8Array(await e.slice(0,12).arrayBuffer()),t=D(n);return t===null?null:URL.createObjectURL(e.type===t?e:e.slice(0,e.size,t))}function F(e){return e.length>=4&&e[0]===26&&e[1]===69&&e[2]===223&&e[3]===163?"video/webm":(e.length>=8&&e[4]===102&&e[5]===116&&e[6]===121&&e[7]===112,"video/mp4")}function te(e,n){return e.acquireMediaBlob({conversationType:n.conversationType,conversationId:n.conversationId,messageId:n.id})}async function ne(e,n,t){let i=e.getClient(),r=n.body.voice;if(i===null||r===void 0)return null;let a=e.getSelfVoiceBytes(n.id);if(a!==void 0)return a;let s=e.getGeneration();try{let o=new Uint8Array(await(await C(e,n)).arrayBuffer());return o.length===0?(e.getGeneration()===s&&t.setNote(t.t("media.voiceLoadEmpty")),null):o}catch(o){return e.getGeneration()===s&&t.setNote(t.t("media.voiceLoadFailed",{reason:o instanceof Error?o.message:String(o)})),null}}async function re(e,n,t,i){let r=e.getClient(),a=n.body.video;if(r===null||a===void 0)return null;let s=e.getGeneration();try{let o=await C(e,n,i);if(o.size===0)return e.getGeneration()===s&&t.setNote(t.t("media.videoOpenEmpty")),null;let l=URL.createObjectURL(o);return e.getGeneration()!==s?(URL.revokeObjectURL(l),null):l}catch(o){return e.getGeneration()===s&&t.setNote(t.t("media.videoLoadFailed",{reason:o instanceof Error?o.message:String(o)})),null}}async function ie(e,n){let t=e.getClient(),i=A(n);if(t===null||i===void 0||n.body.video===void 0)return null;let r=e.getGeneration();try{let a=await t.media.getCached(i);if(a===null||a.size===0||e.getGeneration()!==r)return null;let s=new Uint8Array(await a.slice(0,12).arrayBuffer()),o=a.type||F(s);return e.getGeneration()!==r?null:URL.createObjectURL(a.type===o?a:a.slice(0,a.size,o))}catch{return null}}async function oe(e,n,t){let i=e.getClient(),r=n.body.image;if(i===null||r===void 0)return null;let a=e.getGeneration();try{let s=await C(e,n),o=await U(s);return o===null?(e.getGeneration()===a&&t.setNote(t.t("media.imageInvalid",{size:s.size})),null):e.getGeneration()!==a?(URL.revokeObjectURL(o),null):o}catch(s){return e.getGeneration()===a&&t.setNote(t.t("media.imageLoadFailed",{reason:s instanceof Error?s.message:String(s)})),null}}async function ae(e,n){let t=e.getClient(),i=A(n);if(t===null||i===void 0||n.body.image===void 0)return null;let r=e.getGeneration();try{let a=await t.media.getCached(i);if(a===null||a.size===0||e.getGeneration()!==r)return null;let s=await U(a);return s===null?null:e.getGeneration()!==r?(URL.revokeObjectURL(s),null):s}catch{return null}}async function se(e,n,t,i){let r=e.getClient(),a=n.body.file;if(r===null||a===void 0)return null;let s=e.getGeneration();try{let o=await C(e,n,i);if(o.size===0)return e.getGeneration()===s&&t.setNote(t.t("media.fileDownloadEmpty")),null;let l=URL.createObjectURL(o);return e.getGeneration()!==s?(URL.revokeObjectURL(l),null):l}catch(o){return e.getGeneration()===s&&t.setNote(t.t("media.fileDownloadFailed",{reason:o instanceof Error?o.message:String(o)})),null}}var B={};a(B,{markReadUpTo:()=>le});function le(e,n,t,i){let r=T(e);if(r===null||n.conversationId===""||t==="")return;let a=r.client.conversations.list().find(o=>o.id===n.conversationId&&o.type===n.conversationType);if(a?.manuallyUnread===true&&a.unreadCount<=0){r.client.conversations.markConversationRead(n).catch(o=>{r.isCurrent()&&e.getDiagnostics().record("warn","chat-kit","conversation","clear-manual-unread-skipped",()=>({conversation:n,error:{message:"\u6E05\u9664\u624B\u5DE5\u672A\u8BFB\u63D0\u9192\u5931\u8D25",data:o}}));});return}if(a?.type==="group"&&a.unreadCount<=0)return;let s=i.getConversationHandle();s===void 0||s.ref.conversationId!==n.conversationId||s.ref.conversationType!==n.conversationType||s.markRead(t).catch(o=>{r.isCurrent()&&i.getConversationHandle()===s&&e.getDiagnostics().record("warn","chat-kit","message","mark-read-skipped",()=>({conversation:n,data:{messageId:t},error:{message:"markRead \u8DF3\u8FC7",data:o}}));});}function de(e,n){if(n.length===0)return [{text:e,hit:false}];let t=[],i=0;for(let[r,a]of n)r>i&&t.push({text:e.slice(i,r),hit:false}),t.push({text:e.slice(r,a),hit:true}),i=a;return i<e.length&&t.push({text:e.slice(i),hit:false}),t}var ce=/\b(?:https?:\/\/|www\.)[^\s<>"')】]+/gi,me=/\b(?:https?:\/\/|www\.)/i,ue=/[),.!?;:,。!?;:、)】]+$/u;function V(e){let n=/^www\./i.test(e)?`https://${e}`:e;try{let t=new URL(n);return t.protocol==="http:"||t.protocol==="https:"?t.href:void 0}catch{return}}function fe(e){return me.test(e)}function pe(){return e=>{let n=[];for(let t of e.matchAll(ce)){if(t.index===void 0)continue;let i=t[0].replace(ue,"");if(i==="")continue;let r=V(i);r!==void 0&&n.push({start:t.index,end:t.index+i.length-1,segment:{kind:"link",text:i,href:r}});}return n}}function p(e,n){if(!Number.isFinite(e)||e<=0)throw new Error(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565 ${n} \u5FC5\u987B\u662F\u5927\u4E8E 0 \u7684\u6709\u9650\u6570`)}function ge(e){if(p(e.fallbackAspectRatio,"fallbackAspectRatio"),!Array.isArray(e.rules)||e.rules.length===0)throw new Error("\u5A92\u4F53\u5C55\u793A\u7B56\u7565 rules \u4E0D\u80FD\u4E3A\u7A7A");let n=new Set;e.rules.forEach((t,i)=>{let r=`rules[${i}]`;if(t.id.trim()==="")throw new Error(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565 ${r}.id \u4E0D\u80FD\u4E3A\u7A7A`);if(n.has(t.id))throw new Error(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565\u89C4\u5219 id \u91CD\u590D\uFF1A${t.id}`);if(n.add(t.id),t.minAspectRatio!==void 0&&(!Number.isFinite(t.minAspectRatio)||t.minAspectRatio<0))throw new Error(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565 ${r}.minAspectRatio \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 0 \u7684\u6709\u9650\u6570`);if(t.maxAspectRatio!==void 0&&p(t.maxAspectRatio,`${r}.maxAspectRatio`),t.minAspectRatio!==void 0&&t.maxAspectRatio!==void 0&&t.minAspectRatio>=t.maxAspectRatio)throw new Error(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565 ${r} \u7684\u5BBD\u9AD8\u6BD4\u4E0B\u754C\u5FC5\u987B\u5C0F\u4E8E\u4E0A\u754C`);if(p(t.preferredWidth,`${r}.preferredWidth`),p(t.minWidth,`${r}.minWidth`),p(t.maxWidth,`${r}.maxWidth`),p(t.minHeight,`${r}.minHeight`),p(t.maxHeight,`${r}.maxHeight`),t.minWidth>t.preferredWidth||t.preferredWidth>t.maxWidth)throw new Error(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565 ${r}.preferredWidth \u5FC5\u987B\u4F4D\u4E8E minWidth \u548C maxWidth \u4E4B\u95F4`);if(t.minHeight>t.maxHeight)throw new Error(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565 ${r}.minHeight \u4E0D\u80FD\u5927\u4E8E maxHeight`);if(typeof t.allowUpscale!="boolean")throw new TypeError(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565 ${r}.allowUpscale \u5FC5\u987B\u662F boolean`);if(t.fit!=="cover"&&t.fit!=="contain")throw new Error(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565 ${r}.fit \u53EA\u652F\u6301 cover \u6216 contain`)});}function he(e){let{intrinsicWidth:n,intrinsicHeight:t,availableWidth:i,policy:r}=e;p(i,"availableWidth"),ge(r);let a=Number.isFinite(n)&&Number.isFinite(t)&&n>0&&t>0,s=a?n/t:r.fallbackAspectRatio,o=r.rules.find(m=>{let h=m.minAspectRatio===void 0||s>=m.minAspectRatio,I=m.maxAspectRatio===void 0||s<m.maxAspectRatio;return h&&I});if(o===void 0)throw new Error(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565\u6CA1\u6709\u5339\u914D\u5BBD\u9AD8\u6BD4 ${s}`);let l=!o.allowUpscale&&a?Math.min(o.preferredWidth,n):o.preferredWidth,v=Math.min(i,o.maxWidth,Math.max(o.minWidth,l)),c=Math.max(1,Math.round(v)),u=c/s,f=Math.min(o.maxHeight,Math.max(o.minHeight,u)),g=Math.max(1,Math.round(f));return {width:c,height:g,aspectRatio:c/g,sourceAspectRatio:s,ruleId:o.id,fit:o.fit,aspectClamped:f!==u}}function ve(e,n,t,i){if(!Number.isFinite(e)||!Number.isFinite(n)||e<=0||n<=0)return null;let r=Math.min(t/e,i/n,1);return {width:`${Math.max(1,Math.round(e*r))}px`,aspectRatio:`${e} / ${n}`}}function Me(e){if(!Number.isFinite(e)||e<=0)return "0:00";let n=Math.floor(e),t=Math.floor(n/3600),i=Math.floor(n%3600/60),r=n%60,a=s=>s.toString().padStart(2,"0");return t>0?`${t}:${a(i)}:${a(r)}`:`${i}:${a(r)}`}function ye(e){if(!Number.isFinite(e)||e<=0)return "0 B";let n=["B","KB","MB","GB","TB"],t=Math.min(n.length-1,Math.floor(Math.log(e)/Math.log(1024))),i=e/1024**t;return `${t===0?i:Math.round(i*10)/10} ${n[t]}`}function xe(e){let n=e.lastIndexOf(".");return n>-1&&n<e.length-1?e.slice(n+1).toLowerCase():""}var Ie=4;function Se(e){let n=Math.min(Math.max(e/1e3,0)/10,1);return Math.round(22+24*n)}function Ce(e,n){if(e.length===0)return Array.from({length:n},()=>0);let t=[],i=(e.length-1)/Math.max(1,n-1);for(let r=0;r<n;r+=1){let a=r*i,s=Math.round(a),o=e[Math.max(0,s-1)]??0,l=e[Math.min(e.length-1,s)]??0,v=e[Math.min(e.length-1,s+1)]??0;t.push((o+l+v)/3);}return t}function be(e,n){let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);let i=[];for(let r=0;r<n;r+=1)t=Math.imul(t^t>>>15,2246822519)>>>0,i.push(90+t%111);return i}
|
|
2
|
+
export{H as a,J as b,Q as c,Y as d,X as e,Z as f,ee as g,T as h,_ as i,B as j,de as k,V as l,fe as m,pe as n,he as o,ve as p,Me as q,ye as r,xe as s,Ie as t,Se as u,Ce as v,be as w};
|