@wp-playground/client 0.1.61 → 0.2.0
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 +41 -34
- package/index.d.ts +99 -12
- package/index.js +7316 -1310
- package/package.json +6 -2
- package/blueprint-schema.json +0 -1276
package/index.d.ts
CHANGED
|
@@ -274,7 +274,7 @@ export interface RequestHandler {
|
|
|
274
274
|
* }
|
|
275
275
|
* })
|
|
276
276
|
* php.writeFile("/www/index.php", `<?php echo file_get_contents("php://input");`);
|
|
277
|
-
* const result = await php.
|
|
277
|
+
* const result = await php.request({
|
|
278
278
|
* method: "GET",
|
|
279
279
|
* headers: {
|
|
280
280
|
* "Content-Type": "text/plain"
|
|
@@ -512,7 +512,7 @@ export interface IsomorphicLocalPHP extends RequestHandler {
|
|
|
512
512
|
* post_message_to_js(string $data)
|
|
513
513
|
*
|
|
514
514
|
* Arguments:
|
|
515
|
-
* $data –
|
|
515
|
+
* $data (string) – Data to pass to JavaScript.
|
|
516
516
|
*
|
|
517
517
|
* @example
|
|
518
518
|
*
|
|
@@ -1062,17 +1062,25 @@ export declare class SemaphoreResource<T extends Resource> extends DecoratedReso
|
|
|
1062
1062
|
/** @inheritDoc */
|
|
1063
1063
|
resolve(): Promise<File>;
|
|
1064
1064
|
}
|
|
1065
|
+
/**
|
|
1066
|
+
* @inheritDoc activatePlugin
|
|
1067
|
+
*/
|
|
1065
1068
|
export interface ActivatePluginStep {
|
|
1066
1069
|
step: "activatePlugin";
|
|
1070
|
+
/** Path to the plugin directory as absolute path (/wordpress/wp-content/plugins/plugin-name); or the plugin entry file relative to the plugins directory (plugin-name/plugin-name.php). */
|
|
1067
1071
|
pluginPath: string;
|
|
1072
|
+
/** Optional. Plugin name to display in the progress bar. */
|
|
1068
1073
|
pluginName?: string;
|
|
1069
1074
|
}
|
|
1070
1075
|
/**
|
|
1071
|
-
* Activates a WordPress plugin
|
|
1076
|
+
* Activates a WordPress plugin (if it's installed).
|
|
1072
1077
|
*
|
|
1073
1078
|
* @param playground The playground client.
|
|
1074
1079
|
*/
|
|
1075
1080
|
export declare const activatePlugin: StepHandler<ActivatePluginStep>;
|
|
1081
|
+
/**
|
|
1082
|
+
* @private
|
|
1083
|
+
*/
|
|
1076
1084
|
export interface ApplyWordPressPatchesStep {
|
|
1077
1085
|
step: "applyWordPressPatches";
|
|
1078
1086
|
siteUrl?: string;
|
|
@@ -1083,12 +1091,25 @@ export interface ApplyWordPressPatchesStep {
|
|
|
1083
1091
|
disableWpNewBlogNotification?: boolean;
|
|
1084
1092
|
}
|
|
1085
1093
|
export declare const applyWordPressPatches: StepHandler<ApplyWordPressPatchesStep>;
|
|
1094
|
+
/**
|
|
1095
|
+
* @inheritDoc defineSiteUrl
|
|
1096
|
+
* @hasRunnableExample
|
|
1097
|
+
* @example
|
|
1098
|
+
*
|
|
1099
|
+
* <code>
|
|
1100
|
+
* {
|
|
1101
|
+
* "step": "defineSiteUrl",
|
|
1102
|
+
* "siteUrl": "https://playground.wordpress.net"
|
|
1103
|
+
* }
|
|
1104
|
+
* </code>
|
|
1105
|
+
*/
|
|
1086
1106
|
export interface DefineSiteUrlStep {
|
|
1087
1107
|
step: "defineSiteUrl";
|
|
1108
|
+
/** The URL */
|
|
1088
1109
|
siteUrl: string;
|
|
1089
1110
|
}
|
|
1090
1111
|
/**
|
|
1091
|
-
* Sets
|
|
1112
|
+
* Sets WP_HOME and WP_SITEURL constants for the WordPress installation.
|
|
1092
1113
|
*
|
|
1093
1114
|
* @param playground The playground client.
|
|
1094
1115
|
* @param siteUrl
|
|
@@ -1103,20 +1124,31 @@ export declare const defineSiteUrl: StepHandler<DefineSiteUrlStep>;
|
|
|
1103
1124
|
* @param playground Playground client.
|
|
1104
1125
|
*/
|
|
1105
1126
|
export declare function zipEntireSite(playground: UniversalPHP): Promise<File>;
|
|
1127
|
+
/**
|
|
1128
|
+
* @inheritDoc replaceSite
|
|
1129
|
+
*/
|
|
1106
1130
|
export interface ReplaceSiteStep<ResourceType> {
|
|
1107
1131
|
step: "replaceSite";
|
|
1132
|
+
/** The zip file containing the new WordPress site */
|
|
1108
1133
|
fullSiteZip: ResourceType;
|
|
1109
1134
|
}
|
|
1110
1135
|
/**
|
|
1111
|
-
* Replace the current site with
|
|
1136
|
+
* Replace the current site with a site from the provided zip file.
|
|
1137
|
+
* Remember to install the SQLite integration plugin in the zipped site:
|
|
1138
|
+
* https://wordpress.org/plugins/sqlite-database-integration.
|
|
1112
1139
|
*
|
|
1113
1140
|
* @param playground Playground client.
|
|
1114
1141
|
* @param fullSiteZip Zipped WordPress site.
|
|
1115
1142
|
*/
|
|
1116
1143
|
export declare const replaceSite: StepHandler<ReplaceSiteStep<File>>;
|
|
1144
|
+
/**
|
|
1145
|
+
* @inheritDoc unzip
|
|
1146
|
+
*/
|
|
1117
1147
|
export interface UnzipStep {
|
|
1118
1148
|
step: "unzip";
|
|
1149
|
+
/** The zip file to extract */
|
|
1119
1150
|
zipPath: string;
|
|
1151
|
+
/** The path to extract the zip file to */
|
|
1120
1152
|
extractToPath: string;
|
|
1121
1153
|
}
|
|
1122
1154
|
/**
|
|
@@ -1127,8 +1159,12 @@ export interface UnzipStep {
|
|
|
1127
1159
|
* @param extractTo The directory to extract the zip file to.
|
|
1128
1160
|
*/
|
|
1129
1161
|
export declare const unzip: StepHandler<UnzipStep>;
|
|
1162
|
+
/**
|
|
1163
|
+
* @inheritDoc importFile
|
|
1164
|
+
*/
|
|
1130
1165
|
export interface ImportFileStep<ResourceType> {
|
|
1131
1166
|
step: "importFile";
|
|
1167
|
+
/** The file to import */
|
|
1132
1168
|
file: ResourceType;
|
|
1133
1169
|
}
|
|
1134
1170
|
/**
|
|
@@ -1270,6 +1306,9 @@ export type LoginStep = {
|
|
|
1270
1306
|
* just like a user would.
|
|
1271
1307
|
*/
|
|
1272
1308
|
export declare const login: StepHandler<LoginStep>;
|
|
1309
|
+
/**
|
|
1310
|
+
* @private
|
|
1311
|
+
*/
|
|
1273
1312
|
export interface RunWpInstallationWizardStep {
|
|
1274
1313
|
step: "runWpInstallationWizard";
|
|
1275
1314
|
options: WordPressInstallationOptions;
|
|
@@ -1331,7 +1370,9 @@ export declare const setSiteOptions: StepHandler<SetSiteOptionsStep>;
|
|
|
1331
1370
|
*/
|
|
1332
1371
|
export interface UpdateUserMetaStep {
|
|
1333
1372
|
step: "updateUserMeta";
|
|
1373
|
+
/** An object of user meta values to set, e.g. { "first_name": "John" } */
|
|
1334
1374
|
meta: Record<string, unknown>;
|
|
1375
|
+
/** User ID */
|
|
1335
1376
|
userId: number;
|
|
1336
1377
|
}
|
|
1337
1378
|
/**
|
|
@@ -1380,6 +1421,9 @@ export declare const runPHP: StepHandler<RunPHPStep>;
|
|
|
1380
1421
|
*/
|
|
1381
1422
|
export interface RunPHPWithOptionsStep {
|
|
1382
1423
|
step: "runPHPWithOptions";
|
|
1424
|
+
/**
|
|
1425
|
+
* Run options (See /wordpress-playground/api/universal/interface/PHPRunOptions)
|
|
1426
|
+
*/
|
|
1383
1427
|
options: PHPRunOptions;
|
|
1384
1428
|
}
|
|
1385
1429
|
/**
|
|
@@ -1401,7 +1445,9 @@ export declare const runPHPWithOptions: StepHandler<RunPHPWithOptionsStep>;
|
|
|
1401
1445
|
*/
|
|
1402
1446
|
export interface SetPhpIniEntryStep {
|
|
1403
1447
|
step: "setPhpIniEntry";
|
|
1448
|
+
/** Entry name e.g. "display_errors" */
|
|
1404
1449
|
key: string;
|
|
1450
|
+
/** Entry value as a string e.g. "1" */
|
|
1405
1451
|
value: string;
|
|
1406
1452
|
}
|
|
1407
1453
|
/**
|
|
@@ -1430,6 +1476,9 @@ export declare const setPhpIniEntry: StepHandler<SetPhpIniEntryStep>;
|
|
|
1430
1476
|
*/
|
|
1431
1477
|
export interface RequestStep {
|
|
1432
1478
|
step: "request";
|
|
1479
|
+
/**
|
|
1480
|
+
* Request details (See /wordpress-playground/api/universal/interface/PHPRequest)
|
|
1481
|
+
*/
|
|
1433
1482
|
request: PHPRequest;
|
|
1434
1483
|
}
|
|
1435
1484
|
/**
|
|
@@ -1452,7 +1501,9 @@ export declare const request: StepHandler<RequestStep>;
|
|
|
1452
1501
|
*/
|
|
1453
1502
|
export interface CpStep {
|
|
1454
1503
|
step: "cp";
|
|
1504
|
+
/** Source path */
|
|
1455
1505
|
fromPath: string;
|
|
1506
|
+
/** Target path */
|
|
1456
1507
|
toPath: string;
|
|
1457
1508
|
}
|
|
1458
1509
|
/**
|
|
@@ -1475,7 +1526,9 @@ export declare const cp: StepHandler<CpStep>;
|
|
|
1475
1526
|
*/
|
|
1476
1527
|
export interface MvStep {
|
|
1477
1528
|
step: "mv";
|
|
1529
|
+
/** Source path */
|
|
1478
1530
|
fromPath: string;
|
|
1531
|
+
/** Target path */
|
|
1479
1532
|
toPath: string;
|
|
1480
1533
|
}
|
|
1481
1534
|
/**
|
|
@@ -1496,6 +1549,7 @@ export declare const mv: StepHandler<MvStep>;
|
|
|
1496
1549
|
*/
|
|
1497
1550
|
export interface MkdirStep {
|
|
1498
1551
|
step: "mkdir";
|
|
1552
|
+
/** The path of the directory you want to create */
|
|
1499
1553
|
path: string;
|
|
1500
1554
|
}
|
|
1501
1555
|
/**
|
|
@@ -1517,6 +1571,7 @@ export declare const mkdir: StepHandler<MkdirStep>;
|
|
|
1517
1571
|
*/
|
|
1518
1572
|
export interface RmStep {
|
|
1519
1573
|
step: "rm";
|
|
1574
|
+
/** The path to remove */
|
|
1520
1575
|
path: string;
|
|
1521
1576
|
}
|
|
1522
1577
|
/**
|
|
@@ -1538,6 +1593,7 @@ export declare const rm: StepHandler<RmStep>;
|
|
|
1538
1593
|
*/
|
|
1539
1594
|
export interface RmdirStep {
|
|
1540
1595
|
step: "rmdir";
|
|
1596
|
+
/** The path to remove */
|
|
1541
1597
|
path: string;
|
|
1542
1598
|
}
|
|
1543
1599
|
/**
|
|
@@ -1560,7 +1616,9 @@ export declare const rmdir: StepHandler<RmdirStep>;
|
|
|
1560
1616
|
*/
|
|
1561
1617
|
export interface WriteFileStep<ResourceType> {
|
|
1562
1618
|
step: "writeFile";
|
|
1619
|
+
/** The path of the file to write to */
|
|
1563
1620
|
path: string;
|
|
1621
|
+
/** The data to write */
|
|
1564
1622
|
data: ResourceType | string | Uint8Array;
|
|
1565
1623
|
}
|
|
1566
1624
|
/**
|
|
@@ -1568,7 +1626,19 @@ export interface WriteFileStep<ResourceType> {
|
|
|
1568
1626
|
*/
|
|
1569
1627
|
export declare const writeFile: StepHandler<WriteFileStep<File>>;
|
|
1570
1628
|
/**
|
|
1571
|
-
*
|
|
1629
|
+
* @inheritDoc defineWpConfigConsts
|
|
1630
|
+
* @hasRunnableExample
|
|
1631
|
+
* @example
|
|
1632
|
+
*
|
|
1633
|
+
* <code>
|
|
1634
|
+
* {
|
|
1635
|
+
* "step": "defineWpConfigConsts",
|
|
1636
|
+
* "consts": {
|
|
1637
|
+
* "WP_DEBUG": true
|
|
1638
|
+
* },
|
|
1639
|
+
* "virtualize": true
|
|
1640
|
+
* }
|
|
1641
|
+
* </code>
|
|
1572
1642
|
*/
|
|
1573
1643
|
export interface DefineWpConfigConstsStep {
|
|
1574
1644
|
step: "defineWpConfigConsts";
|
|
@@ -1583,19 +1653,24 @@ export interface DefineWpConfigConstsStep {
|
|
|
1583
1653
|
virtualize?: boolean;
|
|
1584
1654
|
}
|
|
1585
1655
|
/**
|
|
1586
|
-
*
|
|
1656
|
+
* Defines the wp-config.php constants
|
|
1587
1657
|
*
|
|
1588
1658
|
* @param playground The playground client.
|
|
1589
|
-
* @param wpConfigConst
|
|
1590
|
-
* @returns Returns the virtual file system configuration file path.
|
|
1659
|
+
* @param wpConfigConst
|
|
1591
1660
|
*/
|
|
1592
1661
|
export declare const defineWpConfigConsts: StepHandler<DefineWpConfigConstsStep>;
|
|
1662
|
+
/**
|
|
1663
|
+
* @inheritDoc activateTheme
|
|
1664
|
+
*/
|
|
1593
1665
|
export interface ActivateThemeStep {
|
|
1594
1666
|
step: "activateTheme";
|
|
1667
|
+
/**
|
|
1668
|
+
* The name of the theme folder inside wp-content/themes/
|
|
1669
|
+
*/
|
|
1595
1670
|
themeFolderName: string;
|
|
1596
1671
|
}
|
|
1597
1672
|
/**
|
|
1598
|
-
* Activates a WordPress theme
|
|
1673
|
+
* Activates a WordPress theme (if it's installed).
|
|
1599
1674
|
*
|
|
1600
1675
|
* @param playground The playground client.
|
|
1601
1676
|
* @param themeFolderName The theme folder name.
|
|
@@ -1655,7 +1730,8 @@ declare const supportedWordPressVersions: readonly [
|
|
|
1655
1730
|
"6.2",
|
|
1656
1731
|
"6.1",
|
|
1657
1732
|
"6.0",
|
|
1658
|
-
"5.9"
|
|
1733
|
+
"5.9",
|
|
1734
|
+
"nightly"
|
|
1659
1735
|
];
|
|
1660
1736
|
export type supportedWordPressVersion = (typeof supportedWordPressVersions)[number];
|
|
1661
1737
|
export interface CompiledBlueprint {
|
|
@@ -1781,6 +1857,13 @@ declare class WebPHPEndpoint implements IsomorphicLocalPHP {
|
|
|
1781
1857
|
/** @inheritDoc @php-wasm/web!WebPHP.onMessage */
|
|
1782
1858
|
onMessage(listener: MessageListener): void;
|
|
1783
1859
|
}
|
|
1860
|
+
export type SyncProgress = {
|
|
1861
|
+
/** The number of files that have been synced. */
|
|
1862
|
+
files: number;
|
|
1863
|
+
/** The number of all files that need to be synced. */
|
|
1864
|
+
total: number;
|
|
1865
|
+
};
|
|
1866
|
+
export type SyncProgressCallback = (progress: SyncProgress) => void;
|
|
1784
1867
|
declare class PlaygroundWorkerEndpoint extends WebPHPEndpoint {
|
|
1785
1868
|
/**
|
|
1786
1869
|
* A string representing the scope of the Playground instance.
|
|
@@ -1799,10 +1882,13 @@ declare class PlaygroundWorkerEndpoint extends WebPHPEndpoint {
|
|
|
1799
1882
|
* @returns WordPress module details, including the static assets directory and default theme.
|
|
1800
1883
|
*/
|
|
1801
1884
|
getWordPressModuleDetails(): Promise<{
|
|
1885
|
+
majorVersion: string;
|
|
1802
1886
|
staticAssetsDirectory: string;
|
|
1803
1887
|
defaultTheme: any;
|
|
1804
1888
|
}>;
|
|
1805
|
-
|
|
1889
|
+
resetVirtualOpfs(): Promise<void>;
|
|
1890
|
+
reloadFilesFromOpfs(): Promise<void>;
|
|
1891
|
+
bindOpfs(opfs: FileSystemDirectoryHandle, onProgress?: SyncProgressCallback): Promise<void>;
|
|
1806
1892
|
}
|
|
1807
1893
|
export interface ProgressBarOptions {
|
|
1808
1894
|
caption?: string;
|
|
@@ -1845,6 +1931,7 @@ export interface WebClientMixin extends ProgressReceiver {
|
|
|
1845
1931
|
onDownloadProgress: PlaygroundWorkerEndpoint["onDownloadProgress"];
|
|
1846
1932
|
/** @inheritDoc @php-wasm/universal!UniversalPHP.onMessage */
|
|
1847
1933
|
onMessage: PlaygroundWorkerEndpoint["onMessage"];
|
|
1934
|
+
bindOpfs(opfs: FileSystemDirectoryHandle, onProgress?: SyncProgressCallback): Promise<void>;
|
|
1848
1935
|
}
|
|
1849
1936
|
/**
|
|
1850
1937
|
* The Playground Client interface.
|