@php-wasm/web 0.1.32 → 0.1.34
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-a3b4b54b.js → index-5569499f.js} +88 -87
- package/index.d.ts +11 -8
- 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 = "", l = 0) {
|
|
3
|
+
this.httpStatusCode = e, this.headers = r, this.bytes = n, this.exitCode = l, this.errors = s;
|
|
4
4
|
}
|
|
5
5
|
static fromRawData(e) {
|
|
6
6
|
return new R(
|
|
@@ -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), l = r.substring(n + 1).split(";")[0];
|
|
121
|
+
this.#e[s] = l;
|
|
122
122
|
} catch (n) {
|
|
123
123
|
console.error(n);
|
|
124
124
|
}
|
|
@@ -184,9 +184,9 @@ class re {
|
|
|
184
184
|
const {
|
|
185
185
|
documentRoot: n = "/www/",
|
|
186
186
|
absoluteUrl: s = typeof location == "object" ? location?.href : "",
|
|
187
|
-
isStaticFilePath:
|
|
187
|
+
isStaticFilePath: l = () => !1
|
|
188
188
|
} = r;
|
|
189
|
-
this.php = e, this.#e = n, this.#l =
|
|
189
|
+
this.php = e, this.#e = n, this.#l = l;
|
|
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;
|
|
@@ -274,27 +274,27 @@ class re {
|
|
|
274
274
|
this.#o.startsWith("https://") ? "on" : ""
|
|
275
275
|
);
|
|
276
276
|
let s = "GET";
|
|
277
|
-
const
|
|
277
|
+
const l = {
|
|
278
278
|
host: this.#i,
|
|
279
279
|
...W(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 a in e.files) {
|
|
284
|
+
const u = e.files[a];
|
|
285
285
|
i.push({
|
|
286
|
-
key:
|
|
286
|
+
key: a,
|
|
287
287
|
name: u.name,
|
|
288
288
|
type: u.type,
|
|
289
289
|
data: new Uint8Array(await u.arrayBuffer())
|
|
290
290
|
});
|
|
291
291
|
}
|
|
292
|
-
|
|
292
|
+
l["content-type"]?.startsWith("multipart/form-data") && (e.formData = ne(
|
|
293
293
|
e.body || ""
|
|
294
|
-
),
|
|
294
|
+
), l["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", l["content-type"] = l["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
300
|
relativeUri: te(
|
|
@@ -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: l
|
|
310
310
|
});
|
|
311
311
|
} finally {
|
|
312
312
|
n();
|
|
@@ -332,13 +332,13 @@ function ne(t) {
|
|
|
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((l) => {
|
|
336
|
+
const i = l.indexOf(`\r
|
|
337
337
|
\r
|
|
338
|
-
`), o =
|
|
338
|
+
`), o = l.substring(0, i).trim(), a = l.substring(i + 4).trim(), u = o.match(/name="([^"]+)"/);
|
|
339
339
|
if (u) {
|
|
340
340
|
const d = u[1];
|
|
341
|
-
e[d] =
|
|
341
|
+
e[d] = a;
|
|
342
342
|
}
|
|
343
343
|
}), e;
|
|
344
344
|
}
|
|
@@ -463,14 +463,14 @@ const N = {
|
|
|
463
463
|
};
|
|
464
464
|
function y(t = "") {
|
|
465
465
|
return function(r, n, s) {
|
|
466
|
-
const
|
|
466
|
+
const l = s.value;
|
|
467
467
|
s.value = function(...i) {
|
|
468
468
|
try {
|
|
469
|
-
return
|
|
469
|
+
return l.apply(this, i);
|
|
470
470
|
} catch (o) {
|
|
471
|
-
const
|
|
472
|
-
if (
|
|
473
|
-
const u = N[
|
|
471
|
+
const a = typeof o == "object" ? o?.errno : null;
|
|
472
|
+
if (a in N) {
|
|
473
|
+
const u = N[a], 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
|
});
|
|
@@ -482,31 +482,31 @@ function y(t = "") {
|
|
|
482
482
|
}
|
|
483
483
|
async function ie(t, e = {}, r = []) {
|
|
484
484
|
let n, s;
|
|
485
|
-
const
|
|
486
|
-
s =
|
|
487
|
-
}), i = new Promise((
|
|
488
|
-
n =
|
|
485
|
+
const l = new Promise((a) => {
|
|
486
|
+
s = a;
|
|
487
|
+
}), i = new Promise((a) => {
|
|
488
|
+
n = a;
|
|
489
489
|
}), o = t.init(ae, {
|
|
490
|
-
onAbort(
|
|
491
|
-
console.error("WASM aborted: "), console.error(
|
|
490
|
+
onAbort(a) {
|
|
491
|
+
console.error("WASM aborted: "), console.error(a);
|
|
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: (a) => a,
|
|
498
498
|
...e,
|
|
499
499
|
noInitialRun: !0,
|
|
500
500
|
onRuntimeInitialized() {
|
|
501
501
|
e.onRuntimeInitialized && e.onRuntimeInitialized(), n();
|
|
502
502
|
},
|
|
503
|
-
monitorRunDependencies(
|
|
504
|
-
|
|
503
|
+
monitorRunDependencies(a) {
|
|
504
|
+
a === 0 && (delete o.monitorRunDependencies, s());
|
|
505
505
|
}
|
|
506
506
|
});
|
|
507
|
-
for (const { default:
|
|
508
|
-
|
|
509
|
-
return r.length || s(), await
|
|
507
|
+
for (const { default: a } of r)
|
|
508
|
+
a(o);
|
|
509
|
+
return r.length || s(), await l, await i, O.push(o), O.length - 1;
|
|
510
510
|
}
|
|
511
511
|
const O = [];
|
|
512
512
|
function oe(t) {
|
|
@@ -516,8 +516,8 @@ const ae = function() {
|
|
|
516
516
|
return typeof window < "u" && !{}.TEST ? "WEB" : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? "WORKER" : "NODE";
|
|
517
517
|
}();
|
|
518
518
|
var le = Object.defineProperty, ce = Object.getOwnPropertyDescriptor, w = (t, e, r, n) => {
|
|
519
|
-
for (var s = n > 1 ? void 0 : n ? ce(e, r) : e,
|
|
520
|
-
(i = t[
|
|
519
|
+
for (var s = n > 1 ? void 0 : n ? ce(e, r) : e, l = t.length - 1, i; l >= 0; l--)
|
|
520
|
+
(i = t[l]) && (s = (n ? i(e, r, s) : i(s)) || s);
|
|
521
521
|
return n && s && le(e, r, s), s;
|
|
522
522
|
};
|
|
523
523
|
const f = "string", b = "number", c = Symbol("__private__dont__use");
|
|
@@ -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 l = s.indexOf(": "), i = s.substring(0, l).toLowerCase(), o = s.substring(l + 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: l } = e, i = `/tmp/${Math.random().toFixed(20)}`;
|
|
743
|
+
this.writeFile(i, l);
|
|
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, l.byteLength]
|
|
750
750
|
);
|
|
751
751
|
}
|
|
752
752
|
#d(e) {
|
|
@@ -910,7 +910,7 @@ function F(t, e = globalThis, r = ["*"]) {
|
|
|
910
910
|
console.warn(`Invalid origin '${s.origin}' for comlink proxy`);
|
|
911
911
|
return;
|
|
912
912
|
}
|
|
913
|
-
const { id:
|
|
913
|
+
const { id: l, type: i, path: o } = Object.assign({ path: [] }, s.data), a = (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,11 +922,11 @@ 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, a);
|
|
926
926
|
break;
|
|
927
927
|
case "CONSTRUCT":
|
|
928
928
|
{
|
|
929
|
-
const p = new g(...
|
|
929
|
+
const p = new g(...a);
|
|
930
930
|
u = G(p);
|
|
931
931
|
}
|
|
932
932
|
break;
|
|
@@ -947,13 +947,13 @@ 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: l }), p), i === "RELEASE" && (e.removeEventListener("message", n), $(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: l }), p);
|
|
957
957
|
});
|
|
958
958
|
}), e.start && e.start();
|
|
959
959
|
}
|
|
@@ -992,7 +992,7 @@ function U(t, e = [], r = function() {
|
|
|
992
992
|
}) {
|
|
993
993
|
let n = !1;
|
|
994
994
|
const s = new Proxy(r, {
|
|
995
|
-
get(
|
|
995
|
+
get(l, i) {
|
|
996
996
|
if (_(n), i === de)
|
|
997
997
|
return () => {
|
|
998
998
|
ye(s), j(t), n = !0;
|
|
@@ -1002,29 +1002,29 @@ function U(t, e = [], r = function() {
|
|
|
1002
1002
|
return { then: () => s };
|
|
1003
1003
|
const o = E(t, {
|
|
1004
1004
|
type: "GET",
|
|
1005
|
-
path: e.map((
|
|
1005
|
+
path: e.map((a) => a.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(l, i, o) {
|
|
1012
1012
|
_(n);
|
|
1013
|
-
const [
|
|
1013
|
+
const [a, 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: a
|
|
1018
1018
|
}, u).then(P);
|
|
1019
1019
|
},
|
|
1020
|
-
apply(
|
|
1020
|
+
apply(l, i, o) {
|
|
1021
1021
|
_(n);
|
|
1022
|
-
const
|
|
1023
|
-
if (
|
|
1022
|
+
const a = e[e.length - 1];
|
|
1023
|
+
if (a === ue)
|
|
1024
1024
|
return E(t, {
|
|
1025
1025
|
type: "ENDPOINT"
|
|
1026
1026
|
}).then(P);
|
|
1027
|
-
if (
|
|
1027
|
+
if (a === "bind")
|
|
1028
1028
|
return U(t, e.slice(0, -1));
|
|
1029
1029
|
const [u, d] = D(o);
|
|
1030
1030
|
return E(t, {
|
|
@@ -1033,14 +1033,14 @@ function U(t, e = [], r = function() {
|
|
|
1033
1033
|
argumentList: u
|
|
1034
1034
|
}, d).then(P);
|
|
1035
1035
|
},
|
|
1036
|
-
construct(
|
|
1036
|
+
construct(l, i) {
|
|
1037
1037
|
_(n);
|
|
1038
|
-
const [o,
|
|
1038
|
+
const [o, a] = D(i);
|
|
1039
1039
|
return E(t, {
|
|
1040
1040
|
type: "CONSTRUCT",
|
|
1041
1041
|
path: e.map((u) => u.toString()),
|
|
1042
1042
|
argumentList: o
|
|
1043
|
-
},
|
|
1043
|
+
}, a).then(P);
|
|
1044
1044
|
}
|
|
1045
1045
|
});
|
|
1046
1046
|
return ge(s, t), s;
|
|
@@ -1098,8 +1098,8 @@ function P(t) {
|
|
|
1098
1098
|
function E(t, e, r) {
|
|
1099
1099
|
return new Promise((n) => {
|
|
1100
1100
|
const s = be();
|
|
1101
|
-
t.addEventListener("message", function
|
|
1102
|
-
!i.data || !i.data.id || i.data.id !== s || (t.removeEventListener("message",
|
|
1101
|
+
t.addEventListener("message", function l(i) {
|
|
1102
|
+
!i.data || !i.data.id || i.data.id !== s || (t.removeEventListener("message", l), n(i.data));
|
|
1103
1103
|
}), t.start && t.start(), t.postMessage(Object.assign({ id: s }, e), r);
|
|
1104
1104
|
});
|
|
1105
1105
|
}
|
|
@@ -1113,16 +1113,17 @@ function ke(t) {
|
|
|
1113
1113
|
}
|
|
1114
1114
|
function xe(t, e) {
|
|
1115
1115
|
J();
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1116
|
+
const r = Promise.resolve();
|
|
1117
|
+
let n;
|
|
1118
|
+
const s = new Promise((o) => {
|
|
1119
|
+
n = o;
|
|
1120
|
+
}), l = Y(t), i = new Proxy(l, {
|
|
1121
|
+
get: (o, a) => a === "isConnected" ? () => r : a === "isReady" ? () => s : a in o ? o[a] : e?.[a]
|
|
1121
1122
|
});
|
|
1122
1123
|
return F(
|
|
1123
|
-
|
|
1124
|
+
i,
|
|
1124
1125
|
typeof window < "u" ? V(self.parent) : void 0
|
|
1125
|
-
), [
|
|
1126
|
+
), [n, i];
|
|
1126
1127
|
}
|
|
1127
1128
|
function J() {
|
|
1128
1129
|
S.set("EVENT", {
|
|
@@ -1219,11 +1220,11 @@ class A extends m {
|
|
|
1219
1220
|
* @see load
|
|
1220
1221
|
*/
|
|
1221
1222
|
static loadSync(e, r = {}) {
|
|
1222
|
-
const n = new A(void 0, r.requestHandler),
|
|
1223
|
+
const n = new A(void 0, r.requestHandler), l = (async () => {
|
|
1223
1224
|
const i = await Promise.all([
|
|
1224
1225
|
Ee(e),
|
|
1225
1226
|
...r.dataModules || []
|
|
1226
|
-
]), [o, ...
|
|
1227
|
+
]), [o, ...a] = i;
|
|
1227
1228
|
r.downloadMonitor?.setModules(i);
|
|
1228
1229
|
const u = await ie(
|
|
1229
1230
|
o,
|
|
@@ -1231,14 +1232,14 @@ class A extends m {
|
|
|
1231
1232
|
...r.emscriptenOptions || {},
|
|
1232
1233
|
...r.downloadMonitor?.getEmscriptenOptions() || {}
|
|
1233
1234
|
},
|
|
1234
|
-
|
|
1235
|
+
a
|
|
1235
1236
|
);
|
|
1236
|
-
return n.initializeRuntime(u), { dataModules:
|
|
1237
|
+
return n.initializeRuntime(u), { dataModules: a };
|
|
1237
1238
|
})();
|
|
1238
1239
|
return {
|
|
1239
1240
|
php: n,
|
|
1240
|
-
phpReady:
|
|
1241
|
-
dataModules:
|
|
1241
|
+
phpReady: l.then(() => n),
|
|
1242
|
+
dataModules: l.then((i) => i.dataModules)
|
|
1242
1243
|
};
|
|
1243
1244
|
}
|
|
1244
1245
|
}
|
|
@@ -1246,7 +1247,7 @@ const h = /* @__PURE__ */ new WeakMap();
|
|
|
1246
1247
|
class Te {
|
|
1247
1248
|
/** @inheritDoc */
|
|
1248
1249
|
constructor(e, r) {
|
|
1249
|
-
|
|
1250
|
+
h.set(this, {
|
|
1250
1251
|
php: e,
|
|
1251
1252
|
monitor: r
|
|
1252
1253
|
}), this.absoluteUrl = e.absoluteUrl, this.documentRoot = e.documentRoot;
|
|
@@ -1260,7 +1261,7 @@ class Te {
|
|
|
1260
1261
|
return h.get(this).php.internalUrlToPath(e);
|
|
1261
1262
|
}
|
|
1262
1263
|
async onDownloadProgress(e) {
|
|
1263
|
-
h.get(this).monitor?.addEventListener("progress", e);
|
|
1264
|
+
return h.get(this).monitor?.addEventListener("progress", e);
|
|
1264
1265
|
}
|
|
1265
1266
|
/** @inheritDoc */
|
|
1266
1267
|
mv(e, r) {
|
|
@@ -1288,15 +1289,15 @@ class Te {
|
|
|
1288
1289
|
}
|
|
1289
1290
|
/** @inheritDoc @php-wasm/web!WebPHP.setPhpIniEntry */
|
|
1290
1291
|
setPhpIniEntry(e, r) {
|
|
1291
|
-
h.get(this).php.setPhpIniEntry(e, r);
|
|
1292
|
+
return h.get(this).php.setPhpIniEntry(e, r);
|
|
1292
1293
|
}
|
|
1293
1294
|
/** @inheritDoc @php-wasm/web!WebPHP.mkdir */
|
|
1294
1295
|
mkdir(e) {
|
|
1295
|
-
h.get(this).php.mkdir(e);
|
|
1296
|
+
return h.get(this).php.mkdir(e);
|
|
1296
1297
|
}
|
|
1297
1298
|
/** @inheritDoc @php-wasm/web!WebPHP.mkdirTree */
|
|
1298
1299
|
mkdirTree(e) {
|
|
1299
|
-
h.get(this).php.mkdirTree(e);
|
|
1300
|
+
return h.get(this).php.mkdirTree(e);
|
|
1300
1301
|
}
|
|
1301
1302
|
/** @inheritDoc @php-wasm/web!WebPHP.readFileAsText */
|
|
1302
1303
|
readFileAsText(e) {
|
|
@@ -1308,11 +1309,11 @@ class Te {
|
|
|
1308
1309
|
}
|
|
1309
1310
|
/** @inheritDoc @php-wasm/web!WebPHP.writeFile */
|
|
1310
1311
|
writeFile(e, r) {
|
|
1311
|
-
h.get(this).php.writeFile(e, r);
|
|
1312
|
+
return h.get(this).php.writeFile(e, r);
|
|
1312
1313
|
}
|
|
1313
1314
|
/** @inheritDoc @php-wasm/web!WebPHP.unlink */
|
|
1314
1315
|
unlink(e) {
|
|
1315
|
-
h.get(this).php.unlink(e);
|
|
1316
|
+
return h.get(this).php.unlink(e);
|
|
1316
1317
|
}
|
|
1317
1318
|
/** @inheritDoc @php-wasm/web!WebPHP.listFiles */
|
|
1318
1319
|
listFiles(e) {
|
|
@@ -1338,22 +1339,22 @@ async function Ce(t, e, r, n) {
|
|
|
1338
1339
|
const s = navigator.serviceWorker;
|
|
1339
1340
|
if (!s)
|
|
1340
1341
|
throw new Error("Service workers are not supported in this browser.");
|
|
1341
|
-
const
|
|
1342
|
-
if (
|
|
1342
|
+
const l = await s.getRegistrations();
|
|
1343
|
+
if (l.length > 0) {
|
|
1343
1344
|
const i = await ve();
|
|
1344
1345
|
if (n !== i) {
|
|
1345
1346
|
console.debug(
|
|
1346
1347
|
`[window] Reloading the currently registered Service Worker (expected version: ${n}, registered version: ${i})`
|
|
1347
1348
|
);
|
|
1348
|
-
for (const o of
|
|
1349
|
-
let
|
|
1349
|
+
for (const o of l) {
|
|
1350
|
+
let a = !1;
|
|
1350
1351
|
try {
|
|
1351
1352
|
await o.update();
|
|
1352
1353
|
} catch {
|
|
1353
|
-
|
|
1354
|
+
a = !0;
|
|
1354
1355
|
}
|
|
1355
1356
|
const u = o.waiting || o.installing;
|
|
1356
|
-
u && !
|
|
1357
|
+
u && !a && (i !== null ? u.postMessage("skip-waiting") : a = !0), a && (await o.unregister(), window.location.reload());
|
|
1357
1358
|
}
|
|
1358
1359
|
}
|
|
1359
1360
|
} else
|
|
@@ -1367,7 +1368,7 @@ async function Ce(t, e, r, n) {
|
|
|
1367
1368
|
async function(o) {
|
|
1368
1369
|
if (console.debug("Message from ServiceWorker", o), e && o.data.scope !== e)
|
|
1369
1370
|
return;
|
|
1370
|
-
const
|
|
1371
|
+
const a = o.data.args || [], u = o.data.method, d = await t[u](...a);
|
|
1371
1372
|
o.source.postMessage(Re(o.data.requestId, d));
|
|
1372
1373
|
}
|
|
1373
1374
|
), s.startMessages();
|
package/index.d.ts
CHANGED
|
@@ -3,11 +3,19 @@
|
|
|
3
3
|
import * as Comlink from 'comlink';
|
|
4
4
|
import { Remote } from 'comlink';
|
|
5
5
|
|
|
6
|
-
export type
|
|
7
|
-
/**
|
|
6
|
+
export type WithAPIState = {
|
|
7
|
+
/**
|
|
8
|
+
* Resolves to true when the remote API is ready for
|
|
9
|
+
* Comlink communication, but not necessarily fully initialized yet.
|
|
10
|
+
*/
|
|
11
|
+
isConnected: () => Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Resolves to true when the remote API is declares it's
|
|
14
|
+
* fully loaded and ready to be used.
|
|
15
|
+
*/
|
|
8
16
|
isReady: () => Promise<void>;
|
|
9
17
|
};
|
|
10
|
-
export type RemoteAPI<T> = Comlink.Remote<T &
|
|
18
|
+
export type RemoteAPI<T> = Comlink.Remote<T & WithAPIState>;
|
|
11
19
|
export declare function consumeAPI<APIType>(remote: Worker | Window): RemoteAPI<APIType>;
|
|
12
20
|
export type PublicAPI<Methods, PipedAPI = unknown> = RemoteAPI<Methods & PipedAPI>;
|
|
13
21
|
export declare function exposeAPI<Methods, PipedAPI>(apiMethods?: Methods, pipedApi?: PipedAPI): [
|
|
@@ -576,11 +584,6 @@ export declare class WebPHP extends BasePHP {
|
|
|
576
584
|
* A PHP client that can be used to run PHP code in the browser.
|
|
577
585
|
*/
|
|
578
586
|
export declare class WebPHPEndpoint implements IsomorphicLocalPHP {
|
|
579
|
-
/**
|
|
580
|
-
* A dummy promise that resolves immediately.
|
|
581
|
-
* Used to assert that the PHPClient is ready for communication.
|
|
582
|
-
*/
|
|
583
|
-
connected: Promise<void>;
|
|
584
587
|
/** @inheritDoc */
|
|
585
588
|
absoluteUrl: string;
|
|
586
589
|
/** @inheritDoc */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@php-wasm/web",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.34",
|
|
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": "8c0a6a74f00bbf4bead78d49845dcdd79b02edd6"
|
|
33
33
|
}
|