@php-wasm/universal 0.5.2 → 0.5.4
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 +11 -11
- package/index.js +739 -471
- package/lib/index.d.ts +3 -0
- package/lib/iterate-files.d.ts +26 -0
- package/lib/rethrow-file-system-error.d.ts +5 -0
- package/lib/stream-read-file-from-php.d.ts +5 -0
- package/lib/write-files-stream-to-php.d.ts +5 -0
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -1,15 +1,74 @@
|
|
|
1
|
-
var
|
|
2
|
-
if (!e.has(
|
|
1
|
+
var ne = (r, e, t) => {
|
|
2
|
+
if (!e.has(r))
|
|
3
3
|
throw TypeError("Cannot " + t);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
if (e.has(
|
|
5
|
+
var a = (r, e, t) => (ne(r, e, "read from private field"), t ? t.call(r) : e.get(r)), c = (r, e, t) => {
|
|
6
|
+
if (e.has(r))
|
|
7
7
|
throw TypeError("Cannot add the same private member more than once");
|
|
8
|
-
e instanceof WeakSet ? e.add(
|
|
9
|
-
}, p = (
|
|
10
|
-
var m = (
|
|
11
|
-
|
|
12
|
-
class
|
|
8
|
+
e instanceof WeakSet ? e.add(r) : e.set(r, t);
|
|
9
|
+
}, p = (r, e, t, n) => (ne(r, e, "write to private field"), n ? n.call(r, t) : e.set(r, t), t);
|
|
10
|
+
var m = (r, e, t) => (ne(r, e, "access private method"), t);
|
|
11
|
+
if (typeof File > "u") {
|
|
12
|
+
class r extends Blob {
|
|
13
|
+
constructor(t, n, s) {
|
|
14
|
+
super(t);
|
|
15
|
+
let i;
|
|
16
|
+
s != null && s.lastModified && (i = /* @__PURE__ */ new Date()), (!i || isNaN(i.getFullYear())) && (i = /* @__PURE__ */ new Date()), this.lastModifiedDate = i, this.lastModified = i.getMilliseconds(), this.name = n || "";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
global.File = r;
|
|
20
|
+
}
|
|
21
|
+
function ye(r) {
|
|
22
|
+
return new Promise(function(e, t) {
|
|
23
|
+
r.onload = r.onerror = function(n) {
|
|
24
|
+
r.onload = r.onerror = null, n.type === "load" ? e(r.result) : t(new Error("Failed to read the blob/file"));
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
typeof Blob.prototype.arrayBuffer > "u" && (Blob.prototype.arrayBuffer = function() {
|
|
29
|
+
const e = new FileReader();
|
|
30
|
+
return e.readAsArrayBuffer(this), ye(e);
|
|
31
|
+
});
|
|
32
|
+
typeof Blob.prototype.text > "u" && (Blob.prototype.text = function() {
|
|
33
|
+
const e = new FileReader();
|
|
34
|
+
return e.readAsText(this), ye(e);
|
|
35
|
+
});
|
|
36
|
+
function Le() {
|
|
37
|
+
const r = new Uint8Array([1, 2, 3, 4]), t = new File([r], "test").stream();
|
|
38
|
+
try {
|
|
39
|
+
return t.getReader({ mode: "byob" }), t.getReader({ mode: "byob" }), !0;
|
|
40
|
+
} catch {
|
|
41
|
+
return !1;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
(typeof Blob.prototype.stream > "u" || !Le()) && (Blob.prototype.stream = function() {
|
|
45
|
+
let r = 0;
|
|
46
|
+
const e = this;
|
|
47
|
+
return new ReadableStream({
|
|
48
|
+
type: "bytes",
|
|
49
|
+
// 0.5 MB seems like a reasonable chunk size, let's adjust
|
|
50
|
+
// this if needed.
|
|
51
|
+
autoAllocateChunkSize: 512 * 1024,
|
|
52
|
+
async pull(t) {
|
|
53
|
+
const n = t.byobRequest.view, i = await e.slice(r, r + n.byteLength).arrayBuffer(), o = new Uint8Array(i);
|
|
54
|
+
new Uint8Array(n.buffer).set(o);
|
|
55
|
+
const l = o.byteLength;
|
|
56
|
+
t.byobRequest.respond(l), r += l, r >= e.size && t.close();
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
if (typeof CustomEvent > "u") {
|
|
61
|
+
class r extends Event {
|
|
62
|
+
constructor(t, n = {}) {
|
|
63
|
+
super(t, n), this.detail = n.detail;
|
|
64
|
+
}
|
|
65
|
+
initCustomEvent() {
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
globalThis.CustomEvent = r;
|
|
69
|
+
}
|
|
70
|
+
const ae = Symbol("error"), le = Symbol("message");
|
|
71
|
+
class ie extends Event {
|
|
13
72
|
/**
|
|
14
73
|
* Create a new `ErrorEvent`.
|
|
15
74
|
*
|
|
@@ -18,22 +77,22 @@ class ne extends Event {
|
|
|
18
77
|
* attributes via object members of the same name.
|
|
19
78
|
*/
|
|
20
79
|
constructor(e, t = {}) {
|
|
21
|
-
super(e), this[
|
|
80
|
+
super(e), this[ae] = t.error === void 0 ? null : t.error, this[le] = t.message === void 0 ? "" : t.message;
|
|
22
81
|
}
|
|
23
82
|
get error() {
|
|
24
|
-
return this[
|
|
83
|
+
return this[ae];
|
|
25
84
|
}
|
|
26
85
|
get message() {
|
|
27
|
-
return this[
|
|
86
|
+
return this[le];
|
|
28
87
|
}
|
|
29
88
|
}
|
|
30
|
-
Object.defineProperty(
|
|
31
|
-
Object.defineProperty(
|
|
32
|
-
const
|
|
33
|
-
function Oe(
|
|
34
|
-
return
|
|
89
|
+
Object.defineProperty(ie.prototype, "error", { enumerable: !0 });
|
|
90
|
+
Object.defineProperty(ie.prototype, "message", { enumerable: !0 });
|
|
91
|
+
const Ie = typeof globalThis.ErrorEvent == "function" ? globalThis.ErrorEvent : ie;
|
|
92
|
+
function Oe(r) {
|
|
93
|
+
return r instanceof Error ? "exitCode" in r && (r == null ? void 0 : r.exitCode) === 0 || (r == null ? void 0 : r.name) === "ExitStatus" && "status" in r && r.status === 0 : !1;
|
|
35
94
|
}
|
|
36
|
-
class
|
|
95
|
+
class Ne extends EventTarget {
|
|
37
96
|
constructor() {
|
|
38
97
|
super(...arguments), this.listenersCount = 0;
|
|
39
98
|
}
|
|
@@ -47,63 +106,63 @@ class Ie extends EventTarget {
|
|
|
47
106
|
return this.listenersCount > 0;
|
|
48
107
|
}
|
|
49
108
|
}
|
|
50
|
-
function
|
|
51
|
-
|
|
52
|
-
...
|
|
109
|
+
function qe(r) {
|
|
110
|
+
r.asm = {
|
|
111
|
+
...r.asm
|
|
53
112
|
};
|
|
54
|
-
const e = new
|
|
55
|
-
for (const t in
|
|
56
|
-
if (typeof
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
var
|
|
113
|
+
const e = new Ne();
|
|
114
|
+
for (const t in r.asm)
|
|
115
|
+
if (typeof r.asm[t] == "function") {
|
|
116
|
+
const n = r.asm[t];
|
|
117
|
+
r.asm[t] = function(...s) {
|
|
118
|
+
var i;
|
|
60
119
|
try {
|
|
61
|
-
return
|
|
62
|
-
} catch (
|
|
63
|
-
if (!(
|
|
64
|
-
throw
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
(
|
|
120
|
+
return n(...s);
|
|
121
|
+
} catch (o) {
|
|
122
|
+
if (!(o instanceof Error))
|
|
123
|
+
throw o;
|
|
124
|
+
const l = Me(
|
|
125
|
+
o,
|
|
126
|
+
(i = r.lastAsyncifyStackSource) == null ? void 0 : i.stack
|
|
68
127
|
);
|
|
69
|
-
if (
|
|
128
|
+
if (r.lastAsyncifyStackSource && (o.cause = r.lastAsyncifyStackSource), e.hasListeners()) {
|
|
70
129
|
e.dispatchEvent(
|
|
71
|
-
new
|
|
72
|
-
error:
|
|
73
|
-
message:
|
|
130
|
+
new Ie("error", {
|
|
131
|
+
error: o,
|
|
132
|
+
message: l
|
|
74
133
|
})
|
|
75
134
|
);
|
|
76
135
|
return;
|
|
77
136
|
}
|
|
78
|
-
throw Oe(
|
|
137
|
+
throw Oe(o) || ze(l), o;
|
|
79
138
|
}
|
|
80
139
|
};
|
|
81
140
|
}
|
|
82
141
|
return e;
|
|
83
142
|
}
|
|
84
|
-
let
|
|
85
|
-
function
|
|
86
|
-
return
|
|
143
|
+
let se = [];
|
|
144
|
+
function De() {
|
|
145
|
+
return se;
|
|
87
146
|
}
|
|
88
|
-
function
|
|
89
|
-
if (
|
|
90
|
-
let t =
|
|
147
|
+
function Me(r, e) {
|
|
148
|
+
if (r.message === "unreachable") {
|
|
149
|
+
let t = je;
|
|
91
150
|
e || (t += `
|
|
92
151
|
|
|
93
152
|
This stack trace is lacking. For a better one initialize
|
|
94
153
|
the PHP runtime with { debug: true }, e.g. PHPNode.load('8.1', { debug: true }).
|
|
95
154
|
|
|
96
|
-
`),
|
|
97
|
-
e ||
|
|
155
|
+
`), se = Ge(
|
|
156
|
+
e || r.stack || ""
|
|
98
157
|
);
|
|
99
|
-
for (const
|
|
100
|
-
t += ` * ${
|
|
158
|
+
for (const n of se)
|
|
159
|
+
t += ` * ${n}
|
|
101
160
|
`;
|
|
102
161
|
return t;
|
|
103
162
|
}
|
|
104
|
-
return
|
|
163
|
+
return r.message;
|
|
105
164
|
}
|
|
106
|
-
const
|
|
165
|
+
const je = `
|
|
107
166
|
"unreachable" WASM instruction executed.
|
|
108
167
|
|
|
109
168
|
The typical reason is a PHP function missing from the ASYNCIFY_ONLY
|
|
@@ -127,42 +186,264 @@ the Dockerfile, you'll need to trigger this error again with long stack
|
|
|
127
186
|
traces enabled. In node.js, you can do it using the --stack-trace-limit=100
|
|
128
187
|
CLI option:
|
|
129
188
|
|
|
130
|
-
`,
|
|
131
|
-
let
|
|
132
|
-
function
|
|
133
|
-
if (!
|
|
134
|
-
|
|
135
|
-
${
|
|
136
|
-
${
|
|
137
|
-
for (const e of
|
|
189
|
+
`, ce = "\x1B[41m", We = "\x1B[1m", ue = "\x1B[0m", he = "\x1B[K";
|
|
190
|
+
let de = !1;
|
|
191
|
+
function ze(r) {
|
|
192
|
+
if (!de) {
|
|
193
|
+
de = !0, console.log(`${ce}
|
|
194
|
+
${he}
|
|
195
|
+
${We} WASM ERROR${ue}${ce}`);
|
|
196
|
+
for (const e of r.split(`
|
|
138
197
|
`))
|
|
139
|
-
console.log(`${
|
|
140
|
-
console.log(`${
|
|
198
|
+
console.log(`${he} ${e} `);
|
|
199
|
+
console.log(`${ue}`);
|
|
141
200
|
}
|
|
142
201
|
}
|
|
143
|
-
function
|
|
202
|
+
function Ge(r) {
|
|
144
203
|
try {
|
|
145
|
-
const e =
|
|
204
|
+
const e = r.split(`
|
|
146
205
|
`).slice(1).map((t) => {
|
|
147
|
-
const
|
|
206
|
+
const n = t.trim().substring(3).split(" ");
|
|
148
207
|
return {
|
|
149
|
-
fn:
|
|
208
|
+
fn: n.length >= 2 ? n[0] : "<unknown>",
|
|
150
209
|
isWasm: t.includes("wasm://")
|
|
151
210
|
};
|
|
152
211
|
}).filter(
|
|
153
|
-
({ fn: t, isWasm:
|
|
212
|
+
({ fn: t, isWasm: n }) => n && !t.startsWith("dynCall_") && !t.startsWith("invoke_")
|
|
154
213
|
).map(({ fn: t }) => t);
|
|
155
214
|
return Array.from(new Set(e));
|
|
156
215
|
} catch {
|
|
157
216
|
return [];
|
|
158
217
|
}
|
|
159
218
|
}
|
|
160
|
-
class
|
|
161
|
-
constructor(
|
|
162
|
-
this.
|
|
219
|
+
class we {
|
|
220
|
+
constructor({ concurrency: e }) {
|
|
221
|
+
this._running = 0, this.concurrency = e, this.queue = [];
|
|
222
|
+
}
|
|
223
|
+
get running() {
|
|
224
|
+
return this._running;
|
|
225
|
+
}
|
|
226
|
+
async acquire() {
|
|
227
|
+
for (; ; )
|
|
228
|
+
if (this._running >= this.concurrency)
|
|
229
|
+
await new Promise((e) => this.queue.push(e));
|
|
230
|
+
else {
|
|
231
|
+
this._running++;
|
|
232
|
+
let e = !1;
|
|
233
|
+
return () => {
|
|
234
|
+
e || (e = !0, this._running--, this.queue.length > 0 && this.queue.shift()());
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
async run(e) {
|
|
239
|
+
const t = await this.acquire();
|
|
240
|
+
try {
|
|
241
|
+
return await e();
|
|
242
|
+
} finally {
|
|
243
|
+
t();
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
function ge(...r) {
|
|
248
|
+
let e = r.join("/");
|
|
249
|
+
const t = e[0] === "/", n = e.substring(e.length - 1) === "/";
|
|
250
|
+
return e = oe(e), !e && !t && (e = "."), e && n && (e += "/"), e;
|
|
251
|
+
}
|
|
252
|
+
function Ve(r) {
|
|
253
|
+
if (r === "/")
|
|
254
|
+
return "/";
|
|
255
|
+
r = oe(r);
|
|
256
|
+
const e = r.lastIndexOf("/");
|
|
257
|
+
return e === -1 ? "" : e === 0 ? "/" : r.substr(0, e);
|
|
258
|
+
}
|
|
259
|
+
function oe(r) {
|
|
260
|
+
const e = r[0] === "/";
|
|
261
|
+
return r = Je(
|
|
262
|
+
r.split("/").filter((t) => !!t),
|
|
263
|
+
!e
|
|
264
|
+
).join("/"), (e ? "/" : "") + r.replace(/\/$/, "");
|
|
265
|
+
}
|
|
266
|
+
function Je(r, e) {
|
|
267
|
+
let t = 0;
|
|
268
|
+
for (let n = r.length - 1; n >= 0; n--) {
|
|
269
|
+
const s = r[n];
|
|
270
|
+
s === "." ? r.splice(n, 1) : s === ".." ? (r.splice(n, 1), t++) : t && (r.splice(n, 1), t--);
|
|
271
|
+
}
|
|
272
|
+
if (e)
|
|
273
|
+
for (; t; t--)
|
|
274
|
+
r.unshift("..");
|
|
275
|
+
return r;
|
|
276
|
+
}
|
|
277
|
+
function Ye(...r) {
|
|
278
|
+
const e = new Uint8Array(
|
|
279
|
+
r.reduce((n, s) => n + s.length, 0)
|
|
280
|
+
);
|
|
281
|
+
let t = 0;
|
|
282
|
+
for (const n of r)
|
|
283
|
+
e.set(n, t), t += n.length;
|
|
284
|
+
return e;
|
|
285
|
+
}
|
|
286
|
+
function Ke(r) {
|
|
287
|
+
if (r === void 0) {
|
|
288
|
+
let e = new Uint8Array();
|
|
289
|
+
return new TransformStream({
|
|
290
|
+
transform(t) {
|
|
291
|
+
e = Ye(e, t);
|
|
292
|
+
},
|
|
293
|
+
flush(t) {
|
|
294
|
+
t.enqueue(e);
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
} else {
|
|
298
|
+
const e = new ArrayBuffer(r || 0);
|
|
299
|
+
let t = 0;
|
|
300
|
+
return new TransformStream({
|
|
301
|
+
transform(n) {
|
|
302
|
+
new Uint8Array(e).set(n, t), t += n.byteLength;
|
|
303
|
+
},
|
|
304
|
+
flush(n) {
|
|
305
|
+
n.enqueue(new Uint8Array(e));
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
function Ze(r, e) {
|
|
311
|
+
if (e === 0)
|
|
312
|
+
return new ReadableStream({
|
|
313
|
+
start(s) {
|
|
314
|
+
s.close();
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
const t = r.getReader({ mode: "byob" });
|
|
318
|
+
let n = 0;
|
|
319
|
+
return new ReadableStream({
|
|
320
|
+
async pull(s) {
|
|
321
|
+
const { value: i, done: o } = await t.read(
|
|
322
|
+
new Uint8Array(e - n)
|
|
323
|
+
);
|
|
324
|
+
if (o) {
|
|
325
|
+
t.releaseLock(), s.close();
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
n += i.length, s.enqueue(i), n >= e && (t.releaseLock(), s.close());
|
|
329
|
+
},
|
|
330
|
+
cancel() {
|
|
331
|
+
t.cancel();
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
async function Qe(r, e) {
|
|
336
|
+
return e !== void 0 && (r = Ze(r, e)), await r.pipeThrough(Ke(e)).getReader().read().then(({ value: t }) => t);
|
|
337
|
+
}
|
|
338
|
+
class Xe extends File {
|
|
339
|
+
/**
|
|
340
|
+
* Creates a new StreamedFile instance.
|
|
341
|
+
*
|
|
342
|
+
* @param readableStream The readable stream containing the file data.
|
|
343
|
+
* @param name The name of the file.
|
|
344
|
+
* @param type The MIME type of the file.
|
|
345
|
+
*/
|
|
346
|
+
constructor(e, t, n) {
|
|
347
|
+
super([], t, { type: n }), this.readableStream = e;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Overrides the slice() method of the File class.
|
|
351
|
+
*
|
|
352
|
+
* @returns A Blob representing a portion of the file.
|
|
353
|
+
*/
|
|
354
|
+
slice() {
|
|
355
|
+
throw new Error("slice() is not possible on a StreamedFile");
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Returns the readable stream associated with the file.
|
|
359
|
+
*
|
|
360
|
+
* @returns The readable stream.
|
|
361
|
+
*/
|
|
362
|
+
stream() {
|
|
363
|
+
return this.readableStream;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Loads the file data into memory and then returns it as a string.
|
|
367
|
+
*
|
|
368
|
+
* @returns File data as text.
|
|
369
|
+
*/
|
|
370
|
+
async text() {
|
|
371
|
+
return new TextDecoder().decode(await this.arrayBuffer());
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Loads the file data into memory and then returns it as an ArrayBuffer.
|
|
375
|
+
*
|
|
376
|
+
* @returns File data as an ArrayBuffer.
|
|
377
|
+
*/
|
|
378
|
+
async arrayBuffer() {
|
|
379
|
+
return await Qe(this.stream());
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
ReadableStream.prototype[Symbol.asyncIterator] || (ReadableStream.prototype[Symbol.asyncIterator] = async function* () {
|
|
383
|
+
const r = this.getReader();
|
|
384
|
+
try {
|
|
385
|
+
for (; ; ) {
|
|
386
|
+
const { done: e, value: t } = await r.read();
|
|
387
|
+
if (e)
|
|
388
|
+
return;
|
|
389
|
+
yield t;
|
|
390
|
+
}
|
|
391
|
+
} finally {
|
|
392
|
+
r.releaseLock();
|
|
393
|
+
}
|
|
394
|
+
}, ReadableStream.prototype.iterate = // @ts-ignore
|
|
395
|
+
ReadableStream.prototype[Symbol.asyncIterator]);
|
|
396
|
+
function et(r, e) {
|
|
397
|
+
return new ReadableStream({
|
|
398
|
+
async pull(t) {
|
|
399
|
+
const n = await r.readFileAsBuffer(e);
|
|
400
|
+
t.enqueue(n), t.close();
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
async function* bt(r, e, {
|
|
405
|
+
relativePaths: t = !0,
|
|
406
|
+
pathPrefix: n,
|
|
407
|
+
exceptPaths: s = []
|
|
408
|
+
} = {}) {
|
|
409
|
+
e = oe(e);
|
|
410
|
+
const i = [e];
|
|
411
|
+
for (; i.length; ) {
|
|
412
|
+
const o = i.pop();
|
|
413
|
+
if (!o)
|
|
414
|
+
return;
|
|
415
|
+
const l = await r.listFiles(o);
|
|
416
|
+
for (const d of l) {
|
|
417
|
+
const f = `${o}/${d}`;
|
|
418
|
+
if (s.includes(f.substring(e.length + 1)))
|
|
419
|
+
continue;
|
|
420
|
+
await r.isDir(f) ? i.push(f) : yield new Xe(
|
|
421
|
+
et(r, f),
|
|
422
|
+
t ? ge(
|
|
423
|
+
n || "",
|
|
424
|
+
f.substring(e.length + 1)
|
|
425
|
+
) : f
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
function Pt(r, e) {
|
|
431
|
+
return new WritableStream({
|
|
432
|
+
async write(t) {
|
|
433
|
+
const n = ge(e, t.name);
|
|
434
|
+
t.type === "directory" ? await r.mkdir(n) : (await r.mkdir(Ve(n)), await r.writeFile(
|
|
435
|
+
n,
|
|
436
|
+
new Uint8Array(await t.arrayBuffer())
|
|
437
|
+
));
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
class H {
|
|
442
|
+
constructor(e, t, n, s = "", i = 0) {
|
|
443
|
+
this.httpStatusCode = e, this.headers = t, this.bytes = n, this.exitCode = i, this.errors = s;
|
|
163
444
|
}
|
|
164
445
|
static fromRawData(e) {
|
|
165
|
-
return new
|
|
446
|
+
return new H(
|
|
166
447
|
e.httpStatusCode,
|
|
167
448
|
e.headers,
|
|
168
449
|
e.bytes,
|
|
@@ -192,7 +473,7 @@ class F {
|
|
|
192
473
|
return new TextDecoder().decode(this.bytes);
|
|
193
474
|
}
|
|
194
475
|
}
|
|
195
|
-
const
|
|
476
|
+
const be = [
|
|
196
477
|
"8.3",
|
|
197
478
|
"8.2",
|
|
198
479
|
"8.1",
|
|
@@ -202,24 +483,24 @@ const me = [
|
|
|
202
483
|
"7.2",
|
|
203
484
|
"7.1",
|
|
204
485
|
"7.0"
|
|
205
|
-
],
|
|
486
|
+
], Et = be[0], St = be, tt = [
|
|
206
487
|
"iconv",
|
|
207
488
|
"mbstring",
|
|
208
489
|
"xml-bundle",
|
|
209
490
|
"gd"
|
|
210
|
-
],
|
|
211
|
-
"kitchen-sink":
|
|
491
|
+
], vt = {
|
|
492
|
+
"kitchen-sink": tt
|
|
212
493
|
};
|
|
213
|
-
var
|
|
214
|
-
class
|
|
494
|
+
var _, A;
|
|
495
|
+
class rt {
|
|
215
496
|
/**
|
|
216
497
|
* @param server - The PHP server to browse.
|
|
217
498
|
* @param config - The browser configuration.
|
|
218
499
|
*/
|
|
219
500
|
constructor(e, t = {}) {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
this.requestHandler = e, p(this,
|
|
501
|
+
c(this, _, void 0);
|
|
502
|
+
c(this, A, void 0);
|
|
503
|
+
this.requestHandler = e, p(this, _, {}), p(this, A, {
|
|
223
504
|
handleRedirects: !1,
|
|
224
505
|
maxRedirects: 4,
|
|
225
506
|
...t
|
|
@@ -240,28 +521,28 @@ class We {
|
|
|
240
521
|
* @returns PHPRequestHandler response.
|
|
241
522
|
*/
|
|
242
523
|
async request(e, t = 0) {
|
|
243
|
-
const
|
|
524
|
+
const n = await this.requestHandler.request({
|
|
244
525
|
...e,
|
|
245
526
|
headers: {
|
|
246
527
|
...e.headers,
|
|
247
528
|
cookie: this.serializeCookies()
|
|
248
529
|
}
|
|
249
530
|
});
|
|
250
|
-
if (
|
|
251
|
-
const
|
|
252
|
-
|
|
531
|
+
if (n.headers["set-cookie"] && this.setCookies(n.headers["set-cookie"]), a(this, A).handleRedirects && n.headers.location && t < a(this, A).maxRedirects) {
|
|
532
|
+
const s = new URL(
|
|
533
|
+
n.headers.location[0],
|
|
253
534
|
this.requestHandler.absoluteUrl
|
|
254
535
|
);
|
|
255
536
|
return this.request(
|
|
256
537
|
{
|
|
257
|
-
url:
|
|
538
|
+
url: s.toString(),
|
|
258
539
|
method: "GET",
|
|
259
540
|
headers: {}
|
|
260
541
|
},
|
|
261
542
|
t + 1
|
|
262
543
|
);
|
|
263
544
|
}
|
|
264
|
-
return
|
|
545
|
+
return n;
|
|
265
546
|
}
|
|
266
547
|
/** @inheritDoc */
|
|
267
548
|
pathToInternalUrl(e) {
|
|
@@ -284,60 +565,32 @@ class We {
|
|
|
284
565
|
try {
|
|
285
566
|
if (!t.includes("="))
|
|
286
567
|
continue;
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
} catch (
|
|
290
|
-
console.error(
|
|
568
|
+
const n = t.indexOf("="), s = t.substring(0, n), i = t.substring(n + 1).split(";")[0];
|
|
569
|
+
a(this, _)[s] = i;
|
|
570
|
+
} catch (n) {
|
|
571
|
+
console.error(n);
|
|
291
572
|
}
|
|
292
573
|
}
|
|
293
574
|
serializeCookies() {
|
|
294
575
|
const e = [];
|
|
295
|
-
for (const t in
|
|
296
|
-
e.push(`${t}=${
|
|
576
|
+
for (const t in a(this, _))
|
|
577
|
+
e.push(`${t}=${a(this, _)[t]}`);
|
|
297
578
|
return e.join("; ");
|
|
298
579
|
}
|
|
299
580
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
}
|
|
305
|
-
get running() {
|
|
306
|
-
return this._running;
|
|
307
|
-
}
|
|
308
|
-
async acquire() {
|
|
309
|
-
for (; ; )
|
|
310
|
-
if (this._running >= this.concurrency)
|
|
311
|
-
await new Promise((e) => this.queue.push(e));
|
|
312
|
-
else {
|
|
313
|
-
this._running++;
|
|
314
|
-
let e = !1;
|
|
315
|
-
return () => {
|
|
316
|
-
e || (e = !0, this._running--, this.queue.length > 0 && this.queue.shift()());
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
async run(e) {
|
|
321
|
-
const t = await this.acquire();
|
|
322
|
-
try {
|
|
323
|
-
return await e();
|
|
324
|
-
} finally {
|
|
325
|
-
t();
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
const ze = "http://example.com";
|
|
330
|
-
function ue(s) {
|
|
331
|
-
return s.toString().substring(s.origin.length);
|
|
581
|
+
_ = new WeakMap(), A = new WeakMap();
|
|
582
|
+
const nt = "http://example.com";
|
|
583
|
+
function fe(r) {
|
|
584
|
+
return r.toString().substring(r.origin.length);
|
|
332
585
|
}
|
|
333
|
-
function
|
|
334
|
-
return !e || !
|
|
586
|
+
function pe(r, e) {
|
|
587
|
+
return !e || !r.startsWith(e) ? r : r.substring(e.length);
|
|
335
588
|
}
|
|
336
|
-
function
|
|
337
|
-
return !e ||
|
|
589
|
+
function st(r, e) {
|
|
590
|
+
return !e || r.startsWith(e) ? r : e + r;
|
|
338
591
|
}
|
|
339
|
-
var
|
|
340
|
-
class
|
|
592
|
+
var g, $, O, F, U, b, B, L, M, Pe, j, Ee, W, Se;
|
|
593
|
+
class it {
|
|
341
594
|
/**
|
|
342
595
|
* @param php - The PHP instance.
|
|
343
596
|
* @param config - Request Handler configuration.
|
|
@@ -349,7 +602,7 @@ class Ve {
|
|
|
349
602
|
* @param fsPath - Absolute path of the static file to serve.
|
|
350
603
|
* @returns The response.
|
|
351
604
|
*/
|
|
352
|
-
|
|
605
|
+
c(this, M);
|
|
353
606
|
/**
|
|
354
607
|
* Runs the requested PHP file with all the request and $_SERVER
|
|
355
608
|
* superglobals populated.
|
|
@@ -357,7 +610,7 @@ class Ve {
|
|
|
357
610
|
* @param request - The request.
|
|
358
611
|
* @returns The response.
|
|
359
612
|
*/
|
|
360
|
-
|
|
613
|
+
c(this, j);
|
|
361
614
|
/**
|
|
362
615
|
* Resolve the requested path to the filesystem path of the requested PHP file.
|
|
363
616
|
*
|
|
@@ -367,31 +620,31 @@ class Ve {
|
|
|
367
620
|
* @throws {Error} If the requested path doesn't exist.
|
|
368
621
|
* @returns The resolved filesystem path.
|
|
369
622
|
*/
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
p(this, L, new
|
|
623
|
+
c(this, W);
|
|
624
|
+
c(this, g, void 0);
|
|
625
|
+
c(this, $, void 0);
|
|
626
|
+
c(this, O, void 0);
|
|
627
|
+
c(this, F, void 0);
|
|
628
|
+
c(this, U, void 0);
|
|
629
|
+
c(this, b, void 0);
|
|
630
|
+
c(this, B, void 0);
|
|
631
|
+
c(this, L, void 0);
|
|
632
|
+
p(this, L, new we({ concurrency: 1 }));
|
|
380
633
|
const {
|
|
381
|
-
documentRoot:
|
|
382
|
-
absoluteUrl:
|
|
634
|
+
documentRoot: n = "/www/",
|
|
635
|
+
absoluteUrl: s = typeof location == "object" ? location == null ? void 0 : location.href : ""
|
|
383
636
|
} = t;
|
|
384
|
-
this.php = e, p(this,
|
|
385
|
-
const
|
|
386
|
-
p(this,
|
|
387
|
-
const
|
|
388
|
-
p(this,
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
].join("")), p(this,
|
|
392
|
-
`${
|
|
393
|
-
|
|
394
|
-
|
|
637
|
+
this.php = e, p(this, g, n);
|
|
638
|
+
const i = new URL(s);
|
|
639
|
+
p(this, O, i.hostname), p(this, F, i.port ? Number(i.port) : i.protocol === "https:" ? 443 : 80), p(this, $, (i.protocol || "").replace(":", ""));
|
|
640
|
+
const o = a(this, F) !== 443 && a(this, F) !== 80;
|
|
641
|
+
p(this, U, [
|
|
642
|
+
a(this, O),
|
|
643
|
+
o ? `:${a(this, F)}` : ""
|
|
644
|
+
].join("")), p(this, b, i.pathname.replace(/\/+$/, "")), p(this, B, [
|
|
645
|
+
`${a(this, $)}://`,
|
|
646
|
+
a(this, U),
|
|
647
|
+
a(this, b)
|
|
395
648
|
].join(""));
|
|
396
649
|
}
|
|
397
650
|
/** @inheritDoc */
|
|
@@ -401,34 +654,34 @@ class Ve {
|
|
|
401
654
|
/** @inheritDoc */
|
|
402
655
|
internalUrlToPath(e) {
|
|
403
656
|
const t = new URL(e);
|
|
404
|
-
return t.pathname.startsWith(
|
|
657
|
+
return t.pathname.startsWith(a(this, b)) && (t.pathname = t.pathname.slice(a(this, b).length)), fe(t);
|
|
405
658
|
}
|
|
406
659
|
get isRequestRunning() {
|
|
407
|
-
return
|
|
660
|
+
return a(this, L).running > 0;
|
|
408
661
|
}
|
|
409
662
|
/** @inheritDoc */
|
|
410
663
|
get absoluteUrl() {
|
|
411
|
-
return
|
|
664
|
+
return a(this, B);
|
|
412
665
|
}
|
|
413
666
|
/** @inheritDoc */
|
|
414
667
|
get documentRoot() {
|
|
415
|
-
return
|
|
668
|
+
return a(this, g);
|
|
416
669
|
}
|
|
417
670
|
/** @inheritDoc */
|
|
418
671
|
async request(e) {
|
|
419
|
-
const t = e.url.startsWith("http://") || e.url.startsWith("https://"),
|
|
672
|
+
const t = e.url.startsWith("http://") || e.url.startsWith("https://"), n = new URL(
|
|
420
673
|
e.url,
|
|
421
|
-
t ? void 0 :
|
|
422
|
-
),
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
),
|
|
426
|
-
return
|
|
674
|
+
t ? void 0 : nt
|
|
675
|
+
), s = pe(
|
|
676
|
+
n.pathname,
|
|
677
|
+
a(this, b)
|
|
678
|
+
), i = `${a(this, g)}${s}`;
|
|
679
|
+
return lt(i) ? await m(this, j, Ee).call(this, e, n) : m(this, M, Pe).call(this, i);
|
|
427
680
|
}
|
|
428
681
|
}
|
|
429
|
-
|
|
682
|
+
g = new WeakMap(), $ = new WeakMap(), O = new WeakMap(), F = new WeakMap(), U = new WeakMap(), b = new WeakMap(), B = new WeakMap(), L = new WeakMap(), M = new WeakSet(), Pe = function(e) {
|
|
430
683
|
if (!this.php.fileExists(e))
|
|
431
|
-
return new
|
|
684
|
+
return new H(
|
|
432
685
|
404,
|
|
433
686
|
// Let the service worker know that no static file was found
|
|
434
687
|
// and that it's okay to issue a real fetch() to the server.
|
|
@@ -438,103 +691,103 @@ b = new WeakMap(), A = new WeakMap(), N = new WeakMap(), k = new WeakMap(), O =
|
|
|
438
691
|
new TextEncoder().encode("404 File not found")
|
|
439
692
|
);
|
|
440
693
|
const t = this.php.readFileAsBuffer(e);
|
|
441
|
-
return new
|
|
694
|
+
return new H(
|
|
442
695
|
200,
|
|
443
696
|
{
|
|
444
697
|
"content-length": [`${t.byteLength}`],
|
|
445
698
|
// @TODO: Infer the content-type from the arrayBuffer instead of the file path.
|
|
446
699
|
// The code below won't return the correct mime-type if the extension
|
|
447
700
|
// was tampered with.
|
|
448
|
-
"content-type": [
|
|
701
|
+
"content-type": [at(e)],
|
|
449
702
|
"accept-ranges": ["bytes"],
|
|
450
703
|
"cache-control": ["public, max-age=0"]
|
|
451
704
|
},
|
|
452
705
|
t
|
|
453
706
|
);
|
|
454
|
-
}, j = new WeakSet(),
|
|
455
|
-
var
|
|
456
|
-
const
|
|
707
|
+
}, j = new WeakSet(), Ee = async function(e, t) {
|
|
708
|
+
var s;
|
|
709
|
+
const n = await a(this, L).acquire();
|
|
457
710
|
try {
|
|
458
|
-
this.php.addServerGlobalEntry("DOCUMENT_ROOT",
|
|
711
|
+
this.php.addServerGlobalEntry("DOCUMENT_ROOT", a(this, g)), this.php.addServerGlobalEntry(
|
|
459
712
|
"HTTPS",
|
|
460
|
-
|
|
713
|
+
a(this, B).startsWith("https://") ? "on" : ""
|
|
461
714
|
);
|
|
462
|
-
let
|
|
463
|
-
const
|
|
464
|
-
host:
|
|
465
|
-
|
|
466
|
-
},
|
|
715
|
+
let i = "GET";
|
|
716
|
+
const o = {
|
|
717
|
+
host: a(this, U),
|
|
718
|
+
...Be(e.headers || {})
|
|
719
|
+
}, l = [];
|
|
467
720
|
if (e.files && Object.keys(e.files).length) {
|
|
468
|
-
|
|
469
|
-
for (const
|
|
470
|
-
const
|
|
471
|
-
|
|
472
|
-
key:
|
|
473
|
-
name:
|
|
474
|
-
type:
|
|
475
|
-
data: new Uint8Array(await
|
|
721
|
+
i = "POST";
|
|
722
|
+
for (const h in e.files) {
|
|
723
|
+
const S = e.files[h];
|
|
724
|
+
l.push({
|
|
725
|
+
key: h,
|
|
726
|
+
name: S.name,
|
|
727
|
+
type: S.type,
|
|
728
|
+
data: new Uint8Array(await S.arrayBuffer())
|
|
476
729
|
});
|
|
477
730
|
}
|
|
478
|
-
(
|
|
731
|
+
(s = o["content-type"]) != null && s.startsWith("multipart/form-data") && (e.formData = ot(
|
|
479
732
|
e.body || ""
|
|
480
|
-
),
|
|
733
|
+
), o["content-type"] = "application/x-www-form-urlencoded", delete e.body);
|
|
481
734
|
}
|
|
482
735
|
let d;
|
|
483
|
-
e.formData !== void 0 ? (
|
|
736
|
+
e.formData !== void 0 ? (i = "POST", o["content-type"] = o["content-type"] || "application/x-www-form-urlencoded", d = new URLSearchParams(
|
|
484
737
|
e.formData
|
|
485
738
|
).toString()) : d = e.body;
|
|
486
739
|
let f;
|
|
487
740
|
try {
|
|
488
|
-
f = m(this,
|
|
741
|
+
f = m(this, W, Se).call(this, t.pathname);
|
|
489
742
|
} catch {
|
|
490
|
-
return new
|
|
743
|
+
return new H(
|
|
491
744
|
404,
|
|
492
745
|
{},
|
|
493
746
|
new TextEncoder().encode("404 File not found")
|
|
494
747
|
);
|
|
495
748
|
}
|
|
496
749
|
return await this.php.run({
|
|
497
|
-
relativeUri:
|
|
498
|
-
|
|
499
|
-
|
|
750
|
+
relativeUri: st(
|
|
751
|
+
fe(t),
|
|
752
|
+
a(this, b)
|
|
500
753
|
),
|
|
501
|
-
protocol:
|
|
502
|
-
method: e.method ||
|
|
754
|
+
protocol: a(this, $),
|
|
755
|
+
method: e.method || i,
|
|
503
756
|
body: d,
|
|
504
|
-
fileInfos:
|
|
757
|
+
fileInfos: l,
|
|
505
758
|
scriptPath: f,
|
|
506
|
-
headers:
|
|
759
|
+
headers: o
|
|
507
760
|
});
|
|
508
761
|
} finally {
|
|
509
|
-
|
|
762
|
+
n();
|
|
510
763
|
}
|
|
511
|
-
},
|
|
512
|
-
let t =
|
|
764
|
+
}, W = new WeakSet(), Se = function(e) {
|
|
765
|
+
let t = pe(e, a(this, b));
|
|
513
766
|
t.includes(".php") ? t = t.split(".php")[0] + ".php" : (t.endsWith("/") || (t += "/"), t.endsWith("index.php") || (t += "index.php"));
|
|
514
|
-
const
|
|
515
|
-
if (this.php.fileExists(
|
|
516
|
-
return
|
|
517
|
-
if (!this.php.fileExists(`${
|
|
518
|
-
throw new Error(`File not found: ${
|
|
519
|
-
return `${
|
|
767
|
+
const n = `${a(this, g)}${t}`;
|
|
768
|
+
if (this.php.fileExists(n))
|
|
769
|
+
return n;
|
|
770
|
+
if (!this.php.fileExists(`${a(this, g)}/index.php`))
|
|
771
|
+
throw new Error(`File not found: ${n}`);
|
|
772
|
+
return `${a(this, g)}/index.php`;
|
|
520
773
|
};
|
|
521
|
-
function
|
|
522
|
-
const e = {}, t =
|
|
774
|
+
function ot(r) {
|
|
775
|
+
const e = {}, t = r.match(/--(.*)\r\n/);
|
|
523
776
|
if (!t)
|
|
524
777
|
return e;
|
|
525
|
-
const
|
|
526
|
-
return
|
|
527
|
-
const
|
|
778
|
+
const n = t[1], s = r.split(`--${n}`);
|
|
779
|
+
return s.shift(), s.pop(), s.forEach((i) => {
|
|
780
|
+
const o = i.indexOf(`\r
|
|
528
781
|
\r
|
|
529
|
-
`),
|
|
782
|
+
`), l = i.substring(0, o).trim(), d = i.substring(o + 4).trim(), f = l.match(/name="([^"]+)"/);
|
|
530
783
|
if (f) {
|
|
531
|
-
const
|
|
532
|
-
e[
|
|
784
|
+
const h = f[1];
|
|
785
|
+
e[h] = d;
|
|
533
786
|
}
|
|
534
787
|
}), e;
|
|
535
788
|
}
|
|
536
|
-
function
|
|
537
|
-
switch (
|
|
789
|
+
function at(r) {
|
|
790
|
+
switch (r.split(".").pop()) {
|
|
538
791
|
case "css":
|
|
539
792
|
return "text/css";
|
|
540
793
|
case "js":
|
|
@@ -573,16 +826,16 @@ function Ye(s) {
|
|
|
573
826
|
return "application-octet-stream";
|
|
574
827
|
}
|
|
575
828
|
}
|
|
576
|
-
function
|
|
577
|
-
return
|
|
829
|
+
function lt(r) {
|
|
830
|
+
return ct(r) || ut(r);
|
|
578
831
|
}
|
|
579
|
-
function
|
|
580
|
-
return
|
|
832
|
+
function ct(r) {
|
|
833
|
+
return r.endsWith(".php") || r.includes(".php/");
|
|
581
834
|
}
|
|
582
|
-
function
|
|
583
|
-
return !
|
|
835
|
+
function ut(r) {
|
|
836
|
+
return !r.split("/").pop().includes(".");
|
|
584
837
|
}
|
|
585
|
-
const
|
|
838
|
+
const D = {
|
|
586
839
|
0: "No error occurred. System call completed successfully.",
|
|
587
840
|
1: "Argument list too long.",
|
|
588
841
|
2: "Permission denied.",
|
|
@@ -661,75 +914,80 @@ const pe = {
|
|
|
661
914
|
75: "Cross-device link.",
|
|
662
915
|
76: "Extension: Capabilities insufficient."
|
|
663
916
|
};
|
|
664
|
-
function
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
917
|
+
function ht(r) {
|
|
918
|
+
const e = typeof r == "object" ? r == null ? void 0 : r.errno : null;
|
|
919
|
+
if (e in D)
|
|
920
|
+
return D[e];
|
|
921
|
+
}
|
|
922
|
+
function P(r = "") {
|
|
923
|
+
return function(t, n, s) {
|
|
924
|
+
const i = s.value;
|
|
925
|
+
s.value = function(...o) {
|
|
668
926
|
try {
|
|
669
|
-
return
|
|
670
|
-
} catch (
|
|
671
|
-
const d = typeof
|
|
672
|
-
if (d in
|
|
673
|
-
const f =
|
|
674
|
-
throw new Error(`${
|
|
675
|
-
cause:
|
|
927
|
+
return i.apply(this, o);
|
|
928
|
+
} catch (l) {
|
|
929
|
+
const d = typeof l == "object" ? l == null ? void 0 : l.errno : null;
|
|
930
|
+
if (d in D) {
|
|
931
|
+
const f = D[d], h = typeof o[0] == "string" ? o[0] : null, S = h !== null ? r.replaceAll("{path}", h) : r;
|
|
932
|
+
throw new Error(`${S}: ${f}`, {
|
|
933
|
+
cause: l
|
|
676
934
|
});
|
|
677
935
|
}
|
|
678
|
-
throw
|
|
936
|
+
throw l;
|
|
679
937
|
}
|
|
680
938
|
};
|
|
681
939
|
};
|
|
682
940
|
}
|
|
683
|
-
const
|
|
684
|
-
async function
|
|
685
|
-
const [
|
|
686
|
-
onAbort(
|
|
687
|
-
|
|
941
|
+
const dt = Symbol("RuntimeId"), q = /* @__PURE__ */ new Map();
|
|
942
|
+
async function Rt(r, e = {}, t = []) {
|
|
943
|
+
const [n, s, i] = me(), [o, l] = me(), d = r.init(pt, {
|
|
944
|
+
onAbort(h) {
|
|
945
|
+
i(h), l(), console.error(h);
|
|
688
946
|
},
|
|
689
947
|
ENV: {},
|
|
690
948
|
// Emscripten sometimes prepends a '/' to the path, which
|
|
691
949
|
// breaks vite dev mode. An identity `locateFile` function
|
|
692
950
|
// fixes it.
|
|
693
|
-
locateFile: (
|
|
951
|
+
locateFile: (h) => h,
|
|
694
952
|
...e,
|
|
695
953
|
noInitialRun: !0,
|
|
696
954
|
onRuntimeInitialized() {
|
|
697
|
-
e.onRuntimeInitialized && e.onRuntimeInitialized(),
|
|
955
|
+
e.onRuntimeInitialized && e.onRuntimeInitialized(), s();
|
|
698
956
|
},
|
|
699
|
-
monitorRunDependencies(
|
|
700
|
-
|
|
957
|
+
monitorRunDependencies(h) {
|
|
958
|
+
h === 0 && (delete d.monitorRunDependencies, l());
|
|
701
959
|
}
|
|
702
960
|
});
|
|
703
961
|
await Promise.all(
|
|
704
962
|
t.map(
|
|
705
|
-
({ default:
|
|
963
|
+
({ default: h }) => h(d)
|
|
706
964
|
)
|
|
707
|
-
), t.length ||
|
|
965
|
+
), t.length || l(), await o, await n;
|
|
708
966
|
const f = q.size;
|
|
709
|
-
return d.originalExit = d._exit, d._exit = function(
|
|
710
|
-
return q.delete(f), d.originalExit(
|
|
711
|
-
}, d[
|
|
967
|
+
return d.originalExit = d._exit, d._exit = function(h) {
|
|
968
|
+
return q.delete(f), d.originalExit(h);
|
|
969
|
+
}, d[dt] = f, q.set(f, d), f;
|
|
712
970
|
}
|
|
713
|
-
function
|
|
714
|
-
return q.get(
|
|
971
|
+
function ft(r) {
|
|
972
|
+
return q.get(r);
|
|
715
973
|
}
|
|
716
|
-
const
|
|
717
|
-
var
|
|
718
|
-
return typeof process < "u" && ((
|
|
719
|
-
}(),
|
|
720
|
-
const
|
|
721
|
-
|
|
974
|
+
const pt = function() {
|
|
975
|
+
var r;
|
|
976
|
+
return typeof process < "u" && ((r = process.release) == null ? void 0 : r.name) === "node" ? "NODE" : typeof window < "u" ? "WEB" : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? "WORKER" : "NODE";
|
|
977
|
+
}(), me = () => {
|
|
978
|
+
const r = [], e = new Promise((t, n) => {
|
|
979
|
+
r.push(t, n);
|
|
722
980
|
});
|
|
723
|
-
return
|
|
981
|
+
return r.unshift(e), r;
|
|
724
982
|
};
|
|
725
|
-
var
|
|
726
|
-
for (var
|
|
727
|
-
(
|
|
728
|
-
return
|
|
983
|
+
var mt = Object.defineProperty, yt = Object.getOwnPropertyDescriptor, E = (r, e, t, n) => {
|
|
984
|
+
for (var s = n > 1 ? void 0 : n ? yt(e, t) : e, i = r.length - 1, o; i >= 0; i--)
|
|
985
|
+
(o = r[i]) && (s = (n ? o(e, t, s) : o(s)) || s);
|
|
986
|
+
return n && s && mt(e, t, s), s;
|
|
729
987
|
};
|
|
730
|
-
const y = "string",
|
|
731
|
-
var
|
|
732
|
-
class
|
|
988
|
+
const y = "string", C = "number", u = Symbol("__private__dont__use");
|
|
989
|
+
var k, R, T, x, v, I, N, z, ve, G, Re, V, xe, J, _e, Y, Fe, K, ke, Z, Te, Q, Ce, X, He, ee, Ae, te, $e, re, Ue;
|
|
990
|
+
class w {
|
|
733
991
|
/**
|
|
734
992
|
* Initializes a PHP runtime.
|
|
735
993
|
*
|
|
@@ -738,15 +996,15 @@ class g {
|
|
|
738
996
|
* @param serverOptions - Optional. Options for the PHPRequestHandler. If undefined, no request handler will be initialized.
|
|
739
997
|
*/
|
|
740
998
|
constructor(e, t) {
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
999
|
+
c(this, z);
|
|
1000
|
+
c(this, G);
|
|
1001
|
+
c(this, V);
|
|
1002
|
+
c(this, J);
|
|
1003
|
+
c(this, Y);
|
|
1004
|
+
c(this, K);
|
|
1005
|
+
c(this, Z);
|
|
1006
|
+
c(this, Q);
|
|
1007
|
+
c(this, X);
|
|
750
1008
|
/**
|
|
751
1009
|
* Adds file information to $_FILES superglobal in PHP.
|
|
752
1010
|
*
|
|
@@ -756,40 +1014,40 @@ class g {
|
|
|
756
1014
|
*
|
|
757
1015
|
* @param fileInfo - File details
|
|
758
1016
|
*/
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
p(this,
|
|
770
|
-
new
|
|
1017
|
+
c(this, ee);
|
|
1018
|
+
c(this, te);
|
|
1019
|
+
c(this, re);
|
|
1020
|
+
c(this, k, void 0);
|
|
1021
|
+
c(this, R, void 0);
|
|
1022
|
+
c(this, T, void 0);
|
|
1023
|
+
c(this, x, void 0);
|
|
1024
|
+
c(this, v, void 0);
|
|
1025
|
+
c(this, I, void 0);
|
|
1026
|
+
c(this, N, void 0);
|
|
1027
|
+
p(this, k, []), p(this, R, !1), p(this, T, null), p(this, x, {}), p(this, v, /* @__PURE__ */ new Map()), p(this, I, []), p(this, N, new we({ concurrency: 1 })), e !== void 0 && this.initializeRuntime(e), t && (this.requestHandler = new rt(
|
|
1028
|
+
new it(this, t)
|
|
771
1029
|
));
|
|
772
1030
|
}
|
|
773
1031
|
addEventListener(e, t) {
|
|
774
|
-
|
|
1032
|
+
a(this, v).has(e) || a(this, v).set(e, /* @__PURE__ */ new Set()), a(this, v).get(e).add(t);
|
|
775
1033
|
}
|
|
776
1034
|
removeEventListener(e, t) {
|
|
777
|
-
var
|
|
778
|
-
(
|
|
1035
|
+
var n;
|
|
1036
|
+
(n = a(this, v).get(e)) == null || n.delete(t);
|
|
779
1037
|
}
|
|
780
1038
|
dispatchEvent(e) {
|
|
781
|
-
const t =
|
|
1039
|
+
const t = a(this, v).get(e.type);
|
|
782
1040
|
if (t)
|
|
783
|
-
for (const
|
|
784
|
-
|
|
1041
|
+
for (const n of t)
|
|
1042
|
+
n(e);
|
|
785
1043
|
}
|
|
786
1044
|
/** @inheritDoc */
|
|
787
1045
|
async onMessage(e) {
|
|
788
|
-
|
|
1046
|
+
a(this, I).push(e);
|
|
789
1047
|
}
|
|
790
1048
|
/** @inheritDoc */
|
|
791
1049
|
async setSpawnHandler(e) {
|
|
792
|
-
this[
|
|
1050
|
+
this[u].spawnProcess = e;
|
|
793
1051
|
}
|
|
794
1052
|
/** @inheritDoc */
|
|
795
1053
|
get absoluteUrl() {
|
|
@@ -810,25 +1068,25 @@ class g {
|
|
|
810
1068
|
);
|
|
811
1069
|
}
|
|
812
1070
|
initializeRuntime(e) {
|
|
813
|
-
if (this[
|
|
1071
|
+
if (this[u])
|
|
814
1072
|
throw new Error("PHP runtime already initialized.");
|
|
815
|
-
const t =
|
|
1073
|
+
const t = ft(e);
|
|
816
1074
|
if (!t)
|
|
817
1075
|
throw new Error("Invalid PHP runtime id.");
|
|
818
|
-
this[
|
|
819
|
-
for (const
|
|
820
|
-
const
|
|
821
|
-
if (
|
|
822
|
-
return
|
|
1076
|
+
this[u] = t, t.onMessage = async (n) => {
|
|
1077
|
+
for (const s of a(this, I)) {
|
|
1078
|
+
const i = await s(n);
|
|
1079
|
+
if (i)
|
|
1080
|
+
return i;
|
|
823
1081
|
}
|
|
824
1082
|
return "";
|
|
825
|
-
}, p(this,
|
|
1083
|
+
}, p(this, T, qe(t));
|
|
826
1084
|
}
|
|
827
1085
|
/** @inheritDoc */
|
|
828
1086
|
setPhpIniPath(e) {
|
|
829
|
-
if (
|
|
1087
|
+
if (a(this, R))
|
|
830
1088
|
throw new Error("Cannot set PHP ini path after calling run().");
|
|
831
|
-
this[
|
|
1089
|
+
this[u].ccall(
|
|
832
1090
|
"wasm_set_phpini_path",
|
|
833
1091
|
null,
|
|
834
1092
|
["string"],
|
|
@@ -837,13 +1095,13 @@ class g {
|
|
|
837
1095
|
}
|
|
838
1096
|
/** @inheritDoc */
|
|
839
1097
|
setPhpIniEntry(e, t) {
|
|
840
|
-
if (
|
|
1098
|
+
if (a(this, R))
|
|
841
1099
|
throw new Error("Cannot set PHP ini entries after calling run().");
|
|
842
|
-
|
|
1100
|
+
a(this, k).push([e, t]);
|
|
843
1101
|
}
|
|
844
1102
|
/** @inheritDoc */
|
|
845
1103
|
chdir(e) {
|
|
846
|
-
this[
|
|
1104
|
+
this[u].FS.chdir(e);
|
|
847
1105
|
}
|
|
848
1106
|
/** @inheritDoc */
|
|
849
1107
|
async request(e, t) {
|
|
@@ -853,14 +1111,14 @@ class g {
|
|
|
853
1111
|
}
|
|
854
1112
|
/** @inheritDoc */
|
|
855
1113
|
async run(e) {
|
|
856
|
-
const t = await
|
|
1114
|
+
const t = await a(this, N).acquire();
|
|
857
1115
|
try {
|
|
858
|
-
|
|
859
|
-
const
|
|
860
|
-
if (m(this,
|
|
861
|
-
for (const
|
|
862
|
-
m(this,
|
|
863
|
-
return e.code && m(this,
|
|
1116
|
+
a(this, R) || (m(this, z, ve).call(this), p(this, R, !0)), m(this, Q, Ce).call(this, e.scriptPath || ""), m(this, V, xe).call(this, e.relativeUri || ""), m(this, Y, Fe).call(this, e.method || "GET");
|
|
1117
|
+
const n = Be(e.headers || {}), s = n.host || "example.com:443";
|
|
1118
|
+
if (m(this, J, _e).call(this, s, e.protocol || "http"), m(this, K, ke).call(this, n), e.body && m(this, Z, Te).call(this, e.body), e.fileInfos)
|
|
1119
|
+
for (const i of e.fileInfos)
|
|
1120
|
+
m(this, ee, Ae).call(this, i);
|
|
1121
|
+
return e.code && m(this, te, $e).call(this, " ?>" + e.code), m(this, X, He).call(this), await m(this, re, Ue).call(this);
|
|
864
1122
|
} finally {
|
|
865
1123
|
t(), this.dispatchEvent({
|
|
866
1124
|
type: "request.end"
|
|
@@ -868,12 +1126,12 @@ class g {
|
|
|
868
1126
|
}
|
|
869
1127
|
}
|
|
870
1128
|
addServerGlobalEntry(e, t) {
|
|
871
|
-
|
|
1129
|
+
a(this, x)[e] = t;
|
|
872
1130
|
}
|
|
873
1131
|
defineConstant(e, t) {
|
|
874
|
-
let
|
|
1132
|
+
let n = {};
|
|
875
1133
|
try {
|
|
876
|
-
|
|
1134
|
+
n = JSON.parse(
|
|
877
1135
|
this.fileExists("/tmp/consts.json") && this.readFileAsText("/tmp/consts.json") || "{}"
|
|
878
1136
|
);
|
|
879
1137
|
} catch {
|
|
@@ -881,13 +1139,13 @@ class g {
|
|
|
881
1139
|
this.writeFile(
|
|
882
1140
|
"/tmp/consts.json",
|
|
883
1141
|
JSON.stringify({
|
|
884
|
-
...
|
|
1142
|
+
...n,
|
|
885
1143
|
[e]: t
|
|
886
1144
|
})
|
|
887
1145
|
);
|
|
888
1146
|
}
|
|
889
1147
|
mkdir(e) {
|
|
890
|
-
this[
|
|
1148
|
+
this[u].FS.mkdirTree(e);
|
|
891
1149
|
}
|
|
892
1150
|
mkdirTree(e) {
|
|
893
1151
|
this.mkdir(e);
|
|
@@ -896,56 +1154,67 @@ class g {
|
|
|
896
1154
|
return new TextDecoder().decode(this.readFileAsBuffer(e));
|
|
897
1155
|
}
|
|
898
1156
|
readFileAsBuffer(e) {
|
|
899
|
-
return this[
|
|
1157
|
+
return this[u].FS.readFile(e);
|
|
900
1158
|
}
|
|
901
1159
|
writeFile(e, t) {
|
|
902
|
-
this[
|
|
1160
|
+
this[u].FS.writeFile(e, t);
|
|
903
1161
|
}
|
|
904
1162
|
unlink(e) {
|
|
905
|
-
this[
|
|
1163
|
+
this[u].FS.unlink(e);
|
|
906
1164
|
}
|
|
1165
|
+
/** @inheritDoc */
|
|
907
1166
|
mv(e, t) {
|
|
908
|
-
|
|
1167
|
+
try {
|
|
1168
|
+
this[u].FS.rename(e, t);
|
|
1169
|
+
} catch (n) {
|
|
1170
|
+
const s = ht(n);
|
|
1171
|
+
throw s ? new Error(
|
|
1172
|
+
`Could not move ${e} to ${t}: ${s}`,
|
|
1173
|
+
{
|
|
1174
|
+
cause: n
|
|
1175
|
+
}
|
|
1176
|
+
) : n;
|
|
1177
|
+
}
|
|
909
1178
|
}
|
|
910
1179
|
rmdir(e, t = { recursive: !0 }) {
|
|
911
|
-
t != null && t.recursive && this.listFiles(e).forEach((
|
|
912
|
-
const
|
|
913
|
-
this.isDir(
|
|
914
|
-
}), this[
|
|
1180
|
+
t != null && t.recursive && this.listFiles(e).forEach((n) => {
|
|
1181
|
+
const s = `${e}/${n}`;
|
|
1182
|
+
this.isDir(s) ? this.rmdir(s, t) : this.unlink(s);
|
|
1183
|
+
}), this[u].FS.rmdir(e);
|
|
915
1184
|
}
|
|
916
1185
|
listFiles(e, t = { prependPath: !1 }) {
|
|
917
1186
|
if (!this.fileExists(e))
|
|
918
1187
|
return [];
|
|
919
1188
|
try {
|
|
920
|
-
const
|
|
921
|
-
(
|
|
1189
|
+
const n = this[u].FS.readdir(e).filter(
|
|
1190
|
+
(s) => s !== "." && s !== ".."
|
|
922
1191
|
);
|
|
923
1192
|
if (t.prependPath) {
|
|
924
|
-
const
|
|
925
|
-
return
|
|
1193
|
+
const s = e.replace(/\/$/, "");
|
|
1194
|
+
return n.map((i) => `${s}/${i}`);
|
|
926
1195
|
}
|
|
927
|
-
return
|
|
928
|
-
} catch (
|
|
929
|
-
return console.error(
|
|
1196
|
+
return n;
|
|
1197
|
+
} catch (n) {
|
|
1198
|
+
return console.error(n, { path: e }), [];
|
|
930
1199
|
}
|
|
931
1200
|
}
|
|
932
1201
|
isDir(e) {
|
|
933
|
-
return this.fileExists(e) ? this[
|
|
934
|
-
this[
|
|
1202
|
+
return this.fileExists(e) ? this[u].FS.isDir(
|
|
1203
|
+
this[u].FS.lookupPath(e).node.mode
|
|
935
1204
|
) : !1;
|
|
936
1205
|
}
|
|
937
1206
|
fileExists(e) {
|
|
938
1207
|
try {
|
|
939
|
-
return this[
|
|
1208
|
+
return this[u].FS.lookupPath(e), !0;
|
|
940
1209
|
} catch {
|
|
941
1210
|
return !1;
|
|
942
1211
|
}
|
|
943
1212
|
}
|
|
944
1213
|
exit(e = 0) {
|
|
945
|
-
return this[
|
|
1214
|
+
return this[u]._exit(e);
|
|
946
1215
|
}
|
|
947
1216
|
}
|
|
948
|
-
|
|
1217
|
+
k = new WeakMap(), R = new WeakMap(), T = new WeakMap(), x = new WeakMap(), v = new WeakMap(), I = new WeakMap(), N = new WeakMap(), z = new WeakSet(), ve = function() {
|
|
949
1218
|
if (this.setPhpIniEntry("auto_prepend_file", "/tmp/consts.php"), this.fileExists("/tmp/consts.php") || this.writeFile(
|
|
950
1219
|
"/tmp/consts.php",
|
|
951
1220
|
`<?php
|
|
@@ -957,252 +1226,251 @@ H = new WeakMap(), x = new WeakMap(), C = new WeakMap(), R = new WeakMap(), v =
|
|
|
957
1226
|
}
|
|
958
1227
|
}
|
|
959
1228
|
}`
|
|
960
|
-
),
|
|
961
|
-
const e =
|
|
1229
|
+
), a(this, k).length > 0) {
|
|
1230
|
+
const e = a(this, k).map(([t, n]) => `${t}=${n}`).join(`
|
|
962
1231
|
`) + `
|
|
963
1232
|
|
|
964
1233
|
`;
|
|
965
|
-
this[
|
|
1234
|
+
this[u].ccall(
|
|
966
1235
|
"wasm_set_phpini_entries",
|
|
967
1236
|
null,
|
|
968
1237
|
[y],
|
|
969
1238
|
[e]
|
|
970
1239
|
);
|
|
971
1240
|
}
|
|
972
|
-
this[
|
|
973
|
-
},
|
|
1241
|
+
this[u].ccall("php_wasm_init", null, [], []);
|
|
1242
|
+
}, G = new WeakSet(), Re = function() {
|
|
974
1243
|
const e = "/tmp/headers.json";
|
|
975
1244
|
if (!this.fileExists(e))
|
|
976
1245
|
throw new Error(
|
|
977
1246
|
"SAPI Error: Could not find response headers file."
|
|
978
1247
|
);
|
|
979
|
-
const t = JSON.parse(this.readFileAsText(e)),
|
|
980
|
-
for (const
|
|
981
|
-
if (!
|
|
1248
|
+
const t = JSON.parse(this.readFileAsText(e)), n = {};
|
|
1249
|
+
for (const s of t.headers) {
|
|
1250
|
+
if (!s.includes(": "))
|
|
982
1251
|
continue;
|
|
983
|
-
const
|
|
984
|
-
|
|
1252
|
+
const i = s.indexOf(": "), o = s.substring(0, i).toLowerCase(), l = s.substring(i + 2);
|
|
1253
|
+
o in n || (n[o] = []), n[o].push(l);
|
|
985
1254
|
}
|
|
986
1255
|
return {
|
|
987
|
-
headers:
|
|
1256
|
+
headers: n,
|
|
988
1257
|
httpStatusCode: t.status
|
|
989
1258
|
};
|
|
990
|
-
},
|
|
991
|
-
if (this[
|
|
1259
|
+
}, V = new WeakSet(), xe = function(e) {
|
|
1260
|
+
if (this[u].ccall(
|
|
992
1261
|
"wasm_set_request_uri",
|
|
993
1262
|
null,
|
|
994
1263
|
[y],
|
|
995
1264
|
[e]
|
|
996
1265
|
), e.includes("?")) {
|
|
997
1266
|
const t = e.substring(e.indexOf("?") + 1);
|
|
998
|
-
this[
|
|
1267
|
+
this[u].ccall(
|
|
999
1268
|
"wasm_set_query_string",
|
|
1000
1269
|
null,
|
|
1001
1270
|
[y],
|
|
1002
1271
|
[t]
|
|
1003
1272
|
);
|
|
1004
1273
|
}
|
|
1005
|
-
},
|
|
1006
|
-
this[
|
|
1274
|
+
}, J = new WeakSet(), _e = function(e, t) {
|
|
1275
|
+
this[u].ccall(
|
|
1007
1276
|
"wasm_set_request_host",
|
|
1008
1277
|
null,
|
|
1009
1278
|
[y],
|
|
1010
1279
|
[e]
|
|
1011
1280
|
);
|
|
1012
|
-
let
|
|
1281
|
+
let n;
|
|
1013
1282
|
try {
|
|
1014
|
-
|
|
1283
|
+
n = parseInt(new URL(e).port, 10);
|
|
1015
1284
|
} catch {
|
|
1016
1285
|
}
|
|
1017
|
-
(!
|
|
1286
|
+
(!n || isNaN(n) || n === 80) && (n = t === "https" ? 443 : 80), this[u].ccall(
|
|
1018
1287
|
"wasm_set_request_port",
|
|
1019
1288
|
null,
|
|
1020
|
-
[
|
|
1021
|
-
[
|
|
1022
|
-
), (t === "https" || !t &&
|
|
1023
|
-
},
|
|
1024
|
-
this[
|
|
1289
|
+
[C],
|
|
1290
|
+
[n]
|
|
1291
|
+
), (t === "https" || !t && n === 443) && this.addServerGlobalEntry("HTTPS", "on");
|
|
1292
|
+
}, Y = new WeakSet(), Fe = function(e) {
|
|
1293
|
+
this[u].ccall(
|
|
1025
1294
|
"wasm_set_request_method",
|
|
1026
1295
|
null,
|
|
1027
1296
|
[y],
|
|
1028
1297
|
[e]
|
|
1029
1298
|
);
|
|
1030
|
-
},
|
|
1031
|
-
e.cookie && this[
|
|
1299
|
+
}, K = new WeakSet(), ke = function(e) {
|
|
1300
|
+
e.cookie && this[u].ccall(
|
|
1032
1301
|
"wasm_set_cookies",
|
|
1033
1302
|
null,
|
|
1034
1303
|
[y],
|
|
1035
1304
|
[e.cookie]
|
|
1036
|
-
), e["content-type"] && this[
|
|
1305
|
+
), e["content-type"] && this[u].ccall(
|
|
1037
1306
|
"wasm_set_content_type",
|
|
1038
1307
|
null,
|
|
1039
1308
|
[y],
|
|
1040
1309
|
[e["content-type"]]
|
|
1041
|
-
), e["content-length"] && this[
|
|
1310
|
+
), e["content-length"] && this[u].ccall(
|
|
1042
1311
|
"wasm_set_content_length",
|
|
1043
1312
|
null,
|
|
1044
|
-
[
|
|
1313
|
+
[C],
|
|
1045
1314
|
[parseInt(e["content-length"], 10)]
|
|
1046
1315
|
);
|
|
1047
1316
|
for (const t in e) {
|
|
1048
|
-
let
|
|
1049
|
-
["content-type", "content-length"].includes(t.toLowerCase()) && (
|
|
1050
|
-
`${
|
|
1317
|
+
let n = "HTTP_";
|
|
1318
|
+
["content-type", "content-length"].includes(t.toLowerCase()) && (n = ""), this.addServerGlobalEntry(
|
|
1319
|
+
`${n}${t.toUpperCase().replace(/-/g, "_")}`,
|
|
1051
1320
|
e[t]
|
|
1052
1321
|
);
|
|
1053
1322
|
}
|
|
1054
|
-
},
|
|
1055
|
-
this[
|
|
1323
|
+
}, Z = new WeakSet(), Te = function(e) {
|
|
1324
|
+
this[u].ccall(
|
|
1056
1325
|
"wasm_set_request_body",
|
|
1057
1326
|
null,
|
|
1058
1327
|
[y],
|
|
1059
1328
|
[e]
|
|
1060
|
-
), this[
|
|
1329
|
+
), this[u].ccall(
|
|
1061
1330
|
"wasm_set_content_length",
|
|
1062
1331
|
null,
|
|
1063
|
-
[
|
|
1332
|
+
[C],
|
|
1064
1333
|
[new TextEncoder().encode(e).length]
|
|
1065
1334
|
);
|
|
1066
|
-
},
|
|
1067
|
-
this[
|
|
1335
|
+
}, Q = new WeakSet(), Ce = function(e) {
|
|
1336
|
+
this[u].ccall(
|
|
1068
1337
|
"wasm_set_path_translated",
|
|
1069
1338
|
null,
|
|
1070
1339
|
[y],
|
|
1071
1340
|
[e]
|
|
1072
1341
|
);
|
|
1073
|
-
},
|
|
1074
|
-
for (const e in
|
|
1075
|
-
this[
|
|
1342
|
+
}, X = new WeakSet(), He = function() {
|
|
1343
|
+
for (const e in a(this, x))
|
|
1344
|
+
this[u].ccall(
|
|
1076
1345
|
"wasm_add_SERVER_entry",
|
|
1077
1346
|
null,
|
|
1078
1347
|
[y, y],
|
|
1079
|
-
[e,
|
|
1348
|
+
[e, a(this, x)[e]]
|
|
1080
1349
|
);
|
|
1081
|
-
},
|
|
1082
|
-
const { key: t, name:
|
|
1083
|
-
this.writeFile(
|
|
1084
|
-
const
|
|
1085
|
-
this[
|
|
1350
|
+
}, ee = new WeakSet(), Ae = function(e) {
|
|
1351
|
+
const { key: t, name: n, type: s, data: i } = e, o = `/tmp/${Math.random().toFixed(20)}`;
|
|
1352
|
+
this.writeFile(o, i);
|
|
1353
|
+
const l = 0;
|
|
1354
|
+
this[u].ccall(
|
|
1086
1355
|
"wasm_add_uploaded_file",
|
|
1087
1356
|
null,
|
|
1088
|
-
[y, y, y, y,
|
|
1089
|
-
[t,
|
|
1357
|
+
[y, y, y, y, C, C],
|
|
1358
|
+
[t, n, s, o, l, i.byteLength]
|
|
1090
1359
|
);
|
|
1091
|
-
},
|
|
1092
|
-
this[
|
|
1360
|
+
}, te = new WeakSet(), $e = function(e) {
|
|
1361
|
+
this[u].ccall(
|
|
1093
1362
|
"wasm_set_php_code",
|
|
1094
1363
|
null,
|
|
1095
1364
|
[y],
|
|
1096
1365
|
[e]
|
|
1097
1366
|
);
|
|
1098
|
-
},
|
|
1099
|
-
var
|
|
1367
|
+
}, re = new WeakSet(), Ue = async function() {
|
|
1368
|
+
var i;
|
|
1100
1369
|
let e, t;
|
|
1101
1370
|
try {
|
|
1102
|
-
e = await new Promise((
|
|
1371
|
+
e = await new Promise((o, l) => {
|
|
1103
1372
|
var f;
|
|
1104
|
-
t = (
|
|
1105
|
-
const
|
|
1106
|
-
|
|
1107
|
-
}, (f =
|
|
1373
|
+
t = (h) => {
|
|
1374
|
+
const S = new Error("Rethrown");
|
|
1375
|
+
S.cause = h.error, S.betterMessage = h.message, l(S);
|
|
1376
|
+
}, (f = a(this, T)) == null || f.addEventListener(
|
|
1108
1377
|
"error",
|
|
1109
1378
|
t
|
|
1110
1379
|
);
|
|
1111
|
-
const d = this[
|
|
1380
|
+
const d = this[u].ccall(
|
|
1112
1381
|
"wasm_sapi_handle_request",
|
|
1113
|
-
|
|
1382
|
+
C,
|
|
1114
1383
|
[],
|
|
1115
1384
|
[],
|
|
1116
1385
|
{ async: !0 }
|
|
1117
1386
|
);
|
|
1118
|
-
return d instanceof Promise ? d.then(
|
|
1387
|
+
return d instanceof Promise ? d.then(o, l) : o(d);
|
|
1119
1388
|
});
|
|
1120
|
-
} catch (
|
|
1121
|
-
for (const
|
|
1122
|
-
typeof this[
|
|
1389
|
+
} catch (o) {
|
|
1390
|
+
for (const h in this)
|
|
1391
|
+
typeof this[h] == "function" && (this[h] = () => {
|
|
1123
1392
|
throw new Error(
|
|
1124
1393
|
"PHP runtime has crashed – see the earlier error for details."
|
|
1125
1394
|
);
|
|
1126
1395
|
});
|
|
1127
|
-
this.functionsMaybeMissingFromAsyncify =
|
|
1128
|
-
const
|
|
1129
|
-
throw f.cause =
|
|
1396
|
+
this.functionsMaybeMissingFromAsyncify = De();
|
|
1397
|
+
const l = o, d = "betterMessage" in l ? l.betterMessage : l.message, f = new Error(d);
|
|
1398
|
+
throw f.cause = l, f;
|
|
1130
1399
|
} finally {
|
|
1131
|
-
(
|
|
1400
|
+
(i = a(this, T)) == null || i.removeEventListener("error", t), p(this, x, {});
|
|
1132
1401
|
}
|
|
1133
|
-
const { headers:
|
|
1134
|
-
return new
|
|
1402
|
+
const { headers: n, httpStatusCode: s } = m(this, G, Re).call(this);
|
|
1403
|
+
return new H(
|
|
1404
|
+
s,
|
|
1135
1405
|
n,
|
|
1136
|
-
r,
|
|
1137
1406
|
this.readFileAsBuffer("/tmp/stdout"),
|
|
1138
1407
|
this.readFileAsText("/tmp/stderr"),
|
|
1139
1408
|
e
|
|
1140
1409
|
);
|
|
1141
1410
|
};
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
],
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
],
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
],
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
],
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
],
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
],
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
],
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
],
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
],
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
],
|
|
1172
|
-
|
|
1173
|
-
w('Could not stat "{path}"')
|
|
1174
|
-
], g.prototype, "fileExists", 1);
|
|
1175
|
-
function $e(s) {
|
|
1411
|
+
E([
|
|
1412
|
+
P('Could not create directory "{path}"')
|
|
1413
|
+
], w.prototype, "mkdir", 1);
|
|
1414
|
+
E([
|
|
1415
|
+
P('Could not create directory "{path}"')
|
|
1416
|
+
], w.prototype, "mkdirTree", 1);
|
|
1417
|
+
E([
|
|
1418
|
+
P('Could not read "{path}"')
|
|
1419
|
+
], w.prototype, "readFileAsText", 1);
|
|
1420
|
+
E([
|
|
1421
|
+
P('Could not read "{path}"')
|
|
1422
|
+
], w.prototype, "readFileAsBuffer", 1);
|
|
1423
|
+
E([
|
|
1424
|
+
P('Could not write to "{path}"')
|
|
1425
|
+
], w.prototype, "writeFile", 1);
|
|
1426
|
+
E([
|
|
1427
|
+
P('Could not unlink "{path}"')
|
|
1428
|
+
], w.prototype, "unlink", 1);
|
|
1429
|
+
E([
|
|
1430
|
+
P('Could not remove directory "{path}"')
|
|
1431
|
+
], w.prototype, "rmdir", 1);
|
|
1432
|
+
E([
|
|
1433
|
+
P('Could not list files in "{path}"')
|
|
1434
|
+
], w.prototype, "listFiles", 1);
|
|
1435
|
+
E([
|
|
1436
|
+
P('Could not stat "{path}"')
|
|
1437
|
+
], w.prototype, "isDir", 1);
|
|
1438
|
+
E([
|
|
1439
|
+
P('Could not stat "{path}"')
|
|
1440
|
+
], w.prototype, "fileExists", 1);
|
|
1441
|
+
function Be(r) {
|
|
1176
1442
|
const e = {};
|
|
1177
|
-
for (const t in
|
|
1178
|
-
e[t.toLowerCase()] =
|
|
1443
|
+
for (const t in r)
|
|
1444
|
+
e[t.toLowerCase()] = r[t];
|
|
1179
1445
|
return e;
|
|
1180
1446
|
}
|
|
1181
|
-
function
|
|
1182
|
-
return !(
|
|
1447
|
+
function wt(r) {
|
|
1448
|
+
return !(r instanceof w);
|
|
1183
1449
|
}
|
|
1184
|
-
function
|
|
1185
|
-
return !
|
|
1450
|
+
function xt(r) {
|
|
1451
|
+
return !wt(r);
|
|
1186
1452
|
}
|
|
1187
1453
|
export {
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1454
|
+
w as BasePHP,
|
|
1455
|
+
nt as DEFAULT_BASE_URL,
|
|
1456
|
+
Et as LatestSupportedPHPVersion,
|
|
1457
|
+
rt as PHPBrowser,
|
|
1458
|
+
it as PHPRequestHandler,
|
|
1459
|
+
H as PHPResponse,
|
|
1460
|
+
vt as SupportedPHPExtensionBundles,
|
|
1461
|
+
tt as SupportedPHPExtensionsList,
|
|
1462
|
+
be as SupportedPHPVersions,
|
|
1463
|
+
St as SupportedPHPVersionsList,
|
|
1464
|
+
Ne as UnhandledRejectionsTarget,
|
|
1465
|
+
u as __private__dont__use,
|
|
1466
|
+
st as ensurePathPrefix,
|
|
1201
1467
|
Oe as isExitCodeZero,
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1468
|
+
wt as isLocalPHP,
|
|
1469
|
+
xt as isRemotePHP,
|
|
1470
|
+
bt as iterateFiles,
|
|
1471
|
+
Rt as loadPHPRuntime,
|
|
1472
|
+
pe as removePathPrefix,
|
|
1473
|
+
P as rethrowFileSystemError,
|
|
1474
|
+
fe as toRelativeUrl,
|
|
1475
|
+
Pt as writeFilesStreamToPhp
|
|
1208
1476
|
};
|