@funhub/platform 0.2.1-beta.1 → 0.2.1-beta.2

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
- import{getCookie as e}from"../../../../utils/common.mjs";import{getOrCreateDeviceId as t}from"../../../../utils/device-id.mjs";const n=process.env.NEXT_PUBLIC_APP_CODE||`APP001`;async function r(n){let r=n.userId??await e(`userId`),i=n.deviceId??t();return{...n,userId:r||void 0,deviceId:i||void 0}}function i(e){return e?.trim()||n}function a(e){let t=e?.adExtData;if(!t)return{};try{let e=JSON.parse(t);return typeof e==`object`&&e?e:{}}catch{return{}}}function o(e){return[...e??[]].sort((e,t)=>Number(e?.sort??0)-Number(t?.sort??0))}function s(e){return!!(e?.hit&&Array.isArray(e.materials)&&e.materials.length>0)}function c(e){return o(e?.materials).find(e=>!!(e?.advertiseIcon&&e?.advertiseUrl))}function l(e){let t=c(e);if(t)return{materialUrl:t.advertiseIcon||``,jumpUrl:t.advertiseUrl||``,name:t.advertiseName||``}}function u(e){let t=o(e?.materials).filter(e=>e.advertiseIcon&&e.advertiseUrl).map(e=>({title:a(e).title||e.advertiseName||``,icon:e.advertiseIcon||``,jumpUrl:e.advertiseUrl||``,badgeText:`广告`})).filter(e=>e.title&&e.icon&&e.jumpUrl);return{displayCount:m(e?.config,t.length),items:t}}function d(e){let t=o(e?.materials).map(e=>({text:e.advertiseName||e.advertiseDesc||``,jumpUrl:e.advertiseUrl||``})).filter(e=>e.text);return{displayCount:m(e?.config,t.length),items:t}}function f(e){let t=o(e?.materials).filter(e=>e.advertiseIcon&&e.advertiseUrl),n=t.map(e=>{let t=a(e);return{coverUrl:e.advertiseIcon||``,jumpUrl:e.advertiseUrl||``,title:t.title||e.advertiseName||``}}).filter(e=>e.coverUrl&&e.jumpUrl);return{displayCount:m(e?.config,n.length),switchInterval:h(e?.config,t),styleSize:g(e?.config,t),items:n}}function p(e){return o(e?.materials).map(e=>{let t=a(e);return{id:e.advertiseCode||``,title:t.title||e.advertiseName||``,jumpUrl:e.advertiseUrl||``,materialUrl:e.advertiseIcon||``,desc:e.advertiseDesc||``}}).filter(e=>e.id&&e.materialUrl&&e.jumpUrl)}function m(e,t=0){let n=Number(e?.displayCount??t);return!Number.isFinite(n)||n<=0?t:Math.min(Math.floor(n),t)}function h(e,t){let n=a(t?.[0]),r=Number(e?.switchInterval??n.switchInterval??3e3);return!Number.isFinite(r)||r<=0?3e3:r}function g(e,t){let n=a(t?.[0]),r=String(e?.styleSize??n.styleSize??`large`);return r===`small`||r===`medium`||r===`large`?r:`large`}export{f as adaptBannerAdProps,l as adaptFloatingAdItem,u as adaptIconAdProps,p as adaptPopupAdMaterials,d as adaptTextAdProps,r as buildAdsMatchRequest,c as getFirstMatchedMaterial,s as hasMatchedAds,a as parseAdsMatchExtData,i as resolveAdsAppCode,o as sortAdsMatchMaterials};
2
+ import{getCookie as e}from"../../../../utils/common.mjs";import{getOrCreateDeviceId as t}from"../../../../utils/device-id.mjs";const n=process.env.NEXT_PUBLIC_APP_CODE||`APP001`;async function r(n){let r=n.userId??await e(`userId`),i=n.deviceId??t();return{...n,userId:r||void 0,deviceId:i||void 0}}function i(e){return e?.trim()||n}function a(e){let t=e?.adExtData;if(!t)return{};try{let e=JSON.parse(t);return typeof e==`object`&&e?e:{}}catch{return{}}}function o(e){return[...e??[]].sort((e,t)=>Number(e?.sort??0)-Number(t?.sort??0))}function s(e){return!!(e?.hit&&Array.isArray(e.materials)&&e.materials.length>0)}function c(e){return o(e?.materials).find(e=>!!(e?.advertiseIcon&&e?.advertiseUrl))}function l(e){let t=c(e);if(t)return{materialUrl:t.advertiseIcon||``,jumpUrl:t.advertiseUrl||``,name:t.advertiseName||``}}function u(e){let t=o(e?.materials).filter(e=>e.advertiseIcon&&e.advertiseUrl).map(e=>({title:a(e).title||e.advertiseName||``,icon:e.advertiseIcon||``,jumpUrl:e.advertiseUrl||``,badgeText:`广告`})).filter(e=>e.title&&e.icon&&e.jumpUrl);return{displayCount:m(e?.config,t.length),items:t}}function d(e){let t=o(e?.materials).map(e=>({text:e.advertiseName||e.advertiseDesc||``,jumpUrl:e.advertiseUrl||``})).filter(e=>e.text);return{displayCount:m(e?.config,t.length),items:t}}function f(e){let t=o(e?.materials).filter(e=>e.advertiseIcon&&e.advertiseUrl),n=t.map(e=>{let t=a(e);return{coverUrl:e.advertiseIcon||``,jumpUrl:e.advertiseUrl||``,title:t.title||e.advertiseName||``}}).filter(e=>e.coverUrl&&e.jumpUrl);return{displayCount:m(e?.config,n.length),switchInterval:h(e?.config,t),styleSize:g(e?.config,t),items:n}}function p(e){return o(e?.materials).map(e=>{let t=a(e);return{id:e.advertiseCode||``,title:t.title||e.advertiseName||``,jumpUrl:e.advertiseUrl||``,materialUrl:e.advertiseIcon||``,desc:e.advertiseDesc||``}}).filter(e=>e.id&&e.materialUrl&&e.jumpUrl)}function m(e,t=0){let n=Number(e?.displayCount??t);return!Number.isFinite(n)||n<=0?t:Math.min(Math.floor(n),t)}function h(e,t){let n=a(t?.[0]),r=Number(e?.switchInterval??n.switchInterval??3e3);return!Number.isFinite(r)||r<=0?3e3:r}function g(e,t){let n=a(t?.[0]),r=String(e?.styleSize??n.styleSize??`large`);return r===`700x400`||r===`700x200`||r===`720x150`||r===`720x300`?r:r===`small`?`720x150`:r===`medium`?`700x200`:`700x400`}export{f as adaptBannerAdProps,l as adaptFloatingAdItem,u as adaptIconAdProps,p as adaptPopupAdMaterials,d as adaptTextAdProps,r as buildAdsMatchRequest,c as getFirstMatchedMaterial,s as hasMatchedAds,a as parseAdsMatchExtData,i as resolveAdsAppCode,o as sortAdsMatchMaterials};
@@ -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{Carousel as n,CarouselContent as r,CarouselItem as i}from"../../../../ui/carousel.mjs";import{Text as a}from"../../../../ui/text.mjs";import o from"../../../../ui/link.mjs";import{adaptBannerAdProps as s,hasMatchedAds as c}from"../ad-match.mjs";import{useAdProvider as l}from"../ad-provider.mjs";import{bannerAdInspectorDefaultProps as u}from"./schema.mjs";import d from"clsx";import{useEffect as f,useMemo as p,useRef as m,useState as h}from"react";import{jsx as g,jsxs as _}from"react/jsx-runtime";const v={small:{minHeight:`140px`,aspectRatio:`2.3 / 1`},medium:{minHeight:`180px`,aspectRatio:`2 / 1`},large:{aspectRatio:`7 / 4`}};function y(e,t){return Array.isArray(e)&&e.length>0?e:t??[]}function b(e,t){return typeof e==`number`&&e>0?e:t}function x(e,t){return typeof e==`number`&&e>0?e:t}function S(e,t){return e??t}function C({mode:C=`renderer`,displayCount:w,switchInterval:T=3e3,styleSize:E=`large`,items:D,pointerEventsDisabled:O=!1}){let k=C===`editor`?{displayCount:b(w,u.displayCount),switchInterval:x(T,u.switchInterval),styleSize:S(E,u.styleSize),items:y(D,u.items)}:{displayCount:w,switchInterval:T,styleSize:E,items:D},A=l(),j=p(()=>c(A?.matchData)?s(A?.matchData):{displayCount:k.displayCount,switchInterval:k.switchInterval,styleSize:k.styleSize,items:k.items},[A?.matchData,k.displayCount,k.items,k.styleSize,k.switchInterval]),[M,N]=h(),[P,F]=h(0),I=m(null),L=p(()=>typeof j.displayCount==`number`?j.items.slice(0,Math.max(j.displayCount,0)):j.items,[j]);if(f(()=>{if(!M||L.length<=1)return;let e=()=>{F(M.selectedScrollSnap())};return M.on(`select`,e),e(),()=>{M.off(`select`,e)}},[M,L.length]),f(()=>{if(!(!M||L.length<=1))return I.current=setInterval(()=>{if(M.canScrollNext()){M.scrollNext();return}M.scrollTo(0)},j.switchInterval??3e3),()=>{I.current&&=(clearInterval(I.current),null)}},[M,j.switchInterval,L.length]),L.length===0)return null;let R=j.styleSize??`large`,z=v[R];return g(t,{as:`section`,className:`w-full px-[12px] py-[12px]`,"aria-label":`Banner 广告`,style:{pointerEvents:O?`none`:void 0},children:_(n,{setApi:N,opts:{align:`start`,loop:L.length>1},className:`w-full`,children:[g(r,{className:`ml-0`,children:L.map((n,r)=>g(i,{className:`pl-0`,children:_(o,{href:n.jumpUrl,className:d(`relative block w-full overflow-hidden bg-white`),style:{minHeight:z.minHeight,aspectRatio:z.aspectRatio,borderRadius:`10px`},children:[g(t,{className:`absolute inset-0`,children:g(e,{src:n.coverUrl,alt:n.title||`Banner 广告`,fill:!0,className:`object-cover object-center`,unoptimized:!0})}),g(t,{className:`absolute inset-x-0 bottom-0`,style:{height:`28%`,background:`linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.8) 100%)`,opacity:.84}}),g(t,{className:`absolute right-0 top-0 overflow-hidden`,style:{width:`56px`,height:`25px`,backgroundColor:`rgba(255, 255, 255, 0.16)`,borderBottomLeftRadius:`8px`},children:g(a,{className:`flex h-full items-center justify-center text-white`,style:{fontSize:`12px`,lineHeight:`normal`,fontWeight:400},children:`广告`})}),n.title?g(a,{className:`absolute line-clamp-2 text-white`,style:{left:`16px`,bottom:`16px`,maxWidth:`calc(100% - 120px)`,fontSize:R===`large`?`14px`:R===`medium`?`26px`:`20px`,lineHeight:`normal`,fontWeight:500},children:n.title}):null]})},`${n.jumpUrl}-${r}`))}),L.length>1?g(t,{className:`pointer-events-none absolute bottom-[18px] right-[16px] z-10 flex items-center gap-[6px]`,children:L.map((e,n)=>g(t,{className:`rounded-full transition-all duration-300`,style:{width:n===P?`16px`:`8px`,height:`8px`,backgroundColor:n===P?`#FFFFFF`:`rgba(255, 255, 255, 0.78)`}},n))}):null]})})}export{C as BannerAd};
2
+ "use client";import{Image as e}from"../../../../ui/image.mjs";import{Box as t}from"../../../../ui/box.mjs";import{Carousel as n,CarouselContent as r,CarouselItem as i}from"../../../../ui/carousel.mjs";import{Text as a}from"../../../../ui/text.mjs";import o from"../../../../ui/link.mjs";import{adaptBannerAdProps as s,hasMatchedAds as c}from"../ad-match.mjs";import{useAdProvider as l}from"../ad-provider.mjs";import{bannerAdInspectorDefaultProps as u}from"./schema.mjs";import d from"clsx";import{useEffect as f,useMemo as p,useRef as m,useState as h}from"react";import{jsx as g,jsxs as _}from"react/jsx-runtime";const v={"700x400":{minHeight:`400px`,aspectRatio:`7 / 4`,titleFontSize:`14px`},"700x200":{minHeight:`200px`,aspectRatio:`7 / 2`,titleFontSize:`14px`},"720x150":{minHeight:`150px`,aspectRatio:`24 / 5`,titleFontSize:`12px`},"720x300":{minHeight:`300px`,aspectRatio:`12 / 5`,titleFontSize:`14px`}};function y(e,t){return Array.isArray(e)&&e.length>0?e:t??[]}function b(e,t){return typeof e==`number`&&e>0?e:t}function x(e,t){return typeof e==`number`&&e>0?e:t}function S(e,t){return e??t}function C({mode:C=`renderer`,displayCount:w,switchInterval:T=3e3,styleSize:E=`700x400`,items:D,pointerEventsDisabled:O=!1}){let k=C===`editor`?{displayCount:b(w,u.displayCount),switchInterval:x(T,u.switchInterval),styleSize:S(E,u.styleSize),items:y(D,u.items)}:{displayCount:w,switchInterval:T,styleSize:E,items:D},A=l(),j=p(()=>c(A?.matchData)?s(A?.matchData):{displayCount:k.displayCount,switchInterval:k.switchInterval,styleSize:k.styleSize,items:k.items},[A?.matchData,k.displayCount,k.items,k.styleSize,k.switchInterval]),[M,N]=h(),[P,F]=h(0),I=m(null),L=p(()=>typeof j.displayCount==`number`?j.items.slice(0,Math.max(j.displayCount,0)):j.items,[j]);if(f(()=>{if(!M||L.length<=1)return;let e=()=>{F(M.selectedScrollSnap())};return M.on(`select`,e),e(),()=>{M.off(`select`,e)}},[M,L.length]),f(()=>{if(!(!M||L.length<=1))return I.current=setInterval(()=>{if(M.canScrollNext()){M.scrollNext();return}M.scrollTo(0)},j.switchInterval??3e3),()=>{I.current&&=(clearInterval(I.current),null)}},[M,j.switchInterval,L.length]),L.length===0)return null;let R=v[j.styleSize??`700x400`];return g(t,{as:`section`,className:`w-full px-[12px] py-[12px]`,"aria-label":`Banner 广告`,style:{pointerEvents:O?`none`:void 0},children:_(n,{setApi:N,opts:{align:`start`,loop:L.length>1},className:`w-full`,children:[g(r,{className:`ml-0`,children:L.map((n,r)=>g(i,{className:`pl-0`,children:_(o,{href:n.jumpUrl,className:d(`relative block w-full overflow-hidden bg-white`),style:{minHeight:R.minHeight,aspectRatio:R.aspectRatio,borderRadius:`10px`},children:[g(t,{className:`absolute inset-0`,children:g(e,{src:n.coverUrl,alt:n.title||`Banner 广告`,fill:!0,className:`object-cover object-center`,unoptimized:!0})}),g(t,{className:`absolute inset-x-0 bottom-0`,style:{height:`28%`,background:`linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.8) 100%)`,opacity:.84}}),g(t,{className:`absolute right-0 top-0 overflow-hidden`,style:{width:`56px`,height:`25px`,backgroundColor:`rgba(255, 255, 255, 0.16)`,borderBottomLeftRadius:`8px`},children:g(a,{className:`flex h-full items-center justify-center text-white`,style:{fontSize:`12px`,lineHeight:`normal`,fontWeight:400},children:`广告`})}),n.title?g(a,{className:`absolute line-clamp-2 text-white`,style:{left:`16px`,bottom:`16px`,maxWidth:`calc(100% - 120px)`,fontSize:R.titleFontSize,lineHeight:`normal`,fontWeight:500},children:n.title}):null]})},`${n.jumpUrl}-${r}`))}),L.length>1?g(t,{className:`pointer-events-none absolute bottom-[18px] right-[16px] z-10 flex items-center gap-[6px]`,children:L.map((e,n)=>g(t,{className:`rounded-full transition-all duration-300`,style:{width:n===P?`16px`:`8px`,height:`8px`,backgroundColor:n===P?`#FFFFFF`:`rgba(255, 255, 255, 0.78)`}},n))}):null]})})}export{C as BannerAd};
@@ -14,7 +14,7 @@ import * as zod_v4_core0 from "zod/v4/core";
14
14
  declare const bannerAdMaterial: DefineMaterialOption<typeof BannerAdServer, typeof BannerAd, zod.ZodObject<{
15
15
  readonly displayCount: zod.ZodNumber & SchemaHasDefaultValue;
16
16
  readonly switchInterval: zod.ZodNumber & SchemaHasDefaultValue;
17
- readonly styleSize: zod.ZodType<"medium" | "small" | "large", unknown, zod_v4_core0.$ZodTypeInternals<"medium" | "small" | "large", unknown>> & SchemaHasDefaultValue;
17
+ readonly styleSize: zod.ZodType<"700x400" | "700x200" | "720x150" | "720x300", unknown, zod_v4_core0.$ZodTypeInternals<"700x400" | "700x200" | "720x150" | "720x300", unknown>> & SchemaHasDefaultValue;
18
18
  readonly items: zod.ZodArray<zod.ZodObject<{
19
19
  coverUrl: zod.ZodString & SchemaHasDefaultValue;
20
20
  jumpUrl: zod.ZodString & SchemaHasDefaultValue;
@@ -8,7 +8,7 @@ import z$1 from "zod";
8
8
  /**
9
9
  * Banner 尺寸选项。
10
10
  */
11
- declare const bannerAdStyleSizeOptions: readonly ["small", "medium", "large"];
11
+ declare const bannerAdStyleSizeOptions: readonly ["700x400", "700x200", "720x150", "720x300"];
12
12
  /**
13
13
  * Banner 广告样式尺寸。
14
14
  */
@@ -36,7 +36,7 @@ interface BannerAdItem {
36
36
  declare const bannerAdInspectorPropsSchema: z$1.ZodObject<{
37
37
  readonly displayCount: z$1.ZodNumber & SchemaHasDefaultValue;
38
38
  readonly switchInterval: z$1.ZodNumber & SchemaHasDefaultValue;
39
- readonly styleSize: z$1.ZodType<"medium" | "small" | "large", unknown, z$1.core.$ZodTypeInternals<"medium" | "small" | "large", unknown>> & SchemaHasDefaultValue;
39
+ readonly styleSize: z$1.ZodType<"700x400" | "700x200" | "720x150" | "720x300", unknown, z$1.core.$ZodTypeInternals<"700x400" | "700x200" | "720x150" | "720x300", unknown>> & SchemaHasDefaultValue;
40
40
  readonly items: z$1.ZodArray<z$1.ZodObject<{
41
41
  coverUrl: z$1.ZodString & SchemaHasDefaultValue;
42
42
  jumpUrl: z$1.ZodString & SchemaHasDefaultValue;
@@ -51,7 +51,7 @@ declare const bannerAdInspectorPropsSchema: z$1.ZodObject<{
51
51
  declare const bannerAdInspectorDefaultProps: {
52
52
  readonly displayCount: number;
53
53
  readonly switchInterval: number;
54
- readonly styleSize: "medium" | "small" | "large";
54
+ readonly styleSize: "700x400" | "700x200" | "720x150" | "720x300";
55
55
  readonly items: {
56
56
  coverUrl: string;
57
57
  jumpUrl: string;
@@ -1,2 +1,2 @@
1
1
 
2
- import{defineComponentPropsSchema as e,getSchemaDefaultProps as t}from"../../../../../utils/schema/schema.mjs";import n from"zod";const r=[`small`,`medium`,`large`],i=e(e=>({displayCount:e.number(1,{label:`轮播数量`,required:!0}).refine(e=>e>=1&&e<=5,`轮播数量必须为 1-5`),switchInterval:e.number(3e3,{label:`轮播切换时间`,required:!0}),styleSize:e.enum(r,`large`,{label:`样式尺寸选择`,required:!0}),items:e.array(n.object({coverUrl:e.string(``,{label:`封面图`,required:!0}),jumpUrl:e.string(``,{label:`跳转链接`,required:!0}),title:e.string(`Banner 广告`,{label:`标题`,required:!1})}),{label:`Banner 列表`,required:!0,defaultValue:[{coverUrl:`/static/components-resource/banner.png`,jumpUrl:`/search`,title:`Banner 广告一`},{coverUrl:`/static/components-resource/banner.png`,jumpUrl:`/search`,title:`Banner 广告二`}]})})),a=t(i);export{a as bannerAdInspectorDefaultProps,i as bannerAdInspectorPropsSchema,r as bannerAdStyleSizeOptions};
2
+ import{defineComponentPropsSchema as e,getSchemaDefaultProps as t}from"../../../../../utils/schema/schema.mjs";import n from"zod";const r=[`700x400`,`700x200`,`720x150`,`720x300`],i=e(e=>({displayCount:e.number(1,{label:`轮播数量`,required:!0}).refine(e=>e>=1&&e<=5,`轮播数量必须为 1-5`),switchInterval:e.number(3e3,{label:`轮播切换时间`,required:!0}),styleSize:e.enum(r,`700x400`,{label:`样式尺寸选择`,required:!0}),items:e.array(n.object({coverUrl:e.string(``,{label:`封面图`,required:!0}),jumpUrl:e.string(``,{label:`跳转链接`,required:!0}),title:e.string(`Banner 广告`,{label:`标题`,required:!1})}),{label:`Banner 列表`,required:!0,defaultValue:[{coverUrl:`/static/components-resource/banner.png`,jumpUrl:`/search`,title:`Banner 广告一`},{coverUrl:`/static/components-resource/banner.png`,jumpUrl:`/search`,title:`Banner 广告二`},{coverUrl:`/static/components-resource/banner.png`,jumpUrl:`/search`,title:`Banner 广告三`},{coverUrl:`/static/components-resource/banner.png`,jumpUrl:`/search`,title:`Banner 广告四`},{coverUrl:`/static/components-resource/banner.png`,jumpUrl:`/search`,title:`Banner 广告五`}]})})),a=t(i);export{a as bannerAdInspectorDefaultProps,i as bannerAdInspectorPropsSchema,r as bannerAdStyleSizeOptions};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@funhub/platform",
3
3
  "type": "module",
4
- "version": "0.2.1-beta.1",
4
+ "version": "0.2.1-beta.2",
5
5
  "private": false,
6
6
  "sideEffects": [
7
7
  "**/*.css"