@funhub/platform 0.1.85 → 0.1.87
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/components/biz/business/marquee/client.mjs +1 -1
- package/dist/components/biz/business/tab-bar/client.mjs +1 -1
- package/dist/components/biz/business/text-recommend/client.mjs +1 -1
- package/dist/components/pages/search-result/page-client.mjs +1 -1
- package/dist/components/ui/avatar.mjs +1 -1
- package/dist/components/ui/badge.d.mts +1 -1
- package/dist/components/ui/button.d.mts +1 -1
- package/dist/components/ui/image.d.mts +4 -4
- package/dist/utils/decrypt-image-client.mjs +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
"use client";import{Image as e}from"../../../ui/image.mjs";import{Box as t}from"../../../ui/box.mjs";import{Text as n}from"../../../ui/text.mjs";import r from"../../../../assets/icons/right_arrow.mjs";import i from"../../../../assets/images/marquee.mjs";import a from"./marquee.module.mjs";import{defaultMarqueePeriod as o}from"./schema.mjs";import{useEffect as s,useMemo as c,useRef as l,useState as u}from"react";import{X as d}from"lucide-react";import{jsx as f,jsxs as p}from"react/jsx-runtime";import{useTranslations as m}from"next-intl";import{useRouter as h}from"next/navigation";const g=[];function _(e
|
|
2
|
+
"use client";import{Image as e}from"../../../ui/image.mjs";import{Box as t}from"../../../ui/box.mjs";import{Text as n}from"../../../ui/text.mjs";import r from"../../../../assets/icons/right_arrow.mjs";import i from"../../../../assets/images/marquee.mjs";import a from"./marquee.module.mjs";import{defaultMarqueePeriod as o}from"./schema.mjs";import{useEffect as s,useMemo as c,useRef as l,useState as u}from"react";import{X as d}from"lucide-react";import{jsx as f,jsxs as p}from"react/jsx-runtime";import{useTranslations as m}from"next-intl";import{useRouter as h}from"next/navigation";const g=[];function _(e,t=20){let n=Array.from(e);return n.length<=t?e:`${n.slice(0,t).join(``)}...`}function v(e){let t=5381;for(let n=0;n<e.length;n+=1)t=(t<<5)+t^(e.codePointAt(n)??0);return(t>>>0).toString(36)}function y(e,t){return e?t===`once`?!0:new Date(e).toLocaleDateString()===new Date().toLocaleDateString():!1}function b(e){let t=localStorage.getItem(e);if(!t)return{};try{return JSON.parse(t)}catch{let e=Number(t);return Number.isNaN(e)?{}:{closedAt:e}}}function x(e,t){localStorage.setItem(e,JSON.stringify(t))}function S(e,t){return t===`once`?y(e.closedAt,t)||y(e.displayedAt,t):!!e.closedAt}function C(C){let w=m(`components.biz.business.marquee`),{contents:T=g,click:E,close:D,displayStrategy:O,mode:k=`renderer`}=C,A=k===`editor`,j=h(),[M,N]=u(!0),[P,F]=u(!1),[I,L]=u(0),R=l(null);s(()=>{F(!0)},[]);let z=c(()=>{let e=O?.period??o,t=e.start,n=e.end;if(!t&&!n)return!0;let r=Date.now(),i=t?new Date(t).getTime():0,a=n?new Date(n).getTime():2**53-1;return r>=i&&r<=a},[O?.period]),B=c(()=>(T??[]).map(e=>({...e,text:_(String(e?.text??``))})).filter(e=>!!e.text),[T]),V=c(()=>{let e=O?.period??o;return`marquee_state_${v(JSON.stringify({rule:O?.rule??``,start:e.start??``,end:e.end??``,clickEnabled:E?.enabled??!1,clickLink:E?.link??``,items:B.map(e=>({text:e.text??``,link:e.link??``}))}))}`},[E?.enabled,E?.link,O?.period,O?.rule,B]);if(s(()=>{N(!0)},[V]),s(()=>()=>{R.current!=null&&(window.clearTimeout(R.current),R.current=null)},[]),s(()=>{L(0)},[B.length]),s(()=>{if(!(!P||A||!O?.rule||B.length===0)){if(S(b(V),O.rule)){N(!1);return}N(!0)}},[O?.rule,A,P,B.length,V]),s(()=>{if(R.current!=null&&(window.clearTimeout(R.current),R.current=null),!(!P||A||!O?.rule||!M||!z||B.length===0))return()=>{R.current!=null&&(window.clearTimeout(R.current),R.current=null)}},[O?.rule,A,P,z,M,B.length,V]),!A&&(!P||!M||!z)||B.length===0)return null;let H=B[I%B.length],U=E?.enabled===!0,W=E?.link||H.link,G=U&&!!W,K=D?.enabled===!0;function q(){!O?.rule||B.length===0||x(V,{...b(V),closedAt:Date.now()})}let J=e=>{e.stopPropagation(),N(!1),q()},Y=()=>{A||G&&W&&(N(!1),q(),j.push(W))},X=()=>{if(!(A||!M)){if(O?.rule===`once`){let e=b(V);if(y(e.displayedAt,`once`)||e.closedAt)return;x(V,{...e,displayedAt:Date.now()}),N(!1);return}B.length<=1||L(e=>(e+1)%B.length)}},Z=A?a[`marquee-item-paused`]:O?.rule===`once`||B.length>1?a[`marquee-item-once`]:a[`marquee-item-loop`];return f(t,{className:A?`px-3 py-2 w-full bg-bg1 pointer-events-none`:`px-3 py-2 w-full bg-bg1`,children:p(t,{className:`pl-[2px] pr-[12px] py-[2px] flex items-center w-full cursor-pointer relative rounded-[8px] overflow-hidden ${a[`marquee-shell`]}`,onClick:Y,children:[f(t,{className:`relative shrink-0 w-[36px] h-[36px] mr-[4px]`,children:f(e,{src:typeof i==`string`?i:i.src,alt:w(`noticeAlt`),fill:!0,className:`object-cover`,unoptimized:!0})}),f(t,{className:`flex-1 overflow-hidden relative h-[22px] ml-1`,children:f(t,{className:`absolute inset-y-0 left-0 flex items-center whitespace-nowrap ${Z}`,onAnimationEnd:X,children:f(n,{className:`inline-block text-[14px] text-[#f59e0b] leading-[22px] font-medium`,children:H.text})},`marquee-item-${I}`)}),p(t,{className:`flex items-center gap-[12px] shrink-0 ml-[4px]`,children:[G&&f(r,{className:`w-[16px] h-[16px] text-[#f59e0b]`}),K&&f(t,{className:`opacity-30 hover:opacity-100 transition-opacity`,onClick:J,children:f(d,{className:`w-[12px] h-[12px] text-[#F59E0B]`})})]})]})})}export{C as MarqueeClient};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
"use client";import{Image as e}from"../../../ui/image.mjs";import{Box as t}from"../../../ui/box.mjs";import{Text as n}from"../../../ui/text.mjs";import{useMemo as r}from"react";import{jsx as i,jsxs as a}from"react/jsx-runtime";import{usePathname as
|
|
2
|
+
"use client";import{Image as e}from"../../../ui/image.mjs";import{Box as t}from"../../../ui/box.mjs";import{Text as n}from"../../../ui/text.mjs";import{useMemo as r}from"react";import{jsx as i,jsxs as a}from"react/jsx-runtime";import o from"next/link";import{usePathname as s}from"next/navigation";const c=[];function l(e){return e.split(`?`)[0].replace(/\/+$/,``)||`/`}function u(e){let t=typeof e.path==`string`?e.path.trim():``;if(t)return t;if(e.configType===1)switch(e.functionPageType){case`搜索`:return`/search`;case`个人中心`:return`/user/mine`;case`内容列表`:return`/video-list?tags=${e.tags}&title=${e.title}`;default:return`/`}let n=(e.domainId??``).toString().trim();return n?`/domain/${n}`:`/`}function d(e,t){let n=l(t),r=l(u(e).split(`?`)[0]);return r===`/`?n===`/`:n===r||n.startsWith(`${r}/`)}function f(e,t){return e.findIndex(e=>d(e,t))}function p(l){let{items:d=c,mode:p=`renderer`}=l,m=s(),h=r(()=>p===`editor`?0:f(d??[],m),[d,m,p]),g=r(()=>(d??[]).some(e=>e.label!=null&&String(e.label).trim()!==``),[d]);if(!d?.length)return null;function _(e){p===`editor`&&e.preventDefault()}let v=`flex min-w-0 flex-1 cursor-pointer flex-col items-center justify-center ${g?`gap-1`:``}`;return i(t,{className:`fixed bottom-0 left-0 right-0 z-50 safe-area-bottom bg-bg1 border-t border-line1 backdrop-blur-[2px] py-3 shadow-[0px_-4px_10px_0px_rgba(0,0,0,0.02)]`,children:i(t,{className:`flex w-full items-center`,children:d.map((r,s)=>{let c=h===s,l=c&&r.activeIcon?r.activeIcon:r.icon,d=typeof r.label==`string`?r.label:String(r.label??``);return a(o,{href:u(r),className:v,onClick:_,children:[i(t,{className:`relative size-[22px] shrink-0`,children:l?i(e,{src:l,alt:d,fill:!0,className:`object-contain`}):i(t,{"data-active":c,className:`size-full rounded-sm bg-text3 data-[active=true]:bg-theme5`})}),g&&i(n,{"data-active":c,className:`truncate text-center text-[10px] leading-[10px] font-medium min-w-0 max-w-full px-0.5 text-text2 data-[active=true]:text-theme5`,children:d})]},s)})})})}export{p as TabBarClient};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
"use client";import{Box as e}from"../../../ui/box.mjs";import{Text as t}from"../../../ui/text.mjs";import n from"../../../../assets/icons/refresh.mjs";import{useMemo as r,useState as i}from"react";import{jsx as a,jsxs as o}from"react/jsx-runtime";import{usePathname as s,useRouter as c,useSearchParams as l}from"next/navigation";const u=[];function d(
|
|
2
|
+
"use client";import{Box as e}from"../../../ui/box.mjs";import{Text as t}from"../../../ui/text.mjs";import n from"../../../../assets/icons/refresh.mjs";import{useMemo as r,useState as i}from"react";import{jsx as a,jsxs as o}from"react/jsx-runtime";import{usePathname as s,useRouter as c,useSearchParams as l}from"next/navigation";const u=[];function d(e,t){if(e.length<=t)return[...e];let n=[...e];for(let e=0;e<t;e++){let t=e+Math.floor(Math.random()*(n.length-e));[n[e],n[t]]=[n[t],n[e]]}return n.slice(0,t)}function f(f){let{title:p,items:m=u,onItemClick:h,mode:g=`renderer`}=f,_=g===`editor`,v=c(),y=s(),b=l(),[x,S]=i(0),C=r(()=>d(m,6),[m,x]);if(m.length===0)return null;let w=e=>{e.stopPropagation(),S(e=>e+1)},T=e=>{if(h){h(e);return}let t=new URLSearchParams(b.toString());t.set(`q`,e);let n=y.includes(`/search-result`)?y:`/search-result`;v.push(`${n}?${t.toString()}`)};return o(e,{className:`bg-bg1 p-3 flex flex-col gap-3 w-full${_?` pointer-events-none`:``}`,children:[o(e,{className:`flex items-center justify-between w-full`,children:[a(t,{className:`text-[18px] font-bold text-text1 leading-[26px]`,children:p}),o(e,{className:`flex items-center gap-1 cursor-pointer active:opacity-70 transition-opacity`,onClick:w,children:[a(t,{className:`text-[14px] text-text3 leading-[22px]`,children:`换一批`}),a(n,{className:`w-3 h-3 text-text3`})]})]}),a(e,{className:`grid grid-cols-2 gap-x-1 gap-y-1 w-full`,children:C.map((n,r)=>a(e,{className:`flex items-center h-[32px] cursor-pointer active:opacity-70 transition-opacity overflow-hidden`,onClick:()=>T(n.label),children:a(t,{className:`text-[14px] text-text1 leading-[22px] truncate w-full`,children:n.label})},`${x}-${r}`))})]})}export{f as TextRecommendClient};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
"use client";import{updateUrlParams as e}from"../../../utils/common.mjs";import t from"../../../utils/event-bus.mjs";import{useUserStore as n}from"../../../store/modules/user-store.mjs";import{Box as r}from"../../ui/box.mjs";import{eventKey as i}from"../../../constants/event-key.mjs";import{useSearchHistory as a}from"../../../hooks/use-search-history.mjs";import o from"../search/top-header.mjs";import s from"./search-user.mjs";import c from"./search-video.mjs";import l from"./search-all.mjs";import{SORT_OPTIONS as u,SearchTab as d}from"./search-tab.mjs";import{useEffect as f,useMemo as p,useState as m}from"react";import{Fragment as h,jsx as g,jsxs as _}from"react/jsx-runtime";import{useRouter as v,useSearchParams as y}from"next/navigation";const b=[{label:`综合`,value:`all`},{label:`视频`,value:`video`},{label:`用户`,value:`user`}];function x(){let x=v(),{userInfo:S}=n(),C=S?.user_id||`guest`,w=y().get(`q`)?.toString()||``,T=w?decodeURIComponent(w):``,[E,D]=m(T),[O]=m(T),
|
|
2
|
+
"use client";import{updateUrlParams as e}from"../../../utils/common.mjs";import t from"../../../utils/event-bus.mjs";import{useUserStore as n}from"../../../store/modules/user-store.mjs";import{Box as r}from"../../ui/box.mjs";import{eventKey as i}from"../../../constants/event-key.mjs";import{useSearchHistory as a}from"../../../hooks/use-search-history.mjs";import o from"../search/top-header.mjs";import s from"./search-user.mjs";import c from"./search-video.mjs";import l from"./search-all.mjs";import{SORT_OPTIONS as u,SearchTab as d}from"./search-tab.mjs";import{useEffect as f,useMemo as p,useState as m}from"react";import{Fragment as h,jsx as g,jsxs as _}from"react/jsx-runtime";import{useRouter as v,useSearchParams as y}from"next/navigation";const b=[{label:`综合`,value:`all`},{label:`视频`,value:`video`},{label:`用户`,value:`user`}];function x(){let x=v(),{userInfo:S}=n(),C=S?.user_id||`guest`,w=y().get(`q`)?.toString()||``,T=w?decodeURIComponent(w):``,[E,D]=m(T),[O,k]=m(0);f(()=>{D(T),k(e=>e+1)},[T]);let[A,j]=m(b[0].value),[M,N]=m(u[0].value),[P,F]=m(0),[,I]=m([]),{addHistory:L}=a({storageKey:C}),R=p(()=>E.trim()!==``,[E]);f(()=>(t.on(i.EXCHANGE_SEARCH_TYPE,j),()=>{t.off(i.EXCHANGE_SEARCH_TYPE,j)}),[j]);function z(){x.push(`/search`)}return _(r,{className:`w-full min-h-screen bg-bg1 pb-[12px] overscroll-y-none`,children:[g(o,{setSearchInputVal:t=>{t!==E&&(I([]),D(t),e({q:t}))},initInputVal:T,initInputVersion:O,addSearchHistory:L,clearCallback:z}),g(d,{searchType:A,tabList:b,onChange:e=>{j(e),I([])},sort:M,onSortChange:e=>{N(e),F(e=>e+1)}}),R&&_(h,{children:[A===`user`&&g(s,{mode:`user`,inputVal:E,sort:M,refreshVersion:P}),A===`all`&&g(l,{searchInputVal:E,sort:M,refreshVersion:P}),A===`video`&&g(c,{mode:`video`,inputVal:E,sort:M,refreshVersion:P})]}),!R&&g(r,{className:`w-full pt-[12px]`})]})}export{x as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
"use client";import{cn as e}from"../../utils/cn.mjs";import t from"../../assets/images/default_avatar.mjs";import{Image as n}from"./image.mjs";import*as r from"react";import{jsx as i}from"react/jsx-runtime";import{Avatar as a}from"@base-ui/react/avatar";function o(e){if(!e)return;let t=e.trim();if(t)return/^(?:https?:|data:|blob:)/i.test(t)||t.startsWith(`/`)||t.startsWith(`assets/`)||t.startsWith(`./`)||t.startsWith(`../`)?t:`/${t.replace(/^\/+/,``)}`}const s=typeof t==`string`?t:t.src||String(t),c=o(s)||s;function l({className:t,size:n=`default`,...r}){return i(a.Root,{"data-slot":`avatar`,"data-size":n,className:e(`w-8 h-8 rounded-full after:rounded-full data-[size=lg]:w-10 data-[size=lg]:h-10 data-[size=sm]:w-6 data-[size=sm]:h-6 after:border-border group/avatar relative flex shrink-0 select-none after:absolute after:inset-0 after:border after:mix-blend-darken dark:after:mix-blend-lighten`,t),...r})}function
|
|
2
|
+
"use client";import{cn as e}from"../../utils/cn.mjs";import t from"../../assets/images/default_avatar.mjs";import{Image as n}from"./image.mjs";import*as r from"react";import{jsx as i}from"react/jsx-runtime";import{Avatar as a}from"@base-ui/react/avatar";function o(e){if(!e)return;let t=e.trim();if(t)return/^(?:https?:|data:|blob:)/i.test(t)||t.startsWith(`/`)||t.startsWith(`assets/`)||t.startsWith(`./`)||t.startsWith(`../`)?t:`/${t.replace(/^\/+/,``)}`}const s=typeof t==`string`?t:t.src||String(t),c=o(s)||s;function l({className:t,size:n=`default`,...r}){return i(a.Root,{"data-slot":`avatar`,"data-size":n,className:e(`w-8 h-8 rounded-full after:rounded-full data-[size=lg]:w-10 data-[size=lg]:h-10 data-[size=sm]:w-6 data-[size=sm]:h-6 after:border-border group/avatar relative flex shrink-0 select-none after:absolute after:inset-0 after:border after:mix-blend-darken dark:after:mix-blend-lighten`,t),...r})}const u=new Set;function d({className:t,src:a,thumbnailSrc:s,onError:c,onLoad:l,...d}){let f=r.useMemo(()=>o(a),[a]),p=r.useMemo(()=>o(s),[s])||f,[m,h]=r.useState(!p),[g,_]=r.useState(()=>p?u.has(p):!1);if(r.useEffect(()=>{h(!p),_(p?u.has(p):!1)},[p]),!p||m)return null;let v=e=>{h(!0),c?.(e)},y=e=>{u.add(p),h(!1),_(!0),l?.(e)};return i(n,{"data-slot":`avatar-image`,className:e(`rounded-full aspect-square w-full h-full object-cover transition-opacity duration-200`,g?`opacity-100`:`opacity-0`,t),fill:!0,src:p,priority:!0,onError:v,onLoad:y,...d})}function f({className:t,children:n,...r}){return i(a.Fallback,{"data-slot":`avatar-fallback`,className:e(`bg-muted text-muted-foreground rounded-full flex w-full h-full items-center justify-center text-sm group-data-[size=sm]/avatar:text-xs`,t),...r,children:n??i(`img`,{src:c,alt:`avatar`,className:`w-full h-full rounded-full object-cover`})})}function p({className:t,...n}){return i(`span`,{"data-slot":`avatar-badge`,className:e(`bg-primary text-primary-foreground ring-background absolute right-0 bottom-0 z-10 inline-flex items-center justify-center rounded-full bg-blend-color ring-2 select-none`,`group-data-[size=sm]/avatar:w-2 group-data-[size=sm]/avatar:h-2 group-data-[size=sm]/avatar:[&>svg]:hidden`,`group-data-[size=default]/avatar:w-2.5 group-data-[size=default]/avatar:h-2.5 group-data-[size=default]/avatar:[&>svg]:w-2 group-data-[size=default]/avatar:[&>svg]:h-2`,`group-data-[size=lg]/avatar:w-3 group-data-[size=lg]/avatar:h-3 group-data-[size=lg]/avatar:[&>svg]:w-2 group-data-[size=lg]/avatar:[&>svg]:h-2`,t),...n})}function m({className:t,...n}){return i(`div`,{"data-slot":`avatar-group`,className:e(`[&>[data-slot=avatar]]:ring-background group/avatar-group flex -space-x-2 [&>[data-slot=avatar]]:ring-2`,t),...n})}function h({className:t,...n}){return i(`div`,{"data-slot":`avatar-group-count`,className:e(`bg-muted text-muted-foreground w-8 h-8 rounded-full text-sm group-has-[data-size=lg]/avatar-group:w-10 group-has-[data-size=lg]/avatar-group:h-10 group-has-[data-size=sm]/avatar-group:w-6 group-has-[data-size=sm]/avatar-group:h-6 [&>svg]:w-4 [&>svg]:h-4 group-has-[data-size=lg]/avatar-group:[&>svg]:w-5 group-has-[data-size=lg]/avatar-group:[&>svg]:h-5 group-has-[data-size=sm]/avatar-group:[&>svg]:w-3 group-has-[data-size=sm]/avatar-group:[&>svg]:h-3 ring-background relative flex shrink-0 items-center justify-center ring-2`,t),...n})}export{l as Avatar,p as AvatarBadge,f as AvatarFallback,m as AvatarGroup,h as AvatarGroupCount,d as AvatarImage};
|
|
@@ -6,7 +6,7 @@ import * as class_variance_authority_types0 from "class-variance-authority/types
|
|
|
6
6
|
//#region components/ui/badge.d.ts
|
|
7
7
|
/** badgeVariants 工具定义。 */
|
|
8
8
|
declare const badgeVariants: (props?: ({
|
|
9
|
-
variant?: "
|
|
9
|
+
variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
|
|
10
10
|
} & class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
11
11
|
/** Badge 组件。 */
|
|
12
12
|
declare function Badge({
|
|
@@ -7,7 +7,7 @@ import * as class_variance_authority_types0 from "class-variance-authority/types
|
|
|
7
7
|
//#region components/ui/button.d.ts
|
|
8
8
|
/** buttonVariants 工具定义。 */
|
|
9
9
|
declare const buttonVariants: (props?: ({
|
|
10
|
-
variant?: "
|
|
10
|
+
variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
|
|
11
11
|
size?: "default" | "icon" | "xs" | "sm" | "lg" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
|
|
12
12
|
} & class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
13
13
|
/** Button 组件属性。 */
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
|
-
import
|
|
4
|
+
import NextImage from "next/image";
|
|
5
5
|
|
|
6
6
|
//#region components/ui/image.d.ts
|
|
7
7
|
/** BaseImageProps 属性定义。 */
|
|
8
|
-
type BaseImageProps = Omit<React.ComponentPropsWithoutRef<typeof
|
|
8
|
+
type BaseImageProps = Omit<React.ComponentPropsWithoutRef<typeof NextImage>, 'className' | 'src' | 'alt' | 'width' | 'height' | 'loading' | 'priority' | 'fill' | 'style'>;
|
|
9
9
|
type CommonImageProps = BaseImageProps & {
|
|
10
10
|
/** 图片地址,支持普通 URL、默认资源路径和加密地址。 */src: string; /** 图片替代文本。 */
|
|
11
11
|
alt?: string; /** 图片类名。 */
|
|
@@ -27,6 +27,6 @@ type ImagePropsWithSize = CommonImageProps & {
|
|
|
27
27
|
/** ImageProps 属性定义。 */
|
|
28
28
|
type ImageProps = ImagePropsWithFill | ImagePropsWithSize;
|
|
29
29
|
/** 图片组件:支持 bnc 解密、默认资源域名拼接与错误占位。 */
|
|
30
|
-
declare function Image
|
|
30
|
+
declare function Image(props: ImageProps): react_jsx_runtime0.JSX.Element;
|
|
31
31
|
//#endregion
|
|
32
|
-
export { BaseImageProps, CommonImageProps, Image
|
|
32
|
+
export { BaseImageProps, CommonImageProps, Image, ImageProps, ImagePropsWithFill, ImagePropsWithSize };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
"use client";import{getItem as e,setItem as t}from"./db.mjs";import{createBncDecryptWorker as n}from"./decrypt.worker.mjs";import r from"./get-res-url.mjs";let i=null;function a(){if(typeof window>`u`)return null;if(i)return i;let e=[];function t(){let e={worker:n(),busy:!1,current:null},t=()=>{try{e.worker.terminate()}catch{}e.worker=n(),e.busy=!1,e.current=null,r(e)},r=e=>{e.worker.addEventListener(`message`,t=>{let n=t.data;if(!e.current||n?.id!==e.current.id)return;let{resolve:r}=e.current;e.current=null,e.busy=!1,r(n),d()}),e.worker.addEventListener(`error`,n=>{if(e.current){let{reject:t}=e.current;e.current=null,e.busy=!1,t(n)}t(),d()})};return r(e),e}for(let n=0;n<4;n++)e.push(t());return i=e,i}const o=[];function s(e){if(!e)return!1;let t=e.split(`?`)[0];return/bnc$/i.test(t)||/xxx$/i.test(t)}function c(e){let t=String(e||``).split(`?`)[0].toLowerCase().match(/\.(jpg|jpeg|png|gif|webp)(?:\.?(?:bnc|xxx))?$/i)?.[1];return t===`jpg`||t===`jpeg`?`image/jpeg`:t===`png`?`image/png`:t===`gif`?`image/gif`:t===`webp`?`image/webp`:`application/octet-stream`}async function l(n,i){if(!n?.trim())return null;if(s(n)){let r=await e(n);if(r instanceof ArrayBuffer)return{buffer:r,contentType:c(n)};let{buffer:a,contentType:o,error:s}=await f(n,i);return s?null:(await t(n,a),{buffer:a,contentType:o??c(n)})}let a=r(),o=n.startsWith(`http`)?n:n.startsWith(`/`)?a?`${a}${n}`:n:a?`${a}/${n}`:`/${n}`,l=await fetch(o);return l.ok?{buffer:await l.arrayBuffer(),contentType:l.headers.get(`content-type`)||c(n)}:null}async function u(e,t){let n=await l(e,t);return n?{bytes:new Uint8Array(n.buffer),contentType:n.contentType}:null}function d(){let e=a();if(e)for(let t of e){if(t.busy)continue;let e=o.shift();if(!e)return;t.busy=!0,t.current={id:e.id,resolve:e.resolve,reject:e.reject};let n={id:e.id,mode:`bnc-url`,url:e.url,apiRes:r(),secretKey:e.secretKey};t.worker.postMessage(n)}}function f(e,t){if(!a())return Promise.resolve({id:`no-worker`,buffer:new ArrayBuffer(0),error:`worker not available`});let n=typeof crypto<`u`&&`randomUUID`in crypto?crypto.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`;return new Promise((r,i)=>{o.push({id:n,url:e,secretKey:t,resolve:r,reject:i}),d()})}async function
|
|
2
|
+
"use client";import{getItem as e,setItem as t}from"./db.mjs";import{createBncDecryptWorker as n}from"./decrypt.worker.mjs";import r from"./get-res-url.mjs";let i=null;function a(){if(typeof window>`u`)return null;if(i)return i;let e=[];function t(){let e={worker:n(),busy:!1,current:null},t=()=>{try{e.worker.terminate()}catch{}e.worker=n(),e.busy=!1,e.current=null,r(e)},r=e=>{e.worker.addEventListener(`message`,t=>{let n=t.data;if(!e.current||n?.id!==e.current.id)return;let{resolve:r}=e.current;e.current=null,e.busy=!1,r(n),d()}),e.worker.addEventListener(`error`,n=>{if(e.current){let{reject:t}=e.current;e.current=null,e.busy=!1,t(n)}t(),d()})};return r(e),e}for(let n=0;n<4;n++)e.push(t());return i=e,i}const o=[];function s(e){if(!e)return!1;let t=e.split(`?`)[0];return/bnc$/i.test(t)||/xxx$/i.test(t)}function c(e){let t=String(e||``).split(`?`)[0].toLowerCase().match(/\.(jpg|jpeg|png|gif|webp)(?:\.?(?:bnc|xxx))?$/i)?.[1];return t===`jpg`||t===`jpeg`?`image/jpeg`:t===`png`?`image/png`:t===`gif`?`image/gif`:t===`webp`?`image/webp`:`application/octet-stream`}async function l(n,i){if(!n?.trim())return null;if(s(n)){let r=await e(n);if(r instanceof ArrayBuffer)return{buffer:r,contentType:c(n)};let{buffer:a,contentType:o,error:s}=await f(n,i);return s?null:(await t(n,a),{buffer:a,contentType:o??c(n)})}let a=r(),o=n.startsWith(`http`)?n:n.startsWith(`/`)?a?`${a}${n}`:n:a?`${a}/${n}`:`/${n}`,l=await fetch(o);return l.ok?{buffer:await l.arrayBuffer(),contentType:l.headers.get(`content-type`)||c(n)}:null}async function u(e,t){let n=await l(e,t);return n?{bytes:new Uint8Array(n.buffer),contentType:n.contentType}:null}function d(){let e=a();if(e)for(let t of e){if(t.busy)continue;let e=o.shift();if(!e)return;t.busy=!0,t.current={id:e.id,resolve:e.resolve,reject:e.reject};let n={id:e.id,mode:`bnc-url`,url:e.url,apiRes:r(),secretKey:e.secretKey};t.worker.postMessage(n)}}function f(e,t){if(!a())return Promise.resolve({id:`no-worker`,buffer:new ArrayBuffer(0),error:`worker not available`});let n=typeof crypto<`u`&&`randomUUID`in crypto?crypto.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`;return new Promise((r,i)=>{o.push({id:n,url:e,secretKey:t,resolve:r,reject:i}),d()})}function p(e){return e.startsWith(`default/`)||e.startsWith(`/default/`)||e.startsWith(`/images/default`)}function m(e){return/^(https?:)?\/\//.test(e)||e.startsWith(`data:`)}async function h(n,i){let a=await e(n);if(a instanceof ArrayBuffer)return URL.createObjectURL(new Blob([a],{type:c(n)}));if(s(n)){let{buffer:e,contentType:r,error:a}=await f(n,i);return a?``:(await t(n,e),URL.createObjectURL(new Blob([e],{type:r??c(n)})))}else{let e=r();return p(n)?e?`${e}${n.startsWith(`/`)?n:`/${n}`}`:`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4//8/LwAJCQMLCIuEYQAAAABJRU5ErkJggg==`:m(n)?n:n.startsWith(`/md-204`)?`${e}${n.startsWith(`/`)?n:`/${n}`}`:n}}export{l as decryptImageToArrayBuffer,u as decryptImageToUint8Array,h as decryptImageUrl,c as guessImageContentTypeFromUrl,s as isEncryptedImageUrl};
|