hmb HF Staff commited on
Commit
a296c4d
·
1 Parent(s): ae50712

Upload folder using huggingface_hub

Browse files
Dockerfile ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ FROM python:3.9
3
+
4
+ WORKDIR /code
5
+
6
+ COPY --link --chown=1000 . .
7
+
8
+ RUN pip install --no-cache-dir -r requirements.txt
9
+
10
+ ENV PYTHONUNBUFFERED=1 GRADIO_ALLOW_FLAGGING=never GRADIO_NUM_PORTS=1 GRADIO_SERVER_NAME=0.0.0.0 GRADIO_SERVER_PORT=7860 SYSTEM=spaces
11
+
12
+ CMD ["python", "app.py"]
Duck.glb ADDED
Binary file (120 kB). View file
 
README.md CHANGED
@@ -1,10 +1,10 @@
 
1
  ---
2
- title: Gradio Shinymodel3d
3
- emoji: 🌖
4
- colorFrom: blue
5
- colorTo: pink
6
  sdk: docker
7
  pinned: false
 
8
  ---
9
-
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+
2
  ---
3
+ tags: [gradio-custom-component, gradio-template-Model3D]
4
+ title: gradio_shinymodel3d V0.0.1
5
+ colorFrom: purple
6
+ colorTo: purple
7
  sdk: docker
8
  pinned: false
9
+ license: apache-2.0
10
  ---
 
 
__init__.py ADDED
File without changes
__pycache__/app.cpython-311.pyc ADDED
Binary file (770 Bytes). View file
 
app.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ from gradio_shinymodel3d import ShinyModel3D
4
+ import os
5
+
6
+ model_file = os.path.join(os.path.dirname(__file__), "Duck.glb")
7
+
8
+ with gr.Blocks() as demo:
9
+ ShinyModel3D(model_file)
10
+
11
+
12
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ gradio_shinymodel3d-0.0.1-py3-none-any.whl
src/.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
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,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Shinymodel3d
3
+ emoji: 📊
4
+ colorFrom: blue
5
+ colorTo: blue
6
+ sdk: gradio
7
+ sdk_version: 4.1.2
8
+ app_file: app.py
9
+ pinned: false
10
+ ---
11
+
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
src/backend/gradio_shinymodel3d/__init__.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+
2
+ from .shinymodel3d import ShinyModel3D
3
+
4
+ __all__ = ['ShinyModel3D']
src/backend/gradio_shinymodel3d/shinymodel3d.py ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """gr.Model3D() component."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+ from typing import Callable
7
+
8
+ from gradio_client.documentation import document, set_documentation_group
9
+
10
+ from gradio.components.base import Component
11
+ from gradio.data_classes import FileData
12
+ from gradio.events import Events
13
+
14
+ set_documentation_group("component")
15
+
16
+
17
+ @document()
18
+ class ShinyModel3D(Component):
19
+ """
20
+ Component allows users to upload or view 3D Model files (.obj, .glb, or .gltf).
21
+ Preprocessing: This component passes the uploaded file as a {str}filepath.
22
+ Postprocessing: expects function to return a {str} or {pathlib.Path} filepath of type (.obj, glb, or .gltf)
23
+
24
+ Demos: model3D
25
+ Guides: how-to-use-3D-model-component
26
+ """
27
+
28
+ EVENTS = [Events.change, Events.upload, Events.edit, Events.clear]
29
+
30
+ data_model = FileData
31
+
32
+ def __init__(
33
+ self,
34
+ value: str | Callable | None = None,
35
+ *,
36
+ clear_color: tuple[float, float, float, float] | None = None,
37
+ camera_position: tuple[
38
+ int | float | None, int | float | None, int | float | None
39
+ ] = (
40
+ None,
41
+ None,
42
+ None,
43
+ ),
44
+ zoom_speed: float = 1,
45
+ pan_speed: float = 1,
46
+ height: int | None = None,
47
+ label: str | None = None,
48
+ show_label: bool | None = None,
49
+ every: float | None = None,
50
+ container: bool = True,
51
+ scale: int | None = None,
52
+ min_width: int = 160,
53
+ interactive: bool | None = None,
54
+ visible: bool = True,
55
+ elem_id: str | None = None,
56
+ elem_classes: list[str] | str | None = None,
57
+ render: bool = True,
58
+ ):
59
+ """
60
+ Parameters:
61
+ value: path to (.obj, glb, or .gltf) file to show in model3D viewer. If callable, the function will be called whenever the app loads to set the initial value of the component.
62
+ clear_color: background color of scene, should be a tuple of 4 floats between 0 and 1 representing RGBA values.
63
+ camera_position: initial camera position of scene, provided as a tuple of `(alpha, beta, radius)`. Each value is optional. If provided, `alpha` and `beta` should be in degrees reflecting the angular position along the longitudinal and latitudinal axes, respectively. Radius corresponds to the distance from the center of the object to the camera.
64
+ zoom_speed: the speed of zooming in and out of the scene when the cursor wheel is rotated or when screen is pinched on a mobile device. Should be a positive float, increase this value to make zooming faster, decrease to make it slower. Affects the wheelPrecision property of the camera.
65
+ pan_speed: the speed of panning the scene when the cursor is dragged or when the screen is dragged on a mobile device. Should be a positive float, increase this value to make panning faster, decrease to make it slower. Affects the panSensibility property of the camera.
66
+ height: height of the model3D component, in pixels.
67
+ interactive: if True, will allow users to upload a file; if False, can only be used to display files. If not provided, this is inferred based on whether the component is used as an input or output.
68
+ 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.
69
+ show_label: if True, will display label.
70
+ 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.
71
+ container: If True, will place the component in a container - providing some extra padding around the border.
72
+ 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.
73
+ 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.
74
+ visible: If False, component will be hidden.
75
+ 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.
76
+ 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.
77
+ 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.
78
+ """
79
+ self.clear_color = clear_color or [0, 0, 0, 0]
80
+ self.camera_position = camera_position
81
+ self.height = height
82
+ self.zoom_speed = zoom_speed
83
+ self.pan_speed = pan_speed
84
+ super().__init__(
85
+ label=label,
86
+ every=every,
87
+ show_label=show_label,
88
+ container=container,
89
+ scale=scale,
90
+ min_width=min_width,
91
+ interactive=interactive,
92
+ visible=visible,
93
+ elem_id=elem_id,
94
+ elem_classes=elem_classes,
95
+ render=render,
96
+ value=value,
97
+ )
98
+
99
+ def preprocess(self, payload: FileData | None) -> str | None:
100
+ if payload is None:
101
+ return payload
102
+ return payload.path
103
+
104
+ def postprocess(self, value: str | Path | None) -> FileData | None:
105
+ if value is None:
106
+ return value
107
+ return FileData(path=str(value))
108
+
109
+ def as_example(self, input_data: str | None) -> str:
110
+ return Path(input_data).name if input_data else ""
111
+
112
+ def example_inputs(self):
113
+ # TODO: Use permanent link
114
+ return "https://raw.githubusercontent.com/gradio-app/gradio/main/demo/model3D/files/Fox.gltf"
src/backend/gradio_shinymodel3d/shinymodel3d.pyi ADDED
@@ -0,0 +1,264 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """gr.Model3D() component."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+ from typing import Callable
7
+
8
+ from gradio_client.documentation import document, set_documentation_group
9
+
10
+ from gradio.components.base import Component
11
+ from gradio.data_classes import FileData
12
+ from gradio.events import Events
13
+
14
+ set_documentation_group("component")
15
+
16
+ from gradio.events import Dependency
17
+
18
+ @document()
19
+ class ShinyModel3D(Component):
20
+ """
21
+ Component allows users to upload or view 3D Model files (.obj, .glb, or .gltf).
22
+ Preprocessing: This component passes the uploaded file as a {str}filepath.
23
+ Postprocessing: expects function to return a {str} or {pathlib.Path} filepath of type (.obj, glb, or .gltf)
24
+
25
+ Demos: model3D
26
+ Guides: how-to-use-3D-model-component
27
+ """
28
+
29
+ EVENTS = [Events.change, Events.upload, Events.edit, Events.clear]
30
+
31
+ data_model = FileData
32
+
33
+ def __init__(
34
+ self,
35
+ value: str | Callable | None = None,
36
+ *,
37
+ clear_color: tuple[float, float, float, float] | None = None,
38
+ camera_position: tuple[
39
+ int | float | None, int | float | None, int | float | None
40
+ ] = (
41
+ None,
42
+ None,
43
+ None,
44
+ ),
45
+ zoom_speed: float = 1,
46
+ pan_speed: float = 1,
47
+ height: int | None = None,
48
+ label: str | None = None,
49
+ show_label: bool | None = None,
50
+ every: float | None = None,
51
+ container: bool = True,
52
+ scale: int | None = None,
53
+ min_width: int = 160,
54
+ interactive: bool | None = None,
55
+ visible: bool = True,
56
+ elem_id: str | None = None,
57
+ elem_classes: list[str] | str | None = None,
58
+ render: bool = True,
59
+ ):
60
+ """
61
+ Parameters:
62
+ value: path to (.obj, glb, or .gltf) file to show in model3D viewer. If callable, the function will be called whenever the app loads to set the initial value of the component.
63
+ clear_color: background color of scene, should be a tuple of 4 floats between 0 and 1 representing RGBA values.
64
+ camera_position: initial camera position of scene, provided as a tuple of `(alpha, beta, radius)`. Each value is optional. If provided, `alpha` and `beta` should be in degrees reflecting the angular position along the longitudinal and latitudinal axes, respectively. Radius corresponds to the distance from the center of the object to the camera.
65
+ zoom_speed: the speed of zooming in and out of the scene when the cursor wheel is rotated or when screen is pinched on a mobile device. Should be a positive float, increase this value to make zooming faster, decrease to make it slower. Affects the wheelPrecision property of the camera.
66
+ pan_speed: the speed of panning the scene when the cursor is dragged or when the screen is dragged on a mobile device. Should be a positive float, increase this value to make panning faster, decrease to make it slower. Affects the panSensibility property of the camera.
67
+ height: height of the model3D component, in pixels.
68
+ interactive: if True, will allow users to upload a file; if False, can only be used to display files. If not provided, this is inferred based on whether the component is used as an input or output.
69
+ 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.
70
+ show_label: if True, will display label.
71
+ 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.
72
+ container: If True, will place the component in a container - providing some extra padding around the border.
73
+ 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.
74
+ 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.
75
+ visible: If False, component will be hidden.
76
+ 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.
77
+ 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.
78
+ 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.
79
+ """
80
+ self.clear_color = clear_color or [0, 0, 0, 0]
81
+ self.camera_position = camera_position
82
+ self.height = height
83
+ self.zoom_speed = zoom_speed
84
+ self.pan_speed = pan_speed
85
+ super().__init__(
86
+ label=label,
87
+ every=every,
88
+ show_label=show_label,
89
+ container=container,
90
+ scale=scale,
91
+ min_width=min_width,
92
+ interactive=interactive,
93
+ visible=visible,
94
+ elem_id=elem_id,
95
+ elem_classes=elem_classes,
96
+ render=render,
97
+ value=value,
98
+ )
99
+
100
+ def preprocess(self, payload: FileData | None) -> str | None:
101
+ if payload is None:
102
+ return payload
103
+ return payload.path
104
+
105
+ def postprocess(self, value: str | Path | None) -> FileData | None:
106
+ if value is None:
107
+ return value
108
+ return FileData(path=str(value))
109
+
110
+ def as_example(self, input_data: str | None) -> str:
111
+ return Path(input_data).name if input_data else ""
112
+
113
+ def example_inputs(self):
114
+ # TODO: Use permanent link
115
+ return "https://raw.githubusercontent.com/gradio-app/gradio/main/demo/model3D/files/Fox.gltf"
116
+
117
+
118
+ def change(self,
119
+ fn: Callable | None,
120
+ inputs: Component | Sequence[Component] | set[Component] | None = None,
121
+ outputs: Component | Sequence[Component] | None = None,
122
+ api_name: str | None | Literal[False] = None,
123
+ status_tracker: None = None,
124
+ scroll_to_output: bool = False,
125
+ show_progress: Literal["full", "minimal", "hidden"] = "full",
126
+ queue: bool | None = None,
127
+ batch: bool = False,
128
+ max_batch_size: int = 4,
129
+ preprocess: bool = True,
130
+ postprocess: bool = True,
131
+ cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
132
+ every: float | None = None,
133
+ trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
134
+ js: str | None = None,) -> Dependency:
135
+ """
136
+ Parameters:
137
+ 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.
138
+ inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
139
+ outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
140
+ 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.
141
+ scroll_to_output: If True, will scroll to output component on completion
142
+ show_progress: If True, will show progress animation while pending
143
+ 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.
144
+ 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.
145
+ max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
146
+ 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).
147
+ postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
148
+ 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.
149
+ every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
150
+ 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.
151
+ 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.
152
+ """
153
+ ...
154
+
155
+ def upload(self,
156
+ fn: Callable | None,
157
+ inputs: Component | Sequence[Component] | set[Component] | None = None,
158
+ outputs: Component | Sequence[Component] | None = None,
159
+ api_name: str | None | Literal[False] = None,
160
+ status_tracker: None = None,
161
+ scroll_to_output: bool = False,
162
+ show_progress: Literal["full", "minimal", "hidden"] = "full",
163
+ queue: bool | None = None,
164
+ batch: bool = False,
165
+ max_batch_size: int = 4,
166
+ preprocess: bool = True,
167
+ postprocess: bool = True,
168
+ cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
169
+ every: float | None = None,
170
+ trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
171
+ js: str | None = None,) -> Dependency:
172
+ """
173
+ Parameters:
174
+ 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.
175
+ inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
176
+ outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
177
+ 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.
178
+ scroll_to_output: If True, will scroll to output component on completion
179
+ show_progress: If True, will show progress animation while pending
180
+ 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.
181
+ 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.
182
+ max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
183
+ 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).
184
+ postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
185
+ 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.
186
+ every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
187
+ 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.
188
+ 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.
189
+ """
190
+ ...
191
+
192
+ def edit(self,
193
+ fn: Callable | None,
194
+ inputs: Component | Sequence[Component] | set[Component] | None = None,
195
+ outputs: Component | Sequence[Component] | None = None,
196
+ api_name: str | None | Literal[False] = None,
197
+ status_tracker: None = None,
198
+ scroll_to_output: bool = False,
199
+ show_progress: Literal["full", "minimal", "hidden"] = "full",
200
+ queue: bool | None = None,
201
+ batch: bool = False,
202
+ max_batch_size: int = 4,
203
+ preprocess: bool = True,
204
+ postprocess: bool = True,
205
+ cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
206
+ every: float | None = None,
207
+ trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
208
+ js: str | None = None,) -> Dependency:
209
+ """
210
+ Parameters:
211
+ 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.
212
+ inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
213
+ outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
214
+ 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.
215
+ scroll_to_output: If True, will scroll to output component on completion
216
+ show_progress: If True, will show progress animation while pending
217
+ 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.
218
+ 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.
219
+ max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
220
+ 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).
221
+ postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
222
+ 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.
223
+ every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
224
+ 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.
225
+ 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.
226
+ """
227
+ ...
228
+
229
+ def clear(self,
230
+ fn: Callable | None,
231
+ inputs: Component | Sequence[Component] | set[Component] | None = None,
232
+ outputs: Component | Sequence[Component] | None = None,
233
+ api_name: str | None | Literal[False] = None,
234
+ status_tracker: None = None,
235
+ scroll_to_output: bool = False,
236
+ show_progress: Literal["full", "minimal", "hidden"] = "full",
237
+ queue: bool | None = None,
238
+ batch: bool = False,
239
+ max_batch_size: int = 4,
240
+ preprocess: bool = True,
241
+ postprocess: bool = True,
242
+ cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
243
+ every: float | None = None,
244
+ trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
245
+ js: str | None = None,) -> Dependency:
246
+ """
247
+ Parameters:
248
+ 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.
249
+ inputs: List of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
250
+ outputs: List of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
251
+ 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.
252
+ scroll_to_output: If True, will scroll to output component on completion
253
+ show_progress: If True, will show progress animation while pending
254
+ 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.
255
+ 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.
256
+ max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
257
+ 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).
258
+ postprocess: If False, will not run postprocessing of component data before returning 'fn' output to the browser.
259
+ 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.
260
+ every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
261
+ 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.
262
+ 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.
263
+ """
264
+ ...
src/backend/gradio_shinymodel3d/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_shinymodel3d/templates/component/index.js ADDED
The diff for this file is too large to render. See raw diff
 
src/backend/gradio_shinymodel3d/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-xtz2g8{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}.padded.svelte-xtz2g8{padding:2px;background:var(--background-fill-primary);box-shadow:var(--shadow-drop);border:1px solid var(--button-secondary-border-color)}button.svelte-xtz2g8:hover{cursor:pointer;color:var(--color-accent)}.padded.svelte-xtz2g8:hover{border:2px solid var(--button-secondary-border-color-hover);padding:1px;color:var(--block-label-text-color)}span.svelte-xtz2g8{padding:0 1px;font-size:10px}div.svelte-xtz2g8{padding:2px;display:flex;align-items:flex-end}.small.svelte-xtz2g8{width:14px;height:14px}.large.svelte-xtz2g8{width:22px;height:22px}.pending.svelte-xtz2g8{animation:svelte-xtz2g8-flash .5s infinite}@keyframes svelte-xtz2g8-flash{0%{opacity:.5}50%{opacity:1}to{opacity:.5}}.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-1nba87b{border-top:1px solid transparent;display:flex;max-height:100%;justify-content:center;gap:var(--spacing-sm);height:auto;align-items:flex-end;box-shadow:var(--shadow-drop);padding:var(--spacing-xl) 0;color:var(--block-label-text-color);flex-shrink:0;width:95%}.show_border.svelte-1nba87b{border-top:1px solid var(--block-border-color);margin-top:var(--spacing-xxl)}.source-selection.svelte-lde7lt{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;align-self:flex-end}.icon.svelte-lde7lt{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-lde7lt{color:var(--color-accent)}.icon.svelte-lde7lt:hover,.icon.svelte-lde7lt:focus{color:var(--color-accent)}.separator.svelte-xc9xu7.svelte-xc9xu7{border-bottom:1px solid var(--border-color-primary);margin:10px 0;width:100%}.add.svelte-xc9xu7.svelte-xc9xu7{border:var(--button-border-width) solid var(--button-secondary-border-color);background:var(--button-secondary-background-fill);color:var(--button-secondary-text-color);margin:5px 0}.add.svelte-xc9xu7.svelte-xc9xu7:disabled{background-color:var(--button-secondary-background-fill-disabled);cursor:not-allowed;opacity:.5;filter:grayscale(30%)}.input-container.svelte-xc9xu7.svelte-xc9xu7{display:flex;flex-direction:column}.light-dropdown.svelte-xc9xu7.svelte-xc9xu7{all:unset;border:var(--button-border-width) solid var(--button-secondary-border-color);background:var(--button-secondary-background-fill);color:var(--button-secondary-text-color);margin:5px 0;width:min-content;height:min-content;font-size:var(--text-md);padding:5px;position:relative;text-align:left}.input-wrapper.svelte-xc9xu7.svelte-xc9xu7{display:flex;flex-direction:row}.caret.svelte-xc9xu7.svelte-xc9xu7{display:inline-flex;border-left:solid 5px transparent;border-right:solid 5px transparent;border-bottom:solid 5px #fff;transform:rotate(90deg);top:-2px;position:relative}.input-wrapper.svelte-xc9xu7 input[type=number].svelte-xc9xu7{width:min-content;height:min-content;display:inline-block;background:var(--input-background-fill);border:1px solid var(--input-border-color);padding:0 5px;color:var(--body-text-color);margin:0 2px}.input-title.svelte-xc9xu7.svelte-xc9xu7{color:#fff;margin:5px 0;text-align:right}.input-wrapper-axes.svelte-xc9xu7.svelte-xc9xu7{display:flex;flex-direction:row;align-items:center;justify-content:space-between}.input-wrapper-axes.svelte-xc9xu7 input[type=checkbox].svelte-xc9xu7{background-color:var(--checkbox-background-color)}input[type=checkbox].svelte-xc9xu7.svelte-xc9xu7:checked{background-color:var(--checkbox-background-color);border:1px solid var(--checkbox-border-color-selected)}.light-menu.svelte-xc9xu7.svelte-xc9xu7{display:flex;flex-direction:column;position:absolute;text-align:right;bottom:0;right:0;margin:10px;min-width:200px;color:#000;background-color:#0b0f1999;border:1px solid var(--border-color-primary);border-radius:var(--table-radius);padding:15px;max-height:90%;overflow-y:scroll}.light-menu.svelte-xc9xu7 label.svelte-xc9xu7{font-size:12px;margin-right:5px;color:#fff;font:var(--font);width:100%;padding:5px}.model3D.svelte-xc9xu7.svelte-xc9xu7{display:flex;position:relative;width:var(--size-full);height:var(--size-full)}canvas.svelte-xc9xu7.svelte-xc9xu7{width:var(--size-full);height:var(--size-full);object-fit:contain;overflow:hidden}.buttons.svelte-xc9xu7.svelte-xc9xu7{display:flex;position:absolute;top:var(--size-2);right:var(--size-2);justify-content:flex-end;gap:var(--spacing-sm);z-index:var(--layer-5)}button.svelte-a356bc{cursor:pointer;width:var(--size-full)}.hidden.svelte-a356bc{display:none;height:0;position:absolute}.center.svelte-a356bc{display:flex;justify-content:center}.flex.svelte-a356bc{display:flex;justify-content:center;align-items:center}input.svelte-a356bc{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)}.input-model.svelte-oqq3x6{display:flex;position:relative;justify-content:center;align-items:center;width:var(--size-full);height:var(--size-full)}canvas.svelte-oqq3x6{width:var(--size-full);height:var(--size-full);object-fit:contain;overflow:hidden}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-14miwb5.svelte-14miwb5{display:flex;flex-direction:column;justify-content:center;align-items:center;z-index:var(--layer-5);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-14miwb5.svelte-14miwb5{top:0;right:0;left:0}.wrap.default.svelte-14miwb5.svelte-14miwb5{top:0;right:0;bottom:0;left:0}.hide.svelte-14miwb5.svelte-14miwb5{opacity:0;pointer-events:none}.generating.svelte-14miwb5.svelte-14miwb5{animation:svelte-14miwb5-pulse 2s cubic-bezier(.4,0,.6,1) infinite;border:2px solid var(--color-accent);background:transparent}.translucent.svelte-14miwb5.svelte-14miwb5{background:none}@keyframes svelte-14miwb5-pulse{0%,to{opacity:1}50%{opacity:.5}}.loading.svelte-14miwb5.svelte-14miwb5{z-index:var(--layer-2);color:var(--body-text-color)}.eta-bar.svelte-14miwb5.svelte-14miwb5{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-14miwb5.svelte-14miwb5{border:1px solid var(--border-color-primary);background:var(--background-fill-primary);width:55.5%;height:var(--size-4)}.progress-bar.svelte-14miwb5.svelte-14miwb5{transform-origin:left;background-color:var(--loader-color);width:var(--size-full);height:var(--size-full)}.progress-level.svelte-14miwb5.svelte-14miwb5{display:flex;flex-direction:column;align-items:center;gap:1;z-index:var(--layer-2);width:var(--size-full)}.progress-level-inner.svelte-14miwb5.svelte-14miwb5{margin:var(--size-2) auto;color:var(--body-text-color);font-size:var(--text-sm);font-family:var(--font-mono)}.meta-text.svelte-14miwb5.svelte-14miwb5{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-14miwb5.svelte-14miwb5{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-14miwb5.svelte-14miwb5{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-14miwb5 .progress-text.svelte-14miwb5{background:var(--block-background-fill)}.border.svelte-14miwb5.svelte-14miwb5{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))}}.gallery.svelte-1gecy8w{padding:var(--size-1) var(--size-2)}
src/backend/gradio_shinymodel3d/templates/component/wrapper-98f94c21-f7f71f53.js ADDED
@@ -0,0 +1,2449 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ return this instanceof r ? Reflect.construct(e, arguments, this.constructor) : e.apply(this, arguments);
12
+ };
13
+ t.prototype = e.prototype;
14
+ } else
15
+ t = {};
16
+ return Object.defineProperty(t, "__esModule", { value: !0 }), Object.keys(s).forEach(function(r) {
17
+ var i = Object.getOwnPropertyDescriptor(s, r);
18
+ Object.defineProperty(t, r, i.get ? i : {
19
+ enumerable: !0,
20
+ get: function() {
21
+ return s[r];
22
+ }
23
+ });
24
+ }), t;
25
+ }
26
+ const { Duplex: yt } = S;
27
+ function Oe(s) {
28
+ s.emit("close");
29
+ }
30
+ function vt() {
31
+ !this.destroyed && this._writableState.finished && this.destroy();
32
+ }
33
+ function Qe(s) {
34
+ this.removeListener("error", Qe), this.destroy(), this.listenerCount("error") === 0 && this.emit("error", s);
35
+ }
36
+ function St(s, e) {
37
+ let t = !0;
38
+ const r = new yt({
39
+ ...e,
40
+ autoDestroy: !1,
41
+ emitClose: !1,
42
+ objectMode: !1,
43
+ writableObjectMode: !1
44
+ });
45
+ return s.on("message", function(n, o) {
46
+ const l = !o && r._readableState.objectMode ? n.toString() : n;
47
+ r.push(l) || s.pause();
48
+ }), s.once("error", function(n) {
49
+ r.destroyed || (t = !1, r.destroy(n));
50
+ }), s.once("close", function() {
51
+ r.destroyed || r.push(null);
52
+ }), r._destroy = function(i, n) {
53
+ if (s.readyState === s.CLOSED) {
54
+ n(i), process.nextTick(Oe, r);
55
+ return;
56
+ }
57
+ let o = !1;
58
+ s.once("error", function(f) {
59
+ o = !0, n(f);
60
+ }), s.once("close", function() {
61
+ o || n(i), process.nextTick(Oe, r);
62
+ }), t && s.terminate();
63
+ }, r._final = function(i) {
64
+ if (s.readyState === s.CONNECTING) {
65
+ s.once("open", function() {
66
+ r._final(i);
67
+ });
68
+ return;
69
+ }
70
+ s._socket !== null && (s._socket._writableState.finished ? (i(), r._readableState.endEmitted && r.destroy()) : (s._socket.once("finish", function() {
71
+ i();
72
+ }), s.close()));
73
+ }, r._read = function() {
74
+ s.isPaused && s.resume();
75
+ }, r._write = function(i, n, o) {
76
+ if (s.readyState === s.CONNECTING) {
77
+ s.once("open", function() {
78
+ r._write(i, n, o);
79
+ });
80
+ return;
81
+ }
82
+ s.send(i, o);
83
+ }, r.on("end", vt), r.on("error", Qe), r;
84
+ }
85
+ var Et = St;
86
+ const Vs = /* @__PURE__ */ z(Et);
87
+ var te = { exports: {} }, U = {
88
+ BINARY_TYPES: ["nodebuffer", "arraybuffer", "fragments"],
89
+ EMPTY_BUFFER: Buffer.alloc(0),
90
+ GUID: "258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
91
+ kForOnEventAttribute: Symbol("kIsForOnEventAttribute"),
92
+ kListener: Symbol("kListener"),
93
+ kStatusCode: Symbol("status-code"),
94
+ kWebSocket: Symbol("websocket"),
95
+ NOOP: () => {
96
+ }
97
+ }, bt, xt;
98
+ const { EMPTY_BUFFER: kt } = U, Se = Buffer[Symbol.species];
99
+ function wt(s, e) {
100
+ if (s.length === 0)
101
+ return kt;
102
+ if (s.length === 1)
103
+ return s[0];
104
+ const t = Buffer.allocUnsafe(e);
105
+ let r = 0;
106
+ for (let i = 0; i < s.length; i++) {
107
+ const n = s[i];
108
+ t.set(n, r), r += n.length;
109
+ }
110
+ return r < e ? new Se(t.buffer, t.byteOffset, r) : t;
111
+ }
112
+ function Je(s, e, t, r, i) {
113
+ for (let n = 0; n < i; n++)
114
+ t[r + n] = s[n] ^ e[n & 3];
115
+ }
116
+ function et(s, e) {
117
+ for (let t = 0; t < s.length; t++)
118
+ s[t] ^= e[t & 3];
119
+ }
120
+ function Ot(s) {
121
+ return s.length === s.buffer.byteLength ? s.buffer : s.buffer.slice(s.byteOffset, s.byteOffset + s.length);
122
+ }
123
+ function Ee(s) {
124
+ if (Ee.readOnly = !0, Buffer.isBuffer(s))
125
+ return s;
126
+ let e;
127
+ 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;
128
+ }
129
+ te.exports = {
130
+ concat: wt,
131
+ mask: Je,
132
+ toArrayBuffer: Ot,
133
+ toBuffer: Ee,
134
+ unmask: et
135
+ };
136
+ if (!process.env.WS_NO_BUFFER_UTIL)
137
+ try {
138
+ const s = require("bufferutil");
139
+ xt = te.exports.mask = function(e, t, r, i, n) {
140
+ n < 48 ? Je(e, t, r, i, n) : s.mask(e, t, r, i, n);
141
+ }, bt = te.exports.unmask = function(e, t) {
142
+ e.length < 32 ? et(e, t) : s.unmask(e, t);
143
+ };
144
+ } catch {
145
+ }
146
+ var ne = te.exports;
147
+ const Ce = Symbol("kDone"), ue = Symbol("kRun");
148
+ let Ct = class {
149
+ /**
150
+ * Creates a new `Limiter`.
151
+ *
152
+ * @param {Number} [concurrency=Infinity] The maximum number of jobs allowed
153
+ * to run concurrently
154
+ */
155
+ constructor(e) {
156
+ this[Ce] = () => {
157
+ this.pending--, this[ue]();
158
+ }, this.concurrency = e || 1 / 0, this.jobs = [], this.pending = 0;
159
+ }
160
+ /**
161
+ * Adds a job to the queue.
162
+ *
163
+ * @param {Function} job The job to run
164
+ * @public
165
+ */
166
+ add(e) {
167
+ this.jobs.push(e), this[ue]();
168
+ }
169
+ /**
170
+ * Removes a job from the queue and runs it if possible.
171
+ *
172
+ * @private
173
+ */
174
+ [ue]() {
175
+ if (this.pending !== this.concurrency && this.jobs.length) {
176
+ const e = this.jobs.shift();
177
+ this.pending++, e(this[Ce]);
178
+ }
179
+ }
180
+ };
181
+ var Tt = Ct;
182
+ 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");
183
+ let K, Rt = class {
184
+ /**
185
+ * Creates a PerMessageDeflate instance.
186
+ *
187
+ * @param {Object} [options] Configuration options
188
+ * @param {(Boolean|Number)} [options.clientMaxWindowBits] Advertise support
189
+ * for, or request, a custom client window size
190
+ * @param {Boolean} [options.clientNoContextTakeover=false] Advertise/
191
+ * acknowledge disabling of client context takeover
192
+ * @param {Number} [options.concurrencyLimit=10] The number of concurrent
193
+ * calls to zlib
194
+ * @param {(Boolean|Number)} [options.serverMaxWindowBits] Request/confirm the
195
+ * use of a custom server window size
196
+ * @param {Boolean} [options.serverNoContextTakeover=false] Request/accept
197
+ * disabling of server context takeover
198
+ * @param {Number} [options.threshold=1024] Size (in bytes) below which
199
+ * messages should not be compressed if context takeover is disabled
200
+ * @param {Object} [options.zlibDeflateOptions] Options to pass to zlib on
201
+ * deflate
202
+ * @param {Object} [options.zlibInflateOptions] Options to pass to zlib on
203
+ * inflate
204
+ * @param {Boolean} [isServer=false] Create the instance in either server or
205
+ * client mode
206
+ * @param {Number} [maxPayload=0] The maximum allowed message length
207
+ */
208
+ constructor(e, t, r) {
209
+ 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) {
210
+ const i = this._options.concurrencyLimit !== void 0 ? this._options.concurrencyLimit : 10;
211
+ K = new Lt(i);
212
+ }
213
+ }
214
+ /**
215
+ * @type {String}
216
+ */
217
+ static get extensionName() {
218
+ return "permessage-deflate";
219
+ }
220
+ /**
221
+ * Create an extension negotiation offer.
222
+ *
223
+ * @return {Object} Extension parameters
224
+ * @public
225
+ */
226
+ offer() {
227
+ const e = {};
228
+ 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;
229
+ }
230
+ /**
231
+ * Accept an extension negotiation offer/response.
232
+ *
233
+ * @param {Array} configurations The extension negotiation offers/reponse
234
+ * @return {Object} Accepted configuration
235
+ * @public
236
+ */
237
+ accept(e) {
238
+ return e = this.normalizeParams(e), this.params = this._isServer ? this.acceptAsServer(e) : this.acceptAsClient(e), this.params;
239
+ }
240
+ /**
241
+ * Releases all resources used by the extension.
242
+ *
243
+ * @public
244
+ */
245
+ cleanup() {
246
+ if (this._inflate && (this._inflate.close(), this._inflate = null), this._deflate) {
247
+ const e = this._deflate[V];
248
+ this._deflate.close(), this._deflate = null, e && e(
249
+ new Error(
250
+ "The deflate stream was closed while data was being processed"
251
+ )
252
+ );
253
+ }
254
+ }
255
+ /**
256
+ * Accept an extension negotiation offer.
257
+ *
258
+ * @param {Array} offers The extension negotiation offers
259
+ * @return {Object} Accepted configuration
260
+ * @private
261
+ */
262
+ acceptAsServer(e) {
263
+ 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));
264
+ if (!r)
265
+ throw new Error("None of the extension offers can be accepted");
266
+ 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;
267
+ }
268
+ /**
269
+ * Accept the extension negotiation response.
270
+ *
271
+ * @param {Array} response The extension negotiation response
272
+ * @return {Object} Accepted configuration
273
+ * @private
274
+ */
275
+ acceptAsClient(e) {
276
+ const t = e[0];
277
+ if (this._options.clientNoContextTakeover === !1 && t.client_no_context_takeover)
278
+ throw new Error('Unexpected parameter "client_no_context_takeover"');
279
+ if (!t.client_max_window_bits)
280
+ typeof this._options.clientMaxWindowBits == "number" && (t.client_max_window_bits = this._options.clientMaxWindowBits);
281
+ else if (this._options.clientMaxWindowBits === !1 || typeof this._options.clientMaxWindowBits == "number" && t.client_max_window_bits > this._options.clientMaxWindowBits)
282
+ throw new Error(
283
+ 'Unexpected or invalid parameter "client_max_window_bits"'
284
+ );
285
+ return t;
286
+ }
287
+ /**
288
+ * Normalize parameters.
289
+ *
290
+ * @param {Array} configurations The extension negotiation offers/reponse
291
+ * @return {Array} The offers/response with normalized parameters
292
+ * @private
293
+ */
294
+ normalizeParams(e) {
295
+ return e.forEach((t) => {
296
+ Object.keys(t).forEach((r) => {
297
+ let i = t[r];
298
+ if (i.length > 1)
299
+ throw new Error(`Parameter "${r}" must have only a single value`);
300
+ if (i = i[0], r === "client_max_window_bits") {
301
+ if (i !== !0) {
302
+ const n = +i;
303
+ if (!Number.isInteger(n) || n < 8 || n > 15)
304
+ throw new TypeError(
305
+ `Invalid value for parameter "${r}": ${i}`
306
+ );
307
+ i = n;
308
+ } else if (!this._isServer)
309
+ throw new TypeError(
310
+ `Invalid value for parameter "${r}": ${i}`
311
+ );
312
+ } else if (r === "server_max_window_bits") {
313
+ const n = +i;
314
+ if (!Number.isInteger(n) || n < 8 || n > 15)
315
+ throw new TypeError(
316
+ `Invalid value for parameter "${r}": ${i}`
317
+ );
318
+ i = n;
319
+ } else if (r === "client_no_context_takeover" || r === "server_no_context_takeover") {
320
+ if (i !== !0)
321
+ throw new TypeError(
322
+ `Invalid value for parameter "${r}": ${i}`
323
+ );
324
+ } else
325
+ throw new Error(`Unknown parameter "${r}"`);
326
+ t[r] = i;
327
+ });
328
+ }), e;
329
+ }
330
+ /**
331
+ * Decompress data. Concurrency limited.
332
+ *
333
+ * @param {Buffer} data Compressed data
334
+ * @param {Boolean} fin Specifies whether or not this is the last fragment
335
+ * @param {Function} callback Callback
336
+ * @public
337
+ */
338
+ decompress(e, t, r) {
339
+ K.add((i) => {
340
+ this._decompress(e, t, (n, o) => {
341
+ i(), r(n, o);
342
+ });
343
+ });
344
+ }
345
+ /**
346
+ * Compress data. Concurrency limited.
347
+ *
348
+ * @param {(Buffer|String)} data Data to compress
349
+ * @param {Boolean} fin Specifies whether or not this is the last fragment
350
+ * @param {Function} callback Callback
351
+ * @public
352
+ */
353
+ compress(e, t, r) {
354
+ K.add((i) => {
355
+ this._compress(e, t, (n, o) => {
356
+ i(), r(n, o);
357
+ });
358
+ });
359
+ }
360
+ /**
361
+ * Decompress data.
362
+ *
363
+ * @param {Buffer} data Compressed data
364
+ * @param {Boolean} fin Specifies whether or not this is the last fragment
365
+ * @param {Function} callback Callback
366
+ * @private
367
+ */
368
+ _decompress(e, t, r) {
369
+ const i = this._isServer ? "client" : "server";
370
+ if (!this._inflate) {
371
+ const n = `${i}_max_window_bits`, o = typeof this.params[n] != "number" ? W.Z_DEFAULT_WINDOWBITS : this.params[n];
372
+ this._inflate = W.createInflateRaw({
373
+ ...this._options.zlibInflateOptions,
374
+ windowBits: o
375
+ }), this._inflate[se] = this, this._inflate[w] = 0, this._inflate[C] = [], this._inflate.on("error", Bt), this._inflate.on("data", st);
376
+ }
377
+ this._inflate[V] = r, this._inflate.write(e), t && this._inflate.write(Pt), this._inflate.flush(() => {
378
+ const n = this._inflate[J];
379
+ if (n) {
380
+ this._inflate.close(), this._inflate = null, r(n);
381
+ return;
382
+ }
383
+ const o = Te.concat(
384
+ this._inflate[C],
385
+ this._inflate[w]
386
+ );
387
+ 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);
388
+ });
389
+ }
390
+ /**
391
+ * Compress data.
392
+ *
393
+ * @param {(Buffer|String)} data Data to compress
394
+ * @param {Boolean} fin Specifies whether or not this is the last fragment
395
+ * @param {Function} callback Callback
396
+ * @private
397
+ */
398
+ _compress(e, t, r) {
399
+ const i = this._isServer ? "server" : "client";
400
+ if (!this._deflate) {
401
+ const n = `${i}_max_window_bits`, o = typeof this.params[n] != "number" ? W.Z_DEFAULT_WINDOWBITS : this.params[n];
402
+ this._deflate = W.createDeflateRaw({
403
+ ...this._options.zlibDeflateOptions,
404
+ windowBits: o
405
+ }), this._deflate[w] = 0, this._deflate[C] = [], this._deflate.on("data", Ut);
406
+ }
407
+ this._deflate[V] = r, this._deflate.write(e), this._deflate.flush(W.Z_SYNC_FLUSH, () => {
408
+ if (!this._deflate)
409
+ return;
410
+ let n = Te.concat(
411
+ this._deflate[C],
412
+ this._deflate[w]
413
+ );
414
+ 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);
415
+ });
416
+ }
417
+ };
418
+ var oe = Rt;
419
+ function Ut(s) {
420
+ this[C].push(s), this[w] += s.length;
421
+ }
422
+ function st(s) {
423
+ if (this[w] += s.length, this[se]._maxPayload < 1 || this[w] <= this[se]._maxPayload) {
424
+ this[C].push(s);
425
+ return;
426
+ }
427
+ 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();
428
+ }
429
+ function Bt(s) {
430
+ this[se]._inflate = null, s[tt] = 1007, this[V](s);
431
+ }
432
+ var re = { exports: {} };
433
+ const $t = {}, Mt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
434
+ __proto__: null,
435
+ default: $t
436
+ }, Symbol.toStringTag, { value: "Module" })), It = /* @__PURE__ */ gt(Mt);
437
+ var Le;
438
+ const { isUtf8: Ne } = S, Dt = [
439
+ 0,
440
+ 0,
441
+ 0,
442
+ 0,
443
+ 0,
444
+ 0,
445
+ 0,
446
+ 0,
447
+ 0,
448
+ 0,
449
+ 0,
450
+ 0,
451
+ 0,
452
+ 0,
453
+ 0,
454
+ 0,
455
+ // 0 - 15
456
+ 0,
457
+ 0,
458
+ 0,
459
+ 0,
460
+ 0,
461
+ 0,
462
+ 0,
463
+ 0,
464
+ 0,
465
+ 0,
466
+ 0,
467
+ 0,
468
+ 0,
469
+ 0,
470
+ 0,
471
+ 0,
472
+ // 16 - 31
473
+ 0,
474
+ 1,
475
+ 0,
476
+ 1,
477
+ 1,
478
+ 1,
479
+ 1,
480
+ 1,
481
+ 0,
482
+ 0,
483
+ 1,
484
+ 1,
485
+ 0,
486
+ 1,
487
+ 1,
488
+ 0,
489
+ // 32 - 47
490
+ 1,
491
+ 1,
492
+ 1,
493
+ 1,
494
+ 1,
495
+ 1,
496
+ 1,
497
+ 1,
498
+ 1,
499
+ 1,
500
+ 0,
501
+ 0,
502
+ 0,
503
+ 0,
504
+ 0,
505
+ 0,
506
+ // 48 - 63
507
+ 0,
508
+ 1,
509
+ 1,
510
+ 1,
511
+ 1,
512
+ 1,
513
+ 1,
514
+ 1,
515
+ 1,
516
+ 1,
517
+ 1,
518
+ 1,
519
+ 1,
520
+ 1,
521
+ 1,
522
+ 1,
523
+ // 64 - 79
524
+ 1,
525
+ 1,
526
+ 1,
527
+ 1,
528
+ 1,
529
+ 1,
530
+ 1,
531
+ 1,
532
+ 1,
533
+ 1,
534
+ 1,
535
+ 0,
536
+ 0,
537
+ 0,
538
+ 1,
539
+ 1,
540
+ // 80 - 95
541
+ 1,
542
+ 1,
543
+ 1,
544
+ 1,
545
+ 1,
546
+ 1,
547
+ 1,
548
+ 1,
549
+ 1,
550
+ 1,
551
+ 1,
552
+ 1,
553
+ 1,
554
+ 1,
555
+ 1,
556
+ 1,
557
+ // 96 - 111
558
+ 1,
559
+ 1,
560
+ 1,
561
+ 1,
562
+ 1,
563
+ 1,
564
+ 1,
565
+ 1,
566
+ 1,
567
+ 1,
568
+ 1,
569
+ 0,
570
+ 1,
571
+ 0,
572
+ 1,
573
+ 0
574
+ // 112 - 127
575
+ ];
576
+ function Wt(s) {
577
+ return s >= 1e3 && s <= 1014 && s !== 1004 && s !== 1005 && s !== 1006 || s >= 3e3 && s <= 4999;
578
+ }
579
+ function be(s) {
580
+ const e = s.length;
581
+ let t = 0;
582
+ for (; t < e; )
583
+ if (!(s[t] & 128))
584
+ t++;
585
+ else if ((s[t] & 224) === 192) {
586
+ if (t + 1 === e || (s[t + 1] & 192) !== 128 || (s[t] & 254) === 192)
587
+ return !1;
588
+ t += 2;
589
+ } else if ((s[t] & 240) === 224) {
590
+ if (t + 2 >= e || (s[t + 1] & 192) !== 128 || (s[t + 2] & 192) !== 128 || s[t] === 224 && (s[t + 1] & 224) === 128 || // Overlong
591
+ s[t] === 237 && (s[t + 1] & 224) === 160)
592
+ return !1;
593
+ t += 3;
594
+ } else if ((s[t] & 248) === 240) {
595
+ 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
596
+ s[t] === 244 && s[t + 1] > 143 || s[t] > 244)
597
+ return !1;
598
+ t += 4;
599
+ } else
600
+ return !1;
601
+ return !0;
602
+ }
603
+ re.exports = {
604
+ isValidStatusCode: Wt,
605
+ isValidUTF8: be,
606
+ tokenChars: Dt
607
+ };
608
+ if (Ne)
609
+ Le = re.exports.isValidUTF8 = function(s) {
610
+ return s.length < 24 ? be(s) : Ne(s);
611
+ };
612
+ else if (!process.env.WS_NO_UTF_8_VALIDATE)
613
+ try {
614
+ const s = It;
615
+ Le = re.exports.isValidUTF8 = function(e) {
616
+ return e.length < 32 ? be(e) : s(e);
617
+ };
618
+ } catch {
619
+ }
620
+ var ae = re.exports;
621
+ const { Writable: At } = S, Pe = oe, {
622
+ BINARY_TYPES: Ft,
623
+ EMPTY_BUFFER: Re,
624
+ kStatusCode: jt,
625
+ kWebSocket: Gt
626
+ } = 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;
627
+ let qt = class extends At {
628
+ /**
629
+ * Creates a Receiver instance.
630
+ *
631
+ * @param {Object} [options] Options object
632
+ * @param {String} [options.binaryType=nodebuffer] The type for binary data
633
+ * @param {Object} [options.extensions] An object containing the negotiated
634
+ * extensions
635
+ * @param {Boolean} [options.isServer=false] Specifies whether to operate in
636
+ * client or server mode
637
+ * @param {Number} [options.maxPayload=0] The maximum allowed message length
638
+ * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
639
+ * not to skip UTF-8 validation for text and close messages
640
+ */
641
+ constructor(e = {}) {
642
+ 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;
643
+ }
644
+ /**
645
+ * Implements `Writable.prototype._write()`.
646
+ *
647
+ * @param {Buffer} chunk The chunk of data to write
648
+ * @param {String} encoding The character encoding of `chunk`
649
+ * @param {Function} cb Callback
650
+ * @private
651
+ */
652
+ _write(e, t, r) {
653
+ if (this._opcode === 8 && this._state == A)
654
+ return r();
655
+ this._bufferedBytes += e.length, this._buffers.push(e), this.startLoop(r);
656
+ }
657
+ /**
658
+ * Consumes `n` bytes from the buffered data.
659
+ *
660
+ * @param {Number} n The number of bytes to consume
661
+ * @return {Buffer} The consumed bytes
662
+ * @private
663
+ */
664
+ consume(e) {
665
+ if (this._bufferedBytes -= e, e === this._buffers[0].length)
666
+ return this._buffers.shift();
667
+ if (e < this._buffers[0].length) {
668
+ const r = this._buffers[0];
669
+ return this._buffers[0] = new X(
670
+ r.buffer,
671
+ r.byteOffset + e,
672
+ r.length - e
673
+ ), new X(r.buffer, r.byteOffset, e);
674
+ }
675
+ const t = Buffer.allocUnsafe(e);
676
+ do {
677
+ const r = this._buffers[0], i = t.length - e;
678
+ e >= r.length ? t.set(this._buffers.shift(), i) : (t.set(new Uint8Array(r.buffer, r.byteOffset, e), i), this._buffers[0] = new X(
679
+ r.buffer,
680
+ r.byteOffset + e,
681
+ r.length - e
682
+ )), e -= r.length;
683
+ } while (e > 0);
684
+ return t;
685
+ }
686
+ /**
687
+ * Starts the parsing loop.
688
+ *
689
+ * @param {Function} cb Callback
690
+ * @private
691
+ */
692
+ startLoop(e) {
693
+ let t;
694
+ this._loop = !0;
695
+ do
696
+ switch (this._state) {
697
+ case A:
698
+ t = this.getInfo();
699
+ break;
700
+ case Be:
701
+ t = this.getPayloadLength16();
702
+ break;
703
+ case $e:
704
+ t = this.getPayloadLength64();
705
+ break;
706
+ case Me:
707
+ this.getMask();
708
+ break;
709
+ case _e:
710
+ t = this.getData(e);
711
+ break;
712
+ default:
713
+ this._loop = !1;
714
+ return;
715
+ }
716
+ while (this._loop);
717
+ e(t);
718
+ }
719
+ /**
720
+ * Reads the first two bytes of a frame.
721
+ *
722
+ * @return {(RangeError|undefined)} A possible error
723
+ * @private
724
+ */
725
+ getInfo() {
726
+ if (this._bufferedBytes < 2) {
727
+ this._loop = !1;
728
+ return;
729
+ }
730
+ const e = this.consume(2);
731
+ if (e[0] & 48)
732
+ return this._loop = !1, g(
733
+ RangeError,
734
+ "RSV2 and RSV3 must be clear",
735
+ !0,
736
+ 1002,
737
+ "WS_ERR_UNEXPECTED_RSV_2_3"
738
+ );
739
+ const t = (e[0] & 64) === 64;
740
+ if (t && !this._extensions[Pe.extensionName])
741
+ return this._loop = !1, g(
742
+ RangeError,
743
+ "RSV1 must be clear",
744
+ !0,
745
+ 1002,
746
+ "WS_ERR_UNEXPECTED_RSV_1"
747
+ );
748
+ if (this._fin = (e[0] & 128) === 128, this._opcode = e[0] & 15, this._payloadLength = e[1] & 127, this._opcode === 0) {
749
+ if (t)
750
+ return this._loop = !1, g(
751
+ RangeError,
752
+ "RSV1 must be clear",
753
+ !0,
754
+ 1002,
755
+ "WS_ERR_UNEXPECTED_RSV_1"
756
+ );
757
+ if (!this._fragmented)
758
+ return this._loop = !1, g(
759
+ RangeError,
760
+ "invalid opcode 0",
761
+ !0,
762
+ 1002,
763
+ "WS_ERR_INVALID_OPCODE"
764
+ );
765
+ this._opcode = this._fragmented;
766
+ } else if (this._opcode === 1 || this._opcode === 2) {
767
+ if (this._fragmented)
768
+ return this._loop = !1, g(
769
+ RangeError,
770
+ `invalid opcode ${this._opcode}`,
771
+ !0,
772
+ 1002,
773
+ "WS_ERR_INVALID_OPCODE"
774
+ );
775
+ this._compressed = t;
776
+ } else if (this._opcode > 7 && this._opcode < 11) {
777
+ if (!this._fin)
778
+ return this._loop = !1, g(
779
+ RangeError,
780
+ "FIN must be set",
781
+ !0,
782
+ 1002,
783
+ "WS_ERR_EXPECTED_FIN"
784
+ );
785
+ if (t)
786
+ return this._loop = !1, g(
787
+ RangeError,
788
+ "RSV1 must be clear",
789
+ !0,
790
+ 1002,
791
+ "WS_ERR_UNEXPECTED_RSV_1"
792
+ );
793
+ if (this._payloadLength > 125 || this._opcode === 8 && this._payloadLength === 1)
794
+ return this._loop = !1, g(
795
+ RangeError,
796
+ `invalid payload length ${this._payloadLength}`,
797
+ !0,
798
+ 1002,
799
+ "WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"
800
+ );
801
+ } else
802
+ return this._loop = !1, g(
803
+ RangeError,
804
+ `invalid opcode ${this._opcode}`,
805
+ !0,
806
+ 1002,
807
+ "WS_ERR_INVALID_OPCODE"
808
+ );
809
+ if (!this._fin && !this._fragmented && (this._fragmented = this._opcode), this._masked = (e[1] & 128) === 128, this._isServer) {
810
+ if (!this._masked)
811
+ return this._loop = !1, g(
812
+ RangeError,
813
+ "MASK must be set",
814
+ !0,
815
+ 1002,
816
+ "WS_ERR_EXPECTED_MASK"
817
+ );
818
+ } else if (this._masked)
819
+ return this._loop = !1, g(
820
+ RangeError,
821
+ "MASK must be clear",
822
+ !0,
823
+ 1002,
824
+ "WS_ERR_UNEXPECTED_MASK"
825
+ );
826
+ if (this._payloadLength === 126)
827
+ this._state = Be;
828
+ else if (this._payloadLength === 127)
829
+ this._state = $e;
830
+ else
831
+ return this.haveLength();
832
+ }
833
+ /**
834
+ * Gets extended payload length (7+16).
835
+ *
836
+ * @return {(RangeError|undefined)} A possible error
837
+ * @private
838
+ */
839
+ getPayloadLength16() {
840
+ if (this._bufferedBytes < 2) {
841
+ this._loop = !1;
842
+ return;
843
+ }
844
+ return this._payloadLength = this.consume(2).readUInt16BE(0), this.haveLength();
845
+ }
846
+ /**
847
+ * Gets extended payload length (7+64).
848
+ *
849
+ * @return {(RangeError|undefined)} A possible error
850
+ * @private
851
+ */
852
+ getPayloadLength64() {
853
+ if (this._bufferedBytes < 8) {
854
+ this._loop = !1;
855
+ return;
856
+ }
857
+ const e = this.consume(8), t = e.readUInt32BE(0);
858
+ return t > Math.pow(2, 53 - 32) - 1 ? (this._loop = !1, g(
859
+ RangeError,
860
+ "Unsupported WebSocket frame: payload length > 2^53 - 1",
861
+ !1,
862
+ 1009,
863
+ "WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH"
864
+ )) : (this._payloadLength = t * Math.pow(2, 32) + e.readUInt32BE(4), this.haveLength());
865
+ }
866
+ /**
867
+ * Payload length has been read.
868
+ *
869
+ * @return {(RangeError|undefined)} A possible error
870
+ * @private
871
+ */
872
+ haveLength() {
873
+ if (this._payloadLength && this._opcode < 8 && (this._totalPayloadLength += this._payloadLength, this._totalPayloadLength > this._maxPayload && this._maxPayload > 0))
874
+ return this._loop = !1, g(
875
+ RangeError,
876
+ "Max payload size exceeded",
877
+ !1,
878
+ 1009,
879
+ "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"
880
+ );
881
+ this._masked ? this._state = Me : this._state = _e;
882
+ }
883
+ /**
884
+ * Reads mask bytes.
885
+ *
886
+ * @private
887
+ */
888
+ getMask() {
889
+ if (this._bufferedBytes < 4) {
890
+ this._loop = !1;
891
+ return;
892
+ }
893
+ this._mask = this.consume(4), this._state = _e;
894
+ }
895
+ /**
896
+ * Reads data bytes.
897
+ *
898
+ * @param {Function} cb Callback
899
+ * @return {(Error|RangeError|undefined)} A possible error
900
+ * @private
901
+ */
902
+ getData(e) {
903
+ let t = Re;
904
+ if (this._payloadLength) {
905
+ if (this._bufferedBytes < this._payloadLength) {
906
+ this._loop = !1;
907
+ return;
908
+ }
909
+ t = this.consume(this._payloadLength), this._masked && this._mask[0] | this._mask[1] | this._mask[2] | this._mask[3] && Ht(t, this._mask);
910
+ }
911
+ if (this._opcode > 7)
912
+ return this.controlMessage(t);
913
+ if (this._compressed) {
914
+ this._state = Yt, this.decompress(t, e);
915
+ return;
916
+ }
917
+ return t.length && (this._messageLength = this._totalPayloadLength, this._fragments.push(t)), this.dataMessage();
918
+ }
919
+ /**
920
+ * Decompresses data.
921
+ *
922
+ * @param {Buffer} data Compressed data
923
+ * @param {Function} cb Callback
924
+ * @private
925
+ */
926
+ decompress(e, t) {
927
+ this._extensions[Pe.extensionName].decompress(e, this._fin, (i, n) => {
928
+ if (i)
929
+ return t(i);
930
+ if (n.length) {
931
+ if (this._messageLength += n.length, this._messageLength > this._maxPayload && this._maxPayload > 0)
932
+ return t(
933
+ g(
934
+ RangeError,
935
+ "Max payload size exceeded",
936
+ !1,
937
+ 1009,
938
+ "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"
939
+ )
940
+ );
941
+ this._fragments.push(n);
942
+ }
943
+ const o = this.dataMessage();
944
+ if (o)
945
+ return t(o);
946
+ this.startLoop(t);
947
+ });
948
+ }
949
+ /**
950
+ * Handles a data message.
951
+ *
952
+ * @return {(Error|undefined)} A possible error
953
+ * @private
954
+ */
955
+ dataMessage() {
956
+ if (this._fin) {
957
+ const e = this._messageLength, t = this._fragments;
958
+ if (this._totalPayloadLength = 0, this._messageLength = 0, this._fragmented = 0, this._fragments = [], this._opcode === 2) {
959
+ let r;
960
+ this._binaryType === "nodebuffer" ? r = de(t, e) : this._binaryType === "arraybuffer" ? r = Vt(de(t, e)) : r = t, this.emit("message", r, !0);
961
+ } else {
962
+ const r = de(t, e);
963
+ if (!this._skipUTF8Validation && !Ue(r))
964
+ return this._loop = !1, g(
965
+ Error,
966
+ "invalid UTF-8 sequence",
967
+ !0,
968
+ 1007,
969
+ "WS_ERR_INVALID_UTF8"
970
+ );
971
+ this.emit("message", r, !1);
972
+ }
973
+ }
974
+ this._state = A;
975
+ }
976
+ /**
977
+ * Handles a control message.
978
+ *
979
+ * @param {Buffer} data Data to handle
980
+ * @return {(Error|RangeError|undefined)} A possible error
981
+ * @private
982
+ */
983
+ controlMessage(e) {
984
+ if (this._opcode === 8)
985
+ if (this._loop = !1, e.length === 0)
986
+ this.emit("conclude", 1005, Re), this.end();
987
+ else {
988
+ const t = e.readUInt16BE(0);
989
+ if (!zt(t))
990
+ return g(
991
+ RangeError,
992
+ `invalid status code ${t}`,
993
+ !0,
994
+ 1002,
995
+ "WS_ERR_INVALID_CLOSE_CODE"
996
+ );
997
+ const r = new X(
998
+ e.buffer,
999
+ e.byteOffset + 2,
1000
+ e.length - 2
1001
+ );
1002
+ if (!this._skipUTF8Validation && !Ue(r))
1003
+ return g(
1004
+ Error,
1005
+ "invalid UTF-8 sequence",
1006
+ !0,
1007
+ 1007,
1008
+ "WS_ERR_INVALID_UTF8"
1009
+ );
1010
+ this.emit("conclude", t, r), this.end();
1011
+ }
1012
+ else
1013
+ this._opcode === 9 ? this.emit("ping", e) : this.emit("pong", e);
1014
+ this._state = A;
1015
+ }
1016
+ };
1017
+ var rt = qt;
1018
+ function g(s, e, t, r, i) {
1019
+ const n = new s(
1020
+ t ? `Invalid WebSocket frame: ${e}` : e
1021
+ );
1022
+ return Error.captureStackTrace(n, g), n.code = i, n[jt] = r, n;
1023
+ }
1024
+ 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);
1025
+ let Jt = class P {
1026
+ /**
1027
+ * Creates a Sender instance.
1028
+ *
1029
+ * @param {(net.Socket|tls.Socket)} socket The connection socket
1030
+ * @param {Object} [extensions] An object containing the negotiated extensions
1031
+ * @param {Function} [generateMask] The function used to generate the masking
1032
+ * key
1033
+ */
1034
+ constructor(e, t, r) {
1035
+ 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 = [];
1036
+ }
1037
+ /**
1038
+ * Frames a piece of data according to the HyBi WebSocket protocol.
1039
+ *
1040
+ * @param {(Buffer|String)} data The data to frame
1041
+ * @param {Object} options Options object
1042
+ * @param {Boolean} [options.fin=false] Specifies whether or not to set the
1043
+ * FIN bit
1044
+ * @param {Function} [options.generateMask] The function used to generate the
1045
+ * masking key
1046
+ * @param {Boolean} [options.mask=false] Specifies whether or not to mask
1047
+ * `data`
1048
+ * @param {Buffer} [options.maskBuffer] The buffer used to store the masking
1049
+ * key
1050
+ * @param {Number} options.opcode The opcode
1051
+ * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
1052
+ * modified
1053
+ * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
1054
+ * RSV1 bit
1055
+ * @return {(Buffer|String)[]} The framed data
1056
+ * @public
1057
+ */
1058
+ static frame(e, t) {
1059
+ let r, i = !1, n = 2, o = !1;
1060
+ 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);
1061
+ let l;
1062
+ 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);
1063
+ let f = l;
1064
+ l >= 65536 ? (n += 8, f = 127) : l > 125 && (n += 2, f = 126);
1065
+ const a = Buffer.allocUnsafe(i ? l + n : n);
1066
+ 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];
1067
+ }
1068
+ /**
1069
+ * Sends a close message to the other peer.
1070
+ *
1071
+ * @param {Number} [code] The status code component of the body
1072
+ * @param {(String|Buffer)} [data] The message component of the body
1073
+ * @param {Boolean} [mask=false] Specifies whether or not to mask the message
1074
+ * @param {Function} [cb] Callback
1075
+ * @public
1076
+ */
1077
+ close(e, t, r, i) {
1078
+ let n;
1079
+ if (e === void 0)
1080
+ n = Xt;
1081
+ else {
1082
+ if (typeof e != "number" || !Zt(e))
1083
+ throw new TypeError("First argument must be a valid error code number");
1084
+ if (t === void 0 || !t.length)
1085
+ n = Buffer.allocUnsafe(2), n.writeUInt16BE(e, 0);
1086
+ else {
1087
+ const l = Buffer.byteLength(t);
1088
+ if (l > 123)
1089
+ throw new RangeError("The message must not be greater than 123 bytes");
1090
+ n = Buffer.allocUnsafe(2 + l), n.writeUInt16BE(e, 0), typeof t == "string" ? n.write(t, 2) : n.set(t, 2);
1091
+ }
1092
+ }
1093
+ const o = {
1094
+ [x]: n.length,
1095
+ fin: !0,
1096
+ generateMask: this._generateMask,
1097
+ mask: r,
1098
+ maskBuffer: this._maskBuffer,
1099
+ opcode: 8,
1100
+ readOnly: !1,
1101
+ rsv1: !1
1102
+ };
1103
+ this._deflating ? this.enqueue([this.dispatch, n, !1, o, i]) : this.sendFrame(P.frame(n, o), i);
1104
+ }
1105
+ /**
1106
+ * Sends a ping message to the other peer.
1107
+ *
1108
+ * @param {*} data The message to send
1109
+ * @param {Boolean} [mask=false] Specifies whether or not to mask `data`
1110
+ * @param {Function} [cb] Callback
1111
+ * @public
1112
+ */
1113
+ ping(e, t, r) {
1114
+ let i, n;
1115
+ if (typeof e == "string" ? (i = Buffer.byteLength(e), n = !1) : (e = M(e), i = e.length, n = M.readOnly), i > 125)
1116
+ throw new RangeError("The data size must not be greater than 125 bytes");
1117
+ const o = {
1118
+ [x]: i,
1119
+ fin: !0,
1120
+ generateMask: this._generateMask,
1121
+ mask: t,
1122
+ maskBuffer: this._maskBuffer,
1123
+ opcode: 9,
1124
+ readOnly: n,
1125
+ rsv1: !1
1126
+ };
1127
+ this._deflating ? this.enqueue([this.dispatch, e, !1, o, r]) : this.sendFrame(P.frame(e, o), r);
1128
+ }
1129
+ /**
1130
+ * Sends a pong message to the other peer.
1131
+ *
1132
+ * @param {*} data The message to send
1133
+ * @param {Boolean} [mask=false] Specifies whether or not to mask `data`
1134
+ * @param {Function} [cb] Callback
1135
+ * @public
1136
+ */
1137
+ pong(e, t, r) {
1138
+ let i, n;
1139
+ if (typeof e == "string" ? (i = Buffer.byteLength(e), n = !1) : (e = M(e), i = e.length, n = M.readOnly), i > 125)
1140
+ throw new RangeError("The data size must not be greater than 125 bytes");
1141
+ const o = {
1142
+ [x]: i,
1143
+ fin: !0,
1144
+ generateMask: this._generateMask,
1145
+ mask: t,
1146
+ maskBuffer: this._maskBuffer,
1147
+ opcode: 10,
1148
+ readOnly: n,
1149
+ rsv1: !1
1150
+ };
1151
+ this._deflating ? this.enqueue([this.dispatch, e, !1, o, r]) : this.sendFrame(P.frame(e, o), r);
1152
+ }
1153
+ /**
1154
+ * Sends a data message to the other peer.
1155
+ *
1156
+ * @param {*} data The message to send
1157
+ * @param {Object} options Options object
1158
+ * @param {Boolean} [options.binary=false] Specifies whether `data` is binary
1159
+ * or text
1160
+ * @param {Boolean} [options.compress=false] Specifies whether or not to
1161
+ * compress `data`
1162
+ * @param {Boolean} [options.fin=false] Specifies whether the fragment is the
1163
+ * last one
1164
+ * @param {Boolean} [options.mask=false] Specifies whether or not to mask
1165
+ * `data`
1166
+ * @param {Function} [cb] Callback
1167
+ * @public
1168
+ */
1169
+ send(e, t, r) {
1170
+ const i = this._extensions[Ie.extensionName];
1171
+ let n = t.binary ? 2 : 1, o = t.compress, l, f;
1172
+ 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) {
1173
+ const a = {
1174
+ [x]: l,
1175
+ fin: t.fin,
1176
+ generateMask: this._generateMask,
1177
+ mask: t.mask,
1178
+ maskBuffer: this._maskBuffer,
1179
+ opcode: n,
1180
+ readOnly: f,
1181
+ rsv1: o
1182
+ };
1183
+ this._deflating ? this.enqueue([this.dispatch, e, this._compress, a, r]) : this.dispatch(e, this._compress, a, r);
1184
+ } else
1185
+ this.sendFrame(
1186
+ P.frame(e, {
1187
+ [x]: l,
1188
+ fin: t.fin,
1189
+ generateMask: this._generateMask,
1190
+ mask: t.mask,
1191
+ maskBuffer: this._maskBuffer,
1192
+ opcode: n,
1193
+ readOnly: f,
1194
+ rsv1: !1
1195
+ }),
1196
+ r
1197
+ );
1198
+ }
1199
+ /**
1200
+ * Dispatches a message.
1201
+ *
1202
+ * @param {(Buffer|String)} data The message to send
1203
+ * @param {Boolean} [compress=false] Specifies whether or not to compress
1204
+ * `data`
1205
+ * @param {Object} options Options object
1206
+ * @param {Boolean} [options.fin=false] Specifies whether or not to set the
1207
+ * FIN bit
1208
+ * @param {Function} [options.generateMask] The function used to generate the
1209
+ * masking key
1210
+ * @param {Boolean} [options.mask=false] Specifies whether or not to mask
1211
+ * `data`
1212
+ * @param {Buffer} [options.maskBuffer] The buffer used to store the masking
1213
+ * key
1214
+ * @param {Number} options.opcode The opcode
1215
+ * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
1216
+ * modified
1217
+ * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
1218
+ * RSV1 bit
1219
+ * @param {Function} [cb] Callback
1220
+ * @private
1221
+ */
1222
+ dispatch(e, t, r, i) {
1223
+ if (!t) {
1224
+ this.sendFrame(P.frame(e, r), i);
1225
+ return;
1226
+ }
1227
+ const n = this._extensions[Ie.extensionName];
1228
+ this._bufferedBytes += r[x], this._deflating = !0, n.compress(e, r.fin, (o, l) => {
1229
+ if (this._socket.destroyed) {
1230
+ const f = new Error(
1231
+ "The socket was closed while data was being compressed"
1232
+ );
1233
+ typeof i == "function" && i(f);
1234
+ for (let a = 0; a < this._queue.length; a++) {
1235
+ const c = this._queue[a], h = c[c.length - 1];
1236
+ typeof h == "function" && h(f);
1237
+ }
1238
+ return;
1239
+ }
1240
+ this._bufferedBytes -= r[x], this._deflating = !1, r.readOnly = !1, this.sendFrame(P.frame(l, r), i), this.dequeue();
1241
+ });
1242
+ }
1243
+ /**
1244
+ * Executes queued send operations.
1245
+ *
1246
+ * @private
1247
+ */
1248
+ dequeue() {
1249
+ for (; !this._deflating && this._queue.length; ) {
1250
+ const e = this._queue.shift();
1251
+ this._bufferedBytes -= e[3][x], Reflect.apply(e[0], this, e.slice(1));
1252
+ }
1253
+ }
1254
+ /**
1255
+ * Enqueues a send operation.
1256
+ *
1257
+ * @param {Array} params Send operation parameters.
1258
+ * @private
1259
+ */
1260
+ enqueue(e) {
1261
+ this._bufferedBytes += e[3][x], this._queue.push(e);
1262
+ }
1263
+ /**
1264
+ * Sends a frame.
1265
+ *
1266
+ * @param {Buffer[]} list The frame to send
1267
+ * @param {Function} [cb] Callback
1268
+ * @private
1269
+ */
1270
+ sendFrame(e, t) {
1271
+ 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);
1272
+ }
1273
+ };
1274
+ var it = Jt;
1275
+ 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");
1276
+ class B {
1277
+ /**
1278
+ * Create a new `Event`.
1279
+ *
1280
+ * @param {String} type The name of the event
1281
+ * @throws {TypeError} If the `type` argument is not specified
1282
+ */
1283
+ constructor(e) {
1284
+ this[I] = null, this[Ve] = e;
1285
+ }
1286
+ /**
1287
+ * @type {*}
1288
+ */
1289
+ get target() {
1290
+ return this[I];
1291
+ }
1292
+ /**
1293
+ * @type {String}
1294
+ */
1295
+ get type() {
1296
+ return this[Ve];
1297
+ }
1298
+ }
1299
+ Object.defineProperty(B.prototype, "target", { enumerable: !0 });
1300
+ Object.defineProperty(B.prototype, "type", { enumerable: !0 });
1301
+ class Y extends B {
1302
+ /**
1303
+ * Create a new `CloseEvent`.
1304
+ *
1305
+ * @param {String} type The name of the event
1306
+ * @param {Object} [options] A dictionary object that allows for setting
1307
+ * attributes via object members of the same name
1308
+ * @param {Number} [options.code=0] The status code explaining why the
1309
+ * connection was closed
1310
+ * @param {String} [options.reason=''] A human-readable string explaining why
1311
+ * the connection was closed
1312
+ * @param {Boolean} [options.wasClean=false] Indicates whether or not the
1313
+ * connection was cleanly closed
1314
+ */
1315
+ constructor(e, t = {}) {
1316
+ 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;
1317
+ }
1318
+ /**
1319
+ * @type {Number}
1320
+ */
1321
+ get code() {
1322
+ return this[We];
1323
+ }
1324
+ /**
1325
+ * @type {String}
1326
+ */
1327
+ get reason() {
1328
+ return this[Ge];
1329
+ }
1330
+ /**
1331
+ * @type {Boolean}
1332
+ */
1333
+ get wasClean() {
1334
+ return this[He];
1335
+ }
1336
+ }
1337
+ Object.defineProperty(Y.prototype, "code", { enumerable: !0 });
1338
+ Object.defineProperty(Y.prototype, "reason", { enumerable: !0 });
1339
+ Object.defineProperty(Y.prototype, "wasClean", { enumerable: !0 });
1340
+ class le extends B {
1341
+ /**
1342
+ * Create a new `ErrorEvent`.
1343
+ *
1344
+ * @param {String} type The name of the event
1345
+ * @param {Object} [options] A dictionary object that allows for setting
1346
+ * attributes via object members of the same name
1347
+ * @param {*} [options.error=null] The error that generated this event
1348
+ * @param {String} [options.message=''] The error message
1349
+ */
1350
+ constructor(e, t = {}) {
1351
+ super(e), this[Fe] = t.error === void 0 ? null : t.error, this[je] = t.message === void 0 ? "" : t.message;
1352
+ }
1353
+ /**
1354
+ * @type {*}
1355
+ */
1356
+ get error() {
1357
+ return this[Fe];
1358
+ }
1359
+ /**
1360
+ * @type {String}
1361
+ */
1362
+ get message() {
1363
+ return this[je];
1364
+ }
1365
+ }
1366
+ Object.defineProperty(le.prototype, "error", { enumerable: !0 });
1367
+ Object.defineProperty(le.prototype, "message", { enumerable: !0 });
1368
+ class xe extends B {
1369
+ /**
1370
+ * Create a new `MessageEvent`.
1371
+ *
1372
+ * @param {String} type The name of the event
1373
+ * @param {Object} [options] A dictionary object that allows for setting
1374
+ * attributes via object members of the same name
1375
+ * @param {*} [options.data=null] The message content
1376
+ */
1377
+ constructor(e, t = {}) {
1378
+ super(e), this[Ae] = t.data === void 0 ? null : t.data;
1379
+ }
1380
+ /**
1381
+ * @type {*}
1382
+ */
1383
+ get data() {
1384
+ return this[Ae];
1385
+ }
1386
+ }
1387
+ Object.defineProperty(xe.prototype, "data", { enumerable: !0 });
1388
+ const es = {
1389
+ /**
1390
+ * Register an event listener.
1391
+ *
1392
+ * @param {String} type A string representing the event type to listen for
1393
+ * @param {(Function|Object)} handler The listener to add
1394
+ * @param {Object} [options] An options object specifies characteristics about
1395
+ * the event listener
1396
+ * @param {Boolean} [options.once=false] A `Boolean` indicating that the
1397
+ * listener should be invoked at most once after being added. If `true`,
1398
+ * the listener would be automatically removed when invoked.
1399
+ * @public
1400
+ */
1401
+ addEventListener(s, e, t = {}) {
1402
+ for (const i of this.listeners(s))
1403
+ if (!t[F] && i[pe] === e && !i[F])
1404
+ return;
1405
+ let r;
1406
+ if (s === "message")
1407
+ r = function(n, o) {
1408
+ const l = new xe("message", {
1409
+ data: o ? n : n.toString()
1410
+ });
1411
+ l[I] = this, Z(e, this, l);
1412
+ };
1413
+ else if (s === "close")
1414
+ r = function(n, o) {
1415
+ const l = new Y("close", {
1416
+ code: n,
1417
+ reason: o.toString(),
1418
+ wasClean: this._closeFrameReceived && this._closeFrameSent
1419
+ });
1420
+ l[I] = this, Z(e, this, l);
1421
+ };
1422
+ else if (s === "error")
1423
+ r = function(n) {
1424
+ const o = new le("error", {
1425
+ error: n,
1426
+ message: n.message
1427
+ });
1428
+ o[I] = this, Z(e, this, o);
1429
+ };
1430
+ else if (s === "open")
1431
+ r = function() {
1432
+ const n = new B("open");
1433
+ n[I] = this, Z(e, this, n);
1434
+ };
1435
+ else
1436
+ return;
1437
+ r[F] = !!t[F], r[pe] = e, t.once ? this.once(s, r) : this.on(s, r);
1438
+ },
1439
+ /**
1440
+ * Remove an event listener.
1441
+ *
1442
+ * @param {String} type A string representing the event type to remove
1443
+ * @param {(Function|Object)} handler The listener to remove
1444
+ * @public
1445
+ */
1446
+ removeEventListener(s, e) {
1447
+ for (const t of this.listeners(s))
1448
+ if (t[pe] === e && !t[F]) {
1449
+ this.removeListener(s, t);
1450
+ break;
1451
+ }
1452
+ }
1453
+ };
1454
+ var ts = {
1455
+ CloseEvent: Y,
1456
+ ErrorEvent: le,
1457
+ Event: B,
1458
+ EventTarget: es,
1459
+ MessageEvent: xe
1460
+ };
1461
+ function Z(s, e, t) {
1462
+ typeof s == "object" && s.handleEvent ? s.handleEvent.call(s, t) : s.call(e, t);
1463
+ }
1464
+ const { tokenChars: j } = ae;
1465
+ function k(s, e, t) {
1466
+ s[e] === void 0 ? s[e] = [t] : s[e].push(t);
1467
+ }
1468
+ function ss(s) {
1469
+ const e = /* @__PURE__ */ Object.create(null);
1470
+ let t = /* @__PURE__ */ Object.create(null), r = !1, i = !1, n = !1, o, l, f = -1, a = -1, c = -1, h = 0;
1471
+ for (; h < s.length; h++)
1472
+ if (a = s.charCodeAt(h), o === void 0)
1473
+ if (c === -1 && j[a] === 1)
1474
+ f === -1 && (f = h);
1475
+ else if (h !== 0 && (a === 32 || a === 9))
1476
+ c === -1 && f !== -1 && (c = h);
1477
+ else if (a === 59 || a === 44) {
1478
+ if (f === -1)
1479
+ throw new SyntaxError(`Unexpected character at index ${h}`);
1480
+ c === -1 && (c = h);
1481
+ const v = s.slice(f, c);
1482
+ a === 44 ? (k(e, v, t), t = /* @__PURE__ */ Object.create(null)) : o = v, f = c = -1;
1483
+ } else
1484
+ throw new SyntaxError(`Unexpected character at index ${h}`);
1485
+ else if (l === void 0)
1486
+ if (c === -1 && j[a] === 1)
1487
+ f === -1 && (f = h);
1488
+ else if (a === 32 || a === 9)
1489
+ c === -1 && f !== -1 && (c = h);
1490
+ else if (a === 59 || a === 44) {
1491
+ if (f === -1)
1492
+ throw new SyntaxError(`Unexpected character at index ${h}`);
1493
+ 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;
1494
+ } else if (a === 61 && f !== -1 && c === -1)
1495
+ l = s.slice(f, h), f = c = -1;
1496
+ else
1497
+ throw new SyntaxError(`Unexpected character at index ${h}`);
1498
+ else if (i) {
1499
+ if (j[a] !== 1)
1500
+ throw new SyntaxError(`Unexpected character at index ${h}`);
1501
+ f === -1 ? f = h : r || (r = !0), i = !1;
1502
+ } else if (n)
1503
+ if (j[a] === 1)
1504
+ f === -1 && (f = h);
1505
+ else if (a === 34 && f !== -1)
1506
+ n = !1, c = h;
1507
+ else if (a === 92)
1508
+ i = !0;
1509
+ else
1510
+ throw new SyntaxError(`Unexpected character at index ${h}`);
1511
+ else if (a === 34 && s.charCodeAt(h - 1) === 61)
1512
+ n = !0;
1513
+ else if (c === -1 && j[a] === 1)
1514
+ f === -1 && (f = h);
1515
+ else if (f !== -1 && (a === 32 || a === 9))
1516
+ c === -1 && (c = h);
1517
+ else if (a === 59 || a === 44) {
1518
+ if (f === -1)
1519
+ throw new SyntaxError(`Unexpected character at index ${h}`);
1520
+ c === -1 && (c = h);
1521
+ let v = s.slice(f, c);
1522
+ 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;
1523
+ } else
1524
+ throw new SyntaxError(`Unexpected character at index ${h}`);
1525
+ if (f === -1 || n || a === 32 || a === 9)
1526
+ throw new SyntaxError("Unexpected end of input");
1527
+ c === -1 && (c = h);
1528
+ const p = s.slice(f, c);
1529
+ 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;
1530
+ }
1531
+ function rs(s) {
1532
+ return Object.keys(s).map((e) => {
1533
+ let t = s[e];
1534
+ return Array.isArray(t) || (t = [t]), t.map((r) => [e].concat(
1535
+ Object.keys(r).map((i) => {
1536
+ let n = r[i];
1537
+ return Array.isArray(n) || (n = [n]), n.map((o) => o === !0 ? i : `${i}=${o}`).join("; ");
1538
+ })
1539
+ ).join("; ")).join(", ");
1540
+ }).join(", ");
1541
+ }
1542
+ var nt = { format: rs, parse: ss };
1543
+ 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, {
1544
+ BINARY_TYPES: ze,
1545
+ EMPTY_BUFFER: Q,
1546
+ GUID: us,
1547
+ kForOnEventAttribute: ge,
1548
+ kListener: ds,
1549
+ kStatusCode: _s,
1550
+ kWebSocket: y,
1551
+ NOOP: at
1552
+ } = U, {
1553
+ EventTarget: { addEventListener: ps, removeEventListener: ms }
1554
+ } = 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~]+$/;
1555
+ let m = class d extends is {
1556
+ /**
1557
+ * Create a new `WebSocket`.
1558
+ *
1559
+ * @param {(String|URL)} address The URL to which to connect
1560
+ * @param {(String|String[])} [protocols] The subprotocols
1561
+ * @param {Object} [options] Connection options
1562
+ */
1563
+ constructor(e, t, r) {
1564
+ 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;
1565
+ }
1566
+ /**
1567
+ * This deviates from the WHATWG interface since ws doesn't support the
1568
+ * required default "blob" type (instead we define a custom "nodebuffer"
1569
+ * type).
1570
+ *
1571
+ * @type {String}
1572
+ */
1573
+ get binaryType() {
1574
+ return this._binaryType;
1575
+ }
1576
+ set binaryType(e) {
1577
+ ze.includes(e) && (this._binaryType = e, this._receiver && (this._receiver._binaryType = e));
1578
+ }
1579
+ /**
1580
+ * @type {Number}
1581
+ */
1582
+ get bufferedAmount() {
1583
+ return this._socket ? this._socket._writableState.length + this._sender._bufferedBytes : this._bufferedAmount;
1584
+ }
1585
+ /**
1586
+ * @type {String}
1587
+ */
1588
+ get extensions() {
1589
+ return Object.keys(this._extensions).join();
1590
+ }
1591
+ /**
1592
+ * @type {Boolean}
1593
+ */
1594
+ get isPaused() {
1595
+ return this._paused;
1596
+ }
1597
+ /**
1598
+ * @type {Function}
1599
+ */
1600
+ /* istanbul ignore next */
1601
+ get onclose() {
1602
+ return null;
1603
+ }
1604
+ /**
1605
+ * @type {Function}
1606
+ */
1607
+ /* istanbul ignore next */
1608
+ get onerror() {
1609
+ return null;
1610
+ }
1611
+ /**
1612
+ * @type {Function}
1613
+ */
1614
+ /* istanbul ignore next */
1615
+ get onopen() {
1616
+ return null;
1617
+ }
1618
+ /**
1619
+ * @type {Function}
1620
+ */
1621
+ /* istanbul ignore next */
1622
+ get onmessage() {
1623
+ return null;
1624
+ }
1625
+ /**
1626
+ * @type {String}
1627
+ */
1628
+ get protocol() {
1629
+ return this._protocol;
1630
+ }
1631
+ /**
1632
+ * @type {Number}
1633
+ */
1634
+ get readyState() {
1635
+ return this._readyState;
1636
+ }
1637
+ /**
1638
+ * @type {String}
1639
+ */
1640
+ get url() {
1641
+ return this._url;
1642
+ }
1643
+ /**
1644
+ * Set up the socket and the internal resources.
1645
+ *
1646
+ * @param {(net.Socket|tls.Socket)} socket The network socket between the
1647
+ * server and client
1648
+ * @param {Buffer} head The first packet of the upgraded stream
1649
+ * @param {Object} options Options object
1650
+ * @param {Function} [options.generateMask] The function used to generate the
1651
+ * masking key
1652
+ * @param {Number} [options.maxPayload=0] The maximum allowed message size
1653
+ * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
1654
+ * not to skip UTF-8 validation for text and close messages
1655
+ * @private
1656
+ */
1657
+ setSocket(e, t, r) {
1658
+ const i = new hs({
1659
+ binaryType: this.binaryType,
1660
+ extensions: this._extensions,
1661
+ isServer: this._isServer,
1662
+ maxPayload: r.maxPayload,
1663
+ skipUTF8Validation: r.skipUTF8Validation
1664
+ });
1665
+ 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");
1666
+ }
1667
+ /**
1668
+ * Emit the `'close'` event.
1669
+ *
1670
+ * @private
1671
+ */
1672
+ emitClose() {
1673
+ if (!this._socket) {
1674
+ this._readyState = d.CLOSED, this.emit("close", this._closeCode, this._closeMessage);
1675
+ return;
1676
+ }
1677
+ this._extensions[T.extensionName] && this._extensions[T.extensionName].cleanup(), this._receiver.removeAllListeners(), this._readyState = d.CLOSED, this.emit("close", this._closeCode, this._closeMessage);
1678
+ }
1679
+ /**
1680
+ * Start a closing handshake.
1681
+ *
1682
+ * +----------+ +-----------+ +----------+
1683
+ * - - -|ws.close()|-->|close frame|-->|ws.close()|- - -
1684
+ * | +----------+ +-----------+ +----------+ |
1685
+ * +----------+ +-----------+ |
1686
+ * CLOSING |ws.close()|<--|close frame|<--+-----+ CLOSING
1687
+ * +----------+ +-----------+ |
1688
+ * | | | +---+ |
1689
+ * +------------------------+-->|fin| - - - -
1690
+ * | +---+ | +---+
1691
+ * - - - - -|fin|<---------------------+
1692
+ * +---+
1693
+ *
1694
+ * @param {Number} [code] Status code explaining why the connection is closing
1695
+ * @param {(String|Buffer)} [data] The reason why the connection is
1696
+ * closing
1697
+ * @public
1698
+ */
1699
+ close(e, t) {
1700
+ if (this.readyState !== d.CLOSED) {
1701
+ if (this.readyState === d.CONNECTING) {
1702
+ const r = "WebSocket was closed before the connection was established";
1703
+ b(this, this._req, r);
1704
+ return;
1705
+ }
1706
+ if (this.readyState === d.CLOSING) {
1707
+ this._closeFrameSent && (this._closeFrameReceived || this._receiver._writableState.errorEmitted) && this._socket.end();
1708
+ return;
1709
+ }
1710
+ this._readyState = d.CLOSING, this._sender.close(e, t, !this._isServer, (r) => {
1711
+ r || (this._closeFrameSent = !0, (this._closeFrameReceived || this._receiver._writableState.errorEmitted) && this._socket.end());
1712
+ }), this._closeTimer = setTimeout(
1713
+ this._socket.destroy.bind(this._socket),
1714
+ Ss
1715
+ );
1716
+ }
1717
+ }
1718
+ /**
1719
+ * Pause the socket.
1720
+ *
1721
+ * @public
1722
+ */
1723
+ pause() {
1724
+ this.readyState === d.CONNECTING || this.readyState === d.CLOSED || (this._paused = !0, this._socket.pause());
1725
+ }
1726
+ /**
1727
+ * Send a ping.
1728
+ *
1729
+ * @param {*} [data] The data to send
1730
+ * @param {Boolean} [mask] Indicates whether or not to mask `data`
1731
+ * @param {Function} [cb] Callback which is executed when the ping is sent
1732
+ * @public
1733
+ */
1734
+ ping(e, t, r) {
1735
+ if (this.readyState === d.CONNECTING)
1736
+ throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
1737
+ 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) {
1738
+ ve(this, e, r);
1739
+ return;
1740
+ }
1741
+ t === void 0 && (t = !this._isServer), this._sender.ping(e || Q, t, r);
1742
+ }
1743
+ /**
1744
+ * Send a pong.
1745
+ *
1746
+ * @param {*} [data] The data to send
1747
+ * @param {Boolean} [mask] Indicates whether or not to mask `data`
1748
+ * @param {Function} [cb] Callback which is executed when the pong is sent
1749
+ * @public
1750
+ */
1751
+ pong(e, t, r) {
1752
+ if (this.readyState === d.CONNECTING)
1753
+ throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
1754
+ 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) {
1755
+ ve(this, e, r);
1756
+ return;
1757
+ }
1758
+ t === void 0 && (t = !this._isServer), this._sender.pong(e || Q, t, r);
1759
+ }
1760
+ /**
1761
+ * Resume the socket.
1762
+ *
1763
+ * @public
1764
+ */
1765
+ resume() {
1766
+ this.readyState === d.CONNECTING || this.readyState === d.CLOSED || (this._paused = !1, this._receiver._writableState.needDrain || this._socket.resume());
1767
+ }
1768
+ /**
1769
+ * Send a data message.
1770
+ *
1771
+ * @param {*} data The message to send
1772
+ * @param {Object} [options] Options object
1773
+ * @param {Boolean} [options.binary] Specifies whether `data` is binary or
1774
+ * text
1775
+ * @param {Boolean} [options.compress] Specifies whether or not to compress
1776
+ * `data`
1777
+ * @param {Boolean} [options.fin=true] Specifies whether the fragment is the
1778
+ * last one
1779
+ * @param {Boolean} [options.mask] Specifies whether or not to mask `data`
1780
+ * @param {Function} [cb] Callback which is executed when data is written out
1781
+ * @public
1782
+ */
1783
+ send(e, t, r) {
1784
+ if (this.readyState === d.CONNECTING)
1785
+ throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
1786
+ if (typeof t == "function" && (r = t, t = {}), typeof e == "number" && (e = e.toString()), this.readyState !== d.OPEN) {
1787
+ ve(this, e, r);
1788
+ return;
1789
+ }
1790
+ const i = {
1791
+ binary: typeof e != "string",
1792
+ mask: !this._isServer,
1793
+ compress: !0,
1794
+ fin: !0,
1795
+ ...t
1796
+ };
1797
+ this._extensions[T.extensionName] || (i.compress = !1), this._sender.send(e || Q, i, r);
1798
+ }
1799
+ /**
1800
+ * Forcibly close the connection.
1801
+ *
1802
+ * @public
1803
+ */
1804
+ terminate() {
1805
+ if (this.readyState !== d.CLOSED) {
1806
+ if (this.readyState === d.CONNECTING) {
1807
+ const e = "WebSocket was closed before the connection was established";
1808
+ b(this, this._req, e);
1809
+ return;
1810
+ }
1811
+ this._socket && (this._readyState = d.CLOSING, this._socket.destroy());
1812
+ }
1813
+ }
1814
+ };
1815
+ Object.defineProperty(m, "CONNECTING", {
1816
+ enumerable: !0,
1817
+ value: O.indexOf("CONNECTING")
1818
+ });
1819
+ Object.defineProperty(m.prototype, "CONNECTING", {
1820
+ enumerable: !0,
1821
+ value: O.indexOf("CONNECTING")
1822
+ });
1823
+ Object.defineProperty(m, "OPEN", {
1824
+ enumerable: !0,
1825
+ value: O.indexOf("OPEN")
1826
+ });
1827
+ Object.defineProperty(m.prototype, "OPEN", {
1828
+ enumerable: !0,
1829
+ value: O.indexOf("OPEN")
1830
+ });
1831
+ Object.defineProperty(m, "CLOSING", {
1832
+ enumerable: !0,
1833
+ value: O.indexOf("CLOSING")
1834
+ });
1835
+ Object.defineProperty(m.prototype, "CLOSING", {
1836
+ enumerable: !0,
1837
+ value: O.indexOf("CLOSING")
1838
+ });
1839
+ Object.defineProperty(m, "CLOSED", {
1840
+ enumerable: !0,
1841
+ value: O.indexOf("CLOSED")
1842
+ });
1843
+ Object.defineProperty(m.prototype, "CLOSED", {
1844
+ enumerable: !0,
1845
+ value: O.indexOf("CLOSED")
1846
+ });
1847
+ [
1848
+ "binaryType",
1849
+ "bufferedAmount",
1850
+ "extensions",
1851
+ "isPaused",
1852
+ "protocol",
1853
+ "readyState",
1854
+ "url"
1855
+ ].forEach((s) => {
1856
+ Object.defineProperty(m.prototype, s, { enumerable: !0 });
1857
+ });
1858
+ ["open", "error", "close", "message"].forEach((s) => {
1859
+ Object.defineProperty(m.prototype, `on${s}`, {
1860
+ enumerable: !0,
1861
+ get() {
1862
+ for (const e of this.listeners(s))
1863
+ if (e[ge])
1864
+ return e[ds];
1865
+ return null;
1866
+ },
1867
+ set(e) {
1868
+ for (const t of this.listeners(s))
1869
+ if (t[ge]) {
1870
+ this.removeListener(s, t);
1871
+ break;
1872
+ }
1873
+ typeof e == "function" && this.addEventListener(s, e, {
1874
+ [ge]: !0
1875
+ });
1876
+ }
1877
+ });
1878
+ });
1879
+ m.prototype.addEventListener = ps;
1880
+ m.prototype.removeEventListener = ms;
1881
+ var ft = m;
1882
+ function ht(s, e, t, r) {
1883
+ const i = {
1884
+ protocolVersion: ye[1],
1885
+ maxPayload: 104857600,
1886
+ skipUTF8Validation: !1,
1887
+ perMessageDeflate: !0,
1888
+ followRedirects: !1,
1889
+ maxRedirects: 10,
1890
+ ...r,
1891
+ createConnection: void 0,
1892
+ socketPath: void 0,
1893
+ hostname: void 0,
1894
+ protocol: void 0,
1895
+ timeout: void 0,
1896
+ method: "GET",
1897
+ host: void 0,
1898
+ path: void 0,
1899
+ port: void 0
1900
+ };
1901
+ if (!ye.includes(i.protocolVersion))
1902
+ throw new RangeError(
1903
+ `Unsupported protocol version: ${i.protocolVersion} (supported versions: ${ye.join(", ")})`
1904
+ );
1905
+ let n;
1906
+ if (e instanceof me)
1907
+ n = e, s._url = e.href;
1908
+ else {
1909
+ try {
1910
+ n = new me(e);
1911
+ } catch {
1912
+ throw new SyntaxError(`Invalid URL: ${e}`);
1913
+ }
1914
+ s._url = e;
1915
+ }
1916
+ const o = n.protocol === "wss:", l = n.protocol === "ws+unix:";
1917
+ let f;
1918
+ 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) {
1919
+ const u = new SyntaxError(f);
1920
+ if (s._redirects === 0)
1921
+ throw u;
1922
+ ee(s, u);
1923
+ return;
1924
+ }
1925
+ const a = o ? 443 : 80, c = ls(16).toString("base64"), h = o ? ns.request : os.request, p = /* @__PURE__ */ new Set();
1926
+ let v;
1927
+ 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 = {
1928
+ ...i.headers,
1929
+ "Sec-WebSocket-Version": i.protocolVersion,
1930
+ "Sec-WebSocket-Key": c,
1931
+ Connection: "Upgrade",
1932
+ Upgrade: "websocket"
1933
+ }, i.path = n.pathname + n.search, i.timeout = i.handshakeTimeout, i.perMessageDeflate && (v = new T(
1934
+ i.perMessageDeflate !== !0 ? i.perMessageDeflate : {},
1935
+ !1,
1936
+ i.maxPayload
1937
+ ), i.headers["Sec-WebSocket-Extensions"] = gs({
1938
+ [T.extensionName]: v.offer()
1939
+ })), t.length) {
1940
+ for (const u of t) {
1941
+ if (typeof u != "string" || !Es.test(u) || p.has(u))
1942
+ throw new SyntaxError(
1943
+ "An invalid or duplicated subprotocol was specified"
1944
+ );
1945
+ p.add(u);
1946
+ }
1947
+ i.headers["Sec-WebSocket-Protocol"] = t.join(",");
1948
+ }
1949
+ 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) {
1950
+ const u = i.path.split(":");
1951
+ i.socketPath = u[0], i.path = u[1];
1952
+ }
1953
+ let _;
1954
+ if (i.followRedirects) {
1955
+ if (s._redirects === 0) {
1956
+ s._originalIpc = l, s._originalSecure = o, s._originalHostOrSocketPath = l ? i.socketPath : n.host;
1957
+ const u = r && r.headers;
1958
+ if (r = { ...r, headers: {} }, u)
1959
+ for (const [E, $] of Object.entries(u))
1960
+ r.headers[E.toLowerCase()] = $;
1961
+ } else if (s.listenerCount("redirect") === 0) {
1962
+ const u = l ? s._originalIpc ? i.socketPath === s._originalHostOrSocketPath : !1 : s._originalIpc ? !1 : n.host === s._originalHostOrSocketPath;
1963
+ (!u || s._originalSecure && !o) && (delete i.headers.authorization, delete i.headers.cookie, u || delete i.headers.host, i.auth = void 0);
1964
+ }
1965
+ 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, _);
1966
+ } else
1967
+ _ = s._req = h(i);
1968
+ i.timeout && _.on("timeout", () => {
1969
+ b(s, _, "Opening handshake has timed out");
1970
+ }), _.on("error", (u) => {
1971
+ _ === null || _[lt] || (_ = s._req = null, ee(s, u));
1972
+ }), _.on("response", (u) => {
1973
+ const E = u.headers.location, $ = u.statusCode;
1974
+ if (E && i.followRedirects && $ >= 300 && $ < 400) {
1975
+ if (++s._redirects > i.maxRedirects) {
1976
+ b(s, _, "Maximum redirects exceeded");
1977
+ return;
1978
+ }
1979
+ _.abort();
1980
+ let q;
1981
+ try {
1982
+ q = new me(E, e);
1983
+ } catch {
1984
+ const L = new SyntaxError(`Invalid URL: ${E}`);
1985
+ ee(s, L);
1986
+ return;
1987
+ }
1988
+ ht(s, q, t, r);
1989
+ } else
1990
+ s.emit("unexpected-response", _, u) || b(
1991
+ s,
1992
+ _,
1993
+ `Unexpected server response: ${u.statusCode}`
1994
+ );
1995
+ }), _.on("upgrade", (u, E, $) => {
1996
+ if (s.emit("upgrade", u), s.readyState !== m.CONNECTING)
1997
+ return;
1998
+ if (_ = s._req = null, u.headers.upgrade.toLowerCase() !== "websocket") {
1999
+ b(s, E, "Invalid Upgrade header");
2000
+ return;
2001
+ }
2002
+ const q = fs("sha1").update(c + us).digest("base64");
2003
+ if (u.headers["sec-websocket-accept"] !== q) {
2004
+ b(s, E, "Invalid Sec-WebSocket-Accept header");
2005
+ return;
2006
+ }
2007
+ const D = u.headers["sec-websocket-protocol"];
2008
+ let L;
2009
+ 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) {
2010
+ b(s, E, L);
2011
+ return;
2012
+ }
2013
+ D && (s._protocol = D);
2014
+ const ke = u.headers["sec-websocket-extensions"];
2015
+ if (ke !== void 0) {
2016
+ if (!v) {
2017
+ b(s, E, "Server sent a Sec-WebSocket-Extensions header but no extension was requested");
2018
+ return;
2019
+ }
2020
+ let he;
2021
+ try {
2022
+ he = ys(ke);
2023
+ } catch {
2024
+ b(s, E, "Invalid Sec-WebSocket-Extensions header");
2025
+ return;
2026
+ }
2027
+ const we = Object.keys(he);
2028
+ if (we.length !== 1 || we[0] !== T.extensionName) {
2029
+ b(s, E, "Server indicated an extension that was not requested");
2030
+ return;
2031
+ }
2032
+ try {
2033
+ v.accept(he[T.extensionName]);
2034
+ } catch {
2035
+ b(s, E, "Invalid Sec-WebSocket-Extensions header");
2036
+ return;
2037
+ }
2038
+ s._extensions[T.extensionName] = v;
2039
+ }
2040
+ s.setSocket(E, $, {
2041
+ generateMask: i.generateMask,
2042
+ maxPayload: i.maxPayload,
2043
+ skipUTF8Validation: i.skipUTF8Validation
2044
+ });
2045
+ }), i.finishRequest ? i.finishRequest(_, s) : _.end();
2046
+ }
2047
+ function ee(s, e) {
2048
+ s._readyState = m.CLOSING, s.emit("error", e), s.emitClose();
2049
+ }
2050
+ function bs(s) {
2051
+ return s.path = s.socketPath, ot.connect(s);
2052
+ }
2053
+ function xs(s) {
2054
+ return s.path = void 0, !s.servername && s.servername !== "" && (s.servername = ot.isIP(s.host) ? "" : s.host), as.connect(s);
2055
+ }
2056
+ function b(s, e, t) {
2057
+ s._readyState = m.CLOSING;
2058
+ const r = new Error(t);
2059
+ 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)));
2060
+ }
2061
+ function ve(s, e, t) {
2062
+ if (e) {
2063
+ const r = vs(e).length;
2064
+ s._socket ? s._sender._bufferedBytes += r : s._bufferedAmount += r;
2065
+ }
2066
+ if (t) {
2067
+ const r = new Error(
2068
+ `WebSocket is not open: readyState ${s.readyState} (${O[s.readyState]})`
2069
+ );
2070
+ process.nextTick(t, r);
2071
+ }
2072
+ }
2073
+ function ks(s, e) {
2074
+ const t = this[y];
2075
+ 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));
2076
+ }
2077
+ function ws() {
2078
+ const s = this[y];
2079
+ s.isPaused || s._socket.resume();
2080
+ }
2081
+ function Os(s) {
2082
+ const e = this[y];
2083
+ e._socket[y] !== void 0 && (e._socket.removeListener("data", fe), process.nextTick(ct, e._socket), e.close(s[_s])), e.emit("error", s);
2084
+ }
2085
+ function Ye() {
2086
+ this[y].emitClose();
2087
+ }
2088
+ function Cs(s, e) {
2089
+ this[y].emit("message", s, e);
2090
+ }
2091
+ function Ts(s) {
2092
+ const e = this[y];
2093
+ e.pong(s, !e._isServer, at), e.emit("ping", s);
2094
+ }
2095
+ function Ls(s) {
2096
+ this[y].emit("pong", s);
2097
+ }
2098
+ function ct(s) {
2099
+ s.resume();
2100
+ }
2101
+ function ut() {
2102
+ const s = this[y];
2103
+ this.removeListener("close", ut), this.removeListener("data", fe), this.removeListener("end", dt), s._readyState = m.CLOSING;
2104
+ let e;
2105
+ !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));
2106
+ }
2107
+ function fe(s) {
2108
+ this[y]._receiver.write(s) || this.pause();
2109
+ }
2110
+ function dt() {
2111
+ const s = this[y];
2112
+ s._readyState = m.CLOSING, s._receiver.end(), this.end();
2113
+ }
2114
+ function _t() {
2115
+ const s = this[y];
2116
+ this.removeListener("error", _t), this.on("error", at), s && (s._readyState = m.CLOSING, this.destroy());
2117
+ }
2118
+ const Xs = /* @__PURE__ */ z(ft), { tokenChars: Ns } = ae;
2119
+ function Ps(s) {
2120
+ const e = /* @__PURE__ */ new Set();
2121
+ let t = -1, r = -1, i = 0;
2122
+ for (i; i < s.length; i++) {
2123
+ const o = s.charCodeAt(i);
2124
+ if (r === -1 && Ns[o] === 1)
2125
+ t === -1 && (t = i);
2126
+ else if (i !== 0 && (o === 32 || o === 9))
2127
+ r === -1 && t !== -1 && (r = i);
2128
+ else if (o === 44) {
2129
+ if (t === -1)
2130
+ throw new SyntaxError(`Unexpected character at index ${i}`);
2131
+ r === -1 && (r = i);
2132
+ const l = s.slice(t, r);
2133
+ if (e.has(l))
2134
+ throw new SyntaxError(`The "${l}" subprotocol is duplicated`);
2135
+ e.add(l), t = r = -1;
2136
+ } else
2137
+ throw new SyntaxError(`Unexpected character at index ${i}`);
2138
+ }
2139
+ if (t === -1 || r !== -1)
2140
+ throw new SyntaxError("Unexpected end of input");
2141
+ const n = s.slice(t, i);
2142
+ if (e.has(n))
2143
+ throw new SyntaxError(`The "${n}" subprotocol is duplicated`);
2144
+ return e.add(n), e;
2145
+ }
2146
+ var Rs = { parse: Ps };
2147
+ 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;
2148
+ class As extends Us {
2149
+ /**
2150
+ * Create a `WebSocketServer` instance.
2151
+ *
2152
+ * @param {Object} options Configuration options
2153
+ * @param {Number} [options.backlog=511] The maximum length of the queue of
2154
+ * pending connections
2155
+ * @param {Boolean} [options.clientTracking=true] Specifies whether or not to
2156
+ * track clients
2157
+ * @param {Function} [options.handleProtocols] A hook to handle protocols
2158
+ * @param {String} [options.host] The hostname where to bind the server
2159
+ * @param {Number} [options.maxPayload=104857600] The maximum allowed message
2160
+ * size
2161
+ * @param {Boolean} [options.noServer=false] Enable no server mode
2162
+ * @param {String} [options.path] Accept only connections matching this path
2163
+ * @param {(Boolean|Object)} [options.perMessageDeflate=false] Enable/disable
2164
+ * permessage-deflate
2165
+ * @param {Number} [options.port] The port where to bind the server
2166
+ * @param {(http.Server|https.Server)} [options.server] A pre-created HTTP/S
2167
+ * server to use
2168
+ * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
2169
+ * not to skip UTF-8 validation for text and close messages
2170
+ * @param {Function} [options.verifyClient] A hook to reject connections
2171
+ * @param {Function} [options.WebSocket=WebSocket] Specifies the `WebSocket`
2172
+ * class to use. It must be the `WebSocket` class or class that extends it
2173
+ * @param {Function} [callback] A listener for the `listening` event
2174
+ */
2175
+ constructor(e, t) {
2176
+ if (super(), e = {
2177
+ maxPayload: 100 * 1024 * 1024,
2178
+ skipUTF8Validation: !1,
2179
+ perMessageDeflate: !1,
2180
+ handleProtocols: null,
2181
+ clientTracking: !0,
2182
+ verifyClient: null,
2183
+ noServer: !1,
2184
+ backlog: null,
2185
+ // use default (511 as implemented in net.js)
2186
+ server: null,
2187
+ host: null,
2188
+ path: null,
2189
+ port: null,
2190
+ WebSocket: Ms,
2191
+ ...e
2192
+ }, e.port == null && !e.server && !e.noServer || e.port != null && (e.server || e.noServer) || e.server && e.noServer)
2193
+ throw new TypeError(
2194
+ 'One and only one of the "port", "server", or "noServer" options must be specified'
2195
+ );
2196
+ if (e.port != null ? (this._server = ie.createServer((r, i) => {
2197
+ const n = ie.STATUS_CODES[426];
2198
+ i.writeHead(426, {
2199
+ "Content-Length": n.length,
2200
+ "Content-Type": "text/plain"
2201
+ }), i.end(n);
2202
+ }), this._server.listen(
2203
+ e.port,
2204
+ e.host,
2205
+ e.backlog,
2206
+ t
2207
+ )) : e.server && (this._server = e.server), this._server) {
2208
+ const r = this.emit.bind(this, "connection");
2209
+ this._removeListeners = js(this._server, {
2210
+ listening: this.emit.bind(this, "listening"),
2211
+ error: this.emit.bind(this, "error"),
2212
+ upgrade: (i, n, o) => {
2213
+ this.handleUpgrade(i, n, o, r);
2214
+ }
2215
+ });
2216
+ }
2217
+ e.perMessageDeflate === !0 && (e.perMessageDeflate = {}), e.clientTracking && (this.clients = /* @__PURE__ */ new Set(), this._shouldEmitClose = !1), this.options = e, this._state = Ke;
2218
+ }
2219
+ /**
2220
+ * Returns the bound address, the address family name, and port of the server
2221
+ * as reported by the operating system if listening on an IP socket.
2222
+ * If the server is listening on a pipe or UNIX domain socket, the name is
2223
+ * returned as a string.
2224
+ *
2225
+ * @return {(Object|String|null)} The address of the server
2226
+ * @public
2227
+ */
2228
+ address() {
2229
+ if (this.options.noServer)
2230
+ throw new Error('The server is operating in "noServer" mode');
2231
+ return this._server ? this._server.address() : null;
2232
+ }
2233
+ /**
2234
+ * Stop the server from accepting new connections and emit the `'close'` event
2235
+ * when all existing connections are closed.
2236
+ *
2237
+ * @param {Function} [cb] A one-time listener for the `'close'` event
2238
+ * @public
2239
+ */
2240
+ close(e) {
2241
+ if (this._state === pt) {
2242
+ e && this.once("close", () => {
2243
+ e(new Error("The server is not running"));
2244
+ }), process.nextTick(G, this);
2245
+ return;
2246
+ }
2247
+ if (e && this.once("close", e), this._state !== Xe)
2248
+ if (this._state = Xe, this.options.noServer || this.options.server)
2249
+ 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);
2250
+ else {
2251
+ const t = this._server;
2252
+ this._removeListeners(), this._removeListeners = this._server = null, t.close(() => {
2253
+ G(this);
2254
+ });
2255
+ }
2256
+ }
2257
+ /**
2258
+ * See if a given request should be handled by this server instance.
2259
+ *
2260
+ * @param {http.IncomingMessage} req Request object to inspect
2261
+ * @return {Boolean} `true` if the request is valid, else `false`
2262
+ * @public
2263
+ */
2264
+ shouldHandle(e) {
2265
+ if (this.options.path) {
2266
+ const t = e.url.indexOf("?");
2267
+ if ((t !== -1 ? e.url.slice(0, t) : e.url) !== this.options.path)
2268
+ return !1;
2269
+ }
2270
+ return !0;
2271
+ }
2272
+ /**
2273
+ * Handle a HTTP Upgrade request.
2274
+ *
2275
+ * @param {http.IncomingMessage} req The request object
2276
+ * @param {(net.Socket|tls.Socket)} socket The network socket between the
2277
+ * server and client
2278
+ * @param {Buffer} head The first packet of the upgraded stream
2279
+ * @param {Function} cb Callback
2280
+ * @public
2281
+ */
2282
+ handleUpgrade(e, t, r, i) {
2283
+ t.on("error", Ze);
2284
+ const n = e.headers["sec-websocket-key"], o = +e.headers["sec-websocket-version"];
2285
+ if (e.method !== "GET") {
2286
+ R(this, e, t, 405, "Invalid HTTP method");
2287
+ return;
2288
+ }
2289
+ if (e.headers.upgrade.toLowerCase() !== "websocket") {
2290
+ R(this, e, t, 400, "Invalid Upgrade header");
2291
+ return;
2292
+ }
2293
+ if (!n || !Ws.test(n)) {
2294
+ R(this, e, t, 400, "Missing or invalid Sec-WebSocket-Key header");
2295
+ return;
2296
+ }
2297
+ if (o !== 8 && o !== 13) {
2298
+ R(this, e, t, 400, "Missing or invalid Sec-WebSocket-Version header");
2299
+ return;
2300
+ }
2301
+ if (!this.shouldHandle(e)) {
2302
+ H(t, 400);
2303
+ return;
2304
+ }
2305
+ const l = e.headers["sec-websocket-protocol"];
2306
+ let f = /* @__PURE__ */ new Set();
2307
+ if (l !== void 0)
2308
+ try {
2309
+ f = $s.parse(l);
2310
+ } catch {
2311
+ R(this, e, t, 400, "Invalid Sec-WebSocket-Protocol header");
2312
+ return;
2313
+ }
2314
+ const a = e.headers["sec-websocket-extensions"], c = {};
2315
+ if (this.options.perMessageDeflate && a !== void 0) {
2316
+ const h = new N(
2317
+ this.options.perMessageDeflate,
2318
+ !0,
2319
+ this.options.maxPayload
2320
+ );
2321
+ try {
2322
+ const p = qe.parse(a);
2323
+ p[N.extensionName] && (h.accept(p[N.extensionName]), c[N.extensionName] = h);
2324
+ } catch {
2325
+ R(this, e, t, 400, "Invalid or unacceptable Sec-WebSocket-Extensions header");
2326
+ return;
2327
+ }
2328
+ }
2329
+ if (this.options.verifyClient) {
2330
+ const h = {
2331
+ origin: e.headers[`${o === 8 ? "sec-websocket-origin" : "origin"}`],
2332
+ secure: !!(e.socket.authorized || e.socket.encrypted),
2333
+ req: e
2334
+ };
2335
+ if (this.options.verifyClient.length === 2) {
2336
+ this.options.verifyClient(h, (p, v, _, u) => {
2337
+ if (!p)
2338
+ return H(t, v || 401, _, u);
2339
+ this.completeUpgrade(
2340
+ c,
2341
+ n,
2342
+ f,
2343
+ e,
2344
+ t,
2345
+ r,
2346
+ i
2347
+ );
2348
+ });
2349
+ return;
2350
+ }
2351
+ if (!this.options.verifyClient(h))
2352
+ return H(t, 401);
2353
+ }
2354
+ this.completeUpgrade(c, n, f, e, t, r, i);
2355
+ }
2356
+ /**
2357
+ * Upgrade the connection to WebSocket.
2358
+ *
2359
+ * @param {Object} extensions The accepted extensions
2360
+ * @param {String} key The value of the `Sec-WebSocket-Key` header
2361
+ * @param {Set} protocols The subprotocols
2362
+ * @param {http.IncomingMessage} req The request object
2363
+ * @param {(net.Socket|tls.Socket)} socket The network socket between the
2364
+ * server and client
2365
+ * @param {Buffer} head The first packet of the upgraded stream
2366
+ * @param {Function} cb Callback
2367
+ * @throws {Error} If called more than once with the same socket
2368
+ * @private
2369
+ */
2370
+ completeUpgrade(e, t, r, i, n, o, l) {
2371
+ if (!n.readable || !n.writable)
2372
+ return n.destroy();
2373
+ if (n[Ds])
2374
+ throw new Error(
2375
+ "server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration"
2376
+ );
2377
+ if (this._state > Ke)
2378
+ return H(n, 503);
2379
+ const a = [
2380
+ "HTTP/1.1 101 Switching Protocols",
2381
+ "Upgrade: websocket",
2382
+ "Connection: Upgrade",
2383
+ `Sec-WebSocket-Accept: ${Bs("sha1").update(t + Is).digest("base64")}`
2384
+ ], c = new this.options.WebSocket(null);
2385
+ if (r.size) {
2386
+ const h = this.options.handleProtocols ? this.options.handleProtocols(r, i) : r.values().next().value;
2387
+ h && (a.push(`Sec-WebSocket-Protocol: ${h}`), c._protocol = h);
2388
+ }
2389
+ if (e[N.extensionName]) {
2390
+ const h = e[N.extensionName].params, p = qe.format({
2391
+ [N.extensionName]: [h]
2392
+ });
2393
+ a.push(`Sec-WebSocket-Extensions: ${p}`), c._extensions = e;
2394
+ }
2395
+ this.emit("headers", a, i), n.write(a.concat(`\r
2396
+ `).join(`\r
2397
+ `)), n.removeListener("error", Ze), c.setSocket(n, o, {
2398
+ maxPayload: this.options.maxPayload,
2399
+ skipUTF8Validation: this.options.skipUTF8Validation
2400
+ }), this.clients && (this.clients.add(c), c.on("close", () => {
2401
+ this.clients.delete(c), this._shouldEmitClose && !this.clients.size && process.nextTick(G, this);
2402
+ })), l(c, i);
2403
+ }
2404
+ }
2405
+ var Fs = As;
2406
+ function js(s, e) {
2407
+ for (const t of Object.keys(e))
2408
+ s.on(t, e[t]);
2409
+ return function() {
2410
+ for (const r of Object.keys(e))
2411
+ s.removeListener(r, e[r]);
2412
+ };
2413
+ }
2414
+ function G(s) {
2415
+ s._state = pt, s.emit("close");
2416
+ }
2417
+ function Ze() {
2418
+ this.destroy();
2419
+ }
2420
+ function H(s, e, t, r) {
2421
+ t = t || ie.STATUS_CODES[e], r = {
2422
+ Connection: "close",
2423
+ "Content-Type": "text/html",
2424
+ "Content-Length": Buffer.byteLength(t),
2425
+ ...r
2426
+ }, s.once("finish", s.destroy), s.end(
2427
+ `HTTP/1.1 ${e} ${ie.STATUS_CODES[e]}\r
2428
+ ` + Object.keys(r).map((i) => `${i}: ${r[i]}`).join(`\r
2429
+ `) + `\r
2430
+ \r
2431
+ ` + t
2432
+ );
2433
+ }
2434
+ function R(s, e, t, r, i) {
2435
+ if (s.listenerCount("wsClientError")) {
2436
+ const n = new Error(i);
2437
+ Error.captureStackTrace(n, R), s.emit("wsClientError", n, t, e);
2438
+ } else
2439
+ H(t, r, i);
2440
+ }
2441
+ const Zs = /* @__PURE__ */ z(Fs);
2442
+ export {
2443
+ qs as Receiver,
2444
+ Ks as Sender,
2445
+ Xs as WebSocket,
2446
+ Zs as WebSocketServer,
2447
+ Vs as createWebSocketStream,
2448
+ Xs as default
2449
+ };
src/backend/gradio_shinymodel3d/templates/example/index.js ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const {
2
+ SvelteComponent: f,
3
+ append: u,
4
+ attr: d,
5
+ detach: g,
6
+ element: o,
7
+ init: v,
8
+ insert: r,
9
+ noop: c,
10
+ safe_not_equal: y,
11
+ set_data: m,
12
+ text: b,
13
+ toggle_class: i
14
+ } = window.__gradio__svelte__internal;
15
+ function w(a) {
16
+ let e, n;
17
+ return {
18
+ c() {
19
+ e = o("div"), n = b(
20
+ /*value*/
21
+ a[0]
22
+ ), d(e, "class", "svelte-1gecy8w"), i(
23
+ e,
24
+ "table",
25
+ /*type*/
26
+ a[1] === "table"
27
+ ), i(
28
+ e,
29
+ "gallery",
30
+ /*type*/
31
+ a[1] === "gallery"
32
+ ), i(
33
+ e,
34
+ "selected",
35
+ /*selected*/
36
+ a[2]
37
+ );
38
+ },
39
+ m(t, l) {
40
+ r(t, e, l), u(e, n);
41
+ },
42
+ p(t, [l]) {
43
+ l & /*value*/
44
+ 1 && m(
45
+ n,
46
+ /*value*/
47
+ t[0]
48
+ ), l & /*type*/
49
+ 2 && i(
50
+ e,
51
+ "table",
52
+ /*type*/
53
+ t[1] === "table"
54
+ ), l & /*type*/
55
+ 2 && i(
56
+ e,
57
+ "gallery",
58
+ /*type*/
59
+ t[1] === "gallery"
60
+ ), l & /*selected*/
61
+ 4 && i(
62
+ e,
63
+ "selected",
64
+ /*selected*/
65
+ t[2]
66
+ );
67
+ },
68
+ i: c,
69
+ o: c,
70
+ d(t) {
71
+ t && g(e);
72
+ }
73
+ };
74
+ }
75
+ function h(a, e, n) {
76
+ let { value: t } = e, { type: l } = e, { selected: _ = !1 } = e;
77
+ return a.$$set = (s) => {
78
+ "value" in s && n(0, t = s.value), "type" in s && n(1, l = s.type), "selected" in s && n(2, _ = s.selected);
79
+ }, [t, l, _];
80
+ }
81
+ class E extends f {
82
+ constructor(e) {
83
+ super(), v(this, e, h, w, y, { value: 0, type: 1, selected: 2 });
84
+ }
85
+ }
86
+ export {
87
+ E as default
88
+ };
src/backend/gradio_shinymodel3d/templates/example/style.css ADDED
@@ -0,0 +1 @@
 
 
1
+ .gallery.svelte-1gecy8w{padding:var(--size-1) var(--size-2)}
src/demo/Duck.glb ADDED
Binary file (120 kB). View file
 
src/demo/__init__.py ADDED
File without changes
src/demo/app.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ from gradio_shinymodel3d import ShinyModel3D
4
+ import os
5
+
6
+ model_file = os.path.join(os.path.dirname(__file__), "Duck.glb")
7
+
8
+ with gr.Blocks() as demo:
9
+ ShinyModel3D(model_file)
10
+
11
+
12
+ demo.launch()
src/frontend/Example.svelte ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ export let value: string;
3
+ export let type: "gallery" | "table";
4
+ export let selected = false;
5
+ </script>
6
+
7
+ <div
8
+ class:table={type === "table"}
9
+ class:gallery={type === "gallery"}
10
+ class:selected
11
+ >
12
+ {value}
13
+ </div>
14
+
15
+ <style>
16
+ .gallery {
17
+ padding: var(--size-1) var(--size-2);
18
+ }
19
+ </style>
src/frontend/Index.svelte ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script context="module" lang="ts">
2
+ export { default as BaseModel3D } from "./shared/Model3D.svelte";
3
+ export { default as BaseModel3DUpload } from "./shared/Model3DUpload.svelte";
4
+ export { default as BaseExample } from "./Example.svelte";
5
+ </script>
6
+
7
+ <script lang="ts">
8
+ import { normalise_file, type FileData } from "@gradio/client";
9
+ import Model3D from "./shared/Model3D.svelte";
10
+ import Model3DUpload from "./shared/Model3DUpload.svelte";
11
+ import { BlockLabel, Block, Empty, UploadText } from "@gradio/atoms";
12
+ import { File } from "@gradio/icons";
13
+
14
+ import { StatusTracker } from "@gradio/statustracker";
15
+ import type { LoadingStatus } from "@gradio/statustracker";
16
+ import type { Gradio } from "@gradio/utils";
17
+
18
+ export let elem_id = "";
19
+ export let elem_classes: string[] = [];
20
+ export let visible = true;
21
+ export let value: null | FileData = null;
22
+ export let root: string;
23
+ export let proxy_url: null | string;
24
+ export let clear_color: [number, number, number, number];
25
+ export let loading_status: LoadingStatus;
26
+ export let label: string;
27
+ export let show_label: boolean;
28
+ export let container = true;
29
+ export let scale: number | null = null;
30
+ export let min_width: number | undefined = undefined;
31
+ export let gradio: Gradio;
32
+ export let height: number | undefined = undefined;
33
+ export let zoom_speed = 1;
34
+
35
+ // alpha, beta, radius
36
+ export let camera_position: [number | null, number | null, number | null] = [
37
+ null,
38
+ null,
39
+ null,
40
+ ];
41
+ export let interactive: boolean;
42
+
43
+ let _value: null | FileData;
44
+ $: _value = normalise_file(value, root, proxy_url);
45
+
46
+ let dragging = false;
47
+ </script>
48
+
49
+ {#if !interactive}
50
+ <Block
51
+ {visible}
52
+ variant={value === null ? "dashed" : "solid"}
53
+ border_mode={dragging ? "focus" : "base"}
54
+ padding={false}
55
+ {elem_id}
56
+ {elem_classes}
57
+ {container}
58
+ {scale}
59
+ {min_width}
60
+ {height}
61
+ >
62
+ <StatusTracker
63
+ autoscroll={gradio.autoscroll}
64
+ i18n={gradio.i18n}
65
+ {...loading_status}
66
+ />
67
+
68
+ {#if value}
69
+ <Model3D
70
+ value={_value}
71
+ i18n={gradio.i18n}
72
+ {clear_color}
73
+ {label}
74
+ {show_label}
75
+ {camera_position}
76
+ {zoom_speed}
77
+ />
78
+ {:else}
79
+ <!-- Not ideal but some bugs to work out before we can
80
+ make this consistent with other components -->
81
+
82
+ <BlockLabel {show_label} Icon={File} label={label || "3D Model"} />
83
+
84
+ <Empty unpadded_box={true} size="large"><File /></Empty>
85
+ {/if}
86
+ </Block>
87
+ {:else}
88
+ <Block
89
+ {visible}
90
+ variant={value === null ? "dashed" : "solid"}
91
+ border_mode={dragging ? "focus" : "base"}
92
+ padding={false}
93
+ {elem_id}
94
+ {elem_classes}
95
+ {container}
96
+ {scale}
97
+ {min_width}
98
+ {height}
99
+ >
100
+ <StatusTracker
101
+ autoscroll={gradio.autoscroll}
102
+ i18n={gradio.i18n}
103
+ {...loading_status}
104
+ />
105
+
106
+ <Model3DUpload
107
+ {label}
108
+ {show_label}
109
+ {root}
110
+ {clear_color}
111
+ value={_value}
112
+ {camera_position}
113
+ {zoom_speed}
114
+ on:change={({ detail }) => (value = detail)}
115
+ on:drag={({ detail }) => (dragging = detail)}
116
+ on:change={({ detail }) => gradio.dispatch("change", detail)}
117
+ on:clear={() => gradio.dispatch("clear")}
118
+ i18n={gradio.i18n}
119
+ >
120
+ <UploadText i18n={gradio.i18n} type="file" />
121
+ </Model3DUpload>
122
+ </Block>
123
+ {/if}
src/frontend/icons/Minus.svelte ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <svg
2
+ width="10px"
3
+ height="10px"
4
+ version="1.1"
5
+ viewBox="0 0 32 32"
6
+ xmlns="http://www.w3.org/2000/svg"
7
+ >
8
+ <title>minus-circle</title>
9
+ <g fill="none" fill-rule="evenodd">
10
+ <g transform="translate(-516 -1087)" fill="var(--block-label-text-color)">
11
+ <path
12
+ d="m532 1117c-7.732 0-14-6.27-14-14s6.268-14 14-14 14 6.27 14 14-6.268 14-14 14zm0-30c-8.837 0-16 7.16-16 16s7.163 16 16 16 16-7.16 16-16-7.163-16-16-16zm6 15h-12c-0.553 0-1 0.45-1 1s0.447 1 1 1h12c0.553 0 1-0.45 1-1s-0.447-1-1-1z"
13
+ />
14
+ </g>
15
+ </g>
16
+ </svg>
src/frontend/icons/Plus.svelte ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <svg
2
+ width="10px"
3
+ height="10px"
4
+ fill="white"
5
+ version="1.1"
6
+ viewBox="0 0 32 32"
7
+ xmlns="http://www.w3.org/2000/svg"
8
+ >
9
+ <title>plus-circle</title>
10
+ <g fill="none" fill-rule="evenodd">
11
+ <g transform="translate(-464 -1087)" fill="var(--block-label-text-color)">
12
+ <path
13
+ d="m480 1117c-7.732 0-14-6.27-14-14s6.268-14 14-14 14 6.27 14 14-6.268 14-14 14zm0-30c-8.837 0-16 7.16-16 16s7.163 16 16 16 16-7.16 16-16-7.163-16-16-16zm6 15h-5v-5c0-0.55-0.447-1-1-1s-1 0.45-1 1v5h-5c-0.553 0-1 0.45-1 1s0.447 1 1 1h5v5c0 0.55 0.447 1 1 1s1-0.45 1-1v-5h5c0.553 0 1-0.45 1-1s-0.447-1-1-1z"
14
+ />
15
+ </g>
16
+ </g>
17
+ </svg>
src/frontend/package-lock.json ADDED
@@ -0,0 +1,1039 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gradio_shinymodel3d",
3
+ "version": "0.4.1",
4
+ "lockfileVersion": 3,
5
+ "requires": true,
6
+ "packages": {
7
+ "": {
8
+ "name": "gradio_shinymodel3d",
9
+ "version": "0.4.1",
10
+ "license": "ISC",
11
+ "dependencies": {
12
+ "@gradio/atoms": "0.2.1",
13
+ "@gradio/client": "0.7.2",
14
+ "@gradio/icons": "0.2.0",
15
+ "@gradio/statustracker": "0.3.1",
16
+ "@gradio/upload": "0.3.3",
17
+ "@gradio/utils": "0.2.0",
18
+ "@types/babylon": "^6.16.6",
19
+ "babylonjs": "^4.2.1",
20
+ "babylonjs-loaders": "^4.2.1"
21
+ }
22
+ },
23
+ "node_modules/@ampproject/remapping": {
24
+ "version": "2.2.1",
25
+ "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz",
26
+ "integrity": "sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==",
27
+ "peer": true,
28
+ "dependencies": {
29
+ "@jridgewell/gen-mapping": "^0.3.0",
30
+ "@jridgewell/trace-mapping": "^0.3.9"
31
+ },
32
+ "engines": {
33
+ "node": ">=6.0.0"
34
+ }
35
+ },
36
+ "node_modules/@esbuild/android-arm": {
37
+ "version": "0.19.5",
38
+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.5.tgz",
39
+ "integrity": "sha512-bhvbzWFF3CwMs5tbjf3ObfGqbl/17ict2/uwOSfr3wmxDE6VdS2GqY/FuzIPe0q0bdhj65zQsvqfArI9MY6+AA==",
40
+ "cpu": [
41
+ "arm"
42
+ ],
43
+ "optional": true,
44
+ "os": [
45
+ "android"
46
+ ],
47
+ "engines": {
48
+ "node": ">=12"
49
+ }
50
+ },
51
+ "node_modules/@esbuild/android-arm64": {
52
+ "version": "0.19.5",
53
+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.19.5.tgz",
54
+ "integrity": "sha512-5d1OkoJxnYQfmC+Zd8NBFjkhyCNYwM4n9ODrycTFY6Jk1IGiZ+tjVJDDSwDt77nK+tfpGP4T50iMtVi4dEGzhQ==",
55
+ "cpu": [
56
+ "arm64"
57
+ ],
58
+ "optional": true,
59
+ "os": [
60
+ "android"
61
+ ],
62
+ "engines": {
63
+ "node": ">=12"
64
+ }
65
+ },
66
+ "node_modules/@esbuild/android-x64": {
67
+ "version": "0.19.5",
68
+ "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.19.5.tgz",
69
+ "integrity": "sha512-9t+28jHGL7uBdkBjL90QFxe7DVA+KGqWlHCF8ChTKyaKO//VLuoBricQCgwhOjA1/qOczsw843Fy4cbs4H3DVA==",
70
+ "cpu": [
71
+ "x64"
72
+ ],
73
+ "optional": true,
74
+ "os": [
75
+ "android"
76
+ ],
77
+ "engines": {
78
+ "node": ">=12"
79
+ }
80
+ },
81
+ "node_modules/@esbuild/darwin-arm64": {
82
+ "version": "0.19.5",
83
+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.5.tgz",
84
+ "integrity": "sha512-mvXGcKqqIqyKoxq26qEDPHJuBYUA5KizJncKOAf9eJQez+L9O+KfvNFu6nl7SCZ/gFb2QPaRqqmG0doSWlgkqw==",
85
+ "cpu": [
86
+ "arm64"
87
+ ],
88
+ "optional": true,
89
+ "os": [
90
+ "darwin"
91
+ ],
92
+ "engines": {
93
+ "node": ">=12"
94
+ }
95
+ },
96
+ "node_modules/@esbuild/darwin-x64": {
97
+ "version": "0.19.5",
98
+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.19.5.tgz",
99
+ "integrity": "sha512-Ly8cn6fGLNet19s0X4unjcniX24I0RqjPv+kurpXabZYSXGM4Pwpmf85WHJN3lAgB8GSth7s5A0r856S+4DyiA==",
100
+ "cpu": [
101
+ "x64"
102
+ ],
103
+ "optional": true,
104
+ "os": [
105
+ "darwin"
106
+ ],
107
+ "engines": {
108
+ "node": ">=12"
109
+ }
110
+ },
111
+ "node_modules/@esbuild/freebsd-arm64": {
112
+ "version": "0.19.5",
113
+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.5.tgz",
114
+ "integrity": "sha512-GGDNnPWTmWE+DMchq1W8Sd0mUkL+APvJg3b11klSGUDvRXh70JqLAO56tubmq1s2cgpVCSKYywEiKBfju8JztQ==",
115
+ "cpu": [
116
+ "arm64"
117
+ ],
118
+ "optional": true,
119
+ "os": [
120
+ "freebsd"
121
+ ],
122
+ "engines": {
123
+ "node": ">=12"
124
+ }
125
+ },
126
+ "node_modules/@esbuild/freebsd-x64": {
127
+ "version": "0.19.5",
128
+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.19.5.tgz",
129
+ "integrity": "sha512-1CCwDHnSSoA0HNwdfoNY0jLfJpd7ygaLAp5EHFos3VWJCRX9DMwWODf96s9TSse39Br7oOTLryRVmBoFwXbuuQ==",
130
+ "cpu": [
131
+ "x64"
132
+ ],
133
+ "optional": true,
134
+ "os": [
135
+ "freebsd"
136
+ ],
137
+ "engines": {
138
+ "node": ">=12"
139
+ }
140
+ },
141
+ "node_modules/@esbuild/linux-arm": {
142
+ "version": "0.19.5",
143
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.19.5.tgz",
144
+ "integrity": "sha512-lrWXLY/vJBzCPC51QN0HM71uWgIEpGSjSZZADQhq7DKhPcI6NH1IdzjfHkDQws2oNpJKpR13kv7/pFHBbDQDwQ==",
145
+ "cpu": [
146
+ "arm"
147
+ ],
148
+ "optional": true,
149
+ "os": [
150
+ "linux"
151
+ ],
152
+ "engines": {
153
+ "node": ">=12"
154
+ }
155
+ },
156
+ "node_modules/@esbuild/linux-arm64": {
157
+ "version": "0.19.5",
158
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.19.5.tgz",
159
+ "integrity": "sha512-o3vYippBmSrjjQUCEEiTZ2l+4yC0pVJD/Dl57WfPwwlvFkrxoSO7rmBZFii6kQB3Wrn/6GwJUPLU5t52eq2meA==",
160
+ "cpu": [
161
+ "arm64"
162
+ ],
163
+ "optional": true,
164
+ "os": [
165
+ "linux"
166
+ ],
167
+ "engines": {
168
+ "node": ">=12"
169
+ }
170
+ },
171
+ "node_modules/@esbuild/linux-ia32": {
172
+ "version": "0.19.5",
173
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.19.5.tgz",
174
+ "integrity": "sha512-MkjHXS03AXAkNp1KKkhSKPOCYztRtK+KXDNkBa6P78F8Bw0ynknCSClO/ztGszILZtyO/lVKpa7MolbBZ6oJtQ==",
175
+ "cpu": [
176
+ "ia32"
177
+ ],
178
+ "optional": true,
179
+ "os": [
180
+ "linux"
181
+ ],
182
+ "engines": {
183
+ "node": ">=12"
184
+ }
185
+ },
186
+ "node_modules/@esbuild/linux-loong64": {
187
+ "version": "0.19.5",
188
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.19.5.tgz",
189
+ "integrity": "sha512-42GwZMm5oYOD/JHqHska3Jg0r+XFb/fdZRX+WjADm3nLWLcIsN27YKtqxzQmGNJgu0AyXg4HtcSK9HuOk3v1Dw==",
190
+ "cpu": [
191
+ "loong64"
192
+ ],
193
+ "optional": true,
194
+ "os": [
195
+ "linux"
196
+ ],
197
+ "engines": {
198
+ "node": ">=12"
199
+ }
200
+ },
201
+ "node_modules/@esbuild/linux-mips64el": {
202
+ "version": "0.19.5",
203
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.19.5.tgz",
204
+ "integrity": "sha512-kcjndCSMitUuPJobWCnwQ9lLjiLZUR3QLQmlgaBfMX23UEa7ZOrtufnRds+6WZtIS9HdTXqND4yH8NLoVVIkcg==",
205
+ "cpu": [
206
+ "mips64el"
207
+ ],
208
+ "optional": true,
209
+ "os": [
210
+ "linux"
211
+ ],
212
+ "engines": {
213
+ "node": ">=12"
214
+ }
215
+ },
216
+ "node_modules/@esbuild/linux-ppc64": {
217
+ "version": "0.19.5",
218
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.19.5.tgz",
219
+ "integrity": "sha512-yJAxJfHVm0ZbsiljbtFFP1BQKLc8kUF6+17tjQ78QjqjAQDnhULWiTA6u0FCDmYT1oOKS9PzZ2z0aBI+Mcyj7Q==",
220
+ "cpu": [
221
+ "ppc64"
222
+ ],
223
+ "optional": true,
224
+ "os": [
225
+ "linux"
226
+ ],
227
+ "engines": {
228
+ "node": ">=12"
229
+ }
230
+ },
231
+ "node_modules/@esbuild/linux-riscv64": {
232
+ "version": "0.19.5",
233
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.19.5.tgz",
234
+ "integrity": "sha512-5u8cIR/t3gaD6ad3wNt1MNRstAZO+aNyBxu2We8X31bA8XUNyamTVQwLDA1SLoPCUehNCymhBhK3Qim1433Zag==",
235
+ "cpu": [
236
+ "riscv64"
237
+ ],
238
+ "optional": true,
239
+ "os": [
240
+ "linux"
241
+ ],
242
+ "engines": {
243
+ "node": ">=12"
244
+ }
245
+ },
246
+ "node_modules/@esbuild/linux-s390x": {
247
+ "version": "0.19.5",
248
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.19.5.tgz",
249
+ "integrity": "sha512-Z6JrMyEw/EmZBD/OFEFpb+gao9xJ59ATsoTNlj39jVBbXqoZm4Xntu6wVmGPB/OATi1uk/DB+yeDPv2E8PqZGw==",
250
+ "cpu": [
251
+ "s390x"
252
+ ],
253
+ "optional": true,
254
+ "os": [
255
+ "linux"
256
+ ],
257
+ "engines": {
258
+ "node": ">=12"
259
+ }
260
+ },
261
+ "node_modules/@esbuild/linux-x64": {
262
+ "version": "0.19.5",
263
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.19.5.tgz",
264
+ "integrity": "sha512-psagl+2RlK1z8zWZOmVdImisMtrUxvwereIdyJTmtmHahJTKb64pAcqoPlx6CewPdvGvUKe2Jw+0Z/0qhSbG1A==",
265
+ "cpu": [
266
+ "x64"
267
+ ],
268
+ "optional": true,
269
+ "os": [
270
+ "linux"
271
+ ],
272
+ "engines": {
273
+ "node": ">=12"
274
+ }
275
+ },
276
+ "node_modules/@esbuild/netbsd-x64": {
277
+ "version": "0.19.5",
278
+ "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.19.5.tgz",
279
+ "integrity": "sha512-kL2l+xScnAy/E/3119OggX8SrWyBEcqAh8aOY1gr4gPvw76la2GlD4Ymf832UCVbmuWeTf2adkZDK+h0Z/fB4g==",
280
+ "cpu": [
281
+ "x64"
282
+ ],
283
+ "optional": true,
284
+ "os": [
285
+ "netbsd"
286
+ ],
287
+ "engines": {
288
+ "node": ">=12"
289
+ }
290
+ },
291
+ "node_modules/@esbuild/openbsd-x64": {
292
+ "version": "0.19.5",
293
+ "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.19.5.tgz",
294
+ "integrity": "sha512-sPOfhtzFufQfTBgRnE1DIJjzsXukKSvZxloZbkJDG383q0awVAq600pc1nfqBcl0ice/WN9p4qLc39WhBShRTA==",
295
+ "cpu": [
296
+ "x64"
297
+ ],
298
+ "optional": true,
299
+ "os": [
300
+ "openbsd"
301
+ ],
302
+ "engines": {
303
+ "node": ">=12"
304
+ }
305
+ },
306
+ "node_modules/@esbuild/sunos-x64": {
307
+ "version": "0.19.5",
308
+ "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.19.5.tgz",
309
+ "integrity": "sha512-dGZkBXaafuKLpDSjKcB0ax0FL36YXCvJNnztjKV+6CO82tTYVDSH2lifitJ29jxRMoUhgkg9a+VA/B03WK5lcg==",
310
+ "cpu": [
311
+ "x64"
312
+ ],
313
+ "optional": true,
314
+ "os": [
315
+ "sunos"
316
+ ],
317
+ "engines": {
318
+ "node": ">=12"
319
+ }
320
+ },
321
+ "node_modules/@esbuild/win32-arm64": {
322
+ "version": "0.19.5",
323
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.19.5.tgz",
324
+ "integrity": "sha512-dWVjD9y03ilhdRQ6Xig1NWNgfLtf2o/STKTS+eZuF90fI2BhbwD6WlaiCGKptlqXlURVB5AUOxUj09LuwKGDTg==",
325
+ "cpu": [
326
+ "arm64"
327
+ ],
328
+ "optional": true,
329
+ "os": [
330
+ "win32"
331
+ ],
332
+ "engines": {
333
+ "node": ">=12"
334
+ }
335
+ },
336
+ "node_modules/@esbuild/win32-ia32": {
337
+ "version": "0.19.5",
338
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.19.5.tgz",
339
+ "integrity": "sha512-4liggWIA4oDgUxqpZwrDhmEfAH4d0iljanDOK7AnVU89T6CzHon/ony8C5LeOdfgx60x5cnQJFZwEydVlYx4iw==",
340
+ "cpu": [
341
+ "ia32"
342
+ ],
343
+ "optional": true,
344
+ "os": [
345
+ "win32"
346
+ ],
347
+ "engines": {
348
+ "node": ">=12"
349
+ }
350
+ },
351
+ "node_modules/@esbuild/win32-x64": {
352
+ "version": "0.19.5",
353
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.19.5.tgz",
354
+ "integrity": "sha512-czTrygUsB/jlM8qEW5MD8bgYU2Xg14lo6kBDXW6HdxKjh8M5PzETGiSHaz9MtbXBYDloHNUAUW2tMiKW4KM9Mw==",
355
+ "cpu": [
356
+ "x64"
357
+ ],
358
+ "optional": true,
359
+ "os": [
360
+ "win32"
361
+ ],
362
+ "engines": {
363
+ "node": ">=12"
364
+ }
365
+ },
366
+ "node_modules/@formatjs/ecma402-abstract": {
367
+ "version": "1.11.4",
368
+ "resolved": "https://registry.npmjs.org/@formatjs/ecma402-abstract/-/ecma402-abstract-1.11.4.tgz",
369
+ "integrity": "sha512-EBikYFp2JCdIfGEb5G9dyCkTGDmC57KSHhRQOC3aYxoPWVZvfWCDjZwkGYHN7Lis/fmuWl906bnNTJifDQ3sXw==",
370
+ "dependencies": {
371
+ "@formatjs/intl-localematcher": "0.2.25",
372
+ "tslib": "^2.1.0"
373
+ }
374
+ },
375
+ "node_modules/@formatjs/fast-memoize": {
376
+ "version": "1.2.1",
377
+ "resolved": "https://registry.npmjs.org/@formatjs/fast-memoize/-/fast-memoize-1.2.1.tgz",
378
+ "integrity": "sha512-Rg0e76nomkz3vF9IPlKeV+Qynok0r7YZjL6syLz4/urSg0IbjPZCB/iYUMNsYA643gh4mgrX3T7KEIFIxJBQeg==",
379
+ "dependencies": {
380
+ "tslib": "^2.1.0"
381
+ }
382
+ },
383
+ "node_modules/@formatjs/icu-messageformat-parser": {
384
+ "version": "2.1.0",
385
+ "resolved": "https://registry.npmjs.org/@formatjs/icu-messageformat-parser/-/icu-messageformat-parser-2.1.0.tgz",
386
+ "integrity": "sha512-Qxv/lmCN6hKpBSss2uQ8IROVnta2r9jd3ymUEIjm2UyIkUCHVcbUVRGL/KS/wv7876edvsPe+hjHVJ4z8YuVaw==",
387
+ "dependencies": {
388
+ "@formatjs/ecma402-abstract": "1.11.4",
389
+ "@formatjs/icu-skeleton-parser": "1.3.6",
390
+ "tslib": "^2.1.0"
391
+ }
392
+ },
393
+ "node_modules/@formatjs/icu-skeleton-parser": {
394
+ "version": "1.3.6",
395
+ "resolved": "https://registry.npmjs.org/@formatjs/icu-skeleton-parser/-/icu-skeleton-parser-1.3.6.tgz",
396
+ "integrity": "sha512-I96mOxvml/YLrwU2Txnd4klA7V8fRhb6JG/4hm3VMNmeJo1F03IpV2L3wWt7EweqNLES59SZ4d6hVOPCSf80Bg==",
397
+ "dependencies": {
398
+ "@formatjs/ecma402-abstract": "1.11.4",
399
+ "tslib": "^2.1.0"
400
+ }
401
+ },
402
+ "node_modules/@formatjs/intl-localematcher": {
403
+ "version": "0.2.25",
404
+ "resolved": "https://registry.npmjs.org/@formatjs/intl-localematcher/-/intl-localematcher-0.2.25.tgz",
405
+ "integrity": "sha512-YmLcX70BxoSopLFdLr1Ds99NdlTI2oWoLbaUW2M406lxOIPzE1KQhRz2fPUkq34xVZQaihCoU29h0KK7An3bhA==",
406
+ "dependencies": {
407
+ "tslib": "^2.1.0"
408
+ }
409
+ },
410
+ "node_modules/@gradio/atoms": {
411
+ "version": "0.2.1",
412
+ "resolved": "https://registry.npmjs.org/@gradio/atoms/-/atoms-0.2.1.tgz",
413
+ "integrity": "sha512-di3kKSbjxKGngvTAaqUaA6whOVs5BFlQULlWDPq1m37VRgUD7Oq2MkIE+T+YiNAhByN93pqA0hGrWwAUUuxy5Q==",
414
+ "dependencies": {
415
+ "@gradio/icons": "^0.2.0",
416
+ "@gradio/utils": "^0.2.0"
417
+ }
418
+ },
419
+ "node_modules/@gradio/client": {
420
+ "version": "0.7.2",
421
+ "resolved": "https://registry.npmjs.org/@gradio/client/-/client-0.7.2.tgz",
422
+ "integrity": "sha512-YkT3c0u38ZYPKvOCmT0xLu3Gau4SwMe1Yo0PNvqTLwHfI4++dp5MJIWH97820MUqgQhYy6V3GmVAliHRmnfPbw==",
423
+ "dependencies": {
424
+ "bufferutil": "^4.0.7",
425
+ "semiver": "^1.1.0",
426
+ "ws": "^8.13.0"
427
+ },
428
+ "engines": {
429
+ "node": ">=18.0.0"
430
+ }
431
+ },
432
+ "node_modules/@gradio/column": {
433
+ "version": "0.1.0",
434
+ "resolved": "https://registry.npmjs.org/@gradio/column/-/column-0.1.0.tgz",
435
+ "integrity": "sha512-P24nqqVnMXBaDA1f/zSN5HZRho4PxP8Dq+7VltPHlmxIEiZYik2AJ4J0LeuIha34FDO0guu/16evdrpvGIUAfw=="
436
+ },
437
+ "node_modules/@gradio/icons": {
438
+ "version": "0.2.0",
439
+ "resolved": "https://registry.npmjs.org/@gradio/icons/-/icons-0.2.0.tgz",
440
+ "integrity": "sha512-rfCSmOF+ALqBOjTWL1ICasyA8JuO0MPwFrtlVMyAWp7R14AN8YChC/gbz5fZ0kNBiGGEYOOfqpKxyvC95jGGlg=="
441
+ },
442
+ "node_modules/@gradio/statustracker": {
443
+ "version": "0.3.1",
444
+ "resolved": "https://registry.npmjs.org/@gradio/statustracker/-/statustracker-0.3.1.tgz",
445
+ "integrity": "sha512-ZpmXZSnbgoFU2J54SrNntwfo2OEuEoRV310Q0zGVTH1VL7loziR7GuYhfIbgS8qFlrWM0MhMoLGDX+k7LAig5w==",
446
+ "dependencies": {
447
+ "@gradio/atoms": "^0.2.1",
448
+ "@gradio/column": "^0.1.0",
449
+ "@gradio/icons": "^0.2.0",
450
+ "@gradio/utils": "^0.2.0"
451
+ }
452
+ },
453
+ "node_modules/@gradio/theme": {
454
+ "version": "0.2.0",
455
+ "resolved": "https://registry.npmjs.org/@gradio/theme/-/theme-0.2.0.tgz",
456
+ "integrity": "sha512-33c68Nk7oRXLn08OxPfjcPm7S4tXGOUV1I1bVgzdM2YV5o1QBOS1GEnXPZPu/CEYPePLMB6bsDwffrLEyLGWVQ=="
457
+ },
458
+ "node_modules/@gradio/upload": {
459
+ "version": "0.3.3",
460
+ "resolved": "https://registry.npmjs.org/@gradio/upload/-/upload-0.3.3.tgz",
461
+ "integrity": "sha512-KWRtH9UTe20u1/14KezuZDEwecLZzjDHdSPDUCrk27SrE6ptV8/qLtefOkg9zE+W51iATxDtQAvi0afLQ8XGrw==",
462
+ "dependencies": {
463
+ "@gradio/atoms": "^0.2.1",
464
+ "@gradio/client": "^0.7.2",
465
+ "@gradio/icons": "^0.2.0",
466
+ "@gradio/upload": "^0.3.3",
467
+ "@gradio/utils": "^0.2.0"
468
+ }
469
+ },
470
+ "node_modules/@gradio/utils": {
471
+ "version": "0.2.0",
472
+ "resolved": "https://registry.npmjs.org/@gradio/utils/-/utils-0.2.0.tgz",
473
+ "integrity": "sha512-YkwzXufi6IxQrlMW+1sFo8Yn6F9NLL69ZoBsbo7QEhms0v5L7pmOTw+dfd7M3dwbRP2lgjrb52i1kAIN3n6aqQ==",
474
+ "dependencies": {
475
+ "@gradio/theme": "^0.2.0",
476
+ "svelte-i18n": "^3.6.0"
477
+ }
478
+ },
479
+ "node_modules/@jridgewell/gen-mapping": {
480
+ "version": "0.3.3",
481
+ "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz",
482
+ "integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==",
483
+ "peer": true,
484
+ "dependencies": {
485
+ "@jridgewell/set-array": "^1.0.1",
486
+ "@jridgewell/sourcemap-codec": "^1.4.10",
487
+ "@jridgewell/trace-mapping": "^0.3.9"
488
+ },
489
+ "engines": {
490
+ "node": ">=6.0.0"
491
+ }
492
+ },
493
+ "node_modules/@jridgewell/resolve-uri": {
494
+ "version": "3.1.1",
495
+ "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz",
496
+ "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==",
497
+ "peer": true,
498
+ "engines": {
499
+ "node": ">=6.0.0"
500
+ }
501
+ },
502
+ "node_modules/@jridgewell/set-array": {
503
+ "version": "1.1.2",
504
+ "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz",
505
+ "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==",
506
+ "peer": true,
507
+ "engines": {
508
+ "node": ">=6.0.0"
509
+ }
510
+ },
511
+ "node_modules/@jridgewell/sourcemap-codec": {
512
+ "version": "1.4.15",
513
+ "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz",
514
+ "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==",
515
+ "peer": true
516
+ },
517
+ "node_modules/@jridgewell/trace-mapping": {
518
+ "version": "0.3.20",
519
+ "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.20.tgz",
520
+ "integrity": "sha512-R8LcPeWZol2zR8mmH3JeKQ6QRCFb7XgUhV9ZlGhHLGyg4wpPiPZNQOOWhFZhxKw8u//yTbNGI42Bx/3paXEQ+Q==",
521
+ "peer": true,
522
+ "dependencies": {
523
+ "@jridgewell/resolve-uri": "^3.1.0",
524
+ "@jridgewell/sourcemap-codec": "^1.4.14"
525
+ }
526
+ },
527
+ "node_modules/@types/babel-types": {
528
+ "version": "7.0.14",
529
+ "resolved": "https://registry.npmjs.org/@types/babel-types/-/babel-types-7.0.14.tgz",
530
+ "integrity": "sha512-5BC5W3pCoX12SH8nC8ReAOiMBy/rd9xil3es3S6dh83Pl9i4J3ZujfWUu5mXnEwo/WLqcD5+uj9Yk115Dh0obw=="
531
+ },
532
+ "node_modules/@types/babylon": {
533
+ "version": "6.16.9",
534
+ "resolved": "https://registry.npmjs.org/@types/babylon/-/babylon-6.16.9.tgz",
535
+ "integrity": "sha512-sEKyxMVEowhcr8WLfN0jJYe4gS4Z9KC2DGz0vqfC7+MXFbmvOF7jSjALC77thvAO2TLgFUPa9vDeOak+AcUrZA==",
536
+ "dependencies": {
537
+ "@types/babel-types": "*"
538
+ }
539
+ },
540
+ "node_modules/@types/estree": {
541
+ "version": "1.0.5",
542
+ "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz",
543
+ "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==",
544
+ "peer": true
545
+ },
546
+ "node_modules/acorn": {
547
+ "version": "8.11.2",
548
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.2.tgz",
549
+ "integrity": "sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==",
550
+ "peer": true,
551
+ "bin": {
552
+ "acorn": "bin/acorn"
553
+ },
554
+ "engines": {
555
+ "node": ">=0.4.0"
556
+ }
557
+ },
558
+ "node_modules/aria-query": {
559
+ "version": "5.3.0",
560
+ "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz",
561
+ "integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==",
562
+ "peer": true,
563
+ "dependencies": {
564
+ "dequal": "^2.0.3"
565
+ }
566
+ },
567
+ "node_modules/axobject-query": {
568
+ "version": "3.2.1",
569
+ "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.2.1.tgz",
570
+ "integrity": "sha512-jsyHu61e6N4Vbz/v18DHwWYKK0bSWLqn47eeDSKPB7m8tqMHF9YJ+mhIk2lVteyZrY8tnSj/jHOv4YiTCuCJgg==",
571
+ "peer": true,
572
+ "dependencies": {
573
+ "dequal": "^2.0.3"
574
+ }
575
+ },
576
+ "node_modules/babylonjs": {
577
+ "version": "4.2.2",
578
+ "resolved": "https://registry.npmjs.org/babylonjs/-/babylonjs-4.2.2.tgz",
579
+ "integrity": "sha512-p7mTi6+nLuWJTLbwxEJxLOh/QMHMV2KA0bviEoQSK5VtsAq1F0JghoOZYRs4aEqAZF/deFPWvMQk1vbXJ+4eEA==",
580
+ "engines": {
581
+ "node": "*"
582
+ }
583
+ },
584
+ "node_modules/babylonjs-gltf2interface": {
585
+ "version": "4.2.2",
586
+ "resolved": "https://registry.npmjs.org/babylonjs-gltf2interface/-/babylonjs-gltf2interface-4.2.2.tgz",
587
+ "integrity": "sha512-LCQgW1lM+EpKK4yWMiPEgi6ONwJ7W4JrSu3t9JixNRgvnic72OnN2f0bt91rE30EJr1ZaokvkXD/aEiBp/Juyg==",
588
+ "engines": {
589
+ "node": "*"
590
+ }
591
+ },
592
+ "node_modules/babylonjs-loaders": {
593
+ "version": "4.2.2",
594
+ "resolved": "https://registry.npmjs.org/babylonjs-loaders/-/babylonjs-loaders-4.2.2.tgz",
595
+ "integrity": "sha512-IuShR5N4zkDMzKEGsCZ0uZDCn07BLLj8LlKwyiSwFR1V9KxAALkt2INTMCdXjuWELTcZEALZlyO85mKJ2pDPHw==",
596
+ "dependencies": {
597
+ "babylonjs": "4.2.2",
598
+ "babylonjs-gltf2interface": "4.2.2"
599
+ },
600
+ "engines": {
601
+ "node": "*"
602
+ }
603
+ },
604
+ "node_modules/bufferutil": {
605
+ "version": "4.0.8",
606
+ "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.8.tgz",
607
+ "integrity": "sha512-4T53u4PdgsXqKaIctwF8ifXlRTTmEPJ8iEPWFdGZvcf7sbwYo6FKFEX9eNNAnzFZ7EzJAQ3CJeOtCRA4rDp7Pw==",
608
+ "hasInstallScript": true,
609
+ "dependencies": {
610
+ "node-gyp-build": "^4.3.0"
611
+ },
612
+ "engines": {
613
+ "node": ">=6.14.2"
614
+ }
615
+ },
616
+ "node_modules/cli-color": {
617
+ "version": "2.0.3",
618
+ "resolved": "https://registry.npmjs.org/cli-color/-/cli-color-2.0.3.tgz",
619
+ "integrity": "sha512-OkoZnxyC4ERN3zLzZaY9Emb7f/MhBOIpePv0Ycok0fJYT+Ouo00UBEIwsVsr0yoow++n5YWlSUgST9GKhNHiRQ==",
620
+ "dependencies": {
621
+ "d": "^1.0.1",
622
+ "es5-ext": "^0.10.61",
623
+ "es6-iterator": "^2.0.3",
624
+ "memoizee": "^0.4.15",
625
+ "timers-ext": "^0.1.7"
626
+ },
627
+ "engines": {
628
+ "node": ">=0.10"
629
+ }
630
+ },
631
+ "node_modules/code-red": {
632
+ "version": "1.0.4",
633
+ "resolved": "https://registry.npmjs.org/code-red/-/code-red-1.0.4.tgz",
634
+ "integrity": "sha512-7qJWqItLA8/VPVlKJlFXU+NBlo/qyfs39aJcuMT/2ere32ZqvF5OSxgdM5xOfJJ7O429gg2HM47y8v9P+9wrNw==",
635
+ "peer": true,
636
+ "dependencies": {
637
+ "@jridgewell/sourcemap-codec": "^1.4.15",
638
+ "@types/estree": "^1.0.1",
639
+ "acorn": "^8.10.0",
640
+ "estree-walker": "^3.0.3",
641
+ "periscopic": "^3.1.0"
642
+ }
643
+ },
644
+ "node_modules/css-tree": {
645
+ "version": "2.3.1",
646
+ "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-2.3.1.tgz",
647
+ "integrity": "sha512-6Fv1DV/TYw//QF5IzQdqsNDjx/wc8TrMBZsqjL9eW01tWb7R7k/mq+/VXfJCl7SoD5emsJop9cOByJZfs8hYIw==",
648
+ "peer": true,
649
+ "dependencies": {
650
+ "mdn-data": "2.0.30",
651
+ "source-map-js": "^1.0.1"
652
+ },
653
+ "engines": {
654
+ "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0"
655
+ }
656
+ },
657
+ "node_modules/d": {
658
+ "version": "1.0.1",
659
+ "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz",
660
+ "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==",
661
+ "dependencies": {
662
+ "es5-ext": "^0.10.50",
663
+ "type": "^1.0.1"
664
+ }
665
+ },
666
+ "node_modules/deepmerge": {
667
+ "version": "4.3.1",
668
+ "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz",
669
+ "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==",
670
+ "engines": {
671
+ "node": ">=0.10.0"
672
+ }
673
+ },
674
+ "node_modules/dequal": {
675
+ "version": "2.0.3",
676
+ "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",
677
+ "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==",
678
+ "peer": true,
679
+ "engines": {
680
+ "node": ">=6"
681
+ }
682
+ },
683
+ "node_modules/es5-ext": {
684
+ "version": "0.10.62",
685
+ "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz",
686
+ "integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==",
687
+ "hasInstallScript": true,
688
+ "dependencies": {
689
+ "es6-iterator": "^2.0.3",
690
+ "es6-symbol": "^3.1.3",
691
+ "next-tick": "^1.1.0"
692
+ },
693
+ "engines": {
694
+ "node": ">=0.10"
695
+ }
696
+ },
697
+ "node_modules/es6-iterator": {
698
+ "version": "2.0.3",
699
+ "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz",
700
+ "integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==",
701
+ "dependencies": {
702
+ "d": "1",
703
+ "es5-ext": "^0.10.35",
704
+ "es6-symbol": "^3.1.1"
705
+ }
706
+ },
707
+ "node_modules/es6-symbol": {
708
+ "version": "3.1.3",
709
+ "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz",
710
+ "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==",
711
+ "dependencies": {
712
+ "d": "^1.0.1",
713
+ "ext": "^1.1.2"
714
+ }
715
+ },
716
+ "node_modules/es6-weak-map": {
717
+ "version": "2.0.3",
718
+ "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.3.tgz",
719
+ "integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==",
720
+ "dependencies": {
721
+ "d": "1",
722
+ "es5-ext": "^0.10.46",
723
+ "es6-iterator": "^2.0.3",
724
+ "es6-symbol": "^3.1.1"
725
+ }
726
+ },
727
+ "node_modules/esbuild": {
728
+ "version": "0.19.5",
729
+ "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.5.tgz",
730
+ "integrity": "sha512-bUxalY7b1g8vNhQKdB24QDmHeY4V4tw/s6Ak5z+jJX9laP5MoQseTOMemAr0gxssjNcH0MCViG8ONI2kksvfFQ==",
731
+ "hasInstallScript": true,
732
+ "bin": {
733
+ "esbuild": "bin/esbuild"
734
+ },
735
+ "engines": {
736
+ "node": ">=12"
737
+ },
738
+ "optionalDependencies": {
739
+ "@esbuild/android-arm": "0.19.5",
740
+ "@esbuild/android-arm64": "0.19.5",
741
+ "@esbuild/android-x64": "0.19.5",
742
+ "@esbuild/darwin-arm64": "0.19.5",
743
+ "@esbuild/darwin-x64": "0.19.5",
744
+ "@esbuild/freebsd-arm64": "0.19.5",
745
+ "@esbuild/freebsd-x64": "0.19.5",
746
+ "@esbuild/linux-arm": "0.19.5",
747
+ "@esbuild/linux-arm64": "0.19.5",
748
+ "@esbuild/linux-ia32": "0.19.5",
749
+ "@esbuild/linux-loong64": "0.19.5",
750
+ "@esbuild/linux-mips64el": "0.19.5",
751
+ "@esbuild/linux-ppc64": "0.19.5",
752
+ "@esbuild/linux-riscv64": "0.19.5",
753
+ "@esbuild/linux-s390x": "0.19.5",
754
+ "@esbuild/linux-x64": "0.19.5",
755
+ "@esbuild/netbsd-x64": "0.19.5",
756
+ "@esbuild/openbsd-x64": "0.19.5",
757
+ "@esbuild/sunos-x64": "0.19.5",
758
+ "@esbuild/win32-arm64": "0.19.5",
759
+ "@esbuild/win32-ia32": "0.19.5",
760
+ "@esbuild/win32-x64": "0.19.5"
761
+ }
762
+ },
763
+ "node_modules/estree-walker": {
764
+ "version": "3.0.3",
765
+ "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz",
766
+ "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==",
767
+ "peer": true,
768
+ "dependencies": {
769
+ "@types/estree": "^1.0.0"
770
+ }
771
+ },
772
+ "node_modules/event-emitter": {
773
+ "version": "0.3.5",
774
+ "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz",
775
+ "integrity": "sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==",
776
+ "dependencies": {
777
+ "d": "1",
778
+ "es5-ext": "~0.10.14"
779
+ }
780
+ },
781
+ "node_modules/ext": {
782
+ "version": "1.7.0",
783
+ "resolved": "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz",
784
+ "integrity": "sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==",
785
+ "dependencies": {
786
+ "type": "^2.7.2"
787
+ }
788
+ },
789
+ "node_modules/ext/node_modules/type": {
790
+ "version": "2.7.2",
791
+ "resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz",
792
+ "integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw=="
793
+ },
794
+ "node_modules/globalyzer": {
795
+ "version": "0.1.0",
796
+ "resolved": "https://registry.npmjs.org/globalyzer/-/globalyzer-0.1.0.tgz",
797
+ "integrity": "sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q=="
798
+ },
799
+ "node_modules/globrex": {
800
+ "version": "0.1.2",
801
+ "resolved": "https://registry.npmjs.org/globrex/-/globrex-0.1.2.tgz",
802
+ "integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg=="
803
+ },
804
+ "node_modules/intl-messageformat": {
805
+ "version": "9.13.0",
806
+ "resolved": "https://registry.npmjs.org/intl-messageformat/-/intl-messageformat-9.13.0.tgz",
807
+ "integrity": "sha512-7sGC7QnSQGa5LZP7bXLDhVDtQOeKGeBFGHF2Y8LVBwYZoQZCgWeKoPGTa5GMG8g/TzDgeXuYJQis7Ggiw2xTOw==",
808
+ "dependencies": {
809
+ "@formatjs/ecma402-abstract": "1.11.4",
810
+ "@formatjs/fast-memoize": "1.2.1",
811
+ "@formatjs/icu-messageformat-parser": "2.1.0",
812
+ "tslib": "^2.1.0"
813
+ }
814
+ },
815
+ "node_modules/is-promise": {
816
+ "version": "2.2.2",
817
+ "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz",
818
+ "integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ=="
819
+ },
820
+ "node_modules/is-reference": {
821
+ "version": "3.0.2",
822
+ "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.2.tgz",
823
+ "integrity": "sha512-v3rht/LgVcsdZa3O2Nqs+NMowLOxeOm7Ay9+/ARQ2F+qEoANRcqrjAZKGN0v8ymUetZGgkp26LTnGT7H0Qo9Pg==",
824
+ "peer": true,
825
+ "dependencies": {
826
+ "@types/estree": "*"
827
+ }
828
+ },
829
+ "node_modules/locate-character": {
830
+ "version": "3.0.0",
831
+ "resolved": "https://registry.npmjs.org/locate-character/-/locate-character-3.0.0.tgz",
832
+ "integrity": "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==",
833
+ "peer": true
834
+ },
835
+ "node_modules/lru-queue": {
836
+ "version": "0.1.0",
837
+ "resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz",
838
+ "integrity": "sha512-BpdYkt9EvGl8OfWHDQPISVpcl5xZthb+XPsbELj5AQXxIC8IriDZIQYjBJPEm5rS420sjZ0TLEzRcq5KdBhYrQ==",
839
+ "dependencies": {
840
+ "es5-ext": "~0.10.2"
841
+ }
842
+ },
843
+ "node_modules/magic-string": {
844
+ "version": "0.30.5",
845
+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.5.tgz",
846
+ "integrity": "sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==",
847
+ "peer": true,
848
+ "dependencies": {
849
+ "@jridgewell/sourcemap-codec": "^1.4.15"
850
+ },
851
+ "engines": {
852
+ "node": ">=12"
853
+ }
854
+ },
855
+ "node_modules/mdn-data": {
856
+ "version": "2.0.30",
857
+ "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.30.tgz",
858
+ "integrity": "sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==",
859
+ "peer": true
860
+ },
861
+ "node_modules/memoizee": {
862
+ "version": "0.4.15",
863
+ "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.15.tgz",
864
+ "integrity": "sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ==",
865
+ "dependencies": {
866
+ "d": "^1.0.1",
867
+ "es5-ext": "^0.10.53",
868
+ "es6-weak-map": "^2.0.3",
869
+ "event-emitter": "^0.3.5",
870
+ "is-promise": "^2.2.2",
871
+ "lru-queue": "^0.1.0",
872
+ "next-tick": "^1.1.0",
873
+ "timers-ext": "^0.1.7"
874
+ }
875
+ },
876
+ "node_modules/mri": {
877
+ "version": "1.2.0",
878
+ "resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",
879
+ "integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==",
880
+ "engines": {
881
+ "node": ">=4"
882
+ }
883
+ },
884
+ "node_modules/next-tick": {
885
+ "version": "1.1.0",
886
+ "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz",
887
+ "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ=="
888
+ },
889
+ "node_modules/node-gyp-build": {
890
+ "version": "4.6.1",
891
+ "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.6.1.tgz",
892
+ "integrity": "sha512-24vnklJmyRS8ViBNI8KbtK/r/DmXQMRiOMXTNz2nrTnAYUwjmEEbnnpB/+kt+yWRv73bPsSPRFddrcIbAxSiMQ==",
893
+ "bin": {
894
+ "node-gyp-build": "bin.js",
895
+ "node-gyp-build-optional": "optional.js",
896
+ "node-gyp-build-test": "build-test.js"
897
+ }
898
+ },
899
+ "node_modules/periscopic": {
900
+ "version": "3.1.0",
901
+ "resolved": "https://registry.npmjs.org/periscopic/-/periscopic-3.1.0.tgz",
902
+ "integrity": "sha512-vKiQ8RRtkl9P+r/+oefh25C3fhybptkHKCZSPlcXiJux2tJF55GnEj3BVn4A5gKfq9NWWXXrxkHBwVPUfH0opw==",
903
+ "peer": true,
904
+ "dependencies": {
905
+ "@types/estree": "^1.0.0",
906
+ "estree-walker": "^3.0.0",
907
+ "is-reference": "^3.0.0"
908
+ }
909
+ },
910
+ "node_modules/sade": {
911
+ "version": "1.8.1",
912
+ "resolved": "https://registry.npmjs.org/sade/-/sade-1.8.1.tgz",
913
+ "integrity": "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==",
914
+ "dependencies": {
915
+ "mri": "^1.1.0"
916
+ },
917
+ "engines": {
918
+ "node": ">=6"
919
+ }
920
+ },
921
+ "node_modules/semiver": {
922
+ "version": "1.1.0",
923
+ "resolved": "https://registry.npmjs.org/semiver/-/semiver-1.1.0.tgz",
924
+ "integrity": "sha512-QNI2ChmuioGC1/xjyYwyZYADILWyW6AmS1UH6gDj/SFUUUS4MBAWs/7mxnkRPc/F4iHezDP+O8t0dO8WHiEOdg==",
925
+ "engines": {
926
+ "node": ">=6"
927
+ }
928
+ },
929
+ "node_modules/source-map-js": {
930
+ "version": "1.0.2",
931
+ "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz",
932
+ "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==",
933
+ "peer": true,
934
+ "engines": {
935
+ "node": ">=0.10.0"
936
+ }
937
+ },
938
+ "node_modules/svelte": {
939
+ "version": "4.2.2",
940
+ "resolved": "https://registry.npmjs.org/svelte/-/svelte-4.2.2.tgz",
941
+ "integrity": "sha512-My2tytF2e2NnHSpn2M7/3VdXT4JdTglYVUuSuK/mXL2XtulPYbeBfl8Dm1QiaKRn0zoULRnL+EtfZHHP0k4H3A==",
942
+ "peer": true,
943
+ "dependencies": {
944
+ "@ampproject/remapping": "^2.2.1",
945
+ "@jridgewell/sourcemap-codec": "^1.4.15",
946
+ "@jridgewell/trace-mapping": "^0.3.18",
947
+ "acorn": "^8.9.0",
948
+ "aria-query": "^5.3.0",
949
+ "axobject-query": "^3.2.1",
950
+ "code-red": "^1.0.3",
951
+ "css-tree": "^2.3.1",
952
+ "estree-walker": "^3.0.3",
953
+ "is-reference": "^3.0.1",
954
+ "locate-character": "^3.0.0",
955
+ "magic-string": "^0.30.4",
956
+ "periscopic": "^3.1.0"
957
+ },
958
+ "engines": {
959
+ "node": ">=16"
960
+ }
961
+ },
962
+ "node_modules/svelte-i18n": {
963
+ "version": "3.7.4",
964
+ "resolved": "https://registry.npmjs.org/svelte-i18n/-/svelte-i18n-3.7.4.tgz",
965
+ "integrity": "sha512-yGRCNo+eBT4cPuU7IVsYTYjxB7I2V8qgUZPlHnNctJj5IgbJgV78flsRzpjZ/8iUYZrS49oCt7uxlU3AZv/N5Q==",
966
+ "dependencies": {
967
+ "cli-color": "^2.0.3",
968
+ "deepmerge": "^4.2.2",
969
+ "esbuild": "^0.19.2",
970
+ "estree-walker": "^2",
971
+ "intl-messageformat": "^9.13.0",
972
+ "sade": "^1.8.1",
973
+ "tiny-glob": "^0.2.9"
974
+ },
975
+ "bin": {
976
+ "svelte-i18n": "dist/cli.js"
977
+ },
978
+ "engines": {
979
+ "node": ">= 16"
980
+ },
981
+ "peerDependencies": {
982
+ "svelte": "^3 || ^4"
983
+ }
984
+ },
985
+ "node_modules/svelte-i18n/node_modules/estree-walker": {
986
+ "version": "2.0.2",
987
+ "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz",
988
+ "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w=="
989
+ },
990
+ "node_modules/timers-ext": {
991
+ "version": "0.1.7",
992
+ "resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz",
993
+ "integrity": "sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==",
994
+ "dependencies": {
995
+ "es5-ext": "~0.10.46",
996
+ "next-tick": "1"
997
+ }
998
+ },
999
+ "node_modules/tiny-glob": {
1000
+ "version": "0.2.9",
1001
+ "resolved": "https://registry.npmjs.org/tiny-glob/-/tiny-glob-0.2.9.tgz",
1002
+ "integrity": "sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg==",
1003
+ "dependencies": {
1004
+ "globalyzer": "0.1.0",
1005
+ "globrex": "^0.1.2"
1006
+ }
1007
+ },
1008
+ "node_modules/tslib": {
1009
+ "version": "2.6.2",
1010
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
1011
+ "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q=="
1012
+ },
1013
+ "node_modules/type": {
1014
+ "version": "1.2.0",
1015
+ "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz",
1016
+ "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg=="
1017
+ },
1018
+ "node_modules/ws": {
1019
+ "version": "8.14.2",
1020
+ "resolved": "https://registry.npmjs.org/ws/-/ws-8.14.2.tgz",
1021
+ "integrity": "sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g==",
1022
+ "engines": {
1023
+ "node": ">=10.0.0"
1024
+ },
1025
+ "peerDependencies": {
1026
+ "bufferutil": "^4.0.1",
1027
+ "utf-8-validate": ">=5.0.2"
1028
+ },
1029
+ "peerDependenciesMeta": {
1030
+ "bufferutil": {
1031
+ "optional": true
1032
+ },
1033
+ "utf-8-validate": {
1034
+ "optional": true
1035
+ }
1036
+ }
1037
+ }
1038
+ }
1039
+ }
src/frontend/package.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gradio_shinymodel3d",
3
+ "version": "0.4.1",
4
+ "description": "Gradio UI packages",
5
+ "type": "module",
6
+ "author": "",
7
+ "license": "ISC",
8
+ "private": false,
9
+ "dependencies": {
10
+ "@gradio/atoms": "0.2.1",
11
+ "@gradio/client": "0.7.2",
12
+ "@gradio/icons": "0.2.0",
13
+ "@gradio/statustracker": "0.3.1",
14
+ "@gradio/upload": "0.3.3",
15
+ "@gradio/utils": "0.2.0",
16
+ "@types/babylon": "^6.16.6",
17
+ "babylonjs": "^4.2.1",
18
+ "babylonjs-loaders": "^4.2.1"
19
+ },
20
+ "main_changeset": true,
21
+ "main": "./Index.svelte",
22
+ "exports": {
23
+ ".": "./Index.svelte",
24
+ "./example": "./Example.svelte",
25
+ "./package.json": "./package.json"
26
+ }
27
+ }
src/frontend/shared/Model3D.svelte ADDED
@@ -0,0 +1,415 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import type { FileData } from "@gradio/client";
3
+ import { BlockLabel, IconButton } from "@gradio/atoms";
4
+ import { File, Download, Undo } from "@gradio/icons";
5
+ import {
6
+ add_new_light,
7
+ add_new_model,
8
+ change_camera_position,
9
+ change_light,
10
+ change_show_axes,
11
+ reset_camera_position,
12
+ zoom,
13
+ } from "./utils";
14
+ import { onMount } from "svelte";
15
+ import BABYLON from "babylonjs";
16
+ import BABYLON_LOADERS from "babylonjs-loaders";
17
+ import type { I18nFormatter } from "@gradio/utils";
18
+ import Plus from "../icons/Plus.svelte";
19
+ import Minus from "../icons/Minus.svelte";
20
+
21
+ export let value: FileData | null;
22
+ export let clear_color: [number, number, number, number] = [0, 0, 0, 0];
23
+ export let label = "";
24
+ export let show_label: boolean;
25
+ export let i18n: I18nFormatter;
26
+ export let zoom_speed = 1;
27
+ export let pan_speed = 1;
28
+ export let show_axes = false;
29
+
30
+ const light_list = ["HemiLight", "pointLight", "DirectionLight"];
31
+
32
+ export let lights: { type: string; position: [number, number, number] }[] = [
33
+ {
34
+ type: "HemiLight",
35
+ position: [0, 1, 0],
36
+ },
37
+ ];
38
+
39
+ let visible_submenu: null | string = null;
40
+
41
+ const label_dict = {
42
+ 1: "X",
43
+ 2: "Y",
44
+ 3: "Z",
45
+ };
46
+
47
+ // alpha, beta, radius
48
+ export let camera_position: [number | null, number | null, number | null] = [
49
+ null,
50
+ null,
51
+ null,
52
+ ];
53
+
54
+ $: {
55
+ if (
56
+ BABYLON_LOADERS.OBJFileLoader != undefined &&
57
+ !BABYLON_LOADERS.OBJFileLoader.IMPORT_VERTEX_COLORS
58
+ ) {
59
+ BABYLON_LOADERS.OBJFileLoader.IMPORT_VERTEX_COLORS = true;
60
+ }
61
+ }
62
+
63
+ let canvas: HTMLCanvasElement;
64
+ let scene: BABYLON.Scene;
65
+ let engine: BABYLON.Engine | null;
66
+ let mounted = false;
67
+
68
+ onMount(() => {
69
+ engine = new BABYLON.Engine(canvas, true);
70
+ window.addEventListener("resize", () => {
71
+ engine?.resize();
72
+ });
73
+ mounted = true;
74
+ });
75
+
76
+ $: ({ path } = value || {
77
+ path: undefined,
78
+ });
79
+
80
+ $: canvas && mounted && path && dispose();
81
+
82
+ function dispose(): void {
83
+ if (scene && !scene.isDisposed) {
84
+ scene.dispose();
85
+ engine?.stopRenderLoop();
86
+ engine?.dispose();
87
+ engine = null;
88
+ engine = new BABYLON.Engine(canvas, true);
89
+ window.addEventListener("resize", () => {
90
+ engine?.resize();
91
+ });
92
+ }
93
+ if (engine !== null) {
94
+ scene = add_new_model(
95
+ canvas,
96
+ scene,
97
+ engine,
98
+ value,
99
+ clear_color,
100
+ camera_position,
101
+ zoom_speed,
102
+ pan_speed
103
+ );
104
+ }
105
+ }
106
+
107
+ function handle_undo(): void {
108
+ reset_camera_position(scene, camera_position, zoom_speed, pan_speed);
109
+ }
110
+
111
+ $: if (scene)
112
+ reset_camera_position(scene, camera_position, zoom_speed, pan_speed);
113
+ </script>
114
+
115
+ <BlockLabel
116
+ {show_label}
117
+ Icon={File}
118
+ label={label || i18n("3D_model.3d_model")}
119
+ />
120
+ {#if value}
121
+ <div class="model3D">
122
+ <div class="buttons">
123
+ <IconButton
124
+ Icon={Plus}
125
+ label={"Zoom In"}
126
+ on:click={() => zoom("in", scene, zoom_speed)}
127
+ />
128
+
129
+ <IconButton
130
+ Icon={Minus}
131
+ label={"Zoom Out"}
132
+ on:click={() => zoom("out", scene, zoom_speed)}
133
+ />
134
+
135
+ <IconButton Icon={Undo} label="Undo" on:click={() => handle_undo()} />
136
+ <a
137
+ href={value.path}
138
+ target={window.__is_colab__ ? "_blank" : null}
139
+ download={window.__is_colab__ ? null : value.orig_name || value.path}
140
+ >
141
+ <IconButton Icon={Download} label={i18n("common.download")} />
142
+ </a>
143
+ </div>
144
+
145
+ <canvas bind:this={canvas} />
146
+
147
+ <div class="light-menu">
148
+ <span class="input-container">
149
+ <div class="input-wrapper-axes">
150
+ <label for="axes">Show Axes</label>
151
+ <input
152
+ type="checkbox"
153
+ bind:checked={show_axes}
154
+ on:change={() => {
155
+ if (show_axes) {
156
+ change_show_axes(scene, show_axes);
157
+ } else {
158
+ dispose();
159
+ }
160
+ }}
161
+ />
162
+ </div>
163
+ </span>
164
+
165
+ <button
166
+ class="input-title"
167
+ aria-label="Toggle open camera submenu"
168
+ on:click={() => {
169
+ if (visible_submenu === "camera") {
170
+ visible_submenu = null;
171
+ } else {
172
+ visible_submenu = "camera";
173
+ }
174
+ }}
175
+ ><span
176
+ class="caret"
177
+ style:transform={visible_submenu === "camera"
178
+ ? "rotateZ(180deg)"
179
+ : "rotateZ(90deg)"}
180
+ /> Camera Position</button
181
+ >
182
+
183
+ {#if visible_submenu === "camera"}
184
+ <span class="input-wrapper">
185
+ {#each camera_position as camera_value, index}
186
+ <span class="input-container">
187
+ <label for="position">Axis {label_dict[index + 1]} </label>
188
+ <input
189
+ type="number"
190
+ class={`position-${index}`}
191
+ min="0"
192
+ max="999"
193
+ step="5"
194
+ placeholder="0"
195
+ bind:value={camera_value}
196
+ on:change={() =>
197
+ change_camera_position(scene, camera_position, zoom_speed)}
198
+ />
199
+ </span>
200
+ {/each}
201
+ </span>
202
+ {/if}
203
+
204
+ <button
205
+ aria-label="Toggle open light submenu"
206
+ class="input-title"
207
+ on:click={() => {
208
+ if (visible_submenu === "light") {
209
+ visible_submenu = null;
210
+ } else {
211
+ visible_submenu = "light";
212
+ }
213
+ }}
214
+ ><span
215
+ class="caret"
216
+ style:transform={visible_submenu === "light"
217
+ ? "rotateZ(180deg)"
218
+ : "rotateZ(90deg)"}
219
+ /> Light Position</button
220
+ >
221
+ {#if visible_submenu === "light"}
222
+ {#each lights as light, index}
223
+ <span>
224
+ <label for="light">Light Type</label>
225
+ <select
226
+ class="light-dropdown"
227
+ name="light"
228
+ bind:value={light.type}
229
+ on:change={(e) => {
230
+ change_light(
231
+ scene,
232
+ e.currentTarget.value,
233
+ light.position,
234
+ index
235
+ );
236
+ }}
237
+ >
238
+ {#each light_list as light_type}
239
+ <option value={light_type}>{light_type}</option>
240
+ {/each}
241
+ </select>
242
+ </span>
243
+ <span class="input-wrapper">
244
+ {#each light.position as light_value, index}
245
+ <span class="input-container">
246
+ <label for="light">Axis {label_dict[index + 1]} </label>
247
+ <input
248
+ type="number"
249
+ class={`light-${index}`}
250
+ min="0"
251
+ max="5"
252
+ step="0.1"
253
+ placeholder="0"
254
+ bind:value={light_value}
255
+ on:change={() =>
256
+ change_light(scene, light.type, light.position, index)}
257
+ />
258
+ </span>
259
+ {/each}
260
+ </span>
261
+ <div class="separator" />
262
+ {/each}
263
+
264
+ <button
265
+ class="add"
266
+ disabled={lights.length >= 5}
267
+ on:click={() => {
268
+ if (lights.length < 5) {
269
+ lights = [...lights, { type: "HemiLight", position: [0, 1, 0] }];
270
+ add_new_light(scene, [0, 1, 0]);
271
+ }
272
+ }}>Add Light</button
273
+ >
274
+ {/if}
275
+ </div>
276
+ </div>
277
+ {/if}
278
+
279
+ <style>
280
+ .separator {
281
+ border-bottom: 1px solid var(--border-color-primary);
282
+ margin: 10px 0;
283
+ width: 100%;
284
+ }
285
+ .add {
286
+ border: var(--button-border-width) solid
287
+ var(--button-secondary-border-color);
288
+ background: var(--button-secondary-background-fill);
289
+ color: var(--button-secondary-text-color);
290
+ margin: 5px 0;
291
+ }
292
+
293
+ .add:disabled {
294
+ background-color: var(--button-secondary-background-fill-disabled);
295
+ cursor: not-allowed;
296
+ opacity: 0.5;
297
+ filter: grayscale(30%);
298
+ }
299
+ .input-container {
300
+ display: flex;
301
+ flex-direction: column;
302
+ }
303
+
304
+ .light-dropdown {
305
+ all: unset;
306
+ border: var(--button-border-width) solid
307
+ var(--button-secondary-border-color);
308
+ background: var(--button-secondary-background-fill);
309
+ color: var(--button-secondary-text-color);
310
+ margin: 5px 0;
311
+ width: min-content;
312
+ height: min-content;
313
+ font-size: var(--text-md);
314
+ padding: 5px;
315
+ position: relative;
316
+ text-align: left;
317
+ }
318
+
319
+ .input-wrapper {
320
+ display: flex;
321
+ flex-direction: row;
322
+ }
323
+
324
+ .caret {
325
+ display: inline-flex;
326
+ border-left: solid 5px transparent;
327
+ border-right: solid 5px transparent;
328
+ border-bottom: solid 5px #fff;
329
+ transform: rotateZ(90deg);
330
+ top: -2px;
331
+ position: relative;
332
+ }
333
+
334
+ .input-wrapper input[type="number"] {
335
+ width: min-content;
336
+ height: min-content;
337
+ display: inline-block;
338
+ background: var(--input-background-fill);
339
+ border: 1px solid var(--input-border-color);
340
+ padding: 0 5px;
341
+ color: var(--body-text-color);
342
+ margin: 0 2px;
343
+ }
344
+
345
+ .input-title {
346
+ color: white;
347
+ margin: 5px 0;
348
+ text-align: right;
349
+ }
350
+
351
+ .input-wrapper-axes {
352
+ display: flex;
353
+ flex-direction: row;
354
+ align-items: center;
355
+ justify-content: space-between;
356
+ }
357
+
358
+ .input-wrapper-axes input[type="checkbox"] {
359
+ background-color: var(--checkbox-background-color);
360
+ }
361
+
362
+ input[type="checkbox"]:checked {
363
+ background-color: var(--checkbox-background-color);
364
+ border: 1px solid var(--checkbox-border-color-selected);
365
+ }
366
+
367
+ .light-menu {
368
+ display: flex;
369
+ flex-direction: column;
370
+ position: absolute;
371
+ text-align: right;
372
+ bottom: 0;
373
+ right: 0;
374
+ margin: 10px;
375
+ min-width: 200px;
376
+ color: black;
377
+ background-color: rgba(11, 15, 25, 0.6);
378
+ border: 1px solid var(--border-color-primary);
379
+ border-radius: var(--table-radius);
380
+ padding: 15px;
381
+ max-height: 90%;
382
+ overflow-y: scroll;
383
+ }
384
+
385
+ .light-menu label {
386
+ font-size: 12px;
387
+ margin-right: 5px;
388
+ color: white;
389
+ font: var(--font);
390
+ width: 100%;
391
+ padding: 5px;
392
+ }
393
+
394
+ .model3D {
395
+ display: flex;
396
+ position: relative;
397
+ width: var(--size-full);
398
+ height: var(--size-full);
399
+ }
400
+ canvas {
401
+ width: var(--size-full);
402
+ height: var(--size-full);
403
+ object-fit: contain;
404
+ overflow: hidden;
405
+ }
406
+ .buttons {
407
+ display: flex;
408
+ position: absolute;
409
+ top: var(--size-2);
410
+ right: var(--size-2);
411
+ justify-content: flex-end;
412
+ gap: var(--spacing-sm);
413
+ z-index: var(--layer-5);
414
+ }
415
+ </style>
src/frontend/shared/Model3DUpload.svelte ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { createEventDispatcher, tick, onMount } from "svelte";
3
+ import { Upload, ModifyUpload } from "@gradio/upload";
4
+ import type { FileData } from "@gradio/client";
5
+ import { BlockLabel } from "@gradio/atoms";
6
+ import { File } from "@gradio/icons";
7
+ import { add_new_model, reset_camera_position } from "./utils";
8
+
9
+ export let value: null | FileData;
10
+ export let clear_color: [number, number, number, number] = [0, 0, 0, 0];
11
+ export let label = "";
12
+ export let show_label: boolean;
13
+ export let root: string;
14
+ export let i18n: I18nFormatter;
15
+ export let zoom_speed = 1;
16
+ export let pan_speed = 1;
17
+
18
+ // alpha, beta, radius
19
+ export let camera_position: [number | null, number | null, number | null] = [
20
+ null,
21
+ null,
22
+ null,
23
+ ];
24
+
25
+ let mounted = false;
26
+ let canvas: HTMLCanvasElement;
27
+ let scene: BABYLON.Scene;
28
+ let engine: BABYLON.Engine;
29
+
30
+ function reset_scene(): void {
31
+ scene = add_new_model(
32
+ canvas,
33
+ scene,
34
+ engine,
35
+ value,
36
+ clear_color,
37
+ camera_position,
38
+ zoom_speed,
39
+ pan_speed
40
+ );
41
+ }
42
+
43
+ onMount(() => {
44
+ if (value != null) {
45
+ reset_scene();
46
+ }
47
+ mounted = true;
48
+ });
49
+
50
+ $: ({ path } = value || {
51
+ path: undefined,
52
+ });
53
+
54
+ $: canvas && mounted && path != null && reset_scene();
55
+
56
+ async function handle_upload({
57
+ detail,
58
+ }: CustomEvent<FileData>): Promise<void> {
59
+ value = detail;
60
+ await tick();
61
+ reset_scene();
62
+ dispatch("change", value);
63
+ }
64
+
65
+ async function handle_clear(): Promise<void> {
66
+ if (scene && engine) {
67
+ scene.dispose();
68
+ engine.dispose();
69
+ }
70
+ value = null;
71
+ await tick();
72
+ dispatch("clear");
73
+ }
74
+
75
+ async function handle_undo(): Promise<void> {
76
+ reset_camera_position(scene, camera_position, zoom_speed, pan_speed);
77
+ }
78
+
79
+ const dispatch = createEventDispatcher<{
80
+ change: FileData | null;
81
+ clear: undefined;
82
+ drag: boolean;
83
+ }>();
84
+
85
+ let dragging = false;
86
+
87
+ import BABYLON from "babylonjs";
88
+ import BABYLON_LOADERS from "babylonjs-loaders";
89
+ import type { I18nFormatter } from "@gradio/utils";
90
+
91
+ $: {
92
+ if (
93
+ BABYLON_LOADERS.OBJFileLoader != undefined &&
94
+ !BABYLON_LOADERS.OBJFileLoader.IMPORT_VERTEX_COLORS
95
+ ) {
96
+ BABYLON_LOADERS.OBJFileLoader.IMPORT_VERTEX_COLORS = true;
97
+ }
98
+ }
99
+
100
+ $: dispatch("drag", dragging);
101
+ </script>
102
+
103
+ <BlockLabel {show_label} Icon={File} label={label || "3D Model"} />
104
+
105
+ {#if value === null}
106
+ <Upload
107
+ on:load={handle_upload}
108
+ {root}
109
+ filetype=".obj, .gltf, .glb"
110
+ bind:dragging
111
+ >
112
+ <slot />
113
+ </Upload>
114
+ {:else}
115
+ <div class="input-model">
116
+ <ModifyUpload
117
+ undoable
118
+ on:clear={handle_clear}
119
+ {i18n}
120
+ on:undo={handle_undo}
121
+ absolute
122
+ />
123
+ <canvas bind:this={canvas} />
124
+ </div>
125
+ {/if}
126
+
127
+ <style>
128
+ .input-model {
129
+ display: flex;
130
+ position: relative;
131
+ justify-content: center;
132
+ align-items: center;
133
+ width: var(--size-full);
134
+ height: var(--size-full);
135
+ }
136
+
137
+ canvas {
138
+ width: var(--size-full);
139
+ height: var(--size-full);
140
+ object-fit: contain;
141
+ overflow: hidden;
142
+ }
143
+ </style>
src/frontend/shared/utils.ts ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { FileData } from "@gradio/client";
2
+ import BABYLON from "babylonjs";
3
+
4
+ const light_types = {
5
+ DirectionalLight: BABYLON.DirectionalLight,
6
+ PointLight: BABYLON.PointLight,
7
+ HemiLight: BABYLON.HemisphericLight,
8
+ };
9
+
10
+ const create_camera = (
11
+ scene: BABYLON.Scene,
12
+ camera_position: [number | null, number | null, number | null],
13
+ zoom_speed: number,
14
+ pan_speed: number
15
+ ): void => {
16
+ scene.createDefaultCamera(true, true, true);
17
+ var helperCamera = scene.activeCamera! as BABYLON.ArcRotateCamera;
18
+ if (camera_position[0] !== null) {
19
+ helperCamera.alpha = BABYLON.Tools.ToRadians(camera_position[0]);
20
+ }
21
+ if (camera_position[1] !== null) {
22
+ helperCamera.beta = BABYLON.Tools.ToRadians(camera_position[1]);
23
+ }
24
+ if (camera_position[2] !== null) {
25
+ helperCamera.radius = camera_position[2];
26
+ }
27
+ helperCamera.lowerRadiusLimit = 0.1;
28
+ const updateCameraSensibility = (): void => {
29
+ helperCamera.wheelPrecision = 250 / (helperCamera.radius * zoom_speed);
30
+ helperCamera.panningSensibility = (10000 * pan_speed) / helperCamera.radius;
31
+ };
32
+ updateCameraSensibility();
33
+ helperCamera.attachControl(true);
34
+ helperCamera.onAfterCheckInputsObservable.add(updateCameraSensibility);
35
+ };
36
+
37
+ export const add_new_model = (
38
+ canvas: HTMLCanvasElement,
39
+ scene: BABYLON.Scene,
40
+ engine: BABYLON.Engine,
41
+ value: FileData | null,
42
+ clear_color: [number, number, number, number],
43
+ camera_position: [number | null, number | null, number | null],
44
+ zoom_speed: number,
45
+ pan_speed: number
46
+ ): BABYLON.Scene => {
47
+ if (scene && !scene.isDisposed && engine) {
48
+ scene.dispose();
49
+ engine.dispose();
50
+ }
51
+
52
+ engine = new BABYLON.Engine(canvas, true);
53
+ scene = new BABYLON.Scene(engine);
54
+ scene.createDefaultCameraOrLight();
55
+ scene.clearColor = scene.clearColor = new BABYLON.Color4(...clear_color);
56
+
57
+ engine.runRenderLoop(() => {
58
+ scene.render();
59
+ });
60
+
61
+ window.addEventListener("resize", () => {
62
+ engine.resize();
63
+ });
64
+
65
+ if (!value) return scene;
66
+ let url: string;
67
+
68
+ url = value.url!;
69
+
70
+ BABYLON.SceneLoader.ShowLoadingScreen = false;
71
+ BABYLON.SceneLoader.Append(
72
+ url,
73
+ "",
74
+ scene,
75
+ () => create_camera(scene, camera_position, zoom_speed, pan_speed),
76
+ undefined,
77
+ undefined,
78
+ "." + value.path.split(".")[1]
79
+ );
80
+ return scene;
81
+ };
82
+
83
+ export const change_camera_position = (
84
+ scene: BABYLON.Scene,
85
+ camera_position: [number | null, number | null, number | null],
86
+ zoom_speed: number
87
+ ): void => {
88
+ var helperCamera = scene.activeCamera! as BABYLON.ArcRotateCamera;
89
+ if (camera_position[0] !== null) {
90
+ helperCamera.alpha = BABYLON.Tools.ToRadians(camera_position[0]);
91
+ }
92
+ if (camera_position[1] !== null) {
93
+ helperCamera.beta = BABYLON.Tools.ToRadians(camera_position[1]);
94
+ }
95
+ if (camera_position[2] !== null) {
96
+ helperCamera.radius = camera_position[2];
97
+ }
98
+ helperCamera.wheelPrecision = 2500 / zoom_speed;
99
+ };
100
+
101
+ export const change_light = (
102
+ scene: BABYLON.Scene,
103
+ light_type: string,
104
+ light_position: [number, number, number],
105
+ index: number
106
+ ): void => {
107
+ var light = scene.lights[index];
108
+ light.dispose();
109
+
110
+ switch (light_type) {
111
+ case "DirectionalLight":
112
+ light = new BABYLON.DirectionalLight(
113
+ light_type,
114
+ new BABYLON.Vector3(...light_position),
115
+ scene
116
+ );
117
+ break;
118
+ case "PointLight":
119
+ light = new BABYLON.PointLight(
120
+ light_type,
121
+ new BABYLON.Vector3(...light_position),
122
+ scene
123
+ );
124
+ break;
125
+ case "HemiLight":
126
+ light = new BABYLON.HemisphericLight(
127
+ light_type,
128
+ new BABYLON.Vector3(...light_position),
129
+ scene
130
+ );
131
+ break;
132
+ }
133
+
134
+ scene.addLight(light);
135
+ };
136
+
137
+ export const add_new_light = (
138
+ scene: BABYLON.Scene,
139
+ light_position: [number, number, number]
140
+ ): void => {
141
+ const newLight = new BABYLON.HemisphericLight(
142
+ "HemiLight",
143
+ new BABYLON.Vector3(...light_position),
144
+ scene
145
+ );
146
+ scene.addLight(newLight);
147
+ };
148
+
149
+ export const change_show_axes = (
150
+ scene: BABYLON.Scene,
151
+ show_axes: boolean
152
+ ): void => {
153
+ if (show_axes) {
154
+ const axes = new BABYLON.Debug.AxesViewer(scene, 5);
155
+ }
156
+ };
157
+
158
+ export const zoom = (
159
+ inOrOut: "in" | "out",
160
+ scene: BABYLON.Scene,
161
+ zoom_speed: number
162
+ ): void => {
163
+ var helperCamera = scene.activeCamera! as BABYLON.ArcRotateCamera;
164
+ helperCamera.wheelPrecision = 2500 / zoom_speed;
165
+
166
+ if (inOrOut === "in") {
167
+ helperCamera.radius = helperCamera.radius / 2;
168
+ } else {
169
+ helperCamera.radius = helperCamera.radius * 2;
170
+ }
171
+ };
172
+
173
+ export const reset_camera_position = (
174
+ scene: BABYLON.Scene,
175
+ camera_position: [number | null, number | null, number | null],
176
+ zoom_speed: number,
177
+ pan_speed: number
178
+ ): void => {
179
+ scene.removeCamera(scene.activeCamera!);
180
+ create_camera(scene, camera_position, zoom_speed, pan_speed);
181
+ };
src/pyproject.toml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_shinymodel3d"
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 = "[email protected]" }]
17
+ keywords = [
18
+ "machine learning",
19
+ "reproducibility",
20
+ "visualization",
21
+ "gradio",
22
+ "gradio custom component",
23
+ "gradio-template-Model3D"
24
+ ]
25
+ # Add dependencies here
26
+ dependencies = ["gradio>=4.0,<5.0"]
27
+ classifiers = [
28
+ 'Development Status :: 3 - Alpha',
29
+ 'License :: OSI Approved :: Apache Software License',
30
+ 'Operating System :: OS Independent',
31
+ 'Programming Language :: Python :: 3',
32
+ 'Programming Language :: Python :: 3 :: Only',
33
+ 'Programming Language :: Python :: 3.8',
34
+ 'Programming Language :: Python :: 3.9',
35
+ 'Programming Language :: Python :: 3.10',
36
+ 'Programming Language :: Python :: 3.11',
37
+ 'Topic :: Scientific/Engineering',
38
+ 'Topic :: Scientific/Engineering :: Artificial Intelligence',
39
+ 'Topic :: Scientific/Engineering :: Visualization',
40
+ ]
41
+
42
+ [project.optional-dependencies]
43
+ dev = ["build", "twine"]
44
+
45
+ [tool.hatch.build]
46
+ artifacts = ["/backend/gradio_shinymodel3d/templates", "*.pyi", "backend/gradio_shinymodel3d/templates"]
47
+
48
+ [tool.hatch.build.targets.wheel]
49
+ packages = ["/backend/gradio_shinymodel3d"]