@gradio/core 1.0.0-dev.0 → 1.0.0
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 +110 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/src/Blocks.svelte +534 -1001
- package/dist/src/Blocks.svelte.d.ts +32 -45
- package/dist/src/Embed.svelte +82 -55
- package/dist/src/Embed.svelte.d.ts +39 -30
- package/dist/src/Login.svelte +33 -29
- package/dist/src/Login.svelte.d.ts +21 -19
- package/dist/src/MountComponents.svelte +19 -25
- package/dist/src/MountComponents.svelte.d.ts +5 -28
- package/dist/src/{init.d.ts → _init.d.ts} +5 -4
- package/dist/src/{init.js → _init.js} +31 -108
- package/dist/src/api_docs/ApiBanner.svelte +12 -8
- package/dist/src/api_docs/ApiBanner.svelte.d.ts +22 -20
- package/dist/src/api_docs/ApiDocs.svelte +356 -247
- package/dist/src/api_docs/ApiDocs.svelte.d.ts +27 -24
- package/dist/src/api_docs/ApiRecorder.svelte +6 -3
- package/dist/src/api_docs/ApiRecorder.svelte.d.ts +19 -17
- package/dist/src/api_docs/CodeSnippet.svelte +122 -48
- package/dist/src/api_docs/CodeSnippet.svelte.d.ts +29 -25
- package/dist/src/api_docs/CopyButton.svelte +69 -13
- package/dist/src/api_docs/CopyButton.svelte.d.ts +18 -16
- package/dist/src/api_docs/CopyMarkdown.svelte +734 -0
- package/dist/src/api_docs/CopyMarkdown.svelte.d.ts +37 -0
- package/dist/src/api_docs/EndpointDetail.svelte +81 -23
- package/dist/src/api_docs/EndpointDetail.svelte.d.ts +23 -18
- package/dist/src/api_docs/IconArrowUpRight.svelte +34 -0
- package/dist/src/api_docs/IconArrowUpRight.svelte.d.ts +20 -0
- package/dist/src/api_docs/IconCaret.svelte +39 -0
- package/dist/src/api_docs/IconCaret.svelte.d.ts +20 -0
- package/dist/src/api_docs/IconHuggingChat.svelte +62 -0
- package/dist/src/api_docs/IconHuggingChat.svelte.d.ts +20 -0
- package/dist/src/api_docs/InputPayload.svelte +17 -11
- package/dist/src/api_docs/InputPayload.svelte.d.ts +25 -23
- package/dist/src/api_docs/InstallSnippet.svelte +9 -6
- package/dist/src/api_docs/InstallSnippet.svelte.d.ts +18 -16
- package/dist/src/api_docs/MCPSnippet.svelte +139 -126
- package/dist/src/api_docs/MCPSnippet.svelte.d.ts +60 -58
- package/dist/src/api_docs/NoApi.svelte +7 -4
- package/dist/src/api_docs/NoApi.svelte.d.ts +20 -18
- package/dist/src/api_docs/ParametersSnippet.svelte +8 -6
- package/dist/src/api_docs/ParametersSnippet.svelte.d.ts +21 -19
- package/dist/src/api_docs/PercentileChart.svelte +125 -0
- package/dist/src/api_docs/PercentileChart.svelte.d.ts +22 -0
- package/dist/src/api_docs/RecordingSnippet.svelte +124 -110
- package/dist/src/api_docs/RecordingSnippet.svelte.d.ts +24 -22
- package/dist/src/api_docs/ResponseSnippet.svelte +7 -5
- package/dist/src/api_docs/ResponseSnippet.svelte.d.ts +21 -19
- package/dist/src/api_docs/Settings.svelte +73 -62
- package/dist/src/api_docs/Settings.svelte.d.ts +25 -23
- package/dist/src/api_docs/SettingsBanner.svelte +11 -8
- package/dist/src/api_docs/SettingsBanner.svelte.d.ts +20 -18
- package/dist/src/api_docs/TryButton.svelte +5 -3
- package/dist/src/api_docs/TryButton.svelte.d.ts +19 -17
- package/dist/src/api_docs/img/IconCheck.svelte +33 -0
- package/dist/src/api_docs/img/IconCheck.svelte.d.ts +26 -0
- package/dist/src/api_docs/img/IconCopy.svelte +40 -0
- package/dist/src/api_docs/img/IconCopy.svelte.d.ts +26 -0
- package/dist/src/api_docs/img/clear.svelte.d.ts +22 -21
- package/dist/src/dependency.d.ts +145 -0
- package/dist/src/dependency.js +668 -0
- package/dist/src/init.svelte.d.ts +78 -0
- package/dist/src/init.svelte.js +469 -0
- package/dist/src/init_utils.d.ts +32 -0
- package/dist/src/init_utils.js +73 -0
- package/dist/src/lang/en.json +10 -1
- package/dist/src/lang/get_lang_names.js +0 -3
- package/dist/src/lang/ru.json +10 -1
- package/dist/src/stores.d.ts +0 -21
- package/dist/src/stories/I18nMultiLanguageTestComponent.svelte +5 -3
- package/dist/src/stories/I18nMultiLanguageTestComponent.svelte.d.ts +16 -14
- package/dist/src/stories/I18nTestSetup.svelte +14 -10
- package/dist/src/stories/I18nTestSetup.svelte.d.ts +18 -16
- package/dist/src/types.d.ts +31 -26
- package/index.ts +1 -1
- package/package.json +62 -63
- package/src/Blocks.svelte +360 -1063
- package/src/MountComponents.svelte +17 -27
- package/src/{init.ts → _init.ts} +49 -126
- package/src/api_docs/ApiDocs.svelte +84 -62
- package/src/api_docs/CodeSnippet.svelte +83 -24
- package/src/api_docs/CopyButton.svelte +61 -7
- package/src/api_docs/CopyMarkdown.svelte +734 -0
- package/src/api_docs/EndpointDetail.svelte +73 -17
- package/src/api_docs/IconArrowUpRight.svelte +34 -0
- package/src/api_docs/IconCaret.svelte +39 -0
- package/src/api_docs/IconHuggingChat.svelte +62 -0
- package/src/api_docs/MCPSnippet.svelte +44 -73
- package/src/api_docs/ParametersSnippet.svelte +1 -1
- package/src/api_docs/PercentileChart.svelte +125 -0
- package/src/api_docs/ResponseSnippet.svelte +1 -1
- package/src/api_docs/Settings.svelte +11 -11
- package/src/api_docs/img/IconCheck.svelte +33 -0
- package/src/api_docs/img/IconCopy.svelte +40 -0
- package/src/dependency.ts +909 -0
- package/src/init.svelte.ts +717 -0
- package/src/init_utils.ts +99 -0
- package/src/lang/en.json +10 -1
- package/src/lang/get_lang_names.js +0 -3
- package/src/lang/ru.json +10 -1
- package/src/stores.ts +22 -22
- package/src/types.ts +55 -43
- package/dist/src/Render.svelte +0 -105
- package/dist/src/Render.svelte.d.ts +0 -31
- package/dist/src/RenderComponent.svelte +0 -72
- package/dist/src/RenderComponent.svelte.d.ts +0 -33
- package/src/Render.svelte +0 -126
- package/src/RenderComponent.svelte +0 -91
|
@@ -1,29 +1,32 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { ComponentMeta, Dependency } from "../types";
|
|
3
2
|
import type { Client } from "@gradio/client";
|
|
4
3
|
import type { Payload } from "../types";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
5
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
6
|
+
$$bindings?: Bindings;
|
|
7
|
+
} & Exports;
|
|
8
|
+
(internal: unknown, props: Props & {
|
|
9
|
+
$$events?: Events;
|
|
10
|
+
$$slots?: Slots;
|
|
11
|
+
}): Exports & {
|
|
12
|
+
$set?: any;
|
|
13
|
+
$on?: any;
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
close: CustomEvent<any>;
|
|
17
|
-
} & {
|
|
18
|
-
[evt: string]: CustomEvent<any>;
|
|
19
|
-
};
|
|
20
|
-
slots: {};
|
|
21
|
-
exports?: {} | undefined;
|
|
22
|
-
bindings?: string | undefined;
|
|
23
|
-
};
|
|
24
|
-
export type ApiDocsProps = typeof __propDef.props;
|
|
25
|
-
export type ApiDocsEvents = typeof __propDef.events;
|
|
26
|
-
export type ApiDocsSlots = typeof __propDef.slots;
|
|
27
|
-
export default class ApiDocs extends SvelteComponent<ApiDocsProps, ApiDocsEvents, ApiDocsSlots> {
|
|
15
|
+
z_$$bindings?: Bindings;
|
|
28
16
|
}
|
|
29
|
-
|
|
17
|
+
declare const ApiDocs: $$__sveltets_2_IsomorphicComponent<{
|
|
18
|
+
dependencies: Dependency[];
|
|
19
|
+
root: string;
|
|
20
|
+
app: Awaited<ReturnType<typeof Client.connect>>;
|
|
21
|
+
space_id: string | null;
|
|
22
|
+
root_node: ComponentMeta;
|
|
23
|
+
username: string | null;
|
|
24
|
+
last_api_call?: Payload | null;
|
|
25
|
+
api_calls?: Payload[];
|
|
26
|
+
}, {
|
|
27
|
+
close: CustomEvent<any>;
|
|
28
|
+
} & {
|
|
29
|
+
[evt: string]: CustomEvent<any>;
|
|
30
|
+
}, {}, {}, string>;
|
|
31
|
+
type ApiDocs = InstanceType<typeof ApiDocs>;
|
|
32
|
+
export default ApiDocs;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Payload, Dependency } from "../types";
|
|
3
|
+
import { BaseButton as Button } from "@gradio/button";
|
|
4
|
+
|
|
5
|
+
export let api_calls: Payload[] = [];
|
|
6
|
+
export let dependencies: Dependency[];
|
|
4
7
|
</script>
|
|
5
8
|
|
|
6
9
|
<div id="api-recorder">
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { Payload, Dependency } from "../types";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
7
12
|
};
|
|
8
|
-
|
|
9
|
-
[evt: string]: CustomEvent<any>;
|
|
10
|
-
};
|
|
11
|
-
slots: {};
|
|
12
|
-
exports?: {} | undefined;
|
|
13
|
-
bindings?: string | undefined;
|
|
14
|
-
};
|
|
15
|
-
export type ApiRecorderProps = typeof __propDef.props;
|
|
16
|
-
export type ApiRecorderEvents = typeof __propDef.events;
|
|
17
|
-
export type ApiRecorderSlots = typeof __propDef.slots;
|
|
18
|
-
export default class ApiRecorder extends SvelteComponent<ApiRecorderProps, ApiRecorderEvents, ApiRecorderSlots> {
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
19
14
|
}
|
|
20
|
-
|
|
15
|
+
declare const ApiRecorder: $$__sveltets_2_IsomorphicComponent<{
|
|
16
|
+
api_calls?: Payload[];
|
|
17
|
+
dependencies: Dependency[];
|
|
18
|
+
}, {
|
|
19
|
+
[evt: string]: CustomEvent<any>;
|
|
20
|
+
}, {}, {}, string>;
|
|
21
|
+
type ApiRecorder = InstanceType<typeof ApiRecorder>;
|
|
22
|
+
export default ApiRecorder;
|
|
@@ -1,29 +1,75 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
let
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
let
|
|
22
|
-
let
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ComponentMeta, Dependency, Payload } from "../types";
|
|
3
|
+
import CopyButton from "./CopyButton.svelte";
|
|
4
|
+
import { represent_value, is_potentially_nested_file_data } from "./utils";
|
|
5
|
+
import { Block } from "@gradio/atoms";
|
|
6
|
+
import EndpointDetail from "./EndpointDetail.svelte";
|
|
7
|
+
|
|
8
|
+
interface EndpointParameter {
|
|
9
|
+
label: string;
|
|
10
|
+
type: string;
|
|
11
|
+
python_type: { type: string };
|
|
12
|
+
component: string;
|
|
13
|
+
example_input: string;
|
|
14
|
+
serializer: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export let dependency: Dependency;
|
|
18
|
+
export let root: string;
|
|
19
|
+
export let api_prefix: string;
|
|
20
|
+
export let space_id: string | null;
|
|
21
|
+
export let endpoint_parameters: any;
|
|
22
|
+
export let username: string | null;
|
|
23
|
+
export let current_language: "python" | "javascript" | "bash" | "mcp";
|
|
24
|
+
export let api_description: string | null = null;
|
|
25
|
+
export let analytics: Record<string, any>;
|
|
26
|
+
export let markdown_code_snippets: Record<string, Record<string, string>>;
|
|
27
|
+
export let last_api_call: Payload | null = null;
|
|
28
|
+
|
|
29
|
+
let python_code: HTMLElement;
|
|
30
|
+
let js_code: HTMLElement;
|
|
31
|
+
let bash_post_code: HTMLElement;
|
|
32
|
+
let bash_get_code: HTMLElement;
|
|
33
|
+
|
|
34
|
+
let has_file_path = endpoint_parameters.some((param: EndpointParameter) =>
|
|
35
|
+
is_potentially_nested_file_data(param.example_input)
|
|
36
|
+
);
|
|
37
|
+
let blob_components = ["Audio", "File", "Image", "Video"];
|
|
38
|
+
let blob_examples: any[] = endpoint_parameters.filter(
|
|
39
|
+
(param: EndpointParameter) => blob_components.includes(param.component)
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
$: normalised_api_prefix = api_prefix ? api_prefix : "/";
|
|
43
|
+
$: normalised_root = root.replace(/\/$/, "");
|
|
44
|
+
|
|
45
|
+
$: is_most_recently_used = last_api_call?.fn_index === dependency.id;
|
|
46
|
+
|
|
47
|
+
$: actual_data =
|
|
48
|
+
is_most_recently_used && last_api_call?.data
|
|
49
|
+
? last_api_call.data.filter((d) => typeof d !== "undefined")
|
|
50
|
+
: null;
|
|
51
|
+
|
|
52
|
+
function getParameterValue(param: any, index: number): any {
|
|
53
|
+
if (
|
|
54
|
+
is_most_recently_used &&
|
|
55
|
+
actual_data &&
|
|
56
|
+
actual_data[index] !== undefined
|
|
57
|
+
) {
|
|
58
|
+
return actual_data[index];
|
|
59
|
+
}
|
|
60
|
+
return param.parameter_has_default !== undefined &&
|
|
61
|
+
param.parameter_has_default
|
|
62
|
+
? param.parameter_default
|
|
63
|
+
: param.example_input;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
$: markdown_code_snippets[
|
|
67
|
+
dependency.api_name as keyof typeof markdown_code_snippets
|
|
68
|
+
] = {
|
|
69
|
+
python: python_code?.innerText || "",
|
|
70
|
+
javascript: js_code?.innerText || "",
|
|
71
|
+
bash: bash_post_code?.innerText || ""
|
|
72
|
+
};
|
|
27
73
|
</script>
|
|
28
74
|
|
|
29
75
|
<div class="container">
|
|
@@ -31,8 +77,10 @@ $: normalised_root = root.replace(/\/$/, "");
|
|
|
31
77
|
api_name={dependency.api_name}
|
|
32
78
|
description={api_description}
|
|
33
79
|
{analytics}
|
|
80
|
+
{last_api_call}
|
|
81
|
+
dependency_id={dependency.id}
|
|
34
82
|
/>
|
|
35
|
-
{
|
|
83
|
+
<div class:hidden={current_language !== "python"}>
|
|
36
84
|
<Block>
|
|
37
85
|
<code>
|
|
38
86
|
<div class="copy">
|
|
@@ -47,14 +95,16 @@ client = Client(<span class="token string">"{space_id || root}"</span
|
|
|
47
95
|
>{#if username !== null}, auth=("{username}", **password**){/if})
|
|
48
96
|
result = client.<span class="highlight">predict</span
|
|
49
97
|
>(<!--
|
|
50
|
-
-->{#each endpoint_parameters as
|
|
98
|
+
-->{#each endpoint_parameters as param, i}<!--
|
|
51
99
|
-->
|
|
52
|
-
{parameter_name
|
|
53
|
-
? parameter_name + "="
|
|
100
|
+
{param.parameter_name
|
|
101
|
+
? param.parameter_name + "="
|
|
54
102
|
: ""}<span
|
|
103
|
+
class:recent-value={is_most_recently_used &&
|
|
104
|
+
actual_data?.[i] !== undefined}
|
|
55
105
|
>{represent_value(
|
|
56
|
-
|
|
57
|
-
python_type.type,
|
|
106
|
+
getParameterValue(param, i),
|
|
107
|
+
param.python_type.type,
|
|
58
108
|
"py"
|
|
59
109
|
)}</span
|
|
60
110
|
>,{/each}<!--
|
|
@@ -67,7 +117,8 @@ result = client.<span class="highlight">predict</span
|
|
|
67
117
|
</div>
|
|
68
118
|
</code>
|
|
69
119
|
</Block>
|
|
70
|
-
|
|
120
|
+
</div>
|
|
121
|
+
<div class:hidden={current_language !== "javascript"}>
|
|
71
122
|
<Block>
|
|
72
123
|
<code>
|
|
73
124
|
<div class="copy">
|
|
@@ -87,22 +138,26 @@ result = client.<span class="highlight">predict</span
|
|
|
87
138
|
const result = await client.predict(<span class="api-name"
|
|
88
139
|
>"/{dependency.api_name}"</span
|
|
89
140
|
>, { <!--
|
|
90
|
-
-->{#each endpoint_parameters as
|
|
91
|
-
-->{#if blob_components.includes(component)}<!--
|
|
141
|
+
-->{#each endpoint_parameters as param, i}<!--
|
|
142
|
+
-->{#if blob_components.includes(param.component)}<!--
|
|
92
143
|
-->
|
|
93
144
|
<span
|
|
94
145
|
class="example-inputs"
|
|
95
|
-
>{parameter_name}: example{component}</span
|
|
146
|
+
>{param.parameter_name}: example{param.component}</span
|
|
96
147
|
>, <!--
|
|
97
148
|
--><span class="desc"><!--
|
|
98
149
|
--></span
|
|
99
150
|
><!--
|
|
100
151
|
-->{:else}<!--
|
|
101
152
|
-->
|
|
102
|
-
<span
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
153
|
+
<span
|
|
154
|
+
class="example-inputs {is_most_recently_used &&
|
|
155
|
+
actual_data?.[i] !== undefined
|
|
156
|
+
? 'recent-value'
|
|
157
|
+
: ''}"
|
|
158
|
+
>{param.parameter_name}: {represent_value(
|
|
159
|
+
getParameterValue(param, i),
|
|
160
|
+
param.python_type.type,
|
|
106
161
|
"js"
|
|
107
162
|
)}</span
|
|
108
163
|
>, <!--
|
|
@@ -116,7 +171,8 @@ result = client.<span class="highlight">predict</span
|
|
|
116
171
|
</div>
|
|
117
172
|
</code>
|
|
118
173
|
</Block>
|
|
119
|
-
|
|
174
|
+
</div>
|
|
175
|
+
<div class:hidden={current_language !== "bash"}>
|
|
120
176
|
<Block>
|
|
121
177
|
<code>
|
|
122
178
|
<div class="copy">
|
|
@@ -125,13 +181,18 @@ result = client.<span class="highlight">predict</span
|
|
|
125
181
|
|
|
126
182
|
<div bind:this={bash_post_code}>
|
|
127
183
|
<pre>curl -X POST {normalised_root}{normalised_api_prefix}/call/{dependency.api_name} -s -H "Content-Type: application/json" -d '{"{"}
|
|
128
|
-
"data": [{#each endpoint_parameters as
|
|
184
|
+
"data": [{#each endpoint_parameters as param, i}
|
|
129
185
|
<!--
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
186
|
+
--><span
|
|
187
|
+
class={is_most_recently_used && actual_data?.[i] !== undefined
|
|
188
|
+
? "recent-value"
|
|
189
|
+
: ""}
|
|
190
|
+
>{represent_value(
|
|
191
|
+
getParameterValue(param, i),
|
|
192
|
+
param.python_type.type,
|
|
193
|
+
"bash"
|
|
194
|
+
)}</span
|
|
195
|
+
>{#if i < endpoint_parameters.length - 1},
|
|
135
196
|
{/if}
|
|
136
197
|
{/each}
|
|
137
198
|
]{"}"}' \
|
|
@@ -140,7 +201,7 @@ result = client.<span class="highlight">predict</span
|
|
|
140
201
|
</div>
|
|
141
202
|
</code>
|
|
142
203
|
</Block>
|
|
143
|
-
|
|
204
|
+
</div>
|
|
144
205
|
</div>
|
|
145
206
|
|
|
146
207
|
<style>
|
|
@@ -184,4 +245,17 @@ result = client.<span class="highlight">predict</span
|
|
|
184
245
|
.api-name {
|
|
185
246
|
color: var(--color-accent);
|
|
186
247
|
}
|
|
248
|
+
|
|
249
|
+
.recent-value {
|
|
250
|
+
color: #fd7b00;
|
|
251
|
+
background: #fff4e6;
|
|
252
|
+
border: 1px solid #ffd9b3;
|
|
253
|
+
border-radius: var(--radius-sm);
|
|
254
|
+
padding: 1px 4px;
|
|
255
|
+
font-weight: var(--weight-medium);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.hidden {
|
|
259
|
+
display: none;
|
|
260
|
+
}
|
|
187
261
|
</style>
|
|
@@ -1,27 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
api_description?: string | null;
|
|
13
|
-
analytics: Record<string, any>;
|
|
1
|
+
import type { Dependency, Payload } from "../types";
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
14
12
|
};
|
|
15
|
-
|
|
16
|
-
[evt: string]: CustomEvent<any>;
|
|
17
|
-
};
|
|
18
|
-
slots: {};
|
|
19
|
-
exports?: {} | undefined;
|
|
20
|
-
bindings?: string | undefined;
|
|
21
|
-
};
|
|
22
|
-
export type CodeSnippetProps = typeof __propDef.props;
|
|
23
|
-
export type CodeSnippetEvents = typeof __propDef.events;
|
|
24
|
-
export type CodeSnippetSlots = typeof __propDef.slots;
|
|
25
|
-
export default class CodeSnippet extends SvelteComponent<CodeSnippetProps, CodeSnippetEvents, CodeSnippetSlots> {
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
26
14
|
}
|
|
27
|
-
|
|
15
|
+
declare const CodeSnippet: $$__sveltets_2_IsomorphicComponent<{
|
|
16
|
+
dependency: Dependency;
|
|
17
|
+
root: string;
|
|
18
|
+
api_prefix: string;
|
|
19
|
+
space_id: string | null;
|
|
20
|
+
endpoint_parameters: any;
|
|
21
|
+
username: string | null;
|
|
22
|
+
current_language: "python" | "javascript" | "bash" | "mcp";
|
|
23
|
+
api_description?: string | null;
|
|
24
|
+
analytics: Record<string, any>;
|
|
25
|
+
markdown_code_snippets: Record<string, Record<string, string>>;
|
|
26
|
+
last_api_call?: Payload | null;
|
|
27
|
+
}, {
|
|
28
|
+
[evt: string]: CustomEvent<any>;
|
|
29
|
+
}, {}, {}, string>;
|
|
30
|
+
type CodeSnippet = InstanceType<typeof CodeSnippet>;
|
|
31
|
+
export default CodeSnippet;
|
|
@@ -1,15 +1,71 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import IconCopy from "./img/IconCopy.svelte";
|
|
3
|
+
import IconCheck from "./img/IconCheck.svelte";
|
|
4
|
+
|
|
5
|
+
export let code: string;
|
|
6
|
+
|
|
7
|
+
let copied = false;
|
|
8
|
+
|
|
9
|
+
function copy(): void {
|
|
10
|
+
navigator.clipboard.writeText(code);
|
|
11
|
+
copied = true;
|
|
12
|
+
setTimeout(() => {
|
|
13
|
+
copied = false;
|
|
14
|
+
}, 1500);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
$: copied;
|
|
11
18
|
</script>
|
|
12
19
|
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
<button on:click={copy} class="copy-button" aria-live="polite">
|
|
21
|
+
<span
|
|
22
|
+
class="inline-flex items-center justify-center rounded-md p-0.5 max-sm:p-0"
|
|
23
|
+
>
|
|
24
|
+
{#if copied}
|
|
25
|
+
<IconCheck classNames="w-3 h-3 max-sm:w-2.5 max-sm:h-2.5" />
|
|
26
|
+
{:else}
|
|
27
|
+
<IconCopy classNames="w-3 h-3 max-sm:w-2.5 max-sm:h-2.5" />
|
|
28
|
+
{/if}
|
|
29
|
+
</span>
|
|
30
|
+
</button>
|
|
31
|
+
|
|
32
|
+
<style>
|
|
33
|
+
.copy-button {
|
|
34
|
+
display: inline-flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
gap: 4px;
|
|
37
|
+
height: 24px;
|
|
38
|
+
padding-left: 8px;
|
|
39
|
+
padding-right: 8px;
|
|
40
|
+
font-size: 11px;
|
|
41
|
+
font-weight: 500;
|
|
42
|
+
color: rgb(31, 41, 55);
|
|
43
|
+
border: 1px solid rgb(229, 231, 235);
|
|
44
|
+
border-radius: 6px;
|
|
45
|
+
background-color: white;
|
|
46
|
+
|
|
47
|
+
@media (max-width: 640px) {
|
|
48
|
+
gap: 2px;
|
|
49
|
+
height: 20px;
|
|
50
|
+
padding-left: 6px;
|
|
51
|
+
padding-right: 6px;
|
|
52
|
+
font-size: 9px;
|
|
53
|
+
border-top-left-radius: 4px;
|
|
54
|
+
border-bottom-left-radius: 4px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&:hover {
|
|
58
|
+
box-shadow: inset 0 2px 4px 0 rgb(0 0 0 / 0.05);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@media (prefers-color-scheme: dark) {
|
|
62
|
+
border-color: rgb(38, 38, 38);
|
|
63
|
+
background-color: rgb(10, 10, 10);
|
|
64
|
+
color: rgb(229, 231, 235);
|
|
65
|
+
|
|
66
|
+
&:hover {
|
|
67
|
+
background-color: rgb(38, 38, 38);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
</style>
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: Props & {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
5
11
|
};
|
|
6
|
-
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
};
|
|
9
|
-
slots: {};
|
|
10
|
-
exports?: {} | undefined;
|
|
11
|
-
bindings?: string | undefined;
|
|
12
|
-
};
|
|
13
|
-
export type CopyButtonProps = typeof __propDef.props;
|
|
14
|
-
export type CopyButtonEvents = typeof __propDef.events;
|
|
15
|
-
export type CopyButtonSlots = typeof __propDef.slots;
|
|
16
|
-
export default class CopyButton extends SvelteComponent<CopyButtonProps, CopyButtonEvents, CopyButtonSlots> {
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
17
13
|
}
|
|
18
|
-
|
|
14
|
+
declare const CopyButton: $$__sveltets_2_IsomorphicComponent<{
|
|
15
|
+
code: string;
|
|
16
|
+
}, {
|
|
17
|
+
[evt: string]: CustomEvent<any>;
|
|
18
|
+
}, {}, {}, string>;
|
|
19
|
+
type CopyButton = InstanceType<typeof CopyButton>;
|
|
20
|
+
export default CopyButton;
|