This devcontainer is configured to provide you an Emscripten and other tools to compile libcurl.js, and run both server-side (websocket-enabled "proxy") and client side (web server to deliever WASM and glue code to browsers).
The sample code and following instructions are partially based on libcurl.js docs and examples.
Tested with libcurl.js
0.6.11,
and Emscripten 3.1.6.
-
Open this repo in devcontainer, e.g. using Github Codespaces. Type or copy/paste following commands to devcontainer's terminal.
-
Clone the libcurl.js repo:
git clone https://github.com/ading2210/libcurl.js --recursive --depth=1
cd
to sources of server-side part:
cd libcurl.js/server
- Run the server-side part:
./run.sh
This will install dependencies if needed (by using venv
) and start a websocket server.
- Press
Make Public
button when codespace shows port forwarding confirmation dialog.
-
Open new terminal tab in your codespace, leaving server-side tab running.
-
In new tab,
cd
to sources of client-side part:
cd libcurl.js/client
- Compile the client-side code, including patched libcurl:
./build.sh
The compilation will take about 5-10 minutes, resulting to 2.8Mb libcurl.wasm
file in the out
subfolder,
along with 2 glue JS files.
Continue to use terminal tab for client side.
- Copy HTTP-request-enabled example from parent folder instead default one:
cp ../../index.html ./
- Run simple HTTP server to temporarily publish project to Web:
python3 -m http.server
-
Codespace will show you "Open in Browser" button. Just click that button or obtain web address from "Forwarded Ports" tab.
-
As
index.html
, JS files, and a 2.8M-sizedlibcurl.wasm
are loaded into browser, refer to browser developer console to see the results.
Perform your own experiments if desired.
The worker.html
is one of the earliest candidates to try.
Created for (wannabe-awesome) list