@php-wasm/web 0.1.19 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{index-e5292333.js → index-76fc2ecf.js} +156 -146
- package/index.d.ts +12 -4
- package/package.json +2 -2
|
@@ -150,7 +150,7 @@ class ee {
|
|
|
150
150
|
#n;
|
|
151
151
|
#o;
|
|
152
152
|
#a;
|
|
153
|
-
#
|
|
153
|
+
#c;
|
|
154
154
|
/**
|
|
155
155
|
* @param php - The PHP instance.
|
|
156
156
|
* @param config - Request Handler configuration.
|
|
@@ -159,10 +159,10 @@ class ee {
|
|
|
159
159
|
this.#a = new Z({ concurrency: 1 });
|
|
160
160
|
const {
|
|
161
161
|
documentRoot: n = "/www/",
|
|
162
|
-
absoluteUrl: s = location
|
|
162
|
+
absoluteUrl: s = typeof location == "object" ? location?.href : "",
|
|
163
163
|
isStaticFilePath: a = () => !1
|
|
164
164
|
} = r;
|
|
165
|
-
this.php = e, this.#e = n, this.#
|
|
165
|
+
this.php = e, this.#e = n, this.#c = a;
|
|
166
166
|
const i = new URL(s);
|
|
167
167
|
this.#r = i.hostname, this.#s = i.port ? Number(i.port) : i.protocol === "https:" ? 443 : 80, this.#t = (i.protocol || "").replace(":", "");
|
|
168
168
|
const o = this.#s !== 443 && this.#s !== 80;
|
|
@@ -226,7 +226,7 @@ class ee {
|
|
|
226
226
|
n.pathname,
|
|
227
227
|
this.#n
|
|
228
228
|
);
|
|
229
|
-
return this.#
|
|
229
|
+
return this.#c(s) ? this.#l(s) : await this.#u(e, n);
|
|
230
230
|
}
|
|
231
231
|
/**
|
|
232
232
|
* Serves a static file from the PHP filesystem.
|
|
@@ -234,7 +234,7 @@ class ee {
|
|
|
234
234
|
* @param path - The requested static file path.
|
|
235
235
|
* @returns The response.
|
|
236
236
|
*/
|
|
237
|
-
#
|
|
237
|
+
#l(e) {
|
|
238
238
|
const r = `${this.#e}${e}`;
|
|
239
239
|
if (!this.php.fileExists(r))
|
|
240
240
|
return new E(
|
|
@@ -275,13 +275,13 @@ class ee {
|
|
|
275
275
|
const a = [];
|
|
276
276
|
if (e.files) {
|
|
277
277
|
s = "POST";
|
|
278
|
-
for (const
|
|
279
|
-
const
|
|
278
|
+
for (const c in e.files) {
|
|
279
|
+
const l = e.files[c];
|
|
280
280
|
a.push({
|
|
281
|
-
key:
|
|
282
|
-
name:
|
|
283
|
-
type:
|
|
284
|
-
data: new Uint8Array(await
|
|
281
|
+
key: c,
|
|
282
|
+
name: l.name,
|
|
283
|
+
type: l.type,
|
|
284
|
+
data: new Uint8Array(await l.arrayBuffer())
|
|
285
285
|
});
|
|
286
286
|
}
|
|
287
287
|
}
|
|
@@ -444,17 +444,17 @@ const I = {
|
|
|
444
444
|
75: "Cross-device link.",
|
|
445
445
|
76: "Extension: Capabilities insufficient."
|
|
446
446
|
};
|
|
447
|
-
function
|
|
447
|
+
function y(t = "") {
|
|
448
448
|
return function(r, n, s) {
|
|
449
449
|
const a = s.value;
|
|
450
450
|
s.value = function(...i) {
|
|
451
451
|
try {
|
|
452
452
|
return a.apply(this, i);
|
|
453
453
|
} catch (o) {
|
|
454
|
-
const
|
|
455
|
-
if (
|
|
456
|
-
const
|
|
457
|
-
throw new Error(`${p}: ${
|
|
454
|
+
const c = typeof o == "object" ? o?.errno : null;
|
|
455
|
+
if (c in I) {
|
|
456
|
+
const l = I[c], u = typeof i[0] == "string" ? i[0] : null, p = u !== null ? t.replaceAll("{path}", u) : t;
|
|
457
|
+
throw new Error(`${p}: ${l}`, {
|
|
458
458
|
cause: o
|
|
459
459
|
});
|
|
460
460
|
}
|
|
@@ -463,12 +463,12 @@ function g(t = "") {
|
|
|
463
463
|
};
|
|
464
464
|
};
|
|
465
465
|
}
|
|
466
|
-
var re = Object.defineProperty, ne = Object.getOwnPropertyDescriptor,
|
|
466
|
+
var re = Object.defineProperty, ne = Object.getOwnPropertyDescriptor, g = (t, e, r, n) => {
|
|
467
467
|
for (var s = n > 1 ? void 0 : n ? ne(e, r) : e, a = t.length - 1, i; a >= 0; a--)
|
|
468
468
|
(i = t[a]) && (s = (n ? i(e, r, s) : i(s)) || s);
|
|
469
469
|
return n && s && re(e, r, s), s;
|
|
470
470
|
};
|
|
471
|
-
const
|
|
471
|
+
const d = "string", w = "number", x = [], se = function() {
|
|
472
472
|
return typeof window < "u" && !{}.TEST ? "WEB" : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? "WORKER" : "NODE";
|
|
473
473
|
}();
|
|
474
474
|
class m {
|
|
@@ -490,9 +490,9 @@ class m {
|
|
|
490
490
|
initializeRuntime(e) {
|
|
491
491
|
if (this.#e)
|
|
492
492
|
throw new Error("PHP runtime already initialized.");
|
|
493
|
-
if (!
|
|
493
|
+
if (!x[e])
|
|
494
494
|
throw new Error("Invalid PHP runtime id.");
|
|
495
|
-
this.#e =
|
|
495
|
+
this.#e = x[e];
|
|
496
496
|
}
|
|
497
497
|
/** @inheritDoc */
|
|
498
498
|
setPhpIniPath(e) {
|
|
@@ -523,7 +523,7 @@ class m {
|
|
|
523
523
|
host: "example.com:443",
|
|
524
524
|
...ie(e.headers || {})
|
|
525
525
|
};
|
|
526
|
-
if (this.#o(r, e.protocol || "http"), this.#
|
|
526
|
+
if (this.#o(r, e.protocol || "http"), this.#c(n), e.body && this.#l(e.body), e.fileInfos)
|
|
527
527
|
for (const s of e.fileInfos)
|
|
528
528
|
this.#h(s);
|
|
529
529
|
return e.code && this.#d(" ?>" + e.code), await this.#f();
|
|
@@ -537,7 +537,7 @@ class m {
|
|
|
537
537
|
this.#e.ccall(
|
|
538
538
|
"wasm_set_phpini_entries",
|
|
539
539
|
null,
|
|
540
|
-
[
|
|
540
|
+
[d],
|
|
541
541
|
[e]
|
|
542
542
|
);
|
|
543
543
|
}
|
|
@@ -545,7 +545,7 @@ class m {
|
|
|
545
545
|
}
|
|
546
546
|
cli(e) {
|
|
547
547
|
for (const r of e)
|
|
548
|
-
this.#e.ccall("wasm_add_cli_arg", null, [
|
|
548
|
+
this.#e.ccall("wasm_add_cli_arg", null, [d], [r]);
|
|
549
549
|
return this.#e.ccall("run_cli", null, [], [], { async: !0 });
|
|
550
550
|
}
|
|
551
551
|
#i() {
|
|
@@ -567,51 +567,51 @@ class m {
|
|
|
567
567
|
};
|
|
568
568
|
}
|
|
569
569
|
#n(e) {
|
|
570
|
-
if (this.#e.ccall("wasm_set_request_uri", null, [
|
|
570
|
+
if (this.#e.ccall("wasm_set_request_uri", null, [d], [e]), e.includes("?")) {
|
|
571
571
|
const r = e.substring(e.indexOf("?") + 1);
|
|
572
572
|
this.#e.ccall(
|
|
573
573
|
"wasm_set_query_string",
|
|
574
574
|
null,
|
|
575
|
-
[
|
|
575
|
+
[d],
|
|
576
576
|
[r]
|
|
577
577
|
);
|
|
578
578
|
}
|
|
579
579
|
}
|
|
580
580
|
#o(e, r) {
|
|
581
|
-
this.#e.ccall("wasm_set_request_host", null, [
|
|
581
|
+
this.#e.ccall("wasm_set_request_host", null, [d], [e]);
|
|
582
582
|
let n;
|
|
583
583
|
try {
|
|
584
584
|
n = parseInt(new URL(e).port, 10);
|
|
585
585
|
} catch {
|
|
586
586
|
}
|
|
587
|
-
(!n || isNaN(n) || n === 80) && (n = r === "https" ? 443 : 80), this.#e.ccall("wasm_set_request_port", null, [
|
|
587
|
+
(!n || isNaN(n) || n === 80) && (n = r === "https" ? 443 : 80), this.#e.ccall("wasm_set_request_port", null, [w], [n]), (r === "https" || !r && n === 443) && this.addServerGlobalEntry("HTTPS", "on");
|
|
588
588
|
}
|
|
589
589
|
#a(e) {
|
|
590
|
-
this.#e.ccall("wasm_set_request_method", null, [
|
|
590
|
+
this.#e.ccall("wasm_set_request_method", null, [d], [e]);
|
|
591
591
|
}
|
|
592
592
|
setSkipShebang(e) {
|
|
593
593
|
this.#e.ccall(
|
|
594
594
|
"wasm_set_skip_shebang",
|
|
595
595
|
null,
|
|
596
|
-
[
|
|
596
|
+
[w],
|
|
597
597
|
[e ? 1 : 0]
|
|
598
598
|
);
|
|
599
599
|
}
|
|
600
|
-
#
|
|
600
|
+
#c(e) {
|
|
601
601
|
e.cookie && this.#e.ccall(
|
|
602
602
|
"wasm_set_cookies",
|
|
603
603
|
null,
|
|
604
|
-
[
|
|
604
|
+
[d],
|
|
605
605
|
[e.cookie]
|
|
606
606
|
), e["content-type"] && this.#e.ccall(
|
|
607
607
|
"wasm_set_content_type",
|
|
608
608
|
null,
|
|
609
|
-
[
|
|
609
|
+
[d],
|
|
610
610
|
[e["content-type"]]
|
|
611
611
|
), e["content-length"] && this.#e.ccall(
|
|
612
612
|
"wasm_set_content_length",
|
|
613
613
|
null,
|
|
614
|
-
[
|
|
614
|
+
[w],
|
|
615
615
|
[parseInt(e["content-length"], 10)]
|
|
616
616
|
);
|
|
617
617
|
for (const r in e)
|
|
@@ -620,22 +620,22 @@ class m {
|
|
|
620
620
|
e[r]
|
|
621
621
|
);
|
|
622
622
|
}
|
|
623
|
-
#
|
|
624
|
-
this.#e.ccall("wasm_set_request_body", null, [
|
|
623
|
+
#l(e) {
|
|
624
|
+
this.#e.ccall("wasm_set_request_body", null, [d], [e]), this.#e.ccall(
|
|
625
625
|
"wasm_set_content_length",
|
|
626
626
|
null,
|
|
627
|
-
[
|
|
627
|
+
[w],
|
|
628
628
|
[e.length]
|
|
629
629
|
);
|
|
630
630
|
}
|
|
631
631
|
#u(e) {
|
|
632
|
-
this.#e.ccall("wasm_set_path_translated", null, [
|
|
632
|
+
this.#e.ccall("wasm_set_path_translated", null, [d], [e]);
|
|
633
633
|
}
|
|
634
634
|
addServerGlobalEntry(e, r) {
|
|
635
635
|
this.#e.ccall(
|
|
636
636
|
"wasm_add_SERVER_entry",
|
|
637
637
|
null,
|
|
638
|
-
[
|
|
638
|
+
[d, d],
|
|
639
639
|
[e, r]
|
|
640
640
|
);
|
|
641
641
|
}
|
|
@@ -655,17 +655,17 @@ class m {
|
|
|
655
655
|
this.#e.ccall(
|
|
656
656
|
"wasm_add_uploaded_file",
|
|
657
657
|
null,
|
|
658
|
-
[
|
|
658
|
+
[d, d, d, d, w, w],
|
|
659
659
|
[r, n, s, i, o, a.byteLength]
|
|
660
660
|
);
|
|
661
661
|
}
|
|
662
662
|
#d(e) {
|
|
663
|
-
this.#e.ccall("wasm_set_php_code", null, [
|
|
663
|
+
this.#e.ccall("wasm_set_php_code", null, [d], [e]);
|
|
664
664
|
}
|
|
665
665
|
async #f() {
|
|
666
666
|
const e = await await this.#e.ccall(
|
|
667
667
|
"wasm_sapi_handle_request",
|
|
668
|
-
|
|
668
|
+
w,
|
|
669
669
|
[],
|
|
670
670
|
[]
|
|
671
671
|
), { headers: r, httpStatusCode: n } = this.#i();
|
|
@@ -677,9 +677,12 @@ class m {
|
|
|
677
677
|
e
|
|
678
678
|
);
|
|
679
679
|
}
|
|
680
|
-
|
|
680
|
+
mkdir(e) {
|
|
681
681
|
this.#e.FS.mkdirTree(e);
|
|
682
682
|
}
|
|
683
|
+
mkdirTree(e) {
|
|
684
|
+
this.mkdir(e);
|
|
685
|
+
}
|
|
683
686
|
readFileAsText(e) {
|
|
684
687
|
return new TextDecoder().decode(this.readFileAsBuffer(e));
|
|
685
688
|
}
|
|
@@ -718,37 +721,40 @@ class m {
|
|
|
718
721
|
mount(e, r) {
|
|
719
722
|
this.#e.FS.mount(
|
|
720
723
|
this.#e.FS.filesystems.NODEFS,
|
|
721
|
-
e,
|
|
724
|
+
typeof e == "object" ? e : { root: e },
|
|
722
725
|
r
|
|
723
726
|
);
|
|
724
727
|
}
|
|
725
728
|
}
|
|
726
|
-
|
|
727
|
-
|
|
729
|
+
g([
|
|
730
|
+
y('Could not create directory "{path}"')
|
|
731
|
+
], m.prototype, "mkdir", 1);
|
|
732
|
+
g([
|
|
733
|
+
y('Could not create directory "{path}"')
|
|
728
734
|
], m.prototype, "mkdirTree", 1);
|
|
729
|
-
|
|
730
|
-
|
|
735
|
+
g([
|
|
736
|
+
y('Could not read "{path}"')
|
|
731
737
|
], m.prototype, "readFileAsText", 1);
|
|
732
|
-
|
|
733
|
-
|
|
738
|
+
g([
|
|
739
|
+
y('Could not read "{path}"')
|
|
734
740
|
], m.prototype, "readFileAsBuffer", 1);
|
|
735
|
-
|
|
736
|
-
|
|
741
|
+
g([
|
|
742
|
+
y('Could not write to "{path}"')
|
|
737
743
|
], m.prototype, "writeFile", 1);
|
|
738
|
-
|
|
739
|
-
|
|
744
|
+
g([
|
|
745
|
+
y('Could not unlink "{path}"')
|
|
740
746
|
], m.prototype, "unlink", 1);
|
|
741
|
-
|
|
742
|
-
|
|
747
|
+
g([
|
|
748
|
+
y('Could not list files in "{path}"')
|
|
743
749
|
], m.prototype, "listFiles", 1);
|
|
744
|
-
|
|
745
|
-
|
|
750
|
+
g([
|
|
751
|
+
y('Could not stat "{path}"')
|
|
746
752
|
], m.prototype, "isDir", 1);
|
|
747
|
-
|
|
748
|
-
|
|
753
|
+
g([
|
|
754
|
+
y('Could not stat "{path}"')
|
|
749
755
|
], m.prototype, "fileExists", 1);
|
|
750
|
-
|
|
751
|
-
|
|
756
|
+
g([
|
|
757
|
+
y("Could not mount a directory")
|
|
752
758
|
], m.prototype, "mount", 1);
|
|
753
759
|
function ie(t) {
|
|
754
760
|
const e = {};
|
|
@@ -758,38 +764,38 @@ function ie(t) {
|
|
|
758
764
|
}
|
|
759
765
|
async function oe(t, e = {}, r = []) {
|
|
760
766
|
let n, s;
|
|
761
|
-
const a = new Promise((
|
|
762
|
-
s =
|
|
763
|
-
}), i = new Promise((
|
|
764
|
-
n =
|
|
767
|
+
const a = new Promise((c) => {
|
|
768
|
+
s = c;
|
|
769
|
+
}), i = new Promise((c) => {
|
|
770
|
+
n = c;
|
|
765
771
|
}), o = t.init(se, {
|
|
766
|
-
onAbort(
|
|
767
|
-
console.error("WASM aborted: "), console.error(
|
|
772
|
+
onAbort(c) {
|
|
773
|
+
console.error("WASM aborted: "), console.error(c);
|
|
768
774
|
},
|
|
769
775
|
ENV: {},
|
|
770
776
|
// Emscripten sometimes prepends a '/' to the path, which
|
|
771
777
|
// breaks vite dev mode. An identity `locateFile` function
|
|
772
778
|
// fixes it.
|
|
773
|
-
locateFile: (
|
|
779
|
+
locateFile: (c) => c,
|
|
774
780
|
...e,
|
|
775
781
|
noInitialRun: !0,
|
|
776
782
|
onRuntimeInitialized() {
|
|
777
783
|
e.onRuntimeInitialized && e.onRuntimeInitialized(), n();
|
|
778
784
|
},
|
|
779
|
-
monitorRunDependencies(
|
|
780
|
-
|
|
785
|
+
monitorRunDependencies(c) {
|
|
786
|
+
c === 0 && (delete o.monitorRunDependencies, s());
|
|
781
787
|
}
|
|
782
788
|
});
|
|
783
|
-
for (const { default:
|
|
784
|
-
|
|
785
|
-
return r.length || s(), await a, await i,
|
|
789
|
+
for (const { default: c } of r)
|
|
790
|
+
c(o);
|
|
791
|
+
return r.length || s(), await a, await i, x.push(o), x.length - 1;
|
|
786
792
|
}
|
|
787
793
|
/**
|
|
788
794
|
* @license
|
|
789
795
|
* Copyright 2019 Google LLC
|
|
790
796
|
* SPDX-License-Identifier: Apache-2.0
|
|
791
797
|
*/
|
|
792
|
-
const D = Symbol("Comlink.proxy"), ae = Symbol("Comlink.endpoint"),
|
|
798
|
+
const D = Symbol("Comlink.proxy"), ae = Symbol("Comlink.endpoint"), ce = Symbol("Comlink.releaseProxy"), O = Symbol("Comlink.finalizer"), k = Symbol("Comlink.thrown"), z = (t) => typeof t == "object" && t !== null || typeof t == "function", le = {
|
|
793
799
|
canHandle: (t) => z(t) && t[D],
|
|
794
800
|
serialize(t) {
|
|
795
801
|
const { port1: e, port2: r } = new MessageChannel();
|
|
@@ -799,7 +805,7 @@ const D = Symbol("Comlink.proxy"), ae = Symbol("Comlink.endpoint"), le = Symbol(
|
|
|
799
805
|
return t.start(), L(t);
|
|
800
806
|
}
|
|
801
807
|
}, ue = {
|
|
802
|
-
canHandle: (t) => z(t) &&
|
|
808
|
+
canHandle: (t) => z(t) && k in t,
|
|
803
809
|
serialize({ value: t }) {
|
|
804
810
|
let e;
|
|
805
811
|
return t instanceof Error ? e = {
|
|
@@ -815,7 +821,7 @@ const D = Symbol("Comlink.proxy"), ae = Symbol("Comlink.endpoint"), le = Symbol(
|
|
|
815
821
|
throw t.isError ? Object.assign(new Error(t.value.message), t.value) : t.value;
|
|
816
822
|
}
|
|
817
823
|
}, S = /* @__PURE__ */ new Map([
|
|
818
|
-
["proxy",
|
|
824
|
+
["proxy", le],
|
|
819
825
|
["throw", ue]
|
|
820
826
|
]);
|
|
821
827
|
function he(t, e) {
|
|
@@ -832,48 +838,48 @@ function F(t, e = globalThis, r = ["*"]) {
|
|
|
832
838
|
console.warn(`Invalid origin '${s.origin}' for comlink proxy`);
|
|
833
839
|
return;
|
|
834
840
|
}
|
|
835
|
-
const { id: a, type: i, path: o } = Object.assign({ path: [] }, s.data),
|
|
836
|
-
let
|
|
841
|
+
const { id: a, type: i, path: o } = Object.assign({ path: [] }, s.data), c = (s.data.argumentList || []).map(P);
|
|
842
|
+
let l;
|
|
837
843
|
try {
|
|
838
844
|
const u = o.slice(0, -1).reduce((f, R) => f[R], t), p = o.reduce((f, R) => f[R], t);
|
|
839
845
|
switch (i) {
|
|
840
846
|
case "GET":
|
|
841
|
-
|
|
847
|
+
l = p;
|
|
842
848
|
break;
|
|
843
849
|
case "SET":
|
|
844
|
-
u[o.slice(-1)[0]] = P(s.data.value),
|
|
850
|
+
u[o.slice(-1)[0]] = P(s.data.value), l = !0;
|
|
845
851
|
break;
|
|
846
852
|
case "APPLY":
|
|
847
|
-
|
|
853
|
+
l = p.apply(u, c);
|
|
848
854
|
break;
|
|
849
855
|
case "CONSTRUCT":
|
|
850
856
|
{
|
|
851
|
-
const f = new p(...
|
|
852
|
-
|
|
857
|
+
const f = new p(...c);
|
|
858
|
+
l = B(f);
|
|
853
859
|
}
|
|
854
860
|
break;
|
|
855
861
|
case "ENDPOINT":
|
|
856
862
|
{
|
|
857
863
|
const { port1: f, port2: R } = new MessageChannel();
|
|
858
|
-
F(t, R),
|
|
864
|
+
F(t, R), l = ye(f, [f]);
|
|
859
865
|
}
|
|
860
866
|
break;
|
|
861
867
|
case "RELEASE":
|
|
862
|
-
|
|
868
|
+
l = void 0;
|
|
863
869
|
break;
|
|
864
870
|
default:
|
|
865
871
|
return;
|
|
866
872
|
}
|
|
867
873
|
} catch (u) {
|
|
868
|
-
|
|
874
|
+
l = { value: u, [k]: 0 };
|
|
869
875
|
}
|
|
870
|
-
Promise.resolve(
|
|
876
|
+
Promise.resolve(l).catch((u) => ({ value: u, [k]: 0 })).then((u) => {
|
|
871
877
|
const [p, f] = C(u);
|
|
872
878
|
e.postMessage(Object.assign(Object.assign({}, p), { id: a }), f), i === "RELEASE" && (e.removeEventListener("message", n), $(e), O in t && typeof t[O] == "function" && t[O]());
|
|
873
879
|
}).catch((u) => {
|
|
874
880
|
const [p, f] = C({
|
|
875
881
|
value: new TypeError("Unserializable return value"),
|
|
876
|
-
[
|
|
882
|
+
[k]: 0
|
|
877
883
|
});
|
|
878
884
|
e.postMessage(Object.assign(Object.assign({}, p), { id: a }), f);
|
|
879
885
|
});
|
|
@@ -899,13 +905,13 @@ function q(t) {
|
|
|
899
905
|
$(t);
|
|
900
906
|
});
|
|
901
907
|
}
|
|
902
|
-
const
|
|
903
|
-
const e = (
|
|
904
|
-
|
|
908
|
+
const _ = /* @__PURE__ */ new WeakMap(), T = "FinalizationRegistry" in globalThis && new FinalizationRegistry((t) => {
|
|
909
|
+
const e = (_.get(t) || 0) - 1;
|
|
910
|
+
_.set(t, e), e === 0 && q(t);
|
|
905
911
|
});
|
|
906
912
|
function fe(t, e) {
|
|
907
|
-
const r = (
|
|
908
|
-
|
|
913
|
+
const r = (_.get(e) || 0) + 1;
|
|
914
|
+
_.set(e, r), T && T.register(t, e, t);
|
|
909
915
|
}
|
|
910
916
|
function pe(t) {
|
|
911
917
|
T && T.unregister(t);
|
|
@@ -915,7 +921,7 @@ function H(t, e = [], r = function() {
|
|
|
915
921
|
let n = !1;
|
|
916
922
|
const s = new Proxy(r, {
|
|
917
923
|
get(a, i) {
|
|
918
|
-
if (v(n), i ===
|
|
924
|
+
if (v(n), i === ce)
|
|
919
925
|
return () => {
|
|
920
926
|
pe(s), q(t), n = !0;
|
|
921
927
|
};
|
|
@@ -924,7 +930,7 @@ function H(t, e = [], r = function() {
|
|
|
924
930
|
return { then: () => s };
|
|
925
931
|
const o = b(t, {
|
|
926
932
|
type: "GET",
|
|
927
|
-
path: e.map((
|
|
933
|
+
path: e.map((c) => c.toString())
|
|
928
934
|
}).then(P);
|
|
929
935
|
return o.then.bind(o);
|
|
930
936
|
}
|
|
@@ -932,37 +938,37 @@ function H(t, e = [], r = function() {
|
|
|
932
938
|
},
|
|
933
939
|
set(a, i, o) {
|
|
934
940
|
v(n);
|
|
935
|
-
const [
|
|
941
|
+
const [c, l] = C(o);
|
|
936
942
|
return b(t, {
|
|
937
943
|
type: "SET",
|
|
938
944
|
path: [...e, i].map((u) => u.toString()),
|
|
939
|
-
value:
|
|
940
|
-
},
|
|
945
|
+
value: c
|
|
946
|
+
}, l).then(P);
|
|
941
947
|
},
|
|
942
948
|
apply(a, i, o) {
|
|
943
949
|
v(n);
|
|
944
|
-
const
|
|
945
|
-
if (
|
|
950
|
+
const c = e[e.length - 1];
|
|
951
|
+
if (c === ae)
|
|
946
952
|
return b(t, {
|
|
947
953
|
type: "ENDPOINT"
|
|
948
954
|
}).then(P);
|
|
949
|
-
if (
|
|
955
|
+
if (c === "bind")
|
|
950
956
|
return H(t, e.slice(0, -1));
|
|
951
|
-
const [
|
|
957
|
+
const [l, u] = U(o);
|
|
952
958
|
return b(t, {
|
|
953
959
|
type: "APPLY",
|
|
954
960
|
path: e.map((p) => p.toString()),
|
|
955
|
-
argumentList:
|
|
961
|
+
argumentList: l
|
|
956
962
|
}, u).then(P);
|
|
957
963
|
},
|
|
958
964
|
construct(a, i) {
|
|
959
965
|
v(n);
|
|
960
|
-
const [o,
|
|
966
|
+
const [o, c] = U(i);
|
|
961
967
|
return b(t, {
|
|
962
968
|
type: "CONSTRUCT",
|
|
963
|
-
path: e.map((
|
|
969
|
+
path: e.map((l) => l.toString()),
|
|
964
970
|
argumentList: o
|
|
965
|
-
},
|
|
971
|
+
}, c).then(P);
|
|
966
972
|
}
|
|
967
973
|
});
|
|
968
974
|
return fe(s, t), s;
|
|
@@ -975,7 +981,7 @@ function U(t) {
|
|
|
975
981
|
return [e.map((r) => r[0]), me(e.map((r) => r[1]))];
|
|
976
982
|
}
|
|
977
983
|
const j = /* @__PURE__ */ new WeakMap();
|
|
978
|
-
function
|
|
984
|
+
function ye(t, e) {
|
|
979
985
|
return j.set(t, e), t;
|
|
980
986
|
}
|
|
981
987
|
function B(t) {
|
|
@@ -1019,13 +1025,13 @@ function P(t) {
|
|
|
1019
1025
|
}
|
|
1020
1026
|
function b(t, e, r) {
|
|
1021
1027
|
return new Promise((n) => {
|
|
1022
|
-
const s =
|
|
1028
|
+
const s = ge();
|
|
1023
1029
|
t.addEventListener("message", function a(i) {
|
|
1024
1030
|
!i.data || !i.data.id || i.data.id !== s || (t.removeEventListener("message", a), n(i.data));
|
|
1025
1031
|
}), t.start && t.start(), t.postMessage(Object.assign({ id: s }, e), r);
|
|
1026
1032
|
});
|
|
1027
1033
|
}
|
|
1028
|
-
function
|
|
1034
|
+
function ge() {
|
|
1029
1035
|
return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
|
|
1030
1036
|
}
|
|
1031
1037
|
function ve(t) {
|
|
@@ -1033,7 +1039,7 @@ function ve(t) {
|
|
|
1033
1039
|
const e = t instanceof Worker ? t : V(t);
|
|
1034
1040
|
return L(e);
|
|
1035
1041
|
}
|
|
1036
|
-
function
|
|
1042
|
+
function ke(t, e) {
|
|
1037
1043
|
G();
|
|
1038
1044
|
let r;
|
|
1039
1045
|
const n = new Promise((i) => {
|
|
@@ -1094,7 +1100,7 @@ function J(t) {
|
|
|
1094
1100
|
}
|
|
1095
1101
|
});
|
|
1096
1102
|
}
|
|
1097
|
-
async function
|
|
1103
|
+
async function we(t = Y) {
|
|
1098
1104
|
switch (t) {
|
|
1099
1105
|
case "8.2":
|
|
1100
1106
|
return await import("php_8_2.js");
|
|
@@ -1143,19 +1149,19 @@ class A extends m {
|
|
|
1143
1149
|
static loadSync(e, r = {}) {
|
|
1144
1150
|
const n = new A(void 0, r.requestHandler), a = (async () => {
|
|
1145
1151
|
const i = await Promise.all([
|
|
1146
|
-
|
|
1152
|
+
we(e),
|
|
1147
1153
|
...r.dataModules || []
|
|
1148
|
-
]), [o, ...
|
|
1154
|
+
]), [o, ...c] = i;
|
|
1149
1155
|
r.downloadMonitor?.setModules(i);
|
|
1150
|
-
const
|
|
1156
|
+
const l = await oe(
|
|
1151
1157
|
o,
|
|
1152
1158
|
{
|
|
1153
1159
|
...r.emscriptenOptions || {},
|
|
1154
1160
|
...r.downloadMonitor?.getEmscriptenOptions() || {}
|
|
1155
1161
|
},
|
|
1156
|
-
|
|
1162
|
+
c
|
|
1157
1163
|
);
|
|
1158
|
-
return n.initializeRuntime(
|
|
1164
|
+
return n.initializeRuntime(l), { dataModules: c };
|
|
1159
1165
|
})();
|
|
1160
1166
|
return {
|
|
1161
1167
|
php: n,
|
|
@@ -1164,11 +1170,11 @@ class A extends m {
|
|
|
1164
1170
|
};
|
|
1165
1171
|
}
|
|
1166
1172
|
}
|
|
1167
|
-
const
|
|
1168
|
-
class
|
|
1173
|
+
const h = /* @__PURE__ */ new WeakMap();
|
|
1174
|
+
class xe {
|
|
1169
1175
|
/** @inheritDoc */
|
|
1170
1176
|
constructor(e, r) {
|
|
1171
|
-
|
|
1177
|
+
h.set(this, {
|
|
1172
1178
|
php: e,
|
|
1173
1179
|
monitor: r
|
|
1174
1180
|
}), this.absoluteUrl = Promise.resolve(
|
|
@@ -1179,66 +1185,70 @@ class _e {
|
|
|
1179
1185
|
}
|
|
1180
1186
|
/** @inheritDoc @php-wasm/web!PHPRequestHandler.pathToInternalUrl */
|
|
1181
1187
|
async pathToInternalUrl(e) {
|
|
1182
|
-
return
|
|
1188
|
+
return h.get(this).php.requestHandler.server.pathToInternalUrl(e);
|
|
1183
1189
|
}
|
|
1184
1190
|
/** @inheritDoc @php-wasm/web!PHPRequestHandler.internalUrlToPath */
|
|
1185
1191
|
async internalUrlToPath(e) {
|
|
1186
|
-
return
|
|
1192
|
+
return h.get(this).php.requestHandler.server.internalUrlToPath(e);
|
|
1187
1193
|
}
|
|
1188
1194
|
async onDownloadProgress(e) {
|
|
1189
|
-
|
|
1195
|
+
h.get(this).monitor?.addEventListener("progress", e);
|
|
1190
1196
|
}
|
|
1191
1197
|
/** @inheritDoc @php-wasm/web!PHPRequestHandler.request */
|
|
1192
1198
|
request(e, r) {
|
|
1193
|
-
return
|
|
1199
|
+
return h.get(this).php.request(e, r);
|
|
1194
1200
|
}
|
|
1195
1201
|
/** @inheritDoc @php-wasm/web!PHP.run */
|
|
1196
1202
|
async run(e) {
|
|
1197
|
-
return
|
|
1203
|
+
return h.get(this).php.run(e);
|
|
1198
1204
|
}
|
|
1199
1205
|
/** @inheritDoc @php-wasm/web!PHP.chdir */
|
|
1200
1206
|
chdir(e) {
|
|
1201
|
-
return
|
|
1207
|
+
return h.get(this).php.chdir(e);
|
|
1202
1208
|
}
|
|
1203
1209
|
/** @inheritDoc @php-wasm/web!PHP.setPhpIniPath */
|
|
1204
1210
|
setPhpIniPath(e) {
|
|
1205
|
-
return
|
|
1211
|
+
return h.get(this).php.setPhpIniPath(e);
|
|
1206
1212
|
}
|
|
1207
1213
|
/** @inheritDoc @php-wasm/web!PHP.setPhpIniEntry */
|
|
1208
1214
|
setPhpIniEntry(e, r) {
|
|
1209
|
-
|
|
1215
|
+
h.get(this).php.setPhpIniEntry(e, r);
|
|
1216
|
+
}
|
|
1217
|
+
/** @inheritDoc @php-wasm/web!PHP.mkdir */
|
|
1218
|
+
mkdir(e) {
|
|
1219
|
+
h.get(this).php.mkdir(e);
|
|
1210
1220
|
}
|
|
1211
1221
|
/** @inheritDoc @php-wasm/web!PHP.mkdirTree */
|
|
1212
1222
|
mkdirTree(e) {
|
|
1213
|
-
|
|
1223
|
+
h.get(this).php.mkdirTree(e);
|
|
1214
1224
|
}
|
|
1215
1225
|
/** @inheritDoc @php-wasm/web!PHP.readFileAsText */
|
|
1216
1226
|
async readFileAsText(e) {
|
|
1217
|
-
return
|
|
1227
|
+
return h.get(this).php.readFileAsText(e);
|
|
1218
1228
|
}
|
|
1219
1229
|
/** @inheritDoc @php-wasm/web!PHP.readFileAsBuffer */
|
|
1220
1230
|
async readFileAsBuffer(e) {
|
|
1221
|
-
return
|
|
1231
|
+
return h.get(this).php.readFileAsBuffer(e);
|
|
1222
1232
|
}
|
|
1223
1233
|
/** @inheritDoc @php-wasm/web!PHP.writeFile */
|
|
1224
1234
|
writeFile(e, r) {
|
|
1225
|
-
|
|
1235
|
+
h.get(this).php.writeFile(e, r);
|
|
1226
1236
|
}
|
|
1227
1237
|
/** @inheritDoc @php-wasm/web!PHP.unlink */
|
|
1228
1238
|
unlink(e) {
|
|
1229
|
-
|
|
1239
|
+
h.get(this).php.unlink(e);
|
|
1230
1240
|
}
|
|
1231
1241
|
/** @inheritDoc @php-wasm/web!PHP.listFiles */
|
|
1232
1242
|
async listFiles(e) {
|
|
1233
|
-
return
|
|
1243
|
+
return h.get(this).php.listFiles(e);
|
|
1234
1244
|
}
|
|
1235
1245
|
/** @inheritDoc @php-wasm/web!PHP.isDir */
|
|
1236
1246
|
async isDir(e) {
|
|
1237
|
-
return
|
|
1247
|
+
return h.get(this).php.isDir(e);
|
|
1238
1248
|
}
|
|
1239
1249
|
/** @inheritDoc @php-wasm/web!PHP.fileExists */
|
|
1240
1250
|
async fileExists(e) {
|
|
1241
|
-
return
|
|
1251
|
+
return h.get(this).php.fileExists(e);
|
|
1242
1252
|
}
|
|
1243
1253
|
}
|
|
1244
1254
|
function Pe(t, e) {
|
|
@@ -1248,7 +1258,7 @@ function Pe(t, e) {
|
|
|
1248
1258
|
response: e
|
|
1249
1259
|
};
|
|
1250
1260
|
}
|
|
1251
|
-
async function
|
|
1261
|
+
async function _e(t, e, r, n) {
|
|
1252
1262
|
const s = navigator.serviceWorker;
|
|
1253
1263
|
if (!s)
|
|
1254
1264
|
throw new Error("Service workers are not supported in this browser.");
|
|
@@ -1260,14 +1270,14 @@ async function ke(t, e, r, n) {
|
|
|
1260
1270
|
`[window] Reloading the currently registered Service Worker (expected version: ${n}, registered version: ${i})`
|
|
1261
1271
|
);
|
|
1262
1272
|
for (const o of a) {
|
|
1263
|
-
let
|
|
1273
|
+
let c = !1;
|
|
1264
1274
|
try {
|
|
1265
1275
|
await o.update();
|
|
1266
1276
|
} catch {
|
|
1267
|
-
|
|
1277
|
+
c = !0;
|
|
1268
1278
|
}
|
|
1269
|
-
const
|
|
1270
|
-
|
|
1279
|
+
const l = o.waiting || o.installing;
|
|
1280
|
+
l && !c && (i !== null ? l.postMessage("skip-waiting") : c = !0), c && (await o.unregister(), window.location.reload());
|
|
1271
1281
|
}
|
|
1272
1282
|
}
|
|
1273
1283
|
} else
|
|
@@ -1281,7 +1291,7 @@ async function ke(t, e, r, n) {
|
|
|
1281
1291
|
async function(o) {
|
|
1282
1292
|
if (console.debug("Message from ServiceWorker", o), e && o.data.scope !== e)
|
|
1283
1293
|
return;
|
|
1284
|
-
const
|
|
1294
|
+
const c = o.data.args || [], l = o.data.method, u = await t[l](...c);
|
|
1285
1295
|
o.source.postMessage(Pe(o.data.requestId, u));
|
|
1286
1296
|
}
|
|
1287
1297
|
), s.startMessages();
|
|
@@ -1300,7 +1310,7 @@ function Te() {
|
|
|
1300
1310
|
}), t;
|
|
1301
1311
|
}
|
|
1302
1312
|
const Ce = function() {
|
|
1303
|
-
return navigator
|
|
1313
|
+
return navigator?.userAgent?.toLowerCase().indexOf("firefox") > -1 ? "iframe" : "webworker";
|
|
1304
1314
|
}();
|
|
1305
1315
|
async function Fe(t, e = "webworker", r = {}) {
|
|
1306
1316
|
if (t = Ee(t, r), e === "webworker")
|
|
@@ -1327,16 +1337,16 @@ export {
|
|
|
1327
1337
|
Y as LatestSupportedPHPVersion,
|
|
1328
1338
|
A as PHP,
|
|
1329
1339
|
K as PHPBrowser,
|
|
1330
|
-
|
|
1340
|
+
xe as PHPClient,
|
|
1331
1341
|
ee as PHPRequestHandler,
|
|
1332
1342
|
W as SupportedPHPVersions,
|
|
1333
1343
|
Se as SupportedPHPVersionsList,
|
|
1334
1344
|
ve as consumeAPI,
|
|
1335
|
-
|
|
1336
|
-
|
|
1345
|
+
ke as exposeAPI,
|
|
1346
|
+
we as getPHPLoaderModule,
|
|
1337
1347
|
oe as loadPHPRuntime,
|
|
1338
1348
|
Te as parseWorkerStartupOptions,
|
|
1339
1349
|
Ce as recommendedWorkerBackend,
|
|
1340
|
-
|
|
1350
|
+
_e as registerServiceWorker,
|
|
1341
1351
|
Fe as spawnPHPWorkerThread
|
|
1342
1352
|
};
|
package/index.d.ts
CHANGED
|
@@ -304,11 +304,11 @@ export interface WithNodeFilesystem {
|
|
|
304
304
|
/**
|
|
305
305
|
* Mounts a Node.js filesystem to a given path in the PHP filesystem.
|
|
306
306
|
*
|
|
307
|
-
* @param
|
|
308
|
-
* @param
|
|
307
|
+
* @param localPath - The path of a real local directory you want to mount.
|
|
308
|
+
* @param virtualFSPath - Where to mount it in the virtual filesystem.
|
|
309
309
|
* @see {@link https://emscripten.org/docs/api_reference/Filesystem-API.html#FS.mount}
|
|
310
310
|
*/
|
|
311
|
-
mount(
|
|
311
|
+
mount(localPath: string | MountSettings, virtualFSPath: string): void;
|
|
312
312
|
}
|
|
313
313
|
export interface WithFilesystem {
|
|
314
314
|
/**
|
|
@@ -318,6 +318,10 @@ export interface WithFilesystem {
|
|
|
318
318
|
*
|
|
319
319
|
* @param path - The directory path to create.
|
|
320
320
|
*/
|
|
321
|
+
mkdir(path: string): void;
|
|
322
|
+
/**
|
|
323
|
+
* @deprecated Use mkdir instead.
|
|
324
|
+
*/
|
|
321
325
|
mkdirTree(path: string): void;
|
|
322
326
|
/**
|
|
323
327
|
* Reads a file from the PHP filesystem and returns it as a string.
|
|
@@ -480,6 +484,8 @@ declare abstract class BasePHP implements WithPHPIniBindings, WithFilesystem, Wi
|
|
|
480
484
|
setSkipShebang(shouldSkip: boolean): void;
|
|
481
485
|
addServerGlobalEntry(key: string, value: string): void;
|
|
482
486
|
/** @inheritDoc */
|
|
487
|
+
mkdir(path: string): void;
|
|
488
|
+
/** @inheritDoc */
|
|
483
489
|
mkdirTree(path: string): void;
|
|
484
490
|
/** @inheritDoc */
|
|
485
491
|
readFileAsText(path: string): string;
|
|
@@ -496,7 +502,7 @@ declare abstract class BasePHP implements WithPHPIniBindings, WithFilesystem, Wi
|
|
|
496
502
|
/** @inheritDoc */
|
|
497
503
|
fileExists(path: string): boolean;
|
|
498
504
|
/** @inheritDoc */
|
|
499
|
-
mount(
|
|
505
|
+
mount(localPath: string | MountSettings, virtualFSPath: string): void;
|
|
500
506
|
}
|
|
501
507
|
/**
|
|
502
508
|
* Output of the PHP.wasm runtime.
|
|
@@ -743,6 +749,8 @@ export declare class PHPClient implements Promisify<WithPHPIniBindings & WithFil
|
|
|
743
749
|
setPhpIniPath(path: string): void;
|
|
744
750
|
/** @inheritDoc @php-wasm/web!PHP.setPhpIniEntry */
|
|
745
751
|
setPhpIniEntry(key: string, value: string): void;
|
|
752
|
+
/** @inheritDoc @php-wasm/web!PHP.mkdir */
|
|
753
|
+
mkdir(path: string): void;
|
|
746
754
|
/** @inheritDoc @php-wasm/web!PHP.mkdirTree */
|
|
747
755
|
mkdirTree(path: string): void;
|
|
748
756
|
/** @inheritDoc @php-wasm/web!PHP.readFileAsText */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@php-wasm/web",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
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": "f28412f5d32026c3d3030db0035c867bbf26d73c"
|
|
33
33
|
}
|