@php-wasm/web 0.9.44 → 0.9.46
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.js +222 -178
- package/lib/register-service-worker.d.ts +14 -5
- package/package.json +7 -7
package/index.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { PHPResponse as
|
|
2
|
-
import * as
|
|
3
|
-
import { PhpWasmError as
|
|
4
|
-
import { responseTo as
|
|
5
|
-
import { logger as
|
|
6
|
-
import { journalFSEvents as
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
const e = r instanceof Worker ? r :
|
|
10
|
-
return new Proxy(
|
|
1
|
+
import { PHPResponse as D, LatestSupportedPHPVersion as R, loadPHPRuntime as L, FSHelpers as p, __private__dont__use as P } from "@php-wasm/universal";
|
|
2
|
+
import * as f from "comlink";
|
|
3
|
+
import { PhpWasmError as y, Semaphore as z, joinPaths as T } from "@php-wasm/util";
|
|
4
|
+
import { responseTo as M } from "@php-wasm/web-service-worker";
|
|
5
|
+
import { logger as h } from "@php-wasm/logger";
|
|
6
|
+
import { journalFSEvents as O } from "@php-wasm/fs-journal";
|
|
7
|
+
function Q(r, t = void 0) {
|
|
8
|
+
v();
|
|
9
|
+
const e = r instanceof Worker ? r : f.windowEndpoint(r, t), n = f.wrap(e), a = g(n);
|
|
10
|
+
return new Proxy(a, {
|
|
11
11
|
get: (i, s) => s === "isConnected" ? async () => {
|
|
12
12
|
for (; ; )
|
|
13
13
|
try {
|
|
14
|
-
await
|
|
14
|
+
await A(n.isConnected(), 200);
|
|
15
15
|
break;
|
|
16
16
|
} catch {
|
|
17
17
|
}
|
|
18
|
-
} :
|
|
18
|
+
} : n[s]
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
async function
|
|
22
|
-
return new Promise((e,
|
|
23
|
-
setTimeout(
|
|
21
|
+
async function A(r, t) {
|
|
22
|
+
return new Promise((e, n) => {
|
|
23
|
+
setTimeout(n, t), r.then(e);
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
26
|
+
function X(r, t) {
|
|
27
|
+
v();
|
|
28
28
|
const e = Promise.resolve();
|
|
29
|
-
let
|
|
30
|
-
const i = new Promise((
|
|
31
|
-
|
|
32
|
-
}), s =
|
|
33
|
-
get: (
|
|
29
|
+
let n, a;
|
|
30
|
+
const i = new Promise((c, u) => {
|
|
31
|
+
n = c, a = u;
|
|
32
|
+
}), s = g(r), o = new Proxy(s, {
|
|
33
|
+
get: (c, u) => u === "isConnected" ? () => e : u === "isReady" ? () => i : u in c ? c[u] : t == null ? void 0 : t[u]
|
|
34
34
|
});
|
|
35
|
-
return
|
|
36
|
-
|
|
37
|
-
typeof window < "u" ?
|
|
38
|
-
), [
|
|
35
|
+
return f.expose(
|
|
36
|
+
o,
|
|
37
|
+
typeof window < "u" ? f.windowEndpoint(self.parent) : void 0
|
|
38
|
+
), [n, a, o];
|
|
39
39
|
}
|
|
40
|
-
let
|
|
41
|
-
function
|
|
42
|
-
if (
|
|
40
|
+
let E = !1;
|
|
41
|
+
function v() {
|
|
42
|
+
if (E)
|
|
43
43
|
return;
|
|
44
|
-
|
|
44
|
+
E = !0, f.transferHandlers.set("EVENT", {
|
|
45
45
|
canHandle: (e) => e instanceof CustomEvent,
|
|
46
46
|
serialize: (e) => [
|
|
47
47
|
{
|
|
@@ -50,49 +50,49 @@ function W() {
|
|
|
50
50
|
[]
|
|
51
51
|
],
|
|
52
52
|
deserialize: (e) => e
|
|
53
|
-
}),
|
|
53
|
+
}), f.transferHandlers.set("FUNCTION", {
|
|
54
54
|
canHandle: (e) => typeof e == "function",
|
|
55
55
|
serialize(e) {
|
|
56
|
-
const { port1:
|
|
57
|
-
return
|
|
56
|
+
const { port1: n, port2: a } = new MessageChannel();
|
|
57
|
+
return f.expose(e, n), [a, [a]];
|
|
58
58
|
},
|
|
59
59
|
deserialize(e) {
|
|
60
|
-
return e.start(),
|
|
60
|
+
return e.start(), f.wrap(e);
|
|
61
61
|
}
|
|
62
|
-
}),
|
|
62
|
+
}), f.transferHandlers.set("PHPResponse", {
|
|
63
63
|
canHandle: (e) => typeof e == "object" && e !== null && "headers" in e && "bytes" in e && "errors" in e && "exitCode" in e && "httpStatusCode" in e,
|
|
64
64
|
serialize(e) {
|
|
65
65
|
return [e.toRawData(), []];
|
|
66
66
|
},
|
|
67
67
|
deserialize(e) {
|
|
68
|
-
return
|
|
68
|
+
return D.fromRawData(e);
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
|
-
const r =
|
|
71
|
+
const r = f.transferHandlers.get("throw"), t = r == null ? void 0 : r.serialize;
|
|
72
72
|
r.serialize = ({ value: e }) => {
|
|
73
|
-
const
|
|
74
|
-
return e.response && (
|
|
73
|
+
const n = t({ value: e });
|
|
74
|
+
return e.response && (n[0].value.response = e.response), e.source && (n[0].value.source = e.source), n;
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
|
-
function
|
|
77
|
+
function g(r) {
|
|
78
78
|
return new Proxy(r, {
|
|
79
79
|
get(t, e) {
|
|
80
80
|
switch (typeof t[e]) {
|
|
81
81
|
case "function":
|
|
82
|
-
return (...
|
|
82
|
+
return (...n) => t[e](...n);
|
|
83
83
|
case "object":
|
|
84
|
-
return t[e] === null ? t[e] :
|
|
84
|
+
return t[e] === null ? t[e] : g(t[e]);
|
|
85
85
|
case "undefined":
|
|
86
86
|
case "number":
|
|
87
87
|
case "string":
|
|
88
88
|
return t[e];
|
|
89
89
|
default:
|
|
90
|
-
return
|
|
90
|
+
return f.proxy(t[e]);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
|
-
async function
|
|
95
|
+
async function I(r = R, t = "light") {
|
|
96
96
|
if (t === "kitchen-sink")
|
|
97
97
|
switch (r) {
|
|
98
98
|
case "8.3":
|
|
@@ -137,7 +137,7 @@ async function M(r = R, t = "light") {
|
|
|
137
137
|
}
|
|
138
138
|
throw new Error(`Unsupported PHP version ${r}`);
|
|
139
139
|
}
|
|
140
|
-
const
|
|
140
|
+
const _ = () => ({
|
|
141
141
|
websocket: {
|
|
142
142
|
decorator: (r) => class extends r {
|
|
143
143
|
constructor() {
|
|
@@ -152,168 +152,199 @@ const A = () => ({
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
});
|
|
155
|
-
async function
|
|
156
|
-
var
|
|
157
|
-
const e = t.loadAllExtensions ? "kitchen-sink" : "light",
|
|
158
|
-
return (
|
|
155
|
+
async function Z(r, t = {}) {
|
|
156
|
+
var a;
|
|
157
|
+
const e = t.loadAllExtensions ? "kitchen-sink" : "light", n = await I(r, e);
|
|
158
|
+
return (a = t.onPhpLoaderModuleLoaded) == null || a.call(t, n), await L(n, {
|
|
159
159
|
...t.emscriptenOptions || {},
|
|
160
|
-
...
|
|
160
|
+
..._()
|
|
161
161
|
});
|
|
162
162
|
}
|
|
163
163
|
let b;
|
|
164
|
-
const
|
|
164
|
+
const $ = new Promise((r) => {
|
|
165
165
|
b = r;
|
|
166
166
|
});
|
|
167
|
-
function
|
|
167
|
+
function ee(r) {
|
|
168
168
|
if (!r)
|
|
169
|
-
throw new
|
|
169
|
+
throw new y("PHP API client must be a valid client object.");
|
|
170
170
|
b(r);
|
|
171
171
|
}
|
|
172
|
-
async function
|
|
173
|
-
const
|
|
174
|
-
if (!
|
|
175
|
-
throw window.isSecureContext ? new
|
|
172
|
+
async function te(r) {
|
|
173
|
+
const t = navigator.serviceWorker;
|
|
174
|
+
if (!t)
|
|
175
|
+
throw window.isSecureContext ? new y(
|
|
176
176
|
"Service workers are not supported in your browser."
|
|
177
|
-
) : new
|
|
177
|
+
) : new y(
|
|
178
178
|
"WordPress Playground uses service workers and may only work on HTTPS and http://localhost/ sites, but the current site is neither."
|
|
179
179
|
);
|
|
180
|
-
const
|
|
180
|
+
const e = await t.register(r, {
|
|
181
181
|
type: "module",
|
|
182
182
|
// Always bypass HTTP cache when fetching the new Service Worker script:
|
|
183
183
|
updateViaCache: "none"
|
|
184
184
|
});
|
|
185
185
|
try {
|
|
186
|
-
await
|
|
186
|
+
await e.update();
|
|
187
187
|
} catch (n) {
|
|
188
|
-
|
|
188
|
+
h.error("Failed to update service worker.", n);
|
|
189
189
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
190
|
+
return {
|
|
191
|
+
/**
|
|
192
|
+
* Establishes the communication bridge between the service worker and the web worker
|
|
193
|
+
* where the current site is running.
|
|
194
|
+
*
|
|
195
|
+
* @param scope The string prefix used in the site URL served by the currently
|
|
196
|
+
* running remote.html. E.g. for a prefix like `/scope:playground/`,
|
|
197
|
+
* the scope would be `playground`. See the `@php-wasm/scopes` package
|
|
198
|
+
* for more details.
|
|
199
|
+
*/
|
|
200
|
+
startServiceWorkerCommunicationBridge({ scope: n }) {
|
|
201
|
+
navigator.serviceWorker.addEventListener(
|
|
202
|
+
"message",
|
|
203
|
+
async function(i) {
|
|
204
|
+
if (n && i.data.scope !== n)
|
|
205
|
+
return;
|
|
206
|
+
const s = await $, o = i.data.args || [], c = i.data.method, u = await s[c](...o);
|
|
207
|
+
i.source.postMessage(
|
|
208
|
+
M(i.data.requestId, u)
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
), t.startMessages();
|
|
197
212
|
}
|
|
198
|
-
|
|
213
|
+
};
|
|
199
214
|
}
|
|
200
|
-
function
|
|
215
|
+
function re(r, t) {
|
|
201
216
|
window.addEventListener("message", (e) => {
|
|
202
217
|
e.source === r.contentWindow && (t && e.origin !== t || typeof e.data != "object" || e.data.type !== "relay" || window.parent.postMessage(e.data, "*"));
|
|
203
218
|
}), window.addEventListener("message", (e) => {
|
|
204
|
-
var
|
|
205
|
-
e.source === window.parent && (typeof e.data != "object" || e.data.type !== "relay" || (
|
|
219
|
+
var n;
|
|
220
|
+
e.source === window.parent && (typeof e.data != "object" || e.data.type !== "relay" || (n = r == null ? void 0 : r.contentWindow) == null || n.postMessage(e.data));
|
|
206
221
|
});
|
|
207
222
|
}
|
|
208
|
-
async function
|
|
223
|
+
async function ne(r) {
|
|
209
224
|
const t = new Worker(r, { type: "module" });
|
|
210
|
-
return new Promise((e,
|
|
225
|
+
return new Promise((e, n) => {
|
|
211
226
|
t.onerror = (i) => {
|
|
212
227
|
const s = new Error(
|
|
213
228
|
`WebWorker failed to load at ${r}. ${i.message ? `Original error: ${i.message}` : ""}`
|
|
214
229
|
);
|
|
215
|
-
s.filename = i.filename,
|
|
230
|
+
s.filename = i.filename, n(s);
|
|
216
231
|
};
|
|
217
|
-
function
|
|
218
|
-
i.data === "worker-script-started" && (e(t), t.removeEventListener("message",
|
|
232
|
+
function a(i) {
|
|
233
|
+
i.data === "worker-script-started" && (e(t), t.removeEventListener("message", a));
|
|
219
234
|
}
|
|
220
|
-
t.addEventListener("message",
|
|
235
|
+
t.addEventListener("message", a);
|
|
221
236
|
});
|
|
222
237
|
}
|
|
223
|
-
function
|
|
238
|
+
function ae(r, t = { initialSync: {} }) {
|
|
224
239
|
return t = {
|
|
225
240
|
...t,
|
|
226
241
|
initialSync: {
|
|
227
242
|
...t.initialSync,
|
|
228
243
|
direction: t.initialSync.direction ?? "opfs-to-memfs"
|
|
229
244
|
}
|
|
230
|
-
}, async function(e,
|
|
231
|
-
return t.initialSync.direction === "opfs-to-memfs" ? (
|
|
232
|
-
a,
|
|
233
|
-
r,
|
|
245
|
+
}, async function(e, n, a) {
|
|
246
|
+
return t.initialSync.direction === "opfs-to-memfs" ? (p.fileExists(n, a) && p.rmdir(n, a), p.mkdir(n, a), await q(n, r, a)) : await x(
|
|
234
247
|
n,
|
|
248
|
+
r,
|
|
249
|
+
a,
|
|
235
250
|
t.initialSync.onProgress
|
|
236
|
-
),
|
|
251
|
+
), J(e, r, a);
|
|
237
252
|
};
|
|
238
253
|
}
|
|
239
|
-
async function
|
|
240
|
-
|
|
241
|
-
const
|
|
254
|
+
async function q(r, t, e) {
|
|
255
|
+
p.mkdir(r, e);
|
|
256
|
+
const n = new z({
|
|
242
257
|
concurrency: 40
|
|
243
|
-
}),
|
|
258
|
+
}), a = [], i = [
|
|
244
259
|
[t, e]
|
|
245
260
|
];
|
|
246
261
|
for (; i.length > 0; ) {
|
|
247
|
-
const [s,
|
|
248
|
-
for await (const
|
|
249
|
-
const u =
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
|
|
262
|
+
const [s, o] = i.pop();
|
|
263
|
+
for await (const c of s.values()) {
|
|
264
|
+
const u = n.run(async () => {
|
|
265
|
+
const w = T(
|
|
266
|
+
o,
|
|
267
|
+
c.name
|
|
253
268
|
);
|
|
254
|
-
if (
|
|
269
|
+
if (c.kind === "directory") {
|
|
255
270
|
try {
|
|
256
|
-
r.mkdir(
|
|
257
|
-
} catch (
|
|
258
|
-
if ((
|
|
259
|
-
throw
|
|
271
|
+
r.mkdir(w);
|
|
272
|
+
} catch (l) {
|
|
273
|
+
if ((l == null ? void 0 : l.errno) !== 20)
|
|
274
|
+
throw h.error(l), l;
|
|
260
275
|
}
|
|
261
|
-
i.push([
|
|
262
|
-
} else if (
|
|
263
|
-
const
|
|
276
|
+
i.push([c, w]);
|
|
277
|
+
} else if (c.kind === "file") {
|
|
278
|
+
const l = await c.getFile(), d = new Uint8Array(await l.arrayBuffer());
|
|
264
279
|
r.createDataFile(
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
280
|
+
o,
|
|
281
|
+
c.name,
|
|
282
|
+
d,
|
|
268
283
|
!0,
|
|
269
284
|
!0,
|
|
270
285
|
!0
|
|
271
286
|
);
|
|
272
287
|
}
|
|
273
|
-
|
|
288
|
+
a.splice(a.indexOf(u), 1);
|
|
274
289
|
});
|
|
275
|
-
|
|
290
|
+
a.push(u);
|
|
276
291
|
}
|
|
277
|
-
for (; i.length === 0 &&
|
|
278
|
-
await Promise.any(
|
|
292
|
+
for (; i.length === 0 && a.length > 0; )
|
|
293
|
+
await Promise.any(a);
|
|
279
294
|
}
|
|
280
295
|
}
|
|
281
|
-
async function
|
|
296
|
+
async function x(r, t, e, n) {
|
|
282
297
|
r.mkdirTree(e);
|
|
283
|
-
const
|
|
284
|
-
async function i(
|
|
298
|
+
const a = [];
|
|
299
|
+
async function i(w, l) {
|
|
285
300
|
await Promise.all(
|
|
286
|
-
r.readdir(
|
|
287
|
-
(
|
|
288
|
-
).map(async (
|
|
289
|
-
const
|
|
290
|
-
if (
|
|
291
|
-
|
|
301
|
+
r.readdir(w).filter(
|
|
302
|
+
(d) => d !== "." && d !== ".."
|
|
303
|
+
).map(async (d) => {
|
|
304
|
+
const m = T(w, d);
|
|
305
|
+
if (!F(r, m)) {
|
|
306
|
+
a.push([l, m, d]);
|
|
292
307
|
return;
|
|
293
308
|
}
|
|
294
|
-
const
|
|
309
|
+
const S = await l.getDirectoryHandle(d, {
|
|
295
310
|
create: !0
|
|
296
311
|
});
|
|
297
|
-
return await i(
|
|
312
|
+
return await i(m, S);
|
|
298
313
|
})
|
|
299
314
|
);
|
|
300
315
|
}
|
|
301
316
|
await i(e, t);
|
|
302
317
|
let s = 0;
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
318
|
+
const o = n && B(n, 100), c = 100, u = /* @__PURE__ */ new Set();
|
|
319
|
+
try {
|
|
320
|
+
for (const [w, l, d] of a) {
|
|
321
|
+
const m = C(
|
|
322
|
+
w,
|
|
323
|
+
d,
|
|
324
|
+
r,
|
|
325
|
+
l
|
|
326
|
+
).then(() => {
|
|
327
|
+
s++, u.delete(m), o == null || o({
|
|
328
|
+
files: s,
|
|
329
|
+
total: a.length
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
u.add(m), u.size >= c && (await Promise.race(u), o == null || o({
|
|
333
|
+
files: s,
|
|
334
|
+
total: a.length
|
|
335
|
+
}));
|
|
336
|
+
}
|
|
337
|
+
} finally {
|
|
338
|
+
await Promise.allSettled(u);
|
|
339
|
+
}
|
|
309
340
|
}
|
|
310
|
-
function
|
|
341
|
+
function F(r, t) {
|
|
311
342
|
return r.isDir(r.lookupPath(t, { follow: !0 }).node.mode);
|
|
312
343
|
}
|
|
313
|
-
async function
|
|
314
|
-
let
|
|
344
|
+
async function C(r, t, e, n) {
|
|
345
|
+
let a;
|
|
315
346
|
try {
|
|
316
|
-
|
|
347
|
+
a = e.readFile(n, {
|
|
317
348
|
encoding: "binary"
|
|
318
349
|
});
|
|
319
350
|
} catch {
|
|
@@ -327,31 +358,31 @@ async function x(r, t, e, a) {
|
|
|
327
358
|
await i.createSyncAccessHandle()
|
|
328
359
|
);
|
|
329
360
|
try {
|
|
330
|
-
await s.truncate(0), await s.write(
|
|
361
|
+
await s.truncate(0), await s.write(a);
|
|
331
362
|
} finally {
|
|
332
363
|
await s.close();
|
|
333
364
|
}
|
|
334
365
|
}
|
|
335
|
-
function
|
|
336
|
-
const
|
|
337
|
-
|
|
338
|
-
}), i = new
|
|
366
|
+
function J(r, t, e) {
|
|
367
|
+
const n = [], a = O(r, e, (o) => {
|
|
368
|
+
n.push(o);
|
|
369
|
+
}), i = new j(r, t, e);
|
|
339
370
|
async function s() {
|
|
340
|
-
const
|
|
371
|
+
const o = await r.semaphore.acquire();
|
|
341
372
|
try {
|
|
342
|
-
for (;
|
|
343
|
-
await i.processEntry(
|
|
373
|
+
for (; n.length; )
|
|
374
|
+
await i.processEntry(n.shift());
|
|
344
375
|
} finally {
|
|
345
|
-
|
|
376
|
+
o();
|
|
346
377
|
}
|
|
347
378
|
}
|
|
348
379
|
return r.addEventListener("request.end", s), function() {
|
|
349
|
-
|
|
380
|
+
a(), r.removeEventListener("request.end", s);
|
|
350
381
|
};
|
|
351
382
|
}
|
|
352
|
-
class
|
|
353
|
-
constructor(t, e,
|
|
354
|
-
this.php = t, this.opfs = e, this.memfsRoot = k(
|
|
383
|
+
class j {
|
|
384
|
+
constructor(t, e, n) {
|
|
385
|
+
this.php = t, this.opfs = e, this.memfsRoot = k(n);
|
|
355
386
|
}
|
|
356
387
|
toOpfsPath(t) {
|
|
357
388
|
return k(t.substring(this.memfsRoot.length));
|
|
@@ -359,82 +390,95 @@ class J {
|
|
|
359
390
|
async processEntry(t) {
|
|
360
391
|
if (!t.path.startsWith(this.memfsRoot) || t.path === this.memfsRoot)
|
|
361
392
|
return;
|
|
362
|
-
const e = this.toOpfsPath(t.path),
|
|
363
|
-
if (
|
|
393
|
+
const e = this.toOpfsPath(t.path), n = await W(this.opfs, e), a = H(e);
|
|
394
|
+
if (a)
|
|
364
395
|
try {
|
|
365
396
|
if (t.operation === "DELETE")
|
|
366
397
|
try {
|
|
367
|
-
await
|
|
398
|
+
await n.removeEntry(a, {
|
|
368
399
|
recursive: !0
|
|
369
400
|
});
|
|
370
401
|
} catch {
|
|
371
402
|
}
|
|
372
403
|
else if (t.operation === "CREATE")
|
|
373
|
-
t.nodeType === "directory" ? await
|
|
404
|
+
t.nodeType === "directory" ? await n.getDirectoryHandle(a, {
|
|
374
405
|
create: !0
|
|
375
|
-
}) : await
|
|
406
|
+
}) : await n.getFileHandle(a, {
|
|
376
407
|
create: !0
|
|
377
408
|
});
|
|
378
409
|
else if (t.operation === "WRITE")
|
|
379
|
-
await
|
|
380
|
-
a,
|
|
410
|
+
await C(
|
|
381
411
|
n,
|
|
382
|
-
|
|
412
|
+
a,
|
|
413
|
+
this.php[P].FS,
|
|
383
414
|
t.path
|
|
384
415
|
);
|
|
385
416
|
else if (t.operation === "RENAME" && t.toPath.startsWith(this.memfsRoot)) {
|
|
386
|
-
const i = this.toOpfsPath(t.toPath), s = await
|
|
417
|
+
const i = this.toOpfsPath(t.toPath), s = await W(
|
|
387
418
|
this.opfs,
|
|
388
419
|
i
|
|
389
|
-
),
|
|
420
|
+
), o = H(i);
|
|
390
421
|
if (t.nodeType === "directory") {
|
|
391
|
-
const
|
|
392
|
-
|
|
422
|
+
const c = await s.getDirectoryHandle(
|
|
423
|
+
a,
|
|
393
424
|
{
|
|
394
425
|
create: !0
|
|
395
426
|
}
|
|
396
427
|
);
|
|
397
|
-
await
|
|
398
|
-
this.php[
|
|
399
|
-
|
|
428
|
+
await x(
|
|
429
|
+
this.php[P].FS,
|
|
430
|
+
c,
|
|
400
431
|
t.toPath
|
|
401
|
-
), await
|
|
432
|
+
), await n.removeEntry(a, {
|
|
402
433
|
recursive: !0
|
|
403
434
|
});
|
|
404
435
|
} else
|
|
405
|
-
(await
|
|
436
|
+
(await n.getFileHandle(a)).move(s, o);
|
|
406
437
|
}
|
|
407
438
|
} catch (i) {
|
|
408
|
-
throw
|
|
439
|
+
throw h.log({ entry: t, name: a }), h.error(i), i;
|
|
409
440
|
}
|
|
410
441
|
}
|
|
411
442
|
}
|
|
412
443
|
function k(r) {
|
|
413
444
|
return r.replace(/\/$/, "").replace(/\/\/+/g, "/");
|
|
414
445
|
}
|
|
415
|
-
function
|
|
446
|
+
function H(r) {
|
|
416
447
|
return r.substring(r.lastIndexOf("/") + 1);
|
|
417
448
|
}
|
|
418
|
-
async function
|
|
449
|
+
async function W(r, t) {
|
|
419
450
|
const e = t.replace(/^\/+|\/+$/g, "").replace(/\/+/, "/");
|
|
420
451
|
if (!e)
|
|
421
452
|
return r;
|
|
422
|
-
const
|
|
423
|
-
let
|
|
424
|
-
for (let i = 0; i <
|
|
425
|
-
const s =
|
|
426
|
-
|
|
453
|
+
const n = e.split("/");
|
|
454
|
+
let a = r;
|
|
455
|
+
for (let i = 0; i < n.length - 1; i++) {
|
|
456
|
+
const s = n[i];
|
|
457
|
+
a = await a.getDirectoryHandle(s, { create: !0 });
|
|
427
458
|
}
|
|
428
|
-
return
|
|
459
|
+
return a;
|
|
460
|
+
}
|
|
461
|
+
function B(r, t) {
|
|
462
|
+
let e = 0, n, a;
|
|
463
|
+
return function(...s) {
|
|
464
|
+
a = s;
|
|
465
|
+
const o = Date.now() - e;
|
|
466
|
+
if (n === void 0) {
|
|
467
|
+
const c = Math.max(0, t - o);
|
|
468
|
+
n = setTimeout(() => {
|
|
469
|
+
n = void 0, e = Date.now(), r(...a);
|
|
470
|
+
}, c);
|
|
471
|
+
}
|
|
472
|
+
};
|
|
429
473
|
}
|
|
430
474
|
export {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
475
|
+
Q as consumeAPI,
|
|
476
|
+
ae as createDirectoryHandleMountHandler,
|
|
477
|
+
X as exposeAPI,
|
|
478
|
+
I as getPHPLoaderModule,
|
|
479
|
+
Z as loadWebRuntime,
|
|
480
|
+
te as registerServiceWorker,
|
|
481
|
+
ee as setPhpInstanceUsedByServiceWorker,
|
|
482
|
+
re as setupPostMessageRelay,
|
|
483
|
+
ne as spawnPHPWorkerThread
|
|
440
484
|
};
|
|
@@ -15,10 +15,19 @@ export declare function setPhpInstanceUsedByServiceWorker(api: Client): void;
|
|
|
15
15
|
* reload the registered worker if the app expects a different version
|
|
16
16
|
* than the currently registered one.
|
|
17
17
|
*
|
|
18
|
-
* @param scope The numeric value used in the path prefix of the site
|
|
19
|
-
* this service worker is meant to serve. E.g. for a prefix
|
|
20
|
-
* like `/scope:793/`, the scope would be `793`. See the
|
|
21
|
-
* `@php-wasm/scopes` package for more details.
|
|
22
18
|
* @param scriptUrl The URL of the service worker script.
|
|
23
19
|
*/
|
|
24
|
-
export declare function registerServiceWorker(
|
|
20
|
+
export declare function registerServiceWorker(scriptUrl: string): Promise<{
|
|
21
|
+
/**
|
|
22
|
+
* Establishes the communication bridge between the service worker and the web worker
|
|
23
|
+
* where the current site is running.
|
|
24
|
+
*
|
|
25
|
+
* @param scope The string prefix used in the site URL served by the currently
|
|
26
|
+
* running remote.html. E.g. for a prefix like `/scope:playground/`,
|
|
27
|
+
* the scope would be `playground`. See the `@php-wasm/scopes` package
|
|
28
|
+
* for more details.
|
|
29
|
+
*/
|
|
30
|
+
startServiceWorkerCommunicationBridge({ scope }: {
|
|
31
|
+
scope: string;
|
|
32
|
+
}): void;
|
|
33
|
+
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@php-wasm/web",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.46",
|
|
4
4
|
"description": "PHP.wasm for the web",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"type": "module",
|
|
30
30
|
"main": "index.js",
|
|
31
31
|
"types": "index.d.ts",
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "fa393bcf69536e421246aa8e321e3e9af4b61c7b",
|
|
33
33
|
"engines": {
|
|
34
34
|
"node": ">=16.15.1",
|
|
35
35
|
"npm": ">=8.11.0"
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"ini": "4.1.2",
|
|
41
41
|
"ws": "8.18.0",
|
|
42
42
|
"yargs": "17.7.2",
|
|
43
|
-
"@php-wasm/universal": "0.9.
|
|
44
|
-
"@php-wasm/util": "0.9.
|
|
45
|
-
"@php-wasm/logger": "0.9.
|
|
46
|
-
"@php-wasm/fs-journal": "0.9.
|
|
47
|
-
"@php-wasm/web-service-worker": "0.9.
|
|
43
|
+
"@php-wasm/universal": "0.9.46",
|
|
44
|
+
"@php-wasm/util": "0.9.46",
|
|
45
|
+
"@php-wasm/logger": "0.9.46",
|
|
46
|
+
"@php-wasm/fs-journal": "0.9.46",
|
|
47
|
+
"@php-wasm/web-service-worker": "0.9.46"
|
|
48
48
|
}
|
|
49
49
|
}
|