@funhub/platform 0.1.158 → 0.1.159

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,2 +1,2 @@
1
1
 
2
- "use client";import{decryptImageToUint8Array as e}from"../../../../../utils/decrypt-image-client.mjs";import{useUserStore as t}from"../../../../../store/modules/user-store.mjs";import{gContentGetVideoDetail as n,pInteractionBrowse as r}from"../../../../../service/generated/client.mjs";import{uint8ArrayToBase64 as i}from"../../../../../utils/uint8.mjs";import{resolveM3u8Urls as a,resolveVideoPlayerSrc as o}from"../../../../common/video-player/process-m3u8-cache.mjs";import{useLoginModalStore as s}from"../../../../../store/modules/login-modal-store.mjs";import{batchQueryContentInteractions as c}from"../../../../../hooks/use-content-operate.mjs";import{useCallback as l,useEffect as u,useRef as d}from"react";import{usePathname as f}from"next/navigation";import{useQueryClient as p}from"@tanstack/react-query";const m=new Map,h=new Map;function g(){if(typeof window>`u`)return!1;let e={open:!1};return window.dispatchEvent(new CustomEvent(`funhub:detail-series-popup-query`,{detail:e})),!!e.open}function _(){typeof window>`u`||window.dispatchEvent(new Event(`funhub:detail-series-popup-close`))}function v(e){let t=Math.floor(Number(e)||1);return t>0?t:1}function y(e){let t=typeof e==`string`?e:typeof window>`u`?``:window.location.pathname,n=String(t||``).split(`/`).filter(Boolean),r=n.findIndex(e=>e===`video`||e===`webview`);if(r<0)return{detailId:``,currentSeriesNum:1,episodeIndex:0};let i=n[r+1]||``;try{let e=decodeURIComponent(i),t=n.slice(r+1),a=t.findIndex(e=>e===`episode`),o=v(a>=0?t[a+1]:t[2]);return{detailId:e,currentSeriesNum:o,episodeIndex:Math.max(0,o-1)}}catch{let e=n.slice(r+1),t=e.findIndex(e=>e===`episode`),a=v(t>=0?e[t+1]:e[2]);return{detailId:i,currentSeriesNum:a,episodeIndex:Math.max(0,a-1)}}}function b(e){for(;e.size>5;){let t=e.keys().next().value;if(!t)break;e.delete(t)}}function x(e){let t=e,n=t?.data?.video||t?.video||t;if(!(!n||typeof n!=`object`))return{...n,content_type:1,episode_cnt:n.links?.length||0}}function S(e){let t=String(e||``).trim();return t?[[`video-detail`,t]]:[]}function C(v){let{enabled:C=!0}=v,w=p(),T=y(f()).detailId,E=d({detailId:``}),D=d(null),O=d(new Map),k=d(new Map);u(()=>{E.current={detailId:T},D.current=null},[T]);let A=l(async e=>{let t=Date.now(),r=()=>typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now(),i=r(),a=String(e||``).trim(),o=`empty-id`,s=!1,c=0,l=!1,u=0;if(!a){o=`empty-id`;return}if(E.current.detailId===a&&E.current.information){o=`cache`;let e=E.current.information;return l=!0,u=Array.isArray(e?.links)?e.links.length:0,e}let d=m.get(a);if(d)return o=`shared-cache`,E.current={detailId:a,information:d},l=!0,u=Array.isArray(d?.links)?d.links.length:0,d;let f=S(a).map(e=>w.getQueryData(e)).map(x).find(Boolean);if(f)return o=`query-cache`,E.current={detailId:a,information:f},m.set(a,f),l=!0,u=Array.isArray(f?.links)?f.links.length:0,f;if(D.current?.detailId===a){o=`inflight`;let e=r(),t=await D.current.promise;return c=Number((r()-e).toFixed(1)),l=!!t,u=Array.isArray(t?.links)?t.links.length:0,t}if(h.has(a)){o=`shared-inflight`;let e=r(),t=await h.get(a);return c=Number((r()-e).toFixed(1)),l=!!t,u=Array.isArray(t?.links)?t.links.length:0,t&&(E.current={detailId:a,information:t}),t}o=`network`;let p=r(),g=n({id:a}).then(e=>{let t=x(e);if(t)return E.current={detailId:a,information:t},m.set(a,t),t});D.current={detailId:a,promise:g},h.set(a,g);try{let e=await g;return c=Number((r()-p).toFixed(1)),l=!!e,u=Array.isArray(e?.links)?e.links.length:0,e||(o=`network-empty`),e}catch(e){throw s=!0,e}finally{let e=Number((r()-i).toFixed(1));console.warn(`[webview bridge] fetchVideoDetailInformation timing:`,JSON.stringify({status:s?`error`:`success`,detailId:a,source:o,hasInformation:l,episodeCnt:u,requestMs:c,totalMs:e,invocationWallStartMs:t,invocationWallStartTime:new Date(t).toISOString()})),D.current?.detailId===a&&(D.current=null),h.get(a)===g&&h.delete(a)}},[w]),j=l(async t=>{let n=String(t||``).trim();if(!n)return``;let r=O.current.get(n);if(r)return r;let a=k.current.get(n);if(a)return await a;let o=(async()=>{try{let t=await e(n);if(!t)return``;let r=i(t.bytes);return O.current.delete(n),O.current.set(n,r),b(O.current),r}catch(e){return console.warn(`[webview bridge] getVideoInfoAsync poster failed:`,e),``}finally{k.current.delete(n)}})();return k.current.set(n,o),await o},[]),M=l(async e=>{let t=String(e||``).trim();if(!t)return``;let n=j(t),r,i=new Promise(e=>{r=setTimeout(()=>{e(``)},150)}),a=await Promise.race([n,i]);return r!==void 0&&clearTimeout(r),a},[j]),N=l(async()=>{let e=Date.now(),t=()=>typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now(),n=[],r=e=>{n.push({stage:e,at:t(),wallAtMs:Date.now()})},i=e=>e<=0||e>=n.length?0:Number((n[e].at-n[e-1].at).toFixed(1));r(`start`);let s=``,c=1,l=``,u=0,d=`empty-url`,f=0,p=0,m=0,h=0,g=!1;try{let e;for(let t=0;t<2;t++){u+=1;let t=y();if(e=await A(t.detailId),y().detailId===t.detailId)break}r(`detail-ready`);let t=y(),n=a(Array.isArray(e?.links)?e.links:[],t.currentSeriesNum);r(`m3u8-ready`);let i=n[0]?await o(n[0]):``;r(`src-ready`);let g=e?.name||``,_=String(t.detailId||``).trim(),v=t.currentSeriesNum,b=String(e?.img_y||e?.img_x||e?.preview_images?.[0]||``).trim(),x=await M(b);return r(`poster-ready`),b&&(d=x?`resolved`:`timeout-or-empty`),f=b.length,p=x.length,h=i.length,s=_,c=v,l=g,m=0,{poster:``,src:i,title:g,contentId:_,episode:v}}catch(e){throw g=!0,e}finally{let r=t(),a=n[0]?.at??r,o=n.map((e,t)=>t===0?null:{stage:n[t].stage,costMs:i(t)}).filter(Boolean),_=n.map(e=>({stage:e.stage,offsetMs:Number((e.at-a).toFixed(1)),wallTime:new Date(e.wallAtMs).toISOString()})),v=Number((r-a).toFixed(1));console.warn(`[webview bridge] getVideoInfoAsync timing:`,JSON.stringify({status:g?`error`:`success`,invocationWallStartMs:e,invocationWallStartTime:new Date(e).toISOString(),detailId:s,seriesNum:c,title:l,detailFetchAttempts:u,posterStatus:d,posterUrlLength:f,resolvedPosterLength:p,returnedPosterLength:m,srcLength:h,phases:o,timeline:_,totalMs:v}))}},[A,M]),P=l(async()=>{if(!t.getState().isLogin)return null;let e=y();if(!e.detailId)return null;let n=await c([e.detailId],1);return n?.interaction_list?.[0]?n.interaction_list[0].browse_record:null},[]),F=l(async e=>{if(!t.getState().isLogin)return;let n=y();if(!n.detailId)return;let i=e.browse_episode||n.currentSeriesNum,a=Date.now(),o=String(e.browse_key||a);try{await r({app_id:0,content_type:1,content_id:n.detailId,browse_duration:Number(e.browse_duration||0),browse_episode:String(i),browse_key:o,browse_page_ts:a})}catch(e){console.error(`上报播放进度失败:`,e)}},[]),I=l(()=>{let e=s.getState(),t=!!e.isOpen,n=g();return!t&&!n?!0:(t&&e.close(),n&&_(),!1)},[]);u(()=>{if(!C||typeof window>`u`)return;let e=window;return e.getVideoInfoAsync=N,e.getVideoBrowseRecordAsync=P,e.reportVideoProgress=F,e.guardWebViewNavigation=I,()=>{e.getVideoInfoAsync===N&&delete e.getVideoInfoAsync,e.getVideoBrowseRecordAsync===P&&delete e.getVideoBrowseRecordAsync,e.reportVideoProgress===F&&delete e.reportVideoProgress,e.guardWebViewNavigation===I&&delete e.guardWebViewNavigation}},[P,N,I,C,F])}export{C as useVideoDetailWebViewBridge};
2
+ "use client";import{decryptImageToUint8Array as e}from"../../../../../utils/decrypt-image-client.mjs";import{useUserStore as t}from"../../../../../store/modules/user-store.mjs";import{gContentGetVideoDetail as n,pInteractionBrowse as r}from"../../../../../service/generated/client.mjs";import{uint8ArrayToBase64 as i}from"../../../../../utils/uint8.mjs";import{resolveM3u8Urls as a,resolveVideoPlayerSrc as o}from"../../../../common/video-player/process-m3u8-cache.mjs";import{useLoginModalStore as s}from"../../../../../store/modules/login-modal-store.mjs";import{batchQueryContentInteractions as c}from"../../../../../hooks/use-content-operate.mjs";import{useCallback as l,useEffect as u,useRef as d}from"react";import{usePathname as f}from"next/navigation";import{useQueryClient as p}from"@tanstack/react-query";const m=new Map,h=new Map;function g(){if(typeof window>`u`)return!1;let e={open:!1};return window.dispatchEvent(new CustomEvent(`funhub:detail-series-popup-query`,{detail:e})),!!e.open}function _(){typeof window>`u`||window.dispatchEvent(new Event(`funhub:detail-series-popup-close`))}function v(e){let t=Math.floor(Number(e)||1);return t>0?t:1}function y(e){let t=typeof e==`string`?e:typeof window>`u`?``:window.location.pathname,n=String(t||``).split(`/`).filter(Boolean),r=n.findIndex(e=>e===`video`||e===`webview`);if(r<0)return{detailId:``,currentSeriesNum:1,episodeIndex:0};let i=n[r+1]||``;try{let e=decodeURIComponent(i),t=n.slice(r+1),a=t.findIndex(e=>e===`episode`),o=v(a>=0?t[a+1]:t[2]);return{detailId:e,currentSeriesNum:o,episodeIndex:Math.max(0,o-1)}}catch{let e=n.slice(r+1),t=e.findIndex(e=>e===`episode`),a=v(t>=0?e[t+1]:e[2]);return{detailId:i,currentSeriesNum:a,episodeIndex:Math.max(0,a-1)}}}function b(e){for(;e.size>5;){let t=e.keys().next().value;if(!t)break;e.delete(t)}}function x(e){let t=e,n=t?.data?.video||t?.video||t;if(!(!n||typeof n!=`object`))return{...n,content_type:1,episode_cnt:n.links?.length||0}}function S(e){let t=String(e||``).trim();return t?[[`video-detail`,t]]:[]}function C(v){let{enabled:C=!0}=v,w=p(),T=y(f()).detailId,E=d({detailId:``}),D=d(null),O=d(new Map),k=d(new Map);u(()=>{E.current={detailId:T},D.current=null},[T]);let A=l(async e=>{let t=String(e||``).trim();if(!t)return;if(E.current.detailId===t&&E.current.information)return E.current.information;let r=m.get(t);if(r)return E.current={detailId:t,information:r},r;let i=S(t).map(e=>w.getQueryData(e)).map(x).find(Boolean);if(i)return E.current={detailId:t,information:i},m.set(t,i),i;if(D.current?.detailId===t)return await D.current.promise;if(h.has(t)){let e=await h.get(t);return e&&(E.current={detailId:t,information:e}),e}let a=n({id:t}).then(e=>{let n=x(e);if(n)return E.current={detailId:t,information:n},m.set(t,n),n});D.current={detailId:t,promise:a},h.set(t,a);try{return await a}finally{D.current?.detailId===t&&(D.current=null),h.get(t)===a&&h.delete(t)}},[w]),j=l(async t=>{let n=String(t||``).trim();if(!n)return``;let r=O.current.get(n);if(r)return r;let a=k.current.get(n);if(a)return await a;let o=(async()=>{try{let t=await e(n);if(!t)return``;let r=i(t.bytes);return O.current.delete(n),O.current.set(n,r),b(O.current),r}catch{return``}finally{k.current.delete(n)}})();return k.current.set(n,o),await o},[]),M=l(async e=>{let t=String(e||``).trim();if(!t)return``;let n=j(t),r,i=new Promise(e=>{r=setTimeout(()=>{e(``)},150)}),a=await Promise.race([n,i]);return r!==void 0&&clearTimeout(r),a},[j]),N=l(async()=>{let e;for(let t=0;t<2;t++){let t=y();if(e=await A(t.detailId),y().detailId===t.detailId)break}let t=y(),n=a(Array.isArray(e?.links)?e.links:[],t.currentSeriesNum),r=n[0]?await o(n[0]):``,i=e?.name||``,s=String(t.detailId||``).trim(),c=t.currentSeriesNum;return{poster:await M(String(e?.img_y||e?.img_x||e?.preview_images?.[0]||``).trim()),src:r,title:i,contentId:s,episode:c}},[A,M]),P=l(async()=>{if(!t.getState().isLogin)return null;let e=y();if(!e.detailId)return null;let n=await c([e.detailId],1);return n?.interaction_list?.[0]?n.interaction_list[0].browse_record:null},[]),F=l(async e=>{if(!t.getState().isLogin)return;let n=y();if(!n.detailId)return;let i=e.browse_episode||n.currentSeriesNum,a=Date.now(),o=String(e.browse_key||a);try{await r({app_id:0,content_type:1,content_id:n.detailId,browse_duration:Number(e.browse_duration||0),browse_episode:String(i),browse_key:o,browse_page_ts:a})}catch{console.error(`上报播放进度失败`)}},[]),I=l(()=>{let e=s.getState(),t=!!e.isOpen,n=g();return!t&&!n?!0:(t&&e.close(),n&&_(),!1)},[]);u(()=>{if(!C||typeof window>`u`)return;let e=window;return e.getVideoInfoAsync=N,e.getVideoBrowseRecordAsync=P,e.reportVideoProgress=F,e.guardWebViewNavigation=I,()=>{e.getVideoInfoAsync===N&&delete e.getVideoInfoAsync,e.getVideoBrowseRecordAsync===P&&delete e.getVideoBrowseRecordAsync,e.reportVideoProgress===F&&delete e.reportVideoProgress,e.guardWebViewNavigation===I&&delete e.guardWebViewNavigation}},[P,N,I,C,F])}export{C as useVideoDetailWebViewBridge};
@@ -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?: "link" | "default" | "destructive" | "secondary" | "outline" | "ghost" | null | undefined;
9
+ variant?: "default" | "link" | "destructive" | "secondary" | "outline" | "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?: "link" | "default" | "destructive" | "secondary" | "outline" | "ghost" | null | undefined;
10
+ variant?: "default" | "link" | "destructive" | "secondary" | "outline" | "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 组件属性。 */
@@ -6,10 +6,10 @@ type InspectorFieldOption<T> = Omit<T, 'type'>;
6
6
  declare const stringInspectorFieldSchema: z.ZodObject<{
7
7
  type: z.ZodLiteral<"string">;
8
8
  fieldType: z.ZodOptional<z.ZodEnum<{
9
- select: "select";
10
9
  input: "input";
11
10
  textarea: "textarea";
12
11
  color: "color";
12
+ select: "select";
13
13
  }>>;
14
14
  defaultValue: z.ZodOptional<z.ZodString>;
15
15
  label: z.ZodOptional<z.ZodString>;
@@ -68,10 +68,10 @@ type ObjectInspectorFieldOption = InspectorFieldOption<z.infer<typeof objectInsp
68
68
  declare const componentInspectorFieldMetaSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
69
69
  type: z.ZodLiteral<"string">;
70
70
  fieldType: z.ZodOptional<z.ZodEnum<{
71
- select: "select";
72
71
  input: "input";
73
72
  textarea: "textarea";
74
73
  color: "color";
74
+ select: "select";
75
75
  }>>;
76
76
  defaultValue: z.ZodOptional<z.ZodString>;
77
77
  label: z.ZodOptional<z.ZodString>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@funhub/platform",
3
3
  "type": "module",
4
- "version": "0.1.158",
4
+ "version": "0.1.159",
5
5
  "private": false,
6
6
  "sideEffects": [
7
7
  "**/*.css"