@wp-playground/client 0.7.18 → 0.7.20
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 +131 -108
- package/index.d.ts +27 -39
- package/index.js +2508 -2338
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -265,19 +265,6 @@ export interface IsomorphicLocalPHP {
|
|
|
265
265
|
* @param listener - The listener function to be removed.
|
|
266
266
|
*/
|
|
267
267
|
removeEventListener(eventType: PHPEvent["type"], listener: PHPEventListener): void;
|
|
268
|
-
/**
|
|
269
|
-
* Sets the path to the php.ini file to use for the PHP instance.
|
|
270
|
-
*
|
|
271
|
-
* @param path - The path to the php.ini file.
|
|
272
|
-
*/
|
|
273
|
-
setPhpIniPath(path: string): void;
|
|
274
|
-
/**
|
|
275
|
-
* Sets a value for a specific key in the php.ini file for the PHP instance.
|
|
276
|
-
*
|
|
277
|
-
* @param key - The key to set the value for.
|
|
278
|
-
* @param value - The value to set for the key.
|
|
279
|
-
*/
|
|
280
|
-
setPhpIniEntry(key: string, value: string): void;
|
|
281
268
|
/**
|
|
282
269
|
* Recursively creates a directory with the given path in the PHP filesystem.
|
|
283
270
|
* For example, if the path is `/root/php/data`, and `/root` already exists,
|
|
@@ -494,7 +481,7 @@ export type SpawnHandler = (command: string, args: string[]) => ChildProcess;
|
|
|
494
481
|
* that can't be serialized over a remote connection. Therefeore,
|
|
495
482
|
* they don't make sense in a remote PHP instance.
|
|
496
483
|
*/
|
|
497
|
-
export type IsomorphicRemotePHP = Remote<Omit<IsomorphicLocalPHP, "setSapiName"
|
|
484
|
+
export type IsomorphicRemotePHP = Remote<Omit<IsomorphicLocalPHP, "setSapiName">>;
|
|
498
485
|
export type UniversalPHP = IsomorphicLocalPHP | IsomorphicRemotePHP;
|
|
499
486
|
export type HTTPMethod = "GET" | "POST" | "HEAD" | "OPTIONS" | "PATCH" | "PUT" | "DELETE";
|
|
500
487
|
export type PHPRequestHeaders = Record<string, string>;
|
|
@@ -581,6 +568,13 @@ export interface ListFilesOptions {
|
|
|
581
568
|
*/
|
|
582
569
|
prependPath: boolean;
|
|
583
570
|
}
|
|
571
|
+
/**
|
|
572
|
+
* Rewrites the php.ini file with the given entries.
|
|
573
|
+
*
|
|
574
|
+
* @param php The PHP instance.
|
|
575
|
+
* @param entries The entries to write to the php.ini file.
|
|
576
|
+
*/
|
|
577
|
+
export declare function setPhpIniEntries(php: UniversalPHP, entries: Record<string, unknown>): Promise<void>;
|
|
584
578
|
export type RuntimeType = "NODE" | "WEB" | "WORKER";
|
|
585
579
|
export type PHPRuntimeId = number;
|
|
586
580
|
export type PHPRuntime = any;
|
|
@@ -856,10 +850,6 @@ declare abstract class BasePHP implements IsomorphicLocalPHP, Disposable {
|
|
|
856
850
|
/** @inheritDoc */
|
|
857
851
|
setSapiName(newName: string): Promise<void>;
|
|
858
852
|
/** @inheritDoc */
|
|
859
|
-
setPhpIniPath(path: string): void;
|
|
860
|
-
/** @inheritDoc */
|
|
861
|
-
setPhpIniEntry(key: string, value: string): void;
|
|
862
|
-
/** @inheritDoc */
|
|
863
853
|
chdir(path: string): void;
|
|
864
854
|
/**
|
|
865
855
|
* Do not use. Use new PHPRequestHandler() instead.
|
|
@@ -1253,10 +1243,10 @@ export interface DefineSiteUrlStep {
|
|
|
1253
1243
|
siteUrl: string;
|
|
1254
1244
|
}
|
|
1255
1245
|
/**
|
|
1256
|
-
* Sets WP_HOME and WP_SITEURL constants for the WordPress installation.
|
|
1246
|
+
* Sets [`WP_HOME`](https://developer.wordpress.org/advanced-administration/wordpress/wp-config/#blog-address-url) and [`WP_SITEURL`](https://developer.wordpress.org/advanced-administration/wordpress/wp-config/#wp-siteurl) constants for the WordPress installation.
|
|
1257
1247
|
*
|
|
1258
|
-
*
|
|
1259
|
-
* It is useful when
|
|
1248
|
+
* Using this step on playground.wordpress.net is moot.
|
|
1249
|
+
* It is useful when building a custom Playground-based tool, like [`wp-now`](https://www.npmjs.com/package/@wp-now/wp-now),
|
|
1260
1250
|
* or deploying Playground on a custom domain.
|
|
1261
1251
|
*
|
|
1262
1252
|
* @param playground The playground client.
|
|
@@ -1407,8 +1397,8 @@ export type LoginStep = {
|
|
|
1407
1397
|
password?: string;
|
|
1408
1398
|
};
|
|
1409
1399
|
/**
|
|
1410
|
-
* Logs in to
|
|
1411
|
-
* Under the hood, this function submits the wp-login.php form
|
|
1400
|
+
* Logs in to Playground.
|
|
1401
|
+
* Under the hood, this function submits the [`wp-login.php`](https://developer.wordpress.org/reference/files/wp-login.php/) [form](https://developer.wordpress.org/reference/functions/wp_login_form/)
|
|
1412
1402
|
* just like a user would.
|
|
1413
1403
|
*/
|
|
1414
1404
|
export declare const login: StepHandler<LoginStep>;
|
|
@@ -1453,8 +1443,8 @@ export type SetSiteOptionsStep = {
|
|
|
1453
1443
|
options: Record<string, unknown>;
|
|
1454
1444
|
};
|
|
1455
1445
|
/**
|
|
1456
|
-
* Sets site options. This is equivalent to calling `update_option` for each
|
|
1457
|
-
* option in the `options` object.
|
|
1446
|
+
* Sets site options. This is equivalent to calling [`update_option`](https://developer.wordpress.org/reference/functions/update_option/) for each
|
|
1447
|
+
* option in the [`options`](https://developer.wordpress.org/apis/options/#available-options-by-category) object.
|
|
1458
1448
|
*/
|
|
1459
1449
|
export declare const setSiteOptions: StepHandler<SetSiteOptionsStep>;
|
|
1460
1450
|
/**
|
|
@@ -1482,7 +1472,7 @@ export interface UpdateUserMetaStep {
|
|
|
1482
1472
|
userId: number;
|
|
1483
1473
|
}
|
|
1484
1474
|
/**
|
|
1485
|
-
* Updates user meta. This is equivalent to calling `update_user_meta` for each
|
|
1475
|
+
* Updates user meta. This is equivalent to calling [`update_user_meta`](https://developer.wordpress.org/reference/functions/update_user_meta/) for each
|
|
1486
1476
|
* meta value in the `meta` object.
|
|
1487
1477
|
*/
|
|
1488
1478
|
export declare const updateUserMeta: StepHandler<UpdateUserMetaStep>;
|
|
@@ -1655,6 +1645,7 @@ export interface RunPHPStep {
|
|
|
1655
1645
|
}
|
|
1656
1646
|
/**
|
|
1657
1647
|
* Runs PHP code.
|
|
1648
|
+
* When running WordPress functions, the `code` key must first load [`wp-load.php`](https://github.com/WordPress/WordPress/blob/master/wp-load.php) and start with `"<?php require_once 'wordpress/wp-load.php'; "`.
|
|
1658
1649
|
*/
|
|
1659
1650
|
export declare const runPHP: StepHandler<RunPHPStep, Promise<PHPResponse>>;
|
|
1660
1651
|
/**
|
|
@@ -1677,7 +1668,7 @@ export declare const runPHP: StepHandler<RunPHPStep, Promise<PHPResponse>>;
|
|
|
1677
1668
|
export interface RunPHPWithOptionsStep {
|
|
1678
1669
|
step: "runPHPWithOptions";
|
|
1679
1670
|
/**
|
|
1680
|
-
* Run options (See /wordpress-playground/api/universal/interface/PHPRunOptions)
|
|
1671
|
+
* Run options (See /wordpress-playground/api/universal/interface/PHPRunOptions/))
|
|
1681
1672
|
*/
|
|
1682
1673
|
options: PHPRunOptions;
|
|
1683
1674
|
}
|
|
@@ -1714,7 +1705,7 @@ export interface RequestStep {
|
|
|
1714
1705
|
request: PHPRequest;
|
|
1715
1706
|
}
|
|
1716
1707
|
/**
|
|
1717
|
-
* Sends a HTTP request to
|
|
1708
|
+
* Sends a HTTP request to Playground.
|
|
1718
1709
|
*/
|
|
1719
1710
|
export declare const request: StepHandler<RequestStep, Promise<PHPResponse>>;
|
|
1720
1711
|
/**
|
|
@@ -1761,13 +1752,14 @@ export interface DefineWpConfigConstsStep {
|
|
|
1761
1752
|
/** The constants to define */
|
|
1762
1753
|
consts: Record<string, unknown>;
|
|
1763
1754
|
/**
|
|
1764
|
-
* The method of defining the constants. Possible values are:
|
|
1755
|
+
* The method of defining the constants in wp-config.php. Possible values are:
|
|
1765
1756
|
*
|
|
1766
1757
|
* - rewrite-wp-config: Default. Rewrites the wp-config.php file to
|
|
1767
1758
|
* explicitly call define() with the requested
|
|
1768
1759
|
* name and value. This method alters the file
|
|
1769
1760
|
* on the disk, but it doesn't conflict with
|
|
1770
1761
|
* existing define() calls in wp-config.php.
|
|
1762
|
+
*
|
|
1771
1763
|
* - define-before-run: Defines the constant before running the requested
|
|
1772
1764
|
* script. It doesn't alter any files on the disk, but
|
|
1773
1765
|
* constants defined this way may conflict with existing
|
|
@@ -1782,7 +1774,7 @@ export interface DefineWpConfigConstsStep {
|
|
|
1782
1774
|
virtualize?: boolean;
|
|
1783
1775
|
}
|
|
1784
1776
|
/**
|
|
1785
|
-
* Defines constants in a wp-config.php file.
|
|
1777
|
+
* Defines constants in a [`wp-config.php`](https://developer.wordpress.org/advanced-administration/wordpress/wp-config/) file.
|
|
1786
1778
|
*
|
|
1787
1779
|
* This step can be called multiple times, and the constants will be merged.
|
|
1788
1780
|
*
|
|
@@ -1878,9 +1870,9 @@ export interface ImportWordPressFilesStep<ResourceType> {
|
|
|
1878
1870
|
}
|
|
1879
1871
|
/**
|
|
1880
1872
|
* Imports top-level WordPress files from a given zip file into
|
|
1881
|
-
* the documentRoot
|
|
1873
|
+
* the `documentRoot`. For example, if a zip file contains the
|
|
1882
1874
|
* `wp-content` and `wp-includes` directories, they will replace
|
|
1883
|
-
* the corresponding directories in Playground's documentRoot
|
|
1875
|
+
* the corresponding directories in Playground's `documentRoot`.
|
|
1884
1876
|
*
|
|
1885
1877
|
* Any files that Playground recognizes as "excluded from the export"
|
|
1886
1878
|
* will carry over from the existing document root into the imported
|
|
@@ -1931,7 +1923,7 @@ export interface EnableMultisiteStep {
|
|
|
1931
1923
|
step: "enableMultisite";
|
|
1932
1924
|
}
|
|
1933
1925
|
/**
|
|
1934
|
-
* Defines constants in a wp-config.php file.
|
|
1926
|
+
* Defines the [Multisite](https://developer.wordpress.org/advanced-administration/multisite/create-network/) constants in a `wp-config.php` file.
|
|
1935
1927
|
*
|
|
1936
1928
|
* This step can be called multiple times, and the constants will be merged.
|
|
1937
1929
|
*
|
|
@@ -1960,7 +1952,7 @@ export interface WPCLIStep {
|
|
|
1960
1952
|
wpCliPath?: string;
|
|
1961
1953
|
}
|
|
1962
1954
|
/**
|
|
1963
|
-
* Runs PHP code.
|
|
1955
|
+
* Runs PHP code using [WP-CLI](https://developer.wordpress.org/cli/commands/).
|
|
1964
1956
|
*/
|
|
1965
1957
|
export declare const wpCLI: StepHandler<WPCLIStep, Promise<PHPResponse>>;
|
|
1966
1958
|
/**
|
|
@@ -2183,7 +2175,7 @@ declare class WebPHP extends BasePHP {
|
|
|
2183
2175
|
static load(phpVersion: SupportedPHPVersion, options?: PHPWebLoaderOptions): Promise<WebPHP>;
|
|
2184
2176
|
static loadRuntime(phpVersion: SupportedPHPVersion, options?: PHPWebLoaderOptions): Promise<number>;
|
|
2185
2177
|
}
|
|
2186
|
-
declare class WebPHPEndpoint implements Omit<IsomorphicLocalPHP, "setSapiName"
|
|
2178
|
+
declare class WebPHPEndpoint implements Omit<IsomorphicLocalPHP, "setSapiName"> {
|
|
2187
2179
|
/** @inheritDoc @php-wasm/universal!RequestHandler.absoluteUrl */
|
|
2188
2180
|
absoluteUrl: string;
|
|
2189
2181
|
/** @inheritDoc @php-wasm/universal!RequestHandler.documentRoot */
|
|
@@ -2219,10 +2211,6 @@ declare class WebPHPEndpoint implements Omit<IsomorphicLocalPHP, "setSapiName" |
|
|
|
2219
2211
|
chdir(path: string): void;
|
|
2220
2212
|
/** @inheritDoc @php-wasm/web!WebPHP.setSapiName */
|
|
2221
2213
|
setSapiName(newName: string): void;
|
|
2222
|
-
/** @inheritDoc @php-wasm/web!WebPHP.setPhpIniPath */
|
|
2223
|
-
setPhpIniPath(path: string): void;
|
|
2224
|
-
/** @inheritDoc @php-wasm/web!WebPHP.setPhpIniEntry */
|
|
2225
|
-
setPhpIniEntry(key: string, value: string): void;
|
|
2226
2214
|
/** @inheritDoc @php-wasm/web!WebPHP.mkdir */
|
|
2227
2215
|
mkdir(path: string): void;
|
|
2228
2216
|
/** @inheritDoc @php-wasm/web!WebPHP.mkdirTree */
|