10 lines
121 KiB
JavaScript
Raw Normal View History

/*!
* This source file is part of the Swift.org open source project
*
* Copyright (c) 2021 Apple Inc. and the Swift project authors
* Licensed under Apache License v2.0 with Runtime Library Exception
*
* See https://swift.org/LICENSE.txt for license information
* See https://swift.org/CONTRIBUTORS.txt for Swift project authors
*/
(self["webpackChunkswift_docc_render"]=self["webpackChunkswift_docc_render"]||[]).push([[866],{4655:function(e,t,n){"use strict";n.d(t,{Z:function(){return F}});var r,i,s=function(){var e=this,t=e._self._c;return t("div",{staticClass:"asset"},[t(e.assetComponent,e._g(e._b({tag:"component"},"component",e.assetProps,!1),e.assetListeners))],1)},a=[],o=n(6769),l=function(){var e=this,t=e._self._c;return t("ConditionalWrapper",{ref:"wrapper",attrs:{tag:e.DeviceFrameComponent,"should-wrap":!!e.deviceFrame,device:e.deviceFrame}},[t("div",[t("video",{key:e.videoAttributes.url,ref:"video",attrs:{id:e.id,controls:e.showsDefaultControls,"data-orientation":e.orientation,autoplay:e.autoplays,poster:e.normalisedPosterPath,width:e.optimalWidth,"aria-roledescription":e.$t("video.title"),"aria-labelledby":e.showsDefaultControls&&e.alt?e.altTextId:null,playsinline:""},domProps:{muted:e.muted},on:{loadedmetadata:e.setOrientation,playing:function(t){return e.$emit("playing")},pause:function(t){return e.$emit("pause")},ended:function(t){return e.$emit("ended")}}},[t("source",{attrs:{src:e.normalizePath(e.videoAttributes.url)}})]),e.alt?t("span",{attrs:{id:e.altTextId,hidden:""}},[e._v(" "+e._s(e.$t("video.description",{alt:e.alt}))+" ")]):e._e()])])},c=[],u=n(5947),d=n(4030),A=n(9804),p={functional:!0,name:"ConditionalWrapper",props:{tag:[Object,String],shouldWrap:Boolean},render(e,t){return t.props.shouldWrap?e(t.props.tag,t.data,t.children):t.children}},h=p,g=n(1001),f=(0,g.Z)(h,r,i,!1,null,null,null),m=f.exports,v=n(889),b={name:"VideoAsset",components:{ConditionalWrapper:m},props:{variants:{type:Array,required:!0},showsDefaultControls:{type:Boolean,default:()=>!1},autoplays:{type:Boolean,default:()=>!1},posterVariants:{type:Array,required:!1,default:()=>[]},muted:{type:Boolean,default:!1},deviceFrame:{type:String,required:!1},alt:{type:String,required:!1},id:{type:String,required:!0}},data:()=>({appState:d["default"].state,optimalWidth:null,orientation:null}),computed:{DeviceFrameComponent:()=>v.Z,preferredColorScheme:({appState:e})=>e.preferredColorScheme,systemColorScheme:({appState:e})=>e.systemColorScheme,altTextId:({id:e})=>`${e}-alt`,userPrefersDark:({preferredColorScheme:e,systemColorScheme:t})=>e===A.Z.dark||e===A.Z.auto&&t===A.Z.dark,shouldShowDarkVariant:({darkVideoVariantAttributes:e,userPrefersDark:t})=>e&&t,defaultVideoAttributes(){return this.videoVariantsGroupedByAppearance.light[0]||this.darkVideoVariantAttributes||{}},darkVideoVariantAttributes(){return this.videoVariantsGroupedByAppearance.dark[0]},videoVariantsGroupedByAppearance(){return(0,u.XV)(this.variants)},posterVariantsGroupedByAppearance(){const{light:e,dark:t}=(0,u.XV)(this.posterVariants);return{light:(0,u.u)(e),dark:(0,u.u)(t)}},defaultPosterAttributes:({posterVariantsGroupedByAppearance:e,userPrefersDark:t})=>t&&e.dark.length?e.dark[0]:e.light[0]||{},normalisedPosterPath:({defaultPosterAttributes:e})=>(0,u.AH)(e.src),videoAttributes:({darkVideoVariantAttributes:e,defaultVideoAttributes:t,shouldShowDarkVariant:n})=>n?e:t},watch:{normalisedPosterPath:{immediate:!0,handler:"getPosterDimensions"}},methods:{normalizePath:u.AH,async getPosterDimensions(e){if(!e)return void(this.optimalWidth=null);const{density:t}=this.defaultPosterAttributes,n=parseInt(t.match(/\d+/)[0],10),{width:r}=await(0,u.RY)(e);this.optimalWidth=r/n},setOrientation(){const{videoWidth:e,videoHeight:t}=this.$refs.video;this.orientation=(0,u.T8)(e,t)}}},y=b,C=(0,g.Z)(y,l,c,!1,null,null,null),I=C.exports,w=function(){var e=this,t=e._self._c;return t("div",{staticClass:"video-replay-container",attrs:{role:"group","aria-roledescription":e.$t("video.title"),"aria-labelledby":e.showsDefaultControls?null:e.ariaLabelledByContainer}},[t("span",{attrs:{id:`${e.id}-custom-controls`,hidden:""}},[e._v(" "+e._s(e.$t("video.custom-controls"))+" ")]),t("VideoAsset",{ref:"asset",attrs:{variants:e.variants,autoplays:e.autoplays,showsDefaultControls:e.showsDefaultControls,muted:e.muted,posterVariants:e.posterVariants,deviceFrame:e.deviceFrame,alt:e.alt,id:e.id},on:{pause:e.onPause,playing:e.onVideoPlaying,ende