Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Introduces a progress bar.
Loading WASM WordPress requires downloading about 20MB of files. Waiting without any feedback is a bad experience, not to mention you can never be sure whether it crashed or is still loading.
Solves #36
Screencast
There are two loading stages:
CleanShot.2022-10-14.at.17.31.41.mp4
How does this PR solve it?
This commit introduces a progress bar. The idea is to capture the progress events in
wasm-worker.js
, pass them on to the main thread, and then use the information to update a CSS progress bar.We can’t simply update the WASM loading code to capture the progress events because that codeis generated by emscripten on each build. Instead, this commit introduces a
WASMDownloadMonitor
class that:php-wasm.wasm
progress eventsdataFileDownloads
using ES Proxies to capture thewp.data
progress eventsIt also introduces a new worker backend method called
addMessageListener
. It’s necessary to propagate the progress information from the worker to the main thread.Finally, it reduces the
init()
method to a simple wrapper that can be configured as needed in the app. This allows the seamlesswordpress.html
to just load WordPress and be done, and the more involvedwordpress-browser.html
to handle the progress bar internally.