File size: 2,479 Bytes
0bd62e5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import config from "$lib/component_json";

const comps = {
	accordion: () => import("@gradio/accordion"),
	annotatedimage: () => import("@gradio/annotatedimage"),
	audio: () => import("@gradio/audio"),
	button: () => import("@gradio/button"),
	chatbot: () => import("@gradio/chatbot"),
	checkbox: () => import("@gradio/checkbox"),
	checkboxgroup: () => import("@gradio/checkboxgroup"),
	code: () => import("@gradio/code"),
	colorpicker: () => import("@gradio/colorpicker"),
	dataframe: () => import("@gradio/dataframe"),
	dataset: () => import("@gradio/dataset"),
	datetime: () => import("@gradio/datetime"),
	downloadbutton: () => import("@gradio/downloadbutton"),
	dropdown: () => import("@gradio/dropdown"),
	file: () => import("@gradio/file"),
	form: () => import("@gradio/form"),
	gallery: () => import("@gradio/gallery"),
	highlightedtext: () => import("@gradio/highlightedtext"),
	html: () => import("@gradio/html"),
	image: () => import("@gradio/image"),
	imageeditor: () => import("@gradio/imageeditor"),
	json: () => import("@gradio/json"),
	label: () => import("@gradio/label"),
	markdown: () => import("@gradio/markdown"),
	model3d: () => import("@gradio/model3d"),
	multimodaltextbox: () => import("@gradio/multimodaltextbox"),
	nativeplot: () => import("@gradio/nativeplot"),
	number: () => import("@gradio/number"),
	paramviewer: () => import("@gradio/paramviewer"),
	plot: () => import("@gradio/plot"),
	radio: () => import("@gradio/radio"),
	simpleimage: () => import("@gradio/simpleimage"),
	slider: () => import("@gradio/slider"),
	state: () => import("@gradio/state"),
	textbox: () => import("@gradio/textbox"),
	timer: () => import("@gradio/timer"),
	uploadbutton: () => import("@gradio/uploadbutton"),
	video: () => import("@gradio/video")
};

import type { PageLoad } from "./$types";

export const load: PageLoad = async ({ url }) => {
	const route_name = url.pathname.split("/").slice(-1)[0];
	const interactive_component = config.find(
		(c) => c.name === route_name && c.props.interactive
	);
	const non_interactive_component = config.find(
		(c) => c.name === route_name && !c.props.interactive
	);

	const comp =
		route_name in comps
			? await comps[route_name as keyof typeof comps]()
			: await import("@gradio/label");

	return {
		component: comp,
		interactive_component: interactive_component,
		non_interactive_component: non_interactive_component,
		name: route_name
	};
};