UNPKG

vue-bilibili-embed-renderer

Version:

It is better to use Bilibili's embed renderer component for Vue applications

2 lines (1 loc) 1.97 kB
(function(n,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(n=typeof globalThis!="undefined"?globalThis:n||self,t(n.BilibiliEmbedRenderer={},n.Vue))})(this,function(n,t){"use strict";const p=(i,e,l,r)=>e||(typeof i=="number"?i*r/l:typeof i=="string"&&i.search("px")!==-1?Number(i.replace("px",""))*r/l:typeof i=="string"&&i==="100%"?"100%":360),d=!!(typeof window!="undefined"&&window.document&&window.document.createElement),h=["width","height","src"],m="//player.bilibili.com/player.html",o=t.defineComponent({inheritAttrs:!1,__name:"core",props:{aid:{},bvid:{},page:{default:1},isWide:{type:Boolean,default:!0},highQuality:{type:Boolean,default:!0},hasDanmaku:{type:Boolean,default:!1},aspectWidth:{},aspectHeight:{},width:{default:480},height:{},iframeClass:{default:""}},setup(i){const e=i;if(!e.aid&&!e.bvid)throw new Error("Either aid or bvid must be provided");const l=d?4:16,r=d?3:9,u=e.aspectWidth||l,g=e.aspectHeight||r,y=p(e.width,e.height,u,g),w=e.highQuality?1:0,B=e.isWide?1:0,_=e.hasDanmaku?1:0,E=t.computed(()=>{let s=`${m}?`;return e.bvid?s+=`bvid=${e.bvid}`:s+=`aid=${e.aid}`,s+=`&page=${e.page}&high_quality=${w}&as_wide=${B}&danmaku=${_}`,s}),a=t.useAttrs(),A=t.computed(()=>{const s=[e.iframeClass];if(typeof a.class=="string")s.push(a.class);else if(Array.isArray(a.class))s.push(...a.class);else if(a.class&&typeof a.class=="object"){const c=a.class;Object.keys(c).forEach(f=>{c[f]&&s.push(f)})}return s.filter(Boolean).join(" ")||void 0}),{width:$}=e;return(s,c)=>(t.openBlock(),t.createElementBlock("iframe",t.mergeProps({width:t.unref($),height:t.unref(y),src:E.value,allowFullScreen:!0,class:A.value},s.$attrs),null,16,h))}});var b={install:i=>{i.component("BilibiliEmbedRenderer",o)},BilibiliEmbedRenderer:o};n.BilibiliEmbedRenderer=o,n.default=b,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});