Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- Dockerfile +16 -0
- README.md +10 -3
- __init__.py +0 -0
- __pycache__/__init__.cpython-311.pyc +0 -0
- __pycache__/app.cpython-311.pyc +0 -0
- alligator_images/.DS_Store +0 -0
- alligator_images/Chinese-Yangtze-alligator.jpeg +0 -0
- alligator_images/Nile-Crocodile.jpg +0 -0
- alligator_images/american_alligator.jpeg +0 -0
- alligator_images/babygator.jpeg +0 -0
- alligator_images/flat_aligator.jpeg +0 -0
- alligator_images/gator.jpeg +0 -0
- alligator_images/gator_fam.jpeg +0 -0
- alligator_images/largegator.jpeg +0 -0
- app.py +18 -0
- css.css +157 -0
- requirements.txt +1 -0
- space.py +155 -0
- src/.gitignore +9 -0
- src/README.md +390 -0
- src/backend/gradio_carousel/__init__.py +4 -0
- src/backend/gradio_carousel/carousel.py +215 -0
- src/backend/gradio_carousel/carousel.pyi +343 -0
- src/backend/gradio_carousel/templates/component/__vite-browser-external-2447137e.js +4 -0
- src/backend/gradio_carousel/templates/component/index.js +0 -0
- src/backend/gradio_carousel/templates/component/style.css +1 -0
- src/backend/gradio_carousel/templates/component/wrapper-6f348d45-f837cf34.js +2455 -0
- src/demo/__init__.py +0 -0
- src/demo/alligator_images/.DS_Store +0 -0
- src/demo/alligator_images/Chinese-Yangtze-alligator.jpeg +0 -0
- src/demo/alligator_images/Nile-Crocodile.jpg +0 -0
- src/demo/alligator_images/american_alligator.jpeg +0 -0
- src/demo/alligator_images/babygator.jpeg +0 -0
- src/demo/alligator_images/flat_aligator.jpeg +0 -0
- src/demo/alligator_images/gator.jpeg +0 -0
- src/demo/alligator_images/gator_fam.jpeg +0 -0
- src/demo/alligator_images/largegator.jpeg +0 -0
- src/demo/app.py +18 -0
- src/demo/css.css +157 -0
- src/demo/space.py +155 -0
- src/frontend/.DS_Store +0 -0
- src/frontend/Index.svelte +110 -0
- src/frontend/package-lock.json +1117 -0
- src/frontend/package.json +30 -0
- src/frontend/shared/Gallery.svelte +520 -0
- src/frontend/shared/tweenOpacity.ts +54 -0
- src/frontend/shared/utils.ts +18 -0
- src/pyproject.toml +45 -0
Dockerfile
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
FROM python:3.9
|
3 |
+
|
4 |
+
WORKDIR /code
|
5 |
+
|
6 |
+
COPY --link --chown=1000 . .
|
7 |
+
|
8 |
+
RUN mkdir -p /tmp/cache/
|
9 |
+
RUN chmod a+rwx -R /tmp/cache/
|
10 |
+
ENV TRANSFORMERS_CACHE=/tmp/cache/
|
11 |
+
|
12 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
13 |
+
|
14 |
+
ENV PYTHONUNBUFFERED=1 GRADIO_ALLOW_FLAGGING=never GRADIO_NUM_PORTS=1 GRADIO_SERVER_NAME=0.0.0.0 GRADIO_SERVER_PORT=7860 SYSTEM=spaces
|
15 |
+
|
16 |
+
CMD ["python", "space.py"]
|
README.md
CHANGED
@@ -1,10 +1,17 @@
|
|
|
|
1 |
---
|
2 |
-
|
3 |
-
|
4 |
colorFrom: blue
|
5 |
colorTo: blue
|
6 |
sdk: docker
|
7 |
pinned: false
|
|
|
8 |
---
|
9 |
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
---
|
3 |
+
tags: [gradio-custom-component,gradio-template-Gallery]
|
4 |
+
title: gradio_carousel V0.0.1
|
5 |
colorFrom: blue
|
6 |
colorTo: blue
|
7 |
sdk: docker
|
8 |
pinned: false
|
9 |
+
license: apache-2.0
|
10 |
---
|
11 |
|
12 |
+
|
13 |
+
# Name: gradio_carousel
|
14 |
+
|
15 |
+
Description: Python library for easily interacting with trained machine learning models
|
16 |
+
|
17 |
+
Install with: pip install gradio_carousel
|
__init__.py
ADDED
File without changes
|
__pycache__/__init__.cpython-311.pyc
ADDED
Binary file (153 Bytes). View file
|
|
__pycache__/app.cpython-311.pyc
ADDED
Binary file (1.5 kB). View file
|
|
alligator_images/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
alligator_images/Chinese-Yangtze-alligator.jpeg
ADDED
alligator_images/Nile-Crocodile.jpg
ADDED
alligator_images/american_alligator.jpeg
ADDED
alligator_images/babygator.jpeg
ADDED
alligator_images/flat_aligator.jpeg
ADDED
alligator_images/gator.jpeg
ADDED
alligator_images/gator_fam.jpeg
ADDED
alligator_images/largegator.jpeg
ADDED
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
|
3 |
+
import os
|
4 |
+
|
5 |
+
import gradio as gr
|
6 |
+
from gradio_carousel import Carousel
|
7 |
+
|
8 |
+
image_dir = os.path.join(os.path.dirname(__file__), "alligator_images")
|
9 |
+
|
10 |
+
images = [os.path.join(image_dir, file) for file in os.listdir(image_dir) if file.endswith((".jpg", ".jpeg", ".png"))]
|
11 |
+
|
12 |
+
with gr.Blocks() as demo:
|
13 |
+
with gr.Row():
|
14 |
+
Carousel(label="cool gators", value=images) # carousel component with images
|
15 |
+
|
16 |
+
|
17 |
+
if __name__ == "__main__":
|
18 |
+
demo.launch()
|
css.css
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
html {
|
2 |
+
font-family: Inter;
|
3 |
+
font-size: 16px;
|
4 |
+
font-weight: 400;
|
5 |
+
line-height: 1.5;
|
6 |
+
-webkit-text-size-adjust: 100%;
|
7 |
+
background: #fff;
|
8 |
+
color: #323232;
|
9 |
+
-webkit-font-smoothing: antialiased;
|
10 |
+
-moz-osx-font-smoothing: grayscale;
|
11 |
+
text-rendering: optimizeLegibility;
|
12 |
+
}
|
13 |
+
|
14 |
+
:root {
|
15 |
+
--space: 1;
|
16 |
+
--vspace: calc(var(--space) * 1rem);
|
17 |
+
--vspace-0: calc(3 * var(--space) * 1rem);
|
18 |
+
--vspace-1: calc(2 * var(--space) * 1rem);
|
19 |
+
--vspace-2: calc(1.5 * var(--space) * 1rem);
|
20 |
+
--vspace-3: calc(0.5 * var(--space) * 1rem);
|
21 |
+
}
|
22 |
+
|
23 |
+
.app {
|
24 |
+
max-width: 748px !important;
|
25 |
+
}
|
26 |
+
|
27 |
+
.prose p {
|
28 |
+
margin: var(--vspace) 0;
|
29 |
+
line-height: var(--vspace * 2);
|
30 |
+
font-size: 1rem;
|
31 |
+
}
|
32 |
+
|
33 |
+
code {
|
34 |
+
font-family: "Inconsolata", sans-serif;
|
35 |
+
font-size: 16px;
|
36 |
+
}
|
37 |
+
|
38 |
+
h1,
|
39 |
+
h1 code {
|
40 |
+
font-weight: 400;
|
41 |
+
line-height: calc(2.5 / var(--space) * var(--vspace));
|
42 |
+
}
|
43 |
+
|
44 |
+
h1 code {
|
45 |
+
background: none;
|
46 |
+
border: none;
|
47 |
+
letter-spacing: 0.05em;
|
48 |
+
padding-bottom: 5px;
|
49 |
+
position: relative;
|
50 |
+
padding: 0;
|
51 |
+
}
|
52 |
+
|
53 |
+
h2 {
|
54 |
+
margin: var(--vspace-1) 0 var(--vspace-2) 0;
|
55 |
+
line-height: 1em;
|
56 |
+
}
|
57 |
+
|
58 |
+
h3,
|
59 |
+
h3 code {
|
60 |
+
margin: var(--vspace-1) 0 var(--vspace-2) 0;
|
61 |
+
line-height: 1em;
|
62 |
+
}
|
63 |
+
|
64 |
+
h4,
|
65 |
+
h5,
|
66 |
+
h6 {
|
67 |
+
margin: var(--vspace-3) 0 var(--vspace-3) 0;
|
68 |
+
line-height: var(--vspace);
|
69 |
+
}
|
70 |
+
|
71 |
+
.bigtitle,
|
72 |
+
h1,
|
73 |
+
h1 code {
|
74 |
+
font-size: calc(8px * 4.5);
|
75 |
+
word-break: break-word;
|
76 |
+
}
|
77 |
+
|
78 |
+
.title,
|
79 |
+
h2,
|
80 |
+
h2 code {
|
81 |
+
font-size: calc(8px * 3.375);
|
82 |
+
font-weight: lighter;
|
83 |
+
word-break: break-word;
|
84 |
+
border: none;
|
85 |
+
background: none;
|
86 |
+
}
|
87 |
+
|
88 |
+
.subheading1,
|
89 |
+
h3,
|
90 |
+
h3 code {
|
91 |
+
font-size: calc(8px * 1.8);
|
92 |
+
font-weight: 600;
|
93 |
+
border: none;
|
94 |
+
background: none;
|
95 |
+
letter-spacing: 0.1em;
|
96 |
+
text-transform: uppercase;
|
97 |
+
}
|
98 |
+
|
99 |
+
h2 code {
|
100 |
+
padding: 0;
|
101 |
+
position: relative;
|
102 |
+
letter-spacing: 0.05em;
|
103 |
+
}
|
104 |
+
|
105 |
+
blockquote {
|
106 |
+
font-size: calc(8px * 1.1667);
|
107 |
+
font-style: italic;
|
108 |
+
line-height: calc(1.1667 * var(--vspace));
|
109 |
+
margin: var(--vspace-2) var(--vspace-2);
|
110 |
+
}
|
111 |
+
|
112 |
+
.subheading2,
|
113 |
+
h4 {
|
114 |
+
font-size: calc(8px * 1.4292);
|
115 |
+
text-transform: uppercase;
|
116 |
+
font-weight: 600;
|
117 |
+
}
|
118 |
+
|
119 |
+
.subheading3,
|
120 |
+
h5 {
|
121 |
+
font-size: calc(8px * 1.2917);
|
122 |
+
line-height: calc(1.2917 * var(--vspace));
|
123 |
+
|
124 |
+
font-weight: lighter;
|
125 |
+
text-transform: uppercase;
|
126 |
+
letter-spacing: 0.15em;
|
127 |
+
}
|
128 |
+
|
129 |
+
h6 {
|
130 |
+
font-size: calc(8px * 1.1667);
|
131 |
+
font-size: 1.1667em;
|
132 |
+
font-weight: normal;
|
133 |
+
font-style: italic;
|
134 |
+
font-family: "le-monde-livre-classic-byol", serif !important;
|
135 |
+
letter-spacing: 0px !important;
|
136 |
+
}
|
137 |
+
|
138 |
+
#start .md > *:first-child {
|
139 |
+
margin-top: 0;
|
140 |
+
}
|
141 |
+
|
142 |
+
h2 + h3 {
|
143 |
+
margin-top: 0;
|
144 |
+
}
|
145 |
+
|
146 |
+
.md hr {
|
147 |
+
border: none;
|
148 |
+
border-top: 1px solid var(--block-border-color);
|
149 |
+
margin: var(--vspace-2) 0 var(--vspace-2) 0;
|
150 |
+
}
|
151 |
+
.prose ul {
|
152 |
+
margin: var(--vspace-2) 0 var(--vspace-1) 0;
|
153 |
+
}
|
154 |
+
|
155 |
+
.gap {
|
156 |
+
gap: 0;
|
157 |
+
}
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
gradio_carousel-0.0.1-py3-none-any.whl
|
space.py
ADDED
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import gradio as gr
|
3 |
+
from app import demo as app
|
4 |
+
import os
|
5 |
+
|
6 |
+
_docs = {'Carousel': {'description': 'Used to display a list of images as a gallery that can be scrolled through.\n', 'members': {'__init__': {'value': {'type': 'list[\n numpy.ndarray\n | PIL.Image.Image\n | str\n | pathlib.Path\n | tuple\n ]\n | Callable\n | None', 'default': 'None', 'description': 'List of images to display in the gallery by default. If callable, the function will be called whenever the app loads to set the initial value of the component.'}, 'label': {'type': 'str | None', 'default': 'None', 'description': 'The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.'}, 'every': {'type': 'float | None', 'default': 'None', 'description': "If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. Queue must be enabled. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute."}, 'show_label': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will display label.'}, 'container': {'type': 'bool', 'default': 'True', 'description': 'If True, will place the component in a container - providing some extra padding around the border.'}, 'scale': {'type': 'int | None', 'default': 'None', 'description': 'relative width compared to adjacent Components in a Row. For example, if Component A has scale=2, and Component B has scale=1, A will be twice as wide as B. Should be an integer.'}, 'min_width': {'type': 'int', 'default': '160', 'description': 'minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.'}, 'visible': {'type': 'bool', 'default': 'True', 'description': 'If False, component will be hidden.'}, 'elem_id': {'type': 'str | None', 'default': 'None', 'description': 'An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'elem_classes': {'type': 'list[str] | str | None', 'default': 'None', 'description': 'An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'render': {'type': 'bool', 'default': 'True', 'description': 'If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.'}, 'columns': {'type': 'int | tuple | None', 'default': '2', 'description': 'Represents the number of images that should be shown in one row, for each of the six standard screen sizes (<576px, <768px, <992px, <1200px, <1400px, >1400px). If fewer than 6 are given then the last will be used for all subsequent breakpoints'}, 'rows': {'type': 'int | tuple | None', 'default': 'None', 'description': 'Represents the number of rows in the image grid, for each of the six standard screen sizes (<576px, <768px, <992px, <1200px, <1400px, >1400px). If fewer than 6 are given then the last will be used for all subsequent breakpoints'}, 'height': {'type': 'int | float | None', 'default': 'None', 'description': 'The height of the gallery component, specified in pixels if a number is passed, or in CSS units if a string is passed. If more images are displayed than can fit in the height, a scrollbar will appear.'}, 'allow_preview': {'type': 'bool', 'default': 'True', 'description': 'If True, images in the gallery will be enlarged when they are clicked. Default is True.'}, 'preview': {'type': 'bool | None', 'default': 'None', 'description': 'If True, Carousel will start in preview mode, which shows all of the images as thumbnails and allows the user to click on them to view them in full size. Only works if allow_preview is True.'}, 'selected_index': {'type': 'int | None', 'default': 'None', 'description': 'The index of the image that should be initially selected. If None, no image will be selected at start. If provided, will set Carousel to preview mode unless allow_preview is set to False.'}, 'object_fit': {'type': '"contain" | "cover" | "fill" | "none" | "scale-down" | None', 'default': 'None', 'description': 'CSS object-fit property for the thumbnail images in the gallery. Can be "contain", "cover", "fill", "none", or "scale-down".'}, 'show_share_button': {'type': 'bool | None', 'default': 'None', 'description': 'If True, will show a share icon in the corner of the component that allows user to share outputs to Hugging Face Spaces Discussions. If False, icon does not appear. If set to None (default behavior), then the icon appears if this Gradio app is launched on Spaces, but not otherwise.'}, 'show_download_button': {'type': 'bool | None', 'default': 'True', 'description': 'If True, will show a download button in the corner of the selected image. If False, the icon does not appear. Default is True.'}, 'interactive': {'type': 'bool | None', 'default': 'None', 'description': 'If True, the gallery will be interactive, allowing the user to upload images. If False, the gallery will be static. Default is True.'}, 'type': {'type': '"numpy" | "pil" | "filepath"', 'default': '"filepath"', 'description': 'The format the image is converted to before being passed into the prediction function. "numpy" converts the image to a numpy array with shape (height, width, 3) and values from 0 to 255, "pil" converts the image to a PIL image object, "filepath" passes a str path to a temporary file containing the image. If the image is SVG, the `type` is ignored and the filepath of the SVG is returned.'}}, 'postprocess': {'value': {'type': 'list[\n numpy.ndarray\n | PIL.Image.Image\n | pathlib.Path\n | str\n | tuple[\n numpy.ndarray\n | PIL.Image.Image\n | pathlib.Path\n | str,\n str,\n ]\n ]\n | None', 'description': 'list of images, or list of (image, caption) tuples'}}, 'preprocess': {'return': {'type': 'list[tuple[str, str | None]]\n | list[tuple[PIL.Image.Image, str | None]]\n | list[tuple[numpy.ndarray, str | None]]\n | None', 'description': None}, 'value': None}}, 'events': {'select': {'type': None, 'default': None, 'description': 'Event listener for when the user selects or deselects the Carousel. Uses event data gradio.SelectData to carry `value` referring to the label of the Carousel, and `selected` to refer to state of the Carousel. See EventData documentation on how to use this event data'}, 'upload': {'type': None, 'default': None, 'description': 'This listener is triggered when the user uploads a file into the Carousel.'}, 'change': {'type': None, 'default': None, 'description': 'Triggered when the value of the Carousel changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input.'}}}, '__meta__': {'additional_interfaces': {}, 'user_fn_refs': {'Carousel': []}}}
|
7 |
+
|
8 |
+
abs_path = os.path.join(os.path.dirname(__file__), "css.css")
|
9 |
+
|
10 |
+
with gr.Blocks(
|
11 |
+
css=abs_path,
|
12 |
+
theme=gr.themes.Default(
|
13 |
+
font_mono=[
|
14 |
+
gr.themes.GoogleFont("Inconsolata"),
|
15 |
+
"monospace",
|
16 |
+
],
|
17 |
+
),
|
18 |
+
) as demo:
|
19 |
+
gr.Markdown(
|
20 |
+
"""
|
21 |
+
# `gradio_carousel`
|
22 |
+
|
23 |
+
<div style="display: flex; gap: 7px;">
|
24 |
+
<img alt="Static Badge" src="https://img.shields.io/badge/version%20-%200.0.1%20-%20orange">
|
25 |
+
</div>
|
26 |
+
|
27 |
+
Python library for easily interacting with trained machine learning models
|
28 |
+
""", elem_classes=["md-custom"], header_links=True)
|
29 |
+
app.render()
|
30 |
+
gr.Markdown(
|
31 |
+
"""
|
32 |
+
## Installation
|
33 |
+
|
34 |
+
```bash
|
35 |
+
pip install gradio_carousel
|
36 |
+
```
|
37 |
+
|
38 |
+
## Usage
|
39 |
+
|
40 |
+
```python
|
41 |
+
|
42 |
+
|
43 |
+
import os
|
44 |
+
|
45 |
+
import gradio as gr
|
46 |
+
from gradio_carousel import Carousel
|
47 |
+
|
48 |
+
image_dir = os.path.join(os.path.dirname(__file__), "alligator_images")
|
49 |
+
|
50 |
+
images = [os.path.join(image_dir, file) for file in os.listdir(image_dir) if file.endswith((".jpg", ".jpeg", ".png"))]
|
51 |
+
|
52 |
+
with gr.Blocks() as demo:
|
53 |
+
with gr.Row():
|
54 |
+
Carousel(label="cool gators", value=images) # carousel component with images
|
55 |
+
|
56 |
+
|
57 |
+
if __name__ == "__main__":
|
58 |
+
demo.launch()
|
59 |
+
|
60 |
+
```
|
61 |
+
""", elem_classes=["md-custom"], header_links=True)
|
62 |
+
|
63 |
+
|
64 |
+
gr.Markdown("""
|
65 |
+
## `Carousel`
|
66 |
+
|
67 |
+
### Initialization
|
68 |
+
""", elem_classes=["md-custom"], header_links=True)
|
69 |
+
|
70 |
+
gr.ParamViewer(value=_docs["Carousel"]["members"]["__init__"], linkify=[])
|
71 |
+
|
72 |
+
|
73 |
+
gr.Markdown("### Events")
|
74 |
+
gr.ParamViewer(value=_docs["Carousel"]["events"], linkify=['Event'])
|
75 |
+
|
76 |
+
|
77 |
+
|
78 |
+
|
79 |
+
gr.Markdown("""
|
80 |
+
|
81 |
+
### User function
|
82 |
+
|
83 |
+
The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
|
84 |
+
|
85 |
+
- When used as an Input, the component only impacts the input signature of the user function.
|
86 |
+
- When used as an output, the component only impacts the return signature of the user function.
|
87 |
+
|
88 |
+
The code snippet below is accurate in cases where the component is used as both an input and an output.
|
89 |
+
|
90 |
+
- **As output:** Should return, list of images, or list of (image, caption) tuples.
|
91 |
+
|
92 |
+
```python
|
93 |
+
def predict(
|
94 |
+
value: list[tuple[str, str | None]]
|
95 |
+
| list[tuple[PIL.Image.Image, str | None]]
|
96 |
+
| list[tuple[numpy.ndarray, str | None]]
|
97 |
+
| None
|
98 |
+
) -> list[
|
99 |
+
numpy.ndarray
|
100 |
+
| PIL.Image.Image
|
101 |
+
| pathlib.Path
|
102 |
+
| str
|
103 |
+
| tuple[
|
104 |
+
numpy.ndarray
|
105 |
+
| PIL.Image.Image
|
106 |
+
| pathlib.Path
|
107 |
+
| str,
|
108 |
+
str,
|
109 |
+
]
|
110 |
+
]
|
111 |
+
| None:
|
112 |
+
return value
|
113 |
+
```
|
114 |
+
""", elem_classes=["md-custom", "Carousel-user-fn"], header_links=True)
|
115 |
+
|
116 |
+
|
117 |
+
|
118 |
+
|
119 |
+
demo.load(None, js=r"""function() {
|
120 |
+
const refs = {};
|
121 |
+
const user_fn_refs = {
|
122 |
+
Carousel: [], };
|
123 |
+
requestAnimationFrame(() => {
|
124 |
+
|
125 |
+
Object.entries(user_fn_refs).forEach(([key, refs]) => {
|
126 |
+
if (refs.length > 0) {
|
127 |
+
const el = document.querySelector(`.${key}-user-fn`);
|
128 |
+
if (!el) return;
|
129 |
+
refs.forEach(ref => {
|
130 |
+
el.innerHTML = el.innerHTML.replace(
|
131 |
+
new RegExp("\\b"+ref+"\\b", "g"),
|
132 |
+
`<a href="#h-${ref.toLowerCase()}">${ref}</a>`
|
133 |
+
);
|
134 |
+
})
|
135 |
+
}
|
136 |
+
})
|
137 |
+
|
138 |
+
Object.entries(refs).forEach(([key, refs]) => {
|
139 |
+
if (refs.length > 0) {
|
140 |
+
const el = document.querySelector(`.${key}`);
|
141 |
+
if (!el) return;
|
142 |
+
refs.forEach(ref => {
|
143 |
+
el.innerHTML = el.innerHTML.replace(
|
144 |
+
new RegExp("\\b"+ref+"\\b", "g"),
|
145 |
+
`<a href="#h-${ref.toLowerCase()}">${ref}</a>`
|
146 |
+
);
|
147 |
+
})
|
148 |
+
}
|
149 |
+
})
|
150 |
+
})
|
151 |
+
}
|
152 |
+
|
153 |
+
""")
|
154 |
+
|
155 |
+
demo.launch()
|
src/.gitignore
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.eggs/
|
2 |
+
dist/
|
3 |
+
*.pyc
|
4 |
+
__pycache__/
|
5 |
+
*.py[cod]
|
6 |
+
*$py.class
|
7 |
+
__tmp/*
|
8 |
+
*.pyi
|
9 |
+
node_modules
|
src/README.md
ADDED
@@ -0,0 +1,390 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
# `gradio_carousel`
|
3 |
+
<img alt="Static Badge" src="https://img.shields.io/badge/version%20-%200.0.1%20-%20orange">
|
4 |
+
|
5 |
+
Python library for easily interacting with trained machine learning models
|
6 |
+
|
7 |
+
## Installation
|
8 |
+
|
9 |
+
```bash
|
10 |
+
pip install gradio_carousel
|
11 |
+
```
|
12 |
+
|
13 |
+
## Usage
|
14 |
+
|
15 |
+
```python
|
16 |
+
|
17 |
+
|
18 |
+
import os
|
19 |
+
|
20 |
+
import gradio as gr
|
21 |
+
from gradio_carousel import Carousel
|
22 |
+
|
23 |
+
image_dir = os.path.join(os.path.dirname(__file__), "alligator_images")
|
24 |
+
|
25 |
+
images = [os.path.join(image_dir, file) for file in os.listdir(image_dir) if file.endswith((".jpg", ".jpeg", ".png"))]
|
26 |
+
|
27 |
+
with gr.Blocks() as demo:
|
28 |
+
with gr.Row():
|
29 |
+
Carousel(label="cool gators", value=images) # carousel component with images
|
30 |
+
|
31 |
+
|
32 |
+
if __name__ == "__main__":
|
33 |
+
demo.launch()
|
34 |
+
|
35 |
+
```
|
36 |
+
|
37 |
+
## `Carousel`
|
38 |
+
|
39 |
+
### Initialization
|
40 |
+
|
41 |
+
<table>
|
42 |
+
<thead>
|
43 |
+
<tr>
|
44 |
+
<th align="left">name</th>
|
45 |
+
<th align="left" style="width: 25%;">type</th>
|
46 |
+
<th align="left">default</th>
|
47 |
+
<th align="left">description</th>
|
48 |
+
</tr>
|
49 |
+
</thead>
|
50 |
+
<tbody>
|
51 |
+
<tr>
|
52 |
+
<td align="left"><code>value</code></td>
|
53 |
+
<td align="left" style="width: 25%;">
|
54 |
+
|
55 |
+
```python
|
56 |
+
list[
|
57 |
+
numpy.ndarray
|
58 |
+
| PIL.Image.Image
|
59 |
+
| str
|
60 |
+
| pathlib.Path
|
61 |
+
| tuple
|
62 |
+
]
|
63 |
+
| Callable
|
64 |
+
| None
|
65 |
+
```
|
66 |
+
|
67 |
+
</td>
|
68 |
+
<td align="left"><code>None</code></td>
|
69 |
+
<td align="left">List of images to display in the gallery by default. If callable, the function will be called whenever the app loads to set the initial value of the component.</td>
|
70 |
+
</tr>
|
71 |
+
|
72 |
+
<tr>
|
73 |
+
<td align="left"><code>label</code></td>
|
74 |
+
<td align="left" style="width: 25%;">
|
75 |
+
|
76 |
+
```python
|
77 |
+
str | None
|
78 |
+
```
|
79 |
+
|
80 |
+
</td>
|
81 |
+
<td align="left"><code>None</code></td>
|
82 |
+
<td align="left">The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.</td>
|
83 |
+
</tr>
|
84 |
+
|
85 |
+
<tr>
|
86 |
+
<td align="left"><code>every</code></td>
|
87 |
+
<td align="left" style="width: 25%;">
|
88 |
+
|
89 |
+
```python
|
90 |
+
float | None
|
91 |
+
```
|
92 |
+
|
93 |
+
</td>
|
94 |
+
<td align="left"><code>None</code></td>
|
95 |
+
<td align="left">If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. Queue must be enabled. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.</td>
|
96 |
+
</tr>
|
97 |
+
|
98 |
+
<tr>
|
99 |
+
<td align="left"><code>show_label</code></td>
|
100 |
+
<td align="left" style="width: 25%;">
|
101 |
+
|
102 |
+
```python
|
103 |
+
bool | None
|
104 |
+
```
|
105 |
+
|
106 |
+
</td>
|
107 |
+
<td align="left"><code>None</code></td>
|
108 |
+
<td align="left">if True, will display label.</td>
|
109 |
+
</tr>
|
110 |
+
|
111 |
+
<tr>
|
112 |
+
<td align="left"><code>container</code></td>
|
113 |
+
<td align="left" style="width: 25%;">
|
114 |
+
|
115 |
+
```python
|
116 |
+
bool
|
117 |
+
```
|
118 |
+
|
119 |
+
</td>
|
120 |
+
<td align="left"><code>True</code></td>
|
121 |
+
<td align="left">If True, will place the component in a container - providing some extra padding around the border.</td>
|
122 |
+
</tr>
|
123 |
+
|
124 |
+
<tr>
|
125 |
+
<td align="left"><code>scale</code></td>
|
126 |
+
<td align="left" style="width: 25%;">
|
127 |
+
|
128 |
+
```python
|
129 |
+
int | None
|
130 |
+
```
|
131 |
+
|
132 |
+
</td>
|
133 |
+
<td align="left"><code>None</code></td>
|
134 |
+
<td align="left">relative width compared to adjacent Components in a Row. For example, if Component A has scale=2, and Component B has scale=1, A will be twice as wide as B. Should be an integer.</td>
|
135 |
+
</tr>
|
136 |
+
|
137 |
+
<tr>
|
138 |
+
<td align="left"><code>min_width</code></td>
|
139 |
+
<td align="left" style="width: 25%;">
|
140 |
+
|
141 |
+
```python
|
142 |
+
int
|
143 |
+
```
|
144 |
+
|
145 |
+
</td>
|
146 |
+
<td align="left"><code>160</code></td>
|
147 |
+
<td align="left">minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.</td>
|
148 |
+
</tr>
|
149 |
+
|
150 |
+
<tr>
|
151 |
+
<td align="left"><code>visible</code></td>
|
152 |
+
<td align="left" style="width: 25%;">
|
153 |
+
|
154 |
+
```python
|
155 |
+
bool
|
156 |
+
```
|
157 |
+
|
158 |
+
</td>
|
159 |
+
<td align="left"><code>True</code></td>
|
160 |
+
<td align="left">If False, component will be hidden.</td>
|
161 |
+
</tr>
|
162 |
+
|
163 |
+
<tr>
|
164 |
+
<td align="left"><code>elem_id</code></td>
|
165 |
+
<td align="left" style="width: 25%;">
|
166 |
+
|
167 |
+
```python
|
168 |
+
str | None
|
169 |
+
```
|
170 |
+
|
171 |
+
</td>
|
172 |
+
<td align="left"><code>None</code></td>
|
173 |
+
<td align="left">An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
|
174 |
+
</tr>
|
175 |
+
|
176 |
+
<tr>
|
177 |
+
<td align="left"><code>elem_classes</code></td>
|
178 |
+
<td align="left" style="width: 25%;">
|
179 |
+
|
180 |
+
```python
|
181 |
+
list[str] | str | None
|
182 |
+
```
|
183 |
+
|
184 |
+
</td>
|
185 |
+
<td align="left"><code>None</code></td>
|
186 |
+
<td align="left">An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
|
187 |
+
</tr>
|
188 |
+
|
189 |
+
<tr>
|
190 |
+
<td align="left"><code>render</code></td>
|
191 |
+
<td align="left" style="width: 25%;">
|
192 |
+
|
193 |
+
```python
|
194 |
+
bool
|
195 |
+
```
|
196 |
+
|
197 |
+
</td>
|
198 |
+
<td align="left"><code>True</code></td>
|
199 |
+
<td align="left">If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.</td>
|
200 |
+
</tr>
|
201 |
+
|
202 |
+
<tr>
|
203 |
+
<td align="left"><code>columns</code></td>
|
204 |
+
<td align="left" style="width: 25%;">
|
205 |
+
|
206 |
+
```python
|
207 |
+
int | tuple | None
|
208 |
+
```
|
209 |
+
|
210 |
+
</td>
|
211 |
+
<td align="left"><code>2</code></td>
|
212 |
+
<td align="left">Represents the number of images that should be shown in one row, for each of the six standard screen sizes (<576px, <768px, <992px, <1200px, <1400px, >1400px). If fewer than 6 are given then the last will be used for all subsequent breakpoints</td>
|
213 |
+
</tr>
|
214 |
+
|
215 |
+
<tr>
|
216 |
+
<td align="left"><code>rows</code></td>
|
217 |
+
<td align="left" style="width: 25%;">
|
218 |
+
|
219 |
+
```python
|
220 |
+
int | tuple | None
|
221 |
+
```
|
222 |
+
|
223 |
+
</td>
|
224 |
+
<td align="left"><code>None</code></td>
|
225 |
+
<td align="left">Represents the number of rows in the image grid, for each of the six standard screen sizes (<576px, <768px, <992px, <1200px, <1400px, >1400px). If fewer than 6 are given then the last will be used for all subsequent breakpoints</td>
|
226 |
+
</tr>
|
227 |
+
|
228 |
+
<tr>
|
229 |
+
<td align="left"><code>height</code></td>
|
230 |
+
<td align="left" style="width: 25%;">
|
231 |
+
|
232 |
+
```python
|
233 |
+
int | float | None
|
234 |
+
```
|
235 |
+
|
236 |
+
</td>
|
237 |
+
<td align="left"><code>None</code></td>
|
238 |
+
<td align="left">The height of the gallery component, specified in pixels if a number is passed, or in CSS units if a string is passed. If more images are displayed than can fit in the height, a scrollbar will appear.</td>
|
239 |
+
</tr>
|
240 |
+
|
241 |
+
<tr>
|
242 |
+
<td align="left"><code>allow_preview</code></td>
|
243 |
+
<td align="left" style="width: 25%;">
|
244 |
+
|
245 |
+
```python
|
246 |
+
bool
|
247 |
+
```
|
248 |
+
|
249 |
+
</td>
|
250 |
+
<td align="left"><code>True</code></td>
|
251 |
+
<td align="left">If True, images in the gallery will be enlarged when they are clicked. Default is True.</td>
|
252 |
+
</tr>
|
253 |
+
|
254 |
+
<tr>
|
255 |
+
<td align="left"><code>preview</code></td>
|
256 |
+
<td align="left" style="width: 25%;">
|
257 |
+
|
258 |
+
```python
|
259 |
+
bool | None
|
260 |
+
```
|
261 |
+
|
262 |
+
</td>
|
263 |
+
<td align="left"><code>None</code></td>
|
264 |
+
<td align="left">If True, Carousel will start in preview mode, which shows all of the images as thumbnails and allows the user to click on them to view them in full size. Only works if allow_preview is True.</td>
|
265 |
+
</tr>
|
266 |
+
|
267 |
+
<tr>
|
268 |
+
<td align="left"><code>selected_index</code></td>
|
269 |
+
<td align="left" style="width: 25%;">
|
270 |
+
|
271 |
+
```python
|
272 |
+
int | None
|
273 |
+
```
|
274 |
+
|
275 |
+
</td>
|
276 |
+
<td align="left"><code>None</code></td>
|
277 |
+
<td align="left">The index of the image that should be initially selected. If None, no image will be selected at start. If provided, will set Carousel to preview mode unless allow_preview is set to False.</td>
|
278 |
+
</tr>
|
279 |
+
|
280 |
+
<tr>
|
281 |
+
<td align="left"><code>object_fit</code></td>
|
282 |
+
<td align="left" style="width: 25%;">
|
283 |
+
|
284 |
+
```python
|
285 |
+
"contain" | "cover" | "fill" | "none" | "scale-down" | None
|
286 |
+
```
|
287 |
+
|
288 |
+
</td>
|
289 |
+
<td align="left"><code>None</code></td>
|
290 |
+
<td align="left">CSS object-fit property for the thumbnail images in the gallery. Can be "contain", "cover", "fill", "none", or "scale-down".</td>
|
291 |
+
</tr>
|
292 |
+
|
293 |
+
<tr>
|
294 |
+
<td align="left"><code>show_share_button</code></td>
|
295 |
+
<td align="left" style="width: 25%;">
|
296 |
+
|
297 |
+
```python
|
298 |
+
bool | None
|
299 |
+
```
|
300 |
+
|
301 |
+
</td>
|
302 |
+
<td align="left"><code>None</code></td>
|
303 |
+
<td align="left">If True, will show a share icon in the corner of the component that allows user to share outputs to Hugging Face Spaces Discussions. If False, icon does not appear. If set to None (default behavior), then the icon appears if this Gradio app is launched on Spaces, but not otherwise.</td>
|
304 |
+
</tr>
|
305 |
+
|
306 |
+
<tr>
|
307 |
+
<td align="left"><code>show_download_button</code></td>
|
308 |
+
<td align="left" style="width: 25%;">
|
309 |
+
|
310 |
+
```python
|
311 |
+
bool | None
|
312 |
+
```
|
313 |
+
|
314 |
+
</td>
|
315 |
+
<td align="left"><code>True</code></td>
|
316 |
+
<td align="left">If True, will show a download button in the corner of the selected image. If False, the icon does not appear. Default is True.</td>
|
317 |
+
</tr>
|
318 |
+
|
319 |
+
<tr>
|
320 |
+
<td align="left"><code>interactive</code></td>
|
321 |
+
<td align="left" style="width: 25%;">
|
322 |
+
|
323 |
+
```python
|
324 |
+
bool | None
|
325 |
+
```
|
326 |
+
|
327 |
+
</td>
|
328 |
+
<td align="left"><code>None</code></td>
|
329 |
+
<td align="left">If True, the gallery will be interactive, allowing the user to upload images. If False, the gallery will be static. Default is True.</td>
|
330 |
+
</tr>
|
331 |
+
|
332 |
+
<tr>
|
333 |
+
<td align="left"><code>type</code></td>
|
334 |
+
<td align="left" style="width: 25%;">
|
335 |
+
|
336 |
+
```python
|
337 |
+
"numpy" | "pil" | "filepath"
|
338 |
+
```
|
339 |
+
|
340 |
+
</td>
|
341 |
+
<td align="left"><code>"filepath"</code></td>
|
342 |
+
<td align="left">The format the image is converted to before being passed into the prediction function. "numpy" converts the image to a numpy array with shape (height, width, 3) and values from 0 to 255, "pil" converts the image to a PIL image object, "filepath" passes a str path to a temporary file containing the image. If the image is SVG, the `type` is ignored and the filepath of the SVG is returned.</td>
|
343 |
+
</tr>
|
344 |
+
</tbody></table>
|
345 |
+
|
346 |
+
|
347 |
+
### Events
|
348 |
+
|
349 |
+
| name | description |
|
350 |
+
|:-----|:------------|
|
351 |
+
| `select` | Event listener for when the user selects or deselects the Carousel. Uses event data gradio.SelectData to carry `value` referring to the label of the Carousel, and `selected` to refer to state of the Carousel. See EventData documentation on how to use this event data |
|
352 |
+
| `upload` | This listener is triggered when the user uploads a file into the Carousel. |
|
353 |
+
| `change` | Triggered when the value of the Carousel changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input. |
|
354 |
+
|
355 |
+
|
356 |
+
|
357 |
+
### User function
|
358 |
+
|
359 |
+
The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
|
360 |
+
|
361 |
+
- When used as an Input, the component only impacts the input signature of the user function.
|
362 |
+
- When used as an output, the component only impacts the return signature of the user function.
|
363 |
+
|
364 |
+
The code snippet below is accurate in cases where the component is used as both an input and an output.
|
365 |
+
|
366 |
+
- **As input:** Should return, list of images, or list of (image, caption) tuples.
|
367 |
+
|
368 |
+
```python
|
369 |
+
def predict(
|
370 |
+
value: list[tuple[str, str | None]]
|
371 |
+
| list[tuple[PIL.Image.Image, str | None]]
|
372 |
+
| list[tuple[numpy.ndarray, str | None]]
|
373 |
+
| None
|
374 |
+
) -> list[
|
375 |
+
numpy.ndarray
|
376 |
+
| PIL.Image.Image
|
377 |
+
| pathlib.Path
|
378 |
+
| str
|
379 |
+
| tuple[
|
380 |
+
numpy.ndarray
|
381 |
+
| PIL.Image.Image
|
382 |
+
| pathlib.Path
|
383 |
+
| str,
|
384 |
+
str,
|
385 |
+
]
|
386 |
+
]
|
387 |
+
| None:
|
388 |
+
return value
|
389 |
+
```
|
390 |
+
|
src/backend/gradio_carousel/__init__.py
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
from .carousel import Carousel
|
3 |
+
|
4 |
+
__all__ = ['Carousel']
|
src/backend/gradio_carousel/carousel.py
ADDED
@@ -0,0 +1,215 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""gr.Gallery() component."""
|
2 |
+
|
3 |
+
from __future__ import annotations
|
4 |
+
|
5 |
+
from pathlib import Path
|
6 |
+
from typing import Any, Callable, List, Literal, Optional, Tuple, Union
|
7 |
+
from urllib.parse import urlparse
|
8 |
+
|
9 |
+
import numpy as np
|
10 |
+
from gradio_client.documentation import document, set_documentation_group
|
11 |
+
from gradio_client.utils import is_http_url_like
|
12 |
+
from PIL import Image as _Image # using _ to minimize namespace pollution
|
13 |
+
|
14 |
+
from gradio import processing_utils, utils
|
15 |
+
from gradio.components.base import Component
|
16 |
+
from gradio.data_classes import FileData, GradioModel, GradioRootModel
|
17 |
+
from gradio.events import Events
|
18 |
+
|
19 |
+
set_documentation_group("component")
|
20 |
+
|
21 |
+
|
22 |
+
GalleryImageType = Union[np.ndarray, _Image.Image, Path, str]
|
23 |
+
CaptionedGalleryImageType = Tuple[GalleryImageType, str]
|
24 |
+
|
25 |
+
|
26 |
+
class GalleryImage(GradioModel):
|
27 |
+
image: FileData
|
28 |
+
caption: Optional[str] = None
|
29 |
+
|
30 |
+
|
31 |
+
class GalleryData(GradioRootModel):
|
32 |
+
root: List[GalleryImage]
|
33 |
+
|
34 |
+
|
35 |
+
@document()
|
36 |
+
class Carousel(Component):
|
37 |
+
"""
|
38 |
+
Used to display a list of images as a gallery that can be scrolled through.
|
39 |
+
Preprocessing: A list of (image, caption) tuples. Each image is a filepath, numpy array or PIL.image depending on the `type` parameter. {List[tuple[str | PIL.Image | numpy.array, str | None]]}.
|
40 |
+
Postprocessing: expects a list of images in any format, {List[numpy.array | PIL.Image | str | pathlib.Path]}, or a {List} of (image, {str} caption) tuples and displays them.
|
41 |
+
|
42 |
+
Demos: fake_gan
|
43 |
+
"""
|
44 |
+
|
45 |
+
EVENTS = [Events.select, Events.upload, Events.change]
|
46 |
+
|
47 |
+
data_model = GalleryData
|
48 |
+
|
49 |
+
def __init__(
|
50 |
+
self,
|
51 |
+
value: list[np.ndarray | _Image.Image | str | Path | tuple]
|
52 |
+
| Callable
|
53 |
+
| None = None,
|
54 |
+
*,
|
55 |
+
label: str | None = None,
|
56 |
+
every: float | None = None,
|
57 |
+
show_label: bool | None = None,
|
58 |
+
container: bool = True,
|
59 |
+
scale: int | None = None,
|
60 |
+
min_width: int = 160,
|
61 |
+
visible: bool = True,
|
62 |
+
elem_id: str | None = None,
|
63 |
+
elem_classes: list[str] | str | None = None,
|
64 |
+
render: bool = True,
|
65 |
+
columns: int | tuple | None = 2,
|
66 |
+
rows: int | tuple | None = None,
|
67 |
+
height: int | float | None = None,
|
68 |
+
allow_preview: bool = True,
|
69 |
+
preview: bool | None = None,
|
70 |
+
selected_index: int | None = None,
|
71 |
+
object_fit: Literal["contain", "cover", "fill", "none", "scale-down"]
|
72 |
+
| None = None,
|
73 |
+
show_share_button: bool | None = None,
|
74 |
+
show_download_button: bool | None = True,
|
75 |
+
interactive: bool | None = None,
|
76 |
+
type: Literal["numpy", "pil", "filepath"] = "filepath",
|
77 |
+
):
|
78 |
+
"""
|
79 |
+
Parameters:
|
80 |
+
value: List of images to display in the gallery by default. If callable, the function will be called whenever the app loads to set the initial value of the component.
|
81 |
+
label: The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.
|
82 |
+
every: If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. Queue must be enabled. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.
|
83 |
+
show_label: if True, will display label.
|
84 |
+
container: If True, will place the component in a container - providing some extra padding around the border.
|
85 |
+
scale: relative width compared to adjacent Components in a Row. For example, if Component A has scale=2, and Component B has scale=1, A will be twice as wide as B. Should be an integer.
|
86 |
+
min_width: minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.
|
87 |
+
visible: If False, component will be hidden.
|
88 |
+
elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
|
89 |
+
elem_classes: An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.
|
90 |
+
render: If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.
|
91 |
+
columns: Represents the number of images that should be shown in one row, for each of the six standard screen sizes (<576px, <768px, <992px, <1200px, <1400px, >1400px). If fewer than 6 are given then the last will be used for all subsequent breakpoints
|
92 |
+
rows: Represents the number of rows in the image grid, for each of the six standard screen sizes (<576px, <768px, <992px, <1200px, <1400px, >1400px). If fewer than 6 are given then the last will be used for all subsequent breakpoints
|
93 |
+
height: The height of the gallery component, specified in pixels if a number is passed, or in CSS units if a string is passed. If more images are displayed than can fit in the height, a scrollbar will appear.
|
94 |
+
allow_preview: If True, images in the gallery will be enlarged when they are clicked. Default is True.
|
95 |
+
preview: If True, Carousel will start in preview mode, which shows all of the images as thumbnails and allows the user to click on them to view them in full size. Only works if allow_preview is True.
|
96 |
+
selected_index: The index of the image that should be initially selected. If None, no image will be selected at start. If provided, will set Carousel to preview mode unless allow_preview is set to False.
|
97 |
+
object_fit: CSS object-fit property for the thumbnail images in the gallery. Can be "contain", "cover", "fill", "none", or "scale-down".
|
98 |
+
show_share_button: If True, will show a share icon in the corner of the component that allows user to share outputs to Hugging Face Spaces Discussions. If False, icon does not appear. If set to None (default behavior), then the icon appears if this Gradio app is launched on Spaces, but not otherwise.
|
99 |
+
show_download_button: If True, will show a download button in the corner of the selected image. If False, the icon does not appear. Default is True.
|
100 |
+
interactive: If True, the gallery will be interactive, allowing the user to upload images. If False, the gallery will be static. Default is True.
|
101 |
+
type: The format the image is converted to before being passed into the prediction function. "numpy" converts the image to a numpy array with shape (height, width, 3) and values from 0 to 255, "pil" converts the image to a PIL image object, "filepath" passes a str path to a temporary file containing the image. If the image is SVG, the `type` is ignored and the filepath of the SVG is returned.
|
102 |
+
"""
|
103 |
+
self.columns = columns
|
104 |
+
self.rows = rows
|
105 |
+
self.height = height
|
106 |
+
self.preview = preview
|
107 |
+
self.object_fit = object_fit
|
108 |
+
self.allow_preview = allow_preview
|
109 |
+
self.show_download_button = (
|
110 |
+
(utils.get_space() is not None)
|
111 |
+
if show_download_button is None
|
112 |
+
else show_download_button
|
113 |
+
)
|
114 |
+
self.selected_index = selected_index
|
115 |
+
self.type = type
|
116 |
+
|
117 |
+
self.show_share_button = (
|
118 |
+
(utils.get_space() is not None)
|
119 |
+
if show_share_button is None
|
120 |
+
else show_share_button
|
121 |
+
)
|
122 |
+
super().__init__(
|
123 |
+
label=label,
|
124 |
+
every=every,
|
125 |
+
show_label=show_label,
|
126 |
+
container=container,
|
127 |
+
scale=scale,
|
128 |
+
min_width=min_width,
|
129 |
+
visible=visible,
|
130 |
+
elem_id=elem_id,
|
131 |
+
elem_classes=elem_classes,
|
132 |
+
render=render,
|
133 |
+
value=value,
|
134 |
+
interactive=interactive,
|
135 |
+
)
|
136 |
+
|
137 |
+
def postprocess(
|
138 |
+
self,
|
139 |
+
value: list[GalleryImageType | CaptionedGalleryImageType] | None,
|
140 |
+
) -> GalleryData:
|
141 |
+
"""
|
142 |
+
Parameters:
|
143 |
+
value: list of images, or list of (image, caption) tuples
|
144 |
+
Returns:
|
145 |
+
list of string file paths to images in temp directory
|
146 |
+
"""
|
147 |
+
if value is None:
|
148 |
+
return GalleryData(root=[])
|
149 |
+
output = []
|
150 |
+
for img in value:
|
151 |
+
url = None
|
152 |
+
caption = None
|
153 |
+
orig_name = None
|
154 |
+
if isinstance(img, (tuple, list)):
|
155 |
+
img, caption = img
|
156 |
+
if isinstance(img, np.ndarray):
|
157 |
+
file = processing_utils.save_img_array_to_cache(
|
158 |
+
img, cache_dir=self.GRADIO_CACHE
|
159 |
+
)
|
160 |
+
file_path = str(utils.abspath(file))
|
161 |
+
elif isinstance(img, _Image.Image):
|
162 |
+
file = processing_utils.save_pil_to_cache(
|
163 |
+
img, cache_dir=self.GRADIO_CACHE
|
164 |
+
)
|
165 |
+
file_path = str(utils.abspath(file))
|
166 |
+
elif isinstance(img, str):
|
167 |
+
file_path = img
|
168 |
+
if is_http_url_like(img):
|
169 |
+
url = img
|
170 |
+
orig_name = Path(urlparse(img).path).name
|
171 |
+
else:
|
172 |
+
url = None
|
173 |
+
orig_name = Path(img).name
|
174 |
+
elif isinstance(img, Path):
|
175 |
+
file_path = str(img)
|
176 |
+
orig_name = img.name
|
177 |
+
else:
|
178 |
+
raise ValueError(f"Cannot process type as image: {type(img)}")
|
179 |
+
entry = GalleryImage(
|
180 |
+
image=FileData(path=file_path, url=url, orig_name=orig_name),
|
181 |
+
caption=caption,
|
182 |
+
)
|
183 |
+
output.append(entry)
|
184 |
+
return GalleryData(root=output)
|
185 |
+
|
186 |
+
@staticmethod
|
187 |
+
def convert_to_type(img: str, type: Literal["filepath", "numpy", "pil"]):
|
188 |
+
if type == "filepath":
|
189 |
+
return img
|
190 |
+
else:
|
191 |
+
converted_image = _Image.open(img)
|
192 |
+
if type == "numpy":
|
193 |
+
converted_image = np.array(converted_image)
|
194 |
+
return converted_image
|
195 |
+
|
196 |
+
def preprocess(
|
197 |
+
self, payload: GalleryData | None
|
198 |
+
) -> (
|
199 |
+
List[tuple[str, str | None]]
|
200 |
+
| List[tuple[_Image.Image, str | None]]
|
201 |
+
| List[tuple[np.ndarray, str | None]]
|
202 |
+
| None
|
203 |
+
):
|
204 |
+
if payload is None or not payload.root:
|
205 |
+
return None
|
206 |
+
data = []
|
207 |
+
for gallery_element in payload.root:
|
208 |
+
image = self.convert_to_type(gallery_element.image.path, self.type) # type: ignore
|
209 |
+
data.append((image, gallery_element.caption))
|
210 |
+
return data
|
211 |
+
|
212 |
+
def example_inputs(self) -> Any:
|
213 |
+
return [
|
214 |
+
"https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png"
|
215 |
+
]
|
src/backend/gradio_carousel/carousel.pyi
ADDED
@@ -0,0 +1,343 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""gr.Gallery() component."""
|
2 |
+
|
3 |
+
from __future__ import annotations
|
4 |
+
|
5 |
+
from pathlib import Path
|
6 |
+
from typing import Any, Callable, List, Literal, Optional, Tuple, Union
|
7 |
+
from urllib.parse import urlparse
|
8 |
+
|
9 |
+
import numpy as np
|
10 |
+
from gradio_client.documentation import document, set_documentation_group
|
11 |
+
from gradio_client.utils import is_http_url_like
|
12 |
+
from PIL import Image as _Image # using _ to minimize namespace pollution
|
13 |
+
|
14 |
+
from gradio import processing_utils, utils
|
15 |
+
from gradio.components.base import Component
|
16 |
+
from gradio.data_classes import FileData, GradioModel, GradioRootModel
|
17 |
+
from gradio.events import Events
|
18 |
+
|
19 |
+
set_documentation_group("component")
|
20 |
+
|
21 |
+
|
22 |
+
GalleryImageType = Union[np.ndarray, _Image.Image, Path, str]
|
23 |
+
CaptionedGalleryImageType = Tuple[GalleryImageType, str]
|
24 |
+
|
25 |
+
|
26 |
+
class GalleryImage(GradioModel):
|
27 |
+
image: FileData
|
28 |
+
caption: Optional[str] = None
|
29 |
+
|
30 |
+
|
31 |
+
class GalleryData(GradioRootModel):
|
32 |
+
root: List[GalleryImage]
|
33 |
+
|
34 |
+
from gradio.events import Dependency
|
35 |
+
|
36 |
+
@document()
|
37 |
+
class Carousel(Component):
|
38 |
+
"""
|
39 |
+
Used to display a list of images as a gallery that can be scrolled through.
|
40 |
+
Preprocessing: A list of (image, caption) tuples. Each image is a filepath, numpy array or PIL.image depending on the `type` parameter. {List[tuple[str | PIL.Image | numpy.array, str | None]]}.
|
41 |
+
Postprocessing: expects a list of images in any format, {List[numpy.array | PIL.Image | str | pathlib.Path]}, or a {List} of (image, {str} caption) tuples and displays them.
|
42 |
+
|
43 |
+
Demos: fake_gan
|
44 |
+
"""
|
45 |
+
|
46 |
+
EVENTS = [Events.select, Events.upload, Events.change]
|
47 |
+
|
48 |
+
data_model = GalleryData
|
49 |
+
|
50 |
+
def __init__(
|
51 |
+
self,
|
52 |
+
value: list[np.ndarray | _Image.Image | str | Path | tuple]
|
53 |
+
| Callable
|
54 |
+
| None = None,
|
55 |
+
*,
|
56 |
+
label: str | None = None,
|
57 |
+
every: float | None = None,
|
58 |
+
show_label: bool | None = None,
|
59 |
+
container: bool = True,
|
60 |
+
scale: int | None = None,
|
61 |
+
min_width: int = 160,
|
62 |
+
visible: bool = True,
|
63 |
+
elem_id: str | None = None,
|
64 |
+
elem_classes: list[str] | str | None = None,
|
65 |
+
render: bool = True,
|
66 |
+
columns: int | tuple | None = 2,
|
67 |
+
rows: int | tuple | None = None,
|
68 |
+
height: int | float | None = None,
|
69 |
+
allow_preview: bool = True,
|
70 |
+
preview: bool | None = None,
|
71 |
+
selected_index: int | None = None,
|
72 |
+
object_fit: Literal["contain", "cover", "fill", "none", "scale-down"]
|
73 |
+
| None = None,
|
74 |
+
show_share_button: bool | None = None,
|
75 |
+
show_download_button: bool | None = True,
|
76 |
+
interactive: bool | None = None,
|
77 |
+
type: Literal["numpy", "pil", "filepath"] = "filepath",
|
78 |
+
):
|
79 |
+
"""
|
80 |
+
Parameters:
|
81 |
+
value: List of images to display in the gallery by default. If callable, the function will be called whenever the app loads to set the initial value of the component.
|
82 |
+
label: The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.
|
83 |
+
every: If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. Queue must be enabled. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.
|
84 |
+
show_label: if True, will display label.
|
85 |
+
container: If True, will place the component in a container - providing some extra padding around the border.
|
86 |
+
scale: relative width compared to adjacent Components in a Row. For example, if Component A has scale=2, and Component B has scale=1, A will be twice as wide as B. Should be an integer.
|
87 |
+
min_width: minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.
|
88 |
+
visible: If False, component will be hidden.
|
89 |
+
elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
|
90 |
+
elem_classes: An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.
|
91 |
+
render: If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.
|
92 |
+
columns: Represents the number of images that should be shown in one row, for each of the six standard screen sizes (<576px, <768px, <992px, <1200px, <1400px, >1400px). If fewer than 6 are given then the last will be used for all subsequent breakpoints
|
93 |
+
rows: Represents the number of rows in the image grid, for each of the six standard screen sizes (<576px, <768px, <992px, <1200px, <1400px, >1400px). If fewer than 6 are given then the last will be used for all subsequent breakpoints
|
94 |
+
height: The height of the gallery component, specified in pixels if a number is passed, or in CSS units if a string is passed. If more images are displayed than can fit in the height, a scrollbar will appear.
|
95 |
+
allow_preview: If True, images in the gallery will be enlarged when they are clicked. Default is True.
|
96 |
+
preview: If True, Carousel will start in preview mode, which shows all of the images as thumbnails and allows the user to click on them to view them in full size. Only works if allow_preview is True.
|
97 |
+
selected_index: The index of the image that should be initially selected. If None, no image will be selected at start. If provided, will set Carousel to preview mode unless allow_preview is set to False.
|
98 |
+
object_fit: CSS object-fit property for the thumbnail images in the gallery. Can be "contain", "cover", "fill", "none", or "scale-down".
|
99 |
+
show_share_button: If True, will show a share icon in the corner of the component that allows user to share outputs to Hugging Face Spaces Discussions. If False, icon does not appear. If set to None (default behavior), then the icon appears if this Gradio app is launched on Spaces, but not otherwise.
|
100 |
+
show_download_button: If True, will show a download button in the corner of the selected image. If False, the icon does not appear. Default is True.
|
101 |
+
interactive: If True, the gallery will be interactive, allowing the user to upload images. If False, the gallery will be static. Default is True.
|
102 |
+
type: The format the image is converted to before being passed into the prediction function. "numpy" converts the image to a numpy array with shape (height, width, 3) and values from 0 to 255, "pil" converts the image to a PIL image object, "filepath" passes a str path to a temporary file containing the image. If the image is SVG, the `type` is ignored and the filepath of the SVG is returned.
|
103 |
+
"""
|
104 |
+
self.columns = columns
|
105 |
+
self.rows = rows
|
106 |
+
self.height = height
|
107 |
+
self.preview = preview
|
108 |
+
self.object_fit = object_fit
|
109 |
+
self.allow_preview = allow_preview
|
110 |
+
self.show_download_button = (
|
111 |
+
(utils.get_space() is not None)
|
112 |
+
if show_download_button is None
|
113 |
+
else show_download_button
|
114 |
+
)
|
115 |
+
self.selected_index = selected_index
|
116 |
+
self.type = type
|
117 |
+
|
118 |
+
self.show_share_button = (
|
119 |
+
(utils.get_space() is not None)
|
120 |
+
if show_share_button is None
|
121 |
+
else show_share_button
|
122 |
+
)
|
123 |
+
super().__init__(
|
124 |
+
label=label,
|
125 |
+
every=every,
|
126 |
+
show_label=show_label,
|
127 |
+
container=container,
|
128 |
+
scale=scale,
|
129 |
+
min_width=min_width,
|
130 |
+
visible=visible,
|
131 |
+
elem_id=elem_id,
|
132 |
+
elem_classes=elem_classes,
|
133 |
+
render=render,
|
134 |
+
value=value,
|
135 |
+
interactive=interactive,
|
136 |
+
)
|
137 |
+
|
138 |
+
def postprocess(
|
139 |
+
self,
|
140 |
+
value: list[GalleryImageType | CaptionedGalleryImageType] | None,
|
141 |
+
) -> GalleryData:
|
142 |
+
"""
|
143 |
+
Parameters:
|
144 |
+
value: list of images, or list of (image, caption) tuples
|
145 |
+
Returns:
|
146 |
+
list of string file paths to images in temp directory
|
147 |
+
"""
|
148 |
+
if value is None:
|
149 |
+
return GalleryData(root=[])
|
150 |
+
output = []
|
151 |
+
for img in value:
|
152 |
+
url = None
|
153 |
+
caption = None
|
154 |
+
orig_name = None
|
155 |
+
if isinstance(img, (tuple, list)):
|
156 |
+
img, caption = img
|
157 |
+
if isinstance(img, np.ndarray):
|
158 |
+
file = processing_utils.save_img_array_to_cache(
|
159 |
+
img, cache_dir=self.GRADIO_CACHE
|
160 |
+
)
|
161 |
+
file_path = str(utils.abspath(file))
|
162 |
+
elif isinstance(img, _Image.Image):
|
163 |
+
file = processing_utils.save_pil_to_cache(
|
164 |
+
img, cache_dir=self.GRADIO_CACHE
|
165 |
+
)
|
166 |
+
file_path = str(utils.abspath(file))
|
167 |
+
elif isinstance(img, str):
|
168 |
+
file_path = img
|
169 |
+
if is_http_url_like(img):
|
170 |
+
url = img
|
171 |
+
orig_name = Path(urlparse(img).path).name
|
172 |
+
else:
|
173 |
+
url = None
|
174 |
+
orig_name = Path(img).name
|
175 |
+
elif isinstance(img, Path):
|
176 |
+
file_path = str(img)
|
177 |
+
orig_name = img.name
|
178 |
+
else:
|
179 |
+
raise ValueError(f"Cannot process type as image: {type(img)}")
|
180 |
+
entry = GalleryImage(
|
181 |
+
image=FileData(path=file_path, url=url, orig_name=orig_name),
|
182 |
+
caption=caption,
|
183 |
+
)
|
184 |
+
output.append(entry)
|
185 |
+
return GalleryData(root=output)
|
186 |
+
|
187 |
+
@staticmethod
|
188 |
+
def convert_to_type(img: str, type: Literal["filepath", "numpy", "pil"]):
|
189 |
+
if type == "filepath":
|
190 |
+
return img
|
191 |
+
else:
|
192 |
+
converted_image = _Image.open(img)
|
193 |
+
if type == "numpy":
|
194 |
+
converted_image = np.array(converted_image)
|
195 |
+
return converted_image
|
196 |
+
|
197 |
+
def preprocess(
|
198 |
+
self, payload: GalleryData | None
|
199 |
+
) -> (
|
200 |
+
List[tuple[str, str | None]]
|
201 |
+
| List[tuple[_Image.Image, str | None]]
|
202 |
+
| List[tuple[np.ndarray, str | None]]
|
203 |
+
| None
|
204 |
+
):
|
205 |
+
if payload is None or not payload.root:
|
206 |
+
return None
|
207 |
+
data = []
|
208 |
+
for gallery_element in payload.root:
|
209 |
+
image = self.convert_to_type(gallery_element.image.path, self.type) # type: ignore
|
210 |
+
data.append((image, gallery_element.caption))
|
211 |
+
return data
|
212 |
+
|
213 |
+
def example_inputs(self) -> Any:
|
214 |
+
return [
|
215 |
+
"https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png"
|
216 |
+
]
|
217 |
+
|
218 |
+
|
219 |
+
def select(self,
|
220 |
+
fn: Callable | None,
|
221 |
+
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
222 |
+
outputs: Component | Sequence[Component] | None = None,
|
223 |
+
api_name: str | None | Literal[False] = None,
|
224 |
+
scroll_to_output: bool = False,
|
225 |
+
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
226 |
+
queue: bool | None = None,
|
227 |
+
batch: bool = False,
|
228 |
+
max_batch_size: int = 4,
|
229 |
+
preprocess: bool = True,
|
230 |
+
postprocess: bool = True,
|
231 |
+
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
232 |
+
every: float | None = None,
|
233 |
+
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
234 |
+
js: str | None = None,
|
235 |
+
concurrency_limit: int | None | Literal["default"] = "default",
|
236 |
+
concurrency_id: str | None = None,
|
237 |
+
show_api: bool = True) -> Dependency:
|
238 |
+
"""
|
239 |
+
Parameters:
|
240 |
+
fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
|
241 |
+
inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
|
242 |
+
outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
|
243 |
+
api_name: Defines how the endpoint appears in the API docs. Can be a string, None, or False. If False, the endpoint will not be exposed in the api docs. If set to None, the endpoint will be exposed in the api docs as an unnamed endpoint, although this behavior will be changed in Gradio 4.0. If set to a string, the endpoint will be exposed in the api docs with the given name.
|
244 |
+
scroll_to_output: If True, will scroll to output component on completion
|
245 |
+
show_progress: If True, will show progress animation while pending
|
246 |
+
queue: If True, will place the request on the queue, if the queue has been enabled. If False, will not put this event on the queue, even if the queue has been enabled. If None, will use the queue setting of the gradio app.
|
247 |
+
batch: If True, then the function should process a batch of inputs, meaning that it should accept a list of input values for each parameter. The lists should be of equal length (and be up to length `max_batch_size`). The function is then *required* to return a tuple of lists (even if there is only 1 output component), with each list in the tuple corresponding to one output component.
|
248 |
+
max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
|
249 |
+
preprocess: If False, will not run preprocessing of component data before running 'fn' (e.g. leaving it as a base64 string if this method is called with the `Image` component).
|
250 |
+
postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
|
251 |
+
cancels: A list of other events to cancel when this listener is triggered. For example, setting cancels=[click_event] will cancel the click_event, where click_event is the return value of another components .click method. Functions that have not yet run (or generators that are iterating) will be cancelled, but functions that are currently running will be allowed to finish.
|
252 |
+
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
253 |
+
trigger_mode: If "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` event) would allow a second submission after the pending event is complete.
|
254 |
+
js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
|
255 |
+
concurrency_limit: If set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit (any number of this event can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `Blocks.queue()`, which itself is 1 by default).
|
256 |
+
concurrency_id: If set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
|
257 |
+
show_api: whether to show this event in the "view API" page of the Gradio app, or in the ".view_api()" method of the Gradio clients. Unlike setting api_name to False, setting show_api to False will still allow downstream apps to use this event. If fn is None, show_api will automatically be set to False.
|
258 |
+
"""
|
259 |
+
...
|
260 |
+
|
261 |
+
def upload(self,
|
262 |
+
fn: Callable | None,
|
263 |
+
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
264 |
+
outputs: Component | Sequence[Component] | None = None,
|
265 |
+
api_name: str | None | Literal[False] = None,
|
266 |
+
scroll_to_output: bool = False,
|
267 |
+
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
268 |
+
queue: bool | None = None,
|
269 |
+
batch: bool = False,
|
270 |
+
max_batch_size: int = 4,
|
271 |
+
preprocess: bool = True,
|
272 |
+
postprocess: bool = True,
|
273 |
+
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
274 |
+
every: float | None = None,
|
275 |
+
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
276 |
+
js: str | None = None,
|
277 |
+
concurrency_limit: int | None | Literal["default"] = "default",
|
278 |
+
concurrency_id: str | None = None,
|
279 |
+
show_api: bool = True) -> Dependency:
|
280 |
+
"""
|
281 |
+
Parameters:
|
282 |
+
fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
|
283 |
+
inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
|
284 |
+
outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
|
285 |
+
api_name: Defines how the endpoint appears in the API docs. Can be a string, None, or False. If False, the endpoint will not be exposed in the api docs. If set to None, the endpoint will be exposed in the api docs as an unnamed endpoint, although this behavior will be changed in Gradio 4.0. If set to a string, the endpoint will be exposed in the api docs with the given name.
|
286 |
+
scroll_to_output: If True, will scroll to output component on completion
|
287 |
+
show_progress: If True, will show progress animation while pending
|
288 |
+
queue: If True, will place the request on the queue, if the queue has been enabled. If False, will not put this event on the queue, even if the queue has been enabled. If None, will use the queue setting of the gradio app.
|
289 |
+
batch: If True, then the function should process a batch of inputs, meaning that it should accept a list of input values for each parameter. The lists should be of equal length (and be up to length `max_batch_size`). The function is then *required* to return a tuple of lists (even if there is only 1 output component), with each list in the tuple corresponding to one output component.
|
290 |
+
max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
|
291 |
+
preprocess: If False, will not run preprocessing of component data before running 'fn' (e.g. leaving it as a base64 string if this method is called with the `Image` component).
|
292 |
+
postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
|
293 |
+
cancels: A list of other events to cancel when this listener is triggered. For example, setting cancels=[click_event] will cancel the click_event, where click_event is the return value of another components .click method. Functions that have not yet run (or generators that are iterating) will be cancelled, but functions that are currently running will be allowed to finish.
|
294 |
+
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
295 |
+
trigger_mode: If "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` event) would allow a second submission after the pending event is complete.
|
296 |
+
js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
|
297 |
+
concurrency_limit: If set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit (any number of this event can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `Blocks.queue()`, which itself is 1 by default).
|
298 |
+
concurrency_id: If set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
|
299 |
+
show_api: whether to show this event in the "view API" page of the Gradio app, or in the ".view_api()" method of the Gradio clients. Unlike setting api_name to False, setting show_api to False will still allow downstream apps to use this event. If fn is None, show_api will automatically be set to False.
|
300 |
+
"""
|
301 |
+
...
|
302 |
+
|
303 |
+
def change(self,
|
304 |
+
fn: Callable | None,
|
305 |
+
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
306 |
+
outputs: Component | Sequence[Component] | None = None,
|
307 |
+
api_name: str | None | Literal[False] = None,
|
308 |
+
scroll_to_output: bool = False,
|
309 |
+
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
310 |
+
queue: bool | None = None,
|
311 |
+
batch: bool = False,
|
312 |
+
max_batch_size: int = 4,
|
313 |
+
preprocess: bool = True,
|
314 |
+
postprocess: bool = True,
|
315 |
+
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
316 |
+
every: float | None = None,
|
317 |
+
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
318 |
+
js: str | None = None,
|
319 |
+
concurrency_limit: int | None | Literal["default"] = "default",
|
320 |
+
concurrency_id: str | None = None,
|
321 |
+
show_api: bool = True) -> Dependency:
|
322 |
+
"""
|
323 |
+
Parameters:
|
324 |
+
fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
|
325 |
+
inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
|
326 |
+
outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
|
327 |
+
api_name: Defines how the endpoint appears in the API docs. Can be a string, None, or False. If False, the endpoint will not be exposed in the api docs. If set to None, the endpoint will be exposed in the api docs as an unnamed endpoint, although this behavior will be changed in Gradio 4.0. If set to a string, the endpoint will be exposed in the api docs with the given name.
|
328 |
+
scroll_to_output: If True, will scroll to output component on completion
|
329 |
+
show_progress: If True, will show progress animation while pending
|
330 |
+
queue: If True, will place the request on the queue, if the queue has been enabled. If False, will not put this event on the queue, even if the queue has been enabled. If None, will use the queue setting of the gradio app.
|
331 |
+
batch: If True, then the function should process a batch of inputs, meaning that it should accept a list of input values for each parameter. The lists should be of equal length (and be up to length `max_batch_size`). The function is then *required* to return a tuple of lists (even if there is only 1 output component), with each list in the tuple corresponding to one output component.
|
332 |
+
max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
|
333 |
+
preprocess: If False, will not run preprocessing of component data before running 'fn' (e.g. leaving it as a base64 string if this method is called with the `Image` component).
|
334 |
+
postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
|
335 |
+
cancels: A list of other events to cancel when this listener is triggered. For example, setting cancels=[click_event] will cancel the click_event, where click_event is the return value of another components .click method. Functions that have not yet run (or generators that are iterating) will be cancelled, but functions that are currently running will be allowed to finish.
|
336 |
+
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
337 |
+
trigger_mode: If "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` event) would allow a second submission after the pending event is complete.
|
338 |
+
js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
|
339 |
+
concurrency_limit: If set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit (any number of this event can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `Blocks.queue()`, which itself is 1 by default).
|
340 |
+
concurrency_id: If set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
|
341 |
+
show_api: whether to show this event in the "view API" page of the Gradio app, or in the ".view_api()" method of the Gradio clients. Unlike setting api_name to False, setting show_api to False will still allow downstream apps to use this event. If fn is None, show_api will automatically be set to False.
|
342 |
+
"""
|
343 |
+
...
|
src/backend/gradio_carousel/templates/component/__vite-browser-external-2447137e.js
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const e = {};
|
2 |
+
export {
|
3 |
+
e as default
|
4 |
+
};
|
src/backend/gradio_carousel/templates/component/index.js
ADDED
The diff for this file is too large to render.
See raw diff
|
|
src/backend/gradio_carousel/templates/component/style.css
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
.block.svelte-1t38q2d{position:relative;margin:0;box-shadow:var(--block-shadow);border-width:var(--block-border-width);border-color:var(--block-border-color);border-radius:var(--block-radius);background:var(--block-background-fill);width:100%;line-height:var(--line-sm)}.block.border_focus.svelte-1t38q2d{border-color:var(--color-accent)}.padded.svelte-1t38q2d{padding:var(--block-padding)}.hidden.svelte-1t38q2d{display:none}.hide-container.svelte-1t38q2d{margin:0;box-shadow:none;--block-border-width:0;background:transparent;padding:0;overflow:visible}div.svelte-1hnfib2{margin-bottom:var(--spacing-lg);color:var(--block-info-text-color);font-weight:var(--block-info-text-weight);font-size:var(--block-info-text-size);line-height:var(--line-sm)}span.has-info.svelte-22c38v{margin-bottom:var(--spacing-xs)}span.svelte-22c38v:not(.has-info){margin-bottom:var(--spacing-lg)}span.svelte-22c38v{display:inline-block;position:relative;z-index:var(--layer-4);border:solid var(--block-title-border-width) var(--block-title-border-color);border-radius:var(--block-title-radius);background:var(--block-title-background-fill);padding:var(--block-title-padding);color:var(--block-title-text-color);font-weight:var(--block-title-text-weight);font-size:var(--block-title-text-size);line-height:var(--line-sm)}.hide.svelte-22c38v{margin:0;height:0}label.svelte-9gxdi0{display:inline-flex;align-items:center;z-index:var(--layer-2);box-shadow:var(--block-label-shadow);border:var(--block-label-border-width) solid var(--border-color-primary);border-top:none;border-left:none;border-radius:var(--block-label-radius);background:var(--block-label-background-fill);padding:var(--block-label-padding);pointer-events:none;color:var(--block-label-text-color);font-weight:var(--block-label-text-weight);font-size:var(--block-label-text-size);line-height:var(--line-sm)}.gr-group label.svelte-9gxdi0{border-top-left-radius:0}label.float.svelte-9gxdi0{position:absolute;top:var(--block-label-margin);left:var(--block-label-margin)}label.svelte-9gxdi0:not(.float){position:static;margin-top:var(--block-label-margin);margin-left:var(--block-label-margin)}.hide.svelte-9gxdi0{height:0}span.svelte-9gxdi0{opacity:.8;margin-right:var(--size-2);width:calc(var(--block-label-text-size) - 1px);height:calc(var(--block-label-text-size) - 1px)}.hide-label.svelte-9gxdi0{box-shadow:none;border-width:0;background:transparent;overflow:visible}button.svelte-lpi64a{display:flex;justify-content:center;align-items:center;gap:1px;z-index:var(--layer-2);border-radius:var(--radius-sm);color:var(--block-label-text-color);border:1px solid transparent}button[disabled].svelte-lpi64a{opacity:.5;box-shadow:none}button[disabled].svelte-lpi64a:hover{cursor:not-allowed}.padded.svelte-lpi64a{padding:2px;background:var(--bg-color);box-shadow:var(--shadow-drop);border:1px solid var(--button-secondary-border-color)}button.svelte-lpi64a:hover,button.highlight.svelte-lpi64a{cursor:pointer;color:var(--color-accent)}.padded.svelte-lpi64a:hover{border:2px solid var(--button-secondary-border-color-hover);padding:1px;color:var(--block-label-text-color)}span.svelte-lpi64a{padding:0 1px;font-size:10px}div.svelte-lpi64a{padding:2px;display:flex;align-items:flex-end}.small.svelte-lpi64a{width:14px;height:14px}.large.svelte-lpi64a{width:22px;height:22px}.pending.svelte-lpi64a{animation:svelte-lpi64a-flash .5s infinite}@keyframes svelte-lpi64a-flash{0%{opacity:.5}50%{opacity:1}to{opacity:.5}}.transparent.svelte-lpi64a{background:transparent;border:none;box-shadow:none}.empty.svelte-3w3rth{display:flex;justify-content:center;align-items:center;margin-top:calc(0px - var(--size-6));height:var(--size-full)}.icon.svelte-3w3rth{opacity:.5;height:var(--size-5);color:var(--body-text-color)}.small.svelte-3w3rth{min-height:calc(var(--size-32) - 20px)}.large.svelte-3w3rth{min-height:calc(var(--size-64) - 20px)}.unpadded_box.svelte-3w3rth{margin-top:0}.small_parent.svelte-3w3rth{min-height:100%!important}.dropdown-arrow.svelte-145leq6{fill:currentColor}.wrap.svelte-kzcjhc{display:flex;flex-direction:column;justify-content:center;align-items:center;min-height:var(--size-60);color:var(--block-label-text-color);line-height:var(--line-md);height:100%;padding-top:var(--size-3)}.or.svelte-kzcjhc{color:var(--body-text-color-subdued);display:flex}.icon-wrap.svelte-kzcjhc{width:30px;margin-bottom:var(--spacing-lg)}@media (--screen-md){.wrap.svelte-kzcjhc{font-size:var(--text-lg)}}.hovered.svelte-kzcjhc{color:var(--color-accent)}div.svelte-ipfyu7{border-top:1px solid transparent;display:flex;max-height:100%;justify-content:center;gap:var(--spacing-sm);height:auto;align-items:flex-end;padding-bottom:var(--spacing-xl);color:var(--block-label-text-color);flex-shrink:0;width:95%}.show_border.svelte-ipfyu7{border-top:1px solid var(--block-border-color);margin-top:var(--spacing-xxl);box-shadow:var(--shadow-drop)}.source-selection.svelte-1jp3vgd{display:flex;align-items:center;justify-content:center;border-top:1px solid var(--border-color-primary);width:95%;bottom:0;left:0;right:0;margin-left:auto;margin-right:auto}.icon.svelte-1jp3vgd{width:22px;height:22px;margin:var(--spacing-lg) var(--spacing-xs);padding:var(--spacing-xs);color:var(--neutral-400);border-radius:var(--radius-md)}.selected.svelte-1jp3vgd{color:var(--color-accent)}.icon.svelte-1jp3vgd:hover,.icon.svelte-1jp3vgd:focus{color:var(--color-accent)}.wrap.svelte-12ckl9l.svelte-12ckl9l{overflow-y:auto;transition:opacity .5s ease-in-out;background:var(--block-background-fill);position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:var(--size-40)}.wrap.svelte-12ckl9l.svelte-12ckl9l:after{content:"";position:absolute;top:0;left:0;width:var(--upload-progress-width);height:100%;transition:all .5s ease-in-out;z-index:1}.uploading.svelte-12ckl9l.svelte-12ckl9l{font-size:var(--text-lg);font-family:var(--font);z-index:2}.file-name.svelte-12ckl9l.svelte-12ckl9l{margin:var(--spacing-md);font-size:var(--text-lg);color:var(--body-text-color-subdued)}.file.svelte-12ckl9l.svelte-12ckl9l{font-size:var(--text-md);z-index:2;display:flex;align-items:center}.file.svelte-12ckl9l progress.svelte-12ckl9l{display:inline;height:var(--size-1);width:100%;transition:all .5s ease-in-out;color:var(--color-accent);border:none}.file.svelte-12ckl9l progress[value].svelte-12ckl9l::-webkit-progress-value{background-color:var(--color-accent);border-radius:20px}.file.svelte-12ckl9l progress[value].svelte-12ckl9l::-webkit-progress-bar{background-color:var(--border-color-accent);border-radius:20px}.progress-bar.svelte-12ckl9l.svelte-12ckl9l{width:14px;height:14px;border-radius:50%;background:radial-gradient(closest-side,var(--block-background-fill) 64%,transparent 53% 100%),conic-gradient(var(--color-accent) var(--upload-progress-width),var(--border-color-accent) 0);transition:all .5s ease-in-out}button.svelte-1aq8tno{cursor:pointer;width:var(--size-full)}.hidden.svelte-1aq8tno{display:none;height:0!important;position:absolute;width:0;flex-grow:0}.center.svelte-1aq8tno{display:flex;justify-content:center}.flex.svelte-1aq8tno{display:flex;justify-content:center;align-items:center}input.svelte-1aq8tno{display:none}div.svelte-1wj0ocy{display:flex;top:var(--size-2);right:var(--size-2);justify-content:flex-end;gap:var(--spacing-sm);z-index:var(--layer-1)}.not-absolute.svelte-1wj0ocy{margin:var(--size-1)}.preview.svelte-a675k2.svelte-a675k2{display:flex;position:absolute;top:0;right:0;bottom:0;left:0;flex-direction:column;z-index:var(--layer-2);-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);background:var(--background-fill-primary);height:var(--size-full)}.image-button.svelte-a675k2.svelte-a675k2{height:calc(100% - 60px);width:100%;display:flex}.image-button.svelte-a675k2 img{width:var(--size-full);height:var(--size-full);object-fit:contain}.thumbnails.svelte-a675k2 img{object-fit:cover;width:var(--size-full);height:var(--size-full)}.preview.svelte-a675k2 img.with-caption{height:var(--size-full)}.caption.svelte-a675k2.svelte-a675k2{padding:var(--size-2) var(--size-3);overflow:hidden;color:var(--block-label-text-color);font-weight:var(--weight-semibold);text-align:center;text-overflow:ellipsis;white-space:nowrap;align-self:center}.thumbnails.svelte-a675k2.svelte-a675k2{display:flex;position:absolute;bottom:0;justify-content:center;align-items:center;gap:var(--spacing-lg);width:var(--size-full);height:var(--size-14);overflow-x:scroll}.thumbnail-item.svelte-a675k2.svelte-a675k2{--ring-color:transparent;position:relative;box-shadow:0 0 0 2px var(--ring-color),var(--shadow-drop);border:1px solid var(--border-color-primary);border-radius:var(--button-small-radius);background:var(--background-fill-secondary);aspect-ratio:var(--ratio-square);width:var(--size-full);height:var(--size-full);overflow:clip}.thumbnail-item.svelte-a675k2.svelte-a675k2:hover{--ring-color:var(--color-accent);filter:brightness(1.1)}.thumbnail-item.selected.svelte-a675k2.svelte-a675k2{--ring-color:var(--color-accent)}.thumbnail-small.svelte-a675k2.svelte-a675k2{flex:none;transform:scale(.9);transition:75ms;width:var(--size-9);height:var(--size-9)}.thumbnail-small.selected.svelte-a675k2.svelte-a675k2{--ring-color:var(--color-accent);transform:scale(1);border-color:var(--color-accent)}.caption-label.svelte-a675k2.svelte-a675k2{position:absolute;right:var(--block-label-margin);bottom:var(--block-label-margin);z-index:var(--layer-1);border-top:1px solid var(--border-color-primary);border-left:1px solid var(--border-color-primary);border-radius:var(--block-label-radius);background:var(--background-fill-secondary);padding:var(--block-label-padding);max-width:80%;overflow:hidden;font-size:var(--block-label-text-size);text-align:left;text-overflow:ellipsis;white-space:nowrap}.icon-button.svelte-a675k2.svelte-a675k2{position:absolute;top:0;right:0;z-index:var(--layer-1)}.icon-buttons.svelte-a675k2.svelte-a675k2{display:flex;position:absolute;right:0}.icon-buttons.svelte-a675k2 .download-button-container.svelte-a675k2{margin:var(--size-1) 0}.embla.svelte-a675k2.svelte-a675k2{--slide-spacing:1rem;--slide-size:50%;--slide-height:19rem;padding:1.6rem}.embla__viewport.svelte-a675k2.svelte-a675k2{overflow:hidden}.embla__container.svelte-a675k2.svelte-a675k2{backface-visibility:hidden;display:flex;touch-action:pan-y;margin-left:calc(var(--slide-spacing) * -1)}.embla__slide.svelte-a675k2.svelte-a675k2{flex:0 0 var(--slide-size);min-width:0;padding-left:var(--slide-spacing);position:relative}.embla__slide__img.svelte-a675k2.svelte-a675k2{display:block;height:var(--slide-height);width:100%;object-fit:cover}svg.svelte-43sxxs.svelte-43sxxs{width:var(--size-20);height:var(--size-20)}svg.svelte-43sxxs path.svelte-43sxxs{fill:var(--loader-color)}div.svelte-43sxxs.svelte-43sxxs{z-index:var(--layer-2)}.margin.svelte-43sxxs.svelte-43sxxs{margin:var(--size-4)}.wrap.svelte-1txqlrd.svelte-1txqlrd{display:flex;flex-direction:column;justify-content:center;align-items:center;z-index:var(--layer-top);transition:opacity .1s ease-in-out;border-radius:var(--block-radius);background:var(--block-background-fill);padding:0 var(--size-6);max-height:var(--size-screen-h);overflow:hidden;pointer-events:none}.wrap.center.svelte-1txqlrd.svelte-1txqlrd{top:0;right:0;left:0}.wrap.default.svelte-1txqlrd.svelte-1txqlrd{top:0;right:0;bottom:0;left:0}.hide.svelte-1txqlrd.svelte-1txqlrd{opacity:0;pointer-events:none}.generating.svelte-1txqlrd.svelte-1txqlrd{animation:svelte-1txqlrd-pulse 2s cubic-bezier(.4,0,.6,1) infinite;border:2px solid var(--color-accent);background:transparent}.translucent.svelte-1txqlrd.svelte-1txqlrd{background:none}@keyframes svelte-1txqlrd-pulse{0%,to{opacity:1}50%{opacity:.5}}.loading.svelte-1txqlrd.svelte-1txqlrd{z-index:var(--layer-2);color:var(--body-text-color)}.eta-bar.svelte-1txqlrd.svelte-1txqlrd{position:absolute;top:0;right:0;bottom:0;left:0;transform-origin:left;opacity:.8;z-index:var(--layer-1);transition:10ms;background:var(--background-fill-secondary)}.progress-bar-wrap.svelte-1txqlrd.svelte-1txqlrd{border:1px solid var(--border-color-primary);background:var(--background-fill-primary);width:55.5%;height:var(--size-4)}.progress-bar.svelte-1txqlrd.svelte-1txqlrd{transform-origin:left;background-color:var(--loader-color);width:var(--size-full);height:var(--size-full)}.progress-level.svelte-1txqlrd.svelte-1txqlrd{display:flex;flex-direction:column;align-items:center;gap:1;z-index:var(--layer-2);width:var(--size-full)}.progress-level-inner.svelte-1txqlrd.svelte-1txqlrd{margin:var(--size-2) auto;color:var(--body-text-color);font-size:var(--text-sm);font-family:var(--font-mono)}.meta-text.svelte-1txqlrd.svelte-1txqlrd{position:absolute;top:0;right:0;z-index:var(--layer-2);padding:var(--size-1) var(--size-2);font-size:var(--text-sm);font-family:var(--font-mono)}.meta-text-center.svelte-1txqlrd.svelte-1txqlrd{display:flex;position:absolute;top:0;right:0;justify-content:center;align-items:center;transform:translateY(var(--size-6));z-index:var(--layer-2);padding:var(--size-1) var(--size-2);font-size:var(--text-sm);font-family:var(--font-mono);text-align:center}.error.svelte-1txqlrd.svelte-1txqlrd{box-shadow:var(--shadow-drop);border:solid 1px var(--error-border-color);border-radius:var(--radius-full);background:var(--error-background-fill);padding-right:var(--size-4);padding-left:var(--size-4);color:var(--error-text-color);font-weight:var(--weight-semibold);font-size:var(--text-lg);line-height:var(--line-lg);font-family:var(--font)}.minimal.svelte-1txqlrd .progress-text.svelte-1txqlrd{background:var(--block-background-fill)}.border.svelte-1txqlrd.svelte-1txqlrd{border:1px solid var(--border-color-primary)}.toast-body.svelte-solcu7{display:flex;position:relative;right:0;left:0;align-items:center;margin:var(--size-6) var(--size-4);margin:auto;border-radius:var(--container-radius);overflow:hidden;pointer-events:auto}.toast-body.error.svelte-solcu7{border:1px solid var(--color-red-700);background:var(--color-red-50)}.dark .toast-body.error.svelte-solcu7{border:1px solid var(--color-red-500);background-color:var(--color-grey-950)}.toast-body.warning.svelte-solcu7{border:1px solid var(--color-yellow-700);background:var(--color-yellow-50)}.dark .toast-body.warning.svelte-solcu7{border:1px solid var(--color-yellow-500);background-color:var(--color-grey-950)}.toast-body.info.svelte-solcu7{border:1px solid var(--color-grey-700);background:var(--color-grey-50)}.dark .toast-body.info.svelte-solcu7{border:1px solid var(--color-grey-500);background-color:var(--color-grey-950)}.toast-title.svelte-solcu7{display:flex;align-items:center;font-weight:var(--weight-bold);font-size:var(--text-lg);line-height:var(--line-sm);text-transform:capitalize}.toast-title.error.svelte-solcu7{color:var(--color-red-700)}.dark .toast-title.error.svelte-solcu7{color:var(--color-red-50)}.toast-title.warning.svelte-solcu7{color:var(--color-yellow-700)}.dark .toast-title.warning.svelte-solcu7{color:var(--color-yellow-50)}.toast-title.info.svelte-solcu7{color:var(--color-grey-700)}.dark .toast-title.info.svelte-solcu7{color:var(--color-grey-50)}.toast-close.svelte-solcu7{margin:0 var(--size-3);border-radius:var(--size-3);padding:0px var(--size-1-5);font-size:var(--size-5);line-height:var(--size-5)}.toast-close.error.svelte-solcu7{color:var(--color-red-700)}.dark .toast-close.error.svelte-solcu7{color:var(--color-red-500)}.toast-close.warning.svelte-solcu7{color:var(--color-yellow-700)}.dark .toast-close.warning.svelte-solcu7{color:var(--color-yellow-500)}.toast-close.info.svelte-solcu7{color:var(--color-grey-700)}.dark .toast-close.info.svelte-solcu7{color:var(--color-grey-500)}.toast-text.svelte-solcu7{font-size:var(--text-lg)}.toast-text.error.svelte-solcu7{color:var(--color-red-700)}.dark .toast-text.error.svelte-solcu7{color:var(--color-red-50)}.toast-text.warning.svelte-solcu7{color:var(--color-yellow-700)}.dark .toast-text.warning.svelte-solcu7{color:var(--color-yellow-50)}.toast-text.info.svelte-solcu7{color:var(--color-grey-700)}.dark .toast-text.info.svelte-solcu7{color:var(--color-grey-50)}.toast-details.svelte-solcu7{margin:var(--size-3) var(--size-3) var(--size-3) 0;width:100%}.toast-icon.svelte-solcu7{display:flex;position:absolute;position:relative;flex-shrink:0;justify-content:center;align-items:center;margin:var(--size-2);border-radius:var(--radius-full);padding:var(--size-1);padding-left:calc(var(--size-1) - 1px);width:35px;height:35px}.toast-icon.error.svelte-solcu7{color:var(--color-red-700)}.dark .toast-icon.error.svelte-solcu7{color:var(--color-red-500)}.toast-icon.warning.svelte-solcu7{color:var(--color-yellow-700)}.dark .toast-icon.warning.svelte-solcu7{color:var(--color-yellow-500)}.toast-icon.info.svelte-solcu7{color:var(--color-grey-700)}.dark .toast-icon.info.svelte-solcu7{color:var(--color-grey-500)}@keyframes svelte-solcu7-countdown{0%{transform:scaleX(1)}to{transform:scaleX(0)}}.timer.svelte-solcu7{position:absolute;bottom:0;left:0;transform-origin:0 0;animation:svelte-solcu7-countdown 10s linear forwards;width:100%;height:var(--size-1)}.timer.error.svelte-solcu7{background:var(--color-red-700)}.dark .timer.error.svelte-solcu7{background:var(--color-red-500)}.timer.warning.svelte-solcu7{background:var(--color-yellow-700)}.dark .timer.warning.svelte-solcu7{background:var(--color-yellow-500)}.timer.info.svelte-solcu7{background:var(--color-grey-700)}.dark .timer.info.svelte-solcu7{background:var(--color-grey-500)}.toast-wrap.svelte-gatr8h{display:flex;position:fixed;top:var(--size-4);right:var(--size-4);flex-direction:column;align-items:end;gap:var(--size-2);z-index:var(--layer-top);width:calc(100% - var(--size-8))}@media (--screen-sm){.toast-wrap.svelte-gatr8h{width:calc(var(--size-96) + var(--size-10))}}.file-preview.svelte-144xq2d.svelte-144xq2d{table-layout:fixed;width:var(--size-full);max-height:var(--size-60);overflow-y:auto;margin-top:var(--size-1);color:var(--body-text-color)}.file.svelte-144xq2d.svelte-144xq2d{display:flex;width:var(--size-full)}.file.svelte-144xq2d>.svelte-144xq2d{padding:var(--size-1) var(--size-2-5)}.filename.svelte-144xq2d.svelte-144xq2d{flex-grow:1;display:flex;overflow:hidden}.filename.svelte-144xq2d .stem.svelte-144xq2d{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.filename.svelte-144xq2d .ext.svelte-144xq2d{white-space:nowrap}.download.svelte-144xq2d.svelte-144xq2d{min-width:8rem;width:10%;white-space:nowrap;text-align:right}.download.svelte-144xq2d.svelte-144xq2d:hover{text-decoration:underline}.download.svelte-144xq2d>a{color:var(--link-text-color)}.download.svelte-144xq2d>a:hover{color:var(--link-text-color-hover)}.download.svelte-144xq2d>a:visited{color:var(--link-text-color-visited)}.download.svelte-144xq2d>a:active{color:var(--link-text-color-active)}.selectable.svelte-144xq2d.svelte-144xq2d{cursor:pointer}tbody.svelte-144xq2d>tr.svelte-144xq2d:nth-child(2n){background:var(--block-background-fill)}tbody.svelte-144xq2d>tr.svelte-144xq2d:nth-child(odd){background:var(--table-odd-background-fill)}div.svelte-1hgn91n{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.gallery.svelte-1hgn91n{display:flex;align-items:center;cursor:pointer;padding:var(--size-1) var(--size-2);text-align:left}
|
src/backend/gradio_carousel/templates/component/wrapper-6f348d45-f837cf34.js
ADDED
@@ -0,0 +1,2455 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import S from "./__vite-browser-external-2447137e.js";
|
2 |
+
function z(s) {
|
3 |
+
return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
|
4 |
+
}
|
5 |
+
function gt(s) {
|
6 |
+
if (s.__esModule)
|
7 |
+
return s;
|
8 |
+
var e = s.default;
|
9 |
+
if (typeof e == "function") {
|
10 |
+
var t = function r() {
|
11 |
+
if (this instanceof r) {
|
12 |
+
var i = [null];
|
13 |
+
i.push.apply(i, arguments);
|
14 |
+
var n = Function.bind.apply(e, i);
|
15 |
+
return new n();
|
16 |
+
}
|
17 |
+
return e.apply(this, arguments);
|
18 |
+
};
|
19 |
+
t.prototype = e.prototype;
|
20 |
+
} else
|
21 |
+
t = {};
|
22 |
+
return Object.defineProperty(t, "__esModule", { value: !0 }), Object.keys(s).forEach(function(r) {
|
23 |
+
var i = Object.getOwnPropertyDescriptor(s, r);
|
24 |
+
Object.defineProperty(t, r, i.get ? i : {
|
25 |
+
enumerable: !0,
|
26 |
+
get: function() {
|
27 |
+
return s[r];
|
28 |
+
}
|
29 |
+
});
|
30 |
+
}), t;
|
31 |
+
}
|
32 |
+
const { Duplex: yt } = S;
|
33 |
+
function Oe(s) {
|
34 |
+
s.emit("close");
|
35 |
+
}
|
36 |
+
function vt() {
|
37 |
+
!this.destroyed && this._writableState.finished && this.destroy();
|
38 |
+
}
|
39 |
+
function Qe(s) {
|
40 |
+
this.removeListener("error", Qe), this.destroy(), this.listenerCount("error") === 0 && this.emit("error", s);
|
41 |
+
}
|
42 |
+
function St(s, e) {
|
43 |
+
let t = !0;
|
44 |
+
const r = new yt({
|
45 |
+
...e,
|
46 |
+
autoDestroy: !1,
|
47 |
+
emitClose: !1,
|
48 |
+
objectMode: !1,
|
49 |
+
writableObjectMode: !1
|
50 |
+
});
|
51 |
+
return s.on("message", function(n, o) {
|
52 |
+
const l = !o && r._readableState.objectMode ? n.toString() : n;
|
53 |
+
r.push(l) || s.pause();
|
54 |
+
}), s.once("error", function(n) {
|
55 |
+
r.destroyed || (t = !1, r.destroy(n));
|
56 |
+
}), s.once("close", function() {
|
57 |
+
r.destroyed || r.push(null);
|
58 |
+
}), r._destroy = function(i, n) {
|
59 |
+
if (s.readyState === s.CLOSED) {
|
60 |
+
n(i), process.nextTick(Oe, r);
|
61 |
+
return;
|
62 |
+
}
|
63 |
+
let o = !1;
|
64 |
+
s.once("error", function(f) {
|
65 |
+
o = !0, n(f);
|
66 |
+
}), s.once("close", function() {
|
67 |
+
o || n(i), process.nextTick(Oe, r);
|
68 |
+
}), t && s.terminate();
|
69 |
+
}, r._final = function(i) {
|
70 |
+
if (s.readyState === s.CONNECTING) {
|
71 |
+
s.once("open", function() {
|
72 |
+
r._final(i);
|
73 |
+
});
|
74 |
+
return;
|
75 |
+
}
|
76 |
+
s._socket !== null && (s._socket._writableState.finished ? (i(), r._readableState.endEmitted && r.destroy()) : (s._socket.once("finish", function() {
|
77 |
+
i();
|
78 |
+
}), s.close()));
|
79 |
+
}, r._read = function() {
|
80 |
+
s.isPaused && s.resume();
|
81 |
+
}, r._write = function(i, n, o) {
|
82 |
+
if (s.readyState === s.CONNECTING) {
|
83 |
+
s.once("open", function() {
|
84 |
+
r._write(i, n, o);
|
85 |
+
});
|
86 |
+
return;
|
87 |
+
}
|
88 |
+
s.send(i, o);
|
89 |
+
}, r.on("end", vt), r.on("error", Qe), r;
|
90 |
+
}
|
91 |
+
var Et = St;
|
92 |
+
const Vs = /* @__PURE__ */ z(Et);
|
93 |
+
var te = { exports: {} }, U = {
|
94 |
+
BINARY_TYPES: ["nodebuffer", "arraybuffer", "fragments"],
|
95 |
+
EMPTY_BUFFER: Buffer.alloc(0),
|
96 |
+
GUID: "258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
|
97 |
+
kForOnEventAttribute: Symbol("kIsForOnEventAttribute"),
|
98 |
+
kListener: Symbol("kListener"),
|
99 |
+
kStatusCode: Symbol("status-code"),
|
100 |
+
kWebSocket: Symbol("websocket"),
|
101 |
+
NOOP: () => {
|
102 |
+
}
|
103 |
+
}, bt, xt;
|
104 |
+
const { EMPTY_BUFFER: kt } = U, Se = Buffer[Symbol.species];
|
105 |
+
function wt(s, e) {
|
106 |
+
if (s.length === 0)
|
107 |
+
return kt;
|
108 |
+
if (s.length === 1)
|
109 |
+
return s[0];
|
110 |
+
const t = Buffer.allocUnsafe(e);
|
111 |
+
let r = 0;
|
112 |
+
for (let i = 0; i < s.length; i++) {
|
113 |
+
const n = s[i];
|
114 |
+
t.set(n, r), r += n.length;
|
115 |
+
}
|
116 |
+
return r < e ? new Se(t.buffer, t.byteOffset, r) : t;
|
117 |
+
}
|
118 |
+
function Je(s, e, t, r, i) {
|
119 |
+
for (let n = 0; n < i; n++)
|
120 |
+
t[r + n] = s[n] ^ e[n & 3];
|
121 |
+
}
|
122 |
+
function et(s, e) {
|
123 |
+
for (let t = 0; t < s.length; t++)
|
124 |
+
s[t] ^= e[t & 3];
|
125 |
+
}
|
126 |
+
function Ot(s) {
|
127 |
+
return s.length === s.buffer.byteLength ? s.buffer : s.buffer.slice(s.byteOffset, s.byteOffset + s.length);
|
128 |
+
}
|
129 |
+
function Ee(s) {
|
130 |
+
if (Ee.readOnly = !0, Buffer.isBuffer(s))
|
131 |
+
return s;
|
132 |
+
let e;
|
133 |
+
return s instanceof ArrayBuffer ? e = new Se(s) : ArrayBuffer.isView(s) ? e = new Se(s.buffer, s.byteOffset, s.byteLength) : (e = Buffer.from(s), Ee.readOnly = !1), e;
|
134 |
+
}
|
135 |
+
te.exports = {
|
136 |
+
concat: wt,
|
137 |
+
mask: Je,
|
138 |
+
toArrayBuffer: Ot,
|
139 |
+
toBuffer: Ee,
|
140 |
+
unmask: et
|
141 |
+
};
|
142 |
+
if (!process.env.WS_NO_BUFFER_UTIL)
|
143 |
+
try {
|
144 |
+
const s = require("bufferutil");
|
145 |
+
xt = te.exports.mask = function(e, t, r, i, n) {
|
146 |
+
n < 48 ? Je(e, t, r, i, n) : s.mask(e, t, r, i, n);
|
147 |
+
}, bt = te.exports.unmask = function(e, t) {
|
148 |
+
e.length < 32 ? et(e, t) : s.unmask(e, t);
|
149 |
+
};
|
150 |
+
} catch {
|
151 |
+
}
|
152 |
+
var ne = te.exports;
|
153 |
+
const Ce = Symbol("kDone"), ue = Symbol("kRun");
|
154 |
+
let Ct = class {
|
155 |
+
/**
|
156 |
+
* Creates a new `Limiter`.
|
157 |
+
*
|
158 |
+
* @param {Number} [concurrency=Infinity] The maximum number of jobs allowed
|
159 |
+
* to run concurrently
|
160 |
+
*/
|
161 |
+
constructor(e) {
|
162 |
+
this[Ce] = () => {
|
163 |
+
this.pending--, this[ue]();
|
164 |
+
}, this.concurrency = e || 1 / 0, this.jobs = [], this.pending = 0;
|
165 |
+
}
|
166 |
+
/**
|
167 |
+
* Adds a job to the queue.
|
168 |
+
*
|
169 |
+
* @param {Function} job The job to run
|
170 |
+
* @public
|
171 |
+
*/
|
172 |
+
add(e) {
|
173 |
+
this.jobs.push(e), this[ue]();
|
174 |
+
}
|
175 |
+
/**
|
176 |
+
* Removes a job from the queue and runs it if possible.
|
177 |
+
*
|
178 |
+
* @private
|
179 |
+
*/
|
180 |
+
[ue]() {
|
181 |
+
if (this.pending !== this.concurrency && this.jobs.length) {
|
182 |
+
const e = this.jobs.shift();
|
183 |
+
this.pending++, e(this[Ce]);
|
184 |
+
}
|
185 |
+
}
|
186 |
+
};
|
187 |
+
var Tt = Ct;
|
188 |
+
const W = S, Te = ne, Lt = Tt, { kStatusCode: tt } = U, Nt = Buffer[Symbol.species], Pt = Buffer.from([0, 0, 255, 255]), se = Symbol("permessage-deflate"), w = Symbol("total-length"), V = Symbol("callback"), C = Symbol("buffers"), J = Symbol("error");
|
189 |
+
let K, Rt = class {
|
190 |
+
/**
|
191 |
+
* Creates a PerMessageDeflate instance.
|
192 |
+
*
|
193 |
+
* @param {Object} [options] Configuration options
|
194 |
+
* @param {(Boolean|Number)} [options.clientMaxWindowBits] Advertise support
|
195 |
+
* for, or request, a custom client window size
|
196 |
+
* @param {Boolean} [options.clientNoContextTakeover=false] Advertise/
|
197 |
+
* acknowledge disabling of client context takeover
|
198 |
+
* @param {Number} [options.concurrencyLimit=10] The number of concurrent
|
199 |
+
* calls to zlib
|
200 |
+
* @param {(Boolean|Number)} [options.serverMaxWindowBits] Request/confirm the
|
201 |
+
* use of a custom server window size
|
202 |
+
* @param {Boolean} [options.serverNoContextTakeover=false] Request/accept
|
203 |
+
* disabling of server context takeover
|
204 |
+
* @param {Number} [options.threshold=1024] Size (in bytes) below which
|
205 |
+
* messages should not be compressed if context takeover is disabled
|
206 |
+
* @param {Object} [options.zlibDeflateOptions] Options to pass to zlib on
|
207 |
+
* deflate
|
208 |
+
* @param {Object} [options.zlibInflateOptions] Options to pass to zlib on
|
209 |
+
* inflate
|
210 |
+
* @param {Boolean} [isServer=false] Create the instance in either server or
|
211 |
+
* client mode
|
212 |
+
* @param {Number} [maxPayload=0] The maximum allowed message length
|
213 |
+
*/
|
214 |
+
constructor(e, t, r) {
|
215 |
+
if (this._maxPayload = r | 0, this._options = e || {}, this._threshold = this._options.threshold !== void 0 ? this._options.threshold : 1024, this._isServer = !!t, this._deflate = null, this._inflate = null, this.params = null, !K) {
|
216 |
+
const i = this._options.concurrencyLimit !== void 0 ? this._options.concurrencyLimit : 10;
|
217 |
+
K = new Lt(i);
|
218 |
+
}
|
219 |
+
}
|
220 |
+
/**
|
221 |
+
* @type {String}
|
222 |
+
*/
|
223 |
+
static get extensionName() {
|
224 |
+
return "permessage-deflate";
|
225 |
+
}
|
226 |
+
/**
|
227 |
+
* Create an extension negotiation offer.
|
228 |
+
*
|
229 |
+
* @return {Object} Extension parameters
|
230 |
+
* @public
|
231 |
+
*/
|
232 |
+
offer() {
|
233 |
+
const e = {};
|
234 |
+
return this._options.serverNoContextTakeover && (e.server_no_context_takeover = !0), this._options.clientNoContextTakeover && (e.client_no_context_takeover = !0), this._options.serverMaxWindowBits && (e.server_max_window_bits = this._options.serverMaxWindowBits), this._options.clientMaxWindowBits ? e.client_max_window_bits = this._options.clientMaxWindowBits : this._options.clientMaxWindowBits == null && (e.client_max_window_bits = !0), e;
|
235 |
+
}
|
236 |
+
/**
|
237 |
+
* Accept an extension negotiation offer/response.
|
238 |
+
*
|
239 |
+
* @param {Array} configurations The extension negotiation offers/reponse
|
240 |
+
* @return {Object} Accepted configuration
|
241 |
+
* @public
|
242 |
+
*/
|
243 |
+
accept(e) {
|
244 |
+
return e = this.normalizeParams(e), this.params = this._isServer ? this.acceptAsServer(e) : this.acceptAsClient(e), this.params;
|
245 |
+
}
|
246 |
+
/**
|
247 |
+
* Releases all resources used by the extension.
|
248 |
+
*
|
249 |
+
* @public
|
250 |
+
*/
|
251 |
+
cleanup() {
|
252 |
+
if (this._inflate && (this._inflate.close(), this._inflate = null), this._deflate) {
|
253 |
+
const e = this._deflate[V];
|
254 |
+
this._deflate.close(), this._deflate = null, e && e(
|
255 |
+
new Error(
|
256 |
+
"The deflate stream was closed while data was being processed"
|
257 |
+
)
|
258 |
+
);
|
259 |
+
}
|
260 |
+
}
|
261 |
+
/**
|
262 |
+
* Accept an extension negotiation offer.
|
263 |
+
*
|
264 |
+
* @param {Array} offers The extension negotiation offers
|
265 |
+
* @return {Object} Accepted configuration
|
266 |
+
* @private
|
267 |
+
*/
|
268 |
+
acceptAsServer(e) {
|
269 |
+
const t = this._options, r = e.find((i) => !(t.serverNoContextTakeover === !1 && i.server_no_context_takeover || i.server_max_window_bits && (t.serverMaxWindowBits === !1 || typeof t.serverMaxWindowBits == "number" && t.serverMaxWindowBits > i.server_max_window_bits) || typeof t.clientMaxWindowBits == "number" && !i.client_max_window_bits));
|
270 |
+
if (!r)
|
271 |
+
throw new Error("None of the extension offers can be accepted");
|
272 |
+
return t.serverNoContextTakeover && (r.server_no_context_takeover = !0), t.clientNoContextTakeover && (r.client_no_context_takeover = !0), typeof t.serverMaxWindowBits == "number" && (r.server_max_window_bits = t.serverMaxWindowBits), typeof t.clientMaxWindowBits == "number" ? r.client_max_window_bits = t.clientMaxWindowBits : (r.client_max_window_bits === !0 || t.clientMaxWindowBits === !1) && delete r.client_max_window_bits, r;
|
273 |
+
}
|
274 |
+
/**
|
275 |
+
* Accept the extension negotiation response.
|
276 |
+
*
|
277 |
+
* @param {Array} response The extension negotiation response
|
278 |
+
* @return {Object} Accepted configuration
|
279 |
+
* @private
|
280 |
+
*/
|
281 |
+
acceptAsClient(e) {
|
282 |
+
const t = e[0];
|
283 |
+
if (this._options.clientNoContextTakeover === !1 && t.client_no_context_takeover)
|
284 |
+
throw new Error('Unexpected parameter "client_no_context_takeover"');
|
285 |
+
if (!t.client_max_window_bits)
|
286 |
+
typeof this._options.clientMaxWindowBits == "number" && (t.client_max_window_bits = this._options.clientMaxWindowBits);
|
287 |
+
else if (this._options.clientMaxWindowBits === !1 || typeof this._options.clientMaxWindowBits == "number" && t.client_max_window_bits > this._options.clientMaxWindowBits)
|
288 |
+
throw new Error(
|
289 |
+
'Unexpected or invalid parameter "client_max_window_bits"'
|
290 |
+
);
|
291 |
+
return t;
|
292 |
+
}
|
293 |
+
/**
|
294 |
+
* Normalize parameters.
|
295 |
+
*
|
296 |
+
* @param {Array} configurations The extension negotiation offers/reponse
|
297 |
+
* @return {Array} The offers/response with normalized parameters
|
298 |
+
* @private
|
299 |
+
*/
|
300 |
+
normalizeParams(e) {
|
301 |
+
return e.forEach((t) => {
|
302 |
+
Object.keys(t).forEach((r) => {
|
303 |
+
let i = t[r];
|
304 |
+
if (i.length > 1)
|
305 |
+
throw new Error(`Parameter "${r}" must have only a single value`);
|
306 |
+
if (i = i[0], r === "client_max_window_bits") {
|
307 |
+
if (i !== !0) {
|
308 |
+
const n = +i;
|
309 |
+
if (!Number.isInteger(n) || n < 8 || n > 15)
|
310 |
+
throw new TypeError(
|
311 |
+
`Invalid value for parameter "${r}": ${i}`
|
312 |
+
);
|
313 |
+
i = n;
|
314 |
+
} else if (!this._isServer)
|
315 |
+
throw new TypeError(
|
316 |
+
`Invalid value for parameter "${r}": ${i}`
|
317 |
+
);
|
318 |
+
} else if (r === "server_max_window_bits") {
|
319 |
+
const n = +i;
|
320 |
+
if (!Number.isInteger(n) || n < 8 || n > 15)
|
321 |
+
throw new TypeError(
|
322 |
+
`Invalid value for parameter "${r}": ${i}`
|
323 |
+
);
|
324 |
+
i = n;
|
325 |
+
} else if (r === "client_no_context_takeover" || r === "server_no_context_takeover") {
|
326 |
+
if (i !== !0)
|
327 |
+
throw new TypeError(
|
328 |
+
`Invalid value for parameter "${r}": ${i}`
|
329 |
+
);
|
330 |
+
} else
|
331 |
+
throw new Error(`Unknown parameter "${r}"`);
|
332 |
+
t[r] = i;
|
333 |
+
});
|
334 |
+
}), e;
|
335 |
+
}
|
336 |
+
/**
|
337 |
+
* Decompress data. Concurrency limited.
|
338 |
+
*
|
339 |
+
* @param {Buffer} data Compressed data
|
340 |
+
* @param {Boolean} fin Specifies whether or not this is the last fragment
|
341 |
+
* @param {Function} callback Callback
|
342 |
+
* @public
|
343 |
+
*/
|
344 |
+
decompress(e, t, r) {
|
345 |
+
K.add((i) => {
|
346 |
+
this._decompress(e, t, (n, o) => {
|
347 |
+
i(), r(n, o);
|
348 |
+
});
|
349 |
+
});
|
350 |
+
}
|
351 |
+
/**
|
352 |
+
* Compress data. Concurrency limited.
|
353 |
+
*
|
354 |
+
* @param {(Buffer|String)} data Data to compress
|
355 |
+
* @param {Boolean} fin Specifies whether or not this is the last fragment
|
356 |
+
* @param {Function} callback Callback
|
357 |
+
* @public
|
358 |
+
*/
|
359 |
+
compress(e, t, r) {
|
360 |
+
K.add((i) => {
|
361 |
+
this._compress(e, t, (n, o) => {
|
362 |
+
i(), r(n, o);
|
363 |
+
});
|
364 |
+
});
|
365 |
+
}
|
366 |
+
/**
|
367 |
+
* Decompress data.
|
368 |
+
*
|
369 |
+
* @param {Buffer} data Compressed data
|
370 |
+
* @param {Boolean} fin Specifies whether or not this is the last fragment
|
371 |
+
* @param {Function} callback Callback
|
372 |
+
* @private
|
373 |
+
*/
|
374 |
+
_decompress(e, t, r) {
|
375 |
+
const i = this._isServer ? "client" : "server";
|
376 |
+
if (!this._inflate) {
|
377 |
+
const n = `${i}_max_window_bits`, o = typeof this.params[n] != "number" ? W.Z_DEFAULT_WINDOWBITS : this.params[n];
|
378 |
+
this._inflate = W.createInflateRaw({
|
379 |
+
...this._options.zlibInflateOptions,
|
380 |
+
windowBits: o
|
381 |
+
}), this._inflate[se] = this, this._inflate[w] = 0, this._inflate[C] = [], this._inflate.on("error", Bt), this._inflate.on("data", st);
|
382 |
+
}
|
383 |
+
this._inflate[V] = r, this._inflate.write(e), t && this._inflate.write(Pt), this._inflate.flush(() => {
|
384 |
+
const n = this._inflate[J];
|
385 |
+
if (n) {
|
386 |
+
this._inflate.close(), this._inflate = null, r(n);
|
387 |
+
return;
|
388 |
+
}
|
389 |
+
const o = Te.concat(
|
390 |
+
this._inflate[C],
|
391 |
+
this._inflate[w]
|
392 |
+
);
|
393 |
+
this._inflate._readableState.endEmitted ? (this._inflate.close(), this._inflate = null) : (this._inflate[w] = 0, this._inflate[C] = [], t && this.params[`${i}_no_context_takeover`] && this._inflate.reset()), r(null, o);
|
394 |
+
});
|
395 |
+
}
|
396 |
+
/**
|
397 |
+
* Compress data.
|
398 |
+
*
|
399 |
+
* @param {(Buffer|String)} data Data to compress
|
400 |
+
* @param {Boolean} fin Specifies whether or not this is the last fragment
|
401 |
+
* @param {Function} callback Callback
|
402 |
+
* @private
|
403 |
+
*/
|
404 |
+
_compress(e, t, r) {
|
405 |
+
const i = this._isServer ? "server" : "client";
|
406 |
+
if (!this._deflate) {
|
407 |
+
const n = `${i}_max_window_bits`, o = typeof this.params[n] != "number" ? W.Z_DEFAULT_WINDOWBITS : this.params[n];
|
408 |
+
this._deflate = W.createDeflateRaw({
|
409 |
+
...this._options.zlibDeflateOptions,
|
410 |
+
windowBits: o
|
411 |
+
}), this._deflate[w] = 0, this._deflate[C] = [], this._deflate.on("data", Ut);
|
412 |
+
}
|
413 |
+
this._deflate[V] = r, this._deflate.write(e), this._deflate.flush(W.Z_SYNC_FLUSH, () => {
|
414 |
+
if (!this._deflate)
|
415 |
+
return;
|
416 |
+
let n = Te.concat(
|
417 |
+
this._deflate[C],
|
418 |
+
this._deflate[w]
|
419 |
+
);
|
420 |
+
t && (n = new Nt(n.buffer, n.byteOffset, n.length - 4)), this._deflate[V] = null, this._deflate[w] = 0, this._deflate[C] = [], t && this.params[`${i}_no_context_takeover`] && this._deflate.reset(), r(null, n);
|
421 |
+
});
|
422 |
+
}
|
423 |
+
};
|
424 |
+
var oe = Rt;
|
425 |
+
function Ut(s) {
|
426 |
+
this[C].push(s), this[w] += s.length;
|
427 |
+
}
|
428 |
+
function st(s) {
|
429 |
+
if (this[w] += s.length, this[se]._maxPayload < 1 || this[w] <= this[se]._maxPayload) {
|
430 |
+
this[C].push(s);
|
431 |
+
return;
|
432 |
+
}
|
433 |
+
this[J] = new RangeError("Max payload size exceeded"), this[J].code = "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH", this[J][tt] = 1009, this.removeListener("data", st), this.reset();
|
434 |
+
}
|
435 |
+
function Bt(s) {
|
436 |
+
this[se]._inflate = null, s[tt] = 1007, this[V](s);
|
437 |
+
}
|
438 |
+
var re = { exports: {} };
|
439 |
+
const $t = {}, Mt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
440 |
+
__proto__: null,
|
441 |
+
default: $t
|
442 |
+
}, Symbol.toStringTag, { value: "Module" })), It = /* @__PURE__ */ gt(Mt);
|
443 |
+
var Le;
|
444 |
+
const { isUtf8: Ne } = S, Dt = [
|
445 |
+
0,
|
446 |
+
0,
|
447 |
+
0,
|
448 |
+
0,
|
449 |
+
0,
|
450 |
+
0,
|
451 |
+
0,
|
452 |
+
0,
|
453 |
+
0,
|
454 |
+
0,
|
455 |
+
0,
|
456 |
+
0,
|
457 |
+
0,
|
458 |
+
0,
|
459 |
+
0,
|
460 |
+
0,
|
461 |
+
// 0 - 15
|
462 |
+
0,
|
463 |
+
0,
|
464 |
+
0,
|
465 |
+
0,
|
466 |
+
0,
|
467 |
+
0,
|
468 |
+
0,
|
469 |
+
0,
|
470 |
+
0,
|
471 |
+
0,
|
472 |
+
0,
|
473 |
+
0,
|
474 |
+
0,
|
475 |
+
0,
|
476 |
+
0,
|
477 |
+
0,
|
478 |
+
// 16 - 31
|
479 |
+
0,
|
480 |
+
1,
|
481 |
+
0,
|
482 |
+
1,
|
483 |
+
1,
|
484 |
+
1,
|
485 |
+
1,
|
486 |
+
1,
|
487 |
+
0,
|
488 |
+
0,
|
489 |
+
1,
|
490 |
+
1,
|
491 |
+
0,
|
492 |
+
1,
|
493 |
+
1,
|
494 |
+
0,
|
495 |
+
// 32 - 47
|
496 |
+
1,
|
497 |
+
1,
|
498 |
+
1,
|
499 |
+
1,
|
500 |
+
1,
|
501 |
+
1,
|
502 |
+
1,
|
503 |
+
1,
|
504 |
+
1,
|
505 |
+
1,
|
506 |
+
0,
|
507 |
+
0,
|
508 |
+
0,
|
509 |
+
0,
|
510 |
+
0,
|
511 |
+
0,
|
512 |
+
// 48 - 63
|
513 |
+
0,
|
514 |
+
1,
|
515 |
+
1,
|
516 |
+
1,
|
517 |
+
1,
|
518 |
+
1,
|
519 |
+
1,
|
520 |
+
1,
|
521 |
+
1,
|
522 |
+
1,
|
523 |
+
1,
|
524 |
+
1,
|
525 |
+
1,
|
526 |
+
1,
|
527 |
+
1,
|
528 |
+
1,
|
529 |
+
// 64 - 79
|
530 |
+
1,
|
531 |
+
1,
|
532 |
+
1,
|
533 |
+
1,
|
534 |
+
1,
|
535 |
+
1,
|
536 |
+
1,
|
537 |
+
1,
|
538 |
+
1,
|
539 |
+
1,
|
540 |
+
1,
|
541 |
+
0,
|
542 |
+
0,
|
543 |
+
0,
|
544 |
+
1,
|
545 |
+
1,
|
546 |
+
// 80 - 95
|
547 |
+
1,
|
548 |
+
1,
|
549 |
+
1,
|
550 |
+
1,
|
551 |
+
1,
|
552 |
+
1,
|
553 |
+
1,
|
554 |
+
1,
|
555 |
+
1,
|
556 |
+
1,
|
557 |
+
1,
|
558 |
+
1,
|
559 |
+
1,
|
560 |
+
1,
|
561 |
+
1,
|
562 |
+
1,
|
563 |
+
// 96 - 111
|
564 |
+
1,
|
565 |
+
1,
|
566 |
+
1,
|
567 |
+
1,
|
568 |
+
1,
|
569 |
+
1,
|
570 |
+
1,
|
571 |
+
1,
|
572 |
+
1,
|
573 |
+
1,
|
574 |
+
1,
|
575 |
+
0,
|
576 |
+
1,
|
577 |
+
0,
|
578 |
+
1,
|
579 |
+
0
|
580 |
+
// 112 - 127
|
581 |
+
];
|
582 |
+
function Wt(s) {
|
583 |
+
return s >= 1e3 && s <= 1014 && s !== 1004 && s !== 1005 && s !== 1006 || s >= 3e3 && s <= 4999;
|
584 |
+
}
|
585 |
+
function be(s) {
|
586 |
+
const e = s.length;
|
587 |
+
let t = 0;
|
588 |
+
for (; t < e; )
|
589 |
+
if (!(s[t] & 128))
|
590 |
+
t++;
|
591 |
+
else if ((s[t] & 224) === 192) {
|
592 |
+
if (t + 1 === e || (s[t + 1] & 192) !== 128 || (s[t] & 254) === 192)
|
593 |
+
return !1;
|
594 |
+
t += 2;
|
595 |
+
} else if ((s[t] & 240) === 224) {
|
596 |
+
if (t + 2 >= e || (s[t + 1] & 192) !== 128 || (s[t + 2] & 192) !== 128 || s[t] === 224 && (s[t + 1] & 224) === 128 || // Overlong
|
597 |
+
s[t] === 237 && (s[t + 1] & 224) === 160)
|
598 |
+
return !1;
|
599 |
+
t += 3;
|
600 |
+
} else if ((s[t] & 248) === 240) {
|
601 |
+
if (t + 3 >= e || (s[t + 1] & 192) !== 128 || (s[t + 2] & 192) !== 128 || (s[t + 3] & 192) !== 128 || s[t] === 240 && (s[t + 1] & 240) === 128 || // Overlong
|
602 |
+
s[t] === 244 && s[t + 1] > 143 || s[t] > 244)
|
603 |
+
return !1;
|
604 |
+
t += 4;
|
605 |
+
} else
|
606 |
+
return !1;
|
607 |
+
return !0;
|
608 |
+
}
|
609 |
+
re.exports = {
|
610 |
+
isValidStatusCode: Wt,
|
611 |
+
isValidUTF8: be,
|
612 |
+
tokenChars: Dt
|
613 |
+
};
|
614 |
+
if (Ne)
|
615 |
+
Le = re.exports.isValidUTF8 = function(s) {
|
616 |
+
return s.length < 24 ? be(s) : Ne(s);
|
617 |
+
};
|
618 |
+
else if (!process.env.WS_NO_UTF_8_VALIDATE)
|
619 |
+
try {
|
620 |
+
const s = It;
|
621 |
+
Le = re.exports.isValidUTF8 = function(e) {
|
622 |
+
return e.length < 32 ? be(e) : s(e);
|
623 |
+
};
|
624 |
+
} catch {
|
625 |
+
}
|
626 |
+
var ae = re.exports;
|
627 |
+
const { Writable: At } = S, Pe = oe, {
|
628 |
+
BINARY_TYPES: Ft,
|
629 |
+
EMPTY_BUFFER: Re,
|
630 |
+
kStatusCode: jt,
|
631 |
+
kWebSocket: Gt
|
632 |
+
} = U, { concat: de, toArrayBuffer: Vt, unmask: Ht } = ne, { isValidStatusCode: zt, isValidUTF8: Ue } = ae, X = Buffer[Symbol.species], A = 0, Be = 1, $e = 2, Me = 3, _e = 4, Yt = 5;
|
633 |
+
let qt = class extends At {
|
634 |
+
/**
|
635 |
+
* Creates a Receiver instance.
|
636 |
+
*
|
637 |
+
* @param {Object} [options] Options object
|
638 |
+
* @param {String} [options.binaryType=nodebuffer] The type for binary data
|
639 |
+
* @param {Object} [options.extensions] An object containing the negotiated
|
640 |
+
* extensions
|
641 |
+
* @param {Boolean} [options.isServer=false] Specifies whether to operate in
|
642 |
+
* client or server mode
|
643 |
+
* @param {Number} [options.maxPayload=0] The maximum allowed message length
|
644 |
+
* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
|
645 |
+
* not to skip UTF-8 validation for text and close messages
|
646 |
+
*/
|
647 |
+
constructor(e = {}) {
|
648 |
+
super(), this._binaryType = e.binaryType || Ft[0], this._extensions = e.extensions || {}, this._isServer = !!e.isServer, this._maxPayload = e.maxPayload | 0, this._skipUTF8Validation = !!e.skipUTF8Validation, this[Gt] = void 0, this._bufferedBytes = 0, this._buffers = [], this._compressed = !1, this._payloadLength = 0, this._mask = void 0, this._fragmented = 0, this._masked = !1, this._fin = !1, this._opcode = 0, this._totalPayloadLength = 0, this._messageLength = 0, this._fragments = [], this._state = A, this._loop = !1;
|
649 |
+
}
|
650 |
+
/**
|
651 |
+
* Implements `Writable.prototype._write()`.
|
652 |
+
*
|
653 |
+
* @param {Buffer} chunk The chunk of data to write
|
654 |
+
* @param {String} encoding The character encoding of `chunk`
|
655 |
+
* @param {Function} cb Callback
|
656 |
+
* @private
|
657 |
+
*/
|
658 |
+
_write(e, t, r) {
|
659 |
+
if (this._opcode === 8 && this._state == A)
|
660 |
+
return r();
|
661 |
+
this._bufferedBytes += e.length, this._buffers.push(e), this.startLoop(r);
|
662 |
+
}
|
663 |
+
/**
|
664 |
+
* Consumes `n` bytes from the buffered data.
|
665 |
+
*
|
666 |
+
* @param {Number} n The number of bytes to consume
|
667 |
+
* @return {Buffer} The consumed bytes
|
668 |
+
* @private
|
669 |
+
*/
|
670 |
+
consume(e) {
|
671 |
+
if (this._bufferedBytes -= e, e === this._buffers[0].length)
|
672 |
+
return this._buffers.shift();
|
673 |
+
if (e < this._buffers[0].length) {
|
674 |
+
const r = this._buffers[0];
|
675 |
+
return this._buffers[0] = new X(
|
676 |
+
r.buffer,
|
677 |
+
r.byteOffset + e,
|
678 |
+
r.length - e
|
679 |
+
), new X(r.buffer, r.byteOffset, e);
|
680 |
+
}
|
681 |
+
const t = Buffer.allocUnsafe(e);
|
682 |
+
do {
|
683 |
+
const r = this._buffers[0], i = t.length - e;
|
684 |
+
e >= r.length ? t.set(this._buffers.shift(), i) : (t.set(new Uint8Array(r.buffer, r.byteOffset, e), i), this._buffers[0] = new X(
|
685 |
+
r.buffer,
|
686 |
+
r.byteOffset + e,
|
687 |
+
r.length - e
|
688 |
+
)), e -= r.length;
|
689 |
+
} while (e > 0);
|
690 |
+
return t;
|
691 |
+
}
|
692 |
+
/**
|
693 |
+
* Starts the parsing loop.
|
694 |
+
*
|
695 |
+
* @param {Function} cb Callback
|
696 |
+
* @private
|
697 |
+
*/
|
698 |
+
startLoop(e) {
|
699 |
+
let t;
|
700 |
+
this._loop = !0;
|
701 |
+
do
|
702 |
+
switch (this._state) {
|
703 |
+
case A:
|
704 |
+
t = this.getInfo();
|
705 |
+
break;
|
706 |
+
case Be:
|
707 |
+
t = this.getPayloadLength16();
|
708 |
+
break;
|
709 |
+
case $e:
|
710 |
+
t = this.getPayloadLength64();
|
711 |
+
break;
|
712 |
+
case Me:
|
713 |
+
this.getMask();
|
714 |
+
break;
|
715 |
+
case _e:
|
716 |
+
t = this.getData(e);
|
717 |
+
break;
|
718 |
+
default:
|
719 |
+
this._loop = !1;
|
720 |
+
return;
|
721 |
+
}
|
722 |
+
while (this._loop);
|
723 |
+
e(t);
|
724 |
+
}
|
725 |
+
/**
|
726 |
+
* Reads the first two bytes of a frame.
|
727 |
+
*
|
728 |
+
* @return {(RangeError|undefined)} A possible error
|
729 |
+
* @private
|
730 |
+
*/
|
731 |
+
getInfo() {
|
732 |
+
if (this._bufferedBytes < 2) {
|
733 |
+
this._loop = !1;
|
734 |
+
return;
|
735 |
+
}
|
736 |
+
const e = this.consume(2);
|
737 |
+
if (e[0] & 48)
|
738 |
+
return this._loop = !1, g(
|
739 |
+
RangeError,
|
740 |
+
"RSV2 and RSV3 must be clear",
|
741 |
+
!0,
|
742 |
+
1002,
|
743 |
+
"WS_ERR_UNEXPECTED_RSV_2_3"
|
744 |
+
);
|
745 |
+
const t = (e[0] & 64) === 64;
|
746 |
+
if (t && !this._extensions[Pe.extensionName])
|
747 |
+
return this._loop = !1, g(
|
748 |
+
RangeError,
|
749 |
+
"RSV1 must be clear",
|
750 |
+
!0,
|
751 |
+
1002,
|
752 |
+
"WS_ERR_UNEXPECTED_RSV_1"
|
753 |
+
);
|
754 |
+
if (this._fin = (e[0] & 128) === 128, this._opcode = e[0] & 15, this._payloadLength = e[1] & 127, this._opcode === 0) {
|
755 |
+
if (t)
|
756 |
+
return this._loop = !1, g(
|
757 |
+
RangeError,
|
758 |
+
"RSV1 must be clear",
|
759 |
+
!0,
|
760 |
+
1002,
|
761 |
+
"WS_ERR_UNEXPECTED_RSV_1"
|
762 |
+
);
|
763 |
+
if (!this._fragmented)
|
764 |
+
return this._loop = !1, g(
|
765 |
+
RangeError,
|
766 |
+
"invalid opcode 0",
|
767 |
+
!0,
|
768 |
+
1002,
|
769 |
+
"WS_ERR_INVALID_OPCODE"
|
770 |
+
);
|
771 |
+
this._opcode = this._fragmented;
|
772 |
+
} else if (this._opcode === 1 || this._opcode === 2) {
|
773 |
+
if (this._fragmented)
|
774 |
+
return this._loop = !1, g(
|
775 |
+
RangeError,
|
776 |
+
`invalid opcode ${this._opcode}`,
|
777 |
+
!0,
|
778 |
+
1002,
|
779 |
+
"WS_ERR_INVALID_OPCODE"
|
780 |
+
);
|
781 |
+
this._compressed = t;
|
782 |
+
} else if (this._opcode > 7 && this._opcode < 11) {
|
783 |
+
if (!this._fin)
|
784 |
+
return this._loop = !1, g(
|
785 |
+
RangeError,
|
786 |
+
"FIN must be set",
|
787 |
+
!0,
|
788 |
+
1002,
|
789 |
+
"WS_ERR_EXPECTED_FIN"
|
790 |
+
);
|
791 |
+
if (t)
|
792 |
+
return this._loop = !1, g(
|
793 |
+
RangeError,
|
794 |
+
"RSV1 must be clear",
|
795 |
+
!0,
|
796 |
+
1002,
|
797 |
+
"WS_ERR_UNEXPECTED_RSV_1"
|
798 |
+
);
|
799 |
+
if (this._payloadLength > 125 || this._opcode === 8 && this._payloadLength === 1)
|
800 |
+
return this._loop = !1, g(
|
801 |
+
RangeError,
|
802 |
+
`invalid payload length ${this._payloadLength}`,
|
803 |
+
!0,
|
804 |
+
1002,
|
805 |
+
"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"
|
806 |
+
);
|
807 |
+
} else
|
808 |
+
return this._loop = !1, g(
|
809 |
+
RangeError,
|
810 |
+
`invalid opcode ${this._opcode}`,
|
811 |
+
!0,
|
812 |
+
1002,
|
813 |
+
"WS_ERR_INVALID_OPCODE"
|
814 |
+
);
|
815 |
+
if (!this._fin && !this._fragmented && (this._fragmented = this._opcode), this._masked = (e[1] & 128) === 128, this._isServer) {
|
816 |
+
if (!this._masked)
|
817 |
+
return this._loop = !1, g(
|
818 |
+
RangeError,
|
819 |
+
"MASK must be set",
|
820 |
+
!0,
|
821 |
+
1002,
|
822 |
+
"WS_ERR_EXPECTED_MASK"
|
823 |
+
);
|
824 |
+
} else if (this._masked)
|
825 |
+
return this._loop = !1, g(
|
826 |
+
RangeError,
|
827 |
+
"MASK must be clear",
|
828 |
+
!0,
|
829 |
+
1002,
|
830 |
+
"WS_ERR_UNEXPECTED_MASK"
|
831 |
+
);
|
832 |
+
if (this._payloadLength === 126)
|
833 |
+
this._state = Be;
|
834 |
+
else if (this._payloadLength === 127)
|
835 |
+
this._state = $e;
|
836 |
+
else
|
837 |
+
return this.haveLength();
|
838 |
+
}
|
839 |
+
/**
|
840 |
+
* Gets extended payload length (7+16).
|
841 |
+
*
|
842 |
+
* @return {(RangeError|undefined)} A possible error
|
843 |
+
* @private
|
844 |
+
*/
|
845 |
+
getPayloadLength16() {
|
846 |
+
if (this._bufferedBytes < 2) {
|
847 |
+
this._loop = !1;
|
848 |
+
return;
|
849 |
+
}
|
850 |
+
return this._payloadLength = this.consume(2).readUInt16BE(0), this.haveLength();
|
851 |
+
}
|
852 |
+
/**
|
853 |
+
* Gets extended payload length (7+64).
|
854 |
+
*
|
855 |
+
* @return {(RangeError|undefined)} A possible error
|
856 |
+
* @private
|
857 |
+
*/
|
858 |
+
getPayloadLength64() {
|
859 |
+
if (this._bufferedBytes < 8) {
|
860 |
+
this._loop = !1;
|
861 |
+
return;
|
862 |
+
}
|
863 |
+
const e = this.consume(8), t = e.readUInt32BE(0);
|
864 |
+
return t > Math.pow(2, 53 - 32) - 1 ? (this._loop = !1, g(
|
865 |
+
RangeError,
|
866 |
+
"Unsupported WebSocket frame: payload length > 2^53 - 1",
|
867 |
+
!1,
|
868 |
+
1009,
|
869 |
+
"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH"
|
870 |
+
)) : (this._payloadLength = t * Math.pow(2, 32) + e.readUInt32BE(4), this.haveLength());
|
871 |
+
}
|
872 |
+
/**
|
873 |
+
* Payload length has been read.
|
874 |
+
*
|
875 |
+
* @return {(RangeError|undefined)} A possible error
|
876 |
+
* @private
|
877 |
+
*/
|
878 |
+
haveLength() {
|
879 |
+
if (this._payloadLength && this._opcode < 8 && (this._totalPayloadLength += this._payloadLength, this._totalPayloadLength > this._maxPayload && this._maxPayload > 0))
|
880 |
+
return this._loop = !1, g(
|
881 |
+
RangeError,
|
882 |
+
"Max payload size exceeded",
|
883 |
+
!1,
|
884 |
+
1009,
|
885 |
+
"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"
|
886 |
+
);
|
887 |
+
this._masked ? this._state = Me : this._state = _e;
|
888 |
+
}
|
889 |
+
/**
|
890 |
+
* Reads mask bytes.
|
891 |
+
*
|
892 |
+
* @private
|
893 |
+
*/
|
894 |
+
getMask() {
|
895 |
+
if (this._bufferedBytes < 4) {
|
896 |
+
this._loop = !1;
|
897 |
+
return;
|
898 |
+
}
|
899 |
+
this._mask = this.consume(4), this._state = _e;
|
900 |
+
}
|
901 |
+
/**
|
902 |
+
* Reads data bytes.
|
903 |
+
*
|
904 |
+
* @param {Function} cb Callback
|
905 |
+
* @return {(Error|RangeError|undefined)} A possible error
|
906 |
+
* @private
|
907 |
+
*/
|
908 |
+
getData(e) {
|
909 |
+
let t = Re;
|
910 |
+
if (this._payloadLength) {
|
911 |
+
if (this._bufferedBytes < this._payloadLength) {
|
912 |
+
this._loop = !1;
|
913 |
+
return;
|
914 |
+
}
|
915 |
+
t = this.consume(this._payloadLength), this._masked && this._mask[0] | this._mask[1] | this._mask[2] | this._mask[3] && Ht(t, this._mask);
|
916 |
+
}
|
917 |
+
if (this._opcode > 7)
|
918 |
+
return this.controlMessage(t);
|
919 |
+
if (this._compressed) {
|
920 |
+
this._state = Yt, this.decompress(t, e);
|
921 |
+
return;
|
922 |
+
}
|
923 |
+
return t.length && (this._messageLength = this._totalPayloadLength, this._fragments.push(t)), this.dataMessage();
|
924 |
+
}
|
925 |
+
/**
|
926 |
+
* Decompresses data.
|
927 |
+
*
|
928 |
+
* @param {Buffer} data Compressed data
|
929 |
+
* @param {Function} cb Callback
|
930 |
+
* @private
|
931 |
+
*/
|
932 |
+
decompress(e, t) {
|
933 |
+
this._extensions[Pe.extensionName].decompress(e, this._fin, (i, n) => {
|
934 |
+
if (i)
|
935 |
+
return t(i);
|
936 |
+
if (n.length) {
|
937 |
+
if (this._messageLength += n.length, this._messageLength > this._maxPayload && this._maxPayload > 0)
|
938 |
+
return t(
|
939 |
+
g(
|
940 |
+
RangeError,
|
941 |
+
"Max payload size exceeded",
|
942 |
+
!1,
|
943 |
+
1009,
|
944 |
+
"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"
|
945 |
+
)
|
946 |
+
);
|
947 |
+
this._fragments.push(n);
|
948 |
+
}
|
949 |
+
const o = this.dataMessage();
|
950 |
+
if (o)
|
951 |
+
return t(o);
|
952 |
+
this.startLoop(t);
|
953 |
+
});
|
954 |
+
}
|
955 |
+
/**
|
956 |
+
* Handles a data message.
|
957 |
+
*
|
958 |
+
* @return {(Error|undefined)} A possible error
|
959 |
+
* @private
|
960 |
+
*/
|
961 |
+
dataMessage() {
|
962 |
+
if (this._fin) {
|
963 |
+
const e = this._messageLength, t = this._fragments;
|
964 |
+
if (this._totalPayloadLength = 0, this._messageLength = 0, this._fragmented = 0, this._fragments = [], this._opcode === 2) {
|
965 |
+
let r;
|
966 |
+
this._binaryType === "nodebuffer" ? r = de(t, e) : this._binaryType === "arraybuffer" ? r = Vt(de(t, e)) : r = t, this.emit("message", r, !0);
|
967 |
+
} else {
|
968 |
+
const r = de(t, e);
|
969 |
+
if (!this._skipUTF8Validation && !Ue(r))
|
970 |
+
return this._loop = !1, g(
|
971 |
+
Error,
|
972 |
+
"invalid UTF-8 sequence",
|
973 |
+
!0,
|
974 |
+
1007,
|
975 |
+
"WS_ERR_INVALID_UTF8"
|
976 |
+
);
|
977 |
+
this.emit("message", r, !1);
|
978 |
+
}
|
979 |
+
}
|
980 |
+
this._state = A;
|
981 |
+
}
|
982 |
+
/**
|
983 |
+
* Handles a control message.
|
984 |
+
*
|
985 |
+
* @param {Buffer} data Data to handle
|
986 |
+
* @return {(Error|RangeError|undefined)} A possible error
|
987 |
+
* @private
|
988 |
+
*/
|
989 |
+
controlMessage(e) {
|
990 |
+
if (this._opcode === 8)
|
991 |
+
if (this._loop = !1, e.length === 0)
|
992 |
+
this.emit("conclude", 1005, Re), this.end();
|
993 |
+
else {
|
994 |
+
const t = e.readUInt16BE(0);
|
995 |
+
if (!zt(t))
|
996 |
+
return g(
|
997 |
+
RangeError,
|
998 |
+
`invalid status code ${t}`,
|
999 |
+
!0,
|
1000 |
+
1002,
|
1001 |
+
"WS_ERR_INVALID_CLOSE_CODE"
|
1002 |
+
);
|
1003 |
+
const r = new X(
|
1004 |
+
e.buffer,
|
1005 |
+
e.byteOffset + 2,
|
1006 |
+
e.length - 2
|
1007 |
+
);
|
1008 |
+
if (!this._skipUTF8Validation && !Ue(r))
|
1009 |
+
return g(
|
1010 |
+
Error,
|
1011 |
+
"invalid UTF-8 sequence",
|
1012 |
+
!0,
|
1013 |
+
1007,
|
1014 |
+
"WS_ERR_INVALID_UTF8"
|
1015 |
+
);
|
1016 |
+
this.emit("conclude", t, r), this.end();
|
1017 |
+
}
|
1018 |
+
else
|
1019 |
+
this._opcode === 9 ? this.emit("ping", e) : this.emit("pong", e);
|
1020 |
+
this._state = A;
|
1021 |
+
}
|
1022 |
+
};
|
1023 |
+
var rt = qt;
|
1024 |
+
function g(s, e, t, r, i) {
|
1025 |
+
const n = new s(
|
1026 |
+
t ? `Invalid WebSocket frame: ${e}` : e
|
1027 |
+
);
|
1028 |
+
return Error.captureStackTrace(n, g), n.code = i, n[jt] = r, n;
|
1029 |
+
}
|
1030 |
+
const qs = /* @__PURE__ */ z(rt), { randomFillSync: Kt } = S, Ie = oe, { EMPTY_BUFFER: Xt } = U, { isValidStatusCode: Zt } = ae, { mask: De, toBuffer: M } = ne, x = Symbol("kByteLength"), Qt = Buffer.alloc(4);
|
1031 |
+
let Jt = class P {
|
1032 |
+
/**
|
1033 |
+
* Creates a Sender instance.
|
1034 |
+
*
|
1035 |
+
* @param {(net.Socket|tls.Socket)} socket The connection socket
|
1036 |
+
* @param {Object} [extensions] An object containing the negotiated extensions
|
1037 |
+
* @param {Function} [generateMask] The function used to generate the masking
|
1038 |
+
* key
|
1039 |
+
*/
|
1040 |
+
constructor(e, t, r) {
|
1041 |
+
this._extensions = t || {}, r && (this._generateMask = r, this._maskBuffer = Buffer.alloc(4)), this._socket = e, this._firstFragment = !0, this._compress = !1, this._bufferedBytes = 0, this._deflating = !1, this._queue = [];
|
1042 |
+
}
|
1043 |
+
/**
|
1044 |
+
* Frames a piece of data according to the HyBi WebSocket protocol.
|
1045 |
+
*
|
1046 |
+
* @param {(Buffer|String)} data The data to frame
|
1047 |
+
* @param {Object} options Options object
|
1048 |
+
* @param {Boolean} [options.fin=false] Specifies whether or not to set the
|
1049 |
+
* FIN bit
|
1050 |
+
* @param {Function} [options.generateMask] The function used to generate the
|
1051 |
+
* masking key
|
1052 |
+
* @param {Boolean} [options.mask=false] Specifies whether or not to mask
|
1053 |
+
* `data`
|
1054 |
+
* @param {Buffer} [options.maskBuffer] The buffer used to store the masking
|
1055 |
+
* key
|
1056 |
+
* @param {Number} options.opcode The opcode
|
1057 |
+
* @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
|
1058 |
+
* modified
|
1059 |
+
* @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
|
1060 |
+
* RSV1 bit
|
1061 |
+
* @return {(Buffer|String)[]} The framed data
|
1062 |
+
* @public
|
1063 |
+
*/
|
1064 |
+
static frame(e, t) {
|
1065 |
+
let r, i = !1, n = 2, o = !1;
|
1066 |
+
t.mask && (r = t.maskBuffer || Qt, t.generateMask ? t.generateMask(r) : Kt(r, 0, 4), o = (r[0] | r[1] | r[2] | r[3]) === 0, n = 6);
|
1067 |
+
let l;
|
1068 |
+
typeof e == "string" ? (!t.mask || o) && t[x] !== void 0 ? l = t[x] : (e = Buffer.from(e), l = e.length) : (l = e.length, i = t.mask && t.readOnly && !o);
|
1069 |
+
let f = l;
|
1070 |
+
l >= 65536 ? (n += 8, f = 127) : l > 125 && (n += 2, f = 126);
|
1071 |
+
const a = Buffer.allocUnsafe(i ? l + n : n);
|
1072 |
+
return a[0] = t.fin ? t.opcode | 128 : t.opcode, t.rsv1 && (a[0] |= 64), a[1] = f, f === 126 ? a.writeUInt16BE(l, 2) : f === 127 && (a[2] = a[3] = 0, a.writeUIntBE(l, 4, 6)), t.mask ? (a[1] |= 128, a[n - 4] = r[0], a[n - 3] = r[1], a[n - 2] = r[2], a[n - 1] = r[3], o ? [a, e] : i ? (De(e, r, a, n, l), [a]) : (De(e, r, e, 0, l), [a, e])) : [a, e];
|
1073 |
+
}
|
1074 |
+
/**
|
1075 |
+
* Sends a close message to the other peer.
|
1076 |
+
*
|
1077 |
+
* @param {Number} [code] The status code component of the body
|
1078 |
+
* @param {(String|Buffer)} [data] The message component of the body
|
1079 |
+
* @param {Boolean} [mask=false] Specifies whether or not to mask the message
|
1080 |
+
* @param {Function} [cb] Callback
|
1081 |
+
* @public
|
1082 |
+
*/
|
1083 |
+
close(e, t, r, i) {
|
1084 |
+
let n;
|
1085 |
+
if (e === void 0)
|
1086 |
+
n = Xt;
|
1087 |
+
else {
|
1088 |
+
if (typeof e != "number" || !Zt(e))
|
1089 |
+
throw new TypeError("First argument must be a valid error code number");
|
1090 |
+
if (t === void 0 || !t.length)
|
1091 |
+
n = Buffer.allocUnsafe(2), n.writeUInt16BE(e, 0);
|
1092 |
+
else {
|
1093 |
+
const l = Buffer.byteLength(t);
|
1094 |
+
if (l > 123)
|
1095 |
+
throw new RangeError("The message must not be greater than 123 bytes");
|
1096 |
+
n = Buffer.allocUnsafe(2 + l), n.writeUInt16BE(e, 0), typeof t == "string" ? n.write(t, 2) : n.set(t, 2);
|
1097 |
+
}
|
1098 |
+
}
|
1099 |
+
const o = {
|
1100 |
+
[x]: n.length,
|
1101 |
+
fin: !0,
|
1102 |
+
generateMask: this._generateMask,
|
1103 |
+
mask: r,
|
1104 |
+
maskBuffer: this._maskBuffer,
|
1105 |
+
opcode: 8,
|
1106 |
+
readOnly: !1,
|
1107 |
+
rsv1: !1
|
1108 |
+
};
|
1109 |
+
this._deflating ? this.enqueue([this.dispatch, n, !1, o, i]) : this.sendFrame(P.frame(n, o), i);
|
1110 |
+
}
|
1111 |
+
/**
|
1112 |
+
* Sends a ping message to the other peer.
|
1113 |
+
*
|
1114 |
+
* @param {*} data The message to send
|
1115 |
+
* @param {Boolean} [mask=false] Specifies whether or not to mask `data`
|
1116 |
+
* @param {Function} [cb] Callback
|
1117 |
+
* @public
|
1118 |
+
*/
|
1119 |
+
ping(e, t, r) {
|
1120 |
+
let i, n;
|
1121 |
+
if (typeof e == "string" ? (i = Buffer.byteLength(e), n = !1) : (e = M(e), i = e.length, n = M.readOnly), i > 125)
|
1122 |
+
throw new RangeError("The data size must not be greater than 125 bytes");
|
1123 |
+
const o = {
|
1124 |
+
[x]: i,
|
1125 |
+
fin: !0,
|
1126 |
+
generateMask: this._generateMask,
|
1127 |
+
mask: t,
|
1128 |
+
maskBuffer: this._maskBuffer,
|
1129 |
+
opcode: 9,
|
1130 |
+
readOnly: n,
|
1131 |
+
rsv1: !1
|
1132 |
+
};
|
1133 |
+
this._deflating ? this.enqueue([this.dispatch, e, !1, o, r]) : this.sendFrame(P.frame(e, o), r);
|
1134 |
+
}
|
1135 |
+
/**
|
1136 |
+
* Sends a pong message to the other peer.
|
1137 |
+
*
|
1138 |
+
* @param {*} data The message to send
|
1139 |
+
* @param {Boolean} [mask=false] Specifies whether or not to mask `data`
|
1140 |
+
* @param {Function} [cb] Callback
|
1141 |
+
* @public
|
1142 |
+
*/
|
1143 |
+
pong(e, t, r) {
|
1144 |
+
let i, n;
|
1145 |
+
if (typeof e == "string" ? (i = Buffer.byteLength(e), n = !1) : (e = M(e), i = e.length, n = M.readOnly), i > 125)
|
1146 |
+
throw new RangeError("The data size must not be greater than 125 bytes");
|
1147 |
+
const o = {
|
1148 |
+
[x]: i,
|
1149 |
+
fin: !0,
|
1150 |
+
generateMask: this._generateMask,
|
1151 |
+
mask: t,
|
1152 |
+
maskBuffer: this._maskBuffer,
|
1153 |
+
opcode: 10,
|
1154 |
+
readOnly: n,
|
1155 |
+
rsv1: !1
|
1156 |
+
};
|
1157 |
+
this._deflating ? this.enqueue([this.dispatch, e, !1, o, r]) : this.sendFrame(P.frame(e, o), r);
|
1158 |
+
}
|
1159 |
+
/**
|
1160 |
+
* Sends a data message to the other peer.
|
1161 |
+
*
|
1162 |
+
* @param {*} data The message to send
|
1163 |
+
* @param {Object} options Options object
|
1164 |
+
* @param {Boolean} [options.binary=false] Specifies whether `data` is binary
|
1165 |
+
* or text
|
1166 |
+
* @param {Boolean} [options.compress=false] Specifies whether or not to
|
1167 |
+
* compress `data`
|
1168 |
+
* @param {Boolean} [options.fin=false] Specifies whether the fragment is the
|
1169 |
+
* last one
|
1170 |
+
* @param {Boolean} [options.mask=false] Specifies whether or not to mask
|
1171 |
+
* `data`
|
1172 |
+
* @param {Function} [cb] Callback
|
1173 |
+
* @public
|
1174 |
+
*/
|
1175 |
+
send(e, t, r) {
|
1176 |
+
const i = this._extensions[Ie.extensionName];
|
1177 |
+
let n = t.binary ? 2 : 1, o = t.compress, l, f;
|
1178 |
+
if (typeof e == "string" ? (l = Buffer.byteLength(e), f = !1) : (e = M(e), l = e.length, f = M.readOnly), this._firstFragment ? (this._firstFragment = !1, o && i && i.params[i._isServer ? "server_no_context_takeover" : "client_no_context_takeover"] && (o = l >= i._threshold), this._compress = o) : (o = !1, n = 0), t.fin && (this._firstFragment = !0), i) {
|
1179 |
+
const a = {
|
1180 |
+
[x]: l,
|
1181 |
+
fin: t.fin,
|
1182 |
+
generateMask: this._generateMask,
|
1183 |
+
mask: t.mask,
|
1184 |
+
maskBuffer: this._maskBuffer,
|
1185 |
+
opcode: n,
|
1186 |
+
readOnly: f,
|
1187 |
+
rsv1: o
|
1188 |
+
};
|
1189 |
+
this._deflating ? this.enqueue([this.dispatch, e, this._compress, a, r]) : this.dispatch(e, this._compress, a, r);
|
1190 |
+
} else
|
1191 |
+
this.sendFrame(
|
1192 |
+
P.frame(e, {
|
1193 |
+
[x]: l,
|
1194 |
+
fin: t.fin,
|
1195 |
+
generateMask: this._generateMask,
|
1196 |
+
mask: t.mask,
|
1197 |
+
maskBuffer: this._maskBuffer,
|
1198 |
+
opcode: n,
|
1199 |
+
readOnly: f,
|
1200 |
+
rsv1: !1
|
1201 |
+
}),
|
1202 |
+
r
|
1203 |
+
);
|
1204 |
+
}
|
1205 |
+
/**
|
1206 |
+
* Dispatches a message.
|
1207 |
+
*
|
1208 |
+
* @param {(Buffer|String)} data The message to send
|
1209 |
+
* @param {Boolean} [compress=false] Specifies whether or not to compress
|
1210 |
+
* `data`
|
1211 |
+
* @param {Object} options Options object
|
1212 |
+
* @param {Boolean} [options.fin=false] Specifies whether or not to set the
|
1213 |
+
* FIN bit
|
1214 |
+
* @param {Function} [options.generateMask] The function used to generate the
|
1215 |
+
* masking key
|
1216 |
+
* @param {Boolean} [options.mask=false] Specifies whether or not to mask
|
1217 |
+
* `data`
|
1218 |
+
* @param {Buffer} [options.maskBuffer] The buffer used to store the masking
|
1219 |
+
* key
|
1220 |
+
* @param {Number} options.opcode The opcode
|
1221 |
+
* @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
|
1222 |
+
* modified
|
1223 |
+
* @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
|
1224 |
+
* RSV1 bit
|
1225 |
+
* @param {Function} [cb] Callback
|
1226 |
+
* @private
|
1227 |
+
*/
|
1228 |
+
dispatch(e, t, r, i) {
|
1229 |
+
if (!t) {
|
1230 |
+
this.sendFrame(P.frame(e, r), i);
|
1231 |
+
return;
|
1232 |
+
}
|
1233 |
+
const n = this._extensions[Ie.extensionName];
|
1234 |
+
this._bufferedBytes += r[x], this._deflating = !0, n.compress(e, r.fin, (o, l) => {
|
1235 |
+
if (this._socket.destroyed) {
|
1236 |
+
const f = new Error(
|
1237 |
+
"The socket was closed while data was being compressed"
|
1238 |
+
);
|
1239 |
+
typeof i == "function" && i(f);
|
1240 |
+
for (let a = 0; a < this._queue.length; a++) {
|
1241 |
+
const c = this._queue[a], h = c[c.length - 1];
|
1242 |
+
typeof h == "function" && h(f);
|
1243 |
+
}
|
1244 |
+
return;
|
1245 |
+
}
|
1246 |
+
this._bufferedBytes -= r[x], this._deflating = !1, r.readOnly = !1, this.sendFrame(P.frame(l, r), i), this.dequeue();
|
1247 |
+
});
|
1248 |
+
}
|
1249 |
+
/**
|
1250 |
+
* Executes queued send operations.
|
1251 |
+
*
|
1252 |
+
* @private
|
1253 |
+
*/
|
1254 |
+
dequeue() {
|
1255 |
+
for (; !this._deflating && this._queue.length; ) {
|
1256 |
+
const e = this._queue.shift();
|
1257 |
+
this._bufferedBytes -= e[3][x], Reflect.apply(e[0], this, e.slice(1));
|
1258 |
+
}
|
1259 |
+
}
|
1260 |
+
/**
|
1261 |
+
* Enqueues a send operation.
|
1262 |
+
*
|
1263 |
+
* @param {Array} params Send operation parameters.
|
1264 |
+
* @private
|
1265 |
+
*/
|
1266 |
+
enqueue(e) {
|
1267 |
+
this._bufferedBytes += e[3][x], this._queue.push(e);
|
1268 |
+
}
|
1269 |
+
/**
|
1270 |
+
* Sends a frame.
|
1271 |
+
*
|
1272 |
+
* @param {Buffer[]} list The frame to send
|
1273 |
+
* @param {Function} [cb] Callback
|
1274 |
+
* @private
|
1275 |
+
*/
|
1276 |
+
sendFrame(e, t) {
|
1277 |
+
e.length === 2 ? (this._socket.cork(), this._socket.write(e[0]), this._socket.write(e[1], t), this._socket.uncork()) : this._socket.write(e[0], t);
|
1278 |
+
}
|
1279 |
+
};
|
1280 |
+
var it = Jt;
|
1281 |
+
const Ks = /* @__PURE__ */ z(it), { kForOnEventAttribute: F, kListener: pe } = U, We = Symbol("kCode"), Ae = Symbol("kData"), Fe = Symbol("kError"), je = Symbol("kMessage"), Ge = Symbol("kReason"), I = Symbol("kTarget"), Ve = Symbol("kType"), He = Symbol("kWasClean");
|
1282 |
+
class B {
|
1283 |
+
/**
|
1284 |
+
* Create a new `Event`.
|
1285 |
+
*
|
1286 |
+
* @param {String} type The name of the event
|
1287 |
+
* @throws {TypeError} If the `type` argument is not specified
|
1288 |
+
*/
|
1289 |
+
constructor(e) {
|
1290 |
+
this[I] = null, this[Ve] = e;
|
1291 |
+
}
|
1292 |
+
/**
|
1293 |
+
* @type {*}
|
1294 |
+
*/
|
1295 |
+
get target() {
|
1296 |
+
return this[I];
|
1297 |
+
}
|
1298 |
+
/**
|
1299 |
+
* @type {String}
|
1300 |
+
*/
|
1301 |
+
get type() {
|
1302 |
+
return this[Ve];
|
1303 |
+
}
|
1304 |
+
}
|
1305 |
+
Object.defineProperty(B.prototype, "target", { enumerable: !0 });
|
1306 |
+
Object.defineProperty(B.prototype, "type", { enumerable: !0 });
|
1307 |
+
class Y extends B {
|
1308 |
+
/**
|
1309 |
+
* Create a new `CloseEvent`.
|
1310 |
+
*
|
1311 |
+
* @param {String} type The name of the event
|
1312 |
+
* @param {Object} [options] A dictionary object that allows for setting
|
1313 |
+
* attributes via object members of the same name
|
1314 |
+
* @param {Number} [options.code=0] The status code explaining why the
|
1315 |
+
* connection was closed
|
1316 |
+
* @param {String} [options.reason=''] A human-readable string explaining why
|
1317 |
+
* the connection was closed
|
1318 |
+
* @param {Boolean} [options.wasClean=false] Indicates whether or not the
|
1319 |
+
* connection was cleanly closed
|
1320 |
+
*/
|
1321 |
+
constructor(e, t = {}) {
|
1322 |
+
super(e), this[We] = t.code === void 0 ? 0 : t.code, this[Ge] = t.reason === void 0 ? "" : t.reason, this[He] = t.wasClean === void 0 ? !1 : t.wasClean;
|
1323 |
+
}
|
1324 |
+
/**
|
1325 |
+
* @type {Number}
|
1326 |
+
*/
|
1327 |
+
get code() {
|
1328 |
+
return this[We];
|
1329 |
+
}
|
1330 |
+
/**
|
1331 |
+
* @type {String}
|
1332 |
+
*/
|
1333 |
+
get reason() {
|
1334 |
+
return this[Ge];
|
1335 |
+
}
|
1336 |
+
/**
|
1337 |
+
* @type {Boolean}
|
1338 |
+
*/
|
1339 |
+
get wasClean() {
|
1340 |
+
return this[He];
|
1341 |
+
}
|
1342 |
+
}
|
1343 |
+
Object.defineProperty(Y.prototype, "code", { enumerable: !0 });
|
1344 |
+
Object.defineProperty(Y.prototype, "reason", { enumerable: !0 });
|
1345 |
+
Object.defineProperty(Y.prototype, "wasClean", { enumerable: !0 });
|
1346 |
+
class le extends B {
|
1347 |
+
/**
|
1348 |
+
* Create a new `ErrorEvent`.
|
1349 |
+
*
|
1350 |
+
* @param {String} type The name of the event
|
1351 |
+
* @param {Object} [options] A dictionary object that allows for setting
|
1352 |
+
* attributes via object members of the same name
|
1353 |
+
* @param {*} [options.error=null] The error that generated this event
|
1354 |
+
* @param {String} [options.message=''] The error message
|
1355 |
+
*/
|
1356 |
+
constructor(e, t = {}) {
|
1357 |
+
super(e), this[Fe] = t.error === void 0 ? null : t.error, this[je] = t.message === void 0 ? "" : t.message;
|
1358 |
+
}
|
1359 |
+
/**
|
1360 |
+
* @type {*}
|
1361 |
+
*/
|
1362 |
+
get error() {
|
1363 |
+
return this[Fe];
|
1364 |
+
}
|
1365 |
+
/**
|
1366 |
+
* @type {String}
|
1367 |
+
*/
|
1368 |
+
get message() {
|
1369 |
+
return this[je];
|
1370 |
+
}
|
1371 |
+
}
|
1372 |
+
Object.defineProperty(le.prototype, "error", { enumerable: !0 });
|
1373 |
+
Object.defineProperty(le.prototype, "message", { enumerable: !0 });
|
1374 |
+
class xe extends B {
|
1375 |
+
/**
|
1376 |
+
* Create a new `MessageEvent`.
|
1377 |
+
*
|
1378 |
+
* @param {String} type The name of the event
|
1379 |
+
* @param {Object} [options] A dictionary object that allows for setting
|
1380 |
+
* attributes via object members of the same name
|
1381 |
+
* @param {*} [options.data=null] The message content
|
1382 |
+
*/
|
1383 |
+
constructor(e, t = {}) {
|
1384 |
+
super(e), this[Ae] = t.data === void 0 ? null : t.data;
|
1385 |
+
}
|
1386 |
+
/**
|
1387 |
+
* @type {*}
|
1388 |
+
*/
|
1389 |
+
get data() {
|
1390 |
+
return this[Ae];
|
1391 |
+
}
|
1392 |
+
}
|
1393 |
+
Object.defineProperty(xe.prototype, "data", { enumerable: !0 });
|
1394 |
+
const es = {
|
1395 |
+
/**
|
1396 |
+
* Register an event listener.
|
1397 |
+
*
|
1398 |
+
* @param {String} type A string representing the event type to listen for
|
1399 |
+
* @param {(Function|Object)} handler The listener to add
|
1400 |
+
* @param {Object} [options] An options object specifies characteristics about
|
1401 |
+
* the event listener
|
1402 |
+
* @param {Boolean} [options.once=false] A `Boolean` indicating that the
|
1403 |
+
* listener should be invoked at most once after being added. If `true`,
|
1404 |
+
* the listener would be automatically removed when invoked.
|
1405 |
+
* @public
|
1406 |
+
*/
|
1407 |
+
addEventListener(s, e, t = {}) {
|
1408 |
+
for (const i of this.listeners(s))
|
1409 |
+
if (!t[F] && i[pe] === e && !i[F])
|
1410 |
+
return;
|
1411 |
+
let r;
|
1412 |
+
if (s === "message")
|
1413 |
+
r = function(n, o) {
|
1414 |
+
const l = new xe("message", {
|
1415 |
+
data: o ? n : n.toString()
|
1416 |
+
});
|
1417 |
+
l[I] = this, Z(e, this, l);
|
1418 |
+
};
|
1419 |
+
else if (s === "close")
|
1420 |
+
r = function(n, o) {
|
1421 |
+
const l = new Y("close", {
|
1422 |
+
code: n,
|
1423 |
+
reason: o.toString(),
|
1424 |
+
wasClean: this._closeFrameReceived && this._closeFrameSent
|
1425 |
+
});
|
1426 |
+
l[I] = this, Z(e, this, l);
|
1427 |
+
};
|
1428 |
+
else if (s === "error")
|
1429 |
+
r = function(n) {
|
1430 |
+
const o = new le("error", {
|
1431 |
+
error: n,
|
1432 |
+
message: n.message
|
1433 |
+
});
|
1434 |
+
o[I] = this, Z(e, this, o);
|
1435 |
+
};
|
1436 |
+
else if (s === "open")
|
1437 |
+
r = function() {
|
1438 |
+
const n = new B("open");
|
1439 |
+
n[I] = this, Z(e, this, n);
|
1440 |
+
};
|
1441 |
+
else
|
1442 |
+
return;
|
1443 |
+
r[F] = !!t[F], r[pe] = e, t.once ? this.once(s, r) : this.on(s, r);
|
1444 |
+
},
|
1445 |
+
/**
|
1446 |
+
* Remove an event listener.
|
1447 |
+
*
|
1448 |
+
* @param {String} type A string representing the event type to remove
|
1449 |
+
* @param {(Function|Object)} handler The listener to remove
|
1450 |
+
* @public
|
1451 |
+
*/
|
1452 |
+
removeEventListener(s, e) {
|
1453 |
+
for (const t of this.listeners(s))
|
1454 |
+
if (t[pe] === e && !t[F]) {
|
1455 |
+
this.removeListener(s, t);
|
1456 |
+
break;
|
1457 |
+
}
|
1458 |
+
}
|
1459 |
+
};
|
1460 |
+
var ts = {
|
1461 |
+
CloseEvent: Y,
|
1462 |
+
ErrorEvent: le,
|
1463 |
+
Event: B,
|
1464 |
+
EventTarget: es,
|
1465 |
+
MessageEvent: xe
|
1466 |
+
};
|
1467 |
+
function Z(s, e, t) {
|
1468 |
+
typeof s == "object" && s.handleEvent ? s.handleEvent.call(s, t) : s.call(e, t);
|
1469 |
+
}
|
1470 |
+
const { tokenChars: j } = ae;
|
1471 |
+
function k(s, e, t) {
|
1472 |
+
s[e] === void 0 ? s[e] = [t] : s[e].push(t);
|
1473 |
+
}
|
1474 |
+
function ss(s) {
|
1475 |
+
const e = /* @__PURE__ */ Object.create(null);
|
1476 |
+
let t = /* @__PURE__ */ Object.create(null), r = !1, i = !1, n = !1, o, l, f = -1, a = -1, c = -1, h = 0;
|
1477 |
+
for (; h < s.length; h++)
|
1478 |
+
if (a = s.charCodeAt(h), o === void 0)
|
1479 |
+
if (c === -1 && j[a] === 1)
|
1480 |
+
f === -1 && (f = h);
|
1481 |
+
else if (h !== 0 && (a === 32 || a === 9))
|
1482 |
+
c === -1 && f !== -1 && (c = h);
|
1483 |
+
else if (a === 59 || a === 44) {
|
1484 |
+
if (f === -1)
|
1485 |
+
throw new SyntaxError(`Unexpected character at index ${h}`);
|
1486 |
+
c === -1 && (c = h);
|
1487 |
+
const v = s.slice(f, c);
|
1488 |
+
a === 44 ? (k(e, v, t), t = /* @__PURE__ */ Object.create(null)) : o = v, f = c = -1;
|
1489 |
+
} else
|
1490 |
+
throw new SyntaxError(`Unexpected character at index ${h}`);
|
1491 |
+
else if (l === void 0)
|
1492 |
+
if (c === -1 && j[a] === 1)
|
1493 |
+
f === -1 && (f = h);
|
1494 |
+
else if (a === 32 || a === 9)
|
1495 |
+
c === -1 && f !== -1 && (c = h);
|
1496 |
+
else if (a === 59 || a === 44) {
|
1497 |
+
if (f === -1)
|
1498 |
+
throw new SyntaxError(`Unexpected character at index ${h}`);
|
1499 |
+
c === -1 && (c = h), k(t, s.slice(f, c), !0), a === 44 && (k(e, o, t), t = /* @__PURE__ */ Object.create(null), o = void 0), f = c = -1;
|
1500 |
+
} else if (a === 61 && f !== -1 && c === -1)
|
1501 |
+
l = s.slice(f, h), f = c = -1;
|
1502 |
+
else
|
1503 |
+
throw new SyntaxError(`Unexpected character at index ${h}`);
|
1504 |
+
else if (i) {
|
1505 |
+
if (j[a] !== 1)
|
1506 |
+
throw new SyntaxError(`Unexpected character at index ${h}`);
|
1507 |
+
f === -1 ? f = h : r || (r = !0), i = !1;
|
1508 |
+
} else if (n)
|
1509 |
+
if (j[a] === 1)
|
1510 |
+
f === -1 && (f = h);
|
1511 |
+
else if (a === 34 && f !== -1)
|
1512 |
+
n = !1, c = h;
|
1513 |
+
else if (a === 92)
|
1514 |
+
i = !0;
|
1515 |
+
else
|
1516 |
+
throw new SyntaxError(`Unexpected character at index ${h}`);
|
1517 |
+
else if (a === 34 && s.charCodeAt(h - 1) === 61)
|
1518 |
+
n = !0;
|
1519 |
+
else if (c === -1 && j[a] === 1)
|
1520 |
+
f === -1 && (f = h);
|
1521 |
+
else if (f !== -1 && (a === 32 || a === 9))
|
1522 |
+
c === -1 && (c = h);
|
1523 |
+
else if (a === 59 || a === 44) {
|
1524 |
+
if (f === -1)
|
1525 |
+
throw new SyntaxError(`Unexpected character at index ${h}`);
|
1526 |
+
c === -1 && (c = h);
|
1527 |
+
let v = s.slice(f, c);
|
1528 |
+
r && (v = v.replace(/\\/g, ""), r = !1), k(t, l, v), a === 44 && (k(e, o, t), t = /* @__PURE__ */ Object.create(null), o = void 0), l = void 0, f = c = -1;
|
1529 |
+
} else
|
1530 |
+
throw new SyntaxError(`Unexpected character at index ${h}`);
|
1531 |
+
if (f === -1 || n || a === 32 || a === 9)
|
1532 |
+
throw new SyntaxError("Unexpected end of input");
|
1533 |
+
c === -1 && (c = h);
|
1534 |
+
const p = s.slice(f, c);
|
1535 |
+
return o === void 0 ? k(e, p, t) : (l === void 0 ? k(t, p, !0) : r ? k(t, l, p.replace(/\\/g, "")) : k(t, l, p), k(e, o, t)), e;
|
1536 |
+
}
|
1537 |
+
function rs(s) {
|
1538 |
+
return Object.keys(s).map((e) => {
|
1539 |
+
let t = s[e];
|
1540 |
+
return Array.isArray(t) || (t = [t]), t.map((r) => [e].concat(
|
1541 |
+
Object.keys(r).map((i) => {
|
1542 |
+
let n = r[i];
|
1543 |
+
return Array.isArray(n) || (n = [n]), n.map((o) => o === !0 ? i : `${i}=${o}`).join("; ");
|
1544 |
+
})
|
1545 |
+
).join("; ")).join(", ");
|
1546 |
+
}).join(", ");
|
1547 |
+
}
|
1548 |
+
var nt = { format: rs, parse: ss };
|
1549 |
+
const is = S, ns = S, os = S, ot = S, as = S, { randomBytes: ls, createHash: fs } = S, { URL: me } = S, T = oe, hs = rt, cs = it, {
|
1550 |
+
BINARY_TYPES: ze,
|
1551 |
+
EMPTY_BUFFER: Q,
|
1552 |
+
GUID: us,
|
1553 |
+
kForOnEventAttribute: ge,
|
1554 |
+
kListener: ds,
|
1555 |
+
kStatusCode: _s,
|
1556 |
+
kWebSocket: y,
|
1557 |
+
NOOP: at
|
1558 |
+
} = U, {
|
1559 |
+
EventTarget: { addEventListener: ps, removeEventListener: ms }
|
1560 |
+
} = ts, { format: gs, parse: ys } = nt, { toBuffer: vs } = ne, Ss = 30 * 1e3, lt = Symbol("kAborted"), ye = [8, 13], O = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"], Es = /^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;
|
1561 |
+
let m = class d extends is {
|
1562 |
+
/**
|
1563 |
+
* Create a new `WebSocket`.
|
1564 |
+
*
|
1565 |
+
* @param {(String|URL)} address The URL to which to connect
|
1566 |
+
* @param {(String|String[])} [protocols] The subprotocols
|
1567 |
+
* @param {Object} [options] Connection options
|
1568 |
+
*/
|
1569 |
+
constructor(e, t, r) {
|
1570 |
+
super(), this._binaryType = ze[0], this._closeCode = 1006, this._closeFrameReceived = !1, this._closeFrameSent = !1, this._closeMessage = Q, this._closeTimer = null, this._extensions = {}, this._paused = !1, this._protocol = "", this._readyState = d.CONNECTING, this._receiver = null, this._sender = null, this._socket = null, e !== null ? (this._bufferedAmount = 0, this._isServer = !1, this._redirects = 0, t === void 0 ? t = [] : Array.isArray(t) || (typeof t == "object" && t !== null ? (r = t, t = []) : t = [t]), ht(this, e, t, r)) : this._isServer = !0;
|
1571 |
+
}
|
1572 |
+
/**
|
1573 |
+
* This deviates from the WHATWG interface since ws doesn't support the
|
1574 |
+
* required default "blob" type (instead we define a custom "nodebuffer"
|
1575 |
+
* type).
|
1576 |
+
*
|
1577 |
+
* @type {String}
|
1578 |
+
*/
|
1579 |
+
get binaryType() {
|
1580 |
+
return this._binaryType;
|
1581 |
+
}
|
1582 |
+
set binaryType(e) {
|
1583 |
+
ze.includes(e) && (this._binaryType = e, this._receiver && (this._receiver._binaryType = e));
|
1584 |
+
}
|
1585 |
+
/**
|
1586 |
+
* @type {Number}
|
1587 |
+
*/
|
1588 |
+
get bufferedAmount() {
|
1589 |
+
return this._socket ? this._socket._writableState.length + this._sender._bufferedBytes : this._bufferedAmount;
|
1590 |
+
}
|
1591 |
+
/**
|
1592 |
+
* @type {String}
|
1593 |
+
*/
|
1594 |
+
get extensions() {
|
1595 |
+
return Object.keys(this._extensions).join();
|
1596 |
+
}
|
1597 |
+
/**
|
1598 |
+
* @type {Boolean}
|
1599 |
+
*/
|
1600 |
+
get isPaused() {
|
1601 |
+
return this._paused;
|
1602 |
+
}
|
1603 |
+
/**
|
1604 |
+
* @type {Function}
|
1605 |
+
*/
|
1606 |
+
/* istanbul ignore next */
|
1607 |
+
get onclose() {
|
1608 |
+
return null;
|
1609 |
+
}
|
1610 |
+
/**
|
1611 |
+
* @type {Function}
|
1612 |
+
*/
|
1613 |
+
/* istanbul ignore next */
|
1614 |
+
get onerror() {
|
1615 |
+
return null;
|
1616 |
+
}
|
1617 |
+
/**
|
1618 |
+
* @type {Function}
|
1619 |
+
*/
|
1620 |
+
/* istanbul ignore next */
|
1621 |
+
get onopen() {
|
1622 |
+
return null;
|
1623 |
+
}
|
1624 |
+
/**
|
1625 |
+
* @type {Function}
|
1626 |
+
*/
|
1627 |
+
/* istanbul ignore next */
|
1628 |
+
get onmessage() {
|
1629 |
+
return null;
|
1630 |
+
}
|
1631 |
+
/**
|
1632 |
+
* @type {String}
|
1633 |
+
*/
|
1634 |
+
get protocol() {
|
1635 |
+
return this._protocol;
|
1636 |
+
}
|
1637 |
+
/**
|
1638 |
+
* @type {Number}
|
1639 |
+
*/
|
1640 |
+
get readyState() {
|
1641 |
+
return this._readyState;
|
1642 |
+
}
|
1643 |
+
/**
|
1644 |
+
* @type {String}
|
1645 |
+
*/
|
1646 |
+
get url() {
|
1647 |
+
return this._url;
|
1648 |
+
}
|
1649 |
+
/**
|
1650 |
+
* Set up the socket and the internal resources.
|
1651 |
+
*
|
1652 |
+
* @param {(net.Socket|tls.Socket)} socket The network socket between the
|
1653 |
+
* server and client
|
1654 |
+
* @param {Buffer} head The first packet of the upgraded stream
|
1655 |
+
* @param {Object} options Options object
|
1656 |
+
* @param {Function} [options.generateMask] The function used to generate the
|
1657 |
+
* masking key
|
1658 |
+
* @param {Number} [options.maxPayload=0] The maximum allowed message size
|
1659 |
+
* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
|
1660 |
+
* not to skip UTF-8 validation for text and close messages
|
1661 |
+
* @private
|
1662 |
+
*/
|
1663 |
+
setSocket(e, t, r) {
|
1664 |
+
const i = new hs({
|
1665 |
+
binaryType: this.binaryType,
|
1666 |
+
extensions: this._extensions,
|
1667 |
+
isServer: this._isServer,
|
1668 |
+
maxPayload: r.maxPayload,
|
1669 |
+
skipUTF8Validation: r.skipUTF8Validation
|
1670 |
+
});
|
1671 |
+
this._sender = new cs(e, this._extensions, r.generateMask), this._receiver = i, this._socket = e, i[y] = this, e[y] = this, i.on("conclude", ks), i.on("drain", ws), i.on("error", Os), i.on("message", Cs), i.on("ping", Ts), i.on("pong", Ls), e.setTimeout(0), e.setNoDelay(), t.length > 0 && e.unshift(t), e.on("close", ut), e.on("data", fe), e.on("end", dt), e.on("error", _t), this._readyState = d.OPEN, this.emit("open");
|
1672 |
+
}
|
1673 |
+
/**
|
1674 |
+
* Emit the `'close'` event.
|
1675 |
+
*
|
1676 |
+
* @private
|
1677 |
+
*/
|
1678 |
+
emitClose() {
|
1679 |
+
if (!this._socket) {
|
1680 |
+
this._readyState = d.CLOSED, this.emit("close", this._closeCode, this._closeMessage);
|
1681 |
+
return;
|
1682 |
+
}
|
1683 |
+
this._extensions[T.extensionName] && this._extensions[T.extensionName].cleanup(), this._receiver.removeAllListeners(), this._readyState = d.CLOSED, this.emit("close", this._closeCode, this._closeMessage);
|
1684 |
+
}
|
1685 |
+
/**
|
1686 |
+
* Start a closing handshake.
|
1687 |
+
*
|
1688 |
+
* +----------+ +-----------+ +----------+
|
1689 |
+
* - - -|ws.close()|-->|close frame|-->|ws.close()|- - -
|
1690 |
+
* | +----------+ +-----------+ +----------+ |
|
1691 |
+
* +----------+ +-----------+ |
|
1692 |
+
* CLOSING |ws.close()|<--|close frame|<--+-----+ CLOSING
|
1693 |
+
* +----------+ +-----------+ |
|
1694 |
+
* | | | +---+ |
|
1695 |
+
* +------------------------+-->|fin| - - - -
|
1696 |
+
* | +---+ | +---+
|
1697 |
+
* - - - - -|fin|<---------------------+
|
1698 |
+
* +---+
|
1699 |
+
*
|
1700 |
+
* @param {Number} [code] Status code explaining why the connection is closing
|
1701 |
+
* @param {(String|Buffer)} [data] The reason why the connection is
|
1702 |
+
* closing
|
1703 |
+
* @public
|
1704 |
+
*/
|
1705 |
+
close(e, t) {
|
1706 |
+
if (this.readyState !== d.CLOSED) {
|
1707 |
+
if (this.readyState === d.CONNECTING) {
|
1708 |
+
const r = "WebSocket was closed before the connection was established";
|
1709 |
+
b(this, this._req, r);
|
1710 |
+
return;
|
1711 |
+
}
|
1712 |
+
if (this.readyState === d.CLOSING) {
|
1713 |
+
this._closeFrameSent && (this._closeFrameReceived || this._receiver._writableState.errorEmitted) && this._socket.end();
|
1714 |
+
return;
|
1715 |
+
}
|
1716 |
+
this._readyState = d.CLOSING, this._sender.close(e, t, !this._isServer, (r) => {
|
1717 |
+
r || (this._closeFrameSent = !0, (this._closeFrameReceived || this._receiver._writableState.errorEmitted) && this._socket.end());
|
1718 |
+
}), this._closeTimer = setTimeout(
|
1719 |
+
this._socket.destroy.bind(this._socket),
|
1720 |
+
Ss
|
1721 |
+
);
|
1722 |
+
}
|
1723 |
+
}
|
1724 |
+
/**
|
1725 |
+
* Pause the socket.
|
1726 |
+
*
|
1727 |
+
* @public
|
1728 |
+
*/
|
1729 |
+
pause() {
|
1730 |
+
this.readyState === d.CONNECTING || this.readyState === d.CLOSED || (this._paused = !0, this._socket.pause());
|
1731 |
+
}
|
1732 |
+
/**
|
1733 |
+
* Send a ping.
|
1734 |
+
*
|
1735 |
+
* @param {*} [data] The data to send
|
1736 |
+
* @param {Boolean} [mask] Indicates whether or not to mask `data`
|
1737 |
+
* @param {Function} [cb] Callback which is executed when the ping is sent
|
1738 |
+
* @public
|
1739 |
+
*/
|
1740 |
+
ping(e, t, r) {
|
1741 |
+
if (this.readyState === d.CONNECTING)
|
1742 |
+
throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
|
1743 |
+
if (typeof e == "function" ? (r = e, e = t = void 0) : typeof t == "function" && (r = t, t = void 0), typeof e == "number" && (e = e.toString()), this.readyState !== d.OPEN) {
|
1744 |
+
ve(this, e, r);
|
1745 |
+
return;
|
1746 |
+
}
|
1747 |
+
t === void 0 && (t = !this._isServer), this._sender.ping(e || Q, t, r);
|
1748 |
+
}
|
1749 |
+
/**
|
1750 |
+
* Send a pong.
|
1751 |
+
*
|
1752 |
+
* @param {*} [data] The data to send
|
1753 |
+
* @param {Boolean} [mask] Indicates whether or not to mask `data`
|
1754 |
+
* @param {Function} [cb] Callback which is executed when the pong is sent
|
1755 |
+
* @public
|
1756 |
+
*/
|
1757 |
+
pong(e, t, r) {
|
1758 |
+
if (this.readyState === d.CONNECTING)
|
1759 |
+
throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
|
1760 |
+
if (typeof e == "function" ? (r = e, e = t = void 0) : typeof t == "function" && (r = t, t = void 0), typeof e == "number" && (e = e.toString()), this.readyState !== d.OPEN) {
|
1761 |
+
ve(this, e, r);
|
1762 |
+
return;
|
1763 |
+
}
|
1764 |
+
t === void 0 && (t = !this._isServer), this._sender.pong(e || Q, t, r);
|
1765 |
+
}
|
1766 |
+
/**
|
1767 |
+
* Resume the socket.
|
1768 |
+
*
|
1769 |
+
* @public
|
1770 |
+
*/
|
1771 |
+
resume() {
|
1772 |
+
this.readyState === d.CONNECTING || this.readyState === d.CLOSED || (this._paused = !1, this._receiver._writableState.needDrain || this._socket.resume());
|
1773 |
+
}
|
1774 |
+
/**
|
1775 |
+
* Send a data message.
|
1776 |
+
*
|
1777 |
+
* @param {*} data The message to send
|
1778 |
+
* @param {Object} [options] Options object
|
1779 |
+
* @param {Boolean} [options.binary] Specifies whether `data` is binary or
|
1780 |
+
* text
|
1781 |
+
* @param {Boolean} [options.compress] Specifies whether or not to compress
|
1782 |
+
* `data`
|
1783 |
+
* @param {Boolean} [options.fin=true] Specifies whether the fragment is the
|
1784 |
+
* last one
|
1785 |
+
* @param {Boolean} [options.mask] Specifies whether or not to mask `data`
|
1786 |
+
* @param {Function} [cb] Callback which is executed when data is written out
|
1787 |
+
* @public
|
1788 |
+
*/
|
1789 |
+
send(e, t, r) {
|
1790 |
+
if (this.readyState === d.CONNECTING)
|
1791 |
+
throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
|
1792 |
+
if (typeof t == "function" && (r = t, t = {}), typeof e == "number" && (e = e.toString()), this.readyState !== d.OPEN) {
|
1793 |
+
ve(this, e, r);
|
1794 |
+
return;
|
1795 |
+
}
|
1796 |
+
const i = {
|
1797 |
+
binary: typeof e != "string",
|
1798 |
+
mask: !this._isServer,
|
1799 |
+
compress: !0,
|
1800 |
+
fin: !0,
|
1801 |
+
...t
|
1802 |
+
};
|
1803 |
+
this._extensions[T.extensionName] || (i.compress = !1), this._sender.send(e || Q, i, r);
|
1804 |
+
}
|
1805 |
+
/**
|
1806 |
+
* Forcibly close the connection.
|
1807 |
+
*
|
1808 |
+
* @public
|
1809 |
+
*/
|
1810 |
+
terminate() {
|
1811 |
+
if (this.readyState !== d.CLOSED) {
|
1812 |
+
if (this.readyState === d.CONNECTING) {
|
1813 |
+
const e = "WebSocket was closed before the connection was established";
|
1814 |
+
b(this, this._req, e);
|
1815 |
+
return;
|
1816 |
+
}
|
1817 |
+
this._socket && (this._readyState = d.CLOSING, this._socket.destroy());
|
1818 |
+
}
|
1819 |
+
}
|
1820 |
+
};
|
1821 |
+
Object.defineProperty(m, "CONNECTING", {
|
1822 |
+
enumerable: !0,
|
1823 |
+
value: O.indexOf("CONNECTING")
|
1824 |
+
});
|
1825 |
+
Object.defineProperty(m.prototype, "CONNECTING", {
|
1826 |
+
enumerable: !0,
|
1827 |
+
value: O.indexOf("CONNECTING")
|
1828 |
+
});
|
1829 |
+
Object.defineProperty(m, "OPEN", {
|
1830 |
+
enumerable: !0,
|
1831 |
+
value: O.indexOf("OPEN")
|
1832 |
+
});
|
1833 |
+
Object.defineProperty(m.prototype, "OPEN", {
|
1834 |
+
enumerable: !0,
|
1835 |
+
value: O.indexOf("OPEN")
|
1836 |
+
});
|
1837 |
+
Object.defineProperty(m, "CLOSING", {
|
1838 |
+
enumerable: !0,
|
1839 |
+
value: O.indexOf("CLOSING")
|
1840 |
+
});
|
1841 |
+
Object.defineProperty(m.prototype, "CLOSING", {
|
1842 |
+
enumerable: !0,
|
1843 |
+
value: O.indexOf("CLOSING")
|
1844 |
+
});
|
1845 |
+
Object.defineProperty(m, "CLOSED", {
|
1846 |
+
enumerable: !0,
|
1847 |
+
value: O.indexOf("CLOSED")
|
1848 |
+
});
|
1849 |
+
Object.defineProperty(m.prototype, "CLOSED", {
|
1850 |
+
enumerable: !0,
|
1851 |
+
value: O.indexOf("CLOSED")
|
1852 |
+
});
|
1853 |
+
[
|
1854 |
+
"binaryType",
|
1855 |
+
"bufferedAmount",
|
1856 |
+
"extensions",
|
1857 |
+
"isPaused",
|
1858 |
+
"protocol",
|
1859 |
+
"readyState",
|
1860 |
+
"url"
|
1861 |
+
].forEach((s) => {
|
1862 |
+
Object.defineProperty(m.prototype, s, { enumerable: !0 });
|
1863 |
+
});
|
1864 |
+
["open", "error", "close", "message"].forEach((s) => {
|
1865 |
+
Object.defineProperty(m.prototype, `on${s}`, {
|
1866 |
+
enumerable: !0,
|
1867 |
+
get() {
|
1868 |
+
for (const e of this.listeners(s))
|
1869 |
+
if (e[ge])
|
1870 |
+
return e[ds];
|
1871 |
+
return null;
|
1872 |
+
},
|
1873 |
+
set(e) {
|
1874 |
+
for (const t of this.listeners(s))
|
1875 |
+
if (t[ge]) {
|
1876 |
+
this.removeListener(s, t);
|
1877 |
+
break;
|
1878 |
+
}
|
1879 |
+
typeof e == "function" && this.addEventListener(s, e, {
|
1880 |
+
[ge]: !0
|
1881 |
+
});
|
1882 |
+
}
|
1883 |
+
});
|
1884 |
+
});
|
1885 |
+
m.prototype.addEventListener = ps;
|
1886 |
+
m.prototype.removeEventListener = ms;
|
1887 |
+
var ft = m;
|
1888 |
+
function ht(s, e, t, r) {
|
1889 |
+
const i = {
|
1890 |
+
protocolVersion: ye[1],
|
1891 |
+
maxPayload: 104857600,
|
1892 |
+
skipUTF8Validation: !1,
|
1893 |
+
perMessageDeflate: !0,
|
1894 |
+
followRedirects: !1,
|
1895 |
+
maxRedirects: 10,
|
1896 |
+
...r,
|
1897 |
+
createConnection: void 0,
|
1898 |
+
socketPath: void 0,
|
1899 |
+
hostname: void 0,
|
1900 |
+
protocol: void 0,
|
1901 |
+
timeout: void 0,
|
1902 |
+
method: "GET",
|
1903 |
+
host: void 0,
|
1904 |
+
path: void 0,
|
1905 |
+
port: void 0
|
1906 |
+
};
|
1907 |
+
if (!ye.includes(i.protocolVersion))
|
1908 |
+
throw new RangeError(
|
1909 |
+
`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${ye.join(", ")})`
|
1910 |
+
);
|
1911 |
+
let n;
|
1912 |
+
if (e instanceof me)
|
1913 |
+
n = e, s._url = e.href;
|
1914 |
+
else {
|
1915 |
+
try {
|
1916 |
+
n = new me(e);
|
1917 |
+
} catch {
|
1918 |
+
throw new SyntaxError(`Invalid URL: ${e}`);
|
1919 |
+
}
|
1920 |
+
s._url = e;
|
1921 |
+
}
|
1922 |
+
const o = n.protocol === "wss:", l = n.protocol === "ws+unix:";
|
1923 |
+
let f;
|
1924 |
+
if (n.protocol !== "ws:" && !o && !l ? f = `The URL's protocol must be one of "ws:", "wss:", or "ws+unix:"` : l && !n.pathname ? f = "The URL's pathname is empty" : n.hash && (f = "The URL contains a fragment identifier"), f) {
|
1925 |
+
const u = new SyntaxError(f);
|
1926 |
+
if (s._redirects === 0)
|
1927 |
+
throw u;
|
1928 |
+
ee(s, u);
|
1929 |
+
return;
|
1930 |
+
}
|
1931 |
+
const a = o ? 443 : 80, c = ls(16).toString("base64"), h = o ? ns.request : os.request, p = /* @__PURE__ */ new Set();
|
1932 |
+
let v;
|
1933 |
+
if (i.createConnection = o ? xs : bs, i.defaultPort = i.defaultPort || a, i.port = n.port || a, i.host = n.hostname.startsWith("[") ? n.hostname.slice(1, -1) : n.hostname, i.headers = {
|
1934 |
+
...i.headers,
|
1935 |
+
"Sec-WebSocket-Version": i.protocolVersion,
|
1936 |
+
"Sec-WebSocket-Key": c,
|
1937 |
+
Connection: "Upgrade",
|
1938 |
+
Upgrade: "websocket"
|
1939 |
+
}, i.path = n.pathname + n.search, i.timeout = i.handshakeTimeout, i.perMessageDeflate && (v = new T(
|
1940 |
+
i.perMessageDeflate !== !0 ? i.perMessageDeflate : {},
|
1941 |
+
!1,
|
1942 |
+
i.maxPayload
|
1943 |
+
), i.headers["Sec-WebSocket-Extensions"] = gs({
|
1944 |
+
[T.extensionName]: v.offer()
|
1945 |
+
})), t.length) {
|
1946 |
+
for (const u of t) {
|
1947 |
+
if (typeof u != "string" || !Es.test(u) || p.has(u))
|
1948 |
+
throw new SyntaxError(
|
1949 |
+
"An invalid or duplicated subprotocol was specified"
|
1950 |
+
);
|
1951 |
+
p.add(u);
|
1952 |
+
}
|
1953 |
+
i.headers["Sec-WebSocket-Protocol"] = t.join(",");
|
1954 |
+
}
|
1955 |
+
if (i.origin && (i.protocolVersion < 13 ? i.headers["Sec-WebSocket-Origin"] = i.origin : i.headers.Origin = i.origin), (n.username || n.password) && (i.auth = `${n.username}:${n.password}`), l) {
|
1956 |
+
const u = i.path.split(":");
|
1957 |
+
i.socketPath = u[0], i.path = u[1];
|
1958 |
+
}
|
1959 |
+
let _;
|
1960 |
+
if (i.followRedirects) {
|
1961 |
+
if (s._redirects === 0) {
|
1962 |
+
s._originalIpc = l, s._originalSecure = o, s._originalHostOrSocketPath = l ? i.socketPath : n.host;
|
1963 |
+
const u = r && r.headers;
|
1964 |
+
if (r = { ...r, headers: {} }, u)
|
1965 |
+
for (const [E, $] of Object.entries(u))
|
1966 |
+
r.headers[E.toLowerCase()] = $;
|
1967 |
+
} else if (s.listenerCount("redirect") === 0) {
|
1968 |
+
const u = l ? s._originalIpc ? i.socketPath === s._originalHostOrSocketPath : !1 : s._originalIpc ? !1 : n.host === s._originalHostOrSocketPath;
|
1969 |
+
(!u || s._originalSecure && !o) && (delete i.headers.authorization, delete i.headers.cookie, u || delete i.headers.host, i.auth = void 0);
|
1970 |
+
}
|
1971 |
+
i.auth && !r.headers.authorization && (r.headers.authorization = "Basic " + Buffer.from(i.auth).toString("base64")), _ = s._req = h(i), s._redirects && s.emit("redirect", s.url, _);
|
1972 |
+
} else
|
1973 |
+
_ = s._req = h(i);
|
1974 |
+
i.timeout && _.on("timeout", () => {
|
1975 |
+
b(s, _, "Opening handshake has timed out");
|
1976 |
+
}), _.on("error", (u) => {
|
1977 |
+
_ === null || _[lt] || (_ = s._req = null, ee(s, u));
|
1978 |
+
}), _.on("response", (u) => {
|
1979 |
+
const E = u.headers.location, $ = u.statusCode;
|
1980 |
+
if (E && i.followRedirects && $ >= 300 && $ < 400) {
|
1981 |
+
if (++s._redirects > i.maxRedirects) {
|
1982 |
+
b(s, _, "Maximum redirects exceeded");
|
1983 |
+
return;
|
1984 |
+
}
|
1985 |
+
_.abort();
|
1986 |
+
let q;
|
1987 |
+
try {
|
1988 |
+
q = new me(E, e);
|
1989 |
+
} catch {
|
1990 |
+
const L = new SyntaxError(`Invalid URL: ${E}`);
|
1991 |
+
ee(s, L);
|
1992 |
+
return;
|
1993 |
+
}
|
1994 |
+
ht(s, q, t, r);
|
1995 |
+
} else
|
1996 |
+
s.emit("unexpected-response", _, u) || b(
|
1997 |
+
s,
|
1998 |
+
_,
|
1999 |
+
`Unexpected server response: ${u.statusCode}`
|
2000 |
+
);
|
2001 |
+
}), _.on("upgrade", (u, E, $) => {
|
2002 |
+
if (s.emit("upgrade", u), s.readyState !== m.CONNECTING)
|
2003 |
+
return;
|
2004 |
+
if (_ = s._req = null, u.headers.upgrade.toLowerCase() !== "websocket") {
|
2005 |
+
b(s, E, "Invalid Upgrade header");
|
2006 |
+
return;
|
2007 |
+
}
|
2008 |
+
const q = fs("sha1").update(c + us).digest("base64");
|
2009 |
+
if (u.headers["sec-websocket-accept"] !== q) {
|
2010 |
+
b(s, E, "Invalid Sec-WebSocket-Accept header");
|
2011 |
+
return;
|
2012 |
+
}
|
2013 |
+
const D = u.headers["sec-websocket-protocol"];
|
2014 |
+
let L;
|
2015 |
+
if (D !== void 0 ? p.size ? p.has(D) || (L = "Server sent an invalid subprotocol") : L = "Server sent a subprotocol but none was requested" : p.size && (L = "Server sent no subprotocol"), L) {
|
2016 |
+
b(s, E, L);
|
2017 |
+
return;
|
2018 |
+
}
|
2019 |
+
D && (s._protocol = D);
|
2020 |
+
const ke = u.headers["sec-websocket-extensions"];
|
2021 |
+
if (ke !== void 0) {
|
2022 |
+
if (!v) {
|
2023 |
+
b(s, E, "Server sent a Sec-WebSocket-Extensions header but no extension was requested");
|
2024 |
+
return;
|
2025 |
+
}
|
2026 |
+
let he;
|
2027 |
+
try {
|
2028 |
+
he = ys(ke);
|
2029 |
+
} catch {
|
2030 |
+
b(s, E, "Invalid Sec-WebSocket-Extensions header");
|
2031 |
+
return;
|
2032 |
+
}
|
2033 |
+
const we = Object.keys(he);
|
2034 |
+
if (we.length !== 1 || we[0] !== T.extensionName) {
|
2035 |
+
b(s, E, "Server indicated an extension that was not requested");
|
2036 |
+
return;
|
2037 |
+
}
|
2038 |
+
try {
|
2039 |
+
v.accept(he[T.extensionName]);
|
2040 |
+
} catch {
|
2041 |
+
b(s, E, "Invalid Sec-WebSocket-Extensions header");
|
2042 |
+
return;
|
2043 |
+
}
|
2044 |
+
s._extensions[T.extensionName] = v;
|
2045 |
+
}
|
2046 |
+
s.setSocket(E, $, {
|
2047 |
+
generateMask: i.generateMask,
|
2048 |
+
maxPayload: i.maxPayload,
|
2049 |
+
skipUTF8Validation: i.skipUTF8Validation
|
2050 |
+
});
|
2051 |
+
}), i.finishRequest ? i.finishRequest(_, s) : _.end();
|
2052 |
+
}
|
2053 |
+
function ee(s, e) {
|
2054 |
+
s._readyState = m.CLOSING, s.emit("error", e), s.emitClose();
|
2055 |
+
}
|
2056 |
+
function bs(s) {
|
2057 |
+
return s.path = s.socketPath, ot.connect(s);
|
2058 |
+
}
|
2059 |
+
function xs(s) {
|
2060 |
+
return s.path = void 0, !s.servername && s.servername !== "" && (s.servername = ot.isIP(s.host) ? "" : s.host), as.connect(s);
|
2061 |
+
}
|
2062 |
+
function b(s, e, t) {
|
2063 |
+
s._readyState = m.CLOSING;
|
2064 |
+
const r = new Error(t);
|
2065 |
+
Error.captureStackTrace(r, b), e.setHeader ? (e[lt] = !0, e.abort(), e.socket && !e.socket.destroyed && e.socket.destroy(), process.nextTick(ee, s, r)) : (e.destroy(r), e.once("error", s.emit.bind(s, "error")), e.once("close", s.emitClose.bind(s)));
|
2066 |
+
}
|
2067 |
+
function ve(s, e, t) {
|
2068 |
+
if (e) {
|
2069 |
+
const r = vs(e).length;
|
2070 |
+
s._socket ? s._sender._bufferedBytes += r : s._bufferedAmount += r;
|
2071 |
+
}
|
2072 |
+
if (t) {
|
2073 |
+
const r = new Error(
|
2074 |
+
`WebSocket is not open: readyState ${s.readyState} (${O[s.readyState]})`
|
2075 |
+
);
|
2076 |
+
process.nextTick(t, r);
|
2077 |
+
}
|
2078 |
+
}
|
2079 |
+
function ks(s, e) {
|
2080 |
+
const t = this[y];
|
2081 |
+
t._closeFrameReceived = !0, t._closeMessage = e, t._closeCode = s, t._socket[y] !== void 0 && (t._socket.removeListener("data", fe), process.nextTick(ct, t._socket), s === 1005 ? t.close() : t.close(s, e));
|
2082 |
+
}
|
2083 |
+
function ws() {
|
2084 |
+
const s = this[y];
|
2085 |
+
s.isPaused || s._socket.resume();
|
2086 |
+
}
|
2087 |
+
function Os(s) {
|
2088 |
+
const e = this[y];
|
2089 |
+
e._socket[y] !== void 0 && (e._socket.removeListener("data", fe), process.nextTick(ct, e._socket), e.close(s[_s])), e.emit("error", s);
|
2090 |
+
}
|
2091 |
+
function Ye() {
|
2092 |
+
this[y].emitClose();
|
2093 |
+
}
|
2094 |
+
function Cs(s, e) {
|
2095 |
+
this[y].emit("message", s, e);
|
2096 |
+
}
|
2097 |
+
function Ts(s) {
|
2098 |
+
const e = this[y];
|
2099 |
+
e.pong(s, !e._isServer, at), e.emit("ping", s);
|
2100 |
+
}
|
2101 |
+
function Ls(s) {
|
2102 |
+
this[y].emit("pong", s);
|
2103 |
+
}
|
2104 |
+
function ct(s) {
|
2105 |
+
s.resume();
|
2106 |
+
}
|
2107 |
+
function ut() {
|
2108 |
+
const s = this[y];
|
2109 |
+
this.removeListener("close", ut), this.removeListener("data", fe), this.removeListener("end", dt), s._readyState = m.CLOSING;
|
2110 |
+
let e;
|
2111 |
+
!this._readableState.endEmitted && !s._closeFrameReceived && !s._receiver._writableState.errorEmitted && (e = s._socket.read()) !== null && s._receiver.write(e), s._receiver.end(), this[y] = void 0, clearTimeout(s._closeTimer), s._receiver._writableState.finished || s._receiver._writableState.errorEmitted ? s.emitClose() : (s._receiver.on("error", Ye), s._receiver.on("finish", Ye));
|
2112 |
+
}
|
2113 |
+
function fe(s) {
|
2114 |
+
this[y]._receiver.write(s) || this.pause();
|
2115 |
+
}
|
2116 |
+
function dt() {
|
2117 |
+
const s = this[y];
|
2118 |
+
s._readyState = m.CLOSING, s._receiver.end(), this.end();
|
2119 |
+
}
|
2120 |
+
function _t() {
|
2121 |
+
const s = this[y];
|
2122 |
+
this.removeListener("error", _t), this.on("error", at), s && (s._readyState = m.CLOSING, this.destroy());
|
2123 |
+
}
|
2124 |
+
const Xs = /* @__PURE__ */ z(ft), { tokenChars: Ns } = ae;
|
2125 |
+
function Ps(s) {
|
2126 |
+
const e = /* @__PURE__ */ new Set();
|
2127 |
+
let t = -1, r = -1, i = 0;
|
2128 |
+
for (i; i < s.length; i++) {
|
2129 |
+
const o = s.charCodeAt(i);
|
2130 |
+
if (r === -1 && Ns[o] === 1)
|
2131 |
+
t === -1 && (t = i);
|
2132 |
+
else if (i !== 0 && (o === 32 || o === 9))
|
2133 |
+
r === -1 && t !== -1 && (r = i);
|
2134 |
+
else if (o === 44) {
|
2135 |
+
if (t === -1)
|
2136 |
+
throw new SyntaxError(`Unexpected character at index ${i}`);
|
2137 |
+
r === -1 && (r = i);
|
2138 |
+
const l = s.slice(t, r);
|
2139 |
+
if (e.has(l))
|
2140 |
+
throw new SyntaxError(`The "${l}" subprotocol is duplicated`);
|
2141 |
+
e.add(l), t = r = -1;
|
2142 |
+
} else
|
2143 |
+
throw new SyntaxError(`Unexpected character at index ${i}`);
|
2144 |
+
}
|
2145 |
+
if (t === -1 || r !== -1)
|
2146 |
+
throw new SyntaxError("Unexpected end of input");
|
2147 |
+
const n = s.slice(t, i);
|
2148 |
+
if (e.has(n))
|
2149 |
+
throw new SyntaxError(`The "${n}" subprotocol is duplicated`);
|
2150 |
+
return e.add(n), e;
|
2151 |
+
}
|
2152 |
+
var Rs = { parse: Ps };
|
2153 |
+
const Us = S, ie = S, { createHash: Bs } = S, qe = nt, N = oe, $s = Rs, Ms = ft, { GUID: Is, kWebSocket: Ds } = U, Ws = /^[+/0-9A-Za-z]{22}==$/, Ke = 0, Xe = 1, pt = 2;
|
2154 |
+
class As extends Us {
|
2155 |
+
/**
|
2156 |
+
* Create a `WebSocketServer` instance.
|
2157 |
+
*
|
2158 |
+
* @param {Object} options Configuration options
|
2159 |
+
* @param {Number} [options.backlog=511] The maximum length of the queue of
|
2160 |
+
* pending connections
|
2161 |
+
* @param {Boolean} [options.clientTracking=true] Specifies whether or not to
|
2162 |
+
* track clients
|
2163 |
+
* @param {Function} [options.handleProtocols] A hook to handle protocols
|
2164 |
+
* @param {String} [options.host] The hostname where to bind the server
|
2165 |
+
* @param {Number} [options.maxPayload=104857600] The maximum allowed message
|
2166 |
+
* size
|
2167 |
+
* @param {Boolean} [options.noServer=false] Enable no server mode
|
2168 |
+
* @param {String} [options.path] Accept only connections matching this path
|
2169 |
+
* @param {(Boolean|Object)} [options.perMessageDeflate=false] Enable/disable
|
2170 |
+
* permessage-deflate
|
2171 |
+
* @param {Number} [options.port] The port where to bind the server
|
2172 |
+
* @param {(http.Server|https.Server)} [options.server] A pre-created HTTP/S
|
2173 |
+
* server to use
|
2174 |
+
* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
|
2175 |
+
* not to skip UTF-8 validation for text and close messages
|
2176 |
+
* @param {Function} [options.verifyClient] A hook to reject connections
|
2177 |
+
* @param {Function} [options.WebSocket=WebSocket] Specifies the `WebSocket`
|
2178 |
+
* class to use. It must be the `WebSocket` class or class that extends it
|
2179 |
+
* @param {Function} [callback] A listener for the `listening` event
|
2180 |
+
*/
|
2181 |
+
constructor(e, t) {
|
2182 |
+
if (super(), e = {
|
2183 |
+
maxPayload: 100 * 1024 * 1024,
|
2184 |
+
skipUTF8Validation: !1,
|
2185 |
+
perMessageDeflate: !1,
|
2186 |
+
handleProtocols: null,
|
2187 |
+
clientTracking: !0,
|
2188 |
+
verifyClient: null,
|
2189 |
+
noServer: !1,
|
2190 |
+
backlog: null,
|
2191 |
+
// use default (511 as implemented in net.js)
|
2192 |
+
server: null,
|
2193 |
+
host: null,
|
2194 |
+
path: null,
|
2195 |
+
port: null,
|
2196 |
+
WebSocket: Ms,
|
2197 |
+
...e
|
2198 |
+
}, e.port == null && !e.server && !e.noServer || e.port != null && (e.server || e.noServer) || e.server && e.noServer)
|
2199 |
+
throw new TypeError(
|
2200 |
+
'One and only one of the "port", "server", or "noServer" options must be specified'
|
2201 |
+
);
|
2202 |
+
if (e.port != null ? (this._server = ie.createServer((r, i) => {
|
2203 |
+
const n = ie.STATUS_CODES[426];
|
2204 |
+
i.writeHead(426, {
|
2205 |
+
"Content-Length": n.length,
|
2206 |
+
"Content-Type": "text/plain"
|
2207 |
+
}), i.end(n);
|
2208 |
+
}), this._server.listen(
|
2209 |
+
e.port,
|
2210 |
+
e.host,
|
2211 |
+
e.backlog,
|
2212 |
+
t
|
2213 |
+
)) : e.server && (this._server = e.server), this._server) {
|
2214 |
+
const r = this.emit.bind(this, "connection");
|
2215 |
+
this._removeListeners = js(this._server, {
|
2216 |
+
listening: this.emit.bind(this, "listening"),
|
2217 |
+
error: this.emit.bind(this, "error"),
|
2218 |
+
upgrade: (i, n, o) => {
|
2219 |
+
this.handleUpgrade(i, n, o, r);
|
2220 |
+
}
|
2221 |
+
});
|
2222 |
+
}
|
2223 |
+
e.perMessageDeflate === !0 && (e.perMessageDeflate = {}), e.clientTracking && (this.clients = /* @__PURE__ */ new Set(), this._shouldEmitClose = !1), this.options = e, this._state = Ke;
|
2224 |
+
}
|
2225 |
+
/**
|
2226 |
+
* Returns the bound address, the address family name, and port of the server
|
2227 |
+
* as reported by the operating system if listening on an IP socket.
|
2228 |
+
* If the server is listening on a pipe or UNIX domain socket, the name is
|
2229 |
+
* returned as a string.
|
2230 |
+
*
|
2231 |
+
* @return {(Object|String|null)} The address of the server
|
2232 |
+
* @public
|
2233 |
+
*/
|
2234 |
+
address() {
|
2235 |
+
if (this.options.noServer)
|
2236 |
+
throw new Error('The server is operating in "noServer" mode');
|
2237 |
+
return this._server ? this._server.address() : null;
|
2238 |
+
}
|
2239 |
+
/**
|
2240 |
+
* Stop the server from accepting new connections and emit the `'close'` event
|
2241 |
+
* when all existing connections are closed.
|
2242 |
+
*
|
2243 |
+
* @param {Function} [cb] A one-time listener for the `'close'` event
|
2244 |
+
* @public
|
2245 |
+
*/
|
2246 |
+
close(e) {
|
2247 |
+
if (this._state === pt) {
|
2248 |
+
e && this.once("close", () => {
|
2249 |
+
e(new Error("The server is not running"));
|
2250 |
+
}), process.nextTick(G, this);
|
2251 |
+
return;
|
2252 |
+
}
|
2253 |
+
if (e && this.once("close", e), this._state !== Xe)
|
2254 |
+
if (this._state = Xe, this.options.noServer || this.options.server)
|
2255 |
+
this._server && (this._removeListeners(), this._removeListeners = this._server = null), this.clients ? this.clients.size ? this._shouldEmitClose = !0 : process.nextTick(G, this) : process.nextTick(G, this);
|
2256 |
+
else {
|
2257 |
+
const t = this._server;
|
2258 |
+
this._removeListeners(), this._removeListeners = this._server = null, t.close(() => {
|
2259 |
+
G(this);
|
2260 |
+
});
|
2261 |
+
}
|
2262 |
+
}
|
2263 |
+
/**
|
2264 |
+
* See if a given request should be handled by this server instance.
|
2265 |
+
*
|
2266 |
+
* @param {http.IncomingMessage} req Request object to inspect
|
2267 |
+
* @return {Boolean} `true` if the request is valid, else `false`
|
2268 |
+
* @public
|
2269 |
+
*/
|
2270 |
+
shouldHandle(e) {
|
2271 |
+
if (this.options.path) {
|
2272 |
+
const t = e.url.indexOf("?");
|
2273 |
+
if ((t !== -1 ? e.url.slice(0, t) : e.url) !== this.options.path)
|
2274 |
+
return !1;
|
2275 |
+
}
|
2276 |
+
return !0;
|
2277 |
+
}
|
2278 |
+
/**
|
2279 |
+
* Handle a HTTP Upgrade request.
|
2280 |
+
*
|
2281 |
+
* @param {http.IncomingMessage} req The request object
|
2282 |
+
* @param {(net.Socket|tls.Socket)} socket The network socket between the
|
2283 |
+
* server and client
|
2284 |
+
* @param {Buffer} head The first packet of the upgraded stream
|
2285 |
+
* @param {Function} cb Callback
|
2286 |
+
* @public
|
2287 |
+
*/
|
2288 |
+
handleUpgrade(e, t, r, i) {
|
2289 |
+
t.on("error", Ze);
|
2290 |
+
const n = e.headers["sec-websocket-key"], o = +e.headers["sec-websocket-version"];
|
2291 |
+
if (e.method !== "GET") {
|
2292 |
+
R(this, e, t, 405, "Invalid HTTP method");
|
2293 |
+
return;
|
2294 |
+
}
|
2295 |
+
if (e.headers.upgrade.toLowerCase() !== "websocket") {
|
2296 |
+
R(this, e, t, 400, "Invalid Upgrade header");
|
2297 |
+
return;
|
2298 |
+
}
|
2299 |
+
if (!n || !Ws.test(n)) {
|
2300 |
+
R(this, e, t, 400, "Missing or invalid Sec-WebSocket-Key header");
|
2301 |
+
return;
|
2302 |
+
}
|
2303 |
+
if (o !== 8 && o !== 13) {
|
2304 |
+
R(this, e, t, 400, "Missing or invalid Sec-WebSocket-Version header");
|
2305 |
+
return;
|
2306 |
+
}
|
2307 |
+
if (!this.shouldHandle(e)) {
|
2308 |
+
H(t, 400);
|
2309 |
+
return;
|
2310 |
+
}
|
2311 |
+
const l = e.headers["sec-websocket-protocol"];
|
2312 |
+
let f = /* @__PURE__ */ new Set();
|
2313 |
+
if (l !== void 0)
|
2314 |
+
try {
|
2315 |
+
f = $s.parse(l);
|
2316 |
+
} catch {
|
2317 |
+
R(this, e, t, 400, "Invalid Sec-WebSocket-Protocol header");
|
2318 |
+
return;
|
2319 |
+
}
|
2320 |
+
const a = e.headers["sec-websocket-extensions"], c = {};
|
2321 |
+
if (this.options.perMessageDeflate && a !== void 0) {
|
2322 |
+
const h = new N(
|
2323 |
+
this.options.perMessageDeflate,
|
2324 |
+
!0,
|
2325 |
+
this.options.maxPayload
|
2326 |
+
);
|
2327 |
+
try {
|
2328 |
+
const p = qe.parse(a);
|
2329 |
+
p[N.extensionName] && (h.accept(p[N.extensionName]), c[N.extensionName] = h);
|
2330 |
+
} catch {
|
2331 |
+
R(this, e, t, 400, "Invalid or unacceptable Sec-WebSocket-Extensions header");
|
2332 |
+
return;
|
2333 |
+
}
|
2334 |
+
}
|
2335 |
+
if (this.options.verifyClient) {
|
2336 |
+
const h = {
|
2337 |
+
origin: e.headers[`${o === 8 ? "sec-websocket-origin" : "origin"}`],
|
2338 |
+
secure: !!(e.socket.authorized || e.socket.encrypted),
|
2339 |
+
req: e
|
2340 |
+
};
|
2341 |
+
if (this.options.verifyClient.length === 2) {
|
2342 |
+
this.options.verifyClient(h, (p, v, _, u) => {
|
2343 |
+
if (!p)
|
2344 |
+
return H(t, v || 401, _, u);
|
2345 |
+
this.completeUpgrade(
|
2346 |
+
c,
|
2347 |
+
n,
|
2348 |
+
f,
|
2349 |
+
e,
|
2350 |
+
t,
|
2351 |
+
r,
|
2352 |
+
i
|
2353 |
+
);
|
2354 |
+
});
|
2355 |
+
return;
|
2356 |
+
}
|
2357 |
+
if (!this.options.verifyClient(h))
|
2358 |
+
return H(t, 401);
|
2359 |
+
}
|
2360 |
+
this.completeUpgrade(c, n, f, e, t, r, i);
|
2361 |
+
}
|
2362 |
+
/**
|
2363 |
+
* Upgrade the connection to WebSocket.
|
2364 |
+
*
|
2365 |
+
* @param {Object} extensions The accepted extensions
|
2366 |
+
* @param {String} key The value of the `Sec-WebSocket-Key` header
|
2367 |
+
* @param {Set} protocols The subprotocols
|
2368 |
+
* @param {http.IncomingMessage} req The request object
|
2369 |
+
* @param {(net.Socket|tls.Socket)} socket The network socket between the
|
2370 |
+
* server and client
|
2371 |
+
* @param {Buffer} head The first packet of the upgraded stream
|
2372 |
+
* @param {Function} cb Callback
|
2373 |
+
* @throws {Error} If called more than once with the same socket
|
2374 |
+
* @private
|
2375 |
+
*/
|
2376 |
+
completeUpgrade(e, t, r, i, n, o, l) {
|
2377 |
+
if (!n.readable || !n.writable)
|
2378 |
+
return n.destroy();
|
2379 |
+
if (n[Ds])
|
2380 |
+
throw new Error(
|
2381 |
+
"server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration"
|
2382 |
+
);
|
2383 |
+
if (this._state > Ke)
|
2384 |
+
return H(n, 503);
|
2385 |
+
const a = [
|
2386 |
+
"HTTP/1.1 101 Switching Protocols",
|
2387 |
+
"Upgrade: websocket",
|
2388 |
+
"Connection: Upgrade",
|
2389 |
+
`Sec-WebSocket-Accept: ${Bs("sha1").update(t + Is).digest("base64")}`
|
2390 |
+
], c = new this.options.WebSocket(null);
|
2391 |
+
if (r.size) {
|
2392 |
+
const h = this.options.handleProtocols ? this.options.handleProtocols(r, i) : r.values().next().value;
|
2393 |
+
h && (a.push(`Sec-WebSocket-Protocol: ${h}`), c._protocol = h);
|
2394 |
+
}
|
2395 |
+
if (e[N.extensionName]) {
|
2396 |
+
const h = e[N.extensionName].params, p = qe.format({
|
2397 |
+
[N.extensionName]: [h]
|
2398 |
+
});
|
2399 |
+
a.push(`Sec-WebSocket-Extensions: ${p}`), c._extensions = e;
|
2400 |
+
}
|
2401 |
+
this.emit("headers", a, i), n.write(a.concat(`\r
|
2402 |
+
`).join(`\r
|
2403 |
+
`)), n.removeListener("error", Ze), c.setSocket(n, o, {
|
2404 |
+
maxPayload: this.options.maxPayload,
|
2405 |
+
skipUTF8Validation: this.options.skipUTF8Validation
|
2406 |
+
}), this.clients && (this.clients.add(c), c.on("close", () => {
|
2407 |
+
this.clients.delete(c), this._shouldEmitClose && !this.clients.size && process.nextTick(G, this);
|
2408 |
+
})), l(c, i);
|
2409 |
+
}
|
2410 |
+
}
|
2411 |
+
var Fs = As;
|
2412 |
+
function js(s, e) {
|
2413 |
+
for (const t of Object.keys(e))
|
2414 |
+
s.on(t, e[t]);
|
2415 |
+
return function() {
|
2416 |
+
for (const r of Object.keys(e))
|
2417 |
+
s.removeListener(r, e[r]);
|
2418 |
+
};
|
2419 |
+
}
|
2420 |
+
function G(s) {
|
2421 |
+
s._state = pt, s.emit("close");
|
2422 |
+
}
|
2423 |
+
function Ze() {
|
2424 |
+
this.destroy();
|
2425 |
+
}
|
2426 |
+
function H(s, e, t, r) {
|
2427 |
+
t = t || ie.STATUS_CODES[e], r = {
|
2428 |
+
Connection: "close",
|
2429 |
+
"Content-Type": "text/html",
|
2430 |
+
"Content-Length": Buffer.byteLength(t),
|
2431 |
+
...r
|
2432 |
+
}, s.once("finish", s.destroy), s.end(
|
2433 |
+
`HTTP/1.1 ${e} ${ie.STATUS_CODES[e]}\r
|
2434 |
+
` + Object.keys(r).map((i) => `${i}: ${r[i]}`).join(`\r
|
2435 |
+
`) + `\r
|
2436 |
+
\r
|
2437 |
+
` + t
|
2438 |
+
);
|
2439 |
+
}
|
2440 |
+
function R(s, e, t, r, i) {
|
2441 |
+
if (s.listenerCount("wsClientError")) {
|
2442 |
+
const n = new Error(i);
|
2443 |
+
Error.captureStackTrace(n, R), s.emit("wsClientError", n, t, e);
|
2444 |
+
} else
|
2445 |
+
H(t, r, i);
|
2446 |
+
}
|
2447 |
+
const Zs = /* @__PURE__ */ z(Fs);
|
2448 |
+
export {
|
2449 |
+
qs as Receiver,
|
2450 |
+
Ks as Sender,
|
2451 |
+
Xs as WebSocket,
|
2452 |
+
Zs as WebSocketServer,
|
2453 |
+
Vs as createWebSocketStream,
|
2454 |
+
Xs as default
|
2455 |
+
};
|
src/demo/__init__.py
ADDED
File without changes
|
src/demo/alligator_images/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
src/demo/alligator_images/Chinese-Yangtze-alligator.jpeg
ADDED
src/demo/alligator_images/Nile-Crocodile.jpg
ADDED
src/demo/alligator_images/american_alligator.jpeg
ADDED
src/demo/alligator_images/babygator.jpeg
ADDED
src/demo/alligator_images/flat_aligator.jpeg
ADDED
src/demo/alligator_images/gator.jpeg
ADDED
src/demo/alligator_images/gator_fam.jpeg
ADDED
src/demo/alligator_images/largegator.jpeg
ADDED
src/demo/app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
|
3 |
+
import os
|
4 |
+
|
5 |
+
import gradio as gr
|
6 |
+
from gradio_carousel import Carousel
|
7 |
+
|
8 |
+
image_dir = os.path.join(os.path.dirname(__file__), "alligator_images")
|
9 |
+
|
10 |
+
images = [os.path.join(image_dir, file) for file in os.listdir(image_dir) if file.endswith((".jpg", ".jpeg", ".png"))]
|
11 |
+
|
12 |
+
with gr.Blocks() as demo:
|
13 |
+
with gr.Row():
|
14 |
+
Carousel(label="cool gators", value=images) # carousel component with images
|
15 |
+
|
16 |
+
|
17 |
+
if __name__ == "__main__":
|
18 |
+
demo.launch()
|
src/demo/css.css
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
html {
|
2 |
+
font-family: Inter;
|
3 |
+
font-size: 16px;
|
4 |
+
font-weight: 400;
|
5 |
+
line-height: 1.5;
|
6 |
+
-webkit-text-size-adjust: 100%;
|
7 |
+
background: #fff;
|
8 |
+
color: #323232;
|
9 |
+
-webkit-font-smoothing: antialiased;
|
10 |
+
-moz-osx-font-smoothing: grayscale;
|
11 |
+
text-rendering: optimizeLegibility;
|
12 |
+
}
|
13 |
+
|
14 |
+
:root {
|
15 |
+
--space: 1;
|
16 |
+
--vspace: calc(var(--space) * 1rem);
|
17 |
+
--vspace-0: calc(3 * var(--space) * 1rem);
|
18 |
+
--vspace-1: calc(2 * var(--space) * 1rem);
|
19 |
+
--vspace-2: calc(1.5 * var(--space) * 1rem);
|
20 |
+
--vspace-3: calc(0.5 * var(--space) * 1rem);
|
21 |
+
}
|
22 |
+
|
23 |
+
.app {
|
24 |
+
max-width: 748px !important;
|
25 |
+
}
|
26 |
+
|
27 |
+
.prose p {
|
28 |
+
margin: var(--vspace) 0;
|
29 |
+
line-height: var(--vspace * 2);
|
30 |
+
font-size: 1rem;
|
31 |
+
}
|
32 |
+
|
33 |
+
code {
|
34 |
+
font-family: "Inconsolata", sans-serif;
|
35 |
+
font-size: 16px;
|
36 |
+
}
|
37 |
+
|
38 |
+
h1,
|
39 |
+
h1 code {
|
40 |
+
font-weight: 400;
|
41 |
+
line-height: calc(2.5 / var(--space) * var(--vspace));
|
42 |
+
}
|
43 |
+
|
44 |
+
h1 code {
|
45 |
+
background: none;
|
46 |
+
border: none;
|
47 |
+
letter-spacing: 0.05em;
|
48 |
+
padding-bottom: 5px;
|
49 |
+
position: relative;
|
50 |
+
padding: 0;
|
51 |
+
}
|
52 |
+
|
53 |
+
h2 {
|
54 |
+
margin: var(--vspace-1) 0 var(--vspace-2) 0;
|
55 |
+
line-height: 1em;
|
56 |
+
}
|
57 |
+
|
58 |
+
h3,
|
59 |
+
h3 code {
|
60 |
+
margin: var(--vspace-1) 0 var(--vspace-2) 0;
|
61 |
+
line-height: 1em;
|
62 |
+
}
|
63 |
+
|
64 |
+
h4,
|
65 |
+
h5,
|
66 |
+
h6 {
|
67 |
+
margin: var(--vspace-3) 0 var(--vspace-3) 0;
|
68 |
+
line-height: var(--vspace);
|
69 |
+
}
|
70 |
+
|
71 |
+
.bigtitle,
|
72 |
+
h1,
|
73 |
+
h1 code {
|
74 |
+
font-size: calc(8px * 4.5);
|
75 |
+
word-break: break-word;
|
76 |
+
}
|
77 |
+
|
78 |
+
.title,
|
79 |
+
h2,
|
80 |
+
h2 code {
|
81 |
+
font-size: calc(8px * 3.375);
|
82 |
+
font-weight: lighter;
|
83 |
+
word-break: break-word;
|
84 |
+
border: none;
|
85 |
+
background: none;
|
86 |
+
}
|
87 |
+
|
88 |
+
.subheading1,
|
89 |
+
h3,
|
90 |
+
h3 code {
|
91 |
+
font-size: calc(8px * 1.8);
|
92 |
+
font-weight: 600;
|
93 |
+
border: none;
|
94 |
+
background: none;
|
95 |
+
letter-spacing: 0.1em;
|
96 |
+
text-transform: uppercase;
|
97 |
+
}
|
98 |
+
|
99 |
+
h2 code {
|
100 |
+
padding: 0;
|
101 |
+
position: relative;
|
102 |
+
letter-spacing: 0.05em;
|
103 |
+
}
|
104 |
+
|
105 |
+
blockquote {
|
106 |
+
font-size: calc(8px * 1.1667);
|
107 |
+
font-style: italic;
|
108 |
+
line-height: calc(1.1667 * var(--vspace));
|
109 |
+
margin: var(--vspace-2) var(--vspace-2);
|
110 |
+
}
|
111 |
+
|
112 |
+
.subheading2,
|
113 |
+
h4 {
|
114 |
+
font-size: calc(8px * 1.4292);
|
115 |
+
text-transform: uppercase;
|
116 |
+
font-weight: 600;
|
117 |
+
}
|
118 |
+
|
119 |
+
.subheading3,
|
120 |
+
h5 {
|
121 |
+
font-size: calc(8px * 1.2917);
|
122 |
+
line-height: calc(1.2917 * var(--vspace));
|
123 |
+
|
124 |
+
font-weight: lighter;
|
125 |
+
text-transform: uppercase;
|
126 |
+
letter-spacing: 0.15em;
|
127 |
+
}
|
128 |
+
|
129 |
+
h6 {
|
130 |
+
font-size: calc(8px * 1.1667);
|
131 |
+
font-size: 1.1667em;
|
132 |
+
font-weight: normal;
|
133 |
+
font-style: italic;
|
134 |
+
font-family: "le-monde-livre-classic-byol", serif !important;
|
135 |
+
letter-spacing: 0px !important;
|
136 |
+
}
|
137 |
+
|
138 |
+
#start .md > *:first-child {
|
139 |
+
margin-top: 0;
|
140 |
+
}
|
141 |
+
|
142 |
+
h2 + h3 {
|
143 |
+
margin-top: 0;
|
144 |
+
}
|
145 |
+
|
146 |
+
.md hr {
|
147 |
+
border: none;
|
148 |
+
border-top: 1px solid var(--block-border-color);
|
149 |
+
margin: var(--vspace-2) 0 var(--vspace-2) 0;
|
150 |
+
}
|
151 |
+
.prose ul {
|
152 |
+
margin: var(--vspace-2) 0 var(--vspace-1) 0;
|
153 |
+
}
|
154 |
+
|
155 |
+
.gap {
|
156 |
+
gap: 0;
|
157 |
+
}
|
src/demo/space.py
ADDED
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import gradio as gr
|
3 |
+
from app import demo as app
|
4 |
+
import os
|
5 |
+
|
6 |
+
_docs = {'Carousel': {'description': 'Used to display a list of images as a gallery that can be scrolled through.\n', 'members': {'__init__': {'value': {'type': 'list[\n numpy.ndarray\n | PIL.Image.Image\n | str\n | pathlib.Path\n | tuple\n ]\n | Callable\n | None', 'default': 'None', 'description': 'List of images to display in the gallery by default. If callable, the function will be called whenever the app loads to set the initial value of the component.'}, 'label': {'type': 'str | None', 'default': 'None', 'description': 'The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.'}, 'every': {'type': 'float | None', 'default': 'None', 'description': "If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. Queue must be enabled. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute."}, 'show_label': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will display label.'}, 'container': {'type': 'bool', 'default': 'True', 'description': 'If True, will place the component in a container - providing some extra padding around the border.'}, 'scale': {'type': 'int | None', 'default': 'None', 'description': 'relative width compared to adjacent Components in a Row. For example, if Component A has scale=2, and Component B has scale=1, A will be twice as wide as B. Should be an integer.'}, 'min_width': {'type': 'int', 'default': '160', 'description': 'minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.'}, 'visible': {'type': 'bool', 'default': 'True', 'description': 'If False, component will be hidden.'}, 'elem_id': {'type': 'str | None', 'default': 'None', 'description': 'An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'elem_classes': {'type': 'list[str] | str | None', 'default': 'None', 'description': 'An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'render': {'type': 'bool', 'default': 'True', 'description': 'If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.'}, 'columns': {'type': 'int | tuple | None', 'default': '2', 'description': 'Represents the number of images that should be shown in one row, for each of the six standard screen sizes (<576px, <768px, <992px, <1200px, <1400px, >1400px). If fewer than 6 are given then the last will be used for all subsequent breakpoints'}, 'rows': {'type': 'int | tuple | None', 'default': 'None', 'description': 'Represents the number of rows in the image grid, for each of the six standard screen sizes (<576px, <768px, <992px, <1200px, <1400px, >1400px). If fewer than 6 are given then the last will be used for all subsequent breakpoints'}, 'height': {'type': 'int | float | None', 'default': 'None', 'description': 'The height of the gallery component, specified in pixels if a number is passed, or in CSS units if a string is passed. If more images are displayed than can fit in the height, a scrollbar will appear.'}, 'allow_preview': {'type': 'bool', 'default': 'True', 'description': 'If True, images in the gallery will be enlarged when they are clicked. Default is True.'}, 'preview': {'type': 'bool | None', 'default': 'None', 'description': 'If True, Carousel will start in preview mode, which shows all of the images as thumbnails and allows the user to click on them to view them in full size. Only works if allow_preview is True.'}, 'selected_index': {'type': 'int | None', 'default': 'None', 'description': 'The index of the image that should be initially selected. If None, no image will be selected at start. If provided, will set Carousel to preview mode unless allow_preview is set to False.'}, 'object_fit': {'type': '"contain" | "cover" | "fill" | "none" | "scale-down" | None', 'default': 'None', 'description': 'CSS object-fit property for the thumbnail images in the gallery. Can be "contain", "cover", "fill", "none", or "scale-down".'}, 'show_share_button': {'type': 'bool | None', 'default': 'None', 'description': 'If True, will show a share icon in the corner of the component that allows user to share outputs to Hugging Face Spaces Discussions. If False, icon does not appear. If set to None (default behavior), then the icon appears if this Gradio app is launched on Spaces, but not otherwise.'}, 'show_download_button': {'type': 'bool | None', 'default': 'True', 'description': 'If True, will show a download button in the corner of the selected image. If False, the icon does not appear. Default is True.'}, 'interactive': {'type': 'bool | None', 'default': 'None', 'description': 'If True, the gallery will be interactive, allowing the user to upload images. If False, the gallery will be static. Default is True.'}, 'type': {'type': '"numpy" | "pil" | "filepath"', 'default': '"filepath"', 'description': 'The format the image is converted to before being passed into the prediction function. "numpy" converts the image to a numpy array with shape (height, width, 3) and values from 0 to 255, "pil" converts the image to a PIL image object, "filepath" passes a str path to a temporary file containing the image. If the image is SVG, the `type` is ignored and the filepath of the SVG is returned.'}}, 'postprocess': {'value': {'type': 'list[\n numpy.ndarray\n | PIL.Image.Image\n | pathlib.Path\n | str\n | tuple[\n numpy.ndarray\n | PIL.Image.Image\n | pathlib.Path\n | str,\n str,\n ]\n ]\n | None', 'description': 'list of images, or list of (image, caption) tuples'}}, 'preprocess': {'return': {'type': 'list[tuple[str, str | None]]\n | list[tuple[PIL.Image.Image, str | None]]\n | list[tuple[numpy.ndarray, str | None]]\n | None', 'description': None}, 'value': None}}, 'events': {'select': {'type': None, 'default': None, 'description': 'Event listener for when the user selects or deselects the Carousel. Uses event data gradio.SelectData to carry `value` referring to the label of the Carousel, and `selected` to refer to state of the Carousel. See EventData documentation on how to use this event data'}, 'upload': {'type': None, 'default': None, 'description': 'This listener is triggered when the user uploads a file into the Carousel.'}, 'change': {'type': None, 'default': None, 'description': 'Triggered when the value of the Carousel changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input.'}}}, '__meta__': {'additional_interfaces': {}, 'user_fn_refs': {'Carousel': []}}}
|
7 |
+
|
8 |
+
abs_path = os.path.join(os.path.dirname(__file__), "css.css")
|
9 |
+
|
10 |
+
with gr.Blocks(
|
11 |
+
css=abs_path,
|
12 |
+
theme=gr.themes.Default(
|
13 |
+
font_mono=[
|
14 |
+
gr.themes.GoogleFont("Inconsolata"),
|
15 |
+
"monospace",
|
16 |
+
],
|
17 |
+
),
|
18 |
+
) as demo:
|
19 |
+
gr.Markdown(
|
20 |
+
"""
|
21 |
+
# `gradio_carousel`
|
22 |
+
|
23 |
+
<div style="display: flex; gap: 7px;">
|
24 |
+
<img alt="Static Badge" src="https://img.shields.io/badge/version%20-%200.0.1%20-%20orange">
|
25 |
+
</div>
|
26 |
+
|
27 |
+
Python library for easily interacting with trained machine learning models
|
28 |
+
""", elem_classes=["md-custom"], header_links=True)
|
29 |
+
app.render()
|
30 |
+
gr.Markdown(
|
31 |
+
"""
|
32 |
+
## Installation
|
33 |
+
|
34 |
+
```bash
|
35 |
+
pip install gradio_carousel
|
36 |
+
```
|
37 |
+
|
38 |
+
## Usage
|
39 |
+
|
40 |
+
```python
|
41 |
+
|
42 |
+
|
43 |
+
import os
|
44 |
+
|
45 |
+
import gradio as gr
|
46 |
+
from gradio_carousel import Carousel
|
47 |
+
|
48 |
+
image_dir = os.path.join(os.path.dirname(__file__), "alligator_images")
|
49 |
+
|
50 |
+
images = [os.path.join(image_dir, file) for file in os.listdir(image_dir) if file.endswith((".jpg", ".jpeg", ".png"))]
|
51 |
+
|
52 |
+
with gr.Blocks() as demo:
|
53 |
+
with gr.Row():
|
54 |
+
Carousel(label="cool gators", value=images) # carousel component with images
|
55 |
+
|
56 |
+
|
57 |
+
if __name__ == "__main__":
|
58 |
+
demo.launch()
|
59 |
+
|
60 |
+
```
|
61 |
+
""", elem_classes=["md-custom"], header_links=True)
|
62 |
+
|
63 |
+
|
64 |
+
gr.Markdown("""
|
65 |
+
## `Carousel`
|
66 |
+
|
67 |
+
### Initialization
|
68 |
+
""", elem_classes=["md-custom"], header_links=True)
|
69 |
+
|
70 |
+
gr.ParamViewer(value=_docs["Carousel"]["members"]["__init__"], linkify=[])
|
71 |
+
|
72 |
+
|
73 |
+
gr.Markdown("### Events")
|
74 |
+
gr.ParamViewer(value=_docs["Carousel"]["events"], linkify=['Event'])
|
75 |
+
|
76 |
+
|
77 |
+
|
78 |
+
|
79 |
+
gr.Markdown("""
|
80 |
+
|
81 |
+
### User function
|
82 |
+
|
83 |
+
The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
|
84 |
+
|
85 |
+
- When used as an Input, the component only impacts the input signature of the user function.
|
86 |
+
- When used as an output, the component only impacts the return signature of the user function.
|
87 |
+
|
88 |
+
The code snippet below is accurate in cases where the component is used as both an input and an output.
|
89 |
+
|
90 |
+
- **As output:** Should return, list of images, or list of (image, caption) tuples.
|
91 |
+
|
92 |
+
```python
|
93 |
+
def predict(
|
94 |
+
value: list[tuple[str, str | None]]
|
95 |
+
| list[tuple[PIL.Image.Image, str | None]]
|
96 |
+
| list[tuple[numpy.ndarray, str | None]]
|
97 |
+
| None
|
98 |
+
) -> list[
|
99 |
+
numpy.ndarray
|
100 |
+
| PIL.Image.Image
|
101 |
+
| pathlib.Path
|
102 |
+
| str
|
103 |
+
| tuple[
|
104 |
+
numpy.ndarray
|
105 |
+
| PIL.Image.Image
|
106 |
+
| pathlib.Path
|
107 |
+
| str,
|
108 |
+
str,
|
109 |
+
]
|
110 |
+
]
|
111 |
+
| None:
|
112 |
+
return value
|
113 |
+
```
|
114 |
+
""", elem_classes=["md-custom", "Carousel-user-fn"], header_links=True)
|
115 |
+
|
116 |
+
|
117 |
+
|
118 |
+
|
119 |
+
demo.load(None, js=r"""function() {
|
120 |
+
const refs = {};
|
121 |
+
const user_fn_refs = {
|
122 |
+
Carousel: [], };
|
123 |
+
requestAnimationFrame(() => {
|
124 |
+
|
125 |
+
Object.entries(user_fn_refs).forEach(([key, refs]) => {
|
126 |
+
if (refs.length > 0) {
|
127 |
+
const el = document.querySelector(`.${key}-user-fn`);
|
128 |
+
if (!el) return;
|
129 |
+
refs.forEach(ref => {
|
130 |
+
el.innerHTML = el.innerHTML.replace(
|
131 |
+
new RegExp("\\b"+ref+"\\b", "g"),
|
132 |
+
`<a href="#h-${ref.toLowerCase()}">${ref}</a>`
|
133 |
+
);
|
134 |
+
})
|
135 |
+
}
|
136 |
+
})
|
137 |
+
|
138 |
+
Object.entries(refs).forEach(([key, refs]) => {
|
139 |
+
if (refs.length > 0) {
|
140 |
+
const el = document.querySelector(`.${key}`);
|
141 |
+
if (!el) return;
|
142 |
+
refs.forEach(ref => {
|
143 |
+
el.innerHTML = el.innerHTML.replace(
|
144 |
+
new RegExp("\\b"+ref+"\\b", "g"),
|
145 |
+
`<a href="#h-${ref.toLowerCase()}">${ref}</a>`
|
146 |
+
);
|
147 |
+
})
|
148 |
+
}
|
149 |
+
})
|
150 |
+
})
|
151 |
+
}
|
152 |
+
|
153 |
+
""")
|
154 |
+
|
155 |
+
demo.launch()
|
src/frontend/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
src/frontend/Index.svelte
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script context="module" lang="ts">
|
2 |
+
export { default as BaseGallery } from "./shared/Gallery.svelte";
|
3 |
+
</script>
|
4 |
+
|
5 |
+
<script lang="ts">
|
6 |
+
import type { Gradio, ShareData, SelectData } from "@gradio/utils";
|
7 |
+
import { Block, UploadText } from "@gradio/atoms";
|
8 |
+
import Gallery from "./shared/Gallery.svelte";
|
9 |
+
import type { LoadingStatus } from "@gradio/statustracker";
|
10 |
+
import { StatusTracker } from "@gradio/statustracker";
|
11 |
+
import type { FileData } from "@gradio/client";
|
12 |
+
import { createEventDispatcher } from "svelte";
|
13 |
+
import { BaseFileUpload } from "@gradio/file";
|
14 |
+
|
15 |
+
export let loading_status: LoadingStatus;
|
16 |
+
export let show_label: boolean;
|
17 |
+
export let label: string;
|
18 |
+
export let root: string;
|
19 |
+
export let proxy_url: null | string;
|
20 |
+
export let elem_id = "";
|
21 |
+
export let elem_classes: string[] = [];
|
22 |
+
export let visible = true;
|
23 |
+
export let value: { image: FileData; caption: string | null }[] | null = null;
|
24 |
+
export let container = true;
|
25 |
+
export let scale: number | null = null;
|
26 |
+
export let min_width: number | undefined = undefined;
|
27 |
+
export let columns: number | number[] | undefined = [2];
|
28 |
+
export let rows: number | number[] | undefined = undefined;
|
29 |
+
export let height: number | "auto" = "auto";
|
30 |
+
export let preview: boolean;
|
31 |
+
export let allow_preview = true;
|
32 |
+
export let selected_index: number | null = null;
|
33 |
+
export let object_fit: "contain" | "cover" | "fill" | "none" | "scale-down" =
|
34 |
+
"cover";
|
35 |
+
export let show_share_button = false;
|
36 |
+
export let interactive: boolean;
|
37 |
+
export let show_download_button = false;
|
38 |
+
export let gradio: Gradio<{
|
39 |
+
change: typeof value;
|
40 |
+
upload: typeof value;
|
41 |
+
select: SelectData;
|
42 |
+
share: ShareData;
|
43 |
+
error: string;
|
44 |
+
prop_change: Record<string, any>;
|
45 |
+
}>;
|
46 |
+
|
47 |
+
const dispatch = createEventDispatcher();
|
48 |
+
|
49 |
+
$: no_value = Array.isArray(value) ? value.length === 0 : !value;
|
50 |
+
$: selected_index, dispatch("prop_change", { selected_index });
|
51 |
+
</script>
|
52 |
+
|
53 |
+
<Block
|
54 |
+
{visible}
|
55 |
+
variant="solid"
|
56 |
+
padding={false}
|
57 |
+
{elem_id}
|
58 |
+
{elem_classes}
|
59 |
+
{container}
|
60 |
+
{scale}
|
61 |
+
{min_width}
|
62 |
+
allow_overflow={false}
|
63 |
+
height={typeof height === "number" ? height : undefined}
|
64 |
+
>
|
65 |
+
<StatusTracker
|
66 |
+
autoscroll={gradio.autoscroll}
|
67 |
+
i18n={gradio.i18n}
|
68 |
+
{...loading_status}
|
69 |
+
/>
|
70 |
+
{#if interactive && no_value}
|
71 |
+
<BaseFileUpload
|
72 |
+
value={null}
|
73 |
+
{root}
|
74 |
+
{label}
|
75 |
+
file_count={"multiple"}
|
76 |
+
file_types={["image"]}
|
77 |
+
i18n={gradio.i18n}
|
78 |
+
on:upload={(e) => {
|
79 |
+
const files = Array.isArray(e.detail) ? e.detail : [e.detail];
|
80 |
+
value = files.map((x) => ({ image: x, caption: null }));
|
81 |
+
gradio.dispatch("upload", value);
|
82 |
+
}}
|
83 |
+
>
|
84 |
+
<UploadText i18n={gradio.i18n} type="gallery" />
|
85 |
+
</BaseFileUpload>
|
86 |
+
{:else}
|
87 |
+
<Gallery
|
88 |
+
on:change={() => gradio.dispatch("change", value)}
|
89 |
+
on:select={(e) => gradio.dispatch("select", e.detail)}
|
90 |
+
on:share={(e) => gradio.dispatch("share", e.detail)}
|
91 |
+
on:error={(e) => gradio.dispatch("error", e.detail)}
|
92 |
+
{label}
|
93 |
+
{show_label}
|
94 |
+
{root}
|
95 |
+
{proxy_url}
|
96 |
+
{columns}
|
97 |
+
{rows}
|
98 |
+
{height}
|
99 |
+
{preview}
|
100 |
+
{object_fit}
|
101 |
+
{interactive}
|
102 |
+
{allow_preview}
|
103 |
+
bind:selected_index
|
104 |
+
bind:value
|
105 |
+
{show_share_button}
|
106 |
+
{show_download_button}
|
107 |
+
i18n={gradio.i18n}
|
108 |
+
/>
|
109 |
+
{/if}
|
110 |
+
</Block>
|
src/frontend/package-lock.json
ADDED
@@ -0,0 +1,1117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "gradio_carousel",
|
3 |
+
"version": "0.6.0",
|
4 |
+
"lockfileVersion": 3,
|
5 |
+
"requires": true,
|
6 |
+
"packages": {
|
7 |
+
"": {
|
8 |
+
"name": "gradio_carousel",
|
9 |
+
"version": "0.6.0",
|
10 |
+
"license": "ISC",
|
11 |
+
"dependencies": {
|
12 |
+
"@gradio/atoms": "0.5.0",
|
13 |
+
"@gradio/client": "0.10.1",
|
14 |
+
"@gradio/file": "0.4.8",
|
15 |
+
"@gradio/icons": "0.3.2",
|
16 |
+
"@gradio/image": "0.7.1",
|
17 |
+
"@gradio/statustracker": "0.4.4",
|
18 |
+
"@gradio/upload": "0.7.0",
|
19 |
+
"@gradio/utils": "0.2.1",
|
20 |
+
"@gradio/wasm": "0.5.1",
|
21 |
+
"dequal": "^2.0.2",
|
22 |
+
"embla-carousel": "^8.0.0-rc22",
|
23 |
+
"embla-carousel-autoplay": "^8.0.0-rc22",
|
24 |
+
"embla-carousel-svelte": "^8.0.0-rc22"
|
25 |
+
}
|
26 |
+
},
|
27 |
+
"node_modules/@ampproject/remapping": {
|
28 |
+
"version": "2.2.1",
|
29 |
+
"resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz",
|
30 |
+
"integrity": "sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==",
|
31 |
+
"peer": true,
|
32 |
+
"dependencies": {
|
33 |
+
"@jridgewell/gen-mapping": "^0.3.0",
|
34 |
+
"@jridgewell/trace-mapping": "^0.3.9"
|
35 |
+
},
|
36 |
+
"engines": {
|
37 |
+
"node": ">=6.0.0"
|
38 |
+
}
|
39 |
+
},
|
40 |
+
"node_modules/@esbuild/aix-ppc64": {
|
41 |
+
"version": "0.19.12",
|
42 |
+
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.19.12.tgz",
|
43 |
+
"integrity": "sha512-bmoCYyWdEL3wDQIVbcyzRyeKLgk2WtWLTWz1ZIAZF/EGbNOwSA6ew3PftJ1PqMiOOGu0OyFMzG53L0zqIpPeNA==",
|
44 |
+
"cpu": [
|
45 |
+
"ppc64"
|
46 |
+
],
|
47 |
+
"optional": true,
|
48 |
+
"os": [
|
49 |
+
"aix"
|
50 |
+
],
|
51 |
+
"engines": {
|
52 |
+
"node": ">=12"
|
53 |
+
}
|
54 |
+
},
|
55 |
+
"node_modules/@esbuild/android-arm": {
|
56 |
+
"version": "0.19.12",
|
57 |
+
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.12.tgz",
|
58 |
+
"integrity": "sha512-qg/Lj1mu3CdQlDEEiWrlC4eaPZ1KztwGJ9B6J+/6G+/4ewxJg7gqj8eVYWvao1bXrqGiW2rsBZFSX3q2lcW05w==",
|
59 |
+
"cpu": [
|
60 |
+
"arm"
|
61 |
+
],
|
62 |
+
"optional": true,
|
63 |
+
"os": [
|
64 |
+
"android"
|
65 |
+
],
|
66 |
+
"engines": {
|
67 |
+
"node": ">=12"
|
68 |
+
}
|
69 |
+
},
|
70 |
+
"node_modules/@esbuild/android-arm64": {
|
71 |
+
"version": "0.19.12",
|
72 |
+
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.19.12.tgz",
|
73 |
+
"integrity": "sha512-P0UVNGIienjZv3f5zq0DP3Nt2IE/3plFzuaS96vihvD0Hd6H/q4WXUGpCxD/E8YrSXfNyRPbpTq+T8ZQioSuPA==",
|
74 |
+
"cpu": [
|
75 |
+
"arm64"
|
76 |
+
],
|
77 |
+
"optional": true,
|
78 |
+
"os": [
|
79 |
+
"android"
|
80 |
+
],
|
81 |
+
"engines": {
|
82 |
+
"node": ">=12"
|
83 |
+
}
|
84 |
+
},
|
85 |
+
"node_modules/@esbuild/android-x64": {
|
86 |
+
"version": "0.19.12",
|
87 |
+
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.19.12.tgz",
|
88 |
+
"integrity": "sha512-3k7ZoUW6Q6YqhdhIaq/WZ7HwBpnFBlW905Fa4s4qWJyiNOgT1dOqDiVAQFwBH7gBRZr17gLrlFCRzF6jFh7Kew==",
|
89 |
+
"cpu": [
|
90 |
+
"x64"
|
91 |
+
],
|
92 |
+
"optional": true,
|
93 |
+
"os": [
|
94 |
+
"android"
|
95 |
+
],
|
96 |
+
"engines": {
|
97 |
+
"node": ">=12"
|
98 |
+
}
|
99 |
+
},
|
100 |
+
"node_modules/@esbuild/darwin-arm64": {
|
101 |
+
"version": "0.19.12",
|
102 |
+
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.12.tgz",
|
103 |
+
"integrity": "sha512-B6IeSgZgtEzGC42jsI+YYu9Z3HKRxp8ZT3cqhvliEHovq8HSX2YX8lNocDn79gCKJXOSaEot9MVYky7AKjCs8g==",
|
104 |
+
"cpu": [
|
105 |
+
"arm64"
|
106 |
+
],
|
107 |
+
"optional": true,
|
108 |
+
"os": [
|
109 |
+
"darwin"
|
110 |
+
],
|
111 |
+
"engines": {
|
112 |
+
"node": ">=12"
|
113 |
+
}
|
114 |
+
},
|
115 |
+
"node_modules/@esbuild/darwin-x64": {
|
116 |
+
"version": "0.19.12",
|
117 |
+
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.19.12.tgz",
|
118 |
+
"integrity": "sha512-hKoVkKzFiToTgn+41qGhsUJXFlIjxI/jSYeZf3ugemDYZldIXIxhvwN6erJGlX4t5h417iFuheZ7l+YVn05N3A==",
|
119 |
+
"cpu": [
|
120 |
+
"x64"
|
121 |
+
],
|
122 |
+
"optional": true,
|
123 |
+
"os": [
|
124 |
+
"darwin"
|
125 |
+
],
|
126 |
+
"engines": {
|
127 |
+
"node": ">=12"
|
128 |
+
}
|
129 |
+
},
|
130 |
+
"node_modules/@esbuild/freebsd-arm64": {
|
131 |
+
"version": "0.19.12",
|
132 |
+
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.12.tgz",
|
133 |
+
"integrity": "sha512-4aRvFIXmwAcDBw9AueDQ2YnGmz5L6obe5kmPT8Vd+/+x/JMVKCgdcRwH6APrbpNXsPz+K653Qg8HB/oXvXVukA==",
|
134 |
+
"cpu": [
|
135 |
+
"arm64"
|
136 |
+
],
|
137 |
+
"optional": true,
|
138 |
+
"os": [
|
139 |
+
"freebsd"
|
140 |
+
],
|
141 |
+
"engines": {
|
142 |
+
"node": ">=12"
|
143 |
+
}
|
144 |
+
},
|
145 |
+
"node_modules/@esbuild/freebsd-x64": {
|
146 |
+
"version": "0.19.12",
|
147 |
+
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.19.12.tgz",
|
148 |
+
"integrity": "sha512-EYoXZ4d8xtBoVN7CEwWY2IN4ho76xjYXqSXMNccFSx2lgqOG/1TBPW0yPx1bJZk94qu3tX0fycJeeQsKovA8gg==",
|
149 |
+
"cpu": [
|
150 |
+
"x64"
|
151 |
+
],
|
152 |
+
"optional": true,
|
153 |
+
"os": [
|
154 |
+
"freebsd"
|
155 |
+
],
|
156 |
+
"engines": {
|
157 |
+
"node": ">=12"
|
158 |
+
}
|
159 |
+
},
|
160 |
+
"node_modules/@esbuild/linux-arm": {
|
161 |
+
"version": "0.19.12",
|
162 |
+
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.19.12.tgz",
|
163 |
+
"integrity": "sha512-J5jPms//KhSNv+LO1S1TX1UWp1ucM6N6XuL6ITdKWElCu8wXP72l9MM0zDTzzeikVyqFE6U8YAV9/tFyj0ti+w==",
|
164 |
+
"cpu": [
|
165 |
+
"arm"
|
166 |
+
],
|
167 |
+
"optional": true,
|
168 |
+
"os": [
|
169 |
+
"linux"
|
170 |
+
],
|
171 |
+
"engines": {
|
172 |
+
"node": ">=12"
|
173 |
+
}
|
174 |
+
},
|
175 |
+
"node_modules/@esbuild/linux-arm64": {
|
176 |
+
"version": "0.19.12",
|
177 |
+
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.19.12.tgz",
|
178 |
+
"integrity": "sha512-EoTjyYyLuVPfdPLsGVVVC8a0p1BFFvtpQDB/YLEhaXyf/5bczaGeN15QkR+O4S5LeJ92Tqotve7i1jn35qwvdA==",
|
179 |
+
"cpu": [
|
180 |
+
"arm64"
|
181 |
+
],
|
182 |
+
"optional": true,
|
183 |
+
"os": [
|
184 |
+
"linux"
|
185 |
+
],
|
186 |
+
"engines": {
|
187 |
+
"node": ">=12"
|
188 |
+
}
|
189 |
+
},
|
190 |
+
"node_modules/@esbuild/linux-ia32": {
|
191 |
+
"version": "0.19.12",
|
192 |
+
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.19.12.tgz",
|
193 |
+
"integrity": "sha512-Thsa42rrP1+UIGaWz47uydHSBOgTUnwBwNq59khgIwktK6x60Hivfbux9iNR0eHCHzOLjLMLfUMLCypBkZXMHA==",
|
194 |
+
"cpu": [
|
195 |
+
"ia32"
|
196 |
+
],
|
197 |
+
"optional": true,
|
198 |
+
"os": [
|
199 |
+
"linux"
|
200 |
+
],
|
201 |
+
"engines": {
|
202 |
+
"node": ">=12"
|
203 |
+
}
|
204 |
+
},
|
205 |
+
"node_modules/@esbuild/linux-loong64": {
|
206 |
+
"version": "0.19.12",
|
207 |
+
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.19.12.tgz",
|
208 |
+
"integrity": "sha512-LiXdXA0s3IqRRjm6rV6XaWATScKAXjI4R4LoDlvO7+yQqFdlr1Bax62sRwkVvRIrwXxvtYEHHI4dm50jAXkuAA==",
|
209 |
+
"cpu": [
|
210 |
+
"loong64"
|
211 |
+
],
|
212 |
+
"optional": true,
|
213 |
+
"os": [
|
214 |
+
"linux"
|
215 |
+
],
|
216 |
+
"engines": {
|
217 |
+
"node": ">=12"
|
218 |
+
}
|
219 |
+
},
|
220 |
+
"node_modules/@esbuild/linux-mips64el": {
|
221 |
+
"version": "0.19.12",
|
222 |
+
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.19.12.tgz",
|
223 |
+
"integrity": "sha512-fEnAuj5VGTanfJ07ff0gOA6IPsvrVHLVb6Lyd1g2/ed67oU1eFzL0r9WL7ZzscD+/N6i3dWumGE1Un4f7Amf+w==",
|
224 |
+
"cpu": [
|
225 |
+
"mips64el"
|
226 |
+
],
|
227 |
+
"optional": true,
|
228 |
+
"os": [
|
229 |
+
"linux"
|
230 |
+
],
|
231 |
+
"engines": {
|
232 |
+
"node": ">=12"
|
233 |
+
}
|
234 |
+
},
|
235 |
+
"node_modules/@esbuild/linux-ppc64": {
|
236 |
+
"version": "0.19.12",
|
237 |
+
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.19.12.tgz",
|
238 |
+
"integrity": "sha512-nYJA2/QPimDQOh1rKWedNOe3Gfc8PabU7HT3iXWtNUbRzXS9+vgB0Fjaqr//XNbd82mCxHzik2qotuI89cfixg==",
|
239 |
+
"cpu": [
|
240 |
+
"ppc64"
|
241 |
+
],
|
242 |
+
"optional": true,
|
243 |
+
"os": [
|
244 |
+
"linux"
|
245 |
+
],
|
246 |
+
"engines": {
|
247 |
+
"node": ">=12"
|
248 |
+
}
|
249 |
+
},
|
250 |
+
"node_modules/@esbuild/linux-riscv64": {
|
251 |
+
"version": "0.19.12",
|
252 |
+
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.19.12.tgz",
|
253 |
+
"integrity": "sha512-2MueBrlPQCw5dVJJpQdUYgeqIzDQgw3QtiAHUC4RBz9FXPrskyyU3VI1hw7C0BSKB9OduwSJ79FTCqtGMWqJHg==",
|
254 |
+
"cpu": [
|
255 |
+
"riscv64"
|
256 |
+
],
|
257 |
+
"optional": true,
|
258 |
+
"os": [
|
259 |
+
"linux"
|
260 |
+
],
|
261 |
+
"engines": {
|
262 |
+
"node": ">=12"
|
263 |
+
}
|
264 |
+
},
|
265 |
+
"node_modules/@esbuild/linux-s390x": {
|
266 |
+
"version": "0.19.12",
|
267 |
+
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.19.12.tgz",
|
268 |
+
"integrity": "sha512-+Pil1Nv3Umes4m3AZKqA2anfhJiVmNCYkPchwFJNEJN5QxmTs1uzyy4TvmDrCRNT2ApwSari7ZIgrPeUx4UZDg==",
|
269 |
+
"cpu": [
|
270 |
+
"s390x"
|
271 |
+
],
|
272 |
+
"optional": true,
|
273 |
+
"os": [
|
274 |
+
"linux"
|
275 |
+
],
|
276 |
+
"engines": {
|
277 |
+
"node": ">=12"
|
278 |
+
}
|
279 |
+
},
|
280 |
+
"node_modules/@esbuild/linux-x64": {
|
281 |
+
"version": "0.19.12",
|
282 |
+
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.19.12.tgz",
|
283 |
+
"integrity": "sha512-B71g1QpxfwBvNrfyJdVDexenDIt1CiDN1TIXLbhOw0KhJzE78KIFGX6OJ9MrtC0oOqMWf+0xop4qEU8JrJTwCg==",
|
284 |
+
"cpu": [
|
285 |
+
"x64"
|
286 |
+
],
|
287 |
+
"optional": true,
|
288 |
+
"os": [
|
289 |
+
"linux"
|
290 |
+
],
|
291 |
+
"engines": {
|
292 |
+
"node": ">=12"
|
293 |
+
}
|
294 |
+
},
|
295 |
+
"node_modules/@esbuild/netbsd-x64": {
|
296 |
+
"version": "0.19.12",
|
297 |
+
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.19.12.tgz",
|
298 |
+
"integrity": "sha512-3ltjQ7n1owJgFbuC61Oj++XhtzmymoCihNFgT84UAmJnxJfm4sYCiSLTXZtE00VWYpPMYc+ZQmB6xbSdVh0JWA==",
|
299 |
+
"cpu": [
|
300 |
+
"x64"
|
301 |
+
],
|
302 |
+
"optional": true,
|
303 |
+
"os": [
|
304 |
+
"netbsd"
|
305 |
+
],
|
306 |
+
"engines": {
|
307 |
+
"node": ">=12"
|
308 |
+
}
|
309 |
+
},
|
310 |
+
"node_modules/@esbuild/openbsd-x64": {
|
311 |
+
"version": "0.19.12",
|
312 |
+
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.19.12.tgz",
|
313 |
+
"integrity": "sha512-RbrfTB9SWsr0kWmb9srfF+L933uMDdu9BIzdA7os2t0TXhCRjrQyCeOt6wVxr79CKD4c+p+YhCj31HBkYcXebw==",
|
314 |
+
"cpu": [
|
315 |
+
"x64"
|
316 |
+
],
|
317 |
+
"optional": true,
|
318 |
+
"os": [
|
319 |
+
"openbsd"
|
320 |
+
],
|
321 |
+
"engines": {
|
322 |
+
"node": ">=12"
|
323 |
+
}
|
324 |
+
},
|
325 |
+
"node_modules/@esbuild/sunos-x64": {
|
326 |
+
"version": "0.19.12",
|
327 |
+
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.19.12.tgz",
|
328 |
+
"integrity": "sha512-HKjJwRrW8uWtCQnQOz9qcU3mUZhTUQvi56Q8DPTLLB+DawoiQdjsYq+j+D3s9I8VFtDr+F9CjgXKKC4ss89IeA==",
|
329 |
+
"cpu": [
|
330 |
+
"x64"
|
331 |
+
],
|
332 |
+
"optional": true,
|
333 |
+
"os": [
|
334 |
+
"sunos"
|
335 |
+
],
|
336 |
+
"engines": {
|
337 |
+
"node": ">=12"
|
338 |
+
}
|
339 |
+
},
|
340 |
+
"node_modules/@esbuild/win32-arm64": {
|
341 |
+
"version": "0.19.12",
|
342 |
+
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.19.12.tgz",
|
343 |
+
"integrity": "sha512-URgtR1dJnmGvX864pn1B2YUYNzjmXkuJOIqG2HdU62MVS4EHpU2946OZoTMnRUHklGtJdJZ33QfzdjGACXhn1A==",
|
344 |
+
"cpu": [
|
345 |
+
"arm64"
|
346 |
+
],
|
347 |
+
"optional": true,
|
348 |
+
"os": [
|
349 |
+
"win32"
|
350 |
+
],
|
351 |
+
"engines": {
|
352 |
+
"node": ">=12"
|
353 |
+
}
|
354 |
+
},
|
355 |
+
"node_modules/@esbuild/win32-ia32": {
|
356 |
+
"version": "0.19.12",
|
357 |
+
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.19.12.tgz",
|
358 |
+
"integrity": "sha512-+ZOE6pUkMOJfmxmBZElNOx72NKpIa/HFOMGzu8fqzQJ5kgf6aTGrcJaFsNiVMH4JKpMipyK+7k0n2UXN7a8YKQ==",
|
359 |
+
"cpu": [
|
360 |
+
"ia32"
|
361 |
+
],
|
362 |
+
"optional": true,
|
363 |
+
"os": [
|
364 |
+
"win32"
|
365 |
+
],
|
366 |
+
"engines": {
|
367 |
+
"node": ">=12"
|
368 |
+
}
|
369 |
+
},
|
370 |
+
"node_modules/@esbuild/win32-x64": {
|
371 |
+
"version": "0.19.12",
|
372 |
+
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.19.12.tgz",
|
373 |
+
"integrity": "sha512-T1QyPSDCyMXaO3pzBkF96E8xMkiRYbUEZADd29SyPGabqxMViNoii+NcK7eWJAEoU6RZyEm5lVSIjTmcdoB9HA==",
|
374 |
+
"cpu": [
|
375 |
+
"x64"
|
376 |
+
],
|
377 |
+
"optional": true,
|
378 |
+
"os": [
|
379 |
+
"win32"
|
380 |
+
],
|
381 |
+
"engines": {
|
382 |
+
"node": ">=12"
|
383 |
+
}
|
384 |
+
},
|
385 |
+
"node_modules/@formatjs/ecma402-abstract": {
|
386 |
+
"version": "1.11.4",
|
387 |
+
"resolved": "https://registry.npmjs.org/@formatjs/ecma402-abstract/-/ecma402-abstract-1.11.4.tgz",
|
388 |
+
"integrity": "sha512-EBikYFp2JCdIfGEb5G9dyCkTGDmC57KSHhRQOC3aYxoPWVZvfWCDjZwkGYHN7Lis/fmuWl906bnNTJifDQ3sXw==",
|
389 |
+
"dependencies": {
|
390 |
+
"@formatjs/intl-localematcher": "0.2.25",
|
391 |
+
"tslib": "^2.1.0"
|
392 |
+
}
|
393 |
+
},
|
394 |
+
"node_modules/@formatjs/fast-memoize": {
|
395 |
+
"version": "1.2.1",
|
396 |
+
"resolved": "https://registry.npmjs.org/@formatjs/fast-memoize/-/fast-memoize-1.2.1.tgz",
|
397 |
+
"integrity": "sha512-Rg0e76nomkz3vF9IPlKeV+Qynok0r7YZjL6syLz4/urSg0IbjPZCB/iYUMNsYA643gh4mgrX3T7KEIFIxJBQeg==",
|
398 |
+
"dependencies": {
|
399 |
+
"tslib": "^2.1.0"
|
400 |
+
}
|
401 |
+
},
|
402 |
+
"node_modules/@formatjs/icu-messageformat-parser": {
|
403 |
+
"version": "2.1.0",
|
404 |
+
"resolved": "https://registry.npmjs.org/@formatjs/icu-messageformat-parser/-/icu-messageformat-parser-2.1.0.tgz",
|
405 |
+
"integrity": "sha512-Qxv/lmCN6hKpBSss2uQ8IROVnta2r9jd3ymUEIjm2UyIkUCHVcbUVRGL/KS/wv7876edvsPe+hjHVJ4z8YuVaw==",
|
406 |
+
"dependencies": {
|
407 |
+
"@formatjs/ecma402-abstract": "1.11.4",
|
408 |
+
"@formatjs/icu-skeleton-parser": "1.3.6",
|
409 |
+
"tslib": "^2.1.0"
|
410 |
+
}
|
411 |
+
},
|
412 |
+
"node_modules/@formatjs/icu-skeleton-parser": {
|
413 |
+
"version": "1.3.6",
|
414 |
+
"resolved": "https://registry.npmjs.org/@formatjs/icu-skeleton-parser/-/icu-skeleton-parser-1.3.6.tgz",
|
415 |
+
"integrity": "sha512-I96mOxvml/YLrwU2Txnd4klA7V8fRhb6JG/4hm3VMNmeJo1F03IpV2L3wWt7EweqNLES59SZ4d6hVOPCSf80Bg==",
|
416 |
+
"dependencies": {
|
417 |
+
"@formatjs/ecma402-abstract": "1.11.4",
|
418 |
+
"tslib": "^2.1.0"
|
419 |
+
}
|
420 |
+
},
|
421 |
+
"node_modules/@formatjs/intl-localematcher": {
|
422 |
+
"version": "0.2.25",
|
423 |
+
"resolved": "https://registry.npmjs.org/@formatjs/intl-localematcher/-/intl-localematcher-0.2.25.tgz",
|
424 |
+
"integrity": "sha512-YmLcX70BxoSopLFdLr1Ds99NdlTI2oWoLbaUW2M406lxOIPzE1KQhRz2fPUkq34xVZQaihCoU29h0KK7An3bhA==",
|
425 |
+
"dependencies": {
|
426 |
+
"tslib": "^2.1.0"
|
427 |
+
}
|
428 |
+
},
|
429 |
+
"node_modules/@gradio/atoms": {
|
430 |
+
"version": "0.5.0",
|
431 |
+
"resolved": "https://registry.npmjs.org/@gradio/atoms/-/atoms-0.5.0.tgz",
|
432 |
+
"integrity": "sha512-BHDbusMOrmX16lfJdp2EE8ynWPCq8HUGz4fsyLqKzzjo1wR22MKIivjkWt2KVtuWE5foXzyXOWf1MvkhylIgwA==",
|
433 |
+
"dependencies": {
|
434 |
+
"@gradio/icons": "^0.3.2",
|
435 |
+
"@gradio/utils": "^0.2.1"
|
436 |
+
}
|
437 |
+
},
|
438 |
+
"node_modules/@gradio/client": {
|
439 |
+
"version": "0.10.1",
|
440 |
+
"resolved": "https://registry.npmjs.org/@gradio/client/-/client-0.10.1.tgz",
|
441 |
+
"integrity": "sha512-C3uWIWEqlpTuG3sfPw3K3+26Fkr+jXPL8U2lC1u7DlBm25rHdGMVX17o8ApW7XcFtznfaLceVtpnDPkDpQTJlw==",
|
442 |
+
"dependencies": {
|
443 |
+
"bufferutil": "^4.0.7",
|
444 |
+
"semiver": "^1.1.0",
|
445 |
+
"ws": "^8.13.0"
|
446 |
+
},
|
447 |
+
"engines": {
|
448 |
+
"node": ">=18.0.0"
|
449 |
+
}
|
450 |
+
},
|
451 |
+
"node_modules/@gradio/column": {
|
452 |
+
"version": "0.1.0",
|
453 |
+
"resolved": "https://registry.npmjs.org/@gradio/column/-/column-0.1.0.tgz",
|
454 |
+
"integrity": "sha512-P24nqqVnMXBaDA1f/zSN5HZRho4PxP8Dq+7VltPHlmxIEiZYik2AJ4J0LeuIha34FDO0guu/16evdrpvGIUAfw=="
|
455 |
+
},
|
456 |
+
"node_modules/@gradio/file": {
|
457 |
+
"version": "0.4.8",
|
458 |
+
"resolved": "https://registry.npmjs.org/@gradio/file/-/file-0.4.8.tgz",
|
459 |
+
"integrity": "sha512-fHxv/WTl3DC6p9CPWaWHTSh/nXOXMt8kFKwN2+u2snZN17pInrTIoxrIq54Ib6ODf3l3o4FplGCs7MbciUHC5w==",
|
460 |
+
"dependencies": {
|
461 |
+
"@gradio/atoms": "^0.5.0",
|
462 |
+
"@gradio/client": "^0.10.1",
|
463 |
+
"@gradio/icons": "^0.3.2",
|
464 |
+
"@gradio/statustracker": "^0.4.4",
|
465 |
+
"@gradio/upload": "^0.7.0",
|
466 |
+
"@gradio/utils": "^0.2.1",
|
467 |
+
"@gradio/wasm": "^0.5.1"
|
468 |
+
}
|
469 |
+
},
|
470 |
+
"node_modules/@gradio/icons": {
|
471 |
+
"version": "0.3.2",
|
472 |
+
"resolved": "https://registry.npmjs.org/@gradio/icons/-/icons-0.3.2.tgz",
|
473 |
+
"integrity": "sha512-l0jGfSRFiZ/doAXz6L+JEp6MN/a1BTZm88kqVoSnYrKSytP6bnBLRWeF4UvOi2T2fbVrNKenAEt/lwxJE5vK4w=="
|
474 |
+
},
|
475 |
+
"node_modules/@gradio/image": {
|
476 |
+
"version": "0.7.1",
|
477 |
+
"resolved": "https://registry.npmjs.org/@gradio/image/-/image-0.7.1.tgz",
|
478 |
+
"integrity": "sha512-A/aInBNcAs8VSRJK+y/RgP9sjhsrK4RoTMZP5SdpSksm1jAOxDYBR2oMpArkqvMLAgKUAoBkORnEG/pAmk/HUw==",
|
479 |
+
"dependencies": {
|
480 |
+
"@gradio/atoms": "^0.5.0",
|
481 |
+
"@gradio/client": "^0.10.1",
|
482 |
+
"@gradio/icons": "^0.3.2",
|
483 |
+
"@gradio/statustracker": "^0.4.4",
|
484 |
+
"@gradio/upload": "^0.7.0",
|
485 |
+
"@gradio/utils": "^0.2.1",
|
486 |
+
"@gradio/wasm": "^0.5.1",
|
487 |
+
"cropperjs": "^1.5.12",
|
488 |
+
"lazy-brush": "^1.0.1",
|
489 |
+
"resize-observer-polyfill": "^1.5.1"
|
490 |
+
}
|
491 |
+
},
|
492 |
+
"node_modules/@gradio/statustracker": {
|
493 |
+
"version": "0.4.4",
|
494 |
+
"resolved": "https://registry.npmjs.org/@gradio/statustracker/-/statustracker-0.4.4.tgz",
|
495 |
+
"integrity": "sha512-+bqdly30Tnj0YnM8VOAJjFs0i6RxlxRdQYrd0FRAilw0RDejmfO5LFH+vDRnPl0seK/Of37iP+E5CsqVD3dPeg==",
|
496 |
+
"dependencies": {
|
497 |
+
"@gradio/atoms": "^0.5.0",
|
498 |
+
"@gradio/column": "^0.1.0",
|
499 |
+
"@gradio/icons": "^0.3.2",
|
500 |
+
"@gradio/utils": "^0.2.1"
|
501 |
+
}
|
502 |
+
},
|
503 |
+
"node_modules/@gradio/theme": {
|
504 |
+
"version": "0.2.0",
|
505 |
+
"resolved": "https://registry.npmjs.org/@gradio/theme/-/theme-0.2.0.tgz",
|
506 |
+
"integrity": "sha512-33c68Nk7oRXLn08OxPfjcPm7S4tXGOUV1I1bVgzdM2YV5o1QBOS1GEnXPZPu/CEYPePLMB6bsDwffrLEyLGWVQ=="
|
507 |
+
},
|
508 |
+
"node_modules/@gradio/upload": {
|
509 |
+
"version": "0.7.0",
|
510 |
+
"resolved": "https://registry.npmjs.org/@gradio/upload/-/upload-0.7.0.tgz",
|
511 |
+
"integrity": "sha512-7RVTf76WX4apXXep35A1b9ZR/o9XtRWpECPslX68PbtdVuVz/lIKCtRy23E2IZmbeXUTFGaDCZItKhKCd8LPxg==",
|
512 |
+
"dependencies": {
|
513 |
+
"@gradio/atoms": "^0.5.0",
|
514 |
+
"@gradio/client": "^0.10.1",
|
515 |
+
"@gradio/icons": "^0.3.2",
|
516 |
+
"@gradio/upload": "^0.7.0",
|
517 |
+
"@gradio/utils": "^0.2.1",
|
518 |
+
"@gradio/wasm": "^0.5.1"
|
519 |
+
}
|
520 |
+
},
|
521 |
+
"node_modules/@gradio/utils": {
|
522 |
+
"version": "0.2.1",
|
523 |
+
"resolved": "https://registry.npmjs.org/@gradio/utils/-/utils-0.2.1.tgz",
|
524 |
+
"integrity": "sha512-7XnnY9R/FiJ55M2Sw+gHjSvTql5VWG3j2sh+Wt1jLnSURQARoAqizgo2Sg1WZU0igXzrrc9WVZdGE45m5qCHeg==",
|
525 |
+
"dependencies": {
|
526 |
+
"@gradio/theme": "^0.2.0",
|
527 |
+
"svelte-i18n": "^3.6.0"
|
528 |
+
}
|
529 |
+
},
|
530 |
+
"node_modules/@gradio/wasm": {
|
531 |
+
"version": "0.5.1",
|
532 |
+
"resolved": "https://registry.npmjs.org/@gradio/wasm/-/wasm-0.5.1.tgz",
|
533 |
+
"integrity": "sha512-g0UD8M3DSOliq8LB07JAPWxZ98sOzdghW9yF9HkfUdSS23BT8xs2/SHMZXh9Bq9jkZSzIdpktBeZbB1sjgDFgQ==",
|
534 |
+
"dependencies": {
|
535 |
+
"@types/path-browserify": "^1.0.0",
|
536 |
+
"path-browserify": "^1.0.1"
|
537 |
+
}
|
538 |
+
},
|
539 |
+
"node_modules/@jridgewell/gen-mapping": {
|
540 |
+
"version": "0.3.3",
|
541 |
+
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz",
|
542 |
+
"integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==",
|
543 |
+
"peer": true,
|
544 |
+
"dependencies": {
|
545 |
+
"@jridgewell/set-array": "^1.0.1",
|
546 |
+
"@jridgewell/sourcemap-codec": "^1.4.10",
|
547 |
+
"@jridgewell/trace-mapping": "^0.3.9"
|
548 |
+
},
|
549 |
+
"engines": {
|
550 |
+
"node": ">=6.0.0"
|
551 |
+
}
|
552 |
+
},
|
553 |
+
"node_modules/@jridgewell/resolve-uri": {
|
554 |
+
"version": "3.1.1",
|
555 |
+
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz",
|
556 |
+
"integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==",
|
557 |
+
"peer": true,
|
558 |
+
"engines": {
|
559 |
+
"node": ">=6.0.0"
|
560 |
+
}
|
561 |
+
},
|
562 |
+
"node_modules/@jridgewell/set-array": {
|
563 |
+
"version": "1.1.2",
|
564 |
+
"resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz",
|
565 |
+
"integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==",
|
566 |
+
"peer": true,
|
567 |
+
"engines": {
|
568 |
+
"node": ">=6.0.0"
|
569 |
+
}
|
570 |
+
},
|
571 |
+
"node_modules/@jridgewell/sourcemap-codec": {
|
572 |
+
"version": "1.4.15",
|
573 |
+
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz",
|
574 |
+
"integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==",
|
575 |
+
"peer": true
|
576 |
+
},
|
577 |
+
"node_modules/@jridgewell/trace-mapping": {
|
578 |
+
"version": "0.3.22",
|
579 |
+
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.22.tgz",
|
580 |
+
"integrity": "sha512-Wf963MzWtA2sjrNt+g18IAln9lKnlRp+K2eH4jjIoF1wYeq3aMREpG09xhlhdzS0EjwU7qmUJYangWa+151vZw==",
|
581 |
+
"peer": true,
|
582 |
+
"dependencies": {
|
583 |
+
"@jridgewell/resolve-uri": "^3.1.0",
|
584 |
+
"@jridgewell/sourcemap-codec": "^1.4.14"
|
585 |
+
}
|
586 |
+
},
|
587 |
+
"node_modules/@types/estree": {
|
588 |
+
"version": "1.0.5",
|
589 |
+
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz",
|
590 |
+
"integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==",
|
591 |
+
"peer": true
|
592 |
+
},
|
593 |
+
"node_modules/@types/path-browserify": {
|
594 |
+
"version": "1.0.2",
|
595 |
+
"resolved": "https://registry.npmjs.org/@types/path-browserify/-/path-browserify-1.0.2.tgz",
|
596 |
+
"integrity": "sha512-ZkC5IUqqIFPXx3ASTTybTzmQdwHwe2C0u3eL75ldQ6T9E9IWFJodn6hIfbZGab73DfyiHN4Xw15gNxUq2FbvBA=="
|
597 |
+
},
|
598 |
+
"node_modules/acorn": {
|
599 |
+
"version": "8.11.3",
|
600 |
+
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz",
|
601 |
+
"integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==",
|
602 |
+
"peer": true,
|
603 |
+
"bin": {
|
604 |
+
"acorn": "bin/acorn"
|
605 |
+
},
|
606 |
+
"engines": {
|
607 |
+
"node": ">=0.4.0"
|
608 |
+
}
|
609 |
+
},
|
610 |
+
"node_modules/aria-query": {
|
611 |
+
"version": "5.3.0",
|
612 |
+
"resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz",
|
613 |
+
"integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==",
|
614 |
+
"peer": true,
|
615 |
+
"dependencies": {
|
616 |
+
"dequal": "^2.0.3"
|
617 |
+
}
|
618 |
+
},
|
619 |
+
"node_modules/axobject-query": {
|
620 |
+
"version": "4.0.0",
|
621 |
+
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-4.0.0.tgz",
|
622 |
+
"integrity": "sha512-+60uv1hiVFhHZeO+Lz0RYzsVHy5Wr1ayX0mwda9KPDVLNJgZ1T9Ny7VmFbLDzxsH0D87I86vgj3gFrjTJUYznw==",
|
623 |
+
"peer": true,
|
624 |
+
"dependencies": {
|
625 |
+
"dequal": "^2.0.3"
|
626 |
+
}
|
627 |
+
},
|
628 |
+
"node_modules/bufferutil": {
|
629 |
+
"version": "4.0.8",
|
630 |
+
"resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.8.tgz",
|
631 |
+
"integrity": "sha512-4T53u4PdgsXqKaIctwF8ifXlRTTmEPJ8iEPWFdGZvcf7sbwYo6FKFEX9eNNAnzFZ7EzJAQ3CJeOtCRA4rDp7Pw==",
|
632 |
+
"hasInstallScript": true,
|
633 |
+
"dependencies": {
|
634 |
+
"node-gyp-build": "^4.3.0"
|
635 |
+
},
|
636 |
+
"engines": {
|
637 |
+
"node": ">=6.14.2"
|
638 |
+
}
|
639 |
+
},
|
640 |
+
"node_modules/cli-color": {
|
641 |
+
"version": "2.0.3",
|
642 |
+
"resolved": "https://registry.npmjs.org/cli-color/-/cli-color-2.0.3.tgz",
|
643 |
+
"integrity": "sha512-OkoZnxyC4ERN3zLzZaY9Emb7f/MhBOIpePv0Ycok0fJYT+Ouo00UBEIwsVsr0yoow++n5YWlSUgST9GKhNHiRQ==",
|
644 |
+
"dependencies": {
|
645 |
+
"d": "^1.0.1",
|
646 |
+
"es5-ext": "^0.10.61",
|
647 |
+
"es6-iterator": "^2.0.3",
|
648 |
+
"memoizee": "^0.4.15",
|
649 |
+
"timers-ext": "^0.1.7"
|
650 |
+
},
|
651 |
+
"engines": {
|
652 |
+
"node": ">=0.10"
|
653 |
+
}
|
654 |
+
},
|
655 |
+
"node_modules/code-red": {
|
656 |
+
"version": "1.0.4",
|
657 |
+
"resolved": "https://registry.npmjs.org/code-red/-/code-red-1.0.4.tgz",
|
658 |
+
"integrity": "sha512-7qJWqItLA8/VPVlKJlFXU+NBlo/qyfs39aJcuMT/2ere32ZqvF5OSxgdM5xOfJJ7O429gg2HM47y8v9P+9wrNw==",
|
659 |
+
"peer": true,
|
660 |
+
"dependencies": {
|
661 |
+
"@jridgewell/sourcemap-codec": "^1.4.15",
|
662 |
+
"@types/estree": "^1.0.1",
|
663 |
+
"acorn": "^8.10.0",
|
664 |
+
"estree-walker": "^3.0.3",
|
665 |
+
"periscopic": "^3.1.0"
|
666 |
+
}
|
667 |
+
},
|
668 |
+
"node_modules/cropperjs": {
|
669 |
+
"version": "1.6.1",
|
670 |
+
"resolved": "https://registry.npmjs.org/cropperjs/-/cropperjs-1.6.1.tgz",
|
671 |
+
"integrity": "sha512-F4wsi+XkDHCOMrHMYjrTEE4QBOrsHHN5/2VsVAaRq8P7E5z7xQpT75S+f/9WikmBEailas3+yo+6zPIomW+NOA=="
|
672 |
+
},
|
673 |
+
"node_modules/css-tree": {
|
674 |
+
"version": "2.3.1",
|
675 |
+
"resolved": "https://registry.npmjs.org/css-tree/-/css-tree-2.3.1.tgz",
|
676 |
+
"integrity": "sha512-6Fv1DV/TYw//QF5IzQdqsNDjx/wc8TrMBZsqjL9eW01tWb7R7k/mq+/VXfJCl7SoD5emsJop9cOByJZfs8hYIw==",
|
677 |
+
"peer": true,
|
678 |
+
"dependencies": {
|
679 |
+
"mdn-data": "2.0.30",
|
680 |
+
"source-map-js": "^1.0.1"
|
681 |
+
},
|
682 |
+
"engines": {
|
683 |
+
"node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0"
|
684 |
+
}
|
685 |
+
},
|
686 |
+
"node_modules/d": {
|
687 |
+
"version": "1.0.1",
|
688 |
+
"resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz",
|
689 |
+
"integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==",
|
690 |
+
"dependencies": {
|
691 |
+
"es5-ext": "^0.10.50",
|
692 |
+
"type": "^1.0.1"
|
693 |
+
}
|
694 |
+
},
|
695 |
+
"node_modules/deepmerge": {
|
696 |
+
"version": "4.3.1",
|
697 |
+
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz",
|
698 |
+
"integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==",
|
699 |
+
"engines": {
|
700 |
+
"node": ">=0.10.0"
|
701 |
+
}
|
702 |
+
},
|
703 |
+
"node_modules/dequal": {
|
704 |
+
"version": "2.0.3",
|
705 |
+
"resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",
|
706 |
+
"integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==",
|
707 |
+
"engines": {
|
708 |
+
"node": ">=6"
|
709 |
+
}
|
710 |
+
},
|
711 |
+
"node_modules/embla-carousel": {
|
712 |
+
"version": "8.0.0-rc22",
|
713 |
+
"resolved": "https://registry.npmjs.org/embla-carousel/-/embla-carousel-8.0.0-rc22.tgz",
|
714 |
+
"integrity": "sha512-MeXnPT1LShfgAu8qXj3CskayV0R6OkHx7w3cPTx+Q5ZWKyShKpIuu7qVQJ5BoFegalE4n6yxqoQaRuGFbK9pYw=="
|
715 |
+
},
|
716 |
+
"node_modules/embla-carousel-autoplay": {
|
717 |
+
"version": "8.0.0-rc22",
|
718 |
+
"resolved": "https://registry.npmjs.org/embla-carousel-autoplay/-/embla-carousel-autoplay-8.0.0-rc22.tgz",
|
719 |
+
"integrity": "sha512-UFR9ocKapxuYwcAOv8mb6Rmy7TENpzzHTymKADzB1L5dAJJxjUtOci/OpE3KrZedQaniLMz3HIO9hHqgj1h/3w==",
|
720 |
+
"peerDependencies": {
|
721 |
+
"embla-carousel": "8.0.0-rc22"
|
722 |
+
}
|
723 |
+
},
|
724 |
+
"node_modules/embla-carousel-reactive-utils": {
|
725 |
+
"version": "8.0.0-rc22",
|
726 |
+
"resolved": "https://registry.npmjs.org/embla-carousel-reactive-utils/-/embla-carousel-reactive-utils-8.0.0-rc22.tgz",
|
727 |
+
"integrity": "sha512-K4b8QhQGXYW5wr4l+U6XryhafsFV5c/IyohDnZN3MGoYIB9xY7qpjUWAcs5bTDjAD+qCZPOuXre0D3IVa28mqw==",
|
728 |
+
"peerDependencies": {
|
729 |
+
"embla-carousel": "8.0.0-rc22"
|
730 |
+
}
|
731 |
+
},
|
732 |
+
"node_modules/embla-carousel-svelte": {
|
733 |
+
"version": "8.0.0-rc22",
|
734 |
+
"resolved": "https://registry.npmjs.org/embla-carousel-svelte/-/embla-carousel-svelte-8.0.0-rc22.tgz",
|
735 |
+
"integrity": "sha512-kRcKJXslkfrtXjS97AdJHQ28ctm0HOfcTA3Fb9Y57fzLzrB5uC+qOGF7nLSI8Z1s+0ww+OaouxIvbrS987CkfA==",
|
736 |
+
"dependencies": {
|
737 |
+
"embla-carousel": "8.0.0-rc22",
|
738 |
+
"embla-carousel-reactive-utils": "8.0.0-rc22"
|
739 |
+
},
|
740 |
+
"peerDependencies": {
|
741 |
+
"svelte": "^3.49.0 || ^4.0.0"
|
742 |
+
}
|
743 |
+
},
|
744 |
+
"node_modules/es5-ext": {
|
745 |
+
"version": "0.10.62",
|
746 |
+
"resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz",
|
747 |
+
"integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==",
|
748 |
+
"hasInstallScript": true,
|
749 |
+
"dependencies": {
|
750 |
+
"es6-iterator": "^2.0.3",
|
751 |
+
"es6-symbol": "^3.1.3",
|
752 |
+
"next-tick": "^1.1.0"
|
753 |
+
},
|
754 |
+
"engines": {
|
755 |
+
"node": ">=0.10"
|
756 |
+
}
|
757 |
+
},
|
758 |
+
"node_modules/es6-iterator": {
|
759 |
+
"version": "2.0.3",
|
760 |
+
"resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz",
|
761 |
+
"integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==",
|
762 |
+
"dependencies": {
|
763 |
+
"d": "1",
|
764 |
+
"es5-ext": "^0.10.35",
|
765 |
+
"es6-symbol": "^3.1.1"
|
766 |
+
}
|
767 |
+
},
|
768 |
+
"node_modules/es6-symbol": {
|
769 |
+
"version": "3.1.3",
|
770 |
+
"resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz",
|
771 |
+
"integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==",
|
772 |
+
"dependencies": {
|
773 |
+
"d": "^1.0.1",
|
774 |
+
"ext": "^1.1.2"
|
775 |
+
}
|
776 |
+
},
|
777 |
+
"node_modules/es6-weak-map": {
|
778 |
+
"version": "2.0.3",
|
779 |
+
"resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.3.tgz",
|
780 |
+
"integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==",
|
781 |
+
"dependencies": {
|
782 |
+
"d": "1",
|
783 |
+
"es5-ext": "^0.10.46",
|
784 |
+
"es6-iterator": "^2.0.3",
|
785 |
+
"es6-symbol": "^3.1.1"
|
786 |
+
}
|
787 |
+
},
|
788 |
+
"node_modules/esbuild": {
|
789 |
+
"version": "0.19.12",
|
790 |
+
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.12.tgz",
|
791 |
+
"integrity": "sha512-aARqgq8roFBj054KvQr5f1sFu0D65G+miZRCuJyJ0G13Zwx7vRar5Zhn2tkQNzIXcBrNVsv/8stehpj+GAjgbg==",
|
792 |
+
"hasInstallScript": true,
|
793 |
+
"bin": {
|
794 |
+
"esbuild": "bin/esbuild"
|
795 |
+
},
|
796 |
+
"engines": {
|
797 |
+
"node": ">=12"
|
798 |
+
},
|
799 |
+
"optionalDependencies": {
|
800 |
+
"@esbuild/aix-ppc64": "0.19.12",
|
801 |
+
"@esbuild/android-arm": "0.19.12",
|
802 |
+
"@esbuild/android-arm64": "0.19.12",
|
803 |
+
"@esbuild/android-x64": "0.19.12",
|
804 |
+
"@esbuild/darwin-arm64": "0.19.12",
|
805 |
+
"@esbuild/darwin-x64": "0.19.12",
|
806 |
+
"@esbuild/freebsd-arm64": "0.19.12",
|
807 |
+
"@esbuild/freebsd-x64": "0.19.12",
|
808 |
+
"@esbuild/linux-arm": "0.19.12",
|
809 |
+
"@esbuild/linux-arm64": "0.19.12",
|
810 |
+
"@esbuild/linux-ia32": "0.19.12",
|
811 |
+
"@esbuild/linux-loong64": "0.19.12",
|
812 |
+
"@esbuild/linux-mips64el": "0.19.12",
|
813 |
+
"@esbuild/linux-ppc64": "0.19.12",
|
814 |
+
"@esbuild/linux-riscv64": "0.19.12",
|
815 |
+
"@esbuild/linux-s390x": "0.19.12",
|
816 |
+
"@esbuild/linux-x64": "0.19.12",
|
817 |
+
"@esbuild/netbsd-x64": "0.19.12",
|
818 |
+
"@esbuild/openbsd-x64": "0.19.12",
|
819 |
+
"@esbuild/sunos-x64": "0.19.12",
|
820 |
+
"@esbuild/win32-arm64": "0.19.12",
|
821 |
+
"@esbuild/win32-ia32": "0.19.12",
|
822 |
+
"@esbuild/win32-x64": "0.19.12"
|
823 |
+
}
|
824 |
+
},
|
825 |
+
"node_modules/estree-walker": {
|
826 |
+
"version": "3.0.3",
|
827 |
+
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz",
|
828 |
+
"integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==",
|
829 |
+
"peer": true,
|
830 |
+
"dependencies": {
|
831 |
+
"@types/estree": "^1.0.0"
|
832 |
+
}
|
833 |
+
},
|
834 |
+
"node_modules/event-emitter": {
|
835 |
+
"version": "0.3.5",
|
836 |
+
"resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz",
|
837 |
+
"integrity": "sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==",
|
838 |
+
"dependencies": {
|
839 |
+
"d": "1",
|
840 |
+
"es5-ext": "~0.10.14"
|
841 |
+
}
|
842 |
+
},
|
843 |
+
"node_modules/ext": {
|
844 |
+
"version": "1.7.0",
|
845 |
+
"resolved": "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz",
|
846 |
+
"integrity": "sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==",
|
847 |
+
"dependencies": {
|
848 |
+
"type": "^2.7.2"
|
849 |
+
}
|
850 |
+
},
|
851 |
+
"node_modules/ext/node_modules/type": {
|
852 |
+
"version": "2.7.2",
|
853 |
+
"resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz",
|
854 |
+
"integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw=="
|
855 |
+
},
|
856 |
+
"node_modules/globalyzer": {
|
857 |
+
"version": "0.1.0",
|
858 |
+
"resolved": "https://registry.npmjs.org/globalyzer/-/globalyzer-0.1.0.tgz",
|
859 |
+
"integrity": "sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q=="
|
860 |
+
},
|
861 |
+
"node_modules/globrex": {
|
862 |
+
"version": "0.1.2",
|
863 |
+
"resolved": "https://registry.npmjs.org/globrex/-/globrex-0.1.2.tgz",
|
864 |
+
"integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg=="
|
865 |
+
},
|
866 |
+
"node_modules/intl-messageformat": {
|
867 |
+
"version": "9.13.0",
|
868 |
+
"resolved": "https://registry.npmjs.org/intl-messageformat/-/intl-messageformat-9.13.0.tgz",
|
869 |
+
"integrity": "sha512-7sGC7QnSQGa5LZP7bXLDhVDtQOeKGeBFGHF2Y8LVBwYZoQZCgWeKoPGTa5GMG8g/TzDgeXuYJQis7Ggiw2xTOw==",
|
870 |
+
"dependencies": {
|
871 |
+
"@formatjs/ecma402-abstract": "1.11.4",
|
872 |
+
"@formatjs/fast-memoize": "1.2.1",
|
873 |
+
"@formatjs/icu-messageformat-parser": "2.1.0",
|
874 |
+
"tslib": "^2.1.0"
|
875 |
+
}
|
876 |
+
},
|
877 |
+
"node_modules/is-promise": {
|
878 |
+
"version": "2.2.2",
|
879 |
+
"resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz",
|
880 |
+
"integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ=="
|
881 |
+
},
|
882 |
+
"node_modules/is-reference": {
|
883 |
+
"version": "3.0.2",
|
884 |
+
"resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.2.tgz",
|
885 |
+
"integrity": "sha512-v3rht/LgVcsdZa3O2Nqs+NMowLOxeOm7Ay9+/ARQ2F+qEoANRcqrjAZKGN0v8ymUetZGgkp26LTnGT7H0Qo9Pg==",
|
886 |
+
"peer": true,
|
887 |
+
"dependencies": {
|
888 |
+
"@types/estree": "*"
|
889 |
+
}
|
890 |
+
},
|
891 |
+
"node_modules/lazy-brush": {
|
892 |
+
"version": "1.0.1",
|
893 |
+
"resolved": "https://registry.npmjs.org/lazy-brush/-/lazy-brush-1.0.1.tgz",
|
894 |
+
"integrity": "sha512-xT/iSClTVi7vLoF8dCWTBhCuOWqsLXCMPa6ucVmVAk6hyNCM5JeS1NLhXqIrJktUg+caEYKlqSOUU4u3cpXzKg=="
|
895 |
+
},
|
896 |
+
"node_modules/locate-character": {
|
897 |
+
"version": "3.0.0",
|
898 |
+
"resolved": "https://registry.npmjs.org/locate-character/-/locate-character-3.0.0.tgz",
|
899 |
+
"integrity": "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==",
|
900 |
+
"peer": true
|
901 |
+
},
|
902 |
+
"node_modules/lru-queue": {
|
903 |
+
"version": "0.1.0",
|
904 |
+
"resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz",
|
905 |
+
"integrity": "sha512-BpdYkt9EvGl8OfWHDQPISVpcl5xZthb+XPsbELj5AQXxIC8IriDZIQYjBJPEm5rS420sjZ0TLEzRcq5KdBhYrQ==",
|
906 |
+
"dependencies": {
|
907 |
+
"es5-ext": "~0.10.2"
|
908 |
+
}
|
909 |
+
},
|
910 |
+
"node_modules/magic-string": {
|
911 |
+
"version": "0.30.6",
|
912 |
+
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.6.tgz",
|
913 |
+
"integrity": "sha512-n62qCLbPjNjyo+owKtveQxZFZTBm+Ms6YoGD23Wew6Vw337PElFNifQpknPruVRQV57kVShPnLGo9vWxVhpPvA==",
|
914 |
+
"peer": true,
|
915 |
+
"dependencies": {
|
916 |
+
"@jridgewell/sourcemap-codec": "^1.4.15"
|
917 |
+
},
|
918 |
+
"engines": {
|
919 |
+
"node": ">=12"
|
920 |
+
}
|
921 |
+
},
|
922 |
+
"node_modules/mdn-data": {
|
923 |
+
"version": "2.0.30",
|
924 |
+
"resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.30.tgz",
|
925 |
+
"integrity": "sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==",
|
926 |
+
"peer": true
|
927 |
+
},
|
928 |
+
"node_modules/memoizee": {
|
929 |
+
"version": "0.4.15",
|
930 |
+
"resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.15.tgz",
|
931 |
+
"integrity": "sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ==",
|
932 |
+
"dependencies": {
|
933 |
+
"d": "^1.0.1",
|
934 |
+
"es5-ext": "^0.10.53",
|
935 |
+
"es6-weak-map": "^2.0.3",
|
936 |
+
"event-emitter": "^0.3.5",
|
937 |
+
"is-promise": "^2.2.2",
|
938 |
+
"lru-queue": "^0.1.0",
|
939 |
+
"next-tick": "^1.1.0",
|
940 |
+
"timers-ext": "^0.1.7"
|
941 |
+
}
|
942 |
+
},
|
943 |
+
"node_modules/mri": {
|
944 |
+
"version": "1.2.0",
|
945 |
+
"resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",
|
946 |
+
"integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==",
|
947 |
+
"engines": {
|
948 |
+
"node": ">=4"
|
949 |
+
}
|
950 |
+
},
|
951 |
+
"node_modules/next-tick": {
|
952 |
+
"version": "1.1.0",
|
953 |
+
"resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz",
|
954 |
+
"integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ=="
|
955 |
+
},
|
956 |
+
"node_modules/node-gyp-build": {
|
957 |
+
"version": "4.8.0",
|
958 |
+
"resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.0.tgz",
|
959 |
+
"integrity": "sha512-u6fs2AEUljNho3EYTJNBfImO5QTo/J/1Etd+NVdCj7qWKUSN/bSLkZwhDv7I+w/MSC6qJ4cknepkAYykDdK8og==",
|
960 |
+
"bin": {
|
961 |
+
"node-gyp-build": "bin.js",
|
962 |
+
"node-gyp-build-optional": "optional.js",
|
963 |
+
"node-gyp-build-test": "build-test.js"
|
964 |
+
}
|
965 |
+
},
|
966 |
+
"node_modules/path-browserify": {
|
967 |
+
"version": "1.0.1",
|
968 |
+
"resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz",
|
969 |
+
"integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g=="
|
970 |
+
},
|
971 |
+
"node_modules/periscopic": {
|
972 |
+
"version": "3.1.0",
|
973 |
+
"resolved": "https://registry.npmjs.org/periscopic/-/periscopic-3.1.0.tgz",
|
974 |
+
"integrity": "sha512-vKiQ8RRtkl9P+r/+oefh25C3fhybptkHKCZSPlcXiJux2tJF55GnEj3BVn4A5gKfq9NWWXXrxkHBwVPUfH0opw==",
|
975 |
+
"peer": true,
|
976 |
+
"dependencies": {
|
977 |
+
"@types/estree": "^1.0.0",
|
978 |
+
"estree-walker": "^3.0.0",
|
979 |
+
"is-reference": "^3.0.0"
|
980 |
+
}
|
981 |
+
},
|
982 |
+
"node_modules/resize-observer-polyfill": {
|
983 |
+
"version": "1.5.1",
|
984 |
+
"resolved": "https://registry.npmjs.org/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz",
|
985 |
+
"integrity": "sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg=="
|
986 |
+
},
|
987 |
+
"node_modules/sade": {
|
988 |
+
"version": "1.8.1",
|
989 |
+
"resolved": "https://registry.npmjs.org/sade/-/sade-1.8.1.tgz",
|
990 |
+
"integrity": "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==",
|
991 |
+
"dependencies": {
|
992 |
+
"mri": "^1.1.0"
|
993 |
+
},
|
994 |
+
"engines": {
|
995 |
+
"node": ">=6"
|
996 |
+
}
|
997 |
+
},
|
998 |
+
"node_modules/semiver": {
|
999 |
+
"version": "1.1.0",
|
1000 |
+
"resolved": "https://registry.npmjs.org/semiver/-/semiver-1.1.0.tgz",
|
1001 |
+
"integrity": "sha512-QNI2ChmuioGC1/xjyYwyZYADILWyW6AmS1UH6gDj/SFUUUS4MBAWs/7mxnkRPc/F4iHezDP+O8t0dO8WHiEOdg==",
|
1002 |
+
"engines": {
|
1003 |
+
"node": ">=6"
|
1004 |
+
}
|
1005 |
+
},
|
1006 |
+
"node_modules/source-map-js": {
|
1007 |
+
"version": "1.0.2",
|
1008 |
+
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz",
|
1009 |
+
"integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==",
|
1010 |
+
"peer": true,
|
1011 |
+
"engines": {
|
1012 |
+
"node": ">=0.10.0"
|
1013 |
+
}
|
1014 |
+
},
|
1015 |
+
"node_modules/svelte": {
|
1016 |
+
"version": "4.2.9",
|
1017 |
+
"resolved": "https://registry.npmjs.org/svelte/-/svelte-4.2.9.tgz",
|
1018 |
+
"integrity": "sha512-hsoB/WZGEPFXeRRLPhPrbRz67PhP6sqYgvwcAs+gWdSQSvNDw+/lTeUJSWe5h2xC97Fz/8QxAOqItwBzNJPU8w==",
|
1019 |
+
"peer": true,
|
1020 |
+
"dependencies": {
|
1021 |
+
"@ampproject/remapping": "^2.2.1",
|
1022 |
+
"@jridgewell/sourcemap-codec": "^1.4.15",
|
1023 |
+
"@jridgewell/trace-mapping": "^0.3.18",
|
1024 |
+
"@types/estree": "^1.0.1",
|
1025 |
+
"acorn": "^8.9.0",
|
1026 |
+
"aria-query": "^5.3.0",
|
1027 |
+
"axobject-query": "^4.0.0",
|
1028 |
+
"code-red": "^1.0.3",
|
1029 |
+
"css-tree": "^2.3.1",
|
1030 |
+
"estree-walker": "^3.0.3",
|
1031 |
+
"is-reference": "^3.0.1",
|
1032 |
+
"locate-character": "^3.0.0",
|
1033 |
+
"magic-string": "^0.30.4",
|
1034 |
+
"periscopic": "^3.1.0"
|
1035 |
+
},
|
1036 |
+
"engines": {
|
1037 |
+
"node": ">=16"
|
1038 |
+
}
|
1039 |
+
},
|
1040 |
+
"node_modules/svelte-i18n": {
|
1041 |
+
"version": "3.7.4",
|
1042 |
+
"resolved": "https://registry.npmjs.org/svelte-i18n/-/svelte-i18n-3.7.4.tgz",
|
1043 |
+
"integrity": "sha512-yGRCNo+eBT4cPuU7IVsYTYjxB7I2V8qgUZPlHnNctJj5IgbJgV78flsRzpjZ/8iUYZrS49oCt7uxlU3AZv/N5Q==",
|
1044 |
+
"dependencies": {
|
1045 |
+
"cli-color": "^2.0.3",
|
1046 |
+
"deepmerge": "^4.2.2",
|
1047 |
+
"esbuild": "^0.19.2",
|
1048 |
+
"estree-walker": "^2",
|
1049 |
+
"intl-messageformat": "^9.13.0",
|
1050 |
+
"sade": "^1.8.1",
|
1051 |
+
"tiny-glob": "^0.2.9"
|
1052 |
+
},
|
1053 |
+
"bin": {
|
1054 |
+
"svelte-i18n": "dist/cli.js"
|
1055 |
+
},
|
1056 |
+
"engines": {
|
1057 |
+
"node": ">= 16"
|
1058 |
+
},
|
1059 |
+
"peerDependencies": {
|
1060 |
+
"svelte": "^3 || ^4"
|
1061 |
+
}
|
1062 |
+
},
|
1063 |
+
"node_modules/svelte-i18n/node_modules/estree-walker": {
|
1064 |
+
"version": "2.0.2",
|
1065 |
+
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz",
|
1066 |
+
"integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w=="
|
1067 |
+
},
|
1068 |
+
"node_modules/timers-ext": {
|
1069 |
+
"version": "0.1.7",
|
1070 |
+
"resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz",
|
1071 |
+
"integrity": "sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==",
|
1072 |
+
"dependencies": {
|
1073 |
+
"es5-ext": "~0.10.46",
|
1074 |
+
"next-tick": "1"
|
1075 |
+
}
|
1076 |
+
},
|
1077 |
+
"node_modules/tiny-glob": {
|
1078 |
+
"version": "0.2.9",
|
1079 |
+
"resolved": "https://registry.npmjs.org/tiny-glob/-/tiny-glob-0.2.9.tgz",
|
1080 |
+
"integrity": "sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg==",
|
1081 |
+
"dependencies": {
|
1082 |
+
"globalyzer": "0.1.0",
|
1083 |
+
"globrex": "^0.1.2"
|
1084 |
+
}
|
1085 |
+
},
|
1086 |
+
"node_modules/tslib": {
|
1087 |
+
"version": "2.6.2",
|
1088 |
+
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
|
1089 |
+
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q=="
|
1090 |
+
},
|
1091 |
+
"node_modules/type": {
|
1092 |
+
"version": "1.2.0",
|
1093 |
+
"resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz",
|
1094 |
+
"integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg=="
|
1095 |
+
},
|
1096 |
+
"node_modules/ws": {
|
1097 |
+
"version": "8.16.0",
|
1098 |
+
"resolved": "https://registry.npmjs.org/ws/-/ws-8.16.0.tgz",
|
1099 |
+
"integrity": "sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==",
|
1100 |
+
"engines": {
|
1101 |
+
"node": ">=10.0.0"
|
1102 |
+
},
|
1103 |
+
"peerDependencies": {
|
1104 |
+
"bufferutil": "^4.0.1",
|
1105 |
+
"utf-8-validate": ">=5.0.2"
|
1106 |
+
},
|
1107 |
+
"peerDependenciesMeta": {
|
1108 |
+
"bufferutil": {
|
1109 |
+
"optional": true
|
1110 |
+
},
|
1111 |
+
"utf-8-validate": {
|
1112 |
+
"optional": true
|
1113 |
+
}
|
1114 |
+
}
|
1115 |
+
}
|
1116 |
+
}
|
1117 |
+
}
|
src/frontend/package.json
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "gradio_carousel",
|
3 |
+
"version": "0.6.0",
|
4 |
+
"description": "Gradio UI packages",
|
5 |
+
"type": "module",
|
6 |
+
"author": "",
|
7 |
+
"license": "ISC",
|
8 |
+
"private": false,
|
9 |
+
"dependencies": {
|
10 |
+
"@gradio/atoms": "0.5.0",
|
11 |
+
"@gradio/client": "0.10.1",
|
12 |
+
"@gradio/file": "0.4.8",
|
13 |
+
"@gradio/icons": "0.3.2",
|
14 |
+
"@gradio/image": "0.7.1",
|
15 |
+
"@gradio/statustracker": "0.4.4",
|
16 |
+
"@gradio/upload": "0.7.0",
|
17 |
+
"@gradio/utils": "0.2.1",
|
18 |
+
"@gradio/wasm": "0.5.1",
|
19 |
+
"dequal": "^2.0.2",
|
20 |
+
"embla-carousel": "^8.0.0-rc22",
|
21 |
+
"embla-carousel-autoplay": "^8.0.0-rc22",
|
22 |
+
"embla-carousel-svelte": "^8.0.0-rc22"
|
23 |
+
},
|
24 |
+
"main": "./Index.svelte",
|
25 |
+
"main_changeset": true,
|
26 |
+
"exports": {
|
27 |
+
".": "./Index.svelte",
|
28 |
+
"./package.json": "./package.json"
|
29 |
+
}
|
30 |
+
}
|
src/frontend/shared/Gallery.svelte
ADDED
@@ -0,0 +1,520 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script lang="ts">
|
2 |
+
import { BlockLabel, Empty, ShareButton } from "@gradio/atoms";
|
3 |
+
import { ModifyUpload } from "@gradio/upload";
|
4 |
+
import type { SelectData } from "@gradio/utils";
|
5 |
+
import { Image } from "@gradio/image/shared";
|
6 |
+
import { dequal } from "dequal";
|
7 |
+
import { createEventDispatcher, getContext } from "svelte";
|
8 |
+
import { tick } from "svelte";
|
9 |
+
import emblaCarouselSvelte from "embla-carousel-svelte";
|
10 |
+
import { setupTweenOpacity } from "./tweenOpacity";
|
11 |
+
import autoplay from "embla-carousel-autoplay";
|
12 |
+
|
13 |
+
import { Download, Image as ImageIcon } from "@gradio/icons";
|
14 |
+
import { normalise_file, type FileData } from "@gradio/client";
|
15 |
+
import { format_gallery_for_sharing } from "./utils";
|
16 |
+
import { IconButton } from "@gradio/atoms";
|
17 |
+
import type { I18nFormatter } from "@gradio/utils";
|
18 |
+
|
19 |
+
type GalleryImage = { image: FileData; caption: string | null };
|
20 |
+
type GalleryData = GalleryImage[];
|
21 |
+
|
22 |
+
export let show_label = true;
|
23 |
+
export let label: string;
|
24 |
+
export let root = "";
|
25 |
+
export let proxy_url: null | string = null;
|
26 |
+
export let value: GalleryData | null = null;
|
27 |
+
export let preview: boolean;
|
28 |
+
export let allow_preview = true;
|
29 |
+
export let show_share_button = false;
|
30 |
+
export let show_download_button = false;
|
31 |
+
export let i18n: I18nFormatter;
|
32 |
+
export let selected_index: number | null = null;
|
33 |
+
export let interactive: boolean;
|
34 |
+
|
35 |
+
const dispatch = createEventDispatcher<{
|
36 |
+
change: undefined;
|
37 |
+
select: SelectData;
|
38 |
+
}>();
|
39 |
+
|
40 |
+
let emblaApi;
|
41 |
+
let options = { loop: true };
|
42 |
+
|
43 |
+
const onInit = (event) => {
|
44 |
+
emblaApi = event.detail;
|
45 |
+
console.log(emblaApi.slideNodes());
|
46 |
+
};
|
47 |
+
|
48 |
+
$: if (emblaApi != null) {
|
49 |
+
const { applyTweenOpacity } = setupTweenOpacity(emblaApi);
|
50 |
+
|
51 |
+
emblaApi
|
52 |
+
.on("init", applyTweenOpacity)
|
53 |
+
.on("scroll", applyTweenOpacity)
|
54 |
+
.on("reInit", applyTweenOpacity);
|
55 |
+
}
|
56 |
+
|
57 |
+
// tracks whether the value of the gallery was reset
|
58 |
+
let was_reset = true;
|
59 |
+
|
60 |
+
$: was_reset = value == null || value.length === 0 ? true : was_reset;
|
61 |
+
|
62 |
+
let resolved_value: GalleryData | null = null;
|
63 |
+
$: resolved_value =
|
64 |
+
value == null
|
65 |
+
? null
|
66 |
+
: value.map((data) => ({
|
67 |
+
image: normalise_file(data.image, root, proxy_url) as FileData,
|
68 |
+
caption: data.caption,
|
69 |
+
}));
|
70 |
+
|
71 |
+
let prev_value: GalleryData | null = value;
|
72 |
+
if (selected_index == null && preview && value?.length) {
|
73 |
+
selected_index = 0;
|
74 |
+
}
|
75 |
+
let old_selected_index: number | null = selected_index;
|
76 |
+
|
77 |
+
$: if (!dequal(prev_value, value)) {
|
78 |
+
// When value is falsy (clear button or first load),
|
79 |
+
// preview determines the selected image
|
80 |
+
if (was_reset) {
|
81 |
+
selected_index = preview && value?.length ? 0 : null;
|
82 |
+
was_reset = false;
|
83 |
+
// Otherwise we keep the selected_index the same if the
|
84 |
+
// gallery has at least as many elements as it did before
|
85 |
+
} else {
|
86 |
+
selected_index =
|
87 |
+
selected_index != null && value != null && selected_index < value.length
|
88 |
+
? selected_index
|
89 |
+
: null;
|
90 |
+
}
|
91 |
+
dispatch("change");
|
92 |
+
prev_value = value;
|
93 |
+
}
|
94 |
+
|
95 |
+
$: previous =
|
96 |
+
((selected_index ?? 0) + (resolved_value?.length ?? 0) - 1) %
|
97 |
+
(resolved_value?.length ?? 0);
|
98 |
+
$: next = ((selected_index ?? 0) + 1) % (resolved_value?.length ?? 0);
|
99 |
+
|
100 |
+
function handle_preview_click(event: MouseEvent): void {
|
101 |
+
const element = event.target as HTMLElement;
|
102 |
+
const x = event.clientX;
|
103 |
+
const width = element.offsetWidth;
|
104 |
+
const centerX = width / 2;
|
105 |
+
|
106 |
+
if (x < centerX) {
|
107 |
+
selected_index = previous;
|
108 |
+
} else {
|
109 |
+
selected_index = next;
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
function on_keydown(e: KeyboardEvent): void {
|
114 |
+
switch (e.code) {
|
115 |
+
case "Escape":
|
116 |
+
e.preventDefault();
|
117 |
+
selected_index = null;
|
118 |
+
break;
|
119 |
+
case "ArrowLeft":
|
120 |
+
e.preventDefault();
|
121 |
+
selected_index = previous;
|
122 |
+
break;
|
123 |
+
case "ArrowRight":
|
124 |
+
e.preventDefault();
|
125 |
+
selected_index = next;
|
126 |
+
break;
|
127 |
+
default:
|
128 |
+
break;
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
132 |
+
$: {
|
133 |
+
if (selected_index !== old_selected_index) {
|
134 |
+
old_selected_index = selected_index;
|
135 |
+
if (selected_index !== null) {
|
136 |
+
dispatch("select", {
|
137 |
+
index: selected_index,
|
138 |
+
value: resolved_value?.[selected_index],
|
139 |
+
});
|
140 |
+
}
|
141 |
+
}
|
142 |
+
}
|
143 |
+
|
144 |
+
$: if (allow_preview) {
|
145 |
+
scroll_to_img(selected_index);
|
146 |
+
}
|
147 |
+
|
148 |
+
let el: HTMLButtonElement[] = [];
|
149 |
+
let container_element: HTMLDivElement;
|
150 |
+
|
151 |
+
async function scroll_to_img(index: number | null): Promise<void> {
|
152 |
+
if (typeof index !== "number") return;
|
153 |
+
await tick();
|
154 |
+
|
155 |
+
if (el[index] === undefined) return;
|
156 |
+
|
157 |
+
el[index]?.focus();
|
158 |
+
|
159 |
+
const { left: container_left, width: container_width } =
|
160 |
+
container_element.getBoundingClientRect();
|
161 |
+
const { left, width } = el[index].getBoundingClientRect();
|
162 |
+
|
163 |
+
const relative_left = left - container_left;
|
164 |
+
|
165 |
+
const pos =
|
166 |
+
relative_left +
|
167 |
+
width / 2 -
|
168 |
+
container_width / 2 +
|
169 |
+
container_element.scrollLeft;
|
170 |
+
|
171 |
+
if (container_element && typeof container_element.scrollTo === "function") {
|
172 |
+
container_element.scrollTo({
|
173 |
+
left: pos < 0 ? 0 : pos,
|
174 |
+
behavior: "smooth",
|
175 |
+
});
|
176 |
+
}
|
177 |
+
}
|
178 |
+
|
179 |
+
let client_height = 0;
|
180 |
+
let window_height = 0;
|
181 |
+
|
182 |
+
// Unlike `gr.Image()`, images specified via remote URLs are not cached in the server
|
183 |
+
// and their remote URLs are directly passed to the client as `value[].image.url`.
|
184 |
+
// The `download` attribute of the <a> tag doesn't work for remote URLs (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#download),
|
185 |
+
// so we need to download the image via JS as below.
|
186 |
+
const fetch_implementation = getContext<typeof fetch>("fetch_implementation");
|
187 |
+
async function download(file_url: string, name: string): Promise<void> {
|
188 |
+
let response;
|
189 |
+
try {
|
190 |
+
response = await fetch_implementation(file_url);
|
191 |
+
} catch (error) {
|
192 |
+
if (error instanceof TypeError) {
|
193 |
+
// If CORS is not allowed (https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#checking_that_the_fetch_was_successful),
|
194 |
+
// open the link in a new tab instead, mimicing the behavior of the `download` attribute for remote URLs,
|
195 |
+
// which is not ideal, but a reasonable fallback.
|
196 |
+
window.open(file_url, "_blank", "noreferrer");
|
197 |
+
return;
|
198 |
+
}
|
199 |
+
|
200 |
+
throw error;
|
201 |
+
}
|
202 |
+
const blob = await response.blob();
|
203 |
+
const url = URL.createObjectURL(blob);
|
204 |
+
const link = document.createElement("a");
|
205 |
+
link.href = url;
|
206 |
+
link.download = name;
|
207 |
+
link.click();
|
208 |
+
URL.revokeObjectURL(url);
|
209 |
+
}
|
210 |
+
|
211 |
+
$: selected_image =
|
212 |
+
selected_index != null && resolved_value != null
|
213 |
+
? resolved_value[selected_index]
|
214 |
+
: null;
|
215 |
+
</script>
|
216 |
+
|
217 |
+
<svelte:window bind:innerHeight={window_height} />
|
218 |
+
|
219 |
+
{#if show_label}
|
220 |
+
<BlockLabel {show_label} Icon={ImageIcon} label={label || "Gallery"} />
|
221 |
+
{/if}
|
222 |
+
{#if value == null || resolved_value == null || resolved_value.length === 0}
|
223 |
+
<Empty unpadded_box={true} size="large"><ImageIcon /></Empty>
|
224 |
+
{:else}
|
225 |
+
{#if selected_image && allow_preview}
|
226 |
+
<button on:keydown={on_keydown} class="preview">
|
227 |
+
<div class="icon-buttons">
|
228 |
+
{#if show_download_button}
|
229 |
+
<div class="download-button-container">
|
230 |
+
<IconButton
|
231 |
+
Icon={Download}
|
232 |
+
label={i18n("common.download")}
|
233 |
+
on:click={() => {
|
234 |
+
const image = selected_image?.image;
|
235 |
+
if (image == null) {
|
236 |
+
return;
|
237 |
+
}
|
238 |
+
const { url, orig_name } = image;
|
239 |
+
if (url) {
|
240 |
+
download(url, orig_name ?? "image");
|
241 |
+
}
|
242 |
+
}}
|
243 |
+
/>
|
244 |
+
</div>
|
245 |
+
{/if}
|
246 |
+
|
247 |
+
<ModifyUpload
|
248 |
+
{i18n}
|
249 |
+
absolute={false}
|
250 |
+
on:clear={() => (selected_index = null)}
|
251 |
+
/>
|
252 |
+
</div>
|
253 |
+
<button
|
254 |
+
class="image-button"
|
255 |
+
on:click={(event) => handle_preview_click(event)}
|
256 |
+
style="height: calc(100% - {selected_image.caption ? '80px' : '60px'})"
|
257 |
+
aria-label="detailed view of selected image"
|
258 |
+
>
|
259 |
+
<Image
|
260 |
+
data-testid="detailed-image"
|
261 |
+
src={selected_image.image.url}
|
262 |
+
alt={selected_image.caption || ""}
|
263 |
+
title={selected_image.caption || null}
|
264 |
+
class={selected_image.caption && "with-caption"}
|
265 |
+
loading="lazy"
|
266 |
+
/>
|
267 |
+
</button>
|
268 |
+
{#if selected_image?.caption}
|
269 |
+
<caption class="caption">
|
270 |
+
{selected_image.caption}
|
271 |
+
</caption>
|
272 |
+
{/if}
|
273 |
+
<div
|
274 |
+
bind:this={container_element}
|
275 |
+
class="thumbnails scroll-hide"
|
276 |
+
data-testid="container_el"
|
277 |
+
>
|
278 |
+
{#each resolved_value as image, i}
|
279 |
+
<button
|
280 |
+
bind:this={el[i]}
|
281 |
+
on:click={() => (selected_index = i)}
|
282 |
+
class="thumbnail-item thumbnail-small"
|
283 |
+
class:selected={selected_index === i}
|
284 |
+
aria-label={"Thumbnail " + (i + 1) + " of " + resolved_value.length}
|
285 |
+
>
|
286 |
+
<Image
|
287 |
+
src={image.image.url}
|
288 |
+
title={image.caption || null}
|
289 |
+
data-testid={"thumbnail " + (i + 1)}
|
290 |
+
alt=""
|
291 |
+
loading="lazy"
|
292 |
+
/>
|
293 |
+
</button>
|
294 |
+
{/each}
|
295 |
+
</div>
|
296 |
+
</button>
|
297 |
+
{/if}
|
298 |
+
|
299 |
+
<div class="embla">
|
300 |
+
<div
|
301 |
+
class="embla__viewport"
|
302 |
+
use:emblaCarouselSvelte={{
|
303 |
+
options,
|
304 |
+
plugins: [
|
305 |
+
autoplay({
|
306 |
+
delay: 2000,
|
307 |
+
}),
|
308 |
+
],
|
309 |
+
}}
|
310 |
+
on:emblaInit={onInit}
|
311 |
+
>
|
312 |
+
<div class="embla__container">
|
313 |
+
{#each resolved_value as entry, i}
|
314 |
+
<div class="embla__slide">
|
315 |
+
{#if interactive}
|
316 |
+
<div class="icon-button">
|
317 |
+
<ModifyUpload
|
318 |
+
{i18n}
|
319 |
+
absolute={false}
|
320 |
+
on:clear={() => (value = null)}
|
321 |
+
/>
|
322 |
+
</div>
|
323 |
+
{/if}
|
324 |
+
{#if show_share_button}
|
325 |
+
<div class="icon-button">
|
326 |
+
<ShareButton
|
327 |
+
{i18n}
|
328 |
+
on:share
|
329 |
+
on:error
|
330 |
+
value={resolved_value}
|
331 |
+
formatter={format_gallery_for_sharing}
|
332 |
+
/>
|
333 |
+
</div>
|
334 |
+
{/if}
|
335 |
+
<button
|
336 |
+
class="embla__slide__img"
|
337 |
+
class:selected={selected_index === i}
|
338 |
+
on:click={() => (selected_index = i)}
|
339 |
+
aria-label={"Thumbnail " +
|
340 |
+
(i + 1) +
|
341 |
+
" of " +
|
342 |
+
resolved_value.length}
|
343 |
+
>
|
344 |
+
<img
|
345 |
+
class="embla__slide__img"
|
346 |
+
src={entry.image.url}
|
347 |
+
alt={entry.caption || null}
|
348 |
+
loading="lazy"
|
349 |
+
/>
|
350 |
+
{#if entry.caption}
|
351 |
+
<div class="caption-label">
|
352 |
+
{entry.caption}
|
353 |
+
</div>
|
354 |
+
{/if}
|
355 |
+
</button>
|
356 |
+
</div>
|
357 |
+
{/each}
|
358 |
+
</div>
|
359 |
+
</div>
|
360 |
+
</div>
|
361 |
+
{/if}
|
362 |
+
|
363 |
+
<style lang="postcss">
|
364 |
+
.preview {
|
365 |
+
display: flex;
|
366 |
+
position: absolute;
|
367 |
+
top: 0px;
|
368 |
+
right: 0px;
|
369 |
+
bottom: 0px;
|
370 |
+
left: 0px;
|
371 |
+
flex-direction: column;
|
372 |
+
z-index: var(--layer-2);
|
373 |
+
backdrop-filter: blur(8px);
|
374 |
+
background: var(--background-fill-primary);
|
375 |
+
height: var(--size-full);
|
376 |
+
}
|
377 |
+
|
378 |
+
.image-button {
|
379 |
+
height: calc(100% - 60px);
|
380 |
+
width: 100%;
|
381 |
+
display: flex;
|
382 |
+
}
|
383 |
+
.image-button :global(img) {
|
384 |
+
width: var(--size-full);
|
385 |
+
height: var(--size-full);
|
386 |
+
object-fit: contain;
|
387 |
+
}
|
388 |
+
.thumbnails :global(img) {
|
389 |
+
object-fit: cover;
|
390 |
+
width: var(--size-full);
|
391 |
+
height: var(--size-full);
|
392 |
+
}
|
393 |
+
.preview :global(img.with-caption) {
|
394 |
+
height: var(--size-full);
|
395 |
+
}
|
396 |
+
|
397 |
+
.caption {
|
398 |
+
padding: var(--size-2) var(--size-3);
|
399 |
+
overflow: hidden;
|
400 |
+
color: var(--block-label-text-color);
|
401 |
+
font-weight: var(--weight-semibold);
|
402 |
+
text-align: center;
|
403 |
+
text-overflow: ellipsis;
|
404 |
+
white-space: nowrap;
|
405 |
+
align-self: center;
|
406 |
+
}
|
407 |
+
|
408 |
+
.thumbnails {
|
409 |
+
display: flex;
|
410 |
+
position: absolute;
|
411 |
+
bottom: 0;
|
412 |
+
justify-content: center;
|
413 |
+
align-items: center;
|
414 |
+
gap: var(--spacing-lg);
|
415 |
+
width: var(--size-full);
|
416 |
+
height: var(--size-14);
|
417 |
+
overflow-x: scroll;
|
418 |
+
}
|
419 |
+
|
420 |
+
.thumbnail-item {
|
421 |
+
--ring-color: transparent;
|
422 |
+
position: relative;
|
423 |
+
box-shadow:
|
424 |
+
0 0 0 2px var(--ring-color),
|
425 |
+
var(--shadow-drop);
|
426 |
+
border: 1px solid var(--border-color-primary);
|
427 |
+
border-radius: var(--button-small-radius);
|
428 |
+
background: var(--background-fill-secondary);
|
429 |
+
aspect-ratio: var(--ratio-square);
|
430 |
+
width: var(--size-full);
|
431 |
+
height: var(--size-full);
|
432 |
+
overflow: clip;
|
433 |
+
}
|
434 |
+
|
435 |
+
.thumbnail-item:hover {
|
436 |
+
--ring-color: var(--color-accent);
|
437 |
+
filter: brightness(1.1);
|
438 |
+
}
|
439 |
+
|
440 |
+
.thumbnail-item.selected {
|
441 |
+
--ring-color: var(--color-accent);
|
442 |
+
}
|
443 |
+
|
444 |
+
.thumbnail-small {
|
445 |
+
flex: none;
|
446 |
+
transform: scale(0.9);
|
447 |
+
transition: 0.075s;
|
448 |
+
width: var(--size-9);
|
449 |
+
height: var(--size-9);
|
450 |
+
}
|
451 |
+
|
452 |
+
.thumbnail-small.selected {
|
453 |
+
--ring-color: var(--color-accent);
|
454 |
+
transform: scale(1);
|
455 |
+
border-color: var(--color-accent);
|
456 |
+
}
|
457 |
+
|
458 |
+
.caption-label {
|
459 |
+
position: absolute;
|
460 |
+
right: var(--block-label-margin);
|
461 |
+
bottom: var(--block-label-margin);
|
462 |
+
z-index: var(--layer-1);
|
463 |
+
border-top: 1px solid var(--border-color-primary);
|
464 |
+
border-left: 1px solid var(--border-color-primary);
|
465 |
+
border-radius: var(--block-label-radius);
|
466 |
+
background: var(--background-fill-secondary);
|
467 |
+
padding: var(--block-label-padding);
|
468 |
+
max-width: 80%;
|
469 |
+
overflow: hidden;
|
470 |
+
font-size: var(--block-label-text-size);
|
471 |
+
text-align: left;
|
472 |
+
text-overflow: ellipsis;
|
473 |
+
white-space: nowrap;
|
474 |
+
}
|
475 |
+
|
476 |
+
.icon-button {
|
477 |
+
position: absolute;
|
478 |
+
top: 0px;
|
479 |
+
right: 0px;
|
480 |
+
z-index: var(--layer-1);
|
481 |
+
}
|
482 |
+
|
483 |
+
.icon-buttons {
|
484 |
+
display: flex;
|
485 |
+
position: absolute;
|
486 |
+
right: 0;
|
487 |
+
}
|
488 |
+
|
489 |
+
.icon-buttons .download-button-container {
|
490 |
+
margin: var(--size-1) 0;
|
491 |
+
}
|
492 |
+
|
493 |
+
.embla {
|
494 |
+
--slide-spacing: 1rem;
|
495 |
+
--slide-size: 50%;
|
496 |
+
--slide-height: 19rem;
|
497 |
+
padding: 1.6rem;
|
498 |
+
}
|
499 |
+
.embla__viewport {
|
500 |
+
overflow: hidden;
|
501 |
+
}
|
502 |
+
.embla__container {
|
503 |
+
backface-visibility: hidden;
|
504 |
+
display: flex;
|
505 |
+
touch-action: pan-y;
|
506 |
+
margin-left: calc(var(--slide-spacing) * -1);
|
507 |
+
}
|
508 |
+
.embla__slide {
|
509 |
+
flex: 0 0 var(--slide-size);
|
510 |
+
min-width: 0;
|
511 |
+
padding-left: var(--slide-spacing);
|
512 |
+
position: relative;
|
513 |
+
}
|
514 |
+
.embla__slide__img {
|
515 |
+
display: block;
|
516 |
+
height: var(--slide-height);
|
517 |
+
width: 100%;
|
518 |
+
object-fit: cover;
|
519 |
+
}
|
520 |
+
</style>
|
src/frontend/shared/tweenOpacity.ts
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { EmblaCarouselType } from "embla-carousel";
|
2 |
+
|
3 |
+
const TWEEN_FACTOR = 4.2;
|
4 |
+
|
5 |
+
const numberWithinRange = (number: number, min: number, max: number): number =>
|
6 |
+
Math.min(Math.max(number, min), max);
|
7 |
+
|
8 |
+
const calculateTweenValuesOpacity = (emblaApi: EmblaCarouselType): number[] => {
|
9 |
+
const engine = emblaApi.internalEngine();
|
10 |
+
const scrollProgress = emblaApi.scrollProgress();
|
11 |
+
|
12 |
+
return emblaApi.scrollSnapList().map((scrollSnap, index) => {
|
13 |
+
if (!emblaApi.slidesInView().includes(index)) return 0;
|
14 |
+
let diffToTarget = scrollSnap - scrollProgress;
|
15 |
+
|
16 |
+
if (engine.options.loop) {
|
17 |
+
engine.slideLooper.loopPoints.forEach((loopItem) => {
|
18 |
+
const target = loopItem.target();
|
19 |
+
if (index === loopItem.index && target !== 0) {
|
20 |
+
const sign = Math.sign(target);
|
21 |
+
if (sign === -1) diffToTarget = scrollSnap - (1 + scrollProgress);
|
22 |
+
if (sign === 1) diffToTarget = scrollSnap + (1 - scrollProgress);
|
23 |
+
}
|
24 |
+
});
|
25 |
+
}
|
26 |
+
const tweenValue = 1 - Math.abs(diffToTarget * TWEEN_FACTOR);
|
27 |
+
return numberWithinRange(tweenValue, 0, 1);
|
28 |
+
});
|
29 |
+
};
|
30 |
+
|
31 |
+
export const setupTweenOpacity = (
|
32 |
+
emblaApi: EmblaCarouselType
|
33 |
+
): {
|
34 |
+
applyTweenOpacity: () => void;
|
35 |
+
removeTweenOpacity: () => void;
|
36 |
+
} => {
|
37 |
+
const tweenNodes = emblaApi.slideNodes();
|
38 |
+
|
39 |
+
const applyTweenOpacity = (): void => {
|
40 |
+
const tweenValues = calculateTweenValuesOpacity(emblaApi);
|
41 |
+
tweenValues.forEach((tweenValue, index) => {
|
42 |
+
tweenNodes[index].style.opacity = tweenValue.toString();
|
43 |
+
});
|
44 |
+
};
|
45 |
+
|
46 |
+
const removeTweenOpacity = (): void => {
|
47 |
+
tweenNodes.forEach((slide) => slide.removeAttribute("style"));
|
48 |
+
};
|
49 |
+
|
50 |
+
return {
|
51 |
+
applyTweenOpacity,
|
52 |
+
removeTweenOpacity,
|
53 |
+
};
|
54 |
+
};
|
src/frontend/shared/utils.ts
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { uploadToHuggingFace } from "@gradio/utils";
|
2 |
+
import type { FileData } from "@gradio/client";
|
3 |
+
|
4 |
+
export async function format_gallery_for_sharing(
|
5 |
+
value: [FileData, string | null][] | null
|
6 |
+
): Promise<string> {
|
7 |
+
if (!value) return "";
|
8 |
+
let urls = await Promise.all(
|
9 |
+
value.map(async ([image, _]) => {
|
10 |
+
if (image === null || !image.url) return "";
|
11 |
+
return await uploadToHuggingFace(image.url, "url");
|
12 |
+
})
|
13 |
+
);
|
14 |
+
|
15 |
+
return `<div style="display: flex; flex-wrap: wrap; gap: 16px">${urls
|
16 |
+
.map((url) => `<img src="${url}" style="height: 400px" />`)
|
17 |
+
.join("")}</div>`;
|
18 |
+
}
|
src/pyproject.toml
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[build-system]
|
2 |
+
requires = [
|
3 |
+
"hatchling",
|
4 |
+
"hatch-requirements-txt",
|
5 |
+
"hatch-fancy-pypi-readme>=22.5.0",
|
6 |
+
]
|
7 |
+
build-backend = "hatchling.build"
|
8 |
+
|
9 |
+
[project]
|
10 |
+
name = "gradio_carousel"
|
11 |
+
version = "0.0.1"
|
12 |
+
description = "Python library for easily interacting with trained machine learning models"
|
13 |
+
readme = "README.md"
|
14 |
+
license = "Apache-2.0"
|
15 |
+
requires-python = ">=3.8"
|
16 |
+
authors = [{ name = "YOUR NAME", email = "YOUREMAIL@domain.com" }]
|
17 |
+
keywords = [
|
18 |
+
"gradio-custom-component",
|
19 |
+
"gradio-template-Gallery"
|
20 |
+
]
|
21 |
+
# Add dependencies here
|
22 |
+
dependencies = ["gradio>=4.0,<5.0"]
|
23 |
+
classifiers = [
|
24 |
+
'Development Status :: 3 - Alpha',
|
25 |
+
'License :: OSI Approved :: Apache Software License',
|
26 |
+
'Operating System :: OS Independent',
|
27 |
+
'Programming Language :: Python :: 3',
|
28 |
+
'Programming Language :: Python :: 3 :: Only',
|
29 |
+
'Programming Language :: Python :: 3.8',
|
30 |
+
'Programming Language :: Python :: 3.9',
|
31 |
+
'Programming Language :: Python :: 3.10',
|
32 |
+
'Programming Language :: Python :: 3.11',
|
33 |
+
'Topic :: Scientific/Engineering',
|
34 |
+
'Topic :: Scientific/Engineering :: Artificial Intelligence',
|
35 |
+
'Topic :: Scientific/Engineering :: Visualization',
|
36 |
+
]
|
37 |
+
|
38 |
+
[project.optional-dependencies]
|
39 |
+
dev = ["build", "twine"]
|
40 |
+
|
41 |
+
[tool.hatch.build]
|
42 |
+
artifacts = ["/backend/gradio_carousel/templates", "*.pyi", "backend/gradio_carousel/templates"]
|
43 |
+
|
44 |
+
[tool.hatch.build.targets.wheel]
|
45 |
+
packages = ["/backend/gradio_carousel"]
|