Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
TS-ify Audio components (#1311)
Olga Bulatd434a07a9eec
diff --git a/src/components/VAudioThumbnail/VAudioThumbnail.vue b/src/components/VAudioThumbnail/VAudioThumbnail.vueindex 8ef7cb2ea..a3fe7225e 100644--- a/src/components/VAudioThumbnail/VAudioThumbnail.vue+++ b/src/components/VAudioThumbnail/VAudioThumbnail.vue@@ -27,16 +27,23 @@</div></template>-<script>-import { ref, onMounted, useContext, computed } from '@nuxtjs/composition-api'+<script lang="ts">+import {+ ref,+ onMounted,+ useContext,+ defineComponent,+ PropType,+} from '@nuxtjs/composition-api'import { rand, hash } from '~/utils/prng'-import { lerp, dist, bezier } from '~/utils/math'+import { lerp, dist, bezier, Point } from '~/utils/math'+import type { AudioDetail } from '~/models/media'/*** Displays the cover art for the audio in a square aspect ratio.*/-export default {+export default defineComponent({name: 'VAudioThumbnail',props: {/**@@ -44,28 +51,28 @@ export default {* `thumbnail`, `title` and `creator` are used.*/audio: {- type: Object,+ type: Object as PropType<AudioDetail>,required: true,},},setup(props) {const { i18n } = useContext()- const helpText = computed(() =>- i18n.t('audio-thumbnail.alt', {+ const helpText = i18n+ .t('audio-thumbnail.alt', {title: props.audio.title,creator: props.audio.creator,})- )+ ?.toString()/* Switching */- const imgEl = ref(null)+ const imgEl = ref<HTMLImageElement | null>(null)const isOk = ref(false)const handleLoad = () => {isOk.value = true}onMounted(() => {- isOk.value = imgEl.value.complete && imgEl.value.naturalWidth+ isOk.value = Boolean(imgEl.value?.complete && imgEl.value?.naturalWidth)})/* Artwork */@@ -76,18 +83,18 @@ export default {const maxRadius = 27const random = rand(hash(props.audio.title ?? ''))- const ctrlPts = Array.from({ length: 4 }, (_, idx) => [- random() * canvasSize,- (idx / 3) * canvasSize,- ])+ const ctrlPts = Array.from(+ { length: 4 },+ (_, idx) => [random() * canvasSize, (idx / 3) * canvasSize] as Point+ )const pointCount = dotCount + 1const bezierPoints = bezier(ctrlPts, pointCount)- const offset = (i) => {+ const offset = (i: number) => {return i * (canvasSize / (dotCount + 1))}- const radius = (i, j) => {+ const radius = (i: number, j: number) => {const bezierPoint = bezierPoints[i]const distance = dist([0, bezierPoint], [0, offset(j)])const maxFeasibleDistance = canvasSize * ((dotCount - 1) / (dotCount + 1))@@ -106,5 +113,5 @@ export default {helpText,}},-}+})</script>diff --git a/src/components/VAudioTrack/VAudioTrack.vue b/src/components/VAudioTrack/VAudioTrack.vueindex d67c196c9..070b5a4a8 100644--- a/src/components/VAudioTrack/VAudioTrack.vue+++ b/src/components/VAudioTrack/VAudioTrack.vue@@ -38,7 +38,7 @@</Component></template>-<script>+<script lang="ts">import {computed,defineComponent,@@ -46,6 +46,7 @@ import {watch,onUnmounted,useRoute,+ PropType,} from '@nuxtjs/composition-api'import { useActiveAudio } from '~/composables/use-active-audio'@@ -58,6 +59,14 @@ import { useMediaStore } from '~/stores/media'import { AUDIO } from '~/constants/media'import { keycodes } from '~/constants/key-codes'+import type { AudioDetail } from '~/models/media'+import {+ AudioLayout,+ AudioSize,+ AudioStatus,+ layoutMappings,+} from '~/constants/audio'+import VPlayPause from '~/components/VAudioTrack/VPlayPause.vue'import VWaveform from '~/components/VAudioTrack/VWaveform.vue'import VFullLayout from '~/components/VAudioTrack/layouts/VFullLayout.vue'@@ -67,46 +76,6 @@ import VGlobalLayout from '~/components/VAudioTrack/layouts/VGlobalLayout.vue'import VLink from '~/components/VLink.vue'import VWarningSuppressor from '~/components/VWarningSuppressor.vue'-const propTypes = {- /**- * the information about the track, typically from a track's detail endpoint- */- audio: {- type: /** @type {import('@nuxtjs/composition-api').PropType<import('~/models/media').AudioDetail>} */ (- Object- ),- required: /** @type {true} */ (true),- },- /**- * the arrangement of the contents on the canvas; This determines the- * overall L&F of the audio component.- * @todo This type def should be extracted for reuse across components- */- layout: {- type: /** @type {import('@nuxtjs/composition-api').PropType<'full' | 'box' | 'row' | 'global'>} */ (- String- ),- default: 'full',- /**- * @param {string} val- */- validator: (val) => ['full', 'box', 'row', 'global'].includes(val),- },- /**- * the size of the component; Both 'box' and 'row' layouts offer multiple- * sizes to choose from.- */- size: {- type: /** @type {import('@nuxtjs/composition-api').PropType<'s' | 'm' | 'l'>} */ (- String- ),- /**- * @param {string} val- */- validator: (val) => ['s', 'm', 'l'].includes(val),- },-}-/*** Displays the waveform and basic information about the track, along with* controls to play, pause or seek to a point on the track.@@ -125,14 +94,37 @@ export default defineComponent({VBoxLayout,VGlobalLayout,},- props: propTypes,+ props: {+ /**+ * the information about the track, typically from a track's detail endpoint+ */+ audio: {+ type: Object as PropType<AudioDetail>,+ required: true,+ },+ /**+ * the arrangement of the contents on the canvas; This determines the+ * overall L&F of the audio component.+ */+ layout: {+ type: String as PropType<AudioLayout>,+ default: 'full',+ },+ /**+ * the size of the component; Both 'box' and 'row' layouts offer multiple+ * sizes to choose from.+ */+ size: {+ type: String as PropType<AudioSize>,+ },+ },setup(props) {const activeMediaStore = useActiveMediaStore()const route = useRoute()const activeAudio = useActiveAudio()- const status = ref('paused')+ const status = ref<AudioStatus>('paused')const currentTime = ref(0)const initLocalAudio = () => {@@ -189,9 +181,7 @@ export default defineComponent({* the globally active audio already matches the result* that was clicked on, hijack that object instead and* treat it as the local audio for this instance.- *- * @type {HTMLAudioElement | undefined}- * */+ */let localAudio =activeAudio.obj.value?.src === props.audio.url? activeAudio.obj.value@@ -312,10 +302,7 @@ export default defineComponent({/* Interface with VPlayPause */- /**- * @param {'playing' | 'paused'} [state]- */- const handleToggle = (state) => {+ const handleToggle = (state?: 'playing' | 'paused') => {if (!state) {switch (status.value) {case 'playing':@@ -340,10 +327,7 @@ export default defineComponent({/* Interface with VWaveform */- /**- * @param {number} frac- */- const handleSeeked = (frac) => {+ const handleSeeked = (frac: number) => {if (!localAudio) initLocalAudio()/*** Calling initLocalAudio will guarantee localAudio@@ -352,17 +336,12 @@ export default defineComponent({* hoops (using `assert`) or adding unnecessary* runtime checks.*/- localAudio.currentTime = frac * duration.value+ if (localAudio) {+ localAudio.currentTime = frac * duration.value+ }}/* Layout */-- const layoutMappings = {- full: 'VFullLayout',- row: 'VRowLayout',- box: 'VBoxLayout',- global: 'VGlobalLayout',- }const layoutComponent = computed(() => layoutMappings[props.layout])/**@@ -370,7 +349,7 @@ export default defineComponent({*/const _size = computed(() => {if (isBoxed && !props.size) {- return null+ return undefined}return props.size ?? 'm'})@@ -380,7 +359,7 @@ export default defineComponent({* so we can capture clicks and skip* sending an event to the boxed layout.*/- const playPauseRef = ref(null)+ const playPauseRef = ref<HTMLElement | null>(null)/*** These layout-conditional props and listeners allow us@@ -405,10 +384,8 @@ export default defineComponent({}): i18n.t('audio-track.aria-label', { title: props.audio.title }))- /**- * @param {KeyboardEvent} event- */- const handleKeydown = (event) => {++ const handleKeydown = (event: KeyboardEvent) => {if (!isBoxed.value || event.key !== keycodes.Spacebar) returnevent.preventDefault()status.value = status.value === 'playing' ? 'paused' : 'playing'diff --git a/src/components/VAudioTrack/VGlobalAudioTrack.vue b/src/components/VAudioTrack/VGlobalAudioTrack.vueindex a018f019e..a687a1c98 100644--- a/src/components/VAudioTrack/VGlobalAudioTrack.vue+++ b/src/components/VAudioTrack/VGlobalAudioTrack.vue@@ -1,17 +1,17 @@<template><divclass="audio-track"- :aria-label="$t('audio-track.aria-label')"+ :aria-label="$t('audio-track.aria-label').toString()"role="region">- <Component :is="layoutComponent" :audio="audio" :size="size">+ <VGlobalLayout :audio="audio" size="m"><template #controller="waveformProps"><VWaveformv-bind="waveformProps":peaks="audio.peaks":current-time="currentTime":duration="duration"- :message="message ? $t(`audio-track.messages.${message}`) : null"+ :message="message"@seeked="handleSeeked"@toggle-playback="handleToggle"/>@@ -24,64 +24,32 @@@toggle="handleToggle"/></template>- </Component>+ </VGlobalLayout></div></template>-<script>-import { computed, defineComponent, ref, watch } from '@nuxtjs/composition-api'+<script lang="ts">+import {+ computed,+ defineComponent,+ PropType,+ ref,+ watch,+} from '@nuxtjs/composition-api'import { useActiveAudio } from '~/composables/use-active-audio'import { defaultRef } from '~/composables/default-ref'+import { useI18n } from '~/composables/use-i18n'import { useActiveMediaStore } from '~/stores/active-media'+import type { AudioDetail } from '~/models/media'+import type { AudioStatus } from '~/constants/audio'+import VPlayPause from '~/components/VAudioTrack/VPlayPause.vue'import VWaveform from '~/components/VAudioTrack/VWaveform.vue'-import VFullLayout from '~/components/VAudioTrack/layouts/VFullLayout.vue'-import VRowLayout from '~/components/VAudioTrack/layouts/VRowLayout.vue'-import VBoxLayout from '~/components/VAudioTrack/layouts/VBoxLayout.vue'import VGlobalLayout from '~/components/VAudioTrack/layouts/VGlobalLayout.vue'-const propTypes = {- /**- * the information about the track, typically from a track's detail endpoint- */- audio: {- type: Object,- required: true,- },- /**- * the arrangement of the contents on the canvas; This determines the- * overall L&F of the audio component.- * @todo This type def should be extracted for reuse across components- */- layout: {- type: /** @type {import('@nuxtjs/composition-api').PropType<'full' | 'box' | 'row' | 'global'>} */ (- String- ),- default: 'full',- /**- * @param {string} val- */- validator: (val) => ['full', 'box', 'row', 'global'].includes(val),- },- /**- * the size of the component; Both 'box' and 'row' layouts offer multiple- * sizes to choose from.- */- size: {- type: /** @type {import('@nuxtjs/composition-api').PropType<'s' | 'm' | 'l'>} */ (- String- ),- default: 'm',- /**- * @param {string} val- */- validator: (val) => ['s', 'm', 'l'].includes(val),- },-}-/*** Displays the waveform and basic information about the track, along with* controls to play, pause or seek to a point on the track.@@ -91,22 +59,23 @@ export default defineComponent({components: {VPlayPause,VWaveform,-- // Layouts- VFullLayout,- VRowLayout,- VBoxLayout,VGlobalLayout,},- props: propTypes,- /**- * @param {import('@nuxtjs/composition-api').ExtractPropTypes<typeof propTypes>} props- */+ props: {+ /**+ * the information about the track, typically from a track's detail endpoint+ */+ audio: {+ type: Object as PropType<AudioDetail>,+ required: true,+ },+ },setup(props) {+ const i18n = useI18n()const activeMediaStore = useActiveMediaStore()const activeAudio = useActiveAudio()- const status = ref('paused')+ const status = ref<AudioStatus>('paused')const currentTime = ref(0)const duration = defaultRef(() => {if (typeof props.audio?.duration === 'number')@@ -120,13 +89,10 @@ export default defineComponent({}const setPaused = () => (status.value = 'paused')const setPlayed = () => (status.value = 'played')- /**- * @param {Event} event- */- const setTimeWhenPaused = (event) => {++ const setTimeWhenPaused = (event: Event) => {if (status.value !== 'playing' && event.target) {- currentTime.value =- /** @type {HTMLAudioElement} */ (event.target).currentTime ?? 0+ currentTime.value = (event.target as HTMLAudioElement).currentTime ?? 0if (status.value === 'played') {// Set to pause to remove replay iconstatus.value = 'paused'@@ -167,7 +133,7 @@ export default defineComponent({* set to `playing` as the active audio is only updated when* a new track is set to play. But for good measure we might* as well do this robustly and make sure that the status is- * always synced any time the active audio hanges.+ * always synced any time the active audio hangs.*/if (audio.paused) {if (audio.ended) {@@ -194,14 +160,15 @@ export default defineComponent({const pause = () => activeAudio.obj.value?.pause()/* Timekeeping */- const message = computed(() => activeMediaStore.message)+ const message = computed<string | undefined>(() =>+ activeMediaStore.message+ ? i18n.t(`audio-track.messages.${activeMediaStore.message}`).toString()+ : undefined+ )/* Interface with VPlayPause */- /**- * @param {'playing' | 'paused'} [state]- */- const handleToggle = (state) => {+ const handleToggle = (state: 'playing' | 'paused') => {if (!state) {switch (status.value) {case 'playing':@@ -226,25 +193,12 @@ export default defineComponent({/* Interface with VWaveform */- /**- * @param {number} frac- */- const handleSeeked = (frac) => {+ const handleSeeked = (frac: number) => {if (activeAudio.obj.value) {activeAudio.obj.value.currentTime = frac * duration.value}}- /* Layout */-- const layoutMappings = {- full: 'VFullLayout',- row: 'VRowLayout',- box: 'VBoxLayout',- global: 'VGlobalLayout',- }- const layoutComponent = computed(() => layoutMappings[props.layout])-return {status,message,@@ -253,8 +207,6 @@ export default defineComponent({currentTime,duration,-- layoutComponent,}},})diff --git a/src/components/VAudioTrack/VPlayPause.vue b/src/components/VAudioTrack/VPlayPause.vueindex 7f705f7dd..e91e064f9 100644--- a/src/components/VAudioTrack/VPlayPause.vue+++ b/src/components/VAudioTrack/VPlayPause.vue@@ -11,7 +11,9 @@</template><script lang="ts">-import { defineComponent, PropType } from '@nuxtjs/composition-api'+import { computed, defineComponent, PropType } from '@nuxtjs/composition-api'++import type { AudioLayout, AudioStatus } from '~/constants/audio'import VIconButton from '~/components/VIconButton/VIconButton.vue'@@ -19,6 +21,16 @@ import playIcon from '~/assets/icons/play.svg'import pauseIcon from '~/assets/icons/pause.svg'import replayIcon from '~/assets/icons/replay.svg'+const statusVerbMap = {+ playing: 'pause',+ paused: 'play',+ played: 'replay',+}+const statusIconMap = {+ playing: pauseIcon,+ paused: playIcon,+ played: replayIcon,+}/*** Displays the control for switching between the playing and paused states of* a media file.@@ -36,57 +48,36 @@ export default defineComponent({* the current play status of the audio*/status: {- type: String as PropType<'playing' | 'paused' | 'played'>,+ type: String as PropType<AudioStatus>,required: true,- validator: (val: unknown) =>- ['playing', 'paused', 'played'].includes(val as string),},/*** The parent audio layout currently in use- * @todo This type def should be extracted for reuse across components*/layout: {- type: String as PropType<'full' | 'box' | 'row' | 'global'>,+ type: String as PropType<AudioLayout>,default: 'full',- validator: (val: unknown) =>- ['full', 'box', 'row', 'global'].includes(val as string),},},- data() {- return {- statusVerbMap: {- playing: 'pause',- paused: 'play',- played: 'replay',- },- statusIconMap: {- playing: pauseIcon,- paused: playIcon,- played: replayIcon,- },- }- },- computed: {- isPlaying(): boolean {- return this.status === 'playing'- },+ setup(props, { emit }) {+ const isPlaying = computed(() => props.status === 'playing')/*** Get the button label based on the current status of the player.*/- label(): string {- return `play-pause.${this.statusVerbMap[this.status]}`- },+ const label = computed(() => `play-pause.${statusVerbMap[props.status]}`)/*** Get the button icon based on the current status of the player.*/- icon(): string {- return this.statusIconMap[this.status]- },- },- methods: {- handleClick() {- this.$emit('toggle', this.isPlaying ? 'paused' : 'playing')- },+ const icon = computed(() => statusIconMap[props.status])+ const handleClick = () => {+ emit('toggle', isPlaying.value ? 'paused' : 'playing')+ }+ return {+ label,+ icon,++ handleClick,+ }},})</script>diff --git a/src/components/VAudioTrack/VWaveform.vue b/src/components/VAudioTrack/VWaveform.vueindex 0f420706b..7e62d2dd0 100644--- a/src/components/VAudioTrack/VWaveform.vue+++ b/src/components/VAudioTrack/VWaveform.vue@@ -2,14 +2,11 @@<divref="el"class="waveform group relative bg-background-var focus:outline-none overflow-hidden"- :style="{- '--usable-height': `${Math.floor(usableFrac * 100)}%`,- '--unusable-height': `${Math.floor((1 - usableFrac) * 100)}%`,- }"+ :style="heightProperties":tabIndex="isInteractive ? 0 : -1"- :role="isInteractive ? 'slider' : null"+ :role="isInteractive ? 'slider' : undefined":aria-disabled="!isInteractive"- :aria-label="$t('waveform.label')"+ :aria-label="$t('waveform.label').toString()"aria-orientation="horizontal"aria-valuemin="0":aria-valuemax="duration"@@ -120,7 +117,7 @@? ['bg-background-var']: ['bg-yellow', '-translate-x-full']),]"- :style="{ '--progress-time-left': `${progressBarWidth}px` }"+ :style="progressTimeLeft">{{ timeFmt(progressTimestamp) }}</div>@@ -129,7 +126,7 @@ref="seekTimestampEl"class="seek timestamp transform":class="{ '-translate-x-full': !isSeekTimestampCutoff }"- :style="{ '--seek-time-left': `${seekBarWidth}px` }"+ :style="seekTimeLeft">{{ timeFmt(seekTimestamp) }}</div>@@ -160,19 +157,23 @@</div></template>-<script>+<script lang="ts">import {computed,defineComponent,onBeforeUnmount,onMounted,+ PropType,ref,} from '@nuxtjs/composition-api'import { downsampleArray, upsampleArray } from '~/utils/resampling'-import { keycodes } from '~/constants/key-codes'+import type { AudioFeature } from '~/constants/audio'++import type { CSSProperties } from '@vue/runtime-dom'+/*** Renders an SVG representation of the waveform given a list of heights for the* bars.@@ -185,9 +186,10 @@ export default defineComponent({* bars of random length if the prop is not provided.*/peaks: {- type: Array,+ type: Array as PropType<number[]>,required: false,- validator: (val) => val.every((item) => typeof item === 'number'),+ validator: (val: unknown[]) =>+ val.every((item) => typeof item === 'number'),},/*** the message to display instead of the waveform; This is useful when@@ -207,7 +209,7 @@ export default defineComponent({* the total play time of the audio track*/duration: {- type: Number,+ type: Number as PropType<number>,default: 0,},/**@@ -220,18 +222,18 @@ export default defineComponent({},/*** selectively enable features in the waveform; Available features are- * `'timestamp'`, `'duration'`, `'seek'`.+ * `'timestamps'`, `'duration'`, `'seek'`.*/features: {- type: Array,+ type: Array as PropType<AudioFeature[]>,default: () => ['timestamps', 'seek'],},/*** An object of notices to display when a feature is disabled.- * `'timestamp'`, `'duration'`, `'seek'`.+ * `'timestamps'`, `'duration'`, `'seek'`.*/featureNotices: {- type: Object,+ type: Object as PropType<Record<AudioFeature, boolean>>,default: () => ({}),},},@@ -251,10 +253,10 @@ export default defineComponent({/*** Format the time as hh:mm:ss, dropping the hour part if it is zero.- * @param {number} seconds - the number of seconds in the duration- * @returns {string} the duration in a human-friendly format+ * @param seconds - the number of seconds in the duration+ * @returns the duration in a human-friendly format*/- const timeFmt = (seconds) => {+ const timeFmt = (seconds: number): string => {const date = new Date(0)date.setSeconds(seconds)return date.toISOString().substr(11, 8).replace(/^00:/, '')@@ -262,44 +264,46 @@ export default defineComponent({/*** Get the x-coordinate of the event with respect to the bounding box of the* waveform.- * @param {MouseEvent} event - the event from which to get the position- * @returns {number} the x-position of the event inside the waveform+ * @param event - the event from which to get the position+ * @returns the x-position of the event inside the waveform*/- const getPosition = (event) => {- return event.clientX - el.value.getBoundingClientRect().x+ const getPosition = (event: MouseEvent): number => {+ return el.value+ ? event.clientX - el.value.getBoundingClientRect().x+ : event.clientX}/*** Get the x-position of the event with respect to the bounding box of the* waveform, as a fraction of the waveform width.- * @param {MouseEvent} event - the event from which to get the position- * @returns {number} the x-position of the event as a fraction+ * @param event - the event from which to get the position+ * @returns the x-position of the event as a fraction*/- const getPositionFrac = (event) => {+ const getPositionFrac = (event: MouseEvent): number => {const xPos = getPosition(event)return xPos / waveformDimens.value.width}/*** Get the number of peaks that will fit within the given width.- * @param {number} width - the number of pixels inside which to count peaks- * @returns {number} the number of peaks that can be accommodated+ * @param width - the number of pixels inside which to count peaks+ * @returns the number of peaks that can be accommodated*/- const getPeaksInWidth = (width) => {+ const getPeaksInWidth = (width: number): number => {return Math.floor((width - barGap) / (barWidth + barGap))}/* Element dimensions */- const el = ref(null) // template ref+ const el = ref<HTMLElement | null>(null) // template refconst waveformDimens = ref({ width: 0, height: 0 })const updateWaveformDimens = () => {waveformDimens.value = {- width: el.value.clientWidth,- height: el.value.clientHeight,+ width: el.value?.clientWidth || 0,+ height: el.value?.clientHeight || 0,}}- let observer+ let observer: ResizeObserver | undefinedonMounted(() => {- if (window.ResizeObserver) {+ if (window.ResizeObserver && el.value) {observer = new ResizeObserver(updateWaveformDimens)observer.observe(el.value)}@@ -358,8 +362,8 @@ export default defineComponent({const viewBox = computed(() =>[0, 0, waveformDimens.value.width, waveformDimens.value.height].join(' '))- const spaceBefore = (index) => index * barWidth + index * barGap- const spaceAbove = (index) =>+ const spaceBefore = (index: number) => index * barWidth + index * barGap+ const spaceAbove = (index: number) =>waveformDimens.value.height - normalizedPeaks.value[index]/* Progress bar */@@ -368,13 +372,13 @@ export default defineComponent({isReady.value ? props.currentTime / props.duration : 0)const progressBarWidth = computed(() => {- const frac = isDragging.value ? seekFrac.value : currentFrac.value+ const frac = isDragging.value ? seekFrac.value ?? 0 : currentFrac.valuereturn waveformDimens.value.width * frac})/* Progress timestamp */- const progressTimestampEl = ref(null)+ const progressTimestampEl = ref<HTMLElement>()const progressTimestamp = computed(() =>isDragging.value ? seekTimestamp.value : props.currentTime)@@ -387,7 +391,7 @@ export default defineComponent({/* Seek bar */- const seekFrac = ref(null)+ const seekFrac = ref<number | null>(null)const seekBarWidth = computed(() => {const frac = seekFrac.value ?? currentFrac.valuereturn waveformDimens.value.width * frac@@ -396,8 +400,10 @@ export default defineComponent({/* Seek timestamp */- const seekTimestampEl = ref(null)- const seekTimestamp = computed(() => seekFrac.value * props.duration)+ const seekTimestampEl = ref<HTMLElement | null>(null)+ const seekTimestamp = computed(() =>+ seekFrac.value ? seekFrac.value * props.duration : props.duration+ )const isSeekTimestampCutoff = computed(() => {if (!seekTimestampEl.value) return falseconst barWidth = seekBarWidth.value@@ -418,27 +424,27 @@ export default defineComponent({const modSeekDeltaFrac = computed(() =>isReady.value ? modSeekDelta / props.duration : 0)- const setSeekProgress = (event) => {+ const setSeekProgress = (event: MouseEvent) => {seekFrac.value = getPositionFrac(event)}const clearSeekProgress = () => {seekFrac.value = null}- const seek = (event) => {+ const seek = (event: MouseEvent) => {emit('seeked', getPositionFrac(event))}/* Dragging */const dragThreshold = 2 // px- let startPos = null+ let startPos: null | number = nullconst isDragging = ref(false)- const handleMouseDown = (event) => {+ const handleMouseDown = (event: MouseEvent) => {isDragging.value = falsestartPos = getPosition(event)setSeekProgress(event)}- const handleMouseMove = (event) => {+ const handleMouseMove = (event: MouseEvent) => {if (startPos) {const clickPos = getPosition(event)if (Math.abs(clickPos - startPos) > dragThreshold) {@@ -447,7 +453,7 @@ export default defineComponent({}setSeekProgress(event)}- const handleMouseUp = (event) => {+ const handleMouseUp = (event: MouseEvent) => {isDragging.value = falsestartPos = nullseek(event)@@ -458,11 +464,11 @@ export default defineComponent({/* Keyboard */- const handlePosKeys = (frac) => {+ const handlePosKeys = (frac: number) => {clearSeekProgress()emit('seeked', frac)}- const handleArrowKeys = (event) => {+ const handleArrowKeys = (event: KeyboardEvent) => {const { key, shiftKey, metaKey } = eventif (metaKey) {// Always false on Windows@@ -483,25 +489,31 @@ export default defineComponent({}/**- * @param {KeyboardEvent} event+ * @param event*/- const willBeHandled = (event) =>- [- keycodes.ArrowLeft,- keycodes.ArrowRight,- keycodes.Home,- keycodes.End,- keycodes.Spacebar,- ].includes(event.key)+ const willBeHandled = (event: KeyboardEvent) =>+ (+ [+ keycodes.ArrowLeft,+ keycodes.ArrowRight,+ keycodes.Home,+ keycodes.End,+ keycodes.Spacebar,+ ] as string[]+ ).includes(event.key)/**- * @param {KeyboardEvent} event+ * @param event*/- const handleKeys = (event) => {+ const handleKeys = (event: KeyboardEvent) => {if (!willBeHandled(event)) returnevent.preventDefault()- if ([keycodes.ArrowLeft, keycodes.ArrowRight].includes(event.key))+ if (+ ([keycodes.ArrowLeft, keycodes.ArrowRight] as string[]).includes(+ event.key+ )+ )return handleArrowKeys(event)if (event.key === keycodes.Home) return handlePosKeys(0)if (event.key === keycodes.End) return handlePosKeys(1)@@ -524,6 +536,19 @@ export default defineComponent({}})+ const heightProperties = computed<CSSProperties>(() => ({+ '--usable-height': `${Math.floor(props.usableFrac * 100)}%`,+ '--unusable-height': `${Math.floor((1 - props.usableFrac) * 100)}%`,+ }))++ const progressTimeLeft = computed<CSSProperties>(() => ({+ '--progress-time-left': `${progressBarWidth.value}px`,+ }))++ const seekTimeLeft = computed<CSSProperties>(() => ({+ '--seek-time-left': `${seekBarWidth}px`,+ }))+return {timeFmt,@@ -568,6 +593,10 @@ export default defineComponent({handleArrowKeys,eventHandlers,++ heightProperties,+ progressTimeLeft,+ seekTimeLeft,}},computed: {@@ -575,9 +604,9 @@ export default defineComponent({* the waveform current time as a text string; This function was placed* outside because `this` is not accessible inside the `setup`.*/- currentTimeText() {+ currentTimeText(): string {const time = this.timeFmt(this.currentTime)- return this.$t('waveform.current-time', { time })+ return this.$t('waveform.current-time', { time }).toString()},},})diff --git a/src/components/VAudioTrack/layouts/VBoxLayout.vue b/src/components/VAudioTrack/layouts/VBoxLayout.vueindex 2d0f4b361..ae6162e22 100644--- a/src/components/VAudioTrack/layouts/VBoxLayout.vue+++ b/src/components/VAudioTrack/layouts/VBoxLayout.vue@@ -32,8 +32,16 @@</div></template>-<script>-import { computed, defineComponent, useContext } from '@nuxtjs/composition-api'+<script lang="ts">+import {+ computed,+ defineComponent,+ PropType,+ useContext,+} from '@nuxtjs/composition-api'++import type { AudioDetail } from '~/models/media'+import type { AudioSize } from '~/constants/audio'import VLicense from '~/components/VLicense/VLicense.vue'@@ -44,13 +52,12 @@ export default defineComponent({},props: {audio: {- type: /** @type {import('~/models/media').AudioDetail} */ (Object),+ type: Object as PropType<AudioDetail>,required: true,},size: {- type: String,- required: true,- validator: (v) => ['s', 'm', 'l'].includes(v),+ type: String as PropType<AudioSize>,+ required: false,},},setup(props) {@@ -58,13 +65,13 @@ export default defineComponent({const isSmall = computed(() => props.size === 's')const width = computed(() => {- const magnitude = {+ const magnitudes = {l: 13.25,m: 12.25,s: 9.75,- }[props.size]+ }- return props.size ? `${magnitude}rem` : null+ return props.size ? `${magnitudes[props.size]}rem` : undefined})const categoryLabel = computed(() =>i18n.t(`filters.audio-categories.${props.audio.category}`).toString()diff --git a/src/components/VAudioTrack/layouts/VFullLayout.vue b/src/components/VAudioTrack/layouts/VFullLayout.vueindex 0a2306519..0eefe0daf 100644--- a/src/components/VAudioTrack/layouts/VFullLayout.vue+++ b/src/components/VAudioTrack/layouts/VFullLayout.vue@@ -12,11 +12,7 @@aria-hidden/><div class="md:mx-4 lg:mx-10">- <slot- name="controller"- :features="['timestamps', 'duration', 'seek']"- :usable-frac="0.8"- />+ <slot name="controller" :features="audioFeatures" :usable-frac="0.8" /></div></div><div@@ -54,7 +50,7 @@$t('interpunct')}}</span>- <div>{{ timeFmt(audio.duration) }}</div>+ <div>{{ timeFmt(audio.duration || 0) }}</div></div></div>@@ -70,8 +66,11 @@</div></template>-<script>-import { computed, defineComponent } from '@nuxtjs/composition-api'+<script lang="ts">+import { computed, defineComponent, PropType } from '@nuxtjs/composition-api'++import type { AudioDetail } from '~/models/media'+import { AudioSize, AudioStatus, audioFeatures } from '~/constants/audio'import VButton from '~/components/VButton.vue'import VLink from '~/components/VLink.vue'@@ -81,16 +80,14 @@ export default defineComponent({components: { VButton, VLink },props: {audio: {- type: Object,+ type: Object as PropType<AudioDetail>,required: true,},size: {- type: String,- validation: (v) => ['s', 'm', 'l'].includes(v),+ type: String as PropType<AudioSize>,},status: {- type: String,- validation: (v) => ['playing', 'played', 'paused'].includes(v),+ type: String as PropType<AudioStatus>,},currentTime: {type: Number,@@ -100,10 +97,10 @@ export default defineComponent({setup(props) {/*** Format the time as hh:mm:ss, dropping the hour part if it is zero.- * @param {number} ms - the number of milliseconds in the duration- * @returns {string} the duration in a human-friendly format+ * @param ms - the number of milliseconds in the duration+ * @returns the duration in a human-friendly format*/- const timeFmt = (ms) => {+ const timeFmt = (ms: number): string => {if (ms) {const date = new Date(0)date.setSeconds(ms / 1e3)@@ -118,6 +115,7 @@ export default defineComponent({timeFmt,isSmall,+ audioFeatures,}},})diff --git a/src/components/VAudioTrack/layouts/VGlobalLayout.vue b/src/components/VAudioTrack/layouts/VGlobalLayout.vueindex a7e07485a..bf94c00ff 100644--- a/src/components/VAudioTrack/layouts/VGlobalLayout.vue+++ b/src/components/VAudioTrack/layouts/VGlobalLayout.vue@@ -17,8 +17,10 @@</div></template>-<script>-import { defineComponent } from '@nuxtjs/composition-api'+<script lang="ts">+import { defineComponent, PropType } from '@nuxtjs/composition-api'++import type { AudioDetail } from '~/models/media'import VAudioThumbnail from '~/components/VAudioThumbnail/VAudioThumbnail.vue'@@ -27,7 +29,12 @@ export default defineComponent({components: {VAudioThumbnail,},- props: ['audio'],+ props: {+ audio: {+ type: Object as PropType<AudioDetail>,+ required: true,+ },+ },})</script>diff --git a/src/components/VAudioTrack/layouts/VRowLayout.vue b/src/components/VAudioTrack/layouts/VRowLayout.vueindex 772daa361..295b418d7 100644--- a/src/components/VAudioTrack/layouts/VRowLayout.vue+++ b/src/components/VAudioTrack/layouts/VRowLayout.vue@@ -50,7 +50,7 @@<span v-show="isSmall"><spanclass="inline-block text-dark-charcoal font-semibold bg-dark-charcoal-06 p-1 rounded-sm"- >{{ timeFmt(audio.duration) }}</span+ >{{ timeFmt(audio.duration || 0) }}</span><span class="mx-2">{{ $t('interpunct') }}</span></span>@@ -82,11 +82,20 @@</article></template>-<script>-import { computed, defineComponent, useContext } from '@nuxtjs/composition-api'+<script lang="ts">+import {+ computed,+ defineComponent,+ PropType,+ useContext,+} from '@nuxtjs/composition-api'import { useBrowserIsBlink } from '~/composables/use-browser-detection'+import type { AudioDetail } from '~/models/media'++import type { AudioSize } from '~/constants/audio'+import VAudioThumbnail from '~/components/VAudioThumbnail/VAudioThumbnail.vue'import VLicense from '~/components/VLicense/VLicense.vue'import VLink from '~/components/VLink.vue'@@ -98,25 +107,40 @@ export default defineComponent({VLicense,VLink,},- props: ['audio', 'size'],+ props: {+ audio: {+ type: Object as PropType<AudioDetail>,+ required: true,+ },+ size: {+ type: String as PropType<AudioSize>,+ required: false,+ },+ },setup(props) {/* Utils */const browserIsBlink = useBrowserIsBlink()const { i18n } = useContext()- const featureNotices = {}+ const featureNotices: {+ timestamps?: string+ duration?: string+ seek?: string+ } = {}const features = ['timestamps', 'duration', 'seek']if (browserIsBlink && props.audio.source === 'jamendo') {features.pop()- featureNotices.seek = i18n.t('audio-track.messages.blink_seek_disabled')+ featureNotices.seek = i18n+ .t('audio-track.messages.blink_seek_disabled')+ .toString()}/*** Format the time as hh:mm:ss, dropping the hour part if it is zero.- * @param {number} ms - the number of milliseconds in the duration- * @returns {string} the duration in a human-friendly format+ * @param ms - the number of milliseconds in the duration+ * @returns the duration in a human-friendly format*/- const timeFmt = (ms) => {+ const timeFmt = (ms: number): string => {if (ms) {const date = new Date(0)date.setSeconds(ms / 1e3)diff --git a/src/components/VGlobalAudioSection/VGlobalAudioSection.vue b/src/components/VGlobalAudioSection/VGlobalAudioSection.vueindex abaee1468..6fc9bbc30 100644--- a/src/components/VGlobalAudioSection/VGlobalAudioSection.vue+++ b/src/components/VGlobalAudioSection/VGlobalAudioSection.vue@@ -10,8 +10,13 @@</div></template>-<script>-import { useRoute, watch, computed } from '@nuxtjs/composition-api'+<script lang="ts">+import {+ useRoute,+ watch,+ computed,+ defineComponent,+} from '@nuxtjs/composition-api'import { AUDIO } from '~/constants/media'import { useActiveAudio } from '~/composables/use-active-audio'@@ -19,12 +24,14 @@ import { useActiveMediaStore } from '~/stores/active-media'import { useMediaStore } from '~/stores/media'import { useSingleResultStore } from '~/stores/media/single-result'+import type { AudioDetail } from '~/models/media'+import VIconButton from '~/components/VIconButton/VIconButton.vue'import VGlobalAudioTrack from '~/components/VAudioTrack/VGlobalAudioTrack.vue'import closeIcon from '~/assets/icons/close-small.svg'-export default {+export default defineComponent({name: 'VGlobalAudioSection',components: {VGlobalAudioTrack,@@ -38,15 +45,16 @@ export default {const activeAudio = useActiveAudio()/* Active audio track */- const getAudioItemById = (trackId) => {+ const getAudioItemById = (trackId: string): AudioDetail | null => {const audioFromMediaStore = mediaStore.getItemById(AUDIO, trackId)if (audioFromMediaStore) {- return audioFromMediaStore+ return audioFromMediaStore as AudioDetail}const singleResultStore = useSingleResultStore()if (singleResultStore.mediaItem?.id === trackId) {- return singleResultStore.mediaItem+ return singleResultStore.mediaItem as AudioDetail}+ return null}const audio = computed(() => {const trackId = activeMediaStore.id@@ -58,8 +66,13 @@ export default {/* Message */- const handleError = (event) => {+ const handleError = (event: Event) => {+ if (!(event.target instanceof HTMLAudioElement)) {+ activeMediaStore.setMessage({ message: 'err_unknown' })+ return+ }const error = event.target.error+ if (!error) returnlet errorMsgswitch (error.code) {case error.MEDIA_ERR_ABORTED:@@ -74,6 +87,8 @@ export default {case error.MEDIA_ERR_SRC_NOT_SUPPORTED:errorMsg = 'err_unsupported'break+ default:+ errorMsg = 'err_unknown'}activeMediaStore.setMessage({ message: errorMsg })}@@ -91,15 +106,19 @@ export default {{ immediate: true })- const handleClose = activeMediaStore.ejectActiveMediaItem+ const handleClose = () => {+ activeAudio.obj.value?.pause()+ activeAudio.obj.value = undefined+ activeMediaStore.ejectActiveMediaItem()+ }/* Router observation */const routeName = computed(() => route.value.name)watch(routeName, (routeNameVal, oldRouteNameVal) => {if (- oldRouteNameVal.includes('audio') &&- !routeNameVal.includes('audio')+ oldRouteNameVal?.includes('audio') &&+ !routeNameVal?.includes('audio')) {activeAudio.obj.value?.pause()activeMediaStore.ejectActiveMediaItem()@@ -117,5 +136,5 @@ export default {handleClose,}},-}+})</script>diff --git a/src/constants/audio.ts b/src/constants/audio.tsnew file mode 100644index 000000000..2d1b15082--- /dev/null+++ b/src/constants/audio.ts@@ -0,0 +1,16 @@+export const audioLayouts = ['full', 'box', 'row', 'global'] as const+export const audioSizes = ['s', 'm', 'l'] as const+export const audioStatuses = ['playing', 'paused', 'played'] as const+export const audioFeatures = ['timestamps', 'duration', 'seek'] as const++export type AudioLayout = typeof audioLayouts[number]+export type AudioSize = typeof audioSizes[number]+export type AudioStatus = typeof audioStatuses[number]+export type AudioFeature = typeof audioFeatures[number]++export const layoutMappings = {+ full: 'VFullLayout',+ row: 'VRowLayout',+ box: 'VBoxLayout',+ global: 'VGlobalLayout',+}diff --git a/src/locales/po-files/openverse.pot b/src/locales/po-files/openverse.potindex 118b3faca..cec0a53a6 100644--- a/src/locales/po-files/openverse.pot+++ b/src/locales/po-files/openverse.pot@@ -4,7 +4,7 @@ msgid ""msgstr """Project-Id-Version: Openverse \n""Report-Msgid-Bugs-To: https://github.com/wordpress/openverse/issues \n"-"POT-Creation-Date: 2022-04-28T13:02:26+00:00\n"+"POT-Creation-Date: 2022-04-28T15:58:32+00:00\n""MIME-Version: 1.0\n""Content-Type: text/plain; charset=UTF-8\n""Content-Transfer-Encoding: 8bit\n"@@ -13,7 +13,7 @@ msgstr """Language-Team: LANGUAGE <[email protected]>\n"-#: src/components/VAudioTrack/layouts/VFullLayout.vue:54+#: src/components/VAudioTrack/layouts/VFullLayout.vue:50msgctxt "interpunct"msgid "•"msgstr ""@@ -98,7 +98,7 @@ msgctxt "modal.close"msgid "Close"msgstr ""-#: src/components/VAudioTrack/layouts/VFullLayout.vue:67+#: src/components/VAudioTrack/layouts/VFullLayout.vue:63msgctxt "download-button.download"msgid "Download"msgstr ""@@ -186,24 +186,24 @@ msgid "Replay"msgstr ""#. Do not translate words between ### ###.-#: src/components/VAudioTrack/VAudioTrack.vue:406+#: src/components/VAudioTrack/VAudioTrack.vue:385msgctxt "audio-track.aria-label"msgid "###title### - Audio Player"msgstr ""#. Do not translate words between ### ###.-#: src/components/VAudioTrack/VAudioTrack.vue:403+#: src/components/VAudioTrack/VAudioTrack.vue:382msgctxt "audio-track.aria-label-interactive"msgid "###title### - audio player - press the spacebar to play and pause a preview of the audio"msgstr ""#. Do not translate words between ### ###.-#: src/components/VAudioTrack/layouts/VFullLayout.vue:38+#: src/components/VAudioTrack/layouts/VFullLayout.vue:34msgctxt "audio-track.creator"msgid "by ###creator###"msgstr ""-#: src/components/VAudioTrack/layouts/VRowLayout.vue:111+#: src/components/VAudioTrack/layouts/VRowLayout.vue:134msgctxt "audio-track.messages.blink_seek_disabled"msgid "Seeking for Jamendo tracks is limited to Firefox and Safari."msgstr ""@@ -229,18 +229,18 @@ msgid "Loading..."msgstr ""#. Do not translate words between ### ###.-#: src/components/VAudioThumbnail/VAudioThumbnail.vue:54+#: src/components/VAudioThumbnail/VAudioThumbnail.vue:61msgctxt "audio-thumbnail.alt"msgid "Cover art for \"###title###\" by ###creator###"msgstr ""-#: src/components/VAudioTrack/VWaveform.vue:12+#: src/components/VAudioTrack/VWaveform.vue:9msgctxt "waveform.label"msgid "Audio seek bar"msgstr ""#. Do not translate words between ### ###.-#: src/components/VAudioTrack/VWaveform.vue:580+#: src/components/VAudioTrack/VWaveform.vue:609msgctxt "waveform.current-time"msgid "###time### second"msgid_plural "###time### seconds"diff --git a/src/models/media.ts b/src/models/media.tsindex ae1845d15..547022ec9 100644--- a/src/models/media.ts+++ b/src/models/media.ts@@ -26,6 +26,7 @@ export interface Media {frontendMediaType: SupportedMediaType+ category: string | nullprovider: stringsource?: stringproviderName?: stringdiff --git a/src/stores/active-media.ts b/src/stores/active-media.tsindex 3da3fe957..b2bb0e73a 100644--- a/src/stores/active-media.ts+++ b/src/stores/active-media.ts@@ -49,7 +49,7 @@ export const useActiveMediaStore = defineStore(ACTIVE_MEDIA, () => {}: {type: SupportedMediaTypeid: Media['id']- status: MediaStatus+ status?: MediaStatus}) {state.type = typestate.id = iddiff --git a/src/utils/math.ts b/src/utils/math.tsindex 2e9f0580e..dea923a8f 100644--- a/src/utils/math.ts+++ b/src/utils/math.ts@@ -2,7 +2,7 @@* Math utilities*/-type Point = [number, number]+export type Point = [number, number]/*** Perform linear interpolation to find a value that is fractionally betweendiff --git a/test/tapes/related_images_cfa45160-a7be-4911-9b9f-4e66678ec7f7_keep-alive.json5 b/test/tapes/related_images_cfa45160-a7be-4911-9b9f-4e66678ec7f7_keep-alive.json5new file mode 100644index 000000000..03955bbd3--- /dev/null+++ b/test/tapes/related_images_cfa45160-a7be-4911-9b9f-4e66678ec7f7_keep-alive.json5@@ -0,0 +1,1059 @@+{+ meta: {+ createdAt: '2022-04-21T15:53:07.950Z',+ host: 'https://api.openverse.engineering',+ resHumanReadable: true,+ resUncompressed: true,+ },+ req: {+ headers: {+ connection: 'keep-alive',+ },+ url: '/v1/images/cfa45160-a7be-4911-9b9f-4e66678ec7f7/related/',+ method: 'GET',+ body: '',+ },+ res: {+ status: 200,+ headers: {+ date: [+ 'Thu, 21 Apr 2022 15:53:08 GMT',+ ],+ 'content-type': [+ 'application/json',+ ],+ 'transfer-encoding': [+ 'chunked',+ ],+ connection: [+ 'keep-alive',+ ],+ vary: [+ 'Accept-Encoding, Accept, Authorization, Origin',+ ],+ allow: [+ 'GET, HEAD, OPTIONS',+ ],+ 'x-frame-options': [+ 'DENY',+ ],+ 'access-control-allow-origin': [+ '*',+ ],+ 'x-content-type-options': [+ 'nosniff',+ ],+ 'referrer-policy': [+ 'same-origin',+ ],+ 'cross-origin-opener-policy': [+ 'same-origin',+ ],+ 'cache-control': [+ 'max-age=14400',+ ],+ 'cf-cache-status': [+ 'HIT',+ ],+ age: [+ '29995',+ ],+ 'last-modified': [+ 'Thu, 21 Apr 2022 07:33:13 GMT',+ ],+ 'expect-ct': [+ 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"',+ ],+ 'strict-transport-security': [+ 'max-age=15552000; includeSubDomains; preload',+ ],+ server: [+ 'cloudflare',+ ],+ 'cf-ray': [+ '6ff74a724827d407-BUD',+ ],+ 'content-encoding': [+ 'br',+ ],+ 'alt-svc': [+ 'h3=":443"; ma=86400, h3-29=":443"; ma=86400',+ ],+ },+ body: {+ result_count: 10000,+ page_count: 1,+ page_size: 10,+ page: null,+ results: [+ {+ id: '0a44e589-86dc-423a-9002-0f3ae4a9536e',+ title: 'Southwark Cathedral 004 interior 03a Shakespeare window Kal02',+ foreign_landing_url: 'https://www.flickr.com/photos/36699243@N02/14617895311',+ creator: 'Peter2010',+ creator_url: 'https://www.flickr.com/photos/36699243@N02',+ url: 'https://live.staticflickr.com/3924/14617895311_91e7c4a32c_b.jpg',+ license: 'by',+ license_version: '2.0',+ license_url: 'https://creativecommons.org/licenses/by/2.0/',+ provider: 'flickr',+ source: 'flickr',+ category: null,+ tags: [+ {+ name: 'abstract',+ accuracy: 0.99014,+ },+ {+ name: 'arabesque',+ accuracy: 0.97389,+ },+ {+ name: 'embroidery',+ accuracy: 0.96855,+ },+ {+ name: 'floral',+ accuracy: 0.96053,+ },+ {+ name: 'handmade',+ accuracy: 0.97049,+ },+ {+ name: 'round out',+ accuracy: 0.99087,+ },+ {+ name: 'decoration',+ accuracy: 0.99451,+ },+ {+ name: 'geometric',+ accuracy: 0.99176,+ },+ {+ name: 'lace',+ accuracy: 0.97801,+ },+ {+ name: 'ornate',+ accuracy: 0.97896,+ },+ {+ name: 'pattern',+ accuracy: 0.98994,+ },+ {+ name: 'art',+ accuracy: 0.98257,+ },+ {+ name: 'filigree',+ accuracy: 0.94804,+ },+ {+ name: 'flower',+ accuracy: 0.95885,+ },+ {+ name: 'proportion',+ accuracy: 0.98245,+ },+ {+ name: 'round',+ accuracy: 0.9935,+ },+ ],+ thumbnail: 'http://localhost:49153/v1/images/0a44e589-86dc-423a-9002-0f3ae4a9536e/thumb/',+ detail_url: 'http://localhost:49153/v1/images/0a44e589-86dc-423a-9002-0f3ae4a9536e/',+ related_url: 'http://localhost:49153/v1/images/0a44e589-86dc-423a-9002-0f3ae4a9536e/related/',+ },+ {+ id: 'c927bbc0-5585-4a72-b92a-606402ded916',+ title: 'Stone Pile Kaleidoscope',+ foreign_landing_url: 'https://www.flickr.com/photos/78428166@N00/14766083978',+ creator: 'Tobyotter',+ creator_url: 'https://www.flickr.com/photos/78428166@N00',+ url: 'https://live.staticflickr.com/5584/14766083978_ee97203637_b.jpg',+ license: 'by',+ license_version: '2.0',+ license_url: 'https://creativecommons.org/licenses/by/2.0/',+ provider: 'flickr',+ source: 'flickr',+ category: null,+ tags: [+ {+ name: 'design',+ accuracy: 0.92219,+ },+ {+ name: 'floral',+ accuracy: 0.90892,+ },+ {+ name: 'round',+ accuracy: 0.97474,+ },+ {+ name: 'art',+ accuracy: 0.98925,+ },+ {+ name: 'flower',+ accuracy: 0.95012,+ },+ {+ name: 'geometric',+ accuracy: 0.92018,+ },+ {+ name: 'handmade',+ accuracy: 0.90728,+ },+ {+ name: 'retro',+ accuracy: 0.94354,+ },+ {+ name: 'graphic',+ accuracy: 0.94865,+ },+ {+ name: 'pattern',+ accuracy: 0.98674,+ },+ {+ name: 'round out',+ accuracy: 0.97231,+ },+ {+ name: 'abstract',+ accuracy: 0.97831,+ },+ {+ name: 'decoration',+ accuracy: 0.99321,+ },+ {+ name: 'element',+ accuracy: 0.91258,+ },+ {+ name: 'illustration',+ accuracy: 0.98283,+ },+ {+ name: 'ornate',+ accuracy: 0.97358,+ },+ {+ name: 'proportion',+ accuracy: 0.9571,+ },+ {+ name: 'snowflake',+ accuracy: 0.92625,+ },+ {+ name: 'texture',+ accuracy: 0.94865,+ },+ {+ name: 'vector',+ accuracy: 0.94493,+ },+ ],+ thumbnail: 'http://localhost:49153/v1/images/c927bbc0-5585-4a72-b92a-606402ded916/thumb/',+ detail_url: 'http://localhost:49153/v1/images/c927bbc0-5585-4a72-b92a-606402ded916/',+ related_url: 'http://localhost:49153/v1/images/c927bbc0-5585-4a72-b92a-606402ded916/related/',+ },+ {+ id: '366eb553-c6e5-48dc-8f4a-a3e6a6fafedc',+ title: 'S Alban FF 016 Abbey interior 02a Come ye thankful people, come. Kal02',+ foreign_landing_url: 'https://www.flickr.com/photos/36699243@N02/15250817919',+ creator: 'Peter2010',+ creator_url: 'https://www.flickr.com/photos/36699243@N02',+ url: 'https://live.staticflickr.com/2947/15250817919_ef88067dd2_b.jpg',+ license: 'by',+ license_version: '2.0',+ license_url: 'https://creativecommons.org/licenses/by/2.0/',+ provider: 'flickr',+ source: 'flickr',+ category: null,+ tags: [+ {+ name: 'embroidery',+ accuracy: 0.98633,+ },+ {+ name: 'flower',+ accuracy: 0.9931,+ },+ {+ name: 'handmade',+ accuracy: 0.97875,+ },+ {+ name: 'ornate',+ accuracy: 0.98806,+ },+ {+ name: 'proportion',+ accuracy: 0.99572,+ },+ {+ name: 'radiant',+ accuracy: 0.9662,+ },+ {+ name: 'round out',+ accuracy: 0.98673,+ },+ {+ name: 'art',+ accuracy: 0.97959,+ },+ {+ name: 'decoration',+ accuracy: 0.99126,+ },+ {+ name: 'filigree',+ accuracy: 0.97976,+ },+ {+ name: 'illustration',+ accuracy: 0.96468,+ },+ {+ name: 'lace',+ accuracy: 0.98607,+ },+ {+ name: 'napkin',+ accuracy: 0.975,+ },+ {+ name: 'tribal',+ accuracy: 0.96805,+ },+ {+ name: 'abstract',+ accuracy: 0.98299,+ },+ {+ name: 'floral',+ accuracy: 0.9692,+ },+ {+ name: 'geometric',+ accuracy: 0.97924,+ },+ {+ name: 'arabesque',+ accuracy: 0.97518,+ },+ {+ name: 'pattern',+ accuracy: 0.9807,+ },+ {+ name: 'round',+ accuracy: 0.98894,+ },+ ],+ thumbnail: 'http://localhost:49153/v1/images/366eb553-c6e5-48dc-8f4a-a3e6a6fafedc/thumb/',+ detail_url: 'http://localhost:49153/v1/images/366eb553-c6e5-48dc-8f4a-a3e6a6fafedc/',+ related_url: 'http://localhost:49153/v1/images/366eb553-c6e5-48dc-8f4a-a3e6a6fafedc/related/',+ },+ {+ id: '06f2ae25-51e4-4915-bd76-5261025abf98',+ title: 'Lincoln FF 10a Interior 03a Now let me see Kal03',+ foreign_landing_url: 'https://www.flickr.com/photos/36699243@N02/16805030114',+ creator: 'Peter2010',+ creator_url: 'https://www.flickr.com/photos/36699243@N02',+ url: 'https://live.staticflickr.com/8722/16805030114_bf0582f31b_b.jpg',+ license: 'by',+ license_version: '2.0',+ license_url: 'https://creativecommons.org/licenses/by/2.0/',+ provider: 'flickr',+ source: 'flickr',+ category: null,+ tags: [+ {+ name: 'geometric',+ accuracy: 0.92991,+ },+ {+ name: 'pattern',+ accuracy: 0.94602,+ },+ {+ name: 'proportion',+ accuracy: 0.94547,+ },+ {+ name: 'round',+ accuracy: 0.97105,+ },+ {+ name: 'texture',+ accuracy: 0.90361,+ },+ {+ name: 'tribal',+ accuracy: 0.92871,+ },+ {+ name: 'decoration',+ accuracy: 0.98194,+ },+ {+ name: 'floral',+ accuracy: 0.90697,+ },+ {+ name: 'flower',+ accuracy: 0.95864,+ },+ {+ name: 'graphic',+ accuracy: 0.91017,+ },+ {+ name: 'round out',+ accuracy: 0.96194,+ },+ {+ name: 'embroidery',+ accuracy: 0.91789,+ },+ {+ name: 'illustration',+ accuracy: 0.95611,+ },+ {+ name: 'ornate',+ accuracy: 0.92896,+ },+ {+ name: 'abstract',+ accuracy: 0.96547,+ },+ {+ name: 'art',+ accuracy: 0.96114,+ },+ {+ name: 'design',+ accuracy: 0.94605,+ },+ {+ name: 'element',+ accuracy: 0.90863,+ },+ {+ name: 'handmade',+ accuracy: 0.90541,+ },+ ],+ thumbnail: 'http://localhost:49153/v1/images/06f2ae25-51e4-4915-bd76-5261025abf98/thumb/',+ detail_url: 'http://localhost:49153/v1/images/06f2ae25-51e4-4915-bd76-5261025abf98/',+ related_url: 'http://localhost:49153/v1/images/06f2ae25-51e4-4915-bd76-5261025abf98/related/',+ },+ {+ id: '21aa7e9a-21f1-48e1-a7a2-1f34a0438b01',+ title: 'S Alban FF 005 Exterior 01a I the Lord of Sea & Sky. Marquee display Kal02',+ foreign_landing_url: 'https://www.flickr.com/photos/36699243@N02/15370079725',+ creator: 'Peter2010',+ creator_url: 'https://www.flickr.com/photos/36699243@N02',+ url: 'https://live.staticflickr.com/3898/15370079725_4f08f76c80_b.jpg',+ license: 'by',+ license_version: '2.0',+ license_url: 'https://creativecommons.org/licenses/by/2.0/',+ provider: 'flickr',+ source: 'flickr',+ category: null,+ tags: [+ {+ name: 'geometric',+ accuracy: 0.97957,+ },+ {+ name: 'radiant',+ accuracy: 0.94294,+ },+ {+ name: 'art',+ accuracy: 0.96861,+ },+ {+ name: 'decoration',+ accuracy: 0.99048,+ },+ {+ name: 'handmade',+ accuracy: 0.96073,+ },+ {+ name: 'psychedelic',+ accuracy: 0.96127,+ },+ {+ name: 'snowflake',+ accuracy: 0.97696,+ },+ {+ name: 'embroidery',+ accuracy: 0.98176,+ },+ {+ name: 'filigree',+ accuracy: 0.95269,+ },+ {+ name: 'floral',+ accuracy: 0.97099,+ },+ {+ name: 'flower',+ accuracy: 0.99212,+ },+ {+ name: 'illustration',+ accuracy: 0.96963,+ },+ {+ name: 'lace',+ accuracy: 0.96402,+ },+ {+ name: 'ornate',+ accuracy: 0.96849,+ },+ {+ name: 'proportion',+ accuracy: 0.99272,+ },+ {+ name: 'round',+ accuracy: 0.99284,+ },+ {+ name: 'abstract',+ accuracy: 0.97808,+ },+ {+ name: 'napkin',+ accuracy: 0.9626,+ },+ {+ name: 'pattern',+ accuracy: 0.96608,+ },+ {+ name: 'round out',+ accuracy: 0.98568,+ },+ ],+ thumbnail: 'http://localhost:49153/v1/images/21aa7e9a-21f1-48e1-a7a2-1f34a0438b01/thumb/',+ detail_url: 'http://localhost:49153/v1/images/21aa7e9a-21f1-48e1-a7a2-1f34a0438b01/',+ related_url: 'http://localhost:49153/v1/images/21aa7e9a-21f1-48e1-a7a2-1f34a0438b01/related/',+ },+ {+ id: 'dd1a442c-c674-4ef4-a639-6976333b3202',+ title: 'bm_sym_6_20090311_078',+ foreign_landing_url: 'https://www.flickr.com/photos/33409576@N08/3343542459',+ creator: 'jonathanmccabe',+ creator_url: 'https://www.flickr.com/photos/33409576@N08',+ url: 'https://live.staticflickr.com/3391/3343542459_416131109b.jpg',+ license: 'by',+ license_version: '2.0',+ license_url: 'https://creativecommons.org/licenses/by/2.0/',+ provider: 'flickr',+ source: 'flickr',+ category: null,+ tags: [+ {+ name: 'abstract',+ accuracy: 0.99099,+ },+ {+ name: 'arabesque',+ accuracy: 0.96731,+ },+ {+ name: 'art',+ accuracy: 0.98943,+ },+ {+ name: 'floral',+ accuracy: 0.96655,+ },+ {+ name: 'flower',+ accuracy: 0.97933,+ },+ {+ name: 'geometric',+ accuracy: 0.98366,+ },+ {+ name: 'handmade',+ accuracy: 0.96625,+ },+ {+ name: 'pattern',+ accuracy: 0.99577,+ },+ {+ name: 'antique',+ accuracy: 0.97323,+ },+ {+ name: 'decoration',+ accuracy: 0.99281,+ },+ {+ name: 'mosaic',+ accuracy: 0.97729,+ },+ {+ name: 'proportion',+ accuracy: 0.98244,+ },+ {+ name: 'retro',+ accuracy: 0.96465,+ },+ {+ name: 'round',+ accuracy: 0.96695,+ },+ {+ name: 'round out',+ accuracy: 0.9691,+ },+ {+ name: 'texture',+ accuracy: 0.98209,+ },+ {+ name: 'design',+ accuracy: 0.95742,+ },+ {+ name: 'kaleidoscope',+ accuracy: 0.96,+ },+ {+ name: 'lace',+ accuracy: 0.98985,+ },+ {+ name: 'ornate',+ accuracy: 0.99126,+ },+ ],+ thumbnail: 'http://localhost:49153/v1/images/dd1a442c-c674-4ef4-a639-6976333b3202/thumb/',+ detail_url: 'http://localhost:49153/v1/images/dd1a442c-c674-4ef4-a639-6976333b3202/',+ related_url: 'http://localhost:49153/v1/images/dd1a442c-c674-4ef4-a639-6976333b3202/related/',+ },+ {+ id: 'ae6f77b1-385e-4c3c-b11d-0129cc22a191',+ title: 'Brikke',+ foreign_landing_url: 'https://digitaltmuseum.org/021027628921/brikke/media?slide=0',+ creator: 'Vest-Telemark Museum',+ url: 'https://dms-cf-04.dimu.org/image/0331uxv1yXdr?dimension=1200x1200',+ license: 'by-nc-sa',+ license_version: '4.0',+ license_url: 'https://creativecommons.org/licenses/by-nc-sa/4.0/',+ provider: 'digitaltmuseum',+ source: 'digitaltmuseum',+ category: null,+ tags: [+ {+ name: 'lace',+ accuracy: 0.99725,+ },+ {+ name: 'embroidery',+ accuracy: 0.99361,+ },+ {+ name: 'abstract',+ accuracy: 0.99319,+ },+ {+ name: 'round',+ accuracy: 0.9928,+ },+ {+ name: 'decoration',+ accuracy: 0.99184,+ },+ {+ name: 'pattern',+ accuracy: 0.98992,+ },+ {+ name: 'round out',+ accuracy: 0.98746,+ },+ {+ name: 'flower',+ accuracy: 0.98735,+ },+ {+ name: 'arabesque',+ accuracy: 0.98597,+ },+ {+ name: 'napkin',+ accuracy: 0.98461,+ },+ {+ name: 'geometric',+ accuracy: 0.98408,+ },+ {+ name: 'handmade',+ accuracy: 0.98209,+ },+ {+ name: 'art',+ accuracy: 0.98036,+ },+ {+ name: 'doily',+ accuracy: 0.97798,+ },+ {+ name: 'texture',+ accuracy: 0.9777,+ },+ {+ name: 'retro',+ accuracy: 0.97717,+ },+ {+ name: 'illustration',+ accuracy: 0.97391,+ },+ {+ name: 'proportion',+ accuracy: 0.97239,+ },+ {+ name: 'vintage',+ accuracy: 0.97182,+ },+ {+ name: 'vector',+ accuracy: 0.97054,+ },+ ],+ thumbnail: 'http://localhost:49153/v1/images/ae6f77b1-385e-4c3c-b11d-0129cc22a191/thumb/',+ detail_url: 'http://localhost:49153/v1/images/ae6f77b1-385e-4c3c-b11d-0129cc22a191/',+ related_url: 'http://localhost:49153/v1/images/ae6f77b1-385e-4c3c-b11d-0129cc22a191/related/',+ },+ {+ id: '5c5aa3bf-7d02-422b-8741-2e7c7b011940',+ title: 'fpx112412-06',+ foreign_landing_url: 'https://www.flickr.com/photos/7888217@N04/8213410037',+ creator: 'fontplaydotcom',+ creator_url: 'https://www.flickr.com/photos/7888217@N04',+ url: 'https://live.staticflickr.com/8337/8213410037_408562cc1a_b.jpg',+ license: 'by',+ license_version: '2.0',+ license_url: 'https://creativecommons.org/licenses/by/2.0/',+ provider: 'flickr',+ source: 'flickr',+ category: null,+ tags: [+ {+ name: 'needlework',+ },+ {+ name: 'texture',+ },+ {+ name: 'abstract',+ accuracy: 0.9941,+ },+ {+ name: 'arabesque',+ accuracy: 0.98841,+ },+ {+ name: 'art',+ accuracy: 0.98849,+ },+ {+ name: 'craft',+ accuracy: 0.98206,+ },+ {+ name: 'decoration',+ accuracy: 0.99802,+ },+ {+ name: 'doily',+ accuracy: 0.99624,+ },+ {+ name: 'embroidery',+ accuracy: 0.99761,+ },+ {+ name: 'flower',+ accuracy: 0.99192,+ },+ {+ name: 'geometric',+ accuracy: 0.98148,+ },+ {+ name: 'handmade',+ accuracy: 0.99798,+ },+ {+ name: 'lace',+ accuracy: 0.99898,+ },+ {+ name: 'napkin',+ accuracy: 0.99805,+ },+ {+ name: 'ornate',+ accuracy: 0.98749,+ },+ {+ name: 'pattern',+ accuracy: 0.99473,+ },+ {+ name: 'proportion',+ accuracy: 0.98612,+ },+ {+ name: 'retro',+ accuracy: 0.97531,+ },+ {+ name: 'round',+ accuracy: 0.99245,+ },+ {+ name: 'round out',+ accuracy: 0.98447,+ },+ {+ name: 'style',+ accuracy: 0.97693,+ },+ {+ name: 'texture',+ accuracy: 0.9821,+ },+ ],+ thumbnail: 'http://localhost:49153/v1/images/5c5aa3bf-7d02-422b-8741-2e7c7b011940/thumb/',+ detail_url: 'http://localhost:49153/v1/images/5c5aa3bf-7d02-422b-8741-2e7c7b011940/',+ related_url: 'http://localhost:49153/v1/images/5c5aa3bf-7d02-422b-8741-2e7c7b011940/related/',+ },+ {+ id: '68dceb2b-0d9a-499a-90db-81affb8e8c82',+ title: 'S Alban FF 020 Abbey interior 04a Water Music Kal02',+ foreign_landing_url: 'https://www.flickr.com/photos/36699243@N02/15341177097',+ creator: 'Peter2010',+ creator_url: 'https://www.flickr.com/photos/36699243@N02',+ url: 'https://live.staticflickr.com/5604/15341177097_92233a0f5a_b.jpg',+ license: 'by',+ license_version: '2.0',+ license_url: 'https://creativecommons.org/licenses/by/2.0/',+ provider: 'flickr',+ source: 'flickr',+ category: null,+ tags: [+ {+ name: 'arabesque',+ accuracy: 0.96048,+ },+ {+ name: 'art',+ accuracy: 0.97235,+ },+ {+ name: 'illustration',+ accuracy: 0.98143,+ },+ {+ name: 'mosaic',+ accuracy: 0.97328,+ },+ {+ name: 'ornate',+ accuracy: 0.98492,+ },+ {+ name: 'proportion',+ accuracy: 0.99794,+ },+ {+ name: 'doily',+ accuracy: 0.97732,+ },+ {+ name: 'flower',+ accuracy: 0.99016,+ },+ {+ name: 'handmade',+ accuracy: 0.96383,+ },+ {+ name: 'lace',+ accuracy: 0.97952,+ },+ {+ name: 'napkin',+ accuracy: 0.96321,+ },+ {+ name: 'pattern',+ accuracy: 0.9905,+ },+ {+ name: 'round',+ accuracy: 0.99445,+ },+ {+ name: 'abstract',+ accuracy: 0.9943,+ },+ {+ name: 'decoration',+ accuracy: 0.99282,+ },+ {+ name: 'graphic',+ accuracy: 0.96049,+ },+ {+ name: 'psychedelic',+ accuracy: 0.97374,+ },+ {+ name: 'geometric',+ accuracy: 0.9889,+ },+ {+ name: 'round out',+ accuracy: 0.98105,+ },+ {+ name: 'snowflake',+ accuracy: 0.97582,+ },+ ],+ thumbnail: 'http://localhost:49153/v1/images/68dceb2b-0d9a-499a-90db-81affb8e8c82/thumb/',+ detail_url: 'http://localhost:49153/v1/images/68dceb2b-0d9a-499a-90db-81affb8e8c82/',+ related_url: 'http://localhost:49153/v1/images/68dceb2b-0d9a-499a-90db-81affb8e8c82/related/',+ },+ {+ id: '9deb85ad-913c-45c3-8c76-fac79be18a4d',+ title: 'Wheel',+ foreign_landing_url: 'https://www.flickr.com/photos/12457246@N03/7180721417',+ creator: 'chrstphre',+ creator_url: 'https://www.flickr.com/photos/12457246@N03',+ url: 'https://live.staticflickr.com/7245/7180721417_80e283251a_b.jpg',+ license: 'by',+ license_version: '2.0',+ license_url: 'https://creativecommons.org/licenses/by/2.0/',+ provider: 'flickr',+ source: 'flickr',+ category: null,+ tags: [+ {+ name: 'abstract',+ accuracy: 0.97023,+ },+ {+ name: 'decoration',+ accuracy: 0.97476,+ },+ {+ name: 'embroidery',+ accuracy: 0.92725,+ },+ {+ name: 'lace',+ accuracy: 0.99394,+ },+ {+ name: 'pattern',+ accuracy: 0.98314,+ },+ {+ name: 'round out',+ accuracy: 0.99244,+ },+ {+ name: 'texture',+ accuracy: 0.96172,+ },+ {+ name: 'geometric',+ accuracy: 0.93954,+ },+ {+ name: 'handmade',+ accuracy: 0.95815,+ },+ {+ name: 'snowflake',+ accuracy: 0.90829,+ },+ {+ name: 'textile',+ accuracy: 0.92354,+ },+ {+ name: 'fabric',+ accuracy: 0.94779,+ },+ {+ name: 'line',+ accuracy: 0.90114,+ },+ {+ name: 'proportion',+ accuracy: 0.95897,+ },+ {+ name: 'art',+ accuracy: 0.95548,+ },+ {+ name: 'design',+ accuracy: 0.93347,+ },+ {+ name: 'ornate',+ accuracy: 0.97154,+ },+ {+ name: 'round',+ accuracy: 0.99731,+ },+ ],+ thumbnail: 'http://localhost:49153/v1/images/9deb85ad-913c-45c3-8c76-fac79be18a4d/thumb/',+ detail_url: 'http://localhost:49153/v1/images/9deb85ad-913c-45c3-8c76-fac79be18a4d/',+ related_url: 'http://localhost:49153/v1/images/9deb85ad-913c-45c3-8c76-fac79be18a4d/related/',+ },+ ],+ },+ },+}\ No newline at end of filediff --git a/tsconfig.json b/tsconfig.jsonindex 2301e17f3..e3be362e7 100644--- a/tsconfig.json+++ b/tsconfig.json@@ -53,9 +53,11 @@"src/components/VNotificationBanner.vue","src/components/VMigrationNotice.vue","src/components/VVariations.vue",+ "src/components/VAudioTrack/**.vue",+ "src/components/VAudioThumbnail/VAudioThumbnail.vue",+ "src/components/VGlobalAudioSection/VGlobalAudioSection.vue","src/components/VInputField/VInputField.vue","src/components/VHeader/VSearchBar/VSearchBar.vue",- "src/components/VAudioTrack/VPlayPause.vue","src/pages/search-help.vue","src/composables/types.js","src/composables/use-event-listener-outside.js",diff --git a/typings/csstype/index.d.ts b/typings/csstype/index.d.tsnew file mode 100644index 000000000..62ac280ea--- /dev/null+++ b/typings/csstype/index.d.ts@@ -0,0 +1,12 @@+/**+ * To use CSS custom properties in a component that uses TypeScript, add them here.+ * See example in `VWaveform.vue`+ */+declare module 'csstype' {+ interface Properties {+ '--usable-height'?: string+ '--unusable-height'?: string+ '--progress-time-left'?: string+ '--seek-time-left'?: string+ }+}