chore(web): migration svelte 5 syntax (#13883)

This commit is contained in:
Alex 2024-11-14 08:43:25 -06:00 committed by GitHub
parent 9203a61709
commit 0b3742cf13
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
310 changed files with 6435 additions and 4176 deletions

View file

@ -1,4 +1,4 @@
<script context="module" lang="ts">
<script module lang="ts">
export enum ProgressBarStatus {
Playing = 'playing',
Paused = 'paused',
@ -11,41 +11,49 @@
import { onMount } from 'svelte';
import { tweened } from 'svelte/motion';
/**
* Autoplay on mount
* @default false
*/
export let autoplay = false;
interface Props {
/**
* Autoplay on mount
* @default false
*/
autoplay?: boolean;
/**
* Progress bar status
*/
status?: ProgressBarStatus;
hidden?: boolean;
duration?: number;
onDone: () => void;
onPlaying?: () => void;
onPaused?: () => void;
}
/**
* Progress bar status
*/
export let status: ProgressBarStatus = ProgressBarStatus.Paused;
let {
autoplay = false,
status = $bindable(),
hidden = false,
duration = 5,
onDone,
onPlaying = () => {},
onPaused = () => {},
}: Props = $props();
export let hidden = false;
export let duration = 5;
export let onDone: () => void;
export let onPlaying: () => void = () => {};
export let onPaused: () => void = () => {};
const onChange = async () => {
progress = setDuration(duration);
const onChange = async (progressDuration: number) => {
progress = setDuration(progressDuration);
await play();
};
let progress = setDuration(duration);
// svelte 5, again....
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
$: duration, handlePromiseError(onChange());
$effect(() => {
handlePromiseError(onChange(duration));
});
$: {
$effect(() => {
if ($progress === 1) {
onDone();
}
}
});
onMount(async () => {
if (autoplay) {