hc99 commited on
Commit
2b06d1d
·
verified ·
1 Parent(s): c13737d

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +6 -0
  2. testbed/gradio-app__gradio/.dockerignore +40 -0
  3. testbed/gradio-app__gradio/.editorconfig +8 -0
  4. testbed/gradio-app__gradio/.git-blame-ignore-revs +2 -0
  5. testbed/gradio-app__gradio/.gitignore +78 -0
  6. testbed/gradio-app__gradio/CHANGELOG.md +0 -0
  7. testbed/gradio-app__gradio/CITATION.cff +45 -0
  8. testbed/gradio-app__gradio/CONTRIBUTING.md +138 -0
  9. testbed/gradio-app__gradio/LICENSE +201 -0
  10. testbed/gradio-app__gradio/SECURITY.md +5 -0
  11. testbed/gradio-app__gradio/build_pypi.sh +21 -0
  12. testbed/gradio-app__gradio/globals.d.ts +35 -0
  13. testbed/gradio-app__gradio/js/.npmrc +1 -0
  14. testbed/gradio-app__gradio/js/README.md +108 -0
  15. testbed/gradio-app__gradio/js/jsx.d.ts +6 -0
  16. testbed/gradio-app__gradio/js/lite/CHANGELOG.md +39 -0
  17. testbed/gradio-app__gradio/js/lite/index.html +51 -0
  18. testbed/gradio-app__gradio/js/lite/package.json +18 -0
  19. testbed/gradio-app__gradio/js/timeseries/CHANGELOG.md +62 -0
  20. testbed/gradio-app__gradio/js/timeseries/example/Timeseries.svelte +19 -0
  21. testbed/gradio-app__gradio/js/timeseries/example/index.ts +1 -0
  22. testbed/gradio-app__gradio/js/timeseries/interactive/InteractiveTimeseries.svelte +184 -0
  23. testbed/gradio-app__gradio/js/timeseries/interactive/index.ts +1 -0
  24. testbed/gradio-app__gradio/js/timeseries/package.json +34 -0
  25. testbed/gradio-app__gradio/js/timeseries/shared/Chart.svelte +222 -0
  26. testbed/gradio-app__gradio/js/timeseries/shared/index.ts +1 -0
  27. testbed/gradio-app__gradio/js/timeseries/shared/utils.ts +74 -0
  28. testbed/gradio-app__gradio/js/timeseries/static/StaticTimeseries.svelte +69 -0
  29. testbed/gradio-app__gradio/js/timeseries/static/index.ts +1 -0
  30. testbed/gradio-app__gradio/js/tooltip/README.md +11 -0
  31. testbed/gradio-app__gradio/js/tooltip/src/tooltip.ts +50 -0
  32. testbed/gradio-app__gradio/js/tootils/CHANGELOG.md +22 -0
  33. testbed/gradio-app__gradio/js/tootils/README.md +11 -0
  34. testbed/gradio-app__gradio/js/tootils/package.json +10 -0
  35. testbed/gradio-app__gradio/js/upload/CHANGELOG.md +96 -0
  36. testbed/gradio-app__gradio/js/upload/package.json +15 -0
  37. testbed/gradio-app__gradio/js/upload/src/ModifyUpload.svelte +62 -0
  38. testbed/gradio-app__gradio/js/upload/src/Upload.svelte +135 -0
  39. testbed/gradio-app__gradio/js/upload/src/index.ts +8 -0
  40. testbed/gradio-app__gradio/js/upload/src/utils.ts +87 -0
  41. testbed/gradio-app__gradio/js/uploadbutton/CHANGELOG.md +60 -0
  42. testbed/gradio-app__gradio/js/uploadbutton/UploadButton.test.ts +68 -0
  43. testbed/gradio-app__gradio/js/uploadbutton/interactive/InteractiveUploadButton.svelte +81 -0
  44. testbed/gradio-app__gradio/js/uploadbutton/package.json +23 -0
  45. testbed/gradio-app__gradio/js/uploadbutton/shared/UploadButton.svelte +112 -0
  46. testbed/gradio-app__gradio/js/uploadbutton/shared/index.ts +1 -0
  47. testbed/gradio-app__gradio/js/uploadbutton/static/StaticUploadButton.svelte +82 -0
  48. testbed/gradio-app__gradio/js/uploadbutton/static/index.ts +1 -0
  49. testbed/gradio-app__gradio/js/utils/CHANGELOG.md +44 -0
  50. testbed/gradio-app__gradio/js/utils/README.md +1 -0
.gitattributes CHANGED
@@ -68,3 +68,9 @@ testbed/sphinx-doc__sphinx/tests/roots/test-images/img.pdf filter=lfs diff=lfs m
68
  testbed/sphinx-doc__sphinx/tests/roots/test-images/subdir/svgimg.pdf filter=lfs diff=lfs merge=lfs -text
69
  testbed/sphinx-doc__sphinx/tests/roots/test-ext-imgconverter/img.pdf filter=lfs diff=lfs merge=lfs -text
70
  testbed/sphinx-doc__sphinx/sphinx/locale/fa/LC_MESSAGES/sphinx.mo filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
68
  testbed/sphinx-doc__sphinx/tests/roots/test-images/subdir/svgimg.pdf filter=lfs diff=lfs merge=lfs -text
69
  testbed/sphinx-doc__sphinx/tests/roots/test-ext-imgconverter/img.pdf filter=lfs diff=lfs merge=lfs -text
70
  testbed/sphinx-doc__sphinx/sphinx/locale/fa/LC_MESSAGES/sphinx.mo filter=lfs diff=lfs merge=lfs -text
71
+ testbed/scverse__scanpy/scanpy/tests/_data/10x-10k-subset.zarr/X/1.0 filter=lfs diff=lfs merge=lfs -text
72
+ testbed/scverse__scanpy/scanpy/tests/_data/10x-10k-subset.zarr/X/2.0 filter=lfs diff=lfs merge=lfs -text
73
+ testbed/scverse__scanpy/scanpy/tests/_data/10x-10k-subset.zarr/X/3.0 filter=lfs diff=lfs merge=lfs -text
74
+ testbed/scverse__scanpy/scanpy/tests/_data/10x-10k-subset.zarr/X/0.0 filter=lfs diff=lfs merge=lfs -text
75
+ testbed/scverse__scanpy/scanpy/tests/_data/10x-10k-subset.zarr/X/4.0 filter=lfs diff=lfs merge=lfs -text
76
+ testbed/scverse__scanpy/scanpy/datasets/10x_pbmc68k_reduced.h5ad filter=lfs diff=lfs merge=lfs -text
testbed/gradio-app__gradio/.dockerignore ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python build
2
+ .eggs/
3
+ gradio.egg-info/*
4
+ !gradio.egg-info/requires.txt
5
+ !gradio.egg-info/PKG-INFO
6
+ dist/
7
+ *.pyc
8
+ __pycache__/
9
+ *.py[cod]
10
+ *$py.class
11
+ build/
12
+
13
+ # JS build
14
+ gradio/templates/frontend/static
15
+ gradio/templates/frontend/cdn
16
+
17
+ # Secrets
18
+ .env
19
+
20
+ # Gradio run artifacts
21
+ *.db
22
+ *.sqlite3
23
+ gradio/launches.json
24
+
25
+ # Tests
26
+ .coverage
27
+ coverage.xml
28
+ test.txt
29
+
30
+ # Demos
31
+ demo/tmp.zip
32
+ demo/flagged
33
+ demo/files/*.avi
34
+ demo/files/*.mp4
35
+
36
+ # Etc
37
+ .idea/*
38
+ .DS_Store
39
+ *.bak
40
+ workspace.code-workspace
testbed/gradio-app__gradio/.editorconfig ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+
2
+ root = true
3
+
4
+ [{js/**,client/js/**}]
5
+ end_of_line = lf
6
+ insert_final_newline = true
7
+ indent_style = tab
8
+ tab_width = 2
testbed/gradio-app__gradio/.git-blame-ignore-revs ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ # https://github.com/gradio-app/gradio/pull/4487 - refactor components.py to separate files
2
+ 69f36f98535c904e7cac2b4942cecc747ed7443c
testbed/gradio-app__gradio/.gitignore ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python build
2
+ .eggs/
3
+ gradio.egg-info
4
+ dist/
5
+ *.pyc
6
+ __pycache__/
7
+ *.py[cod]
8
+ *$py.class
9
+ build/
10
+ __tmp/*
11
+
12
+ # JS build
13
+ gradio/templates/cdn
14
+ gradio/templates/frontend
15
+
16
+ # Secrets
17
+ .env
18
+
19
+ # Gradio run artifacts
20
+ *.db
21
+ *.sqlite3
22
+ gradio/launches.json
23
+ flagged/
24
+ gradio_cached_examples/
25
+ tmp.zip
26
+
27
+ # Tests
28
+ .coverage
29
+ coverage.xml
30
+ test.txt
31
+ **/snapshots/**/*.png
32
+ playwright-report/
33
+
34
+ # Demos
35
+ demo/tmp.zip
36
+ demo/files/*.avi
37
+ demo/files/*.mp4
38
+ demo/all_demos/demos/*
39
+ demo/all_demos/requirements.txt
40
+ demo/*/config.json
41
+ demo/annotatedimage_component/*.png
42
+
43
+ # Etc
44
+ .idea/*
45
+ .DS_Store
46
+ *.bak
47
+ workspace.code-workspace
48
+ *.h5
49
+
50
+ # dev containers
51
+ .pnpm-store/
52
+
53
+ # log files
54
+ .pnpm-debug.log
55
+
56
+ # Local virtualenv for devs
57
+ .venv*
58
+
59
+ # FRP
60
+ gradio/frpc_*
61
+ .vercel
62
+
63
+ # js
64
+ node_modules
65
+ public/build/
66
+ test-results
67
+ client/js/test.js
68
+ .config/test.py
69
+
70
+ # storybook
71
+ storybook-static
72
+ build-storybook.log
73
+ js/storybook/theme.css
74
+
75
+ # playwright
76
+ .config/playwright
77
+ !.config/playwright/index.html
78
+ !.config/playwright/index.ts
testbed/gradio-app__gradio/CHANGELOG.md ADDED
The diff for this file is too large to render. See raw diff
 
testbed/gradio-app__gradio/CITATION.cff ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ cff-version: 1.2.0
2
+ message: Please cite this project using these metadata.
3
+ title: "Gradio: Hassle-free sharing and testing of ML models in the wild"
4
+ abstract: >-
5
+ Accessibility is a major challenge of machine learning (ML).
6
+ Typical ML models are built by specialists and require
7
+ specialized hardware/software as well as ML experience to
8
+ validate. This makes it challenging for non-technical
9
+ collaborators and endpoint users (e.g. physicians) to easily
10
+ provide feedback on model development and to gain trust in
11
+ ML. The accessibility challenge also makes collaboration
12
+ more difficult and limits the ML researcher's exposure to
13
+ realistic data and scenarios that occur in the wild. To
14
+ improve accessibility and facilitate collaboration, we
15
+ developed an open-source Python package, Gradio, which
16
+ allows researchers to rapidly generate a visual interface
17
+ for their ML models. Gradio makes accessing any ML model as
18
+ easy as sharing a URL. Our development of Gradio is informed
19
+ by interviews with a number of machine learning researchers
20
+ who participate in interdisciplinary collaborations. Their
21
+ feedback identified that Gradio should support a variety of
22
+ interfaces and frameworks, allow for easy sharing of the
23
+ interface, allow for input manipulation and interactive
24
+ inference by the domain expert, as well as allow embedding
25
+ the interface in iPython notebooks. We developed these
26
+ features and carried out a case study to understand Gradio's
27
+ usefulness and usability in the setting of a machine
28
+ learning collaboration between a researcher and a
29
+ cardiologist.
30
+ authors:
31
+ - family-names: Abid
32
+ given-names: Abubakar
33
+ - family-names: Abdalla
34
+ given-names: Ali
35
+ - family-names: Abid
36
+ given-names: Ali
37
+ - family-names: Khan
38
+ given-names: Dawood
39
+ - family-names: Alfozan
40
+ given-names: Abdulrahman
41
+ - family-names: Zou
42
+ given-names: James
43
+ doi: 10.48550/arXiv.1906.02569
44
+ date-released: 2019-06-06
45
+ url: https://arxiv.org/abs/1906.02569
testbed/gradio-app__gradio/CONTRIBUTING.md ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Contributing to Gradio
2
+
3
+ Prerequisites:
4
+
5
+ - [Python 3.8+](https://www.python.org/downloads/)
6
+ - [Node.js v16.14+](https://nodejs.dev/en/download/package-manager/) (only needed if you are making changes to the frontend)
7
+ - [pnpm 8.1+](https://pnpm.io/8.x/installation) (only needed if you are making changes to the frontend)
8
+
9
+ More than 80 awesome developers have contributed to the `gradio` library, and we'd be thrilled if you would like be the next `gradio` contributor! Start by cloning this repo and installing Gradio locally:
10
+
11
+ ### Install Gradio locally from the `main` branch
12
+
13
+ - Clone this repo
14
+ - Navigate to the repo folder and run
15
+
16
+ ```bash
17
+ bash scripts/install_gradio.sh
18
+ ```
19
+
20
+ - Build the front end
21
+
22
+ ```
23
+ bash scripts/build_frontend.sh
24
+ ```
25
+
26
+ ### Install development requirements
27
+
28
+ In order to be able to run the Python linter, formatter, and unit tests, do the following:
29
+
30
+ - Navigate to the repo folder and install test requirements (note that it is highly recommended to use a virtual environment running **Python 3.9** since the versions are pinned)
31
+
32
+ ```
33
+ bash scripts/install_test_requirements.sh
34
+ ```
35
+
36
+ - If you have a different Python version and conflicting packages during the installation, please first run:
37
+
38
+ ```
39
+ bash scripts/create_test_requirements.sh
40
+ ```
41
+
42
+ ### Using dev containers
43
+
44
+ Instead of the above steps, you can alternatively use dev containers. This is supported on all platforms (macOS/Windows/Linux).
45
+
46
+ Prerequisites:
47
+
48
+ - An editor which supports dev containers, like VS Code
49
+ - Docker support on the host computer:
50
+ - macOS: [Docker Desktop 2.0+](https://www.docker.com/products/docker-desktop/)
51
+ - Windows: [Docker Desktop 2.0+](https://www.docker.com/products/docker-desktop/)
52
+ - Linux: [Docker CE/EE 18.06+](https://docs.docker.com/get-docker/) and [Docker Compose 1.21+](https://docs.docker.com/compose/install/)
53
+ - If using VS Code, the [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension
54
+
55
+ Steps:
56
+
57
+ - Clone repository
58
+ - Open it in editor
59
+ - For VS Code, execute `Dev Containers: Reopen in container` command
60
+
61
+ For detailed instructions, please see the [Dev Containers tutorial](https://code.visualstudio.com/docs/devcontainers/tutorial).
62
+
63
+ ### Extra tidbits
64
+
65
+ - You can run gradio scripts in reload mode which will watch for changes in the `gradio` folder and reload the app if changes are made.
66
+
67
+ ```
68
+ gradio app.py
69
+ ```
70
+
71
+ - To develop the frontend app, you should also follow [js/README.md](js/README.md).
72
+
73
+ - To run all of the tests, do:
74
+
75
+ ```
76
+ bash scripts/run_all_tests.sh
77
+ ```
78
+
79
+ ### Structure of the Repository
80
+
81
+ It's helpful to know the overall structure of the repository so that you can focus on the part of the source code you'd like to contribute to
82
+
83
+ - `/gradio`: contains the Python source code for the library
84
+ - `/gradio/interface.py`: contains the Python source code for the core `Interface` class
85
+ - `/gradio/blocks.py`: contains the Python source code for the core `Blocks` class
86
+ - `/gradio/components.py`: contains the Python source code for the `components`, you can add your custom components here.
87
+ - `/js`: contains the HTML/JS/CSS source code for the library ([start here for frontend changes](/js/README.md))
88
+ - `/test`: contains Python unit tests for the library
89
+ - `/demo`: contains demos that are used in the documentation, you can find `Gradio` examples over here.
90
+ - `/website`: contains the code for the Gradio website (www.gradio.app). See the README in the `/website` folder for more details
91
+
92
+ ### Continuous Integration and Testing
93
+
94
+ All PRs must pass the continuous integration tests before merging. To test locally, you can run `python -m unittest` from the repo directory.
95
+
96
+ ## Submitting PRs
97
+
98
+ All PRs should be against `main`. Direct commits to main are blocked, and PRs require an approving review to merge into main. By convention, the Gradio maintainers will review PRs when:
99
+
100
+ - An initial review has been requested, and
101
+ - A description of the change (with a link to the GitHub PR) has been added to CHANGELOG.md, and
102
+ - A maintainer (@abidlabs, @aliabid94, @aliabd, @AK391, @dawoodkhan82, @pngwn, @freddyaboulton) is tagged in the PR comments and asked to complete a review
103
+
104
+ We ask that you make sure initial CI checks are passing before requesting a review. One of the Gradio maintainers will merge the PR when all the checks are passing.
105
+
106
+ Do not forget the format the backend before pushing.
107
+
108
+ ```
109
+ bash scripts/format_backend.sh
110
+ ```
111
+
112
+ ```
113
+ bash scripts/format_frontend.sh
114
+ ```
115
+
116
+ ## CI checks
117
+
118
+ Currently the following checks are run in CI:
119
+
120
+ ### Gradio library (`gradio` package)
121
+
122
+ ```
123
+ bash scripts/lint_backend.sh
124
+ bash scripts/type_check_backend.sh
125
+ python -m pytest -m "not flaky" --ignore=client
126
+ python -m pytest -m "flaky" --ignore=client
127
+ ```
128
+
129
+ ### Gradio client (`gradio_client` package)
130
+
131
+ ```
132
+ cd client/python
133
+ bash scripts/lint.sh
134
+ python -m pytest -m "not flaky"
135
+ python -m pytest -m "flaky"
136
+ ```
137
+
138
+ _Could these guidelines be clearer? Feel free to open a PR to help us faciltiate open-source contributions!_
testbed/gradio-app__gradio/LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
testbed/gradio-app__gradio/SECURITY.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # Security Policy
2
+
3
+ ## Reporting a Vulnerability
4
+
5
+ If you discover a security vulnerability, we would be very grateful if you could email us at team@gradio.app. This is the preferred approach instead of opening a public issue. We take all vulnerability reports seriously, and will work to patch the vulnerability immediately. Whenever possible, we will credit the person or people who report the security vulnerabilities after it has been patched.
testbed/gradio-app__gradio/build_pypi.sh ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ cd "$(dirname ${0})"
5
+
6
+ # You should update the version in package.json before running this script
7
+ FILE="gradio/package.json"
8
+ new_version=$(python -c "import json; f = open('$FILE', 'r'); data = json.load(f); print(data['version']); f.close();")
9
+ GRADIO_VERSION=$new_version
10
+
11
+ rm -rf gradio/templates/frontend
12
+ rm -rf gradio/templates/cdn
13
+ pnpm i --frozen-lockfile --ignore-scripts
14
+ GRADIO_VERSION=$new_version pnpm build
15
+ GRADIO_VERSION=$new_version pnpm build:cdn
16
+ aws s3 cp gradio/templates/cdn "s3://gradio/${new_version}/" --recursive --region us-west-2
17
+ cp gradio/templates/cdn/index.html gradio/templates/frontend/share.html
18
+
19
+ rm -rf dist/*
20
+ rm -rf build/*
21
+ python3 -m build
testbed/gradio-app__gradio/globals.d.ts ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ declare global {
2
+ interface Window {
3
+ __gradio_mode__: "app" | "website";
4
+ __gradio_space__: string | null;
5
+ launchGradio: Function;
6
+ launchGradioFromSpaces: Function;
7
+ gradio_config: Config;
8
+ scoped_css_attach: (link: HTMLLinkElement) => void;
9
+ __is_colab__: boolean;
10
+ parentIFrame?: {
11
+ scrollTo: (x: number, y: number) => void;
12
+ };
13
+ }
14
+ }
15
+
16
+ export interface Config {
17
+ auth_required: boolean | undefined;
18
+ auth_message: string;
19
+ components: any[];
20
+ css: string | null;
21
+ dependencies: any[];
22
+ dev_mode: boolean;
23
+ enable_queue: boolean;
24
+ layout: any;
25
+ mode: "blocks" | "interface";
26
+ root: string;
27
+ theme: string;
28
+ title: string;
29
+ version: string;
30
+ space_id: string | null;
31
+ is_colab: boolean;
32
+ show_api: boolean;
33
+ stylesheets: string[];
34
+ path: string;
35
+ }
testbed/gradio-app__gradio/js/.npmrc ADDED
@@ -0,0 +1 @@
 
 
1
+ strict-peer-dependencies=false
testbed/gradio-app__gradio/js/README.md ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # gradio-ui
2
+
3
+ This folder contains all of the Gradio UI and component source code.
4
+
5
+ - [set up](#setup)
6
+ - [running the application](#running-the-application)
7
+ - [local development](#local-development)
8
+ - [building for production](#building-for-production)
9
+ - [quality checks](#quality-checks)
10
+ - [ci checks](#ci-checks)
11
+
12
+ ## setup
13
+
14
+ This folder is managed as 'monorepo' a multi-package repository which make dependency management very simple. In order to do this we use `pnpm` as our package manager.
15
+
16
+ Make sure [`pnpm`](https://pnpm.io/) is installed by [following the installation instructions for your system](https://pnpm.io/installation).
17
+
18
+ You will also need `node` which you probably already have
19
+
20
+ ## running the application
21
+
22
+ Install all dependencies:
23
+
24
+ ```bash
25
+ pnpm i
26
+ ```
27
+
28
+ This will install the dependencies for all packages and link any local packages
29
+
30
+ ## local development
31
+
32
+ To develop locally, open two terminal tabs from the root of the repository.
33
+
34
+ Run the python test server, from the root directory:
35
+
36
+ ```bash
37
+ cd demo/kitchen_sink
38
+ python run.py
39
+ ```
40
+
41
+ This will start a development server on port `7860` that the web app is expecting.
42
+
43
+ Run the web app:
44
+
45
+ ```bash
46
+ pnpm dev
47
+ ```
48
+
49
+ ## building for production
50
+
51
+ Run the build:
52
+
53
+ ```bash
54
+ pnpm build
55
+ ```
56
+
57
+ This will create the necessary files in `js/app/public` and also in `gradio/templates/frontend`.
58
+
59
+ ## quality checks
60
+
61
+ The repos currently has two quality checks that can be run locally and are run in CI.
62
+
63
+ ### formatting
64
+
65
+ Formatting is handled by [`prettier`](https://prettier.io/) to ensure consistent formatting and prevent style-focused conversations. Formatting failures will fails CI and should be reoslve before merging.
66
+
67
+ To check formatting:
68
+
69
+ ```bash
70
+ pnpm format:check
71
+ ```
72
+
73
+ If you have formatting failures then you can run the following command to fix them:
74
+
75
+ ```bash
76
+ pnpm format:write
77
+ ```
78
+
79
+ ### type checking
80
+
81
+ We use [TypeScript](https://www.typescriptlang.org/) to provide static types to javascript code. These checks are also run in CI.
82
+
83
+ to typecheck the code:
84
+
85
+ ```bash
86
+ pnpm ts:check
87
+ ```
88
+
89
+ ## ci checks
90
+
91
+ Currently the following checks are run in CI:
92
+
93
+ ### static checks
94
+
95
+ - Format check (`pnpm format:check`)
96
+ - Build css (`pnpm css`)
97
+ - Build client (`pnpm build`)
98
+ - Type check (`pnpm ts:check`)
99
+ - Unit tests (`pnpm test:run`)
100
+
101
+ ### functional test
102
+
103
+ ```
104
+ pip install -r demo/outbreak_forecast/requirements.txt
105
+ pnpm exec playwright install chromium
106
+ pnpm exec playwright install-deps chromium
107
+ pnpm test:browser:full
108
+ ```
testbed/gradio-app__gradio/js/jsx.d.ts ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ declare namespace svelteHTML {
2
+ interface HTMLAttributes<T extends EventTarget> {
3
+ webkitdirectory?: boolean | string;
4
+ mozdirectory?: boolean | string;
5
+ }
6
+ }
testbed/gradio-app__gradio/js/lite/CHANGELOG.md ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # @gradio/lite
2
+
3
+ ## 0.3.1
4
+
5
+ ### Features
6
+
7
+ - [#5226](https://github.com/gradio-app/gradio/pull/5226) [`64039707`](https://github.com/gradio-app/gradio/commit/640397075d17307dd4f0713d063ef3d009a87aa0) - add gradio as a devdep of @gradio/lite. Thanks [@pngwn](https://github.com/pngwn)!
8
+
9
+ ## 0.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#4785](https://github.com/gradio-app/gradio/pull/4785) [`da0e9447`](https://github.com/gradio-app/gradio/commit/da0e94479a235de35844a636efb5833cb1fe9aeb) Thanks [@whitphx](https://github.com/whitphx)! - Add methods to execute mounted Python files
14
+
15
+ ### Patch Changes
16
+
17
+ - [#4788](https://github.com/gradio-app/gradio/pull/4788) [`8d0d4e0a`](https://github.com/gradio-app/gradio/commit/8d0d4e0a8ebe2425aef24a6f21b88598684b0965) Thanks [@whitphx](https://github.com/whitphx)! - Generate a prebuilt themed CSS file at build time
18
+
19
+ - [#4826](https://github.com/gradio-app/gradio/pull/4826) [`f0150c62`](https://github.com/gradio-app/gradio/commit/f0150c6260d657b150b73f0eecabd10b19d297c8) Thanks [@whitphx](https://github.com/whitphx)! - Unload the local modules before re-executing a Python script so the edits on the modules are reflected
20
+
21
+ - [#4779](https://github.com/gradio-app/gradio/pull/4779) [`80b49965`](https://github.com/gradio-app/gradio/commit/80b4996595d70167313d9abf29fb4f35abe66a0f) Thanks [@whitphx](https://github.com/whitphx)! - Add file system APIs and an imperative package install method
22
+
23
+ - [#4784](https://github.com/gradio-app/gradio/pull/4784) [`f757febe`](https://github.com/gradio-app/gradio/commit/f757febe181f0555aa01d4d349f92081819e2691) Thanks [@whitphx](https://github.com/whitphx)! - Remove the development code embedded in a dev HTML file so it will not be in a final bundle
24
+
25
+ - [#4785](https://github.com/gradio-app/gradio/pull/4785) [`da0e9447`](https://github.com/gradio-app/gradio/commit/da0e94479a235de35844a636efb5833cb1fe9aeb) Thanks [@whitphx](https://github.com/whitphx)! - Add controller.unmount()
26
+
27
+ - [#4846](https://github.com/gradio-app/gradio/pull/4846) [`76acf3cb`](https://github.com/gradio-app/gradio/commit/76acf3cb0b258c0e6bb38d611d766e5e54b68437) Thanks [@whitphx](https://github.com/whitphx)! - Fix the package name spec of markdown-it on the Wasm worker
28
+
29
+ ## 0.2.0
30
+
31
+ ### Minor Changes
32
+
33
+ - [#4732](https://github.com/gradio-app/gradio/pull/4732) [`1dc3c1a9`](https://github.com/gradio-app/gradio/commit/1dc3c1a9a2063daffc00d9231c1498d983ebc3bf) Thanks [@whitphx](https://github.com/whitphx)! - Add an imperative API to reurn the Python code and refresh the frontend
34
+
35
+ ## 0.1.1
36
+
37
+ ### Patch Changes
38
+
39
+ - [#4731](https://github.com/gradio-app/gradio/pull/4731) [`f9171288`](https://github.com/gradio-app/gradio/commit/f9171288d4cf0174952628276385fb553556c38a) Thanks [@whitphx](https://github.com/whitphx)! - Load the worker file from a different origin, e.g. CDN
testbed/gradio-app__gradio/js/lite/index.html ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <!-- A demo HTML file to test the bundled JS and CSS files -->
3
+ <html style="margin: 0; padding: 0; height: 100%">
4
+ <head>
5
+ <meta charset="utf-8" />
6
+ <meta
7
+ name="viewport"
8
+ content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1"
9
+ />
10
+
11
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
12
+ <link
13
+ rel="preconnect"
14
+ href="https://fonts.gstatic.com"
15
+ crossorigin="anonymous"
16
+ />
17
+
18
+ <script type="module" crossorigin src="./dist/lite.js"></script>
19
+ <link rel="stylesheet" href="./dist/lite.css" />
20
+ </head>
21
+
22
+ <body style="margin: 0; padding: 0; height: 100%">
23
+ <div id="gradio-app"></div>
24
+
25
+ <script type="module">
26
+ // type="module" is necessary to use `createGradioApp()`, which is loaded with <script type="module" /> tag above.
27
+ createGradioApp({
28
+ target: document.getElementById("gradio-app"),
29
+ code: `
30
+ import gradio as gr
31
+
32
+ def greet(name):
33
+ return "Hello " + name + "!"
34
+
35
+ demo = gr.Interface(fn=greet, inputs="text", outputs="text")
36
+
37
+ demo.launch()
38
+ `,
39
+ info: true,
40
+ container: true,
41
+ isEmbed: false,
42
+ initialHeight: "300px",
43
+ eager: false,
44
+ themeMode: null,
45
+ autoScroll: false,
46
+ controlPageTitle: false,
47
+ appMode: true
48
+ });
49
+ </script>
50
+ </body>
51
+ </html>
testbed/gradio-app__gradio/js/lite/package.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@gradio/lite",
3
+ "version": "0.3.1",
4
+ "description": "Serverless Gradio",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "author": "Gradio Team",
8
+ "license": "Apache-2.0",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "scripts": {
13
+ "build": "pnpm --filter @gradio/app build:lite"
14
+ },
15
+ "devDependencies": {
16
+ "gradio": "workspace:^"
17
+ }
18
+ }
testbed/gradio-app__gradio/js/timeseries/CHANGELOG.md ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # @gradio/timeseries
2
+
3
+ ## 0.0.6
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`75ddeb390`](https://github.com/gradio-app/gradio/commit/75ddeb390d665d4484667390a97442081b49a423)]:
8
+ - @gradio/upload@0.3.0
9
+
10
+ ## 0.0.5
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [[`afac0006`](https://github.com/gradio-app/gradio/commit/afac0006337ce2840cf497cd65691f2f60ee5912)]:
15
+ - @gradio/statustracker@0.2.0
16
+ - @gradio/theme@0.1.0
17
+ - @gradio/utils@0.1.1
18
+ - @gradio/atoms@0.1.2
19
+ - @gradio/upload@0.2.1
20
+
21
+ ## 0.0.4
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies [[`abf1c57d`](https://github.com/gradio-app/gradio/commit/abf1c57d7d85de0df233ee3b38aeb38b638477db), [`79d8f9d8`](https://github.com/gradio-app/gradio/commit/79d8f9d891901683c5a1b7486efb44eab2478c96)]:
26
+ - @gradio/icons@0.1.0
27
+ - @gradio/utils@0.1.0
28
+ - @gradio/upload@0.2.0
29
+ - @gradio/atoms@0.1.1
30
+ - @gradio/statustracker@0.1.1
31
+
32
+ ## 0.0.3
33
+
34
+ ### Highlights
35
+
36
+ #### Improve startup performance and markdown support ([#5279](https://github.com/gradio-app/gradio/pull/5279) [`fe057300`](https://github.com/gradio-app/gradio/commit/fe057300f0672c62dab9d9b4501054ac5d45a4ec))
37
+
38
+ ##### Improved markdown support
39
+
40
+ We now have better support for markdown in `gr.Markdown` and `gr.Dataframe`. Including syntax highlighting and Github Flavoured Markdown. We also have more consistent markdown behaviour and styling.
41
+
42
+ ##### Various performance improvements
43
+
44
+ These improvements will be particularly beneficial to large applications.
45
+
46
+ - Rather than attaching events manually, they are now delegated, leading to a significant performance improvement and addressing a performance regression introduced in a recent version of Gradio. App startup for large applications is now around twice as fast.
47
+ - Optimised the mounting of individual components, leading to a modest performance improvement during startup (~30%).
48
+ - Corrected an issue that was causing markdown to re-render infinitely.
49
+ - Ensured that the `gr.3DModel` does re-render prematurely.
50
+
51
+ Thanks [@pngwn](https://github.com/pngwn)!
52
+
53
+ ### Features
54
+
55
+ - [#5215](https://github.com/gradio-app/gradio/pull/5215) [`fbdad78a`](https://github.com/gradio-app/gradio/commit/fbdad78af4c47454cbb570f88cc14bf4479bbceb) - Lazy load interactive or static variants of a component individually, rather than loading both variants regardless. This change will improve performance for many applications. Thanks [@pngwn](https://github.com/pngwn)!
56
+
57
+ ## 0.0.2
58
+
59
+ ### Patch Changes
60
+
61
+ - Updated dependencies [[`667875b2`](https://github.com/gradio-app/gradio/commit/667875b2441753e74d25bd9d3c8adedd8ede11cd)]:
62
+ - @gradio/upload@0.0.3
testbed/gradio-app__gradio/js/timeseries/example/Timeseries.svelte ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ export let value: string;
3
+ export let type: "gallery" | "table";
4
+ export let selected = false;
5
+ </script>
6
+
7
+ <div
8
+ class:table={type === "table"}
9
+ class:gallery={type === "gallery"}
10
+ class:selected
11
+ >
12
+ {value}
13
+ </div>
14
+
15
+ <style>
16
+ .gallery {
17
+ padding: var(--size-1) var(--size-2);
18
+ }
19
+ </style>
testbed/gradio-app__gradio/js/timeseries/example/index.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ export { default } from "./Timeseries.svelte";
testbed/gradio-app__gradio/js/timeseries/interactive/InteractiveTimeseries.svelte ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import type { Gradio } from "@gradio/utils";
3
+ import { Upload, ModifyUpload } from "@gradio/upload";
4
+ import type { FileData } from "@gradio/upload";
5
+ import { Block, BlockLabel, Empty } from "@gradio/atoms";
6
+ import Chart from "../shared";
7
+ import { UploadText } from "@gradio/atoms";
8
+
9
+ import { StatusTracker } from "@gradio/statustracker";
10
+ import type { LoadingStatus } from "@gradio/statustracker";
11
+ import { _ } from "svelte-i18n";
12
+
13
+ import { Chart as ChartIcon } from "@gradio/icons";
14
+
15
+ function format_value(val: StaticData): any {
16
+ return val.data.map((r) =>
17
+ r.reduce((acc, next, i) => ({ ...acc, [val.headers[i]]: next }), {})
18
+ );
19
+ }
20
+
21
+ interface StaticData {
22
+ data: number[][];
23
+ headers: string[];
24
+ }
25
+ interface Data {
26
+ data: number[][] | string;
27
+ headers?: string[];
28
+ }
29
+
30
+ export let elem_id = "";
31
+ export let elem_classes: string[] = [];
32
+ export let visible = true;
33
+ export let value: null | Data;
34
+ export let y: string[];
35
+ export let x: string;
36
+ export let label: string;
37
+ export let show_label: boolean;
38
+ export let colors: string[];
39
+ export let container = true;
40
+ export let scale: number | null = null;
41
+ export let min_width: number | undefined = undefined;
42
+ export let loading_status: LoadingStatus;
43
+ export let gradio: Gradio<{
44
+ change: undefined;
45
+ clear: undefined;
46
+ }>;
47
+
48
+ let _value: string | null;
49
+
50
+ function data_uri_to_blob(data_uri: string): Blob {
51
+ const byte_str = atob(data_uri.split(",")[1]);
52
+ const mime_str = data_uri.split(",")[0].split(":")[1].split(";")[0];
53
+
54
+ const ab = new ArrayBuffer(byte_str.length);
55
+ const ia = new Uint8Array(ab);
56
+
57
+ for (let i = 0; i < byte_str.length; i++) {
58
+ ia[i] = byte_str.charCodeAt(i);
59
+ }
60
+
61
+ return new Blob([ab], { type: mime_str });
62
+ }
63
+
64
+ function blob_to_string(blob: Blob): void {
65
+ const reader = new FileReader();
66
+
67
+ reader.addEventListener("loadend", (e) => {
68
+ //@ts-ignore
69
+ _value = e.srcElement.result;
70
+ });
71
+
72
+ reader.readAsText(blob);
73
+ }
74
+
75
+ function dict_to_string(dict: Data): void {
76
+ if (dict.headers) _value = dict.headers.join(",");
77
+ const data = dict.data as number[][];
78
+ data.forEach((_x: unknown[]) => {
79
+ _value = _value + "\n";
80
+ _value = _value + _x.join(",");
81
+ });
82
+ }
83
+
84
+ $: {
85
+ if (value && value.data && typeof value.data === "string") {
86
+ if (!value) _value = null;
87
+ else blob_to_string(data_uri_to_blob(value.data));
88
+ } else if (value && value.data && typeof value.data != "string") {
89
+ if (!value) _value = null;
90
+ dict_to_string(value);
91
+ }
92
+ }
93
+
94
+ interface XRow {
95
+ name: string;
96
+ values: number[];
97
+ }
98
+
99
+ interface YRow {
100
+ name: string;
101
+ values: { x: number; y: number }[];
102
+ }
103
+
104
+ function make_dict(_x: XRow, _y: YRow[]): Data {
105
+ const headers = [];
106
+ const data = [];
107
+
108
+ headers.push(_x.name);
109
+ _y.forEach(({ name }) => headers.push(name));
110
+
111
+ for (let i = 0; i < _x.values.length; i++) {
112
+ let _data = [];
113
+ _data.push(_x.values[i]);
114
+ _y.forEach(({ values }) => _data.push(values[i].y));
115
+
116
+ data.push(_data);
117
+ }
118
+ return { headers, data };
119
+ }
120
+
121
+ function handle_load(
122
+ v: string | FileData | (string | FileData)[] | null
123
+ ): string | FileData | (string | FileData)[] | null {
124
+ value = { data: v as string };
125
+ return v;
126
+ }
127
+
128
+ function handle_clear({ detail }: CustomEvent<FileData | null>): void {
129
+ value = null;
130
+ gradio.dispatch("change");
131
+ gradio.dispatch("clear");
132
+ }
133
+
134
+ $: _value = value == null ? null : _value;
135
+
136
+ $: value, gradio.dispatch("change");
137
+ </script>
138
+
139
+ <Block
140
+ {visible}
141
+ variant={!_value ? "dashed" : "solid"}
142
+ padding={false}
143
+ {elem_id}
144
+ {elem_classes}
145
+ {container}
146
+ {scale}
147
+ {min_width}
148
+ >
149
+ <BlockLabel {show_label} Icon={ChartIcon} label={label || "TimeSeries"} />
150
+ <StatusTracker {...loading_status} />
151
+
152
+ {#if _value}
153
+ <div class="chart">
154
+ <ModifyUpload on:clear={handle_clear} />
155
+ <Chart
156
+ value={_value}
157
+ {y}
158
+ {x}
159
+ on:process={({ detail: { x, y } }) => (value = make_dict(x, y))}
160
+ {colors}
161
+ />
162
+ </div>
163
+ {:else if value === undefined || value === null}
164
+ <Upload
165
+ filetype="text/csv"
166
+ on:load={({ detail }) => handle_load(detail)}
167
+ include_file_metadata={false}
168
+ >
169
+ <UploadText type="csv" />
170
+ </Upload>
171
+ {/if}
172
+ </Block>
173
+
174
+ <style>
175
+ .chart {
176
+ display: flex;
177
+ display: relative;
178
+ justify-content: center;
179
+ align-items: center;
180
+ background: var(--background-fill-primary);
181
+ width: var(--size-full);
182
+ height: var(--size-64);
183
+ }
184
+ </style>
testbed/gradio-app__gradio/js/timeseries/interactive/index.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ export { default } from "./InteractiveTimeseries.svelte";
testbed/gradio-app__gradio/js/timeseries/package.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@gradio/timeseries",
3
+ "version": "0.0.6",
4
+ "description": "Gradio UI packages",
5
+ "type": "module",
6
+ "main": "index.svelte",
7
+ "author": "",
8
+ "license": "ISC",
9
+ "private": true,
10
+ "main_changeset": true,
11
+ "exports": {
12
+ "./package.json": "./package.json",
13
+ "./interactive": "./interactive/index.ts",
14
+ "./static": "./static/index.ts",
15
+ "./example": "./example/index.ts"
16
+ },
17
+ "dependencies": {
18
+ "@gradio/atoms": "workspace:^",
19
+ "@gradio/icons": "workspace:^",
20
+ "@gradio/statustracker": "workspace:^",
21
+ "@gradio/theme": "workspace:^",
22
+ "@gradio/tooltip": "workspace:^",
23
+ "@gradio/upload": "workspace:^",
24
+ "@gradio/utils": "workspace:^",
25
+ "d3-dsv": "^3.0.1",
26
+ "d3-scale": "^4.0.2",
27
+ "d3-shape": "^3.2.0"
28
+ },
29
+ "devDependencies": {
30
+ "@types/d3-dsv": "^3.0.0",
31
+ "@types/d3-scale": "^4.0.3",
32
+ "@types/d3-shape": "^3.1.1"
33
+ }
34
+ }
testbed/gradio-app__gradio/js/timeseries/shared/Chart.svelte ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { createEventDispatcher, onMount } from "svelte";
3
+ import { csvParse } from "d3-dsv";
4
+ import { scaleLinear } from "d3-scale";
5
+ import { line as _line, curveLinear } from "d3-shape";
6
+
7
+ import { colors as color_palette, ordered_colors } from "@gradio/theme";
8
+ import { get_next_color } from "@gradio/utils";
9
+
10
+ import { get_domains, transform_values } from "./utils";
11
+
12
+ import { tooltip } from "@gradio/tooltip";
13
+
14
+ export let value: string | Record<string, string>[];
15
+ export let x: string | undefined = undefined;
16
+ export let y: string[] | undefined = undefined;
17
+ export let colors: string[] = [];
18
+
19
+ const dispatch = createEventDispatcher();
20
+
21
+ $: ({ x: _x, y: _y } =
22
+ typeof value === "string"
23
+ ? transform_values(csvParse(value) as Record<string, string>[], x, y)
24
+ : transform_values(value, x, y));
25
+
26
+ $: x_domain = get_domains(_x);
27
+ $: y_domain = get_domains(_y);
28
+
29
+ $: scale_x = scaleLinear(x_domain, [0, 600]).nice();
30
+ $: scale_y = scaleLinear(y_domain, [350, 0]).nice();
31
+ $: x_ticks = scale_x.ticks(8);
32
+ $: y_ticks = scale_y.ticks(8);
33
+
34
+ let color_map: Record<string, string>;
35
+ $: color_map = _y.reduce(
36
+ (acc, next, i) => ({ ...acc, [next.name]: get_color(i) }),
37
+ {}
38
+ );
39
+
40
+ function get_color(index: number): string {
41
+ let current_color = colors[index % colors.length];
42
+
43
+ if (current_color && current_color in color_palette) {
44
+ return color_palette[current_color as keyof typeof color_palette]
45
+ ?.primary;
46
+ } else if (!current_color) {
47
+ return color_palette[get_next_color(index) as keyof typeof color_palette]
48
+ .primary;
49
+ }
50
+ return current_color;
51
+ }
52
+
53
+ onMount(() => {
54
+ dispatch("process", { x: _x, y: _y });
55
+ });
56
+ </script>
57
+
58
+ <div class="wrap">
59
+ <div class="legend">
60
+ {#each _y as { name }}
61
+ <div class="legend-item">
62
+ <span class="legend-box" style="background-color: {color_map[name]}" />
63
+ {name}
64
+ </div>
65
+ {/each}
66
+ </div>
67
+ <svg class="w-full" viewBox="-70 -20 700 420">
68
+ <g>
69
+ {#each x_ticks as tick}
70
+ <line
71
+ stroke-width="0.5"
72
+ x1={scale_x(tick)}
73
+ x2={scale_x(tick)}
74
+ y1={scale_y(y_ticks[0] < y_domain[0] ? y_ticks[0] : y_domain[0]) + 10}
75
+ y2={scale_y(
76
+ y_domain[1] > y_ticks[y_ticks.length - 1]
77
+ ? y_domain[1]
78
+ : y_ticks[y_ticks.length - 1]
79
+ )}
80
+ stroke="#aaa"
81
+ />
82
+ <text
83
+ class="label-text"
84
+ text-anchor="middle"
85
+ x={scale_x(tick)}
86
+ y={scale_y(y_ticks[0]) + 30}
87
+ >
88
+ {tick}
89
+ </text>
90
+ {/each}
91
+
92
+ {#each y_ticks as tick}
93
+ <line
94
+ stroke-width="0.5"
95
+ y1={scale_y(tick)}
96
+ y2={scale_y(tick)}
97
+ x1={scale_x(x_ticks[0] < x_domain[0] ? x_ticks[0] : x_domain[0]) - 10}
98
+ x2={scale_x(
99
+ x_domain[1] > x_ticks[x_ticks.length - 1]
100
+ ? x_domain[1]
101
+ : x_ticks[x_ticks.length - 1]
102
+ )}
103
+ stroke="#aaa"
104
+ />
105
+
106
+ <text
107
+ class="label-text"
108
+ text-anchor="end"
109
+ y={scale_y(tick) + 4}
110
+ x={scale_x(x_ticks[0]) - 20}
111
+ >
112
+ {tick}
113
+ </text>
114
+ {/each}
115
+
116
+ {#if y_domain[1] > y_ticks[y_ticks.length - 1]}
117
+ <line
118
+ stroke-width="0.5"
119
+ y1={scale_y(y_domain[1])}
120
+ y2={scale_y(y_domain[1])}
121
+ x1={scale_x(x_ticks[0])}
122
+ x2={scale_x(x_domain[1])}
123
+ stroke="#aaa"
124
+ />
125
+ <text
126
+ class="label-text"
127
+ text-anchor="end"
128
+ y={scale_y(y_domain[1]) + 4}
129
+ x={scale_x(x_ticks[0]) - 20}
130
+ >
131
+ {y_domain[1]}
132
+ </text>
133
+ {/if}
134
+ </g>
135
+
136
+ {#each _y as { name, values }}
137
+ {@const color = color_map[name]}
138
+ {#each values as { x, y }}
139
+ <circle
140
+ r="3.5"
141
+ cx={scale_x(x)}
142
+ cy={scale_y(y)}
143
+ stroke-width="1.5"
144
+ stroke={color}
145
+ fill="none"
146
+ />
147
+ {/each}
148
+ <path
149
+ d={_line().curve(curveLinear)(
150
+ values.map(({ x, y }) => [scale_x(x), scale_y(y)])
151
+ )}
152
+ fill="none"
153
+ stroke={color}
154
+ stroke-width="3"
155
+ />
156
+ {/each}
157
+
158
+ {#each _y as { name, values }}
159
+ {@const color = color_map[name]}
160
+ {#each values as { x, y }}
161
+ <circle
162
+ use:tooltip={{ color, text: `(${x}, ${y})` }}
163
+ r="7"
164
+ cx={scale_x(x)}
165
+ cy={scale_y(y)}
166
+ stroke="black"
167
+ fill="black"
168
+ style="cursor: pointer; opacity: 0"
169
+ />
170
+ {/each}
171
+ {/each}
172
+ </svg>
173
+
174
+ <div class="main-label">
175
+ {_x.name}
176
+ </div>
177
+ </div>
178
+
179
+ <style>
180
+ .wrap {
181
+ margin-top: var(--size-3);
182
+ }
183
+
184
+ .legend {
185
+ display: flex;
186
+ justify-content: center;
187
+ align-items: center;
188
+ color: var(--body-text-color);
189
+ }
190
+
191
+ .legend-item {
192
+ display: flex;
193
+ align-items: center;
194
+ gap: var(--spacing-sm);
195
+ margin-right: var(--size-2);
196
+ margin-left: var(--size-2);
197
+ }
198
+
199
+ .legend-box {
200
+ display: inline-block;
201
+ border-radius: var(--radius-xs);
202
+ width: var(--size-3);
203
+ height: var(--size-3);
204
+ }
205
+
206
+ svg {
207
+ width: var(--size-full);
208
+ }
209
+
210
+ .label-text {
211
+ fill: var(--body-text-color);
212
+ font-size: var(--text-sm);
213
+ font-family: var(--font-mono);
214
+ }
215
+
216
+ .main-label {
217
+ display: flex;
218
+ justify-content: center;
219
+ align-items: center;
220
+ color: var(--body-text-color);
221
+ }
222
+ </style>
testbed/gradio-app__gradio/js/timeseries/shared/index.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ export { default } from "./Chart.svelte";
testbed/gradio-app__gradio/js/timeseries/shared/utils.ts ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ interface XYValue {
2
+ x: number;
3
+ y: number;
4
+ }
5
+
6
+ interface ObjectValue {
7
+ values: XYValue[];
8
+ }
9
+
10
+ export function get_domains(
11
+ values: ObjectValue[] | { values: number[] }
12
+ ): [number, number] {
13
+ let _vs: number[];
14
+ if (Array.isArray(values)) {
15
+ _vs = values.reduce<number[]>((acc, { values }) => {
16
+ return [...acc, ...values.map(({ y }) => y)];
17
+ }, []);
18
+ } else {
19
+ _vs = values.values;
20
+ }
21
+ return [Math.min(..._vs), Math.max(..._vs)];
22
+ }
23
+
24
+ interface Row {
25
+ name: string;
26
+ values: number[];
27
+ }
28
+
29
+ interface RowPoint {
30
+ name: string;
31
+ values: { x: number; y: number }[];
32
+ }
33
+
34
+ interface TransformedValues {
35
+ x: Row;
36
+ y: RowPoint[];
37
+ }
38
+
39
+ export function transform_values(
40
+ values: Record<string, string>[],
41
+ x?: string,
42
+ y?: string[]
43
+ ): TransformedValues {
44
+ const transformed_values = Object.entries(
45
+ values[0]
46
+ ).reduce<TransformedValues>(
47
+ (acc, next, i) => {
48
+ if ((!x && i === 0) || (x && next[0] === x)) {
49
+ acc.x.name = next[0];
50
+ } else if (!y || (y && y.includes(next[0]))) {
51
+ acc.y.push({ name: next[0], values: [] });
52
+ }
53
+ return acc;
54
+ },
55
+ { x: { name: "", values: [] }, y: [] }
56
+ );
57
+
58
+ for (let i = 0; i < values.length; i++) {
59
+ const _a = Object.entries(values[i]);
60
+ for (let j = 0; j < _a.length; j++) {
61
+ let [name, x] = _a[j];
62
+ if (name === transformed_values.x.name) {
63
+ transformed_values.x.values.push(parseFloat(x));
64
+ } else {
65
+ transformed_values.y[j - 1].values.push({
66
+ y: parseFloat(_a[j][1]),
67
+ x: parseFloat(_a[0][1])
68
+ });
69
+ }
70
+ }
71
+ }
72
+
73
+ return transformed_values;
74
+ }
testbed/gradio-app__gradio/js/timeseries/static/StaticTimeseries.svelte ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { createEventDispatcher } from "svelte";
3
+ import { Block, BlockLabel, Empty } from "@gradio/atoms";
4
+ import Chart from "../shared";
5
+ import { StatusTracker } from "@gradio/statustracker";
6
+ import type { LoadingStatus } from "@gradio/statustracker";
7
+ import { _ } from "svelte-i18n";
8
+
9
+ import { Chart as ChartIcon } from "@gradio/icons";
10
+
11
+ function format_value(val: StaticData): any {
12
+ return val.data.map((r) =>
13
+ r.reduce((acc, next, i) => ({ ...acc, [val.headers[i]]: next }), {})
14
+ );
15
+ }
16
+
17
+ const dispatch = createEventDispatcher<{
18
+ change: undefined;
19
+ clear: undefined;
20
+ }>();
21
+
22
+ interface StaticData {
23
+ data: number[][];
24
+ headers: string[];
25
+ }
26
+ interface Data {
27
+ data: number[][] | string;
28
+ headers?: string[];
29
+ }
30
+
31
+ export let elem_id = "";
32
+ export let elem_classes: string[] = [];
33
+ export let visible = true;
34
+ export let value: null | Data;
35
+
36
+ export let label: string;
37
+ export let show_label: boolean;
38
+ export let colors: string[];
39
+ export let container = true;
40
+ export let scale: number | null = null;
41
+ export let min_width: number | undefined = undefined;
42
+ export let loading_status: LoadingStatus;
43
+
44
+ $: static_data = value && format_value(value as StaticData);
45
+
46
+ $: value, dispatch("change");
47
+ </script>
48
+
49
+ <Block
50
+ {visible}
51
+ variant={"solid"}
52
+ padding={false}
53
+ {elem_id}
54
+ {elem_classes}
55
+ {container}
56
+ {scale}
57
+ {min_width}
58
+ >
59
+ <BlockLabel {show_label} Icon={ChartIcon} label={label || "TimeSeries"} />
60
+ <StatusTracker {...loading_status} />
61
+
62
+ {#if static_data}
63
+ <Chart value={static_data} {colors} />
64
+ {:else}
65
+ <Empty unpadded_box={true} size="large">
66
+ <ChartIcon />
67
+ </Empty>
68
+ {/if}
69
+ </Block>
testbed/gradio-app__gradio/js/timeseries/static/index.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ export { default } from "./StaticTimeseries.svelte";
testbed/gradio-app__gradio/js/tooltip/README.md ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # `@gradio/button`
2
+
3
+ ```html
4
+ <script>
5
+ import { Button } from "@gradio/button";
6
+ </script>
7
+
8
+ <button type="primary|secondary" href="string" on:click="{e.detail === href}">
9
+ content
10
+ </button>
11
+ ```
testbed/gradio-app__gradio/js/tooltip/src/tooltip.ts ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { ActionReturn } from "svelte/action";
2
+ import Tooltip from "./Tooltip.svelte";
3
+
4
+ interface ActionArgs {
5
+ color: string;
6
+ text: string;
7
+ }
8
+
9
+ export function tooltip(
10
+ element: HTMLElement | SVGElement,
11
+ { color, text }: ActionArgs
12
+ ): ActionReturn {
13
+ let tooltipComponent: Tooltip;
14
+ function mouse_over(event: MouseEvent): MouseEvent {
15
+ tooltipComponent = new Tooltip({
16
+ props: {
17
+ text,
18
+ x: event.pageX,
19
+ y: event.pageY,
20
+ color
21
+ },
22
+ target: document.body
23
+ });
24
+
25
+ return event;
26
+ }
27
+ function mouseMove(event: MouseEvent): void {
28
+ tooltipComponent.$set({
29
+ x: event.pageX,
30
+ y: event.pageY
31
+ });
32
+ }
33
+ function mouseLeave(): void {
34
+ tooltipComponent.$destroy();
35
+ }
36
+
37
+ const el = element as HTMLElement;
38
+
39
+ el.addEventListener("mouseover", mouse_over);
40
+ el.addEventListener("mouseleave", mouseLeave);
41
+ el.addEventListener("mousemove", mouseMove);
42
+
43
+ return {
44
+ destroy() {
45
+ el.removeEventListener("mouseover", mouse_over);
46
+ el.removeEventListener("mouseleave", mouseLeave);
47
+ el.removeEventListener("mousemove", mouseMove);
48
+ }
49
+ };
50
+ }
testbed/gradio-app__gradio/js/tootils/CHANGELOG.md ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # @gradio/tootils
2
+
3
+ ## 0.0.2
4
+
5
+ ### Highlights
6
+
7
+ #### Improve startup performance and markdown support ([#5279](https://github.com/gradio-app/gradio/pull/5279) [`fe057300`](https://github.com/gradio-app/gradio/commit/fe057300f0672c62dab9d9b4501054ac5d45a4ec))
8
+
9
+ ##### Improved markdown support
10
+
11
+ We now have better support for markdown in `gr.Markdown` and `gr.Dataframe`. Including syntax highlighting and Github Flavoured Markdown. We also have more consistent markdown behaviour and styling.
12
+
13
+ ##### Various performance improvements
14
+
15
+ These improvements will be particularly beneficial to large applications.
16
+
17
+ - Rather than attaching events manually, they are now delegated, leading to a significant performance improvement and addressing a performance regression introduced in a recent version of Gradio. App startup for large applications is now around twice as fast.
18
+ - Optimised the mounting of individual components, leading to a modest performance improvement during startup (~30%).
19
+ - Corrected an issue that was causing markdown to re-render infinitely.
20
+ - Ensured that the `gr.3DModel` does re-render prematurely.
21
+
22
+ Thanks [@pngwn](https://github.com/pngwn)!
testbed/gradio-app__gradio/js/tootils/README.md ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # `@gradio/button`
2
+
3
+ ```html
4
+ <script>
5
+ import { Button } from "@gradio/button";
6
+ </script>
7
+
8
+ <button type="primary|secondary" href="string" on:click="{e.detail === href}">
9
+ content
10
+ </button>
11
+ ```
testbed/gradio-app__gradio/js/tootils/package.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@gradio/tootils",
3
+ "version": "0.0.2",
4
+ "description": "Internal test utilities",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "author": "",
8
+ "license": "ISC",
9
+ "private": true
10
+ }
testbed/gradio-app__gradio/js/upload/CHANGELOG.md ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # @gradio/upload
2
+
3
+ ## 0.3.0
4
+
5
+ ### Features
6
+
7
+ - [#5554](https://github.com/gradio-app/gradio/pull/5554) [`75ddeb390`](https://github.com/gradio-app/gradio/commit/75ddeb390d665d4484667390a97442081b49a423) - Accessibility Improvements. Thanks [@hannahblair](https://github.com/hannahblair)!
8
+
9
+ ## 0.2.1
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies []:
14
+ - @gradio/atoms@0.1.2
15
+
16
+ ## 0.2.0
17
+
18
+ ### Features
19
+
20
+ - [#5373](https://github.com/gradio-app/gradio/pull/5373) [`79d8f9d8`](https://github.com/gradio-app/gradio/commit/79d8f9d891901683c5a1b7486efb44eab2478c96) - Adds `height` and `zoom_speed` parameters to `Model3D` component, as well as a button to reset the camera position. Thanks [@abidlabs](https://github.com/abidlabs)!
21
+
22
+ ## 0.1.0
23
+
24
+ ### Highlights
25
+
26
+ #### Improve startup performance and markdown support ([#5279](https://github.com/gradio-app/gradio/pull/5279) [`fe057300`](https://github.com/gradio-app/gradio/commit/fe057300f0672c62dab9d9b4501054ac5d45a4ec))
27
+
28
+ ##### Improved markdown support
29
+
30
+ We now have better support for markdown in `gr.Markdown` and `gr.Dataframe`. Including syntax highlighting and Github Flavoured Markdown. We also have more consistent markdown behaviour and styling.
31
+
32
+ ##### Various performance improvements
33
+
34
+ These improvements will be particularly beneficial to large applications.
35
+
36
+ - Rather than attaching events manually, they are now delegated, leading to a significant performance improvement and addressing a performance regression introduced in a recent version of Gradio. App startup for large applications is now around twice as fast.
37
+ - Optimised the mounting of individual components, leading to a modest performance improvement during startup (~30%).
38
+ - Corrected an issue that was causing markdown to re-render infinitely.
39
+ - Ensured that the `gr.3DModel` does re-render prematurely.
40
+
41
+ Thanks [@pngwn](https://github.com/pngwn)!
42
+
43
+ ### Features
44
+
45
+ - [#5216](https://github.com/gradio-app/gradio/pull/5216) [`4b58ea6d`](https://github.com/gradio-app/gradio/commit/4b58ea6d98e7a43b3f30d8a4cb6f379bc2eca6a8) - Update i18n tokens and locale files. Thanks [@hannahblair](https://github.com/hannahblair)!
46
+
47
+ ### Fixes
48
+
49
+ - [#5285](https://github.com/gradio-app/gradio/pull/5285) [`cdfd4217`](https://github.com/gradio-app/gradio/commit/cdfd42174a9c777eaee9c1209bf8e90d8c7791f2) - Tweaks to `icon` parameter in `gr.Button()`. Thanks [@abidlabs](https://github.com/abidlabs)!
50
+
51
+ ## 0.0.3
52
+
53
+ ### Fixes
54
+
55
+ - [#5077](https://github.com/gradio-app/gradio/pull/5077) [`667875b2`](https://github.com/gradio-app/gradio/commit/667875b2441753e74d25bd9d3c8adedd8ede11cd) - Live audio streaming output
56
+
57
+ highlight:
58
+
59
+ #### Now supports loading streamed outputs
60
+
61
+ Allows users to use generators to stream audio out, yielding consecutive chunks of audio. Requires `streaming=True` to be set on the output audio.
62
+
63
+ ```python
64
+ import gradio as gr
65
+ from pydub import AudioSegment
66
+
67
+ def stream_audio(audio_file):
68
+ audio = AudioSegment.from_mp3(audio_file)
69
+ i = 0
70
+ chunk_size = 3000
71
+
72
+ while chunk_size*i < len(audio):
73
+ chunk = audio[chunk_size*i:chunk_size*(i+1)]
74
+ i += 1
75
+ if chunk:
76
+ file = f"/tmp/{i}.mp3"
77
+ chunk.export(file, format="mp3")
78
+ yield file
79
+
80
+ demo = gr.Interface(
81
+ fn=stream_audio,
82
+ inputs=gr.Audio(type="filepath", label="Audio file to stream"),
83
+ outputs=gr.Audio(autoplay=True, streaming=True),
84
+ )
85
+
86
+ demo.queue().launch()
87
+ ```
88
+
89
+ From the backend, streamed outputs are served from the `/stream/` endpoint instead of the `/file/` endpoint. Currently just used to serve audio streaming output. The output JSON will have `is_stream`: `true`, instead of `is_file`: `true` in the file data object. Thanks [@aliabid94](https://github.com/aliabid94)!
90
+
91
+ ## 0.0.2
92
+
93
+ ### Patch Changes
94
+
95
+ - Updated dependencies []:
96
+ - @gradio/atoms@0.0.2
testbed/gradio-app__gradio/js/upload/package.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@gradio/upload",
3
+ "version": "0.3.0",
4
+ "description": "Gradio UI packages",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "author": "",
8
+ "license": "ISC",
9
+ "private": true,
10
+ "dependencies": {
11
+ "@gradio/atoms": "workspace:^",
12
+ "@gradio/icons": "workspace:^"
13
+ },
14
+ "main_changeset": true
15
+ }
testbed/gradio-app__gradio/js/upload/src/ModifyUpload.svelte ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { IconButton } from "@gradio/atoms";
3
+ import { Edit, Clear, Undo } from "@gradio/icons";
4
+
5
+ import { createEventDispatcher } from "svelte";
6
+ import { _ } from "svelte-i18n";
7
+
8
+ export let editable = false;
9
+ export let undoable = false;
10
+ export let absolute = true;
11
+
12
+ const dispatch = createEventDispatcher<{
13
+ edit: never;
14
+ clear: never;
15
+ undo: never;
16
+ }>();
17
+ </script>
18
+
19
+ <div
20
+ class:not-absolute={!absolute}
21
+ style:position={absolute ? "absolute" : "static"}
22
+ >
23
+ {#if editable}
24
+ <IconButton
25
+ Icon={Edit}
26
+ label={$_("common.edit")}
27
+ on:click={() => dispatch("edit")}
28
+ />
29
+ {/if}
30
+
31
+ {#if undoable}
32
+ <IconButton
33
+ Icon={Undo}
34
+ label={$_("common.undo")}
35
+ on:click={() => dispatch("undo")}
36
+ />
37
+ {/if}
38
+
39
+ <IconButton
40
+ Icon={Clear}
41
+ label={$_("common.clear")}
42
+ on:click={(event) => {
43
+ dispatch("clear");
44
+ event.stopPropagation();
45
+ }}
46
+ />
47
+ </div>
48
+
49
+ <style>
50
+ div {
51
+ display: flex;
52
+ top: var(--size-2);
53
+ right: var(--size-2);
54
+ justify-content: flex-end;
55
+ gap: var(--spacing-sm);
56
+ z-index: var(--layer-1);
57
+ }
58
+
59
+ .not-absolute {
60
+ margin: var(--size-1);
61
+ }
62
+ </style>
testbed/gradio-app__gradio/js/upload/src/Upload.svelte ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { createEventDispatcher } from "svelte";
3
+ import { blobToBase64 } from "./utils";
4
+
5
+ export let filetype: string | null = null;
6
+ export let include_file_metadata = true;
7
+ export let dragging = false;
8
+ export let boundedheight = true;
9
+ export let center = true;
10
+ export let flex = true;
11
+ export let file_count = "single";
12
+ export let disable_click = false;
13
+ export let parse_to_data_url = true;
14
+
15
+ let hidden_upload: HTMLInputElement;
16
+
17
+ const dispatch = createEventDispatcher();
18
+
19
+ function updateDragging(): void {
20
+ dragging = !dragging;
21
+ }
22
+
23
+ function openFileUpload(): void {
24
+ if (disable_click) return;
25
+ hidden_upload.value = "";
26
+ hidden_upload.click();
27
+ }
28
+
29
+ async function loadFiles(files: FileList): Promise<void> {
30
+ let _files: File[] = Array.from(files);
31
+ if (!files.length || !window.FileReader) {
32
+ return;
33
+ }
34
+ if (file_count === "single") {
35
+ _files = [files[0]];
36
+ }
37
+
38
+ if (include_file_metadata) {
39
+ var file_metadata: { name: string; size: number }[] = _files.map((f) => ({
40
+ name: f.name,
41
+ size: f.size,
42
+ }));
43
+ }
44
+ var load_file_data = [];
45
+ var file_data: string[] | File[] = [];
46
+ if (parse_to_data_url) {
47
+ file_data = await Promise.all(_files.map((f) => blobToBase64(f)));
48
+ } else {
49
+ file_data = _files;
50
+ }
51
+ if (include_file_metadata) {
52
+ if (parse_to_data_url) {
53
+ load_file_data = file_data.map((data, i) => ({
54
+ data,
55
+ ...file_metadata[i],
56
+ }));
57
+ } else {
58
+ load_file_data = file_data.map((data, i) => ({
59
+ data: "",
60
+ blob: data,
61
+ ...file_metadata[i],
62
+ }));
63
+ }
64
+ } else {
65
+ load_file_data = file_data;
66
+ }
67
+ dispatch(
68
+ "load",
69
+ file_count === "single" ? load_file_data[0] : load_file_data
70
+ );
71
+ }
72
+
73
+ async function loadFilesFromUpload(e: Event): Promise<void> {
74
+ const target = e.target as HTMLInputElement;
75
+
76
+ if (!target.files) return;
77
+ await loadFiles(target.files);
78
+ }
79
+
80
+ async function loadFilesFromDrop(e: DragEvent): Promise<void> {
81
+ dragging = false;
82
+ if (!e.dataTransfer?.files) return;
83
+ await loadFiles(e.dataTransfer.files);
84
+ }
85
+ </script>
86
+
87
+ <button
88
+ class:center
89
+ class:boundedheight
90
+ class:flex
91
+ on:drag|preventDefault|stopPropagation
92
+ on:dragstart|preventDefault|stopPropagation
93
+ on:dragend|preventDefault|stopPropagation
94
+ on:dragover|preventDefault|stopPropagation
95
+ on:dragenter|preventDefault|stopPropagation
96
+ on:dragleave|preventDefault|stopPropagation
97
+ on:drop|preventDefault|stopPropagation
98
+ on:click={openFileUpload}
99
+ on:drop={loadFilesFromDrop}
100
+ on:dragenter={updateDragging}
101
+ on:dragleave={updateDragging}
102
+ >
103
+ <slot />
104
+ <input
105
+ type="file"
106
+ bind:this={hidden_upload}
107
+ on:change={loadFilesFromUpload}
108
+ accept={filetype}
109
+ multiple={file_count === "multiple" || undefined}
110
+ webkitdirectory={file_count === "directory" || undefined}
111
+ mozdirectory={file_count === "directory" || undefined}
112
+ />
113
+ </button>
114
+
115
+ <style>
116
+ button {
117
+ cursor: pointer;
118
+ width: var(--size-full);
119
+ height: var(--size-full);
120
+ }
121
+
122
+ .center {
123
+ display: flex;
124
+ justify-content: center;
125
+ }
126
+ .flex {
127
+ display: flex;
128
+ justify-content: center;
129
+ align-items: center;
130
+ }
131
+
132
+ input {
133
+ display: none;
134
+ }
135
+ </style>
testbed/gradio-app__gradio/js/upload/src/index.ts ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ export { default as Upload } from "./Upload.svelte";
2
+ export { default as ModifyUpload } from "./ModifyUpload.svelte";
3
+ export type { FileData } from "./types";
4
+ export {
5
+ normalise_file,
6
+ get_fetchable_url_or_file,
7
+ blobToBase64
8
+ } from "./utils";
testbed/gradio-app__gradio/js/upload/src/utils.ts ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { FileData } from "./types";
2
+
3
+ export function normalise_file(
4
+ file: string | FileData | null,
5
+ root: string,
6
+ root_url: string | null
7
+ ): FileData | null;
8
+
9
+ export function normalise_file(
10
+ file: FileData[] | null,
11
+ root: string,
12
+ root_url: string | null
13
+ ): FileData[] | null;
14
+
15
+ export function normalise_file(
16
+ file: FileData[] | FileData | null,
17
+ root: string,
18
+ root_url: string | null
19
+ ): FileData[] | FileData | null;
20
+
21
+ export function normalise_file(
22
+ file: FileData[] | FileData | string | null,
23
+ root: string,
24
+ root_url: string | null
25
+ ): FileData[] | FileData | null {
26
+ if (file == null) return null;
27
+ if (typeof file === "string") {
28
+ return {
29
+ name: "file_data",
30
+ data: file
31
+ };
32
+ } else if (Array.isArray(file)) {
33
+ const normalized_file: (FileData | null)[] = [];
34
+
35
+ for (const x of file) {
36
+ if (x === null) {
37
+ normalized_file.push(null);
38
+ } else {
39
+ normalized_file.push(normalise_file(x, root, root_url));
40
+ }
41
+ }
42
+
43
+ return normalized_file as FileData[];
44
+ } else if (file.is_file) {
45
+ file.data = get_fetchable_url_or_file(file.name, root, root_url);
46
+ } else if (file.is_stream) {
47
+ if (root_url == null) {
48
+ file.data = root + "/stream/" + file.name;
49
+ } else {
50
+ file.data = "/proxy=" + root_url + "stream/" + file.name;
51
+ }
52
+ }
53
+ return file;
54
+ }
55
+
56
+ function is_url(str: string): boolean {
57
+ try {
58
+ const url = new URL(str);
59
+ return url.protocol === "http:" || url.protocol === "https:";
60
+ } catch {
61
+ return false;
62
+ }
63
+ }
64
+
65
+ export function get_fetchable_url_or_file(
66
+ path: string | null,
67
+ root: string,
68
+ root_url: string | null
69
+ ): string {
70
+ if (path == null) {
71
+ return root_url ? `/proxy=${root_url}file=` : `${root}/file=`;
72
+ }
73
+ if (is_url(path)) {
74
+ return path;
75
+ }
76
+ return root_url ? `/proxy=${root_url}file=${path}` : `${root}/file=${path}`;
77
+ }
78
+
79
+ export const blobToBase64 = (blob: File): Promise<string> => {
80
+ const reader = new FileReader();
81
+ reader.readAsDataURL(blob);
82
+ return new Promise((resolve) => {
83
+ reader.onloadend = (): void => {
84
+ resolve(reader.result as string);
85
+ };
86
+ });
87
+ };
testbed/gradio-app__gradio/js/uploadbutton/CHANGELOG.md ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # @gradio/uploadbutton
2
+
3
+ ## 0.0.6
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`c57f1b75e`](https://github.com/gradio-app/gradio/commit/c57f1b75e272c76b0af4d6bd0c7f44743ff34f26), [`40de3d217`](https://github.com/gradio-app/gradio/commit/40de3d2178b61ebe424b6f6228f94c0c6f679bea), [`ea0e00b20`](https://github.com/gradio-app/gradio/commit/ea0e00b207b4b90a10e9d054c4202d4e705a29ba), [`75ddeb390`](https://github.com/gradio-app/gradio/commit/75ddeb390d665d4484667390a97442081b49a423)]:
8
+ - @gradio/client@0.4.0
9
+ - @gradio/button@0.2.0
10
+ - @gradio/upload@0.3.0
11
+
12
+ ## 0.0.5
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [[`26fef8c7`](https://github.com/gradio-app/gradio/commit/26fef8c7f85a006c7e25cdbed1792df19c512d02)]:
17
+ - @gradio/client@0.3.1
18
+ - @gradio/utils@0.1.1
19
+ - @gradio/button@0.1.3
20
+ - @gradio/upload@0.2.1
21
+
22
+ ## 0.0.4
23
+
24
+ ### Patch Changes
25
+
26
+ - Updated dependencies [[`119c8343`](https://github.com/gradio-app/gradio/commit/119c834331bfae60d4742c8f20e9cdecdd67e8c2), [`abf1c57d`](https://github.com/gradio-app/gradio/commit/abf1c57d7d85de0df233ee3b38aeb38b638477db), [`79d8f9d8`](https://github.com/gradio-app/gradio/commit/79d8f9d891901683c5a1b7486efb44eab2478c96)]:
27
+ - @gradio/client@0.3.0
28
+ - @gradio/utils@0.1.0
29
+ - @gradio/upload@0.2.0
30
+ - @gradio/button@0.1.2
31
+
32
+ ## 0.0.3
33
+
34
+ ### Highlights
35
+
36
+ #### Improve startup performance and markdown support ([#5279](https://github.com/gradio-app/gradio/pull/5279) [`fe057300`](https://github.com/gradio-app/gradio/commit/fe057300f0672c62dab9d9b4501054ac5d45a4ec))
37
+
38
+ ##### Improved markdown support
39
+
40
+ We now have better support for markdown in `gr.Markdown` and `gr.Dataframe`. Including syntax highlighting and Github Flavoured Markdown. We also have more consistent markdown behaviour and styling.
41
+
42
+ ##### Various performance improvements
43
+
44
+ These improvements will be particularly beneficial to large applications.
45
+
46
+ - Rather than attaching events manually, they are now delegated, leading to a significant performance improvement and addressing a performance regression introduced in a recent version of Gradio. App startup for large applications is now around twice as fast.
47
+ - Optimised the mounting of individual components, leading to a modest performance improvement during startup (~30%).
48
+ - Corrected an issue that was causing markdown to re-render infinitely.
49
+ - Ensured that the `gr.3DModel` does re-render prematurely.
50
+
51
+ Thanks [@pngwn](https://github.com/pngwn)!
52
+
53
+ ## 0.0.2
54
+
55
+ ### Patch Changes
56
+
57
+ - Updated dependencies [[`61129052`](https://github.com/gradio-app/gradio/commit/61129052ed1391a75c825c891d57fa0ad6c09fc8), [`667875b2`](https://github.com/gradio-app/gradio/commit/667875b2441753e74d25bd9d3c8adedd8ede11cd), [`67265a58`](https://github.com/gradio-app/gradio/commit/67265a58027ef1f9e4c0eb849a532f72eaebde48), [`8b4eb8ca`](https://github.com/gradio-app/gradio/commit/8b4eb8cac9ea07bde31b44e2006ca2b7b5f4de36), [`37caa2e0`](https://github.com/gradio-app/gradio/commit/37caa2e0fe95d6cab8beb174580fb557904f137f)]:
58
+ - @gradio/client@0.2.0
59
+ - @gradio/upload@0.0.3
60
+ - @gradio/button@0.1.0
testbed/gradio-app__gradio/js/uploadbutton/UploadButton.test.ts ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { test, describe, expect, vi, afterEach, assert } from "vitest";
2
+ import { spy, spyOn } from "tinyspy";
3
+ import { cleanup, render, wait_for_event } from "@gradio/tootils";
4
+ import event from "@testing-library/user-event";
5
+ import { setupi18n } from "../app/src/i18n";
6
+ import UploadButton from "./interactive";
7
+
8
+ describe("UploadButton", () => {
9
+ afterEach(() => {
10
+ cleanup();
11
+ vi.restoreAllMocks();
12
+ });
13
+
14
+ test("Uploads with blob", async () => {
15
+ vi.mock("@gradio/client", async () => {
16
+ return {
17
+ upload_files: vi.fn((f) => new Promise((res) => res({})))
18
+ };
19
+ });
20
+
21
+ const api = await import("@gradio/client");
22
+
23
+ setupi18n();
24
+
25
+ const { getByTestId } = await render(UploadButton, {
26
+ label: "file",
27
+ value: null,
28
+ root: "http://localhost:7860",
29
+ file_count: "1"
30
+ });
31
+
32
+ const item = getByTestId("file-upload-button"); // container.querySelectorAll("input")[0];
33
+
34
+ const file = new File(["hello"], "my-audio.wav", { type: "audio/wav" });
35
+ await event.upload(item, file);
36
+
37
+ expect(api.upload_files).toHaveBeenCalled();
38
+ });
39
+
40
+ test("upload sets change event", async () => {
41
+ vi.mock("@gradio/client", async () => {
42
+ return {
43
+ upload_files: vi.fn((f) => new Promise((res) => res({})))
44
+ };
45
+ });
46
+
47
+ await import("@gradio/client");
48
+ setupi18n();
49
+ const { component, getByTestId, wait_for_event } = await render(
50
+ UploadButton,
51
+ {
52
+ label: "file",
53
+ value: null,
54
+ root: "http://localhost:7860",
55
+ file_count: "1"
56
+ }
57
+ );
58
+
59
+ const item = getByTestId("file-upload-button"); //container.querySelectorAll("input")[0];
60
+ const file = new File(["hello"], "my-audio.wav", { type: "audio/wav" });
61
+ event.upload(item, file);
62
+ const mock = await wait_for_event("change");
63
+ expect(mock.callCount).toBe(1);
64
+ const [data] = component.$capture_state().value;
65
+ expect(data).toBeTruthy();
66
+ assert.equal(data.name, "my-audio.wav");
67
+ });
68
+ });
testbed/gradio-app__gradio/js/uploadbutton/interactive/InteractiveUploadButton.svelte ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import type { Gradio } from "@gradio/utils";
3
+ import { getContext, tick } from "svelte";
4
+ import type { FileData } from "@gradio/upload";
5
+ import UploadButton from "../shared";
6
+ import { upload_files as default_upload_files } from "@gradio/client";
7
+ import { blobToBase64 } from "@gradio/upload";
8
+ import { _ } from "svelte-i18n";
9
+
10
+ export let elem_id = "";
11
+ export let elem_classes: string[] = [];
12
+ export let visible = true;
13
+ export let label: string;
14
+ export let value: null | FileData;
15
+ export let file_count: string;
16
+ export let file_types: string[] = [];
17
+ export let root: string;
18
+ export let size: "sm" | "lg" = "lg";
19
+ export let scale: number | null = null;
20
+ export let min_width: number | undefined = undefined;
21
+ export let variant: "primary" | "secondary" | "stop" = "secondary";
22
+ export let gradio: Gradio<{
23
+ change: FileData | null;
24
+ upload: FileData;
25
+ click: never;
26
+ }>;
27
+
28
+ const upload_files =
29
+ getContext<typeof default_upload_files>("upload_files") ??
30
+ default_upload_files;
31
+
32
+ async function handle_upload({
33
+ detail
34
+ }: CustomEvent<FileData>): Promise<void> {
35
+ value = detail;
36
+ await tick();
37
+ let files = (Array.isArray(detail) ? detail : [detail]).map(
38
+ (file_data) => file_data.blob!
39
+ );
40
+
41
+ upload_files(root, files).then(async (response) => {
42
+ if (response.error) {
43
+ (Array.isArray(detail) ? detail : [detail]).forEach(
44
+ async (file_data, i) => {
45
+ file_data.data = await blobToBase64(file_data.blob!);
46
+ file_data.blob = undefined;
47
+ }
48
+ );
49
+ } else {
50
+ (Array.isArray(detail) ? detail : [detail]).forEach((file_data, i) => {
51
+ if (response.files) {
52
+ file_data.orig_name = file_data.name;
53
+ file_data.name = response.files[i];
54
+ file_data.is_file = true;
55
+ file_data.blob = undefined;
56
+ }
57
+ });
58
+ }
59
+
60
+ gradio.dispatch("change", value);
61
+ gradio.dispatch("upload", detail);
62
+ });
63
+ }
64
+ </script>
65
+
66
+ <UploadButton
67
+ {elem_id}
68
+ {elem_classes}
69
+ {visible}
70
+ {file_count}
71
+ {file_types}
72
+ {size}
73
+ {scale}
74
+ {min_width}
75
+ {variant}
76
+ {label}
77
+ on:click={() => gradio.dispatch("click")}
78
+ on:load={handle_upload}
79
+ >
80
+ {$_(label)}
81
+ </UploadButton>
testbed/gradio-app__gradio/js/uploadbutton/package.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@gradio/uploadbutton",
3
+ "version": "0.0.6",
4
+ "description": "Gradio UI packages",
5
+ "type": "module",
6
+ "main": "index.svelte",
7
+ "author": "",
8
+ "license": "ISC",
9
+ "private": true,
10
+ "main_changeset": true,
11
+ "exports": {
12
+ "./package.json": "./package.json",
13
+ "./interactive": "./interactive/index.ts",
14
+ "./static": "./static/index.ts",
15
+ "./example": "./example/index.ts"
16
+ },
17
+ "dependencies": {
18
+ "@gradio/button": "workspace:^",
19
+ "@gradio/client": "workspace:^",
20
+ "@gradio/upload": "workspace:^",
21
+ "@gradio/utils": "workspace:^"
22
+ }
23
+ }
testbed/gradio-app__gradio/js/uploadbutton/shared/UploadButton.svelte ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { BaseButton } from "@gradio/button/static";
3
+ import { createEventDispatcher } from "svelte";
4
+ import type { FileData } from "@gradio/upload";
5
+
6
+ export let elem_id = "";
7
+ export let elem_classes: string[] = [];
8
+ export let visible = true;
9
+ export let file_count: string;
10
+ export let file_types: string[] = [];
11
+ export let include_file_metadata = true;
12
+ export let size: "sm" | "lg" = "lg";
13
+ export let scale: number | null = null;
14
+ export let min_width: number | undefined = undefined;
15
+ export let variant: "primary" | "secondary" | "stop" = "secondary";
16
+ export let label: string;
17
+ export let disabled = false;
18
+
19
+ let hidden_upload: HTMLInputElement;
20
+ const dispatch = createEventDispatcher();
21
+ let accept_file_types: string | null;
22
+ if (file_types == null) {
23
+ accept_file_types = null;
24
+ } else {
25
+ file_types = file_types.map((x) => {
26
+ if (x.startsWith(".")) {
27
+ return x;
28
+ }
29
+ return x + "/*";
30
+ });
31
+ accept_file_types = file_types.join(", ");
32
+ }
33
+
34
+ function openFileUpload(): void {
35
+ hidden_upload.click();
36
+ }
37
+
38
+ function loadFiles(files: FileList): void {
39
+ let _files: File[] = Array.from(files);
40
+ if (!files.length) {
41
+ return;
42
+ }
43
+ if (file_count === "single") {
44
+ _files = [files[0]];
45
+ }
46
+ var all_file_data: (FileData | File)[] = [];
47
+ _files.forEach((f, i) => {
48
+ all_file_data[i] = include_file_metadata
49
+ ? {
50
+ name: f.name,
51
+ size: f.size,
52
+ data: "",
53
+ blob: f
54
+ }
55
+ : f;
56
+ if (
57
+ all_file_data.filter((x) => x !== undefined).length === files.length
58
+ ) {
59
+ dispatch(
60
+ "load",
61
+ file_count == "single" ? all_file_data[0] : all_file_data
62
+ );
63
+ }
64
+ });
65
+ }
66
+
67
+ function loadFilesFromUpload(e: Event): void {
68
+ const target = e.target as HTMLInputElement;
69
+ if (!target.files) {
70
+ return;
71
+ }
72
+ loadFiles(target.files);
73
+ }
74
+
75
+ function clearInputValue(e: Event): void {
76
+ const target = e.target as HTMLInputElement;
77
+ if (target.value) target.value = "";
78
+ }
79
+ </script>
80
+
81
+ <input
82
+ class="hide"
83
+ accept={accept_file_types}
84
+ type="file"
85
+ bind:this={hidden_upload}
86
+ on:change={loadFilesFromUpload}
87
+ on:click={clearInputValue}
88
+ multiple={file_count === "multiple" || undefined}
89
+ webkitdirectory={file_count === "directory" || undefined}
90
+ mozdirectory={file_count === "directory" || undefined}
91
+ data-testid="{label}-upload-button"
92
+ />
93
+
94
+ <BaseButton
95
+ {size}
96
+ {variant}
97
+ {elem_id}
98
+ {elem_classes}
99
+ {visible}
100
+ on:click={openFileUpload}
101
+ {scale}
102
+ {min_width}
103
+ {disabled}
104
+ >
105
+ <slot />
106
+ </BaseButton>
107
+
108
+ <style>
109
+ .hide {
110
+ display: none;
111
+ }
112
+ </style>
testbed/gradio-app__gradio/js/uploadbutton/shared/index.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ export { default } from "./UploadButton.svelte";
testbed/gradio-app__gradio/js/uploadbutton/static/StaticUploadButton.svelte ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import type { Gradio } from "@gradio/utils";
3
+ import { tick, getContext } from "svelte";
4
+ import type { FileData } from "@gradio/upload";
5
+ import UploadButton from "../shared";
6
+ import { upload_files as default_upload_files } from "@gradio/client";
7
+ import { blobToBase64 } from "@gradio/upload";
8
+ import { _ } from "svelte-i18n";
9
+
10
+ export let elem_id = "";
11
+ export let elem_classes: string[] = [];
12
+ export let visible = true;
13
+ export let label: string;
14
+ export let value: null | FileData;
15
+ export let file_count: string;
16
+ export let file_types: string[] = [];
17
+ export let root: string;
18
+ export let size: "sm" | "lg" = "lg";
19
+ export let scale: number | null = null;
20
+ export let min_width: number | undefined = undefined;
21
+ export let variant: "primary" | "secondary" | "stop" = "secondary";
22
+ export let gradio: Gradio<{
23
+ change: FileData | null;
24
+ upload: FileData;
25
+ click: never;
26
+ }>;
27
+
28
+ const upload_files =
29
+ getContext<typeof default_upload_files>("upload_files") ??
30
+ default_upload_files;
31
+
32
+ async function handle_upload({
33
+ detail
34
+ }: CustomEvent<FileData>): Promise<void> {
35
+ value = detail;
36
+ await tick();
37
+ let files = (Array.isArray(detail) ? detail : [detail]).map(
38
+ (file_data) => file_data.blob!
39
+ );
40
+
41
+ upload_files(root, files).then(async (response) => {
42
+ if (response.error) {
43
+ (Array.isArray(detail) ? detail : [detail]).forEach(
44
+ async (file_data, i) => {
45
+ file_data.data = await blobToBase64(file_data.blob!);
46
+ file_data.blob = undefined;
47
+ }
48
+ );
49
+ } else {
50
+ (Array.isArray(detail) ? detail : [detail]).forEach((file_data, i) => {
51
+ if (response.files) {
52
+ file_data.orig_name = file_data.name;
53
+ file_data.name = response.files[i];
54
+ file_data.is_file = true;
55
+ file_data.blob = undefined;
56
+ }
57
+ });
58
+ }
59
+
60
+ gradio.dispatch("change", value);
61
+ gradio.dispatch("upload", detail);
62
+ });
63
+ }
64
+ </script>
65
+
66
+ <UploadButton
67
+ {elem_id}
68
+ {elem_classes}
69
+ {visible}
70
+ {file_count}
71
+ {file_types}
72
+ {size}
73
+ {scale}
74
+ {min_width}
75
+ disabled
76
+ {variant}
77
+ {label}
78
+ on:click={() => gradio.dispatch("click")}
79
+ on:load={handle_upload}
80
+ >
81
+ {$_(label)}
82
+ </UploadButton>
testbed/gradio-app__gradio/js/uploadbutton/static/index.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ export { default } from "./StaticUploadButton.svelte";
testbed/gradio-app__gradio/js/utils/CHANGELOG.md ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # @gradio/utils
2
+
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`afac0006`](https://github.com/gradio-app/gradio/commit/afac0006337ce2840cf497cd65691f2f60ee5912)]:
8
+ - @gradio/theme@0.1.0
9
+
10
+ ## 0.1.0
11
+
12
+ ### Highlights
13
+
14
+ #### Like/Dislike Button for Chatbot ([#5391](https://github.com/gradio-app/gradio/pull/5391) [`abf1c57d`](https://github.com/gradio-app/gradio/commit/abf1c57d7d85de0df233ee3b38aeb38b638477db))
15
+
16
+ Thanks [@dawoodkhan82](https://github.com/dawoodkhan82)!
17
+
18
+ ## 0.0.3
19
+
20
+ ### Highlights
21
+
22
+ #### Improve startup performance and markdown support ([#5279](https://github.com/gradio-app/gradio/pull/5279) [`fe057300`](https://github.com/gradio-app/gradio/commit/fe057300f0672c62dab9d9b4501054ac5d45a4ec))
23
+
24
+ ##### Improved markdown support
25
+
26
+ We now have better support for markdown in `gr.Markdown` and `gr.Dataframe`. Including syntax highlighting and Github Flavoured Markdown. We also have more consistent markdown behaviour and styling.
27
+
28
+ ##### Various performance improvements
29
+
30
+ These improvements will be particularly beneficial to large applications.
31
+
32
+ - Rather than attaching events manually, they are now delegated, leading to a significant performance improvement and addressing a performance regression introduced in a recent version of Gradio. App startup for large applications is now around twice as fast.
33
+ - Optimised the mounting of individual components, leading to a modest performance improvement during startup (~30%).
34
+ - Corrected an issue that was causing markdown to re-render infinitely.
35
+ - Ensured that the `gr.3DModel` does re-render prematurely.
36
+
37
+ Thanks [@pngwn](https://github.com/pngwn)!
38
+
39
+ ## 0.0.2
40
+
41
+ ### Patch Changes
42
+
43
+ - Updated dependencies [[`41c83070`](https://github.com/gradio-app/gradio/commit/41c83070b01632084e7d29123048a96c1e261407)]:
44
+ - @gradio/theme@0.0.2
testbed/gradio-app__gradio/js/utils/README.md ADDED
@@ -0,0 +1 @@
 
 
1
+ # `@gradio/table`