@gradio/code 0.14.15 → 0.15.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 CHANGED
@@ -1,5 +1,43 @@
1
1
  # @gradio/code
2
2
 
3
+ ## 0.15.0
4
+
5
+ ### Features
6
+
7
+ - [#11858](https://github.com/gradio-app/gradio/pull/11858) [`3f8ea13`](https://github.com/gradio-app/gradio/commit/3f8ea13a8ca92abf0ad34392e403a449fda3c6c2) - remove lite. Thanks @pngwn!
8
+
9
+ ### Fixes
10
+
11
+ - [#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!
12
+
13
+ ### Dependency updates
14
+
15
+ - @gradio/statustracker@0.11.1
16
+ - @gradio/atoms@0.18.0
17
+ - @gradio/upload@0.17.0
18
+
19
+ ## 0.14.16
20
+
21
+ ### Dependency updates
22
+
23
+ - @gradio/icons@0.14.0
24
+ - @gradio/atoms@0.17.0
25
+ - @gradio/statustracker@0.11.0
26
+ - @gradio/upload@0.16.17
27
+
28
+ ## 0.14.15
29
+
30
+ ### Dependency updates
31
+
32
+ - @gradio/statustracker@0.10.18
33
+
34
+ ## 0.14.15
35
+
36
+ ### Dependency updates
37
+
38
+ - @gradio/icons@0.13.1
39
+ - @gradio/upload@0.16.16
40
+
3
41
  ## 0.14.15
4
42
 
5
43
  ### 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;
@@ -2,11 +2,9 @@
2
2
  export let type;
3
3
  export let selected = false;
4
4
  function truncate_text(text, max_length = 60) {
5
- if (!text)
6
- return "";
5
+ if (!text) return "";
7
6
  const str = String(text);
8
- if (str.length <= max_length)
9
- return str;
7
+ if (str.length <= max_length) return str;
10
8
  return str.slice(0, max_length) + "...";
11
9
  }
12
10
  </script>
@@ -3,12 +3,14 @@ declare const __propDef: {
3
3
  props: {
4
4
  value: string | null;
5
5
  type: "gallery" | "table";
6
- selected?: boolean | undefined;
6
+ selected?: boolean;
7
7
  };
8
8
  events: {
9
9
  [evt: string]: CustomEvent<any>;
10
10
  };
11
11
  slots: {};
12
+ exports?: {} | undefined;
13
+ bindings?: string | undefined;
12
14
  };
13
15
  export type ExampleProps = typeof __propDef.props;
14
16
  export type ExampleEvents = typeof __propDef.events;
package/dist/Index.svelte CHANGED
@@ -39,8 +39,7 @@ function handle_change() {
39
39
  afterUpdate(() => {
40
40
  value_is_output = false;
41
41
  });
42
- $:
43
- value, handle_change();
42
+ $: value, handle_change();
44
43
  </script>
45
44
 
46
45
  <Block
@@ -15,28 +15,30 @@ declare const __propDef: {
15
15
  focus: never;
16
16
  clear_status: LoadingStatus;
17
17
  }>;
18
- value?: string | undefined;
19
- value_is_output?: boolean | undefined;
20
- language?: string | undefined;
21
- lines?: number | undefined;
18
+ value?: string;
19
+ value_is_output?: boolean;
20
+ language?: string;
21
+ lines?: number;
22
22
  max_lines?: number | undefined;
23
- elem_id?: string | undefined;
24
- elem_classes?: string[] | undefined;
25
- visible?: boolean | undefined;
23
+ elem_id?: string;
24
+ elem_classes?: string[];
25
+ visible?: boolean | "hidden";
26
26
  label?: any;
27
- show_label?: boolean | undefined;
27
+ show_label?: boolean;
28
28
  loading_status: LoadingStatus;
29
- scale?: (number | null) | undefined;
29
+ scale?: number | null;
30
30
  min_width?: number | undefined;
31
- wrap_lines?: boolean | undefined;
32
- show_line_numbers?: boolean | undefined;
33
- autocomplete?: boolean | undefined;
31
+ wrap_lines?: boolean;
32
+ show_line_numbers?: boolean;
33
+ autocomplete?: boolean;
34
34
  interactive: boolean;
35
35
  };
36
36
  events: {
37
37
  [evt: string]: CustomEvent<any>;
38
38
  };
39
39
  slots: {};
40
+ exports?: {} | undefined;
41
+ bindings?: string | undefined;
40
42
  };
41
43
  export type IndexProps = typeof __propDef.props;
42
44
  export type IndexEvents = typeof __propDef.events;
@@ -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;
@@ -33,24 +31,14 @@ const dispatch = createEventDispatcher();
33
31
  let lang_extension;
34
32
  let element;
35
33
  let view;
36
- $:
37
- get_lang(language);
38
- const pyodide_autocomplete = create_pyodide_autocomplete();
34
+ $: get_lang(language);
39
35
  async function get_lang(val) {
40
36
  const ext = await getLanguageExtension(val);
41
- if (pyodide_autocomplete && val === "python" && ext instanceof LanguageSupport) {
42
- ext.support.push(
43
- ext.language.data.of({ autocomplete: pyodide_autocomplete })
44
- );
45
- }
46
37
  lang_extension = ext;
47
38
  }
48
- $:
49
- reconfigure(), lang_extension, readonly;
50
- $:
51
- set_doc(value);
52
- $:
53
- update_lines();
39
+ $: reconfigure(), lang_extension, readonly;
40
+ $: set_doc(value);
41
+ $: update_lines();
54
42
  function set_doc(new_doc) {
55
43
  if (view && new_doc !== view.state.doc.toString()) {
56
44
  view.dispatch({
@@ -2,20 +2,20 @@ import { SvelteComponent } from "svelte";
2
2
  import { type Extension } from "@codemirror/state";
3
3
  declare const __propDef: {
4
4
  props: {
5
- class_names?: string | undefined;
6
- value?: string | undefined;
5
+ class_names?: string;
6
+ value?: string;
7
7
  dark_mode: boolean;
8
- basic?: boolean | undefined;
8
+ basic?: boolean;
9
9
  language: string;
10
- lines?: number | undefined;
11
- max_lines?: (number | null) | undefined;
12
- extensions?: Extension[] | undefined;
13
- use_tab?: boolean | undefined;
14
- readonly?: boolean | undefined;
10
+ lines?: number;
11
+ max_lines?: number | null;
12
+ extensions?: Extension[];
13
+ use_tab?: boolean;
14
+ readonly?: boolean;
15
15
  placeholder?: string | HTMLElement | null | undefined;
16
- wrap_lines?: boolean | undefined;
17
- show_line_numbers?: boolean | undefined;
18
- autocomplete?: boolean | undefined;
16
+ wrap_lines?: boolean;
17
+ show_line_numbers?: boolean;
18
+ autocomplete?: boolean;
19
19
  };
20
20
  events: {
21
21
  change: CustomEvent<string>;
@@ -25,6 +25,8 @@ declare const __propDef: {
25
25
  [evt: string]: CustomEvent<any>;
26
26
  };
27
27
  slots: {};
28
+ exports?: {} | undefined;
29
+ bindings?: string | undefined;
28
30
  };
29
31
  export type CodeProps = typeof __propDef.props;
30
32
  export type CodeEvents = typeof __propDef.events;
@@ -6,8 +6,7 @@ export let value;
6
6
  let timer;
7
7
  function copy_feedback() {
8
8
  copied = true;
9
- if (timer)
10
- clearTimeout(timer);
9
+ if (timer) clearTimeout(timer);
11
10
  timer = setTimeout(() => {
12
11
  copied = false;
13
12
  }, 2e3);
@@ -19,8 +18,7 @@ async function handle_copy() {
19
18
  }
20
19
  }
21
20
  onDestroy(() => {
22
- if (timer)
23
- clearTimeout(timer);
21
+ if (timer) clearTimeout(timer);
24
22
  });
25
23
  </script>
26
24
 
@@ -7,6 +7,8 @@ declare const __propDef: {
7
7
  [evt: string]: CustomEvent<any>;
8
8
  };
9
9
  slots: {};
10
+ exports?: {} | undefined;
11
+ bindings?: string | undefined;
10
12
  };
11
13
  export type CopyProps = typeof __propDef.props;
12
14
  export type CopyEvents = typeof __propDef.events;
@@ -1,11 +1,10 @@
1
1
  <script>import { onDestroy } from "svelte";
2
2
  import { Download, Check } from "@gradio/icons";
3
- import { DownloadLink } from "@gradio/wasm/svelte";
3
+ import { DownloadLink } from "@gradio/atoms";
4
4
  import { IconButton } from "@gradio/atoms";
5
5
  export let value;
6
6
  export let language;
7
- $:
8
- ext = get_ext_for_type(language);
7
+ $: ext = get_ext_for_type(language);
9
8
  function get_ext_for_type(type) {
10
9
  const exts = {
11
10
  py: "py",
@@ -35,17 +34,14 @@ let copied = false;
35
34
  let timer;
36
35
  function copy_feedback() {
37
36
  copied = true;
38
- if (timer)
39
- clearTimeout(timer);
37
+ if (timer) clearTimeout(timer);
40
38
  timer = setTimeout(() => {
41
39
  copied = false;
42
40
  }, 2e3);
43
41
  }
44
- $:
45
- download_value = URL.createObjectURL(new Blob([value]));
42
+ $: download_value = URL.createObjectURL(new Blob([value]));
46
43
  onDestroy(() => {
47
- if (timer)
48
- clearTimeout(timer);
44
+ if (timer) clearTimeout(timer);
49
45
  });
50
46
  </script>
51
47
 
@@ -8,6 +8,8 @@ declare const __propDef: {
8
8
  [evt: string]: CustomEvent<any>;
9
9
  };
10
10
  slots: {};
11
+ exports?: {} | undefined;
12
+ bindings?: string | undefined;
11
13
  };
12
14
  export type DownloadProps = typeof __propDef.props;
13
15
  export type DownloadEvents = typeof __propDef.events;
@@ -8,6 +8,8 @@ declare const __propDef: {
8
8
  [evt: string]: CustomEvent<any>;
9
9
  };
10
10
  slots: {};
11
+ exports?: {} | undefined;
12
+ bindings?: string | undefined;
11
13
  };
12
14
  export type WidgetsProps = typeof __propDef.props;
13
15
  export type WidgetsEvents = typeof __propDef.events;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradio/code",
3
- "version": "0.14.15",
3
+ "version": "0.15.0",
4
4
  "description": "Gradio UI packages",
5
5
  "type": "module",
6
6
  "author": "",
@@ -27,25 +27,26 @@
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/icons": "^0.13.0",
31
- "@gradio/statustracker": "^0.10.17",
32
- "@gradio/upload": "^0.16.15",
33
- "@gradio/utils": "^0.10.2",
34
- "@gradio/atoms": "^0.16.5",
35
- "@gradio/wasm": "^0.18.1"
30
+ "@gradio/atoms": "^0.18.0",
31
+ "@gradio/icons": "^0.14.0",
32
+ "@gradio/upload": "^0.17.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",
39
38
  "exports": {
40
39
  ".": {
40
+ "types": "./dist/Index.svelte.d.ts",
41
41
  "gradio": "./Index.svelte",
42
42
  "svelte": "./dist/Index.svelte",
43
- "types": "./dist/Index.svelte.d.ts"
43
+ "default": "./dist/Index.svelte"
44
44
  },
45
45
  "./example": {
46
+ "types": "./dist/Example.svelte.d.ts",
46
47
  "gradio": "./Example.svelte",
47
48
  "svelte": "./dist/Example.svelte",
48
- "types": "./dist/Example.svelte.d.ts"
49
+ "default": "./dist/Example.svelte"
49
50
  },
50
51
  "./package.json": "./package.json"
51
52
  },
@@ -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
 
@@ -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/wasm/svelte";
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
- }
@@ -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
- }