-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Isomorphic PHP, Isomorphic Blueprints #214
Conversation
6650dcb
to
2b11f8c
Compare
packages/nx-extensions/src/executors/assert-built-esm-and-cjs/executor.ts
Outdated
Show resolved
Hide resolved
packages/nx-extensions/src/executors/assert-built-esm-and-cjs/executor.ts
Outdated
Show resolved
Hide resolved
packages/nx-extensions/src/executors/assert-built-esm-and-cjs/executor.ts
Outdated
Show resolved
Hide resolved
packages/playground/blueprints/src/lib/steps/define-site-url.ts
Outdated
Show resolved
Hide resolved
packages/playground/blueprints/src/lib/steps/run-wp-installation-wizard.ts
Show resolved
Hide resolved
@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! |
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/blueprints
package that depends on@php-wasm/universal
which is also isomorphic.In other words, step handlers such as
login(playground)
used to require aPlaygroundClient
instance, but now they can work with aUniversalPHP
instance defined as follows:UniversalPHP
is 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/universal
also provides a reference implementation ofUniversalPHP
calledBasePHP
.BasePHP
cannot be used directly. Instead, platform-specific packages@php-wasm/web
and@php-wasm/node
provide platform-specific implementations. The former exportsWebPHP
, which loads files usingfetch()
, and the latter exportsNodePHP
, which reads data directly from the host filesystem. Both implement theUniversalPHP
interface and can be used with any Blueprint step.Other notes
@php-wasm/universal
,@wp-playground/client
, and@wp-playground/blueprints
are published as isomorphic ESM/CJS packages.@php-wasm/node
is published as CJS only for now.Follow-up work
@wp-playground/blueprints
will need to be smart about providing a Node.js polyfill fornew DOMParser()
andfetch()
.