@wp-playground/client 0.1.46 → 0.1.49
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/blueprint-schema.json +8 -4
- package/index.d.ts +366 -19
- package/package.json +2 -2
package/blueprint-schema.json
CHANGED
|
@@ -646,10 +646,12 @@
|
|
|
646
646
|
},
|
|
647
647
|
"step": {
|
|
648
648
|
"type": "string",
|
|
649
|
-
"const": "runPHP"
|
|
649
|
+
"const": "runPHP",
|
|
650
|
+
"description": "The step identifier."
|
|
650
651
|
},
|
|
651
652
|
"code": {
|
|
652
|
-
"type": "string"
|
|
653
|
+
"type": "string",
|
|
654
|
+
"description": "The PHP code to run."
|
|
653
655
|
}
|
|
654
656
|
},
|
|
655
657
|
"required": [
|
|
@@ -766,11 +768,13 @@
|
|
|
766
768
|
},
|
|
767
769
|
"step": {
|
|
768
770
|
"type": "string",
|
|
769
|
-
"const": "setSiteOptions"
|
|
771
|
+
"const": "setSiteOptions",
|
|
772
|
+
"description": "The name of the step. Must be \"setSiteOptions\"."
|
|
770
773
|
},
|
|
771
774
|
"options": {
|
|
772
775
|
"type": "object",
|
|
773
|
-
"additionalProperties": {}
|
|
776
|
+
"additionalProperties": {},
|
|
777
|
+
"description": "The options to set on the site."
|
|
774
778
|
}
|
|
775
779
|
},
|
|
776
780
|
"required": [
|
package/index.d.ts
CHANGED
|
@@ -259,7 +259,33 @@ export interface RequestHandler {
|
|
|
259
259
|
/**
|
|
260
260
|
* Serves the request – either by serving a static file, or by
|
|
261
261
|
* dispatching it to the PHP runtime.
|
|
262
|
-
*
|
|
262
|
+
*
|
|
263
|
+
* The request() method mode behaves like a web server and only works if
|
|
264
|
+
* the PHP was initialized with a `requestHandler` option (which the online version
|
|
265
|
+
* of WordPress Playground does by default).
|
|
266
|
+
*
|
|
267
|
+
* In the request mode, you pass an object containing the request information
|
|
268
|
+
* (method, headers, body, etc.) and the path to the PHP file to run:
|
|
269
|
+
*
|
|
270
|
+
* ```ts
|
|
271
|
+
* const php = PHP.load('7.4', {
|
|
272
|
+
* requestHandler: {
|
|
273
|
+
* documentRoot: "/www"
|
|
274
|
+
* }
|
|
275
|
+
* })
|
|
276
|
+
* php.writeFile("/www/index.php", `<?php echo file_get_contents("php://input");`);
|
|
277
|
+
* const result = await php.run({
|
|
278
|
+
* method: "GET",
|
|
279
|
+
* headers: {
|
|
280
|
+
* "Content-Type": "text/plain"
|
|
281
|
+
* },
|
|
282
|
+
* body: "Hello world!",
|
|
283
|
+
* path: "/www/index.php"
|
|
284
|
+
* });
|
|
285
|
+
* // result.text === "Hello world!"
|
|
286
|
+
* ```
|
|
287
|
+
*
|
|
288
|
+
* The `request()` method cannot be used in conjunction with `cli()`.
|
|
263
289
|
*
|
|
264
290
|
* @example
|
|
265
291
|
* ```js
|
|
@@ -306,7 +332,18 @@ export interface RequestHandler {
|
|
|
306
332
|
documentRoot: string;
|
|
307
333
|
}
|
|
308
334
|
export interface IsomorphicLocalPHP extends RequestHandler {
|
|
335
|
+
/**
|
|
336
|
+
* Sets the path to the php.ini file to use for the PHP instance.
|
|
337
|
+
*
|
|
338
|
+
* @param path - The path to the php.ini file.
|
|
339
|
+
*/
|
|
309
340
|
setPhpIniPath(path: string): void;
|
|
341
|
+
/**
|
|
342
|
+
* Sets a value for a specific key in the php.ini file for the PHP instance.
|
|
343
|
+
*
|
|
344
|
+
* @param key - The key to set the value for.
|
|
345
|
+
* @param value - The value to set for the key.
|
|
346
|
+
*/
|
|
310
347
|
setPhpIniEntry(key: string, value: string): void;
|
|
311
348
|
/**
|
|
312
349
|
* Recursively creates a directory with the given path in the PHP filesystem.
|
|
@@ -398,24 +435,72 @@ export interface IsomorphicLocalPHP extends RequestHandler {
|
|
|
398
435
|
chdir(path: string): void;
|
|
399
436
|
/**
|
|
400
437
|
* Runs PHP code.
|
|
401
|
-
* Cannot be used in conjunction with `cli()`.
|
|
402
438
|
*
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
*
|
|
439
|
+
* This low-level method directly interacts with the WebAssembly
|
|
440
|
+
* PHP interpreter.
|
|
441
|
+
*
|
|
442
|
+
* Every time you call run(), it prepares the PHP
|
|
443
|
+
* environment and:
|
|
444
|
+
*
|
|
445
|
+
* * Resets the internal PHP state
|
|
446
|
+
* * Populates superglobals ($_SERVER, $_GET, etc.)
|
|
447
|
+
* * Handles file uploads
|
|
448
|
+
* * Populates input streams (stdin, argv, etc.)
|
|
449
|
+
* * Sets the current working directory
|
|
450
|
+
*
|
|
451
|
+
* You can use run() in two primary modes:
|
|
452
|
+
*
|
|
453
|
+
* ### Code snippet mode
|
|
454
|
+
*
|
|
455
|
+
* In this mode, you pass a string containing PHP code to run.
|
|
456
|
+
*
|
|
457
|
+
* ```ts
|
|
458
|
+
* const result = await php.run({
|
|
459
|
+
* code: `<?php echo "Hello world!";`
|
|
460
|
+
* });
|
|
461
|
+
* // result.text === "Hello world!"
|
|
407
462
|
* ```
|
|
408
463
|
*
|
|
464
|
+
* In this mode, information like __DIR__ or __FILE__ isn't very
|
|
465
|
+
* useful because the code is not associated with any file.
|
|
466
|
+
*
|
|
467
|
+
* Under the hood, the PHP snippet is passed to the `zend_eval_string`
|
|
468
|
+
* C function.
|
|
469
|
+
*
|
|
470
|
+
* ### File mode
|
|
471
|
+
*
|
|
472
|
+
* In the file mode, you pass a scriptPath and PHP executes a file
|
|
473
|
+
* found at a that path:
|
|
474
|
+
*
|
|
475
|
+
* ```ts
|
|
476
|
+
* php.writeFile(
|
|
477
|
+
* "/www/index.php",
|
|
478
|
+
* `<?php echo "Hello world!";"`
|
|
479
|
+
* );
|
|
480
|
+
* const result = await php.run({
|
|
481
|
+
* scriptPath: "/www/index.php"
|
|
482
|
+
* });
|
|
483
|
+
* // result.text === "Hello world!"
|
|
484
|
+
* ```
|
|
485
|
+
*
|
|
486
|
+
* In this mode, you can rely on path-related information like __DIR__
|
|
487
|
+
* or __FILE__.
|
|
488
|
+
*
|
|
489
|
+
* Under the hood, the PHP file is executed with the `php_execute_script`
|
|
490
|
+
* C function.
|
|
491
|
+
*
|
|
492
|
+
* The `run()` method cannot be used in conjunction with `cli()`.
|
|
493
|
+
*
|
|
409
494
|
* @example
|
|
410
495
|
* ```js
|
|
411
|
-
*
|
|
496
|
+
* const result = await php.run(`<?php
|
|
412
497
|
* $fp = fopen('php://stderr', 'w');
|
|
413
498
|
* fwrite($fp, "Hello, world!");
|
|
414
|
-
* `)
|
|
415
|
-
* //
|
|
499
|
+
* `);
|
|
500
|
+
* // result.errors === "Hello, world!"
|
|
416
501
|
* ```
|
|
417
502
|
*
|
|
418
|
-
* @param options - PHP
|
|
503
|
+
* @param options - PHP runtime options.
|
|
419
504
|
*/
|
|
420
505
|
run(options: PHPRunOptions): Promise<PHPResponse>;
|
|
421
506
|
}
|
|
@@ -1152,70 +1237,287 @@ export interface WordPressInstallationOptions {
|
|
|
1152
1237
|
* @param options Installation options.
|
|
1153
1238
|
*/
|
|
1154
1239
|
export declare const runWpInstallationWizard: StepHandler<RunWpInstallationWizardStep>;
|
|
1240
|
+
/**
|
|
1241
|
+
* @inheritDoc setSiteOptions
|
|
1242
|
+
* @hasRunnableExample
|
|
1243
|
+
*
|
|
1244
|
+
* @example
|
|
1245
|
+
*
|
|
1246
|
+
* <code>
|
|
1247
|
+
* {
|
|
1248
|
+
* "step": "setSiteOptions",
|
|
1249
|
+
* "options": {
|
|
1250
|
+
* "blogname": "My Blog",
|
|
1251
|
+
* "blogdescription": "A great blog"
|
|
1252
|
+
* }
|
|
1253
|
+
* }
|
|
1254
|
+
* </code>
|
|
1255
|
+
*/
|
|
1155
1256
|
export type SetSiteOptionsStep = {
|
|
1257
|
+
/** The name of the step. Must be "setSiteOptions". */
|
|
1156
1258
|
step: "setSiteOptions";
|
|
1259
|
+
/** The options to set on the site. */
|
|
1157
1260
|
options: Record<string, unknown>;
|
|
1158
1261
|
};
|
|
1262
|
+
/**
|
|
1263
|
+
* Sets site options. This is equivalent to calling `update_option` for each
|
|
1264
|
+
* option in the `options` object.
|
|
1265
|
+
*/
|
|
1159
1266
|
export declare const setSiteOptions: StepHandler<SetSiteOptionsStep>;
|
|
1267
|
+
/**
|
|
1268
|
+
* @inheritDoc updateUserMeta
|
|
1269
|
+
* @hasRunnableExample
|
|
1270
|
+
*
|
|
1271
|
+
* @example
|
|
1272
|
+
*
|
|
1273
|
+
* <code>
|
|
1274
|
+
* {
|
|
1275
|
+
* "step": "updateUserMeta",
|
|
1276
|
+
* "meta": {
|
|
1277
|
+
* "first_name": "John",
|
|
1278
|
+
* "last_name": "Doe"
|
|
1279
|
+
* },
|
|
1280
|
+
* "userId": 1
|
|
1281
|
+
* }
|
|
1282
|
+
* </code>
|
|
1283
|
+
*/
|
|
1160
1284
|
export interface UpdateUserMetaStep {
|
|
1161
1285
|
step: "updateUserMeta";
|
|
1162
1286
|
meta: Record<string, unknown>;
|
|
1163
1287
|
userId: number;
|
|
1164
1288
|
}
|
|
1289
|
+
/**
|
|
1290
|
+
* Updates user meta. This is equivalent to calling `update_user_meta` for each
|
|
1291
|
+
* meta value in the `meta` object.
|
|
1292
|
+
*/
|
|
1165
1293
|
export declare const updateUserMeta: StepHandler<UpdateUserMetaStep>;
|
|
1294
|
+
/**
|
|
1295
|
+
* @inheritDoc runPHP
|
|
1296
|
+
* @hasRunnableExample
|
|
1297
|
+
* @example
|
|
1298
|
+
*
|
|
1299
|
+
* <code>
|
|
1300
|
+
* {
|
|
1301
|
+
* "step": "runPHP",
|
|
1302
|
+
* "code": "<?php echo 'Hello World'; ?>"
|
|
1303
|
+
* }
|
|
1304
|
+
* </code>
|
|
1305
|
+
*/
|
|
1166
1306
|
export interface RunPHPStep {
|
|
1307
|
+
/** The step identifier. */
|
|
1167
1308
|
step: "runPHP";
|
|
1309
|
+
/** The PHP code to run. */
|
|
1168
1310
|
code: string;
|
|
1169
1311
|
}
|
|
1312
|
+
/**
|
|
1313
|
+
* Runs PHP code.
|
|
1314
|
+
*/
|
|
1170
1315
|
export declare const runPHP: StepHandler<RunPHPStep>;
|
|
1316
|
+
/**
|
|
1317
|
+
* @inheritDoc runPHP
|
|
1318
|
+
* @hasRunnableExample
|
|
1319
|
+
* @example
|
|
1320
|
+
*
|
|
1321
|
+
* <code>
|
|
1322
|
+
* {
|
|
1323
|
+
* "step": "runPHP",
|
|
1324
|
+
* "options": {
|
|
1325
|
+
* "code": "<?php echo $_SERVER['HTTP_CONTENT_TYPE']; ?>",
|
|
1326
|
+
* "headers": {
|
|
1327
|
+
* "Content-type": "text/plain"
|
|
1328
|
+
* }
|
|
1329
|
+
* }
|
|
1330
|
+
* }
|
|
1331
|
+
* </code>
|
|
1332
|
+
*/
|
|
1171
1333
|
export interface RunPHPWithOptionsStep {
|
|
1172
1334
|
step: "runPHPWithOptions";
|
|
1173
1335
|
options: PHPRunOptions;
|
|
1174
1336
|
}
|
|
1337
|
+
/**
|
|
1338
|
+
* Runs PHP code with the given options.
|
|
1339
|
+
*/
|
|
1175
1340
|
export declare const runPHPWithOptions: StepHandler<RunPHPWithOptionsStep>;
|
|
1341
|
+
/**
|
|
1342
|
+
* @inheritDoc setPhpIniEntry
|
|
1343
|
+
* @hasRunnableExample
|
|
1344
|
+
* @example
|
|
1345
|
+
*
|
|
1346
|
+
* <code>
|
|
1347
|
+
* {
|
|
1348
|
+
* "step": "setPhpIniEntry",
|
|
1349
|
+
* "key": "display_errors",
|
|
1350
|
+
* "value": "1"
|
|
1351
|
+
* }
|
|
1352
|
+
* </code>
|
|
1353
|
+
*/
|
|
1176
1354
|
export interface SetPhpIniEntryStep {
|
|
1177
1355
|
step: "setPhpIniEntry";
|
|
1178
1356
|
key: string;
|
|
1179
1357
|
value: string;
|
|
1180
1358
|
}
|
|
1359
|
+
/**
|
|
1360
|
+
* Sets a PHP ini entry.
|
|
1361
|
+
*/
|
|
1181
1362
|
export declare const setPhpIniEntry: StepHandler<SetPhpIniEntryStep>;
|
|
1363
|
+
/**
|
|
1364
|
+
* @inheritDoc request
|
|
1365
|
+
* @needsLogin
|
|
1366
|
+
* @hasRunnableExample
|
|
1367
|
+
* @example
|
|
1368
|
+
*
|
|
1369
|
+
* <code>
|
|
1370
|
+
* {
|
|
1371
|
+
* "step": "request",
|
|
1372
|
+
* "request": {
|
|
1373
|
+
* "method": "POST",
|
|
1374
|
+
* "url": "/wp-admin/admin-ajax.php",
|
|
1375
|
+
* "formData": {
|
|
1376
|
+
* "action": "my_action",
|
|
1377
|
+
* "foo": "bar"
|
|
1378
|
+
* }
|
|
1379
|
+
* }
|
|
1380
|
+
* }
|
|
1381
|
+
* </code>
|
|
1382
|
+
*/
|
|
1182
1383
|
export interface RequestStep {
|
|
1183
1384
|
step: "request";
|
|
1184
1385
|
request: PHPRequest;
|
|
1185
1386
|
}
|
|
1387
|
+
/**
|
|
1388
|
+
* Sends a HTTP request to the Playground.
|
|
1389
|
+
*/
|
|
1186
1390
|
export declare const request: StepHandler<RequestStep>;
|
|
1391
|
+
/**
|
|
1392
|
+
* @inheritDoc cp
|
|
1393
|
+
* @hasRunnableExample
|
|
1394
|
+
* @landingPage /index2.php
|
|
1395
|
+
* @example
|
|
1396
|
+
*
|
|
1397
|
+
* <code>
|
|
1398
|
+
* {
|
|
1399
|
+
* "step": "cp",
|
|
1400
|
+
* "fromPath": "/wordpress/index.php",
|
|
1401
|
+
* "toPath": "/wordpress/index2.php"
|
|
1402
|
+
* }
|
|
1403
|
+
* </code>
|
|
1404
|
+
*/
|
|
1187
1405
|
export interface CpStep {
|
|
1188
1406
|
step: "cp";
|
|
1189
1407
|
fromPath: string;
|
|
1190
1408
|
toPath: string;
|
|
1191
1409
|
}
|
|
1410
|
+
/**
|
|
1411
|
+
* Copies a file from one path to another.
|
|
1412
|
+
*/
|
|
1192
1413
|
export declare const cp: StepHandler<CpStep>;
|
|
1414
|
+
/**
|
|
1415
|
+
* @inheritDoc mv
|
|
1416
|
+
* @hasRunnableExample
|
|
1417
|
+
* @landingPage /index2.php
|
|
1418
|
+
* @example
|
|
1419
|
+
*
|
|
1420
|
+
* <code>
|
|
1421
|
+
* {
|
|
1422
|
+
* "step": "mv",
|
|
1423
|
+
* "fromPath": "/wordpress/index.php",
|
|
1424
|
+
* "toPath": "/wordpress/index2.php"
|
|
1425
|
+
* }
|
|
1426
|
+
* </code>
|
|
1427
|
+
*/
|
|
1193
1428
|
export interface MvStep {
|
|
1194
1429
|
step: "mv";
|
|
1195
1430
|
fromPath: string;
|
|
1196
1431
|
toPath: string;
|
|
1197
1432
|
}
|
|
1433
|
+
/**
|
|
1434
|
+
* Moves a file or directory from one path to another.
|
|
1435
|
+
*/
|
|
1198
1436
|
export declare const mv: StepHandler<MvStep>;
|
|
1437
|
+
/**
|
|
1438
|
+
* @inheritDoc mkdir
|
|
1439
|
+
* @hasRunnableExample
|
|
1440
|
+
* @example
|
|
1441
|
+
*
|
|
1442
|
+
* <code>
|
|
1443
|
+
* {
|
|
1444
|
+
* "step": "mkdir",
|
|
1445
|
+
* "path": "/wordpress/my-new-folder"
|
|
1446
|
+
* }
|
|
1447
|
+
* </code>
|
|
1448
|
+
*/
|
|
1199
1449
|
export interface MkdirStep {
|
|
1200
1450
|
step: "mkdir";
|
|
1201
1451
|
path: string;
|
|
1202
1452
|
}
|
|
1453
|
+
/**
|
|
1454
|
+
* Creates a directory at the specified path.
|
|
1455
|
+
*/
|
|
1203
1456
|
export declare const mkdir: StepHandler<MkdirStep>;
|
|
1457
|
+
/**
|
|
1458
|
+
* @inheritDoc rm
|
|
1459
|
+
* @hasRunnableExample
|
|
1460
|
+
* @landingPage /index.php
|
|
1461
|
+
* @example
|
|
1462
|
+
*
|
|
1463
|
+
* <code>
|
|
1464
|
+
* {
|
|
1465
|
+
* "step": "rm",
|
|
1466
|
+
* "path": "/wordpress/index.php"
|
|
1467
|
+
* }
|
|
1468
|
+
* </code>
|
|
1469
|
+
*/
|
|
1204
1470
|
export interface RmStep {
|
|
1205
1471
|
step: "rm";
|
|
1206
1472
|
path: string;
|
|
1207
1473
|
}
|
|
1474
|
+
/**
|
|
1475
|
+
* Removes a file at the specified path.
|
|
1476
|
+
*/
|
|
1208
1477
|
export declare const rm: StepHandler<RmStep>;
|
|
1478
|
+
/**
|
|
1479
|
+
* @inheritDoc rmdir
|
|
1480
|
+
* @hasRunnableExample
|
|
1481
|
+
* @landingPage /wp-admin/
|
|
1482
|
+
* @example
|
|
1483
|
+
*
|
|
1484
|
+
* <code>
|
|
1485
|
+
* {
|
|
1486
|
+
* "step": "rm",
|
|
1487
|
+
* "path": "/wordpress/wp-admin"
|
|
1488
|
+
* }
|
|
1489
|
+
* </code>
|
|
1490
|
+
*/
|
|
1209
1491
|
export interface RmdirStep {
|
|
1210
1492
|
step: "rmdir";
|
|
1211
1493
|
path: string;
|
|
1212
1494
|
}
|
|
1495
|
+
/**
|
|
1496
|
+
* Removes a directory at the specified path.
|
|
1497
|
+
*/
|
|
1213
1498
|
export declare const rmdir: StepHandler<RmdirStep>;
|
|
1499
|
+
/**
|
|
1500
|
+
* @inheritDoc writeFile
|
|
1501
|
+
* @hasRunnableExample
|
|
1502
|
+
* @landingPage /test.php
|
|
1503
|
+
* @example
|
|
1504
|
+
*
|
|
1505
|
+
* <code>
|
|
1506
|
+
* {
|
|
1507
|
+
* "step": "writeFile",
|
|
1508
|
+
* "path": "/wordpress/test.php",
|
|
1509
|
+
* "data": "<?php echo 'Hello World!'; ?>"
|
|
1510
|
+
* }
|
|
1511
|
+
* </code>
|
|
1512
|
+
*/
|
|
1214
1513
|
export interface WriteFileStep<ResourceType> {
|
|
1215
1514
|
step: "writeFile";
|
|
1216
1515
|
path: string;
|
|
1217
1516
|
data: ResourceType | string | Uint8Array;
|
|
1218
1517
|
}
|
|
1518
|
+
/**
|
|
1519
|
+
* Writes data to a file at the specified path.
|
|
1520
|
+
*/
|
|
1219
1521
|
export declare const writeFile: StepHandler<WriteFileStep<File>>;
|
|
1220
1522
|
/**
|
|
1221
1523
|
* The step object for defining constants in the wp-config.php file of a WordPress installation.
|
|
@@ -1268,6 +1570,10 @@ export type StepDefinition = Step & {
|
|
|
1268
1570
|
caption?: string;
|
|
1269
1571
|
};
|
|
1270
1572
|
};
|
|
1573
|
+
/**
|
|
1574
|
+
* If you add a step here, make sure to also
|
|
1575
|
+
* add it to the exports below.
|
|
1576
|
+
*/
|
|
1271
1577
|
export type GenericStep<Resource> = ActivatePluginStep | ActivateThemeStep | ApplyWordPressPatchesStep | CpStep | DefineWpConfigConstsStep | DefineVirtualWpConfigConstsStep | DefineSiteUrlStep | ImportFileStep<Resource> | InstallPluginStep<Resource> | InstallThemeStep<Resource> | LoginStep | MkdirStep | MvStep | RequestStep | ReplaceSiteStep<Resource> | RmStep | RmdirStep | RunPHPStep | RunPHPWithOptionsStep | RunWpInstallationWizardStep | SetPhpIniEntryStep | SetSiteOptionsStep | UnzipStep | UpdateUserMetaStep | WriteFileStep<Resource>;
|
|
1272
1578
|
export type StepHandler<S extends GenericStep<File>> = (
|
|
1273
1579
|
/**
|
|
@@ -1354,7 +1660,7 @@ export type WithAPIState = {
|
|
|
1354
1660
|
*/
|
|
1355
1661
|
isReady: () => Promise<void>;
|
|
1356
1662
|
};
|
|
1357
|
-
export type RemoteAPI<T> = Comlink.Remote<T & WithAPIState
|
|
1663
|
+
export type RemoteAPI<T> = Comlink.Remote<T> & WithAPIState;
|
|
1358
1664
|
export interface PHPWebLoaderOptions {
|
|
1359
1665
|
emscriptenOptions?: EmscriptenOptions;
|
|
1360
1666
|
downloadMonitor?: EmscriptenDownloadMonitor;
|
|
@@ -1389,20 +1695,23 @@ declare class WebPHP extends BasePHP {
|
|
|
1389
1695
|
};
|
|
1390
1696
|
}
|
|
1391
1697
|
declare class WebPHPEndpoint implements IsomorphicLocalPHP {
|
|
1392
|
-
/** @inheritDoc */
|
|
1698
|
+
/** @inheritDoc @php-wasm/universal!RequestHandler.absoluteUrl */
|
|
1393
1699
|
absoluteUrl: string;
|
|
1394
|
-
/** @inheritDoc */
|
|
1700
|
+
/** @inheritDoc @php-wasm/universal!RequestHandler.documentRoot */
|
|
1395
1701
|
documentRoot: string;
|
|
1396
1702
|
/** @inheritDoc */
|
|
1397
1703
|
constructor(php: BasePHP, monitor?: EmscriptenDownloadMonitor);
|
|
1398
|
-
/** @inheritDoc */
|
|
1704
|
+
/** @inheritDoc @php-wasm/universal!RequestHandler.pathToInternalUrl */
|
|
1399
1705
|
pathToInternalUrl(path: string): string;
|
|
1400
|
-
/** @inheritDoc */
|
|
1706
|
+
/** @inheritDoc @php-wasm/universal!RequestHandler.internalUrlToPath */
|
|
1401
1707
|
internalUrlToPath(internalUrl: string): string;
|
|
1708
|
+
/**
|
|
1709
|
+
* The onDownloadProgress event listener.
|
|
1710
|
+
*/
|
|
1402
1711
|
onDownloadProgress(callback: (progress: CustomEvent<ProgressEvent>) => void): Promise<void>;
|
|
1403
|
-
/** @inheritDoc */
|
|
1712
|
+
/** @inheritDoc @php-wasm/universal!IsomorphicLocalPHP.mv */
|
|
1404
1713
|
mv(fromPath: string, toPath: string): void;
|
|
1405
|
-
/** @inheritDoc */
|
|
1714
|
+
/** @inheritDoc @php-wasm/universal!IsomorphicLocalPHP.rmdir */
|
|
1406
1715
|
rmdir(path: string, options?: RmDirOptions): void;
|
|
1407
1716
|
/** @inheritDoc @php-wasm/universal!RequestHandler.request */
|
|
1408
1717
|
request(request: PHPRequest, redirects?: number): Promise<PHPResponse>;
|
|
@@ -1434,10 +1743,22 @@ declare class WebPHPEndpoint implements IsomorphicLocalPHP {
|
|
|
1434
1743
|
fileExists(path: string): boolean;
|
|
1435
1744
|
}
|
|
1436
1745
|
declare class PlaygroundWorkerEndpoint extends WebPHPEndpoint {
|
|
1746
|
+
/**
|
|
1747
|
+
* A string representing the scope of the Playground instance.
|
|
1748
|
+
*/
|
|
1437
1749
|
scope: string;
|
|
1750
|
+
/**
|
|
1751
|
+
* A string representing the version of WordPress being used.
|
|
1752
|
+
*/
|
|
1438
1753
|
wordPressVersion: string;
|
|
1754
|
+
/**
|
|
1755
|
+
* A string representing the version of PHP being used.
|
|
1756
|
+
*/
|
|
1439
1757
|
phpVersion: string;
|
|
1440
1758
|
constructor(php: WebPHP, monitor: EmscriptenDownloadMonitor, scope: string, wordPressVersion: string, phpVersion: string);
|
|
1759
|
+
/**
|
|
1760
|
+
* @returns WordPress module details, including the static assets directory and default theme.
|
|
1761
|
+
*/
|
|
1441
1762
|
getWordPressModuleDetails(): Promise<{
|
|
1442
1763
|
staticAssetsDirectory: string;
|
|
1443
1764
|
defaultTheme: any;
|
|
@@ -1450,18 +1771,44 @@ export interface ProgressBarOptions {
|
|
|
1450
1771
|
visible?: boolean;
|
|
1451
1772
|
}
|
|
1452
1773
|
export interface WebClientMixin extends ProgressReceiver {
|
|
1774
|
+
/**
|
|
1775
|
+
* Sets the progress bar options.
|
|
1776
|
+
* @param options The progress bar options.
|
|
1777
|
+
*/
|
|
1453
1778
|
setProgress(options: ProgressBarOptions): Promise<void>;
|
|
1779
|
+
/**
|
|
1780
|
+
* Sets the loaded state.
|
|
1781
|
+
*/
|
|
1454
1782
|
setLoaded(): Promise<void>;
|
|
1783
|
+
/**
|
|
1784
|
+
* Sets the navigation event listener.
|
|
1785
|
+
* @param fn The function to be called when a navigation event occurs.
|
|
1786
|
+
*/
|
|
1455
1787
|
onNavigation(fn: (url: string) => void): Promise<void>;
|
|
1788
|
+
/**
|
|
1789
|
+
* Navigates to the requested path.
|
|
1790
|
+
* @param requestedPath The requested path.
|
|
1791
|
+
*/
|
|
1456
1792
|
goTo(requestedPath: string): Promise<void>;
|
|
1793
|
+
/**
|
|
1794
|
+
* Gets the current URL.
|
|
1795
|
+
*/
|
|
1457
1796
|
getCurrentURL(): Promise<string>;
|
|
1797
|
+
/**
|
|
1798
|
+
* Sets the iframe sandbox flags.
|
|
1799
|
+
* @param flags The iframe sandbox flags.
|
|
1800
|
+
*/
|
|
1458
1801
|
setIframeSandboxFlags(flags: string[]): Promise<void>;
|
|
1802
|
+
/**
|
|
1803
|
+
* The onDownloadProgress event listener.
|
|
1804
|
+
*/
|
|
1459
1805
|
onDownloadProgress: PlaygroundWorkerEndpoint["onDownloadProgress"];
|
|
1460
1806
|
}
|
|
1461
1807
|
/**
|
|
1462
|
-
*
|
|
1808
|
+
* The Playground Client interface.
|
|
1463
1809
|
*/
|
|
1464
|
-
export
|
|
1810
|
+
export interface PlaygroundClient extends RemoteAPI<PlaygroundWorkerEndpoint & WebClientMixin> {
|
|
1811
|
+
}
|
|
1465
1812
|
export interface StartPlaygroundOptions {
|
|
1466
1813
|
iframe: HTMLIFrameElement;
|
|
1467
1814
|
remoteUrl: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-playground/client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.49",
|
|
4
4
|
"description": "WordPress Playground client",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"main": "./index.cjs",
|
|
38
38
|
"module": "./index.js",
|
|
39
39
|
"types": "index.d.ts",
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "93834fa77a89c21be2ade4c1d67430981ed92c83"
|
|
41
41
|
}
|