Conversation
There was a problem hiding this comment.
This is needed for GitHub pages, due to modern requirements for SharedArrayBuffer (after Spectre) and is a bit tacky by using a service worker that reloads the page with the needed headers set.
Ideally, GitHub pages would just set this header (like the the CORS headers), but that's not the case.
There was a problem hiding this comment.
Instead of modifying all the examples, I instead opted for backwards compatibility and added another example that does not use the raylib_js_set_entry function (straight from the official examples).
There was a problem hiding this comment.
Ideally this would be called raylib.js and the other file would be called raylib-worker.js (instead of raylib.js), but that would confuse git
There was a problem hiding this comment.
Because python -m http.server has no CLI options, this just starts http.server with the additional headers.
There was a problem hiding this comment.
Due to enable-threads.js, python3 -m http.server should work too, however this is more clean
There was a problem hiding this comment.
It can be used like this: ./server.py <optional_port>
|
Relates to #22 |
|
Oh damn, I was working on the same thing, you beat me to it! |
- automatically creates properties on both sides - types are synchronized for IDE users
- because we don't await start anyway, I removed the initialized reply
| raylibExampleSelect.value = selectedWasm; | ||
|
|
||
| if (isHosted) { | ||
| if (!isCOI) { |
There was a problem hiding this comment.
The enable-threads.js hack makes this theoretically unnecessary, but if the hack is removed, this at least gives a message to the user.
There was a problem hiding this comment.
This is a little class I wrote to make working with the Data views of Linear memory a bit easier. You describe what attributes you store and their types and it generates the necessary data views, so you don't have to keep track of offsets yourself and instead can "just" refer to the variables created in the schema by name and it resolves to a typed array with the correct type at that location.
I toyed around with Web Workers, Atomics, SharedArrayBuffers and OffscreenCanvas and this actually makes most async tasks possible without using asyncify! This does not require any dependencies or code transformations, it is just the browser's web APIs.
Changes
raylib-wrapper.jsfile that is the new main entry pointraylib.jsis run on a worker (not calledraylib-worker.jsto make git happy)SharedArrayBuffersAtomics#waitserver.pyscript due to security requirements forSharedArrayBufferCloses #45