@wp-playground/blueprints 0.5.6 → 0.6.1
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/__vite-browser-external-2447137e.js +4 -0
- package/__vite-browser-external-b3701507.cjs +1 -0
- package/blueprint-schema.json +34 -49
- package/index.cjs +108 -383
- package/index.d.ts +68 -30
- package/index.js +3979 -4117
- package/lib/steps/enable-multisite.d.ts +24 -0
- package/lib/steps/handlers.d.ts +1 -1
- package/lib/steps/index.d.ts +5 -5
- 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/lib/steps/apply-wordpress-patches/index.d.ts +0 -16
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,12 +340,17 @@ 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.
|
|
334
351
|
* @param value - The value of the constant.
|
|
335
352
|
*/
|
|
336
|
-
defineConstant(key: string, value: string | number | null): void;
|
|
353
|
+
defineConstant(key: string, value: boolean | string | number | null): void;
|
|
337
354
|
/**
|
|
338
355
|
* Adds an event listener for a PHP event.
|
|
339
356
|
* @param eventType - The type of event to listen for.
|
|
@@ -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",
|
|
@@ -919,21 +941,6 @@ export interface ActivatePluginStep {
|
|
|
919
941
|
* @param playground The playground client.
|
|
920
942
|
*/
|
|
921
943
|
export declare const activatePlugin: StepHandler<ActivatePluginStep>;
|
|
922
|
-
/**
|
|
923
|
-
* @private
|
|
924
|
-
*/
|
|
925
|
-
export interface ApplyWordPressPatchesStep {
|
|
926
|
-
step: "applyWordPressPatches";
|
|
927
|
-
siteUrl?: string;
|
|
928
|
-
wordpressPath?: string;
|
|
929
|
-
addPhpInfo?: boolean;
|
|
930
|
-
patchSecrets?: boolean;
|
|
931
|
-
disableSiteHealth?: boolean;
|
|
932
|
-
disableWpNewBlogNotification?: boolean;
|
|
933
|
-
prepareForRunningInsideWebBrowser?: boolean;
|
|
934
|
-
addFetchNetworkTransport?: boolean;
|
|
935
|
-
}
|
|
936
|
-
export declare const applyWordPressPatches: StepHandler<ApplyWordPressPatchesStep>;
|
|
937
944
|
/**
|
|
938
945
|
* @inheritDoc defineSiteUrl
|
|
939
946
|
* @hasRunnableExample
|
|
@@ -1356,7 +1363,7 @@ export interface RunPHPStep {
|
|
|
1356
1363
|
/**
|
|
1357
1364
|
* Runs PHP code.
|
|
1358
1365
|
*/
|
|
1359
|
-
export declare const runPHP: StepHandler<RunPHPStep
|
|
1366
|
+
export declare const runPHP: StepHandler<RunPHPStep, Promise<PHPResponse>>;
|
|
1360
1367
|
/**
|
|
1361
1368
|
* @inheritDoc runPHP
|
|
1362
1369
|
* @hasRunnableExample
|
|
@@ -1415,7 +1422,7 @@ export interface RequestStep {
|
|
|
1415
1422
|
/**
|
|
1416
1423
|
* Sends a HTTP request to the Playground.
|
|
1417
1424
|
*/
|
|
1418
|
-
export declare const request: StepHandler<RequestStep
|
|
1425
|
+
export declare const request: StepHandler<RequestStep, Promise<PHPResponse>>;
|
|
1419
1426
|
/**
|
|
1420
1427
|
* @inheritDoc writeFile
|
|
1421
1428
|
* @hasRunnableExample
|
|
@@ -1522,15 +1529,23 @@ export declare const activateTheme: StepHandler<ActivateThemeStep>;
|
|
|
1522
1529
|
* <code>
|
|
1523
1530
|
* {
|
|
1524
1531
|
* "step": "unzip",
|
|
1525
|
-
* "
|
|
1532
|
+
* "zipFile": {
|
|
1533
|
+
* "resource": "vfs",
|
|
1534
|
+
* "path": "/wordpress/data.zip"
|
|
1535
|
+
* },
|
|
1526
1536
|
* "extractToPath": "/wordpress"
|
|
1527
1537
|
* }
|
|
1528
1538
|
* </code>
|
|
1529
1539
|
*/
|
|
1530
|
-
export interface UnzipStep {
|
|
1540
|
+
export interface UnzipStep<ResourceType> {
|
|
1531
1541
|
step: "unzip";
|
|
1532
1542
|
/** The zip file to extract */
|
|
1533
|
-
|
|
1543
|
+
zipFile?: ResourceType;
|
|
1544
|
+
/**
|
|
1545
|
+
* The path of the zip file to extract
|
|
1546
|
+
* @deprecated Use zipFile instead.
|
|
1547
|
+
*/
|
|
1548
|
+
zipPath?: string;
|
|
1534
1549
|
/** The path to extract the zip file to */
|
|
1535
1550
|
extractToPath: string;
|
|
1536
1551
|
}
|
|
@@ -1541,7 +1556,7 @@ export interface UnzipStep {
|
|
|
1541
1556
|
* @param zipPath The zip file to unzip.
|
|
1542
1557
|
* @param extractTo The directory to extract the zip file to.
|
|
1543
1558
|
*/
|
|
1544
|
-
export declare const unzip: StepHandler<UnzipStep
|
|
1559
|
+
export declare const unzip: StepHandler<UnzipStep<File>>;
|
|
1545
1560
|
/**
|
|
1546
1561
|
* @inheritDoc importWordPressFiles
|
|
1547
1562
|
* @example
|
|
@@ -1610,6 +1625,29 @@ export interface ImportFileStep<ResourceType> {
|
|
|
1610
1625
|
* @param file The file to import.
|
|
1611
1626
|
*/
|
|
1612
1627
|
export declare const importFile: StepHandler<ImportFileStep<File>>;
|
|
1628
|
+
/**
|
|
1629
|
+
* @inheritDoc enableMultisite
|
|
1630
|
+
* @hasRunnableExample
|
|
1631
|
+
* @example
|
|
1632
|
+
*
|
|
1633
|
+
* <code>
|
|
1634
|
+
* {
|
|
1635
|
+
* "step": "enableMultisite"
|
|
1636
|
+
* }
|
|
1637
|
+
* </code>
|
|
1638
|
+
*/
|
|
1639
|
+
export interface EnableMultisiteStep {
|
|
1640
|
+
step: "enableMultisite";
|
|
1641
|
+
}
|
|
1642
|
+
/**
|
|
1643
|
+
* Defines constants in a wp-config.php file.
|
|
1644
|
+
*
|
|
1645
|
+
* This step can be called multiple times, and the constants will be merged.
|
|
1646
|
+
*
|
|
1647
|
+
* @param playground The playground client.
|
|
1648
|
+
* @param enableMultisite
|
|
1649
|
+
*/
|
|
1650
|
+
export declare const enableMultisite: StepHandler<EnableMultisiteStep>;
|
|
1613
1651
|
/**
|
|
1614
1652
|
* Used by the export step to exclude the Playground-specific files
|
|
1615
1653
|
* from the zip file. Keep it in sync with the list of files created
|
|
@@ -1627,7 +1665,7 @@ export type StepDefinition = Step & {
|
|
|
1627
1665
|
* If you add a step here, make sure to also
|
|
1628
1666
|
* add it to the exports below.
|
|
1629
1667
|
*/
|
|
1630
|
-
export type GenericStep<Resource> = ActivatePluginStep | ActivateThemeStep |
|
|
1668
|
+
export type GenericStep<Resource> = ActivatePluginStep | ActivateThemeStep | 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
1669
|
/**
|
|
1632
1670
|
* Progress reporting details.
|
|
1633
1671
|
*/
|
|
@@ -1635,11 +1673,11 @@ export type StepProgress = {
|
|
|
1635
1673
|
tracker: ProgressTracker;
|
|
1636
1674
|
initialCaption?: string;
|
|
1637
1675
|
};
|
|
1638
|
-
export type StepHandler<S extends GenericStep<File
|
|
1676
|
+
export type StepHandler<S extends GenericStep<File>, Return = any> = (
|
|
1639
1677
|
/**
|
|
1640
1678
|
* A PHP instance or Playground client.
|
|
1641
1679
|
*/
|
|
1642
|
-
php: UniversalPHP, args: Omit<S, "step">, progressArgs?: StepProgress) =>
|
|
1680
|
+
php: UniversalPHP, args: Omit<S, "step">, progressArgs?: StepProgress) => Return;
|
|
1643
1681
|
/**
|
|
1644
1682
|
* Exports the WordPress database as a WXR file using
|
|
1645
1683
|
* the core WordPress export tool.
|