@wp-playground/blueprints 0.6.16 → 0.7.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 +46 -18
- package/index.d.ts +22 -170
- package/index.js +851 -744
- package/lib/steps/handlers.d.ts +0 -1
- package/lib/steps/index.d.ts +2 -3
- package/package.json +2 -2
- package/lib/steps/set-php-ini-entry.d.ts +0 -25
package/index.d.ts
CHANGED
|
@@ -217,137 +217,17 @@ export type PHPEvent = PHPRequestEndEvent | PHPRequestErrorEvent | PHPRuntimeIni
|
|
|
217
217
|
* A callback function that handles PHP events.
|
|
218
218
|
*/
|
|
219
219
|
export type PHPEventListener = (event: PHPEvent) => void;
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
* @example Use PHPRequestHandler implicitly with a new PHP instance:
|
|
225
|
-
* ```js
|
|
226
|
-
* import { PHP } from '@php-wasm/web';
|
|
227
|
-
*
|
|
228
|
-
* const php = await PHP.load( '7.4', {
|
|
229
|
-
* requestHandler: {
|
|
230
|
-
* // PHP FS path to serve the files from:
|
|
231
|
-
* documentRoot: '/www',
|
|
232
|
-
*
|
|
233
|
-
* // Used to populate $_SERVER['SERVER_NAME'] etc.:
|
|
234
|
-
* absoluteUrl: 'http://127.0.0.1'
|
|
235
|
-
* }
|
|
236
|
-
* } );
|
|
237
|
-
*
|
|
238
|
-
* php.mkdirTree('/www');
|
|
239
|
-
* php.writeFile('/www/index.php', '<?php echo "Hi from PHP!"; ');
|
|
240
|
-
*
|
|
241
|
-
* const response = await php.request({ path: '/index.php' });
|
|
242
|
-
* console.log(response.text);
|
|
243
|
-
* // "Hi from PHP!"
|
|
244
|
-
* ```
|
|
245
|
-
*
|
|
246
|
-
* @example Explicitly create a PHPRequestHandler instance and run a PHP script:
|
|
247
|
-
* ```js
|
|
248
|
-
* import {
|
|
249
|
-
* loadPHPRuntime,
|
|
250
|
-
* PHP,
|
|
251
|
-
* PHPRequestHandler,
|
|
252
|
-
* getPHPLoaderModule,
|
|
253
|
-
* } from '@php-wasm/web';
|
|
254
|
-
*
|
|
255
|
-
* const runtime = await loadPHPRuntime( await getPHPLoaderModule('7.4') );
|
|
256
|
-
* const php = new PHP( runtime );
|
|
257
|
-
*
|
|
258
|
-
* php.mkdirTree('/www');
|
|
259
|
-
* php.writeFile('/www/index.php', '<?php echo "Hi from PHP!"; ');
|
|
260
|
-
*
|
|
261
|
-
* const server = new PHPRequestHandler(php, {
|
|
262
|
-
* // PHP FS path to serve the files from:
|
|
263
|
-
* documentRoot: '/www',
|
|
264
|
-
*
|
|
265
|
-
* // Used to populate $_SERVER['SERVER_NAME'] etc.:
|
|
266
|
-
* absoluteUrl: 'http://127.0.0.1'
|
|
267
|
-
* });
|
|
268
|
-
*
|
|
269
|
-
* const response = server.request({ path: '/index.php' });
|
|
270
|
-
* console.log(response.text);
|
|
271
|
-
* // "Hi from PHP!"
|
|
272
|
-
* ```
|
|
273
|
-
*/
|
|
274
|
-
export interface RequestHandler {
|
|
275
|
-
/**
|
|
276
|
-
* Serves the request – either by serving a static file, or by
|
|
277
|
-
* dispatching it to the PHP runtime.
|
|
278
|
-
*
|
|
279
|
-
* The request() method mode behaves like a web server and only works if
|
|
280
|
-
* the PHP was initialized with a `requestHandler` option (which the online version
|
|
281
|
-
* of WordPress Playground does by default).
|
|
282
|
-
*
|
|
283
|
-
* In the request mode, you pass an object containing the request information
|
|
284
|
-
* (method, headers, body, etc.) and the path to the PHP file to run:
|
|
285
|
-
*
|
|
286
|
-
* ```ts
|
|
287
|
-
* const php = PHP.load('7.4', {
|
|
288
|
-
* requestHandler: {
|
|
289
|
-
* documentRoot: "/www"
|
|
290
|
-
* }
|
|
291
|
-
* })
|
|
292
|
-
* php.writeFile("/www/index.php", `<?php echo file_get_contents("php://input");`);
|
|
293
|
-
* const result = await php.request({
|
|
294
|
-
* method: "GET",
|
|
295
|
-
* headers: {
|
|
296
|
-
* "Content-Type": "text/plain"
|
|
297
|
-
* },
|
|
298
|
-
* body: "Hello world!",
|
|
299
|
-
* path: "/www/index.php"
|
|
300
|
-
* });
|
|
301
|
-
* // result.text === "Hello world!"
|
|
302
|
-
* ```
|
|
303
|
-
*
|
|
304
|
-
* The `request()` method cannot be used in conjunction with `cli()`.
|
|
305
|
-
*
|
|
306
|
-
* @example
|
|
307
|
-
* ```js
|
|
308
|
-
* const output = await php.request({
|
|
309
|
-
* method: 'GET',
|
|
310
|
-
* url: '/index.php',
|
|
311
|
-
* headers: {
|
|
312
|
-
* 'X-foo': 'bar',
|
|
313
|
-
* },
|
|
314
|
-
* body: {
|
|
315
|
-
* foo: 'bar',
|
|
316
|
-
* },
|
|
317
|
-
* });
|
|
318
|
-
* console.log(output.stdout); // "Hello world!"
|
|
319
|
-
* ```
|
|
320
|
-
*
|
|
321
|
-
* @param request - PHP Request data.
|
|
322
|
-
*/
|
|
323
|
-
request(request: PHPRequest, maxRedirects?: number): Promise<PHPResponse>;
|
|
324
|
-
/**
|
|
325
|
-
* Converts a path to an absolute URL based at the PHPRequestHandler
|
|
326
|
-
* root.
|
|
327
|
-
*
|
|
328
|
-
* @param path The server path to convert to an absolute URL.
|
|
329
|
-
* @returns The absolute URL.
|
|
330
|
-
*/
|
|
220
|
+
export interface IsomorphicLocalPHP {
|
|
221
|
+
/** @deprecated Use PHPRequestHandler instead. */
|
|
222
|
+
request(request: PHPRequest): Promise<PHPResponse>;
|
|
223
|
+
/** @deprecated Use PHPRequestHandler instead. */
|
|
331
224
|
pathToInternalUrl(path: string): string;
|
|
332
|
-
/**
|
|
333
|
-
* Converts an absolute URL based at the PHPRequestHandler to a relative path
|
|
334
|
-
* without the server pathname and scope.
|
|
335
|
-
*
|
|
336
|
-
* @param internalUrl An absolute URL based at the PHPRequestHandler root.
|
|
337
|
-
* @returns The relative path.
|
|
338
|
-
*/
|
|
225
|
+
/** @deprecated Use PHPRequestHandler instead. */
|
|
339
226
|
internalUrlToPath(internalUrl: string): string;
|
|
340
|
-
/**
|
|
341
|
-
* The absolute URL of this PHPRequestHandler instance.
|
|
342
|
-
*/
|
|
227
|
+
/** @deprecated Use PHPRequestHandler instead. */
|
|
343
228
|
absoluteUrl: string;
|
|
344
|
-
/**
|
|
345
|
-
* The directory in the PHP filesystem where the server will look
|
|
346
|
-
* for the files to serve. Default: `/var/www`.
|
|
347
|
-
*/
|
|
229
|
+
/** @deprecated Use PHPRequestHandler instead. */
|
|
348
230
|
documentRoot: string;
|
|
349
|
-
}
|
|
350
|
-
export interface IsomorphicLocalPHP extends RequestHandler {
|
|
351
231
|
/**
|
|
352
232
|
* Sets the SAPI name exposed by the PHP module.
|
|
353
233
|
* @param newName - The new SAPI name.
|
|
@@ -583,25 +463,8 @@ export interface IsomorphicLocalPHP extends RequestHandler {
|
|
|
583
463
|
* @param listener Callback function to handle the message.
|
|
584
464
|
*/
|
|
585
465
|
onMessage(listener: MessageListener): void;
|
|
586
|
-
/**
|
|
587
|
-
* Registers a handler to spawns a child process when
|
|
588
|
-
* `proc_open()`, `popen()`, `exec()`, `system()`, or `passthru()`
|
|
589
|
-
* is called.
|
|
590
|
-
*
|
|
591
|
-
* @param handler Callback function to spawn a process.
|
|
592
|
-
*/
|
|
593
|
-
setSpawnHandler(handler: SpawnHandler | string): void;
|
|
594
466
|
}
|
|
595
467
|
export type MessageListener = (data: string) => Promise<string | Uint8Array | void> | string | void;
|
|
596
|
-
export interface EventEmitter {
|
|
597
|
-
on(event: string, listener: (...args: any[]) => void): this;
|
|
598
|
-
emit(event: string, ...args: any[]): boolean;
|
|
599
|
-
}
|
|
600
|
-
export type ChildProcess = EventEmitter & {
|
|
601
|
-
stdout: EventEmitter;
|
|
602
|
-
stderr: EventEmitter;
|
|
603
|
-
};
|
|
604
|
-
export type SpawnHandler = (command: string, args: string[]) => ChildProcess;
|
|
605
468
|
export type IsomorphicRemotePHP = Remote<IsomorphicLocalPHP>;
|
|
606
469
|
export type UniversalPHP = IsomorphicLocalPHP | IsomorphicRemotePHP;
|
|
607
470
|
export type HTTPMethod = "GET" | "POST" | "HEAD" | "OPTIONS" | "PATCH" | "PUT" | "DELETE";
|
|
@@ -655,6 +518,10 @@ export interface PHPRunOptions {
|
|
|
655
518
|
* Environment variables to set for this run.
|
|
656
519
|
*/
|
|
657
520
|
env?: Record<string, string>;
|
|
521
|
+
/**
|
|
522
|
+
* $_SERVER entries to set for this run.
|
|
523
|
+
*/
|
|
524
|
+
$_SERVER?: Record<string, string>;
|
|
658
525
|
/**
|
|
659
526
|
* The code snippet to eval instead of a php file.
|
|
660
527
|
*/
|
|
@@ -689,13 +556,22 @@ export type SupportedPHPVersion = (typeof SupportedPHPVersions)[number];
|
|
|
689
556
|
export type SupportedPHPExtension = "iconv" | "mbstring" | "xml-bundle" | "gd";
|
|
690
557
|
export type SupportedPHPExtensionBundle = "kitchen-sink" | "light";
|
|
691
558
|
export interface SemaphoreOptions {
|
|
559
|
+
/**
|
|
560
|
+
* The maximum number of concurrent locks.
|
|
561
|
+
*/
|
|
692
562
|
concurrency: number;
|
|
563
|
+
/**
|
|
564
|
+
* The maximum time to wait for a lock to become available.
|
|
565
|
+
*/
|
|
566
|
+
timeout?: number;
|
|
693
567
|
}
|
|
694
568
|
declare class Semaphore {
|
|
695
569
|
private _running;
|
|
696
570
|
private concurrency;
|
|
571
|
+
private timeout?;
|
|
697
572
|
private queue;
|
|
698
|
-
constructor({ concurrency }: SemaphoreOptions);
|
|
573
|
+
constructor({ concurrency, timeout }: SemaphoreOptions);
|
|
574
|
+
get remaining(): number;
|
|
699
575
|
get running(): number;
|
|
700
576
|
acquire(): Promise<() => void>;
|
|
701
577
|
run<T>(fn: () => T | Promise<T>): Promise<T>;
|
|
@@ -1324,30 +1200,6 @@ export interface MvStep {
|
|
|
1324
1200
|
* Moves a file or directory from one path to another.
|
|
1325
1201
|
*/
|
|
1326
1202
|
export declare const mv: StepHandler<MvStep>;
|
|
1327
|
-
/**
|
|
1328
|
-
* @inheritDoc setPhpIniEntry
|
|
1329
|
-
* @hasRunnableExample
|
|
1330
|
-
* @example
|
|
1331
|
-
*
|
|
1332
|
-
* <code>
|
|
1333
|
-
* {
|
|
1334
|
-
* "step": "setPhpIniEntry",
|
|
1335
|
-
* "key": "display_errors",
|
|
1336
|
-
* "value": "1"
|
|
1337
|
-
* }
|
|
1338
|
-
* </code>
|
|
1339
|
-
*/
|
|
1340
|
-
export interface SetPhpIniEntryStep {
|
|
1341
|
-
step: "setPhpIniEntry";
|
|
1342
|
-
/** Entry name e.g. "display_errors" */
|
|
1343
|
-
key: string;
|
|
1344
|
-
/** Entry value as a string e.g. "1" */
|
|
1345
|
-
value: string;
|
|
1346
|
-
}
|
|
1347
|
-
/**
|
|
1348
|
-
* Sets a PHP ini entry.
|
|
1349
|
-
*/
|
|
1350
|
-
export declare const setPhpIniEntry: StepHandler<SetPhpIniEntryStep>;
|
|
1351
1203
|
/**
|
|
1352
1204
|
* @inheritDoc runPHP
|
|
1353
1205
|
* @hasRunnableExample
|
|
@@ -1692,7 +1544,7 @@ export type StepDefinition = Step & {
|
|
|
1692
1544
|
* If you add a step here, make sure to also
|
|
1693
1545
|
* add it to the exports below.
|
|
1694
1546
|
*/
|
|
1695
|
-
export type GenericStep<Resource> = ActivatePluginStep | ActivateThemeStep | CpStep | DefineWpConfigConstsStep | DefineSiteUrlStep | EnableMultisiteStep | ImportWxrStep<Resource> | ImportWordPressFilesStep<Resource> | InstallPluginStep<Resource> | InstallThemeStep<Resource> | LoginStep | MkdirStep | MvStep | RequestStep | RmStep | RmdirStep | RunPHPStep | RunPHPWithOptionsStep | RunWpInstallationWizardStep | RunSqlStep<Resource> |
|
|
1547
|
+
export type GenericStep<Resource> = ActivatePluginStep | ActivateThemeStep | CpStep | DefineWpConfigConstsStep | DefineSiteUrlStep | EnableMultisiteStep | ImportWxrStep<Resource> | ImportWordPressFilesStep<Resource> | InstallPluginStep<Resource> | InstallThemeStep<Resource> | LoginStep | MkdirStep | MvStep | RequestStep | RmStep | RmdirStep | RunPHPStep | RunPHPWithOptionsStep | RunWpInstallationWizardStep | RunSqlStep<Resource> | SetSiteOptionsStep | UnzipStep<Resource> | UpdateUserMetaStep | WriteFileStep<Resource> | WPCLIStep;
|
|
1696
1548
|
/**
|
|
1697
1549
|
* Progress reporting details.
|
|
1698
1550
|
*/
|