|
<script lang="ts"> |
|
import { resolve_wasm_src } from "@gradio/wasm/svelte"; |
|
import type { HTMLImgAttributes } from "svelte/elements"; |
|
import { createEventDispatcher } from "svelte"; |
|
import Canvas from "./Canvas.svelte" |
|
import AnnotatedImageData from "./AnnotatedImageData"; |
|
|
|
interface Props extends HTMLImgAttributes { |
|
"data-testid"?: string; |
|
} |
|
|
|
export let src: HTMLImgAttributes["src"] = undefined; |
|
export let interactive: boolean; |
|
export let boxesAlpha: number; |
|
export let labelList: string[]; |
|
export let labelColors: string[]; |
|
export let boxMinSize: number; |
|
export let handleSize: number; |
|
export let boxThickness: number; |
|
export let boxSelectedThickness: number; |
|
export let value: null | AnnotatedImageData; |
|
export let disableEditBoxes: boolean; |
|
export let singleBox: boolean; |
|
export let showRemoveButton: boolean; |
|
export let handlesCursor: boolean; |
|
|
|
let resolved_src: typeof src; |
|
|
|
|
|
|
|
|
|
let latest_src: typeof src; |
|
$: { |
|
|
|
|
|
|
|
|
|
|
|
resolved_src = src; |
|
|
|
latest_src = src; |
|
const resolving_src = src; |
|
resolve_wasm_src(resolving_src).then((s) => { |
|
if (latest_src === resolving_src) { |
|
resolved_src = s; |
|
} |
|
}); |
|
} |
|
|
|
const dispatch = createEventDispatcher<{ |
|
change: undefined; |
|
}>(); |
|
|
|
</script> |
|
|
|
<Canvas |
|
bind:value |
|
on:change={() => dispatch("change")} |
|
{interactive} |
|
boxAlpha={boxesAlpha} |
|
choices={labelList} |
|
choicesColors={labelColors} |
|
{boxMinSize} |
|
{handleSize} |
|
{boxThickness} |
|
{boxSelectedThickness} |
|
{disableEditBoxes} |
|
{singleBox} |
|
{showRemoveButton} |
|
{handlesCursor} |
|
imageUrl={resolved_src} |
|
/> |
|
|