@php-wasm/web 0.1.34 → 0.1.35
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-5569499f.js → index-f2cf3e89.js} +182 -179
- package/index.d.ts +2 -1
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
class R {
|
|
2
|
-
constructor(e, r, n, s = "",
|
|
3
|
-
this.httpStatusCode = e, this.headers = r, this.bytes = n, this.exitCode =
|
|
2
|
+
constructor(e, r, n, s = "", a = 0) {
|
|
3
|
+
this.httpStatusCode = e, this.headers = r, this.bytes = n, this.exitCode = a, this.errors = s;
|
|
4
4
|
}
|
|
5
5
|
static fromRawData(e) {
|
|
6
6
|
return new R(
|
|
@@ -33,7 +33,7 @@ class R {
|
|
|
33
33
|
return new TextDecoder().decode(this.bytes);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
const
|
|
36
|
+
const Q = [
|
|
37
37
|
"8.2",
|
|
38
38
|
"8.1",
|
|
39
39
|
"8.0",
|
|
@@ -43,8 +43,8 @@ const K = [
|
|
|
43
43
|
"7.1",
|
|
44
44
|
"7.0",
|
|
45
45
|
"5.6"
|
|
46
|
-
],
|
|
47
|
-
class
|
|
46
|
+
], X = Q[0];
|
|
47
|
+
class Z {
|
|
48
48
|
#e;
|
|
49
49
|
#t;
|
|
50
50
|
/**
|
|
@@ -117,8 +117,8 @@ class X {
|
|
|
117
117
|
try {
|
|
118
118
|
if (!r.includes("="))
|
|
119
119
|
continue;
|
|
120
|
-
const n = r.indexOf("="), s = r.substring(0, n),
|
|
121
|
-
this.#e[s] =
|
|
120
|
+
const n = r.indexOf("="), s = r.substring(0, n), a = r.substring(n + 1).split(";")[0];
|
|
121
|
+
this.#e[s] = a;
|
|
122
122
|
} catch (n) {
|
|
123
123
|
console.error(n);
|
|
124
124
|
}
|
|
@@ -130,7 +130,7 @@ class X {
|
|
|
130
130
|
return e.join("; ");
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
class
|
|
133
|
+
class ee {
|
|
134
134
|
constructor({ concurrency: e }) {
|
|
135
135
|
this._running = 0, this.concurrency = e, this.queue = [];
|
|
136
136
|
}
|
|
@@ -155,17 +155,17 @@ class Z {
|
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
-
const
|
|
159
|
-
function
|
|
158
|
+
const te = "http://example.com";
|
|
159
|
+
function L(t) {
|
|
160
160
|
return t.toString().substring(t.origin.length);
|
|
161
161
|
}
|
|
162
|
-
function
|
|
162
|
+
function N(t, e) {
|
|
163
163
|
return !e || !t.startsWith(e) ? t : t.substring(e.length);
|
|
164
164
|
}
|
|
165
|
-
function
|
|
165
|
+
function re(t, e) {
|
|
166
166
|
return !e || t.startsWith(e) ? t : e + t;
|
|
167
167
|
}
|
|
168
|
-
class
|
|
168
|
+
class ne {
|
|
169
169
|
#e;
|
|
170
170
|
#t;
|
|
171
171
|
#s;
|
|
@@ -180,13 +180,13 @@ class re {
|
|
|
180
180
|
* @param config - Request Handler configuration.
|
|
181
181
|
*/
|
|
182
182
|
constructor(e, r = {}) {
|
|
183
|
-
this.#a = new
|
|
183
|
+
this.#a = new ee({ concurrency: 1 });
|
|
184
184
|
const {
|
|
185
185
|
documentRoot: n = "/www/",
|
|
186
186
|
absoluteUrl: s = typeof location == "object" ? location?.href : "",
|
|
187
|
-
isStaticFilePath:
|
|
187
|
+
isStaticFilePath: a = () => !1
|
|
188
188
|
} = r;
|
|
189
|
-
this.php = e, this.#e = n, this.#l =
|
|
189
|
+
this.php = e, this.#e = n, this.#l = a;
|
|
190
190
|
const i = new URL(s);
|
|
191
191
|
this.#s = i.hostname, this.#n = i.port ? Number(i.port) : i.protocol === "https:" ? 443 : 80, this.#t = (i.protocol || "").replace(":", "");
|
|
192
192
|
const o = this.#n !== 443 && this.#n !== 80;
|
|
@@ -206,7 +206,7 @@ class re {
|
|
|
206
206
|
/** @inheritDoc */
|
|
207
207
|
internalUrlToPath(e) {
|
|
208
208
|
const r = new URL(e);
|
|
209
|
-
return r.pathname.startsWith(this.#r) && (r.pathname = r.pathname.slice(this.#r.length)),
|
|
209
|
+
return r.pathname.startsWith(this.#r) && (r.pathname = r.pathname.slice(this.#r.length)), L(r);
|
|
210
210
|
}
|
|
211
211
|
get isRequestRunning() {
|
|
212
212
|
return this.#a.running > 0;
|
|
@@ -223,8 +223,8 @@ class re {
|
|
|
223
223
|
async request(e) {
|
|
224
224
|
const r = e.url.startsWith("http://") || e.url.startsWith("https://"), n = new URL(
|
|
225
225
|
e.url,
|
|
226
|
-
r ? void 0 :
|
|
227
|
-
), s =
|
|
226
|
+
r ? void 0 : te
|
|
227
|
+
), s = N(
|
|
228
228
|
n.pathname,
|
|
229
229
|
this.#r
|
|
230
230
|
);
|
|
@@ -252,7 +252,7 @@ class re {
|
|
|
252
252
|
// @TODO: Infer the content-type from the arrayBuffer instead of the file path.
|
|
253
253
|
// The code below won't return the correct mime-type if the extension
|
|
254
254
|
// was tampered with.
|
|
255
|
-
"content-type": [
|
|
255
|
+
"content-type": [ie(r)],
|
|
256
256
|
"accept-ranges": ["bytes"],
|
|
257
257
|
"cache-control": ["public, max-age=0"]
|
|
258
258
|
},
|
|
@@ -274,31 +274,31 @@ class re {
|
|
|
274
274
|
this.#o.startsWith("https://") ? "on" : ""
|
|
275
275
|
);
|
|
276
276
|
let s = "GET";
|
|
277
|
-
const
|
|
277
|
+
const a = {
|
|
278
278
|
host: this.#i,
|
|
279
|
-
...
|
|
279
|
+
...z(e.headers || {})
|
|
280
280
|
}, i = [];
|
|
281
281
|
if (e.files && Object.keys(e.files).length) {
|
|
282
282
|
s = "POST";
|
|
283
|
-
for (const
|
|
284
|
-
const u = e.files[
|
|
283
|
+
for (const l in e.files) {
|
|
284
|
+
const u = e.files[l];
|
|
285
285
|
i.push({
|
|
286
|
-
key:
|
|
286
|
+
key: l,
|
|
287
287
|
name: u.name,
|
|
288
288
|
type: u.type,
|
|
289
289
|
data: new Uint8Array(await u.arrayBuffer())
|
|
290
290
|
});
|
|
291
291
|
}
|
|
292
|
-
|
|
292
|
+
a["content-type"]?.startsWith("multipart/form-data") && (e.formData = se(
|
|
293
293
|
e.body || ""
|
|
294
|
-
),
|
|
294
|
+
), a["content-type"] = "application/x-www-form-urlencoded", delete e.body);
|
|
295
295
|
}
|
|
296
296
|
let o;
|
|
297
|
-
return e.formData !== void 0 ? (s = "POST",
|
|
297
|
+
return e.formData !== void 0 ? (s = "POST", a["content-type"] = a["content-type"] || "application/x-www-form-urlencoded", o = new URLSearchParams(
|
|
298
298
|
e.formData
|
|
299
299
|
).toString()) : o = e.body, await this.php.run({
|
|
300
|
-
relativeUri:
|
|
301
|
-
|
|
300
|
+
relativeUri: re(
|
|
301
|
+
L(r),
|
|
302
302
|
this.#r
|
|
303
303
|
),
|
|
304
304
|
protocol: this.#t,
|
|
@@ -306,7 +306,7 @@ class re {
|
|
|
306
306
|
body: o,
|
|
307
307
|
fileInfos: i,
|
|
308
308
|
scriptPath: this.#d(r.pathname),
|
|
309
|
-
headers:
|
|
309
|
+
headers: a
|
|
310
310
|
});
|
|
311
311
|
} finally {
|
|
312
312
|
n();
|
|
@@ -321,28 +321,28 @@ class re {
|
|
|
321
321
|
* @returns The resolved filesystem path.
|
|
322
322
|
*/
|
|
323
323
|
#d(e) {
|
|
324
|
-
let r =
|
|
324
|
+
let r = N(e, this.#r);
|
|
325
325
|
r.includes(".php") ? r = r.split(".php")[0] + ".php" : (r.endsWith("/") || (r += "/"), r.endsWith("index.php") || (r += "index.php"));
|
|
326
326
|
const n = `${this.#e}${r}`;
|
|
327
327
|
return this.php.fileExists(n) ? n : `${this.#e}/index.php`;
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
|
-
function
|
|
330
|
+
function se(t) {
|
|
331
331
|
const e = {}, r = t.match(/--(.*)\r\n/);
|
|
332
332
|
if (!r)
|
|
333
333
|
return e;
|
|
334
334
|
const n = r[1], s = t.split(`--${n}`);
|
|
335
|
-
return s.shift(), s.pop(), s.forEach((
|
|
336
|
-
const i =
|
|
335
|
+
return s.shift(), s.pop(), s.forEach((a) => {
|
|
336
|
+
const i = a.indexOf(`\r
|
|
337
337
|
\r
|
|
338
|
-
`), o =
|
|
338
|
+
`), o = a.substring(0, i).trim(), l = a.substring(i + 4).trim(), u = o.match(/name="([^"]+)"/);
|
|
339
339
|
if (u) {
|
|
340
340
|
const d = u[1];
|
|
341
|
-
e[d] =
|
|
341
|
+
e[d] = l;
|
|
342
342
|
}
|
|
343
343
|
}), e;
|
|
344
344
|
}
|
|
345
|
-
function
|
|
345
|
+
function ie(t) {
|
|
346
346
|
switch (t.split(".").pop()) {
|
|
347
347
|
case "css":
|
|
348
348
|
return "text/css";
|
|
@@ -382,7 +382,7 @@ function se(t) {
|
|
|
382
382
|
return "application-octet-stream";
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
|
-
const
|
|
385
|
+
const D = {
|
|
386
386
|
0: "No error occurred. System call completed successfully.",
|
|
387
387
|
1: "Argument list too long.",
|
|
388
388
|
2: "Permission denied.",
|
|
@@ -463,14 +463,14 @@ const N = {
|
|
|
463
463
|
};
|
|
464
464
|
function y(t = "") {
|
|
465
465
|
return function(r, n, s) {
|
|
466
|
-
const
|
|
466
|
+
const a = s.value;
|
|
467
467
|
s.value = function(...i) {
|
|
468
468
|
try {
|
|
469
|
-
return
|
|
469
|
+
return a.apply(this, i);
|
|
470
470
|
} catch (o) {
|
|
471
|
-
const
|
|
472
|
-
if (
|
|
473
|
-
const u =
|
|
471
|
+
const l = typeof o == "object" ? o?.errno : null;
|
|
472
|
+
if (l in D) {
|
|
473
|
+
const u = D[l], d = typeof i[0] == "string" ? i[0] : null, g = d !== null ? t.replaceAll("{path}", d) : t;
|
|
474
474
|
throw new Error(`${g}: ${u}`, {
|
|
475
475
|
cause: o
|
|
476
476
|
});
|
|
@@ -480,45 +480,45 @@ function y(t = "") {
|
|
|
480
480
|
};
|
|
481
481
|
};
|
|
482
482
|
}
|
|
483
|
-
async function
|
|
483
|
+
async function oe(t, e = {}, r = []) {
|
|
484
484
|
let n, s;
|
|
485
|
-
const
|
|
486
|
-
s =
|
|
487
|
-
}), i = new Promise((
|
|
488
|
-
n =
|
|
489
|
-
}), o = t.init(
|
|
490
|
-
onAbort(
|
|
491
|
-
console.error("WASM aborted: "), console.error(
|
|
485
|
+
const a = new Promise((l) => {
|
|
486
|
+
s = l;
|
|
487
|
+
}), i = new Promise((l) => {
|
|
488
|
+
n = l;
|
|
489
|
+
}), o = t.init(le, {
|
|
490
|
+
onAbort(l) {
|
|
491
|
+
console.error("WASM aborted: "), console.error(l);
|
|
492
492
|
},
|
|
493
493
|
ENV: {},
|
|
494
494
|
// Emscripten sometimes prepends a '/' to the path, which
|
|
495
495
|
// breaks vite dev mode. An identity `locateFile` function
|
|
496
496
|
// fixes it.
|
|
497
|
-
locateFile: (
|
|
497
|
+
locateFile: (l) => l,
|
|
498
498
|
...e,
|
|
499
499
|
noInitialRun: !0,
|
|
500
500
|
onRuntimeInitialized() {
|
|
501
501
|
e.onRuntimeInitialized && e.onRuntimeInitialized(), n();
|
|
502
502
|
},
|
|
503
|
-
monitorRunDependencies(
|
|
504
|
-
|
|
503
|
+
monitorRunDependencies(l) {
|
|
504
|
+
l === 0 && (delete o.monitorRunDependencies, s());
|
|
505
505
|
}
|
|
506
506
|
});
|
|
507
|
-
for (const { default:
|
|
508
|
-
|
|
509
|
-
return r.length || s(), await
|
|
507
|
+
for (const { default: l } of r)
|
|
508
|
+
l(o);
|
|
509
|
+
return r.length || s(), await a, await i, O.push(o), O.length - 1;
|
|
510
510
|
}
|
|
511
511
|
const O = [];
|
|
512
|
-
function
|
|
512
|
+
function ae(t) {
|
|
513
513
|
return O[t];
|
|
514
514
|
}
|
|
515
|
-
const
|
|
515
|
+
const le = function() {
|
|
516
516
|
return typeof window < "u" && !{}.TEST ? "WEB" : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? "WORKER" : "NODE";
|
|
517
517
|
}();
|
|
518
|
-
var
|
|
519
|
-
for (var s = n > 1 ? void 0 : n ?
|
|
520
|
-
(i = t[
|
|
521
|
-
return n && s &&
|
|
518
|
+
var ce = Object.defineProperty, ue = Object.getOwnPropertyDescriptor, w = (t, e, r, n) => {
|
|
519
|
+
for (var s = n > 1 ? void 0 : n ? ue(e, r) : e, a = t.length - 1, i; a >= 0; a--)
|
|
520
|
+
(i = t[a]) && (s = (n ? i(e, r, s) : i(s)) || s);
|
|
521
|
+
return n && s && ce(e, r, s), s;
|
|
522
522
|
};
|
|
523
523
|
const f = "string", b = "number", c = Symbol("__private__dont__use");
|
|
524
524
|
class m {
|
|
@@ -530,8 +530,8 @@ class m {
|
|
|
530
530
|
* @param serverOptions - Optional. Options for the PHPRequestHandler. If undefined, no request handler will be initialized.
|
|
531
531
|
*/
|
|
532
532
|
constructor(e, r) {
|
|
533
|
-
this.#e = [], this.#t = !1, e !== void 0 && this.initializeRuntime(e), r && (this.requestHandler = new
|
|
534
|
-
new
|
|
533
|
+
this.#e = [], this.#t = !1, e !== void 0 && this.initializeRuntime(e), r && (this.requestHandler = new Z(
|
|
534
|
+
new ne(this, r)
|
|
535
535
|
));
|
|
536
536
|
}
|
|
537
537
|
#e;
|
|
@@ -542,7 +542,7 @@ class m {
|
|
|
542
542
|
}
|
|
543
543
|
/** @inheritDoc */
|
|
544
544
|
get documentRoot() {
|
|
545
|
-
return this.requestHandler.requestHandler.
|
|
545
|
+
return this.requestHandler.requestHandler.documentRoot;
|
|
546
546
|
}
|
|
547
547
|
/** @inheritDoc */
|
|
548
548
|
pathToInternalUrl(e) {
|
|
@@ -557,7 +557,7 @@ class m {
|
|
|
557
557
|
initializeRuntime(e) {
|
|
558
558
|
if (this[c])
|
|
559
559
|
throw new Error("PHP runtime already initialized.");
|
|
560
|
-
const r =
|
|
560
|
+
const r = ae(e);
|
|
561
561
|
if (!r)
|
|
562
562
|
throw new Error("Invalid PHP runtime id.");
|
|
563
563
|
this[c] = r;
|
|
@@ -594,7 +594,7 @@ class m {
|
|
|
594
594
|
this.#t || (this.#s(), this.#t = !0), this.#c(e.scriptPath || ""), this.#i(e.relativeUri || ""), this.#o(e.method || "GET");
|
|
595
595
|
const { host: r, ...n } = {
|
|
596
596
|
host: "example.com:443",
|
|
597
|
-
...
|
|
597
|
+
...z(e.headers || {})
|
|
598
598
|
};
|
|
599
599
|
if (this.#r(r, e.protocol || "http"), this.#a(n), e.body && this.#l(e.body), e.fileInfos)
|
|
600
600
|
for (const s of e.fileInfos)
|
|
@@ -626,7 +626,7 @@ class m {
|
|
|
626
626
|
for (const s of r.headers) {
|
|
627
627
|
if (!s.includes(": "))
|
|
628
628
|
continue;
|
|
629
|
-
const
|
|
629
|
+
const a = s.indexOf(": "), i = s.substring(0, a).toLowerCase(), o = s.substring(a + 2);
|
|
630
630
|
i in n || (n[i] = []), n[i].push(o);
|
|
631
631
|
}
|
|
632
632
|
return {
|
|
@@ -739,14 +739,14 @@ class m {
|
|
|
739
739
|
* @param fileInfo - File details
|
|
740
740
|
*/
|
|
741
741
|
#u(e) {
|
|
742
|
-
const { key: r, name: n, type: s, data:
|
|
743
|
-
this.writeFile(i,
|
|
742
|
+
const { key: r, name: n, type: s, data: a } = e, i = `/tmp/${Math.random().toFixed(20)}`;
|
|
743
|
+
this.writeFile(i, a);
|
|
744
744
|
const o = 0;
|
|
745
745
|
this[c].ccall(
|
|
746
746
|
"wasm_add_uploaded_file",
|
|
747
747
|
null,
|
|
748
748
|
[f, f, f, f, b, b],
|
|
749
|
-
[r, n, s, i, o,
|
|
749
|
+
[r, n, s, i, o, a.byteLength]
|
|
750
750
|
);
|
|
751
751
|
}
|
|
752
752
|
#d(e) {
|
|
@@ -856,7 +856,7 @@ w([
|
|
|
856
856
|
w([
|
|
857
857
|
y('Could not stat "{path}"')
|
|
858
858
|
], m.prototype, "fileExists", 1);
|
|
859
|
-
function
|
|
859
|
+
function z(t) {
|
|
860
860
|
const e = {};
|
|
861
861
|
for (const r in t)
|
|
862
862
|
e[r.toLowerCase()] = t[r];
|
|
@@ -867,8 +867,8 @@ function W(t) {
|
|
|
867
867
|
* Copyright 2019 Google LLC
|
|
868
868
|
* SPDX-License-Identifier: Apache-2.0
|
|
869
869
|
*/
|
|
870
|
-
const
|
|
871
|
-
canHandle: (t) =>
|
|
870
|
+
const $ = Symbol("Comlink.proxy"), de = Symbol("Comlink.endpoint"), he = Symbol("Comlink.releaseProxy"), H = Symbol("Comlink.finalizer"), k = Symbol("Comlink.thrown"), j = (t) => typeof t == "object" && t !== null || typeof t == "function", fe = {
|
|
871
|
+
canHandle: (t) => j(t) && t[$],
|
|
872
872
|
serialize(t) {
|
|
873
873
|
const { port1: e, port2: r } = new MessageChannel();
|
|
874
874
|
return F(t, e), [r, [r]];
|
|
@@ -876,8 +876,8 @@ const q = Symbol("Comlink.proxy"), ue = Symbol("Comlink.endpoint"), de = Symbol(
|
|
|
876
876
|
deserialize(t) {
|
|
877
877
|
return t.start(), I(t);
|
|
878
878
|
}
|
|
879
|
-
},
|
|
880
|
-
canHandle: (t) =>
|
|
879
|
+
}, pe = {
|
|
880
|
+
canHandle: (t) => j(t) && k in t,
|
|
881
881
|
serialize({ value: t }) {
|
|
882
882
|
let e;
|
|
883
883
|
return t instanceof Error ? e = {
|
|
@@ -893,10 +893,10 @@ const q = Symbol("Comlink.proxy"), ue = Symbol("Comlink.endpoint"), de = Symbol(
|
|
|
893
893
|
throw t.isError ? Object.assign(new Error(t.value.message), t.value) : t.value;
|
|
894
894
|
}
|
|
895
895
|
}, S = /* @__PURE__ */ new Map([
|
|
896
|
-
["proxy",
|
|
897
|
-
["throw",
|
|
896
|
+
["proxy", fe],
|
|
897
|
+
["throw", pe]
|
|
898
898
|
]);
|
|
899
|
-
function
|
|
899
|
+
function me(t, e) {
|
|
900
900
|
for (const r of t)
|
|
901
901
|
if (e === r || r === "*" || r instanceof RegExp && r.test(e))
|
|
902
902
|
return !0;
|
|
@@ -906,11 +906,11 @@ function F(t, e = globalThis, r = ["*"]) {
|
|
|
906
906
|
e.addEventListener("message", function n(s) {
|
|
907
907
|
if (!s || !s.data)
|
|
908
908
|
return;
|
|
909
|
-
if (!
|
|
909
|
+
if (!me(r, s.origin)) {
|
|
910
910
|
console.warn(`Invalid origin '${s.origin}' for comlink proxy`);
|
|
911
911
|
return;
|
|
912
912
|
}
|
|
913
|
-
const { id:
|
|
913
|
+
const { id: a, type: i, path: o } = Object.assign({ path: [] }, s.data), l = (s.data.argumentList || []).map(P);
|
|
914
914
|
let u;
|
|
915
915
|
try {
|
|
916
916
|
const d = o.slice(0, -1).reduce((p, v) => p[v], t), g = o.reduce((p, v) => p[v], t);
|
|
@@ -922,18 +922,18 @@ function F(t, e = globalThis, r = ["*"]) {
|
|
|
922
922
|
d[o.slice(-1)[0]] = P(s.data.value), u = !0;
|
|
923
923
|
break;
|
|
924
924
|
case "APPLY":
|
|
925
|
-
u = g.apply(d,
|
|
925
|
+
u = g.apply(d, l);
|
|
926
926
|
break;
|
|
927
927
|
case "CONSTRUCT":
|
|
928
928
|
{
|
|
929
|
-
const p = new g(...
|
|
930
|
-
u =
|
|
929
|
+
const p = new g(...l);
|
|
930
|
+
u = J(p);
|
|
931
931
|
}
|
|
932
932
|
break;
|
|
933
933
|
case "ENDPOINT":
|
|
934
934
|
{
|
|
935
935
|
const { port1: p, port2: v } = new MessageChannel();
|
|
936
|
-
F(t, v), u =
|
|
936
|
+
F(t, v), u = be(p, [p]);
|
|
937
937
|
}
|
|
938
938
|
break;
|
|
939
939
|
case "RELEASE":
|
|
@@ -947,21 +947,21 @@ function F(t, e = globalThis, r = ["*"]) {
|
|
|
947
947
|
}
|
|
948
948
|
Promise.resolve(u).catch((d) => ({ value: d, [k]: 0 })).then((d) => {
|
|
949
949
|
const [g, p] = C(d);
|
|
950
|
-
e.postMessage(Object.assign(Object.assign({}, g), { id:
|
|
950
|
+
e.postMessage(Object.assign(Object.assign({}, g), { id: a }), p), i === "RELEASE" && (e.removeEventListener("message", n), B(e), H in t && typeof t[H] == "function" && t[H]());
|
|
951
951
|
}).catch((d) => {
|
|
952
952
|
const [g, p] = C({
|
|
953
953
|
value: new TypeError("Unserializable return value"),
|
|
954
954
|
[k]: 0
|
|
955
955
|
});
|
|
956
|
-
e.postMessage(Object.assign(Object.assign({}, g), { id:
|
|
956
|
+
e.postMessage(Object.assign(Object.assign({}, g), { id: a }), p);
|
|
957
957
|
});
|
|
958
958
|
}), e.start && e.start();
|
|
959
959
|
}
|
|
960
|
-
function
|
|
960
|
+
function ge(t) {
|
|
961
961
|
return t.constructor.name === "MessagePort";
|
|
962
962
|
}
|
|
963
|
-
function
|
|
964
|
-
|
|
963
|
+
function B(t) {
|
|
964
|
+
ge(t) && t.close();
|
|
965
965
|
}
|
|
966
966
|
function I(t, e) {
|
|
967
967
|
return U(t, [], e);
|
|
@@ -970,96 +970,96 @@ function _(t) {
|
|
|
970
970
|
if (t)
|
|
971
971
|
throw new Error("Proxy has been released and is not useable");
|
|
972
972
|
}
|
|
973
|
-
function
|
|
973
|
+
function G(t) {
|
|
974
974
|
return E(t, {
|
|
975
975
|
type: "RELEASE"
|
|
976
976
|
}).then(() => {
|
|
977
|
-
|
|
977
|
+
B(t);
|
|
978
978
|
});
|
|
979
979
|
}
|
|
980
980
|
const x = /* @__PURE__ */ new WeakMap(), T = "FinalizationRegistry" in globalThis && new FinalizationRegistry((t) => {
|
|
981
981
|
const e = (x.get(t) || 0) - 1;
|
|
982
|
-
x.set(t, e), e === 0 &&
|
|
982
|
+
x.set(t, e), e === 0 && G(t);
|
|
983
983
|
});
|
|
984
|
-
function
|
|
984
|
+
function ye(t, e) {
|
|
985
985
|
const r = (x.get(e) || 0) + 1;
|
|
986
986
|
x.set(e, r), T && T.register(t, e, t);
|
|
987
987
|
}
|
|
988
|
-
function
|
|
988
|
+
function we(t) {
|
|
989
989
|
T && T.unregister(t);
|
|
990
990
|
}
|
|
991
991
|
function U(t, e = [], r = function() {
|
|
992
992
|
}) {
|
|
993
993
|
let n = !1;
|
|
994
994
|
const s = new Proxy(r, {
|
|
995
|
-
get(
|
|
996
|
-
if (_(n), i ===
|
|
995
|
+
get(a, i) {
|
|
996
|
+
if (_(n), i === he)
|
|
997
997
|
return () => {
|
|
998
|
-
|
|
998
|
+
we(s), G(t), n = !0;
|
|
999
999
|
};
|
|
1000
1000
|
if (i === "then") {
|
|
1001
1001
|
if (e.length === 0)
|
|
1002
1002
|
return { then: () => s };
|
|
1003
1003
|
const o = E(t, {
|
|
1004
1004
|
type: "GET",
|
|
1005
|
-
path: e.map((
|
|
1005
|
+
path: e.map((l) => l.toString())
|
|
1006
1006
|
}).then(P);
|
|
1007
1007
|
return o.then.bind(o);
|
|
1008
1008
|
}
|
|
1009
1009
|
return U(t, [...e, i]);
|
|
1010
1010
|
},
|
|
1011
|
-
set(
|
|
1011
|
+
set(a, i, o) {
|
|
1012
1012
|
_(n);
|
|
1013
|
-
const [
|
|
1013
|
+
const [l, u] = C(o);
|
|
1014
1014
|
return E(t, {
|
|
1015
1015
|
type: "SET",
|
|
1016
1016
|
path: [...e, i].map((d) => d.toString()),
|
|
1017
|
-
value:
|
|
1017
|
+
value: l
|
|
1018
1018
|
}, u).then(P);
|
|
1019
1019
|
},
|
|
1020
|
-
apply(
|
|
1020
|
+
apply(a, i, o) {
|
|
1021
1021
|
_(n);
|
|
1022
|
-
const
|
|
1023
|
-
if (
|
|
1022
|
+
const l = e[e.length - 1];
|
|
1023
|
+
if (l === de)
|
|
1024
1024
|
return E(t, {
|
|
1025
1025
|
type: "ENDPOINT"
|
|
1026
1026
|
}).then(P);
|
|
1027
|
-
if (
|
|
1027
|
+
if (l === "bind")
|
|
1028
1028
|
return U(t, e.slice(0, -1));
|
|
1029
|
-
const [u, d] =
|
|
1029
|
+
const [u, d] = W(o);
|
|
1030
1030
|
return E(t, {
|
|
1031
1031
|
type: "APPLY",
|
|
1032
1032
|
path: e.map((g) => g.toString()),
|
|
1033
1033
|
argumentList: u
|
|
1034
1034
|
}, d).then(P);
|
|
1035
1035
|
},
|
|
1036
|
-
construct(
|
|
1036
|
+
construct(a, i) {
|
|
1037
1037
|
_(n);
|
|
1038
|
-
const [o,
|
|
1038
|
+
const [o, l] = W(i);
|
|
1039
1039
|
return E(t, {
|
|
1040
1040
|
type: "CONSTRUCT",
|
|
1041
1041
|
path: e.map((u) => u.toString()),
|
|
1042
1042
|
argumentList: o
|
|
1043
|
-
},
|
|
1043
|
+
}, l).then(P);
|
|
1044
1044
|
}
|
|
1045
1045
|
});
|
|
1046
|
-
return
|
|
1046
|
+
return ye(s, t), s;
|
|
1047
1047
|
}
|
|
1048
|
-
function
|
|
1048
|
+
function Pe(t) {
|
|
1049
1049
|
return Array.prototype.concat.apply([], t);
|
|
1050
1050
|
}
|
|
1051
|
-
function
|
|
1051
|
+
function W(t) {
|
|
1052
1052
|
const e = t.map(C);
|
|
1053
|
-
return [e.map((r) => r[0]),
|
|
1053
|
+
return [e.map((r) => r[0]), Pe(e.map((r) => r[1]))];
|
|
1054
1054
|
}
|
|
1055
|
-
const
|
|
1056
|
-
function
|
|
1057
|
-
return
|
|
1055
|
+
const V = /* @__PURE__ */ new WeakMap();
|
|
1056
|
+
function be(t, e) {
|
|
1057
|
+
return V.set(t, e), t;
|
|
1058
1058
|
}
|
|
1059
|
-
function
|
|
1060
|
-
return Object.assign(t, { [
|
|
1059
|
+
function J(t) {
|
|
1060
|
+
return Object.assign(t, { [$]: !0 });
|
|
1061
1061
|
}
|
|
1062
|
-
function
|
|
1062
|
+
function Y(t, e = globalThis, r = "*") {
|
|
1063
1063
|
return {
|
|
1064
1064
|
postMessage: (n, s) => t.postMessage(n, r, s),
|
|
1065
1065
|
addEventListener: e.addEventListener.bind(e),
|
|
@@ -1084,7 +1084,7 @@ function C(t) {
|
|
|
1084
1084
|
type: "RAW",
|
|
1085
1085
|
value: t
|
|
1086
1086
|
},
|
|
1087
|
-
|
|
1087
|
+
V.get(t) || []
|
|
1088
1088
|
];
|
|
1089
1089
|
}
|
|
1090
1090
|
function P(t) {
|
|
@@ -1097,36 +1097,39 @@ function P(t) {
|
|
|
1097
1097
|
}
|
|
1098
1098
|
function E(t, e, r) {
|
|
1099
1099
|
return new Promise((n) => {
|
|
1100
|
-
const s =
|
|
1101
|
-
t.addEventListener("message", function
|
|
1102
|
-
!i.data || !i.data.id || i.data.id !== s || (t.removeEventListener("message",
|
|
1100
|
+
const s = Ee();
|
|
1101
|
+
t.addEventListener("message", function a(i) {
|
|
1102
|
+
!i.data || !i.data.id || i.data.id !== s || (t.removeEventListener("message", a), n(i.data));
|
|
1103
1103
|
}), t.start && t.start(), t.postMessage(Object.assign({ id: s }, e), r);
|
|
1104
1104
|
});
|
|
1105
1105
|
}
|
|
1106
|
-
function
|
|
1106
|
+
function Ee() {
|
|
1107
1107
|
return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
|
|
1108
1108
|
}
|
|
1109
|
-
function
|
|
1110
|
-
|
|
1111
|
-
const e = t instanceof Worker ? t :
|
|
1112
|
-
return
|
|
1109
|
+
function xe(t) {
|
|
1110
|
+
K();
|
|
1111
|
+
const e = t instanceof Worker ? t : Y(t), r = I(e), n = M(r);
|
|
1112
|
+
return new Proxy(n, {
|
|
1113
|
+
get: (s, a) => a === "isConnected" ? () => r.isConnected() : r[a]
|
|
1114
|
+
});
|
|
1113
1115
|
}
|
|
1114
|
-
function
|
|
1115
|
-
|
|
1116
|
+
function Te(t, e) {
|
|
1117
|
+
K();
|
|
1116
1118
|
const r = Promise.resolve();
|
|
1117
1119
|
let n;
|
|
1118
1120
|
const s = new Promise((o) => {
|
|
1119
1121
|
n = o;
|
|
1120
|
-
}),
|
|
1121
|
-
get: (o,
|
|
1122
|
+
}), a = M(t), i = new Proxy(a, {
|
|
1123
|
+
get: (o, l) => l === "isConnected" ? () => r : l === "isReady" ? () => s : l in o ? o[l] : e?.[l]
|
|
1122
1124
|
});
|
|
1123
1125
|
return F(
|
|
1124
1126
|
i,
|
|
1125
|
-
typeof window < "u" ?
|
|
1127
|
+
typeof window < "u" ? Y(self.parent) : void 0
|
|
1126
1128
|
), [n, i];
|
|
1127
1129
|
}
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
+
let q = !1;
|
|
1131
|
+
function K() {
|
|
1132
|
+
q || (q = !0, S.set("EVENT", {
|
|
1130
1133
|
canHandle: (t) => t instanceof CustomEvent,
|
|
1131
1134
|
serialize: (t) => [
|
|
1132
1135
|
{
|
|
@@ -1153,27 +1156,27 @@ function J() {
|
|
|
1153
1156
|
deserialize(t) {
|
|
1154
1157
|
return R.fromRawData(t);
|
|
1155
1158
|
}
|
|
1156
|
-
});
|
|
1159
|
+
}));
|
|
1157
1160
|
}
|
|
1158
|
-
function
|
|
1161
|
+
function M(t) {
|
|
1159
1162
|
return new Proxy(t, {
|
|
1160
1163
|
get(e, r) {
|
|
1161
1164
|
switch (typeof e[r]) {
|
|
1162
1165
|
case "function":
|
|
1163
1166
|
return (...n) => e[r](...n);
|
|
1164
1167
|
case "object":
|
|
1165
|
-
return e[r] === null ? e[r] :
|
|
1168
|
+
return e[r] === null ? e[r] : M(e[r]);
|
|
1166
1169
|
case "undefined":
|
|
1167
1170
|
case "number":
|
|
1168
1171
|
case "string":
|
|
1169
1172
|
return e[r];
|
|
1170
1173
|
default:
|
|
1171
|
-
return
|
|
1174
|
+
return J(e[r]);
|
|
1172
1175
|
}
|
|
1173
1176
|
}
|
|
1174
1177
|
});
|
|
1175
1178
|
}
|
|
1176
|
-
async function
|
|
1179
|
+
async function Re(t = X) {
|
|
1177
1180
|
switch (t) {
|
|
1178
1181
|
case "8.2":
|
|
1179
1182
|
return await import("php_8_2.js");
|
|
@@ -1220,31 +1223,31 @@ class A extends m {
|
|
|
1220
1223
|
* @see load
|
|
1221
1224
|
*/
|
|
1222
1225
|
static loadSync(e, r = {}) {
|
|
1223
|
-
const n = new A(void 0, r.requestHandler),
|
|
1226
|
+
const n = new A(void 0, r.requestHandler), a = (async () => {
|
|
1224
1227
|
const i = await Promise.all([
|
|
1225
|
-
|
|
1228
|
+
Re(e),
|
|
1226
1229
|
...r.dataModules || []
|
|
1227
|
-
]), [o, ...
|
|
1230
|
+
]), [o, ...l] = i;
|
|
1228
1231
|
r.downloadMonitor?.setModules(i);
|
|
1229
|
-
const u = await
|
|
1232
|
+
const u = await oe(
|
|
1230
1233
|
o,
|
|
1231
1234
|
{
|
|
1232
1235
|
...r.emscriptenOptions || {},
|
|
1233
1236
|
...r.downloadMonitor?.getEmscriptenOptions() || {}
|
|
1234
1237
|
},
|
|
1235
|
-
|
|
1238
|
+
l
|
|
1236
1239
|
);
|
|
1237
|
-
return n.initializeRuntime(u), { dataModules:
|
|
1240
|
+
return n.initializeRuntime(u), { dataModules: l };
|
|
1238
1241
|
})();
|
|
1239
1242
|
return {
|
|
1240
1243
|
php: n,
|
|
1241
|
-
phpReady:
|
|
1242
|
-
dataModules:
|
|
1244
|
+
phpReady: a.then(() => n),
|
|
1245
|
+
dataModules: a.then((i) => i.dataModules)
|
|
1243
1246
|
};
|
|
1244
1247
|
}
|
|
1245
1248
|
}
|
|
1246
1249
|
const h = /* @__PURE__ */ new WeakMap();
|
|
1247
|
-
class
|
|
1250
|
+
class Ce {
|
|
1248
1251
|
/** @inheritDoc */
|
|
1249
1252
|
constructor(e, r) {
|
|
1250
1253
|
h.set(this, {
|
|
@@ -1328,33 +1331,33 @@ class Te {
|
|
|
1328
1331
|
return h.get(this).php.fileExists(e);
|
|
1329
1332
|
}
|
|
1330
1333
|
}
|
|
1331
|
-
function
|
|
1334
|
+
function ve(t, e) {
|
|
1332
1335
|
return {
|
|
1333
1336
|
type: "response",
|
|
1334
1337
|
requestId: t,
|
|
1335
1338
|
response: e
|
|
1336
1339
|
};
|
|
1337
1340
|
}
|
|
1338
|
-
async function
|
|
1341
|
+
async function Fe(t, e, r, n) {
|
|
1339
1342
|
const s = navigator.serviceWorker;
|
|
1340
1343
|
if (!s)
|
|
1341
1344
|
throw new Error("Service workers are not supported in this browser.");
|
|
1342
|
-
const
|
|
1343
|
-
if (
|
|
1344
|
-
const i = await
|
|
1345
|
+
const a = await s.getRegistrations();
|
|
1346
|
+
if (a.length > 0) {
|
|
1347
|
+
const i = await Se();
|
|
1345
1348
|
if (n !== i) {
|
|
1346
1349
|
console.debug(
|
|
1347
1350
|
`[window] Reloading the currently registered Service Worker (expected version: ${n}, registered version: ${i})`
|
|
1348
1351
|
);
|
|
1349
|
-
for (const o of
|
|
1350
|
-
let
|
|
1352
|
+
for (const o of a) {
|
|
1353
|
+
let l = !1;
|
|
1351
1354
|
try {
|
|
1352
1355
|
await o.update();
|
|
1353
1356
|
} catch {
|
|
1354
|
-
|
|
1357
|
+
l = !0;
|
|
1355
1358
|
}
|
|
1356
1359
|
const u = o.waiting || o.installing;
|
|
1357
|
-
u && !
|
|
1360
|
+
u && !l && (i !== null ? u.postMessage("skip-waiting") : l = !0), l && (await o.unregister(), window.location.reload());
|
|
1358
1361
|
}
|
|
1359
1362
|
}
|
|
1360
1363
|
} else
|
|
@@ -1368,35 +1371,35 @@ async function Ce(t, e, r, n) {
|
|
|
1368
1371
|
async function(o) {
|
|
1369
1372
|
if (console.debug("Message from ServiceWorker", o), e && o.data.scope !== e)
|
|
1370
1373
|
return;
|
|
1371
|
-
const
|
|
1372
|
-
o.source.postMessage(
|
|
1374
|
+
const l = o.data.args || [], u = o.data.method, d = await t[u](...l);
|
|
1375
|
+
o.source.postMessage(ve(o.data.requestId, d));
|
|
1373
1376
|
}
|
|
1374
1377
|
), s.startMessages();
|
|
1375
1378
|
}
|
|
1376
|
-
async function
|
|
1379
|
+
async function Se() {
|
|
1377
1380
|
try {
|
|
1378
1381
|
return (await (await fetch("/version")).json()).version;
|
|
1379
1382
|
} catch {
|
|
1380
1383
|
return null;
|
|
1381
1384
|
}
|
|
1382
1385
|
}
|
|
1383
|
-
function
|
|
1386
|
+
function He() {
|
|
1384
1387
|
const t = {};
|
|
1385
1388
|
return typeof self?.location?.href < "u" && new URL(self.location.href).searchParams.forEach((r, n) => {
|
|
1386
1389
|
t[n] = r;
|
|
1387
1390
|
}), t;
|
|
1388
1391
|
}
|
|
1389
|
-
const
|
|
1392
|
+
const Oe = function() {
|
|
1390
1393
|
return typeof navigator < "u" && navigator?.userAgent?.toLowerCase().indexOf("firefox") > -1 ? "iframe" : "webworker";
|
|
1391
1394
|
}();
|
|
1392
|
-
async function
|
|
1393
|
-
if (t =
|
|
1395
|
+
async function Ue(t, e = "webworker", r = {}) {
|
|
1396
|
+
if (t = _e(t, r), e === "webworker")
|
|
1394
1397
|
return new Worker(t, { type: "module" });
|
|
1395
1398
|
if (e === "iframe")
|
|
1396
|
-
return (await
|
|
1399
|
+
return (await ke(t)).contentWindow;
|
|
1397
1400
|
throw new Error(`Unknown backendName: ${e}`);
|
|
1398
1401
|
}
|
|
1399
|
-
function
|
|
1402
|
+
function _e(t, e) {
|
|
1400
1403
|
if (!Object.entries(e).length)
|
|
1401
1404
|
return t + "";
|
|
1402
1405
|
const r = new URL(t);
|
|
@@ -1404,7 +1407,7 @@ function Se(t, e) {
|
|
|
1404
1407
|
r.searchParams.set(n, s);
|
|
1405
1408
|
return r.toString();
|
|
1406
1409
|
}
|
|
1407
|
-
async function
|
|
1410
|
+
async function ke(t) {
|
|
1408
1411
|
const e = document.createElement("iframe"), r = "/" + t.split("/").slice(-1)[0];
|
|
1409
1412
|
return e.src = r, e.style.display = "none", document.body.appendChild(e), await new Promise((n) => {
|
|
1410
1413
|
e.addEventListener("load", n);
|
|
@@ -1412,12 +1415,12 @@ async function _e(t) {
|
|
|
1412
1415
|
}
|
|
1413
1416
|
export {
|
|
1414
1417
|
A as WebPHP,
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1418
|
+
Ce as WebPHPEndpoint,
|
|
1419
|
+
xe as consumeAPI,
|
|
1420
|
+
Te as exposeAPI,
|
|
1421
|
+
Re as getPHPLoaderModule,
|
|
1422
|
+
He as parseWorkerStartupOptions,
|
|
1423
|
+
Oe as recommendedWorkerBackend,
|
|
1424
|
+
Fe as registerServiceWorker,
|
|
1425
|
+
Ue as spawnPHPWorkerThread
|
|
1423
1426
|
};
|
package/index.d.ts
CHANGED
|
@@ -168,7 +168,8 @@ export interface RequestHandler {
|
|
|
168
168
|
*/
|
|
169
169
|
absoluteUrl: string;
|
|
170
170
|
/**
|
|
171
|
-
* The
|
|
171
|
+
* The directory in the PHP filesystem where the server will look
|
|
172
|
+
* for the files to serve. Default: `/var/www`.
|
|
172
173
|
*/
|
|
173
174
|
documentRoot: string;
|
|
174
175
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@php-wasm/web",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.35",
|
|
4
4
|
"description": "PHP.wasm for the web",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"type": "module",
|
|
30
30
|
"main": "index.js",
|
|
31
31
|
"types": "index.d.ts",
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "0962f89a2b1a438997960a25c26f5341db063a3e"
|
|
33
33
|
}
|