Progress events and progress bar support - #56
Merged
Conversation
adamziel
referenced
this pull request
in WordPress/wordpress-playground
Mar 1, 2024
Renders the Blueprint execution progress information exposed in WordPress/blueprints#56 ## Testing instructions Go to http://localhost:5400/website-server/demos/php-blueprints.html and confirm the progress information gets displayed like on this screenshot:
adamziel
referenced
this pull request
in WordPress/wordpress-playground
Mar 1, 2024
Renders the Blueprint execution progress information exposed in WordPress/blueprints#56 ## Follow-up work * Pre-process the user-provided Blueprint.json and start pre-fetching data from the URL-based resources. Then, inform the user about the progress of those `fetch()` requests. ## Testing instructions Go to http://localhost:5400/website-server/demos/php-blueprints.html and confirm the progress information gets displayed like on this screenshot: <img width="550" src="https://github.com/WordPress/wordpress-playground/assets/205419/ca072946-ad67-483c-a1a3-7f2d146ed8eb">
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Exposes details about the progress of the Blueprint execution:
CleanShot.2024-03-01.at.14.14.57.mp4
Implementation
The
Engineclass no longer exposes a singlerun()method. Instead, the flow is split into two stages: 1. Parsing&compiling, 2. Running:The
CompiledBlueprintobject exposes two progress trackers:progressTrackerwith the joint progress information about steps and resourcesstepsProgressStagewith information only about the Blueprint steps – Playground will use that one as it will start pre-fetching any URL-based resources before PHP is even loaded.The
progressTracker->event->addSubscribermethod accepts anEventSubscriberInterface $progressSubscriberargument that can subscribe to "progress" and "done" events. This enables implementing custom progress reporters, like the one showcased in the video above:Related resources
Follow-up work
blueprints.pharand bring CLI-specific libraries into the library that's supposed to be lightweight and environment-agnostic. Instead, exploring environment-specific packages likeBlueprints/CLIorBlueprints/Playgroundmight make more sense. Or perhaps Playground OR each runtime should even ship its own PHP bindings in its own repo? That's TBD.Testing instructions
Run
rm -rf new-wp/*; php blueprint_compiling.phpand confirm the entire Blueprint gets executed.