@wp-playground/blueprints 0.9.19 → 0.9.21
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.d.ts +7 -2319
- package/lib/blueprint.d.ts +89 -0
- package/lib/compile.d.ts +47 -0
- package/lib/resources.d.ts +210 -0
- package/package.json +2 -2
- package/vitest-setup-file.d.ts +0 -0
package/index.d.ts
CHANGED
|
@@ -1,2324 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export interface ProgressTrackerOptions {
|
|
9
|
-
/** The weight of the progress, a number between 0 and 1. */
|
|
10
|
-
weight?: number;
|
|
11
|
-
/** The caption to display during progress, a string. */
|
|
12
|
-
caption?: string;
|
|
13
|
-
/** The time in milliseconds to fill the progress, a number. */
|
|
14
|
-
fillTime?: number;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Custom event providing information about a loading process.
|
|
18
|
-
*/
|
|
19
|
-
export type LoadingEvent = CustomEvent<{
|
|
20
|
-
/** The number representing how much was loaded. */
|
|
21
|
-
loaded: number;
|
|
22
|
-
/** The number representing how much needs to loaded in total. */
|
|
23
|
-
total: number;
|
|
24
|
-
}>;
|
|
25
|
-
/**
|
|
26
|
-
* Custom event providing progress details.
|
|
27
|
-
*/
|
|
28
|
-
export type ProgressTrackerEvent = CustomEvent<ProgressDetails>;
|
|
29
|
-
export interface ProgressDetails {
|
|
30
|
-
/** The progress percentage as a number between 0 and 100. */
|
|
31
|
-
progress: number;
|
|
32
|
-
/** The caption to display during progress, a string. */
|
|
33
|
-
caption: string;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* ProgressObserver A function that receives progress updates.
|
|
37
|
-
*
|
|
38
|
-
* @param progress The progress percentage as a number between 0 and 100.
|
|
39
|
-
*/
|
|
40
|
-
export type ProgressObserver = (progress: number) => void;
|
|
41
|
-
/**
|
|
42
|
-
* Listener A function for handling specific event types.
|
|
43
|
-
*
|
|
44
|
-
* @param event The event of type T.
|
|
45
|
-
*/
|
|
46
|
-
export type Listener<T> = (event: T) => void;
|
|
47
|
-
export type TSCompatibleListener<T> = EventListenerOrEventListenerObject | null | Listener<T>;
|
|
48
|
-
export interface ProgressReceiver {
|
|
49
|
-
setProgress(details: ProgressDetails): any;
|
|
50
|
-
setLoaded(): any;
|
|
51
|
-
}
|
|
52
|
-
declare class ProgressTracker extends EventTarget {
|
|
53
|
-
private _selfWeight;
|
|
54
|
-
private _selfDone;
|
|
55
|
-
private _selfProgress;
|
|
56
|
-
private _selfCaption;
|
|
57
|
-
private _weight;
|
|
58
|
-
private _progressObserver?;
|
|
59
|
-
private _loadingListener?;
|
|
60
|
-
private _isFilling;
|
|
61
|
-
private _fillTime;
|
|
62
|
-
private _fillInterval?;
|
|
63
|
-
private _subTrackers;
|
|
64
|
-
constructor({ weight, caption, fillTime, }?: ProgressTrackerOptions);
|
|
65
|
-
/**
|
|
66
|
-
* Creates a new sub-tracker with a specific weight.
|
|
67
|
-
*
|
|
68
|
-
* The weight determines what percentage of the overall progress
|
|
69
|
-
* the sub-tracker represents. For example, if the main tracker is
|
|
70
|
-
* monitoring a process that has two stages, and the first stage
|
|
71
|
-
* is expected to take twice as long as the second stage, you could
|
|
72
|
-
* create the first sub-tracker with a weight of 0.67 and the second
|
|
73
|
-
* sub-tracker with a weight of 0.33.
|
|
74
|
-
*
|
|
75
|
-
* The caption is an optional string that describes the current stage
|
|
76
|
-
* of the operation. If provided, it will be used as the progress caption
|
|
77
|
-
* for the sub-tracker. If not provided, the main tracker will look for
|
|
78
|
-
* the next sub-tracker with a non-empty caption and use that as the progress
|
|
79
|
-
* caption instead.
|
|
80
|
-
*
|
|
81
|
-
* Returns the newly-created sub-tracker.
|
|
82
|
-
*
|
|
83
|
-
* @throws {Error} If the weight of the new stage would cause the total weight of all stages to exceed 1.
|
|
84
|
-
*
|
|
85
|
-
* @param weight The weight of the new stage, as a decimal value between 0 and 1.
|
|
86
|
-
* @param caption The caption for the new stage, which will be used as the progress caption for the sub-tracker.
|
|
87
|
-
*
|
|
88
|
-
* @example
|
|
89
|
-
* ```ts
|
|
90
|
-
* const tracker = new ProgressTracker();
|
|
91
|
-
* const subTracker1 = tracker.stage(0.67, 'Slow stage');
|
|
92
|
-
* const subTracker2 = tracker.stage(0.33, 'Fast stage');
|
|
93
|
-
*
|
|
94
|
-
* subTracker2.set(50);
|
|
95
|
-
* subTracker1.set(75);
|
|
96
|
-
* subTracker2.set(100);
|
|
97
|
-
* subTracker1.set(100);
|
|
98
|
-
* ```
|
|
99
|
-
*/
|
|
100
|
-
stage(weight?: number, caption?: string): ProgressTracker;
|
|
101
|
-
/**
|
|
102
|
-
* Fills the progress bar slowly over time, simulating progress.
|
|
103
|
-
*
|
|
104
|
-
* The progress bar is filled in a 100 steps, and each step, the progress
|
|
105
|
-
* is increased by 1. If `stopBeforeFinishing` is true, the progress bar
|
|
106
|
-
* will stop filling when it reaches 99% so that you can call `finish()`
|
|
107
|
-
* explicitly.
|
|
108
|
-
*
|
|
109
|
-
* If the progress bar is filling or already filled, this method does nothing.
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* ```ts
|
|
113
|
-
* const progress = new ProgressTracker({ caption: 'Processing...' });
|
|
114
|
-
* progress.fillSlowly();
|
|
115
|
-
* ```
|
|
116
|
-
*
|
|
117
|
-
* @param options Optional options.
|
|
118
|
-
*/
|
|
119
|
-
fillSlowly({ stopBeforeFinishing }?: {
|
|
120
|
-
stopBeforeFinishing?: boolean | undefined;
|
|
121
|
-
}): void;
|
|
122
|
-
set(value: number): void;
|
|
123
|
-
finish(): void;
|
|
124
|
-
get caption(): string;
|
|
125
|
-
setCaption(caption: string): void;
|
|
126
|
-
get done(): boolean;
|
|
127
|
-
get progress(): number;
|
|
128
|
-
get weight(): number;
|
|
129
|
-
get observer(): ProgressObserver;
|
|
130
|
-
get loadingListener(): Listener<LoadingEvent>;
|
|
131
|
-
pipe(receiver: ProgressReceiver): void;
|
|
132
|
-
addEventListener(type: string, listener: TSCompatibleListener<ProgressTrackerEvent>): void;
|
|
133
|
-
removeEventListener(type: string, listener: TSCompatibleListener<ProgressTrackerEvent>): void;
|
|
134
|
-
private notifyProgress;
|
|
135
|
-
private notifyDone;
|
|
136
|
-
}
|
|
137
|
-
export interface PHPResponseData {
|
|
138
|
-
/**
|
|
139
|
-
* Response headers.
|
|
140
|
-
*/
|
|
141
|
-
readonly headers: Record<string, string[]>;
|
|
142
|
-
/**
|
|
143
|
-
* Response body. Contains the output from `echo`,
|
|
144
|
-
* `print`, inline HTML etc.
|
|
145
|
-
*/
|
|
146
|
-
readonly bytes: ArrayBuffer;
|
|
147
|
-
/**
|
|
148
|
-
* Stderr contents, if any.
|
|
149
|
-
*/
|
|
150
|
-
readonly errors: string;
|
|
151
|
-
/**
|
|
152
|
-
* The exit code of the script. `0` is a success, while
|
|
153
|
-
* `1` and `2` indicate an error.
|
|
154
|
-
*/
|
|
155
|
-
readonly exitCode: number;
|
|
156
|
-
/**
|
|
157
|
-
* Response HTTP status code, e.g. 200.
|
|
158
|
-
*/
|
|
159
|
-
readonly httpStatusCode: number;
|
|
160
|
-
}
|
|
161
|
-
declare class PHPResponse implements PHPResponseData {
|
|
162
|
-
/** @inheritDoc */
|
|
163
|
-
readonly headers: Record<string, string[]>;
|
|
164
|
-
/** @inheritDoc */
|
|
165
|
-
readonly bytes: ArrayBuffer;
|
|
166
|
-
/** @inheritDoc */
|
|
167
|
-
readonly errors: string;
|
|
168
|
-
/** @inheritDoc */
|
|
169
|
-
readonly exitCode: number;
|
|
170
|
-
/** @inheritDoc */
|
|
171
|
-
readonly httpStatusCode: number;
|
|
172
|
-
constructor(httpStatusCode: number, headers: Record<string, string[]>, body: ArrayBuffer, errors?: string, exitCode?: number);
|
|
173
|
-
static forHttpCode(httpStatusCode: number, text?: string): PHPResponse;
|
|
174
|
-
static fromRawData(data: PHPResponseData): PHPResponse;
|
|
175
|
-
toRawData(): PHPResponseData;
|
|
176
|
-
/**
|
|
177
|
-
* Response body as JSON.
|
|
178
|
-
*/
|
|
179
|
-
get json(): any;
|
|
180
|
-
/**
|
|
181
|
-
* Response body as text.
|
|
182
|
-
*/
|
|
183
|
-
get text(): string;
|
|
184
|
-
}
|
|
185
|
-
export type PHPRuntimeId = number;
|
|
186
|
-
/** Other WebAssembly declarations, for compatibility with older versions of Typescript */
|
|
187
|
-
export declare namespace Emscripten {
|
|
188
|
-
export interface RootFS extends Emscripten.FileSystemInstance {
|
|
189
|
-
filesystems: Record<string, Emscripten.FileSystemType>;
|
|
190
|
-
}
|
|
191
|
-
export interface FileSystemType {
|
|
192
|
-
mount(mount: FS.Mount): FS.FSNode;
|
|
193
|
-
syncfs(mount: FS.Mount, populate: () => unknown, done: (err?: number | null) => unknown): void;
|
|
194
|
-
}
|
|
195
|
-
export type EnvironmentType = "WEB" | "NODE" | "SHELL" | "WORKER";
|
|
196
|
-
export type JSType = "number" | "string" | "array" | "boolean";
|
|
197
|
-
export type TypeCompatibleWithC = number | string | any[] | boolean;
|
|
198
|
-
export type CIntType = "i8" | "i16" | "i32" | "i64";
|
|
199
|
-
export type CFloatType = "float" | "double";
|
|
200
|
-
export type CPointerType = "i8*" | "i16*" | "i32*" | "i64*" | "float*" | "double*" | "*";
|
|
201
|
-
export type CType = CIntType | CFloatType | CPointerType;
|
|
202
|
-
export interface CCallOpts {
|
|
203
|
-
async?: boolean | undefined;
|
|
204
|
-
}
|
|
205
|
-
type NamespaceToInstance<T> = {
|
|
206
|
-
[K in keyof T]: T[K] extends (...args: any[]) => any ? T[K] : never;
|
|
207
|
-
};
|
|
208
|
-
export type FileSystemInstance = NamespaceToInstance<typeof FS> & {
|
|
209
|
-
mkdirTree(path: string): void;
|
|
210
|
-
lookupPath(path: string, opts?: any): FS.Lookup;
|
|
211
|
-
};
|
|
212
|
-
export interface EmscriptenModule {
|
|
213
|
-
print(str: string): void;
|
|
214
|
-
printErr(str: string): void;
|
|
215
|
-
arguments: string[];
|
|
216
|
-
environment: Emscripten.EnvironmentType;
|
|
217
|
-
preInit: Array<{
|
|
218
|
-
(): void;
|
|
219
|
-
}>;
|
|
220
|
-
preRun: Array<{
|
|
221
|
-
(): void;
|
|
222
|
-
}>;
|
|
223
|
-
postRun: Array<{
|
|
224
|
-
(): void;
|
|
225
|
-
}>;
|
|
226
|
-
onAbort: {
|
|
227
|
-
(what: any): void;
|
|
228
|
-
};
|
|
229
|
-
onRuntimeInitialized: {
|
|
230
|
-
(): void;
|
|
231
|
-
};
|
|
232
|
-
preinitializedWebGLContext: WebGLRenderingContext;
|
|
233
|
-
noInitialRun: boolean;
|
|
234
|
-
noExitRuntime: boolean;
|
|
235
|
-
logReadFiles: boolean;
|
|
236
|
-
filePackagePrefixURL: string;
|
|
237
|
-
wasmBinary: ArrayBuffer;
|
|
238
|
-
destroy(object: object): void;
|
|
239
|
-
getPreloadedPackage(remotePackageName: string, remotePackageSize: number): ArrayBuffer;
|
|
240
|
-
instantiateWasm(imports: WebAssembly.Imports, successCallback: (module: WebAssembly.Instance) => void): WebAssembly.Exports | undefined;
|
|
241
|
-
locateFile(url: string, scriptDirectory: string): string;
|
|
242
|
-
onCustomMessage(event: MessageEvent): void;
|
|
243
|
-
HEAP: Int32Array;
|
|
244
|
-
IHEAP: Int32Array;
|
|
245
|
-
FHEAP: Float64Array;
|
|
246
|
-
HEAP8: Int8Array;
|
|
247
|
-
HEAP16: Int16Array;
|
|
248
|
-
HEAP32: Int32Array;
|
|
249
|
-
HEAPU8: Uint8Array;
|
|
250
|
-
HEAPU16: Uint16Array;
|
|
251
|
-
HEAPU32: Uint32Array;
|
|
252
|
-
HEAPF32: Float32Array;
|
|
253
|
-
HEAPF64: Float64Array;
|
|
254
|
-
HEAP64: BigInt64Array;
|
|
255
|
-
HEAPU64: BigUint64Array;
|
|
256
|
-
TOTAL_STACK: number;
|
|
257
|
-
TOTAL_MEMORY: number;
|
|
258
|
-
FAST_MEMORY: number;
|
|
259
|
-
addOnPreRun(cb: () => any): void;
|
|
260
|
-
addOnInit(cb: () => any): void;
|
|
261
|
-
addOnPreMain(cb: () => any): void;
|
|
262
|
-
addOnExit(cb: () => any): void;
|
|
263
|
-
addOnPostRun(cb: () => any): void;
|
|
264
|
-
preloadedImages: any;
|
|
265
|
-
preloadedAudios: any;
|
|
266
|
-
_malloc(size: number): number;
|
|
267
|
-
_free(ptr: number): void;
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* A factory function is generated when setting the `MODULARIZE` build option
|
|
271
|
-
* to `1` in your Emscripten build. It return a Promise that resolves to an
|
|
272
|
-
* initialized, ready-to-call `EmscriptenModule` instance.
|
|
273
|
-
*
|
|
274
|
-
* By default, the factory function will be named `Module`. It's recommended to
|
|
275
|
-
* use the `EXPORT_ES6` option, in which the factory function will be the
|
|
276
|
-
* default export. If used without `EXPORT_ES6`, the factory function will be a
|
|
277
|
-
* global variable. You can rename the variable using the `EXPORT_NAME` build
|
|
278
|
-
* option. It's left to you to export any global variables as needed in your
|
|
279
|
-
* application's types.
|
|
280
|
-
* @param moduleOverrides Default properties for the initialized module.
|
|
281
|
-
*/
|
|
282
|
-
export type EmscriptenModuleFactory<T extends EmscriptenModule = EmscriptenModule> = (moduleOverrides?: Partial<T>) => Promise<T>;
|
|
283
|
-
export namespace FS {
|
|
284
|
-
interface Lookup {
|
|
285
|
-
path: string;
|
|
286
|
-
node: FSNode;
|
|
287
|
-
}
|
|
288
|
-
interface Analyze {
|
|
289
|
-
isRoot: boolean;
|
|
290
|
-
exists: boolean;
|
|
291
|
-
error: Error;
|
|
292
|
-
name: string;
|
|
293
|
-
path: Lookup["path"];
|
|
294
|
-
object: Lookup["node"];
|
|
295
|
-
parentExists: boolean;
|
|
296
|
-
parentPath: Lookup["path"];
|
|
297
|
-
parentObject: Lookup["node"];
|
|
298
|
-
}
|
|
299
|
-
interface Mount {
|
|
300
|
-
type: Emscripten.FileSystemType;
|
|
301
|
-
opts: object;
|
|
302
|
-
mountpoint: string;
|
|
303
|
-
mounts: Mount[];
|
|
304
|
-
root: FSNode;
|
|
305
|
-
}
|
|
306
|
-
class FSStream {
|
|
307
|
-
constructor();
|
|
308
|
-
object: FSNode;
|
|
309
|
-
readonly isRead: boolean;
|
|
310
|
-
readonly isWrite: boolean;
|
|
311
|
-
readonly isAppend: boolean;
|
|
312
|
-
flags: number;
|
|
313
|
-
position: number;
|
|
314
|
-
}
|
|
315
|
-
class FSNode {
|
|
316
|
-
parent: FSNode;
|
|
317
|
-
mount: Mount;
|
|
318
|
-
mounted?: Mount;
|
|
319
|
-
id: number;
|
|
320
|
-
name: string;
|
|
321
|
-
mode: number;
|
|
322
|
-
rdev: number;
|
|
323
|
-
readMode: number;
|
|
324
|
-
writeMode: number;
|
|
325
|
-
constructor(parent: FSNode, name: string, mode: number, rdev: number);
|
|
326
|
-
read: boolean;
|
|
327
|
-
write: boolean;
|
|
328
|
-
readonly isFolder: boolean;
|
|
329
|
-
readonly isDevice: boolean;
|
|
330
|
-
}
|
|
331
|
-
interface ErrnoError extends Error {
|
|
332
|
-
name: "ErronoError";
|
|
333
|
-
errno: number;
|
|
334
|
-
code: string;
|
|
335
|
-
}
|
|
336
|
-
function lookupPath(path: string, opts: any): Lookup;
|
|
337
|
-
function getPath(node: FSNode): string;
|
|
338
|
-
function analyzePath(path: string, dontResolveLastLink?: boolean): Analyze;
|
|
339
|
-
function isFile(mode: number): boolean;
|
|
340
|
-
function isDir(mode: number): boolean;
|
|
341
|
-
function isLink(mode: number): boolean;
|
|
342
|
-
function isChrdev(mode: number): boolean;
|
|
343
|
-
function isBlkdev(mode: number): boolean;
|
|
344
|
-
function isFIFO(mode: number): boolean;
|
|
345
|
-
function isSocket(mode: number): boolean;
|
|
346
|
-
function major(dev: number): number;
|
|
347
|
-
function minor(dev: number): number;
|
|
348
|
-
function makedev(ma: number, mi: number): number;
|
|
349
|
-
function registerDevice(dev: number, ops: any): void;
|
|
350
|
-
function syncfs(populate: boolean, callback: (e: any) => any): void;
|
|
351
|
-
function syncfs(callback: (e: any) => any, populate?: boolean): void;
|
|
352
|
-
function mount(type: Emscripten.FileSystemType, opts: any, mountpoint: string): any;
|
|
353
|
-
function unmount(mountpoint: string): void;
|
|
354
|
-
function mkdir(path: string, mode?: number): any;
|
|
355
|
-
function mkdev(path: string, mode?: number, dev?: number): any;
|
|
356
|
-
function symlink(oldpath: string, newpath: string): any;
|
|
357
|
-
function rename(old_path: string, new_path: string): void;
|
|
358
|
-
function rmdir(path: string): void;
|
|
359
|
-
function readdir(path: string): any;
|
|
360
|
-
function unlink(path: string): void;
|
|
361
|
-
function readlink(path: string): string;
|
|
362
|
-
function stat(path: string, dontFollow?: boolean): any;
|
|
363
|
-
function lstat(path: string): any;
|
|
364
|
-
function chmod(path: string, mode: number, dontFollow?: boolean): void;
|
|
365
|
-
function lchmod(path: string, mode: number): void;
|
|
366
|
-
function fchmod(fd: number, mode: number): void;
|
|
367
|
-
function chown(path: string, uid: number, gid: number, dontFollow?: boolean): void;
|
|
368
|
-
function lchown(path: string, uid: number, gid: number): void;
|
|
369
|
-
function fchown(fd: number, uid: number, gid: number): void;
|
|
370
|
-
function truncate(path: string, len: number): void;
|
|
371
|
-
function ftruncate(fd: number, len: number): void;
|
|
372
|
-
function utime(path: string, atime: number, mtime: number): void;
|
|
373
|
-
function open(path: string, flags: string, mode?: number, fd_start?: number, fd_end?: number): FSStream;
|
|
374
|
-
function close(stream: FSStream): void;
|
|
375
|
-
function llseek(stream: FSStream, offset: number, whence: number): any;
|
|
376
|
-
function read(stream: FSStream, buffer: ArrayBufferView, offset: number, length: number, position?: number): number;
|
|
377
|
-
function write(stream: FSStream, buffer: ArrayBufferView, offset: number, length: number, position?: number, canOwn?: boolean): number;
|
|
378
|
-
function allocate(stream: FSStream, offset: number, length: number): void;
|
|
379
|
-
function mmap(stream: FSStream, buffer: ArrayBufferView, offset: number, length: number, position: number, prot: number, flags: number): any;
|
|
380
|
-
function ioctl(stream: FSStream, cmd: any, arg: any): any;
|
|
381
|
-
function readFile(path: string, opts: {
|
|
382
|
-
encoding: "binary";
|
|
383
|
-
flags?: string | undefined;
|
|
384
|
-
}): Uint8Array;
|
|
385
|
-
function readFile(path: string, opts: {
|
|
386
|
-
encoding: "utf8";
|
|
387
|
-
flags?: string | undefined;
|
|
388
|
-
}): string;
|
|
389
|
-
function readFile(path: string, opts?: {
|
|
390
|
-
flags?: string | undefined;
|
|
391
|
-
}): Uint8Array;
|
|
392
|
-
function writeFile(path: string, data: string | ArrayBufferView, opts?: {
|
|
393
|
-
flags?: string | undefined;
|
|
394
|
-
}): void;
|
|
395
|
-
function cwd(): string;
|
|
396
|
-
function chdir(path: string): void;
|
|
397
|
-
function init(input: null | (() => number | null), output: null | ((c: number) => any), error: null | ((c: number) => any)): void;
|
|
398
|
-
function createLazyFile(parent: string | FSNode, name: string, url: string, canRead: boolean, canWrite: boolean): FSNode;
|
|
399
|
-
function createPreloadedFile(parent: string | FSNode, name: string, url: string, canRead: boolean, canWrite: boolean, onload?: () => void, onerror?: () => void, dontCreateFile?: boolean, canOwn?: boolean): void;
|
|
400
|
-
function createDataFile(parent: string | FSNode, name: string, data: ArrayBufferView, canRead: boolean, canWrite: boolean, canOwn: boolean): FSNode;
|
|
401
|
-
}
|
|
402
|
-
export const MEMFS: Emscripten.FileSystemType;
|
|
403
|
-
export const NODEFS: Emscripten.FileSystemType;
|
|
404
|
-
export const IDBFS: Emscripten.FileSystemType;
|
|
405
|
-
type StringToType<R> = R extends Emscripten.JSType ? {
|
|
406
|
-
number: number;
|
|
407
|
-
string: string;
|
|
408
|
-
array: number[] | string[] | boolean[] | Uint8Array | Int8Array;
|
|
409
|
-
boolean: boolean;
|
|
410
|
-
null: null;
|
|
411
|
-
}[R] : never;
|
|
412
|
-
type ArgsToType<T extends Array<Emscripten.JSType | null>> = Extract<{
|
|
413
|
-
[P in keyof T]: StringToType<T[P]>;
|
|
414
|
-
}, any[]>;
|
|
415
|
-
type ReturnToType<R extends Emscripten.JSType | null> = R extends null ? null : StringToType<Exclude<R, null>>;
|
|
416
|
-
export function cwrap<I extends Array<Emscripten.JSType | null> | [
|
|
417
|
-
], R extends Emscripten.JSType | null>(ident: string, returnType: R, argTypes: I, opts?: Emscripten.CCallOpts): (...arg: ArgsToType<I>) => ReturnToType<R>;
|
|
418
|
-
export function ccall<I extends Array<Emscripten.JSType | null> | [
|
|
419
|
-
], R extends Emscripten.JSType | null>(ident: string, returnType: R, argTypes: I, args: ArgsToType<I>, opts?: Emscripten.CCallOpts): ReturnToType<R>;
|
|
420
|
-
export function setValue(ptr: number, value: any, type: Emscripten.CType, noSafe?: boolean): void;
|
|
421
|
-
export function getValue(ptr: number, type: Emscripten.CType, noSafe?: boolean): number;
|
|
422
|
-
export function allocate(slab: number[] | ArrayBufferView | number, types: Emscripten.CType | Emscripten.CType[], allocator: number, ptr?: number): number;
|
|
423
|
-
export function stackAlloc(size: number): number;
|
|
424
|
-
export function stackSave(): number;
|
|
425
|
-
export function stackRestore(ptr: number): void;
|
|
426
|
-
export function UTF8ToString(ptr: number, maxBytesToRead?: number): string;
|
|
427
|
-
export function stringToUTF8(str: string, outPtr: number, maxBytesToRead?: number): void;
|
|
428
|
-
export function lengthBytesUTF8(str: string): number;
|
|
429
|
-
export function allocateUTF8(str: string): number;
|
|
430
|
-
export function allocateUTF8OnStack(str: string): number;
|
|
431
|
-
export function UTF16ToString(ptr: number): string;
|
|
432
|
-
export function stringToUTF16(str: string, outPtr: number, maxBytesToRead?: number): void;
|
|
433
|
-
export function lengthBytesUTF16(str: string): number;
|
|
434
|
-
export function UTF32ToString(ptr: number): string;
|
|
435
|
-
export function stringToUTF32(str: string, outPtr: number, maxBytesToRead?: number): void;
|
|
436
|
-
export function lengthBytesUTF32(str: string): number;
|
|
437
|
-
export function intArrayFromString(stringy: string, dontAddNull?: boolean, length?: number): number[];
|
|
438
|
-
export function intArrayToString(array: number[]): string;
|
|
439
|
-
export function writeStringToMemory(str: string, buffer: number, dontAddNull: boolean): void;
|
|
440
|
-
export function writeArrayToMemory(array: number[], buffer: number): void;
|
|
441
|
-
export function writeAsciiToMemory(str: string, buffer: number, dontAddNull: boolean): void;
|
|
442
|
-
export function addRunDependency(id: any): void;
|
|
443
|
-
export function removeRunDependency(id: any): void;
|
|
444
|
-
export function addFunction(func: (...args: any[]) => any, signature?: string): number;
|
|
445
|
-
export function removeFunction(funcPtr: number): void;
|
|
446
|
-
export const ALLOC_NORMAL: number;
|
|
447
|
-
export const ALLOC_STACK: number;
|
|
448
|
-
export const ALLOC_STATIC: number;
|
|
449
|
-
export const ALLOC_DYNAMIC: number;
|
|
450
|
-
export const ALLOC_NONE: number;
|
|
451
|
-
export {};
|
|
452
|
-
}
|
|
453
|
-
export interface RmDirOptions {
|
|
454
|
-
/**
|
|
455
|
-
* If true, recursively removes the directory and all its contents.
|
|
456
|
-
* Default: true.
|
|
457
|
-
*/
|
|
458
|
-
recursive?: boolean;
|
|
459
|
-
}
|
|
460
|
-
export interface ListFilesOptions {
|
|
461
|
-
/**
|
|
462
|
-
* If true, prepend given folder path to all file names.
|
|
463
|
-
* Default: false.
|
|
464
|
-
*/
|
|
465
|
-
prependPath: boolean;
|
|
466
|
-
}
|
|
467
|
-
export interface SemaphoreOptions {
|
|
468
|
-
/**
|
|
469
|
-
* The maximum number of concurrent locks.
|
|
470
|
-
*/
|
|
471
|
-
concurrency: number;
|
|
472
|
-
/**
|
|
473
|
-
* The maximum time to wait for a lock to become available.
|
|
474
|
-
*/
|
|
475
|
-
timeout?: number;
|
|
476
|
-
}
|
|
477
|
-
declare class Semaphore {
|
|
478
|
-
private _running;
|
|
479
|
-
private concurrency;
|
|
480
|
-
private timeout?;
|
|
481
|
-
private queue;
|
|
482
|
-
constructor({ concurrency, timeout }: SemaphoreOptions);
|
|
483
|
-
get remaining(): number;
|
|
484
|
-
get running(): number;
|
|
485
|
-
acquire(): Promise<() => void>;
|
|
486
|
-
run<T>(fn: () => T | Promise<T>): Promise<T>;
|
|
487
|
-
}
|
|
488
|
-
export type PHPFactoryOptions = {
|
|
489
|
-
isPrimary: boolean;
|
|
490
|
-
};
|
|
491
|
-
export type PHPFactory = (options: PHPFactoryOptions) => Promise<PHP>;
|
|
492
|
-
export interface ProcessManagerOptions {
|
|
493
|
-
/**
|
|
494
|
-
* The maximum number of PHP instances that can exist at
|
|
495
|
-
* the same time.
|
|
496
|
-
*/
|
|
497
|
-
maxPhpInstances?: number;
|
|
498
|
-
/**
|
|
499
|
-
* The number of milliseconds to wait for a PHP instance when
|
|
500
|
-
* we have reached the maximum number of PHP instances and
|
|
501
|
-
* cannot spawn a new one. If the timeout is reached, we assume
|
|
502
|
-
* all the PHP instances are deadlocked and a throw MaxPhpInstancesError.
|
|
503
|
-
*
|
|
504
|
-
* Default: 5000
|
|
505
|
-
*/
|
|
506
|
-
timeout?: number;
|
|
507
|
-
/**
|
|
508
|
-
* The primary PHP instance that's never killed. This instance
|
|
509
|
-
* contains the reference filesystem used by all other PHP instances.
|
|
510
|
-
*/
|
|
511
|
-
primaryPhp?: PHP;
|
|
512
|
-
/**
|
|
513
|
-
* A factory function used for spawning new PHP instances.
|
|
514
|
-
*/
|
|
515
|
-
phpFactory?: PHPFactory;
|
|
516
|
-
}
|
|
517
|
-
export interface SpawnedPHP {
|
|
518
|
-
php: PHP;
|
|
519
|
-
reap: () => void;
|
|
520
|
-
}
|
|
521
|
-
declare class PHPProcessManager implements AsyncDisposable {
|
|
522
|
-
private primaryPhp?;
|
|
523
|
-
private primaryIdle;
|
|
524
|
-
private nextInstance;
|
|
525
|
-
/**
|
|
526
|
-
* All spawned PHP instances, including the primary PHP instance.
|
|
527
|
-
* Used for bookkeeping and reaping all instances on dispose.
|
|
528
|
-
*/
|
|
529
|
-
private allInstances;
|
|
530
|
-
private phpFactory?;
|
|
531
|
-
private maxPhpInstances;
|
|
532
|
-
private semaphore;
|
|
533
|
-
constructor(options?: ProcessManagerOptions);
|
|
534
|
-
/**
|
|
535
|
-
* Get the primary PHP instance.
|
|
536
|
-
*
|
|
537
|
-
* If the primary PHP instance is not set, it will be spawned
|
|
538
|
-
* using the provided phpFactory.
|
|
539
|
-
*
|
|
540
|
-
* @throws {Error} when called twice before the first call is resolved.
|
|
541
|
-
*/
|
|
542
|
-
getPrimaryPhp(): Promise<PHP>;
|
|
543
|
-
/**
|
|
544
|
-
* Get a PHP instance.
|
|
545
|
-
*
|
|
546
|
-
* It could be either the primary PHP instance, an idle disposable PHP instance,
|
|
547
|
-
* or a newly spawned PHP instance – depending on the resource availability.
|
|
548
|
-
*
|
|
549
|
-
* @throws {MaxPhpInstancesError} when the maximum number of PHP instances is reached
|
|
550
|
-
* and the waiting timeout is exceeded.
|
|
551
|
-
*/
|
|
552
|
-
acquirePHPInstance(): Promise<SpawnedPHP>;
|
|
553
|
-
/**
|
|
554
|
-
* Initiated spawning of a new PHP instance.
|
|
555
|
-
* This function is synchronous on purpose – it needs to synchronously
|
|
556
|
-
* add the spawn promise to the allInstances array without waiting
|
|
557
|
-
* for PHP to spawn.
|
|
558
|
-
*/
|
|
559
|
-
private spawn;
|
|
560
|
-
/**
|
|
561
|
-
* Actually acquires the lock and spawns a new PHP instance.
|
|
562
|
-
*/
|
|
563
|
-
private doSpawn;
|
|
564
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
565
|
-
}
|
|
566
|
-
export type RewriteRule = {
|
|
567
|
-
match: RegExp;
|
|
568
|
-
replacement: string;
|
|
569
|
-
};
|
|
570
|
-
export interface BaseConfiguration {
|
|
571
|
-
/**
|
|
572
|
-
* The directory in the PHP filesystem where the server will look
|
|
573
|
-
* for the files to serve. Default: `/var/www`.
|
|
574
|
-
*/
|
|
575
|
-
documentRoot?: string;
|
|
576
|
-
/**
|
|
577
|
-
* Request Handler URL. Used to populate $_SERVER details like HTTP_HOST.
|
|
578
|
-
*/
|
|
579
|
-
absoluteUrl?: string;
|
|
580
|
-
/**
|
|
581
|
-
* Rewrite rules
|
|
582
|
-
*/
|
|
583
|
-
rewriteRules?: RewriteRule[];
|
|
584
|
-
}
|
|
585
|
-
export type PHPRequestHandlerFactoryArgs = PHPFactoryOptions & {
|
|
586
|
-
requestHandler: PHPRequestHandler;
|
|
587
|
-
};
|
|
588
|
-
export type PHPRequestHandlerConfiguration = BaseConfiguration & ({
|
|
589
|
-
/**
|
|
590
|
-
* PHPProcessManager is required because the request handler needs
|
|
591
|
-
* to make a decision for each request.
|
|
592
|
-
*
|
|
593
|
-
* Static assets are served using the primary PHP's filesystem, even
|
|
594
|
-
* when serving 100 static files concurrently. No new PHP interpreter
|
|
595
|
-
* is ever created as there's no need for it.
|
|
596
|
-
*
|
|
597
|
-
* Dynamic PHP requests, however, require grabbing an available PHP
|
|
598
|
-
* interpreter, and that's where the PHPProcessManager comes in.
|
|
599
|
-
*/
|
|
600
|
-
processManager: PHPProcessManager;
|
|
601
|
-
} | {
|
|
602
|
-
phpFactory: (requestHandler: PHPRequestHandlerFactoryArgs) => Promise<PHP>;
|
|
603
|
-
/**
|
|
604
|
-
* The maximum number of PHP instances that can exist at
|
|
605
|
-
* the same time.
|
|
606
|
-
*/
|
|
607
|
-
maxPhpInstances?: number;
|
|
608
|
-
});
|
|
609
|
-
declare class PHPRequestHandler {
|
|
610
|
-
#private;
|
|
611
|
-
rewriteRules: RewriteRule[];
|
|
612
|
-
processManager: PHPProcessManager;
|
|
613
|
-
/**
|
|
614
|
-
* The request handler needs to decide whether to serve a static asset or
|
|
615
|
-
* run the PHP interpreter. For static assets it should just reuse the primary
|
|
616
|
-
* PHP even if there's 50 concurrent requests to serve. However, for
|
|
617
|
-
* dynamic PHP requests, it needs to grab an available interpreter.
|
|
618
|
-
* Therefore, it cannot just accept PHP as an argument as serving requests
|
|
619
|
-
* requires access to ProcessManager.
|
|
620
|
-
*
|
|
621
|
-
* @param php - The PHP instance.
|
|
622
|
-
* @param config - Request Handler configuration.
|
|
623
|
-
*/
|
|
624
|
-
constructor(config: PHPRequestHandlerConfiguration);
|
|
625
|
-
getPrimaryPhp(): Promise<PHP>;
|
|
626
|
-
/**
|
|
627
|
-
* Converts a path to an absolute URL based at the PHPRequestHandler
|
|
628
|
-
* root.
|
|
629
|
-
*
|
|
630
|
-
* @param path The server path to convert to an absolute URL.
|
|
631
|
-
* @returns The absolute URL.
|
|
632
|
-
*/
|
|
633
|
-
pathToInternalUrl(path: string): string;
|
|
634
|
-
/**
|
|
635
|
-
* Converts an absolute URL based at the PHPRequestHandler to a relative path
|
|
636
|
-
* without the server pathname and scope.
|
|
637
|
-
*
|
|
638
|
-
* @param internalUrl An absolute URL based at the PHPRequestHandler root.
|
|
639
|
-
* @returns The relative path.
|
|
640
|
-
*/
|
|
641
|
-
internalUrlToPath(internalUrl: string): string;
|
|
642
|
-
/**
|
|
643
|
-
* The absolute URL of this PHPRequestHandler instance.
|
|
644
|
-
*/
|
|
645
|
-
get absoluteUrl(): string;
|
|
646
|
-
/**
|
|
647
|
-
* The directory in the PHP filesystem where the server will look
|
|
648
|
-
* for the files to serve. Default: `/var/www`.
|
|
649
|
-
*/
|
|
650
|
-
get documentRoot(): string;
|
|
651
|
-
/**
|
|
652
|
-
* Serves the request – either by serving a static file, or by
|
|
653
|
-
* dispatching it to the PHP runtime.
|
|
654
|
-
*
|
|
655
|
-
* The request() method mode behaves like a web server and only works if
|
|
656
|
-
* the PHP was initialized with a `requestHandler` option (which the online version
|
|
657
|
-
* of WordPress Playground does by default).
|
|
658
|
-
*
|
|
659
|
-
* In the request mode, you pass an object containing the request information
|
|
660
|
-
* (method, headers, body, etc.) and the path to the PHP file to run:
|
|
661
|
-
*
|
|
662
|
-
* ```ts
|
|
663
|
-
* const php = PHP.load('7.4', {
|
|
664
|
-
* requestHandler: {
|
|
665
|
-
* documentRoot: "/www"
|
|
666
|
-
* }
|
|
667
|
-
* })
|
|
668
|
-
* php.writeFile("/www/index.php", `<?php echo file_get_contents("php://input");`);
|
|
669
|
-
* const result = await php.request({
|
|
670
|
-
* method: "GET",
|
|
671
|
-
* headers: {
|
|
672
|
-
* "Content-Type": "text/plain"
|
|
673
|
-
* },
|
|
674
|
-
* body: "Hello world!",
|
|
675
|
-
* path: "/www/index.php"
|
|
676
|
-
* });
|
|
677
|
-
* // result.text === "Hello world!"
|
|
678
|
-
* ```
|
|
679
|
-
*
|
|
680
|
-
* The `request()` method cannot be used in conjunction with `cli()`.
|
|
681
|
-
*
|
|
682
|
-
* @example
|
|
683
|
-
* ```js
|
|
684
|
-
* const output = await php.request({
|
|
685
|
-
* method: 'GET',
|
|
686
|
-
* url: '/index.php',
|
|
687
|
-
* headers: {
|
|
688
|
-
* 'X-foo': 'bar',
|
|
689
|
-
* },
|
|
690
|
-
* body: {
|
|
691
|
-
* foo: 'bar',
|
|
692
|
-
* },
|
|
693
|
-
* });
|
|
694
|
-
* console.log(output.stdout); // "Hello world!"
|
|
695
|
-
* ```
|
|
696
|
-
*
|
|
697
|
-
* @param request - PHP Request data.
|
|
698
|
-
*/
|
|
699
|
-
request(request: PHPRequest): Promise<PHPResponse>;
|
|
700
|
-
}
|
|
701
|
-
declare const __private__dont__use: unique symbol;
|
|
702
|
-
export type UnmountFunction = (() => Promise<any>) | (() => any);
|
|
703
|
-
export type MountHandler = (php: PHP, FS: Emscripten.RootFS, vfsMountPoint: string) => UnmountFunction | Promise<UnmountFunction>;
|
|
704
|
-
declare class PHP implements Disposable {
|
|
705
|
-
#private;
|
|
706
|
-
protected [__private__dont__use]: any;
|
|
707
|
-
requestHandler?: PHPRequestHandler;
|
|
708
|
-
/**
|
|
709
|
-
* An exclusive lock that prevent multiple requests from running at
|
|
710
|
-
* the same time.
|
|
711
|
-
*/
|
|
712
|
-
semaphore: Semaphore;
|
|
713
|
-
/**
|
|
714
|
-
* Initializes a PHP runtime.
|
|
715
|
-
*
|
|
716
|
-
* @internal
|
|
717
|
-
* @param PHPRuntime - Optional. PHP Runtime ID as initialized by loadPHPRuntime.
|
|
718
|
-
* @param requestHandlerOptions - Optional. Options for the PHPRequestHandler. If undefined, no request handler will be initialized.
|
|
719
|
-
*/
|
|
720
|
-
constructor(PHPRuntimeId?: PHPRuntimeId);
|
|
721
|
-
/**
|
|
722
|
-
* Adds an event listener for a PHP event.
|
|
723
|
-
* @param eventType - The type of event to listen for.
|
|
724
|
-
* @param listener - The listener function to be called when the event is triggered.
|
|
725
|
-
*/
|
|
726
|
-
addEventListener(eventType: PHPEvent["type"], listener: PHPEventListener): void;
|
|
727
|
-
/**
|
|
728
|
-
* Removes an event listener for a PHP event.
|
|
729
|
-
* @param eventType - The type of event to remove the listener from.
|
|
730
|
-
* @param listener - The listener function to be removed.
|
|
731
|
-
*/
|
|
732
|
-
removeEventListener(eventType: PHPEvent["type"], listener: PHPEventListener): void;
|
|
733
|
-
dispatchEvent<Event extends PHPEvent>(event: Event): void;
|
|
734
|
-
/**
|
|
735
|
-
* Listens to message sent by the PHP code.
|
|
736
|
-
*
|
|
737
|
-
* To dispatch messages, call:
|
|
738
|
-
*
|
|
739
|
-
* post_message_to_js(string $data)
|
|
740
|
-
*
|
|
741
|
-
* Arguments:
|
|
742
|
-
* $data (string) – Data to pass to JavaScript.
|
|
743
|
-
*
|
|
744
|
-
* @example
|
|
745
|
-
*
|
|
746
|
-
* ```ts
|
|
747
|
-
* const php = await PHP.load('8.0');
|
|
748
|
-
*
|
|
749
|
-
* php.onMessage(
|
|
750
|
-
* // The data is always passed as a string
|
|
751
|
-
* function (data: string) {
|
|
752
|
-
* // Let's decode and log the data:
|
|
753
|
-
* console.log(JSON.parse(data));
|
|
754
|
-
* }
|
|
755
|
-
* );
|
|
756
|
-
*
|
|
757
|
-
* // Now that we have a listener in place, let's
|
|
758
|
-
* // dispatch a message:
|
|
759
|
-
* await php.run({
|
|
760
|
-
* code: `<?php
|
|
761
|
-
* post_message_to_js(
|
|
762
|
-
* json_encode([
|
|
763
|
-
* 'post_id' => '15',
|
|
764
|
-
* 'post_title' => 'This is a blog post!'
|
|
765
|
-
* ])
|
|
766
|
-
* ));
|
|
767
|
-
* `,
|
|
768
|
-
* });
|
|
769
|
-
* ```
|
|
770
|
-
*
|
|
771
|
-
* @param listener Callback function to handle the message.
|
|
772
|
-
*/
|
|
773
|
-
onMessage(listener: MessageListener): void;
|
|
774
|
-
setSpawnHandler(handler: SpawnHandler | string): Promise<void>;
|
|
775
|
-
/** @deprecated Use PHPRequestHandler instead. */
|
|
776
|
-
get absoluteUrl(): string;
|
|
777
|
-
/** @deprecated Use PHPRequestHandler instead. */
|
|
778
|
-
get documentRoot(): string;
|
|
779
|
-
/** @deprecated Use PHPRequestHandler instead. */
|
|
780
|
-
pathToInternalUrl(path: string): string;
|
|
781
|
-
/** @deprecated Use PHPRequestHandler instead. */
|
|
782
|
-
internalUrlToPath(internalUrl: string): string;
|
|
783
|
-
initializeRuntime(runtimeId: PHPRuntimeId): void;
|
|
784
|
-
/** @inheritDoc */
|
|
785
|
-
setSapiName(newName: string): Promise<void>;
|
|
786
|
-
/**
|
|
787
|
-
* Changes the current working directory in the PHP filesystem.
|
|
788
|
-
* This is the directory that will be used as the base for relative paths.
|
|
789
|
-
* For example, if the current working directory is `/root/php`, and the
|
|
790
|
-
* path is `data`, the absolute path will be `/root/php/data`.
|
|
791
|
-
*
|
|
792
|
-
* @param path - The new working directory.
|
|
793
|
-
*/
|
|
794
|
-
chdir(path: string): void;
|
|
795
|
-
/**
|
|
796
|
-
* Do not use. Use new PHPRequestHandler() instead.
|
|
797
|
-
* @deprecated
|
|
798
|
-
*/
|
|
799
|
-
request(request: PHPRequest): Promise<PHPResponse>;
|
|
800
|
-
/**
|
|
801
|
-
* Runs PHP code.
|
|
802
|
-
*
|
|
803
|
-
* This low-level method directly interacts with the WebAssembly
|
|
804
|
-
* PHP interpreter.
|
|
805
|
-
*
|
|
806
|
-
* Every time you call run(), it prepares the PHP
|
|
807
|
-
* environment and:
|
|
808
|
-
*
|
|
809
|
-
* * Resets the internal PHP state
|
|
810
|
-
* * Populates superglobals ($_SERVER, $_GET, etc.)
|
|
811
|
-
* * Handles file uploads
|
|
812
|
-
* * Populates input streams (stdin, argv, etc.)
|
|
813
|
-
* * Sets the current working directory
|
|
814
|
-
*
|
|
815
|
-
* You can use run() in two primary modes:
|
|
816
|
-
*
|
|
817
|
-
* ### Code snippet mode
|
|
818
|
-
*
|
|
819
|
-
* In this mode, you pass a string containing PHP code to run.
|
|
820
|
-
*
|
|
821
|
-
* ```ts
|
|
822
|
-
* const result = await php.run({
|
|
823
|
-
* code: `<?php echo "Hello world!";`
|
|
824
|
-
* });
|
|
825
|
-
* // result.text === "Hello world!"
|
|
826
|
-
* ```
|
|
827
|
-
*
|
|
828
|
-
* In this mode, information like __DIR__ or __FILE__ isn't very
|
|
829
|
-
* useful because the code is not associated with any file.
|
|
830
|
-
*
|
|
831
|
-
* Under the hood, the PHP snippet is passed to the `zend_eval_string`
|
|
832
|
-
* C function.
|
|
833
|
-
*
|
|
834
|
-
* ### File mode
|
|
835
|
-
*
|
|
836
|
-
* In the file mode, you pass a scriptPath and PHP executes a file
|
|
837
|
-
* found at a that path:
|
|
838
|
-
*
|
|
839
|
-
* ```ts
|
|
840
|
-
* php.writeFile(
|
|
841
|
-
* "/www/index.php",
|
|
842
|
-
* `<?php echo "Hello world!";"`
|
|
843
|
-
* );
|
|
844
|
-
* const result = await php.run({
|
|
845
|
-
* scriptPath: "/www/index.php"
|
|
846
|
-
* });
|
|
847
|
-
* // result.text === "Hello world!"
|
|
848
|
-
* ```
|
|
849
|
-
*
|
|
850
|
-
* In this mode, you can rely on path-related information like __DIR__
|
|
851
|
-
* or __FILE__.
|
|
852
|
-
*
|
|
853
|
-
* Under the hood, the PHP file is executed with the `php_execute_script`
|
|
854
|
-
* C function.
|
|
855
|
-
*
|
|
856
|
-
* The `run()` method cannot be used in conjunction with `cli()`.
|
|
857
|
-
*
|
|
858
|
-
* @example
|
|
859
|
-
* ```js
|
|
860
|
-
* const result = await php.run(`<?php
|
|
861
|
-
* $fp = fopen('php://stderr', 'w');
|
|
862
|
-
* fwrite($fp, "Hello, world!");
|
|
863
|
-
* `);
|
|
864
|
-
* // result.errors === "Hello, world!"
|
|
865
|
-
* ```
|
|
866
|
-
*
|
|
867
|
-
* @param options - PHP runtime options.
|
|
868
|
-
*/
|
|
869
|
-
run(request: PHPRunOptions): Promise<PHPResponse>;
|
|
870
|
-
/**
|
|
871
|
-
* Defines a constant in the PHP runtime.
|
|
872
|
-
* @param key - The name of the constant.
|
|
873
|
-
* @param value - The value of the constant.
|
|
874
|
-
*/
|
|
875
|
-
defineConstant(key: string, value: string | boolean | number | null): void;
|
|
876
|
-
/**
|
|
877
|
-
* Recursively creates a directory with the given path in the PHP filesystem.
|
|
878
|
-
* For example, if the path is `/root/php/data`, and `/root` already exists,
|
|
879
|
-
* it will create the directories `/root/php` and `/root/php/data`.
|
|
880
|
-
*
|
|
881
|
-
* @param path - The directory path to create.
|
|
882
|
-
*/
|
|
883
|
-
mkdir(path: string): void;
|
|
884
|
-
/**
|
|
885
|
-
* @deprecated Use mkdir instead.
|
|
886
|
-
*/
|
|
887
|
-
mkdirTree(path: string): void;
|
|
888
|
-
/**
|
|
889
|
-
* Reads a file from the PHP filesystem and returns it as a string.
|
|
890
|
-
*
|
|
891
|
-
* @throws {@link @php-wasm/universal:ErrnoError} – If the file doesn't exist.
|
|
892
|
-
* @param path - The file path to read.
|
|
893
|
-
* @returns The file contents.
|
|
894
|
-
*/
|
|
895
|
-
readFileAsText(path: string): string;
|
|
896
|
-
/**
|
|
897
|
-
* Reads a file from the PHP filesystem and returns it as an array buffer.
|
|
898
|
-
*
|
|
899
|
-
* @throws {@link @php-wasm/universal:ErrnoError} – If the file doesn't exist.
|
|
900
|
-
* @param path - The file path to read.
|
|
901
|
-
* @returns The file contents.
|
|
902
|
-
*/
|
|
903
|
-
readFileAsBuffer(path: string): Uint8Array;
|
|
904
|
-
/**
|
|
905
|
-
* Overwrites data in a file in the PHP filesystem.
|
|
906
|
-
* Creates a new file if one doesn't exist yet.
|
|
907
|
-
*
|
|
908
|
-
* @param path - The file path to write to.
|
|
909
|
-
* @param data - The data to write to the file.
|
|
910
|
-
*/
|
|
911
|
-
writeFile(path: string, data: string | Uint8Array): void;
|
|
912
|
-
/**
|
|
913
|
-
* Removes a file from the PHP filesystem.
|
|
914
|
-
*
|
|
915
|
-
* @throws {@link @php-wasm/universal:ErrnoError} – If the file doesn't exist.
|
|
916
|
-
* @param path - The file path to remove.
|
|
917
|
-
*/
|
|
918
|
-
unlink(path: string): void;
|
|
919
|
-
/**
|
|
920
|
-
* Moves a file or directory in the PHP filesystem to a
|
|
921
|
-
* new location.
|
|
922
|
-
*
|
|
923
|
-
* @param oldPath The path to rename.
|
|
924
|
-
* @param newPath The new path.
|
|
925
|
-
*/
|
|
926
|
-
mv(fromPath: string, toPath: string): void;
|
|
927
|
-
/**
|
|
928
|
-
* Removes a directory from the PHP filesystem.
|
|
929
|
-
*
|
|
930
|
-
* @param path The directory path to remove.
|
|
931
|
-
* @param options Options for the removal.
|
|
932
|
-
*/
|
|
933
|
-
rmdir(path: string, options?: RmDirOptions): void;
|
|
934
|
-
/**
|
|
935
|
-
* Lists the files and directories in the given directory.
|
|
936
|
-
*
|
|
937
|
-
* @param path - The directory path to list.
|
|
938
|
-
* @param options - Options for the listing.
|
|
939
|
-
* @returns The list of files and directories in the given directory.
|
|
940
|
-
*/
|
|
941
|
-
listFiles(path: string, options?: ListFilesOptions): string[];
|
|
942
|
-
/**
|
|
943
|
-
* Checks if a directory exists in the PHP filesystem.
|
|
944
|
-
*
|
|
945
|
-
* @param path – The path to check.
|
|
946
|
-
* @returns True if the path is a directory, false otherwise.
|
|
947
|
-
*/
|
|
948
|
-
isDir(path: string): boolean;
|
|
949
|
-
/**
|
|
950
|
-
* Checks if a file (or a directory) exists in the PHP filesystem.
|
|
951
|
-
*
|
|
952
|
-
* @param path - The file path to check.
|
|
953
|
-
* @returns True if the file exists, false otherwise.
|
|
954
|
-
*/
|
|
955
|
-
fileExists(path: string): boolean;
|
|
956
|
-
/**
|
|
957
|
-
* Hot-swaps the PHP runtime for a new one without
|
|
958
|
-
* interrupting the operations of this PHP instance.
|
|
959
|
-
*
|
|
960
|
-
* @param runtime
|
|
961
|
-
* @param cwd. Internal, the VFS path to recreate in the new runtime.
|
|
962
|
-
* This arg is temporary and will be removed once BasePHP
|
|
963
|
-
* is fully decoupled from the request handler and
|
|
964
|
-
* accepts a constructor-level cwd argument.
|
|
965
|
-
*/
|
|
966
|
-
hotSwapPHPRuntime(runtime: number, cwd?: string): void;
|
|
967
|
-
/**
|
|
968
|
-
* Mounts a filesystem to a given path in the PHP filesystem.
|
|
969
|
-
*
|
|
970
|
-
* @param virtualFSPath - Where to mount it in the PHP virtual filesystem.
|
|
971
|
-
* @param mountHandler - The mount handler to use.
|
|
972
|
-
* @return Unmount function to unmount the filesystem.
|
|
973
|
-
*/
|
|
974
|
-
mount(virtualFSPath: string, mountHandler: MountHandler): Promise<UnmountFunction>;
|
|
975
|
-
/**
|
|
976
|
-
* Starts a PHP CLI session with given arguments.
|
|
977
|
-
*
|
|
978
|
-
* This method can only be used when PHP was compiled with the CLI SAPI
|
|
979
|
-
* and it cannot be used in conjunction with `run()`.
|
|
980
|
-
*
|
|
981
|
-
* Once this method finishes running, the PHP instance is no
|
|
982
|
-
* longer usable and should be discarded. This is because PHP
|
|
983
|
-
* internally cleans up all the resources and calls exit().
|
|
984
|
-
*
|
|
985
|
-
* @param argv - The arguments to pass to the CLI.
|
|
986
|
-
* @returns The exit code of the CLI session.
|
|
987
|
-
*/
|
|
988
|
-
cli(argv: string[]): Promise<number>;
|
|
989
|
-
setSkipShebang(shouldSkip: boolean): void;
|
|
990
|
-
exit(code?: number): void;
|
|
991
|
-
[Symbol.dispose](): void;
|
|
992
|
-
}
|
|
993
|
-
export type LimitedPHPApi = Pick<PHP, "request" | "defineConstant" | "addEventListener" | "removeEventListener" | "mkdir" | "mkdirTree" | "readFileAsText" | "readFileAsBuffer" | "writeFile" | "unlink" | "mv" | "rmdir" | "listFiles" | "isDir" | "fileExists" | "chdir" | "run" | "onMessage"> & {
|
|
994
|
-
documentRoot: PHP["documentRoot"];
|
|
995
|
-
absoluteUrl: PHP["absoluteUrl"];
|
|
996
|
-
};
|
|
997
|
-
/**
|
|
998
|
-
* Represents an event related to the PHP request.
|
|
999
|
-
*/
|
|
1000
|
-
export interface PHPRequestEndEvent {
|
|
1001
|
-
type: "request.end";
|
|
1002
|
-
}
|
|
1003
|
-
/**
|
|
1004
|
-
* Represents an error event related to the PHP request.
|
|
1005
|
-
*/
|
|
1006
|
-
export interface PHPRequestErrorEvent {
|
|
1007
|
-
type: "request.error";
|
|
1008
|
-
error: Error;
|
|
1009
|
-
source?: "request" | "php-wasm";
|
|
1010
|
-
}
|
|
1011
|
-
/**
|
|
1012
|
-
* Represents a PHP runtime initialization event.
|
|
1013
|
-
*/
|
|
1014
|
-
export interface PHPRuntimeInitializedEvent {
|
|
1015
|
-
type: "runtime.initialized";
|
|
1016
|
-
}
|
|
1017
|
-
/**
|
|
1018
|
-
* Represents a PHP runtime destruction event.
|
|
1019
|
-
*/
|
|
1020
|
-
export interface PHPRuntimeBeforeDestroyEvent {
|
|
1021
|
-
type: "runtime.beforedestroy";
|
|
1022
|
-
}
|
|
1023
|
-
/**
|
|
1024
|
-
* Represents an event related to the PHP instance.
|
|
1025
|
-
* This is intentionally not an extension of CustomEvent
|
|
1026
|
-
* to make it isomorphic between different JavaScript runtimes.
|
|
1027
|
-
*/
|
|
1028
|
-
export type PHPEvent = PHPRequestEndEvent | PHPRequestErrorEvent | PHPRuntimeInitializedEvent | PHPRuntimeBeforeDestroyEvent;
|
|
1029
|
-
/**
|
|
1030
|
-
* A callback function that handles PHP events.
|
|
1031
|
-
*/
|
|
1032
|
-
export type PHPEventListener = (event: PHPEvent) => void;
|
|
1033
|
-
export type UniversalPHP = LimitedPHPApi | Remote<LimitedPHPApi>;
|
|
1034
|
-
export type MessageListener = (data: string) => Promise<string | Uint8Array | void> | string | void;
|
|
1035
|
-
export interface EventEmitter {
|
|
1036
|
-
on(event: string, listener: (...args: any[]) => void): this;
|
|
1037
|
-
emit(event: string, ...args: any[]): boolean;
|
|
1038
|
-
}
|
|
1039
|
-
export type ChildProcess = EventEmitter & {
|
|
1040
|
-
stdout: EventEmitter;
|
|
1041
|
-
stderr: EventEmitter;
|
|
1042
|
-
};
|
|
1043
|
-
export type SpawnHandler = (command: string, args: string[]) => ChildProcess;
|
|
1044
|
-
export type HTTPMethod = "GET" | "POST" | "HEAD" | "OPTIONS" | "PATCH" | "PUT" | "DELETE";
|
|
1045
|
-
export type PHPRequestHeaders = Record<string, string>;
|
|
1046
|
-
export interface PHPRequest {
|
|
1047
|
-
/**
|
|
1048
|
-
* Request method. Default: `GET`.
|
|
1049
|
-
*/
|
|
1050
|
-
method?: HTTPMethod;
|
|
1051
|
-
/**
|
|
1052
|
-
* Request path or absolute URL.
|
|
1053
|
-
*/
|
|
1054
|
-
url: string;
|
|
1055
|
-
/**
|
|
1056
|
-
* Request headers.
|
|
1057
|
-
*/
|
|
1058
|
-
headers?: PHPRequestHeaders;
|
|
1059
|
-
/**
|
|
1060
|
-
* Request body.
|
|
1061
|
-
* If an object is given, the request will be encoded as multipart
|
|
1062
|
-
* and sent with a `multipart/form-data` header.
|
|
1063
|
-
*/
|
|
1064
|
-
body?: string | Uint8Array | Record<string, string | Uint8Array | File>;
|
|
1065
|
-
}
|
|
1066
|
-
export interface PHPRunOptions {
|
|
1067
|
-
/**
|
|
1068
|
-
* Request path following the domain:port part.
|
|
1069
|
-
*/
|
|
1070
|
-
relativeUri?: string;
|
|
1071
|
-
/**
|
|
1072
|
-
* Path of the .php file to execute.
|
|
1073
|
-
*/
|
|
1074
|
-
scriptPath?: string;
|
|
1075
|
-
/**
|
|
1076
|
-
* Request protocol.
|
|
1077
|
-
*/
|
|
1078
|
-
protocol?: string;
|
|
1079
|
-
/**
|
|
1080
|
-
* Request method. Default: `GET`.
|
|
1081
|
-
*/
|
|
1082
|
-
method?: HTTPMethod;
|
|
1083
|
-
/**
|
|
1084
|
-
* Request headers.
|
|
1085
|
-
*/
|
|
1086
|
-
headers?: PHPRequestHeaders;
|
|
1087
|
-
/**
|
|
1088
|
-
* Request body.
|
|
1089
|
-
*/
|
|
1090
|
-
body?: string | Uint8Array;
|
|
1091
|
-
/**
|
|
1092
|
-
* Environment variables to set for this run.
|
|
1093
|
-
*/
|
|
1094
|
-
env?: Record<string, string>;
|
|
1095
|
-
/**
|
|
1096
|
-
* $_SERVER entries to set for this run.
|
|
1097
|
-
*/
|
|
1098
|
-
$_SERVER?: Record<string, string>;
|
|
1099
|
-
/**
|
|
1100
|
-
* The code snippet to eval instead of a php file.
|
|
1101
|
-
*/
|
|
1102
|
-
code?: string;
|
|
1103
|
-
}
|
|
1104
|
-
declare const SupportedPHPVersions: readonly [
|
|
1105
|
-
"8.3",
|
|
1106
|
-
"8.2",
|
|
1107
|
-
"8.1",
|
|
1108
|
-
"8.0",
|
|
1109
|
-
"7.4",
|
|
1110
|
-
"7.3",
|
|
1111
|
-
"7.2",
|
|
1112
|
-
"7.1",
|
|
1113
|
-
"7.0"
|
|
1114
|
-
];
|
|
1115
|
-
export type SupportedPHPVersion = (typeof SupportedPHPVersions)[number];
|
|
1116
|
-
export type SupportedPHPExtension = "iconv" | "mbstring" | "xml-bundle" | "gd";
|
|
1117
|
-
export type SupportedPHPExtensionBundle = "kitchen-sink" | "light";
|
|
1118
|
-
export declare const ResourceTypes: readonly [
|
|
1119
|
-
"vfs",
|
|
1120
|
-
"literal",
|
|
1121
|
-
"wordpress.org/themes",
|
|
1122
|
-
"wordpress.org/plugins",
|
|
1123
|
-
"url"
|
|
1124
|
-
];
|
|
1125
|
-
export type VFSReference = {
|
|
1126
|
-
/** Identifies the file resource as Virtual File System (VFS) */
|
|
1127
|
-
resource: "vfs";
|
|
1128
|
-
/** The path to the file in the VFS */
|
|
1129
|
-
path: string;
|
|
1130
|
-
};
|
|
1131
|
-
export type LiteralReference = {
|
|
1132
|
-
/** Identifies the file resource as a literal file */
|
|
1133
|
-
resource: "literal";
|
|
1134
|
-
/** The name of the file */
|
|
1135
|
-
name: string;
|
|
1136
|
-
/** The contents of the file */
|
|
1137
|
-
contents: string | Uint8Array;
|
|
1138
|
-
};
|
|
1139
|
-
export type CoreThemeReference = {
|
|
1140
|
-
/** Identifies the file resource as a WordPress Core theme */
|
|
1141
|
-
resource: "wordpress.org/themes";
|
|
1142
|
-
/** The slug of the WordPress Core theme */
|
|
1143
|
-
slug: string;
|
|
1144
|
-
};
|
|
1145
|
-
export type CorePluginReference = {
|
|
1146
|
-
/** Identifies the file resource as a WordPress Core plugin */
|
|
1147
|
-
resource: "wordpress.org/plugins";
|
|
1148
|
-
/** The slug of the WordPress Core plugin */
|
|
1149
|
-
slug: string;
|
|
1150
|
-
};
|
|
1151
|
-
export type UrlReference = {
|
|
1152
|
-
/** Identifies the file resource as a URL */
|
|
1153
|
-
resource: "url";
|
|
1154
|
-
/** The URL of the file */
|
|
1155
|
-
url: string;
|
|
1156
|
-
/** Optional caption for displaying a progress message */
|
|
1157
|
-
caption?: string;
|
|
1158
|
-
};
|
|
1159
|
-
export type FileReference = VFSReference | LiteralReference | CoreThemeReference | CorePluginReference | UrlReference;
|
|
1160
|
-
export interface ResourceOptions {
|
|
1161
|
-
/** Optional semaphore to limit concurrent downloads */
|
|
1162
|
-
semaphore?: Semaphore;
|
|
1163
|
-
progress?: ProgressTracker;
|
|
1164
|
-
}
|
|
1165
|
-
export declare abstract class Resource {
|
|
1166
|
-
/** Optional progress tracker to monitor progress */
|
|
1167
|
-
abstract progress?: ProgressTracker;
|
|
1168
|
-
/** A Promise that resolves to the file contents */
|
|
1169
|
-
protected promise?: Promise<File>;
|
|
1170
|
-
protected playground?: UniversalPHP;
|
|
1171
|
-
/**
|
|
1172
|
-
* Creates a new Resource based on the given file reference
|
|
1173
|
-
*
|
|
1174
|
-
* @param ref The file reference to create the Resource for
|
|
1175
|
-
* @param options Additional options for the Resource
|
|
1176
|
-
* @returns A new Resource instance
|
|
1177
|
-
*/
|
|
1178
|
-
static create(ref: FileReference, { semaphore, progress }: ResourceOptions): Resource;
|
|
1179
|
-
setPlayground(playground: UniversalPHP): void;
|
|
1180
|
-
/**
|
|
1181
|
-
* Resolves the file contents
|
|
1182
|
-
* @returns The resolved file.
|
|
1183
|
-
*/
|
|
1184
|
-
abstract resolve(): Promise<File>;
|
|
1185
|
-
/** The name of the referenced file */
|
|
1186
|
-
abstract get name(): string;
|
|
1187
|
-
/** Whether this Resource is loaded asynchronously */
|
|
1188
|
-
get isAsync(): boolean;
|
|
1189
|
-
}
|
|
1190
|
-
/**
|
|
1191
|
-
* A `Resource` that represents a file in the VFS (virtual file system) of the playground.
|
|
1192
|
-
*/
|
|
1193
|
-
export declare class VFSResource extends Resource {
|
|
1194
|
-
private resource;
|
|
1195
|
-
progress?: ProgressTracker | undefined;
|
|
1196
|
-
/**
|
|
1197
|
-
* Creates a new instance of `VFSResource`.
|
|
1198
|
-
* @param playground The playground client.
|
|
1199
|
-
* @param resource The VFS reference.
|
|
1200
|
-
* @param progress The progress tracker.
|
|
1201
|
-
*/
|
|
1202
|
-
constructor(resource: VFSReference, progress?: ProgressTracker | undefined);
|
|
1203
|
-
/** @inheritDoc */
|
|
1204
|
-
resolve(): Promise<File>;
|
|
1205
|
-
/** @inheritDoc */
|
|
1206
|
-
get name(): string;
|
|
1207
|
-
}
|
|
1208
|
-
/**
|
|
1209
|
-
* A `Resource` that represents a literal file.
|
|
1210
|
-
*/
|
|
1211
|
-
export declare class LiteralResource extends Resource {
|
|
1212
|
-
private resource;
|
|
1213
|
-
progress?: ProgressTracker | undefined;
|
|
1214
|
-
/**
|
|
1215
|
-
* Creates a new instance of `LiteralResource`.
|
|
1216
|
-
* @param resource The literal reference.
|
|
1217
|
-
* @param progress The progress tracker.
|
|
1218
|
-
*/
|
|
1219
|
-
constructor(resource: LiteralReference, progress?: ProgressTracker | undefined);
|
|
1220
|
-
/** @inheritDoc */
|
|
1221
|
-
resolve(): Promise<File>;
|
|
1222
|
-
/** @inheritDoc */
|
|
1223
|
-
get name(): string;
|
|
1224
|
-
}
|
|
1225
|
-
/**
|
|
1226
|
-
* A base class for `Resource`s that require fetching data from a remote URL.
|
|
1227
|
-
*/
|
|
1228
|
-
export declare abstract class FetchResource extends Resource {
|
|
1229
|
-
progress?: ProgressTracker | undefined;
|
|
1230
|
-
/**
|
|
1231
|
-
* Creates a new instance of `FetchResource`.
|
|
1232
|
-
* @param progress The progress tracker.
|
|
1233
|
-
*/
|
|
1234
|
-
constructor(progress?: ProgressTracker | undefined);
|
|
1235
|
-
/** @inheritDoc */
|
|
1236
|
-
resolve(): Promise<File>;
|
|
1237
|
-
/**
|
|
1238
|
-
* Gets the URL to fetch the data from.
|
|
1239
|
-
* @returns The URL.
|
|
1240
|
-
*/
|
|
1241
|
-
protected abstract getURL(): string;
|
|
1242
|
-
/**
|
|
1243
|
-
* Gets the caption for the progress tracker.
|
|
1244
|
-
* @returns The caption.
|
|
1245
|
-
*/
|
|
1246
|
-
protected get caption(): string;
|
|
1247
|
-
/** @inheritDoc */
|
|
1248
|
-
get name(): string;
|
|
1249
|
-
/** @inheritDoc */
|
|
1250
|
-
get isAsync(): boolean;
|
|
1251
|
-
}
|
|
1252
|
-
/**
|
|
1253
|
-
* A `Resource` that represents a file available from a URL.
|
|
1254
|
-
*/
|
|
1255
|
-
export declare class UrlResource extends FetchResource {
|
|
1256
|
-
private resource;
|
|
1257
|
-
/**
|
|
1258
|
-
* Creates a new instance of `UrlResource`.
|
|
1259
|
-
* @param resource The URL reference.
|
|
1260
|
-
* @param progress The progress tracker.
|
|
1261
|
-
*/
|
|
1262
|
-
constructor(resource: UrlReference, progress?: ProgressTracker);
|
|
1263
|
-
/** @inheritDoc */
|
|
1264
|
-
getURL(): string;
|
|
1265
|
-
/** @inheritDoc */
|
|
1266
|
-
protected get caption(): string;
|
|
1267
|
-
}
|
|
1268
|
-
/**
|
|
1269
|
-
* A `Resource` that represents a WordPress core theme.
|
|
1270
|
-
*/
|
|
1271
|
-
export declare class CoreThemeResource extends FetchResource {
|
|
1272
|
-
private resource;
|
|
1273
|
-
constructor(resource: CoreThemeReference, progress?: ProgressTracker);
|
|
1274
|
-
get name(): string;
|
|
1275
|
-
getURL(): string;
|
|
1276
|
-
}
|
|
1277
|
-
/**
|
|
1278
|
-
* A resource that fetches a WordPress plugin from wordpress.org.
|
|
1279
|
-
*/
|
|
1280
|
-
export declare class CorePluginResource extends FetchResource {
|
|
1281
|
-
private resource;
|
|
1282
|
-
constructor(resource: CorePluginReference, progress?: ProgressTracker);
|
|
1283
|
-
/** @inheritDoc */
|
|
1284
|
-
get name(): string;
|
|
1285
|
-
/** @inheritDoc */
|
|
1286
|
-
getURL(): string;
|
|
1287
|
-
}
|
|
1288
|
-
/**
|
|
1289
|
-
* A decorator for a resource that adds functionality such as progress tracking and caching.
|
|
1290
|
-
*/
|
|
1291
|
-
export declare class DecoratedResource<T extends Resource> extends Resource {
|
|
1292
|
-
private resource;
|
|
1293
|
-
constructor(resource: T);
|
|
1294
|
-
/** @inheritDoc */
|
|
1295
|
-
resolve(): Promise<File>;
|
|
1296
|
-
/** @inheritDoc */
|
|
1297
|
-
setPlayground(playground: UniversalPHP): Promise<void>;
|
|
1298
|
-
/** @inheritDoc */
|
|
1299
|
-
get progress(): ProgressTracker | undefined;
|
|
1300
|
-
/** @inheritDoc */
|
|
1301
|
-
set progress(value: ProgressTracker | undefined);
|
|
1302
|
-
/** @inheritDoc */
|
|
1303
|
-
get name(): string;
|
|
1304
|
-
/** @inheritDoc */
|
|
1305
|
-
get isAsync(): boolean;
|
|
1306
|
-
}
|
|
1307
|
-
/**
|
|
1308
|
-
* A decorator for a resource that adds caching functionality.
|
|
1309
|
-
*/
|
|
1310
|
-
export declare class CachedResource<T extends Resource> extends DecoratedResource<T> {
|
|
1311
|
-
protected promise?: Promise<File>;
|
|
1312
|
-
/** @inheritDoc */
|
|
1313
|
-
resolve(): Promise<File>;
|
|
1314
|
-
}
|
|
1315
|
-
/**
|
|
1316
|
-
* A decorator for a resource that adds concurrency control functionality through a semaphore.
|
|
1317
|
-
*/
|
|
1318
|
-
export declare class SemaphoreResource<T extends Resource> extends DecoratedResource<T> {
|
|
1319
|
-
private readonly semaphore;
|
|
1320
|
-
constructor(resource: T, semaphore: Semaphore);
|
|
1321
|
-
/** @inheritDoc */
|
|
1322
|
-
resolve(): Promise<File>;
|
|
1323
|
-
}
|
|
1324
|
-
/**
|
|
1325
|
-
* @inheritDoc activatePlugin
|
|
1326
|
-
* @example
|
|
1327
|
-
*
|
|
1328
|
-
* <code>
|
|
1329
|
-
* {
|
|
1330
|
-
* "step": "activatePlugin",
|
|
1331
|
-
* "pluginName": "Gutenberg",
|
|
1332
|
-
* "pluginPath": "/wordpress/wp-content/plugins/gutenberg"
|
|
1333
|
-
* }
|
|
1334
|
-
* </code>
|
|
1335
|
-
*/
|
|
1336
|
-
export interface ActivatePluginStep {
|
|
1337
|
-
step: "activatePlugin";
|
|
1338
|
-
/** 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). */
|
|
1339
|
-
pluginPath: string;
|
|
1340
|
-
/** Optional. Plugin name to display in the progress bar. */
|
|
1341
|
-
pluginName?: string;
|
|
1342
|
-
}
|
|
1343
|
-
/**
|
|
1344
|
-
* Activates a WordPress plugin (if it's installed).
|
|
1345
|
-
*
|
|
1346
|
-
* @param playground The playground client.
|
|
1347
|
-
*/
|
|
1348
|
-
export declare const activatePlugin: StepHandler<ActivatePluginStep>;
|
|
1349
|
-
/**
|
|
1350
|
-
* Changes the site URL of the WordPress installation.
|
|
1351
|
-
*
|
|
1352
|
-
* @inheritDoc defineSiteUrl
|
|
1353
|
-
*/
|
|
1354
|
-
export interface DefineSiteUrlStep {
|
|
1355
|
-
step: "defineSiteUrl";
|
|
1356
|
-
/** The URL */
|
|
1357
|
-
siteUrl: string;
|
|
1358
|
-
}
|
|
1359
|
-
/**
|
|
1360
|
-
* 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.
|
|
1361
|
-
*
|
|
1362
|
-
* Using this step on playground.wordpress.net is moot.
|
|
1363
|
-
* It is useful when building a custom Playground-based tool, like [`wp-now`](https://www.npmjs.com/package/@wp-now/wp-now),
|
|
1364
|
-
* or deploying Playground on a custom domain.
|
|
1365
|
-
*
|
|
1366
|
-
* @param playground The playground client.
|
|
1367
|
-
* @param siteUrl
|
|
1368
|
-
*/
|
|
1369
|
-
export declare const defineSiteUrl: StepHandler<DefineSiteUrlStep>;
|
|
1370
|
-
export interface InstallAssetOptions {
|
|
1371
|
-
/**
|
|
1372
|
-
* The zip file to install.
|
|
1373
|
-
*/
|
|
1374
|
-
zipFile: File;
|
|
1375
|
-
/**
|
|
1376
|
-
* Target path to extract the main folder.
|
|
1377
|
-
* @example
|
|
1378
|
-
*
|
|
1379
|
-
* <code>
|
|
1380
|
-
* const targetPath = `${await playground.documentRoot}/wp-content/plugins`;
|
|
1381
|
-
* </code>
|
|
1382
|
-
*/
|
|
1383
|
-
targetPath: string;
|
|
1384
|
-
/**
|
|
1385
|
-
* What to do if the asset already exists.
|
|
1386
|
-
*/
|
|
1387
|
-
ifAlreadyInstalled?: "overwrite" | "skip" | "error";
|
|
1388
|
-
}
|
|
1389
|
-
/**
|
|
1390
|
-
* @inheritDoc installPlugin
|
|
1391
|
-
* @hasRunnableExample
|
|
1392
|
-
* @needsLogin
|
|
1393
|
-
* @landingPage /wp-admin/plugins.php
|
|
1394
|
-
* @example
|
|
1395
|
-
*
|
|
1396
|
-
* <code>
|
|
1397
|
-
* {
|
|
1398
|
-
* "step": "installPlugin",
|
|
1399
|
-
* "pluginZipFile": {
|
|
1400
|
-
* "resource": "wordpress.org/plugins",
|
|
1401
|
-
* "slug": "gutenberg"
|
|
1402
|
-
* },
|
|
1403
|
-
* "options": {
|
|
1404
|
-
* "activate": true
|
|
1405
|
-
* }
|
|
1406
|
-
* }
|
|
1407
|
-
* </code>
|
|
1408
|
-
*/
|
|
1409
|
-
export interface InstallPluginStep<ResourceType> extends Pick<InstallAssetOptions, "ifAlreadyInstalled"> {
|
|
1410
|
-
/**
|
|
1411
|
-
* The step identifier.
|
|
1412
|
-
*/
|
|
1413
|
-
step: "installPlugin";
|
|
1414
|
-
/**
|
|
1415
|
-
* The plugin zip file to install.
|
|
1416
|
-
*/
|
|
1417
|
-
pluginZipFile: ResourceType;
|
|
1418
|
-
/**
|
|
1419
|
-
* Optional installation options.
|
|
1420
|
-
*/
|
|
1421
|
-
options?: InstallPluginOptions;
|
|
1422
|
-
}
|
|
1423
|
-
export interface InstallPluginOptions {
|
|
1424
|
-
/**
|
|
1425
|
-
* Whether to activate the plugin after installing it.
|
|
1426
|
-
*/
|
|
1427
|
-
activate?: boolean;
|
|
1428
|
-
}
|
|
1429
|
-
/**
|
|
1430
|
-
* Installs a WordPress plugin in the Playground.
|
|
1431
|
-
*
|
|
1432
|
-
* @param playground The playground client.
|
|
1433
|
-
* @param pluginZipFile The plugin zip file.
|
|
1434
|
-
* @param options Optional. Set `activate` to false if you don't want to activate the plugin.
|
|
1435
|
-
*/
|
|
1436
|
-
export declare const installPlugin: StepHandler<InstallPluginStep<File>>;
|
|
1437
|
-
/**
|
|
1438
|
-
* @inheritDoc installTheme
|
|
1439
|
-
* @hasRunnableExample
|
|
1440
|
-
* @needsLogin
|
|
1441
|
-
* @example
|
|
1442
|
-
*
|
|
1443
|
-
* <code>
|
|
1444
|
-
* {
|
|
1445
|
-
* "step": "installTheme",
|
|
1446
|
-
* "themeZipFile": {
|
|
1447
|
-
* "resource": "wordpress.org/themes",
|
|
1448
|
-
* "slug": "pendant"
|
|
1449
|
-
* },
|
|
1450
|
-
* "options": {
|
|
1451
|
-
* "activate": true,
|
|
1452
|
-
* "importStarterContent": true
|
|
1453
|
-
* }
|
|
1454
|
-
* }
|
|
1455
|
-
* </code>
|
|
1456
|
-
*/
|
|
1457
|
-
export interface InstallThemeStep<ResourceType> extends Pick<InstallAssetOptions, "ifAlreadyInstalled"> {
|
|
1458
|
-
/**
|
|
1459
|
-
* The step identifier.
|
|
1460
|
-
*/
|
|
1461
|
-
step: "installTheme";
|
|
1462
|
-
/**
|
|
1463
|
-
* The theme zip file to install.
|
|
1464
|
-
*/
|
|
1465
|
-
themeZipFile: ResourceType;
|
|
1466
|
-
/**
|
|
1467
|
-
* Optional installation options.
|
|
1468
|
-
*/
|
|
1469
|
-
options?: {
|
|
1470
|
-
/**
|
|
1471
|
-
* Whether to activate the theme after installing it.
|
|
1472
|
-
*/
|
|
1473
|
-
activate?: boolean;
|
|
1474
|
-
/**
|
|
1475
|
-
* Whether to import the theme's starter content after installing it.
|
|
1476
|
-
*/
|
|
1477
|
-
importStarterContent?: boolean;
|
|
1478
|
-
};
|
|
1479
|
-
}
|
|
1480
|
-
export interface InstallThemeOptions {
|
|
1481
|
-
/**
|
|
1482
|
-
* Whether to activate the theme after installing it.
|
|
1483
|
-
*/
|
|
1484
|
-
activate?: boolean;
|
|
1485
|
-
}
|
|
1486
|
-
/**
|
|
1487
|
-
* Installs a WordPress theme in the Playground.
|
|
1488
|
-
*
|
|
1489
|
-
* @param playground The playground client.
|
|
1490
|
-
* @param themeZipFile The theme zip file.
|
|
1491
|
-
* @param options Optional. Set `activate` to false if you don't want to activate the theme.
|
|
1492
|
-
*/
|
|
1493
|
-
export declare const installTheme: StepHandler<InstallThemeStep<File>>;
|
|
1494
|
-
/**
|
|
1495
|
-
* @inheritDoc login
|
|
1496
|
-
* @hasRunnableExample
|
|
1497
|
-
* @example
|
|
1498
|
-
*
|
|
1499
|
-
* <code>
|
|
1500
|
-
* {
|
|
1501
|
-
* "step": "login",
|
|
1502
|
-
* "username": "admin",
|
|
1503
|
-
* "password": "password"
|
|
1504
|
-
* }
|
|
1505
|
-
* </code>
|
|
1506
|
-
*/
|
|
1507
|
-
export type LoginStep = {
|
|
1508
|
-
step: "login";
|
|
1509
|
-
/**
|
|
1510
|
-
* The user to log in as. Defaults to 'admin'.
|
|
1511
|
-
*/
|
|
1512
|
-
username?: string;
|
|
1513
|
-
/**
|
|
1514
|
-
* The password to log in with. Defaults to 'password'.
|
|
1515
|
-
*/
|
|
1516
|
-
password?: string;
|
|
1517
|
-
};
|
|
1518
|
-
/**
|
|
1519
|
-
* Logs in to Playground.
|
|
1520
|
-
* 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/)
|
|
1521
|
-
* just like a user would.
|
|
1522
|
-
*/
|
|
1523
|
-
export declare const login: StepHandler<LoginStep>;
|
|
1524
|
-
/**
|
|
1525
|
-
* @private
|
|
1526
|
-
*/
|
|
1527
|
-
export interface RunWpInstallationWizardStep {
|
|
1528
|
-
step: "runWpInstallationWizard";
|
|
1529
|
-
options: WordPressInstallationOptions;
|
|
1530
|
-
}
|
|
1531
|
-
export interface WordPressInstallationOptions {
|
|
1532
|
-
adminUsername?: string;
|
|
1533
|
-
adminPassword?: string;
|
|
1534
|
-
}
|
|
1535
|
-
/**
|
|
1536
|
-
* Installs WordPress
|
|
1537
|
-
*
|
|
1538
|
-
* @param playground The playground client.
|
|
1539
|
-
* @param options Installation options.
|
|
1540
|
-
*/
|
|
1541
|
-
export declare const runWpInstallationWizard: StepHandler<RunWpInstallationWizardStep>;
|
|
1542
|
-
/**
|
|
1543
|
-
* @inheritDoc setSiteOptions
|
|
1544
|
-
* @hasRunnableExample
|
|
1545
|
-
*
|
|
1546
|
-
* @example
|
|
1547
|
-
*
|
|
1548
|
-
* <code>
|
|
1549
|
-
* {
|
|
1550
|
-
* "step": "setSiteOptions",
|
|
1551
|
-
* "options": {
|
|
1552
|
-
* "blogname": "My Blog",
|
|
1553
|
-
* "blogdescription": "A great blog"
|
|
1554
|
-
* }
|
|
1555
|
-
* }
|
|
1556
|
-
* </code>
|
|
1557
|
-
*/
|
|
1558
|
-
export type SetSiteOptionsStep = {
|
|
1559
|
-
/** The name of the step. Must be "setSiteOptions". */
|
|
1560
|
-
step: "setSiteOptions";
|
|
1561
|
-
/** The options to set on the site. */
|
|
1562
|
-
options: Record<string, unknown>;
|
|
1563
|
-
};
|
|
1564
|
-
/**
|
|
1565
|
-
* Sets site options. This is equivalent to calling [`update_option`](https://developer.wordpress.org/reference/functions/update_option/) for each
|
|
1566
|
-
* option in the [`options`](https://developer.wordpress.org/apis/options/#available-options-by-category) object.
|
|
1567
|
-
*/
|
|
1568
|
-
export declare const setSiteOptions: StepHandler<SetSiteOptionsStep>;
|
|
1569
|
-
/**
|
|
1570
|
-
* @inheritDoc updateUserMeta
|
|
1571
|
-
* @hasRunnableExample
|
|
1572
|
-
*
|
|
1573
|
-
* @example
|
|
1574
|
-
*
|
|
1575
|
-
* <code>
|
|
1576
|
-
* {
|
|
1577
|
-
* "step": "updateUserMeta",
|
|
1578
|
-
* "meta": {
|
|
1579
|
-
* "first_name": "John",
|
|
1580
|
-
* "last_name": "Doe"
|
|
1581
|
-
* },
|
|
1582
|
-
* "userId": 1
|
|
1583
|
-
* }
|
|
1584
|
-
* </code>
|
|
1585
|
-
*/
|
|
1586
|
-
export interface UpdateUserMetaStep {
|
|
1587
|
-
step: "updateUserMeta";
|
|
1588
|
-
/** An object of user meta values to set, e.g. { "first_name": "John" } */
|
|
1589
|
-
meta: Record<string, unknown>;
|
|
1590
|
-
/** User ID */
|
|
1591
|
-
userId: number;
|
|
1592
|
-
}
|
|
1593
|
-
/**
|
|
1594
|
-
* Updates user meta. This is equivalent to calling [`update_user_meta`](https://developer.wordpress.org/reference/functions/update_user_meta/) for each
|
|
1595
|
-
* meta value in the `meta` object.
|
|
1596
|
-
*/
|
|
1597
|
-
export declare const updateUserMeta: StepHandler<UpdateUserMetaStep>;
|
|
1598
|
-
/**
|
|
1599
|
-
* @inheritDoc rm
|
|
1600
|
-
* @hasRunnableExample
|
|
1601
|
-
* @landingPage /index.php
|
|
1602
|
-
* @example
|
|
1603
|
-
*
|
|
1604
|
-
* <code>
|
|
1605
|
-
* {
|
|
1606
|
-
* "step": "rm",
|
|
1607
|
-
* "path": "/wordpress/index.php"
|
|
1608
|
-
* }
|
|
1609
|
-
* </code>
|
|
1610
|
-
*/
|
|
1611
|
-
export interface RmStep {
|
|
1612
|
-
step: "rm";
|
|
1613
|
-
/** The path to remove */
|
|
1614
|
-
path: string;
|
|
1615
|
-
}
|
|
1616
|
-
/**
|
|
1617
|
-
* Removes a file at the specified path.
|
|
1618
|
-
*/
|
|
1619
|
-
export declare const rm: StepHandler<RmStep>;
|
|
1620
|
-
/**
|
|
1621
|
-
* @inheritDoc cp
|
|
1622
|
-
* @hasRunnableExample
|
|
1623
|
-
* @landingPage /index2.php
|
|
1624
|
-
* @example
|
|
1625
|
-
*
|
|
1626
|
-
* <code>
|
|
1627
|
-
* {
|
|
1628
|
-
* "step": "cp",
|
|
1629
|
-
* "fromPath": "/wordpress/index.php",
|
|
1630
|
-
* "toPath": "/wordpress/index2.php"
|
|
1631
|
-
* }
|
|
1632
|
-
* </code>
|
|
1633
|
-
*/
|
|
1634
|
-
export interface CpStep {
|
|
1635
|
-
step: "cp";
|
|
1636
|
-
/** Source path */
|
|
1637
|
-
fromPath: string;
|
|
1638
|
-
/** Target path */
|
|
1639
|
-
toPath: string;
|
|
1640
|
-
}
|
|
1641
|
-
/**
|
|
1642
|
-
* Copies a file from one path to another.
|
|
1643
|
-
*/
|
|
1644
|
-
export declare const cp: StepHandler<CpStep>;
|
|
1645
|
-
/**
|
|
1646
|
-
* @inheritDoc rmdir
|
|
1647
|
-
* @hasRunnableExample
|
|
1648
|
-
* @landingPage /wp-admin/
|
|
1649
|
-
* @example
|
|
1650
|
-
*
|
|
1651
|
-
* <code>
|
|
1652
|
-
* {
|
|
1653
|
-
* "step": "rmdir",
|
|
1654
|
-
* "path": "/wordpress/wp-admin"
|
|
1655
|
-
* }
|
|
1656
|
-
* </code>
|
|
1657
|
-
*/
|
|
1658
|
-
export interface RmdirStep {
|
|
1659
|
-
step: "rmdir";
|
|
1660
|
-
/** The path to remove */
|
|
1661
|
-
path: string;
|
|
1662
|
-
}
|
|
1663
|
-
/**
|
|
1664
|
-
* Removes a directory at the specified path.
|
|
1665
|
-
*/
|
|
1666
|
-
export declare const rmdir: StepHandler<RmdirStep>;
|
|
1667
|
-
/**
|
|
1668
|
-
* @inheritDoc runSql
|
|
1669
|
-
* @hasRunnableExample
|
|
1670
|
-
* @example
|
|
1671
|
-
*
|
|
1672
|
-
* <code>
|
|
1673
|
-
* {
|
|
1674
|
-
* "step": "runSql",
|
|
1675
|
-
* "sql": {
|
|
1676
|
-
* "resource": "literal",
|
|
1677
|
-
* "name": "schema.sql",
|
|
1678
|
-
* "contents": "DELETE FROM wp_posts"
|
|
1679
|
-
* }
|
|
1680
|
-
* }
|
|
1681
|
-
* </code>
|
|
1682
|
-
*/
|
|
1683
|
-
export interface RunSqlStep<ResourceType> {
|
|
1684
|
-
/**
|
|
1685
|
-
* The step identifier.
|
|
1686
|
-
*/
|
|
1687
|
-
step: "runSql";
|
|
1688
|
-
/**
|
|
1689
|
-
* The SQL to run. Each non-empty line must contain a valid SQL query.
|
|
1690
|
-
*/
|
|
1691
|
-
sql: ResourceType;
|
|
1692
|
-
}
|
|
1693
|
-
/**
|
|
1694
|
-
* Run one or more SQL queries.
|
|
1695
|
-
*
|
|
1696
|
-
* This step will treat each non-empty line in the input SQL as a query and
|
|
1697
|
-
* try to execute it using `$wpdb`. Queries spanning multiple lines are not
|
|
1698
|
-
* yet supported.
|
|
1699
|
-
*/
|
|
1700
|
-
export declare const runSql: StepHandler<RunSqlStep<File>>;
|
|
1701
|
-
/**
|
|
1702
|
-
* @inheritDoc mkdir
|
|
1703
|
-
* @hasRunnableExample
|
|
1704
|
-
* @example
|
|
1705
|
-
*
|
|
1706
|
-
* <code>
|
|
1707
|
-
* {
|
|
1708
|
-
* "step": "mkdir",
|
|
1709
|
-
* "path": "/wordpress/my-new-folder"
|
|
1710
|
-
* }
|
|
1711
|
-
* </code>
|
|
1712
|
-
*/
|
|
1713
|
-
export interface MkdirStep {
|
|
1714
|
-
step: "mkdir";
|
|
1715
|
-
/** The path of the directory you want to create */
|
|
1716
|
-
path: string;
|
|
1717
|
-
}
|
|
1718
|
-
/**
|
|
1719
|
-
* Creates a directory at the specified path.
|
|
1720
|
-
*/
|
|
1721
|
-
export declare const mkdir: StepHandler<MkdirStep>;
|
|
1722
|
-
/**
|
|
1723
|
-
* @inheritDoc mv
|
|
1724
|
-
* @hasRunnableExample
|
|
1725
|
-
* @landingPage /index2.php
|
|
1726
|
-
* @example
|
|
1727
|
-
*
|
|
1728
|
-
* <code>
|
|
1729
|
-
* {
|
|
1730
|
-
* "step": "mv",
|
|
1731
|
-
* "fromPath": "/wordpress/index.php",
|
|
1732
|
-
* "toPath": "/wordpress/index2.php"
|
|
1733
|
-
* }
|
|
1734
|
-
* </code>
|
|
1735
|
-
*/
|
|
1736
|
-
export interface MvStep {
|
|
1737
|
-
step: "mv";
|
|
1738
|
-
/** Source path */
|
|
1739
|
-
fromPath: string;
|
|
1740
|
-
/** Target path */
|
|
1741
|
-
toPath: string;
|
|
1742
|
-
}
|
|
1743
|
-
/**
|
|
1744
|
-
* Moves a file or directory from one path to another.
|
|
1745
|
-
*/
|
|
1746
|
-
export declare const mv: StepHandler<MvStep>;
|
|
1747
|
-
/**
|
|
1748
|
-
* @inheritDoc runPHP
|
|
1749
|
-
* @hasRunnableExample
|
|
1750
|
-
* @example
|
|
1751
|
-
*
|
|
1752
|
-
* <code>
|
|
1753
|
-
* {
|
|
1754
|
-
* "step": "runPHP",
|
|
1755
|
-
* "code": "<?php require_once 'wordpress/wp-load.php'; wp_insert_post(array('post_title' => 'wp-load.php required for WP functionality', 'post_status' => 'publish')); ?>"
|
|
1756
|
-
* }
|
|
1757
|
-
* </code>
|
|
1758
|
-
*/
|
|
1759
|
-
export interface RunPHPStep {
|
|
1760
|
-
/** The step identifier. */
|
|
1761
|
-
step: "runPHP";
|
|
1762
|
-
/** The PHP code to run. */
|
|
1763
|
-
code: string;
|
|
1764
|
-
}
|
|
1765
|
-
/**
|
|
1766
|
-
* Runs PHP code.
|
|
1767
|
-
* 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'; "`.
|
|
1768
|
-
*/
|
|
1769
|
-
export declare const runPHP: StepHandler<RunPHPStep, Promise<PHPResponse>>;
|
|
1770
|
-
/**
|
|
1771
|
-
* @inheritDoc runPHP
|
|
1772
|
-
* @hasRunnableExample
|
|
1773
|
-
* @example
|
|
1774
|
-
*
|
|
1775
|
-
* <code>
|
|
1776
|
-
* {
|
|
1777
|
-
* "step": "runPHP",
|
|
1778
|
-
* "options": {
|
|
1779
|
-
* "code": "<?php echo $_SERVER['CONTENT_TYPE']; ?>",
|
|
1780
|
-
* "headers": {
|
|
1781
|
-
* "Content-type": "text/plain"
|
|
1782
|
-
* }
|
|
1783
|
-
* }
|
|
1784
|
-
* }
|
|
1785
|
-
* </code>
|
|
1786
|
-
*/
|
|
1787
|
-
export interface RunPHPWithOptionsStep {
|
|
1788
|
-
step: "runPHPWithOptions";
|
|
1789
|
-
/**
|
|
1790
|
-
* Run options (See /wordpress-playground/api/universal/interface/PHPRunOptions/))
|
|
1791
|
-
*/
|
|
1792
|
-
options: PHPRunOptions;
|
|
1793
|
-
}
|
|
1794
|
-
/**
|
|
1795
|
-
* Runs PHP code with the given options.
|
|
1796
|
-
*/
|
|
1797
|
-
export declare const runPHPWithOptions: StepHandler<RunPHPWithOptionsStep>;
|
|
1798
|
-
/**
|
|
1799
|
-
* @private
|
|
1800
|
-
* @inheritDoc request
|
|
1801
|
-
* @needsLogin
|
|
1802
|
-
* @hasRunnableExample
|
|
1803
|
-
* @example
|
|
1804
|
-
*
|
|
1805
|
-
* <code>
|
|
1806
|
-
* {
|
|
1807
|
-
* "step": "request",
|
|
1808
|
-
* "request": {
|
|
1809
|
-
* "method": "POST",
|
|
1810
|
-
* "url": "/wp-admin/admin-ajax.php",
|
|
1811
|
-
* "formData": {
|
|
1812
|
-
* "action": "my_action",
|
|
1813
|
-
* "foo": "bar"
|
|
1814
|
-
* }
|
|
1815
|
-
* }
|
|
1816
|
-
* }
|
|
1817
|
-
* </code>
|
|
1818
|
-
*/
|
|
1819
|
-
export interface RequestStep {
|
|
1820
|
-
step: "request";
|
|
1821
|
-
/**
|
|
1822
|
-
* Request details (See /wordpress-playground/api/universal/interface/PHPRequest)
|
|
1823
|
-
*/
|
|
1824
|
-
request: PHPRequest;
|
|
1825
|
-
}
|
|
1826
|
-
/**
|
|
1827
|
-
* Sends a HTTP request to Playground.
|
|
1828
|
-
*/
|
|
1829
|
-
export declare const request: StepHandler<RequestStep, Promise<PHPResponse>>;
|
|
1830
|
-
/**
|
|
1831
|
-
* @inheritDoc writeFile
|
|
1832
|
-
* @hasRunnableExample
|
|
1833
|
-
* @landingPage /test.php
|
|
1834
|
-
* @example
|
|
1835
|
-
*
|
|
1836
|
-
* <code>
|
|
1837
|
-
* {
|
|
1838
|
-
* "step": "writeFile",
|
|
1839
|
-
* "path": "/wordpress/test.php",
|
|
1840
|
-
* "data": "<?php echo 'Hello World!'; ?>"
|
|
1841
|
-
* }
|
|
1842
|
-
* </code>
|
|
1843
|
-
*/
|
|
1844
|
-
export interface WriteFileStep<ResourceType> {
|
|
1845
|
-
step: "writeFile";
|
|
1846
|
-
/** The path of the file to write to */
|
|
1847
|
-
path: string;
|
|
1848
|
-
/** The data to write */
|
|
1849
|
-
data: ResourceType | string | Uint8Array;
|
|
1850
|
-
}
|
|
1851
|
-
/**
|
|
1852
|
-
* Writes data to a file at the specified path.
|
|
1853
|
-
*/
|
|
1854
|
-
export declare const writeFile: StepHandler<WriteFileStep<File>>;
|
|
1855
|
-
/**
|
|
1856
|
-
* @inheritDoc defineWpConfigConsts
|
|
1857
|
-
* @hasRunnableExample
|
|
1858
|
-
* @example
|
|
1859
|
-
*
|
|
1860
|
-
* <code>
|
|
1861
|
-
* {
|
|
1862
|
-
* "step": "defineWpConfigConsts",
|
|
1863
|
-
* "consts": {
|
|
1864
|
-
* "WP_DEBUG": true
|
|
1865
|
-
* }
|
|
1866
|
-
* }
|
|
1867
|
-
* </code>
|
|
1868
|
-
*/
|
|
1869
|
-
export interface DefineWpConfigConstsStep {
|
|
1870
|
-
step: "defineWpConfigConsts";
|
|
1871
|
-
/** The constants to define */
|
|
1872
|
-
consts: Record<string, unknown>;
|
|
1873
|
-
/**
|
|
1874
|
-
* The method of defining the constants in wp-config.php. Possible values are:
|
|
1875
|
-
*
|
|
1876
|
-
* - rewrite-wp-config: Default. Rewrites the wp-config.php file to
|
|
1877
|
-
* explicitly call define() with the requested
|
|
1878
|
-
* name and value. This method alters the file
|
|
1879
|
-
* on the disk, but it doesn't conflict with
|
|
1880
|
-
* existing define() calls in wp-config.php.
|
|
1881
|
-
*
|
|
1882
|
-
* - define-before-run: Defines the constant before running the requested
|
|
1883
|
-
* script. It doesn't alter any files on the disk, but
|
|
1884
|
-
* constants defined this way may conflict with existing
|
|
1885
|
-
* define() calls in wp-config.php.
|
|
1886
|
-
*/
|
|
1887
|
-
method?: "rewrite-wp-config" | "define-before-run";
|
|
1888
|
-
/**
|
|
1889
|
-
* @deprecated This option is noop and will be removed in a future version.
|
|
1890
|
-
* This option is only kept in here to avoid breaking Blueprint schema validation
|
|
1891
|
-
* for existing apps using this option.
|
|
1892
|
-
*/
|
|
1893
|
-
virtualize?: boolean;
|
|
1894
|
-
}
|
|
1895
|
-
/**
|
|
1896
|
-
* Defines constants in a [`wp-config.php`](https://developer.wordpress.org/advanced-administration/wordpress/wp-config/) file.
|
|
1897
|
-
*
|
|
1898
|
-
* This step can be called multiple times, and the constants will be merged.
|
|
1899
|
-
*
|
|
1900
|
-
* @param playground The playground client.
|
|
1901
|
-
* @param wpConfigConst
|
|
1902
|
-
*/
|
|
1903
|
-
export declare const defineWpConfigConsts: StepHandler<DefineWpConfigConstsStep>;
|
|
1904
|
-
/**
|
|
1905
|
-
* @inheritDoc activateTheme
|
|
1906
|
-
* @example
|
|
1907
|
-
*
|
|
1908
|
-
* <code>
|
|
1909
|
-
* {
|
|
1910
|
-
* "step": "activateTheme",
|
|
1911
|
-
* "themeFolderName": "storefront"
|
|
1912
|
-
* }
|
|
1913
|
-
* </code>
|
|
1914
|
-
*/
|
|
1915
|
-
export interface ActivateThemeStep {
|
|
1916
|
-
step: "activateTheme";
|
|
1917
|
-
/**
|
|
1918
|
-
* The name of the theme folder inside wp-content/themes/
|
|
1919
|
-
*/
|
|
1920
|
-
themeFolderName: string;
|
|
1921
|
-
}
|
|
1922
|
-
/**
|
|
1923
|
-
* Activates a WordPress theme (if it's installed).
|
|
1924
|
-
*
|
|
1925
|
-
* @param playground The playground client.
|
|
1926
|
-
* @param themeFolderName The theme folder name.
|
|
1927
|
-
*/
|
|
1928
|
-
export declare const activateTheme: StepHandler<ActivateThemeStep>;
|
|
1929
|
-
/**
|
|
1930
|
-
* @inheritDoc unzip
|
|
1931
|
-
* @example
|
|
1932
|
-
*
|
|
1933
|
-
* <code>
|
|
1934
|
-
* {
|
|
1935
|
-
* "step": "unzip",
|
|
1936
|
-
* "zipFile": {
|
|
1937
|
-
* "resource": "vfs",
|
|
1938
|
-
* "path": "/wordpress/data.zip"
|
|
1939
|
-
* },
|
|
1940
|
-
* "extractToPath": "/wordpress"
|
|
1941
|
-
* }
|
|
1942
|
-
* </code>
|
|
1943
|
-
*/
|
|
1944
|
-
export interface UnzipStep<ResourceType> {
|
|
1945
|
-
step: "unzip";
|
|
1946
|
-
/** The zip file to extract */
|
|
1947
|
-
zipFile?: ResourceType;
|
|
1948
|
-
/**
|
|
1949
|
-
* The path of the zip file to extract
|
|
1950
|
-
* @deprecated Use zipFile instead.
|
|
1951
|
-
*/
|
|
1952
|
-
zipPath?: string;
|
|
1953
|
-
/** The path to extract the zip file to */
|
|
1954
|
-
extractToPath: string;
|
|
1955
|
-
}
|
|
1956
|
-
/**
|
|
1957
|
-
* Unzip a zip file.
|
|
1958
|
-
*
|
|
1959
|
-
* @param playground Playground client.
|
|
1960
|
-
* @param zipPath The zip file to unzip.
|
|
1961
|
-
* @param extractTo The directory to extract the zip file to.
|
|
1962
|
-
*/
|
|
1963
|
-
export declare const unzip: StepHandler<UnzipStep<File>>;
|
|
1964
|
-
/**
|
|
1965
|
-
* @inheritDoc importWordPressFiles
|
|
1966
|
-
* @example
|
|
1967
|
-
*
|
|
1968
|
-
* <code>
|
|
1969
|
-
* {
|
|
1970
|
-
* "step": "importWordPressFiles",
|
|
1971
|
-
* "wordPressFilesZip": {
|
|
1972
|
-
* "resource": "url",
|
|
1973
|
-
* "url": "https://mysite.com/import.zip"
|
|
1974
|
-
* }
|
|
1975
|
-
* }
|
|
1976
|
-
* </code>
|
|
1977
|
-
*/
|
|
1978
|
-
export interface ImportWordPressFilesStep<ResourceType> {
|
|
1979
|
-
step: "importWordPressFiles";
|
|
1980
|
-
/**
|
|
1981
|
-
* The zip file containing the top-level WordPress files and
|
|
1982
|
-
* directories.
|
|
1983
|
-
*/
|
|
1984
|
-
wordPressFilesZip: ResourceType;
|
|
1985
|
-
/**
|
|
1986
|
-
* The path inside the zip file where the WordPress files are.
|
|
1987
|
-
*/
|
|
1988
|
-
pathInZip?: string;
|
|
1989
|
-
}
|
|
1990
|
-
/**
|
|
1991
|
-
* Imports top-level WordPress files from a given zip file into
|
|
1992
|
-
* the `documentRoot`. For example, if a zip file contains the
|
|
1993
|
-
* `wp-content` and `wp-includes` directories, they will replace
|
|
1994
|
-
* the corresponding directories in Playground's `documentRoot`.
|
|
1995
|
-
*
|
|
1996
|
-
* Any files that Playground recognizes as "excluded from the export"
|
|
1997
|
-
* will carry over from the existing document root into the imported
|
|
1998
|
-
* directories. For example, the sqlite-database-integration plugin.
|
|
1999
|
-
*
|
|
2000
|
-
* @param playground Playground client.
|
|
2001
|
-
* @param wordPressFilesZip Zipped WordPress site.
|
|
2002
|
-
*/
|
|
2003
|
-
export declare const importWordPressFiles: StepHandler<ImportWordPressFilesStep<File>>;
|
|
2004
|
-
/**
|
|
2005
|
-
* @inheritDoc importThemeStarterContent
|
|
2006
|
-
* @example
|
|
2007
|
-
*
|
|
2008
|
-
* <code>
|
|
2009
|
-
* {
|
|
2010
|
-
* "step": "importThemeStarterContent"
|
|
2011
|
-
* }
|
|
2012
|
-
* </code>
|
|
2013
|
-
*/
|
|
2014
|
-
export interface ImportThemeStarterContentStep {
|
|
2015
|
-
/** The step identifier. */
|
|
2016
|
-
step: "importThemeStarterContent";
|
|
2017
|
-
/**
|
|
2018
|
-
* The name of the theme to import content from.
|
|
2019
|
-
*/
|
|
2020
|
-
themeSlug?: string;
|
|
2021
|
-
}
|
|
2022
|
-
/**
|
|
2023
|
-
* Imports a theme Starter Content into WordPress.
|
|
2024
|
-
*
|
|
2025
|
-
* @param playground Playground client.
|
|
2026
|
-
*/
|
|
2027
|
-
export declare const importThemeStarterContent: StepHandler<ImportThemeStarterContentStep>;
|
|
2028
|
-
/**
|
|
2029
|
-
* @inheritDoc importWxr
|
|
2030
|
-
* @example
|
|
2031
|
-
*
|
|
2032
|
-
* <code>
|
|
2033
|
-
* {
|
|
2034
|
-
* "step": "importWxr",
|
|
2035
|
-
* "file": {
|
|
2036
|
-
* "resource": "url",
|
|
2037
|
-
* "url": "https://your-site.com/starter-content.wxr"
|
|
2038
|
-
* }
|
|
2039
|
-
* }
|
|
2040
|
-
* </code>
|
|
2041
|
-
*/
|
|
2042
|
-
export interface ImportWxrStep<ResourceType> {
|
|
2043
|
-
step: "importWxr";
|
|
2044
|
-
/** The file to import */
|
|
2045
|
-
file: ResourceType;
|
|
2046
|
-
}
|
|
2047
|
-
/**
|
|
2048
|
-
* Imports a WXR file into WordPress.
|
|
2049
|
-
*
|
|
2050
|
-
* @param playground Playground client.
|
|
2051
|
-
* @param file The file to import.
|
|
2052
|
-
*/
|
|
2053
|
-
export declare const importWxr: StepHandler<ImportWxrStep<File>>;
|
|
2054
|
-
/**
|
|
2055
|
-
* @inheritDoc enableMultisite
|
|
2056
|
-
* @hasRunnableExample
|
|
2057
|
-
* @example
|
|
2058
|
-
*
|
|
2059
|
-
* <code>
|
|
2060
|
-
* {
|
|
2061
|
-
* "step": "enableMultisite"
|
|
2062
|
-
* }
|
|
2063
|
-
* </code>
|
|
2064
|
-
*/
|
|
2065
|
-
export interface EnableMultisiteStep {
|
|
2066
|
-
step: "enableMultisite";
|
|
2067
|
-
}
|
|
2068
|
-
/**
|
|
2069
|
-
* Defines the [Multisite](https://developer.wordpress.org/advanced-administration/multisite/create-network/) constants in a `wp-config.php` file.
|
|
2070
|
-
*
|
|
2071
|
-
* This step can be called multiple times, and the constants will be merged.
|
|
2072
|
-
*
|
|
2073
|
-
* @param playground The playground client.
|
|
2074
|
-
* @param enableMultisite
|
|
2075
|
-
*/
|
|
2076
|
-
export declare const enableMultisite: StepHandler<EnableMultisiteStep>;
|
|
2077
|
-
/**
|
|
2078
|
-
* @inheritDoc wpCLI
|
|
2079
|
-
* @hasRunnableExample
|
|
2080
|
-
* @example
|
|
2081
|
-
*
|
|
2082
|
-
* <code>
|
|
2083
|
-
* {
|
|
2084
|
-
* "step": "wp-cli",
|
|
2085
|
-
* "command": "wp post create --post_title='Test post' --post_excerpt='Some content'"
|
|
2086
|
-
* }
|
|
2087
|
-
* </code>
|
|
2088
|
-
*/
|
|
2089
|
-
export interface WPCLIStep {
|
|
2090
|
-
/** The step identifier. */
|
|
2091
|
-
step: "wp-cli";
|
|
2092
|
-
/** The WP CLI command to run. */
|
|
2093
|
-
command: string | string[];
|
|
2094
|
-
/** wp-cli.phar path */
|
|
2095
|
-
wpCliPath?: string;
|
|
2096
|
-
}
|
|
2097
|
-
/**
|
|
2098
|
-
* Runs PHP code using [WP-CLI](https://developer.wordpress.org/cli/commands/).
|
|
2099
|
-
*/
|
|
2100
|
-
export declare const wpCLI: StepHandler<WPCLIStep, Promise<PHPResponse>>;
|
|
2101
|
-
/**
|
|
2102
|
-
* Deletes WordPress posts and comments and sets the auto increment sequence for the
|
|
2103
|
-
* posts and comments tables to 0.
|
|
2104
|
-
*
|
|
2105
|
-
* @private
|
|
2106
|
-
* @internal
|
|
2107
|
-
* @inheritDoc resetData
|
|
2108
|
-
* @example
|
|
2109
|
-
*
|
|
2110
|
-
* <code>
|
|
2111
|
-
* {
|
|
2112
|
-
* "step": "resetData"
|
|
2113
|
-
* }
|
|
2114
|
-
* </code>
|
|
2115
|
-
*/
|
|
2116
|
-
export interface ResetDataStep {
|
|
2117
|
-
step: "resetData";
|
|
2118
|
-
}
|
|
2119
|
-
/**
|
|
2120
|
-
* @param playground Playground client.
|
|
2121
|
-
*/
|
|
2122
|
-
export declare const resetData: StepHandler<ResetDataStep>;
|
|
2123
|
-
/**
|
|
2124
|
-
* @inheritDoc setSiteLanguage
|
|
2125
|
-
* @hasRunnableExample
|
|
2126
|
-
* @example
|
|
2127
|
-
*
|
|
2128
|
-
* <code>
|
|
2129
|
-
* {
|
|
2130
|
-
* "step": "setSiteLanguage",
|
|
2131
|
-
* "language": "en_US"
|
|
2132
|
-
* }
|
|
2133
|
-
* </code>
|
|
2134
|
-
*/
|
|
2135
|
-
export interface SetSiteLanguageStep {
|
|
2136
|
-
step: "setSiteLanguage";
|
|
2137
|
-
/** The language to set, e.g. 'en_US' */
|
|
2138
|
-
language: string;
|
|
2139
|
-
}
|
|
2140
|
-
/**
|
|
2141
|
-
* Sets the site language and download translations.
|
|
2142
|
-
*/
|
|
2143
|
-
export declare const setSiteLanguage: StepHandler<SetSiteLanguageStep>;
|
|
2144
|
-
/**
|
|
2145
|
-
* Used by the export step to exclude the Playground-specific files
|
|
2146
|
-
* from the zip file. Keep it in sync with the list of files created
|
|
2147
|
-
* by WordPressPatcher.
|
|
2148
|
-
*/
|
|
2149
|
-
export declare const wpContentFilesExcludedFromExport: string[];
|
|
2150
|
-
export type Step = GenericStep<FileReference>;
|
|
2151
|
-
export type StepDefinition = Step & {
|
|
2152
|
-
progress?: {
|
|
2153
|
-
weight?: number;
|
|
2154
|
-
caption?: string;
|
|
2155
|
-
};
|
|
2156
|
-
};
|
|
2157
|
-
/**
|
|
2158
|
-
* If you add a step here, make sure to also
|
|
2159
|
-
* add it to the exports below.
|
|
2160
|
-
*/
|
|
2161
|
-
export type GenericStep<Resource> = ActivatePluginStep | ActivateThemeStep | CpStep | DefineWpConfigConstsStep | DefineSiteUrlStep | EnableMultisiteStep | ImportWxrStep<Resource> | ImportThemeStarterContentStep | ImportWordPressFilesStep<Resource> | InstallPluginStep<Resource> | InstallThemeStep<Resource> | LoginStep | MkdirStep | MvStep | ResetDataStep | RequestStep | RmStep | RmdirStep | RunPHPStep | RunPHPWithOptionsStep | RunWpInstallationWizardStep | RunSqlStep<Resource> | SetSiteOptionsStep | UnzipStep<Resource> | UpdateUserMetaStep | WriteFileStep<Resource> | WPCLIStep | SetSiteLanguageStep;
|
|
2162
|
-
/**
|
|
2163
|
-
* Progress reporting details.
|
|
2164
|
-
*/
|
|
2165
|
-
export type StepProgress = {
|
|
2166
|
-
tracker: ProgressTracker;
|
|
2167
|
-
initialCaption?: string;
|
|
2168
|
-
};
|
|
2169
|
-
export type StepHandler<S extends GenericStep<File>, Return = any> = (
|
|
2170
|
-
/**
|
|
2171
|
-
* A PHP instance or Playground client.
|
|
2172
|
-
*/
|
|
2173
|
-
php: UniversalPHP, args: Omit<S, "step">, progressArgs?: StepProgress) => Return;
|
|
2174
|
-
/**
|
|
2175
|
-
* Exports the WordPress database as a WXR file using
|
|
2176
|
-
* the core WordPress export tool.
|
|
2177
|
-
*
|
|
2178
|
-
* @param playground Playground client
|
|
2179
|
-
* @returns WXR file
|
|
2180
|
-
*/
|
|
2181
|
-
export declare function exportWXR(playground: UniversalPHP): Promise<File>;
|
|
2182
|
-
export interface ZipWpContentOptions {
|
|
2183
|
-
/**
|
|
2184
|
-
* @private
|
|
2185
|
-
* A temporary workaround to enable including the WordPress default theme
|
|
2186
|
-
* in the exported zip file.
|
|
2187
|
-
*/
|
|
2188
|
-
selfContained?: boolean;
|
|
2189
|
-
}
|
|
2190
|
-
/**
|
|
2191
|
-
* Replace the current wp-content directory with one from the provided zip file.
|
|
2192
|
-
*
|
|
2193
|
-
* @param playground Playground client.
|
|
2194
|
-
* @param wpContentZip Zipped WordPress site.
|
|
2195
|
-
*/
|
|
2196
|
-
export declare const zipWpContent: (playground: UniversalPHP, { selfContained }?: ZipWpContentOptions) => Promise<Uint8Array>;
|
|
2197
|
-
export interface Blueprint {
|
|
2198
|
-
/**
|
|
2199
|
-
* The URL to navigate to after the blueprint has been run.
|
|
2200
|
-
*/
|
|
2201
|
-
landingPage?: string;
|
|
2202
|
-
/**
|
|
2203
|
-
* Optional description. It doesn't do anything but is exposed as
|
|
2204
|
-
* a courtesy to developers who may want to document which blueprint
|
|
2205
|
-
* file does what.
|
|
2206
|
-
*
|
|
2207
|
-
* @deprecated Use meta.description instead.
|
|
2208
|
-
*/
|
|
2209
|
-
description?: string;
|
|
2210
|
-
/**
|
|
2211
|
-
* Optional metadata. Used by the Blueprints gallery at https://github.com/WordPress/blueprints
|
|
2212
|
-
*/
|
|
2213
|
-
meta?: {
|
|
2214
|
-
/**
|
|
2215
|
-
* A clear and concise name for your Blueprint.
|
|
2216
|
-
*/
|
|
2217
|
-
title: string;
|
|
2218
|
-
/**
|
|
2219
|
-
* A brief explanation of what your Blueprint offers.
|
|
2220
|
-
*/
|
|
2221
|
-
description?: string;
|
|
2222
|
-
/**
|
|
2223
|
-
* A GitHub username of the author of this Blueprint.
|
|
2224
|
-
*/
|
|
2225
|
-
author: string;
|
|
2226
|
-
/**
|
|
2227
|
-
* Relevant categories to help users find your Blueprint in the future Blueprints section on WordPress.org.
|
|
2228
|
-
*/
|
|
2229
|
-
categories?: string[];
|
|
2230
|
-
};
|
|
2231
|
-
/**
|
|
2232
|
-
* The preferred PHP and WordPress versions to use.
|
|
2233
|
-
*/
|
|
2234
|
-
preferredVersions?: {
|
|
2235
|
-
/**
|
|
2236
|
-
* The preferred PHP version to use.
|
|
2237
|
-
* If not specified, the latest supported version will be used
|
|
2238
|
-
*/
|
|
2239
|
-
php: SupportedPHPVersion | "latest";
|
|
2240
|
-
/**
|
|
2241
|
-
* The preferred WordPress version to use.
|
|
2242
|
-
* If not specified, the latest supported version will be used
|
|
2243
|
-
*/
|
|
2244
|
-
wp: string | "latest";
|
|
2245
|
-
};
|
|
2246
|
-
features?: {
|
|
2247
|
-
/** Should boot with support for network request via wp_safe_remote_get? */
|
|
2248
|
-
networking?: boolean;
|
|
2249
|
-
};
|
|
2250
|
-
/**
|
|
2251
|
-
* PHP Constants to define on every request
|
|
2252
|
-
*/
|
|
2253
|
-
constants?: Record<string, string>;
|
|
2254
|
-
/**
|
|
2255
|
-
* WordPress plugins to install and activate
|
|
2256
|
-
*/
|
|
2257
|
-
plugins?: Array<string | FileReference>;
|
|
2258
|
-
/**
|
|
2259
|
-
* WordPress site options to define
|
|
2260
|
-
*/
|
|
2261
|
-
siteOptions?: Record<string, string> & {
|
|
2262
|
-
/** The site title */
|
|
2263
|
-
blogname?: string;
|
|
2264
|
-
};
|
|
2265
|
-
/**
|
|
2266
|
-
* User to log in as.
|
|
2267
|
-
* If true, logs the user in as admin/password.
|
|
2268
|
-
*/
|
|
2269
|
-
login?: boolean | {
|
|
2270
|
-
username: string;
|
|
2271
|
-
password: string;
|
|
2272
|
-
};
|
|
2273
|
-
/**
|
|
2274
|
-
* The PHP extensions to use.
|
|
2275
|
-
*/
|
|
2276
|
-
phpExtensionBundles?: SupportedPHPExtensionBundle[];
|
|
2277
|
-
/**
|
|
2278
|
-
* The steps to run after every other operation in this Blueprint was
|
|
2279
|
-
* executed.
|
|
2280
|
-
*/
|
|
2281
|
-
steps?: Array<StepDefinition | string | undefined | false | null>;
|
|
2282
|
-
}
|
|
2283
|
-
export type CompiledStep = (php: UniversalPHP) => Promise<void> | void;
|
|
2284
|
-
export interface CompiledBlueprint {
|
|
2285
|
-
/** The requested versions of PHP and WordPress for the blueprint */
|
|
2286
|
-
versions: {
|
|
2287
|
-
php: SupportedPHPVersion;
|
|
2288
|
-
wp: string;
|
|
2289
|
-
};
|
|
2290
|
-
/** The requested PHP extensions to load */
|
|
2291
|
-
phpExtensions: SupportedPHPExtension[];
|
|
2292
|
-
features: {
|
|
2293
|
-
/** Should boot with support for network request via wp_safe_remote_get? */
|
|
2294
|
-
networking: boolean;
|
|
2295
|
-
};
|
|
2296
|
-
/** The compiled steps for the blueprint */
|
|
2297
|
-
run: (playground: UniversalPHP) => Promise<void>;
|
|
2298
|
-
}
|
|
2299
|
-
export type OnStepCompleted = (output: any, step: StepDefinition) => any;
|
|
2300
|
-
export interface CompileBlueprintOptions {
|
|
2301
|
-
/** Optional progress tracker to monitor progress */
|
|
2302
|
-
progress?: ProgressTracker;
|
|
2303
|
-
/** Optional semaphore to control access to a shared resource */
|
|
2304
|
-
semaphore?: Semaphore;
|
|
2305
|
-
/** Optional callback with step output */
|
|
2306
|
-
onStepCompleted?: OnStepCompleted;
|
|
2307
|
-
}
|
|
2308
|
-
/**
|
|
2309
|
-
* Compiles Blueprint into a form that can be executed.
|
|
2310
|
-
*
|
|
2311
|
-
* @param playground The PlaygroundClient to use for the compilation
|
|
2312
|
-
* @param blueprint The bBueprint to compile
|
|
2313
|
-
* @param options Additional options for the compilation
|
|
2314
|
-
* @returns The compiled blueprint
|
|
2315
|
-
*/
|
|
2316
|
-
export declare function compileBlueprint(blueprint: Blueprint, { progress, semaphore, onStepCompleted, }?: CompileBlueprintOptions): CompiledBlueprint;
|
|
2317
|
-
export declare function runBlueprintSteps(compiledBlueprint: CompiledBlueprint, playground: UniversalPHP): Promise<void>;
|
|
1
|
+
export * from './lib/steps';
|
|
2
|
+
export * from './lib/steps/handlers';
|
|
3
|
+
export { runBlueprintSteps, compileBlueprint } from './lib/compile';
|
|
4
|
+
export type { Blueprint } from './lib/blueprint';
|
|
5
|
+
export type { CompiledStep, CompiledBlueprint, CompileBlueprintOptions, OnStepCompleted, } from './lib/compile';
|
|
6
|
+
export type { CachedResource, CorePluginReference, CorePluginResource, CoreThemeReference, CoreThemeResource, DecoratedResource, FetchResource, FileReference, LiteralReference, LiteralResource, Resource, ResourceOptions, ResourceTypes, SemaphoreResource, UrlReference, UrlResource, VFSReference, VFSResource, } from './lib/resources';
|
|
7
|
+
export { wpContentFilesExcludedFromExport } from './lib/utils/wp-content-files-excluded-from-exports';
|
|
2318
8
|
/**
|
|
2319
9
|
* @deprecated This function is a no-op. Playground no longer uses a proxy to download plugins and themes.
|
|
2320
10
|
* To be removed in v0.3.0
|
|
2321
11
|
*/
|
|
2322
12
|
export declare function setPluginProxyURL(): void;
|
|
2323
|
-
|
|
2324
|
-
export {};
|