@wp-playground/client 0.1.23 → 0.1.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/blueprint-schema.json +1203 -0
- package/index.cjs +103 -0
- package/index.d.ts +1036 -385
- package/index.js +1652 -958
- package/package.json +11 -3
package/index.d.ts
CHANGED
|
@@ -1,5 +1,151 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v7.2.0
|
|
2
2
|
|
|
3
|
+
import * as Comlink from 'comlink';
|
|
4
|
+
import { Remote } from 'comlink';
|
|
5
|
+
|
|
6
|
+
export interface MonitoredModule {
|
|
7
|
+
dependencyFilename: string;
|
|
8
|
+
dependenciesTotalSize: number;
|
|
9
|
+
}
|
|
10
|
+
declare class EmscriptenDownloadMonitor extends EventTarget {
|
|
11
|
+
#private;
|
|
12
|
+
constructor(modules?: MonitoredModule[]);
|
|
13
|
+
getEmscriptenOptions(): {
|
|
14
|
+
dataFileDownloads: Record<string, any>;
|
|
15
|
+
};
|
|
16
|
+
setModules(modules: MonitoredModule[]): void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Options for customizing the progress tracker.
|
|
20
|
+
*/
|
|
21
|
+
export interface ProgressTrackerOptions {
|
|
22
|
+
/** The weight of the progress, a number between 0 and 1. */
|
|
23
|
+
weight?: number;
|
|
24
|
+
/** The caption to display during progress, a string. */
|
|
25
|
+
caption?: string;
|
|
26
|
+
/** The time in milliseconds to fill the progress, a number. */
|
|
27
|
+
fillTime?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Custom event providing information about a loading process.
|
|
31
|
+
*/
|
|
32
|
+
export type LoadingEvent = CustomEvent<{
|
|
33
|
+
/** The number representing how much was loaded. */
|
|
34
|
+
loaded: number;
|
|
35
|
+
/** The number representing how much needs to loaded in total. */
|
|
36
|
+
total: number;
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Custom event providing progress details.
|
|
40
|
+
*/
|
|
41
|
+
export type ProgressTrackerEvent = CustomEvent<ProgressDetails>;
|
|
42
|
+
export interface ProgressDetails {
|
|
43
|
+
/** The progress percentage as a number between 0 and 100. */
|
|
44
|
+
progress: number;
|
|
45
|
+
/** The caption to display during progress, a string. */
|
|
46
|
+
caption: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* ProgressObserver A function that receives progress updates.
|
|
50
|
+
*
|
|
51
|
+
* @param progress The progress percentage as a number between 0 and 100.
|
|
52
|
+
*/
|
|
53
|
+
export type ProgressObserver = (progress: number) => void;
|
|
54
|
+
/**
|
|
55
|
+
* Listener A function for handling specific event types.
|
|
56
|
+
*
|
|
57
|
+
* @param event The event of type T.
|
|
58
|
+
*/
|
|
59
|
+
export type Listener<T> = (event: T) => void;
|
|
60
|
+
export type TSCompatibleListener<T> = EventListenerOrEventListenerObject | null | Listener<T>;
|
|
61
|
+
export interface ProgressReceiver {
|
|
62
|
+
setProgress(details: ProgressDetails): any;
|
|
63
|
+
setLoaded(): any;
|
|
64
|
+
}
|
|
65
|
+
declare class ProgressTracker extends EventTarget {
|
|
66
|
+
private _selfWeight;
|
|
67
|
+
private _selfProgress;
|
|
68
|
+
private _selfCaption;
|
|
69
|
+
private _weight;
|
|
70
|
+
private _progressObserver?;
|
|
71
|
+
private _loadingListener?;
|
|
72
|
+
private _isFilling;
|
|
73
|
+
private _fillTime;
|
|
74
|
+
private _fillInterval?;
|
|
75
|
+
private _subTrackers;
|
|
76
|
+
constructor({ weight, caption, fillTime, }?: ProgressTrackerOptions);
|
|
77
|
+
/**
|
|
78
|
+
* Creates a new sub-tracker with a specific weight.
|
|
79
|
+
*
|
|
80
|
+
* The weight determines what percentage of the overall progress
|
|
81
|
+
* the sub-tracker represents. For example, if the main tracker is
|
|
82
|
+
* monitoring a process that has two stages, and the first stage
|
|
83
|
+
* is expected to take twice as long as the second stage, you could
|
|
84
|
+
* create the first sub-tracker with a weight of 0.67 and the second
|
|
85
|
+
* sub-tracker with a weight of 0.33.
|
|
86
|
+
*
|
|
87
|
+
* The caption is an optional string that describes the current stage
|
|
88
|
+
* of the operation. If provided, it will be used as the progress caption
|
|
89
|
+
* for the sub-tracker. If not provided, the main tracker will look for
|
|
90
|
+
* the next sub-tracker with a non-empty caption and use that as the progress
|
|
91
|
+
* caption instead.
|
|
92
|
+
*
|
|
93
|
+
* Returns the newly-created sub-tracker.
|
|
94
|
+
*
|
|
95
|
+
* @throws {Error} If the weight of the new stage would cause the total weight of all stages to exceed 1.
|
|
96
|
+
*
|
|
97
|
+
* @param weight The weight of the new stage, as a decimal value between 0 and 1.
|
|
98
|
+
* @param caption The caption for the new stage, which will be used as the progress caption for the sub-tracker.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* const tracker = new ProgressTracker();
|
|
103
|
+
* const subTracker1 = tracker.stage(0.67, 'Slow stage');
|
|
104
|
+
* const subTracker2 = tracker.stage(0.33, 'Fast stage');
|
|
105
|
+
*
|
|
106
|
+
* subTracker2.set(50);
|
|
107
|
+
* subTracker1.set(75);
|
|
108
|
+
* subTracker2.set(100);
|
|
109
|
+
* subTracker1.set(100);
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
stage(weight?: number, caption?: string): ProgressTracker;
|
|
113
|
+
/**
|
|
114
|
+
* Fills the progress bar slowly over time, simulating progress.
|
|
115
|
+
*
|
|
116
|
+
* The progress bar is filled in a 100 steps, and each step, the progress
|
|
117
|
+
* is increased by 1. If `stopBeforeFinishing` is true, the progress bar
|
|
118
|
+
* will stop filling when it reaches 99% so that you can call `finish()`
|
|
119
|
+
* explicitly.
|
|
120
|
+
*
|
|
121
|
+
* If the progress bar is filling or already filled, this method does nothing.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* const progress = new ProgressTracker({ caption: 'Processing...' });
|
|
126
|
+
* progress.fillSlowly();
|
|
127
|
+
* ```
|
|
128
|
+
*
|
|
129
|
+
* @param options Optional options.
|
|
130
|
+
*/
|
|
131
|
+
fillSlowly({ stopBeforeFinishing }?: {
|
|
132
|
+
stopBeforeFinishing?: boolean | undefined;
|
|
133
|
+
}): void;
|
|
134
|
+
set(value: number): void;
|
|
135
|
+
finish(): void;
|
|
136
|
+
get caption(): string;
|
|
137
|
+
setCaption(caption: string): void;
|
|
138
|
+
get done(): boolean;
|
|
139
|
+
get progress(): number;
|
|
140
|
+
get weight(): number;
|
|
141
|
+
get observer(): ProgressObserver;
|
|
142
|
+
get loadingListener(): Listener<LoadingEvent>;
|
|
143
|
+
pipe(receiver: ProgressReceiver): void;
|
|
144
|
+
addEventListener(type: string, listener: TSCompatibleListener<ProgressTrackerEvent>): void;
|
|
145
|
+
removeEventListener(type: string, listener: TSCompatibleListener<ProgressTrackerEvent>): void;
|
|
146
|
+
private notifyProgress;
|
|
147
|
+
private notifyDone;
|
|
148
|
+
}
|
|
3
149
|
export interface PHPResponseData {
|
|
4
150
|
/**
|
|
5
151
|
* Response headers.
|
|
@@ -28,7 +174,7 @@ export interface PHPResponseData {
|
|
|
28
174
|
* PHP response. Body is an `ArrayBuffer` because it can
|
|
29
175
|
* contain binary data.
|
|
30
176
|
*
|
|
31
|
-
* This type is used in Comlink.transferHandlers.set('PHPResponse', { ... })
|
|
177
|
+
* This type is used in Comlink.transferHandlers.set('PHPResponse', \{ ... \})
|
|
32
178
|
* so be sure to update that if you change this type.
|
|
33
179
|
*/
|
|
34
180
|
export declare class PHPResponse implements PHPResponseData {
|
|
@@ -54,62 +200,84 @@ export declare class PHPResponse implements PHPResponseData {
|
|
|
54
200
|
*/
|
|
55
201
|
get text(): string;
|
|
56
202
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
203
|
+
/**
|
|
204
|
+
* Handles HTTP requests using PHP runtime as a backend.
|
|
205
|
+
*
|
|
206
|
+
* @public
|
|
207
|
+
* @example Use PHPRequestHandler implicitly with a new PHP instance:
|
|
208
|
+
* ```js
|
|
209
|
+
* import { PHP } from '@php-wasm/web';
|
|
210
|
+
*
|
|
211
|
+
* const php = await PHP.load( '7.4', {
|
|
212
|
+
* requestHandler: {
|
|
213
|
+
* // PHP FS path to serve the files from:
|
|
214
|
+
* documentRoot: '/www',
|
|
215
|
+
*
|
|
216
|
+
* // Used to populate $_SERVER['SERVER_NAME'] etc.:
|
|
217
|
+
* absoluteUrl: 'http://127.0.0.1'
|
|
218
|
+
* }
|
|
219
|
+
* } );
|
|
220
|
+
*
|
|
221
|
+
* php.mkdirTree('/www');
|
|
222
|
+
* php.writeFile('/www/index.php', '<?php echo "Hi from PHP!"; ');
|
|
223
|
+
*
|
|
224
|
+
* const response = await php.request({ path: '/index.php' });
|
|
225
|
+
* console.log(response.text);
|
|
226
|
+
* // "Hi from PHP!"
|
|
227
|
+
* ```
|
|
228
|
+
*
|
|
229
|
+
* @example Explicitly create a PHPRequestHandler instance and run a PHP script:
|
|
230
|
+
* ```js
|
|
231
|
+
* import {
|
|
232
|
+
* loadPHPRuntime,
|
|
233
|
+
* PHP,
|
|
234
|
+
* PHPRequestHandler,
|
|
235
|
+
* getPHPLoaderModule,
|
|
236
|
+
* } from '@php-wasm/web';
|
|
237
|
+
*
|
|
238
|
+
* const runtime = await loadPHPRuntime( await getPHPLoaderModule('7.4') );
|
|
239
|
+
* const php = new PHP( runtime );
|
|
240
|
+
*
|
|
241
|
+
* php.mkdirTree('/www');
|
|
242
|
+
* php.writeFile('/www/index.php', '<?php echo "Hi from PHP!"; ');
|
|
243
|
+
*
|
|
244
|
+
* const server = new PHPRequestHandler(php, {
|
|
245
|
+
* // PHP FS path to serve the files from:
|
|
246
|
+
* documentRoot: '/www',
|
|
247
|
+
*
|
|
248
|
+
* // Used to populate $_SERVER['SERVER_NAME'] etc.:
|
|
249
|
+
* absoluteUrl: 'http://127.0.0.1'
|
|
250
|
+
* });
|
|
251
|
+
*
|
|
252
|
+
* const response = server.request({ path: '/index.php' });
|
|
253
|
+
* console.log(response.text);
|
|
254
|
+
* // "Hi from PHP!"
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
257
|
+
export interface RequestHandler {
|
|
108
258
|
/**
|
|
109
|
-
*
|
|
110
|
-
*
|
|
259
|
+
* Serves the request – either by serving a static file, or by
|
|
260
|
+
* dispatching it to the PHP runtime.
|
|
261
|
+
* Cannot be used in conjunction with `cli()`.
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```js
|
|
265
|
+
* const output = await php.request({
|
|
266
|
+
* method: 'GET',
|
|
267
|
+
* url: '/index.php',
|
|
268
|
+
* headers: {
|
|
269
|
+
* 'X-foo': 'bar',
|
|
270
|
+
* },
|
|
271
|
+
* formData: {
|
|
272
|
+
* foo: 'bar',
|
|
273
|
+
* },
|
|
274
|
+
* });
|
|
275
|
+
* console.log(output.stdout); // "Hello world!"
|
|
276
|
+
* ```
|
|
277
|
+
*
|
|
278
|
+
* @param request - PHP Request data.
|
|
111
279
|
*/
|
|
112
|
-
|
|
280
|
+
request(request: PHPRequest, maxRedirects?: number): Promise<PHPResponse>;
|
|
113
281
|
/**
|
|
114
282
|
* Converts a path to an absolute URL based at the PHPRequestHandler
|
|
115
283
|
* root.
|
|
@@ -126,127 +294,18 @@ declare class PHPRequestHandler {
|
|
|
126
294
|
* @returns The relative path.
|
|
127
295
|
*/
|
|
128
296
|
internalUrlToPath(internalUrl: string): string;
|
|
129
|
-
get isRequestRunning(): boolean;
|
|
130
297
|
/**
|
|
131
298
|
* The absolute URL of this PHPRequestHandler instance.
|
|
132
299
|
*/
|
|
133
|
-
|
|
300
|
+
absoluteUrl: string;
|
|
134
301
|
/**
|
|
135
302
|
* The absolute URL of this PHPRequestHandler instance.
|
|
136
303
|
*/
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Serves the request – either by serving a static file, or by
|
|
140
|
-
* dispatching it to the PHP runtime.
|
|
141
|
-
*
|
|
142
|
-
* @param request - The request.
|
|
143
|
-
* @returns The response.
|
|
144
|
-
*/
|
|
145
|
-
request(request: PHPRequest): Promise<PHPResponse>;
|
|
146
|
-
}
|
|
147
|
-
export interface PHPBrowserConfiguration {
|
|
148
|
-
/**
|
|
149
|
-
* Should handle redirects internally?
|
|
150
|
-
*/
|
|
151
|
-
handleRedirects?: boolean;
|
|
152
|
-
/**
|
|
153
|
-
* The maximum number of redirects to follow internally. Once
|
|
154
|
-
* exceeded, request() will return the redirecting response.
|
|
155
|
-
*/
|
|
156
|
-
maxRedirects?: number;
|
|
157
|
-
}
|
|
158
|
-
declare class PHPBrowser implements WithRequestHandler {
|
|
159
|
-
#private;
|
|
160
|
-
server: PHPRequestHandler;
|
|
161
|
-
/**
|
|
162
|
-
* @param server - The PHP server to browse.
|
|
163
|
-
* @param config - The browser configuration.
|
|
164
|
-
*/
|
|
165
|
-
constructor(server: PHPRequestHandler, config?: PHPBrowserConfiguration);
|
|
166
|
-
/**
|
|
167
|
-
* Sends the request to the server.
|
|
168
|
-
*
|
|
169
|
-
* When cookies are present in the response, this method stores
|
|
170
|
-
* them and sends them with any subsequent requests.
|
|
171
|
-
*
|
|
172
|
-
* When a redirection is present in the response, this method
|
|
173
|
-
* follows it by discarding a response and sending a subsequent
|
|
174
|
-
* request.
|
|
175
|
-
*
|
|
176
|
-
* @param request - The request.
|
|
177
|
-
* @param redirects - Internal. The number of redirects handled so far.
|
|
178
|
-
* @returns PHPRequestHandler response.
|
|
179
|
-
*/
|
|
180
|
-
request(request: PHPRequest, redirects?: number): Promise<PHPResponse>;
|
|
181
|
-
}
|
|
182
|
-
export interface FileInfo {
|
|
183
|
-
key: string;
|
|
184
|
-
name: string;
|
|
185
|
-
type: string;
|
|
186
|
-
data: Uint8Array;
|
|
187
|
-
}
|
|
188
|
-
export interface PHPRunOptions {
|
|
189
|
-
/**
|
|
190
|
-
* Request path following the domain:port part.
|
|
191
|
-
*/
|
|
192
|
-
relativeUri?: string;
|
|
193
|
-
/**
|
|
194
|
-
* Path of the .php file to execute.
|
|
195
|
-
*/
|
|
196
|
-
scriptPath?: string;
|
|
197
|
-
/**
|
|
198
|
-
* Request protocol.
|
|
199
|
-
*/
|
|
200
|
-
protocol?: string;
|
|
201
|
-
/**
|
|
202
|
-
* Request method. Default: `GET`.
|
|
203
|
-
*/
|
|
204
|
-
method?: HTTPMethod;
|
|
205
|
-
/**
|
|
206
|
-
* Request headers.
|
|
207
|
-
*/
|
|
208
|
-
headers?: PHPRequestHeaders;
|
|
209
|
-
/**
|
|
210
|
-
* Request body without the files.
|
|
211
|
-
*/
|
|
212
|
-
body?: string;
|
|
213
|
-
/**
|
|
214
|
-
* Uploaded files.
|
|
215
|
-
*/
|
|
216
|
-
fileInfos?: FileInfo[];
|
|
217
|
-
/**
|
|
218
|
-
* The code snippet to eval instead of a php file.
|
|
219
|
-
*/
|
|
220
|
-
code?: string;
|
|
304
|
+
documentRoot: string;
|
|
221
305
|
}
|
|
222
|
-
export
|
|
223
|
-
export interface WithPHPIniBindings {
|
|
306
|
+
export interface IsomorphicLocalPHP extends RequestHandler {
|
|
224
307
|
setPhpIniPath(path: string): void;
|
|
225
308
|
setPhpIniEntry(key: string, value: string): void;
|
|
226
|
-
}
|
|
227
|
-
export interface WithCLI {
|
|
228
|
-
/**
|
|
229
|
-
* Starts a PHP CLI session with given arguments.
|
|
230
|
-
*
|
|
231
|
-
* Can only be used when PHP was compiled with the CLI SAPI.
|
|
232
|
-
* Cannot be used in conjunction with `run()`.
|
|
233
|
-
*
|
|
234
|
-
* @param argv - The arguments to pass to the CLI.
|
|
235
|
-
* @returns The exit code of the CLI session.
|
|
236
|
-
*/
|
|
237
|
-
cli(argv: string[]): Promise<number>;
|
|
238
|
-
}
|
|
239
|
-
export interface WithNodeFilesystem {
|
|
240
|
-
/**
|
|
241
|
-
* Mounts a Node.js filesystem to a given path in the PHP filesystem.
|
|
242
|
-
*
|
|
243
|
-
* @param localPath - The path of a real local directory you want to mount.
|
|
244
|
-
* @param virtualFSPath - Where to mount it in the virtual filesystem.
|
|
245
|
-
* @see {@link https://emscripten.org/docs/api_reference/Filesystem-API.html#FS.mount}
|
|
246
|
-
*/
|
|
247
|
-
mount(localPath: string | MountSettings, virtualFSPath: string): void;
|
|
248
|
-
}
|
|
249
|
-
export interface WithFilesystem {
|
|
250
309
|
/**
|
|
251
310
|
* Recursively creates a directory with the given path in the PHP filesystem.
|
|
252
311
|
* For example, if the path is `/root/php/data`, and `/root` already exists,
|
|
@@ -262,7 +321,7 @@ export interface WithFilesystem {
|
|
|
262
321
|
/**
|
|
263
322
|
* Reads a file from the PHP filesystem and returns it as a string.
|
|
264
323
|
*
|
|
265
|
-
* @throws {@link ErrnoError} – If the file doesn't exist.
|
|
324
|
+
* @throws {@link @php-wasm/universal:ErrnoError} – If the file doesn't exist.
|
|
266
325
|
* @param path - The file path to read.
|
|
267
326
|
* @returns The file contents.
|
|
268
327
|
*/
|
|
@@ -270,7 +329,7 @@ export interface WithFilesystem {
|
|
|
270
329
|
/**
|
|
271
330
|
* Reads a file from the PHP filesystem and returns it as an array buffer.
|
|
272
331
|
*
|
|
273
|
-
* @throws {@link ErrnoError} – If the file doesn't exist.
|
|
332
|
+
* @throws {@link @php-wasm/universal:ErrnoError} – If the file doesn't exist.
|
|
274
333
|
* @param path - The file path to read.
|
|
275
334
|
* @returns The file contents.
|
|
276
335
|
*/
|
|
@@ -286,10 +345,25 @@ export interface WithFilesystem {
|
|
|
286
345
|
/**
|
|
287
346
|
* Removes a file from the PHP filesystem.
|
|
288
347
|
*
|
|
289
|
-
* @throws {@link ErrnoError} – If the file doesn't exist.
|
|
348
|
+
* @throws {@link @php-wasm/universal:ErrnoError} – If the file doesn't exist.
|
|
290
349
|
* @param path - The file path to remove.
|
|
291
350
|
*/
|
|
292
351
|
unlink(path: string): void;
|
|
352
|
+
/**
|
|
353
|
+
* Moves a file or directory in the PHP filesystem to a
|
|
354
|
+
* new location.
|
|
355
|
+
*
|
|
356
|
+
* @param oldPath The path to rename.
|
|
357
|
+
* @param newPath The new path.
|
|
358
|
+
*/
|
|
359
|
+
mv(oldPath: string, newPath: string): void;
|
|
360
|
+
/**
|
|
361
|
+
* Removes a directory from the PHP filesystem.
|
|
362
|
+
*
|
|
363
|
+
* @param path The directory path to remove.
|
|
364
|
+
* @param options Options for the removal.
|
|
365
|
+
*/
|
|
366
|
+
rmdir(path: string, options?: RmDirOptions): void;
|
|
293
367
|
/**
|
|
294
368
|
* Lists the files and directories in the given directory.
|
|
295
369
|
*
|
|
@@ -320,8 +394,6 @@ export interface WithFilesystem {
|
|
|
320
394
|
* @param path - The new working directory.
|
|
321
395
|
*/
|
|
322
396
|
chdir(path: string): void;
|
|
323
|
-
}
|
|
324
|
-
export interface WithRun {
|
|
325
397
|
/**
|
|
326
398
|
* Runs PHP code.
|
|
327
399
|
* Cannot be used in conjunction with `cli()`.
|
|
@@ -341,34 +413,216 @@ export interface WithRun {
|
|
|
341
413
|
* // {"exitCode":0,"stdout":"","stderr":["Hello, world!"]}
|
|
342
414
|
* ```
|
|
343
415
|
*
|
|
344
|
-
* @param
|
|
416
|
+
* @param options - PHP run options.
|
|
345
417
|
*/
|
|
346
|
-
run(
|
|
418
|
+
run(options: PHPRunOptions): Promise<PHPResponse>;
|
|
347
419
|
}
|
|
348
|
-
export
|
|
420
|
+
export type IsomorphicRemotePHP = Remote<IsomorphicLocalPHP>;
|
|
421
|
+
export type UniversalPHP = IsomorphicLocalPHP | IsomorphicRemotePHP;
|
|
422
|
+
export type HTTPMethod = "GET" | "POST" | "HEAD" | "OPTIONS" | "PATCH" | "PUT" | "DELETE";
|
|
423
|
+
export type PHPRequestHeaders = Record<string, string>;
|
|
424
|
+
export interface PHPRequest {
|
|
349
425
|
/**
|
|
350
|
-
*
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
*
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
*
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
*
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
*
|
|
426
|
+
* Request method. Default: `GET`.
|
|
427
|
+
*/
|
|
428
|
+
method?: HTTPMethod;
|
|
429
|
+
/**
|
|
430
|
+
* Request path or absolute URL.
|
|
431
|
+
*/
|
|
432
|
+
url: string;
|
|
433
|
+
/**
|
|
434
|
+
* Request headers.
|
|
435
|
+
*/
|
|
436
|
+
headers?: PHPRequestHeaders;
|
|
437
|
+
/**
|
|
438
|
+
* Uploaded files
|
|
439
|
+
*/
|
|
440
|
+
files?: Record<string, File>;
|
|
441
|
+
/**
|
|
442
|
+
* Request body without the files.
|
|
443
|
+
*/
|
|
444
|
+
body?: string;
|
|
445
|
+
/**
|
|
446
|
+
* Form data. If set, the request body will be ignored and
|
|
447
|
+
* the content-type header will be set to `application/x-www-form-urlencoded`.
|
|
448
|
+
*/
|
|
449
|
+
formData?: Record<string, unknown>;
|
|
450
|
+
}
|
|
451
|
+
export interface PHPRunOptions {
|
|
452
|
+
/**
|
|
453
|
+
* Request path following the domain:port part.
|
|
454
|
+
*/
|
|
455
|
+
relativeUri?: string;
|
|
456
|
+
/**
|
|
457
|
+
* Path of the .php file to execute.
|
|
458
|
+
*/
|
|
459
|
+
scriptPath?: string;
|
|
460
|
+
/**
|
|
461
|
+
* Request protocol.
|
|
462
|
+
*/
|
|
463
|
+
protocol?: string;
|
|
464
|
+
/**
|
|
465
|
+
* Request method. Default: `GET`.
|
|
466
|
+
*/
|
|
467
|
+
method?: HTTPMethod;
|
|
468
|
+
/**
|
|
469
|
+
* Request headers.
|
|
470
|
+
*/
|
|
471
|
+
headers?: PHPRequestHeaders;
|
|
472
|
+
/**
|
|
473
|
+
* Request body without the files.
|
|
474
|
+
*/
|
|
475
|
+
body?: string;
|
|
476
|
+
/**
|
|
477
|
+
* Uploaded files.
|
|
478
|
+
*/
|
|
479
|
+
fileInfos?: FileInfo[];
|
|
480
|
+
/**
|
|
481
|
+
* The code snippet to eval instead of a php file.
|
|
482
|
+
*/
|
|
483
|
+
code?: string;
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Output of the PHP.wasm runtime.
|
|
487
|
+
*/
|
|
488
|
+
export interface PHPOutput {
|
|
489
|
+
/** Exit code of the PHP process. 0 means success, 1 and 2 mean error. */
|
|
490
|
+
exitCode: number;
|
|
491
|
+
/** Stdout data */
|
|
492
|
+
stdout: ArrayBuffer;
|
|
493
|
+
/** Stderr lines */
|
|
494
|
+
stderr: string[];
|
|
495
|
+
}
|
|
496
|
+
export interface FileInfo {
|
|
497
|
+
key: string;
|
|
498
|
+
name: string;
|
|
499
|
+
type: string;
|
|
500
|
+
data: Uint8Array;
|
|
501
|
+
}
|
|
502
|
+
export interface RmDirOptions {
|
|
503
|
+
/**
|
|
504
|
+
* If true, recursively removes the directory and all its contents.
|
|
505
|
+
* Default: true.
|
|
506
|
+
*/
|
|
507
|
+
recursive?: boolean;
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Emscripten's filesystem-related Exception.
|
|
511
|
+
*
|
|
512
|
+
* @see https://emscripten.org/docs/api_reference/Filesystem-API.html
|
|
513
|
+
* @see https://github.com/emscripten-core/emscripten/blob/main/system/lib/libc/musl/arch/emscripten/bits/errno.h
|
|
514
|
+
* @see https://github.com/emscripten-core/emscripten/blob/38eedc630f17094b3202fd48ac0c2c585dbea31e/system/include/wasi/api.h#L336
|
|
515
|
+
*/
|
|
516
|
+
export interface ErrnoError extends Error {
|
|
517
|
+
node?: any;
|
|
518
|
+
errno: number;
|
|
519
|
+
message: string;
|
|
520
|
+
}
|
|
521
|
+
export declare const SupportedPHPVersions: readonly [
|
|
522
|
+
"8.2",
|
|
523
|
+
"8.1",
|
|
524
|
+
"8.0",
|
|
525
|
+
"7.4",
|
|
526
|
+
"7.3",
|
|
527
|
+
"7.2",
|
|
528
|
+
"7.1",
|
|
529
|
+
"7.0",
|
|
530
|
+
"5.6"
|
|
531
|
+
];
|
|
532
|
+
export declare const LatestSupportedPHPVersion: "8.2";
|
|
533
|
+
export declare const SupportedPHPVersionsList: string[];
|
|
534
|
+
export type SupportedPHPVersion = (typeof SupportedPHPVersions)[number];
|
|
535
|
+
export interface PHPRequestHandlerConfiguration {
|
|
536
|
+
/**
|
|
537
|
+
* The directory in the PHP filesystem where the server will look
|
|
538
|
+
* for the files to serve. Default: `/var/www`.
|
|
539
|
+
*/
|
|
540
|
+
documentRoot?: string;
|
|
541
|
+
/**
|
|
542
|
+
* Request Handler URL. Used to populate $_SERVER details like HTTP_HOST.
|
|
543
|
+
*/
|
|
544
|
+
absoluteUrl?: string;
|
|
545
|
+
/**
|
|
546
|
+
* Callback used by the PHPRequestHandler to decide whether
|
|
547
|
+
* the requested path refers to a PHP file or a static file.
|
|
548
|
+
*/
|
|
549
|
+
isStaticFilePath?: (path: string) => boolean;
|
|
550
|
+
}
|
|
551
|
+
/** @inheritDoc */
|
|
552
|
+
export declare class PHPRequestHandler implements RequestHandler {
|
|
553
|
+
#private;
|
|
554
|
+
/**
|
|
555
|
+
* The PHP instance
|
|
556
|
+
*/
|
|
557
|
+
php: BasePHP;
|
|
558
|
+
/**
|
|
559
|
+
* @param php - The PHP instance.
|
|
560
|
+
* @param config - Request Handler configuration.
|
|
561
|
+
*/
|
|
562
|
+
constructor(php: BasePHP, config?: PHPRequestHandlerConfiguration);
|
|
563
|
+
/** @inheritDoc */
|
|
564
|
+
pathToInternalUrl(path: string): string;
|
|
565
|
+
/** @inheritDoc */
|
|
566
|
+
internalUrlToPath(internalUrl: string): string;
|
|
567
|
+
get isRequestRunning(): boolean;
|
|
568
|
+
/** @inheritDoc */
|
|
569
|
+
get absoluteUrl(): string;
|
|
570
|
+
/** @inheritDoc */
|
|
571
|
+
get documentRoot(): string;
|
|
572
|
+
/** @inheritDoc */
|
|
573
|
+
request(request: PHPRequest): Promise<PHPResponse>;
|
|
574
|
+
}
|
|
575
|
+
export interface PHPBrowserConfiguration {
|
|
576
|
+
/**
|
|
577
|
+
* Should handle redirects internally?
|
|
578
|
+
*/
|
|
579
|
+
handleRedirects?: boolean;
|
|
580
|
+
/**
|
|
581
|
+
* The maximum number of redirects to follow internally. Once
|
|
582
|
+
* exceeded, request() will return the redirecting response.
|
|
583
|
+
*/
|
|
584
|
+
maxRedirects?: number;
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* A fake web browser that handles PHPRequestHandler's cookies and redirects
|
|
588
|
+
* internally without exposing them to the consumer.
|
|
589
|
+
*
|
|
590
|
+
* @public
|
|
591
|
+
*/
|
|
592
|
+
export declare class PHPBrowser implements RequestHandler {
|
|
593
|
+
#private;
|
|
594
|
+
requestHandler: PHPRequestHandler;
|
|
595
|
+
/**
|
|
596
|
+
* @param server - The PHP server to browse.
|
|
597
|
+
* @param config - The browser configuration.
|
|
598
|
+
*/
|
|
599
|
+
constructor(requestHandler: PHPRequestHandler, config?: PHPBrowserConfiguration);
|
|
600
|
+
/**
|
|
601
|
+
* Sends the request to the server.
|
|
367
602
|
*
|
|
368
|
-
*
|
|
603
|
+
* When cookies are present in the response, this method stores
|
|
604
|
+
* them and sends them with any subsequent requests.
|
|
605
|
+
*
|
|
606
|
+
* When a redirection is present in the response, this method
|
|
607
|
+
* follows it by discarding a response and sending a subsequent
|
|
608
|
+
* request.
|
|
609
|
+
*
|
|
610
|
+
* @param request - The request.
|
|
611
|
+
* @param redirects - Internal. The number of redirects handled so far.
|
|
612
|
+
* @returns PHPRequestHandler response.
|
|
369
613
|
*/
|
|
370
|
-
request(request?:
|
|
614
|
+
request(request: PHPRequest, redirects?: number): Promise<PHPResponse>;
|
|
615
|
+
/** @inheritDoc */
|
|
616
|
+
pathToInternalUrl(path: string): string;
|
|
617
|
+
/** @inheritDoc */
|
|
618
|
+
internalUrlToPath(internalUrl: string): string;
|
|
619
|
+
/** @inheritDoc */
|
|
620
|
+
get absoluteUrl(): string;
|
|
621
|
+
/** @inheritDoc */
|
|
622
|
+
get documentRoot(): string;
|
|
371
623
|
}
|
|
624
|
+
export type RuntimeType = "NODE" | "WEB" | "WORKER";
|
|
625
|
+
export type PHPRuntimeId = number;
|
|
372
626
|
export type PHPRuntime = any;
|
|
373
627
|
export type DataModule = {
|
|
374
628
|
dependencyFilename: string;
|
|
@@ -386,11 +640,10 @@ export type EmscriptenOptions = {
|
|
|
386
640
|
onRuntimeInitialized?: () => void;
|
|
387
641
|
monitorRunDependencies?: (left: number) => void;
|
|
388
642
|
} & Record<string, any>;
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
};
|
|
392
|
-
declare abstract class BasePHP implements WithPHPIniBindings, WithFilesystem, WithNodeFilesystem, WithCLI, WithRequestHandler, WithRun {
|
|
643
|
+
declare const __private__dont__use: unique symbol;
|
|
644
|
+
declare abstract class BasePHP implements IsomorphicLocalPHP {
|
|
393
645
|
#private;
|
|
646
|
+
protected [__private__dont__use]: any;
|
|
394
647
|
requestHandler?: PHPBrowser;
|
|
395
648
|
/**
|
|
396
649
|
* Initializes a PHP runtime.
|
|
@@ -400,6 +653,14 @@ declare abstract class BasePHP implements WithPHPIniBindings, WithFilesystem, Wi
|
|
|
400
653
|
* @param serverOptions - Optional. Options for the PHPRequestHandler. If undefined, no request handler will be initialized.
|
|
401
654
|
*/
|
|
402
655
|
constructor(PHPRuntimeId?: PHPRuntimeId, serverOptions?: PHPRequestHandlerConfiguration);
|
|
656
|
+
/** @inheritDoc */
|
|
657
|
+
get absoluteUrl(): string;
|
|
658
|
+
/** @inheritDoc */
|
|
659
|
+
get documentRoot(): string;
|
|
660
|
+
/** @inheritDoc */
|
|
661
|
+
pathToInternalUrl(path: string): string;
|
|
662
|
+
/** @inheritDoc */
|
|
663
|
+
internalUrlToPath(internalUrl: string): string;
|
|
403
664
|
initializeRuntime(runtimeId: PHPRuntimeId): void;
|
|
404
665
|
/** @inheritDoc */
|
|
405
666
|
setPhpIniPath(path: string): void;
|
|
@@ -410,9 +671,7 @@ declare abstract class BasePHP implements WithPHPIniBindings, WithFilesystem, Wi
|
|
|
410
671
|
/** @inheritDoc */
|
|
411
672
|
request(request: PHPRequest, maxRedirects?: number): Promise<PHPResponse>;
|
|
412
673
|
/** @inheritDoc */
|
|
413
|
-
run(request
|
|
414
|
-
cli(argv: string[]): Promise<number>;
|
|
415
|
-
setSkipShebang(shouldSkip: boolean): void;
|
|
674
|
+
run(request: PHPRunOptions): Promise<PHPResponse>;
|
|
416
675
|
addServerGlobalEntry(key: string, value: string): void;
|
|
417
676
|
/** @inheritDoc */
|
|
418
677
|
mkdir(path: string): void;
|
|
@@ -427,79 +686,535 @@ declare abstract class BasePHP implements WithPHPIniBindings, WithFilesystem, Wi
|
|
|
427
686
|
/** @inheritDoc */
|
|
428
687
|
unlink(path: string): void;
|
|
429
688
|
/** @inheritDoc */
|
|
689
|
+
mv(fromPath: string, toPath: string): void;
|
|
690
|
+
/** @inheritDoc */
|
|
691
|
+
rmdir(path: string, options?: RmDirOptions): void;
|
|
692
|
+
/** @inheritDoc */
|
|
430
693
|
listFiles(path: string): string[];
|
|
431
694
|
/** @inheritDoc */
|
|
432
695
|
isDir(path: string): boolean;
|
|
433
696
|
/** @inheritDoc */
|
|
434
697
|
fileExists(path: string): boolean;
|
|
435
|
-
/** @inheritDoc */
|
|
436
|
-
mount(localPath: string | MountSettings, virtualFSPath: string): void;
|
|
437
698
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
699
|
+
export interface SemaphoreOptions {
|
|
700
|
+
concurrency: number;
|
|
701
|
+
}
|
|
702
|
+
declare class Semaphore {
|
|
703
|
+
private _running;
|
|
704
|
+
private concurrency;
|
|
705
|
+
private queue;
|
|
706
|
+
constructor({ concurrency }: SemaphoreOptions);
|
|
707
|
+
get running(): number;
|
|
708
|
+
acquire(): Promise<() => void>;
|
|
709
|
+
run<T>(fn: () => Promise<T>): Promise<T>;
|
|
710
|
+
}
|
|
711
|
+
export declare function phpVar(value: unknown): string;
|
|
712
|
+
export declare function phpVars<T extends Record<string, unknown>>(vars: T): Record<keyof T, string>;
|
|
713
|
+
export declare const ResourceTypes: readonly [
|
|
714
|
+
"vfs",
|
|
715
|
+
"literal",
|
|
716
|
+
"wordpress.org/themes",
|
|
717
|
+
"wordpress.org/plugins",
|
|
718
|
+
"url"
|
|
448
719
|
];
|
|
449
|
-
export type
|
|
450
|
-
|
|
451
|
-
|
|
720
|
+
export type VFSReference = {
|
|
721
|
+
/** Identifies the file resource as Virtual File System (VFS) */
|
|
722
|
+
resource: "vfs";
|
|
723
|
+
/** The path to the file in the VFS */
|
|
724
|
+
path: string;
|
|
452
725
|
};
|
|
453
|
-
export
|
|
454
|
-
|
|
455
|
-
|
|
726
|
+
export type LiteralReference = {
|
|
727
|
+
/** Identifies the file resource as a literal file */
|
|
728
|
+
resource: "literal";
|
|
729
|
+
/** The name of the file */
|
|
730
|
+
name: string;
|
|
731
|
+
/** The contents of the file */
|
|
732
|
+
contents: string | Uint8Array;
|
|
733
|
+
};
|
|
734
|
+
export type CoreThemeReference = {
|
|
735
|
+
/** Identifies the file resource as a WordPress Core theme */
|
|
736
|
+
resource: "wordpress.org/themes";
|
|
737
|
+
/** The slug of the WordPress Core theme */
|
|
738
|
+
slug: string;
|
|
739
|
+
};
|
|
740
|
+
export type CorePluginReference = {
|
|
741
|
+
/** Identifies the file resource as a WordPress Core plugin */
|
|
742
|
+
resource: "wordpress.org/plugins";
|
|
743
|
+
/** The slug of the WordPress Core plugin */
|
|
744
|
+
slug: string;
|
|
745
|
+
};
|
|
746
|
+
export type UrlReference = {
|
|
747
|
+
/** Identifies the file resource as a URL */
|
|
748
|
+
resource: "url";
|
|
749
|
+
/** The URL of the file */
|
|
750
|
+
url: string;
|
|
751
|
+
/** Optional caption for displaying a progress message */
|
|
752
|
+
caption?: string;
|
|
753
|
+
};
|
|
754
|
+
export type FileReference = VFSReference | LiteralReference | CoreThemeReference | CorePluginReference | UrlReference;
|
|
755
|
+
export interface ResourceOptions {
|
|
756
|
+
/** Optional semaphore to limit concurrent downloads */
|
|
757
|
+
semaphore?: Semaphore;
|
|
758
|
+
progress?: ProgressTracker;
|
|
456
759
|
}
|
|
457
|
-
declare class
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
760
|
+
export declare abstract class Resource {
|
|
761
|
+
/** Optional progress tracker to monitor progress */
|
|
762
|
+
abstract progress?: ProgressTracker;
|
|
763
|
+
/** A Promise that resolves to the file contents */
|
|
764
|
+
protected promise?: Promise<File>;
|
|
765
|
+
protected playground?: UniversalPHP;
|
|
766
|
+
/**
|
|
767
|
+
* Creates a new Resource based on the given file reference
|
|
768
|
+
*
|
|
769
|
+
* @param ref The file reference to create the Resource for
|
|
770
|
+
* @param options Additional options for the Resource
|
|
771
|
+
* @returns A new Resource instance
|
|
772
|
+
*/
|
|
773
|
+
static create(ref: FileReference, { semaphore, progress }: ResourceOptions): Resource;
|
|
774
|
+
setPlayground(playground: UniversalPHP): void;
|
|
775
|
+
/**
|
|
776
|
+
* Resolves the file contents
|
|
777
|
+
* @returns The resolved file.
|
|
778
|
+
*/
|
|
779
|
+
abstract resolve(): Promise<File>;
|
|
780
|
+
/** The name of the referenced file */
|
|
781
|
+
abstract get name(): string;
|
|
782
|
+
/** Whether this Resource is loaded asynchronously */
|
|
783
|
+
get isAsync(): boolean;
|
|
464
784
|
}
|
|
465
|
-
|
|
785
|
+
/**
|
|
786
|
+
* A `Resource` that represents a file in the VFS (virtual file system) of the playground.
|
|
787
|
+
*/
|
|
788
|
+
export declare class VFSResource extends Resource {
|
|
789
|
+
private resource;
|
|
790
|
+
progress?: ProgressTracker | undefined;
|
|
466
791
|
/**
|
|
467
|
-
*
|
|
792
|
+
* Creates a new instance of `VFSResource`.
|
|
793
|
+
* @param playground The playground client.
|
|
794
|
+
* @param resource The VFS reference.
|
|
795
|
+
* @param progress The progress tracker.
|
|
468
796
|
*/
|
|
469
|
-
|
|
797
|
+
constructor(resource: VFSReference, progress?: ProgressTracker | undefined);
|
|
798
|
+
/** @inheritDoc */
|
|
799
|
+
resolve(): Promise<File>;
|
|
800
|
+
/** @inheritDoc */
|
|
801
|
+
get name(): string;
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* A `Resource` that represents a literal file.
|
|
805
|
+
*/
|
|
806
|
+
export declare class LiteralResource extends Resource {
|
|
807
|
+
private resource;
|
|
808
|
+
progress?: ProgressTracker | undefined;
|
|
470
809
|
/**
|
|
471
|
-
*
|
|
810
|
+
* Creates a new instance of `LiteralResource`.
|
|
811
|
+
* @param resource The literal reference.
|
|
812
|
+
* @param progress The progress tracker.
|
|
472
813
|
*/
|
|
473
|
-
|
|
814
|
+
constructor(resource: LiteralReference, progress?: ProgressTracker | undefined);
|
|
815
|
+
/** @inheritDoc */
|
|
816
|
+
resolve(): Promise<File>;
|
|
817
|
+
/** @inheritDoc */
|
|
818
|
+
get name(): string;
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* A base class for `Resource`s that require fetching data from a remote URL.
|
|
822
|
+
*/
|
|
823
|
+
export declare abstract class FetchResource extends Resource {
|
|
824
|
+
progress?: ProgressTracker | undefined;
|
|
825
|
+
/**
|
|
826
|
+
* Creates a new instance of `FetchResource`.
|
|
827
|
+
* @param progress The progress tracker.
|
|
828
|
+
*/
|
|
829
|
+
constructor(progress?: ProgressTracker | undefined);
|
|
830
|
+
/** @inheritDoc */
|
|
831
|
+
resolve(): Promise<File>;
|
|
832
|
+
/**
|
|
833
|
+
* Gets the URL to fetch the data from.
|
|
834
|
+
* @returns The URL.
|
|
835
|
+
*/
|
|
836
|
+
protected abstract getURL(): string;
|
|
837
|
+
/**
|
|
838
|
+
* Gets the caption for the progress tracker.
|
|
839
|
+
* @returns The caption.
|
|
840
|
+
*/
|
|
841
|
+
protected get caption(): string;
|
|
842
|
+
/** @inheritDoc */
|
|
843
|
+
get name(): string;
|
|
844
|
+
/** @inheritDoc */
|
|
845
|
+
get isAsync(): boolean;
|
|
474
846
|
}
|
|
475
|
-
export type ProgressMode =
|
|
476
847
|
/**
|
|
477
|
-
*
|
|
478
|
-
* about the progress.
|
|
848
|
+
* A `Resource` that represents a file available from a URL.
|
|
479
849
|
*/
|
|
480
|
-
|
|
850
|
+
export declare class UrlResource extends FetchResource {
|
|
851
|
+
private resource;
|
|
852
|
+
/**
|
|
853
|
+
* Creates a new instance of `UrlResource`.
|
|
854
|
+
* @param resource The URL reference.
|
|
855
|
+
* @param progress The progress tracker.
|
|
856
|
+
*/
|
|
857
|
+
constructor(resource: UrlReference, progress?: ProgressTracker);
|
|
858
|
+
/** @inheritDoc */
|
|
859
|
+
getURL(): string;
|
|
860
|
+
/** @inheritDoc */
|
|
861
|
+
protected get caption(): string;
|
|
862
|
+
}
|
|
481
863
|
/**
|
|
482
|
-
*
|
|
483
|
-
* an operation will take and just want to keep slowly incrementing
|
|
484
|
-
* the progress bar.
|
|
864
|
+
* A `Resource` that represents a WordPress core theme.
|
|
485
865
|
*/
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
866
|
+
export declare class CoreThemeResource extends FetchResource {
|
|
867
|
+
private resource;
|
|
868
|
+
constructor(resource: CoreThemeReference, progress?: ProgressTracker);
|
|
869
|
+
get name(): string;
|
|
870
|
+
getURL(): string;
|
|
871
|
+
}
|
|
872
|
+
/**
|
|
873
|
+
* A resource that fetches a WordPress plugin from wordpress.org.
|
|
874
|
+
*/
|
|
875
|
+
export declare class CorePluginResource extends FetchResource {
|
|
876
|
+
private resource;
|
|
877
|
+
constructor(resource: CorePluginReference, progress?: ProgressTracker);
|
|
878
|
+
/** @inheritDoc */
|
|
879
|
+
get name(): string;
|
|
880
|
+
/** @inheritDoc */
|
|
881
|
+
getURL(): string;
|
|
882
|
+
}
|
|
883
|
+
/**
|
|
884
|
+
* A decorator for a resource that adds functionality such as progress tracking and caching.
|
|
885
|
+
*/
|
|
886
|
+
export declare class DecoratedResource<T extends Resource> extends Resource {
|
|
887
|
+
private resource;
|
|
888
|
+
constructor(resource: T);
|
|
889
|
+
/** @inheritDoc */
|
|
890
|
+
resolve(): Promise<File>;
|
|
891
|
+
/** @inheritDoc */
|
|
892
|
+
get progress(): ProgressTracker | undefined;
|
|
893
|
+
/** @inheritDoc */
|
|
894
|
+
set progress(value: ProgressTracker | undefined);
|
|
895
|
+
/** @inheritDoc */
|
|
896
|
+
get name(): string;
|
|
897
|
+
/** @inheritDoc */
|
|
898
|
+
get isAsync(): boolean;
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* A decorator for a resource that adds caching functionality.
|
|
902
|
+
*/
|
|
903
|
+
export declare class CachedResource<T extends Resource> extends DecoratedResource<T> {
|
|
904
|
+
protected promise?: Promise<File>;
|
|
905
|
+
/** @inheritDoc */
|
|
906
|
+
resolve(): Promise<File>;
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* A decorator for a resource that adds concurrency control functionality through a semaphore.
|
|
910
|
+
*/
|
|
911
|
+
export declare class SemaphoreResource<T extends Resource> extends DecoratedResource<T> {
|
|
912
|
+
private readonly semaphore;
|
|
913
|
+
constructor(resource: T, semaphore: Semaphore);
|
|
914
|
+
/** @inheritDoc */
|
|
915
|
+
resolve(): Promise<File>;
|
|
916
|
+
}
|
|
917
|
+
export interface ActivatePluginStep {
|
|
918
|
+
step: "activatePlugin";
|
|
919
|
+
plugin: string;
|
|
920
|
+
}
|
|
921
|
+
/**
|
|
922
|
+
* Activates a WordPress plugin in the Playground.
|
|
923
|
+
*
|
|
924
|
+
* @param playground The playground client.
|
|
925
|
+
* @param plugin The plugin slug.
|
|
926
|
+
*/
|
|
927
|
+
export declare const activatePlugin: StepHandler<ActivatePluginStep>;
|
|
928
|
+
export interface ApplyWordPressPatchesStep {
|
|
929
|
+
step: "applyWordPressPatches";
|
|
930
|
+
siteUrl: string;
|
|
931
|
+
wordpressPath?: string;
|
|
932
|
+
patchSqlitePlugin?: boolean;
|
|
933
|
+
addPhpInfo?: boolean;
|
|
934
|
+
patchSiteUrl?: boolean;
|
|
935
|
+
disableSiteHealth?: boolean;
|
|
936
|
+
disableWpNewBlogNotification?: boolean;
|
|
937
|
+
}
|
|
938
|
+
export declare const applyWordPressPatches: StepHandler<ApplyWordPressPatchesStep>;
|
|
939
|
+
export interface DefineSiteUrlStep {
|
|
940
|
+
step: "defineSiteUrl";
|
|
941
|
+
siteUrl: string;
|
|
942
|
+
}
|
|
943
|
+
/**
|
|
944
|
+
* Sets site URL of the WordPress installation.
|
|
945
|
+
*
|
|
946
|
+
* @param playground The playground client.
|
|
947
|
+
* @param siteUrl
|
|
948
|
+
*/
|
|
949
|
+
export declare const defineSiteUrl: StepHandler<DefineSiteUrlStep>;
|
|
950
|
+
/**
|
|
951
|
+
* Full site export support:
|
|
952
|
+
*/
|
|
953
|
+
/**
|
|
954
|
+
* Export the current site as a zip file.
|
|
955
|
+
*
|
|
956
|
+
* @param playground Playground client.
|
|
957
|
+
*/
|
|
958
|
+
export declare function zipEntireSite(playground: UniversalPHP): Promise<File>;
|
|
959
|
+
export interface ReplaceSiteStep<ResourceType> {
|
|
960
|
+
step: "replaceSite";
|
|
961
|
+
fullSiteZip: ResourceType;
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* Replace the current site with the contents of a full site zip file.
|
|
965
|
+
*
|
|
966
|
+
* @param playground Playground client.
|
|
967
|
+
* @param fullSiteZip Zipped WordPress site.
|
|
968
|
+
*/
|
|
969
|
+
export declare const replaceSite: StepHandler<ReplaceSiteStep<File>>;
|
|
970
|
+
export interface UnzipStep {
|
|
971
|
+
step: "unzip";
|
|
972
|
+
zipPath: string;
|
|
973
|
+
extractToPath: string;
|
|
974
|
+
}
|
|
975
|
+
/**
|
|
976
|
+
* Unzip a zip file.
|
|
977
|
+
*
|
|
978
|
+
* @param playground Playground client.
|
|
979
|
+
* @param zipPath The zip file to unzip.
|
|
980
|
+
* @param extractTo The directory to extract the zip file to.
|
|
981
|
+
*/
|
|
982
|
+
export declare const unzip: StepHandler<UnzipStep>;
|
|
983
|
+
export interface ImportFileStep<ResourceType> {
|
|
984
|
+
step: "importFile";
|
|
985
|
+
file: ResourceType;
|
|
986
|
+
}
|
|
987
|
+
/**
|
|
988
|
+
* Uploads a file to the WordPress importer and returns the response.
|
|
989
|
+
* Supports both WXR and WXZ files.
|
|
990
|
+
*
|
|
991
|
+
* @see https://github.com/WordPress/wordpress-importer/compare/master...akirk:wordpress-importer:import-wxz.patch
|
|
992
|
+
* @param playground Playground client.
|
|
993
|
+
* @param file The file to import.
|
|
994
|
+
*/
|
|
995
|
+
export declare const importFile: StepHandler<ImportFileStep<File>>;
|
|
996
|
+
export interface InstallPluginStep<ResourceType> {
|
|
997
|
+
step: "installPlugin";
|
|
998
|
+
pluginZipFile: ResourceType;
|
|
999
|
+
options?: InstallPluginOptions;
|
|
1000
|
+
}
|
|
1001
|
+
export interface InstallPluginOptions {
|
|
1002
|
+
/**
|
|
1003
|
+
* Whether to activate the plugin after installing it.
|
|
1004
|
+
*/
|
|
1005
|
+
activate?: boolean;
|
|
1006
|
+
}
|
|
1007
|
+
/**
|
|
1008
|
+
* Installs a WordPress plugin in the Playground.
|
|
1009
|
+
* Technically, it uses the same plugin upload form as a WordPress user
|
|
1010
|
+
* would, and then activates the plugin if needed.
|
|
1011
|
+
*
|
|
1012
|
+
* @param playground The playground client.
|
|
1013
|
+
* @param pluginZipFile The plugin zip file.
|
|
1014
|
+
* @param options Optional. Set `activate` to false if you don't want to activate the plugin.
|
|
1015
|
+
*/
|
|
1016
|
+
export declare const installPlugin: StepHandler<InstallPluginStep<File>>;
|
|
1017
|
+
export interface InstallThemeStep<ResourceType> {
|
|
1018
|
+
step: "installTheme";
|
|
1019
|
+
themeZipFile: ResourceType;
|
|
1020
|
+
options?: InstallThemeOptions;
|
|
1021
|
+
}
|
|
1022
|
+
export interface InstallThemeOptions {
|
|
1023
|
+
/**
|
|
1024
|
+
* Whether to activate the theme after installing it.
|
|
1025
|
+
*/
|
|
1026
|
+
activate?: boolean;
|
|
1027
|
+
}
|
|
1028
|
+
/**
|
|
1029
|
+
* Installs a WordPress theme in the Playground.
|
|
1030
|
+
* Technically, it uses the same theme upload form as a WordPress user
|
|
1031
|
+
* would, and then activates the theme if needed.
|
|
1032
|
+
*
|
|
1033
|
+
* @param playground The playground client.
|
|
1034
|
+
* @param themeZipFile The theme zip file.
|
|
1035
|
+
* @param options Optional. Set `activate` to false if you don't want to activate the theme.
|
|
1036
|
+
*/
|
|
1037
|
+
export declare const installTheme: StepHandler<InstallThemeStep<File>>;
|
|
1038
|
+
export type LoginStep = {
|
|
1039
|
+
step: "login";
|
|
1040
|
+
username?: string;
|
|
1041
|
+
password?: string;
|
|
1042
|
+
};
|
|
1043
|
+
/**
|
|
1044
|
+
* Logs in to the Playground.
|
|
1045
|
+
* Under the hood, this function submits the wp-login.php form
|
|
1046
|
+
* just like a user would.
|
|
1047
|
+
*
|
|
1048
|
+
* @param playground The playground client.
|
|
1049
|
+
* @param user The user to log in as. Defaults to 'admin'.
|
|
1050
|
+
* @param password The password to log in with. Defaults to 'password'.
|
|
1051
|
+
*/
|
|
1052
|
+
export declare const login: StepHandler<LoginStep>;
|
|
1053
|
+
export interface RunWpInstallationWizardStep {
|
|
1054
|
+
step: "runWpInstallationWizard";
|
|
1055
|
+
options: WordPressInstallationOptions;
|
|
495
1056
|
}
|
|
1057
|
+
export interface WordPressInstallationOptions {
|
|
1058
|
+
adminUsername?: string;
|
|
1059
|
+
adminPassword?: string;
|
|
1060
|
+
}
|
|
1061
|
+
/**
|
|
1062
|
+
* Installs WordPress
|
|
1063
|
+
*
|
|
1064
|
+
* @param playground The playground client.
|
|
1065
|
+
* @param options Installation options.
|
|
1066
|
+
*/
|
|
1067
|
+
export declare const runWpInstallationWizard: StepHandler<RunWpInstallationWizardStep>;
|
|
1068
|
+
export type SetSiteOptionsStep = {
|
|
1069
|
+
step: "setSiteOptions";
|
|
1070
|
+
options: Record<string, unknown>;
|
|
1071
|
+
};
|
|
1072
|
+
export declare const setSiteOptions: StepHandler<SetSiteOptionsStep>;
|
|
1073
|
+
export interface UpdateUserMetaStep {
|
|
1074
|
+
step: "updateUserMeta";
|
|
1075
|
+
meta: Record<string, unknown>;
|
|
1076
|
+
userId: number;
|
|
1077
|
+
}
|
|
1078
|
+
export declare const updateUserMeta: StepHandler<UpdateUserMetaStep>;
|
|
1079
|
+
export interface RunPHPStep {
|
|
1080
|
+
step: "runPHP";
|
|
1081
|
+
code: string;
|
|
1082
|
+
}
|
|
1083
|
+
export declare const runPHP: StepHandler<RunPHPStep>;
|
|
1084
|
+
export interface RunPHPWithOptionsStep {
|
|
1085
|
+
step: "runPHPWithOptions";
|
|
1086
|
+
options: PHPRunOptions;
|
|
1087
|
+
}
|
|
1088
|
+
export declare const runPHPWithOptions: StepHandler<RunPHPWithOptionsStep>;
|
|
1089
|
+
export interface SetPhpIniEntryStep {
|
|
1090
|
+
step: "setPhpIniEntry";
|
|
1091
|
+
key: string;
|
|
1092
|
+
value: string;
|
|
1093
|
+
}
|
|
1094
|
+
export declare const setPhpIniEntry: StepHandler<SetPhpIniEntryStep>;
|
|
1095
|
+
export interface RequestStep {
|
|
1096
|
+
step: "request";
|
|
1097
|
+
request: PHPRequest;
|
|
1098
|
+
}
|
|
1099
|
+
export declare const request: StepHandler<RequestStep>;
|
|
1100
|
+
export interface CpStep {
|
|
1101
|
+
step: "cp";
|
|
1102
|
+
fromPath: string;
|
|
1103
|
+
toPath: string;
|
|
1104
|
+
}
|
|
1105
|
+
export declare const cp: StepHandler<CpStep>;
|
|
1106
|
+
export interface MvStep {
|
|
1107
|
+
step: "mv";
|
|
1108
|
+
fromPath: string;
|
|
1109
|
+
toPath: string;
|
|
1110
|
+
}
|
|
1111
|
+
export declare const mv: StepHandler<MvStep>;
|
|
1112
|
+
export interface MkdirStep {
|
|
1113
|
+
step: "mkdir";
|
|
1114
|
+
path: string;
|
|
1115
|
+
}
|
|
1116
|
+
export declare const mkdir: StepHandler<MkdirStep>;
|
|
1117
|
+
export interface RmStep {
|
|
1118
|
+
step: "rm";
|
|
1119
|
+
path: string;
|
|
1120
|
+
}
|
|
1121
|
+
export declare const rm: StepHandler<RmStep>;
|
|
1122
|
+
export interface RmdirStep {
|
|
1123
|
+
step: "rmdir";
|
|
1124
|
+
path: string;
|
|
1125
|
+
}
|
|
1126
|
+
export declare const rmdir: StepHandler<RmdirStep>;
|
|
1127
|
+
export interface WriteFileStep<ResourceType> {
|
|
1128
|
+
step: "writeFile";
|
|
1129
|
+
path: string;
|
|
1130
|
+
data: ResourceType | string | Uint8Array;
|
|
1131
|
+
}
|
|
1132
|
+
export declare const writeFile: StepHandler<WriteFileStep<File>>;
|
|
1133
|
+
export type Step = GenericStep<FileReference>;
|
|
1134
|
+
export type StepDefinition = Step & {
|
|
1135
|
+
progress?: {
|
|
1136
|
+
weight?: number;
|
|
1137
|
+
caption?: string;
|
|
1138
|
+
};
|
|
1139
|
+
};
|
|
1140
|
+
export type GenericStep<Resource> = ActivatePluginStep | ApplyWordPressPatchesStep | CpStep | DefineSiteUrlStep | ImportFileStep<Resource> | InstallPluginStep<Resource> | InstallThemeStep<Resource> | LoginStep | MkdirStep | MvStep | RequestStep | ReplaceSiteStep<Resource> | RmStep | RmdirStep | RunPHPStep | RunPHPWithOptionsStep | RunWpInstallationWizardStep | SetPhpIniEntryStep | SetSiteOptionsStep | UnzipStep | UpdateUserMetaStep | WriteFileStep<Resource>;
|
|
1141
|
+
export type StepHandler<S extends GenericStep<File>> = (php: UniversalPHP, args: Omit<S, "step">, progressArgs?: {
|
|
1142
|
+
tracker: ProgressTracker;
|
|
1143
|
+
initialCaption?: string;
|
|
1144
|
+
}) => any;
|
|
1145
|
+
export interface Blueprint {
|
|
1146
|
+
/**
|
|
1147
|
+
* The URL to navigate to after the blueprint has been run.
|
|
1148
|
+
*/
|
|
1149
|
+
landingPage?: string;
|
|
1150
|
+
/**
|
|
1151
|
+
* The preferred PHP and WordPress versions to use.
|
|
1152
|
+
*/
|
|
1153
|
+
preferredVersions?: {
|
|
1154
|
+
/**
|
|
1155
|
+
* The preferred PHP version to use.
|
|
1156
|
+
* If not specified, the latest supported version will be used
|
|
1157
|
+
*/
|
|
1158
|
+
php: SupportedPHPVersion | "latest";
|
|
1159
|
+
/**
|
|
1160
|
+
* The preferred WordPress version to use.
|
|
1161
|
+
* If not specified, the latest supported version will be used
|
|
1162
|
+
*/
|
|
1163
|
+
wp: string | "latest";
|
|
1164
|
+
};
|
|
1165
|
+
/**
|
|
1166
|
+
* The steps to run.
|
|
1167
|
+
*/
|
|
1168
|
+
steps?: Array<StepDefinition | string | undefined | false | null>;
|
|
1169
|
+
}
|
|
1170
|
+
export type CompiledStep = (php: UniversalPHP) => Promise<void> | void;
|
|
1171
|
+
declare const supportedWordPressVersions: readonly [
|
|
1172
|
+
"6.2",
|
|
1173
|
+
"6.1",
|
|
1174
|
+
"6.0",
|
|
1175
|
+
"5.9"
|
|
1176
|
+
];
|
|
1177
|
+
export type supportedWordPressVersion = (typeof supportedWordPressVersions)[number];
|
|
1178
|
+
export interface CompiledBlueprint {
|
|
1179
|
+
/** The requested versions of PHP and WordPress for the blueprint */
|
|
1180
|
+
versions: {
|
|
1181
|
+
php: SupportedPHPVersion;
|
|
1182
|
+
wp: supportedWordPressVersion;
|
|
1183
|
+
};
|
|
1184
|
+
/** The compiled steps for the blueprint */
|
|
1185
|
+
run: (playground: UniversalPHP) => Promise<void>;
|
|
1186
|
+
}
|
|
1187
|
+
export type OnStepCompleted = (output: any, step: StepDefinition) => any;
|
|
1188
|
+
export interface CompileBlueprintOptions {
|
|
1189
|
+
/** Optional progress tracker to monitor progress */
|
|
1190
|
+
progress?: ProgressTracker;
|
|
1191
|
+
/** Optional semaphore to control access to a shared resource */
|
|
1192
|
+
semaphore?: Semaphore;
|
|
1193
|
+
/** Optional callback with step output */
|
|
1194
|
+
onStepCompleted?: OnStepCompleted;
|
|
1195
|
+
}
|
|
1196
|
+
/**
|
|
1197
|
+
* Compiles Blueprint into a form that can be executed.
|
|
1198
|
+
*
|
|
1199
|
+
* @param playground The PlaygroundClient to use for the compilation
|
|
1200
|
+
* @param blueprint The bBueprint to compile
|
|
1201
|
+
* @param options Additional options for the compilation
|
|
1202
|
+
* @returns The compiled blueprint
|
|
1203
|
+
*/
|
|
1204
|
+
export declare function compileBlueprint(blueprint: Blueprint, { progress, semaphore, onStepCompleted, }?: CompileBlueprintOptions): CompiledBlueprint;
|
|
1205
|
+
export declare function runBlueprintSteps(compiledBlueprint: CompiledBlueprint, playground: UniversalPHP): Promise<void>;
|
|
1206
|
+
export type WithIsReady = {
|
|
1207
|
+
/** Resolves to true when the remote API is ready to be used */
|
|
1208
|
+
isReady: () => Promise<void>;
|
|
1209
|
+
};
|
|
1210
|
+
export type RemoteAPI<T> = Comlink.Remote<T & WithIsReady>;
|
|
496
1211
|
export interface PHPWebLoaderOptions {
|
|
497
1212
|
emscriptenOptions?: EmscriptenOptions;
|
|
498
1213
|
downloadMonitor?: EmscriptenDownloadMonitor;
|
|
499
1214
|
requestHandler?: PHPRequestHandlerConfiguration;
|
|
500
1215
|
dataModules?: Array<DataModule | Promise<DataModule>>;
|
|
501
1216
|
}
|
|
502
|
-
declare class
|
|
1217
|
+
declare class WebPHP extends BasePHP {
|
|
503
1218
|
/**
|
|
504
1219
|
* Creates a new PHP instance.
|
|
505
1220
|
*
|
|
@@ -512,7 +1227,7 @@ declare class PHP extends BasePHP {
|
|
|
512
1227
|
* @param options The options to use when loading PHP
|
|
513
1228
|
* @returns A new PHP instance
|
|
514
1229
|
*/
|
|
515
|
-
static load(phpVersion: SupportedPHPVersion, options?: PHPWebLoaderOptions): Promise<
|
|
1230
|
+
static load(phpVersion: SupportedPHPVersion, options?: PHPWebLoaderOptions): Promise<WebPHP>;
|
|
516
1231
|
/**
|
|
517
1232
|
* Does what load() does, but synchronously returns
|
|
518
1233
|
* an object with the PHP instance and a promise that
|
|
@@ -521,180 +1236,116 @@ declare class PHP extends BasePHP {
|
|
|
521
1236
|
* @see load
|
|
522
1237
|
*/
|
|
523
1238
|
static loadSync(phpVersion: SupportedPHPVersion, options?: PHPWebLoaderOptions): {
|
|
524
|
-
php:
|
|
525
|
-
phpReady: Promise<
|
|
1239
|
+
php: WebPHP;
|
|
1240
|
+
phpReady: Promise<WebPHP>;
|
|
526
1241
|
dataModules: Promise<DataModule[]>;
|
|
527
1242
|
};
|
|
528
1243
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
}
|
|
540
|
-
declare class PHPClient implements Promisify<WithPHPIniBindings & WithFilesystem & WithRun & WithRequestHandler & WithProgress & WithPathConversion> {
|
|
541
|
-
/** @inheritDoc @php-wasm/web!PHPRequestHandler.absoluteUrl */
|
|
542
|
-
absoluteUrl: Promise<string>;
|
|
543
|
-
/** @inheritDoc @php-wasm/web!PHPRequestHandler.documentRoot */
|
|
544
|
-
documentRoot: Promise<string>;
|
|
1244
|
+
declare class WebPHPEndpoint implements IsomorphicLocalPHP {
|
|
1245
|
+
/**
|
|
1246
|
+
* A dummy promise that resolves immediately.
|
|
1247
|
+
* Used to assert that the PHPClient is ready for communication.
|
|
1248
|
+
*/
|
|
1249
|
+
connected: Promise<void>;
|
|
1250
|
+
/** @inheritDoc */
|
|
1251
|
+
absoluteUrl: string;
|
|
1252
|
+
/** @inheritDoc */
|
|
1253
|
+
documentRoot: string;
|
|
545
1254
|
/** @inheritDoc */
|
|
546
1255
|
constructor(php: BasePHP, monitor?: EmscriptenDownloadMonitor);
|
|
547
|
-
/** @inheritDoc
|
|
548
|
-
pathToInternalUrl(path: string):
|
|
549
|
-
/** @inheritDoc
|
|
550
|
-
internalUrlToPath(internalUrl: string):
|
|
1256
|
+
/** @inheritDoc */
|
|
1257
|
+
pathToInternalUrl(path: string): string;
|
|
1258
|
+
/** @inheritDoc */
|
|
1259
|
+
internalUrlToPath(internalUrl: string): string;
|
|
551
1260
|
onDownloadProgress(callback: (progress: CustomEvent<ProgressEvent>) => void): Promise<void>;
|
|
552
|
-
/** @inheritDoc
|
|
1261
|
+
/** @inheritDoc */
|
|
1262
|
+
mv(fromPath: string, toPath: string): void;
|
|
1263
|
+
/** @inheritDoc */
|
|
1264
|
+
rmdir(path: string, options?: RmDirOptions): void;
|
|
1265
|
+
/** @inheritDoc @php-wasm/universal!RequestHandler.request */
|
|
553
1266
|
request(request: PHPRequest, redirects?: number): Promise<PHPResponse>;
|
|
554
|
-
/** @inheritDoc @php-wasm/web!
|
|
555
|
-
run(request
|
|
556
|
-
/** @inheritDoc @php-wasm/web!
|
|
1267
|
+
/** @inheritDoc @php-wasm/web!WebPHP.run */
|
|
1268
|
+
run(request: PHPRunOptions): Promise<PHPResponse>;
|
|
1269
|
+
/** @inheritDoc @php-wasm/web!WebPHP.chdir */
|
|
557
1270
|
chdir(path: string): void;
|
|
558
|
-
/** @inheritDoc @php-wasm/web!
|
|
1271
|
+
/** @inheritDoc @php-wasm/web!WebPHP.setPhpIniPath */
|
|
559
1272
|
setPhpIniPath(path: string): void;
|
|
560
|
-
/** @inheritDoc @php-wasm/web!
|
|
1273
|
+
/** @inheritDoc @php-wasm/web!WebPHP.setPhpIniEntry */
|
|
561
1274
|
setPhpIniEntry(key: string, value: string): void;
|
|
562
|
-
/** @inheritDoc @php-wasm/web!
|
|
1275
|
+
/** @inheritDoc @php-wasm/web!WebPHP.mkdir */
|
|
563
1276
|
mkdir(path: string): void;
|
|
564
|
-
/** @inheritDoc @php-wasm/web!
|
|
1277
|
+
/** @inheritDoc @php-wasm/web!WebPHP.mkdirTree */
|
|
565
1278
|
mkdirTree(path: string): void;
|
|
566
|
-
/** @inheritDoc @php-wasm/web!
|
|
567
|
-
readFileAsText(path: string):
|
|
568
|
-
/** @inheritDoc @php-wasm/web!
|
|
569
|
-
readFileAsBuffer(path: string):
|
|
570
|
-
/** @inheritDoc @php-wasm/web!
|
|
1279
|
+
/** @inheritDoc @php-wasm/web!WebPHP.readFileAsText */
|
|
1280
|
+
readFileAsText(path: string): string;
|
|
1281
|
+
/** @inheritDoc @php-wasm/web!WebPHP.readFileAsBuffer */
|
|
1282
|
+
readFileAsBuffer(path: string): Uint8Array;
|
|
1283
|
+
/** @inheritDoc @php-wasm/web!WebPHP.writeFile */
|
|
571
1284
|
writeFile(path: string, data: string | Uint8Array): void;
|
|
572
|
-
/** @inheritDoc @php-wasm/web!
|
|
1285
|
+
/** @inheritDoc @php-wasm/web!WebPHP.unlink */
|
|
573
1286
|
unlink(path: string): void;
|
|
574
|
-
/** @inheritDoc @php-wasm/web!
|
|
575
|
-
listFiles(path: string):
|
|
576
|
-
/** @inheritDoc @php-wasm/web!
|
|
577
|
-
isDir(path: string):
|
|
578
|
-
/** @inheritDoc @php-wasm/web!
|
|
579
|
-
fileExists(path: string):
|
|
580
|
-
}
|
|
581
|
-
declare class
|
|
582
|
-
scope:
|
|
583
|
-
wordPressVersion:
|
|
584
|
-
phpVersion:
|
|
585
|
-
constructor(php:
|
|
1287
|
+
/** @inheritDoc @php-wasm/web!WebPHP.listFiles */
|
|
1288
|
+
listFiles(path: string): string[];
|
|
1289
|
+
/** @inheritDoc @php-wasm/web!WebPHP.isDir */
|
|
1290
|
+
isDir(path: string): boolean;
|
|
1291
|
+
/** @inheritDoc @php-wasm/web!WebPHP.fileExists */
|
|
1292
|
+
fileExists(path: string): boolean;
|
|
1293
|
+
}
|
|
1294
|
+
declare class PlaygroundWorkerEndpoint extends WebPHPEndpoint {
|
|
1295
|
+
scope: string;
|
|
1296
|
+
wordPressVersion: string;
|
|
1297
|
+
phpVersion: string;
|
|
1298
|
+
constructor(php: WebPHP, monitor: EmscriptenDownloadMonitor, scope: string, wordPressVersion: string, phpVersion: string);
|
|
586
1299
|
getWordPressModuleDetails(): Promise<{
|
|
587
1300
|
staticAssetsDirectory: string;
|
|
588
1301
|
defaultTheme: any;
|
|
589
1302
|
}>;
|
|
590
1303
|
}
|
|
591
|
-
|
|
592
|
-
|
|
1304
|
+
export interface ProgressBarOptions {
|
|
1305
|
+
caption?: string;
|
|
1306
|
+
progress?: number;
|
|
1307
|
+
isIndefinite?: boolean;
|
|
1308
|
+
visible?: boolean;
|
|
593
1309
|
}
|
|
594
|
-
export interface WebClientMixin {
|
|
1310
|
+
export interface WebClientMixin extends ProgressReceiver {
|
|
1311
|
+
setProgress(options: ProgressBarOptions): Promise<void>;
|
|
1312
|
+
setLoaded(): Promise<void>;
|
|
595
1313
|
onNavigation(fn: (url: string) => void): Promise<void>;
|
|
596
1314
|
goTo(requestedPath: string): Promise<void>;
|
|
597
1315
|
getCurrentURL(): Promise<string>;
|
|
598
1316
|
setIframeSandboxFlags(flags: string[]): Promise<void>;
|
|
599
|
-
onDownloadProgress:
|
|
1317
|
+
onDownloadProgress: PlaygroundWorkerEndpoint["onDownloadProgress"];
|
|
600
1318
|
}
|
|
601
1319
|
/**
|
|
602
1320
|
* @inheritDoc
|
|
603
1321
|
*/
|
|
604
|
-
export
|
|
1322
|
+
export type PlaygroundClient = RemoteAPI<PlaygroundWorkerEndpoint & WebClientMixin>;
|
|
1323
|
+
export interface StartPlaygroundOptions {
|
|
1324
|
+
iframe: HTMLIFrameElement;
|
|
1325
|
+
remoteUrl: string;
|
|
1326
|
+
progressTracker?: ProgressTracker;
|
|
1327
|
+
disableProgressBar?: boolean;
|
|
1328
|
+
blueprint?: Blueprint;
|
|
1329
|
+
onBlueprintStepCompleted?: OnStepCompleted;
|
|
605
1330
|
}
|
|
606
|
-
export declare function exportFile(playground: PlaygroundClient): Promise<void>;
|
|
607
|
-
export declare function importFile(playground: PlaygroundClient, file: File): Promise<boolean>;
|
|
608
1331
|
/**
|
|
609
|
-
*
|
|
610
|
-
* Under the hood, this function submits the wp-login.php form
|
|
611
|
-
* just like a user would.
|
|
612
|
-
*
|
|
613
|
-
* @param playground The playground client.
|
|
614
|
-
* @param user The user to log in as. Defaults to 'admin'.
|
|
615
|
-
* @param password The password to log in with. Defaults to 'password'.
|
|
616
|
-
*/
|
|
617
|
-
export declare function login(playground: PlaygroundClient, user?: string, password?: string): Promise<void>;
|
|
618
|
-
export interface InstallThemeOptions {
|
|
619
|
-
/**
|
|
620
|
-
* Whether to activate the theme after installing it.
|
|
621
|
-
*/
|
|
622
|
-
activate?: boolean;
|
|
623
|
-
}
|
|
624
|
-
/**
|
|
625
|
-
* Installs a WordPress theme in the Playground.
|
|
626
|
-
* Technically, it uses the same theme upload form as a WordPress user
|
|
627
|
-
* would, and then activates the theme if needed.
|
|
628
|
-
*
|
|
629
|
-
* @param playground The playground client.
|
|
630
|
-
* @param themeZipFile The theme zip file.
|
|
631
|
-
* @param options Optional. Set `activate` to false if you don't want to activate the theme.
|
|
632
|
-
*/
|
|
633
|
-
export declare function installTheme(playground: PlaygroundClient, themeZipFile: File, options?: InstallThemeOptions): Promise<void>;
|
|
634
|
-
export interface InstallPluginOptions {
|
|
635
|
-
/**
|
|
636
|
-
* Whether to activate the plugin after installing it.
|
|
637
|
-
*/
|
|
638
|
-
activate?: boolean;
|
|
639
|
-
}
|
|
640
|
-
/**
|
|
641
|
-
* Installs a WordPress plugin in the Playground.
|
|
642
|
-
* Technically, it uses the same plugin upload form as a WordPress user
|
|
643
|
-
* would, and then activates the plugin if needed.
|
|
644
|
-
*
|
|
645
|
-
* @param playground The playground client.
|
|
646
|
-
* @param pluginZipFile The plugin zip file.
|
|
647
|
-
* @param options Optional. Set `activate` to false if you don't want to activate the plugin.
|
|
648
|
-
*/
|
|
649
|
-
export declare function installPlugin(playground: PlaygroundClient, pluginZipFile: File, options?: InstallPluginOptions): Promise<void>;
|
|
650
|
-
/**
|
|
651
|
-
* Activates a WordPress plugin in the Playground.
|
|
652
|
-
*
|
|
653
|
-
* @param playground The playground client.
|
|
654
|
-
* @param plugin The plugin slug.
|
|
655
|
-
*/
|
|
656
|
-
export declare function activatePlugin(playground: PlaygroundClient, plugin: string): Promise<void>;
|
|
657
|
-
/**
|
|
658
|
-
* Downloads and installs a theme from the WordPress.org theme directory.
|
|
659
|
-
* Under the hood, it downloads the themes through a proxy endpoint
|
|
660
|
-
* and installs then one after another using the installTheme function.
|
|
1332
|
+
* Loads playground in iframe and returns a PlaygroundClient instance.
|
|
661
1333
|
*
|
|
662
|
-
* @
|
|
663
|
-
* @param
|
|
664
|
-
* @
|
|
665
|
-
* to "twentytwentythree.1.1.zip" to download the Twenty Twenty Three theme
|
|
666
|
-
* from https://downloads.wordpress.org/theme/twentytwentythree.1.1.zip.
|
|
667
|
-
*
|
|
668
|
-
* @param maxProgress Optional. The maximum progress value to use. Defaults to 100.
|
|
669
|
-
* @param progress Optional. The progress observer that will be notified of the progress.
|
|
1334
|
+
* @param iframe Any iframe with Playground's remote.html loaded.
|
|
1335
|
+
* @param options Options for loading the playground.
|
|
1336
|
+
* @returns A PlaygroundClient instance.
|
|
670
1337
|
*/
|
|
671
|
-
export declare function
|
|
1338
|
+
export declare function startPlaygroundWeb({ iframe, blueprint, remoteUrl, progressTracker, disableProgressBar, onBlueprintStepCompleted, }: StartPlaygroundOptions): Promise<PlaygroundClient>;
|
|
672
1339
|
/**
|
|
673
|
-
*
|
|
674
|
-
* Under the hood, it downloads the plugins through a proxy endpoint
|
|
675
|
-
* and installs then one after another using the installPlugin function.
|
|
676
|
-
*
|
|
677
|
-
* @see installPlugin
|
|
678
|
-
* @param playground The playground client.
|
|
679
|
-
* @param pluginsZipNames The plugin zip file names. For example, set this parameter
|
|
680
|
-
* to ["gutenberg.15.5.0.zip"] to download the Gutenberg plugin
|
|
681
|
-
* from https://downloads.wordpress.org/plugin/gutenberg.15.5.0.zip.
|
|
682
|
-
* @param maxProgress Optional. The maximum progress value to use. Defaults to 100.
|
|
683
|
-
* @param progress Optional. The progress observer that will be notified of the progress.
|
|
684
|
-
*/
|
|
685
|
-
export declare function installPluginsFromDirectory(playground: PlaygroundClient, pluginsZipNames: string[], maxProgress?: number, progress?: ProgressObserver): Promise<void>;
|
|
686
|
-
export interface ConnectPlaygroundOptions {
|
|
687
|
-
loadRemote?: string;
|
|
688
|
-
}
|
|
689
|
-
/**
|
|
690
|
-
* Connects to a playground iframe and returns a PlaygroundClient instance.
|
|
1340
|
+
* @deprecated Use `startPlayground` instead.
|
|
691
1341
|
*
|
|
692
1342
|
* @param iframe Any iframe with Playground's remote.html loaded.
|
|
693
1343
|
* @param options Optional. If `loadRemote` is set, the iframe's `src` will be set to that URL.
|
|
694
1344
|
* In other words, use this option if your iframe doesn't have remote.html already
|
|
695
1345
|
* loaded.
|
|
696
|
-
* @returns A PlaygroundClient instance.
|
|
697
1346
|
*/
|
|
698
|
-
export declare function connectPlayground(iframe: HTMLIFrameElement, options?:
|
|
1347
|
+
export declare function connectPlayground(iframe: HTMLIFrameElement, options?: {
|
|
1348
|
+
loadRemote?: string;
|
|
1349
|
+
}): Promise<PlaygroundClient>;
|
|
699
1350
|
|
|
700
1351
|
export {};
|