@funhub/platform 0.1.153 → 0.1.155

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.
Files changed (143) hide show
  1. package/dist/assets/icons/marquee-enter.mjs +2 -0
  2. package/dist/components/biz/basics/search/shared/components/search-box.mjs +1 -1
  3. package/dist/components/biz/basics/search/variants/basic-search/runtime/client.mjs +1 -1
  4. package/dist/components/biz/business/banner/variants/basic-banner/inspector-schema.d.mts +5 -4
  5. package/dist/components/biz/business/banner/variants/basic-banner/inspector-schema.mjs +1 -1
  6. package/dist/components/biz/business/banner/variants/basic-banner/material.d.mts +3 -2
  7. package/dist/components/biz/business/banner-carousel/material.d.mts +3 -2
  8. package/dist/components/biz/business/banner-carousel/schema.d.mts +3 -2
  9. package/dist/components/biz/business/banner-carousel/schema.mjs +1 -1
  10. package/dist/components/biz/business/channel-list/material.d.mts +3 -2
  11. package/dist/components/biz/business/channel-list/schema.d.mts +3 -2
  12. package/dist/components/biz/business/channel-list/schema.mjs +1 -1
  13. package/dist/components/biz/business/detail/shared/detail-operate.mjs +1 -1
  14. package/dist/components/biz/business/detail/shared/registry.d.mts +17 -14
  15. package/dist/components/biz/business/detail/shared/runtime-context-provider.mjs +1 -1
  16. package/dist/components/biz/business/detail/shared/use-video-detail-webview-bridge.mjs +1 -1
  17. package/dist/components/biz/business/detail/video-detail-actions/schema.mjs +1 -1
  18. package/dist/components/biz/business/detail/video-detail-info/material.d.mts +3 -2
  19. package/dist/components/biz/business/detail/video-detail-info/schema.d.mts +3 -2
  20. package/dist/components/biz/business/detail/video-detail-info/schema.mjs +1 -1
  21. package/dist/components/biz/business/detail/video-detail-info/server.mjs +1 -1
  22. package/dist/components/biz/business/detail/video-detail-info-title-tags-episodes/material.d.mts +3 -2
  23. package/dist/components/biz/business/detail/video-detail-info-title-tags-episodes/schema.d.mts +3 -2
  24. package/dist/components/biz/business/detail/video-detail-info-title-tags-episodes/schema.mjs +1 -1
  25. package/dist/components/biz/business/detail/video-detail-player/schema.mjs +1 -1
  26. package/dist/components/biz/business/detail/video-detail-player-bridge-only/client.d.mts +1 -1
  27. package/dist/components/biz/business/detail/video-detail-player-bridge-only/client.mjs +1 -1
  28. package/dist/components/biz/business/detail/video-detail-player-bridge-only/schema.mjs +1 -1
  29. package/dist/components/biz/business/detail/video-detail-recommend/client.mjs +1 -1
  30. package/dist/components/biz/business/detail/video-detail-recommend/material.d.mts +11 -10
  31. package/dist/components/biz/business/detail/video-detail-recommend/schema.d.mts +11 -10
  32. package/dist/components/biz/business/detail/video-detail-recommend/schema.mjs +1 -1
  33. package/dist/components/biz/business/floating-ball/material.d.mts +3 -2
  34. package/dist/components/biz/business/floating-ball/schema.d.mts +5 -4
  35. package/dist/components/biz/business/floating-ball/schema.mjs +1 -1
  36. package/dist/components/biz/business/header-search/header-avatar-icon/schema.mjs +1 -1
  37. package/dist/components/biz/business/header-search/header-avatar-logo-search/material.d.mts +3 -2
  38. package/dist/components/biz/business/header-search/header-avatar-logo-search/schema.d.mts +3 -2
  39. package/dist/components/biz/business/header-search/header-avatar-logo-search/schema.mjs +1 -1
  40. package/dist/components/biz/business/header-search/header-avatar-logo-search-icon/material.d.mts +3 -2
  41. package/dist/components/biz/business/header-search/header-avatar-logo-search-icon/schema.d.mts +3 -2
  42. package/dist/components/biz/business/header-search/header-avatar-logo-search-icon/schema.mjs +1 -1
  43. package/dist/components/biz/business/header-search/header-logo-search/material.d.mts +3 -2
  44. package/dist/components/biz/business/header-search/header-logo-search/schema.d.mts +3 -2
  45. package/dist/components/biz/business/header-search/header-logo-search/schema.mjs +1 -1
  46. package/dist/components/biz/business/header-search/header-search/schema.mjs +1 -1
  47. package/dist/components/biz/business/home-recommend/home-recommend-grid/inspector-schema.d.mts +13 -12
  48. package/dist/components/biz/business/home-recommend/home-recommend-grid/inspector-schema.mjs +1 -1
  49. package/dist/components/biz/business/home-recommend/home-recommend-grid/material.d.mts +13 -12
  50. package/dist/components/biz/business/home-recommend/home-recommend-waterfall/inspector-schema.d.mts +11 -10
  51. package/dist/components/biz/business/home-recommend/home-recommend-waterfall/inspector-schema.mjs +1 -1
  52. package/dist/components/biz/business/home-recommend/home-recommend-waterfall/material.d.mts +11 -10
  53. package/dist/components/biz/business/home-recommend/shared/home-recommend-base.mjs +1 -1
  54. package/dist/components/biz/business/home-recommend/shared/home-recommend-server-data.mjs +1 -1
  55. package/dist/components/biz/business/home-recommend/shared/home-recommend-video-detail.mjs +1 -1
  56. package/dist/components/biz/business/image-text-recommend/material.d.mts +15 -14
  57. package/dist/components/biz/business/image-text-recommend/schema.d.mts +15 -14
  58. package/dist/components/biz/business/image-text-recommend/schema.mjs +1 -1
  59. package/dist/components/biz/business/large-feature-grid/client.mjs +1 -1
  60. package/dist/components/biz/business/large-feature-grid/schema.mjs +1 -1
  61. package/dist/components/biz/business/marquee/client.mjs +1 -1
  62. package/dist/components/biz/business/marquee/material.d.mts +8 -7
  63. package/dist/components/biz/business/marquee/schema.d.mts +26 -24
  64. package/dist/components/biz/business/marquee/schema.mjs +1 -1
  65. package/dist/components/biz/business/profile/profile-header/client.mjs +1 -1
  66. package/dist/components/biz/business/profile/profile-header/schema.mjs +1 -1
  67. package/dist/components/biz/business/profile/profile-header/user-profile-avatar.mjs +1 -1
  68. package/dist/components/biz/business/profile/profile-header/user-profile-cover-background.mjs +1 -1
  69. package/dist/components/biz/business/profile/profile-main/schema.mjs +1 -1
  70. package/dist/components/biz/business/profile/profile-main/shell.mjs +1 -1
  71. package/dist/components/biz/business/profile/profile-main/tabs/collect-tab/client.mjs +1 -1
  72. package/dist/components/biz/business/profile/profile-main/tabs/like-tab/client.d.mts +1 -1
  73. package/dist/components/biz/business/search-bar/variants/basic-search-bar/runtime/client.mjs +1 -1
  74. package/dist/components/biz/business/search-history/client.mjs +1 -1
  75. package/dist/components/biz/business/search-history/material.d.mts +3 -2
  76. package/dist/components/biz/business/search-history/schema.d.mts +3 -2
  77. package/dist/components/biz/business/search-history/schema.mjs +1 -1
  78. package/dist/components/biz/business/search-input/schema.mjs +1 -1
  79. package/dist/components/biz/business/shortcut-grid/material.d.mts +5 -4
  80. package/dist/components/biz/business/shortcut-grid/schema.d.mts +5 -4
  81. package/dist/components/biz/business/shortcut-grid/schema.mjs +1 -1
  82. package/dist/components/biz/business/tab-bar/schema.mjs +1 -1
  83. package/dist/components/biz/business/text-recommend/material.d.mts +4 -3
  84. package/dist/components/biz/business/text-recommend/schema.d.mts +4 -3
  85. package/dist/components/biz/business/text-recommend/schema.mjs +1 -1
  86. package/dist/components/biz/example/button/material.d.mts +9 -8
  87. package/dist/components/biz/example/button/schema.d.mts +21 -19
  88. package/dist/components/biz/example/button/schema.mjs +1 -1
  89. package/dist/components/common/image-crop-modal/image-crop-modal.mjs +2 -2
  90. package/dist/components/common/series-episodes/index.mjs +1 -1
  91. package/dist/components/common/video-player/process-m3u8-cache.mjs +1 -1
  92. package/dist/components/pages/collection-add/page.mjs +1 -1
  93. package/dist/components/pages/collection-create/form.mjs +1 -1
  94. package/dist/components/pages/collection-detail/detail.mjs +1 -1
  95. package/dist/components/pages/login/verify.mjs +1 -1
  96. package/dist/components/pages/publish/components/upload-progress.mjs +1 -1
  97. package/dist/components/pages/search/hot-recommend.mjs +1 -1
  98. package/dist/components/pages/search/style.module.mjs +3 -31
  99. package/dist/components/pages/search/top-header.mjs +1 -1
  100. package/dist/components/pages/search-result/search-all.mjs +1 -1
  101. package/dist/components/pages/search-result/search-tab.mjs +1 -1
  102. package/dist/components/pages/search-result/search-user.mjs +1 -1
  103. package/dist/components/pages/search-result/search-video.mjs +1 -1
  104. package/dist/components/pages/video-detail/video-detail-client.mjs +1 -1
  105. package/dist/components/pages/video-list/index.mjs +1 -1
  106. package/dist/components/pages/video-list/video-list-client.mjs +1 -1
  107. package/dist/components/ui/badge.d.mts +1 -1
  108. package/dist/components/ui/button.d.mts +1 -1
  109. package/dist/components/ui/image.d.mts +4 -4
  110. package/dist/components/ui/item.mjs +1 -1
  111. package/dist/components/ui/loading.d.mts +42 -0
  112. package/dist/hooks/use-first-row-height.d.mts +69 -0
  113. package/dist/hooks/use-first-row-height.mjs +2 -0
  114. package/dist/hooks/use-min-duration-loading.d.mts +18 -0
  115. package/dist/hooks/use-min-duration-loading.mjs +2 -0
  116. package/dist/hooks.d.mts +3 -1
  117. package/dist/hooks.mjs +1 -1
  118. package/dist/pages.mjs +1 -1
  119. package/dist/service/generated/client.d.mts +12 -4
  120. package/dist/service/generated/client.mjs +1 -1
  121. package/dist/service/generated/tanstack.d.mts +14 -4
  122. package/dist/service/generated/tanstack.mjs +1 -1
  123. package/dist/service/register-by-verify-email-code.d.mts +2 -2
  124. package/dist/service/register-by-verify-email-code.mjs +1 -1
  125. package/dist/service.d.mts +4 -4
  126. package/dist/service.mjs +1 -1
  127. package/dist/types.d.mts +548 -57
  128. package/dist/ui.d.mts +2 -1
  129. package/dist/ui.mjs +1 -1
  130. package/dist/utils/device-id.d.mts +14 -0
  131. package/dist/utils/device-id.mjs +2 -0
  132. package/dist/utils/http.mjs +1 -1
  133. package/dist/utils/image-crop.mjs +1 -1
  134. package/dist/utils/schema/index.d.mts +1 -1
  135. package/dist/utils/schema/inspector.d.mts +43 -71
  136. package/dist/utils/schema/schema.d.mts +59 -53
  137. package/dist/utils/schema/schema.mjs +1 -1
  138. package/dist/utils/tools.mjs +1 -1
  139. package/dist/utils.d.mts +3 -2
  140. package/dist/utils.mjs +1 -1
  141. package/package.json +1 -1
  142. package/dist/components/common/image-crop/image-crop.mjs +0 -2
  143. package/dist/components/common/image-crop/show-image-crop.mjs +0 -2
package/dist/utils.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
 
2
- import{cn as e}from"./utils/cn.mjs";import{clearMyChannelsFromStorage as t,loadHiddenChannelIdsFromStorage as n,loadMyChannelsFromStorage as r,saveHiddenChannelIdsToStorage as i}from"./utils/channel-storage.mjs";import{debounceFun as a,formatVideoDuration as o,generateDynamicSign as s,generateUUID as c,getAtUserElement as l,getCookie as u,getCurrentSecondTime as d,getUserId as f,hashPassword as p,isClient as m,isMobileDevice as h,numToString as g,parseResolution as _,parseTextAtUserIds as v,randomString as y,removeCookie as b,replaceAtUserElement as x,replaceAtUserElementHtmlStr as S,secondToTime as C,setCookie as w,stringToNumber as T,stripHtmlTags as E,updateUrlParams as D}from"./utils/common.mjs";import O from"./utils/get-res-url.mjs";import{decryptImageToArrayBuffer as k,decryptImageToUint8Array as A,decryptImageUrl as j,guessImageContentTypeFromUrl as M,isEncryptedImageUrl as N,resolveImageUrl as P,shouldProbeImageUrl as F,shouldUseApiResDirectly as I}from"./utils/decrypt-image-client.mjs";import L from"./utils/event-bus.mjs";import R,{HttpClient as z,HttpError as B}from"./utils/http.mjs";import{checkFollowStatus as V,followUser as H,getAppId as U,getCurrentUserId as W,unfollowUser as G}from"./utils/follow-service.mjs";import{disablePageScroll as K,enablePageScroll as q,normalizeClassName as J,pxToVw as Y}from"./utils/helper.mjs";import{compressImage as X,defaultImageCompressionMaxSizeMB as Z,defaultImageCompressionQuality as Q,getImageCompressionQuality as $,imageCompressionQualityRules as ee}from"./utils/image-compression.mjs";import{components as te,loadComponent as ne,rewriteComponent as re}from"./utils/loaders.mjs";import{createInputAndSelectFile as ie,getCoverImage as ae,getImageResolutionFromFile as oe}from"./utils/media.mjs";import{PASSWORD_ALLOWED_SPECIAL_CHARS as se,PASSWORD_MAX_LENGTH as ce,PASSWORD_MIN_LENGTH as le,getFirstInvalidPasswordChar as ue,getPasswordCharacterTypeCount as de,getPasswordValidationErrorText as fe,validatePasswordPair as pe}from"./utils/password-validator.mjs";import{uploadToS3WithPresignedUrl as me}from"./utils/s3-uploader.mjs";import{defineMaterial as he,overwriteMaterial as ge}from"./utils/schema/material.mjs";import{INSPECTOR_META_KEY as _e,defineArrayItemPropSchema as ve,defineCheckboxPropSchema as ye,defineColorPropSchema as be,defineComponentPropsSchema as xe,defineDatetimePropSchema as Se,defineNumberPropSchema as Ce,defineObjectPropSchema as we,defineSelectEnumPropSchema as Te,defineSelectPropSchema as Ee,defineSwitchPropSchema as De,defineTextPropSchema as Oe,defineTextareaPropSchema as ke,defineTimeRangePropSchema as Ae,getSchemaDefaultProps as je,withInspectorMeta as Me}from"./utils/schema/schema.mjs";import{generateMaterialMap as Ne,generateMaterialMapGroupByCategory as Pe}from"./utils/schema/utils.mjs";import{base64ToUint8Array as Fe,uint8ArrayToBase64 as Ie,uint8ArrayToNumberArray as Le}from"./utils/uint8.mjs";import{encryptBncBuffer as Re,uploadFile as ze}from"./utils/upload-file.mjs";import{useRouter as Be}from"./utils/use-compatible-router.mjs";export{L as EventBus,z as HttpClient,B as HttpError,_e as INSPECTOR_META_KEY,se as PASSWORD_ALLOWED_SPECIAL_CHARS,ce as PASSWORD_MAX_LENGTH,le as PASSWORD_MIN_LENGTH,Fe as base64ToUint8Array,V as checkFollowStatus,t as clearMyChannelsFromStorage,e as cn,te as components,X as compressImage,ie as createInputAndSelectFile,a as debounceFun,k as decryptImageToArrayBuffer,A as decryptImageToUint8Array,j as decryptImageUrl,Z as defaultImageCompressionMaxSizeMB,Q as defaultImageCompressionQuality,ve as defineArrayItemPropSchema,ye as defineCheckboxPropSchema,be as defineColorPropSchema,xe as defineComponentPropsSchema,Se as defineDatetimePropSchema,he as defineMaterial,Ce as defineNumberPropSchema,we as defineObjectPropSchema,Te as defineSelectEnumPropSchema,Ee as defineSelectPropSchema,De as defineSwitchPropSchema,Oe as defineTextPropSchema,ke as defineTextareaPropSchema,Ae as defineTimeRangePropSchema,K as disablePageScroll,q as enablePageScroll,Re as encryptBncBuffer,H as followUser,o as formatVideoDuration,s as generateDynamicSign,Ne as generateMaterialMap,Pe as generateMaterialMapGroupByCategory,c as generateUUID,U as getAppId,l as getAtUserElement,u as getCookie,ae as getCoverImage,d as getCurrentSecondTime,W as getCurrentUserId,ue as getFirstInvalidPasswordChar,$ as getImageCompressionQuality,oe as getImageResolutionFromFile,de as getPasswordCharacterTypeCount,fe as getPasswordValidationErrorText,O as getResUrl,je as getSchemaDefaultProps,f as getUserId,M as guessImageContentTypeFromUrl,p as hashPassword,R as httpClient,ee as imageCompressionQualityRules,m as isClient,N as isEncryptedImageUrl,h as isMobileDevice,ne as loadComponent,n as loadHiddenChannelIdsFromStorage,r as loadMyChannelsFromStorage,J as normalizeClassName,g as numToString,ge as overwriteMaterial,_ as parseResolution,v as parseTextAtUserIds,Y as pxToVw,y as randomString,b as removeCookie,x as replaceAtUserElement,S as replaceAtUserElementHtmlStr,P as resolveImageUrl,re as rewriteComponent,i as saveHiddenChannelIdsToStorage,C as secondToTime,w as setCookie,F as shouldProbeImageUrl,I as shouldUseApiResDirectly,T as stringToNumber,E as stripHtmlTags,Ie as uint8ArrayToBase64,Le as uint8ArrayToNumberArray,G as unfollowUser,D as updateUrlParams,ze as uploadFile,me as uploadToS3WithPresignedUrl,Be as useRouter,pe as validatePasswordPair,Me as withInspectorMeta};
2
+ import{cn as e}from"./utils/cn.mjs";import{clearMyChannelsFromStorage as t,loadHiddenChannelIdsFromStorage as ee,loadMyChannelsFromStorage as n,saveHiddenChannelIdsToStorage as r}from"./utils/channel-storage.mjs";import{debounceFun as i,formatVideoDuration as a,generateDynamicSign as o,generateUUID as s,getAtUserElement as c,getCookie as l,getCurrentSecondTime as u,getUserId as d,hashPassword as f,isClient as p,isMobileDevice as m,numToString as h,parseResolution as g,parseTextAtUserIds as _,randomString as v,removeCookie as y,replaceAtUserElement as b,replaceAtUserElementHtmlStr as x,secondToTime as S,setCookie as C,stringToNumber as w,stripHtmlTags as T,updateUrlParams as E}from"./utils/common.mjs";import D from"./utils/get-res-url.mjs";import{decryptImageToArrayBuffer as O,decryptImageToUint8Array as k,decryptImageUrl as A,guessImageContentTypeFromUrl as j,isEncryptedImageUrl as M,resolveImageUrl as N,shouldProbeImageUrl as P,shouldUseApiResDirectly as F}from"./utils/decrypt-image-client.mjs";import{getOrCreateDeviceId as I}from"./utils/device-id.mjs";import L from"./utils/event-bus.mjs";import R,{HttpClient as z,HttpError as B}from"./utils/http.mjs";import{checkFollowStatus as V,followUser as H,getAppId as U,getCurrentUserId as W,unfollowUser as G}from"./utils/follow-service.mjs";import{disablePageScroll as K,enablePageScroll as q,normalizeClassName as J,pxToVw as te}from"./utils/helper.mjs";import{compressImage as Y,defaultImageCompressionMaxSizeMB as X,defaultImageCompressionQuality as Z,getImageCompressionQuality as Q,imageCompressionQualityRules as ne}from"./utils/image-compression.mjs";import{components as re,loadComponent as ie,rewriteComponent as ae}from"./utils/loaders.mjs";import{createInputAndSelectFile as oe,getCoverImage as se,getImageResolutionFromFile as ce}from"./utils/media.mjs";import{PASSWORD_ALLOWED_SPECIAL_CHARS as le,PASSWORD_MAX_LENGTH as ue,PASSWORD_MIN_LENGTH as de,getFirstInvalidPasswordChar as fe,getPasswordCharacterTypeCount as pe,getPasswordValidationErrorText as me,validatePasswordPair as he}from"./utils/password-validator.mjs";import{uploadToS3WithPresignedUrl as ge}from"./utils/s3-uploader.mjs";import{defineMaterial as _e,overwriteMaterial as ve}from"./utils/schema/material.mjs";import{INSPECTOR_META_KEY as ye,array as be,boolean as xe,datetime as Se,defineComponentPropsSchema as Ce,enumSchema as $,getSchemaDefaultProps as we,number as Te,object as Ee,string as De,timeRange as Oe,withInspectorMeta as ke}from"./utils/schema/schema.mjs";import{generateMaterialMap as Ae,generateMaterialMapGroupByCategory as je}from"./utils/schema/utils.mjs";import{base64ToUint8Array as Me,uint8ArrayToBase64 as Ne,uint8ArrayToNumberArray as Pe}from"./utils/uint8.mjs";import{encryptBncBuffer as Fe,uploadFile as Ie}from"./utils/upload-file.mjs";import{useRouter as Le}from"./utils/use-compatible-router.mjs";export{L as EventBus,z as HttpClient,B as HttpError,ye as INSPECTOR_META_KEY,le as PASSWORD_ALLOWED_SPECIAL_CHARS,ue as PASSWORD_MAX_LENGTH,de as PASSWORD_MIN_LENGTH,be as array,Me as base64ToUint8Array,xe as boolean,V as checkFollowStatus,t as clearMyChannelsFromStorage,e as cn,re as components,Y as compressImage,oe as createInputAndSelectFile,Se as datetime,i as debounceFun,O as decryptImageToArrayBuffer,k as decryptImageToUint8Array,A as decryptImageUrl,X as defaultImageCompressionMaxSizeMB,Z as defaultImageCompressionQuality,Ce as defineComponentPropsSchema,_e as defineMaterial,K as disablePageScroll,q as enablePageScroll,Fe as encryptBncBuffer,$ as enum,$ as enumSchema,H as followUser,a as formatVideoDuration,o as generateDynamicSign,Ae as generateMaterialMap,je as generateMaterialMapGroupByCategory,s as generateUUID,U as getAppId,c as getAtUserElement,l as getCookie,se as getCoverImage,u as getCurrentSecondTime,W as getCurrentUserId,fe as getFirstInvalidPasswordChar,Q as getImageCompressionQuality,ce as getImageResolutionFromFile,I as getOrCreateDeviceId,pe as getPasswordCharacterTypeCount,me as getPasswordValidationErrorText,D as getResUrl,we as getSchemaDefaultProps,d as getUserId,j as guessImageContentTypeFromUrl,f as hashPassword,R as httpClient,ne as imageCompressionQualityRules,p as isClient,M as isEncryptedImageUrl,m as isMobileDevice,ie as loadComponent,ee as loadHiddenChannelIdsFromStorage,n as loadMyChannelsFromStorage,J as normalizeClassName,h as numToString,Te as number,Ee as object,ve as overwriteMaterial,g as parseResolution,_ as parseTextAtUserIds,te as pxToVw,v as randomString,y as removeCookie,b as replaceAtUserElement,x as replaceAtUserElementHtmlStr,N as resolveImageUrl,ae as rewriteComponent,r as saveHiddenChannelIdsToStorage,S as secondToTime,C as setCookie,P as shouldProbeImageUrl,F as shouldUseApiResDirectly,De as string,w as stringToNumber,T as stripHtmlTags,Oe as timeRange,Ne as uint8ArrayToBase64,Pe as uint8ArrayToNumberArray,G as unfollowUser,E as updateUrlParams,Ie as uploadFile,ge as uploadToS3WithPresignedUrl,Le as useRouter,he as validatePasswordPair,ke as withInspectorMeta};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@funhub/platform",
3
3
  "type": "module",
4
- "version": "0.1.153",
4
+ "version": "0.1.155",
5
5
  "private": false,
6
6
  "sideEffects": [
7
7
  "**/*.css"
@@ -1,2 +0,0 @@
1
-
2
- "use client";import{defaultImageCompressionQuality as e}from"../../../utils/image-compression.mjs";import{Dialog as t,DialogContent as n}from"../../ui/dialog.mjs";import{fileToDataUrl as r,getCroppedFile as i,getOptimalQuality as a,validateImageFile as o}from"../../../utils/image-crop.mjs";import{useCallback as s,useEffect as c,useMemo as l,useState as u}from"react";import{jsx as d,jsxs as f}from"react/jsx-runtime";import p from"react-easy-crop";function m({visible:m,file:h,quality:g,outputFormat:_=`jpeg`,maxWidth:v,maxHeight:y,cropShape:b=`round`,onCropComplete:x,onCancel:S,className:C}){let[w,T]=u(``),[E,D]=u(!1),[O,k]=u(``),[A,j]=u({crop:{x:0,y:0},zoom:1,croppedAreaPixels:null}),M=l(()=>g===void 0?h?a(h.size):e:g,[g,h]);c(()=>{if(!h||!m){T(``),k(``);return}if(!o(h)){k(`请选择有效的图片文件(支持 JPEG、PNG、WebP、GIF 格式)`);return}if(h.size>20*1024*1024){k(`文件大小不能超过 20MB`);return}D(!0),k(``),r(h).then(e=>{T(e),D(!1)}).catch(e=>{console.error(`图片加载失败:`,e),k(`图片加载失败,请重试`),D(!1)})},[h,m]),c(()=>{m&&j({crop:{x:0,y:0},zoom:1,croppedAreaPixels:null})},[m,h]);let N=s(e=>{j(t=>({...t,crop:e}))},[]),P=s(e=>{j(t=>({...t,zoom:e}))},[]),F=s((e,t)=>{j(e=>({...e,croppedAreaPixels:t}))},[]),I=s(async()=>{if(!h||!A.croppedAreaPixels){k(`请先选择裁剪区域`);return}D(!0),k(``);try{let e=`image/${_}`;x({file:await i(w,A.croppedAreaPixels,`cropped.${_}`,{fileType:e,quality:M,maxWidth:v,maxHeight:y,circular:b===`round`}),originalFile:h,cropArea:A.croppedAreaPixels})}catch(e){console.error(`裁剪失败:`,e),k(`裁剪失败,请重试`)}finally{D(!1)}},[h,A.croppedAreaPixels,M,_,v,y,b,w,x]),L=s(()=>{S()},[S]);return m?d(t,{open:m,onOpenChange:L,children:d(n,{showCloseButton:!1,className:`bg-black/90 !m-0 !p-0 !fixed !inset-0 !w-screen !h-screen !max-w-none !rounded-none !top-0 !left-0 !translate-x-0 !translate-y-0 !transform-none z-[9999] !pointer-events-auto ${C||``}`,children:f(`div`,{className:`relative flex h-full w-full flex-col`,children:[w&&!O&&f(`div`,{className:`absolute top-0 left-0 right-0 z-10 flex h-16 items-center justify-between px-4`,children:[d(`button`,{type:`button`,className:`flex h-full items-center justify-center px-4 text-white transition-colors hover:text-white/80`,onClick:L,disabled:E,children:d(`svg`,{className:`w-4 h-4`,xmlns:`http://www.w3.org/2000/svg`,fill:`currentColor`,viewBox:`0 0 16 16`,children:d(`path`,{d:`M14.55.2a.889.889 0 0 1 1.25 1.25l-.06.067L9.255 8l6.483 6.482.06.069a.888.888 0 0 1-1.25 1.25l-.067-.062L8 9.256l-6.482 6.483A.888.888 0 1 1 .26 14.482L6.742 8 .26 1.517.2 1.45A.888.888 0 0 1 1.45.2l.067.062 6.482 6.482L14.482.261l.068-.062Z`})})}),d(`button`,{type:`button`,className:`h-8 rounded-full bg-primary px-4 text-base font-medium text-primary-foreground transition-colors hover:bg-primary/80 disabled:opacity-50`,onClick:I,disabled:E||!A.croppedAreaPixels||!!O,children:`确定`})]}),f(`div`,{className:`relative flex-1 overflow-hidden bg-black`,children:[E&&f(`div`,{className:`absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 items-center gap-2 text-white`,children:[d(`div`,{className:`h-5 w-5 animate-spin rounded-full border-2 border-white/30 border-t-white`}),d(`span`,{children:`处理中...`})]}),O&&d(`div`,{className:`absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 text-center text-red-500`,children:O}),w&&!O&&d(p,{image:w,crop:A.crop,zoom:A.zoom,onCropChange:N,onZoomChange:P,onCropComplete:F,showGrid:!0,cropShape:b,restrictPosition:!0,zoomWithScroll:!0})]})]})})}):null}export{m as ImageCrop};
@@ -1,2 +0,0 @@
1
-
2
- "use client";import{ImageCrop as e}from"./image-crop.mjs";import"react";import{jsx as t}from"react/jsx-runtime";import{createRoot as n}from"react-dom/client";function r(r,i){return new Promise((a,o)=>{if(!r){o(Error(`文件参数不能为空`));return}if(![`image/jpeg`,`image/jpg`,`image/png`,`image/webp`,`image/gif`].includes(r.type)){o(Error(`不支持的文件类型,请选择图片文件`));return}if(r.size>20*1024*1024){o(Error(`文件大小不能超过 20MB`));return}if(i?.aspectRatio!==void 0&&(i.aspectRatio<=0||!Number.isFinite(i.aspectRatio))){o(Error(`aspectRatio 必须是一个大于0的有限数`));return}if(i?.quality!==void 0&&(i.quality<0||i.quality>1)){o(Error(`quality 必须在 0-1 之间`));return}if(i?.maxWidth!==void 0&&i.maxWidth<=0){o(Error(`maxWidth 必须大于0`));return}if(i?.maxHeight!==void 0&&i.maxHeight<=0){o(Error(`maxHeight 必须大于0`));return}let s=document.createElement(`div`);document.body.appendChild(s);let c=n(s),l=()=>{c.unmount(),document.body.removeChild(s)};c.render(t(e,{visible:!0,file:r,aspectRatio:i?.aspectRatio||1,quality:i?.quality,outputFormat:i?.outputFormat||`jpeg`,maxWidth:i?.maxWidth,maxHeight:i?.maxHeight,cropShape:i?.cropShape||`round`,onCropComplete:e=>{l(),a(e.file)},onCancel:()=>{l()}}))})}export{r as showImageCrop};