@wp-playground/blueprints 0.5.5 → 0.6.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/blueprint-schema.json +34 -2
- package/index.cjs +142 -73
- package/index.d.ts +67 -14
- package/index.js +4085 -3711
- package/lib/steps/enable-multisite.d.ts +24 -0
- package/lib/steps/handlers.d.ts +1 -0
- package/lib/steps/index.d.ts +5 -4
- package/lib/steps/request.d.ts +2 -2
- package/lib/steps/run-php.d.ts +2 -1
- package/lib/steps/unzip.d.ts +12 -4
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -182,17 +182,29 @@ declare class PHPResponse implements PHPResponseData {
|
|
|
182
182
|
get text(): string;
|
|
183
183
|
}
|
|
184
184
|
/**
|
|
185
|
-
* Represents an event related to the PHP
|
|
185
|
+
* Represents an event related to the PHP request.
|
|
186
186
|
*/
|
|
187
187
|
export interface PHPRequestEndEvent {
|
|
188
188
|
type: "request.end";
|
|
189
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* Represents a PHP runtime initialization event.
|
|
192
|
+
*/
|
|
193
|
+
export interface PHPRuntimeInitializedEvent {
|
|
194
|
+
type: "runtime.initialized";
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Represents a PHP runtime destruction event.
|
|
198
|
+
*/
|
|
199
|
+
export interface PHPRuntimeBeforeDestroyEvent {
|
|
200
|
+
type: "runtime.beforedestroy";
|
|
201
|
+
}
|
|
190
202
|
/**
|
|
191
203
|
* Represents an event related to the PHP instance.
|
|
192
204
|
* This is intentionally not an extension of CustomEvent
|
|
193
205
|
* to make it isomorphic between different JavaScript runtimes.
|
|
194
206
|
*/
|
|
195
|
-
export type PHPEvent = PHPRequestEndEvent;
|
|
207
|
+
export type PHPEvent = PHPRequestEndEvent | PHPRuntimeInitializedEvent | PHPRuntimeBeforeDestroyEvent;
|
|
196
208
|
/**
|
|
197
209
|
* A callback function that handles PHP events.
|
|
198
210
|
*/
|
|
@@ -328,6 +340,11 @@ export interface RequestHandler {
|
|
|
328
340
|
documentRoot: string;
|
|
329
341
|
}
|
|
330
342
|
export interface IsomorphicLocalPHP extends RequestHandler {
|
|
343
|
+
/**
|
|
344
|
+
* Sets the SAPI name exposed by the PHP module.
|
|
345
|
+
* @param newName - The new SAPI name.
|
|
346
|
+
*/
|
|
347
|
+
setSapiName(newName: string): void;
|
|
331
348
|
/**
|
|
332
349
|
* Defines a constant in the PHP runtime.
|
|
333
350
|
* @param key - The name of the constant.
|
|
@@ -565,7 +582,7 @@ export interface IsomorphicLocalPHP extends RequestHandler {
|
|
|
565
582
|
*
|
|
566
583
|
* @param handler Callback function to spawn a process.
|
|
567
584
|
*/
|
|
568
|
-
setSpawnHandler(handler: SpawnHandler): void;
|
|
585
|
+
setSpawnHandler(handler: SpawnHandler | string): void;
|
|
569
586
|
}
|
|
570
587
|
export type MessageListener = (data: string) => Promise<string | Uint8Array | void> | string | void;
|
|
571
588
|
export interface EventEmitter {
|
|
@@ -576,7 +593,7 @@ export type ChildProcess = EventEmitter & {
|
|
|
576
593
|
stdout: EventEmitter;
|
|
577
594
|
stderr: EventEmitter;
|
|
578
595
|
};
|
|
579
|
-
export type SpawnHandler = (command: string) => ChildProcess;
|
|
596
|
+
export type SpawnHandler = (command: string, args: string[]) => ChildProcess;
|
|
580
597
|
export type IsomorphicRemotePHP = Remote<IsomorphicLocalPHP>;
|
|
581
598
|
export type UniversalPHP = IsomorphicLocalPHP | IsomorphicRemotePHP;
|
|
582
599
|
export type HTTPMethod = "GET" | "POST" | "HEAD" | "OPTIONS" | "PATCH" | "PUT" | "DELETE";
|
|
@@ -641,6 +658,11 @@ export interface PHPRunOptions {
|
|
|
641
658
|
* The code snippet to eval instead of a php file.
|
|
642
659
|
*/
|
|
643
660
|
code?: string;
|
|
661
|
+
/**
|
|
662
|
+
* Whether to throw an error if the PHP process exits with a non-zero code
|
|
663
|
+
* or outputs to stderr.
|
|
664
|
+
*/
|
|
665
|
+
throwOnError?: boolean;
|
|
644
666
|
}
|
|
645
667
|
export interface FileInfo {
|
|
646
668
|
key: string;
|
|
@@ -686,7 +708,7 @@ declare class Semaphore {
|
|
|
686
708
|
constructor({ concurrency }: SemaphoreOptions);
|
|
687
709
|
get running(): number;
|
|
688
710
|
acquire(): Promise<() => void>;
|
|
689
|
-
run<T>(fn: () => Promise<T>): Promise<T>;
|
|
711
|
+
run<T>(fn: () => T | Promise<T>): Promise<T>;
|
|
690
712
|
}
|
|
691
713
|
export declare const ResourceTypes: readonly [
|
|
692
714
|
"vfs",
|
|
@@ -1356,7 +1378,7 @@ export interface RunPHPStep {
|
|
|
1356
1378
|
/**
|
|
1357
1379
|
* Runs PHP code.
|
|
1358
1380
|
*/
|
|
1359
|
-
export declare const runPHP: StepHandler<RunPHPStep
|
|
1381
|
+
export declare const runPHP: StepHandler<RunPHPStep, Promise<PHPResponse>>;
|
|
1360
1382
|
/**
|
|
1361
1383
|
* @inheritDoc runPHP
|
|
1362
1384
|
* @hasRunnableExample
|
|
@@ -1415,7 +1437,7 @@ export interface RequestStep {
|
|
|
1415
1437
|
/**
|
|
1416
1438
|
* Sends a HTTP request to the Playground.
|
|
1417
1439
|
*/
|
|
1418
|
-
export declare const request: StepHandler<RequestStep
|
|
1440
|
+
export declare const request: StepHandler<RequestStep, Promise<PHPResponse>>;
|
|
1419
1441
|
/**
|
|
1420
1442
|
* @inheritDoc writeFile
|
|
1421
1443
|
* @hasRunnableExample
|
|
@@ -1522,15 +1544,23 @@ export declare const activateTheme: StepHandler<ActivateThemeStep>;
|
|
|
1522
1544
|
* <code>
|
|
1523
1545
|
* {
|
|
1524
1546
|
* "step": "unzip",
|
|
1525
|
-
* "
|
|
1547
|
+
* "zipFile": {
|
|
1548
|
+
* "resource": "vfs",
|
|
1549
|
+
* "path": "/wordpress/data.zip"
|
|
1550
|
+
* },
|
|
1526
1551
|
* "extractToPath": "/wordpress"
|
|
1527
1552
|
* }
|
|
1528
1553
|
* </code>
|
|
1529
1554
|
*/
|
|
1530
|
-
export interface UnzipStep {
|
|
1555
|
+
export interface UnzipStep<ResourceType> {
|
|
1531
1556
|
step: "unzip";
|
|
1532
1557
|
/** The zip file to extract */
|
|
1533
|
-
|
|
1558
|
+
zipFile?: ResourceType;
|
|
1559
|
+
/**
|
|
1560
|
+
* The path of the zip file to extract
|
|
1561
|
+
* @deprecated Use zipFile instead.
|
|
1562
|
+
*/
|
|
1563
|
+
zipPath?: string;
|
|
1534
1564
|
/** The path to extract the zip file to */
|
|
1535
1565
|
extractToPath: string;
|
|
1536
1566
|
}
|
|
@@ -1541,7 +1571,7 @@ export interface UnzipStep {
|
|
|
1541
1571
|
* @param zipPath The zip file to unzip.
|
|
1542
1572
|
* @param extractTo The directory to extract the zip file to.
|
|
1543
1573
|
*/
|
|
1544
|
-
export declare const unzip: StepHandler<UnzipStep
|
|
1574
|
+
export declare const unzip: StepHandler<UnzipStep<File>>;
|
|
1545
1575
|
/**
|
|
1546
1576
|
* @inheritDoc importWordPressFiles
|
|
1547
1577
|
* @example
|
|
@@ -1610,6 +1640,29 @@ export interface ImportFileStep<ResourceType> {
|
|
|
1610
1640
|
* @param file The file to import.
|
|
1611
1641
|
*/
|
|
1612
1642
|
export declare const importFile: StepHandler<ImportFileStep<File>>;
|
|
1643
|
+
/**
|
|
1644
|
+
* @inheritDoc enableMultisite
|
|
1645
|
+
* @hasRunnableExample
|
|
1646
|
+
* @example
|
|
1647
|
+
*
|
|
1648
|
+
* <code>
|
|
1649
|
+
* {
|
|
1650
|
+
* "step": "enableMultisite",
|
|
1651
|
+
* }
|
|
1652
|
+
* </code>
|
|
1653
|
+
*/
|
|
1654
|
+
export interface EnableMultisiteStep {
|
|
1655
|
+
step: "enableMultisite";
|
|
1656
|
+
}
|
|
1657
|
+
/**
|
|
1658
|
+
* Defines constants in a wp-config.php file.
|
|
1659
|
+
*
|
|
1660
|
+
* This step can be called multiple times, and the constants will be merged.
|
|
1661
|
+
*
|
|
1662
|
+
* @param playground The playground client.
|
|
1663
|
+
* @param enableMultisite
|
|
1664
|
+
*/
|
|
1665
|
+
export declare const enableMultisite: StepHandler<EnableMultisiteStep>;
|
|
1613
1666
|
/**
|
|
1614
1667
|
* Used by the export step to exclude the Playground-specific files
|
|
1615
1668
|
* from the zip file. Keep it in sync with the list of files created
|
|
@@ -1627,7 +1680,7 @@ export type StepDefinition = Step & {
|
|
|
1627
1680
|
* If you add a step here, make sure to also
|
|
1628
1681
|
* add it to the exports below.
|
|
1629
1682
|
*/
|
|
1630
|
-
export type GenericStep<Resource> = ActivatePluginStep | ActivateThemeStep | ApplyWordPressPatchesStep | CpStep | DefineWpConfigConstsStep | DefineSiteUrlStep | ImportFileStep<Resource> | ImportWordPressFilesStep<Resource> | InstallPluginStep<Resource> | InstallThemeStep<Resource> | LoginStep | MkdirStep | MvStep | RequestStep | RmStep | RmdirStep | RunPHPStep | RunPHPWithOptionsStep | RunWpInstallationWizardStep | RunSqlStep<Resource> | SetPhpIniEntryStep | SetSiteOptionsStep | UnzipStep | UpdateUserMetaStep | WriteFileStep<Resource>;
|
|
1683
|
+
export type GenericStep<Resource> = ActivatePluginStep | ActivateThemeStep | ApplyWordPressPatchesStep | CpStep | DefineWpConfigConstsStep | DefineSiteUrlStep | EnableMultisiteStep | ImportFileStep<Resource> | ImportWordPressFilesStep<Resource> | InstallPluginStep<Resource> | InstallThemeStep<Resource> | LoginStep | MkdirStep | MvStep | RequestStep | RmStep | RmdirStep | RunPHPStep | RunPHPWithOptionsStep | RunWpInstallationWizardStep | RunSqlStep<Resource> | SetPhpIniEntryStep | SetSiteOptionsStep | UnzipStep<Resource> | UpdateUserMetaStep | WriteFileStep<Resource>;
|
|
1631
1684
|
/**
|
|
1632
1685
|
* Progress reporting details.
|
|
1633
1686
|
*/
|
|
@@ -1635,11 +1688,11 @@ export type StepProgress = {
|
|
|
1635
1688
|
tracker: ProgressTracker;
|
|
1636
1689
|
initialCaption?: string;
|
|
1637
1690
|
};
|
|
1638
|
-
export type StepHandler<S extends GenericStep<File
|
|
1691
|
+
export type StepHandler<S extends GenericStep<File>, Return = any> = (
|
|
1639
1692
|
/**
|
|
1640
1693
|
* A PHP instance or Playground client.
|
|
1641
1694
|
*/
|
|
1642
|
-
php: UniversalPHP, args: Omit<S, "step">, progressArgs?: StepProgress) =>
|
|
1695
|
+
php: UniversalPHP, args: Omit<S, "step">, progressArgs?: StepProgress) => Return;
|
|
1643
1696
|
/**
|
|
1644
1697
|
* Exports the WordPress database as a WXR file using
|
|
1645
1698
|
* the core WordPress export tool.
|