Skip to content

Commit 178c3bf

Browse files
committed
New webplayground
1 parent ee6b2d7 commit 178c3bf

26 files changed

Lines changed: 105 additions & 1010 deletions

File tree

arcade/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.0.0a1
1+
4.0.0.dev1

arcade/examples/gl/__init__.py

Whitespace-only changes.

arcade/examples/gui/__init__.py

Whitespace-only changes.

arcade/examples/perf_test/__init__.py

Whitespace-only changes.

arcade/examples/platform_tutorial/__init__.py

Whitespace-only changes.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
await pyodide.loadPackage("micropip");
1313
const micropip = pyodide.pyimport("micropip");
1414
await pyodide.loadPackage("pillow"); // Arcade needs Pillow
15-
await micropip.install("http://localhost:8000/pyglet-3.0.0a1-py3-none-any.whl");
16-
await micropip.install("http://localhost:8000/arcade-3.3.2-py3-none-any.whl");
15+
await micropip.install("http://localhost:8000/static/{{pyglet_wheel}}");
16+
await micropip.install("http://localhost:8000/static/{{arcade_wheel}}");
1717

1818
let response = await fetch("./package.zip");
1919
let buffer = await response.arrayBuffer();

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ dev = [
6161
"click==8.1.7", # Temp fix until we bump typer
6262
"typer==0.12.5", # Needed for make.py
6363
"wheel",
64+
"bottle" # Used for web testing playground
6465
]
6566
# Testing only
6667
testing_libraries = ["pytest", "pytest-mock", "pytest-cov", "pyyaml==6.0.1"]

webplayground/README.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
# Arcade Web Testing
2-
This directory contains a utility and some examples for early Testing of Arcade in web browsers.
2+
This directory contains a utility for early testing of Arcade in web browsers.
33

4-
An http server is provided with the `server.py` file. This file can be run with `python server.py` and will serve
5-
a local HTTP server on port 8000. From there, any desired example can be accessed in the browser by simply navigating
6-
to it's path. For example to view the `basic_renderer` example, you would navigate to `http://localhost:8000/basic_renderer`.
4+
An http server is provided with the `server.py` file. This file can be run with `python server.py` and will serve a local HTTP server on port 8000.
75

8-
There are some pre-requesites to running this server. It assums that you have the `development` branch of Pyglet
6+
The index page will provide a list of all Arcade examples. This is generated dynamically on the fly when the page is loaded, and will show all examples in the `arcade.examples` package. This generates links which can be followed to open any example in the browser.
7+
8+
There are some pre-requesites to running this server. It assumes that you have the `development` branch of Pyglet
99
checked out and in a folder named `pyglet` directly next to your Arcade repo directory. You will also need to have
10-
the `build` and `flit` packages from PyPi installed. These are used by Pyglet and Arcade to build wheel files, but are not
11-
generally installed for local development.
10+
the `build` and `flit` packages from PyPi installed. These are used by Pyglet and Arcade to build wheel files,
11+
but are not generally installed for local development.
1212

1313
Assuming you have Pyglet ready to go, you can then start the server. It will build wheels for both Pyglet and Arcade, and copy them
14-
into this directory. This means that if you make changes to Arcade or Pyglet, you will need to restart this server in order to
15-
build new wheels for those changes to take effect. If you only change example code within this directory, there is no need to
16-
restart the server for it to take effect.
14+
into this directory. This means that if you make any, you will need to restart this server in order to build new wheels.
1715

1816
## How does this work?
1917

20-
One problem with deploying into the web, is that the code and assets need to be injected into the WASM virtual filesystem. This can
21-
be easier said than done. The provided HTTP server has a special component to it, that when it receives a request ending in `.zip` it will
22-
look for a folder name matching the filename of the .zip. It will then create a .zip from that folder, and serve the zip file back.
18+
The web server itself is built with a nice little HTTP server library named [Bottle](https://github.com/bottlepy/bottle). We need to run an HTTP server locally
19+
to load anything into WASM in the browser, it will not work if we just server it files directly due to browser security constraints. For the Arcade examples specifically,
20+
we are taking advantage of the fact that the example code is packaged directly inside of Arcade to enable executing them in the browser.
2321

24-
This means that in an HTML file, code for an example can be included by simple appending `.zip` to the path to the package and assuming
25-
it exists. The server will create it dynamically. For a very basic example, see `basic_renderer` in this directory.
22+
If we need to add extra code that is not part of the Arcade package, that will require extension of this server to handle packaging it properly for loading into WASM, and then
23+
serving that package.

webplayground/basic_renderer/package/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

webplayground/basic_renderer/package/main.py

Lines changed: 0 additions & 91 deletions
This file was deleted.

0 commit comments

Comments
 (0)