@wp-playground/client 0.1.34 → 0.1.37
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.cjs +10 -10
- package/index.d.ts +4 -1
- package/index.js +307 -273
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
function T(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
8
|
async function E(t, e, r) {
|
|
9
9
|
await t.writeFile(e, r(await t.readFileAsText(e)));
|
|
10
10
|
}
|
|
11
|
-
async function
|
|
11
|
+
async function be(t) {
|
|
12
12
|
return new Uint8Array(await t.arrayBuffer());
|
|
13
13
|
}
|
|
14
|
-
const
|
|
14
|
+
const _e = async (t, { plugin: e }, r) => {
|
|
15
15
|
r?.tracker.setCaption(`Activating ${e}`);
|
|
16
16
|
const i = T(
|
|
17
17
|
await t.request({
|
|
@@ -23,15 +23,15 @@ const ge = async (t, { plugin: e }, r) => {
|
|
|
23
23
|
await t.request({
|
|
24
24
|
url: "/wp-admin/" + i
|
|
25
25
|
});
|
|
26
|
-
},
|
|
27
|
-
const r = new
|
|
26
|
+
}, $e = async (t, e) => {
|
|
27
|
+
const r = new Se(
|
|
28
28
|
t,
|
|
29
29
|
e.siteUrl,
|
|
30
30
|
e.wordpressPath || "/wordpress"
|
|
31
31
|
);
|
|
32
32
|
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
33
|
};
|
|
34
|
-
class
|
|
34
|
+
class Se {
|
|
35
35
|
constructor(e, r, s) {
|
|
36
36
|
this.php = e, this.scopedSiteUrl = r, this.wordpressPath = s;
|
|
37
37
|
}
|
|
@@ -82,38 +82,39 @@ class Pe {
|
|
|
82
82
|
);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
const
|
|
85
|
+
const ve = async (t, { code: e }) => await t.run({ code: e }), Ee = async (t, { options: e }) => await t.run(e), Re = async (t, { key: e, value: r }) => {
|
|
86
86
|
await t.setPhpIniEntry(e, r);
|
|
87
|
-
},
|
|
87
|
+
}, Te = async (t, { request: e }) => await t.request(e), xe = async (t, { fromPath: e, toPath: r }) => {
|
|
88
88
|
await t.writeFile(
|
|
89
89
|
r,
|
|
90
90
|
await t.readFileAsBuffer(e)
|
|
91
91
|
);
|
|
92
|
-
},
|
|
92
|
+
}, Ce = async (t, { fromPath: e, toPath: r }) => {
|
|
93
93
|
await t.mv(e, r);
|
|
94
|
-
},
|
|
94
|
+
}, Fe = async (t, { path: e }) => {
|
|
95
95
|
await t.mkdir(e);
|
|
96
|
-
},
|
|
96
|
+
}, ke = async (t, { path: e }) => {
|
|
97
97
|
await t.unlink(e);
|
|
98
|
-
},
|
|
98
|
+
}, Oe = async (t, { path: e }) => {
|
|
99
99
|
await t.rmdir(e);
|
|
100
|
-
},
|
|
101
|
-
r instanceof File && (r = await
|
|
102
|
-
},
|
|
100
|
+
}, Ue = async (t, { path: e, data: r }) => {
|
|
101
|
+
r instanceof File && (r = await be(r)), await t.writeFile(e, r);
|
|
102
|
+
}, Le = async (t, { siteUrl: e }) => {
|
|
103
|
+
const r = await t.documentRoot;
|
|
103
104
|
await E(
|
|
104
105
|
t,
|
|
105
|
-
|
|
106
|
-
(
|
|
106
|
+
`${r}/wp-config.php`,
|
|
107
|
+
(s) => `<?php
|
|
107
108
|
if ( ! defined( 'WP_HOME' ) ) {
|
|
108
109
|
define('WP_HOME', "${e}");
|
|
109
110
|
}
|
|
110
111
|
if ( ! defined( 'WP_SITEURL' ) ) {
|
|
111
112
|
define('WP_SITEURL', "${e}");
|
|
112
113
|
}
|
|
113
|
-
?>${
|
|
114
|
+
?>${s}`
|
|
114
115
|
);
|
|
115
116
|
};
|
|
116
|
-
class
|
|
117
|
+
class se {
|
|
117
118
|
constructor({ concurrency: e }) {
|
|
118
119
|
this._running = 0, this.concurrency = e, this.queue = [];
|
|
119
120
|
}
|
|
@@ -138,7 +139,7 @@ class te {
|
|
|
138
139
|
}
|
|
139
140
|
}
|
|
140
141
|
}
|
|
141
|
-
const
|
|
142
|
+
const Ae = Symbol("literal");
|
|
142
143
|
function S(t) {
|
|
143
144
|
if (typeof t == "string")
|
|
144
145
|
return t.startsWith("$") ? t : JSON.stringify(t);
|
|
@@ -149,18 +150,18 @@ function S(t) {
|
|
|
149
150
|
if (t === null)
|
|
150
151
|
return "null";
|
|
151
152
|
if (typeof t == "object")
|
|
152
|
-
return
|
|
153
|
+
return Ae in t ? t.toString() : `array(${Object.entries(t).map(([r, s]) => `${JSON.stringify(r)} => ${S(s)}`).join(", ")})`;
|
|
153
154
|
if (typeof t == "function")
|
|
154
155
|
return t();
|
|
155
156
|
throw new Error(`Unsupported value: ${t}`);
|
|
156
157
|
}
|
|
157
|
-
function
|
|
158
|
+
function D(t) {
|
|
158
159
|
const e = {};
|
|
159
160
|
for (const r in t)
|
|
160
161
|
e[r] = S(t[r]);
|
|
161
162
|
return e;
|
|
162
163
|
}
|
|
163
|
-
const
|
|
164
|
+
const B = `<?php
|
|
164
165
|
|
|
165
166
|
function zipDir($dir, $output, $additionalFiles = array())
|
|
166
167
|
{
|
|
@@ -223,28 +224,28 @@ function delTree($dir)
|
|
|
223
224
|
return rmdir($dir);
|
|
224
225
|
}
|
|
225
226
|
`;
|
|
226
|
-
async function
|
|
227
|
-
const e = "wordpress-playground.zip", r = `/${e}`, s =
|
|
227
|
+
async function He(t) {
|
|
228
|
+
const e = "wordpress-playground.zip", r = `/${e}`, s = D({
|
|
228
229
|
zipPath: r,
|
|
229
230
|
documentRoot: await t.documentRoot
|
|
230
231
|
});
|
|
231
|
-
await
|
|
232
|
+
await ie(
|
|
232
233
|
t,
|
|
233
234
|
`zipDir(${s.documentRoot}, ${s.zipPath});`
|
|
234
235
|
);
|
|
235
236
|
const n = await t.readFileAsBuffer(r);
|
|
236
237
|
return t.unlink(r), new File([n], e);
|
|
237
238
|
}
|
|
238
|
-
const
|
|
239
|
+
const Ie = async (t, { fullSiteZip: e }) => {
|
|
239
240
|
const r = "/import.zip";
|
|
240
241
|
await t.writeFile(
|
|
241
242
|
r,
|
|
242
243
|
new Uint8Array(await e.arrayBuffer())
|
|
243
244
|
);
|
|
244
245
|
const s = await t.absoluteUrl, n = await t.documentRoot;
|
|
245
|
-
await t.rmdir(n), await
|
|
246
|
-
const i =
|
|
247
|
-
await
|
|
246
|
+
await t.rmdir(n), await ne(t, { zipPath: r, extractToPath: "/" });
|
|
247
|
+
const i = D({ absoluteUrl: s });
|
|
248
|
+
await ze(
|
|
248
249
|
t,
|
|
249
250
|
`${n}/wp-config.php`,
|
|
250
251
|
(o) => `<?php
|
|
@@ -254,30 +255,30 @@ const Ue = async (t, { fullSiteZip: e }) => {
|
|
|
254
255
|
}
|
|
255
256
|
?>${o}`
|
|
256
257
|
);
|
|
257
|
-
},
|
|
258
|
-
const s =
|
|
258
|
+
}, ne = async (t, { zipPath: e, extractToPath: r }) => {
|
|
259
|
+
const s = D({
|
|
259
260
|
zipPath: e,
|
|
260
261
|
extractToPath: r
|
|
261
262
|
});
|
|
262
|
-
await
|
|
263
|
+
await ie(
|
|
263
264
|
t,
|
|
264
265
|
`unzip(${s.zipPath}, ${s.extractToPath});`
|
|
265
266
|
);
|
|
266
|
-
},
|
|
267
|
+
}, Ne = async (t, { file: e }) => {
|
|
267
268
|
const r = await t.request({
|
|
268
269
|
url: "/wp-admin/admin.php?import=wordpress"
|
|
269
|
-
}), s =
|
|
270
|
+
}), s = V(r).getElementById("import-upload-form")?.getAttribute("action"), n = await t.request({
|
|
270
271
|
url: `/wp-admin/${s}`,
|
|
271
272
|
method: "POST",
|
|
272
273
|
files: { import: e }
|
|
273
|
-
}), i =
|
|
274
|
+
}), i = V(n).querySelector(
|
|
274
275
|
"#wpbody-content form"
|
|
275
276
|
);
|
|
276
277
|
if (!i)
|
|
277
278
|
throw console.log(n.text), new Error(
|
|
278
279
|
"Could not find an importer form in response. See the response text above for details."
|
|
279
280
|
);
|
|
280
|
-
const o =
|
|
281
|
+
const o = De(i);
|
|
281
282
|
o.fetch_attachments = "1";
|
|
282
283
|
for (const a in o)
|
|
283
284
|
if (a.startsWith("user_map[")) {
|
|
@@ -290,29 +291,29 @@ const Ue = async (t, { fullSiteZip: e }) => {
|
|
|
290
291
|
formData: o
|
|
291
292
|
});
|
|
292
293
|
};
|
|
293
|
-
function
|
|
294
|
+
function V(t) {
|
|
294
295
|
return new DOMParser().parseFromString(t.text, "text/html");
|
|
295
296
|
}
|
|
296
|
-
function
|
|
297
|
+
function De(t) {
|
|
297
298
|
return Object.fromEntries(new FormData(t).entries());
|
|
298
299
|
}
|
|
299
|
-
async function
|
|
300
|
+
async function ze(t, e, r) {
|
|
300
301
|
await t.writeFile(
|
|
301
302
|
e,
|
|
302
303
|
r(await t.readFileAsText(e))
|
|
303
304
|
);
|
|
304
305
|
}
|
|
305
|
-
async function
|
|
306
|
+
async function ie(t, e) {
|
|
306
307
|
const r = await t.run({
|
|
307
|
-
code:
|
|
308
|
+
code: B + e
|
|
308
309
|
});
|
|
309
310
|
if (r.exitCode !== 0)
|
|
310
|
-
throw console.log(
|
|
311
|
+
throw console.log(B + e), console.log(e + ""), console.log(r.errors), r.errors;
|
|
311
312
|
return r;
|
|
312
313
|
}
|
|
313
|
-
const
|
|
314
|
+
const qe = async (t, { pluginZipFile: e, options: r = {} }, s) => {
|
|
314
315
|
s?.tracker.setCaption(
|
|
315
|
-
`Installing the ${
|
|
316
|
+
`Installing the ${L(e?.name)} plugin`
|
|
316
317
|
);
|
|
317
318
|
try {
|
|
318
319
|
const n = "activate" in r ? r.activate : !0, i = await t.request({
|
|
@@ -338,14 +339,14 @@ const Ie = async (t, { pluginZipFile: e, options: r = {} }, s) => {
|
|
|
338
339
|
}
|
|
339
340
|
await t.isDir(
|
|
340
341
|
"/wordpress/wp-content/plugins/gutenberg"
|
|
341
|
-
) && !await t.fileExists("/wordpress/.gutenberg-patched") && (await t.writeFile("/wordpress/.gutenberg-patched", "1"), await
|
|
342
|
+
) && !await t.fileExists("/wordpress/.gutenberg-patched") && (await t.writeFile("/wordpress/.gutenberg-patched", "1"), await G(
|
|
342
343
|
t,
|
|
343
344
|
"/wordpress/wp-content/plugins/gutenberg/build/block-editor/index.js",
|
|
344
345
|
(d) => d.replace(
|
|
345
346
|
/srcDoc:("[^"]+"|[^,]+)/g,
|
|
346
347
|
'src:"/wp-includes/empty.html"'
|
|
347
348
|
)
|
|
348
|
-
), await
|
|
349
|
+
), await G(
|
|
349
350
|
t,
|
|
350
351
|
"/wordpress/wp-content/plugins/gutenberg/build/block-editor/index.min.js",
|
|
351
352
|
(d) => d.replace(
|
|
@@ -359,15 +360,15 @@ const Ie = async (t, { pluginZipFile: e, options: r = {} }, s) => {
|
|
|
359
360
|
), console.error(n);
|
|
360
361
|
}
|
|
361
362
|
};
|
|
362
|
-
async function
|
|
363
|
+
async function G(t, e, r) {
|
|
363
364
|
return await t.writeFile(
|
|
364
365
|
e,
|
|
365
366
|
r(await t.readFileAsText(e))
|
|
366
367
|
);
|
|
367
368
|
}
|
|
368
|
-
const
|
|
369
|
+
const We = async (t, { themeZipFile: e, options: r = {} }, s) => {
|
|
369
370
|
s?.tracker.setCaption(
|
|
370
|
-
`Installing the ${
|
|
371
|
+
`Installing the ${L(e.name)} theme`
|
|
371
372
|
);
|
|
372
373
|
try {
|
|
373
374
|
const n = "activate" in r ? r.activate : !0, i = await t.request({
|
|
@@ -399,12 +400,12 @@ const Ne = async (t, { themeZipFile: e, options: r = {} }, s) => {
|
|
|
399
400
|
console.error('The "activate" button was not found.');
|
|
400
401
|
return;
|
|
401
402
|
}
|
|
402
|
-
const
|
|
403
|
-
|
|
403
|
+
const ye = y.attributes.getNamedItem("href").value, Pe = new URL(
|
|
404
|
+
ye,
|
|
404
405
|
await t.pathToInternalUrl("/wp-admin/")
|
|
405
406
|
).toString();
|
|
406
407
|
await t.request({
|
|
407
|
-
url:
|
|
408
|
+
url: Pe
|
|
408
409
|
});
|
|
409
410
|
}
|
|
410
411
|
} catch (n) {
|
|
@@ -412,7 +413,7 @@ const Ne = async (t, { themeZipFile: e, options: r = {} }, s) => {
|
|
|
412
413
|
`Proceeding without the ${e.name} theme. Could not install it in wp-admin. The original error was: ${n}`
|
|
413
414
|
), console.error(n);
|
|
414
415
|
}
|
|
415
|
-
},
|
|
416
|
+
}, Me = async (t, { username: e = "admin", password: r = "password" } = {}, s) => {
|
|
416
417
|
s?.tracker.setCaption(s?.initialCaption || "Logging in"), await t.request({
|
|
417
418
|
url: "/wp-login.php"
|
|
418
419
|
}), await t.request({
|
|
@@ -424,7 +425,7 @@ const Ne = async (t, { themeZipFile: e, options: r = {} }, s) => {
|
|
|
424
425
|
rememberme: "forever"
|
|
425
426
|
}
|
|
426
427
|
});
|
|
427
|
-
},
|
|
428
|
+
}, je = async (t, { options: e }) => {
|
|
428
429
|
await t.request({
|
|
429
430
|
url: "/wp-admin/install.php?step=2",
|
|
430
431
|
method: "POST",
|
|
@@ -441,7 +442,7 @@ const Ne = async (t, { themeZipFile: e, options: r = {} }, s) => {
|
|
|
441
442
|
admin_email: "admin@localhost.com"
|
|
442
443
|
}
|
|
443
444
|
});
|
|
444
|
-
},
|
|
445
|
+
}, Be = async (t, { options: e }) => {
|
|
445
446
|
const r = `<?php
|
|
446
447
|
include 'wordpress/wp-load.php';
|
|
447
448
|
$site_options = ${S(e)};
|
|
@@ -452,8 +453,8 @@ const Ne = async (t, { themeZipFile: e, options: r = {} }, s) => {
|
|
|
452
453
|
`, s = await t.run({
|
|
453
454
|
code: r
|
|
454
455
|
});
|
|
455
|
-
return
|
|
456
|
-
},
|
|
456
|
+
return oe(s), { code: r, result: s };
|
|
457
|
+
}, Ve = async (t, { meta: e, userId: r }) => {
|
|
457
458
|
const s = `<?php
|
|
458
459
|
include 'wordpress/wp-load.php';
|
|
459
460
|
$meta = ${S(e)};
|
|
@@ -464,40 +465,40 @@ const Ne = async (t, { themeZipFile: e, options: r = {} }, s) => {
|
|
|
464
465
|
`, n = await t.run({
|
|
465
466
|
code: s
|
|
466
467
|
});
|
|
467
|
-
return
|
|
468
|
+
return oe(n), { code: s, result: n };
|
|
468
469
|
};
|
|
469
|
-
async function
|
|
470
|
+
async function oe(t) {
|
|
470
471
|
if (t.text !== "Success")
|
|
471
472
|
throw console.log(t), new Error(`Failed to run code: ${t.text} ${t.errors}`);
|
|
472
473
|
}
|
|
473
|
-
const
|
|
474
|
+
const Ge = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
474
475
|
__proto__: null,
|
|
475
|
-
activatePlugin:
|
|
476
|
-
applyWordPressPatches:
|
|
477
|
-
cp:
|
|
478
|
-
defineSiteUrl:
|
|
479
|
-
importFile:
|
|
480
|
-
installPlugin:
|
|
481
|
-
installTheme:
|
|
482
|
-
login:
|
|
483
|
-
mkdir:
|
|
484
|
-
mv:
|
|
485
|
-
replaceSite:
|
|
486
|
-
request:
|
|
487
|
-
rm:
|
|
488
|
-
rmdir:
|
|
489
|
-
runPHP:
|
|
490
|
-
runPHPWithOptions:
|
|
491
|
-
runWpInstallationWizard:
|
|
492
|
-
setPhpIniEntry:
|
|
493
|
-
setSiteOptions:
|
|
494
|
-
unzip:
|
|
495
|
-
updateUserMeta:
|
|
496
|
-
writeFile:
|
|
497
|
-
zipEntireSite:
|
|
498
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
499
|
-
function
|
|
500
|
-
const r = t.headers.get("content-length") || "", s = parseInt(r, 10) ||
|
|
476
|
+
activatePlugin: _e,
|
|
477
|
+
applyWordPressPatches: $e,
|
|
478
|
+
cp: xe,
|
|
479
|
+
defineSiteUrl: Le,
|
|
480
|
+
importFile: Ne,
|
|
481
|
+
installPlugin: qe,
|
|
482
|
+
installTheme: We,
|
|
483
|
+
login: Me,
|
|
484
|
+
mkdir: Fe,
|
|
485
|
+
mv: Ce,
|
|
486
|
+
replaceSite: Ie,
|
|
487
|
+
request: Te,
|
|
488
|
+
rm: ke,
|
|
489
|
+
rmdir: Oe,
|
|
490
|
+
runPHP: ve,
|
|
491
|
+
runPHPWithOptions: Ee,
|
|
492
|
+
runWpInstallationWizard: je,
|
|
493
|
+
setPhpIniEntry: Re,
|
|
494
|
+
setSiteOptions: Be,
|
|
495
|
+
unzip: ne,
|
|
496
|
+
updateUserMeta: Ve,
|
|
497
|
+
writeFile: Ue,
|
|
498
|
+
zipEntireSite: He
|
|
499
|
+
}, Symbol.toStringTag, { value: "Module" })), Je = 5 * 1024 * 1024;
|
|
500
|
+
function Ke(t, e) {
|
|
501
|
+
const r = t.headers.get("content-length") || "", s = parseInt(r, 10) || Je;
|
|
501
502
|
function n(i, o) {
|
|
502
503
|
e(
|
|
503
504
|
new CustomEvent("progress", {
|
|
@@ -539,13 +540,13 @@ function Be(t, e) {
|
|
|
539
540
|
);
|
|
540
541
|
}
|
|
541
542
|
const H = 1e-5;
|
|
542
|
-
class
|
|
543
|
+
class A extends EventTarget {
|
|
543
544
|
constructor({
|
|
544
545
|
weight: e = 1,
|
|
545
546
|
caption: r = "",
|
|
546
547
|
fillTime: s = 4
|
|
547
548
|
} = {}) {
|
|
548
|
-
super(), this._selfWeight = 1, this._selfProgress = 0, this._selfCaption = "", this._isFilling = !1, this._subTrackers = [], this._weight = e, this._selfCaption = r, this._fillTime = s;
|
|
549
|
+
super(), this._selfWeight = 1, this._selfDone = !1, this._selfProgress = 0, this._selfCaption = "", this._isFilling = !1, this._subTrackers = [], this._weight = e, this._selfCaption = r, this._fillTime = s;
|
|
549
550
|
}
|
|
550
551
|
/**
|
|
551
552
|
* Creates a new sub-tracker with a specific weight.
|
|
@@ -588,7 +589,7 @@ class L extends EventTarget {
|
|
|
588
589
|
`Cannot add a stage with weight ${e} as the total weight of registered stages would exceed 1.`
|
|
589
590
|
);
|
|
590
591
|
this._selfWeight -= e;
|
|
591
|
-
const s = new
|
|
592
|
+
const s = new A({
|
|
592
593
|
caption: r,
|
|
593
594
|
weight: e,
|
|
594
595
|
fillTime: this._fillTime
|
|
@@ -628,7 +629,7 @@ class L extends EventTarget {
|
|
|
628
629
|
this._selfProgress = Math.min(e, 100), this.notifyProgress(), this._selfProgress + H >= 100 && this.finish();
|
|
629
630
|
}
|
|
630
631
|
finish() {
|
|
631
|
-
this._fillInterval && clearInterval(this._fillInterval), this._selfProgress = 100, this._isFilling = !1, this._fillInterval = void 0, this.notifyProgress(), this.notifyDone();
|
|
632
|
+
this._fillInterval && clearInterval(this._fillInterval), this._selfDone = !0, this._selfProgress = 100, this._isFilling = !1, this._fillInterval = void 0, this.notifyProgress(), this.notifyDone();
|
|
632
633
|
}
|
|
633
634
|
get caption() {
|
|
634
635
|
for (let e = this._subTrackers.length - 1; e >= 0; e--)
|
|
@@ -646,6 +647,8 @@ class L extends EventTarget {
|
|
|
646
647
|
return this.progress + H >= 100;
|
|
647
648
|
}
|
|
648
649
|
get progress() {
|
|
650
|
+
if (this._selfDone)
|
|
651
|
+
return 100;
|
|
649
652
|
const e = this._subTrackers.reduce(
|
|
650
653
|
(r, s) => r + s.progress * s.weight,
|
|
651
654
|
this._selfProgress * this._selfWeight
|
|
@@ -666,7 +669,10 @@ class L extends EventTarget {
|
|
|
666
669
|
}), this._loadingListener;
|
|
667
670
|
}
|
|
668
671
|
pipe(e) {
|
|
669
|
-
|
|
672
|
+
e.setProgress({
|
|
673
|
+
progress: this.progress,
|
|
674
|
+
caption: this.caption
|
|
675
|
+
}), this.addEventListener("progress", (r) => {
|
|
670
676
|
e.setProgress({
|
|
671
677
|
progress: r.detail.progress,
|
|
672
678
|
caption: r.detail.caption
|
|
@@ -735,7 +741,7 @@ class v {
|
|
|
735
741
|
return new TextDecoder().decode(this.bytes);
|
|
736
742
|
}
|
|
737
743
|
}
|
|
738
|
-
const
|
|
744
|
+
const z = [
|
|
739
745
|
"8.2",
|
|
740
746
|
"8.1",
|
|
741
747
|
"8.0",
|
|
@@ -745,8 +751,8 @@ const D = [
|
|
|
745
751
|
"7.1",
|
|
746
752
|
"7.0",
|
|
747
753
|
"5.6"
|
|
748
|
-
],
|
|
749
|
-
class
|
|
754
|
+
], Ye = z[0], Nt = z;
|
|
755
|
+
class Qe {
|
|
750
756
|
#e;
|
|
751
757
|
#t;
|
|
752
758
|
/**
|
|
@@ -832,17 +838,17 @@ class Ge {
|
|
|
832
838
|
return e.join("; ");
|
|
833
839
|
}
|
|
834
840
|
}
|
|
835
|
-
const
|
|
836
|
-
function
|
|
841
|
+
const Xe = "http://example.com";
|
|
842
|
+
function J(t) {
|
|
837
843
|
return t.toString().substring(t.origin.length);
|
|
838
844
|
}
|
|
839
|
-
function
|
|
845
|
+
function K(t, e) {
|
|
840
846
|
return !e || !t.startsWith(e) ? t : t.substring(e.length);
|
|
841
847
|
}
|
|
842
|
-
function
|
|
848
|
+
function Ze(t, e) {
|
|
843
849
|
return !e || t.startsWith(e) ? t : e + t;
|
|
844
850
|
}
|
|
845
|
-
class
|
|
851
|
+
class et {
|
|
846
852
|
#e;
|
|
847
853
|
#t;
|
|
848
854
|
#n;
|
|
@@ -857,7 +863,7 @@ class Ye {
|
|
|
857
863
|
* @param config - Request Handler configuration.
|
|
858
864
|
*/
|
|
859
865
|
constructor(e, r = {}) {
|
|
860
|
-
this.#a = new
|
|
866
|
+
this.#a = new se({ concurrency: 1 });
|
|
861
867
|
const {
|
|
862
868
|
documentRoot: s = "/www/",
|
|
863
869
|
absoluteUrl: n = typeof location == "object" ? location?.href : "",
|
|
@@ -883,7 +889,7 @@ class Ye {
|
|
|
883
889
|
/** @inheritDoc */
|
|
884
890
|
internalUrlToPath(e) {
|
|
885
891
|
const r = new URL(e);
|
|
886
|
-
return r.pathname.startsWith(this.#r) && (r.pathname = r.pathname.slice(this.#r.length)),
|
|
892
|
+
return r.pathname.startsWith(this.#r) && (r.pathname = r.pathname.slice(this.#r.length)), J(r);
|
|
887
893
|
}
|
|
888
894
|
get isRequestRunning() {
|
|
889
895
|
return this.#a.running > 0;
|
|
@@ -900,8 +906,8 @@ class Ye {
|
|
|
900
906
|
async request(e) {
|
|
901
907
|
const r = e.url.startsWith("http://") || e.url.startsWith("https://"), s = new URL(
|
|
902
908
|
e.url,
|
|
903
|
-
r ? void 0 :
|
|
904
|
-
), n =
|
|
909
|
+
r ? void 0 : Xe
|
|
910
|
+
), n = K(
|
|
905
911
|
s.pathname,
|
|
906
912
|
this.#r
|
|
907
913
|
);
|
|
@@ -929,7 +935,7 @@ class Ye {
|
|
|
929
935
|
// @TODO: Infer the content-type from the arrayBuffer instead of the file path.
|
|
930
936
|
// The code below won't return the correct mime-type if the extension
|
|
931
937
|
// was tampered with.
|
|
932
|
-
"content-type": [
|
|
938
|
+
"content-type": [rt(r)],
|
|
933
939
|
"accept-ranges": ["bytes"],
|
|
934
940
|
"cache-control": ["public, max-age=0"]
|
|
935
941
|
},
|
|
@@ -953,7 +959,7 @@ class Ye {
|
|
|
953
959
|
let n = "GET";
|
|
954
960
|
const i = {
|
|
955
961
|
host: this.#i,
|
|
956
|
-
...
|
|
962
|
+
...ae(e.headers || {})
|
|
957
963
|
}, o = [];
|
|
958
964
|
if (e.files && Object.keys(e.files).length) {
|
|
959
965
|
n = "POST";
|
|
@@ -966,7 +972,7 @@ class Ye {
|
|
|
966
972
|
data: new Uint8Array(await c.arrayBuffer())
|
|
967
973
|
});
|
|
968
974
|
}
|
|
969
|
-
i["content-type"]?.startsWith("multipart/form-data") && (e.formData =
|
|
975
|
+
i["content-type"]?.startsWith("multipart/form-data") && (e.formData = tt(
|
|
970
976
|
e.body || ""
|
|
971
977
|
), i["content-type"] = "application/x-www-form-urlencoded", delete e.body);
|
|
972
978
|
}
|
|
@@ -974,8 +980,8 @@ class Ye {
|
|
|
974
980
|
return e.formData !== void 0 ? (n = "POST", i["content-type"] = i["content-type"] || "application/x-www-form-urlencoded", a = new URLSearchParams(
|
|
975
981
|
e.formData
|
|
976
982
|
).toString()) : a = e.body, await this.php.run({
|
|
977
|
-
relativeUri:
|
|
978
|
-
|
|
983
|
+
relativeUri: Ze(
|
|
984
|
+
J(r),
|
|
979
985
|
this.#r
|
|
980
986
|
),
|
|
981
987
|
protocol: this.#t,
|
|
@@ -998,13 +1004,13 @@ class Ye {
|
|
|
998
1004
|
* @returns The resolved filesystem path.
|
|
999
1005
|
*/
|
|
1000
1006
|
#h(e) {
|
|
1001
|
-
let r =
|
|
1007
|
+
let r = K(e, this.#r);
|
|
1002
1008
|
r.includes(".php") ? r = r.split(".php")[0] + ".php" : (r.endsWith("/") || (r += "/"), r.endsWith("index.php") || (r += "index.php"));
|
|
1003
1009
|
const s = `${this.#e}${r}`;
|
|
1004
1010
|
return this.php.fileExists(s) ? s : `${this.#e}/index.php`;
|
|
1005
1011
|
}
|
|
1006
1012
|
}
|
|
1007
|
-
function
|
|
1013
|
+
function tt(t) {
|
|
1008
1014
|
const e = {}, r = t.match(/--(.*)\r\n/);
|
|
1009
1015
|
if (!r)
|
|
1010
1016
|
return e;
|
|
@@ -1019,7 +1025,7 @@ function Qe(t) {
|
|
|
1019
1025
|
}
|
|
1020
1026
|
}), e;
|
|
1021
1027
|
}
|
|
1022
|
-
function
|
|
1028
|
+
function rt(t) {
|
|
1023
1029
|
switch (t.split(".").pop()) {
|
|
1024
1030
|
case "css":
|
|
1025
1031
|
return "text/css";
|
|
@@ -1059,7 +1065,7 @@ function Xe(t) {
|
|
|
1059
1065
|
return "application-octet-stream";
|
|
1060
1066
|
}
|
|
1061
1067
|
}
|
|
1062
|
-
const
|
|
1068
|
+
const Y = {
|
|
1063
1069
|
0: "No error occurred. System call completed successfully.",
|
|
1064
1070
|
1: "Argument list too long.",
|
|
1065
1071
|
2: "Permission denied.",
|
|
@@ -1146,8 +1152,8 @@ function m(t = "") {
|
|
|
1146
1152
|
return i.apply(this, o);
|
|
1147
1153
|
} catch (a) {
|
|
1148
1154
|
const l = typeof a == "object" ? a?.errno : null;
|
|
1149
|
-
if (l in
|
|
1150
|
-
const c =
|
|
1155
|
+
if (l in Y) {
|
|
1156
|
+
const c = Y[l], u = typeof o[0] == "string" ? o[0] : null, d = u !== null ? t.replaceAll("{path}", u) : t;
|
|
1151
1157
|
throw new Error(`${d}: ${c}`, {
|
|
1152
1158
|
cause: a
|
|
1153
1159
|
});
|
|
@@ -1157,17 +1163,17 @@ function m(t = "") {
|
|
|
1157
1163
|
};
|
|
1158
1164
|
};
|
|
1159
1165
|
}
|
|
1160
|
-
const
|
|
1161
|
-
function
|
|
1162
|
-
return
|
|
1166
|
+
const st = [];
|
|
1167
|
+
function nt(t) {
|
|
1168
|
+
return st[t];
|
|
1163
1169
|
}
|
|
1164
1170
|
(function() {
|
|
1165
1171
|
return typeof window < "u" && !{}.TEST ? "WEB" : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? "WORKER" : "NODE";
|
|
1166
1172
|
})();
|
|
1167
|
-
var
|
|
1168
|
-
for (var n = s > 1 ? void 0 : s ?
|
|
1173
|
+
var it = Object.defineProperty, ot = Object.getOwnPropertyDescriptor, w = (t, e, r, s) => {
|
|
1174
|
+
for (var n = s > 1 ? void 0 : s ? ot(e, r) : e, i = t.length - 1, o; i >= 0; i--)
|
|
1169
1175
|
(o = t[i]) && (n = (s ? o(e, r, n) : o(n)) || n);
|
|
1170
|
-
return s && n &&
|
|
1176
|
+
return s && n && it(e, r, n), n;
|
|
1171
1177
|
};
|
|
1172
1178
|
const f = "string", _ = "number", h = Symbol("__private__dont__use");
|
|
1173
1179
|
class g {
|
|
@@ -1179,8 +1185,8 @@ class g {
|
|
|
1179
1185
|
* @param serverOptions - Optional. Options for the PHPRequestHandler. If undefined, no request handler will be initialized.
|
|
1180
1186
|
*/
|
|
1181
1187
|
constructor(e, r) {
|
|
1182
|
-
this.#e = [], this.#t = !1, e !== void 0 && this.initializeRuntime(e), r && (this.requestHandler = new
|
|
1183
|
-
new
|
|
1188
|
+
this.#e = [], this.#t = !1, e !== void 0 && this.initializeRuntime(e), r && (this.requestHandler = new Qe(
|
|
1189
|
+
new et(this, r)
|
|
1184
1190
|
));
|
|
1185
1191
|
}
|
|
1186
1192
|
#e;
|
|
@@ -1191,7 +1197,7 @@ class g {
|
|
|
1191
1197
|
}
|
|
1192
1198
|
/** @inheritDoc */
|
|
1193
1199
|
get documentRoot() {
|
|
1194
|
-
return this.requestHandler.requestHandler.
|
|
1200
|
+
return this.requestHandler.requestHandler.documentRoot;
|
|
1195
1201
|
}
|
|
1196
1202
|
/** @inheritDoc */
|
|
1197
1203
|
pathToInternalUrl(e) {
|
|
@@ -1206,7 +1212,7 @@ class g {
|
|
|
1206
1212
|
initializeRuntime(e) {
|
|
1207
1213
|
if (this[h])
|
|
1208
1214
|
throw new Error("PHP runtime already initialized.");
|
|
1209
|
-
const r =
|
|
1215
|
+
const r = nt(e);
|
|
1210
1216
|
if (!r)
|
|
1211
1217
|
throw new Error("Invalid PHP runtime id.");
|
|
1212
1218
|
this[h] = r;
|
|
@@ -1243,7 +1249,7 @@ class g {
|
|
|
1243
1249
|
this.#t || (this.#n(), this.#t = !0), this.#l(e.scriptPath || ""), this.#i(e.relativeUri || ""), this.#o(e.method || "GET");
|
|
1244
1250
|
const { host: r, ...s } = {
|
|
1245
1251
|
host: "example.com:443",
|
|
1246
|
-
...
|
|
1252
|
+
...ae(e.headers || {})
|
|
1247
1253
|
};
|
|
1248
1254
|
if (this.#r(r, e.protocol || "http"), this.#a(s), e.body && this.#c(e.body), e.fileInfos)
|
|
1249
1255
|
for (const n of e.fileInfos)
|
|
@@ -1505,21 +1511,21 @@ w([
|
|
|
1505
1511
|
w([
|
|
1506
1512
|
m('Could not stat "{path}"')
|
|
1507
1513
|
], g.prototype, "fileExists", 1);
|
|
1508
|
-
function
|
|
1514
|
+
function ae(t) {
|
|
1509
1515
|
const e = {};
|
|
1510
1516
|
for (const r in t)
|
|
1511
1517
|
e[r.toLowerCase()] = t[r];
|
|
1512
1518
|
return e;
|
|
1513
1519
|
}
|
|
1514
|
-
const
|
|
1520
|
+
const at = [
|
|
1515
1521
|
"vfs",
|
|
1516
1522
|
"literal",
|
|
1517
1523
|
"wordpress.org/themes",
|
|
1518
1524
|
"wordpress.org/plugins",
|
|
1519
1525
|
"url"
|
|
1520
1526
|
];
|
|
1521
|
-
function
|
|
1522
|
-
return t && typeof t == "object" && typeof t.resource == "string" &&
|
|
1527
|
+
function ct(t) {
|
|
1528
|
+
return t && typeof t == "object" && typeof t.resource == "string" && at.includes(t.resource);
|
|
1523
1529
|
}
|
|
1524
1530
|
class b {
|
|
1525
1531
|
/**
|
|
@@ -1533,24 +1539,24 @@ class b {
|
|
|
1533
1539
|
let n;
|
|
1534
1540
|
switch (e.resource) {
|
|
1535
1541
|
case "vfs":
|
|
1536
|
-
n = new
|
|
1542
|
+
n = new lt(e, s);
|
|
1537
1543
|
break;
|
|
1538
1544
|
case "literal":
|
|
1539
|
-
n = new
|
|
1545
|
+
n = new ut(e, s);
|
|
1540
1546
|
break;
|
|
1541
1547
|
case "wordpress.org/themes":
|
|
1542
|
-
n = new
|
|
1548
|
+
n = new pt(e, s);
|
|
1543
1549
|
break;
|
|
1544
1550
|
case "wordpress.org/plugins":
|
|
1545
|
-
n = new
|
|
1551
|
+
n = new ft(e, s);
|
|
1546
1552
|
break;
|
|
1547
1553
|
case "url":
|
|
1548
|
-
n = new
|
|
1554
|
+
n = new dt(e, s);
|
|
1549
1555
|
break;
|
|
1550
1556
|
default:
|
|
1551
1557
|
throw new Error(`Invalid resource: ${e}`);
|
|
1552
1558
|
}
|
|
1553
|
-
return n = new
|
|
1559
|
+
return n = new mt(n), r && (n = new wt(n, r)), n;
|
|
1554
1560
|
}
|
|
1555
1561
|
setPlayground(e) {
|
|
1556
1562
|
this.playground = e;
|
|
@@ -1560,7 +1566,7 @@ class b {
|
|
|
1560
1566
|
return !1;
|
|
1561
1567
|
}
|
|
1562
1568
|
}
|
|
1563
|
-
class
|
|
1569
|
+
class lt extends b {
|
|
1564
1570
|
/**
|
|
1565
1571
|
* Creates a new instance of `VFSResource`.
|
|
1566
1572
|
* @param playground The playground client.
|
|
@@ -1582,7 +1588,7 @@ class it extends b {
|
|
|
1582
1588
|
return this.resource.path;
|
|
1583
1589
|
}
|
|
1584
1590
|
}
|
|
1585
|
-
class
|
|
1591
|
+
class ut extends b {
|
|
1586
1592
|
/**
|
|
1587
1593
|
* Creates a new instance of `LiteralResource`.
|
|
1588
1594
|
* @param resource The literal reference.
|
|
@@ -1613,9 +1619,9 @@ class q extends b {
|
|
|
1613
1619
|
this.progress?.setCaption(this.caption);
|
|
1614
1620
|
const e = this.getURL();
|
|
1615
1621
|
let r = await fetch(e);
|
|
1616
|
-
if (r = await
|
|
1622
|
+
if (r = await Ke(
|
|
1617
1623
|
r,
|
|
1618
|
-
this.progress?.loadingListener ??
|
|
1624
|
+
this.progress?.loadingListener ?? ht
|
|
1619
1625
|
), r.status !== 200)
|
|
1620
1626
|
throw new Error(`Could not download "${e}"`);
|
|
1621
1627
|
return new File([await r.blob()], this.name);
|
|
@@ -1636,9 +1642,9 @@ class q extends b {
|
|
|
1636
1642
|
return !0;
|
|
1637
1643
|
}
|
|
1638
1644
|
}
|
|
1639
|
-
const
|
|
1645
|
+
const ht = () => {
|
|
1640
1646
|
};
|
|
1641
|
-
class
|
|
1647
|
+
class dt extends q {
|
|
1642
1648
|
/**
|
|
1643
1649
|
* Creates a new instance of `UrlResource`.
|
|
1644
1650
|
* @param resource The URL reference.
|
|
@@ -1656,34 +1662,40 @@ class ct extends q {
|
|
|
1656
1662
|
return this.resource.caption ?? super.caption;
|
|
1657
1663
|
}
|
|
1658
1664
|
}
|
|
1659
|
-
|
|
1665
|
+
let W = "/plugin-proxy";
|
|
1666
|
+
function Dt(t) {
|
|
1667
|
+
W = t;
|
|
1668
|
+
}
|
|
1669
|
+
class pt extends q {
|
|
1660
1670
|
constructor(e, r) {
|
|
1661
1671
|
super(r), this.resource = e;
|
|
1662
1672
|
}
|
|
1663
1673
|
get name() {
|
|
1664
|
-
return
|
|
1674
|
+
return L(this.resource.slug);
|
|
1665
1675
|
}
|
|
1666
1676
|
getURL() {
|
|
1667
|
-
|
|
1677
|
+
const e = ce(this.resource.slug);
|
|
1678
|
+
return `${W}?theme=` + e;
|
|
1668
1679
|
}
|
|
1669
1680
|
}
|
|
1670
|
-
class
|
|
1681
|
+
class ft extends q {
|
|
1671
1682
|
constructor(e, r) {
|
|
1672
1683
|
super(r), this.resource = e;
|
|
1673
1684
|
}
|
|
1674
1685
|
/** @inheritDoc */
|
|
1675
1686
|
get name() {
|
|
1676
|
-
return
|
|
1687
|
+
return L(this.resource.slug);
|
|
1677
1688
|
}
|
|
1678
1689
|
/** @inheritDoc */
|
|
1679
1690
|
getURL() {
|
|
1680
|
-
|
|
1691
|
+
const e = ce(this.resource.slug);
|
|
1692
|
+
return `${W}?plugin=` + e;
|
|
1681
1693
|
}
|
|
1682
1694
|
}
|
|
1683
|
-
function
|
|
1695
|
+
function ce(t) {
|
|
1684
1696
|
return !t || t.endsWith(".zip") ? t : t + ".latest-stable.zip";
|
|
1685
1697
|
}
|
|
1686
|
-
class
|
|
1698
|
+
class le extends b {
|
|
1687
1699
|
constructor(e) {
|
|
1688
1700
|
super(), this.resource = e;
|
|
1689
1701
|
}
|
|
@@ -1712,13 +1724,13 @@ class ae extends b {
|
|
|
1712
1724
|
return this.resource.isAsync;
|
|
1713
1725
|
}
|
|
1714
1726
|
}
|
|
1715
|
-
class
|
|
1727
|
+
class mt extends le {
|
|
1716
1728
|
/** @inheritDoc */
|
|
1717
1729
|
async resolve() {
|
|
1718
1730
|
return this.promise || (this.promise = super.resolve()), this.promise;
|
|
1719
1731
|
}
|
|
1720
1732
|
}
|
|
1721
|
-
class
|
|
1733
|
+
class wt extends le {
|
|
1722
1734
|
constructor(e, r) {
|
|
1723
1735
|
super(e), this.semaphore = r;
|
|
1724
1736
|
}
|
|
@@ -1727,18 +1739,18 @@ class dt extends ae {
|
|
|
1727
1739
|
return this.isAsync ? this.semaphore.run(() => super.resolve()) : super.resolve();
|
|
1728
1740
|
}
|
|
1729
1741
|
}
|
|
1730
|
-
const
|
|
1731
|
-
function
|
|
1732
|
-
progress: e = new
|
|
1733
|
-
semaphore: r = new
|
|
1742
|
+
const gt = ["6.2", "6.1", "6.0", "5.9"];
|
|
1743
|
+
function yt(t, {
|
|
1744
|
+
progress: e = new A(),
|
|
1745
|
+
semaphore: r = new se({ concurrency: 3 }),
|
|
1734
1746
|
onStepCompleted: s = () => {
|
|
1735
1747
|
}
|
|
1736
1748
|
} = {}) {
|
|
1737
|
-
const n = (t.steps || []).filter(
|
|
1749
|
+
const n = (t.steps || []).filter(Pt), i = n.reduce(
|
|
1738
1750
|
(a, l) => a + (l.progress?.weight || 1),
|
|
1739
1751
|
0
|
|
1740
1752
|
), o = n.map(
|
|
1741
|
-
(a) =>
|
|
1753
|
+
(a) => bt(a, {
|
|
1742
1754
|
semaphore: r,
|
|
1743
1755
|
rootProgressTracker: e,
|
|
1744
1756
|
totalProgressWeight: i
|
|
@@ -1746,14 +1758,14 @@ function ft(t, {
|
|
|
1746
1758
|
);
|
|
1747
1759
|
return {
|
|
1748
1760
|
versions: {
|
|
1749
|
-
php:
|
|
1761
|
+
php: Q(
|
|
1750
1762
|
t.preferredVersions?.php,
|
|
1751
|
-
|
|
1752
|
-
|
|
1763
|
+
z,
|
|
1764
|
+
Ye
|
|
1753
1765
|
),
|
|
1754
|
-
wp:
|
|
1766
|
+
wp: Q(
|
|
1755
1767
|
t.preferredVersions?.wp,
|
|
1756
|
-
|
|
1768
|
+
gt,
|
|
1757
1769
|
"6.2"
|
|
1758
1770
|
)
|
|
1759
1771
|
},
|
|
@@ -1778,13 +1790,13 @@ function ft(t, {
|
|
|
1778
1790
|
}
|
|
1779
1791
|
};
|
|
1780
1792
|
}
|
|
1781
|
-
function
|
|
1793
|
+
function Q(t, e, r) {
|
|
1782
1794
|
return t && e.includes(t) ? t : r;
|
|
1783
1795
|
}
|
|
1784
|
-
function
|
|
1796
|
+
function Pt(t) {
|
|
1785
1797
|
return !!(typeof t == "object" && t);
|
|
1786
1798
|
}
|
|
1787
|
-
function
|
|
1799
|
+
function bt(t, {
|
|
1788
1800
|
semaphore: e,
|
|
1789
1801
|
rootProgressTracker: r,
|
|
1790
1802
|
totalProgressWeight: s
|
|
@@ -1794,15 +1806,15 @@ function wt(t, {
|
|
|
1794
1806
|
), i = {};
|
|
1795
1807
|
for (const u of Object.keys(t)) {
|
|
1796
1808
|
let d = t[u];
|
|
1797
|
-
|
|
1809
|
+
ct(d) && (d = b.create(d, {
|
|
1798
1810
|
semaphore: e
|
|
1799
1811
|
})), i[u] = d;
|
|
1800
1812
|
}
|
|
1801
1813
|
const o = async (u) => {
|
|
1802
1814
|
try {
|
|
1803
|
-
return n.fillSlowly(), await
|
|
1815
|
+
return n.fillSlowly(), await Ge[t.step](
|
|
1804
1816
|
u,
|
|
1805
|
-
await
|
|
1817
|
+
await _t(i),
|
|
1806
1818
|
{
|
|
1807
1819
|
tracker: n,
|
|
1808
1820
|
initialCaption: t.progress?.caption
|
|
@@ -1811,14 +1823,14 @@ function wt(t, {
|
|
|
1811
1823
|
} finally {
|
|
1812
1824
|
n.finish();
|
|
1813
1825
|
}
|
|
1814
|
-
}, a =
|
|
1826
|
+
}, a = X(i), l = X(i).filter(
|
|
1815
1827
|
(u) => u.isAsync
|
|
1816
1828
|
), c = 1 / (l.length + 1);
|
|
1817
1829
|
for (const u of l)
|
|
1818
1830
|
u.progress = n.stage(c);
|
|
1819
1831
|
return { run: o, step: t, resources: a };
|
|
1820
1832
|
}
|
|
1821
|
-
function
|
|
1833
|
+
function X(t) {
|
|
1822
1834
|
const e = [];
|
|
1823
1835
|
for (const r in t) {
|
|
1824
1836
|
const s = t[r];
|
|
@@ -1826,7 +1838,7 @@ function Q(t) {
|
|
|
1826
1838
|
}
|
|
1827
1839
|
return e;
|
|
1828
1840
|
}
|
|
1829
|
-
async function
|
|
1841
|
+
async function _t(t) {
|
|
1830
1842
|
const e = {};
|
|
1831
1843
|
for (const r in t) {
|
|
1832
1844
|
const s = t[r];
|
|
@@ -1834,7 +1846,7 @@ async function gt(t) {
|
|
|
1834
1846
|
}
|
|
1835
1847
|
return e;
|
|
1836
1848
|
}
|
|
1837
|
-
async function
|
|
1849
|
+
async function $t(t, e) {
|
|
1838
1850
|
await t.run(e);
|
|
1839
1851
|
}
|
|
1840
1852
|
/**
|
|
@@ -1842,17 +1854,17 @@ async function yt(t, e) {
|
|
|
1842
1854
|
* Copyright 2019 Google LLC
|
|
1843
1855
|
* SPDX-License-Identifier: Apache-2.0
|
|
1844
1856
|
*/
|
|
1845
|
-
const
|
|
1846
|
-
canHandle: (t) =>
|
|
1857
|
+
const ue = Symbol("Comlink.proxy"), St = Symbol("Comlink.endpoint"), vt = Symbol("Comlink.releaseProxy"), I = Symbol("Comlink.finalizer"), C = Symbol("Comlink.thrown"), he = (t) => typeof t == "object" && t !== null || typeof t == "function", Et = {
|
|
1858
|
+
canHandle: (t) => he(t) && t[ue],
|
|
1847
1859
|
serialize(t) {
|
|
1848
1860
|
const { port1: e, port2: r } = new MessageChannel();
|
|
1849
|
-
return
|
|
1861
|
+
return M(t, e), [r, [r]];
|
|
1850
1862
|
},
|
|
1851
1863
|
deserialize(t) {
|
|
1852
|
-
return t.start(),
|
|
1864
|
+
return t.start(), j(t);
|
|
1853
1865
|
}
|
|
1854
|
-
},
|
|
1855
|
-
canHandle: (t) =>
|
|
1866
|
+
}, Rt = {
|
|
1867
|
+
canHandle: (t) => he(t) && C in t,
|
|
1856
1868
|
serialize({ value: t }) {
|
|
1857
1869
|
let e;
|
|
1858
1870
|
return t instanceof Error ? e = {
|
|
@@ -1868,20 +1880,20 @@ const ce = Symbol("Comlink.proxy"), Pt = Symbol("Comlink.endpoint"), bt = Symbol
|
|
|
1868
1880
|
throw t.isError ? Object.assign(new Error(t.value.message), t.value) : t.value;
|
|
1869
1881
|
}
|
|
1870
1882
|
}, R = /* @__PURE__ */ new Map([
|
|
1871
|
-
["proxy",
|
|
1872
|
-
["throw",
|
|
1883
|
+
["proxy", Et],
|
|
1884
|
+
["throw", Rt]
|
|
1873
1885
|
]);
|
|
1874
|
-
function
|
|
1886
|
+
function Tt(t, e) {
|
|
1875
1887
|
for (const r of t)
|
|
1876
1888
|
if (e === r || r === "*" || r instanceof RegExp && r.test(e))
|
|
1877
1889
|
return !0;
|
|
1878
1890
|
return !1;
|
|
1879
1891
|
}
|
|
1880
|
-
function
|
|
1892
|
+
function M(t, e = globalThis, r = ["*"]) {
|
|
1881
1893
|
e.addEventListener("message", function s(n) {
|
|
1882
1894
|
if (!n || !n.data)
|
|
1883
1895
|
return;
|
|
1884
|
-
if (!
|
|
1896
|
+
if (!Tt(r, n.origin)) {
|
|
1885
1897
|
console.warn(`Invalid origin '${n.origin}' for comlink proxy`);
|
|
1886
1898
|
return;
|
|
1887
1899
|
}
|
|
@@ -1902,13 +1914,13 @@ function W(t, e = globalThis, r = ["*"]) {
|
|
|
1902
1914
|
case "CONSTRUCT":
|
|
1903
1915
|
{
|
|
1904
1916
|
const p = new d(...l);
|
|
1905
|
-
c =
|
|
1917
|
+
c = me(p);
|
|
1906
1918
|
}
|
|
1907
1919
|
break;
|
|
1908
1920
|
case "ENDPOINT":
|
|
1909
1921
|
{
|
|
1910
1922
|
const { port1: p, port2: y } = new MessageChannel();
|
|
1911
|
-
|
|
1923
|
+
M(t, y), c = Ot(p, [p]);
|
|
1912
1924
|
}
|
|
1913
1925
|
break;
|
|
1914
1926
|
case "RELEASE":
|
|
@@ -1922,7 +1934,7 @@ function W(t, e = globalThis, r = ["*"]) {
|
|
|
1922
1934
|
}
|
|
1923
1935
|
Promise.resolve(c).catch((u) => ({ value: u, [C]: 0 })).then((u) => {
|
|
1924
1936
|
const [d, p] = U(u);
|
|
1925
|
-
e.postMessage(Object.assign(Object.assign({}, d), { id: i }), p), o === "RELEASE" && (e.removeEventListener("message", s),
|
|
1937
|
+
e.postMessage(Object.assign(Object.assign({}, d), { id: i }), p), o === "RELEASE" && (e.removeEventListener("message", s), de(e), I in t && typeof t[I] == "function" && t[I]());
|
|
1926
1938
|
}).catch((u) => {
|
|
1927
1939
|
const [d, p] = U({
|
|
1928
1940
|
value: new TypeError("Unserializable return value"),
|
|
@@ -1932,35 +1944,35 @@ function W(t, e = globalThis, r = ["*"]) {
|
|
|
1932
1944
|
});
|
|
1933
1945
|
}), e.start && e.start();
|
|
1934
1946
|
}
|
|
1935
|
-
function
|
|
1947
|
+
function xt(t) {
|
|
1936
1948
|
return t.constructor.name === "MessagePort";
|
|
1937
1949
|
}
|
|
1938
|
-
function
|
|
1939
|
-
|
|
1950
|
+
function de(t) {
|
|
1951
|
+
xt(t) && t.close();
|
|
1940
1952
|
}
|
|
1941
|
-
function
|
|
1953
|
+
function j(t, e) {
|
|
1942
1954
|
return N(t, [], e);
|
|
1943
1955
|
}
|
|
1944
1956
|
function x(t) {
|
|
1945
1957
|
if (t)
|
|
1946
1958
|
throw new Error("Proxy has been released and is not useable");
|
|
1947
1959
|
}
|
|
1948
|
-
function
|
|
1960
|
+
function pe(t) {
|
|
1949
1961
|
return $(t, {
|
|
1950
1962
|
type: "RELEASE"
|
|
1951
1963
|
}).then(() => {
|
|
1952
|
-
|
|
1964
|
+
de(t);
|
|
1953
1965
|
});
|
|
1954
1966
|
}
|
|
1955
1967
|
const k = /* @__PURE__ */ new WeakMap(), O = "FinalizationRegistry" in globalThis && new FinalizationRegistry((t) => {
|
|
1956
1968
|
const e = (k.get(t) || 0) - 1;
|
|
1957
|
-
k.set(t, e), e === 0 &&
|
|
1969
|
+
k.set(t, e), e === 0 && pe(t);
|
|
1958
1970
|
});
|
|
1959
|
-
function
|
|
1971
|
+
function Ct(t, e) {
|
|
1960
1972
|
const r = (k.get(e) || 0) + 1;
|
|
1961
1973
|
k.set(e, r), O && O.register(t, e, t);
|
|
1962
1974
|
}
|
|
1963
|
-
function
|
|
1975
|
+
function Ft(t) {
|
|
1964
1976
|
O && O.unregister(t);
|
|
1965
1977
|
}
|
|
1966
1978
|
function N(t, e = [], r = function() {
|
|
@@ -1968,9 +1980,9 @@ function N(t, e = [], r = function() {
|
|
|
1968
1980
|
let s = !1;
|
|
1969
1981
|
const n = new Proxy(r, {
|
|
1970
1982
|
get(i, o) {
|
|
1971
|
-
if (x(s), o ===
|
|
1983
|
+
if (x(s), o === vt)
|
|
1972
1984
|
return () => {
|
|
1973
|
-
|
|
1985
|
+
Ft(n), pe(t), s = !0;
|
|
1974
1986
|
};
|
|
1975
1987
|
if (o === "then") {
|
|
1976
1988
|
if (e.length === 0)
|
|
@@ -1995,13 +2007,13 @@ function N(t, e = [], r = function() {
|
|
|
1995
2007
|
apply(i, o, a) {
|
|
1996
2008
|
x(s);
|
|
1997
2009
|
const l = e[e.length - 1];
|
|
1998
|
-
if (l ===
|
|
2010
|
+
if (l === St)
|
|
1999
2011
|
return $(t, {
|
|
2000
2012
|
type: "ENDPOINT"
|
|
2001
2013
|
}).then(P);
|
|
2002
2014
|
if (l === "bind")
|
|
2003
2015
|
return N(t, e.slice(0, -1));
|
|
2004
|
-
const [c, u] =
|
|
2016
|
+
const [c, u] = Z(a);
|
|
2005
2017
|
return $(t, {
|
|
2006
2018
|
type: "APPLY",
|
|
2007
2019
|
path: e.map((d) => d.toString()),
|
|
@@ -2010,7 +2022,7 @@ function N(t, e = [], r = function() {
|
|
|
2010
2022
|
},
|
|
2011
2023
|
construct(i, o) {
|
|
2012
2024
|
x(s);
|
|
2013
|
-
const [a, l] =
|
|
2025
|
+
const [a, l] = Z(o);
|
|
2014
2026
|
return $(t, {
|
|
2015
2027
|
type: "CONSTRUCT",
|
|
2016
2028
|
path: e.map((c) => c.toString()),
|
|
@@ -2018,23 +2030,23 @@ function N(t, e = [], r = function() {
|
|
|
2018
2030
|
}, l).then(P);
|
|
2019
2031
|
}
|
|
2020
2032
|
});
|
|
2021
|
-
return
|
|
2033
|
+
return Ct(n, t), n;
|
|
2022
2034
|
}
|
|
2023
|
-
function
|
|
2035
|
+
function kt(t) {
|
|
2024
2036
|
return Array.prototype.concat.apply([], t);
|
|
2025
2037
|
}
|
|
2026
|
-
function
|
|
2038
|
+
function Z(t) {
|
|
2027
2039
|
const e = t.map(U);
|
|
2028
|
-
return [e.map((r) => r[0]),
|
|
2040
|
+
return [e.map((r) => r[0]), kt(e.map((r) => r[1]))];
|
|
2029
2041
|
}
|
|
2030
|
-
const
|
|
2031
|
-
function
|
|
2032
|
-
return
|
|
2042
|
+
const fe = /* @__PURE__ */ new WeakMap();
|
|
2043
|
+
function Ot(t, e) {
|
|
2044
|
+
return fe.set(t, e), t;
|
|
2033
2045
|
}
|
|
2034
|
-
function
|
|
2035
|
-
return Object.assign(t, { [
|
|
2046
|
+
function me(t) {
|
|
2047
|
+
return Object.assign(t, { [ue]: !0 });
|
|
2036
2048
|
}
|
|
2037
|
-
function
|
|
2049
|
+
function Ut(t, e = globalThis, r = "*") {
|
|
2038
2050
|
return {
|
|
2039
2051
|
postMessage: (s, n) => t.postMessage(s, r, n),
|
|
2040
2052
|
addEventListener: e.addEventListener.bind(e),
|
|
@@ -2059,7 +2071,7 @@ function U(t) {
|
|
|
2059
2071
|
type: "RAW",
|
|
2060
2072
|
value: t
|
|
2061
2073
|
},
|
|
2062
|
-
|
|
2074
|
+
fe.get(t) || []
|
|
2063
2075
|
];
|
|
2064
2076
|
}
|
|
2065
2077
|
function P(t) {
|
|
@@ -2072,22 +2084,25 @@ function P(t) {
|
|
|
2072
2084
|
}
|
|
2073
2085
|
function $(t, e, r) {
|
|
2074
2086
|
return new Promise((s) => {
|
|
2075
|
-
const n =
|
|
2087
|
+
const n = Lt();
|
|
2076
2088
|
t.addEventListener("message", function i(o) {
|
|
2077
2089
|
!o.data || !o.data.id || o.data.id !== n || (t.removeEventListener("message", i), s(o.data));
|
|
2078
2090
|
}), t.start && t.start(), t.postMessage(Object.assign({ id: n }, e), r);
|
|
2079
2091
|
});
|
|
2080
2092
|
}
|
|
2081
|
-
function
|
|
2093
|
+
function Lt() {
|
|
2082
2094
|
return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
|
|
2083
2095
|
}
|
|
2084
|
-
function
|
|
2085
|
-
|
|
2086
|
-
const e = t instanceof Worker ? t :
|
|
2087
|
-
return
|
|
2096
|
+
function we(t) {
|
|
2097
|
+
At();
|
|
2098
|
+
const e = t instanceof Worker ? t : Ut(t), r = j(e), s = ge(r);
|
|
2099
|
+
return new Proxy(s, {
|
|
2100
|
+
get: (n, i) => i === "isConnected" ? () => r.isConnected() : r[i]
|
|
2101
|
+
});
|
|
2088
2102
|
}
|
|
2089
|
-
|
|
2090
|
-
|
|
2103
|
+
let ee = !1;
|
|
2104
|
+
function At() {
|
|
2105
|
+
ee || (ee = !0, R.set("EVENT", {
|
|
2091
2106
|
canHandle: (t) => t instanceof CustomEvent,
|
|
2092
2107
|
serialize: (t) => [
|
|
2093
2108
|
{
|
|
@@ -2101,10 +2116,10 @@ function Ot() {
|
|
|
2101
2116
|
serialize(t) {
|
|
2102
2117
|
console.debug("[Comlink][Performance] Proxying a function");
|
|
2103
2118
|
const { port1: e, port2: r } = new MessageChannel();
|
|
2104
|
-
return
|
|
2119
|
+
return M(t, e), [r, [r]];
|
|
2105
2120
|
},
|
|
2106
2121
|
deserialize(t) {
|
|
2107
|
-
return t.start(),
|
|
2122
|
+
return t.start(), j(t);
|
|
2108
2123
|
}
|
|
2109
2124
|
}), R.set("PHPResponse", {
|
|
2110
2125
|
canHandle: (t) => typeof t == "object" && t !== null && "headers" in t && "bytes" in t && "errors" in t && "exitCode" in t && "httpStatusCode" in t,
|
|
@@ -2114,105 +2129,124 @@ function Ot() {
|
|
|
2114
2129
|
deserialize(t) {
|
|
2115
2130
|
return v.fromRawData(t);
|
|
2116
2131
|
}
|
|
2132
|
+
}));
|
|
2133
|
+
}
|
|
2134
|
+
function ge(t) {
|
|
2135
|
+
return new Proxy(t, {
|
|
2136
|
+
get(e, r) {
|
|
2137
|
+
switch (typeof e[r]) {
|
|
2138
|
+
case "function":
|
|
2139
|
+
return (...s) => e[r](...s);
|
|
2140
|
+
case "object":
|
|
2141
|
+
return e[r] === null ? e[r] : ge(e[r]);
|
|
2142
|
+
case "undefined":
|
|
2143
|
+
case "number":
|
|
2144
|
+
case "string":
|
|
2145
|
+
return e[r];
|
|
2146
|
+
default:
|
|
2147
|
+
return me(e[r]);
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2117
2150
|
});
|
|
2118
2151
|
}
|
|
2119
2152
|
(function() {
|
|
2120
2153
|
return typeof navigator < "u" && navigator?.userAgent?.toLowerCase().indexOf("firefox") > -1 ? "iframe" : "webworker";
|
|
2121
2154
|
})();
|
|
2122
|
-
async function
|
|
2155
|
+
async function Ht({
|
|
2123
2156
|
iframe: t,
|
|
2124
2157
|
blueprint: e,
|
|
2125
2158
|
remoteUrl: r,
|
|
2126
|
-
progressTracker: s = new
|
|
2159
|
+
progressTracker: s = new A(),
|
|
2127
2160
|
disableProgressBar: n,
|
|
2128
2161
|
onBlueprintStepCompleted: i
|
|
2129
2162
|
}) {
|
|
2130
|
-
if (
|
|
2163
|
+
if (It(r), r = re(r, {
|
|
2131
2164
|
progressbar: !n
|
|
2132
2165
|
}), s.setCaption("Preparing WordPress"), !e)
|
|
2133
|
-
return
|
|
2134
|
-
const o =
|
|
2166
|
+
return te(t, r, s);
|
|
2167
|
+
const o = yt(e, {
|
|
2135
2168
|
progress: s.stage(0.5),
|
|
2136
2169
|
onStepCompleted: i
|
|
2137
|
-
}), a = await
|
|
2170
|
+
}), a = await te(
|
|
2138
2171
|
t,
|
|
2139
|
-
|
|
2172
|
+
re(r, {
|
|
2140
2173
|
php: o.versions.php,
|
|
2141
2174
|
wp: o.versions.wp
|
|
2142
2175
|
}),
|
|
2143
2176
|
s
|
|
2144
2177
|
);
|
|
2145
|
-
return await
|
|
2178
|
+
return await $t(o, a), s.finish(), a;
|
|
2146
2179
|
}
|
|
2147
|
-
async function
|
|
2148
|
-
await new Promise((
|
|
2149
|
-
t.src = e, t.addEventListener("load",
|
|
2180
|
+
async function te(t, e, r) {
|
|
2181
|
+
await new Promise((i) => {
|
|
2182
|
+
t.src = e, t.addEventListener("load", i, !1);
|
|
2150
2183
|
});
|
|
2151
|
-
const s =
|
|
2184
|
+
const s = we(
|
|
2152
2185
|
t.contentWindow
|
|
2153
2186
|
);
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
), await s.isReady(), s;
|
|
2187
|
+
await s.isConnected(), r.pipe(s);
|
|
2188
|
+
const n = r.stage();
|
|
2189
|
+
return await s.onDownloadProgress(n.loadingListener), await s.isReady(), n.finish(), s;
|
|
2157
2190
|
}
|
|
2158
2191
|
const F = "https://playground.wordpress.net";
|
|
2159
|
-
function
|
|
2192
|
+
function It(t) {
|
|
2160
2193
|
const e = new URL(t, F);
|
|
2161
2194
|
if ((e.origin === F || e.hostname === "localhost") && e.pathname !== "/remote.html")
|
|
2162
2195
|
throw new Error(
|
|
2163
2196
|
`Invalid remote URL: ${e}. Expected origin to be ${F}/remote.html.`
|
|
2164
2197
|
);
|
|
2165
2198
|
}
|
|
2166
|
-
function
|
|
2199
|
+
function re(t, e) {
|
|
2167
2200
|
const r = new URL(t, F), s = new URLSearchParams(r.search);
|
|
2168
2201
|
for (const [n, i] of Object.entries(e))
|
|
2169
2202
|
i != null && i !== !1 && s.set(n, i.toString());
|
|
2170
2203
|
return r.search = s.toString(), r.toString();
|
|
2171
2204
|
}
|
|
2172
|
-
async function
|
|
2205
|
+
async function zt(t, e) {
|
|
2173
2206
|
if (console.warn(
|
|
2174
2207
|
"`connectPlayground` is deprecated and will be removed. Use `startPlayground` instead."
|
|
2175
2208
|
), e?.loadRemote)
|
|
2176
|
-
return
|
|
2209
|
+
return Ht({
|
|
2177
2210
|
iframe: t,
|
|
2178
2211
|
remoteUrl: e.loadRemote
|
|
2179
2212
|
});
|
|
2180
|
-
const r =
|
|
2213
|
+
const r = we(
|
|
2181
2214
|
t.contentWindow
|
|
2182
2215
|
);
|
|
2183
2216
|
return await r.isConnected(), r;
|
|
2184
2217
|
}
|
|
2185
2218
|
export {
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2219
|
+
Ye as LatestSupportedPHPVersion,
|
|
2220
|
+
z as SupportedPHPVersions,
|
|
2221
|
+
Nt as SupportedPHPVersionsList,
|
|
2222
|
+
_e as activatePlugin,
|
|
2223
|
+
$e as applyWordPressPatches,
|
|
2224
|
+
yt as compileBlueprint,
|
|
2225
|
+
zt as connectPlayground,
|
|
2226
|
+
xe as cp,
|
|
2227
|
+
Le as defineSiteUrl,
|
|
2228
|
+
Ne as importFile,
|
|
2229
|
+
qe as installPlugin,
|
|
2230
|
+
We as installTheme,
|
|
2231
|
+
Me as login,
|
|
2232
|
+
Fe as mkdir,
|
|
2233
|
+
Ce as mv,
|
|
2201
2234
|
S as phpVar,
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2235
|
+
D as phpVars,
|
|
2236
|
+
Ie as replaceSite,
|
|
2237
|
+
Te as request,
|
|
2238
|
+
ke as rm,
|
|
2239
|
+
Oe as rmdir,
|
|
2240
|
+
$t as runBlueprintSteps,
|
|
2241
|
+
ve as runPHP,
|
|
2242
|
+
Ee as runPHPWithOptions,
|
|
2243
|
+
je as runWpInstallationWizard,
|
|
2244
|
+
Re as setPhpIniEntry,
|
|
2245
|
+
Dt as setPluginProxyURL,
|
|
2246
|
+
Be as setSiteOptions,
|
|
2247
|
+
Ht as startPlaygroundWeb,
|
|
2248
|
+
ne as unzip,
|
|
2249
|
+
Ve as updateUserMeta,
|
|
2250
|
+
Ue as writeFile,
|
|
2251
|
+
He as zipEntireSite
|
|
2218
2252
|
};
|