@gradio/code 0.14.16 → 0.15.1-dev.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 +29 -0
- package/Index.svelte +1 -1
- package/dist/Index.svelte.d.ts +1 -1
- package/dist/shared/Code.svelte +0 -8
- package/dist/shared/Download.svelte +1 -1
- package/package.json +5 -6
- package/shared/Code.svelte +0 -13
- package/shared/Download.svelte +1 -1
- package/dist/shared/autocomplete.d.ts +0 -4
- package/dist/shared/autocomplete.js +0 -49
- package/shared/autocomplete.ts +0 -63
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @gradio/code
|
|
2
2
|
|
|
3
|
+
## 0.15.1-dev.0
|
|
4
|
+
|
|
5
|
+
### Dependency updates
|
|
6
|
+
|
|
7
|
+
- @gradio/upload@0.17.2-dev.0
|
|
8
|
+
|
|
9
|
+
## 0.15.0
|
|
10
|
+
|
|
11
|
+
### Dependency updates
|
|
12
|
+
|
|
13
|
+
- @gradio/upload@0.17.1
|
|
14
|
+
- @gradio/atoms@0.18.1
|
|
15
|
+
|
|
16
|
+
## 0.15.0
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
- [#11858](https://github.com/gradio-app/gradio/pull/11858) [`3f8ea13`](https://github.com/gradio-app/gradio/commit/3f8ea13a8ca92abf0ad34392e403a449fda3c6c2) - remove lite. Thanks @pngwn!
|
|
21
|
+
|
|
22
|
+
### Fixes
|
|
23
|
+
|
|
24
|
+
- [#11784](https://github.com/gradio-app/gradio/pull/11784) [`d9dd3f5`](https://github.com/gradio-app/gradio/commit/d9dd3f54b7fb34cf7118e549d39fc63937ca3489) - Add "hidden" option to component's `visible` kwarg to render but visually hide the component. Thanks @pngwn!
|
|
25
|
+
|
|
26
|
+
### Dependency updates
|
|
27
|
+
|
|
28
|
+
- @gradio/statustracker@0.11.1
|
|
29
|
+
- @gradio/atoms@0.18.0
|
|
30
|
+
- @gradio/upload@0.17.0
|
|
31
|
+
|
|
3
32
|
## 0.14.16
|
|
4
33
|
|
|
5
34
|
### Dependency updates
|
package/Index.svelte
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
export let max_lines: number | undefined = undefined;
|
|
33
33
|
export let elem_id = "";
|
|
34
34
|
export let elem_classes: string[] = [];
|
|
35
|
-
export let visible = true;
|
|
35
|
+
export let visible: boolean | "hidden" = true;
|
|
36
36
|
export let label = gradio.i18n("code.code");
|
|
37
37
|
export let show_label = true;
|
|
38
38
|
export let loading_status: LoadingStatus;
|
package/dist/Index.svelte.d.ts
CHANGED
package/dist/shared/Code.svelte
CHANGED
|
@@ -9,12 +9,10 @@ import {
|
|
|
9
9
|
import { StateEffect, EditorState } from "@codemirror/state";
|
|
10
10
|
import { indentWithTab } from "@codemirror/commands";
|
|
11
11
|
import { autocompletion, acceptCompletion } from "@codemirror/autocomplete";
|
|
12
|
-
import { LanguageSupport } from "@codemirror/language";
|
|
13
12
|
import { basicDark } from "cm6-theme-basic-dark";
|
|
14
13
|
import { basicLight } from "cm6-theme-basic-light";
|
|
15
14
|
import { basicSetup } from "./extensions";
|
|
16
15
|
import { getLanguageExtension } from "./language";
|
|
17
|
-
import { create_pyodide_autocomplete } from "./autocomplete";
|
|
18
16
|
export let class_names = "";
|
|
19
17
|
export let value = "";
|
|
20
18
|
export let dark_mode;
|
|
@@ -34,14 +32,8 @@ let lang_extension;
|
|
|
34
32
|
let element;
|
|
35
33
|
let view;
|
|
36
34
|
$: get_lang(language);
|
|
37
|
-
const pyodide_autocomplete = create_pyodide_autocomplete();
|
|
38
35
|
async function get_lang(val) {
|
|
39
36
|
const ext = await getLanguageExtension(val);
|
|
40
|
-
if (pyodide_autocomplete && val === "python" && ext instanceof LanguageSupport) {
|
|
41
|
-
ext.support.push(
|
|
42
|
-
ext.language.data.of({ autocomplete: pyodide_autocomplete })
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
37
|
lang_extension = ext;
|
|
46
38
|
}
|
|
47
39
|
$: reconfigure(), lang_extension, readonly;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>import { onDestroy } from "svelte";
|
|
2
2
|
import { Download, Check } from "@gradio/icons";
|
|
3
|
-
import { DownloadLink } from "@gradio/
|
|
3
|
+
import { DownloadLink } from "@gradio/atoms";
|
|
4
4
|
import { IconButton } from "@gradio/atoms";
|
|
5
5
|
export let value;
|
|
6
6
|
export let language;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradio/code",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.1-dev.0",
|
|
4
4
|
"description": "Gradio UI packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "",
|
|
@@ -27,12 +27,11 @@
|
|
|
27
27
|
"cm6-theme-basic-dark": "^0.2.0",
|
|
28
28
|
"cm6-theme-basic-light": "^0.2.0",
|
|
29
29
|
"codemirror": "^6.0.1",
|
|
30
|
-
"@gradio/atoms": "^0.
|
|
30
|
+
"@gradio/atoms": "^0.18.1",
|
|
31
31
|
"@gradio/icons": "^0.14.0",
|
|
32
|
-
"@gradio/
|
|
33
|
-
"@gradio/
|
|
34
|
-
"@gradio/
|
|
35
|
-
"@gradio/wasm": "^0.18.1"
|
|
32
|
+
"@gradio/upload": "^0.17.2-dev.0",
|
|
33
|
+
"@gradio/statustracker": "^0.11.1",
|
|
34
|
+
"@gradio/utils": "^0.10.2"
|
|
36
35
|
},
|
|
37
36
|
"main_changeset": true,
|
|
38
37
|
"main": "./Index.svelte",
|
package/shared/Code.svelte
CHANGED
|
@@ -10,13 +10,11 @@
|
|
|
10
10
|
import { StateEffect, EditorState, type Extension } from "@codemirror/state";
|
|
11
11
|
import { indentWithTab } from "@codemirror/commands";
|
|
12
12
|
import { autocompletion, acceptCompletion } from "@codemirror/autocomplete";
|
|
13
|
-
import { LanguageSupport } from "@codemirror/language";
|
|
14
13
|
|
|
15
14
|
import { basicDark } from "cm6-theme-basic-dark";
|
|
16
15
|
import { basicLight } from "cm6-theme-basic-light";
|
|
17
16
|
import { basicSetup } from "./extensions";
|
|
18
17
|
import { getLanguageExtension } from "./language";
|
|
19
|
-
import { create_pyodide_autocomplete } from "./autocomplete";
|
|
20
18
|
|
|
21
19
|
export let class_names = "";
|
|
22
20
|
export let value = "";
|
|
@@ -44,19 +42,8 @@
|
|
|
44
42
|
|
|
45
43
|
$: get_lang(language);
|
|
46
44
|
|
|
47
|
-
const pyodide_autocomplete = create_pyodide_autocomplete();
|
|
48
|
-
|
|
49
45
|
async function get_lang(val: string): Promise<void> {
|
|
50
46
|
const ext = await getLanguageExtension(val);
|
|
51
|
-
if (
|
|
52
|
-
pyodide_autocomplete &&
|
|
53
|
-
val === "python" &&
|
|
54
|
-
ext instanceof LanguageSupport
|
|
55
|
-
) {
|
|
56
|
-
(ext.support as Extension[]).push(
|
|
57
|
-
ext.language.data.of({ autocomplete: pyodide_autocomplete })
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
47
|
lang_extension = ext;
|
|
61
48
|
}
|
|
62
49
|
|
package/shared/Download.svelte
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { onDestroy } from "svelte";
|
|
3
3
|
import { Download, Check } from "@gradio/icons";
|
|
4
|
-
import { DownloadLink } from "@gradio/
|
|
4
|
+
import { DownloadLink } from "@gradio/atoms";
|
|
5
5
|
import { IconButton } from "@gradio/atoms";
|
|
6
6
|
|
|
7
7
|
export let value: string;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { CompletionContext, CompletionResult } from "@codemirror/autocomplete";
|
|
2
|
-
type CodeMirrorAutocompleteAsyncFn = (context: CompletionContext) => Promise<CompletionResult | null>;
|
|
3
|
-
export declare function create_pyodide_autocomplete(): CodeMirrorAutocompleteAsyncFn | null;
|
|
4
|
-
export {};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { getWorkerProxyContext } from "@gradio/wasm/svelte";
|
|
2
|
-
// Jedi's completion types to CodeMirror's completion types.
|
|
3
|
-
// If not defined here, Jedi's completion types will be used.
|
|
4
|
-
const completion_type_map = {
|
|
5
|
-
module: "namespace"
|
|
6
|
-
};
|
|
7
|
-
export function create_pyodide_autocomplete() {
|
|
8
|
-
let maybe_worker_proxy;
|
|
9
|
-
try {
|
|
10
|
-
maybe_worker_proxy = getWorkerProxyContext();
|
|
11
|
-
}
|
|
12
|
-
catch (e) {
|
|
13
|
-
console.debug("Not in the Wasm env. Context-aware autocomplete disabled.");
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
if (!maybe_worker_proxy) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
const worker_proxy = maybe_worker_proxy;
|
|
20
|
-
return async function pyodide_autocomplete(context) {
|
|
21
|
-
try {
|
|
22
|
-
const completions = await worker_proxy.getCodeCompletions({
|
|
23
|
-
code: context.state.doc.toString(),
|
|
24
|
-
line: context.state.doc.lineAt(context.state.selection.main.head)
|
|
25
|
-
.number,
|
|
26
|
-
column: context.state.selection.main.head -
|
|
27
|
-
context.state.doc.lineAt(context.state.selection.main.head).from
|
|
28
|
-
});
|
|
29
|
-
if (completions.length === 0) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
return {
|
|
33
|
-
from: context.state.selection.main.head -
|
|
34
|
-
completions[0].completion_prefix_length,
|
|
35
|
-
options: completions.map((completion) => ({
|
|
36
|
-
label: completion.label,
|
|
37
|
-
type: completion_type_map[completion.type] ?? completion.type,
|
|
38
|
-
documentation: completion.docstring,
|
|
39
|
-
// Items starting with "_" are private attributes and should be sorted last.
|
|
40
|
-
boost: completion.label.startsWith("_") ? -1 : 0
|
|
41
|
-
}))
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
catch (e) {
|
|
45
|
-
console.error("Error getting completions", e);
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
}
|
package/shared/autocomplete.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
CompletionContext,
|
|
3
|
-
CompletionResult
|
|
4
|
-
} from "@codemirror/autocomplete";
|
|
5
|
-
import { getWorkerProxyContext } from "@gradio/wasm/svelte";
|
|
6
|
-
import type { WorkerProxy } from "@gradio/wasm";
|
|
7
|
-
|
|
8
|
-
// Jedi's completion types to CodeMirror's completion types.
|
|
9
|
-
// If not defined here, Jedi's completion types will be used.
|
|
10
|
-
const completion_type_map: Record<string, string> = {
|
|
11
|
-
module: "namespace"
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
type CodeMirrorAutocompleteAsyncFn = (
|
|
15
|
-
context: CompletionContext
|
|
16
|
-
) => Promise<CompletionResult | null>;
|
|
17
|
-
|
|
18
|
-
export function create_pyodide_autocomplete(): CodeMirrorAutocompleteAsyncFn | null {
|
|
19
|
-
let maybe_worker_proxy: WorkerProxy | undefined;
|
|
20
|
-
try {
|
|
21
|
-
maybe_worker_proxy = getWorkerProxyContext();
|
|
22
|
-
} catch (e) {
|
|
23
|
-
console.debug("Not in the Wasm env. Context-aware autocomplete disabled.");
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
if (!maybe_worker_proxy) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
const worker_proxy = maybe_worker_proxy;
|
|
30
|
-
|
|
31
|
-
return async function pyodide_autocomplete(
|
|
32
|
-
context: CompletionContext
|
|
33
|
-
): Promise<CompletionResult | null> {
|
|
34
|
-
try {
|
|
35
|
-
const completions = await worker_proxy.getCodeCompletions({
|
|
36
|
-
code: context.state.doc.toString(),
|
|
37
|
-
line: context.state.doc.lineAt(context.state.selection.main.head)
|
|
38
|
-
.number,
|
|
39
|
-
column:
|
|
40
|
-
context.state.selection.main.head -
|
|
41
|
-
context.state.doc.lineAt(context.state.selection.main.head).from
|
|
42
|
-
});
|
|
43
|
-
if (completions.length === 0) {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
from:
|
|
48
|
-
context.state.selection.main.head -
|
|
49
|
-
completions[0].completion_prefix_length,
|
|
50
|
-
options: completions.map((completion) => ({
|
|
51
|
-
label: completion.label,
|
|
52
|
-
type: completion_type_map[completion.type] ?? completion.type,
|
|
53
|
-
documentation: completion.docstring,
|
|
54
|
-
// Items starting with "_" are private attributes and should be sorted last.
|
|
55
|
-
boost: completion.label.startsWith("_") ? -1 : 0
|
|
56
|
-
}))
|
|
57
|
-
};
|
|
58
|
-
} catch (e) {
|
|
59
|
-
console.error("Error getting completions", e);
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
}
|