@wp-playground/client 0.9.24 → 0.9.26
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/index.cjs +1 -1
- package/index.d.ts +38 -2722
- package/index.js +1 -2
- package/package.json +54 -43
- package/README.md +0 -42
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,45 +1,56 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
2
|
+
"name": "@wp-playground/client",
|
|
3
|
+
"version": "0.9.26",
|
|
4
|
+
"description": "WordPress Playground client",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/WordPress/wordpress-playground"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://developer.wordpress.org/playground",
|
|
10
|
+
"author": "The WordPress contributors",
|
|
11
|
+
"contributors": [
|
|
12
|
+
{
|
|
13
|
+
"name": "Adam Zielinski",
|
|
14
|
+
"email": "adam@adamziel.com",
|
|
15
|
+
"url": "https://github.com/adamziel"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"import": "./index.js",
|
|
21
|
+
"require": "./index.cjs"
|
|
22
|
+
},
|
|
23
|
+
"./package.json": "./package.json"
|
|
24
|
+
},
|
|
25
|
+
"typedoc": {
|
|
26
|
+
"entryPoint": "./src/index.ts",
|
|
27
|
+
"readmeFile": "./README.md",
|
|
28
|
+
"displayName": "@wp-playground/client",
|
|
29
|
+
"tsconfig": "./tsconfig.lib.json"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public",
|
|
33
|
+
"directory": "../../../dist/packages/playground/client"
|
|
34
|
+
},
|
|
35
|
+
"license": "GPL-2.0-or-later",
|
|
36
|
+
"type": "module",
|
|
37
|
+
"main": "./index.cjs",
|
|
38
|
+
"module": "./index.js",
|
|
39
|
+
"types": "index.d.ts",
|
|
40
|
+
"gitHead": "03453bf7ca06857dc31c496ded43ca2857023021",
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=18.18.0",
|
|
43
|
+
"npm": ">=8.11.0"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"ajv": "8.12.0",
|
|
47
|
+
"comlink": "^4.4.1",
|
|
48
|
+
"ini": "4.1.2",
|
|
49
|
+
"@wp-playground/blueprints": "0.9.26",
|
|
50
|
+
"@php-wasm/universal": "0.9.26",
|
|
51
|
+
"@php-wasm/util": "0.9.26",
|
|
52
|
+
"@php-wasm/web": "0.9.26",
|
|
53
|
+
"@php-wasm/progress": "0.9.26",
|
|
54
|
+
"@php-wasm/logger": "0.9.26"
|
|
55
|
+
}
|
|
45
56
|
}
|
package/README.md
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# Playground Client
|
|
2
|
-
|
|
3
|
-
Provides a [PlaygroundClient](https://wordpress.github.io/wordpress-playground/api/client/) that can be used to control a WordPress Playground iframe:
|
|
4
|
-
|
|
5
|
-
```ts
|
|
6
|
-
import { startPlaygroundWeb } from '@wp-playground/client';
|
|
7
|
-
|
|
8
|
-
const client = await startPlaygroundWeb({
|
|
9
|
-
// An iframe pointing to https://playground.wordpress.net/remote.html:
|
|
10
|
-
iframe: document.getElementById('wp'),
|
|
11
|
-
remoteUrl: `https://playground.wordpress.net/remote.html`,
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
const response = await client.run({
|
|
15
|
-
// wp-load.php is only required if you want to interact with WordPress.
|
|
16
|
-
code: '<?php require_once "/wordpress/wp-load.php"; $posts = get_posts(); echo "Post Title: " . $posts[0]->post_title;',
|
|
17
|
-
});
|
|
18
|
-
console.log(response.text);
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Using TypeScript is highly recommended as this package ships with comprehensive types – hit ctrl+space in your IDE after `client.` and you'll see all the available methods.
|
|
22
|
-
|
|
23
|
-
Once you have a [PlaygroundClient](https://wordpress.github.io/wordpress-playground/api/client/) instance, you can use it to control the playground:
|
|
24
|
-
|
|
25
|
-
```ts
|
|
26
|
-
await client.writeFile('/index.php', '<?php echo "Hi!"; ');
|
|
27
|
-
await client.run({
|
|
28
|
-
scriptPath: '/index.php',
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
console.log(await client.readFileAsText('/index.php'));
|
|
32
|
-
|
|
33
|
-
await client.request({
|
|
34
|
-
url: '/index.php',
|
|
35
|
-
method: 'POST',
|
|
36
|
-
body: {
|
|
37
|
-
foo: 'bar',
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
To see all the available methods, check out the [PlaygroundClient](https://wordpress.github.io/wordpress-playground/api/client/) interface.
|