Upload folder using huggingface_hub
Browse files- 6.0.0-dev.6/timer/Index.svelte +24 -0
- 6.0.0-dev.6/timer/package.json +32 -0
- 6.0.0-dev.6/timer/types.ts +9 -0
6.0.0-dev.6/timer/Index.svelte
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import { onDestroy } from "svelte";
|
| 3 |
+
import type { TimerProps, TimerEvents } from "./types";
|
| 4 |
+
import { Gradio } from "@gradio/utils";
|
| 5 |
+
|
| 6 |
+
const props = $props();
|
| 7 |
+
const gradio = new Gradio<TimerEvents, TimerProps>(props);
|
| 8 |
+
|
| 9 |
+
let interval: NodeJS.Timeout | undefined = undefined;
|
| 10 |
+
|
| 11 |
+
$effect(() => {
|
| 12 |
+
if (interval) clearInterval(interval);
|
| 13 |
+
if (gradio.props.active) {
|
| 14 |
+
interval = setInterval(() => {
|
| 15 |
+
if (document.visibilityState === "visible") {
|
| 16 |
+
gradio.dispatch("tick");
|
| 17 |
+
}
|
| 18 |
+
}, gradio.props.value * 1000);
|
| 19 |
+
}
|
| 20 |
+
});
|
| 21 |
+
onDestroy(() => {
|
| 22 |
+
if (interval) clearInterval(interval);
|
| 23 |
+
});
|
| 24 |
+
</script>
|
6.0.0-dev.6/timer/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@gradio/timer",
|
| 3 |
+
"version": "0.4.6-dev.0",
|
| 4 |
+
"description": "Gradio UI packages",
|
| 5 |
+
"type": "module",
|
| 6 |
+
"author": "",
|
| 7 |
+
"license": "ISC",
|
| 8 |
+
"private": false,
|
| 9 |
+
"main_changeset": true,
|
| 10 |
+
"exports": {
|
| 11 |
+
".": {
|
| 12 |
+
"gradio": "./Index.svelte",
|
| 13 |
+
"svelte": "./dist/Index.svelte",
|
| 14 |
+
"types": "./dist/Index.svelte.d.ts"
|
| 15 |
+
},
|
| 16 |
+
"./package.json": "./package.json"
|
| 17 |
+
},
|
| 18 |
+
"dependencies": {
|
| 19 |
+
"@gradio/utils": "workspace:^"
|
| 20 |
+
},
|
| 21 |
+
"devDependencies": {
|
| 22 |
+
"@gradio/preview": "workspace:^"
|
| 23 |
+
},
|
| 24 |
+
"peerDependencies": {
|
| 25 |
+
"svelte": "^5.43.4"
|
| 26 |
+
},
|
| 27 |
+
"repository": {
|
| 28 |
+
"type": "git",
|
| 29 |
+
"url": "git+https://github.com/gradio-app/gradio.git",
|
| 30 |
+
"directory": "js/timer"
|
| 31 |
+
}
|
| 32 |
+
}
|
6.0.0-dev.6/timer/types.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export interface TimerProps {
|
| 2 |
+
value: number;
|
| 3 |
+
active: boolean;
|
| 4 |
+
}
|
| 5 |
+
|
| 6 |
+
export interface TimerEvents {
|
| 7 |
+
tick: never;
|
| 8 |
+
clear_status: never;
|
| 9 |
+
}
|