@wp-playground/client 3.1.21 → 3.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -4
- package/index.cjs +78 -67
- package/index.d.ts +5531 -84
- package/index.js +5354 -5193
- package/package.json +3 -2
- package/blueprints-v1-handler.d.ts +0 -7
- package/blueprints-v2-handler.d.ts +0 -7
package/README.md
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
# Playground Client
|
|
2
2
|
|
|
3
|
-
Provides a [PlaygroundClient](https://wordpress.github.io/wordpress-playground/api/client/) that can be used to control a WordPress Playground iframe
|
|
3
|
+
Provides a [PlaygroundClient](https://wordpress.github.io/wordpress-playground/api/client/) that can be used to control a WordPress Playground iframe.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
In browser applications, consume the client over HTTP from the same Playground deployment that serves `remote.html`:
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import { startPlaygroundWeb } from 'https://playground.wordpress.net/client/index.js';
|
|
7
9
|
|
|
8
10
|
const client = await startPlaygroundWeb({
|
|
9
11
|
// An iframe pointing to https://playground.wordpress.net/remote.html:
|
|
@@ -18,7 +20,25 @@ const response = await client.run({
|
|
|
18
20
|
console.log(response.text);
|
|
19
21
|
```
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
Loading the client from `https://playground.wordpress.net/client/index.js` keeps it in sync with the remote Playground runtime. The client and the iframe communicate over an internal protocol, and backwards compatibility is guaranteed by serving a matching client and remote from the same deployment.
|
|
24
|
+
|
|
25
|
+
## npm package
|
|
26
|
+
|
|
27
|
+
The npm package exists for projects that want to install `@wp-playground/client` through a package manager, bundle it with their application, or use its TypeScript declarations locally.
|
|
28
|
+
|
|
29
|
+
Prefer the direct `https://playground.wordpress.net/client/index.js` import for browser applications that use the hosted Playground runtime. An npm-installed client can drift from the `remote.html` it controls, and that may expose protocol mismatches between the parent page and iframe. If you use the npm package, make sure the client and remote runtime are versioned together.
|
|
30
|
+
|
|
31
|
+
The npm package ships comprehensive types for the client API. In TypeScript, your editor can show the available methods after `client.`.
|
|
32
|
+
|
|
33
|
+
## TypeScript declarations
|
|
34
|
+
|
|
35
|
+
The published npm package ships one bundled declaration file, `index.d.ts`. That file is generated from `src/index.ts` and inlines the Playground and PHP-WASM types that are reachable from the public client API.
|
|
36
|
+
|
|
37
|
+
This is intentional. `@wp-playground/client` exposes types such as Blueprints, PHP responses, mounts, and filesystem options that are implemented across several packages in this monorepo. Consumers should not need to install or resolve those internal workspace packages just to type-check code that imports `@wp-playground/client`.
|
|
38
|
+
|
|
39
|
+
The build verifies this by checking that the published package contains a single declaration file and that `index.d.ts` does not import from other packages.
|
|
40
|
+
|
|
41
|
+
Known limitation: The bundled declarations are not yet guaranteed to pass `skipLibCheck: false` in every TypeScript and DOM library combination. The rollup includes lower-level Playground APIs, and strict declaration checking may still surface environment-specific type issues such as Node `Buffer` references or `File.stream()` compatibility. These issues do not affect the usual `PlaygroundClient` API usage.
|
|
22
42
|
|
|
23
43
|
Once you have a [PlaygroundClient](https://wordpress.github.io/wordpress-playground/api/client/) instance, you can use it to control the playground:
|
|
24
44
|
|