Repository navigation
Isomorphic PHP, Isomorphic Blueprints - #214
Merged
Merged
Conversation
adamziel
force-pushed
the
isomorphic-helpers
branch
from
April 24, 2023 09:46
6650dcb to
2b11f8c
Compare
dmsnell
reviewed
Apr 24, 2023
dmsnell
reviewed
Apr 24, 2023
adamziel
marked this pull request as ready for review
April 24, 2023 11:24
dmsnell
reviewed
Apr 24, 2023
dmsnell
reviewed
Apr 24, 2023
dmsnell
reviewed
Apr 24, 2023
dmsnell
reviewed
Apr 24, 2023
dmsnell
reviewed
Apr 24, 2023
dmsnell
reviewed
Apr 24, 2023
dmsnell
reviewed
Apr 24, 2023
dmsnell
reviewed
Apr 24, 2023
dmsnell
reviewed
Apr 24, 2023
Collaborator
Author
|
@dmsnell I'm going to merge this one, but that doesn't mean it's closed for feedback. Your suggestions were invaluable and made it a lot better – I'm happy to keep addressing them, only in a follow-up PR. Oh, and it's a huge PR but I'm still going to merge the entire thing. Turning it into a series of commits would require quite a few intermediate scaffolds to keep the CI happy along the way. I hope it's not going to come up too much during future bisects! |
This was referenced Apr 26, 2023
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
Generalizes Playground Blueprints from working with just the in-browser Playground API client to working:
With this PR applied, all of the following
login()calls are valid:This opens the door to using Blueprints in the VS Code extension, wp-now, and other tools.
Implementation
Blueprint were initially implemented as a part of the browser API client in
@wp-playground/client. This PR decouples them into an isomorphic@wp-playground/blueprintspackage that depends on@php-wasm/universalwhich is also isomorphic.In other words, step handlers such as
login(playground)used to require aPlaygroundClientinstance, but now they can work with aUniversalPHPinstance defined as follows:UniversalPHPis a type, not a class. It's a common core of all PHP implementations in other packages and provides methods likerun(),request(), andwriteFile().@php-wasm/universalalso provides a reference implementation ofUniversalPHPcalledBasePHP.BasePHPcannot be used directly. Instead, platform-specific packages@php-wasm/weband@php-wasm/nodeprovide platform-specific implementations. The former exportsWebPHP, which loads files usingfetch(), and the latter exportsNodePHP, which reads data directly from the host filesystem. Both implement theUniversalPHPinterface and can be used with any Blueprint step.Other notes
@php-wasm/universal,@wp-playground/client, and@wp-playground/blueprintsare published as isomorphic ESM/CJS packages.@php-wasm/nodeis published as CJS only for now.Follow-up work
@wp-playground/blueprintswill need to be smart about providing a Node.js polyfill fornew DOMParser()andfetch().