@wp-playground/client 0.1.39 → 0.1.40
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/blueprint-schema.json +30 -0
- package/index.cjs +23 -23
- package/index.d.ts +12 -1
- package/index.js +290 -275
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
function x(t) {
|
|
2
2
|
return new DOMParser().parseFromString(t.text, "text/html");
|
|
3
3
|
}
|
|
4
|
-
function
|
|
4
|
+
function L(t) {
|
|
5
5
|
const e = t.split(".").shift().replace("-", " ");
|
|
6
6
|
return e.charAt(0).toUpperCase() + e.slice(1).toLowerCase();
|
|
7
7
|
}
|
|
8
|
-
async function
|
|
9
|
-
|
|
8
|
+
async function E(t, e, r) {
|
|
9
|
+
let s = "";
|
|
10
|
+
await t.fileExists(e) && (s = await t.readFileAsText(e)), await t.writeFile(e, r(s));
|
|
10
11
|
}
|
|
11
|
-
async function
|
|
12
|
+
async function Ce(t) {
|
|
12
13
|
return new Uint8Array(await t.arrayBuffer());
|
|
13
14
|
}
|
|
14
|
-
const
|
|
15
|
+
const ke = async (t, { plugin: e }, r) => {
|
|
15
16
|
r?.tracker.setCaption(`Activating ${e}`);
|
|
16
17
|
const i = x(
|
|
17
18
|
await t.request({
|
|
@@ -23,20 +24,20 @@ const Ce = async (t, { plugin: e }, r) => {
|
|
|
23
24
|
await t.request({
|
|
24
25
|
url: "/wp-admin/" + i
|
|
25
26
|
});
|
|
26
|
-
},
|
|
27
|
-
const r = new
|
|
27
|
+
}, Fe = async (t, e) => {
|
|
28
|
+
const r = new Oe(
|
|
28
29
|
t,
|
|
29
30
|
e.siteUrl,
|
|
30
31
|
e.wordpressPath || "/wordpress"
|
|
31
32
|
);
|
|
32
33
|
e.patchSqlitePlugin !== !1 && await r.patchSqlitePlugin(), e.addPhpInfo !== !1 && await r.addPhpInfo(), e.patchSiteUrl !== !1 && await r.patchSiteUrl(), e.disableSiteHealth !== !1 && await r.disableSiteHealth(), e.disableWpNewBlogNotification !== !1 && await r.disableWpNewBlogNotification();
|
|
33
34
|
};
|
|
34
|
-
class
|
|
35
|
+
class Oe {
|
|
35
36
|
constructor(e, r, s) {
|
|
36
37
|
this.php = e, this.scopedSiteUrl = r, this.wordpressPath = s;
|
|
37
38
|
}
|
|
38
39
|
async patchSqlitePlugin() {
|
|
39
|
-
await
|
|
40
|
+
await E(
|
|
40
41
|
this.php,
|
|
41
42
|
`${this.wordpressPath}/wp-content/plugins/sqlite-database-integration/wp-includes/sqlite/class-wp-sqlite-translator.php`,
|
|
42
43
|
(e) => e.replace(
|
|
@@ -52,7 +53,7 @@ class Fe {
|
|
|
52
53
|
);
|
|
53
54
|
}
|
|
54
55
|
async patchSiteUrl() {
|
|
55
|
-
await
|
|
56
|
+
await E(
|
|
56
57
|
this.php,
|
|
57
58
|
`${this.wordpressPath}/wp-config.php`,
|
|
58
59
|
(e) => `<?php
|
|
@@ -64,7 +65,7 @@ class Fe {
|
|
|
64
65
|
);
|
|
65
66
|
}
|
|
66
67
|
async disableSiteHealth() {
|
|
67
|
-
await
|
|
68
|
+
await E(
|
|
68
69
|
this.php,
|
|
69
70
|
`${this.wordpressPath}/wp-includes/default-filters.php`,
|
|
70
71
|
(e) => e.replace(
|
|
@@ -74,7 +75,7 @@ class Fe {
|
|
|
74
75
|
);
|
|
75
76
|
}
|
|
76
77
|
async disableWpNewBlogNotification() {
|
|
77
|
-
await
|
|
78
|
+
await E(
|
|
78
79
|
this.php,
|
|
79
80
|
`${this.wordpressPath}/wp-config.php`,
|
|
80
81
|
// The original version of this function crashes WASM PHP, let's define an empty one instead.
|
|
@@ -82,39 +83,51 @@ class Fe {
|
|
|
82
83
|
);
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
|
-
const
|
|
86
|
+
const Ae = async (t, { code: e }) => await t.run({ code: e }), Le = async (t, { options: e }) => await t.run(e), Ue = async (t, { key: e, value: r }) => {
|
|
86
87
|
await t.setPhpIniEntry(e, r);
|
|
87
|
-
},
|
|
88
|
+
}, He = async (t, { request: e }) => await t.request(e), Ie = async (t, { fromPath: e, toPath: r }) => {
|
|
88
89
|
await t.writeFile(
|
|
89
90
|
r,
|
|
90
91
|
await t.readFileAsBuffer(e)
|
|
91
92
|
);
|
|
92
|
-
},
|
|
93
|
+
}, Ne = async (t, { fromPath: e, toPath: r }) => {
|
|
93
94
|
await t.mv(e, r);
|
|
94
95
|
}, Me = async (t, { path: e }) => {
|
|
95
96
|
await t.mkdir(e);
|
|
96
|
-
}, Ne = async (t, { path: e }) => {
|
|
97
|
-
await t.unlink(e);
|
|
98
97
|
}, We = async (t, { path: e }) => {
|
|
98
|
+
await t.unlink(e);
|
|
99
|
+
}, De = async (t, { path: e }) => {
|
|
99
100
|
await t.rmdir(e);
|
|
100
|
-
},
|
|
101
|
-
r instanceof File && (r = await
|
|
102
|
-
},
|
|
101
|
+
}, ze = async (t, { path: e, data: r }) => {
|
|
102
|
+
r instanceof File && (r = await Ce(r)), await t.writeFile(e, r);
|
|
103
|
+
}, he = async (t, { consts: e }) => {
|
|
103
104
|
const r = await t.documentRoot;
|
|
104
|
-
await
|
|
105
|
+
await E(
|
|
106
|
+
t,
|
|
107
|
+
`${r}/playground-consts.json`,
|
|
108
|
+
(s) => JSON.stringify({
|
|
109
|
+
...JSON.parse(s || "{}"),
|
|
110
|
+
...e
|
|
111
|
+
})
|
|
112
|
+
), await E(
|
|
105
113
|
t,
|
|
106
114
|
`${r}/wp-config.php`,
|
|
107
|
-
(s) => `<?php
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
+
(s) => s.includes("playground-consts.json") ? s : `<?php
|
|
116
|
+
$consts = json_decode(file_get_contents('./playground-consts.json'), true);
|
|
117
|
+
foreach ($consts as $const => $value) {
|
|
118
|
+
if (!defined($const)) {
|
|
119
|
+
define($const, $value);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
?>${s}`
|
|
115
123
|
);
|
|
116
|
-
}
|
|
117
|
-
|
|
124
|
+
}, qe = async (t, { siteUrl: e }) => await he(t, {
|
|
125
|
+
consts: {
|
|
126
|
+
WP_HOME: e,
|
|
127
|
+
WP_SITEURL: e
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
class de {
|
|
118
131
|
constructor({ concurrency: e }) {
|
|
119
132
|
this._running = 0, this.concurrency = e, this.queue = [];
|
|
120
133
|
}
|
|
@@ -139,18 +152,18 @@ class he {
|
|
|
139
152
|
}
|
|
140
153
|
}
|
|
141
154
|
}
|
|
142
|
-
const
|
|
143
|
-
function
|
|
155
|
+
const je = Symbol("literal");
|
|
156
|
+
function v(t) {
|
|
144
157
|
if (typeof t == "string")
|
|
145
158
|
return t.startsWith("$") ? t : JSON.stringify(t);
|
|
146
159
|
if (typeof t == "number")
|
|
147
160
|
return t.toString();
|
|
148
161
|
if (Array.isArray(t))
|
|
149
|
-
return `array(${t.map(
|
|
162
|
+
return `array(${t.map(v).join(", ")})`;
|
|
150
163
|
if (t === null)
|
|
151
164
|
return "null";
|
|
152
165
|
if (typeof t == "object")
|
|
153
|
-
return
|
|
166
|
+
return je in t ? t.toString() : `array(${Object.entries(t).map(([r, s]) => `${JSON.stringify(r)} => ${v(s)}`).join(", ")})`;
|
|
154
167
|
if (typeof t == "function")
|
|
155
168
|
return t();
|
|
156
169
|
throw new Error(`Unsupported value: ${t}`);
|
|
@@ -158,7 +171,7 @@ function $(t) {
|
|
|
158
171
|
function W(t) {
|
|
159
172
|
const e = {};
|
|
160
173
|
for (const r in t)
|
|
161
|
-
e[r] =
|
|
174
|
+
e[r] = v(t[r]);
|
|
162
175
|
return e;
|
|
163
176
|
}
|
|
164
177
|
const G = `<?php
|
|
@@ -229,21 +242,21 @@ async function Be(t) {
|
|
|
229
242
|
zipPath: r,
|
|
230
243
|
documentRoot: await t.documentRoot
|
|
231
244
|
});
|
|
232
|
-
await
|
|
245
|
+
await fe(
|
|
233
246
|
t,
|
|
234
247
|
`zipDir(${s.documentRoot}, ${s.zipPath});`
|
|
235
248
|
);
|
|
236
249
|
const n = await t.readFileAsBuffer(r);
|
|
237
250
|
return t.unlink(r), new File([n], e);
|
|
238
251
|
}
|
|
239
|
-
const
|
|
252
|
+
const Ve = async (t, { fullSiteZip: e }) => {
|
|
240
253
|
const r = "/import.zip";
|
|
241
254
|
await t.writeFile(
|
|
242
255
|
r,
|
|
243
256
|
new Uint8Array(await e.arrayBuffer())
|
|
244
257
|
);
|
|
245
258
|
const s = await t.absoluteUrl, n = await t.documentRoot;
|
|
246
|
-
await t.rmdir(n), await
|
|
259
|
+
await t.rmdir(n), await pe(t, { zipPath: r, extractToPath: "/" });
|
|
247
260
|
const i = W({ absoluteUrl: s });
|
|
248
261
|
await Ye(
|
|
249
262
|
t,
|
|
@@ -255,30 +268,30 @@ const je = async (t, { fullSiteZip: e }) => {
|
|
|
255
268
|
}
|
|
256
269
|
?>${o}`
|
|
257
270
|
);
|
|
258
|
-
},
|
|
271
|
+
}, pe = async (t, { zipPath: e, extractToPath: r }) => {
|
|
259
272
|
const s = W({
|
|
260
273
|
zipPath: e,
|
|
261
274
|
extractToPath: r
|
|
262
275
|
});
|
|
263
|
-
await
|
|
276
|
+
await fe(
|
|
264
277
|
t,
|
|
265
278
|
`unzip(${s.zipPath}, ${s.extractToPath});`
|
|
266
279
|
);
|
|
267
|
-
},
|
|
280
|
+
}, Ge = async (t, { file: e }) => {
|
|
268
281
|
const r = await t.request({
|
|
269
282
|
url: "/wp-admin/admin.php?import=wordpress"
|
|
270
|
-
}), s =
|
|
283
|
+
}), s = J(r).getElementById("import-upload-form")?.getAttribute("action"), n = await t.request({
|
|
271
284
|
url: `/wp-admin/${s}`,
|
|
272
285
|
method: "POST",
|
|
273
286
|
files: { import: e }
|
|
274
|
-
}), i =
|
|
287
|
+
}), i = J(n).querySelector(
|
|
275
288
|
"#wpbody-content form"
|
|
276
289
|
);
|
|
277
290
|
if (!i)
|
|
278
291
|
throw console.log(n.text), new Error(
|
|
279
292
|
"Could not find an importer form in response. See the response text above for details."
|
|
280
293
|
);
|
|
281
|
-
const o =
|
|
294
|
+
const o = Je(i);
|
|
282
295
|
o.fetch_attachments = "1";
|
|
283
296
|
for (const a in o)
|
|
284
297
|
if (a.startsWith("user_map[")) {
|
|
@@ -291,10 +304,10 @@ const je = async (t, { fullSiteZip: e }) => {
|
|
|
291
304
|
formData: o
|
|
292
305
|
});
|
|
293
306
|
};
|
|
294
|
-
function
|
|
307
|
+
function J(t) {
|
|
295
308
|
return new DOMParser().parseFromString(t.text, "text/html");
|
|
296
309
|
}
|
|
297
|
-
function
|
|
310
|
+
function Je(t) {
|
|
298
311
|
return Object.fromEntries(new FormData(t).entries());
|
|
299
312
|
}
|
|
300
313
|
async function Ye(t, e, r) {
|
|
@@ -303,7 +316,7 @@ async function Ye(t, e, r) {
|
|
|
303
316
|
r(await t.readFileAsText(e))
|
|
304
317
|
);
|
|
305
318
|
}
|
|
306
|
-
async function
|
|
319
|
+
async function fe(t, e) {
|
|
307
320
|
const r = await t.run({
|
|
308
321
|
code: G + e
|
|
309
322
|
});
|
|
@@ -311,9 +324,9 @@ async function pe(t, e) {
|
|
|
311
324
|
throw console.log(G + e), console.log(e + ""), console.log(r.errors), r.errors;
|
|
312
325
|
return r;
|
|
313
326
|
}
|
|
314
|
-
const
|
|
327
|
+
const Ke = async (t, { pluginZipFile: e, options: r = {} }, s) => {
|
|
315
328
|
s?.tracker.setCaption(
|
|
316
|
-
`Installing the ${
|
|
329
|
+
`Installing the ${L(e?.name)} plugin`
|
|
317
330
|
);
|
|
318
331
|
try {
|
|
319
332
|
const n = "activate" in r ? r.activate : !0, i = await t.request({
|
|
@@ -339,14 +352,14 @@ const Je = async (t, { pluginZipFile: e, options: r = {} }, s) => {
|
|
|
339
352
|
}
|
|
340
353
|
await t.isDir(
|
|
341
354
|
"/wordpress/wp-content/plugins/gutenberg"
|
|
342
|
-
) && !await t.fileExists("/wordpress/.gutenberg-patched") && (await t.writeFile("/wordpress/.gutenberg-patched", "1"), await
|
|
355
|
+
) && !await t.fileExists("/wordpress/.gutenberg-patched") && (await t.writeFile("/wordpress/.gutenberg-patched", "1"), await Y(
|
|
343
356
|
t,
|
|
344
357
|
"/wordpress/wp-content/plugins/gutenberg/build/block-editor/index.js",
|
|
345
358
|
(d) => d.replace(
|
|
346
359
|
/srcDoc:("[^"]+"|[^,]+)/g,
|
|
347
360
|
'src:"/wp-includes/empty.html"'
|
|
348
361
|
)
|
|
349
|
-
), await
|
|
362
|
+
), await Y(
|
|
350
363
|
t,
|
|
351
364
|
"/wordpress/wp-content/plugins/gutenberg/build/block-editor/index.min.js",
|
|
352
365
|
(d) => d.replace(
|
|
@@ -360,15 +373,15 @@ const Je = async (t, { pluginZipFile: e, options: r = {} }, s) => {
|
|
|
360
373
|
), console.error(n);
|
|
361
374
|
}
|
|
362
375
|
};
|
|
363
|
-
async function
|
|
376
|
+
async function Y(t, e, r) {
|
|
364
377
|
return await t.writeFile(
|
|
365
378
|
e,
|
|
366
379
|
r(await t.readFileAsText(e))
|
|
367
380
|
);
|
|
368
381
|
}
|
|
369
|
-
const
|
|
382
|
+
const Qe = async (t, { themeZipFile: e, options: r = {} }, s) => {
|
|
370
383
|
s?.tracker.setCaption(
|
|
371
|
-
`Installing the ${
|
|
384
|
+
`Installing the ${L(e.name)} theme`
|
|
372
385
|
);
|
|
373
386
|
try {
|
|
374
387
|
const n = "activate" in r ? r.activate : !0, i = await t.request({
|
|
@@ -400,12 +413,12 @@ const Ke = async (t, { themeZipFile: e, options: r = {} }, s) => {
|
|
|
400
413
|
console.error('The "activate" button was not found.');
|
|
401
414
|
return;
|
|
402
415
|
}
|
|
403
|
-
const
|
|
404
|
-
|
|
416
|
+
const xe = y.attributes.getNamedItem("href").value, Te = new URL(
|
|
417
|
+
xe,
|
|
405
418
|
await t.pathToInternalUrl("/wp-admin/")
|
|
406
419
|
).toString();
|
|
407
420
|
await t.request({
|
|
408
|
-
url:
|
|
421
|
+
url: Te
|
|
409
422
|
});
|
|
410
423
|
}
|
|
411
424
|
} catch (n) {
|
|
@@ -413,7 +426,7 @@ const Ke = async (t, { themeZipFile: e, options: r = {} }, s) => {
|
|
|
413
426
|
`Proceeding without the ${e.name} theme. Could not install it in wp-admin. The original error was: ${n}`
|
|
414
427
|
), console.error(n);
|
|
415
428
|
}
|
|
416
|
-
},
|
|
429
|
+
}, Xe = async (t, { username: e = "admin", password: r = "password" } = {}, s) => {
|
|
417
430
|
s?.tracker.setCaption(s?.initialCaption || "Logging in"), await t.request({
|
|
418
431
|
url: "/wp-login.php"
|
|
419
432
|
}), await t.request({
|
|
@@ -425,7 +438,7 @@ const Ke = async (t, { themeZipFile: e, options: r = {} }, s) => {
|
|
|
425
438
|
rememberme: "forever"
|
|
426
439
|
}
|
|
427
440
|
});
|
|
428
|
-
},
|
|
441
|
+
}, Ze = async (t, { options: e }) => {
|
|
429
442
|
await t.request({
|
|
430
443
|
url: "/wp-admin/install.php?step=2",
|
|
431
444
|
method: "POST",
|
|
@@ -442,10 +455,10 @@ const Ke = async (t, { themeZipFile: e, options: r = {} }, s) => {
|
|
|
442
455
|
admin_email: "admin@localhost.com"
|
|
443
456
|
}
|
|
444
457
|
});
|
|
445
|
-
},
|
|
458
|
+
}, et = async (t, { options: e }) => {
|
|
446
459
|
const r = `<?php
|
|
447
460
|
include 'wordpress/wp-load.php';
|
|
448
|
-
$site_options = ${
|
|
461
|
+
$site_options = ${v(e)};
|
|
449
462
|
foreach($site_options as $name => $value) {
|
|
450
463
|
update_option($name, $value);
|
|
451
464
|
}
|
|
@@ -453,52 +466,53 @@ const Ke = async (t, { themeZipFile: e, options: r = {} }, s) => {
|
|
|
453
466
|
`, s = await t.run({
|
|
454
467
|
code: r
|
|
455
468
|
});
|
|
456
|
-
return
|
|
457
|
-
},
|
|
469
|
+
return me(s), { code: r, result: s };
|
|
470
|
+
}, tt = async (t, { meta: e, userId: r }) => {
|
|
458
471
|
const s = `<?php
|
|
459
472
|
include 'wordpress/wp-load.php';
|
|
460
|
-
$meta = ${
|
|
473
|
+
$meta = ${v(e)};
|
|
461
474
|
foreach($meta as $name => $value) {
|
|
462
|
-
update_user_meta(${
|
|
475
|
+
update_user_meta(${v(r)}, $name, $value);
|
|
463
476
|
}
|
|
464
477
|
echo "Success";
|
|
465
478
|
`, n = await t.run({
|
|
466
479
|
code: s
|
|
467
480
|
});
|
|
468
|
-
return
|
|
481
|
+
return me(n), { code: s, result: n };
|
|
469
482
|
};
|
|
470
|
-
async function
|
|
483
|
+
async function me(t) {
|
|
471
484
|
if (t.text !== "Success")
|
|
472
485
|
throw console.log(t), new Error(`Failed to run code: ${t.text} ${t.errors}`);
|
|
473
486
|
}
|
|
474
|
-
const
|
|
487
|
+
const rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
475
488
|
__proto__: null,
|
|
476
|
-
activatePlugin:
|
|
477
|
-
applyWordPressPatches:
|
|
478
|
-
cp:
|
|
479
|
-
defineSiteUrl:
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
489
|
+
activatePlugin: ke,
|
|
490
|
+
applyWordPressPatches: Fe,
|
|
491
|
+
cp: Ie,
|
|
492
|
+
defineSiteUrl: qe,
|
|
493
|
+
defineWpConfigConsts: he,
|
|
494
|
+
importFile: Ge,
|
|
495
|
+
installPlugin: Ke,
|
|
496
|
+
installTheme: Qe,
|
|
497
|
+
login: Xe,
|
|
484
498
|
mkdir: Me,
|
|
485
|
-
mv:
|
|
486
|
-
replaceSite:
|
|
487
|
-
request:
|
|
488
|
-
rm:
|
|
489
|
-
rmdir:
|
|
490
|
-
runPHP:
|
|
491
|
-
runPHPWithOptions:
|
|
492
|
-
runWpInstallationWizard:
|
|
493
|
-
setPhpIniEntry:
|
|
494
|
-
setSiteOptions:
|
|
495
|
-
unzip:
|
|
496
|
-
updateUserMeta:
|
|
497
|
-
writeFile:
|
|
499
|
+
mv: Ne,
|
|
500
|
+
replaceSite: Ve,
|
|
501
|
+
request: He,
|
|
502
|
+
rm: We,
|
|
503
|
+
rmdir: De,
|
|
504
|
+
runPHP: Ae,
|
|
505
|
+
runPHPWithOptions: Le,
|
|
506
|
+
runWpInstallationWizard: Ze,
|
|
507
|
+
setPhpIniEntry: Ue,
|
|
508
|
+
setSiteOptions: et,
|
|
509
|
+
unzip: pe,
|
|
510
|
+
updateUserMeta: tt,
|
|
511
|
+
writeFile: ze,
|
|
498
512
|
zipEntireSite: Be
|
|
499
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
500
|
-
function
|
|
501
|
-
const r = t.headers.get("content-length") || "", s = parseInt(r, 10) ||
|
|
513
|
+
}, Symbol.toStringTag, { value: "Module" })), st = 5 * 1024 * 1024;
|
|
514
|
+
function nt(t, e) {
|
|
515
|
+
const r = t.headers.get("content-length") || "", s = parseInt(r, 10) || st;
|
|
502
516
|
function n(i, o) {
|
|
503
517
|
e(
|
|
504
518
|
new CustomEvent("progress", {
|
|
@@ -706,12 +720,12 @@ class U extends EventTarget {
|
|
|
706
720
|
this.dispatchEvent(new CustomEvent("done"));
|
|
707
721
|
}
|
|
708
722
|
}
|
|
709
|
-
class
|
|
723
|
+
class S {
|
|
710
724
|
constructor(e, r, s, n = "", i = 0) {
|
|
711
725
|
this.httpStatusCode = e, this.headers = r, this.bytes = s, this.exitCode = i, this.errors = n;
|
|
712
726
|
}
|
|
713
727
|
static fromRawData(e) {
|
|
714
|
-
return new
|
|
728
|
+
return new S(
|
|
715
729
|
e.httpStatusCode,
|
|
716
730
|
e.headers,
|
|
717
731
|
e.bytes,
|
|
@@ -751,8 +765,8 @@ const D = [
|
|
|
751
765
|
"7.1",
|
|
752
766
|
"7.0",
|
|
753
767
|
"5.6"
|
|
754
|
-
],
|
|
755
|
-
class
|
|
768
|
+
], it = D[0], rr = D;
|
|
769
|
+
class ot {
|
|
756
770
|
#e;
|
|
757
771
|
#t;
|
|
758
772
|
/**
|
|
@@ -838,17 +852,17 @@ class it {
|
|
|
838
852
|
return e.join("; ");
|
|
839
853
|
}
|
|
840
854
|
}
|
|
841
|
-
const
|
|
855
|
+
const at = "http://example.com";
|
|
842
856
|
function K(t) {
|
|
843
857
|
return t.toString().substring(t.origin.length);
|
|
844
858
|
}
|
|
845
859
|
function Q(t, e) {
|
|
846
860
|
return !e || !t.startsWith(e) ? t : t.substring(e.length);
|
|
847
861
|
}
|
|
848
|
-
function
|
|
862
|
+
function ct(t, e) {
|
|
849
863
|
return !e || t.startsWith(e) ? t : e + t;
|
|
850
864
|
}
|
|
851
|
-
class
|
|
865
|
+
class lt {
|
|
852
866
|
#e;
|
|
853
867
|
#t;
|
|
854
868
|
#r;
|
|
@@ -863,7 +877,7 @@ class ct {
|
|
|
863
877
|
* @param config - Request Handler configuration.
|
|
864
878
|
*/
|
|
865
879
|
constructor(e, r = {}) {
|
|
866
|
-
this.#a = new
|
|
880
|
+
this.#a = new de({ concurrency: 1 });
|
|
867
881
|
const {
|
|
868
882
|
documentRoot: s = "/www/",
|
|
869
883
|
absoluteUrl: n = typeof location == "object" ? location?.href : "",
|
|
@@ -906,7 +920,7 @@ class ct {
|
|
|
906
920
|
async request(e) {
|
|
907
921
|
const r = e.url.startsWith("http://") || e.url.startsWith("https://"), s = new URL(
|
|
908
922
|
e.url,
|
|
909
|
-
r ? void 0 :
|
|
923
|
+
r ? void 0 : at
|
|
910
924
|
), n = Q(
|
|
911
925
|
s.pathname,
|
|
912
926
|
this.#s
|
|
@@ -922,20 +936,20 @@ class ct {
|
|
|
922
936
|
#l(e) {
|
|
923
937
|
const r = `${this.#e}${e}`;
|
|
924
938
|
if (!this.php.fileExists(r))
|
|
925
|
-
return new
|
|
939
|
+
return new S(
|
|
926
940
|
404,
|
|
927
941
|
{},
|
|
928
942
|
new TextEncoder().encode("404 File not found")
|
|
929
943
|
);
|
|
930
944
|
const s = this.php.readFileAsBuffer(r);
|
|
931
|
-
return new
|
|
945
|
+
return new S(
|
|
932
946
|
200,
|
|
933
947
|
{
|
|
934
948
|
"content-length": [`${s.byteLength}`],
|
|
935
949
|
// @TODO: Infer the content-type from the arrayBuffer instead of the file path.
|
|
936
950
|
// The code below won't return the correct mime-type if the extension
|
|
937
951
|
// was tampered with.
|
|
938
|
-
"content-type": [
|
|
952
|
+
"content-type": [ht(r)],
|
|
939
953
|
"accept-ranges": ["bytes"],
|
|
940
954
|
"cache-control": ["public, max-age=0"]
|
|
941
955
|
},
|
|
@@ -959,7 +973,7 @@ class ct {
|
|
|
959
973
|
let n = "GET";
|
|
960
974
|
const i = {
|
|
961
975
|
host: this.#i,
|
|
962
|
-
...
|
|
976
|
+
...ge(e.headers || {})
|
|
963
977
|
}, o = [];
|
|
964
978
|
if (e.files && Object.keys(e.files).length) {
|
|
965
979
|
n = "POST";
|
|
@@ -972,7 +986,7 @@ class ct {
|
|
|
972
986
|
data: new Uint8Array(await l.arrayBuffer())
|
|
973
987
|
});
|
|
974
988
|
}
|
|
975
|
-
i["content-type"]?.startsWith("multipart/form-data") && (e.formData =
|
|
989
|
+
i["content-type"]?.startsWith("multipart/form-data") && (e.formData = ut(
|
|
976
990
|
e.body || ""
|
|
977
991
|
), i["content-type"] = "application/x-www-form-urlencoded", delete e.body);
|
|
978
992
|
}
|
|
@@ -980,7 +994,7 @@ class ct {
|
|
|
980
994
|
return e.formData !== void 0 ? (n = "POST", i["content-type"] = i["content-type"] || "application/x-www-form-urlencoded", a = new URLSearchParams(
|
|
981
995
|
e.formData
|
|
982
996
|
).toString()) : a = e.body, await this.php.run({
|
|
983
|
-
relativeUri:
|
|
997
|
+
relativeUri: ct(
|
|
984
998
|
K(r),
|
|
985
999
|
this.#s
|
|
986
1000
|
),
|
|
@@ -1010,7 +1024,7 @@ class ct {
|
|
|
1010
1024
|
return this.php.fileExists(s) ? s : `${this.#e}/index.php`;
|
|
1011
1025
|
}
|
|
1012
1026
|
}
|
|
1013
|
-
function
|
|
1027
|
+
function ut(t) {
|
|
1014
1028
|
const e = {}, r = t.match(/--(.*)\r\n/);
|
|
1015
1029
|
if (!r)
|
|
1016
1030
|
return e;
|
|
@@ -1025,7 +1039,7 @@ function lt(t) {
|
|
|
1025
1039
|
}
|
|
1026
1040
|
}), e;
|
|
1027
1041
|
}
|
|
1028
|
-
function
|
|
1042
|
+
function ht(t) {
|
|
1029
1043
|
switch (t.split(".").pop()) {
|
|
1030
1044
|
case "css":
|
|
1031
1045
|
return "text/css";
|
|
@@ -1163,12 +1177,12 @@ function m(t = "") {
|
|
|
1163
1177
|
};
|
|
1164
1178
|
};
|
|
1165
1179
|
}
|
|
1166
|
-
const
|
|
1167
|
-
function
|
|
1168
|
-
return
|
|
1180
|
+
const dt = [];
|
|
1181
|
+
function pt(t) {
|
|
1182
|
+
return dt[t];
|
|
1169
1183
|
}
|
|
1170
1184
|
(function() {
|
|
1171
|
-
return typeof
|
|
1185
|
+
return typeof process < "u" && process.release?.name === "node" ? "NODE" : typeof window < "u" ? "WEB" : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? "WORKER" : "NODE";
|
|
1172
1186
|
})();
|
|
1173
1187
|
const Z = Symbol("error"), ee = Symbol("message");
|
|
1174
1188
|
class z extends Event {
|
|
@@ -1191,8 +1205,8 @@ class z extends Event {
|
|
|
1191
1205
|
}
|
|
1192
1206
|
Object.defineProperty(z.prototype, "error", { enumerable: !0 });
|
|
1193
1207
|
Object.defineProperty(z.prototype, "message", { enumerable: !0 });
|
|
1194
|
-
const
|
|
1195
|
-
class
|
|
1208
|
+
const ft = typeof globalThis.ErrorEvent == "function" ? globalThis.ErrorEvent : z;
|
|
1209
|
+
class mt extends EventTarget {
|
|
1196
1210
|
constructor() {
|
|
1197
1211
|
super(...arguments), this.listenersCount = 0;
|
|
1198
1212
|
}
|
|
@@ -1206,11 +1220,11 @@ class ft extends EventTarget {
|
|
|
1206
1220
|
return this.listenersCount > 0;
|
|
1207
1221
|
}
|
|
1208
1222
|
}
|
|
1209
|
-
function
|
|
1223
|
+
function gt(t) {
|
|
1210
1224
|
t.asm = {
|
|
1211
1225
|
...t.asm
|
|
1212
1226
|
};
|
|
1213
|
-
const e = new
|
|
1227
|
+
const e = new mt();
|
|
1214
1228
|
for (const r in t.asm)
|
|
1215
1229
|
if (typeof t.asm[r] == "function") {
|
|
1216
1230
|
const s = t.asm[r];
|
|
@@ -1222,14 +1236,14 @@ function mt(t) {
|
|
|
1222
1236
|
throw i;
|
|
1223
1237
|
if ("exitCode" in i && i?.exitCode === 0)
|
|
1224
1238
|
return;
|
|
1225
|
-
const o =
|
|
1239
|
+
const o = yt(
|
|
1226
1240
|
i,
|
|
1227
1241
|
t.lastAsyncifyStackSource?.stack
|
|
1228
1242
|
);
|
|
1229
1243
|
if (t.lastAsyncifyStackSource && (i.cause = t.lastAsyncifyStackSource), !e.hasListeners())
|
|
1230
|
-
throw
|
|
1244
|
+
throw _t(o), i;
|
|
1231
1245
|
e.dispatchEvent(
|
|
1232
|
-
new
|
|
1246
|
+
new ft("error", {
|
|
1233
1247
|
error: i,
|
|
1234
1248
|
message: o
|
|
1235
1249
|
})
|
|
@@ -1239,29 +1253,29 @@ function mt(t) {
|
|
|
1239
1253
|
}
|
|
1240
1254
|
return e;
|
|
1241
1255
|
}
|
|
1242
|
-
let
|
|
1243
|
-
function
|
|
1244
|
-
return
|
|
1256
|
+
let N = [];
|
|
1257
|
+
function wt() {
|
|
1258
|
+
return N;
|
|
1245
1259
|
}
|
|
1246
|
-
function
|
|
1260
|
+
function yt(t, e) {
|
|
1247
1261
|
if (t.message === "unreachable") {
|
|
1248
|
-
let r =
|
|
1262
|
+
let r = Pt;
|
|
1249
1263
|
e || (r += `
|
|
1250
1264
|
|
|
1251
1265
|
This stack trace is lacking. For a better one initialize
|
|
1252
1266
|
the PHP runtime with { debug: true }, e.g. PHPNode.load('8.1', { debug: true }).
|
|
1253
1267
|
|
|
1254
|
-
`),
|
|
1268
|
+
`), N = $t(
|
|
1255
1269
|
e || t.stack || ""
|
|
1256
1270
|
);
|
|
1257
|
-
for (const s of
|
|
1271
|
+
for (const s of N)
|
|
1258
1272
|
r += ` * ${s}
|
|
1259
1273
|
`;
|
|
1260
1274
|
return r;
|
|
1261
1275
|
}
|
|
1262
1276
|
return t.message;
|
|
1263
1277
|
}
|
|
1264
|
-
const
|
|
1278
|
+
const Pt = `
|
|
1265
1279
|
"unreachable" WASM instruction executed.
|
|
1266
1280
|
|
|
1267
1281
|
The typical reason is a PHP function missing from the ASYNCIFY_ONLY
|
|
@@ -1285,20 +1299,20 @@ the Dockerfile, you'll need to trigger this error again with long stack
|
|
|
1285
1299
|
traces enabled. In node.js, you can do it using the --stack-trace-limit=100
|
|
1286
1300
|
CLI option:
|
|
1287
1301
|
|
|
1288
|
-
`, te = "\x1B[41m",
|
|
1302
|
+
`, te = "\x1B[41m", bt = "\x1B[1m", re = "\x1B[0m", se = "\x1B[K";
|
|
1289
1303
|
let ne = !1;
|
|
1290
|
-
function
|
|
1304
|
+
function _t(t) {
|
|
1291
1305
|
if (!ne) {
|
|
1292
1306
|
ne = !0, console.log(`${te}
|
|
1293
1307
|
${se}
|
|
1294
|
-
${
|
|
1308
|
+
${bt} WASM ERROR${re}${te}`);
|
|
1295
1309
|
for (const e of t.split(`
|
|
1296
1310
|
`))
|
|
1297
1311
|
console.log(`${se} ${e} `);
|
|
1298
1312
|
console.log(`${re}`);
|
|
1299
1313
|
}
|
|
1300
1314
|
}
|
|
1301
|
-
function
|
|
1315
|
+
function $t(t) {
|
|
1302
1316
|
try {
|
|
1303
1317
|
const e = t.split(`
|
|
1304
1318
|
`).slice(1).map((r) => {
|
|
@@ -1315,8 +1329,8 @@ function _t(t) {
|
|
|
1315
1329
|
return [];
|
|
1316
1330
|
}
|
|
1317
1331
|
}
|
|
1318
|
-
var Et = Object.defineProperty,
|
|
1319
|
-
for (var n = s > 1 ? void 0 : s ?
|
|
1332
|
+
var Et = Object.defineProperty, vt = Object.getOwnPropertyDescriptor, g = (t, e, r, s) => {
|
|
1333
|
+
for (var n = s > 1 ? void 0 : s ? vt(e, r) : e, i = t.length - 1, o; i >= 0; i--)
|
|
1320
1334
|
(o = t[i]) && (n = (s ? o(e, r, n) : o(n)) || n);
|
|
1321
1335
|
return s && n && Et(e, r, n), n;
|
|
1322
1336
|
};
|
|
@@ -1330,8 +1344,8 @@ class w {
|
|
|
1330
1344
|
* @param serverOptions - Optional. Options for the PHPRequestHandler. If undefined, no request handler will be initialized.
|
|
1331
1345
|
*/
|
|
1332
1346
|
constructor(e, r) {
|
|
1333
|
-
this.#e = [], this.#t = !1, this.#r = null, e !== void 0 && this.initializeRuntime(e), r && (this.requestHandler = new
|
|
1334
|
-
new
|
|
1347
|
+
this.#e = [], this.#t = !1, this.#r = null, e !== void 0 && this.initializeRuntime(e), r && (this.requestHandler = new ot(
|
|
1348
|
+
new lt(this, r)
|
|
1335
1349
|
));
|
|
1336
1350
|
}
|
|
1337
1351
|
#e;
|
|
@@ -1358,10 +1372,10 @@ class w {
|
|
|
1358
1372
|
initializeRuntime(e) {
|
|
1359
1373
|
if (this[h])
|
|
1360
1374
|
throw new Error("PHP runtime already initialized.");
|
|
1361
|
-
const r =
|
|
1375
|
+
const r = pt(e);
|
|
1362
1376
|
if (!r)
|
|
1363
1377
|
throw new Error("Invalid PHP runtime id.");
|
|
1364
|
-
this[h] = r, this.#r =
|
|
1378
|
+
this[h] = r, this.#r = gt(r);
|
|
1365
1379
|
}
|
|
1366
1380
|
/** @inheritDoc */
|
|
1367
1381
|
setPhpIniPath(e) {
|
|
@@ -1395,7 +1409,7 @@ class w {
|
|
|
1395
1409
|
this.#t || (this.#n(), this.#t = !0), this.#u(e.scriptPath || ""), this.#s(e.relativeUri || ""), this.#a(e.method || "GET");
|
|
1396
1410
|
const { host: r, ...s } = {
|
|
1397
1411
|
host: "example.com:443",
|
|
1398
|
-
...
|
|
1412
|
+
...ge(e.headers || {})
|
|
1399
1413
|
};
|
|
1400
1414
|
if (this.#o(r, e.protocol || "http"), this.#c(s), e.body && this.#l(e.body), e.fileInfos)
|
|
1401
1415
|
for (const n of e.fileInfos)
|
|
@@ -1595,14 +1609,14 @@ class w {
|
|
|
1595
1609
|
"PHP runtime has crashed – see the earlier error for details."
|
|
1596
1610
|
);
|
|
1597
1611
|
});
|
|
1598
|
-
this.functionsMaybeMissingFromAsyncify =
|
|
1612
|
+
this.functionsMaybeMissingFromAsyncify = wt();
|
|
1599
1613
|
const o = i, a = "betterMessage" in o ? o.betterMessage : o.message, c = new Error(a);
|
|
1600
1614
|
throw c.cause = o, c;
|
|
1601
1615
|
} finally {
|
|
1602
1616
|
this.#r?.removeEventListener("error", r);
|
|
1603
1617
|
}
|
|
1604
1618
|
const { headers: s, httpStatusCode: n } = this.#i();
|
|
1605
|
-
return new
|
|
1619
|
+
return new S(
|
|
1606
1620
|
n,
|
|
1607
1621
|
s,
|
|
1608
1622
|
this.readFileAsBuffer("/tmp/stdout"),
|
|
@@ -1694,21 +1708,21 @@ g([
|
|
|
1694
1708
|
g([
|
|
1695
1709
|
m('Could not stat "{path}"')
|
|
1696
1710
|
], w.prototype, "fileExists", 1);
|
|
1697
|
-
function
|
|
1711
|
+
function ge(t) {
|
|
1698
1712
|
const e = {};
|
|
1699
1713
|
for (const r in t)
|
|
1700
1714
|
e[r.toLowerCase()] = t[r];
|
|
1701
1715
|
return e;
|
|
1702
1716
|
}
|
|
1703
|
-
const
|
|
1717
|
+
const St = [
|
|
1704
1718
|
"vfs",
|
|
1705
1719
|
"literal",
|
|
1706
1720
|
"wordpress.org/themes",
|
|
1707
1721
|
"wordpress.org/plugins",
|
|
1708
1722
|
"url"
|
|
1709
1723
|
];
|
|
1710
|
-
function
|
|
1711
|
-
return t && typeof t == "object" && typeof t.resource == "string" &&
|
|
1724
|
+
function Rt(t) {
|
|
1725
|
+
return t && typeof t == "object" && typeof t.resource == "string" && St.includes(t.resource);
|
|
1712
1726
|
}
|
|
1713
1727
|
class b {
|
|
1714
1728
|
/**
|
|
@@ -1722,24 +1736,24 @@ class b {
|
|
|
1722
1736
|
let n;
|
|
1723
1737
|
switch (e.resource) {
|
|
1724
1738
|
case "vfs":
|
|
1725
|
-
n = new
|
|
1739
|
+
n = new xt(e, s);
|
|
1726
1740
|
break;
|
|
1727
1741
|
case "literal":
|
|
1728
|
-
n = new
|
|
1742
|
+
n = new Tt(e, s);
|
|
1729
1743
|
break;
|
|
1730
1744
|
case "wordpress.org/themes":
|
|
1731
|
-
n = new
|
|
1745
|
+
n = new Ft(e, s);
|
|
1732
1746
|
break;
|
|
1733
1747
|
case "wordpress.org/plugins":
|
|
1734
|
-
n = new
|
|
1748
|
+
n = new Ot(e, s);
|
|
1735
1749
|
break;
|
|
1736
1750
|
case "url":
|
|
1737
|
-
n = new
|
|
1751
|
+
n = new kt(e, s);
|
|
1738
1752
|
break;
|
|
1739
1753
|
default:
|
|
1740
1754
|
throw new Error(`Invalid resource: ${e}`);
|
|
1741
1755
|
}
|
|
1742
|
-
return n = new
|
|
1756
|
+
return n = new At(n), r && (n = new Lt(n, r)), n;
|
|
1743
1757
|
}
|
|
1744
1758
|
setPlayground(e) {
|
|
1745
1759
|
this.playground = e;
|
|
@@ -1749,7 +1763,7 @@ class b {
|
|
|
1749
1763
|
return !1;
|
|
1750
1764
|
}
|
|
1751
1765
|
}
|
|
1752
|
-
class
|
|
1766
|
+
class xt extends b {
|
|
1753
1767
|
/**
|
|
1754
1768
|
* Creates a new instance of `VFSResource`.
|
|
1755
1769
|
* @param playground The playground client.
|
|
@@ -1771,7 +1785,7 @@ class Rt extends b {
|
|
|
1771
1785
|
return this.resource.path;
|
|
1772
1786
|
}
|
|
1773
1787
|
}
|
|
1774
|
-
class
|
|
1788
|
+
class Tt extends b {
|
|
1775
1789
|
/**
|
|
1776
1790
|
* Creates a new instance of `LiteralResource`.
|
|
1777
1791
|
* @param resource The literal reference.
|
|
@@ -1802,9 +1816,9 @@ class q extends b {
|
|
|
1802
1816
|
this.progress?.setCaption(this.caption);
|
|
1803
1817
|
const e = this.getURL();
|
|
1804
1818
|
let r = await fetch(e);
|
|
1805
|
-
if (r = await
|
|
1819
|
+
if (r = await nt(
|
|
1806
1820
|
r,
|
|
1807
|
-
this.progress?.loadingListener ??
|
|
1821
|
+
this.progress?.loadingListener ?? Ct
|
|
1808
1822
|
), r.status !== 200)
|
|
1809
1823
|
throw new Error(`Could not download "${e}"`);
|
|
1810
1824
|
return new File([await r.blob()], this.name);
|
|
@@ -1829,9 +1843,9 @@ class q extends b {
|
|
|
1829
1843
|
return !0;
|
|
1830
1844
|
}
|
|
1831
1845
|
}
|
|
1832
|
-
const
|
|
1846
|
+
const Ct = () => {
|
|
1833
1847
|
};
|
|
1834
|
-
class
|
|
1848
|
+
class kt extends q {
|
|
1835
1849
|
/**
|
|
1836
1850
|
* Creates a new instance of `UrlResource`.
|
|
1837
1851
|
* @param resource The URL reference.
|
|
@@ -1849,40 +1863,40 @@ class Ct extends q {
|
|
|
1849
1863
|
return this.resource.caption ?? super.caption;
|
|
1850
1864
|
}
|
|
1851
1865
|
}
|
|
1852
|
-
let
|
|
1853
|
-
function
|
|
1854
|
-
|
|
1866
|
+
let j = "https://playground.wordpress.net/plugin-proxy";
|
|
1867
|
+
function sr(t) {
|
|
1868
|
+
j = t;
|
|
1855
1869
|
}
|
|
1856
|
-
class
|
|
1870
|
+
class Ft extends q {
|
|
1857
1871
|
constructor(e, r) {
|
|
1858
1872
|
super(r), this.resource = e;
|
|
1859
1873
|
}
|
|
1860
1874
|
get name() {
|
|
1861
|
-
return
|
|
1875
|
+
return L(this.resource.slug);
|
|
1862
1876
|
}
|
|
1863
1877
|
getURL() {
|
|
1864
|
-
const e =
|
|
1865
|
-
return `${
|
|
1878
|
+
const e = we(this.resource.slug);
|
|
1879
|
+
return `${j}?theme=` + e;
|
|
1866
1880
|
}
|
|
1867
1881
|
}
|
|
1868
|
-
class
|
|
1882
|
+
class Ot extends q {
|
|
1869
1883
|
constructor(e, r) {
|
|
1870
1884
|
super(r), this.resource = e;
|
|
1871
1885
|
}
|
|
1872
1886
|
/** @inheritDoc */
|
|
1873
1887
|
get name() {
|
|
1874
|
-
return
|
|
1888
|
+
return L(this.resource.slug);
|
|
1875
1889
|
}
|
|
1876
1890
|
/** @inheritDoc */
|
|
1877
1891
|
getURL() {
|
|
1878
|
-
const e =
|
|
1879
|
-
return `${
|
|
1892
|
+
const e = we(this.resource.slug);
|
|
1893
|
+
return `${j}?plugin=` + e;
|
|
1880
1894
|
}
|
|
1881
1895
|
}
|
|
1882
|
-
function
|
|
1896
|
+
function we(t) {
|
|
1883
1897
|
return !t || t.endsWith(".zip") ? t : t + ".latest-stable.zip";
|
|
1884
1898
|
}
|
|
1885
|
-
class
|
|
1899
|
+
class ye extends b {
|
|
1886
1900
|
constructor(e) {
|
|
1887
1901
|
super(), this.resource = e;
|
|
1888
1902
|
}
|
|
@@ -1911,13 +1925,13 @@ class we extends b {
|
|
|
1911
1925
|
return this.resource.isAsync;
|
|
1912
1926
|
}
|
|
1913
1927
|
}
|
|
1914
|
-
class
|
|
1928
|
+
class At extends ye {
|
|
1915
1929
|
/** @inheritDoc */
|
|
1916
1930
|
async resolve() {
|
|
1917
1931
|
return this.promise || (this.promise = super.resolve()), this.promise;
|
|
1918
1932
|
}
|
|
1919
1933
|
}
|
|
1920
|
-
class
|
|
1934
|
+
class Lt extends ye {
|
|
1921
1935
|
constructor(e, r) {
|
|
1922
1936
|
super(e), this.semaphore = r;
|
|
1923
1937
|
}
|
|
@@ -1926,18 +1940,18 @@ class At extends we {
|
|
|
1926
1940
|
return this.isAsync ? this.semaphore.run(() => super.resolve()) : super.resolve();
|
|
1927
1941
|
}
|
|
1928
1942
|
}
|
|
1929
|
-
const
|
|
1930
|
-
function
|
|
1943
|
+
const Ut = ["6.2", "6.1", "6.0", "5.9"];
|
|
1944
|
+
function Ht(t, {
|
|
1931
1945
|
progress: e = new U(),
|
|
1932
|
-
semaphore: r = new
|
|
1946
|
+
semaphore: r = new de({ concurrency: 3 }),
|
|
1933
1947
|
onStepCompleted: s = () => {
|
|
1934
1948
|
}
|
|
1935
1949
|
} = {}) {
|
|
1936
|
-
const n = (t.steps || []).filter(
|
|
1950
|
+
const n = (t.steps || []).filter(It), i = n.reduce(
|
|
1937
1951
|
(a, c) => a + (c.progress?.weight || 1),
|
|
1938
1952
|
0
|
|
1939
1953
|
), o = n.map(
|
|
1940
|
-
(a) =>
|
|
1954
|
+
(a) => Nt(a, {
|
|
1941
1955
|
semaphore: r,
|
|
1942
1956
|
rootProgressTracker: e,
|
|
1943
1957
|
totalProgressWeight: i
|
|
@@ -1948,11 +1962,11 @@ function Ut(t, {
|
|
|
1948
1962
|
php: ie(
|
|
1949
1963
|
t.preferredVersions?.php,
|
|
1950
1964
|
D,
|
|
1951
|
-
|
|
1965
|
+
it
|
|
1952
1966
|
),
|
|
1953
1967
|
wp: ie(
|
|
1954
1968
|
t.preferredVersions?.wp,
|
|
1955
|
-
|
|
1969
|
+
Ut,
|
|
1956
1970
|
"6.2"
|
|
1957
1971
|
)
|
|
1958
1972
|
},
|
|
@@ -1980,10 +1994,10 @@ function Ut(t, {
|
|
|
1980
1994
|
function ie(t, e, r) {
|
|
1981
1995
|
return t && e.includes(t) ? t : r;
|
|
1982
1996
|
}
|
|
1983
|
-
function
|
|
1997
|
+
function It(t) {
|
|
1984
1998
|
return !!(typeof t == "object" && t);
|
|
1985
1999
|
}
|
|
1986
|
-
function
|
|
2000
|
+
function Nt(t, {
|
|
1987
2001
|
semaphore: e,
|
|
1988
2002
|
rootProgressTracker: r,
|
|
1989
2003
|
totalProgressWeight: s
|
|
@@ -1993,13 +2007,13 @@ function It(t, {
|
|
|
1993
2007
|
), i = {};
|
|
1994
2008
|
for (const u of Object.keys(t)) {
|
|
1995
2009
|
let d = t[u];
|
|
1996
|
-
|
|
2010
|
+
Rt(d) && (d = b.create(d, {
|
|
1997
2011
|
semaphore: e
|
|
1998
2012
|
})), i[u] = d;
|
|
1999
2013
|
}
|
|
2000
2014
|
const o = async (u) => {
|
|
2001
2015
|
try {
|
|
2002
|
-
return n.fillSlowly(), await
|
|
2016
|
+
return n.fillSlowly(), await rt[t.step](
|
|
2003
2017
|
u,
|
|
2004
2018
|
await Mt(i),
|
|
2005
2019
|
{
|
|
@@ -2033,7 +2047,7 @@ async function Mt(t) {
|
|
|
2033
2047
|
}
|
|
2034
2048
|
return e;
|
|
2035
2049
|
}
|
|
2036
|
-
async function
|
|
2050
|
+
async function Wt(t, e) {
|
|
2037
2051
|
await t.run(e);
|
|
2038
2052
|
}
|
|
2039
2053
|
/**
|
|
@@ -2041,17 +2055,17 @@ async function Nt(t, e) {
|
|
|
2041
2055
|
* Copyright 2019 Google LLC
|
|
2042
2056
|
* SPDX-License-Identifier: Apache-2.0
|
|
2043
2057
|
*/
|
|
2044
|
-
const
|
|
2045
|
-
canHandle: (t) =>
|
|
2058
|
+
const Pe = Symbol("Comlink.proxy"), Dt = Symbol("Comlink.endpoint"), zt = Symbol("Comlink.releaseProxy"), I = Symbol("Comlink.finalizer"), C = Symbol("Comlink.thrown"), be = (t) => typeof t == "object" && t !== null || typeof t == "function", qt = {
|
|
2059
|
+
canHandle: (t) => be(t) && t[Pe],
|
|
2046
2060
|
serialize(t) {
|
|
2047
2061
|
const { port1: e, port2: r } = new MessageChannel();
|
|
2048
|
-
return
|
|
2062
|
+
return B(t, e), [r, [r]];
|
|
2049
2063
|
},
|
|
2050
2064
|
deserialize(t) {
|
|
2051
2065
|
return t.start(), V(t);
|
|
2052
2066
|
}
|
|
2053
|
-
},
|
|
2054
|
-
canHandle: (t) =>
|
|
2067
|
+
}, jt = {
|
|
2068
|
+
canHandle: (t) => be(t) && C in t,
|
|
2055
2069
|
serialize({ value: t }) {
|
|
2056
2070
|
let e;
|
|
2057
2071
|
return t instanceof Error ? e = {
|
|
@@ -2067,8 +2081,8 @@ const ye = Symbol("Comlink.proxy"), Wt = Symbol("Comlink.endpoint"), Dt = Symbol
|
|
|
2067
2081
|
throw t.isError ? Object.assign(new Error(t.value.message), t.value) : t.value;
|
|
2068
2082
|
}
|
|
2069
2083
|
}, R = /* @__PURE__ */ new Map([
|
|
2070
|
-
["proxy",
|
|
2071
|
-
["throw",
|
|
2084
|
+
["proxy", qt],
|
|
2085
|
+
["throw", jt]
|
|
2072
2086
|
]);
|
|
2073
2087
|
function Bt(t, e) {
|
|
2074
2088
|
for (const r of t)
|
|
@@ -2076,7 +2090,7 @@ function Bt(t, e) {
|
|
|
2076
2090
|
return !0;
|
|
2077
2091
|
return !1;
|
|
2078
2092
|
}
|
|
2079
|
-
function
|
|
2093
|
+
function B(t, e = globalThis, r = ["*"]) {
|
|
2080
2094
|
e.addEventListener("message", function s(n) {
|
|
2081
2095
|
if (!n || !n.data)
|
|
2082
2096
|
return;
|
|
@@ -2101,13 +2115,13 @@ function j(t, e = globalThis, r = ["*"]) {
|
|
|
2101
2115
|
case "CONSTRUCT":
|
|
2102
2116
|
{
|
|
2103
2117
|
const p = new d(...c);
|
|
2104
|
-
l =
|
|
2118
|
+
l = ve(p);
|
|
2105
2119
|
}
|
|
2106
2120
|
break;
|
|
2107
2121
|
case "ENDPOINT":
|
|
2108
2122
|
{
|
|
2109
2123
|
const { port1: p, port2: y } = new MessageChannel();
|
|
2110
|
-
|
|
2124
|
+
B(t, y), l = Kt(p, [p]);
|
|
2111
2125
|
}
|
|
2112
2126
|
break;
|
|
2113
2127
|
case "RELEASE":
|
|
@@ -2121,7 +2135,7 @@ function j(t, e = globalThis, r = ["*"]) {
|
|
|
2121
2135
|
}
|
|
2122
2136
|
Promise.resolve(l).catch((u) => ({ value: u, [C]: 0 })).then((u) => {
|
|
2123
2137
|
const [d, p] = A(u);
|
|
2124
|
-
e.postMessage(Object.assign(Object.assign({}, d), { id: i }), p), o === "RELEASE" && (e.removeEventListener("message", s),
|
|
2138
|
+
e.postMessage(Object.assign(Object.assign({}, d), { id: i }), p), o === "RELEASE" && (e.removeEventListener("message", s), _e(e), I in t && typeof t[I] == "function" && t[I]());
|
|
2125
2139
|
}).catch((u) => {
|
|
2126
2140
|
const [d, p] = A({
|
|
2127
2141
|
value: new TypeError("Unserializable return value"),
|
|
@@ -2131,61 +2145,61 @@ function j(t, e = globalThis, r = ["*"]) {
|
|
|
2131
2145
|
});
|
|
2132
2146
|
}), e.start && e.start();
|
|
2133
2147
|
}
|
|
2134
|
-
function
|
|
2148
|
+
function Vt(t) {
|
|
2135
2149
|
return t.constructor.name === "MessagePort";
|
|
2136
2150
|
}
|
|
2137
|
-
function
|
|
2138
|
-
|
|
2151
|
+
function _e(t) {
|
|
2152
|
+
Vt(t) && t.close();
|
|
2139
2153
|
}
|
|
2140
2154
|
function V(t, e) {
|
|
2141
|
-
return
|
|
2155
|
+
return M(t, [], e);
|
|
2142
2156
|
}
|
|
2143
2157
|
function T(t) {
|
|
2144
2158
|
if (t)
|
|
2145
2159
|
throw new Error("Proxy has been released and is not useable");
|
|
2146
2160
|
}
|
|
2147
|
-
function
|
|
2148
|
-
return
|
|
2161
|
+
function $e(t) {
|
|
2162
|
+
return $(t, {
|
|
2149
2163
|
type: "RELEASE"
|
|
2150
2164
|
}).then(() => {
|
|
2151
|
-
|
|
2165
|
+
_e(t);
|
|
2152
2166
|
});
|
|
2153
2167
|
}
|
|
2154
|
-
const F = /* @__PURE__ */ new WeakMap(),
|
|
2168
|
+
const F = /* @__PURE__ */ new WeakMap(), O = "FinalizationRegistry" in globalThis && new FinalizationRegistry((t) => {
|
|
2155
2169
|
const e = (F.get(t) || 0) - 1;
|
|
2156
|
-
F.set(t, e), e === 0 &&
|
|
2170
|
+
F.set(t, e), e === 0 && $e(t);
|
|
2157
2171
|
});
|
|
2158
|
-
function
|
|
2172
|
+
function Gt(t, e) {
|
|
2159
2173
|
const r = (F.get(e) || 0) + 1;
|
|
2160
|
-
F.set(e, r),
|
|
2174
|
+
F.set(e, r), O && O.register(t, e, t);
|
|
2161
2175
|
}
|
|
2162
|
-
function
|
|
2163
|
-
|
|
2176
|
+
function Jt(t) {
|
|
2177
|
+
O && O.unregister(t);
|
|
2164
2178
|
}
|
|
2165
|
-
function
|
|
2179
|
+
function M(t, e = [], r = function() {
|
|
2166
2180
|
}) {
|
|
2167
2181
|
let s = !1;
|
|
2168
2182
|
const n = new Proxy(r, {
|
|
2169
2183
|
get(i, o) {
|
|
2170
|
-
if (T(s), o ===
|
|
2184
|
+
if (T(s), o === zt)
|
|
2171
2185
|
return () => {
|
|
2172
|
-
|
|
2186
|
+
Jt(n), $e(t), s = !0;
|
|
2173
2187
|
};
|
|
2174
2188
|
if (o === "then") {
|
|
2175
2189
|
if (e.length === 0)
|
|
2176
2190
|
return { then: () => n };
|
|
2177
|
-
const a =
|
|
2191
|
+
const a = $(t, {
|
|
2178
2192
|
type: "GET",
|
|
2179
2193
|
path: e.map((c) => c.toString())
|
|
2180
2194
|
}).then(P);
|
|
2181
2195
|
return a.then.bind(a);
|
|
2182
2196
|
}
|
|
2183
|
-
return
|
|
2197
|
+
return M(t, [...e, o]);
|
|
2184
2198
|
},
|
|
2185
2199
|
set(i, o, a) {
|
|
2186
2200
|
T(s);
|
|
2187
2201
|
const [c, l] = A(a);
|
|
2188
|
-
return
|
|
2202
|
+
return $(t, {
|
|
2189
2203
|
type: "SET",
|
|
2190
2204
|
path: [...e, o].map((u) => u.toString()),
|
|
2191
2205
|
value: c
|
|
@@ -2194,14 +2208,14 @@ function N(t, e = [], r = function() {
|
|
|
2194
2208
|
apply(i, o, a) {
|
|
2195
2209
|
T(s);
|
|
2196
2210
|
const c = e[e.length - 1];
|
|
2197
|
-
if (c ===
|
|
2198
|
-
return
|
|
2211
|
+
if (c === Dt)
|
|
2212
|
+
return $(t, {
|
|
2199
2213
|
type: "ENDPOINT"
|
|
2200
2214
|
}).then(P);
|
|
2201
2215
|
if (c === "bind")
|
|
2202
|
-
return
|
|
2216
|
+
return M(t, e.slice(0, -1));
|
|
2203
2217
|
const [l, u] = ae(a);
|
|
2204
|
-
return
|
|
2218
|
+
return $(t, {
|
|
2205
2219
|
type: "APPLY",
|
|
2206
2220
|
path: e.map((d) => d.toString()),
|
|
2207
2221
|
argumentList: l
|
|
@@ -2210,14 +2224,14 @@ function N(t, e = [], r = function() {
|
|
|
2210
2224
|
construct(i, o) {
|
|
2211
2225
|
T(s);
|
|
2212
2226
|
const [a, c] = ae(o);
|
|
2213
|
-
return
|
|
2227
|
+
return $(t, {
|
|
2214
2228
|
type: "CONSTRUCT",
|
|
2215
2229
|
path: e.map((l) => l.toString()),
|
|
2216
2230
|
argumentList: a
|
|
2217
2231
|
}, c).then(P);
|
|
2218
2232
|
}
|
|
2219
2233
|
});
|
|
2220
|
-
return
|
|
2234
|
+
return Gt(n, t), n;
|
|
2221
2235
|
}
|
|
2222
2236
|
function Yt(t) {
|
|
2223
2237
|
return Array.prototype.concat.apply([], t);
|
|
@@ -2227,13 +2241,13 @@ function ae(t) {
|
|
|
2227
2241
|
return [e.map((r) => r[0]), Yt(e.map((r) => r[1]))];
|
|
2228
2242
|
}
|
|
2229
2243
|
const Ee = /* @__PURE__ */ new WeakMap();
|
|
2230
|
-
function
|
|
2244
|
+
function Kt(t, e) {
|
|
2231
2245
|
return Ee.set(t, e), t;
|
|
2232
2246
|
}
|
|
2233
|
-
function
|
|
2234
|
-
return Object.assign(t, { [
|
|
2247
|
+
function ve(t) {
|
|
2248
|
+
return Object.assign(t, { [Pe]: !0 });
|
|
2235
2249
|
}
|
|
2236
|
-
function
|
|
2250
|
+
function Qt(t, e = globalThis, r = "*") {
|
|
2237
2251
|
return {
|
|
2238
2252
|
postMessage: (s, n) => t.postMessage(s, r, n),
|
|
2239
2253
|
addEventListener: e.addEventListener.bind(e),
|
|
@@ -2269,26 +2283,26 @@ function P(t) {
|
|
|
2269
2283
|
return t.value;
|
|
2270
2284
|
}
|
|
2271
2285
|
}
|
|
2272
|
-
function
|
|
2286
|
+
function $(t, e, r) {
|
|
2273
2287
|
return new Promise((s) => {
|
|
2274
|
-
const n =
|
|
2288
|
+
const n = Xt();
|
|
2275
2289
|
t.addEventListener("message", function i(o) {
|
|
2276
2290
|
!o.data || !o.data.id || o.data.id !== n || (t.removeEventListener("message", i), s(o.data));
|
|
2277
2291
|
}), t.start && t.start(), t.postMessage(Object.assign({ id: n }, e), r);
|
|
2278
2292
|
});
|
|
2279
2293
|
}
|
|
2280
|
-
function
|
|
2294
|
+
function Xt() {
|
|
2281
2295
|
return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
|
|
2282
2296
|
}
|
|
2283
|
-
function
|
|
2284
|
-
|
|
2285
|
-
const e = t instanceof Worker ? t :
|
|
2297
|
+
function Se(t) {
|
|
2298
|
+
Zt();
|
|
2299
|
+
const e = t instanceof Worker ? t : Qt(t), r = V(e), s = Re(r);
|
|
2286
2300
|
return new Proxy(s, {
|
|
2287
2301
|
get: (n, i) => i === "isConnected" ? () => r.isConnected() : r[i]
|
|
2288
2302
|
});
|
|
2289
2303
|
}
|
|
2290
2304
|
let ce = !1;
|
|
2291
|
-
function
|
|
2305
|
+
function Zt() {
|
|
2292
2306
|
ce || (ce = !0, R.set("EVENT", {
|
|
2293
2307
|
canHandle: (t) => t instanceof CustomEvent,
|
|
2294
2308
|
serialize: (t) => [
|
|
@@ -2303,7 +2317,7 @@ function Xt() {
|
|
|
2303
2317
|
serialize(t) {
|
|
2304
2318
|
console.debug("[Comlink][Performance] Proxying a function");
|
|
2305
2319
|
const { port1: e, port2: r } = new MessageChannel();
|
|
2306
|
-
return
|
|
2320
|
+
return B(t, e), [r, [r]];
|
|
2307
2321
|
},
|
|
2308
2322
|
deserialize(t) {
|
|
2309
2323
|
return t.start(), V(t);
|
|
@@ -2314,24 +2328,24 @@ function Xt() {
|
|
|
2314
2328
|
return [t.toRawData(), []];
|
|
2315
2329
|
},
|
|
2316
2330
|
deserialize(t) {
|
|
2317
|
-
return
|
|
2331
|
+
return S.fromRawData(t);
|
|
2318
2332
|
}
|
|
2319
2333
|
}));
|
|
2320
2334
|
}
|
|
2321
|
-
function
|
|
2335
|
+
function Re(t) {
|
|
2322
2336
|
return new Proxy(t, {
|
|
2323
2337
|
get(e, r) {
|
|
2324
2338
|
switch (typeof e[r]) {
|
|
2325
2339
|
case "function":
|
|
2326
2340
|
return (...s) => e[r](...s);
|
|
2327
2341
|
case "object":
|
|
2328
|
-
return e[r] === null ? e[r] :
|
|
2342
|
+
return e[r] === null ? e[r] : Re(e[r]);
|
|
2329
2343
|
case "undefined":
|
|
2330
2344
|
case "number":
|
|
2331
2345
|
case "string":
|
|
2332
2346
|
return e[r];
|
|
2333
2347
|
default:
|
|
2334
|
-
return
|
|
2348
|
+
return ve(e[r]);
|
|
2335
2349
|
}
|
|
2336
2350
|
}
|
|
2337
2351
|
});
|
|
@@ -2339,7 +2353,7 @@ function Se(t) {
|
|
|
2339
2353
|
(function() {
|
|
2340
2354
|
return typeof navigator < "u" && navigator?.userAgent?.toLowerCase().indexOf("firefox") > -1 ? "iframe" : "webworker";
|
|
2341
2355
|
})();
|
|
2342
|
-
async function
|
|
2356
|
+
async function er({
|
|
2343
2357
|
iframe: t,
|
|
2344
2358
|
blueprint: e,
|
|
2345
2359
|
remoteUrl: r,
|
|
@@ -2347,11 +2361,11 @@ async function Zt({
|
|
|
2347
2361
|
disableProgressBar: n,
|
|
2348
2362
|
onBlueprintStepCompleted: i
|
|
2349
2363
|
}) {
|
|
2350
|
-
if (
|
|
2364
|
+
if (tr(r), r = ue(r, {
|
|
2351
2365
|
progressbar: !n
|
|
2352
2366
|
}), s.setCaption("Preparing WordPress"), !e)
|
|
2353
2367
|
return le(t, r, s);
|
|
2354
|
-
const o =
|
|
2368
|
+
const o = Ht(e, {
|
|
2355
2369
|
progress: s.stage(0.5),
|
|
2356
2370
|
onStepCompleted: i
|
|
2357
2371
|
}), a = await le(
|
|
@@ -2362,13 +2376,13 @@ async function Zt({
|
|
|
2362
2376
|
}),
|
|
2363
2377
|
s
|
|
2364
2378
|
);
|
|
2365
|
-
return await
|
|
2379
|
+
return await Wt(o, a), s.finish(), a;
|
|
2366
2380
|
}
|
|
2367
2381
|
async function le(t, e, r) {
|
|
2368
2382
|
await new Promise((i) => {
|
|
2369
2383
|
t.src = e, t.addEventListener("load", i, !1);
|
|
2370
2384
|
});
|
|
2371
|
-
const s =
|
|
2385
|
+
const s = Se(
|
|
2372
2386
|
t.contentWindow
|
|
2373
2387
|
);
|
|
2374
2388
|
await s.isConnected(), r.pipe(s);
|
|
@@ -2376,7 +2390,7 @@ async function le(t, e, r) {
|
|
|
2376
2390
|
return await s.onDownloadProgress(n.loadingListener), await s.isReady(), n.finish(), s;
|
|
2377
2391
|
}
|
|
2378
2392
|
const k = "https://playground.wordpress.net";
|
|
2379
|
-
function
|
|
2393
|
+
function tr(t) {
|
|
2380
2394
|
const e = new URL(t, k);
|
|
2381
2395
|
if ((e.origin === k || e.hostname === "localhost") && e.pathname !== "/remote.html")
|
|
2382
2396
|
throw new Error(
|
|
@@ -2389,51 +2403,52 @@ function ue(t, e) {
|
|
|
2389
2403
|
i != null && i !== !1 && s.set(n, i.toString());
|
|
2390
2404
|
return r.search = s.toString(), r.toString();
|
|
2391
2405
|
}
|
|
2392
|
-
async function
|
|
2406
|
+
async function nr(t, e) {
|
|
2393
2407
|
if (console.warn(
|
|
2394
2408
|
"`connectPlayground` is deprecated and will be removed. Use `startPlayground` instead."
|
|
2395
2409
|
), e?.loadRemote)
|
|
2396
|
-
return
|
|
2410
|
+
return er({
|
|
2397
2411
|
iframe: t,
|
|
2398
2412
|
remoteUrl: e.loadRemote
|
|
2399
2413
|
});
|
|
2400
|
-
const r =
|
|
2414
|
+
const r = Se(
|
|
2401
2415
|
t.contentWindow
|
|
2402
2416
|
);
|
|
2403
2417
|
return await r.isConnected(), r;
|
|
2404
2418
|
}
|
|
2405
2419
|
export {
|
|
2406
|
-
|
|
2420
|
+
it as LatestSupportedPHPVersion,
|
|
2407
2421
|
D as SupportedPHPVersions,
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
Ke as
|
|
2418
|
-
Qe as
|
|
2422
|
+
rr as SupportedPHPVersionsList,
|
|
2423
|
+
ke as activatePlugin,
|
|
2424
|
+
Fe as applyWordPressPatches,
|
|
2425
|
+
Ht as compileBlueprint,
|
|
2426
|
+
nr as connectPlayground,
|
|
2427
|
+
Ie as cp,
|
|
2428
|
+
qe as defineSiteUrl,
|
|
2429
|
+
he as defineWpConfigConsts,
|
|
2430
|
+
Ge as importFile,
|
|
2431
|
+
Ke as installPlugin,
|
|
2432
|
+
Qe as installTheme,
|
|
2433
|
+
Xe as login,
|
|
2419
2434
|
Me as mkdir,
|
|
2420
|
-
|
|
2421
|
-
|
|
2435
|
+
Ne as mv,
|
|
2436
|
+
v as phpVar,
|
|
2422
2437
|
W as phpVars,
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
+
Ve as replaceSite,
|
|
2439
|
+
He as request,
|
|
2440
|
+
We as rm,
|
|
2441
|
+
De as rmdir,
|
|
2442
|
+
Wt as runBlueprintSteps,
|
|
2443
|
+
Ae as runPHP,
|
|
2444
|
+
Le as runPHPWithOptions,
|
|
2445
|
+
Ze as runWpInstallationWizard,
|
|
2446
|
+
Ue as setPhpIniEntry,
|
|
2447
|
+
sr as setPluginProxyURL,
|
|
2448
|
+
et as setSiteOptions,
|
|
2449
|
+
er as startPlaygroundWeb,
|
|
2450
|
+
pe as unzip,
|
|
2451
|
+
tt as updateUserMeta,
|
|
2452
|
+
ze as writeFile,
|
|
2438
2453
|
Be as zipEntireSite
|
|
2439
2454
|
};
|