@php-wasm/universal 1.2.1 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +55 -18
- package/index.cjs.map +1 -1
- package/index.js +1369 -658
- package/index.js.map +1 -1
- package/lib/api.d.ts +4 -3
- package/lib/comlink-sync.d.ts +297 -0
- package/lib/error-reporting.d.ts +12 -0
- package/lib/index.d.ts +2 -0
- package/lib/is-exit-code.d.ts +1 -1
- package/lib/php.d.ts +8 -0
- package/lib/rethrow-file-system-error.d.ts +2 -2
- package/lib/sandboxed-spawn-handler-factory.d.ts +12 -0
- package/lib/serialize-error.d.ts +17 -0
- package/lib/universal-php.d.ts +7 -4
- package/package.json +7 -8
package/index.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
var
|
|
2
|
-
throw TypeError(
|
|
1
|
+
var q = (t) => {
|
|
2
|
+
throw TypeError(t);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var N = (t, e, r) => e.has(t) || q("Cannot " + r);
|
|
5
|
+
var u = (t, e, r) => (N(t, e, "read from private field"), r ? r.call(t) : e.get(t)), _ = (t, e, r) => e.has(t) ? q("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), f = (t, e, r, s) => (N(t, e, "write to private field"), s ? s.call(t, r) : e.set(t, r), r), m = (t, e, r) => (N(t, e, "access private method"), r);
|
|
6
6
|
import "@php-wasm/node-polyfills";
|
|
7
7
|
import { logger } from "@php-wasm/logger";
|
|
8
8
|
import { dirname, joinPaths, Semaphore, createSpawnHandler, normalizePath, AcquireTimeoutError } from "@php-wasm/util";
|
|
9
9
|
import { parse, stringify } from "ini";
|
|
10
10
|
import { StreamedFile } from "@php-wasm/stream-compression";
|
|
11
|
-
|
|
11
|
+
class ErrnoError extends Error {
|
|
12
|
+
constructor(e, r, s) {
|
|
13
|
+
super(r, s), this.name = "ErrnoError", this.errno = e;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
12
16
|
const FileErrorCodes = {
|
|
13
17
|
0: "No error occurred. System call completed successfully.",
|
|
14
18
|
1: "Argument list too long.",
|
|
@@ -88,25 +92,29 @@ const FileErrorCodes = {
|
|
|
88
92
|
75: "Cross-device link.",
|
|
89
93
|
76: "Extension: Capabilities insufficient."
|
|
90
94
|
};
|
|
91
|
-
function getEmscriptenFsError(
|
|
92
|
-
const e = typeof
|
|
95
|
+
function getEmscriptenFsError(t) {
|
|
96
|
+
const e = typeof t == "object" ? t == null ? void 0 : t.errno : null;
|
|
93
97
|
if (e in FileErrorCodes)
|
|
94
98
|
return FileErrorCodes[e];
|
|
95
99
|
}
|
|
96
|
-
function rethrowFileSystemError(
|
|
97
|
-
return function(
|
|
100
|
+
function rethrowFileSystemError(t = "") {
|
|
101
|
+
return function(r) {
|
|
98
102
|
return function(...s) {
|
|
99
103
|
try {
|
|
100
|
-
return
|
|
101
|
-
} catch (
|
|
102
|
-
const
|
|
103
|
-
if (
|
|
104
|
-
const o = FileErrorCodes[
|
|
105
|
-
throw new
|
|
106
|
-
|
|
107
|
-
|
|
104
|
+
return r.apply(this, s);
|
|
105
|
+
} catch (n) {
|
|
106
|
+
const i = typeof n == "object" ? n == null ? void 0 : n.errno : null;
|
|
107
|
+
if (i in FileErrorCodes) {
|
|
108
|
+
const o = FileErrorCodes[i], a = typeof s[1] == "string" ? s[1] : null, l = a !== null ? t.replaceAll("{path}", a) : t;
|
|
109
|
+
throw new ErrnoError(
|
|
110
|
+
i,
|
|
111
|
+
`${l}: ${o}`,
|
|
112
|
+
{
|
|
113
|
+
cause: n
|
|
114
|
+
}
|
|
115
|
+
);
|
|
108
116
|
}
|
|
109
|
-
throw
|
|
117
|
+
throw n;
|
|
110
118
|
}
|
|
111
119
|
};
|
|
112
120
|
};
|
|
@@ -120,8 +128,8 @@ class FSHelpers {
|
|
|
120
128
|
* @param path - The file path to read.
|
|
121
129
|
* @returns The file contents.
|
|
122
130
|
*/
|
|
123
|
-
static readFileAsText(e,
|
|
124
|
-
return new TextDecoder().decode(FSHelpers.readFileAsBuffer(e,
|
|
131
|
+
static readFileAsText(e, r) {
|
|
132
|
+
return new TextDecoder().decode(FSHelpers.readFileAsBuffer(e, r));
|
|
125
133
|
}
|
|
126
134
|
/**
|
|
127
135
|
* Reads a file from the PHP filesystem and returns it as an array buffer.
|
|
@@ -131,8 +139,8 @@ class FSHelpers {
|
|
|
131
139
|
* @param path - The file path to read.
|
|
132
140
|
* @returns The file contents.
|
|
133
141
|
*/
|
|
134
|
-
static readFileAsBuffer(e,
|
|
135
|
-
return e.readFile(
|
|
142
|
+
static readFileAsBuffer(e, r) {
|
|
143
|
+
return e.readFile(r);
|
|
136
144
|
}
|
|
137
145
|
/**
|
|
138
146
|
* Overwrites data in a file in the PHP filesystem.
|
|
@@ -142,8 +150,8 @@ class FSHelpers {
|
|
|
142
150
|
* @param path - The file path to write to.
|
|
143
151
|
* @param data - The data to write to the file.
|
|
144
152
|
*/
|
|
145
|
-
static writeFile(e,
|
|
146
|
-
e.writeFile(
|
|
153
|
+
static writeFile(e, r, s) {
|
|
154
|
+
e.writeFile(r, s);
|
|
147
155
|
}
|
|
148
156
|
/**
|
|
149
157
|
* Removes a file from the PHP filesystem.
|
|
@@ -152,8 +160,8 @@ class FSHelpers {
|
|
|
152
160
|
* @param FS
|
|
153
161
|
* @param path - The file path to remove.
|
|
154
162
|
*/
|
|
155
|
-
static unlink(e,
|
|
156
|
-
e.unlink(
|
|
163
|
+
static unlink(e, r) {
|
|
164
|
+
e.unlink(r);
|
|
157
165
|
}
|
|
158
166
|
/**
|
|
159
167
|
* Moves a file or directory in the PHP filesystem to a
|
|
@@ -163,18 +171,18 @@ class FSHelpers {
|
|
|
163
171
|
* @param fromPath The path to rename.
|
|
164
172
|
* @param toPath The new path.
|
|
165
173
|
*/
|
|
166
|
-
static mv(e,
|
|
174
|
+
static mv(e, r, s) {
|
|
167
175
|
try {
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
} catch (
|
|
171
|
-
const
|
|
172
|
-
throw
|
|
173
|
-
`Could not move ${
|
|
176
|
+
const n = e.lookupPath(r).node.mount, i = FSHelpers.fileExists(e, s) ? e.lookupPath(s).node.mount : e.lookupPath(dirname(s)).node.mount;
|
|
177
|
+
n.mountpoint !== i.mountpoint ? (FSHelpers.copyRecursive(e, r, s), FSHelpers.isDir(e, r) ? FSHelpers.rmdir(e, r, { recursive: !0 }) : e.unlink(r)) : e.rename(r, s);
|
|
178
|
+
} catch (n) {
|
|
179
|
+
const i = getEmscriptenFsError(n);
|
|
180
|
+
throw i ? new Error(
|
|
181
|
+
`Could not move ${r} to ${s}: ${i}`,
|
|
174
182
|
{
|
|
175
|
-
cause:
|
|
183
|
+
cause: n
|
|
176
184
|
}
|
|
177
|
-
) :
|
|
185
|
+
) : n;
|
|
178
186
|
}
|
|
179
187
|
}
|
|
180
188
|
/**
|
|
@@ -184,11 +192,14 @@ class FSHelpers {
|
|
|
184
192
|
* @param path The directory path to remove.
|
|
185
193
|
* @param options Options for the removal.
|
|
186
194
|
*/
|
|
187
|
-
static rmdir(e,
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
195
|
+
static rmdir(e, r, s = { recursive: !0 }) {
|
|
196
|
+
const n = e.lookupPath(r, { follow: !1 });
|
|
197
|
+
if ((n == null ? void 0 : n.node.mount.mountpoint) === r)
|
|
198
|
+
throw new ErrnoError(10);
|
|
199
|
+
s != null && s.recursive && FSHelpers.listFiles(e, r).forEach((i) => {
|
|
200
|
+
const o = `${r}/${i}`;
|
|
201
|
+
FSHelpers.isDir(e, o) ? FSHelpers.rmdir(e, o, s) : FSHelpers.unlink(e, o);
|
|
202
|
+
}), e.getPath(e.lookupPath(r).node) === e.cwd() && e.chdir(joinPaths(e.cwd(), "..")), e.rmdir(r);
|
|
192
203
|
}
|
|
193
204
|
/**
|
|
194
205
|
* Lists the files and directories in the given directory.
|
|
@@ -198,20 +209,20 @@ class FSHelpers {
|
|
|
198
209
|
* @param options - Options for the listing.
|
|
199
210
|
* @returns The list of files and directories in the given directory.
|
|
200
211
|
*/
|
|
201
|
-
static listFiles(e,
|
|
202
|
-
if (!FSHelpers.fileExists(e,
|
|
212
|
+
static listFiles(e, r, s = { prependPath: !1 }) {
|
|
213
|
+
if (!FSHelpers.fileExists(e, r))
|
|
203
214
|
return [];
|
|
204
215
|
try {
|
|
205
|
-
const
|
|
206
|
-
(
|
|
216
|
+
const n = e.readdir(r).filter(
|
|
217
|
+
(i) => i !== "." && i !== ".."
|
|
207
218
|
);
|
|
208
219
|
if (s.prependPath) {
|
|
209
|
-
const
|
|
210
|
-
return
|
|
220
|
+
const i = r.replace(/\/$/, "");
|
|
221
|
+
return n.map((o) => `${i}/${o}`);
|
|
211
222
|
}
|
|
212
|
-
return
|
|
213
|
-
} catch (
|
|
214
|
-
return logger.error(
|
|
223
|
+
return n;
|
|
224
|
+
} catch (n) {
|
|
225
|
+
return logger.error(n, { path: r }), [];
|
|
215
226
|
}
|
|
216
227
|
}
|
|
217
228
|
/**
|
|
@@ -221,8 +232,8 @@ class FSHelpers {
|
|
|
221
232
|
* @param path – The path to check.
|
|
222
233
|
* @returns True if the path is a directory, false otherwise.
|
|
223
234
|
*/
|
|
224
|
-
static isDir(e,
|
|
225
|
-
return FSHelpers.fileExists(e,
|
|
235
|
+
static isDir(e, r) {
|
|
236
|
+
return FSHelpers.fileExists(e, r) ? e.isDir(e.lookupPath(r, { follow: !0 }).node.mode) : !1;
|
|
226
237
|
}
|
|
227
238
|
/**
|
|
228
239
|
* Checks if a file exists in the PHP filesystem.
|
|
@@ -231,8 +242,8 @@ class FSHelpers {
|
|
|
231
242
|
* @param path – The path to check.
|
|
232
243
|
* @returns True if the path is a file, false otherwise.
|
|
233
244
|
*/
|
|
234
|
-
static isFile(e,
|
|
235
|
-
return FSHelpers.fileExists(e,
|
|
245
|
+
static isFile(e, r) {
|
|
246
|
+
return FSHelpers.fileExists(e, r) ? e.isFile(e.lookupPath(r, { follow: !0 }).node.mode) : !1;
|
|
236
247
|
}
|
|
237
248
|
/**
|
|
238
249
|
* Creates a symlink in the PHP filesystem.
|
|
@@ -241,8 +252,8 @@ class FSHelpers {
|
|
|
241
252
|
* @param target
|
|
242
253
|
* @param link
|
|
243
254
|
*/
|
|
244
|
-
static symlink(e,
|
|
245
|
-
return e.symlink(
|
|
255
|
+
static symlink(e, r, s) {
|
|
256
|
+
return e.symlink(r, s);
|
|
246
257
|
}
|
|
247
258
|
/**
|
|
248
259
|
* Checks if a path is a symlink in the PHP filesystem.
|
|
@@ -251,8 +262,8 @@ class FSHelpers {
|
|
|
251
262
|
* @param path
|
|
252
263
|
* @returns True if the path is a symlink, false otherwise.
|
|
253
264
|
*/
|
|
254
|
-
static isSymlink(e,
|
|
255
|
-
return FSHelpers.fileExists(e,
|
|
265
|
+
static isSymlink(e, r) {
|
|
266
|
+
return FSHelpers.fileExists(e, r) ? e.isLink(e.lookupPath(r).node.mode) : !1;
|
|
256
267
|
}
|
|
257
268
|
/**
|
|
258
269
|
* Reads the target of a symlink in the PHP filesystem.
|
|
@@ -261,8 +272,8 @@ class FSHelpers {
|
|
|
261
272
|
* @returns The target of the symlink.
|
|
262
273
|
* @throws {@link @php-wasm/universal:ErrnoError} – If the path is not a symlink.
|
|
263
274
|
*/
|
|
264
|
-
static readlink(e,
|
|
265
|
-
return e.readlink(
|
|
275
|
+
static readlink(e, r) {
|
|
276
|
+
return e.readlink(r);
|
|
266
277
|
}
|
|
267
278
|
/**
|
|
268
279
|
* Gets the real path of a file in the PHP filesystem.
|
|
@@ -271,8 +282,8 @@ class FSHelpers {
|
|
|
271
282
|
*
|
|
272
283
|
* @returns The real path of the file.
|
|
273
284
|
*/
|
|
274
|
-
static realpath(e,
|
|
275
|
-
return e.lookupPath(
|
|
285
|
+
static realpath(e, r) {
|
|
286
|
+
return e.lookupPath(r, { follow: !0 }).path;
|
|
276
287
|
}
|
|
277
288
|
/**
|
|
278
289
|
* Checks if a file (or a directory) exists in the PHP filesystem.
|
|
@@ -281,9 +292,9 @@ class FSHelpers {
|
|
|
281
292
|
* @param path - The file path to check.
|
|
282
293
|
* @returns True if the file exists, false otherwise.
|
|
283
294
|
*/
|
|
284
|
-
static fileExists(e,
|
|
295
|
+
static fileExists(e, r) {
|
|
285
296
|
try {
|
|
286
|
-
return e.lookupPath(
|
|
297
|
+
return e.lookupPath(r), !0;
|
|
287
298
|
} catch {
|
|
288
299
|
return !1;
|
|
289
300
|
}
|
|
@@ -296,24 +307,23 @@ class FSHelpers {
|
|
|
296
307
|
* @param FS
|
|
297
308
|
* @param path - The directory path to create.
|
|
298
309
|
*/
|
|
299
|
-
static mkdir(e,
|
|
300
|
-
e.mkdirTree(
|
|
310
|
+
static mkdir(e, r) {
|
|
311
|
+
e.mkdirTree(r);
|
|
301
312
|
}
|
|
302
|
-
static copyRecursive(e,
|
|
303
|
-
const
|
|
304
|
-
if (e.isDir(
|
|
313
|
+
static copyRecursive(e, r, s) {
|
|
314
|
+
const n = e.lookupPath(r).node;
|
|
315
|
+
if (e.isDir(n.mode)) {
|
|
305
316
|
e.mkdirTree(s);
|
|
306
|
-
const
|
|
317
|
+
const i = e.readdir(r).filter(
|
|
307
318
|
(o) => o !== "." && o !== ".."
|
|
308
319
|
);
|
|
309
|
-
for (const o of
|
|
320
|
+
for (const o of i)
|
|
310
321
|
FSHelpers.copyRecursive(
|
|
311
322
|
e,
|
|
312
|
-
joinPaths(
|
|
323
|
+
joinPaths(r, o),
|
|
313
324
|
joinPaths(s, o)
|
|
314
325
|
);
|
|
315
|
-
} else
|
|
316
|
-
e.writeFile(s, e.readFile(t));
|
|
326
|
+
} else e.isLink(n.mode) ? e.symlink(e.readlink(r), s) : e.writeFile(s, e.readFile(r));
|
|
317
327
|
}
|
|
318
328
|
}
|
|
319
329
|
FSHelpers.readFileAsText = rethrowFileSystemError('Could not read "{path}"')(
|
|
@@ -355,9 +365,9 @@ FSHelpers.copyRecursive = rethrowFileSystemError(
|
|
|
355
365
|
const _private = /* @__PURE__ */ new WeakMap();
|
|
356
366
|
class PHPWorker {
|
|
357
367
|
/** @inheritDoc */
|
|
358
|
-
constructor(e,
|
|
368
|
+
constructor(e, r) {
|
|
359
369
|
this.absoluteUrl = "", this.documentRoot = "", _private.set(this, {
|
|
360
|
-
monitor:
|
|
370
|
+
monitor: r
|
|
361
371
|
}), e && this.__internal_setRequestHandler(e);
|
|
362
372
|
}
|
|
363
373
|
__internal_setRequestHandler(e) {
|
|
@@ -394,16 +404,16 @@ class PHPWorker {
|
|
|
394
404
|
* The onDownloadProgress event listener.
|
|
395
405
|
*/
|
|
396
406
|
async onDownloadProgress(e) {
|
|
397
|
-
var
|
|
398
|
-
return (
|
|
407
|
+
var r;
|
|
408
|
+
return (r = _private.get(this).monitor) == null ? void 0 : r.addEventListener("progress", e);
|
|
399
409
|
}
|
|
400
410
|
/** @inheritDoc @php-wasm/universal!PHP.mv */
|
|
401
|
-
async mv(e,
|
|
402
|
-
return _private.get(this).php.mv(e,
|
|
411
|
+
async mv(e, r) {
|
|
412
|
+
return _private.get(this).php.mv(e, r);
|
|
403
413
|
}
|
|
404
414
|
/** @inheritDoc @php-wasm/universal!PHP.rmdir */
|
|
405
|
-
async rmdir(e,
|
|
406
|
-
return _private.get(this).php.rmdir(e,
|
|
415
|
+
async rmdir(e, r) {
|
|
416
|
+
return _private.get(this).php.rmdir(e, r);
|
|
407
417
|
}
|
|
408
418
|
/** @inheritDoc @php-wasm/universal!PHPRequestHandler.request */
|
|
409
419
|
async request(e) {
|
|
@@ -411,9 +421,9 @@ class PHPWorker {
|
|
|
411
421
|
}
|
|
412
422
|
/** @inheritDoc @php-wasm/universal!/PHP.run */
|
|
413
423
|
async run(e) {
|
|
414
|
-
const { php:
|
|
424
|
+
const { php: r, reap: s } = await _private.get(this).requestHandler.processManager.acquirePHPInstance();
|
|
415
425
|
try {
|
|
416
|
-
return await
|
|
426
|
+
return await r.run(e);
|
|
417
427
|
} finally {
|
|
418
428
|
s();
|
|
419
429
|
}
|
|
@@ -443,16 +453,16 @@ class PHPWorker {
|
|
|
443
453
|
return _private.get(this).php.readFileAsBuffer(e);
|
|
444
454
|
}
|
|
445
455
|
/** @inheritDoc @php-wasm/universal!/PHP.writeFile */
|
|
446
|
-
writeFile(e,
|
|
447
|
-
return _private.get(this).php.writeFile(e,
|
|
456
|
+
writeFile(e, r) {
|
|
457
|
+
return _private.get(this).php.writeFile(e, r);
|
|
448
458
|
}
|
|
449
459
|
/** @inheritDoc @php-wasm/universal!/PHP.unlink */
|
|
450
460
|
unlink(e) {
|
|
451
461
|
return _private.get(this).php.unlink(e);
|
|
452
462
|
}
|
|
453
463
|
/** @inheritDoc @php-wasm/universal!/PHP.listFiles */
|
|
454
|
-
listFiles(e,
|
|
455
|
-
return _private.get(this).php.listFiles(e,
|
|
464
|
+
listFiles(e, r) {
|
|
465
|
+
return _private.get(this).php.listFiles(e, r);
|
|
456
466
|
}
|
|
457
467
|
/** @inheritDoc @php-wasm/universal!/PHP.isDir */
|
|
458
468
|
isDir(e) {
|
|
@@ -471,16 +481,16 @@ class PHPWorker {
|
|
|
471
481
|
return _private.get(this).php.onMessage(e);
|
|
472
482
|
}
|
|
473
483
|
/** @inheritDoc @php-wasm/universal!/PHP.defineConstant */
|
|
474
|
-
defineConstant(e,
|
|
475
|
-
_private.get(this).php.defineConstant(e,
|
|
484
|
+
defineConstant(e, r) {
|
|
485
|
+
_private.get(this).php.defineConstant(e, r);
|
|
476
486
|
}
|
|
477
487
|
/** @inheritDoc @php-wasm/universal!/PHP.addEventListener */
|
|
478
|
-
addEventListener(e,
|
|
479
|
-
_private.get(this).php.addEventListener(e,
|
|
488
|
+
addEventListener(e, r) {
|
|
489
|
+
_private.get(this).php.addEventListener(e, r);
|
|
480
490
|
}
|
|
481
491
|
/** @inheritDoc @php-wasm/universal!/PHP.removeEventListener */
|
|
482
|
-
removeEventListener(e,
|
|
483
|
-
_private.get(this).php.removeEventListener(e,
|
|
492
|
+
removeEventListener(e, r) {
|
|
493
|
+
_private.get(this).php.removeEventListener(e, r);
|
|
484
494
|
}
|
|
485
495
|
async [Symbol.asyncDispose]() {
|
|
486
496
|
var e;
|
|
@@ -503,8 +513,8 @@ const responseTexts = {
|
|
|
503
513
|
200: "OK"
|
|
504
514
|
};
|
|
505
515
|
class StreamedPHPResponse {
|
|
506
|
-
constructor(e,
|
|
507
|
-
this.parsedHeaders = null, this.cachedStdoutText = null, this.cachedStderrText = null, this.headersStream = e, this.stdout =
|
|
516
|
+
constructor(e, r, s, n) {
|
|
517
|
+
this.parsedHeaders = null, this.cachedStdoutText = null, this.cachedStderrText = null, this.headersStream = e, this.stdout = r, this.stderr = s, this.exitCode = n;
|
|
508
518
|
}
|
|
509
519
|
/**
|
|
510
520
|
* True if the response is successful (HTTP status code 200-399),
|
|
@@ -544,7 +554,7 @@ class StreamedPHPResponse {
|
|
|
544
554
|
(e) => e !== 0 ? 500 : void 0
|
|
545
555
|
)
|
|
546
556
|
]).then((e) => e !== void 0 ? e : this.getParsedHeaders().then(
|
|
547
|
-
(
|
|
557
|
+
(r) => r.httpStatusCode,
|
|
548
558
|
() => 200
|
|
549
559
|
)).catch(() => 500);
|
|
550
560
|
}
|
|
@@ -564,45 +574,45 @@ class StreamedPHPResponse {
|
|
|
564
574
|
return this.parsedHeaders || (this.parsedHeaders = parseHeadersStream(this.headersStream)), await this.parsedHeaders;
|
|
565
575
|
}
|
|
566
576
|
}
|
|
567
|
-
async function parseHeadersStream(
|
|
568
|
-
const e = await streamToText(
|
|
569
|
-
let
|
|
577
|
+
async function parseHeadersStream(t) {
|
|
578
|
+
const e = await streamToText(t);
|
|
579
|
+
let r;
|
|
570
580
|
try {
|
|
571
|
-
|
|
581
|
+
r = JSON.parse(e);
|
|
572
582
|
} catch {
|
|
573
583
|
return { headers: {}, httpStatusCode: 200 };
|
|
574
584
|
}
|
|
575
585
|
const s = {};
|
|
576
|
-
for (const
|
|
577
|
-
if (!
|
|
586
|
+
for (const n of r.headers) {
|
|
587
|
+
if (!n.includes(": "))
|
|
578
588
|
continue;
|
|
579
|
-
const
|
|
589
|
+
const i = n.indexOf(": "), o = n.substring(0, i).toLowerCase(), a = n.substring(i + 2);
|
|
580
590
|
o in s || (s[o] = []), s[o].push(a);
|
|
581
591
|
}
|
|
582
592
|
return {
|
|
583
593
|
headers: s,
|
|
584
|
-
httpStatusCode:
|
|
594
|
+
httpStatusCode: r.status
|
|
585
595
|
};
|
|
586
596
|
}
|
|
587
|
-
async function streamToText(
|
|
588
|
-
const e =
|
|
597
|
+
async function streamToText(t) {
|
|
598
|
+
const e = t.pipeThrough(new TextDecoderStream()).getReader(), r = [];
|
|
589
599
|
for (; ; ) {
|
|
590
|
-
const { done: s, value:
|
|
600
|
+
const { done: s, value: n } = await e.read();
|
|
591
601
|
if (s)
|
|
592
|
-
return
|
|
593
|
-
|
|
602
|
+
return r.join("");
|
|
603
|
+
n && r.push(n);
|
|
594
604
|
}
|
|
595
605
|
}
|
|
596
606
|
class PHPResponse {
|
|
597
|
-
constructor(e,
|
|
598
|
-
this.httpStatusCode = e, this.headers =
|
|
607
|
+
constructor(e, r, s, n = "", i = 0) {
|
|
608
|
+
this.httpStatusCode = e, this.headers = r, this.bytes = s, this.exitCode = i, this.errors = n;
|
|
599
609
|
}
|
|
600
|
-
static forHttpCode(e,
|
|
610
|
+
static forHttpCode(e, r = "") {
|
|
601
611
|
return new PHPResponse(
|
|
602
612
|
e,
|
|
603
613
|
{},
|
|
604
614
|
new TextEncoder().encode(
|
|
605
|
-
|
|
615
|
+
r || responseTexts[e] || ""
|
|
606
616
|
)
|
|
607
617
|
);
|
|
608
618
|
}
|
|
@@ -648,20 +658,20 @@ class PHPResponse {
|
|
|
648
658
|
}
|
|
649
659
|
const RuntimeId = Symbol("RuntimeId"), loadedRuntimes = /* @__PURE__ */ new Map();
|
|
650
660
|
let lastRuntimeId = 0;
|
|
651
|
-
async function loadPHPRuntime(
|
|
652
|
-
const
|
|
661
|
+
async function loadPHPRuntime(t, ...e) {
|
|
662
|
+
const r = Object.assign({}, ...e), [s, n, i] = makePromise(), o = t.init(currentJsRuntime, {
|
|
653
663
|
onAbort(l) {
|
|
654
|
-
|
|
664
|
+
i(l), logger.error(l);
|
|
655
665
|
},
|
|
656
666
|
ENV: {},
|
|
657
667
|
// Emscripten sometimes prepends a '/' to the path, which
|
|
658
668
|
// breaks vite dev mode. An identity `locateFile` function
|
|
659
669
|
// fixes it.
|
|
660
670
|
locateFile: (l) => l,
|
|
661
|
-
...
|
|
671
|
+
...r,
|
|
662
672
|
noInitialRun: !0,
|
|
663
673
|
onRuntimeInitialized() {
|
|
664
|
-
|
|
674
|
+
r.onRuntimeInitialized && r.onRuntimeInitialized(o), n();
|
|
665
675
|
}
|
|
666
676
|
});
|
|
667
677
|
await s;
|
|
@@ -670,17 +680,17 @@ async function loadPHPRuntime(r, ...e) {
|
|
|
670
680
|
return o.outboundNetworkProxyServer && (o.outboundNetworkProxyServer.close(), o.outboundNetworkProxyServer.closeAllConnections()), loadedRuntimes.delete(a), o.originalExit(l);
|
|
671
681
|
}, o[RuntimeId] = a, loadedRuntimes.set(a, o), a;
|
|
672
682
|
}
|
|
673
|
-
function getLoadedRuntime(
|
|
674
|
-
return loadedRuntimes.get(
|
|
683
|
+
function getLoadedRuntime(t) {
|
|
684
|
+
return loadedRuntimes.get(t);
|
|
675
685
|
}
|
|
676
686
|
const currentJsRuntime = function() {
|
|
677
|
-
var
|
|
678
|
-
return typeof process < "u" && ((
|
|
687
|
+
var t;
|
|
688
|
+
return typeof process < "u" && ((t = process.release) == null ? void 0 : t.name) === "node" ? "NODE" : typeof window < "u" ? "WEB" : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? "WORKER" : "NODE";
|
|
679
689
|
}(), makePromise = () => {
|
|
680
|
-
const
|
|
681
|
-
|
|
690
|
+
const t = [], e = new Promise((r, s) => {
|
|
691
|
+
t.push(r, s);
|
|
682
692
|
});
|
|
683
|
-
return
|
|
693
|
+
return t.unshift(e), t;
|
|
684
694
|
};
|
|
685
695
|
var _a;
|
|
686
696
|
const kError = Symbol("error"), kMessage = Symbol("message");
|
|
@@ -692,8 +702,8 @@ class ErrorEvent2 extends (_a = Event, _a) {
|
|
|
692
702
|
* @param options A dictionary object that allows for setting
|
|
693
703
|
* attributes via object members of the same name.
|
|
694
704
|
*/
|
|
695
|
-
constructor(e,
|
|
696
|
-
super(e), this[kError] =
|
|
705
|
+
constructor(e, r = {}) {
|
|
706
|
+
super(e), this[kError] = r.error === void 0 ? null : r.error, this[kMessage] = r.message === void 0 ? "" : r.message;
|
|
697
707
|
}
|
|
698
708
|
get error() {
|
|
699
709
|
return this[kError];
|
|
@@ -705,24 +715,24 @@ class ErrorEvent2 extends (_a = Event, _a) {
|
|
|
705
715
|
Object.defineProperty(ErrorEvent2.prototype, "error", { enumerable: !0 });
|
|
706
716
|
Object.defineProperty(ErrorEvent2.prototype, "message", { enumerable: !0 });
|
|
707
717
|
const ErrorEvent = typeof globalThis.ErrorEvent == "function" ? globalThis.ErrorEvent : ErrorEvent2;
|
|
708
|
-
function isExitCode(
|
|
709
|
-
return
|
|
718
|
+
function isExitCode(t) {
|
|
719
|
+
return t instanceof Error ? (t == null ? void 0 : t.name) === "ExitStatus" && "status" in t : !1;
|
|
710
720
|
}
|
|
711
721
|
class UnhandledRejectionsTarget extends EventTarget {
|
|
712
722
|
constructor() {
|
|
713
723
|
super(...arguments), this.listenersCount = 0;
|
|
714
724
|
}
|
|
715
|
-
addEventListener(e,
|
|
725
|
+
addEventListener(e, r, s) {
|
|
716
726
|
++this.listenersCount, super.addEventListener(
|
|
717
727
|
e,
|
|
718
|
-
|
|
728
|
+
r,
|
|
719
729
|
s
|
|
720
730
|
);
|
|
721
731
|
}
|
|
722
|
-
removeEventListener(e,
|
|
732
|
+
removeEventListener(e, r, s) {
|
|
723
733
|
--this.listenersCount, super.removeEventListener(
|
|
724
734
|
e,
|
|
725
|
-
|
|
735
|
+
r,
|
|
726
736
|
s
|
|
727
737
|
);
|
|
728
738
|
}
|
|
@@ -730,31 +740,29 @@ class UnhandledRejectionsTarget extends EventTarget {
|
|
|
730
740
|
return this.listenersCount > 0;
|
|
731
741
|
}
|
|
732
742
|
}
|
|
733
|
-
function improveWASMErrorReporting(
|
|
743
|
+
function improveWASMErrorReporting(t) {
|
|
734
744
|
const e = new UnhandledRejectionsTarget();
|
|
735
|
-
for (const
|
|
736
|
-
if (typeof
|
|
737
|
-
const s =
|
|
738
|
-
|
|
739
|
-
var
|
|
745
|
+
for (const r in t.wasmExports)
|
|
746
|
+
if (typeof t.wasmExports[r] == "function") {
|
|
747
|
+
const s = t.wasmExports[r];
|
|
748
|
+
t.wasmExports[r] = function(...n) {
|
|
749
|
+
var i;
|
|
740
750
|
try {
|
|
741
|
-
return s(...
|
|
751
|
+
return s(...n);
|
|
742
752
|
} catch (o) {
|
|
743
753
|
if (!(o instanceof Error))
|
|
744
754
|
throw o;
|
|
745
|
-
|
|
755
|
+
t.lastAsyncifyStackSource && (o.cause = t.lastAsyncifyStackSource);
|
|
746
756
|
const a = clarifyErrorMessage(
|
|
747
757
|
o,
|
|
748
|
-
(
|
|
758
|
+
(i = t.lastAsyncifyStackSource) == null ? void 0 : i.stack
|
|
749
759
|
);
|
|
750
760
|
if (e.hasListeners()) {
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
message: a
|
|
754
|
-
});
|
|
761
|
+
o.message = a;
|
|
762
|
+
const l = new ErrorEvent("error", { error: o });
|
|
755
763
|
throw e.dispatchEvent(l), o;
|
|
756
764
|
}
|
|
757
|
-
throw (!isExitCode(o) || o.
|
|
765
|
+
throw (!isExitCode(o) || o.status !== 0) && showCriticalErrorBox(a), o;
|
|
758
766
|
}
|
|
759
767
|
};
|
|
760
768
|
}
|
|
@@ -764,33 +772,34 @@ let functionsMaybeMissingFromAsyncify = [];
|
|
|
764
772
|
function getFunctionsMaybeMissingFromAsyncify() {
|
|
765
773
|
return functionsMaybeMissingFromAsyncify;
|
|
766
774
|
}
|
|
767
|
-
function clarifyErrorMessage(
|
|
768
|
-
if (
|
|
769
|
-
let
|
|
770
|
-
e || (
|
|
775
|
+
function clarifyErrorMessage(t, e) {
|
|
776
|
+
if (t.message === "unreachable") {
|
|
777
|
+
let r = UNREACHABLE_ERROR;
|
|
778
|
+
e || (r += `
|
|
771
779
|
|
|
772
780
|
This stack trace is lacking. For a better one initialize
|
|
773
|
-
the PHP runtime with
|
|
781
|
+
the PHP runtime with debug: true, e.g. loadNodeRuntime('8.1', { emscriptenOptions: { debug: true } }).
|
|
774
782
|
|
|
775
783
|
`);
|
|
776
784
|
const s = new Set(
|
|
777
785
|
extractPHPFunctionsFromStack(e || "")
|
|
778
786
|
);
|
|
779
|
-
let
|
|
787
|
+
let n = t;
|
|
780
788
|
do {
|
|
781
|
-
for (const
|
|
782
|
-
|
|
789
|
+
for (const i of extractPHPFunctionsFromStack(
|
|
790
|
+
n.stack || ""
|
|
783
791
|
))
|
|
784
|
-
s.add(
|
|
785
|
-
|
|
786
|
-
} while (
|
|
792
|
+
s.add(i);
|
|
793
|
+
n = n.cause;
|
|
794
|
+
} while (n);
|
|
787
795
|
functionsMaybeMissingFromAsyncify = Array.from(s);
|
|
788
|
-
for (const
|
|
789
|
-
|
|
796
|
+
for (const i of s)
|
|
797
|
+
r += ` * ${i}
|
|
790
798
|
`;
|
|
791
|
-
return t
|
|
799
|
+
return r += `Original error message: ${t.message}
|
|
800
|
+
`, r;
|
|
792
801
|
}
|
|
793
|
-
return
|
|
802
|
+
return t.message;
|
|
794
803
|
}
|
|
795
804
|
const UNREACHABLE_ERROR = `
|
|
796
805
|
"unreachable" WASM instruction executed.
|
|
@@ -818,29 +827,29 @@ CLI option:
|
|
|
818
827
|
|
|
819
828
|
`, redBg = "\x1B[41m", bold = "\x1B[1m", reset = "\x1B[0m", eol = "\x1B[K";
|
|
820
829
|
let logged = !1;
|
|
821
|
-
function showCriticalErrorBox(
|
|
822
|
-
if (!logged && (logged = !0, !(
|
|
830
|
+
function showCriticalErrorBox(t) {
|
|
831
|
+
if (!logged && (logged = !0, !(t != null && t.trim().startsWith("Program terminated with exit")))) {
|
|
823
832
|
logger.log(`${redBg}
|
|
824
833
|
${eol}
|
|
825
834
|
${bold} WASM ERROR${reset}${redBg}`);
|
|
826
|
-
for (const e of
|
|
835
|
+
for (const e of t.split(`
|
|
827
836
|
`))
|
|
828
837
|
logger.log(`${eol} ${e} `);
|
|
829
838
|
logger.log(`${reset}`);
|
|
830
839
|
}
|
|
831
840
|
}
|
|
832
|
-
function extractPHPFunctionsFromStack(
|
|
841
|
+
function extractPHPFunctionsFromStack(t) {
|
|
833
842
|
try {
|
|
834
|
-
const e =
|
|
835
|
-
`).slice(1).map((
|
|
836
|
-
const s =
|
|
843
|
+
const e = t.split(`
|
|
844
|
+
`).slice(1).map((r) => {
|
|
845
|
+
const s = r.trim().substring(3).split(" ");
|
|
837
846
|
return {
|
|
838
847
|
fn: s.length >= 2 ? s[0] : "<unknown>",
|
|
839
|
-
isWasm:
|
|
848
|
+
isWasm: r.includes("wasm:/")
|
|
840
849
|
};
|
|
841
850
|
}).filter(
|
|
842
|
-
({ fn:
|
|
843
|
-
).map(({ fn:
|
|
851
|
+
({ fn: r, isWasm: s }) => s && !r.startsWith("dynCall_") && !r.startsWith("invoke_")
|
|
852
|
+
).map(({ fn: r }) => r);
|
|
844
853
|
return Array.from(new Set(e));
|
|
845
854
|
} catch {
|
|
846
855
|
return [];
|
|
@@ -848,12 +857,12 @@ function extractPHPFunctionsFromStack(r) {
|
|
|
848
857
|
}
|
|
849
858
|
const STRING = "string", NUMBER = "number", __private__dont__use = Symbol("__private__dont__use");
|
|
850
859
|
class PHPExecutionFailureError extends Error {
|
|
851
|
-
constructor(e,
|
|
852
|
-
super(e), this.response =
|
|
860
|
+
constructor(e, r, s) {
|
|
861
|
+
super(e), this.response = r, this.source = s;
|
|
853
862
|
}
|
|
854
863
|
}
|
|
855
864
|
const PHP_INI_PATH = "/internal/shared/php.ini", AUTO_PREPEND_SCRIPT = "/internal/shared/auto_prepend_file.php";
|
|
856
|
-
var
|
|
865
|
+
var k, E, x, g, v, T, d, z, W, B, $, V, G, J, Y, K, L, X, U, O;
|
|
857
866
|
class PHP {
|
|
858
867
|
/**
|
|
859
868
|
* Initializes a PHP runtime.
|
|
@@ -862,38 +871,38 @@ class PHP {
|
|
|
862
871
|
* @param PHPRuntime - Optional. PHP Runtime ID as initialized by loadPHPRuntime.
|
|
863
872
|
* @param requestHandlerOptions - Optional. Options for the PHPRequestHandler. If undefined, no request handler will be initialized.
|
|
864
873
|
*/
|
|
865
|
-
constructor(
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
this.semaphore = new Semaphore({ concurrency: 1 }),
|
|
874
|
+
constructor(t) {
|
|
875
|
+
_(this, d);
|
|
876
|
+
_(this, k);
|
|
877
|
+
_(this, E);
|
|
878
|
+
_(this, x);
|
|
879
|
+
_(this, g);
|
|
880
|
+
_(this, v);
|
|
881
|
+
_(this, T);
|
|
882
|
+
f(this, E, !1), f(this, x, null), f(this, g, /* @__PURE__ */ new Map()), f(this, v, []), f(this, T, {}), this.cliCalled = !1, this.runStreamCalled = !1, this.semaphore = new Semaphore({ concurrency: 1 }), t !== void 0 && this.initializeRuntime(t);
|
|
874
883
|
}
|
|
875
884
|
/**
|
|
876
885
|
* Adds an event listener for a PHP event.
|
|
877
886
|
* @param eventType - The type of event to listen for.
|
|
878
887
|
* @param listener - The listener function to be called when the event is triggered.
|
|
879
888
|
*/
|
|
880
|
-
addEventListener(
|
|
881
|
-
|
|
889
|
+
addEventListener(t, e) {
|
|
890
|
+
u(this, g).has(t) || u(this, g).set(t, /* @__PURE__ */ new Set()), u(this, g).get(t).add(e);
|
|
882
891
|
}
|
|
883
892
|
/**
|
|
884
893
|
* Removes an event listener for a PHP event.
|
|
885
894
|
* @param eventType - The type of event to remove the listener from.
|
|
886
895
|
* @param listener - The listener function to be removed.
|
|
887
896
|
*/
|
|
888
|
-
removeEventListener(
|
|
889
|
-
var
|
|
890
|
-
(
|
|
897
|
+
removeEventListener(t, e) {
|
|
898
|
+
var r;
|
|
899
|
+
(r = u(this, g).get(t)) == null || r.delete(e);
|
|
891
900
|
}
|
|
892
|
-
dispatchEvent(
|
|
893
|
-
const e =
|
|
901
|
+
dispatchEvent(t) {
|
|
902
|
+
const e = u(this, g).get(t.type);
|
|
894
903
|
if (e)
|
|
895
|
-
for (const
|
|
896
|
-
t
|
|
904
|
+
for (const r of e)
|
|
905
|
+
r(t);
|
|
897
906
|
}
|
|
898
907
|
/**
|
|
899
908
|
* Listens to message sent by the PHP code.
|
|
@@ -934,10 +943,10 @@ class PHP {
|
|
|
934
943
|
*
|
|
935
944
|
* @param listener Callback function to handle the message.
|
|
936
945
|
*/
|
|
937
|
-
onMessage(
|
|
938
|
-
return
|
|
939
|
-
f(this,
|
|
940
|
-
(e) => e !==
|
|
946
|
+
onMessage(t) {
|
|
947
|
+
return u(this, v).push(t), async () => {
|
|
948
|
+
f(this, v, u(this, v).filter(
|
|
949
|
+
(e) => e !== t
|
|
941
950
|
));
|
|
942
951
|
};
|
|
943
952
|
}
|
|
@@ -953,17 +962,17 @@ class PHP {
|
|
|
953
962
|
return this.requestHandler.documentRoot;
|
|
954
963
|
}
|
|
955
964
|
/** @deprecated Use PHPRequestHandler instead. */
|
|
956
|
-
pathToInternalUrl(
|
|
957
|
-
return this.requestHandler.pathToInternalUrl(
|
|
965
|
+
pathToInternalUrl(t) {
|
|
966
|
+
return this.requestHandler.pathToInternalUrl(t);
|
|
958
967
|
}
|
|
959
968
|
/** @deprecated Use PHPRequestHandler instead. */
|
|
960
|
-
internalUrlToPath(
|
|
961
|
-
return this.requestHandler.internalUrlToPath(
|
|
969
|
+
internalUrlToPath(t) {
|
|
970
|
+
return this.requestHandler.internalUrlToPath(t);
|
|
962
971
|
}
|
|
963
|
-
initializeRuntime(
|
|
972
|
+
initializeRuntime(t) {
|
|
964
973
|
if (this[__private__dont__use])
|
|
965
974
|
throw new Error("PHP runtime already initialized.");
|
|
966
|
-
const e = getLoadedRuntime(
|
|
975
|
+
const e = getLoadedRuntime(t);
|
|
967
976
|
if (!e)
|
|
968
977
|
throw new Error("Invalid PHP runtime id.");
|
|
969
978
|
this[__private__dont__use] = e, this[__private__dont__use].ccall(
|
|
@@ -1011,29 +1020,29 @@ class PHP {
|
|
|
1011
1020
|
require_once $file;
|
|
1012
1021
|
}
|
|
1013
1022
|
`
|
|
1014
|
-
), e.onMessage = async (
|
|
1015
|
-
for (const s of
|
|
1016
|
-
const
|
|
1017
|
-
if (
|
|
1018
|
-
return
|
|
1023
|
+
), e.onMessage = async (r) => {
|
|
1024
|
+
for (const s of u(this, v)) {
|
|
1025
|
+
const n = await s(r);
|
|
1026
|
+
if (n)
|
|
1027
|
+
return n;
|
|
1019
1028
|
}
|
|
1020
1029
|
return "";
|
|
1021
|
-
}, f(this,
|
|
1030
|
+
}, f(this, x, improveWASMErrorReporting(e)), this.dispatchEvent({
|
|
1022
1031
|
type: "runtime.initialized"
|
|
1023
1032
|
});
|
|
1024
1033
|
}
|
|
1025
1034
|
/** @inheritDoc */
|
|
1026
|
-
async setSapiName(
|
|
1035
|
+
async setSapiName(t) {
|
|
1027
1036
|
if (this[__private__dont__use].ccall(
|
|
1028
1037
|
"wasm_set_sapi_name",
|
|
1029
1038
|
NUMBER,
|
|
1030
1039
|
[STRING],
|
|
1031
|
-
[
|
|
1040
|
+
[t]
|
|
1032
1041
|
) !== 0)
|
|
1033
1042
|
throw new Error(
|
|
1034
1043
|
"Could not set SAPI name. This can only be done before the PHP WASM module is initialized.Did you already dispatch any requests?"
|
|
1035
1044
|
);
|
|
1036
|
-
f(this,
|
|
1045
|
+
f(this, k, t);
|
|
1037
1046
|
}
|
|
1038
1047
|
/**
|
|
1039
1048
|
* Changes the current working directory in the PHP filesystem.
|
|
@@ -1043,19 +1052,27 @@ class PHP {
|
|
|
1043
1052
|
*
|
|
1044
1053
|
* @param path - The new working directory.
|
|
1045
1054
|
*/
|
|
1046
|
-
chdir(
|
|
1047
|
-
this[__private__dont__use].FS.chdir(
|
|
1055
|
+
chdir(t) {
|
|
1056
|
+
this[__private__dont__use].FS.chdir(t);
|
|
1057
|
+
}
|
|
1058
|
+
/**
|
|
1059
|
+
* Changes the permissions of a file or directory.
|
|
1060
|
+
* @param path - The path to the file or directory.
|
|
1061
|
+
* @param mode - The new permissions.
|
|
1062
|
+
*/
|
|
1063
|
+
chmod(t, e) {
|
|
1064
|
+
this[__private__dont__use].FS.chmod(t, e);
|
|
1048
1065
|
}
|
|
1049
1066
|
/**
|
|
1050
1067
|
* Do not use. Use new PHPRequestHandler() instead.
|
|
1051
1068
|
* @deprecated
|
|
1052
1069
|
*/
|
|
1053
|
-
async request(
|
|
1070
|
+
async request(t) {
|
|
1054
1071
|
if (logger.warn(
|
|
1055
1072
|
"PHP.request() is deprecated. Please use new PHPRequestHandler() instead."
|
|
1056
1073
|
), !this.requestHandler)
|
|
1057
1074
|
throw new Error("No request handler available.");
|
|
1058
|
-
return this.requestHandler.request(
|
|
1075
|
+
return this.requestHandler.request(t);
|
|
1059
1076
|
}
|
|
1060
1077
|
/**
|
|
1061
1078
|
* Runs PHP code.
|
|
@@ -1129,29 +1146,23 @@ class PHP {
|
|
|
1129
1146
|
* @deprecated Use stream() instead.
|
|
1130
1147
|
* @param request - PHP runtime options.
|
|
1131
1148
|
*/
|
|
1132
|
-
async run(
|
|
1133
|
-
const e = await this.runStream(
|
|
1149
|
+
async run(t) {
|
|
1150
|
+
const e = await this.runStream(t), r = await PHPResponse.fromStreamedResponse(
|
|
1134
1151
|
e
|
|
1135
1152
|
);
|
|
1136
|
-
if (
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
`PHP.run() failed with exit code ${t.exitCode} and the following output: ` + t.errors + `
|
|
1153
|
+
if (r.exitCode !== 0)
|
|
1154
|
+
throw new PHPExecutionFailureError(
|
|
1155
|
+
`PHP.run() failed with exit code ${r.exitCode}.
|
|
1140
1156
|
|
|
1141
|
-
|
|
1142
|
-
|
|
1157
|
+
=== Stdout ===
|
|
1158
|
+
${r.text}
|
|
1159
|
+
|
|
1160
|
+
=== Stderr ===
|
|
1161
|
+
${r.errors}`,
|
|
1162
|
+
r,
|
|
1143
1163
|
"request"
|
|
1144
1164
|
);
|
|
1145
|
-
|
|
1146
|
-
type: "request.error",
|
|
1147
|
-
error: new Error(
|
|
1148
|
-
"PHP.run() failed with exit code " + t.exitCode
|
|
1149
|
-
),
|
|
1150
|
-
// Distinguish between PHP request and PHP-wasm errors
|
|
1151
|
-
source: "request"
|
|
1152
|
-
}), s;
|
|
1153
|
-
}
|
|
1154
|
-
return t;
|
|
1165
|
+
return r;
|
|
1155
1166
|
}
|
|
1156
1167
|
/**
|
|
1157
1168
|
* Runs PHP code and returns a StreamedPHPResponse object that can be used to
|
|
@@ -1244,31 +1255,36 @@ class PHP {
|
|
|
1244
1255
|
* @param request - PHP runtime options.
|
|
1245
1256
|
* @returns A StreamedPHPResponse object.
|
|
1246
1257
|
*/
|
|
1247
|
-
async runStream(
|
|
1258
|
+
async runStream(t) {
|
|
1259
|
+
if (this.cliCalled)
|
|
1260
|
+
throw new Error(
|
|
1261
|
+
"php.runStream() can only be called if php.cli() was not called before. The two methods set a conflicting C-level global state."
|
|
1262
|
+
);
|
|
1263
|
+
this.runStreamCalled = !0;
|
|
1248
1264
|
const e = await this.semaphore.acquire();
|
|
1249
|
-
let
|
|
1250
|
-
const s =
|
|
1251
|
-
if (
|
|
1265
|
+
let r;
|
|
1266
|
+
const s = m(this, d, O).call(this, async () => {
|
|
1267
|
+
if (u(this, E) || (await m(this, d, W).call(this), f(this, E, !0)), t.scriptPath && !this.fileExists(t.scriptPath))
|
|
1252
1268
|
throw new Error(
|
|
1253
|
-
`The script path "${
|
|
1269
|
+
`The script path "${t.scriptPath}" does not exist.`
|
|
1254
1270
|
);
|
|
1255
|
-
|
|
1256
|
-
const
|
|
1257
|
-
if (
|
|
1258
|
-
this.writeFile("/internal/eval.php",
|
|
1259
|
-
else if (typeof
|
|
1260
|
-
|
|
1271
|
+
m(this, d, B).call(this, t.relativeUri || ""), m(this, d, J).call(this, t.method || "GET");
|
|
1272
|
+
const n = normalizeHeaders(t.headers || {}), i = n.host || "example.com:443", o = m(this, d, G).call(this, i, t.protocol || "http");
|
|
1273
|
+
if (m(this, d, $).call(this, i), m(this, d, V).call(this, o), m(this, d, Y).call(this, n), t.body && (r = m(this, d, K).call(this, t.body)), typeof t.code == "string")
|
|
1274
|
+
this.writeFile("/internal/eval.php", t.code), m(this, d, L).call(this, "/internal/eval.php");
|
|
1275
|
+
else if (typeof t.scriptPath == "string")
|
|
1276
|
+
m(this, d, L).call(this, t.scriptPath || "");
|
|
1261
1277
|
else
|
|
1262
1278
|
throw new TypeError(
|
|
1263
1279
|
"The request object must have either a `code` or a `scriptPath` property."
|
|
1264
1280
|
);
|
|
1265
|
-
const a =
|
|
1266
|
-
for (const
|
|
1267
|
-
|
|
1268
|
-
const l =
|
|
1269
|
-
for (const
|
|
1270
|
-
|
|
1271
|
-
return
|
|
1281
|
+
const a = m(this, d, z).call(this, t.$_SERVER, n, o);
|
|
1282
|
+
for (const c in a)
|
|
1283
|
+
m(this, d, X).call(this, c, a[c]);
|
|
1284
|
+
const l = t.env || {};
|
|
1285
|
+
for (const c in l)
|
|
1286
|
+
m(this, d, U).call(this, c, l[c]);
|
|
1287
|
+
return await this[__private__dont__use].ccall(
|
|
1272
1288
|
"wasm_sapi_handle_request",
|
|
1273
1289
|
NUMBER,
|
|
1274
1290
|
[],
|
|
@@ -1276,15 +1292,15 @@ class PHP {
|
|
|
1276
1292
|
{ async: !0 }
|
|
1277
1293
|
);
|
|
1278
1294
|
});
|
|
1279
|
-
return await s.catch((
|
|
1280
|
-
this.dispatchEvent({
|
|
1295
|
+
return await s.catch((n) => {
|
|
1296
|
+
throw this.dispatchEvent({
|
|
1281
1297
|
type: "request.error",
|
|
1282
|
-
error:
|
|
1298
|
+
error: n,
|
|
1283
1299
|
// Distinguish between PHP request and PHP-wasm errors
|
|
1284
|
-
source:
|
|
1285
|
-
});
|
|
1300
|
+
source: n.source ?? "php-wasm"
|
|
1301
|
+
}), n;
|
|
1286
1302
|
}).finally(() => {
|
|
1287
|
-
|
|
1303
|
+
r && this[__private__dont__use].free(r);
|
|
1288
1304
|
}).finally(() => {
|
|
1289
1305
|
e(), this.dispatchEvent({
|
|
1290
1306
|
type: "request.end"
|
|
@@ -1296,10 +1312,10 @@ class PHP {
|
|
|
1296
1312
|
* @param key - The name of the constant.
|
|
1297
1313
|
* @param value - The value of the constant.
|
|
1298
1314
|
*/
|
|
1299
|
-
defineConstant(
|
|
1300
|
-
let
|
|
1315
|
+
defineConstant(t, e) {
|
|
1316
|
+
let r = {};
|
|
1301
1317
|
try {
|
|
1302
|
-
|
|
1318
|
+
r = JSON.parse(
|
|
1303
1319
|
this.fileExists("/internal/shared/consts.json") && this.readFileAsText("/internal/shared/consts.json") || "{}"
|
|
1304
1320
|
);
|
|
1305
1321
|
} catch {
|
|
@@ -1307,8 +1323,8 @@ class PHP {
|
|
|
1307
1323
|
this.writeFile(
|
|
1308
1324
|
"/internal/shared/consts.json",
|
|
1309
1325
|
JSON.stringify({
|
|
1310
|
-
...
|
|
1311
|
-
[
|
|
1326
|
+
...r,
|
|
1327
|
+
[t]: e
|
|
1312
1328
|
})
|
|
1313
1329
|
);
|
|
1314
1330
|
}
|
|
@@ -1319,14 +1335,14 @@ class PHP {
|
|
|
1319
1335
|
*
|
|
1320
1336
|
* @param path - The directory path to create.
|
|
1321
1337
|
*/
|
|
1322
|
-
mkdir(
|
|
1323
|
-
return FSHelpers.mkdir(this[__private__dont__use].FS,
|
|
1338
|
+
mkdir(t) {
|
|
1339
|
+
return FSHelpers.mkdir(this[__private__dont__use].FS, t);
|
|
1324
1340
|
}
|
|
1325
1341
|
/**
|
|
1326
1342
|
* @deprecated Use mkdir instead.
|
|
1327
1343
|
*/
|
|
1328
|
-
mkdirTree(
|
|
1329
|
-
return FSHelpers.mkdir(this[__private__dont__use].FS,
|
|
1344
|
+
mkdirTree(t) {
|
|
1345
|
+
return FSHelpers.mkdir(this[__private__dont__use].FS, t);
|
|
1330
1346
|
}
|
|
1331
1347
|
/**
|
|
1332
1348
|
* Reads a file from the PHP filesystem and returns it as a string.
|
|
@@ -1335,8 +1351,8 @@ class PHP {
|
|
|
1335
1351
|
* @param path - The file path to read.
|
|
1336
1352
|
* @returns The file contents.
|
|
1337
1353
|
*/
|
|
1338
|
-
readFileAsText(
|
|
1339
|
-
return FSHelpers.readFileAsText(this[__private__dont__use].FS,
|
|
1354
|
+
readFileAsText(t) {
|
|
1355
|
+
return FSHelpers.readFileAsText(this[__private__dont__use].FS, t);
|
|
1340
1356
|
}
|
|
1341
1357
|
/**
|
|
1342
1358
|
* Reads a file from the PHP filesystem and returns it as an array buffer.
|
|
@@ -1345,8 +1361,8 @@ class PHP {
|
|
|
1345
1361
|
* @param path - The file path to read.
|
|
1346
1362
|
* @returns The file contents.
|
|
1347
1363
|
*/
|
|
1348
|
-
readFileAsBuffer(
|
|
1349
|
-
return FSHelpers.readFileAsBuffer(this[__private__dont__use].FS,
|
|
1364
|
+
readFileAsBuffer(t) {
|
|
1365
|
+
return FSHelpers.readFileAsBuffer(this[__private__dont__use].FS, t);
|
|
1350
1366
|
}
|
|
1351
1367
|
/**
|
|
1352
1368
|
* Overwrites data in a file in the PHP filesystem.
|
|
@@ -1355,8 +1371,8 @@ class PHP {
|
|
|
1355
1371
|
* @param path - The file path to write to.
|
|
1356
1372
|
* @param data - The data to write to the file.
|
|
1357
1373
|
*/
|
|
1358
|
-
writeFile(
|
|
1359
|
-
return FSHelpers.writeFile(this[__private__dont__use].FS,
|
|
1374
|
+
writeFile(t, e) {
|
|
1375
|
+
return FSHelpers.writeFile(this[__private__dont__use].FS, t, e);
|
|
1360
1376
|
}
|
|
1361
1377
|
/**
|
|
1362
1378
|
* Removes a file from the PHP filesystem.
|
|
@@ -1364,8 +1380,8 @@ class PHP {
|
|
|
1364
1380
|
* @throws {@link @php-wasm/universal:ErrnoError} – If the file doesn't exist.
|
|
1365
1381
|
* @param path - The file path to remove.
|
|
1366
1382
|
*/
|
|
1367
|
-
unlink(
|
|
1368
|
-
return FSHelpers.unlink(this[__private__dont__use].FS,
|
|
1383
|
+
unlink(t) {
|
|
1384
|
+
return FSHelpers.unlink(this[__private__dont__use].FS, t);
|
|
1369
1385
|
}
|
|
1370
1386
|
/**
|
|
1371
1387
|
* Moves a file or directory in the PHP filesystem to a
|
|
@@ -1374,8 +1390,8 @@ class PHP {
|
|
|
1374
1390
|
* @param oldPath The path to rename.
|
|
1375
1391
|
* @param newPath The new path.
|
|
1376
1392
|
*/
|
|
1377
|
-
mv(
|
|
1378
|
-
return FSHelpers.mv(this[__private__dont__use].FS,
|
|
1393
|
+
mv(t, e) {
|
|
1394
|
+
return FSHelpers.mv(this[__private__dont__use].FS, t, e);
|
|
1379
1395
|
}
|
|
1380
1396
|
/**
|
|
1381
1397
|
* Removes a directory from the PHP filesystem.
|
|
@@ -1383,8 +1399,8 @@ class PHP {
|
|
|
1383
1399
|
* @param path The directory path to remove.
|
|
1384
1400
|
* @param options Options for the removal.
|
|
1385
1401
|
*/
|
|
1386
|
-
rmdir(
|
|
1387
|
-
return FSHelpers.rmdir(this[__private__dont__use].FS,
|
|
1402
|
+
rmdir(t, e = { recursive: !0 }) {
|
|
1403
|
+
return FSHelpers.rmdir(this[__private__dont__use].FS, t, e);
|
|
1388
1404
|
}
|
|
1389
1405
|
/**
|
|
1390
1406
|
* Lists the files and directories in the given directory.
|
|
@@ -1393,10 +1409,10 @@ class PHP {
|
|
|
1393
1409
|
* @param options - Options for the listing.
|
|
1394
1410
|
* @returns The list of files and directories in the given directory.
|
|
1395
1411
|
*/
|
|
1396
|
-
listFiles(
|
|
1412
|
+
listFiles(t, e = { prependPath: !1 }) {
|
|
1397
1413
|
return FSHelpers.listFiles(
|
|
1398
1414
|
this[__private__dont__use].FS,
|
|
1399
|
-
|
|
1415
|
+
t,
|
|
1400
1416
|
e
|
|
1401
1417
|
);
|
|
1402
1418
|
}
|
|
@@ -1406,8 +1422,8 @@ class PHP {
|
|
|
1406
1422
|
* @param path – The path to check.
|
|
1407
1423
|
* @returns True if the path is a directory, false otherwise.
|
|
1408
1424
|
*/
|
|
1409
|
-
isDir(
|
|
1410
|
-
return FSHelpers.isDir(this[__private__dont__use].FS,
|
|
1425
|
+
isDir(t) {
|
|
1426
|
+
return FSHelpers.isDir(this[__private__dont__use].FS, t);
|
|
1411
1427
|
}
|
|
1412
1428
|
/**
|
|
1413
1429
|
* Checks if a file exists in the PHP filesystem.
|
|
@@ -1415,16 +1431,16 @@ class PHP {
|
|
|
1415
1431
|
* @param path – The path to check.
|
|
1416
1432
|
* @returns True if the path is a file, false otherwise.
|
|
1417
1433
|
*/
|
|
1418
|
-
isFile(
|
|
1419
|
-
return FSHelpers.isFile(this[__private__dont__use].FS,
|
|
1434
|
+
isFile(t) {
|
|
1435
|
+
return FSHelpers.isFile(this[__private__dont__use].FS, t);
|
|
1420
1436
|
}
|
|
1421
1437
|
/**
|
|
1422
1438
|
* Creates a symlink in the PHP filesystem.
|
|
1423
1439
|
* @param target
|
|
1424
1440
|
* @param path
|
|
1425
1441
|
*/
|
|
1426
|
-
symlink(
|
|
1427
|
-
return FSHelpers.symlink(this[__private__dont__use].FS,
|
|
1442
|
+
symlink(t, e) {
|
|
1443
|
+
return FSHelpers.symlink(this[__private__dont__use].FS, t, e);
|
|
1428
1444
|
}
|
|
1429
1445
|
/**
|
|
1430
1446
|
* Checks if a path is a symlink in the PHP filesystem.
|
|
@@ -1432,8 +1448,8 @@ class PHP {
|
|
|
1432
1448
|
* @param path
|
|
1433
1449
|
* @returns True if the path is a symlink, false otherwise.
|
|
1434
1450
|
*/
|
|
1435
|
-
isSymlink(
|
|
1436
|
-
return FSHelpers.isSymlink(this[__private__dont__use].FS,
|
|
1451
|
+
isSymlink(t) {
|
|
1452
|
+
return FSHelpers.isSymlink(this[__private__dont__use].FS, t);
|
|
1437
1453
|
}
|
|
1438
1454
|
/**
|
|
1439
1455
|
* Reads the target of a symlink in the PHP filesystem.
|
|
@@ -1441,16 +1457,16 @@ class PHP {
|
|
|
1441
1457
|
* @param path
|
|
1442
1458
|
* @returns The target of the symlink.
|
|
1443
1459
|
*/
|
|
1444
|
-
readlink(
|
|
1445
|
-
return FSHelpers.readlink(this[__private__dont__use].FS,
|
|
1460
|
+
readlink(t) {
|
|
1461
|
+
return FSHelpers.readlink(this[__private__dont__use].FS, t);
|
|
1446
1462
|
}
|
|
1447
1463
|
/**
|
|
1448
1464
|
* Resolves the real path of a file in the PHP filesystem.
|
|
1449
1465
|
* @param path
|
|
1450
1466
|
* @returns The real path of the file.
|
|
1451
1467
|
*/
|
|
1452
|
-
realpath(
|
|
1453
|
-
return FSHelpers.realpath(this[__private__dont__use].FS,
|
|
1468
|
+
realpath(t) {
|
|
1469
|
+
return FSHelpers.realpath(this[__private__dont__use].FS, t);
|
|
1454
1470
|
}
|
|
1455
1471
|
/**
|
|
1456
1472
|
* Checks if a file (or a directory) exists in the PHP filesystem.
|
|
@@ -1458,8 +1474,8 @@ class PHP {
|
|
|
1458
1474
|
* @param path - The file path to check.
|
|
1459
1475
|
* @returns True if the file exists, false otherwise.
|
|
1460
1476
|
*/
|
|
1461
|
-
fileExists(
|
|
1462
|
-
return FSHelpers.fileExists(this[__private__dont__use].FS,
|
|
1477
|
+
fileExists(t) {
|
|
1478
|
+
return FSHelpers.fileExists(this[__private__dont__use].FS, t);
|
|
1463
1479
|
}
|
|
1464
1480
|
/**
|
|
1465
1481
|
* Hot-swaps the PHP runtime for a new one without
|
|
@@ -1471,17 +1487,17 @@ class PHP {
|
|
|
1471
1487
|
* is fully decoupled from the request handler and
|
|
1472
1488
|
* accepts a constructor-level cwd argument.
|
|
1473
1489
|
*/
|
|
1474
|
-
async hotSwapPHPRuntime(
|
|
1475
|
-
const
|
|
1476
|
-
for (const [
|
|
1477
|
-
s.push({ mountHandler:
|
|
1490
|
+
async hotSwapPHPRuntime(t, e) {
|
|
1491
|
+
const r = this[__private__dont__use].FS, s = [];
|
|
1492
|
+
for (const [n, i] of Object.entries(u(this, T)))
|
|
1493
|
+
s.push({ mountHandler: i.mountHandler, vfsPath: n }), await i.unmount();
|
|
1478
1494
|
try {
|
|
1479
1495
|
this.exit();
|
|
1480
1496
|
} catch {
|
|
1481
1497
|
}
|
|
1482
|
-
this.initializeRuntime(
|
|
1483
|
-
for (const { mountHandler:
|
|
1484
|
-
this.mkdir(
|
|
1498
|
+
this.initializeRuntime(t), u(this, k) && this.setSapiName(u(this, k)), copyFS(r, this[__private__dont__use].FS, "/internal"), e && copyFS(r, this[__private__dont__use].FS, e);
|
|
1499
|
+
for (const { mountHandler: n, vfsPath: i } of s)
|
|
1500
|
+
this.mkdir(i), await this.mount(i, n);
|
|
1485
1501
|
}
|
|
1486
1502
|
/**
|
|
1487
1503
|
* Mounts a filesystem to a given path in the PHP filesystem.
|
|
@@ -1490,18 +1506,18 @@ class PHP {
|
|
|
1490
1506
|
* @param mountHandler - The mount handler to use.
|
|
1491
1507
|
* @return Unmount function to unmount the filesystem.
|
|
1492
1508
|
*/
|
|
1493
|
-
async mount(
|
|
1494
|
-
const
|
|
1509
|
+
async mount(t, e) {
|
|
1510
|
+
const r = await e(
|
|
1495
1511
|
this,
|
|
1496
1512
|
this[__private__dont__use].FS,
|
|
1497
|
-
|
|
1513
|
+
t
|
|
1498
1514
|
), s = {
|
|
1499
1515
|
mountHandler: e,
|
|
1500
1516
|
unmount: async () => {
|
|
1501
|
-
await
|
|
1517
|
+
await r(), delete u(this, T)[t];
|
|
1502
1518
|
}
|
|
1503
1519
|
};
|
|
1504
|
-
return
|
|
1520
|
+
return u(this, T)[t] = s, () => {
|
|
1505
1521
|
s.unmount();
|
|
1506
1522
|
};
|
|
1507
1523
|
}
|
|
@@ -1518,45 +1534,54 @@ class PHP {
|
|
|
1518
1534
|
* @param argv - The arguments to pass to the CLI.
|
|
1519
1535
|
* @returns The exit code of the CLI session.
|
|
1520
1536
|
*/
|
|
1521
|
-
async cli(
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1537
|
+
async cli(t, e = {}) {
|
|
1538
|
+
if (this.cliCalled)
|
|
1539
|
+
throw new Error(
|
|
1540
|
+
"php.cli() can only be called once. The method sets a C-level global state that does not allow repeated calls."
|
|
1541
|
+
);
|
|
1542
|
+
if (this.runStreamCalled)
|
|
1543
|
+
throw new Error(
|
|
1544
|
+
"php.cli() can only be called if php.runStream() was not called before. The two methods set a conflicting C-level global state."
|
|
1545
|
+
);
|
|
1546
|
+
this.cliCalled = !0;
|
|
1547
|
+
const r = await this.semaphore.acquire(), s = e.env || {};
|
|
1548
|
+
for (const [n, i] of Object.entries(s))
|
|
1549
|
+
m(this, d, U).call(this, n, i);
|
|
1550
|
+
t = [t[0], "-c", PHP_INI_PATH, ...t.slice(1)];
|
|
1551
|
+
for (const n of t)
|
|
1527
1552
|
this[__private__dont__use].ccall(
|
|
1528
1553
|
"wasm_add_cli_arg",
|
|
1529
1554
|
null,
|
|
1530
1555
|
[STRING],
|
|
1531
|
-
[
|
|
1556
|
+
[n]
|
|
1532
1557
|
);
|
|
1533
|
-
return await
|
|
1558
|
+
return await m(this, d, O).call(this, () => this[__private__dont__use].ccall("run_cli", null, [], [], {
|
|
1534
1559
|
async: !0
|
|
1535
|
-
})).then((
|
|
1560
|
+
})).then((n) => (n.exitCode.finally(r), n));
|
|
1536
1561
|
}
|
|
1537
|
-
setSkipShebang(
|
|
1562
|
+
setSkipShebang(t) {
|
|
1538
1563
|
this[__private__dont__use].ccall(
|
|
1539
1564
|
"wasm_set_skip_shebang",
|
|
1540
1565
|
null,
|
|
1541
1566
|
[NUMBER],
|
|
1542
|
-
[
|
|
1567
|
+
[t ? 1 : 0]
|
|
1543
1568
|
);
|
|
1544
1569
|
}
|
|
1545
|
-
exit(
|
|
1570
|
+
exit(t = 0) {
|
|
1546
1571
|
this.dispatchEvent({
|
|
1547
1572
|
type: "runtime.beforedestroy"
|
|
1548
1573
|
});
|
|
1549
1574
|
try {
|
|
1550
|
-
this[__private__dont__use]._exit(
|
|
1575
|
+
this[__private__dont__use]._exit(t);
|
|
1551
1576
|
} catch {
|
|
1552
1577
|
}
|
|
1553
|
-
f(this,
|
|
1578
|
+
f(this, E, !1), f(this, x, null), this[__private__dont__use] && (delete this[__private__dont__use].onMessage, delete this[__private__dont__use]);
|
|
1554
1579
|
}
|
|
1555
1580
|
[Symbol.dispose]() {
|
|
1556
|
-
|
|
1581
|
+
u(this, E) && this.exit(0);
|
|
1557
1582
|
}
|
|
1558
1583
|
}
|
|
1559
|
-
|
|
1584
|
+
k = new WeakMap(), E = new WeakMap(), x = new WeakMap(), g = new WeakMap(), v = new WeakMap(), T = new WeakMap(), d = new WeakSet(), /**
|
|
1560
1585
|
* Prepares the $_SERVER entries for the PHP runtime.
|
|
1561
1586
|
*
|
|
1562
1587
|
* @param defaults Default entries to include in $_SERVER.
|
|
@@ -1565,90 +1590,92 @@ T = new WeakMap(), _ = new WeakMap(), H = new WeakMap(), P = new WeakMap(), R =
|
|
|
1565
1590
|
* was provided.
|
|
1566
1591
|
* @returns Computed $_SERVER entries.
|
|
1567
1592
|
*/
|
|
1568
|
-
z = function(
|
|
1593
|
+
z = function(t, e, r) {
|
|
1569
1594
|
const s = {
|
|
1570
|
-
...
|
|
1595
|
+
...t || {}
|
|
1571
1596
|
};
|
|
1572
|
-
s.HTTPS = s.HTTPS ||
|
|
1573
|
-
for (const
|
|
1574
|
-
let
|
|
1575
|
-
["content-type", "content-length"].includes(
|
|
1597
|
+
s.HTTPS = s.HTTPS || r === 443 ? "on" : "off";
|
|
1598
|
+
for (const n in e) {
|
|
1599
|
+
let i = "HTTP_";
|
|
1600
|
+
["content-type", "content-length"].includes(n.toLowerCase()) && (i = ""), s[`${i}${n.toUpperCase().replace(/-/g, "_")}`] = e[n];
|
|
1576
1601
|
}
|
|
1577
1602
|
return s;
|
|
1578
|
-
},
|
|
1579
|
-
this[__private__dont__use].ccall("php_wasm_init", null, [], []
|
|
1580
|
-
|
|
1603
|
+
}, W = function() {
|
|
1604
|
+
return this[__private__dont__use].ccall("php_wasm_init", null, [], [], {
|
|
1605
|
+
isAsync: !0
|
|
1606
|
+
});
|
|
1607
|
+
}, B = function(t) {
|
|
1581
1608
|
this[__private__dont__use].ccall(
|
|
1582
1609
|
"wasm_set_request_uri",
|
|
1583
1610
|
null,
|
|
1584
1611
|
[STRING],
|
|
1585
|
-
[
|
|
1612
|
+
[t]
|
|
1586
1613
|
);
|
|
1587
1614
|
let e = "";
|
|
1588
|
-
|
|
1615
|
+
t.includes("?") && (e = t.substring(t.indexOf("?") + 1)), this[__private__dont__use].ccall(
|
|
1589
1616
|
"wasm_set_query_string",
|
|
1590
1617
|
null,
|
|
1591
1618
|
[STRING],
|
|
1592
1619
|
[e]
|
|
1593
1620
|
);
|
|
1594
|
-
},
|
|
1621
|
+
}, $ = function(t) {
|
|
1595
1622
|
this[__private__dont__use].ccall(
|
|
1596
1623
|
"wasm_set_request_host",
|
|
1597
1624
|
null,
|
|
1598
1625
|
[STRING],
|
|
1599
|
-
[
|
|
1626
|
+
[t]
|
|
1600
1627
|
);
|
|
1601
|
-
}, V = function(
|
|
1628
|
+
}, V = function(t) {
|
|
1602
1629
|
this[__private__dont__use].ccall(
|
|
1603
1630
|
"wasm_set_request_port",
|
|
1604
1631
|
null,
|
|
1605
1632
|
[NUMBER],
|
|
1606
|
-
[
|
|
1633
|
+
[t]
|
|
1607
1634
|
);
|
|
1608
|
-
},
|
|
1609
|
-
let
|
|
1635
|
+
}, G = function(t, e) {
|
|
1636
|
+
let r;
|
|
1610
1637
|
try {
|
|
1611
|
-
|
|
1638
|
+
r = parseInt(new URL(t).port, 10);
|
|
1612
1639
|
} catch {
|
|
1613
1640
|
}
|
|
1614
|
-
return (!
|
|
1615
|
-
},
|
|
1641
|
+
return (!r || isNaN(r) || r === 80) && (r = e === "https" ? 443 : 80), r;
|
|
1642
|
+
}, J = function(t) {
|
|
1616
1643
|
this[__private__dont__use].ccall(
|
|
1617
1644
|
"wasm_set_request_method",
|
|
1618
1645
|
null,
|
|
1619
1646
|
[STRING],
|
|
1620
|
-
[
|
|
1647
|
+
[t]
|
|
1621
1648
|
);
|
|
1622
|
-
},
|
|
1623
|
-
|
|
1649
|
+
}, Y = function(t) {
|
|
1650
|
+
t.cookie && this[__private__dont__use].ccall(
|
|
1624
1651
|
"wasm_set_cookies",
|
|
1625
1652
|
null,
|
|
1626
1653
|
[STRING],
|
|
1627
|
-
[
|
|
1628
|
-
),
|
|
1654
|
+
[t.cookie]
|
|
1655
|
+
), t["content-type"] && this[__private__dont__use].ccall(
|
|
1629
1656
|
"wasm_set_content_type",
|
|
1630
1657
|
null,
|
|
1631
1658
|
[STRING],
|
|
1632
|
-
[
|
|
1633
|
-
),
|
|
1659
|
+
[t["content-type"]]
|
|
1660
|
+
), t["content-length"] && this[__private__dont__use].ccall(
|
|
1634
1661
|
"wasm_set_content_length",
|
|
1635
1662
|
null,
|
|
1636
1663
|
[NUMBER],
|
|
1637
|
-
[parseInt(
|
|
1664
|
+
[parseInt(t["content-length"], 10)]
|
|
1638
1665
|
);
|
|
1639
|
-
},
|
|
1640
|
-
let e,
|
|
1641
|
-
typeof
|
|
1666
|
+
}, K = function(t) {
|
|
1667
|
+
let e, r;
|
|
1668
|
+
typeof t == "string" ? (logger.warn(
|
|
1642
1669
|
"Passing a string as the request body is deprecated. Please use a Uint8Array instead. See https://github.com/WordPress/wordpress-playground/issues/997 for more details"
|
|
1643
|
-
),
|
|
1670
|
+
), r = this[__private__dont__use].lengthBytesUTF8(t), e = r + 1) : (r = t.byteLength, e = t.byteLength);
|
|
1644
1671
|
const s = this[__private__dont__use].malloc(e);
|
|
1645
1672
|
if (!s)
|
|
1646
1673
|
throw new Error("Could not allocate memory for the request body.");
|
|
1647
|
-
return typeof
|
|
1648
|
-
|
|
1674
|
+
return typeof t == "string" ? this[__private__dont__use].stringToUTF8(
|
|
1675
|
+
t,
|
|
1649
1676
|
s,
|
|
1650
1677
|
e + 1
|
|
1651
|
-
) : this[__private__dont__use].HEAPU8.set(
|
|
1678
|
+
) : this[__private__dont__use].HEAPU8.set(t, s), this[__private__dont__use].ccall(
|
|
1652
1679
|
"wasm_set_request_body",
|
|
1653
1680
|
null,
|
|
1654
1681
|
[NUMBER],
|
|
@@ -1657,221 +1684,268 @@ z = function(r, e, t) {
|
|
|
1657
1684
|
"wasm_set_content_length",
|
|
1658
1685
|
null,
|
|
1659
1686
|
[NUMBER],
|
|
1660
|
-
[
|
|
1687
|
+
[r]
|
|
1661
1688
|
), s;
|
|
1662
|
-
},
|
|
1689
|
+
}, L = function(t) {
|
|
1663
1690
|
this[__private__dont__use].ccall(
|
|
1664
1691
|
"wasm_set_path_translated",
|
|
1665
1692
|
null,
|
|
1666
1693
|
[STRING],
|
|
1667
|
-
[
|
|
1694
|
+
[t]
|
|
1668
1695
|
);
|
|
1669
|
-
},
|
|
1696
|
+
}, X = function(t, e) {
|
|
1670
1697
|
this[__private__dont__use].ccall(
|
|
1671
1698
|
"wasm_add_SERVER_entry",
|
|
1672
1699
|
null,
|
|
1673
1700
|
[STRING, STRING],
|
|
1674
|
-
[
|
|
1701
|
+
[t, e]
|
|
1675
1702
|
);
|
|
1676
|
-
},
|
|
1703
|
+
}, U = function(t, e) {
|
|
1677
1704
|
this[__private__dont__use].ccall(
|
|
1678
1705
|
"wasm_add_ENV_entry",
|
|
1679
1706
|
null,
|
|
1680
1707
|
[STRING, STRING],
|
|
1681
|
-
[
|
|
1708
|
+
[t, e]
|
|
1682
1709
|
);
|
|
1683
|
-
},
|
|
1684
|
-
const e = this[__private__dont__use],
|
|
1685
|
-
e.onHeaders = (
|
|
1686
|
-
a || s ||
|
|
1710
|
+
}, O = async function(t) {
|
|
1711
|
+
const e = this[__private__dont__use], r = await createInvertedReadableStream();
|
|
1712
|
+
e.onHeaders = (h) => {
|
|
1713
|
+
a || s || r.controller.enqueue(h.slice());
|
|
1687
1714
|
};
|
|
1688
1715
|
let s = !1;
|
|
1689
|
-
const
|
|
1690
|
-
s || (s = !0,
|
|
1691
|
-
},
|
|
1692
|
-
e.onStdout = (
|
|
1693
|
-
|
|
1716
|
+
const n = () => {
|
|
1717
|
+
s || (s = !0, r.controller.close());
|
|
1718
|
+
}, i = await createInvertedReadableStream();
|
|
1719
|
+
e.onStdout = (h) => {
|
|
1720
|
+
n(), !a && i.controller.enqueue(h.slice());
|
|
1694
1721
|
};
|
|
1695
1722
|
const o = await createInvertedReadableStream();
|
|
1696
|
-
e.onStderr = (
|
|
1697
|
-
a || o.controller.enqueue(
|
|
1723
|
+
e.onStderr = (h) => {
|
|
1724
|
+
a || o.controller.enqueue(h.slice());
|
|
1698
1725
|
};
|
|
1699
1726
|
let a = !1, l;
|
|
1700
|
-
const
|
|
1701
|
-
var
|
|
1727
|
+
const p = (async () => {
|
|
1728
|
+
var h;
|
|
1702
1729
|
try {
|
|
1703
1730
|
return await Promise.race([
|
|
1704
|
-
|
|
1705
|
-
new Promise((
|
|
1706
|
-
var
|
|
1707
|
-
l = (
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
j.cause = w.error, j.betterMessage = w.message, U(j);
|
|
1711
|
-
}
|
|
1712
|
-
}, (b = c(this, H)) == null || b.addEventListener(
|
|
1731
|
+
t(),
|
|
1732
|
+
new Promise((w, b) => {
|
|
1733
|
+
var j;
|
|
1734
|
+
l = (D) => {
|
|
1735
|
+
isExitCode(D.error) || b(D.error);
|
|
1736
|
+
}, (j = u(this, x)) == null || j.addEventListener(
|
|
1713
1737
|
"error",
|
|
1714
1738
|
l,
|
|
1715
1739
|
{ once: !0 }
|
|
1716
1740
|
);
|
|
1717
1741
|
})
|
|
1718
1742
|
]);
|
|
1719
|
-
} catch (
|
|
1720
|
-
if (isExitCode(
|
|
1721
|
-
return
|
|
1722
|
-
|
|
1743
|
+
} catch (y) {
|
|
1744
|
+
if (isExitCode(y))
|
|
1745
|
+
return y.status;
|
|
1746
|
+
i.controller.error(y), o.controller.error(y), r.controller.error(y), a = !0;
|
|
1723
1747
|
for (const w in this)
|
|
1724
1748
|
typeof this[w] == "function" && (this[w] = () => {
|
|
1725
1749
|
throw new Error(
|
|
1726
1750
|
"PHP runtime has crashed – see the earlier error for details."
|
|
1727
1751
|
);
|
|
1728
1752
|
});
|
|
1729
|
-
this.functionsMaybeMissingFromAsyncify = getFunctionsMaybeMissingFromAsyncify();
|
|
1730
|
-
const N = S, U = "betterMessage" in N ? N.betterMessage : N.message, b = new Error(U);
|
|
1731
|
-
throw b.cause = N, logger.error(b), b;
|
|
1753
|
+
throw this.functionsMaybeMissingFromAsyncify = getFunctionsMaybeMissingFromAsyncify(), y;
|
|
1732
1754
|
} finally {
|
|
1733
|
-
a || (
|
|
1755
|
+
a || (i.controller.close(), o.controller.close(), n(), a = !0), (h = u(this, x)) == null || h.removeEventListener(
|
|
1734
1756
|
"error",
|
|
1735
1757
|
l
|
|
1736
1758
|
);
|
|
1737
1759
|
}
|
|
1738
1760
|
})();
|
|
1739
1761
|
return new StreamedPHPResponse(
|
|
1740
|
-
|
|
1741
|
-
|
|
1762
|
+
r.stream,
|
|
1763
|
+
i.stream,
|
|
1742
1764
|
o.stream,
|
|
1743
|
-
|
|
1765
|
+
p
|
|
1744
1766
|
);
|
|
1745
1767
|
};
|
|
1746
|
-
function normalizeHeaders(
|
|
1768
|
+
function normalizeHeaders(t) {
|
|
1747
1769
|
const e = {};
|
|
1748
|
-
for (const
|
|
1749
|
-
e[
|
|
1770
|
+
for (const r in t)
|
|
1771
|
+
e[r.toLowerCase()] = t[r];
|
|
1750
1772
|
return e;
|
|
1751
1773
|
}
|
|
1752
|
-
function copyFS(
|
|
1774
|
+
function copyFS(t, e, r) {
|
|
1753
1775
|
let s;
|
|
1754
1776
|
try {
|
|
1755
|
-
s =
|
|
1777
|
+
s = t.lookupPath(r);
|
|
1756
1778
|
} catch {
|
|
1757
1779
|
return;
|
|
1758
1780
|
}
|
|
1759
1781
|
if (!("contents" in s.node))
|
|
1760
1782
|
return;
|
|
1761
|
-
if (!
|
|
1762
|
-
e.writeFile(
|
|
1783
|
+
if (!t.isDir(s.node.mode)) {
|
|
1784
|
+
e.writeFile(r, t.readFile(r));
|
|
1763
1785
|
return;
|
|
1764
1786
|
}
|
|
1765
|
-
e.mkdirTree(
|
|
1766
|
-
const
|
|
1767
|
-
for (const
|
|
1768
|
-
copyFS(
|
|
1787
|
+
e.mkdirTree(r);
|
|
1788
|
+
const n = t.readdir(r).filter((i) => i !== "." && i !== "..");
|
|
1789
|
+
for (const i of n)
|
|
1790
|
+
copyFS(t, e, joinPaths(r, i));
|
|
1769
1791
|
}
|
|
1770
|
-
async function createInvertedReadableStream(
|
|
1792
|
+
async function createInvertedReadableStream(t = {}) {
|
|
1771
1793
|
let e;
|
|
1772
|
-
const
|
|
1773
|
-
(
|
|
1774
|
-
e =
|
|
1794
|
+
const r = new Promise(
|
|
1795
|
+
(i) => {
|
|
1796
|
+
e = i;
|
|
1775
1797
|
}
|
|
1776
1798
|
), s = new ReadableStream({
|
|
1777
|
-
...
|
|
1778
|
-
start(
|
|
1779
|
-
if (e(
|
|
1780
|
-
return
|
|
1799
|
+
...t,
|
|
1800
|
+
start(i) {
|
|
1801
|
+
if (e(i), t.start)
|
|
1802
|
+
return t.start(i);
|
|
1781
1803
|
}
|
|
1782
|
-
}),
|
|
1804
|
+
}), n = await r;
|
|
1783
1805
|
return {
|
|
1784
1806
|
stream: s,
|
|
1785
|
-
controller:
|
|
1807
|
+
controller: n
|
|
1786
1808
|
};
|
|
1787
1809
|
}
|
|
1788
|
-
async function getPhpIniEntries(
|
|
1789
|
-
const
|
|
1810
|
+
async function getPhpIniEntries(t, e) {
|
|
1811
|
+
const r = parse(await t.readFileAsText(PHP_INI_PATH));
|
|
1790
1812
|
if (e === void 0)
|
|
1791
|
-
return
|
|
1813
|
+
return r;
|
|
1792
1814
|
const s = {};
|
|
1793
|
-
for (const
|
|
1794
|
-
s[
|
|
1815
|
+
for (const n of e)
|
|
1816
|
+
s[n] = r[n];
|
|
1795
1817
|
return s;
|
|
1796
1818
|
}
|
|
1797
|
-
async function setPhpIniEntries(
|
|
1798
|
-
const
|
|
1799
|
-
for (const [s,
|
|
1800
|
-
|
|
1801
|
-
await
|
|
1819
|
+
async function setPhpIniEntries(t, e) {
|
|
1820
|
+
const r = parse(await t.readFileAsText(PHP_INI_PATH));
|
|
1821
|
+
for (const [s, n] of Object.entries(e))
|
|
1822
|
+
n == null ? delete r[s] : r[s] = n;
|
|
1823
|
+
await t.writeFile(PHP_INI_PATH, stringify(r));
|
|
1802
1824
|
}
|
|
1803
|
-
async function withPHPIniValues(
|
|
1804
|
-
const s = await
|
|
1825
|
+
async function withPHPIniValues(t, e, r) {
|
|
1826
|
+
const s = await t.readFileAsText(PHP_INI_PATH);
|
|
1805
1827
|
try {
|
|
1806
|
-
return await setPhpIniEntries(
|
|
1828
|
+
return await setPhpIniEntries(t, e), await r();
|
|
1807
1829
|
} finally {
|
|
1808
|
-
await
|
|
1830
|
+
await t.writeFile(PHP_INI_PATH, s);
|
|
1809
1831
|
}
|
|
1810
1832
|
}
|
|
1833
|
+
async function printDebugDetails(t, e) {
|
|
1834
|
+
e && printResponseDebugDetails(
|
|
1835
|
+
await PHPResponse.fromStreamedResponse(e)
|
|
1836
|
+
), await prettyPrintFullStackTrace(t);
|
|
1837
|
+
}
|
|
1838
|
+
async function prettyPrintFullStackTrace(t) {
|
|
1839
|
+
let e = t, r = !0;
|
|
1840
|
+
for (; e; )
|
|
1841
|
+
r || process.stderr.write(`
|
|
1842
|
+
Caused by:
|
|
1843
|
+
|
|
1844
|
+
`), process.stderr.write(e.originalErrorClassName ?? e.name), process.stderr.write(": " + e.message + `
|
|
1845
|
+
`), process.stderr.write(
|
|
1846
|
+
(e.stack + "").split(`
|
|
1847
|
+
`).slice(1).join(`
|
|
1848
|
+
`)
|
|
1849
|
+
), process.stderr.write(`
|
|
1850
|
+
`), e.response && printResponseDebugDetails(e.response), e.phpLogs && (process.stderr.write(`
|
|
1851
|
+
|
|
1852
|
+
==== PHP error log ====
|
|
1853
|
+
|
|
1854
|
+
`), process.stderr.write(e.phpLogs)), e = e.cause, r = !1;
|
|
1855
|
+
process.stderr.write(`
|
|
1856
|
+
`);
|
|
1857
|
+
}
|
|
1858
|
+
function printResponseDebugDetails(t) {
|
|
1859
|
+
process.stderr.write(
|
|
1860
|
+
`
|
|
1861
|
+
exitCode=${t.exitCode} httpStatusCode=${t.httpStatusCode} `
|
|
1862
|
+
);
|
|
1863
|
+
const e = t.headers && Object.keys(t.headers).length > 0;
|
|
1864
|
+
e || process.stderr.write("responseHeaders=(empty) "), t.text || process.stderr.write("stdout=(empty) "), t.errors || process.stderr.write("stderr=(empty) "), process.stderr.write(`
|
|
1865
|
+
`), e && process.stderr.write(
|
|
1866
|
+
`
|
|
1867
|
+
==== PHP response headers ====
|
|
1868
|
+
|
|
1869
|
+
${JSON.stringify(
|
|
1870
|
+
t.headers,
|
|
1871
|
+
null,
|
|
1872
|
+
2
|
|
1873
|
+
)}
|
|
1874
|
+
|
|
1875
|
+
`
|
|
1876
|
+
), t.text && (process.stderr.write(`
|
|
1877
|
+
==== PHP stdout ====
|
|
1878
|
+
|
|
1879
|
+
`), process.stderr.write(t.text)), t.errors && (process.stderr.write(`
|
|
1880
|
+
==== PHP stderr ====
|
|
1881
|
+
|
|
1882
|
+
`), process.stderr.write(t.errors)), process.stderr.write(`
|
|
1883
|
+
`);
|
|
1884
|
+
}
|
|
1811
1885
|
class HttpCookieStore {
|
|
1812
1886
|
constructor() {
|
|
1813
1887
|
this.cookies = {};
|
|
1814
1888
|
}
|
|
1815
1889
|
rememberCookiesFromResponseHeaders(e) {
|
|
1816
1890
|
if (e != null && e["set-cookie"])
|
|
1817
|
-
for (const
|
|
1891
|
+
for (const r of e["set-cookie"])
|
|
1818
1892
|
try {
|
|
1819
|
-
if (!
|
|
1893
|
+
if (!r.includes("="))
|
|
1820
1894
|
continue;
|
|
1821
|
-
const s =
|
|
1822
|
-
this.cookies[
|
|
1895
|
+
const s = r.indexOf("="), n = r.substring(0, s), i = r.substring(s + 1).split(";")[0];
|
|
1896
|
+
this.cookies[n] = i;
|
|
1823
1897
|
} catch (s) {
|
|
1824
1898
|
logger.error(s);
|
|
1825
1899
|
}
|
|
1826
1900
|
}
|
|
1827
1901
|
getCookieRequestHeader() {
|
|
1828
1902
|
const e = [];
|
|
1829
|
-
for (const
|
|
1830
|
-
e.push(`${
|
|
1903
|
+
for (const r in this.cookies)
|
|
1904
|
+
e.push(`${r}=${this.cookies[r]}`);
|
|
1831
1905
|
return e.join("; ");
|
|
1832
1906
|
}
|
|
1833
1907
|
}
|
|
1834
|
-
function streamReadFileFromPHP(
|
|
1908
|
+
function streamReadFileFromPHP(t, e) {
|
|
1835
1909
|
return new ReadableStream({
|
|
1836
|
-
async pull(
|
|
1837
|
-
const s = await
|
|
1838
|
-
|
|
1910
|
+
async pull(r) {
|
|
1911
|
+
const s = await t.readFileAsBuffer(e);
|
|
1912
|
+
r.enqueue(s), r.close();
|
|
1839
1913
|
}
|
|
1840
1914
|
});
|
|
1841
1915
|
}
|
|
1842
|
-
async function* iteratePhpFiles(
|
|
1843
|
-
relativePaths:
|
|
1916
|
+
async function* iteratePhpFiles(t, e, {
|
|
1917
|
+
relativePaths: r = !0,
|
|
1844
1918
|
pathPrefix: s,
|
|
1845
|
-
exceptPaths:
|
|
1919
|
+
exceptPaths: n = []
|
|
1846
1920
|
} = {}) {
|
|
1847
1921
|
e = normalizePath(e);
|
|
1848
|
-
const
|
|
1849
|
-
for (;
|
|
1850
|
-
const o =
|
|
1922
|
+
const i = [e];
|
|
1923
|
+
for (; i.length; ) {
|
|
1924
|
+
const o = i.pop();
|
|
1851
1925
|
if (!o)
|
|
1852
1926
|
return;
|
|
1853
|
-
const a = await
|
|
1927
|
+
const a = await t.listFiles(o);
|
|
1854
1928
|
for (const l of a) {
|
|
1855
|
-
const
|
|
1856
|
-
if (
|
|
1929
|
+
const c = `${o}/${l}`;
|
|
1930
|
+
if (n.includes(c.substring(e.length + 1)))
|
|
1857
1931
|
continue;
|
|
1858
|
-
await
|
|
1859
|
-
streamReadFileFromPHP(
|
|
1860
|
-
|
|
1932
|
+
await t.isDir(c) ? i.push(c) : yield new StreamedFile(
|
|
1933
|
+
streamReadFileFromPHP(t, c),
|
|
1934
|
+
r ? joinPaths(
|
|
1861
1935
|
s || "",
|
|
1862
|
-
|
|
1863
|
-
) :
|
|
1936
|
+
c.substring(e.length + 1)
|
|
1937
|
+
) : c
|
|
1864
1938
|
);
|
|
1865
1939
|
}
|
|
1866
1940
|
}
|
|
1867
1941
|
}
|
|
1868
|
-
function writeFilesStreamToPhp(
|
|
1942
|
+
function writeFilesStreamToPhp(t, e) {
|
|
1869
1943
|
return new WritableStream({
|
|
1870
|
-
async write(
|
|
1871
|
-
const s = joinPaths(e,
|
|
1872
|
-
|
|
1944
|
+
async write(r) {
|
|
1945
|
+
const s = joinPaths(e, r.name);
|
|
1946
|
+
r.type === "directory" ? await t.mkdir(s) : (await t.mkdir(dirname(s)), await t.writeFile(
|
|
1873
1947
|
s,
|
|
1874
|
-
new Uint8Array(await
|
|
1948
|
+
new Uint8Array(await r.arrayBuffer())
|
|
1875
1949
|
));
|
|
1876
1950
|
}
|
|
1877
1951
|
});
|
|
@@ -1931,7 +2005,7 @@ class PHPProcessManager {
|
|
|
1931
2005
|
* and the waiting timeout is exceeded.
|
|
1932
2006
|
*/
|
|
1933
2007
|
async acquirePHPInstance({
|
|
1934
|
-
considerPrimary: e = !
|
|
2008
|
+
considerPrimary: e = !1
|
|
1935
2009
|
} = {}) {
|
|
1936
2010
|
if (this.primaryPhp || await this.getPrimaryPhp(), this.primaryIdle && e)
|
|
1937
2011
|
return this.primaryIdle = !1, {
|
|
@@ -1940,8 +2014,8 @@ class PHPProcessManager {
|
|
|
1940
2014
|
this.primaryIdle = !0;
|
|
1941
2015
|
}
|
|
1942
2016
|
};
|
|
1943
|
-
const
|
|
1944
|
-
return this.semaphore.remaining > 0 ? this.nextInstance = this.spawn({ isPrimary: !1 }) : this.nextInstance = null, await
|
|
2017
|
+
const r = this.nextInstance || this.spawn({ isPrimary: !1 });
|
|
2018
|
+
return this.semaphore.remaining > 0 ? this.nextInstance = this.spawn({ isPrimary: !1 }) : this.nextInstance = null, await r;
|
|
1945
2019
|
}
|
|
1946
2020
|
/**
|
|
1947
2021
|
* Initiated spawning of a new PHP instance.
|
|
@@ -1950,23 +2024,23 @@ class PHPProcessManager {
|
|
|
1950
2024
|
* for PHP to spawn.
|
|
1951
2025
|
*/
|
|
1952
2026
|
spawn(e) {
|
|
1953
|
-
if (e.isPrimary && this.
|
|
2027
|
+
if (e.isPrimary && this.allInstances.length > 0)
|
|
1954
2028
|
throw new Error(
|
|
1955
2029
|
"Requested spawning a primary PHP instance when another primary instance already started spawning."
|
|
1956
2030
|
);
|
|
1957
|
-
const
|
|
1958
|
-
this.allInstances.push(
|
|
2031
|
+
const r = this.doSpawn(e);
|
|
2032
|
+
this.allInstances.push(r);
|
|
1959
2033
|
const s = () => {
|
|
1960
2034
|
this.allInstances = this.allInstances.filter(
|
|
1961
|
-
(
|
|
2035
|
+
(n) => n !== r
|
|
1962
2036
|
);
|
|
1963
2037
|
};
|
|
1964
|
-
return
|
|
1965
|
-
throw s(),
|
|
1966
|
-
}).then((
|
|
1967
|
-
...
|
|
2038
|
+
return r.catch((n) => {
|
|
2039
|
+
throw s(), n;
|
|
2040
|
+
}).then((n) => ({
|
|
2041
|
+
...n,
|
|
1968
2042
|
reap: () => {
|
|
1969
|
-
s(),
|
|
2043
|
+
s(), n.reap();
|
|
1970
2044
|
}
|
|
1971
2045
|
}));
|
|
1972
2046
|
}
|
|
@@ -1974,9 +2048,9 @@ class PHPProcessManager {
|
|
|
1974
2048
|
* Actually acquires the lock and spawns a new PHP instance.
|
|
1975
2049
|
*/
|
|
1976
2050
|
async doSpawn(e) {
|
|
1977
|
-
let
|
|
2051
|
+
let r;
|
|
1978
2052
|
try {
|
|
1979
|
-
|
|
2053
|
+
r = await this.semaphore.acquire();
|
|
1980
2054
|
} catch (s) {
|
|
1981
2055
|
throw s instanceof AcquireTimeoutError ? new MaxPhpInstancesError(this.maxPhpInstances) : s;
|
|
1982
2056
|
}
|
|
@@ -1985,17 +2059,17 @@ class PHPProcessManager {
|
|
|
1985
2059
|
return {
|
|
1986
2060
|
php: s,
|
|
1987
2061
|
reap() {
|
|
1988
|
-
s.exit(),
|
|
2062
|
+
s.exit(), r();
|
|
1989
2063
|
}
|
|
1990
2064
|
};
|
|
1991
2065
|
} catch (s) {
|
|
1992
|
-
throw
|
|
2066
|
+
throw r(), s;
|
|
1993
2067
|
}
|
|
1994
2068
|
}
|
|
1995
2069
|
async [Symbol.asyncDispose]() {
|
|
1996
2070
|
this.primaryPhp && this.primaryPhp.exit(), await Promise.all(
|
|
1997
2071
|
this.allInstances.map(
|
|
1998
|
-
(e) => e.then(({ reap:
|
|
2072
|
+
(e) => e.then(({ reap: r }) => r())
|
|
1999
2073
|
)
|
|
2000
2074
|
);
|
|
2001
2075
|
}
|
|
@@ -2010,37 +2084,37 @@ const SupportedPHPVersions = [
|
|
|
2010
2084
|
"7.3",
|
|
2011
2085
|
"7.2"
|
|
2012
2086
|
], LatestSupportedPHPVersion = SupportedPHPVersions[0], SupportedPHPVersionsList = SupportedPHPVersions, DEFAULT_BASE_URL = "http://example.com";
|
|
2013
|
-
function toRelativeUrl(
|
|
2014
|
-
return
|
|
2015
|
-
}
|
|
2016
|
-
function removePathPrefix(
|
|
2017
|
-
return !e || !
|
|
2018
|
-
}
|
|
2019
|
-
function ensurePathPrefix(
|
|
2020
|
-
return !e ||
|
|
2021
|
-
}
|
|
2022
|
-
async function encodeAsMultipart(
|
|
2023
|
-
const e = `----${Math.random().toString(36).slice(2)}`,
|
|
2024
|
-
for (const [l,
|
|
2025
|
-
|
|
2026
|
-
`),
|
|
2027
|
-
`),
|
|
2028
|
-
`)),
|
|
2029
|
-
`),
|
|
2087
|
+
function toRelativeUrl(t) {
|
|
2088
|
+
return t.toString().substring(t.origin.length);
|
|
2089
|
+
}
|
|
2090
|
+
function removePathPrefix(t, e) {
|
|
2091
|
+
return !e || !t.startsWith(e) ? t : t.substring(e.length);
|
|
2092
|
+
}
|
|
2093
|
+
function ensurePathPrefix(t, e) {
|
|
2094
|
+
return !e || t.startsWith(e) ? t : e + t;
|
|
2095
|
+
}
|
|
2096
|
+
async function encodeAsMultipart(t) {
|
|
2097
|
+
const e = `----${Math.random().toString(36).slice(2)}`, r = `multipart/form-data; boundary=${e}`, s = new TextEncoder(), n = [];
|
|
2098
|
+
for (const [l, c] of Object.entries(t))
|
|
2099
|
+
n.push(`--${e}\r
|
|
2100
|
+
`), n.push(`Content-Disposition: form-data; name="${l}"`), c instanceof File && n.push(`; filename="${c.name}"`), n.push(`\r
|
|
2101
|
+
`), c instanceof File && (n.push("Content-Type: application/octet-stream"), n.push(`\r
|
|
2102
|
+
`)), n.push(`\r
|
|
2103
|
+
`), c instanceof File ? n.push(await fileToUint8Array(c)) : n.push(c), n.push(`\r
|
|
2030
2104
|
`);
|
|
2031
|
-
|
|
2105
|
+
n.push(`--${e}--\r
|
|
2032
2106
|
`);
|
|
2033
|
-
const
|
|
2107
|
+
const i = n.reduce((l, c) => l + c.length, 0), o = new Uint8Array(i);
|
|
2034
2108
|
let a = 0;
|
|
2035
|
-
for (const l of
|
|
2109
|
+
for (const l of n)
|
|
2036
2110
|
o.set(
|
|
2037
2111
|
typeof l == "string" ? s.encode(l) : l,
|
|
2038
2112
|
a
|
|
2039
2113
|
), a += l.length;
|
|
2040
|
-
return { bytes: o, contentType:
|
|
2114
|
+
return { bytes: o, contentType: r };
|
|
2041
2115
|
}
|
|
2042
|
-
function fileToUint8Array(
|
|
2043
|
-
return
|
|
2116
|
+
function fileToUint8Array(t) {
|
|
2117
|
+
return t.arrayBuffer().then((e) => new Uint8Array(e));
|
|
2044
2118
|
}
|
|
2045
2119
|
const _default = "application/octet-stream", asx = "video/x-ms-asf", atom = "application/atom+xml", avi = "video/x-msvideo", avif = "image/avif", bin = "application/octet-stream", bmp = "image/x-ms-bmp", cco = "application/x-cocoa", css = "text/css", data = "application/octet-stream", deb = "application/octet-stream", der = "application/x-x509-ca-cert", dmg = "application/octet-stream", doc = "application/msword", docx = "application/vnd.openxmlformats-officedocument.wordprocessingml.document", eot = "application/vnd.ms-fontobject", flv = "video/x-flv", gif = "image/gif", gz = "application/gzip", hqx = "application/mac-binhex40", htc = "text/x-component", html = "text/html", ico = "image/x-icon", iso = "application/octet-stream", jad = "text/vnd.sun.j2me.app-descriptor", jar = "application/java-archive", jardiff = "application/x-java-archive-diff", jng = "image/x-jng", jnlp = "application/x-java-jnlp-file", jpg = "image/jpeg", jpeg = "image/jpeg", js = "application/javascript", json = "application/json", kml = "application/vnd.google-earth.kml+xml", kmz = "application/vnd.google-earth.kmz", m3u8 = "application/vnd.apple.mpegurl", m4a = "audio/x-m4a", m4v = "video/x-m4v", md = "text/plain", mid = "audio/midi", mml = "text/mathml", mng = "video/x-mng", mov = "video/quicktime", mp3 = "audio/mpeg", mp4 = "video/mp4", mpeg = "video/mpeg", msi = "application/octet-stream", odg = "application/vnd.oasis.opendocument.graphics", odp = "application/vnd.oasis.opendocument.presentation", ods = "application/vnd.oasis.opendocument.spreadsheet", odt = "application/vnd.oasis.opendocument.text", ogg = "audio/ogg", otf = "font/otf", pdf = "application/pdf", pl = "application/x-perl", png = "image/png", ppt = "application/vnd.ms-powerpoint", pptx = "application/vnd.openxmlformats-officedocument.presentationml.presentation", prc = "application/x-pilot", ps = "application/postscript", ra = "audio/x-realaudio", rar = "application/x-rar-compressed", rpm = "application/x-redhat-package-manager", rss = "application/rss+xml", rtf = "application/rtf", run = "application/x-makeself", sea = "application/x-sea", sit = "application/x-stuffit", svg = "image/svg+xml", swf = "application/x-shockwave-flash", tcl = "application/x-tcl", tar = "application/x-tar", tif = "image/tiff", ts = "video/mp2t", ttf = "font/ttf", txt = "text/plain", wasm = "application/wasm", wbmp = "image/vnd.wap.wbmp", webm = "video/webm", webp = "image/webp", wml = "text/vnd.wap.wml", wmlc = "application/vnd.wap.wmlc", wmv = "video/x-ms-wmv", woff = "font/woff", woff2 = "font/woff2", xhtml = "application/xhtml+xml", xls = "application/vnd.ms-excel", xlsx = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", xml = "text/xml", xpi = "application/x-xpinstall", xspf = "application/xspf+xml", zip = "application/zip", mimeTypes = {
|
|
2046
2120
|
_default,
|
|
@@ -2138,7 +2212,7 @@ const _default = "application/octet-stream", asx = "video/x-ms-asf", atom = "app
|
|
|
2138
2212
|
xspf,
|
|
2139
2213
|
zip
|
|
2140
2214
|
};
|
|
2141
|
-
var
|
|
2215
|
+
var S, C, A, F, I, P, M, R, H, Q, Z, ee;
|
|
2142
2216
|
class PHPRequestHandler {
|
|
2143
2217
|
/**
|
|
2144
2218
|
* The request handler needs to decide whether to serve a static asset or
|
|
@@ -2152,42 +2226,42 @@ class PHPRequestHandler {
|
|
|
2152
2226
|
* @param config - Request Handler configuration.
|
|
2153
2227
|
*/
|
|
2154
2228
|
constructor(e) {
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2229
|
+
_(this, H);
|
|
2230
|
+
_(this, S);
|
|
2231
|
+
_(this, C);
|
|
2232
|
+
_(this, A);
|
|
2233
|
+
_(this, F);
|
|
2234
|
+
_(this, I);
|
|
2235
|
+
_(this, P);
|
|
2236
|
+
_(this, M);
|
|
2237
|
+
_(this, R);
|
|
2164
2238
|
const {
|
|
2165
|
-
documentRoot:
|
|
2239
|
+
documentRoot: r = "/www/",
|
|
2166
2240
|
absoluteUrl: s = typeof location == "object" ? location.href : DEFAULT_BASE_URL,
|
|
2167
|
-
rewriteRules:
|
|
2168
|
-
getFileNotFoundAction:
|
|
2241
|
+
rewriteRules: n = [],
|
|
2242
|
+
getFileNotFoundAction: i = () => ({ type: "404" })
|
|
2169
2243
|
} = e;
|
|
2170
2244
|
"processManager" in e ? this.processManager = e.processManager : this.processManager = new PHPProcessManager({
|
|
2171
2245
|
phpFactory: async (l) => {
|
|
2172
|
-
const
|
|
2246
|
+
const c = await e.phpFactory({
|
|
2173
2247
|
...l,
|
|
2174
2248
|
requestHandler: this
|
|
2175
2249
|
});
|
|
2176
|
-
return
|
|
2250
|
+
return c.isDir(r) || c.mkdir(r), c.chdir(r), c.requestHandler = this, c;
|
|
2177
2251
|
},
|
|
2178
2252
|
maxPhpInstances: e.maxPhpInstances
|
|
2179
|
-
}), f(this,
|
|
2253
|
+
}), f(this, R, e.cookieStore === void 0 ? new HttpCookieStore() : e.cookieStore), f(this, S, r);
|
|
2180
2254
|
const o = new URL(s);
|
|
2181
|
-
f(this,
|
|
2182
|
-
const a =
|
|
2255
|
+
f(this, A, o.hostname), f(this, F, o.port ? Number(o.port) : o.protocol === "https:" ? 443 : 80), f(this, C, (o.protocol || "").replace(":", ""));
|
|
2256
|
+
const a = u(this, F) !== 443 && u(this, F) !== 80;
|
|
2183
2257
|
f(this, I, [
|
|
2184
|
-
|
|
2185
|
-
a ? `:${
|
|
2186
|
-
].join("")), f(this,
|
|
2187
|
-
`${
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
].join("")), this.rewriteRules =
|
|
2258
|
+
u(this, A),
|
|
2259
|
+
a ? `:${u(this, F)}` : ""
|
|
2260
|
+
].join("")), f(this, P, o.pathname.replace(/\/+$/, "")), f(this, M, [
|
|
2261
|
+
`${u(this, C)}://`,
|
|
2262
|
+
u(this, I),
|
|
2263
|
+
u(this, P)
|
|
2264
|
+
].join("")), this.rewriteRules = n, this.getFileNotFoundAction = i;
|
|
2191
2265
|
}
|
|
2192
2266
|
async getPrimaryPhp() {
|
|
2193
2267
|
return await this.processManager.getPrimaryPhp();
|
|
@@ -2210,21 +2284,21 @@ class PHPRequestHandler {
|
|
|
2210
2284
|
* @returns The relative path.
|
|
2211
2285
|
*/
|
|
2212
2286
|
internalUrlToPath(e) {
|
|
2213
|
-
const
|
|
2214
|
-
return
|
|
2287
|
+
const r = new URL(e);
|
|
2288
|
+
return r.pathname.startsWith(u(this, P)) && (r.pathname = r.pathname.slice(u(this, P).length)), toRelativeUrl(r);
|
|
2215
2289
|
}
|
|
2216
2290
|
/**
|
|
2217
2291
|
* The absolute URL of this PHPRequestHandler instance.
|
|
2218
2292
|
*/
|
|
2219
2293
|
get absoluteUrl() {
|
|
2220
|
-
return
|
|
2294
|
+
return u(this, M);
|
|
2221
2295
|
}
|
|
2222
2296
|
/**
|
|
2223
2297
|
* The directory in the PHP filesystem where the server will look
|
|
2224
2298
|
* for the files to serve. Default: `/var/www`.
|
|
2225
2299
|
*/
|
|
2226
2300
|
get documentRoot() {
|
|
2227
|
-
return
|
|
2301
|
+
return u(this, S);
|
|
2228
2302
|
}
|
|
2229
2303
|
/**
|
|
2230
2304
|
* Serves the request – either by serving a static file, or by
|
|
@@ -2275,19 +2349,19 @@ class PHPRequestHandler {
|
|
|
2275
2349
|
* @param request - PHP Request data.
|
|
2276
2350
|
*/
|
|
2277
2351
|
async request(e) {
|
|
2278
|
-
const
|
|
2352
|
+
const r = URL.canParse(e.url), s = new URL(
|
|
2279
2353
|
// Remove the hash part of the URL as it's not meant for the server.
|
|
2280
2354
|
e.url.split("#")[0],
|
|
2281
|
-
|
|
2282
|
-
),
|
|
2355
|
+
r ? void 0 : DEFAULT_BASE_URL
|
|
2356
|
+
), n = applyRewriteRules(
|
|
2283
2357
|
removePathPrefix(
|
|
2284
2358
|
decodeURIComponent(s.pathname),
|
|
2285
|
-
|
|
2359
|
+
u(this, P)
|
|
2286
2360
|
),
|
|
2287
2361
|
this.rewriteRules
|
|
2288
|
-
),
|
|
2289
|
-
let o = joinPaths(
|
|
2290
|
-
if (
|
|
2362
|
+
), i = await this.getPrimaryPhp();
|
|
2363
|
+
let o = joinPaths(u(this, S), n);
|
|
2364
|
+
if (i.isDir(o)) {
|
|
2291
2365
|
if (!o.endsWith("/"))
|
|
2292
2366
|
return new PHPResponse(
|
|
2293
2367
|
301,
|
|
@@ -2296,21 +2370,21 @@ class PHPRequestHandler {
|
|
|
2296
2370
|
);
|
|
2297
2371
|
for (const a of ["index.php", "index.html"]) {
|
|
2298
2372
|
const l = joinPaths(o, a);
|
|
2299
|
-
if (
|
|
2373
|
+
if (i.isFile(l)) {
|
|
2300
2374
|
o = l;
|
|
2301
2375
|
break;
|
|
2302
2376
|
}
|
|
2303
2377
|
}
|
|
2304
2378
|
}
|
|
2305
|
-
if (!
|
|
2379
|
+
if (!i.isFile(o)) {
|
|
2306
2380
|
const a = this.getFileNotFoundAction(
|
|
2307
|
-
|
|
2381
|
+
n
|
|
2308
2382
|
);
|
|
2309
2383
|
switch (a.type) {
|
|
2310
2384
|
case "response":
|
|
2311
2385
|
return a.response;
|
|
2312
2386
|
case "internal-redirect":
|
|
2313
|
-
o = joinPaths(
|
|
2387
|
+
o = joinPaths(u(this, S), a.uri);
|
|
2314
2388
|
break;
|
|
2315
2389
|
case "404":
|
|
2316
2390
|
return PHPResponse.forHttpCode(404);
|
|
@@ -2320,16 +2394,16 @@ class PHPRequestHandler {
|
|
|
2320
2394
|
);
|
|
2321
2395
|
}
|
|
2322
2396
|
}
|
|
2323
|
-
if (
|
|
2397
|
+
if (i.isFile(o))
|
|
2324
2398
|
if (o.endsWith(".php")) {
|
|
2325
2399
|
const a = {
|
|
2326
2400
|
...e,
|
|
2327
2401
|
// Pass along URL with the #fragment filtered out
|
|
2328
2402
|
url: s.toString()
|
|
2329
2403
|
};
|
|
2330
|
-
return
|
|
2404
|
+
return m(this, H, Z).call(this, a, o);
|
|
2331
2405
|
} else
|
|
2332
|
-
return
|
|
2406
|
+
return m(this, H, Q).call(this, i, o);
|
|
2333
2407
|
else
|
|
2334
2408
|
return PHPResponse.forHttpCode(404);
|
|
2335
2409
|
}
|
|
@@ -2337,14 +2411,14 @@ class PHPRequestHandler {
|
|
|
2337
2411
|
await this.processManager[Symbol.asyncDispose]();
|
|
2338
2412
|
}
|
|
2339
2413
|
}
|
|
2340
|
-
|
|
2414
|
+
S = new WeakMap(), C = new WeakMap(), A = new WeakMap(), F = new WeakMap(), I = new WeakMap(), P = new WeakMap(), M = new WeakMap(), R = new WeakMap(), H = new WeakSet(), /**
|
|
2341
2415
|
* Serves a static file from the PHP filesystem.
|
|
2342
2416
|
*
|
|
2343
2417
|
* @param fsPath - Absolute path of the static file to serve.
|
|
2344
2418
|
* @returns The response.
|
|
2345
2419
|
*/
|
|
2346
|
-
|
|
2347
|
-
const s = e.readFileAsBuffer(
|
|
2420
|
+
Q = function(e, r) {
|
|
2421
|
+
const s = e.readFileAsBuffer(r);
|
|
2348
2422
|
return new PHPResponse(
|
|
2349
2423
|
200,
|
|
2350
2424
|
{
|
|
@@ -2352,57 +2426,57 @@ Z = function(e, t) {
|
|
|
2352
2426
|
// @TODO: Infer the content-type from the arrayBuffer instead of the
|
|
2353
2427
|
// file path. The code below won't return the correct mime-type if the
|
|
2354
2428
|
// extension was tampered with.
|
|
2355
|
-
"content-type": [inferMimeType(
|
|
2429
|
+
"content-type": [inferMimeType(r)],
|
|
2356
2430
|
"accept-ranges": ["bytes"],
|
|
2357
2431
|
"cache-control": ["public, max-age=0"]
|
|
2358
2432
|
},
|
|
2359
2433
|
s
|
|
2360
2434
|
);
|
|
2361
|
-
},
|
|
2435
|
+
}, Z = async function(e, r) {
|
|
2362
2436
|
let s;
|
|
2363
2437
|
try {
|
|
2364
2438
|
s = await this.processManager.acquirePHPInstance({
|
|
2365
2439
|
considerPrimary: !0
|
|
2366
2440
|
});
|
|
2367
|
-
} catch (
|
|
2368
|
-
return
|
|
2441
|
+
} catch (n) {
|
|
2442
|
+
return n instanceof MaxPhpInstancesError ? PHPResponse.forHttpCode(502) : PHPResponse.forHttpCode(500);
|
|
2369
2443
|
}
|
|
2370
2444
|
try {
|
|
2371
|
-
return await
|
|
2445
|
+
return await m(this, H, ee).call(this, s.php, e, r);
|
|
2372
2446
|
} finally {
|
|
2373
2447
|
s.reap();
|
|
2374
2448
|
}
|
|
2375
|
-
},
|
|
2376
|
-
let
|
|
2377
|
-
const
|
|
2378
|
-
host:
|
|
2379
|
-
...normalizeHeaders(
|
|
2449
|
+
}, ee = async function(e, r, s) {
|
|
2450
|
+
let n = "GET";
|
|
2451
|
+
const i = {
|
|
2452
|
+
host: u(this, I),
|
|
2453
|
+
...normalizeHeaders(r.headers || {})
|
|
2380
2454
|
};
|
|
2381
|
-
|
|
2382
|
-
let o =
|
|
2455
|
+
u(this, R) && (i.cookie = u(this, R).getCookieRequestHeader());
|
|
2456
|
+
let o = r.body;
|
|
2383
2457
|
if (typeof o == "object" && !(o instanceof Uint8Array)) {
|
|
2384
|
-
|
|
2458
|
+
n = "POST";
|
|
2385
2459
|
const { bytes: a, contentType: l } = await encodeAsMultipart(o);
|
|
2386
|
-
o = a,
|
|
2460
|
+
o = a, i["content-type"] = l;
|
|
2387
2461
|
}
|
|
2388
2462
|
try {
|
|
2389
2463
|
const a = await e.run({
|
|
2390
2464
|
relativeUri: ensurePathPrefix(
|
|
2391
|
-
toRelativeUrl(new URL(
|
|
2392
|
-
|
|
2465
|
+
toRelativeUrl(new URL(r.url)),
|
|
2466
|
+
u(this, P)
|
|
2393
2467
|
),
|
|
2394
|
-
protocol:
|
|
2395
|
-
method:
|
|
2468
|
+
protocol: u(this, C),
|
|
2469
|
+
method: r.method || n,
|
|
2396
2470
|
$_SERVER: {
|
|
2397
2471
|
REMOTE_ADDR: "127.0.0.1",
|
|
2398
|
-
DOCUMENT_ROOT:
|
|
2399
|
-
HTTPS:
|
|
2472
|
+
DOCUMENT_ROOT: u(this, S),
|
|
2473
|
+
HTTPS: u(this, M).startsWith("https://") ? "on" : ""
|
|
2400
2474
|
},
|
|
2401
2475
|
body: o,
|
|
2402
2476
|
scriptPath: s,
|
|
2403
|
-
headers:
|
|
2477
|
+
headers: i
|
|
2404
2478
|
});
|
|
2405
|
-
return
|
|
2479
|
+
return u(this, R) && u(this, R).rememberCookiesFromResponseHeaders(
|
|
2406
2480
|
a.headers
|
|
2407
2481
|
), a;
|
|
2408
2482
|
} catch (a) {
|
|
@@ -2412,20 +2486,20 @@ Z = function(e, t) {
|
|
|
2412
2486
|
throw a;
|
|
2413
2487
|
}
|
|
2414
2488
|
};
|
|
2415
|
-
function inferMimeType(
|
|
2416
|
-
const e =
|
|
2489
|
+
function inferMimeType(t) {
|
|
2490
|
+
const e = t.split(".").pop();
|
|
2417
2491
|
return mimeTypes[e] || mimeTypes._default;
|
|
2418
2492
|
}
|
|
2419
|
-
function applyRewriteRules(
|
|
2420
|
-
for (const
|
|
2421
|
-
if (new RegExp(
|
|
2422
|
-
return
|
|
2423
|
-
return
|
|
2493
|
+
function applyRewriteRules(t, e) {
|
|
2494
|
+
for (const r of e)
|
|
2495
|
+
if (new RegExp(r.match).test(t))
|
|
2496
|
+
return t.replace(r.match, r.replacement);
|
|
2497
|
+
return t;
|
|
2424
2498
|
}
|
|
2425
2499
|
function rotatePHPRuntime({
|
|
2426
|
-
php:
|
|
2500
|
+
php: t,
|
|
2427
2501
|
cwd: e,
|
|
2428
|
-
recreateRuntime:
|
|
2502
|
+
recreateRuntime: r,
|
|
2429
2503
|
/*
|
|
2430
2504
|
* 400 is an arbitrary number that should trigger a rotation
|
|
2431
2505
|
* way before the memory gets too fragmented. If it doesn't,
|
|
@@ -2436,154 +2510,785 @@ function rotatePHPRuntime({
|
|
|
2436
2510
|
*/
|
|
2437
2511
|
maxRequests: s = 400
|
|
2438
2512
|
}) {
|
|
2439
|
-
let
|
|
2440
|
-
async function
|
|
2441
|
-
const l = await
|
|
2513
|
+
let n = 0;
|
|
2514
|
+
async function i() {
|
|
2515
|
+
const l = await t.semaphore.acquire();
|
|
2442
2516
|
try {
|
|
2443
|
-
await
|
|
2517
|
+
await t.hotSwapPHPRuntime(await r(), e), n = 0;
|
|
2444
2518
|
} finally {
|
|
2445
2519
|
l();
|
|
2446
2520
|
}
|
|
2447
2521
|
}
|
|
2448
2522
|
async function o() {
|
|
2449
|
-
++
|
|
2523
|
+
++n < s || await i();
|
|
2450
2524
|
}
|
|
2451
2525
|
async function a(l) {
|
|
2452
|
-
l.type === "request.error" && l.source === "php-wasm" && await
|
|
2526
|
+
l.type === "request.error" && l.source === "php-wasm" && await i();
|
|
2453
2527
|
}
|
|
2454
|
-
return
|
|
2455
|
-
|
|
2528
|
+
return t.addEventListener("request.error", a), t.addEventListener("request.end", o), function() {
|
|
2529
|
+
t.removeEventListener("request.error", a), t.removeEventListener("request.end", o);
|
|
2456
2530
|
};
|
|
2457
2531
|
}
|
|
2458
|
-
async function writeFiles(
|
|
2459
|
-
s && await
|
|
2460
|
-
for (const [
|
|
2461
|
-
const o = joinPaths(e,
|
|
2462
|
-
await
|
|
2532
|
+
async function writeFiles(t, e, r, { rmRoot: s = !1 } = {}) {
|
|
2533
|
+
s && await t.isDir(e) && await t.rmdir(e, { recursive: !0 });
|
|
2534
|
+
for (const [n, i] of Object.entries(r)) {
|
|
2535
|
+
const o = joinPaths(e, n);
|
|
2536
|
+
await t.fileExists(dirname(o)) || await t.mkdir(dirname(o)), i instanceof Uint8Array || typeof i == "string" ? await t.writeFile(o, i) : await writeFiles(t, o, i);
|
|
2463
2537
|
}
|
|
2464
2538
|
}
|
|
2465
|
-
function proxyFileSystem(
|
|
2466
|
-
const s = Object.getOwnPropertySymbols(
|
|
2467
|
-
for (const
|
|
2468
|
-
e.fileExists(
|
|
2539
|
+
function proxyFileSystem(t, e, r) {
|
|
2540
|
+
const s = Object.getOwnPropertySymbols(t)[0];
|
|
2541
|
+
for (const n of r)
|
|
2542
|
+
e.fileExists(n) || e.mkdir(n), t.fileExists(n) || t.mkdir(n), e[s].FS.mount(
|
|
2469
2543
|
// @ts-ignore
|
|
2470
2544
|
e[s].PROXYFS,
|
|
2471
2545
|
{
|
|
2472
|
-
root:
|
|
2546
|
+
root: n,
|
|
2473
2547
|
// @ts-ignore
|
|
2474
|
-
fs:
|
|
2548
|
+
fs: t[s].FS
|
|
2475
2549
|
},
|
|
2476
|
-
|
|
2550
|
+
n
|
|
2477
2551
|
);
|
|
2478
2552
|
}
|
|
2553
|
+
function sandboxedSpawnHandlerFactory(t) {
|
|
2554
|
+
return createSpawnHandler(async function(e, r, s) {
|
|
2555
|
+
r.notifySpawn(), e[0] === "exec" && e.shift(), (e[0].endsWith(".php") || e[0].endsWith(".phar")) && e.unshift("php");
|
|
2556
|
+
const n = e[0].split("/").pop();
|
|
2557
|
+
if (e[0] === "/usr/bin/env" && e[1] === "stty" && e[2] === "size")
|
|
2558
|
+
r.stdout("18 140"), r.exit(0);
|
|
2559
|
+
else if (n === "tput" && e[1] === "cols")
|
|
2560
|
+
r.stdout("140"), r.exit(0);
|
|
2561
|
+
else if (n === "less")
|
|
2562
|
+
r.on("stdin", (i) => {
|
|
2563
|
+
r.stdout(i);
|
|
2564
|
+
}), r.exit(0);
|
|
2565
|
+
else if (n === "php") {
|
|
2566
|
+
const { php: i, reap: o } = await t.acquirePHPInstance({
|
|
2567
|
+
considerPrimary: !1
|
|
2568
|
+
});
|
|
2569
|
+
i.chdir(s.cwd);
|
|
2570
|
+
try {
|
|
2571
|
+
const a = await i.cli(e, {
|
|
2572
|
+
env: {
|
|
2573
|
+
...s.env,
|
|
2574
|
+
SCRIPT_PATH: e[1],
|
|
2575
|
+
// Set SHELL_PIPE to 0 to ensure WP-CLI formats
|
|
2576
|
+
// the output as ASCII tables.
|
|
2577
|
+
// @see https://github.com/wp-cli/wp-cli/issues/1102
|
|
2578
|
+
SHELL_PIPE: "0"
|
|
2579
|
+
}
|
|
2580
|
+
});
|
|
2581
|
+
a.stdout.pipeTo(
|
|
2582
|
+
new WritableStream({
|
|
2583
|
+
write(l) {
|
|
2584
|
+
r.stdout(l);
|
|
2585
|
+
}
|
|
2586
|
+
})
|
|
2587
|
+
), a.stderr.pipeTo(
|
|
2588
|
+
new WritableStream({
|
|
2589
|
+
write(l) {
|
|
2590
|
+
r.stderr(l);
|
|
2591
|
+
}
|
|
2592
|
+
})
|
|
2593
|
+
), r.exit(await a.exitCode);
|
|
2594
|
+
} catch (a) {
|
|
2595
|
+
throw r.exit(1), a;
|
|
2596
|
+
} finally {
|
|
2597
|
+
o();
|
|
2598
|
+
}
|
|
2599
|
+
} else
|
|
2600
|
+
r.exit(1);
|
|
2601
|
+
});
|
|
2602
|
+
}
|
|
2603
|
+
function exposeSync(t, e, r, s = ["*"]) {
|
|
2604
|
+
return expose(t, e, s, r.afterResponseSent);
|
|
2605
|
+
}
|
|
2606
|
+
function createSyncProxy(t, e = [], r) {
|
|
2607
|
+
return new Proxy(() => {
|
|
2608
|
+
}, {
|
|
2609
|
+
get(s, n) {
|
|
2610
|
+
return n === "then" && !e.length ? {
|
|
2611
|
+
then: (i, o) => o(createSyncProxy(t, [], r))
|
|
2612
|
+
} : createSyncProxy(t, [...e, n], r);
|
|
2613
|
+
},
|
|
2614
|
+
set(s, n, i) {
|
|
2615
|
+
const [o, a] = toWireValue(i);
|
|
2616
|
+
return r.send(
|
|
2617
|
+
t,
|
|
2618
|
+
{
|
|
2619
|
+
type: MessageType.SET,
|
|
2620
|
+
path: [...e, n].map(String),
|
|
2621
|
+
value: o
|
|
2622
|
+
},
|
|
2623
|
+
a
|
|
2624
|
+
), !0;
|
|
2625
|
+
},
|
|
2626
|
+
apply(s, n, i) {
|
|
2627
|
+
if (e.at(-1) === "bind")
|
|
2628
|
+
return createSyncProxy(t, e.slice(0, -1), r);
|
|
2629
|
+
const [a, l] = processArguments(i), c = r.send(
|
|
2630
|
+
t,
|
|
2631
|
+
{
|
|
2632
|
+
type: MessageType.APPLY,
|
|
2633
|
+
path: e.map(String),
|
|
2634
|
+
argumentList: a
|
|
2635
|
+
},
|
|
2636
|
+
l
|
|
2637
|
+
);
|
|
2638
|
+
return fromWireValue(c);
|
|
2639
|
+
},
|
|
2640
|
+
construct(s, n) {
|
|
2641
|
+
const [i, o] = processArguments(n), a = r.send(
|
|
2642
|
+
t,
|
|
2643
|
+
{
|
|
2644
|
+
type: MessageType.CONSTRUCT,
|
|
2645
|
+
path: e.map(String),
|
|
2646
|
+
argumentList: i
|
|
2647
|
+
},
|
|
2648
|
+
o
|
|
2649
|
+
);
|
|
2650
|
+
return fromWireValue(a);
|
|
2651
|
+
}
|
|
2652
|
+
});
|
|
2653
|
+
}
|
|
2654
|
+
function wrapSync(t, e) {
|
|
2655
|
+
return createSyncProxy(t, [], e);
|
|
2656
|
+
}
|
|
2657
|
+
class NodeSABSyncReceiveMessageTransport {
|
|
2658
|
+
static async create() {
|
|
2659
|
+
if (!NodeSABSyncReceiveMessageTransport.receiveMessageOnPort)
|
|
2660
|
+
try {
|
|
2661
|
+
NodeSABSyncReceiveMessageTransport.receiveMessageOnPort = require("worker_threads").receiveMessageOnPort;
|
|
2662
|
+
} catch {
|
|
2663
|
+
NodeSABSyncReceiveMessageTransport.receiveMessageOnPort = await import("worker_threads").then(
|
|
2664
|
+
(e) => e.receiveMessageOnPort
|
|
2665
|
+
);
|
|
2666
|
+
}
|
|
2667
|
+
return new NodeSABSyncReceiveMessageTransport();
|
|
2668
|
+
}
|
|
2669
|
+
constructor() {
|
|
2670
|
+
}
|
|
2671
|
+
afterResponseSent(e) {
|
|
2672
|
+
const { notifyBuffer: r } = e.data;
|
|
2673
|
+
if (r) {
|
|
2674
|
+
const s = new Int32Array(r);
|
|
2675
|
+
s[0] = 1, Atomics.notify(s, 0);
|
|
2676
|
+
}
|
|
2677
|
+
}
|
|
2678
|
+
send(e, r, s) {
|
|
2679
|
+
var c;
|
|
2680
|
+
const n = new SharedArrayBuffer(4), i = new Int32Array(n);
|
|
2681
|
+
i[0] = 0;
|
|
2682
|
+
const o = generateUUID();
|
|
2683
|
+
if (e.postMessage(
|
|
2684
|
+
{ ...r, id: o, notifyBuffer: n },
|
|
2685
|
+
s
|
|
2686
|
+
), Atomics.wait(i, 0, 0, 5e3) === "timed-out")
|
|
2687
|
+
throw new Error("Timeout waiting for response");
|
|
2688
|
+
for (; ; ) {
|
|
2689
|
+
const p = NodeSABSyncReceiveMessageTransport.receiveMessageOnPort(e);
|
|
2690
|
+
if (((c = p.message) == null ? void 0 : c.id) === o)
|
|
2691
|
+
return p.message;
|
|
2692
|
+
if (!p)
|
|
2693
|
+
throw new Error("No response received");
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
}
|
|
2479
2697
|
/**
|
|
2698
|
+
* Original, unmodified Comlink library from Google:
|
|
2699
|
+
*
|
|
2480
2700
|
* @license
|
|
2481
2701
|
* Copyright 2019 Google LLC
|
|
2482
2702
|
* SPDX-License-Identifier: Apache-2.0
|
|
2483
2703
|
*/
|
|
2484
|
-
|
|
2704
|
+
const proxyMarker = Symbol("Comlink.proxy"), createEndpoint = Symbol("Comlink.endpoint"), releaseProxy = Symbol("Comlink.releaseProxy"), finalizer = Symbol("Comlink.finalizer"), throwMarker = Symbol("Comlink.thrown");
|
|
2705
|
+
/**
|
|
2706
|
+
* @license
|
|
2707
|
+
* Copyright 2019 Google LLC
|
|
2708
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
2709
|
+
*/
|
|
2710
|
+
const WireValueType = {
|
|
2711
|
+
RAW: "RAW",
|
|
2712
|
+
HANDLER: "HANDLER"
|
|
2713
|
+
}, MessageType = {
|
|
2714
|
+
GET: "GET",
|
|
2715
|
+
SET: "SET",
|
|
2716
|
+
APPLY: "APPLY",
|
|
2717
|
+
CONSTRUCT: "CONSTRUCT",
|
|
2718
|
+
ENDPOINT: "ENDPOINT",
|
|
2719
|
+
RELEASE: "RELEASE"
|
|
2720
|
+
}, isObject = (t) => typeof t == "object" && t !== null || typeof t == "function", proxyTransferHandler = {
|
|
2721
|
+
canHandle: (t) => isObject(t) && t[proxyMarker],
|
|
2722
|
+
serialize(t) {
|
|
2723
|
+
const { port1: e, port2: r } = new MessageChannel();
|
|
2724
|
+
return expose(t, e), [r, [r]];
|
|
2725
|
+
},
|
|
2726
|
+
deserialize(t) {
|
|
2727
|
+
return t.start(), wrap(t);
|
|
2728
|
+
}
|
|
2729
|
+
}, throwTransferHandler$1 = {
|
|
2730
|
+
canHandle: (t) => isObject(t) && throwMarker in t,
|
|
2731
|
+
serialize({ value: t }) {
|
|
2732
|
+
let e;
|
|
2733
|
+
return t instanceof Error ? e = {
|
|
2734
|
+
isError: !0,
|
|
2735
|
+
value: {
|
|
2736
|
+
message: t.message,
|
|
2737
|
+
name: t.name,
|
|
2738
|
+
stack: t.stack
|
|
2739
|
+
}
|
|
2740
|
+
} : e = { isError: !1, value: t }, [e, []];
|
|
2741
|
+
},
|
|
2742
|
+
deserialize(t) {
|
|
2743
|
+
throw t.isError ? Object.assign(
|
|
2744
|
+
new Error(t.value.message),
|
|
2745
|
+
t.value
|
|
2746
|
+
) : t.value;
|
|
2747
|
+
}
|
|
2748
|
+
}, transferHandlers = /* @__PURE__ */ new Map([
|
|
2749
|
+
["proxy", proxyTransferHandler],
|
|
2750
|
+
["throw", throwTransferHandler$1]
|
|
2751
|
+
]);
|
|
2752
|
+
function isAllowedOrigin(t, e) {
|
|
2753
|
+
for (const r of t)
|
|
2754
|
+
if (e === r || r === "*" || r instanceof RegExp && r.test(e))
|
|
2755
|
+
return !0;
|
|
2756
|
+
return !1;
|
|
2757
|
+
}
|
|
2758
|
+
function expose(t, e = globalThis, r = ["*"], s) {
|
|
2759
|
+
e.addEventListener("message", function n(i) {
|
|
2760
|
+
if (!i || !i.data)
|
|
2761
|
+
return;
|
|
2762
|
+
if (!isAllowedOrigin(r, i.origin)) {
|
|
2763
|
+
console.warn(`Invalid origin '${i.origin}' for comlink proxy`);
|
|
2764
|
+
return;
|
|
2765
|
+
}
|
|
2766
|
+
const { id: o, type: a, path: l } = {
|
|
2767
|
+
path: [],
|
|
2768
|
+
...i.data
|
|
2769
|
+
}, c = (i.data.argumentList || []).map(fromWireValue);
|
|
2770
|
+
let p;
|
|
2771
|
+
try {
|
|
2772
|
+
const h = l.slice(0, -1).reduce((w, b) => w[b], t), y = l.reduce((w, b) => w[b], t);
|
|
2773
|
+
switch (a) {
|
|
2774
|
+
case MessageType.GET:
|
|
2775
|
+
p = y;
|
|
2776
|
+
break;
|
|
2777
|
+
case MessageType.SET:
|
|
2778
|
+
h[l.slice(-1)[0]] = fromWireValue(
|
|
2779
|
+
i.data.value
|
|
2780
|
+
), p = !0;
|
|
2781
|
+
break;
|
|
2782
|
+
case MessageType.APPLY:
|
|
2783
|
+
p = y.apply(h, c);
|
|
2784
|
+
break;
|
|
2785
|
+
case MessageType.CONSTRUCT:
|
|
2786
|
+
{
|
|
2787
|
+
const w = new y(...c);
|
|
2788
|
+
p = proxy(w);
|
|
2789
|
+
}
|
|
2790
|
+
break;
|
|
2791
|
+
case MessageType.ENDPOINT:
|
|
2792
|
+
{
|
|
2793
|
+
const { port1: w, port2: b } = new MessageChannel();
|
|
2794
|
+
expose(t, b), p = transfer(w, [w]);
|
|
2795
|
+
}
|
|
2796
|
+
break;
|
|
2797
|
+
case MessageType.RELEASE:
|
|
2798
|
+
p = void 0;
|
|
2799
|
+
break;
|
|
2800
|
+
default:
|
|
2801
|
+
return;
|
|
2802
|
+
}
|
|
2803
|
+
} catch (h) {
|
|
2804
|
+
p = { value: h, [throwMarker]: 0 };
|
|
2805
|
+
}
|
|
2806
|
+
Promise.resolve(p).catch((h) => ({ value: h, [throwMarker]: 0 })).then((h) => {
|
|
2807
|
+
const [y, w] = toWireValue(h);
|
|
2808
|
+
e.postMessage({ ...y, id: o }, w), a === MessageType.RELEASE && (e.removeEventListener("message", n), closeEndPoint(e), finalizer in t && typeof t[finalizer] == "function" && t[finalizer]());
|
|
2809
|
+
}).catch(() => {
|
|
2810
|
+
const [h, y] = toWireValue({
|
|
2811
|
+
value: new TypeError("Unserializable return value"),
|
|
2812
|
+
[throwMarker]: 0
|
|
2813
|
+
});
|
|
2814
|
+
e.postMessage({ ...h, id: o }, y);
|
|
2815
|
+
}).finally(() => {
|
|
2816
|
+
s == null || s(i);
|
|
2817
|
+
});
|
|
2818
|
+
}), e.start && e.start();
|
|
2819
|
+
}
|
|
2820
|
+
function isMessagePort(t) {
|
|
2821
|
+
return t.constructor.name === "MessagePort";
|
|
2822
|
+
}
|
|
2823
|
+
function closeEndPoint(t) {
|
|
2824
|
+
isMessagePort(t) && t.close();
|
|
2825
|
+
}
|
|
2826
|
+
function wrap(t, e) {
|
|
2827
|
+
const r = /* @__PURE__ */ new Map();
|
|
2828
|
+
return t.addEventListener("message", function(n) {
|
|
2829
|
+
const { data: i } = n;
|
|
2830
|
+
if (!i || !i.id)
|
|
2831
|
+
return;
|
|
2832
|
+
const o = r.get(i.id);
|
|
2833
|
+
if (o)
|
|
2834
|
+
try {
|
|
2835
|
+
o(i);
|
|
2836
|
+
} finally {
|
|
2837
|
+
r.delete(i.id);
|
|
2838
|
+
}
|
|
2839
|
+
}), createProxy(t, r, [], e);
|
|
2840
|
+
}
|
|
2841
|
+
function throwIfProxyReleased(t) {
|
|
2842
|
+
if (t)
|
|
2843
|
+
throw new Error("Proxy has been released and is not useable");
|
|
2844
|
+
}
|
|
2845
|
+
function releaseEndpoint(t) {
|
|
2846
|
+
return requestResponseMessage(t, /* @__PURE__ */ new Map(), {
|
|
2847
|
+
type: MessageType.RELEASE
|
|
2848
|
+
}).then(() => {
|
|
2849
|
+
closeEndPoint(t);
|
|
2850
|
+
});
|
|
2851
|
+
}
|
|
2852
|
+
const proxyCounter = /* @__PURE__ */ new WeakMap(), proxyFinalizers = "FinalizationRegistry" in globalThis && new FinalizationRegistry((t) => {
|
|
2853
|
+
const e = (proxyCounter.get(t) || 0) - 1;
|
|
2854
|
+
proxyCounter.set(t, e), e === 0 && releaseEndpoint(t);
|
|
2855
|
+
});
|
|
2856
|
+
function registerProxy(t, e) {
|
|
2857
|
+
const r = (proxyCounter.get(e) || 0) + 1;
|
|
2858
|
+
proxyCounter.set(e, r), proxyFinalizers && proxyFinalizers.register(t, e, t);
|
|
2859
|
+
}
|
|
2860
|
+
function unregisterProxy(t) {
|
|
2861
|
+
proxyFinalizers && proxyFinalizers.unregister(t);
|
|
2862
|
+
}
|
|
2863
|
+
function createProxy(t, e, r = [], s = function() {
|
|
2864
|
+
}) {
|
|
2865
|
+
let n = !1;
|
|
2866
|
+
const i = new Proxy(s, {
|
|
2867
|
+
get(o, a) {
|
|
2868
|
+
if (throwIfProxyReleased(n), a === releaseProxy)
|
|
2869
|
+
return () => {
|
|
2870
|
+
unregisterProxy(i), releaseEndpoint(t), e.clear(), n = !0;
|
|
2871
|
+
};
|
|
2872
|
+
if (a === "then") {
|
|
2873
|
+
if (r.length === 0)
|
|
2874
|
+
return { then: () => i };
|
|
2875
|
+
const l = requestResponseMessage(t, e, {
|
|
2876
|
+
type: MessageType.GET,
|
|
2877
|
+
path: r.map((c) => c.toString())
|
|
2878
|
+
}).then(fromWireValue);
|
|
2879
|
+
return l.then.bind(l);
|
|
2880
|
+
}
|
|
2881
|
+
return createProxy(t, e, [...r, a]);
|
|
2882
|
+
},
|
|
2883
|
+
set(o, a, l) {
|
|
2884
|
+
throwIfProxyReleased(n);
|
|
2885
|
+
const [c, p] = toWireValue(l);
|
|
2886
|
+
return requestResponseMessage(
|
|
2887
|
+
t,
|
|
2888
|
+
e,
|
|
2889
|
+
{
|
|
2890
|
+
type: MessageType.SET,
|
|
2891
|
+
path: [...r, a].map((h) => h.toString()),
|
|
2892
|
+
value: c
|
|
2893
|
+
},
|
|
2894
|
+
p
|
|
2895
|
+
).then(fromWireValue);
|
|
2896
|
+
},
|
|
2897
|
+
apply(o, a, l) {
|
|
2898
|
+
throwIfProxyReleased(n);
|
|
2899
|
+
const c = r[r.length - 1];
|
|
2900
|
+
if (c === createEndpoint)
|
|
2901
|
+
return requestResponseMessage(t, e, {
|
|
2902
|
+
type: MessageType.ENDPOINT
|
|
2903
|
+
}).then(fromWireValue);
|
|
2904
|
+
if (c === "bind")
|
|
2905
|
+
return createProxy(t, e, r.slice(0, -1));
|
|
2906
|
+
const [p, h] = processArguments(l);
|
|
2907
|
+
return requestResponseMessage(
|
|
2908
|
+
t,
|
|
2909
|
+
e,
|
|
2910
|
+
{
|
|
2911
|
+
type: MessageType.APPLY,
|
|
2912
|
+
path: r.map((y) => y.toString()),
|
|
2913
|
+
argumentList: p
|
|
2914
|
+
},
|
|
2915
|
+
h
|
|
2916
|
+
).then(fromWireValue);
|
|
2917
|
+
},
|
|
2918
|
+
construct(o, a) {
|
|
2919
|
+
throwIfProxyReleased(n);
|
|
2920
|
+
const [l, c] = processArguments(a);
|
|
2921
|
+
return requestResponseMessage(
|
|
2922
|
+
t,
|
|
2923
|
+
e,
|
|
2924
|
+
{
|
|
2925
|
+
type: MessageType.CONSTRUCT,
|
|
2926
|
+
path: r.map((p) => p.toString()),
|
|
2927
|
+
argumentList: l
|
|
2928
|
+
},
|
|
2929
|
+
c
|
|
2930
|
+
).then(fromWireValue);
|
|
2931
|
+
}
|
|
2932
|
+
});
|
|
2933
|
+
return registerProxy(i, t), i;
|
|
2934
|
+
}
|
|
2935
|
+
function myFlat(t) {
|
|
2936
|
+
return Array.prototype.concat.apply([], t);
|
|
2937
|
+
}
|
|
2938
|
+
function processArguments(t) {
|
|
2939
|
+
const e = t.map(toWireValue);
|
|
2940
|
+
return [e.map((r) => r[0]), myFlat(e.map((r) => r[1]))];
|
|
2941
|
+
}
|
|
2942
|
+
const transferCache = /* @__PURE__ */ new WeakMap();
|
|
2943
|
+
function transfer(t, e) {
|
|
2944
|
+
return transferCache.set(t, e), t;
|
|
2945
|
+
}
|
|
2946
|
+
function proxy(t) {
|
|
2947
|
+
return Object.assign(t, { [proxyMarker]: !0 });
|
|
2948
|
+
}
|
|
2949
|
+
function windowEndpoint(t, e = globalThis, r = "*") {
|
|
2950
|
+
return {
|
|
2951
|
+
postMessage: (s, n) => t.postMessage(s, r, n),
|
|
2952
|
+
addEventListener: e.addEventListener.bind(e),
|
|
2953
|
+
removeEventListener: e.removeEventListener.bind(e)
|
|
2954
|
+
};
|
|
2955
|
+
}
|
|
2956
|
+
function toWireValue(t) {
|
|
2957
|
+
for (const [e, r] of transferHandlers)
|
|
2958
|
+
if (r.canHandle(t)) {
|
|
2959
|
+
const [s, n] = r.serialize(t);
|
|
2960
|
+
return [
|
|
2961
|
+
{
|
|
2962
|
+
type: WireValueType.HANDLER,
|
|
2963
|
+
name: e,
|
|
2964
|
+
value: s
|
|
2965
|
+
},
|
|
2966
|
+
n
|
|
2967
|
+
];
|
|
2968
|
+
}
|
|
2969
|
+
return [
|
|
2970
|
+
{
|
|
2971
|
+
type: WireValueType.RAW,
|
|
2972
|
+
value: t
|
|
2973
|
+
},
|
|
2974
|
+
transferCache.get(t) || []
|
|
2975
|
+
];
|
|
2976
|
+
}
|
|
2977
|
+
function fromWireValue(t) {
|
|
2978
|
+
switch (t.type) {
|
|
2979
|
+
case WireValueType.HANDLER:
|
|
2980
|
+
return transferHandlers.get(t.name).deserialize(t.value);
|
|
2981
|
+
case WireValueType.RAW:
|
|
2982
|
+
return t.value;
|
|
2983
|
+
}
|
|
2984
|
+
}
|
|
2985
|
+
function requestResponseMessage(t, e, r, s) {
|
|
2986
|
+
return new Promise((n) => {
|
|
2987
|
+
const i = generateUUID();
|
|
2988
|
+
e.set(i, n), t.start && t.start(), t.postMessage({ id: i, ...r }, s);
|
|
2989
|
+
});
|
|
2990
|
+
}
|
|
2991
|
+
function generateUUID() {
|
|
2992
|
+
return new Array(4).fill(0).map(
|
|
2993
|
+
() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)
|
|
2994
|
+
).join("-");
|
|
2995
|
+
}
|
|
2996
|
+
function nodeEndpoint(t) {
|
|
2485
2997
|
const e = /* @__PURE__ */ new WeakMap();
|
|
2486
2998
|
return {
|
|
2487
|
-
postMessage:
|
|
2488
|
-
addEventListener: (
|
|
2489
|
-
const
|
|
2490
|
-
"handleEvent" in s ? s.handleEvent({ data:
|
|
2999
|
+
postMessage: t.postMessage.bind(t),
|
|
3000
|
+
addEventListener: (r, s) => {
|
|
3001
|
+
const n = (i) => {
|
|
3002
|
+
"handleEvent" in s ? s.handleEvent({ data: i }) : s({ data: i });
|
|
2491
3003
|
};
|
|
2492
|
-
|
|
3004
|
+
t.on("message", n), e.set(s, n);
|
|
2493
3005
|
},
|
|
2494
|
-
removeEventListener: (
|
|
2495
|
-
const
|
|
2496
|
-
|
|
3006
|
+
removeEventListener: (r, s) => {
|
|
3007
|
+
const n = e.get(s);
|
|
3008
|
+
n && (t.off("message", n), e.delete(s));
|
|
2497
3009
|
},
|
|
2498
|
-
start:
|
|
3010
|
+
start: t.start && t.start.bind(t)
|
|
2499
3011
|
};
|
|
2500
3012
|
}
|
|
2501
|
-
|
|
3013
|
+
const list = [
|
|
3014
|
+
// Native ES errors https://262.ecma-international.org/12.0/#sec-well-known-intrinsic-objects
|
|
3015
|
+
Error,
|
|
3016
|
+
EvalError,
|
|
3017
|
+
RangeError,
|
|
3018
|
+
ReferenceError,
|
|
3019
|
+
SyntaxError,
|
|
3020
|
+
TypeError,
|
|
3021
|
+
URIError,
|
|
3022
|
+
AggregateError,
|
|
3023
|
+
// Built-in errors
|
|
3024
|
+
globalThis.DOMException,
|
|
3025
|
+
// Node-specific errors
|
|
3026
|
+
// https://nodejs.org/api/errors.html
|
|
3027
|
+
globalThis.AssertionError,
|
|
3028
|
+
globalThis.SystemError
|
|
3029
|
+
].filter(Boolean).map((t) => [t.name, t]), errorConstructors = new Map(list);
|
|
3030
|
+
class NonError extends Error {
|
|
3031
|
+
constructor(e) {
|
|
3032
|
+
super(NonError._prepareSuperMessage(e)), this.name = "NonError";
|
|
3033
|
+
}
|
|
3034
|
+
static _prepareSuperMessage(e) {
|
|
3035
|
+
try {
|
|
3036
|
+
return JSON.stringify(e);
|
|
3037
|
+
} catch {
|
|
3038
|
+
return String(e);
|
|
3039
|
+
}
|
|
3040
|
+
}
|
|
3041
|
+
}
|
|
3042
|
+
const errorProperties = [
|
|
3043
|
+
{
|
|
3044
|
+
property: "name",
|
|
3045
|
+
enumerable: !1
|
|
3046
|
+
},
|
|
3047
|
+
{
|
|
3048
|
+
property: "message",
|
|
3049
|
+
enumerable: !1
|
|
3050
|
+
},
|
|
3051
|
+
{
|
|
3052
|
+
property: "stack",
|
|
3053
|
+
enumerable: !1
|
|
3054
|
+
},
|
|
3055
|
+
{
|
|
3056
|
+
property: "code",
|
|
3057
|
+
enumerable: !0
|
|
3058
|
+
},
|
|
3059
|
+
{
|
|
3060
|
+
property: "cause",
|
|
3061
|
+
enumerable: !1
|
|
3062
|
+
},
|
|
3063
|
+
{
|
|
3064
|
+
property: "errors",
|
|
3065
|
+
enumerable: !1
|
|
3066
|
+
}
|
|
3067
|
+
], toJsonWasCalled = /* @__PURE__ */ new WeakSet(), toJSON = (t) => {
|
|
3068
|
+
toJsonWasCalled.add(t);
|
|
3069
|
+
const e = t.toJSON();
|
|
3070
|
+
return toJsonWasCalled.delete(t), e;
|
|
3071
|
+
}, newError = (t) => {
|
|
3072
|
+
const e = errorConstructors.get(t) ?? Error;
|
|
3073
|
+
return e === AggregateError ? new e([]) : new e();
|
|
3074
|
+
}, destroyCircular = ({
|
|
3075
|
+
from: t,
|
|
3076
|
+
seen: e,
|
|
3077
|
+
to: r,
|
|
3078
|
+
forceEnumerable: s,
|
|
3079
|
+
maxDepth: n,
|
|
3080
|
+
depth: i,
|
|
3081
|
+
useToJSON: o,
|
|
3082
|
+
serialize: a
|
|
3083
|
+
}) => {
|
|
3084
|
+
if (r || (Array.isArray(t) ? r = [] : !a && isErrorLike(t) ? r = newError(t.name) : r = {}), e.push(t), i >= n)
|
|
3085
|
+
return r;
|
|
3086
|
+
if (o && typeof t.toJSON == "function" && !toJsonWasCalled.has(t))
|
|
3087
|
+
return toJSON(t);
|
|
3088
|
+
const l = (c) => destroyCircular({
|
|
3089
|
+
from: c,
|
|
3090
|
+
seen: [...e],
|
|
3091
|
+
forceEnumerable: s,
|
|
3092
|
+
maxDepth: n,
|
|
3093
|
+
depth: i,
|
|
3094
|
+
useToJSON: o,
|
|
3095
|
+
serialize: a
|
|
3096
|
+
});
|
|
3097
|
+
for (const [c, p] of Object.entries(t)) {
|
|
3098
|
+
if (p && p instanceof Uint8Array && p.constructor.name === "Buffer") {
|
|
3099
|
+
r[c] = "[object Buffer]";
|
|
3100
|
+
continue;
|
|
3101
|
+
}
|
|
3102
|
+
if (p !== null && typeof p == "object" && typeof p.pipe == "function") {
|
|
3103
|
+
r[c] = "[object Stream]";
|
|
3104
|
+
continue;
|
|
3105
|
+
}
|
|
3106
|
+
if (typeof p != "function") {
|
|
3107
|
+
if (!p || typeof p != "object") {
|
|
3108
|
+
try {
|
|
3109
|
+
r[c] = p;
|
|
3110
|
+
} catch {
|
|
3111
|
+
}
|
|
3112
|
+
continue;
|
|
3113
|
+
}
|
|
3114
|
+
if (!e.includes(t[c])) {
|
|
3115
|
+
i++, r[c] = l(t[c]);
|
|
3116
|
+
continue;
|
|
3117
|
+
}
|
|
3118
|
+
r[c] = "[Circular]";
|
|
3119
|
+
}
|
|
3120
|
+
}
|
|
3121
|
+
if (a || r instanceof Error)
|
|
3122
|
+
for (const { property: c, enumerable: p } of errorProperties)
|
|
3123
|
+
t[c] !== void 0 && t[c] !== null && Object.defineProperty(r, c, {
|
|
3124
|
+
value: isErrorLike(t[c]) || Array.isArray(t[c]) ? l(t[c]) : t[c],
|
|
3125
|
+
enumerable: s ? !0 : p,
|
|
3126
|
+
configurable: !0,
|
|
3127
|
+
writable: !0
|
|
3128
|
+
});
|
|
3129
|
+
return r;
|
|
3130
|
+
};
|
|
3131
|
+
function serializeError(t, e = {}) {
|
|
3132
|
+
const { maxDepth: r = Number.POSITIVE_INFINITY, useToJSON: s = !0 } = e;
|
|
3133
|
+
return typeof t == "object" && t !== null ? destroyCircular({
|
|
3134
|
+
from: t,
|
|
3135
|
+
seen: [],
|
|
3136
|
+
forceEnumerable: !0,
|
|
3137
|
+
maxDepth: r,
|
|
3138
|
+
depth: 0,
|
|
3139
|
+
useToJSON: s,
|
|
3140
|
+
serialize: !0
|
|
3141
|
+
}) : typeof t == "function" ? `[Function: ${t.name || "anonymous"}]` : t;
|
|
3142
|
+
}
|
|
3143
|
+
function deserializeError(t, e = {}) {
|
|
3144
|
+
const { maxDepth: r = Number.POSITIVE_INFINITY } = e;
|
|
3145
|
+
return t instanceof Error ? t : isMinimumViableSerializedError(t) ? destroyCircular({
|
|
3146
|
+
from: t,
|
|
3147
|
+
seen: [],
|
|
3148
|
+
to: newError(t.name),
|
|
3149
|
+
maxDepth: r,
|
|
3150
|
+
depth: 0,
|
|
3151
|
+
serialize: !1
|
|
3152
|
+
}) : new NonError(t);
|
|
3153
|
+
}
|
|
3154
|
+
function isErrorLike(t) {
|
|
3155
|
+
return !!t && typeof t == "object" && typeof t.name == "string" && typeof t.message == "string" && typeof t.stack == "string";
|
|
3156
|
+
}
|
|
3157
|
+
function isMinimumViableSerializedError(t) {
|
|
3158
|
+
return !!t && typeof t == "object" && typeof t.message == "string" && !Array.isArray(t);
|
|
3159
|
+
}
|
|
3160
|
+
async function consumeAPISync(t) {
|
|
3161
|
+
setupTransferHandlers();
|
|
3162
|
+
const e = await NodeSABSyncReceiveMessageTransport.create();
|
|
3163
|
+
return wrapSync(t, e);
|
|
3164
|
+
}
|
|
3165
|
+
function consumeAPI(t, e = void 0) {
|
|
2502
3166
|
setupTransferHandlers();
|
|
2503
|
-
let
|
|
2504
|
-
import.meta.url.startsWith("file://") ?
|
|
2505
|
-
const
|
|
2506
|
-
return new Proxy(
|
|
3167
|
+
let r;
|
|
3168
|
+
import.meta.url.startsWith("file://") ? r = nodeEndpoint(t) : r = t instanceof Worker ? t : windowEndpoint(t, e);
|
|
3169
|
+
const n = wrap(r), i = proxyClone(n);
|
|
3170
|
+
return new Proxy(i, {
|
|
2507
3171
|
get: (o, a) => a === "isConnected" ? async () => {
|
|
2508
3172
|
for (; ; )
|
|
2509
3173
|
try {
|
|
2510
|
-
await runWithTimeout(
|
|
3174
|
+
await runWithTimeout(n.isConnected(), 200);
|
|
2511
3175
|
break;
|
|
2512
3176
|
} catch {
|
|
2513
3177
|
}
|
|
2514
|
-
} :
|
|
3178
|
+
} : n[a]
|
|
2515
3179
|
});
|
|
2516
3180
|
}
|
|
2517
|
-
async function runWithTimeout(
|
|
2518
|
-
return new Promise((
|
|
2519
|
-
setTimeout(s, e),
|
|
3181
|
+
async function runWithTimeout(t, e) {
|
|
3182
|
+
return new Promise((r, s) => {
|
|
3183
|
+
setTimeout(s, e), t.then(r);
|
|
2520
3184
|
});
|
|
2521
3185
|
}
|
|
2522
|
-
function exposeAPI(
|
|
3186
|
+
function exposeAPI(t, e, r) {
|
|
3187
|
+
const { setReady: s, setFailed: n, exposedApi: i } = prepareForExpose(
|
|
3188
|
+
t,
|
|
3189
|
+
e
|
|
3190
|
+
);
|
|
3191
|
+
let o;
|
|
3192
|
+
return r ? o = nodeEndpoint(r) : o = typeof window < "u" ? windowEndpoint(self.parent) : void 0, expose(i, o), [s, n, i];
|
|
3193
|
+
}
|
|
3194
|
+
async function exposeSyncAPI(t, e) {
|
|
3195
|
+
const { setReady: r, setFailed: s, exposedApi: n } = prepareForExpose(t), i = await NodeSABSyncReceiveMessageTransport.create(), o = nodeEndpoint(e);
|
|
3196
|
+
return exposeSync(n, o, i), [r, s, n];
|
|
3197
|
+
}
|
|
3198
|
+
function prepareForExpose(t, e) {
|
|
2523
3199
|
setupTransferHandlers();
|
|
2524
|
-
const
|
|
2525
|
-
let
|
|
2526
|
-
const
|
|
2527
|
-
|
|
2528
|
-
}),
|
|
2529
|
-
get: (
|
|
3200
|
+
const r = Promise.resolve();
|
|
3201
|
+
let s, n;
|
|
3202
|
+
const i = new Promise((l, c) => {
|
|
3203
|
+
s = l, n = c;
|
|
3204
|
+
}), o = proxyClone(t), a = new Proxy(o, {
|
|
3205
|
+
get: (l, c) => c === "isConnected" ? () => r : c === "isReady" ? () => i : c in l ? l[c] : e == null ? void 0 : e[c]
|
|
2530
3206
|
});
|
|
2531
|
-
|
|
2532
|
-
return t ? p = nodeEndpoint(t) : p = typeof window < "u" ? Comlink.windowEndpoint(self.parent) : void 0, Comlink.expose(l, p), [i, n, l];
|
|
3207
|
+
return { setReady: s, setFailed: n, exposedApi: a };
|
|
2533
3208
|
}
|
|
2534
3209
|
let isTransferHandlersSetup = !1;
|
|
2535
3210
|
function setupTransferHandlers() {
|
|
2536
3211
|
if (isTransferHandlersSetup)
|
|
2537
3212
|
return;
|
|
2538
|
-
isTransferHandlersSetup = !0,
|
|
2539
|
-
canHandle: (
|
|
2540
|
-
serialize: (
|
|
3213
|
+
isTransferHandlersSetup = !0, transferHandlers.set("EVENT", {
|
|
3214
|
+
canHandle: (r) => r instanceof CustomEvent,
|
|
3215
|
+
serialize: (r) => [
|
|
2541
3216
|
{
|
|
2542
|
-
detail:
|
|
3217
|
+
detail: r.detail
|
|
2543
3218
|
},
|
|
2544
3219
|
[]
|
|
2545
3220
|
],
|
|
2546
|
-
deserialize: (
|
|
2547
|
-
}),
|
|
3221
|
+
deserialize: (r) => r
|
|
3222
|
+
}), transferHandlers.set("FUNCTION", {
|
|
2548
3223
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
2549
|
-
canHandle: (
|
|
3224
|
+
canHandle: (r) => typeof r == "function",
|
|
2550
3225
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
2551
|
-
serialize(
|
|
2552
|
-
const { port1: s, port2:
|
|
2553
|
-
return
|
|
3226
|
+
serialize(r) {
|
|
3227
|
+
const { port1: s, port2: n } = new MessageChannel();
|
|
3228
|
+
return expose(r, s), [n, [n]];
|
|
2554
3229
|
},
|
|
2555
|
-
deserialize(
|
|
2556
|
-
return
|
|
3230
|
+
deserialize(r) {
|
|
3231
|
+
return r.start(), wrap(r);
|
|
2557
3232
|
}
|
|
2558
|
-
}),
|
|
2559
|
-
canHandle: (
|
|
2560
|
-
serialize(
|
|
2561
|
-
return [
|
|
3233
|
+
}), transferHandlers.set("MESSAGE_PORT", {
|
|
3234
|
+
canHandle: (r) => r instanceof MessagePort,
|
|
3235
|
+
serialize(r) {
|
|
3236
|
+
return [r, [r]];
|
|
2562
3237
|
},
|
|
2563
|
-
deserialize(
|
|
2564
|
-
return
|
|
3238
|
+
deserialize(r) {
|
|
3239
|
+
return r;
|
|
3240
|
+
}
|
|
3241
|
+
}), transferHandlers.set("PHPResponse", {
|
|
3242
|
+
canHandle: (r) => typeof r == "object" && r !== null && "headers" in r && "bytes" in r && "errors" in r && "exitCode" in r && "httpStatusCode" in r,
|
|
3243
|
+
serialize(r) {
|
|
3244
|
+
return [r.toRawData(), []];
|
|
3245
|
+
},
|
|
3246
|
+
deserialize(r) {
|
|
3247
|
+
return PHPResponse.fromRawData(r);
|
|
2565
3248
|
}
|
|
2566
3249
|
});
|
|
2567
|
-
const
|
|
2568
|
-
|
|
2569
|
-
const s = e({ value:
|
|
2570
|
-
return
|
|
3250
|
+
const t = transferHandlers.get("throw"), e = t == null ? void 0 : t.serialize;
|
|
3251
|
+
t.serialize = ({ value: r }) => {
|
|
3252
|
+
const s = e({ value: r });
|
|
3253
|
+
return r.response && (s[0].value.response = r.response), r.source && (s[0].value.source = r.source), s;
|
|
2571
3254
|
};
|
|
2572
3255
|
}
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
3256
|
+
const throwTransferHandler = transferHandlers.get(
|
|
3257
|
+
"throw"
|
|
3258
|
+
), throwTransferHandlerCustom = {
|
|
3259
|
+
canHandle: throwTransferHandler.canHandle,
|
|
3260
|
+
serialize: ({ value: t }) => {
|
|
3261
|
+
let e;
|
|
3262
|
+
return t instanceof Error ? (e = {
|
|
3263
|
+
isError: !0,
|
|
3264
|
+
value: serializeError(t)
|
|
3265
|
+
}, e.value.originalErrorClassName = t.constructor.name) : e = { isError: !1, value: t }, [e, []];
|
|
3266
|
+
},
|
|
3267
|
+
deserialize: (t) => {
|
|
3268
|
+
if (t.isError) {
|
|
3269
|
+
const e = deserializeError(t.value);
|
|
3270
|
+
throw new Error("Comlink method call failed", {
|
|
3271
|
+
cause: e
|
|
3272
|
+
});
|
|
3273
|
+
}
|
|
3274
|
+
throw t.value;
|
|
3275
|
+
}
|
|
3276
|
+
};
|
|
3277
|
+
transferHandlers.set("throw", throwTransferHandlerCustom);
|
|
3278
|
+
function proxyClone(t) {
|
|
3279
|
+
return new Proxy(t, {
|
|
3280
|
+
get(e, r) {
|
|
3281
|
+
switch (typeof e[r]) {
|
|
2577
3282
|
case "function":
|
|
2578
|
-
return (...s) => e[
|
|
3283
|
+
return (...s) => e[r](...s);
|
|
2579
3284
|
case "object":
|
|
2580
|
-
return e[
|
|
3285
|
+
return e[r] === null ? e[r] : proxyClone(e[r]);
|
|
2581
3286
|
case "undefined":
|
|
2582
3287
|
case "number":
|
|
2583
3288
|
case "string":
|
|
2584
|
-
return e[
|
|
3289
|
+
return e[r];
|
|
2585
3290
|
default:
|
|
2586
|
-
return
|
|
3291
|
+
return proxy(e[r]);
|
|
2587
3292
|
}
|
|
2588
3293
|
}
|
|
2589
3294
|
});
|
|
@@ -2606,16 +3311,22 @@ export {
|
|
|
2606
3311
|
__private__dont__use,
|
|
2607
3312
|
applyRewriteRules,
|
|
2608
3313
|
consumeAPI,
|
|
3314
|
+
consumeAPISync,
|
|
2609
3315
|
ensurePathPrefix,
|
|
2610
3316
|
exposeAPI,
|
|
3317
|
+
exposeSyncAPI,
|
|
2611
3318
|
getLoadedRuntime,
|
|
2612
3319
|
getPhpIniEntries,
|
|
2613
3320
|
isExitCode,
|
|
2614
3321
|
iteratePhpFiles as iterateFiles,
|
|
2615
3322
|
loadPHPRuntime,
|
|
3323
|
+
prettyPrintFullStackTrace,
|
|
3324
|
+
printDebugDetails,
|
|
3325
|
+
printResponseDebugDetails,
|
|
2616
3326
|
proxyFileSystem,
|
|
2617
3327
|
removePathPrefix,
|
|
2618
3328
|
rotatePHPRuntime,
|
|
3329
|
+
sandboxedSpawnHandlerFactory,
|
|
2619
3330
|
setPhpIniEntries,
|
|
2620
3331
|
toRelativeUrl,
|
|
2621
3332
|
withPHPIniValues,
|