Skip to content
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

Add network support via fetch() #724

Merged
merged 15 commits into from Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/docs/site/docs/08-query-api/01-index.md
Expand Up @@ -24,8 +24,9 @@ You can go ahead and try it out. The Playground will automatically install the t
| Option | Default Value | Description |
| ---------------------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `php` | `8.0` | Loads the specified PHP version. Supported values: `5.6`, `7.0`, `7.1`, `7.2`, `7.3`, `7.4`, `8.0`, `8.1`, `8.2`, `latest` |
| `wp` | `latest` | Loads the specified WordPress version. Supported values: `5.9`, `6.0`, `6.1`, `6.2`, `6.3`, `latest`, `nightly`, `beta` |
| `wp` | `latest` | Loads the specified WordPress version. Supported values: `5.9`, `6.0`, `6.1`, `6.2`, `6.3`, `latest`, `nightly`, `beta` |
| `php-extension-bundle` | | Loads a bundle of PHP extensions. Supported bundles: `kitchen-sink` (for gd, mbstring, iconv, libxml, xml, dom, simplexml, xmlreader, xmlwriter) |
| `networking` | `yes` or `no` | Enables or disables the networking support for Playground. Defaults to `yes` |
| `plugin` | | Installs the specified plugin. Use the plugin name from the plugins directory URL, e.g. for a URL like `https://wordpress.org/plugins/wp-lazy-loading/`, the plugin name would be `wp-lazy-loading`. You can pre-install multiple plugins by saying `plugin=coblocks&plugin=wp-lazy-loading&…`. Installing a plugin automatically logs the user in as an admin |
| `theme` | | Installs the specified theme. Use the theme name from the themes directory URL, e.g. for a URL like `https://wordpress.org/themes/disco/`, the theme name would be `disco`. Installing a theme automatically logs the user in as an admin |
| `url` | `/wp-admin/` | Load the specified initial page displaying WordPress |
Expand Down
9 changes: 9 additions & 0 deletions packages/docs/site/docs/09-blueprints-api/03-data-format.md
Expand Up @@ -22,6 +22,9 @@ import BlueprintExample from '@site/src/components/Blueprints/BlueprintExample.m
"wp": "5.9"
},
"phpExtensionBundles": ["kitchen-sink"],
"features": {
"networking": true
},
"steps": [
{
"step": "login",
Expand Down Expand Up @@ -55,3 +58,9 @@ The `preferredVersions` property, unsurprisingly, declares the preferred of PHP
The `phpExtensionBundles` property is an array of PHP extension bundles to load. The following bundles are supported:

- `kitchen-sink`: Installs `gd`, `mbstring`, `iconv`, `libxml`, `xml`, `dom`, `simplexml`, `xmlreader`, `xmlwriter`

## Features

The `features` property is used to enable or disable certain features of the Playground. It can contain the following properties:

- `networking`: Defaults to `true`. Enables or disables the networking support for Playground. If enabled, `wp_safe_remote_get` and similar WordPress functions will actually use `fetch()` to make HTTP requests. If disabled, they will immediately fail instead.
2 changes: 1 addition & 1 deletion packages/php-wasm/universal/src/lib/universal-php.ts
Expand Up @@ -416,7 +416,7 @@ export interface IsomorphicLocalPHP extends RequestHandler {

export type MessageListener = (
data: string
) => Promise<string> | Promise<Uint8Array> | Promise<void> | string | void;
) => Promise<string | Uint8Array | void> | string | void;
interface EventEmitter {
on(event: string, listener: (...args: any[]) => void): this;
emit(event: string, ...args: any[]): boolean;
Expand Down