Spaces:
Running
on
A10G
Running
on
A10G
GitLab CI
commited on
Commit
·
97e7d36
1
Parent(s):
bd78b84
Update game build from GitLab CI
Browse files- .gitattributes +2 -0
- Dockerfile +41 -0
- README.md +10 -8
- poetry.lock +268 -0
- pyproject.toml +17 -0
- server/__main__.py +111 -0
- server/static/index.apple-touch-icon.png +0 -0
- server/static/index.audio.worklet.js +213 -0
- server/static/index.html +248 -0
- server/static/index.icon.png +0 -0
- server/static/index.js +0 -0
- server/static/index.pck +3 -0
- server/static/index.png +0 -0
- server/static/index.wasm +3 -0
- server/static/index.worker.js +161 -0
.gitattributes
CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* 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
|
|
|
|
|
|
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
|
36 |
+
server/static/*.wasm filter=lfs diff=lfs merge=lfs -text
|
37 |
+
server/static/*.pck filter=lfs diff=lfs merge=lfs -text
|
Dockerfile
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Utiliser Python 3.9 comme base
|
2 |
+
FROM python:3.9-slim
|
3 |
+
|
4 |
+
# Installer poetry
|
5 |
+
RUN pip install poetry
|
6 |
+
|
7 |
+
# Create a non-root user
|
8 |
+
RUN useradd -m -u 1000 appuser
|
9 |
+
|
10 |
+
# Définir le répertoire de travail
|
11 |
+
WORKDIR /app
|
12 |
+
|
13 |
+
# Copier les fichiers de dépendances
|
14 |
+
COPY poetry.lock pyproject.toml ./
|
15 |
+
COPY . .
|
16 |
+
|
17 |
+
# Configurer poetry pour ne pas créer un environnement virtuel
|
18 |
+
RUN poetry config virtualenvs.create false
|
19 |
+
|
20 |
+
# Installer les dépendances sans installer le projet lui-même
|
21 |
+
RUN poetry install --only main --no-interaction --no-ansi --no-root
|
22 |
+
|
23 |
+
# Create static directory and set permissions
|
24 |
+
RUN mkdir -p /app/server/static && \
|
25 |
+
chown -R appuser:appuser /app && \
|
26 |
+
# Verify the static files are present
|
27 |
+
ls -la /app/server/static
|
28 |
+
|
29 |
+
# Switch to non-root user
|
30 |
+
USER appuser
|
31 |
+
|
32 |
+
# Verify permissions after user switch
|
33 |
+
RUN ls -la ~ && \
|
34 |
+
mkdir -p ~/static && \
|
35 |
+
ls -la ~/static
|
36 |
+
|
37 |
+
# Exposer le port utilisé par Flask
|
38 |
+
EXPOSE 7860
|
39 |
+
|
40 |
+
# Commande pour démarrer l'application
|
41 |
+
CMD ["python", "-m", "server"]
|
README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: docker
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
1 |
---
|
2 |
+
title: Test
|
3 |
+
emoji: 🐳
|
4 |
+
colorFrom: purple
|
5 |
+
colorTo: gray
|
6 |
sdk: docker
|
7 |
+
app_port: 7860
|
8 |
+
custom_headers:
|
9 |
+
cross-origin-embedder-policy: require-corp
|
10 |
+
cross-origin-opener-policy: same-origin
|
11 |
+
cross-origin-resource-policy: cross-origin
|
12 |
+
---
|
poetry.lock
ADDED
@@ -0,0 +1,268 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand.
|
2 |
+
|
3 |
+
[[package]]
|
4 |
+
name = "blinker"
|
5 |
+
version = "1.9.0"
|
6 |
+
description = "Fast, simple object-to-object and broadcast signaling"
|
7 |
+
optional = false
|
8 |
+
python-versions = ">=3.9"
|
9 |
+
files = [
|
10 |
+
{file = "blinker-1.9.0-py3-none-any.whl", hash = "sha256:ba0efaa9080b619ff2f3459d1d500c57bddea4a6b424b60a91141db6fd2f08bc"},
|
11 |
+
{file = "blinker-1.9.0.tar.gz", hash = "sha256:b4ce2265a7abece45e7cc896e98dbebe6cead56bcf805a3d23136d145f5445bf"},
|
12 |
+
]
|
13 |
+
|
14 |
+
[[package]]
|
15 |
+
name = "click"
|
16 |
+
version = "8.1.8"
|
17 |
+
description = "Composable command line interface toolkit"
|
18 |
+
optional = false
|
19 |
+
python-versions = ">=3.7"
|
20 |
+
files = [
|
21 |
+
{file = "click-8.1.8-py3-none-any.whl", hash = "sha256:63c132bbbed01578a06712a2d1f497bb62d9c1c0d329b7903a866228027263b2"},
|
22 |
+
{file = "click-8.1.8.tar.gz", hash = "sha256:ed53c9d8990d83c2a27deae68e4ee337473f6330c040a31d4225c9574d16096a"},
|
23 |
+
]
|
24 |
+
|
25 |
+
[package.dependencies]
|
26 |
+
colorama = {version = "*", markers = "platform_system == \"Windows\""}
|
27 |
+
|
28 |
+
[[package]]
|
29 |
+
name = "colorama"
|
30 |
+
version = "0.4.6"
|
31 |
+
description = "Cross-platform colored terminal text."
|
32 |
+
optional = false
|
33 |
+
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7"
|
34 |
+
files = [
|
35 |
+
{file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"},
|
36 |
+
{file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"},
|
37 |
+
]
|
38 |
+
|
39 |
+
[[package]]
|
40 |
+
name = "flask"
|
41 |
+
version = "3.1.0"
|
42 |
+
description = "A simple framework for building complex web applications."
|
43 |
+
optional = false
|
44 |
+
python-versions = ">=3.9"
|
45 |
+
files = [
|
46 |
+
{file = "flask-3.1.0-py3-none-any.whl", hash = "sha256:d667207822eb83f1c4b50949b1623c8fc8d51f2341d65f72e1a1815397551136"},
|
47 |
+
{file = "flask-3.1.0.tar.gz", hash = "sha256:5f873c5184c897c8d9d1b05df1e3d01b14910ce69607a117bd3277098a5836ac"},
|
48 |
+
]
|
49 |
+
|
50 |
+
[package.dependencies]
|
51 |
+
blinker = ">=1.9"
|
52 |
+
click = ">=8.1.3"
|
53 |
+
importlib-metadata = {version = ">=3.6", markers = "python_version < \"3.10\""}
|
54 |
+
itsdangerous = ">=2.2"
|
55 |
+
Jinja2 = ">=3.1.2"
|
56 |
+
Werkzeug = ">=3.1"
|
57 |
+
|
58 |
+
[package.extras]
|
59 |
+
async = ["asgiref (>=3.2)"]
|
60 |
+
dotenv = ["python-dotenv"]
|
61 |
+
|
62 |
+
[[package]]
|
63 |
+
name = "flask-cors"
|
64 |
+
version = "5.0.0"
|
65 |
+
description = "A Flask extension adding a decorator for CORS support"
|
66 |
+
optional = false
|
67 |
+
python-versions = "*"
|
68 |
+
files = [
|
69 |
+
{file = "Flask_Cors-5.0.0-py2.py3-none-any.whl", hash = "sha256:b9e307d082a9261c100d8fb0ba909eec6a228ed1b60a8315fd85f783d61910bc"},
|
70 |
+
{file = "flask_cors-5.0.0.tar.gz", hash = "sha256:5aadb4b950c4e93745034594d9f3ea6591f734bb3662e16e255ffbf5e89c88ef"},
|
71 |
+
]
|
72 |
+
|
73 |
+
[package.dependencies]
|
74 |
+
Flask = ">=0.9"
|
75 |
+
|
76 |
+
[[package]]
|
77 |
+
name = "gunicorn"
|
78 |
+
version = "23.0.0"
|
79 |
+
description = "WSGI HTTP Server for UNIX"
|
80 |
+
optional = false
|
81 |
+
python-versions = ">=3.7"
|
82 |
+
files = [
|
83 |
+
{file = "gunicorn-23.0.0-py3-none-any.whl", hash = "sha256:ec400d38950de4dfd418cff8328b2c8faed0edb0d517d3394e457c317908ca4d"},
|
84 |
+
{file = "gunicorn-23.0.0.tar.gz", hash = "sha256:f014447a0101dc57e294f6c18ca6b40227a4c90e9bdb586042628030cba004ec"},
|
85 |
+
]
|
86 |
+
|
87 |
+
[package.dependencies]
|
88 |
+
packaging = "*"
|
89 |
+
|
90 |
+
[package.extras]
|
91 |
+
eventlet = ["eventlet (>=0.24.1,!=0.36.0)"]
|
92 |
+
gevent = ["gevent (>=1.4.0)"]
|
93 |
+
setproctitle = ["setproctitle"]
|
94 |
+
testing = ["coverage", "eventlet", "gevent", "pytest", "pytest-cov"]
|
95 |
+
tornado = ["tornado (>=0.2)"]
|
96 |
+
|
97 |
+
[[package]]
|
98 |
+
name = "importlib-metadata"
|
99 |
+
version = "8.6.1"
|
100 |
+
description = "Read metadata from Python packages"
|
101 |
+
optional = false
|
102 |
+
python-versions = ">=3.9"
|
103 |
+
files = [
|
104 |
+
{file = "importlib_metadata-8.6.1-py3-none-any.whl", hash = "sha256:02a89390c1e15fdfdc0d7c6b25cb3e62650d0494005c97d6f148bf5b9787525e"},
|
105 |
+
{file = "importlib_metadata-8.6.1.tar.gz", hash = "sha256:310b41d755445d74569f993ccfc22838295d9fe005425094fad953d7f15c8580"},
|
106 |
+
]
|
107 |
+
|
108 |
+
[package.dependencies]
|
109 |
+
zipp = ">=3.20"
|
110 |
+
|
111 |
+
[package.extras]
|
112 |
+
check = ["pytest-checkdocs (>=2.4)", "pytest-ruff (>=0.2.1)"]
|
113 |
+
cover = ["pytest-cov"]
|
114 |
+
doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"]
|
115 |
+
enabler = ["pytest-enabler (>=2.2)"]
|
116 |
+
perf = ["ipython"]
|
117 |
+
test = ["flufl.flake8", "importlib_resources (>=1.3)", "jaraco.test (>=5.4)", "packaging", "pyfakefs", "pytest (>=6,!=8.1.*)", "pytest-perf (>=0.9.2)"]
|
118 |
+
type = ["pytest-mypy"]
|
119 |
+
|
120 |
+
[[package]]
|
121 |
+
name = "itsdangerous"
|
122 |
+
version = "2.2.0"
|
123 |
+
description = "Safely pass data to untrusted environments and back."
|
124 |
+
optional = false
|
125 |
+
python-versions = ">=3.8"
|
126 |
+
files = [
|
127 |
+
{file = "itsdangerous-2.2.0-py3-none-any.whl", hash = "sha256:c6242fc49e35958c8b15141343aa660db5fc54d4f13a1db01a3f5891b98700ef"},
|
128 |
+
{file = "itsdangerous-2.2.0.tar.gz", hash = "sha256:e0050c0b7da1eea53ffaf149c0cfbb5c6e2e2b69c4bef22c81fa6eb73e5f6173"},
|
129 |
+
]
|
130 |
+
|
131 |
+
[[package]]
|
132 |
+
name = "jinja2"
|
133 |
+
version = "3.1.5"
|
134 |
+
description = "A very fast and expressive template engine."
|
135 |
+
optional = false
|
136 |
+
python-versions = ">=3.7"
|
137 |
+
files = [
|
138 |
+
{file = "jinja2-3.1.5-py3-none-any.whl", hash = "sha256:aba0f4dc9ed8013c424088f68a5c226f7d6097ed89b246d7749c2ec4175c6adb"},
|
139 |
+
{file = "jinja2-3.1.5.tar.gz", hash = "sha256:8fefff8dc3034e27bb80d67c671eb8a9bc424c0ef4c0826edbff304cceff43bb"},
|
140 |
+
]
|
141 |
+
|
142 |
+
[package.dependencies]
|
143 |
+
MarkupSafe = ">=2.0"
|
144 |
+
|
145 |
+
[package.extras]
|
146 |
+
i18n = ["Babel (>=2.7)"]
|
147 |
+
|
148 |
+
[[package]]
|
149 |
+
name = "markupsafe"
|
150 |
+
version = "3.0.2"
|
151 |
+
description = "Safely add untrusted strings to HTML/XML markup."
|
152 |
+
optional = false
|
153 |
+
python-versions = ">=3.9"
|
154 |
+
files = [
|
155 |
+
{file = "MarkupSafe-3.0.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:7e94c425039cde14257288fd61dcfb01963e658efbc0ff54f5306b06054700f8"},
|
156 |
+
{file = "MarkupSafe-3.0.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9e2d922824181480953426608b81967de705c3cef4d1af983af849d7bd619158"},
|
157 |
+
{file = "MarkupSafe-3.0.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:38a9ef736c01fccdd6600705b09dc574584b89bea478200c5fbf112a6b0d5579"},
|
158 |
+
{file = "MarkupSafe-3.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bbcb445fa71794da8f178f0f6d66789a28d7319071af7a496d4d507ed566270d"},
|
159 |
+
{file = "MarkupSafe-3.0.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:57cb5a3cf367aeb1d316576250f65edec5bb3be939e9247ae594b4bcbc317dfb"},
|
160 |
+
{file = "MarkupSafe-3.0.2-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:3809ede931876f5b2ec92eef964286840ed3540dadf803dd570c3b7e13141a3b"},
|
161 |
+
{file = "MarkupSafe-3.0.2-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:e07c3764494e3776c602c1e78e298937c3315ccc9043ead7e685b7f2b8d47b3c"},
|
162 |
+
{file = "MarkupSafe-3.0.2-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:b424c77b206d63d500bcb69fa55ed8d0e6a3774056bdc4839fc9298a7edca171"},
|
163 |
+
{file = "MarkupSafe-3.0.2-cp310-cp310-win32.whl", hash = "sha256:fcabf5ff6eea076f859677f5f0b6b5c1a51e70a376b0579e0eadef8db48c6b50"},
|
164 |
+
{file = "MarkupSafe-3.0.2-cp310-cp310-win_amd64.whl", hash = "sha256:6af100e168aa82a50e186c82875a5893c5597a0c1ccdb0d8b40240b1f28b969a"},
|
165 |
+
{file = "MarkupSafe-3.0.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:9025b4018f3a1314059769c7bf15441064b2207cb3f065e6ea1e7359cb46db9d"},
|
166 |
+
{file = "MarkupSafe-3.0.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:93335ca3812df2f366e80509ae119189886b0f3c2b81325d39efdb84a1e2ae93"},
|
167 |
+
{file = "MarkupSafe-3.0.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2cb8438c3cbb25e220c2ab33bb226559e7afb3baec11c4f218ffa7308603c832"},
|
168 |
+
{file = "MarkupSafe-3.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a123e330ef0853c6e822384873bef7507557d8e4a082961e1defa947aa59ba84"},
|
169 |
+
{file = "MarkupSafe-3.0.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1e084f686b92e5b83186b07e8a17fc09e38fff551f3602b249881fec658d3eca"},
|
170 |
+
{file = "MarkupSafe-3.0.2-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:d8213e09c917a951de9d09ecee036d5c7d36cb6cb7dbaece4c71a60d79fb9798"},
|
171 |
+
{file = "MarkupSafe-3.0.2-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:5b02fb34468b6aaa40dfc198d813a641e3a63b98c2b05a16b9f80b7ec314185e"},
|
172 |
+
{file = "MarkupSafe-3.0.2-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:0bff5e0ae4ef2e1ae4fdf2dfd5b76c75e5c2fa4132d05fc1b0dabcd20c7e28c4"},
|
173 |
+
{file = "MarkupSafe-3.0.2-cp311-cp311-win32.whl", hash = "sha256:6c89876f41da747c8d3677a2b540fb32ef5715f97b66eeb0c6b66f5e3ef6f59d"},
|
174 |
+
{file = "MarkupSafe-3.0.2-cp311-cp311-win_amd64.whl", hash = "sha256:70a87b411535ccad5ef2f1df5136506a10775d267e197e4cf531ced10537bd6b"},
|
175 |
+
{file = "MarkupSafe-3.0.2-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:9778bd8ab0a994ebf6f84c2b949e65736d5575320a17ae8984a77fab08db94cf"},
|
176 |
+
{file = "MarkupSafe-3.0.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:846ade7b71e3536c4e56b386c2a47adf5741d2d8b94ec9dc3e92e5e1ee1e2225"},
|
177 |
+
{file = "MarkupSafe-3.0.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1c99d261bd2d5f6b59325c92c73df481e05e57f19837bdca8413b9eac4bd8028"},
|
178 |
+
{file = "MarkupSafe-3.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e17c96c14e19278594aa4841ec148115f9c7615a47382ecb6b82bd8fea3ab0c8"},
|
179 |
+
{file = "MarkupSafe-3.0.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:88416bd1e65dcea10bc7569faacb2c20ce071dd1f87539ca2ab364bf6231393c"},
|
180 |
+
{file = "MarkupSafe-3.0.2-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:2181e67807fc2fa785d0592dc2d6206c019b9502410671cc905d132a92866557"},
|
181 |
+
{file = "MarkupSafe-3.0.2-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:52305740fe773d09cffb16f8ed0427942901f00adedac82ec8b67752f58a1b22"},
|
182 |
+
{file = "MarkupSafe-3.0.2-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:ad10d3ded218f1039f11a75f8091880239651b52e9bb592ca27de44eed242a48"},
|
183 |
+
{file = "MarkupSafe-3.0.2-cp312-cp312-win32.whl", hash = "sha256:0f4ca02bea9a23221c0182836703cbf8930c5e9454bacce27e767509fa286a30"},
|
184 |
+
{file = "MarkupSafe-3.0.2-cp312-cp312-win_amd64.whl", hash = "sha256:8e06879fc22a25ca47312fbe7c8264eb0b662f6db27cb2d3bbbc74b1df4b9b87"},
|
185 |
+
{file = "MarkupSafe-3.0.2-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:ba9527cdd4c926ed0760bc301f6728ef34d841f405abf9d4f959c478421e4efd"},
|
186 |
+
{file = "MarkupSafe-3.0.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:f8b3d067f2e40fe93e1ccdd6b2e1d16c43140e76f02fb1319a05cf2b79d99430"},
|
187 |
+
{file = "MarkupSafe-3.0.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:569511d3b58c8791ab4c2e1285575265991e6d8f8700c7be0e88f86cb0672094"},
|
188 |
+
{file = "MarkupSafe-3.0.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:15ab75ef81add55874e7ab7055e9c397312385bd9ced94920f2802310c930396"},
|
189 |
+
{file = "MarkupSafe-3.0.2-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f3818cb119498c0678015754eba762e0d61e5b52d34c8b13d770f0719f7b1d79"},
|
190 |
+
{file = "MarkupSafe-3.0.2-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:cdb82a876c47801bb54a690c5ae105a46b392ac6099881cdfb9f6e95e4014c6a"},
|
191 |
+
{file = "MarkupSafe-3.0.2-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:cabc348d87e913db6ab4aa100f01b08f481097838bdddf7c7a84b7575b7309ca"},
|
192 |
+
{file = "MarkupSafe-3.0.2-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:444dcda765c8a838eaae23112db52f1efaf750daddb2d9ca300bcae1039adc5c"},
|
193 |
+
{file = "MarkupSafe-3.0.2-cp313-cp313-win32.whl", hash = "sha256:bcf3e58998965654fdaff38e58584d8937aa3096ab5354d493c77d1fdd66d7a1"},
|
194 |
+
{file = "MarkupSafe-3.0.2-cp313-cp313-win_amd64.whl", hash = "sha256:e6a2a455bd412959b57a172ce6328d2dd1f01cb2135efda2e4576e8a23fa3b0f"},
|
195 |
+
{file = "MarkupSafe-3.0.2-cp313-cp313t-macosx_10_13_universal2.whl", hash = "sha256:b5a6b3ada725cea8a5e634536b1b01c30bcdcd7f9c6fff4151548d5bf6b3a36c"},
|
196 |
+
{file = "MarkupSafe-3.0.2-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:a904af0a6162c73e3edcb969eeeb53a63ceeb5d8cf642fade7d39e7963a22ddb"},
|
197 |
+
{file = "MarkupSafe-3.0.2-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4aa4e5faecf353ed117801a068ebab7b7e09ffb6e1d5e412dc852e0da018126c"},
|
198 |
+
{file = "MarkupSafe-3.0.2-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c0ef13eaeee5b615fb07c9a7dadb38eac06a0608b41570d8ade51c56539e509d"},
|
199 |
+
{file = "MarkupSafe-3.0.2-cp313-cp313t-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d16a81a06776313e817c951135cf7340a3e91e8c1ff2fac444cfd75fffa04afe"},
|
200 |
+
{file = "MarkupSafe-3.0.2-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:6381026f158fdb7c72a168278597a5e3a5222e83ea18f543112b2662a9b699c5"},
|
201 |
+
{file = "MarkupSafe-3.0.2-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:3d79d162e7be8f996986c064d1c7c817f6df3a77fe3d6859f6f9e7be4b8c213a"},
|
202 |
+
{file = "MarkupSafe-3.0.2-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:131a3c7689c85f5ad20f9f6fb1b866f402c445b220c19fe4308c0b147ccd2ad9"},
|
203 |
+
{file = "MarkupSafe-3.0.2-cp313-cp313t-win32.whl", hash = "sha256:ba8062ed2cf21c07a9e295d5b8a2a5ce678b913b45fdf68c32d95d6c1291e0b6"},
|
204 |
+
{file = "MarkupSafe-3.0.2-cp313-cp313t-win_amd64.whl", hash = "sha256:e444a31f8db13eb18ada366ab3cf45fd4b31e4db1236a4448f68778c1d1a5a2f"},
|
205 |
+
{file = "MarkupSafe-3.0.2-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:eaa0a10b7f72326f1372a713e73c3f739b524b3af41feb43e4921cb529f5929a"},
|
206 |
+
{file = "MarkupSafe-3.0.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:48032821bbdf20f5799ff537c7ac3d1fba0ba032cfc06194faffa8cda8b560ff"},
|
207 |
+
{file = "MarkupSafe-3.0.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1a9d3f5f0901fdec14d8d2f66ef7d035f2157240a433441719ac9a3fba440b13"},
|
208 |
+
{file = "MarkupSafe-3.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:88b49a3b9ff31e19998750c38e030fc7bb937398b1f78cfa599aaef92d693144"},
|
209 |
+
{file = "MarkupSafe-3.0.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:cfad01eed2c2e0c01fd0ecd2ef42c492f7f93902e39a42fc9ee1692961443a29"},
|
210 |
+
{file = "MarkupSafe-3.0.2-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:1225beacc926f536dc82e45f8a4d68502949dc67eea90eab715dea3a21c1b5f0"},
|
211 |
+
{file = "MarkupSafe-3.0.2-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:3169b1eefae027567d1ce6ee7cae382c57fe26e82775f460f0b2778beaad66c0"},
|
212 |
+
{file = "MarkupSafe-3.0.2-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:eb7972a85c54febfb25b5c4b4f3af4dcc731994c7da0d8a0b4a6eb0640e1d178"},
|
213 |
+
{file = "MarkupSafe-3.0.2-cp39-cp39-win32.whl", hash = "sha256:8c4e8c3ce11e1f92f6536ff07154f9d49677ebaaafc32db9db4620bc11ed480f"},
|
214 |
+
{file = "MarkupSafe-3.0.2-cp39-cp39-win_amd64.whl", hash = "sha256:6e296a513ca3d94054c2c881cc913116e90fd030ad1c656b3869762b754f5f8a"},
|
215 |
+
{file = "markupsafe-3.0.2.tar.gz", hash = "sha256:ee55d3edf80167e48ea11a923c7386f4669df67d7994554387f84e7d8b0a2bf0"},
|
216 |
+
]
|
217 |
+
|
218 |
+
[[package]]
|
219 |
+
name = "packaging"
|
220 |
+
version = "24.2"
|
221 |
+
description = "Core utilities for Python packages"
|
222 |
+
optional = false
|
223 |
+
python-versions = ">=3.8"
|
224 |
+
files = [
|
225 |
+
{file = "packaging-24.2-py3-none-any.whl", hash = "sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759"},
|
226 |
+
{file = "packaging-24.2.tar.gz", hash = "sha256:c228a6dc5e932d346bc5739379109d49e8853dd8223571c7c5b55260edc0b97f"},
|
227 |
+
]
|
228 |
+
|
229 |
+
[[package]]
|
230 |
+
name = "werkzeug"
|
231 |
+
version = "3.1.3"
|
232 |
+
description = "The comprehensive WSGI web application library."
|
233 |
+
optional = false
|
234 |
+
python-versions = ">=3.9"
|
235 |
+
files = [
|
236 |
+
{file = "werkzeug-3.1.3-py3-none-any.whl", hash = "sha256:54b78bf3716d19a65be4fceccc0d1d7b89e608834989dfae50ea87564639213e"},
|
237 |
+
{file = "werkzeug-3.1.3.tar.gz", hash = "sha256:60723ce945c19328679790e3282cc758aa4a6040e4bb330f53d30fa546d44746"},
|
238 |
+
]
|
239 |
+
|
240 |
+
[package.dependencies]
|
241 |
+
MarkupSafe = ">=2.1.1"
|
242 |
+
|
243 |
+
[package.extras]
|
244 |
+
watchdog = ["watchdog (>=2.3)"]
|
245 |
+
|
246 |
+
[[package]]
|
247 |
+
name = "zipp"
|
248 |
+
version = "3.21.0"
|
249 |
+
description = "Backport of pathlib-compatible object wrapper for zip files"
|
250 |
+
optional = false
|
251 |
+
python-versions = ">=3.9"
|
252 |
+
files = [
|
253 |
+
{file = "zipp-3.21.0-py3-none-any.whl", hash = "sha256:ac1bbe05fd2991f160ebce24ffbac5f6d11d83dc90891255885223d42b3cd931"},
|
254 |
+
{file = "zipp-3.21.0.tar.gz", hash = "sha256:2c9958f6430a2040341a52eb608ed6dd93ef4392e02ffe219417c1b28b5dd1f4"},
|
255 |
+
]
|
256 |
+
|
257 |
+
[package.extras]
|
258 |
+
check = ["pytest-checkdocs (>=2.4)", "pytest-ruff (>=0.2.1)"]
|
259 |
+
cover = ["pytest-cov"]
|
260 |
+
doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"]
|
261 |
+
enabler = ["pytest-enabler (>=2.2)"]
|
262 |
+
test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more-itertools", "pytest (>=6,!=8.1.*)", "pytest-ignore-flaky"]
|
263 |
+
type = ["pytest-mypy"]
|
264 |
+
|
265 |
+
[metadata]
|
266 |
+
lock-version = "2.0"
|
267 |
+
python-versions = "^3.9"
|
268 |
+
content-hash = "66d405748614b53a5677c2b0e29d9676abafe1e94dbfd0f0d25c4dd781223d3c"
|
pyproject.toml
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[tool.poetry]
|
2 |
+
name = "godot"
|
3 |
+
version = "0.1.0"
|
4 |
+
description = ""
|
5 |
+
authors = ["Gabriel Kasser <[email protected]>"]
|
6 |
+
readme = "README.md"
|
7 |
+
|
8 |
+
[tool.poetry.dependencies]
|
9 |
+
python = "^3.9"
|
10 |
+
flask = "^3.1.0"
|
11 |
+
gunicorn = "^23.0.0"
|
12 |
+
flask-cors = "^5.0.0"
|
13 |
+
|
14 |
+
|
15 |
+
[build-system]
|
16 |
+
requires = ["poetry-core"]
|
17 |
+
build-backend = "poetry.core.masonry.api"
|
server/__main__.py
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import Flask, send_from_directory, jsonify, request, abort
|
2 |
+
import os
|
3 |
+
import gunicorn.app.base
|
4 |
+
from flask_cors import CORS
|
5 |
+
|
6 |
+
# Use a directory in the user's home folder for static files
|
7 |
+
STATIC_DIR = "/app/server/static"
|
8 |
+
|
9 |
+
|
10 |
+
app = Flask(__name__, static_folder=STATIC_DIR)
|
11 |
+
|
12 |
+
_ = CORS(
|
13 |
+
app,
|
14 |
+
origins=["*"],
|
15 |
+
methods=["GET", "POST", "OPTIONS"],
|
16 |
+
allow_headers=["Content-Type", "Authorization"],
|
17 |
+
)
|
18 |
+
|
19 |
+
|
20 |
+
@app.after_request
|
21 |
+
def add_header(response):
|
22 |
+
# Add permissive CORS headers
|
23 |
+
response.headers["Access-Control-Allow-Origin"] = "*"
|
24 |
+
response.headers["Access-Control-Allow-Methods"] = "GET, POST, PUT, DELETE, OPTIONS"
|
25 |
+
response.headers["Access-Control-Allow-Headers"] = "*" # Allow all headers
|
26 |
+
# Cross-origin isolation headers
|
27 |
+
response.headers["Cross-Origin-Embedder-Policy"] = "require-corp"
|
28 |
+
response.headers["Cross-Origin-Opener-Policy"] = "same-origin"
|
29 |
+
response.headers["Cross-Origin-Resource-Policy"] = "cross-origin"
|
30 |
+
return response
|
31 |
+
|
32 |
+
|
33 |
+
@app.route("/")
|
34 |
+
def serve_index():
|
35 |
+
# Handle logs=container query parameter
|
36 |
+
if request.args.get("logs") == "container":
|
37 |
+
files = (
|
38 |
+
os.listdir(app.static_folder) if os.path.exists(app.static_folder) else []
|
39 |
+
)
|
40 |
+
return jsonify(
|
41 |
+
{
|
42 |
+
"static_folder": app.static_folder,
|
43 |
+
"exists": os.path.exists(app.static_folder),
|
44 |
+
"files": files,
|
45 |
+
"pwd": os.getcwd(),
|
46 |
+
"user": os.getenv("USER"),
|
47 |
+
}
|
48 |
+
)
|
49 |
+
|
50 |
+
try:
|
51 |
+
response = send_from_directory(app.static_folder, "index.html")
|
52 |
+
response.headers["Cross-Origin-Opener-Policy"] = "same-origin"
|
53 |
+
response.headers["Cross-Origin-Embedder-Policy"] = "require-corp"
|
54 |
+
return response
|
55 |
+
except FileNotFoundError:
|
56 |
+
abort(
|
57 |
+
404,
|
58 |
+
description=f"Static folder or index.html not found. Static folder: {app.static_folder}",
|
59 |
+
)
|
60 |
+
|
61 |
+
|
62 |
+
@app.route("/api/data", methods=["GET"])
|
63 |
+
def get_data():
|
64 |
+
return jsonify({"message": "Voici vos données", "status": "success"})
|
65 |
+
|
66 |
+
|
67 |
+
@app.route("/api/process", methods=["POST"])
|
68 |
+
def process_data():
|
69 |
+
data = request.get_json()
|
70 |
+
return jsonify({"message": "Données reçues", "received_data": data})
|
71 |
+
|
72 |
+
|
73 |
+
@app.route("/<path:path>")
|
74 |
+
def serve_static(path: str):
|
75 |
+
try:
|
76 |
+
return send_from_directory(app.static_folder, path)
|
77 |
+
except FileNotFoundError:
|
78 |
+
abort(404, description=f"File {path} not found in static folder")
|
79 |
+
|
80 |
+
|
81 |
+
class StandaloneApplication(gunicorn.app.base.BaseApplication):
|
82 |
+
def __init__(self, app, options=None):
|
83 |
+
self.options = options or {}
|
84 |
+
self.application = app
|
85 |
+
super().__init__()
|
86 |
+
|
87 |
+
def load_config(self):
|
88 |
+
for key, value in self.options.items():
|
89 |
+
self.cfg.set(key.lower(), value)
|
90 |
+
|
91 |
+
def load(self):
|
92 |
+
return self.application
|
93 |
+
|
94 |
+
|
95 |
+
if __name__ == "__main__":
|
96 |
+
print(f"Static folder path: {app.static_folder}")
|
97 |
+
print(f"Static folder exists: {os.path.exists(app.static_folder)}")
|
98 |
+
if os.path.exists(app.static_folder):
|
99 |
+
print(f"Static folder contents: {os.listdir(app.static_folder)}")
|
100 |
+
|
101 |
+
os.makedirs(app.static_folder, exist_ok=True)
|
102 |
+
|
103 |
+
options = {
|
104 |
+
"bind": "0.0.0.0:7860",
|
105 |
+
"workers": 3,
|
106 |
+
"worker_class": "sync",
|
107 |
+
"timeout": 120,
|
108 |
+
"forwarded_allow_ips": "*",
|
109 |
+
}
|
110 |
+
|
111 |
+
StandaloneApplication(app, options).run()
|
server/static/index.apple-touch-icon.png
ADDED
![]() |
server/static/index.audio.worklet.js
ADDED
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**************************************************************************/
|
2 |
+
/* audio.worklet.js */
|
3 |
+
/**************************************************************************/
|
4 |
+
/* This file is part of: */
|
5 |
+
/* GODOT ENGINE */
|
6 |
+
/* https://godotengine.org */
|
7 |
+
/**************************************************************************/
|
8 |
+
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
9 |
+
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
10 |
+
/* */
|
11 |
+
/* Permission is hereby granted, free of charge, to any person obtaining */
|
12 |
+
/* a copy of this software and associated documentation files (the */
|
13 |
+
/* "Software"), to deal in the Software without restriction, including */
|
14 |
+
/* without limitation the rights to use, copy, modify, merge, publish, */
|
15 |
+
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
16 |
+
/* permit persons to whom the Software is furnished to do so, subject to */
|
17 |
+
/* the following conditions: */
|
18 |
+
/* */
|
19 |
+
/* The above copyright notice and this permission notice shall be */
|
20 |
+
/* included in all copies or substantial portions of the Software. */
|
21 |
+
/* */
|
22 |
+
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
23 |
+
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
24 |
+
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
25 |
+
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
26 |
+
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
27 |
+
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
28 |
+
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
29 |
+
/**************************************************************************/
|
30 |
+
|
31 |
+
class RingBuffer {
|
32 |
+
constructor(p_buffer, p_state, p_threads) {
|
33 |
+
this.buffer = p_buffer;
|
34 |
+
this.avail = p_state;
|
35 |
+
this.threads = p_threads;
|
36 |
+
this.rpos = 0;
|
37 |
+
this.wpos = 0;
|
38 |
+
}
|
39 |
+
|
40 |
+
data_left() {
|
41 |
+
return this.threads ? Atomics.load(this.avail, 0) : this.avail;
|
42 |
+
}
|
43 |
+
|
44 |
+
space_left() {
|
45 |
+
return this.buffer.length - this.data_left();
|
46 |
+
}
|
47 |
+
|
48 |
+
read(output) {
|
49 |
+
const size = this.buffer.length;
|
50 |
+
let from = 0;
|
51 |
+
let to_write = output.length;
|
52 |
+
if (this.rpos + to_write > size) {
|
53 |
+
const high = size - this.rpos;
|
54 |
+
output.set(this.buffer.subarray(this.rpos, size));
|
55 |
+
from = high;
|
56 |
+
to_write -= high;
|
57 |
+
this.rpos = 0;
|
58 |
+
}
|
59 |
+
if (to_write) {
|
60 |
+
output.set(this.buffer.subarray(this.rpos, this.rpos + to_write), from);
|
61 |
+
}
|
62 |
+
this.rpos += to_write;
|
63 |
+
if (this.threads) {
|
64 |
+
Atomics.add(this.avail, 0, -output.length);
|
65 |
+
Atomics.notify(this.avail, 0);
|
66 |
+
} else {
|
67 |
+
this.avail -= output.length;
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
write(p_buffer) {
|
72 |
+
const to_write = p_buffer.length;
|
73 |
+
const mw = this.buffer.length - this.wpos;
|
74 |
+
if (mw >= to_write) {
|
75 |
+
this.buffer.set(p_buffer, this.wpos);
|
76 |
+
this.wpos += to_write;
|
77 |
+
if (mw === to_write) {
|
78 |
+
this.wpos = 0;
|
79 |
+
}
|
80 |
+
} else {
|
81 |
+
const high = p_buffer.subarray(0, mw);
|
82 |
+
const low = p_buffer.subarray(mw);
|
83 |
+
this.buffer.set(high, this.wpos);
|
84 |
+
this.buffer.set(low);
|
85 |
+
this.wpos = low.length;
|
86 |
+
}
|
87 |
+
if (this.threads) {
|
88 |
+
Atomics.add(this.avail, 0, to_write);
|
89 |
+
Atomics.notify(this.avail, 0);
|
90 |
+
} else {
|
91 |
+
this.avail += to_write;
|
92 |
+
}
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
class GodotProcessor extends AudioWorkletProcessor {
|
97 |
+
constructor() {
|
98 |
+
super();
|
99 |
+
this.threads = false;
|
100 |
+
this.running = true;
|
101 |
+
this.lock = null;
|
102 |
+
this.notifier = null;
|
103 |
+
this.output = null;
|
104 |
+
this.output_buffer = new Float32Array();
|
105 |
+
this.input = null;
|
106 |
+
this.input_buffer = new Float32Array();
|
107 |
+
this.port.onmessage = (event) => {
|
108 |
+
const cmd = event.data['cmd'];
|
109 |
+
const data = event.data['data'];
|
110 |
+
this.parse_message(cmd, data);
|
111 |
+
};
|
112 |
+
}
|
113 |
+
|
114 |
+
process_notify() {
|
115 |
+
if (this.notifier) {
|
116 |
+
Atomics.add(this.notifier, 0, 1);
|
117 |
+
Atomics.notify(this.notifier, 0);
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
parse_message(p_cmd, p_data) {
|
122 |
+
if (p_cmd === 'start' && p_data) {
|
123 |
+
const state = p_data[0];
|
124 |
+
let idx = 0;
|
125 |
+
this.threads = true;
|
126 |
+
this.lock = state.subarray(idx, ++idx);
|
127 |
+
this.notifier = state.subarray(idx, ++idx);
|
128 |
+
const avail_in = state.subarray(idx, ++idx);
|
129 |
+
const avail_out = state.subarray(idx, ++idx);
|
130 |
+
this.input = new RingBuffer(p_data[1], avail_in, true);
|
131 |
+
this.output = new RingBuffer(p_data[2], avail_out, true);
|
132 |
+
} else if (p_cmd === 'stop') {
|
133 |
+
this.running = false;
|
134 |
+
this.output = null;
|
135 |
+
this.input = null;
|
136 |
+
this.lock = null;
|
137 |
+
this.notifier = null;
|
138 |
+
} else if (p_cmd === 'start_nothreads') {
|
139 |
+
this.output = new RingBuffer(p_data[0], p_data[0].length, false);
|
140 |
+
} else if (p_cmd === 'chunk') {
|
141 |
+
this.output.write(p_data);
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
static array_has_data(arr) {
|
146 |
+
return arr.length && arr[0].length && arr[0][0].length;
|
147 |
+
}
|
148 |
+
|
149 |
+
process(inputs, outputs, parameters) {
|
150 |
+
if (!this.running) {
|
151 |
+
return false; // Stop processing.
|
152 |
+
}
|
153 |
+
if (this.output === null) {
|
154 |
+
return true; // Not ready yet, keep processing.
|
155 |
+
}
|
156 |
+
const process_input = GodotProcessor.array_has_data(inputs);
|
157 |
+
if (process_input) {
|
158 |
+
const input = inputs[0];
|
159 |
+
const chunk = input[0].length * input.length;
|
160 |
+
if (this.input_buffer.length !== chunk) {
|
161 |
+
this.input_buffer = new Float32Array(chunk);
|
162 |
+
}
|
163 |
+
if (!this.threads) {
|
164 |
+
GodotProcessor.write_input(this.input_buffer, input);
|
165 |
+
this.port.postMessage({ 'cmd': 'input', 'data': this.input_buffer });
|
166 |
+
} else if (this.input.space_left() >= chunk) {
|
167 |
+
GodotProcessor.write_input(this.input_buffer, input);
|
168 |
+
this.input.write(this.input_buffer);
|
169 |
+
} else {
|
170 |
+
this.port.postMessage('Input buffer is full! Skipping input frame.');
|
171 |
+
}
|
172 |
+
}
|
173 |
+
const process_output = GodotProcessor.array_has_data(outputs);
|
174 |
+
if (process_output) {
|
175 |
+
const output = outputs[0];
|
176 |
+
const chunk = output[0].length * output.length;
|
177 |
+
if (this.output_buffer.length !== chunk) {
|
178 |
+
this.output_buffer = new Float32Array(chunk);
|
179 |
+
}
|
180 |
+
if (this.output.data_left() >= chunk) {
|
181 |
+
this.output.read(this.output_buffer);
|
182 |
+
GodotProcessor.write_output(output, this.output_buffer);
|
183 |
+
if (!this.threads) {
|
184 |
+
this.port.postMessage({ 'cmd': 'read', 'data': chunk });
|
185 |
+
}
|
186 |
+
} else {
|
187 |
+
this.port.postMessage('Output buffer has not enough frames! Skipping output frame.');
|
188 |
+
}
|
189 |
+
}
|
190 |
+
this.process_notify();
|
191 |
+
return true;
|
192 |
+
}
|
193 |
+
|
194 |
+
static write_output(dest, source) {
|
195 |
+
const channels = dest.length;
|
196 |
+
for (let ch = 0; ch < channels; ch++) {
|
197 |
+
for (let sample = 0; sample < dest[ch].length; sample++) {
|
198 |
+
dest[ch][sample] = source[sample * channels + ch];
|
199 |
+
}
|
200 |
+
}
|
201 |
+
}
|
202 |
+
|
203 |
+
static write_input(dest, source) {
|
204 |
+
const channels = source.length;
|
205 |
+
for (let ch = 0; ch < channels; ch++) {
|
206 |
+
for (let sample = 0; sample < source[ch].length; sample++) {
|
207 |
+
dest[sample * channels + ch] = source[ch][sample];
|
208 |
+
}
|
209 |
+
}
|
210 |
+
}
|
211 |
+
}
|
212 |
+
|
213 |
+
registerProcessor('godot-processor', GodotProcessor);
|
server/static/index.html
ADDED
@@ -0,0 +1,248 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="utf-8">
|
5 |
+
<meta name="viewport" content="width=device-width, user-scalable=no">
|
6 |
+
<title>Magame</title>
|
7 |
+
<style>
|
8 |
+
body {
|
9 |
+
touch-action: none;
|
10 |
+
margin: 0;
|
11 |
+
border: 0 none;
|
12 |
+
padding: 0;
|
13 |
+
text-align: center;
|
14 |
+
background-color: black;
|
15 |
+
}
|
16 |
+
|
17 |
+
#canvas {
|
18 |
+
display: block;
|
19 |
+
margin: 0;
|
20 |
+
color: white;
|
21 |
+
}
|
22 |
+
|
23 |
+
#canvas:focus {
|
24 |
+
outline: none;
|
25 |
+
}
|
26 |
+
|
27 |
+
.godot {
|
28 |
+
font-family: 'Noto Sans', 'Droid Sans', Arial, sans-serif;
|
29 |
+
color: #e0e0e0;
|
30 |
+
background-color: #3b3943;
|
31 |
+
background-image: linear-gradient(to bottom, #403e48, #35333c);
|
32 |
+
border: 1px solid #45434e;
|
33 |
+
box-shadow: 0 0 1px 1px #2f2d35;
|
34 |
+
}
|
35 |
+
|
36 |
+
/* Status display */
|
37 |
+
|
38 |
+
#status {
|
39 |
+
position: absolute;
|
40 |
+
left: 0;
|
41 |
+
top: 0;
|
42 |
+
right: 0;
|
43 |
+
bottom: 0;
|
44 |
+
display: flex;
|
45 |
+
justify-content: center;
|
46 |
+
align-items: center;
|
47 |
+
/* don't consume click events - make children visible explicitly */
|
48 |
+
visibility: hidden;
|
49 |
+
}
|
50 |
+
|
51 |
+
#status-progress {
|
52 |
+
width: 366px;
|
53 |
+
height: 7px;
|
54 |
+
background-color: #38363A;
|
55 |
+
border: 1px solid #444246;
|
56 |
+
padding: 1px;
|
57 |
+
box-shadow: 0 0 2px 1px #1B1C22;
|
58 |
+
border-radius: 2px;
|
59 |
+
visibility: visible;
|
60 |
+
}
|
61 |
+
|
62 |
+
@media only screen and (orientation:portrait) {
|
63 |
+
#status-progress {
|
64 |
+
width: 61.8%;
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
#status-progress-inner {
|
69 |
+
height: 100%;
|
70 |
+
width: 0;
|
71 |
+
box-sizing: border-box;
|
72 |
+
transition: width 0.5s linear;
|
73 |
+
background-color: #202020;
|
74 |
+
border: 1px solid #222223;
|
75 |
+
box-shadow: 0 0 1px 1px #27282E;
|
76 |
+
border-radius: 3px;
|
77 |
+
}
|
78 |
+
|
79 |
+
#status-indeterminate {
|
80 |
+
height: 42px;
|
81 |
+
visibility: visible;
|
82 |
+
position: relative;
|
83 |
+
}
|
84 |
+
|
85 |
+
#status-indeterminate > div {
|
86 |
+
width: 4.5px;
|
87 |
+
height: 0;
|
88 |
+
border-style: solid;
|
89 |
+
border-width: 9px 3px 0 3px;
|
90 |
+
border-color: #2b2b2b transparent transparent transparent;
|
91 |
+
transform-origin: center 21px;
|
92 |
+
position: absolute;
|
93 |
+
}
|
94 |
+
|
95 |
+
#status-indeterminate > div:nth-child(1) { transform: rotate( 22.5deg); }
|
96 |
+
#status-indeterminate > div:nth-child(2) { transform: rotate( 67.5deg); }
|
97 |
+
#status-indeterminate > div:nth-child(3) { transform: rotate(112.5deg); }
|
98 |
+
#status-indeterminate > div:nth-child(4) { transform: rotate(157.5deg); }
|
99 |
+
#status-indeterminate > div:nth-child(5) { transform: rotate(202.5deg); }
|
100 |
+
#status-indeterminate > div:nth-child(6) { transform: rotate(247.5deg); }
|
101 |
+
#status-indeterminate > div:nth-child(7) { transform: rotate(292.5deg); }
|
102 |
+
#status-indeterminate > div:nth-child(8) { transform: rotate(337.5deg); }
|
103 |
+
|
104 |
+
#status-notice {
|
105 |
+
margin: 0 100px;
|
106 |
+
line-height: 1.3;
|
107 |
+
visibility: visible;
|
108 |
+
padding: 4px 6px;
|
109 |
+
visibility: visible;
|
110 |
+
}
|
111 |
+
</style>
|
112 |
+
<link id='-gd-engine-icon' rel='icon' type='image/png' href='index.icon.png' />
|
113 |
+
<link rel='apple-touch-icon' href='index.apple-touch-icon.png'/>
|
114 |
+
|
115 |
+
</head>
|
116 |
+
<body>
|
117 |
+
<canvas id="canvas">
|
118 |
+
HTML5 canvas appears to be unsupported in the current browser.<br >
|
119 |
+
Please try updating or use a different browser.
|
120 |
+
</canvas>
|
121 |
+
<div id="status">
|
122 |
+
<div id="status-progress" style="display: none;" oncontextmenu="event.preventDefault();">
|
123 |
+
<div id ="status-progress-inner"></div>
|
124 |
+
</div>
|
125 |
+
<div id="status-indeterminate" style="display: none;" oncontextmenu="event.preventDefault();">
|
126 |
+
<div></div>
|
127 |
+
<div></div>
|
128 |
+
<div></div>
|
129 |
+
<div></div>
|
130 |
+
<div></div>
|
131 |
+
<div></div>
|
132 |
+
<div></div>
|
133 |
+
<div></div>
|
134 |
+
</div>
|
135 |
+
<div id="status-notice" class="godot" style="display: none;"></div>
|
136 |
+
</div>
|
137 |
+
|
138 |
+
<script src="index.js"></script>
|
139 |
+
<script>
|
140 |
+
const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"executable":"index","experimentalVK":false,"fileSizes":{"index.pck":5424,"index.wasm":35410474},"focusCanvas":true,"gdextensionLibs":[]};
|
141 |
+
const engine = new Engine(GODOT_CONFIG);
|
142 |
+
|
143 |
+
(function () {
|
144 |
+
const INDETERMINATE_STATUS_STEP_MS = 100;
|
145 |
+
const statusProgress = document.getElementById('status-progress');
|
146 |
+
const statusProgressInner = document.getElementById('status-progress-inner');
|
147 |
+
const statusIndeterminate = document.getElementById('status-indeterminate');
|
148 |
+
const statusNotice = document.getElementById('status-notice');
|
149 |
+
|
150 |
+
let initializing = true;
|
151 |
+
let statusMode = 'hidden';
|
152 |
+
|
153 |
+
let animationCallbacks = [];
|
154 |
+
function animate(time) {
|
155 |
+
animationCallbacks.forEach((callback) => callback(time));
|
156 |
+
requestAnimationFrame(animate);
|
157 |
+
}
|
158 |
+
requestAnimationFrame(animate);
|
159 |
+
|
160 |
+
function animateStatusIndeterminate(ms) {
|
161 |
+
const i = Math.floor((ms / INDETERMINATE_STATUS_STEP_MS) % 8);
|
162 |
+
if (statusIndeterminate.children[i].style.borderTopColor === '') {
|
163 |
+
Array.prototype.slice.call(statusIndeterminate.children).forEach((child) => {
|
164 |
+
child.style.borderTopColor = '';
|
165 |
+
});
|
166 |
+
statusIndeterminate.children[i].style.borderTopColor = '#dfdfdf';
|
167 |
+
}
|
168 |
+
}
|
169 |
+
|
170 |
+
function setStatusMode(mode) {
|
171 |
+
if (statusMode === mode || !initializing) {
|
172 |
+
return;
|
173 |
+
}
|
174 |
+
[statusProgress, statusIndeterminate, statusNotice].forEach((elem) => {
|
175 |
+
elem.style.display = 'none';
|
176 |
+
});
|
177 |
+
animationCallbacks = animationCallbacks.filter(function (value) {
|
178 |
+
return (value !== animateStatusIndeterminate);
|
179 |
+
});
|
180 |
+
switch (mode) {
|
181 |
+
case 'progress':
|
182 |
+
statusProgress.style.display = 'block';
|
183 |
+
break;
|
184 |
+
case 'indeterminate':
|
185 |
+
statusIndeterminate.style.display = 'block';
|
186 |
+
animationCallbacks.push(animateStatusIndeterminate);
|
187 |
+
break;
|
188 |
+
case 'notice':
|
189 |
+
statusNotice.style.display = 'block';
|
190 |
+
break;
|
191 |
+
case 'hidden':
|
192 |
+
break;
|
193 |
+
default:
|
194 |
+
throw new Error('Invalid status mode');
|
195 |
+
}
|
196 |
+
statusMode = mode;
|
197 |
+
}
|
198 |
+
|
199 |
+
function setStatusNotice(text) {
|
200 |
+
while (statusNotice.lastChild) {
|
201 |
+
statusNotice.removeChild(statusNotice.lastChild);
|
202 |
+
}
|
203 |
+
const lines = text.split('\n');
|
204 |
+
lines.forEach((line) => {
|
205 |
+
statusNotice.appendChild(document.createTextNode(line));
|
206 |
+
statusNotice.appendChild(document.createElement('br'));
|
207 |
+
});
|
208 |
+
}
|
209 |
+
|
210 |
+
function displayFailureNotice(err) {
|
211 |
+
const msg = err.message || err;
|
212 |
+
console.error(msg);
|
213 |
+
setStatusNotice(msg);
|
214 |
+
setStatusMode('notice');
|
215 |
+
initializing = false;
|
216 |
+
}
|
217 |
+
|
218 |
+
const missing = Engine.getMissingFeatures();
|
219 |
+
if (missing.length !== 0) {
|
220 |
+
const missingMsg = 'Error\nThe following features required to run Godot projects on the Web are missing:\n';
|
221 |
+
displayFailureNotice(missingMsg + missing.join('\n'));
|
222 |
+
} else {
|
223 |
+
setStatusMode('indeterminate');
|
224 |
+
engine.startGame({
|
225 |
+
'onProgress': function (current, total) {
|
226 |
+
if (total > 0) {
|
227 |
+
statusProgressInner.style.width = `${(current / total) * 100}%`;
|
228 |
+
setStatusMode('progress');
|
229 |
+
if (current === total) {
|
230 |
+
// wait for progress bar animation
|
231 |
+
setTimeout(() => {
|
232 |
+
setStatusMode('indeterminate');
|
233 |
+
}, 500);
|
234 |
+
}
|
235 |
+
} else {
|
236 |
+
setStatusMode('indeterminate');
|
237 |
+
}
|
238 |
+
},
|
239 |
+
}).then(() => {
|
240 |
+
setStatusMode('hidden');
|
241 |
+
initializing = false;
|
242 |
+
}, displayFailureNotice);
|
243 |
+
}
|
244 |
+
}());
|
245 |
+
</script>
|
246 |
+
</body>
|
247 |
+
</html>
|
248 |
+
|
server/static/index.icon.png
ADDED
![]() |
server/static/index.js
ADDED
The diff for this file is too large to render.
See raw diff
|
|
server/static/index.pck
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:66a491c47db387a79e701d71d84c5c2d517649710b6b7a611f699de82955bcb6
|
3 |
+
size 5424
|
server/static/index.png
ADDED
![]() |
server/static/index.wasm
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f5082a4e3d191de748c21ba54b8490614c4ca4a092c6db3f35a40e5183d459bd
|
3 |
+
size 35410474
|
server/static/index.worker.js
ADDED
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* @license
|
3 |
+
* Copyright 2015 The Emscripten Authors
|
4 |
+
* SPDX-License-Identifier: MIT
|
5 |
+
*/
|
6 |
+
|
7 |
+
// Pthread Web Worker startup routine:
|
8 |
+
// This is the entry point file that is loaded first by each Web Worker
|
9 |
+
// that executes pthreads on the Emscripten application.
|
10 |
+
|
11 |
+
'use strict';
|
12 |
+
|
13 |
+
var Module = {};
|
14 |
+
|
15 |
+
// Thread-local guard variable for one-time init of the JS state
|
16 |
+
var initializedJS = false;
|
17 |
+
|
18 |
+
function assert(condition, text) {
|
19 |
+
if (!condition) abort('Assertion failed: ' + text);
|
20 |
+
}
|
21 |
+
|
22 |
+
function threadPrintErr() {
|
23 |
+
var text = Array.prototype.slice.call(arguments).join(' ');
|
24 |
+
console.error(text);
|
25 |
+
}
|
26 |
+
function threadAlert() {
|
27 |
+
var text = Array.prototype.slice.call(arguments).join(' ');
|
28 |
+
postMessage({cmd: 'alert', text: text, threadId: Module['_pthread_self']()});
|
29 |
+
}
|
30 |
+
// We don't need out() for now, but may need to add it if we want to use it
|
31 |
+
// here. Or, if this code all moves into the main JS, that problem will go
|
32 |
+
// away. (For now, adding it here increases code size for no benefit.)
|
33 |
+
var out = () => { throw 'out() is not defined in worker.js.'; }
|
34 |
+
var err = threadPrintErr;
|
35 |
+
self.alert = threadAlert;
|
36 |
+
|
37 |
+
Module['instantiateWasm'] = (info, receiveInstance) => {
|
38 |
+
// Instantiate from the module posted from the main thread.
|
39 |
+
// We can just use sync instantiation in the worker.
|
40 |
+
var module = Module['wasmModule'];
|
41 |
+
// We don't need the module anymore; new threads will be spawned from the main thread.
|
42 |
+
Module['wasmModule'] = null;
|
43 |
+
var instance = new WebAssembly.Instance(module, info);
|
44 |
+
// TODO: Due to Closure regression https://github.com/google/closure-compiler/issues/3193,
|
45 |
+
// the above line no longer optimizes out down to the following line.
|
46 |
+
// When the regression is fixed, we can remove this if/else.
|
47 |
+
return receiveInstance(instance);
|
48 |
+
}
|
49 |
+
|
50 |
+
// Turn unhandled rejected promises into errors so that the main thread will be
|
51 |
+
// notified about them.
|
52 |
+
self.onunhandledrejection = (e) => {
|
53 |
+
throw e.reason ?? e;
|
54 |
+
};
|
55 |
+
|
56 |
+
function handleMessage(e) {
|
57 |
+
try {
|
58 |
+
if (e.data.cmd === 'load') { // Preload command that is called once per worker to parse and load the Emscripten code.
|
59 |
+
|
60 |
+
// Until we initialize the runtime, queue up any further incoming messages.
|
61 |
+
let messageQueue = [];
|
62 |
+
self.onmessage = (e) => messageQueue.push(e);
|
63 |
+
|
64 |
+
// And add a callback for when the runtime is initialized.
|
65 |
+
self.startWorker = (instance) => {
|
66 |
+
Module = instance;
|
67 |
+
// Notify the main thread that this thread has loaded.
|
68 |
+
postMessage({ 'cmd': 'loaded' });
|
69 |
+
// Process any messages that were queued before the thread was ready.
|
70 |
+
for (let msg of messageQueue) {
|
71 |
+
handleMessage(msg);
|
72 |
+
}
|
73 |
+
// Restore the real message handler.
|
74 |
+
self.onmessage = handleMessage;
|
75 |
+
};
|
76 |
+
|
77 |
+
// Module and memory were sent from main thread
|
78 |
+
Module['wasmModule'] = e.data.wasmModule;
|
79 |
+
|
80 |
+
// Use `const` here to ensure that the variable is scoped only to
|
81 |
+
// that iteration, allowing safe reference from a closure.
|
82 |
+
for (const handler of e.data.handlers) {
|
83 |
+
Module[handler] = function() {
|
84 |
+
postMessage({ cmd: 'callHandler', handler, args: [...arguments] });
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
Module['wasmMemory'] = e.data.wasmMemory;
|
89 |
+
|
90 |
+
Module['buffer'] = Module['wasmMemory'].buffer;
|
91 |
+
|
92 |
+
Module['workerID'] = e.data.workerID;
|
93 |
+
|
94 |
+
Module['ENVIRONMENT_IS_PTHREAD'] = true;
|
95 |
+
|
96 |
+
if (typeof e.data.urlOrBlob == 'string') {
|
97 |
+
importScripts(e.data.urlOrBlob);
|
98 |
+
} else {
|
99 |
+
var objectUrl = URL.createObjectURL(e.data.urlOrBlob);
|
100 |
+
importScripts(objectUrl);
|
101 |
+
URL.revokeObjectURL(objectUrl);
|
102 |
+
}
|
103 |
+
Godot(Module);
|
104 |
+
} else if (e.data.cmd === 'run') {
|
105 |
+
// Pass the thread address to wasm to store it for fast access.
|
106 |
+
Module['__emscripten_thread_init'](e.data.pthread_ptr, /*isMainBrowserThread=*/0, /*isMainRuntimeThread=*/0, /*canBlock=*/1);
|
107 |
+
|
108 |
+
// Await mailbox notifications with `Atomics.waitAsync` so we can start
|
109 |
+
// using the fast `Atomics.notify` notification path.
|
110 |
+
Module['__emscripten_thread_mailbox_await'](e.data.pthread_ptr);
|
111 |
+
|
112 |
+
assert(e.data.pthread_ptr);
|
113 |
+
// Also call inside JS module to set up the stack frame for this pthread in JS module scope
|
114 |
+
Module['establishStackSpace']();
|
115 |
+
Module['PThread'].receiveObjectTransfer(e.data);
|
116 |
+
Module['PThread'].threadInitTLS();
|
117 |
+
|
118 |
+
if (!initializedJS) {
|
119 |
+
initializedJS = true;
|
120 |
+
}
|
121 |
+
|
122 |
+
try {
|
123 |
+
Module['invokeEntryPoint'](e.data.start_routine, e.data.arg);
|
124 |
+
} catch(ex) {
|
125 |
+
if (ex != 'unwind') {
|
126 |
+
// The pthread "crashed". Do not call `_emscripten_thread_exit` (which
|
127 |
+
// would make this thread joinable). Instead, re-throw the exception
|
128 |
+
// and let the top level handler propagate it back to the main thread.
|
129 |
+
throw ex;
|
130 |
+
}
|
131 |
+
}
|
132 |
+
} else if (e.data.cmd === 'cancel') { // Main thread is asking for a pthread_cancel() on this thread.
|
133 |
+
if (Module['_pthread_self']()) {
|
134 |
+
Module['__emscripten_thread_exit'](-1);
|
135 |
+
}
|
136 |
+
} else if (e.data.target === 'setimmediate') {
|
137 |
+
// no-op
|
138 |
+
} else if (e.data.cmd === 'checkMailbox') {
|
139 |
+
if (initializedJS) {
|
140 |
+
Module['checkMailbox']();
|
141 |
+
}
|
142 |
+
} else if (e.data.cmd) {
|
143 |
+
// The received message looks like something that should be handled by this message
|
144 |
+
// handler, (since there is a e.data.cmd field present), but is not one of the
|
145 |
+
// recognized commands:
|
146 |
+
err('worker.js received unknown command ' + e.data.cmd);
|
147 |
+
err(e.data);
|
148 |
+
}
|
149 |
+
} catch(ex) {
|
150 |
+
err('worker.js onmessage() captured an uncaught exception: ' + ex);
|
151 |
+
if (ex && ex.stack) err(ex.stack);
|
152 |
+
if (Module['__emscripten_thread_crashed']) {
|
153 |
+
Module['__emscripten_thread_crashed']();
|
154 |
+
}
|
155 |
+
throw ex;
|
156 |
+
}
|
157 |
+
};
|
158 |
+
|
159 |
+
self.onmessage = handleMessage;
|
160 |
+
|
161 |
+
|