@gradio/core 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/blocks.d.ts +1 -0
- package/dist/blocks.js +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/login.d.ts +1 -0
- package/dist/login.js +1 -0
- package/dist/src/Blocks.svelte +671 -0
- package/dist/src/Blocks.svelte.d.ts +41 -0
- package/dist/src/Embed.svelte +195 -0
- package/dist/src/Embed.svelte.d.ts +26 -0
- package/dist/src/Login.svelte +107 -0
- package/dist/src/Login.svelte.d.ts +19 -0
- package/dist/src/MountComponents.svelte +26 -0
- package/dist/src/MountComponents.svelte.d.ts +26 -0
- package/dist/src/Render.svelte +91 -0
- package/dist/src/Render.svelte.d.ts +29 -0
- package/dist/src/RenderComponent.svelte +51 -0
- package/dist/src/RenderComponent.svelte.d.ts +32 -0
- package/dist/src/api_docs/ApiBanner.svelte +115 -0
- package/dist/src/api_docs/ApiBanner.svelte.d.ts +19 -0
- package/dist/src/api_docs/ApiDocs.svelte +388 -0
- package/dist/src/api_docs/ApiDocs.svelte.d.ts +27 -0
- package/dist/src/api_docs/ApiRecorder.svelte +72 -0
- package/dist/src/api_docs/ApiRecorder.svelte.d.ts +18 -0
- package/dist/src/api_docs/CodeSnippet.svelte +184 -0
- package/dist/src/api_docs/CodeSnippet.svelte.d.ts +24 -0
- package/dist/src/api_docs/CopyButton.svelte +15 -0
- package/dist/src/api_docs/CopyButton.svelte.d.ts +16 -0
- package/dist/src/api_docs/EndpointDetail.svelte +36 -0
- package/dist/src/api_docs/EndpointDetail.svelte.d.ts +18 -0
- package/dist/src/api_docs/InputPayload.svelte +149 -0
- package/dist/src/api_docs/InputPayload.svelte.d.ts +24 -0
- package/dist/src/api_docs/InstallSnippet.svelte +56 -0
- package/dist/src/api_docs/InstallSnippet.svelte.d.ts +16 -0
- package/dist/src/api_docs/NoApi.svelte +71 -0
- package/dist/src/api_docs/NoApi.svelte.d.ts +18 -0
- package/dist/src/api_docs/ParametersSnippet.svelte +104 -0
- package/dist/src/api_docs/ParametersSnippet.svelte.d.ts +19 -0
- package/dist/src/api_docs/RecordingSnippet.svelte +210 -0
- package/dist/src/api_docs/RecordingSnippet.svelte.d.ts +22 -0
- package/dist/src/api_docs/ResponseSnippet.svelte +95 -0
- package/dist/src/api_docs/ResponseSnippet.svelte.d.ts +19 -0
- package/dist/src/api_docs/TryButton.svelte +17 -0
- package/dist/src/api_docs/TryButton.svelte.d.ts +17 -0
- package/dist/src/api_docs/img/api-logo.svg +4 -0
- package/dist/src/api_docs/img/bash.svg +8 -0
- package/dist/src/api_docs/img/clear.svelte +19 -0
- package/dist/src/api_docs/img/clear.svelte.d.ts +23 -0
- package/dist/src/api_docs/img/javascript.svg +16 -0
- package/dist/src/api_docs/img/python.svg +20 -0
- package/dist/src/api_docs/index.d.ts +2 -0
- package/dist/src/api_docs/index.js +2 -0
- package/dist/src/api_docs/utils.d.ts +2 -0
- package/dist/src/api_docs/utils.js +135 -0
- package/dist/src/css.d.ts +2 -0
- package/dist/src/css.js +93 -0
- package/dist/src/gradio_helper.js +4 -0
- package/dist/src/i18n.d.ts +6 -0
- package/dist/src/i18n.js +22 -0
- package/dist/src/images/lightning.svg +2 -0
- package/dist/src/images/logo.svg +19 -0
- package/dist/src/images/play.svg +2 -0
- package/dist/src/images/spaces.svg +7 -0
- package/dist/src/init.d.ts +107 -0
- package/dist/src/init.js +377 -0
- package/dist/src/lang/BCP47_codes.d.ts +2 -0
- package/dist/src/lang/BCP47_codes.js +58 -0
- package/dist/src/lang/ar.json +16 -0
- package/dist/src/lang/ca.json +19 -0
- package/dist/src/lang/ckb.json +108 -0
- package/dist/src/lang/de.json +16 -0
- package/dist/src/lang/en.json +118 -0
- package/dist/src/lang/es.json +17 -0
- package/dist/src/lang/eu.json +16 -0
- package/dist/src/lang/fa.json +16 -0
- package/dist/src/lang/fr.json +30 -0
- package/dist/src/lang/he.json +16 -0
- package/dist/src/lang/hi.json +16 -0
- package/dist/src/lang/ja.json +16 -0
- package/dist/src/lang/ko.json +16 -0
- package/dist/src/lang/lt.json +16 -0
- package/dist/src/lang/nl.json +16 -0
- package/dist/src/lang/pl.json +16 -0
- package/dist/src/lang/pt-BR.json +19 -0
- package/dist/src/lang/ru.json +118 -0
- package/dist/src/lang/ta.json +16 -0
- package/dist/src/lang/tr.json +16 -0
- package/dist/src/lang/uk.json +16 -0
- package/dist/src/lang/ur.json +16 -0
- package/dist/src/lang/uz.json +15 -0
- package/dist/src/lang/zh-CN.json +115 -0
- package/dist/src/lang/zh-TW.json +16 -0
- package/dist/src/s-blocks.d.ts +1 -0
- package/dist/src/s-blocks.js +1 -0
- package/dist/src/s-login.d.ts +1 -0
- package/dist/src/s-login.js +1 -0
- package/dist/src/stores.d.ts +30 -0
- package/dist/src/stores.js +93 -0
- package/dist/src/types.d.ts +95 -0
- package/dist/src/types.js +1 -0
- package/dist/src/vite-env-override.d.ts +20 -0
- package/package.json +71 -60
- package/src/Render.svelte +3 -1
- package/src/api_docs/ApiDocs.svelte +1 -1
- package/src/api_docs/ApiRecorder.svelte +1 -1
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<script>import { createEventDispatcher } from "svelte";
|
|
2
|
+
import api_logo from "./img/api-logo.svg";
|
|
3
|
+
import Clear from "./img/clear.svelte";
|
|
4
|
+
import { BaseButton } from "@gradio/button";
|
|
5
|
+
export let root;
|
|
6
|
+
export let api_count;
|
|
7
|
+
const dispatch = createEventDispatcher();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<h2>
|
|
11
|
+
<img src={api_logo} alt="" />
|
|
12
|
+
<div class="title">
|
|
13
|
+
API documentation
|
|
14
|
+
<div class="url">
|
|
15
|
+
{root}
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
<span class="counts">
|
|
19
|
+
<BaseButton
|
|
20
|
+
size="sm"
|
|
21
|
+
variant="secondary"
|
|
22
|
+
elem_id="start-api-recorder"
|
|
23
|
+
on:click={() => dispatch("close", { api_recorder_visible: true })}
|
|
24
|
+
>
|
|
25
|
+
<div class="loading-dot self-baseline"></div>
|
|
26
|
+
<p class="self-baseline btn-text">API Recorder</p>
|
|
27
|
+
</BaseButton>
|
|
28
|
+
<p>
|
|
29
|
+
<span class="url">{api_count}</span> API endpoint{#if api_count > 1}s{/if}<br
|
|
30
|
+
/>
|
|
31
|
+
</p>
|
|
32
|
+
</span>
|
|
33
|
+
</h2>
|
|
34
|
+
|
|
35
|
+
<button on:click={() => dispatch("close")}>
|
|
36
|
+
<Clear />
|
|
37
|
+
</button>
|
|
38
|
+
|
|
39
|
+
<style>
|
|
40
|
+
h2 {
|
|
41
|
+
display: flex;
|
|
42
|
+
color: var(--body-text-color);
|
|
43
|
+
font-weight: var(--weight-semibold);
|
|
44
|
+
gap: var(--size-4);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
h2 img {
|
|
48
|
+
margin-right: var(--size-2);
|
|
49
|
+
width: var(--size-4);
|
|
50
|
+
display: inline-block;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.url {
|
|
54
|
+
color: var(--color-accent);
|
|
55
|
+
font-weight: normal;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
button {
|
|
59
|
+
position: absolute;
|
|
60
|
+
top: var(--size-5);
|
|
61
|
+
right: var(--size-6);
|
|
62
|
+
width: var(--size-4);
|
|
63
|
+
color: var(--body-text-color);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
button:hover {
|
|
67
|
+
color: var(--color-accent);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@media (--screen-md) {
|
|
71
|
+
button {
|
|
72
|
+
top: var(--size-6);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
h2 img {
|
|
76
|
+
width: var(--size-5);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.counts {
|
|
81
|
+
margin-top: auto;
|
|
82
|
+
margin-right: var(--size-8);
|
|
83
|
+
margin-bottom: auto;
|
|
84
|
+
margin-left: auto;
|
|
85
|
+
color: var(--body-text-color);
|
|
86
|
+
font-weight: var(--weight-light);
|
|
87
|
+
display: flex;
|
|
88
|
+
flex-direction: row;
|
|
89
|
+
gap: 0.5rem;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.loading-dot {
|
|
93
|
+
position: relative;
|
|
94
|
+
left: -9999px;
|
|
95
|
+
width: 12px;
|
|
96
|
+
height: 12px;
|
|
97
|
+
border-radius: 6px;
|
|
98
|
+
background-color: #fd7b00;
|
|
99
|
+
color: #fd7b00;
|
|
100
|
+
box-shadow: 9999px 0 0 -1px;
|
|
101
|
+
margin-right: 0.3rem;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.self-baseline {
|
|
105
|
+
align-self: baseline;
|
|
106
|
+
}
|
|
107
|
+
.title {
|
|
108
|
+
display: flex;
|
|
109
|
+
flex-direction: row;
|
|
110
|
+
gap: 0.5rem;
|
|
111
|
+
}
|
|
112
|
+
.btn-text {
|
|
113
|
+
font-size: var(--text-lg);
|
|
114
|
+
}
|
|
115
|
+
</style>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
root: string;
|
|
5
|
+
api_count: number;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
close: CustomEvent<any>;
|
|
9
|
+
} & {
|
|
10
|
+
[evt: string]: CustomEvent<any>;
|
|
11
|
+
};
|
|
12
|
+
slots: {};
|
|
13
|
+
};
|
|
14
|
+
export type ApiBannerProps = typeof __propDef.props;
|
|
15
|
+
export type ApiBannerEvents = typeof __propDef.events;
|
|
16
|
+
export type ApiBannerSlots = typeof __propDef.slots;
|
|
17
|
+
export default class ApiBanner extends SvelteComponent<ApiBannerProps, ApiBannerEvents, ApiBannerSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
<script>import { onMount, createEventDispatcher } from "svelte";
|
|
2
|
+
import NoApi from "./NoApi.svelte";
|
|
3
|
+
import ApiBanner from "./ApiBanner.svelte";
|
|
4
|
+
import { BaseButton as Button } from "@gradio/button";
|
|
5
|
+
import ParametersSnippet from "./ParametersSnippet.svelte";
|
|
6
|
+
import InstallSnippet from "./InstallSnippet.svelte";
|
|
7
|
+
import CodeSnippet from "./CodeSnippet.svelte";
|
|
8
|
+
import RecordingSnippet from "./RecordingSnippet.svelte";
|
|
9
|
+
import python from "./img/python.svg";
|
|
10
|
+
import javascript from "./img/javascript.svg";
|
|
11
|
+
import bash from "./img/bash.svg";
|
|
12
|
+
import ResponseSnippet from "./ResponseSnippet.svelte";
|
|
13
|
+
export let dependencies;
|
|
14
|
+
export let root;
|
|
15
|
+
export let app;
|
|
16
|
+
export let space_id;
|
|
17
|
+
export let root_node;
|
|
18
|
+
export let username;
|
|
19
|
+
const js_docs = "https://www.gradio.app/guides/getting-started-with-the-js-client";
|
|
20
|
+
const py_docs = "https://www.gradio.app/guides/getting-started-with-the-python-client";
|
|
21
|
+
const bash_docs = "https://www.gradio.app/guides/querying-gradio-apps-with-curl";
|
|
22
|
+
const spaces_docs_suffix = "#connecting-to-a-hugging-face-space";
|
|
23
|
+
let api_count = dependencies.filter(
|
|
24
|
+
(dependency) => dependency.show_api
|
|
25
|
+
).length;
|
|
26
|
+
if (root === "") {
|
|
27
|
+
root = location.protocol + "//" + location.host + location.pathname;
|
|
28
|
+
}
|
|
29
|
+
if (!root.endsWith("/")) {
|
|
30
|
+
root += "/";
|
|
31
|
+
}
|
|
32
|
+
export let api_calls = [];
|
|
33
|
+
let current_language = "python";
|
|
34
|
+
const langs = [
|
|
35
|
+
["python", python],
|
|
36
|
+
["javascript", javascript],
|
|
37
|
+
["bash", bash]
|
|
38
|
+
];
|
|
39
|
+
let is_running = false;
|
|
40
|
+
async function get_info() {
|
|
41
|
+
let response = await fetch(root + "info");
|
|
42
|
+
let data = await response.json();
|
|
43
|
+
return data;
|
|
44
|
+
}
|
|
45
|
+
async function get_js_info() {
|
|
46
|
+
let js_api_info = await app.view_api();
|
|
47
|
+
return js_api_info;
|
|
48
|
+
}
|
|
49
|
+
let info;
|
|
50
|
+
let js_info;
|
|
51
|
+
get_info().then((data) => {
|
|
52
|
+
info = data;
|
|
53
|
+
});
|
|
54
|
+
get_js_info().then((js_api_info) => {
|
|
55
|
+
js_info = js_api_info;
|
|
56
|
+
});
|
|
57
|
+
const dispatch = createEventDispatcher();
|
|
58
|
+
onMount(() => {
|
|
59
|
+
document.body.style.overflow = "hidden";
|
|
60
|
+
if ("parentIFrame" in window) {
|
|
61
|
+
window.parentIFrame?.scrollTo(0, 0);
|
|
62
|
+
}
|
|
63
|
+
return () => {
|
|
64
|
+
document.body.style.overflow = "auto";
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
{#if info}
|
|
70
|
+
{#if api_count}
|
|
71
|
+
<div class="banner-wrap">
|
|
72
|
+
<ApiBanner on:close root={space_id || root} {api_count} />
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
<div class="docs-wrap">
|
|
76
|
+
<div class="client-doc">
|
|
77
|
+
<p style="font-size: var(--text-lg);">
|
|
78
|
+
Choose a language to see the code snippets for interacting with the
|
|
79
|
+
API.
|
|
80
|
+
</p>
|
|
81
|
+
</div>
|
|
82
|
+
<div class="endpoint">
|
|
83
|
+
<div class="snippets">
|
|
84
|
+
{#each langs as [language, img]}
|
|
85
|
+
<li
|
|
86
|
+
class="snippet
|
|
87
|
+
{current_language === language ? 'current-lang' : 'inactive-lang'}"
|
|
88
|
+
on:click={() => (current_language = language)}
|
|
89
|
+
>
|
|
90
|
+
<img src={img} alt="" />
|
|
91
|
+
{language}
|
|
92
|
+
</li>
|
|
93
|
+
{/each}
|
|
94
|
+
</div>
|
|
95
|
+
{#if api_calls.length}
|
|
96
|
+
<div>
|
|
97
|
+
<p
|
|
98
|
+
id="num-recorded-api-calls"
|
|
99
|
+
style="font-size: var(--text-lg); font-weight:bold; margin: 10px 0px;"
|
|
100
|
+
>
|
|
101
|
+
🪄 Recorded API Calls <span class="api-count"
|
|
102
|
+
>[{api_calls.length}]</span
|
|
103
|
+
>
|
|
104
|
+
</p>
|
|
105
|
+
<p>
|
|
106
|
+
Here is the code snippet to replay the most recently recorded API
|
|
107
|
+
calls using the {current_language}
|
|
108
|
+
client.
|
|
109
|
+
</p>
|
|
110
|
+
|
|
111
|
+
<RecordingSnippet
|
|
112
|
+
{current_language}
|
|
113
|
+
{api_calls}
|
|
114
|
+
{dependencies}
|
|
115
|
+
{root}
|
|
116
|
+
short_root={space_id || root}
|
|
117
|
+
{username}
|
|
118
|
+
/>
|
|
119
|
+
<p>
|
|
120
|
+
Note: Some API calls only affect the UI, so when using the
|
|
121
|
+
clients, the desired result may be achieved with only a subset of
|
|
122
|
+
the recorded calls.
|
|
123
|
+
</p>
|
|
124
|
+
</div>
|
|
125
|
+
<p
|
|
126
|
+
style="font-size: var(--text-lg); font-weight:bold; margin: 30px 0px 10px;"
|
|
127
|
+
>
|
|
128
|
+
API Documentation
|
|
129
|
+
</p>
|
|
130
|
+
{:else}
|
|
131
|
+
<p class="padded">
|
|
132
|
+
{#if current_language == "python" || current_language == "javascript"}
|
|
133
|
+
1. Install the
|
|
134
|
+
<span style="text-transform:capitalize">{current_language}</span>
|
|
135
|
+
client (<a
|
|
136
|
+
href={current_language == "python" ? py_docs : js_docs}
|
|
137
|
+
target="_blank">docs</a
|
|
138
|
+
>) if you don't already have it installed.
|
|
139
|
+
{:else}
|
|
140
|
+
1. Confirm that you have cURL installed on your system.
|
|
141
|
+
{/if}
|
|
142
|
+
</p>
|
|
143
|
+
|
|
144
|
+
<InstallSnippet {current_language} />
|
|
145
|
+
|
|
146
|
+
<p class="padded">
|
|
147
|
+
2. Find the API endpoint below corresponding to your desired
|
|
148
|
+
function in the app. Copy the code snippet, replacing the
|
|
149
|
+
placeholder values with your own input data.
|
|
150
|
+
{#if space_id}If this is a private Space, you may need to pass your
|
|
151
|
+
Hugging Face token as well (<a
|
|
152
|
+
href={current_language == "python"
|
|
153
|
+
? py_docs + spaces_docs_suffix
|
|
154
|
+
: current_language == "javascript"
|
|
155
|
+
? js_docs + spaces_docs_suffix
|
|
156
|
+
: bash_docs}
|
|
157
|
+
class="underline"
|
|
158
|
+
target="_blank">read more</a
|
|
159
|
+
>).{/if}
|
|
160
|
+
|
|
161
|
+
Or use the
|
|
162
|
+
<Button
|
|
163
|
+
size="sm"
|
|
164
|
+
variant="secondary"
|
|
165
|
+
on:click={() => dispatch("close", { api_recorder_visible: true })}
|
|
166
|
+
>
|
|
167
|
+
<div class="loading-dot"></div>
|
|
168
|
+
<p class="self-baseline">API Recorder</p>
|
|
169
|
+
</Button>
|
|
170
|
+
to automatically generate your API requests.
|
|
171
|
+
{#if current_language == "bash"}<br /> <br />Making a
|
|
172
|
+
prediction and getting a result requires
|
|
173
|
+
<strong>2 requests</strong>: a
|
|
174
|
+
<code>POST</code>
|
|
175
|
+
and a <code>GET</code> request. The <code>POST</code> request
|
|
176
|
+
returns an <code>EVENT_ID</code>, which is used in the second
|
|
177
|
+
<code>GET</code> request to fetch the results. In these snippets,
|
|
178
|
+
we've used <code>awk</code> and <code>read</code> to parse the
|
|
179
|
+
results, combining these two requests into one command for ease of
|
|
180
|
+
use. {#if username !== null}
|
|
181
|
+
Note: connecting to an authenticated app requires an additional
|
|
182
|
+
request.{/if} See
|
|
183
|
+
<a href={bash_docs} target="_blank">curl docs</a>.
|
|
184
|
+
{/if}
|
|
185
|
+
|
|
186
|
+
<!-- <span
|
|
187
|
+
id="api-recorder"
|
|
188
|
+
on:click={() => dispatch("close", { api_recorder_visible: true })}
|
|
189
|
+
>🪄 API Recorder</span
|
|
190
|
+
> to automatically generate your API requests! -->
|
|
191
|
+
</p>
|
|
192
|
+
{/if}
|
|
193
|
+
|
|
194
|
+
{#each dependencies as dependency, dependency_index}
|
|
195
|
+
{#if dependency.show_api && info.named_endpoints["/" + dependency.api_name]}
|
|
196
|
+
<div class="endpoint-container">
|
|
197
|
+
<CodeSnippet
|
|
198
|
+
named={true}
|
|
199
|
+
endpoint_parameters={info.named_endpoints[
|
|
200
|
+
"/" + dependency.api_name
|
|
201
|
+
].parameters}
|
|
202
|
+
{dependency}
|
|
203
|
+
{dependency_index}
|
|
204
|
+
{current_language}
|
|
205
|
+
{root}
|
|
206
|
+
{space_id}
|
|
207
|
+
{username}
|
|
208
|
+
/>
|
|
209
|
+
|
|
210
|
+
<ParametersSnippet
|
|
211
|
+
endpoint_returns={info.named_endpoints[
|
|
212
|
+
"/" + dependency.api_name
|
|
213
|
+
].parameters}
|
|
214
|
+
js_returns={js_info.named_endpoints["/" + dependency.api_name]
|
|
215
|
+
.parameters}
|
|
216
|
+
{is_running}
|
|
217
|
+
{current_language}
|
|
218
|
+
/>
|
|
219
|
+
|
|
220
|
+
<ResponseSnippet
|
|
221
|
+
endpoint_returns={info.named_endpoints[
|
|
222
|
+
"/" + dependency.api_name
|
|
223
|
+
].returns}
|
|
224
|
+
js_returns={js_info.named_endpoints["/" + dependency.api_name]
|
|
225
|
+
.returns}
|
|
226
|
+
{is_running}
|
|
227
|
+
{current_language}
|
|
228
|
+
/>
|
|
229
|
+
</div>
|
|
230
|
+
{/if}
|
|
231
|
+
{/each}
|
|
232
|
+
</div>
|
|
233
|
+
</div>
|
|
234
|
+
{:else}
|
|
235
|
+
<NoApi {root} on:close />
|
|
236
|
+
{/if}
|
|
237
|
+
{/if}
|
|
238
|
+
|
|
239
|
+
<style>
|
|
240
|
+
.banner-wrap {
|
|
241
|
+
position: relative;
|
|
242
|
+
border-bottom: 1px solid var(--border-color-primary);
|
|
243
|
+
padding: var(--size-4) var(--size-6);
|
|
244
|
+
font-size: var(--text-md);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
@media (--screen-md) {
|
|
248
|
+
.banner-wrap {
|
|
249
|
+
font-size: var(--text-xl);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.docs-wrap {
|
|
254
|
+
display: flex;
|
|
255
|
+
flex-direction: column;
|
|
256
|
+
gap: var(--spacing-xxl);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.endpoint {
|
|
260
|
+
border-radius: var(--radius-md);
|
|
261
|
+
background: var(--background-fill-primary);
|
|
262
|
+
padding: var(--size-6);
|
|
263
|
+
padding-top: var(--size-1);
|
|
264
|
+
font-size: var(--text-md);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.client-doc {
|
|
268
|
+
padding-top: var(--size-6);
|
|
269
|
+
padding-right: var(--size-6);
|
|
270
|
+
padding-left: var(--size-6);
|
|
271
|
+
font-size: var(--text-md);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.library {
|
|
275
|
+
border: 1px solid var(--border-color-accent);
|
|
276
|
+
border-radius: var(--radius-sm);
|
|
277
|
+
background: var(--color-accent-soft);
|
|
278
|
+
padding: 0px var(--size-1);
|
|
279
|
+
color: var(--color-accent);
|
|
280
|
+
font-size: var(--text-md);
|
|
281
|
+
text-decoration: none;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.snippets {
|
|
285
|
+
display: flex;
|
|
286
|
+
align-items: center;
|
|
287
|
+
margin-bottom: var(--size-4);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.snippets > * + * {
|
|
291
|
+
margin-left: var(--size-2);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
.snippet {
|
|
295
|
+
display: flex;
|
|
296
|
+
align-items: center;
|
|
297
|
+
border: 1px solid var(--border-color-primary);
|
|
298
|
+
|
|
299
|
+
border-radius: var(--radius-md);
|
|
300
|
+
padding: var(--size-1) var(--size-1-5);
|
|
301
|
+
color: var(--body-text-color-subdued);
|
|
302
|
+
color: var(--body-text-color);
|
|
303
|
+
line-height: 1;
|
|
304
|
+
user-select: none;
|
|
305
|
+
text-transform: capitalize;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.current-lang {
|
|
309
|
+
border: 1px solid var(--body-text-color-subdued);
|
|
310
|
+
color: var(--body-text-color);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
.inactive-lang {
|
|
314
|
+
cursor: pointer;
|
|
315
|
+
color: var(--body-text-color-subdued);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.inactive-lang:hover,
|
|
319
|
+
.inactive-lang:focus {
|
|
320
|
+
box-shadow: var(--shadow-drop);
|
|
321
|
+
color: var(--body-text-color);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
.snippet img {
|
|
325
|
+
margin-right: var(--size-1-5);
|
|
326
|
+
width: var(--size-3);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.header {
|
|
330
|
+
margin-top: var(--size-6);
|
|
331
|
+
font-size: var(--text-xl);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.endpoint-container {
|
|
335
|
+
margin-top: var(--size-3);
|
|
336
|
+
margin-bottom: var(--size-3);
|
|
337
|
+
border: 1px solid var(--body-text-color);
|
|
338
|
+
border-radius: var(--radius-xl);
|
|
339
|
+
padding: var(--size-3);
|
|
340
|
+
padding-top: 0;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
a {
|
|
344
|
+
text-decoration: underline;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
p.padded {
|
|
348
|
+
padding: 15px 0px;
|
|
349
|
+
font-size: var(--text-lg);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
#api-recorder {
|
|
353
|
+
border: 1px solid var(--color-accent);
|
|
354
|
+
background-color: var(--color-accent-soft);
|
|
355
|
+
padding: 0px var(--size-2);
|
|
356
|
+
border-radius: var(--size-1);
|
|
357
|
+
cursor: pointer;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
code {
|
|
361
|
+
font-size: var(--text-md);
|
|
362
|
+
}
|
|
363
|
+
.loading-dot {
|
|
364
|
+
position: relative;
|
|
365
|
+
left: -9999px;
|
|
366
|
+
width: 10px;
|
|
367
|
+
height: 10px;
|
|
368
|
+
border-radius: 5px;
|
|
369
|
+
background-color: #fd7b00;
|
|
370
|
+
color: #fd7b00;
|
|
371
|
+
box-shadow: 9999px 0 0 -1px;
|
|
372
|
+
margin-right: 0.25rem;
|
|
373
|
+
}
|
|
374
|
+
:global(.docs-wrap .sm.secondary) {
|
|
375
|
+
padding-top: 1px;
|
|
376
|
+
padding-bottom: 1px;
|
|
377
|
+
}
|
|
378
|
+
.self-baseline {
|
|
379
|
+
align-self: baseline;
|
|
380
|
+
}
|
|
381
|
+
.api-count {
|
|
382
|
+
font-weight: bold;
|
|
383
|
+
color: #fd7b00;
|
|
384
|
+
align-self: baseline;
|
|
385
|
+
font-family: var(--font-mono);
|
|
386
|
+
font-size: var(--text-md);
|
|
387
|
+
}
|
|
388
|
+
</style>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { ComponentMeta, Dependency } from "../types";
|
|
3
|
+
import type { Client } from "@gradio/client";
|
|
4
|
+
import type { Payload } from "../types";
|
|
5
|
+
declare const __propDef: {
|
|
6
|
+
props: {
|
|
7
|
+
dependencies: Dependency[];
|
|
8
|
+
root: string;
|
|
9
|
+
app: Awaited<ReturnType<typeof Client.connect>>;
|
|
10
|
+
space_id: string | null;
|
|
11
|
+
root_node: ComponentMeta;
|
|
12
|
+
username: string | null;
|
|
13
|
+
api_calls?: Payload[] | undefined;
|
|
14
|
+
};
|
|
15
|
+
events: {
|
|
16
|
+
close: CustomEvent<any>;
|
|
17
|
+
} & {
|
|
18
|
+
[evt: string]: CustomEvent<any>;
|
|
19
|
+
};
|
|
20
|
+
slots: {};
|
|
21
|
+
};
|
|
22
|
+
export type ApiDocsProps = typeof __propDef.props;
|
|
23
|
+
export type ApiDocsEvents = typeof __propDef.events;
|
|
24
|
+
export type ApiDocsSlots = typeof __propDef.slots;
|
|
25
|
+
export default class ApiDocs extends SvelteComponent<ApiDocsProps, ApiDocsEvents, ApiDocsSlots> {
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<script>import { BaseButton as Button } from "@gradio/button";
|
|
2
|
+
export let api_calls = [];
|
|
3
|
+
export let dependencies;
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<div id="api-recorder">
|
|
7
|
+
<Button size="sm" variant="secondary">
|
|
8
|
+
<div class="loading-dot self-baseline"></div>
|
|
9
|
+
<p class="self-baseline">Recording API Calls:</p>
|
|
10
|
+
<p class="self-baseline api-section">
|
|
11
|
+
<span class="api-count">
|
|
12
|
+
[{api_calls.length}]
|
|
13
|
+
</span>
|
|
14
|
+
{#if api_calls.length > 0}
|
|
15
|
+
<span class="api-name"
|
|
16
|
+
>/{dependencies[api_calls[api_calls.length - 1].fn_index]
|
|
17
|
+
.api_name}</span
|
|
18
|
+
>
|
|
19
|
+
{/if}
|
|
20
|
+
</p>
|
|
21
|
+
</Button>
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
<style>
|
|
25
|
+
.api-name {
|
|
26
|
+
font-size: var(--text-sm);
|
|
27
|
+
font-family: var(--font-mono);
|
|
28
|
+
color: #fd7b00;
|
|
29
|
+
}
|
|
30
|
+
.loading-dot {
|
|
31
|
+
position: relative;
|
|
32
|
+
left: -9999px;
|
|
33
|
+
width: 10px;
|
|
34
|
+
height: 10px;
|
|
35
|
+
border-radius: 5px;
|
|
36
|
+
background-color: #fd7b00;
|
|
37
|
+
color: #fd7b00;
|
|
38
|
+
box-shadow: 9999px 0 0 -1px;
|
|
39
|
+
animation: loading-dot 2s infinite linear;
|
|
40
|
+
animation-delay: 0.25s;
|
|
41
|
+
margin-left: 0.25rem;
|
|
42
|
+
margin-right: 0.5rem;
|
|
43
|
+
}
|
|
44
|
+
:global(.docs-wrap .sm.secondary) {
|
|
45
|
+
padding-top: 1px;
|
|
46
|
+
padding-bottom: 1px;
|
|
47
|
+
}
|
|
48
|
+
.self-baseline {
|
|
49
|
+
align-self: baseline;
|
|
50
|
+
}
|
|
51
|
+
@keyframes loading-dot {
|
|
52
|
+
0% {
|
|
53
|
+
box-shadow: 9999px 0 0 -1px;
|
|
54
|
+
}
|
|
55
|
+
50% {
|
|
56
|
+
box-shadow: 9999px 0 0 2px;
|
|
57
|
+
}
|
|
58
|
+
100% {
|
|
59
|
+
box-shadow: 9999px 0 0 -1px;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
.api-count {
|
|
63
|
+
font-weight: bold;
|
|
64
|
+
color: #fd7b00;
|
|
65
|
+
align-self: baseline;
|
|
66
|
+
font-family: var(--font-mono);
|
|
67
|
+
font-size: var(--text-sm);
|
|
68
|
+
}
|
|
69
|
+
.api-section {
|
|
70
|
+
margin-left: 4px;
|
|
71
|
+
}
|
|
72
|
+
</style>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { Payload, Dependency } from "../types";
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
api_calls?: Payload[] | undefined;
|
|
6
|
+
dependencies: Dependency[];
|
|
7
|
+
};
|
|
8
|
+
events: {
|
|
9
|
+
[evt: string]: CustomEvent<any>;
|
|
10
|
+
};
|
|
11
|
+
slots: {};
|
|
12
|
+
};
|
|
13
|
+
export type ApiRecorderProps = typeof __propDef.props;
|
|
14
|
+
export type ApiRecorderEvents = typeof __propDef.events;
|
|
15
|
+
export type ApiRecorderSlots = typeof __propDef.slots;
|
|
16
|
+
export default class ApiRecorder extends SvelteComponent<ApiRecorderProps, ApiRecorderEvents, ApiRecorderSlots> {
|
|
17
|
+
}
|
|
18
|
+
export {};
|