@wp-playground/blueprints 0.1.51 → 0.1.56
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 +24 -31
- package/index.js +248 -272
- package/lib/steps/common.d.ts +0 -2
- package/lib/steps/define-wp-config-consts.d.ts +10 -1
- package/lib/steps/handlers.d.ts +0 -1
- package/lib/steps/index.d.ts +2 -3
- package/package.json +2 -2
- package/lib/steps/define-virtual-wp-config-consts.d.ts +0 -19
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const ie = async (r, { pluginPath: e }, t) => {
|
|
2
2
|
t?.tracker.setCaption(`Activating ${e}`);
|
|
3
3
|
const s = [
|
|
4
4
|
`${r.documentRoot}/wp-load.php`,
|
|
@@ -17,7 +17,7 @@ const oe = async (r, { pluginPath: e }, t) => {
|
|
|
17
17
|
activate_plugin('${e}');
|
|
18
18
|
`
|
|
19
19
|
});
|
|
20
|
-
},
|
|
20
|
+
}, oe = async (r, { themeFolderName: e }, t) => {
|
|
21
21
|
t?.tracker.setCaption(`Activating ${e}`);
|
|
22
22
|
const s = `${r.documentRoot}/wp-load.php`;
|
|
23
23
|
if (!r.fileExists(s))
|
|
@@ -38,27 +38,27 @@ function E(r) {
|
|
|
38
38
|
const e = r.split(".").shift().replace("-", " ");
|
|
39
39
|
return e.charAt(0).toUpperCase() + e.slice(1).toLowerCase();
|
|
40
40
|
}
|
|
41
|
-
async function
|
|
41
|
+
async function P(r, e, t) {
|
|
42
42
|
let s = "";
|
|
43
43
|
await r.fileExists(e) && (s = await r.readFileAsText(e)), await r.writeFile(e, t(s));
|
|
44
44
|
}
|
|
45
|
-
async function
|
|
45
|
+
async function ae(r) {
|
|
46
46
|
return new Uint8Array(await r.arrayBuffer());
|
|
47
47
|
}
|
|
48
|
-
const
|
|
49
|
-
const t = new
|
|
48
|
+
const ce = async (r, e) => {
|
|
49
|
+
const t = new le(
|
|
50
50
|
r,
|
|
51
51
|
e.siteUrl,
|
|
52
52
|
e.wordpressPath || "/wordpress"
|
|
53
53
|
);
|
|
54
54
|
e.patchSqlitePlugin !== !1 && await t.patchSqlitePlugin(), e.addPhpInfo !== !1 && await t.addPhpInfo(), e.patchSiteUrl !== !1 && await t.patchSiteUrl(), e.disableSiteHealth !== !1 && await t.disableSiteHealth(), e.disableWpNewBlogNotification !== !1 && await t.disableWpNewBlogNotification();
|
|
55
55
|
};
|
|
56
|
-
class
|
|
56
|
+
class le {
|
|
57
57
|
constructor(e, t, s) {
|
|
58
58
|
this.php = e, this.scopedSiteUrl = t, this.wordpressPath = s;
|
|
59
59
|
}
|
|
60
60
|
async patchSqlitePlugin() {
|
|
61
|
-
await
|
|
61
|
+
await P(
|
|
62
62
|
this.php,
|
|
63
63
|
`${this.wordpressPath}/wp-content/plugins/sqlite-database-integration/wp-includes/sqlite/class-wp-sqlite-translator.php`,
|
|
64
64
|
(e) => e.replace(
|
|
@@ -74,7 +74,7 @@ class ue {
|
|
|
74
74
|
);
|
|
75
75
|
}
|
|
76
76
|
async patchSiteUrl() {
|
|
77
|
-
await
|
|
77
|
+
await P(
|
|
78
78
|
this.php,
|
|
79
79
|
`${this.wordpressPath}/wp-config.php`,
|
|
80
80
|
(e) => `<?php
|
|
@@ -86,7 +86,7 @@ class ue {
|
|
|
86
86
|
);
|
|
87
87
|
}
|
|
88
88
|
async disableSiteHealth() {
|
|
89
|
-
await
|
|
89
|
+
await P(
|
|
90
90
|
this.php,
|
|
91
91
|
`${this.wordpressPath}/wp-includes/default-filters.php`,
|
|
92
92
|
(e) => e.replace(
|
|
@@ -96,7 +96,7 @@ class ue {
|
|
|
96
96
|
);
|
|
97
97
|
}
|
|
98
98
|
async disableWpNewBlogNotification() {
|
|
99
|
-
await
|
|
99
|
+
await P(
|
|
100
100
|
this.php,
|
|
101
101
|
`${this.wordpressPath}/wp-config.php`,
|
|
102
102
|
// The original version of this function crashes WASM PHP, let's define an empty one instead.
|
|
@@ -104,45 +104,41 @@ class ue {
|
|
|
104
104
|
);
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
const
|
|
107
|
+
const ue = async (r, { code: e }) => await r.run({ code: e }), he = async (r, { options: e }) => await r.run(e), pe = async (r, { key: e, value: t }) => {
|
|
108
108
|
await r.setPhpIniEntry(e, t);
|
|
109
|
-
},
|
|
109
|
+
}, de = async (r, { request: e }) => await r.request(e), fe = async (r, { fromPath: e, toPath: t }) => {
|
|
110
110
|
await r.writeFile(
|
|
111
111
|
t,
|
|
112
112
|
await r.readFileAsBuffer(e)
|
|
113
113
|
);
|
|
114
|
-
},
|
|
114
|
+
}, me = async (r, { fromPath: e, toPath: t }) => {
|
|
115
115
|
await r.mv(e, t);
|
|
116
|
-
},
|
|
116
|
+
}, we = async (r, { path: e }) => {
|
|
117
117
|
await r.mkdir(e);
|
|
118
|
-
},
|
|
118
|
+
}, ge = async (r, { path: e }) => {
|
|
119
119
|
await r.unlink(e);
|
|
120
|
-
},
|
|
120
|
+
}, ye = async (r, { path: e }) => {
|
|
121
121
|
await r.rmdir(e);
|
|
122
|
-
},
|
|
123
|
-
t instanceof File && (t = await
|
|
124
|
-
},
|
|
125
|
-
const
|
|
126
|
-
await
|
|
122
|
+
}, Pe = async (r, { path: e, data: t }) => {
|
|
123
|
+
t instanceof File && (t = await ae(t)), await r.writeFile(e, t);
|
|
124
|
+
}, A = "/vfs-blueprints", J = async (r, { consts: e, virtualize: t = !1 }) => {
|
|
125
|
+
const s = await r.documentRoot, n = t ? A : s, i = `${n}/playground-consts.json`, o = `${n}/wp-config.php`;
|
|
126
|
+
return t && (r.mkdir(A), r.setPhpIniEntry("auto_prepend_file", o)), await P(
|
|
127
127
|
r,
|
|
128
|
-
|
|
129
|
-
(
|
|
130
|
-
...JSON.parse(
|
|
128
|
+
i,
|
|
129
|
+
(a) => JSON.stringify({
|
|
130
|
+
...JSON.parse(a || "{}"),
|
|
131
131
|
...e
|
|
132
132
|
})
|
|
133
|
-
), await
|
|
134
|
-
|
|
135
|
-
`${t}/wp-config.php`,
|
|
136
|
-
(s) => s.includes("playground-consts.json") ? s : `<?php
|
|
137
|
-
$consts = json_decode(file_get_contents('./playground-consts.json'), true);
|
|
133
|
+
), await P(r, o, (a) => a.includes("playground-consts.json") ? a : `<?php
|
|
134
|
+
$consts = json_decode(file_get_contents('${i}'), true);
|
|
138
135
|
foreach ($consts as $const => $value) {
|
|
139
136
|
if (!defined($const)) {
|
|
140
137
|
define($const, $value);
|
|
141
138
|
}
|
|
142
139
|
}
|
|
143
|
-
?>${
|
|
144
|
-
|
|
145
|
-
}, $e = async (r, { siteUrl: e }) => await K(r, {
|
|
140
|
+
?>${a}`), o;
|
|
141
|
+
}, _e = async (r, { siteUrl: e }) => await J(r, {
|
|
146
142
|
consts: {
|
|
147
143
|
WP_HOME: e,
|
|
148
144
|
WP_SITEURL: e
|
|
@@ -174,17 +170,17 @@ class Y {
|
|
|
174
170
|
}
|
|
175
171
|
}
|
|
176
172
|
const be = Symbol("literal");
|
|
177
|
-
function
|
|
173
|
+
function b(r) {
|
|
178
174
|
if (typeof r == "string")
|
|
179
175
|
return r.startsWith("$") ? r : JSON.stringify(r);
|
|
180
176
|
if (typeof r == "number")
|
|
181
177
|
return r.toString();
|
|
182
178
|
if (Array.isArray(r))
|
|
183
|
-
return `array(${r.map(
|
|
179
|
+
return `array(${r.map(b).join(", ")})`;
|
|
184
180
|
if (r === null)
|
|
185
181
|
return "null";
|
|
186
182
|
if (typeof r == "object")
|
|
187
|
-
return be in r ? r.toString() : `array(${Object.entries(r).map(([t, s]) => `${JSON.stringify(t)} => ${
|
|
183
|
+
return be in r ? r.toString() : `array(${Object.entries(r).map(([t, s]) => `${JSON.stringify(t)} => ${b(s)}`).join(", ")})`;
|
|
188
184
|
if (typeof r == "function")
|
|
189
185
|
return r();
|
|
190
186
|
throw new Error(`Unsupported value: ${r}`);
|
|
@@ -192,10 +188,10 @@ function $(r) {
|
|
|
192
188
|
function T(r) {
|
|
193
189
|
const e = {};
|
|
194
190
|
for (const t in r)
|
|
195
|
-
e[t] =
|
|
191
|
+
e[t] = b(r[t]);
|
|
196
192
|
return e;
|
|
197
193
|
}
|
|
198
|
-
const
|
|
194
|
+
const O = `<?php
|
|
199
195
|
|
|
200
196
|
function zipDir($dir, $output, $additionalFiles = array())
|
|
201
197
|
{
|
|
@@ -258,26 +254,26 @@ function delTree($dir)
|
|
|
258
254
|
return rmdir($dir);
|
|
259
255
|
}
|
|
260
256
|
`;
|
|
261
|
-
async function
|
|
257
|
+
async function $e(r) {
|
|
262
258
|
const e = "wordpress-playground.zip", t = `/${e}`, s = T({
|
|
263
259
|
zipPath: t,
|
|
264
260
|
documentRoot: await r.documentRoot
|
|
265
261
|
});
|
|
266
|
-
await
|
|
262
|
+
await Z(
|
|
267
263
|
r,
|
|
268
264
|
`zipDir(${s.documentRoot}, ${s.zipPath});`
|
|
269
265
|
);
|
|
270
266
|
const n = await r.readFileAsBuffer(t);
|
|
271
267
|
return r.unlink(t), new File([n], e);
|
|
272
268
|
}
|
|
273
|
-
const
|
|
269
|
+
const ve = async (r, { fullSiteZip: e }) => {
|
|
274
270
|
const t = "/import.zip";
|
|
275
271
|
await r.writeFile(
|
|
276
272
|
t,
|
|
277
273
|
new Uint8Array(await e.arrayBuffer())
|
|
278
274
|
);
|
|
279
275
|
const s = await r.absoluteUrl, n = await r.documentRoot;
|
|
280
|
-
await r.rmdir(n), await
|
|
276
|
+
await r.rmdir(n), await K(r, { zipPath: t, extractToPath: "/" });
|
|
281
277
|
const i = T({ absoluteUrl: s });
|
|
282
278
|
await Re(
|
|
283
279
|
r,
|
|
@@ -289,30 +285,30 @@ const Se = async (r, { fullSiteZip: e }) => {
|
|
|
289
285
|
}
|
|
290
286
|
?>${o}`
|
|
291
287
|
);
|
|
292
|
-
},
|
|
288
|
+
}, K = async (r, { zipPath: e, extractToPath: t }) => {
|
|
293
289
|
const s = T({
|
|
294
290
|
zipPath: e,
|
|
295
291
|
extractToPath: t
|
|
296
292
|
});
|
|
297
|
-
await
|
|
293
|
+
await Z(
|
|
298
294
|
r,
|
|
299
295
|
`unzip(${s.zipPath}, ${s.extractToPath});`
|
|
300
296
|
);
|
|
301
|
-
},
|
|
297
|
+
}, Se = async (r, { file: e }) => {
|
|
302
298
|
const t = await r.request({
|
|
303
299
|
url: "/wp-admin/admin.php?import=wordpress"
|
|
304
|
-
}), s =
|
|
300
|
+
}), s = I(t).getElementById("import-upload-form")?.getAttribute("action"), n = await r.request({
|
|
305
301
|
url: `/wp-admin/${s}`,
|
|
306
302
|
method: "POST",
|
|
307
303
|
files: { import: e }
|
|
308
|
-
}), i =
|
|
304
|
+
}), i = I(n).querySelector(
|
|
309
305
|
"#wpbody-content form"
|
|
310
306
|
);
|
|
311
307
|
if (!i)
|
|
312
308
|
throw console.log(n.text), new Error(
|
|
313
309
|
"Could not find an importer form in response. See the response text above for details."
|
|
314
310
|
);
|
|
315
|
-
const o =
|
|
311
|
+
const o = Ee(i);
|
|
316
312
|
o.fetch_attachments = "1";
|
|
317
313
|
for (const a in o)
|
|
318
314
|
if (a.startsWith("user_map[")) {
|
|
@@ -325,10 +321,10 @@ const Se = async (r, { fullSiteZip: e }) => {
|
|
|
325
321
|
formData: o
|
|
326
322
|
});
|
|
327
323
|
};
|
|
328
|
-
function
|
|
324
|
+
function I(r) {
|
|
329
325
|
return new DOMParser().parseFromString(r.text, "text/html");
|
|
330
326
|
}
|
|
331
|
-
function
|
|
327
|
+
function Ee(r) {
|
|
332
328
|
return Object.fromEntries(new FormData(r).entries());
|
|
333
329
|
}
|
|
334
330
|
async function Re(r, e, t) {
|
|
@@ -337,15 +333,15 @@ async function Re(r, e, t) {
|
|
|
337
333
|
t(await r.readFileAsText(e))
|
|
338
334
|
);
|
|
339
335
|
}
|
|
340
|
-
async function
|
|
336
|
+
async function Z(r, e) {
|
|
341
337
|
const t = await r.run({
|
|
342
|
-
code:
|
|
338
|
+
code: O + e
|
|
343
339
|
});
|
|
344
340
|
if (t.exitCode !== 0)
|
|
345
|
-
throw console.log(
|
|
341
|
+
throw console.log(O + e), console.log(e + ""), console.log(t.errors), t.errors;
|
|
346
342
|
return t;
|
|
347
343
|
}
|
|
348
|
-
const
|
|
344
|
+
const xe = async (r, { pluginZipFile: e, options: t = {} }, s) => {
|
|
349
345
|
s?.tracker.setCaption(
|
|
350
346
|
`Installing the ${E(e?.name)} plugin`
|
|
351
347
|
);
|
|
@@ -363,8 +359,8 @@ const Te = async (r, { pluginZipFile: e, options: t = {} }, s) => {
|
|
|
363
359
|
files: { pluginzip: e }
|
|
364
360
|
});
|
|
365
361
|
if (n) {
|
|
366
|
-
const
|
|
367
|
-
|
|
362
|
+
const $ = S(h).querySelector("#wpbody-content .button.button-primary").attributes.getNamedItem("href").value, v = new URL(
|
|
363
|
+
$,
|
|
368
364
|
await r.pathToInternalUrl("/wp-admin/")
|
|
369
365
|
).toString();
|
|
370
366
|
await r.request({
|
|
@@ -373,14 +369,14 @@ const Te = async (r, { pluginZipFile: e, options: t = {} }, s) => {
|
|
|
373
369
|
}
|
|
374
370
|
await r.isDir(
|
|
375
371
|
"/wordpress/wp-content/plugins/gutenberg"
|
|
376
|
-
) && !await r.fileExists("/wordpress/.gutenberg-patched") && (await r.writeFile("/wordpress/.gutenberg-patched", "1"), await
|
|
372
|
+
) && !await r.fileExists("/wordpress/.gutenberg-patched") && (await r.writeFile("/wordpress/.gutenberg-patched", "1"), await L(
|
|
377
373
|
r,
|
|
378
374
|
"/wordpress/wp-content/plugins/gutenberg/build/block-editor/index.js",
|
|
379
375
|
(d) => d.replace(
|
|
380
376
|
/srcDoc:("[^"]+"|[^,]+)/g,
|
|
381
377
|
'src:"/wp-includes/empty.html"'
|
|
382
378
|
)
|
|
383
|
-
), await
|
|
379
|
+
), await L(
|
|
384
380
|
r,
|
|
385
381
|
"/wordpress/wp-content/plugins/gutenberg/build/block-editor/index.min.js",
|
|
386
382
|
(d) => d.replace(
|
|
@@ -394,13 +390,13 @@ const Te = async (r, { pluginZipFile: e, options: t = {} }, s) => {
|
|
|
394
390
|
), console.error(n);
|
|
395
391
|
}
|
|
396
392
|
};
|
|
397
|
-
async function
|
|
393
|
+
async function L(r, e, t) {
|
|
398
394
|
return await r.writeFile(
|
|
399
395
|
e,
|
|
400
396
|
t(await r.readFileAsText(e))
|
|
401
397
|
);
|
|
402
398
|
}
|
|
403
|
-
const
|
|
399
|
+
const Te = async (r, { themeZipFile: e, options: t = {} }, s) => {
|
|
404
400
|
s?.tracker.setCaption(
|
|
405
401
|
`Installing the ${E(e.name)} theme`
|
|
406
402
|
);
|
|
@@ -418,13 +414,13 @@ const Fe = async (r, { themeZipFile: e, options: t = {} }, s) => {
|
|
|
418
414
|
files: { themezip: e }
|
|
419
415
|
});
|
|
420
416
|
if (n) {
|
|
421
|
-
const d = S(h),
|
|
417
|
+
const d = S(h), $ = d.querySelector(
|
|
422
418
|
"#wpbody-content > .wrap"
|
|
423
419
|
);
|
|
424
|
-
if (
|
|
420
|
+
if ($?.textContent?.includes(
|
|
425
421
|
"Theme installation failed."
|
|
426
422
|
)) {
|
|
427
|
-
console.error(
|
|
423
|
+
console.error($?.textContent);
|
|
428
424
|
return;
|
|
429
425
|
}
|
|
430
426
|
const v = d.querySelector(
|
|
@@ -434,12 +430,12 @@ const Fe = async (r, { themeZipFile: e, options: t = {} }, s) => {
|
|
|
434
430
|
console.error('The "activate" button was not found.');
|
|
435
431
|
return;
|
|
436
432
|
}
|
|
437
|
-
const
|
|
438
|
-
|
|
433
|
+
const se = v.attributes.getNamedItem("href").value, ne = new URL(
|
|
434
|
+
se,
|
|
439
435
|
await r.pathToInternalUrl("/wp-admin/")
|
|
440
436
|
).toString();
|
|
441
437
|
await r.request({
|
|
442
|
-
url:
|
|
438
|
+
url: ne
|
|
443
439
|
});
|
|
444
440
|
}
|
|
445
441
|
} catch (n) {
|
|
@@ -447,7 +443,7 @@ const Fe = async (r, { themeZipFile: e, options: t = {} }, s) => {
|
|
|
447
443
|
`Proceeding without the ${e.name} theme. Could not install it in wp-admin. The original error was: ${n}`
|
|
448
444
|
), console.error(n);
|
|
449
445
|
}
|
|
450
|
-
},
|
|
446
|
+
}, Fe = async (r, { username: e = "admin", password: t = "password" } = {}, s) => {
|
|
451
447
|
s?.tracker.setCaption(s?.initialCaption || "Logging in"), await r.request({
|
|
452
448
|
url: "/wp-login.php"
|
|
453
449
|
}), await r.request({
|
|
@@ -476,10 +472,10 @@ const Fe = async (r, { themeZipFile: e, options: t = {} }, s) => {
|
|
|
476
472
|
admin_email: "admin@localhost.com"
|
|
477
473
|
}
|
|
478
474
|
});
|
|
479
|
-
},
|
|
475
|
+
}, Ce = async (r, { options: e }) => {
|
|
480
476
|
const t = `<?php
|
|
481
477
|
include 'wordpress/wp-load.php';
|
|
482
|
-
$site_options = ${
|
|
478
|
+
$site_options = ${b(e)};
|
|
483
479
|
foreach($site_options as $name => $value) {
|
|
484
480
|
update_option($name, $value);
|
|
485
481
|
}
|
|
@@ -487,73 +483,54 @@ const Fe = async (r, { themeZipFile: e, options: t = {} }, s) => {
|
|
|
487
483
|
`, s = await r.run({
|
|
488
484
|
code: t
|
|
489
485
|
});
|
|
490
|
-
return
|
|
491
|
-
},
|
|
486
|
+
return Q(s), { code: t, result: s };
|
|
487
|
+
}, Ue = async (r, { meta: e, userId: t }) => {
|
|
492
488
|
const s = `<?php
|
|
493
489
|
include 'wordpress/wp-load.php';
|
|
494
|
-
$meta = ${
|
|
490
|
+
$meta = ${b(e)};
|
|
495
491
|
foreach($meta as $name => $value) {
|
|
496
|
-
update_user_meta(${
|
|
492
|
+
update_user_meta(${b(t)}, $name, $value);
|
|
497
493
|
}
|
|
498
494
|
echo "Success";
|
|
499
495
|
`, n = await r.run({
|
|
500
496
|
code: s
|
|
501
497
|
});
|
|
502
|
-
return
|
|
498
|
+
return Q(n), { code: s, result: n };
|
|
503
499
|
};
|
|
504
|
-
async function
|
|
500
|
+
async function Q(r) {
|
|
505
501
|
if (r.text !== "Success")
|
|
506
502
|
throw console.log(r), new Error(`Failed to run code: ${r.text} ${r.errors}`);
|
|
507
503
|
}
|
|
508
|
-
const
|
|
509
|
-
r.mkdir(A);
|
|
510
|
-
const t = `${A}/playground-consts.json`;
|
|
511
|
-
return await g(
|
|
512
|
-
r,
|
|
513
|
-
t,
|
|
514
|
-
(s) => JSON.stringify({
|
|
515
|
-
...JSON.parse(s || "{}"),
|
|
516
|
-
...e
|
|
517
|
-
})
|
|
518
|
-
), await g(r, O, (s) => s.includes("playground-consts.json") ? s : `<?php
|
|
519
|
-
$consts = json_decode(file_get_contents('${t}'), true);
|
|
520
|
-
foreach ($consts as $const => $value) {
|
|
521
|
-
if (!defined($const)) {
|
|
522
|
-
define($const, $value);
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
?>${s}`), O;
|
|
526
|
-
}, Ie = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
504
|
+
const Ae = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
527
505
|
__proto__: null,
|
|
528
|
-
activatePlugin:
|
|
529
|
-
activateTheme:
|
|
530
|
-
applyWordPressPatches:
|
|
531
|
-
cp:
|
|
532
|
-
defineSiteUrl:
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
runPHPWithOptions: pe,
|
|
506
|
+
activatePlugin: ie,
|
|
507
|
+
activateTheme: oe,
|
|
508
|
+
applyWordPressPatches: ce,
|
|
509
|
+
cp: fe,
|
|
510
|
+
defineSiteUrl: _e,
|
|
511
|
+
defineWpConfigConsts: J,
|
|
512
|
+
importFile: Se,
|
|
513
|
+
installPlugin: xe,
|
|
514
|
+
installTheme: Te,
|
|
515
|
+
login: Fe,
|
|
516
|
+
mkdir: we,
|
|
517
|
+
mv: me,
|
|
518
|
+
replaceSite: ve,
|
|
519
|
+
request: de,
|
|
520
|
+
rm: ge,
|
|
521
|
+
rmdir: ye,
|
|
522
|
+
runPHP: ue,
|
|
523
|
+
runPHPWithOptions: he,
|
|
547
524
|
runWpInstallationWizard: ke,
|
|
548
|
-
setPhpIniEntry:
|
|
549
|
-
setSiteOptions:
|
|
550
|
-
unzip:
|
|
551
|
-
updateUserMeta:
|
|
552
|
-
writeFile:
|
|
553
|
-
zipEntireSite:
|
|
554
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
555
|
-
function
|
|
556
|
-
const t = r.headers.get("content-length") || "", s = parseInt(t, 10) ||
|
|
525
|
+
setPhpIniEntry: pe,
|
|
526
|
+
setSiteOptions: Ce,
|
|
527
|
+
unzip: K,
|
|
528
|
+
updateUserMeta: Ue,
|
|
529
|
+
writeFile: Pe,
|
|
530
|
+
zipEntireSite: $e
|
|
531
|
+
}, Symbol.toStringTag, { value: "Module" })), Oe = 5 * 1024 * 1024;
|
|
532
|
+
function Ie(r, e) {
|
|
533
|
+
const t = r.headers.get("content-length") || "", s = parseInt(t, 10) || Oe;
|
|
557
534
|
function n(i, o) {
|
|
558
535
|
e(
|
|
559
536
|
new CustomEvent("progress", {
|
|
@@ -594,7 +571,7 @@ function He(r, e) {
|
|
|
594
571
|
}
|
|
595
572
|
);
|
|
596
573
|
}
|
|
597
|
-
const
|
|
574
|
+
const R = 1e-5;
|
|
598
575
|
class F extends EventTarget {
|
|
599
576
|
constructor({
|
|
600
577
|
weight: e = 1,
|
|
@@ -639,7 +616,7 @@ class F extends EventTarget {
|
|
|
639
616
|
* ```
|
|
640
617
|
*/
|
|
641
618
|
stage(e, t = "") {
|
|
642
|
-
if (e || (e = this._selfWeight), this._selfWeight - e < -
|
|
619
|
+
if (e || (e = this._selfWeight), this._selfWeight - e < -R)
|
|
643
620
|
throw new Error(
|
|
644
621
|
`Cannot add a stage with weight ${e} as the total weight of registered stages would exceed 1.`
|
|
645
622
|
);
|
|
@@ -681,7 +658,7 @@ class F extends EventTarget {
|
|
|
681
658
|
}, s);
|
|
682
659
|
}
|
|
683
660
|
set(e) {
|
|
684
|
-
this._selfProgress = Math.min(e, 100), this.notifyProgress(), this._selfProgress +
|
|
661
|
+
this._selfProgress = Math.min(e, 100), this.notifyProgress(), this._selfProgress + R >= 100 && this.finish();
|
|
685
662
|
}
|
|
686
663
|
finish() {
|
|
687
664
|
this._fillInterval && clearInterval(this._fillInterval), this._selfDone = !0, this._selfProgress = 100, this._isFilling = !1, this._fillInterval = void 0, this.notifyProgress(), this.notifyDone();
|
|
@@ -699,7 +676,7 @@ class F extends EventTarget {
|
|
|
699
676
|
this._selfCaption = e, this.notifyProgress();
|
|
700
677
|
}
|
|
701
678
|
get done() {
|
|
702
|
-
return this.progress +
|
|
679
|
+
return this.progress + R >= 100;
|
|
703
680
|
}
|
|
704
681
|
get progress() {
|
|
705
682
|
if (this._selfDone)
|
|
@@ -761,8 +738,8 @@ class F extends EventTarget {
|
|
|
761
738
|
this.dispatchEvent(new CustomEvent("done"));
|
|
762
739
|
}
|
|
763
740
|
}
|
|
764
|
-
const
|
|
765
|
-
class
|
|
741
|
+
const H = Symbol("error"), q = Symbol("message");
|
|
742
|
+
class k extends Event {
|
|
766
743
|
/**
|
|
767
744
|
* Create a new `ErrorEvent`.
|
|
768
745
|
*
|
|
@@ -771,19 +748,19 @@ class C extends Event {
|
|
|
771
748
|
* attributes via object members of the same name.
|
|
772
749
|
*/
|
|
773
750
|
constructor(e, t = {}) {
|
|
774
|
-
super(e), this[
|
|
751
|
+
super(e), this[H] = t.error === void 0 ? null : t.error, this[q] = t.message === void 0 ? "" : t.message;
|
|
775
752
|
}
|
|
776
753
|
get error() {
|
|
777
|
-
return this[
|
|
754
|
+
return this[H];
|
|
778
755
|
}
|
|
779
756
|
get message() {
|
|
780
757
|
return this[q];
|
|
781
758
|
}
|
|
782
759
|
}
|
|
783
|
-
Object.defineProperty(
|
|
784
|
-
Object.defineProperty(
|
|
785
|
-
const
|
|
786
|
-
class
|
|
760
|
+
Object.defineProperty(k.prototype, "error", { enumerable: !0 });
|
|
761
|
+
Object.defineProperty(k.prototype, "message", { enumerable: !0 });
|
|
762
|
+
const Le = typeof globalThis.ErrorEvent == "function" ? globalThis.ErrorEvent : k;
|
|
763
|
+
class He extends EventTarget {
|
|
787
764
|
constructor() {
|
|
788
765
|
super(...arguments), this.listenersCount = 0;
|
|
789
766
|
}
|
|
@@ -797,11 +774,11 @@ class qe extends EventTarget {
|
|
|
797
774
|
return this.listenersCount > 0;
|
|
798
775
|
}
|
|
799
776
|
}
|
|
800
|
-
function
|
|
777
|
+
function qe(r) {
|
|
801
778
|
r.asm = {
|
|
802
779
|
...r.asm
|
|
803
780
|
};
|
|
804
|
-
const e = new
|
|
781
|
+
const e = new He();
|
|
805
782
|
for (const t in r.asm)
|
|
806
783
|
if (typeof r.asm[t] == "function") {
|
|
807
784
|
const s = r.asm[t];
|
|
@@ -813,14 +790,14 @@ function We(r) {
|
|
|
813
790
|
throw i;
|
|
814
791
|
if ("exitCode" in i && i?.exitCode === 0)
|
|
815
792
|
return;
|
|
816
|
-
const o =
|
|
793
|
+
const o = Ne(
|
|
817
794
|
i,
|
|
818
795
|
r.lastAsyncifyStackSource?.stack
|
|
819
796
|
);
|
|
820
797
|
if (r.lastAsyncifyStackSource && (i.cause = r.lastAsyncifyStackSource), !e.hasListeners())
|
|
821
|
-
throw
|
|
798
|
+
throw je(o), i;
|
|
822
799
|
e.dispatchEvent(
|
|
823
|
-
new
|
|
800
|
+
new Le("error", {
|
|
824
801
|
error: i,
|
|
825
802
|
message: o
|
|
826
803
|
})
|
|
@@ -830,29 +807,29 @@ function We(r) {
|
|
|
830
807
|
}
|
|
831
808
|
return e;
|
|
832
809
|
}
|
|
833
|
-
let
|
|
810
|
+
let x = [];
|
|
834
811
|
function De() {
|
|
835
|
-
return
|
|
812
|
+
return x;
|
|
836
813
|
}
|
|
837
|
-
function
|
|
814
|
+
function Ne(r, e) {
|
|
838
815
|
if (r.message === "unreachable") {
|
|
839
|
-
let t =
|
|
816
|
+
let t = We;
|
|
840
817
|
e || (t += `
|
|
841
818
|
|
|
842
819
|
This stack trace is lacking. For a better one initialize
|
|
843
820
|
the PHP runtime with { debug: true }, e.g. PHPNode.load('8.1', { debug: true }).
|
|
844
821
|
|
|
845
|
-
`),
|
|
822
|
+
`), x = ze(
|
|
846
823
|
e || r.stack || ""
|
|
847
824
|
);
|
|
848
|
-
for (const s of
|
|
825
|
+
for (const s of x)
|
|
849
826
|
t += ` * ${s}
|
|
850
827
|
`;
|
|
851
828
|
return t;
|
|
852
829
|
}
|
|
853
830
|
return r.message;
|
|
854
831
|
}
|
|
855
|
-
const
|
|
832
|
+
const We = `
|
|
856
833
|
"unreachable" WASM instruction executed.
|
|
857
834
|
|
|
858
835
|
The typical reason is a PHP function missing from the ASYNCIFY_ONLY
|
|
@@ -876,20 +853,20 @@ the Dockerfile, you'll need to trigger this error again with long stack
|
|
|
876
853
|
traces enabled. In node.js, you can do it using the --stack-trace-limit=100
|
|
877
854
|
CLI option:
|
|
878
855
|
|
|
879
|
-
`,
|
|
880
|
-
let
|
|
881
|
-
function
|
|
882
|
-
if (!
|
|
883
|
-
|
|
884
|
-
${
|
|
885
|
-
${
|
|
856
|
+
`, D = "\x1B[41m", Me = "\x1B[1m", N = "\x1B[0m", W = "\x1B[K";
|
|
857
|
+
let M = !1;
|
|
858
|
+
function je(r) {
|
|
859
|
+
if (!M) {
|
|
860
|
+
M = !0, console.log(`${D}
|
|
861
|
+
${W}
|
|
862
|
+
${Me} WASM ERROR${N}${D}`);
|
|
886
863
|
for (const e of r.split(`
|
|
887
864
|
`))
|
|
888
|
-
console.log(`${
|
|
889
|
-
console.log(`${
|
|
865
|
+
console.log(`${W} ${e} `);
|
|
866
|
+
console.log(`${N}`);
|
|
890
867
|
}
|
|
891
868
|
}
|
|
892
|
-
function
|
|
869
|
+
function ze(r) {
|
|
893
870
|
try {
|
|
894
871
|
const e = r.split(`
|
|
895
872
|
`).slice(1).map((t) => {
|
|
@@ -941,7 +918,7 @@ class _ {
|
|
|
941
918
|
return new TextDecoder().decode(this.bytes);
|
|
942
919
|
}
|
|
943
920
|
}
|
|
944
|
-
const
|
|
921
|
+
const X = [
|
|
945
922
|
"8.2",
|
|
946
923
|
"8.1",
|
|
947
924
|
"8.0",
|
|
@@ -951,8 +928,8 @@ const ee = [
|
|
|
951
928
|
"7.1",
|
|
952
929
|
"7.0",
|
|
953
930
|
"5.6"
|
|
954
|
-
],
|
|
955
|
-
class
|
|
931
|
+
], Be = X[0];
|
|
932
|
+
class Ge {
|
|
956
933
|
#e;
|
|
957
934
|
#t;
|
|
958
935
|
/**
|
|
@@ -1038,17 +1015,17 @@ class Je {
|
|
|
1038
1015
|
return e.join("; ");
|
|
1039
1016
|
}
|
|
1040
1017
|
}
|
|
1041
|
-
const
|
|
1042
|
-
function
|
|
1018
|
+
const Ve = "http://example.com";
|
|
1019
|
+
function j(r) {
|
|
1043
1020
|
return r.toString().substring(r.origin.length);
|
|
1044
1021
|
}
|
|
1045
|
-
function
|
|
1022
|
+
function z(r, e) {
|
|
1046
1023
|
return !e || !r.startsWith(e) ? r : r.substring(e.length);
|
|
1047
1024
|
}
|
|
1048
|
-
function
|
|
1025
|
+
function Je(r, e) {
|
|
1049
1026
|
return !e || r.startsWith(e) ? r : e + r;
|
|
1050
1027
|
}
|
|
1051
|
-
class
|
|
1028
|
+
class Ye {
|
|
1052
1029
|
#e;
|
|
1053
1030
|
#t;
|
|
1054
1031
|
#s;
|
|
@@ -1089,7 +1066,7 @@ class Ze {
|
|
|
1089
1066
|
/** @inheritDoc */
|
|
1090
1067
|
internalUrlToPath(e) {
|
|
1091
1068
|
const t = new URL(e);
|
|
1092
|
-
return t.pathname.startsWith(this.#n) && (t.pathname = t.pathname.slice(this.#n.length)),
|
|
1069
|
+
return t.pathname.startsWith(this.#n) && (t.pathname = t.pathname.slice(this.#n.length)), j(t);
|
|
1093
1070
|
}
|
|
1094
1071
|
get isRequestRunning() {
|
|
1095
1072
|
return this.#a.running > 0;
|
|
@@ -1106,8 +1083,8 @@ class Ze {
|
|
|
1106
1083
|
async request(e) {
|
|
1107
1084
|
const t = e.url.startsWith("http://") || e.url.startsWith("https://"), s = new URL(
|
|
1108
1085
|
e.url,
|
|
1109
|
-
t ? void 0 :
|
|
1110
|
-
), n =
|
|
1086
|
+
t ? void 0 : Ve
|
|
1087
|
+
), n = z(
|
|
1111
1088
|
s.pathname,
|
|
1112
1089
|
this.#n
|
|
1113
1090
|
);
|
|
@@ -1135,7 +1112,7 @@ class Ze {
|
|
|
1135
1112
|
// @TODO: Infer the content-type from the arrayBuffer instead of the file path.
|
|
1136
1113
|
// The code below won't return the correct mime-type if the extension
|
|
1137
1114
|
// was tampered with.
|
|
1138
|
-
"content-type": [
|
|
1115
|
+
"content-type": [Ze(t)],
|
|
1139
1116
|
"accept-ranges": ["bytes"],
|
|
1140
1117
|
"cache-control": ["public, max-age=0"]
|
|
1141
1118
|
},
|
|
@@ -1159,7 +1136,7 @@ class Ze {
|
|
|
1159
1136
|
let n = "GET";
|
|
1160
1137
|
const i = {
|
|
1161
1138
|
host: this.#i,
|
|
1162
|
-
...
|
|
1139
|
+
...ee(e.headers || {})
|
|
1163
1140
|
}, o = [];
|
|
1164
1141
|
if (e.files && Object.keys(e.files).length) {
|
|
1165
1142
|
n = "POST";
|
|
@@ -1172,7 +1149,7 @@ class Ze {
|
|
|
1172
1149
|
data: new Uint8Array(await h.arrayBuffer())
|
|
1173
1150
|
});
|
|
1174
1151
|
}
|
|
1175
|
-
i["content-type"]?.startsWith("multipart/form-data") && (e.formData =
|
|
1152
|
+
i["content-type"]?.startsWith("multipart/form-data") && (e.formData = Ke(
|
|
1176
1153
|
e.body || ""
|
|
1177
1154
|
), i["content-type"] = "application/x-www-form-urlencoded", delete e.body);
|
|
1178
1155
|
}
|
|
@@ -1191,8 +1168,8 @@ class Ze {
|
|
|
1191
1168
|
);
|
|
1192
1169
|
}
|
|
1193
1170
|
return await this.php.run({
|
|
1194
|
-
relativeUri:
|
|
1195
|
-
|
|
1171
|
+
relativeUri: Je(
|
|
1172
|
+
j(t),
|
|
1196
1173
|
this.#n
|
|
1197
1174
|
),
|
|
1198
1175
|
protocol: this.#t,
|
|
@@ -1216,7 +1193,7 @@ class Ze {
|
|
|
1216
1193
|
* @returns The resolved filesystem path.
|
|
1217
1194
|
*/
|
|
1218
1195
|
#h(e) {
|
|
1219
|
-
let t =
|
|
1196
|
+
let t = z(e, this.#n);
|
|
1220
1197
|
t.includes(".php") ? t = t.split(".php")[0] + ".php" : (t.endsWith("/") || (t += "/"), t.endsWith("index.php") || (t += "index.php"));
|
|
1221
1198
|
const s = `${this.#e}${t}`;
|
|
1222
1199
|
if (this.php.fileExists(s))
|
|
@@ -1226,7 +1203,7 @@ class Ze {
|
|
|
1226
1203
|
return `${this.#e}/index.php`;
|
|
1227
1204
|
}
|
|
1228
1205
|
}
|
|
1229
|
-
function
|
|
1206
|
+
function Ke(r) {
|
|
1230
1207
|
const e = {}, t = r.match(/--(.*)\r\n/);
|
|
1231
1208
|
if (!t)
|
|
1232
1209
|
return e;
|
|
@@ -1241,7 +1218,7 @@ function Qe(r) {
|
|
|
1241
1218
|
}
|
|
1242
1219
|
}), e;
|
|
1243
1220
|
}
|
|
1244
|
-
function
|
|
1221
|
+
function Ze(r) {
|
|
1245
1222
|
switch (r.split(".").pop()) {
|
|
1246
1223
|
case "css":
|
|
1247
1224
|
return "text/css";
|
|
@@ -1281,7 +1258,7 @@ function Xe(r) {
|
|
|
1281
1258
|
return "application-octet-stream";
|
|
1282
1259
|
}
|
|
1283
1260
|
}
|
|
1284
|
-
const
|
|
1261
|
+
const B = {
|
|
1285
1262
|
0: "No error occurred. System call completed successfully.",
|
|
1286
1263
|
1: "Argument list too long.",
|
|
1287
1264
|
2: "Permission denied.",
|
|
@@ -1368,8 +1345,8 @@ function f(r = "") {
|
|
|
1368
1345
|
return i.apply(this, o);
|
|
1369
1346
|
} catch (a) {
|
|
1370
1347
|
const c = typeof a == "object" ? a?.errno : null;
|
|
1371
|
-
if (c in
|
|
1372
|
-
const l =
|
|
1348
|
+
if (c in B) {
|
|
1349
|
+
const l = B[c], h = typeof o[0] == "string" ? o[0] : null, d = h !== null ? r.replaceAll("{path}", h) : r;
|
|
1373
1350
|
throw new Error(`${d}: ${l}`, {
|
|
1374
1351
|
cause: a
|
|
1375
1352
|
});
|
|
@@ -1379,19 +1356,19 @@ function f(r = "") {
|
|
|
1379
1356
|
};
|
|
1380
1357
|
};
|
|
1381
1358
|
}
|
|
1382
|
-
const
|
|
1383
|
-
function
|
|
1384
|
-
return
|
|
1359
|
+
const Qe = [];
|
|
1360
|
+
function Xe(r) {
|
|
1361
|
+
return Qe[r];
|
|
1385
1362
|
}
|
|
1386
1363
|
(function() {
|
|
1387
1364
|
return typeof process < "u" && process.release?.name === "node" ? "NODE" : typeof window < "u" ? "WEB" : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? "WORKER" : "NODE";
|
|
1388
1365
|
})();
|
|
1389
|
-
var
|
|
1390
|
-
for (var n = s > 1 ? void 0 : s ?
|
|
1366
|
+
var et = Object.defineProperty, tt = Object.getOwnPropertyDescriptor, m = (r, e, t, s) => {
|
|
1367
|
+
for (var n = s > 1 ? void 0 : s ? tt(e, t) : e, i = r.length - 1, o; i >= 0; i--)
|
|
1391
1368
|
(o = r[i]) && (n = (s ? o(e, t, n) : o(n)) || n);
|
|
1392
|
-
return s && n &&
|
|
1369
|
+
return s && n && et(e, t, n), n;
|
|
1393
1370
|
};
|
|
1394
|
-
const p = "string",
|
|
1371
|
+
const p = "string", y = "number", u = Symbol("__private__dont__use");
|
|
1395
1372
|
class w {
|
|
1396
1373
|
/**
|
|
1397
1374
|
* Initializes a PHP runtime.
|
|
@@ -1401,8 +1378,8 @@ class w {
|
|
|
1401
1378
|
* @param serverOptions - Optional. Options for the PHPRequestHandler. If undefined, no request handler will be initialized.
|
|
1402
1379
|
*/
|
|
1403
1380
|
constructor(e, t) {
|
|
1404
|
-
this.#e = [], this.#t = !1, this.#s = null, this.#r = {}, e !== void 0 && this.initializeRuntime(e), t && (this.requestHandler = new
|
|
1405
|
-
new
|
|
1381
|
+
this.#e = [], this.#t = !1, this.#s = null, this.#r = {}, e !== void 0 && this.initializeRuntime(e), t && (this.requestHandler = new Ge(
|
|
1382
|
+
new Ye(this, t)
|
|
1406
1383
|
));
|
|
1407
1384
|
}
|
|
1408
1385
|
#e;
|
|
@@ -1430,10 +1407,10 @@ class w {
|
|
|
1430
1407
|
initializeRuntime(e) {
|
|
1431
1408
|
if (this[u])
|
|
1432
1409
|
throw new Error("PHP runtime already initialized.");
|
|
1433
|
-
const t =
|
|
1410
|
+
const t = Xe(e);
|
|
1434
1411
|
if (!t)
|
|
1435
1412
|
throw new Error("Invalid PHP runtime id.");
|
|
1436
|
-
this[u] = t, this.#s =
|
|
1413
|
+
this[u] = t, this.#s = qe(t);
|
|
1437
1414
|
}
|
|
1438
1415
|
/** @inheritDoc */
|
|
1439
1416
|
setPhpIniPath(e) {
|
|
@@ -1467,7 +1444,7 @@ class w {
|
|
|
1467
1444
|
this.#t || (this.#i(), this.#t = !0), this.#h(e.scriptPath || ""), this.#o(e.relativeUri || ""), this.#c(e.method || "GET");
|
|
1468
1445
|
const { host: t, ...s } = {
|
|
1469
1446
|
host: "example.com:443",
|
|
1470
|
-
...
|
|
1447
|
+
...ee(e.headers || {})
|
|
1471
1448
|
};
|
|
1472
1449
|
if (this.#a(t, e.protocol || "http"), this.#l(s), e.body && this.#u(e.body), e.fileInfos)
|
|
1473
1450
|
for (const n of e.fileInfos)
|
|
@@ -1538,7 +1515,7 @@ class w {
|
|
|
1538
1515
|
(!s || isNaN(s) || s === 80) && (s = t === "https" ? 443 : 80), this[u].ccall(
|
|
1539
1516
|
"wasm_set_request_port",
|
|
1540
1517
|
null,
|
|
1541
|
-
[
|
|
1518
|
+
[y],
|
|
1542
1519
|
[s]
|
|
1543
1520
|
), (t === "https" || !t && s === 443) && this.addServerGlobalEntry("HTTPS", "on");
|
|
1544
1521
|
}
|
|
@@ -1564,7 +1541,7 @@ class w {
|
|
|
1564
1541
|
), e["content-length"] && this[u].ccall(
|
|
1565
1542
|
"wasm_set_content_length",
|
|
1566
1543
|
null,
|
|
1567
|
-
[
|
|
1544
|
+
[y],
|
|
1568
1545
|
[parseInt(e["content-length"], 10)]
|
|
1569
1546
|
);
|
|
1570
1547
|
for (const t in e)
|
|
@@ -1582,7 +1559,7 @@ class w {
|
|
|
1582
1559
|
), this[u].ccall(
|
|
1583
1560
|
"wasm_set_content_length",
|
|
1584
1561
|
null,
|
|
1585
|
-
[
|
|
1562
|
+
[y],
|
|
1586
1563
|
[new TextEncoder().encode(e).length]
|
|
1587
1564
|
);
|
|
1588
1565
|
}
|
|
@@ -1622,7 +1599,7 @@ class w {
|
|
|
1622
1599
|
this[u].ccall(
|
|
1623
1600
|
"wasm_add_uploaded_file",
|
|
1624
1601
|
null,
|
|
1625
|
-
[p, p, p, p,
|
|
1602
|
+
[p, p, p, p, y, y],
|
|
1626
1603
|
[t, s, n, o, a, i.byteLength]
|
|
1627
1604
|
);
|
|
1628
1605
|
}
|
|
@@ -1647,7 +1624,7 @@ class w {
|
|
|
1647
1624
|
);
|
|
1648
1625
|
const a = this[u].ccall(
|
|
1649
1626
|
"wasm_sapi_handle_request",
|
|
1650
|
-
|
|
1627
|
+
y,
|
|
1651
1628
|
[],
|
|
1652
1629
|
[]
|
|
1653
1630
|
);
|
|
@@ -1694,7 +1671,7 @@ class w {
|
|
|
1694
1671
|
this[u].FS.unlink(e);
|
|
1695
1672
|
}
|
|
1696
1673
|
mv(e, t) {
|
|
1697
|
-
this[u].FS.
|
|
1674
|
+
this[u].FS.rename(e, t);
|
|
1698
1675
|
}
|
|
1699
1676
|
rmdir(e, t = { recursive: !0 }) {
|
|
1700
1677
|
t?.recursive && this.listFiles(e).forEach((s) => {
|
|
@@ -1759,23 +1736,23 @@ m([
|
|
|
1759
1736
|
m([
|
|
1760
1737
|
f('Could not stat "{path}"')
|
|
1761
1738
|
], w.prototype, "fileExists", 1);
|
|
1762
|
-
function
|
|
1739
|
+
function ee(r) {
|
|
1763
1740
|
const e = {};
|
|
1764
1741
|
for (const t in r)
|
|
1765
1742
|
e[t.toLowerCase()] = r[t];
|
|
1766
1743
|
return e;
|
|
1767
1744
|
}
|
|
1768
|
-
const
|
|
1745
|
+
const rt = [
|
|
1769
1746
|
"vfs",
|
|
1770
1747
|
"literal",
|
|
1771
1748
|
"wordpress.org/themes",
|
|
1772
1749
|
"wordpress.org/plugins",
|
|
1773
1750
|
"url"
|
|
1774
1751
|
];
|
|
1775
|
-
function
|
|
1776
|
-
return r && typeof r == "object" && typeof r.resource == "string" &&
|
|
1752
|
+
function st(r) {
|
|
1753
|
+
return r && typeof r == "object" && typeof r.resource == "string" && rt.includes(r.resource);
|
|
1777
1754
|
}
|
|
1778
|
-
class
|
|
1755
|
+
class g {
|
|
1779
1756
|
/**
|
|
1780
1757
|
* Creates a new Resource based on the given file reference
|
|
1781
1758
|
*
|
|
@@ -1787,24 +1764,24 @@ class y {
|
|
|
1787
1764
|
let n;
|
|
1788
1765
|
switch (e.resource) {
|
|
1789
1766
|
case "vfs":
|
|
1790
|
-
n = new
|
|
1767
|
+
n = new nt(e, s);
|
|
1791
1768
|
break;
|
|
1792
1769
|
case "literal":
|
|
1793
|
-
n = new
|
|
1770
|
+
n = new it(e, s);
|
|
1794
1771
|
break;
|
|
1795
1772
|
case "wordpress.org/themes":
|
|
1796
|
-
n = new
|
|
1773
|
+
n = new ct(e, s);
|
|
1797
1774
|
break;
|
|
1798
1775
|
case "wordpress.org/plugins":
|
|
1799
|
-
n = new
|
|
1776
|
+
n = new lt(e, s);
|
|
1800
1777
|
break;
|
|
1801
1778
|
case "url":
|
|
1802
|
-
n = new
|
|
1779
|
+
n = new at(e, s);
|
|
1803
1780
|
break;
|
|
1804
1781
|
default:
|
|
1805
1782
|
throw new Error(`Invalid resource: ${e}`);
|
|
1806
1783
|
}
|
|
1807
|
-
return n = new
|
|
1784
|
+
return n = new ut(n), t && (n = new ht(n, t)), n;
|
|
1808
1785
|
}
|
|
1809
1786
|
setPlayground(e) {
|
|
1810
1787
|
this.playground = e;
|
|
@@ -1814,7 +1791,7 @@ class y {
|
|
|
1814
1791
|
return !1;
|
|
1815
1792
|
}
|
|
1816
1793
|
}
|
|
1817
|
-
class
|
|
1794
|
+
class nt extends g {
|
|
1818
1795
|
/**
|
|
1819
1796
|
* Creates a new instance of `VFSResource`.
|
|
1820
1797
|
* @param playground The playground client.
|
|
@@ -1836,7 +1813,7 @@ class ot extends y {
|
|
|
1836
1813
|
return this.resource.path;
|
|
1837
1814
|
}
|
|
1838
1815
|
}
|
|
1839
|
-
class
|
|
1816
|
+
class it extends g {
|
|
1840
1817
|
/**
|
|
1841
1818
|
* Creates a new instance of `LiteralResource`.
|
|
1842
1819
|
* @param resource The literal reference.
|
|
@@ -1854,7 +1831,7 @@ class at extends y {
|
|
|
1854
1831
|
return this.resource.name;
|
|
1855
1832
|
}
|
|
1856
1833
|
}
|
|
1857
|
-
class
|
|
1834
|
+
class C extends g {
|
|
1858
1835
|
/**
|
|
1859
1836
|
* Creates a new instance of `FetchResource`.
|
|
1860
1837
|
* @param progress The progress tracker.
|
|
@@ -1867,9 +1844,9 @@ class k extends y {
|
|
|
1867
1844
|
this.progress?.setCaption(this.caption);
|
|
1868
1845
|
const e = this.getURL();
|
|
1869
1846
|
let t = await fetch(e);
|
|
1870
|
-
if (t = await
|
|
1847
|
+
if (t = await Ie(
|
|
1871
1848
|
t,
|
|
1872
|
-
this.progress?.loadingListener ??
|
|
1849
|
+
this.progress?.loadingListener ?? ot
|
|
1873
1850
|
), t.status !== 200)
|
|
1874
1851
|
throw new Error(`Could not download "${e}"`);
|
|
1875
1852
|
return new File([await t.blob()], this.name);
|
|
@@ -1894,9 +1871,9 @@ class k extends y {
|
|
|
1894
1871
|
return !0;
|
|
1895
1872
|
}
|
|
1896
1873
|
}
|
|
1897
|
-
const
|
|
1874
|
+
const ot = () => {
|
|
1898
1875
|
};
|
|
1899
|
-
class
|
|
1876
|
+
class at extends C {
|
|
1900
1877
|
/**
|
|
1901
1878
|
* Creates a new instance of `UrlResource`.
|
|
1902
1879
|
* @param resource The URL reference.
|
|
@@ -1915,10 +1892,10 @@ class lt extends k {
|
|
|
1915
1892
|
}
|
|
1916
1893
|
}
|
|
1917
1894
|
let U = "https://playground.wordpress.net/plugin-proxy";
|
|
1918
|
-
function
|
|
1895
|
+
function wt(r) {
|
|
1919
1896
|
U = r;
|
|
1920
1897
|
}
|
|
1921
|
-
class
|
|
1898
|
+
class ct extends C {
|
|
1922
1899
|
constructor(e, t) {
|
|
1923
1900
|
super(t), this.resource = e;
|
|
1924
1901
|
}
|
|
@@ -1926,11 +1903,11 @@ class ut extends k {
|
|
|
1926
1903
|
return E(this.resource.slug);
|
|
1927
1904
|
}
|
|
1928
1905
|
getURL() {
|
|
1929
|
-
const e =
|
|
1906
|
+
const e = te(this.resource.slug);
|
|
1930
1907
|
return `${U}?theme=` + e;
|
|
1931
1908
|
}
|
|
1932
1909
|
}
|
|
1933
|
-
class
|
|
1910
|
+
class lt extends C {
|
|
1934
1911
|
constructor(e, t) {
|
|
1935
1912
|
super(t), this.resource = e;
|
|
1936
1913
|
}
|
|
@@ -1940,14 +1917,14 @@ class ht extends k {
|
|
|
1940
1917
|
}
|
|
1941
1918
|
/** @inheritDoc */
|
|
1942
1919
|
getURL() {
|
|
1943
|
-
const e =
|
|
1920
|
+
const e = te(this.resource.slug);
|
|
1944
1921
|
return `${U}?plugin=` + e;
|
|
1945
1922
|
}
|
|
1946
1923
|
}
|
|
1947
|
-
function
|
|
1924
|
+
function te(r) {
|
|
1948
1925
|
return !r || r.endsWith(".zip") ? r : r + ".latest-stable.zip";
|
|
1949
1926
|
}
|
|
1950
|
-
class
|
|
1927
|
+
class re extends g {
|
|
1951
1928
|
constructor(e) {
|
|
1952
1929
|
super(), this.resource = e;
|
|
1953
1930
|
}
|
|
@@ -1976,13 +1953,13 @@ class se extends y {
|
|
|
1976
1953
|
return this.resource.isAsync;
|
|
1977
1954
|
}
|
|
1978
1955
|
}
|
|
1979
|
-
class
|
|
1956
|
+
class ut extends re {
|
|
1980
1957
|
/** @inheritDoc */
|
|
1981
1958
|
async resolve() {
|
|
1982
1959
|
return this.promise || (this.promise = super.resolve()), this.promise;
|
|
1983
1960
|
}
|
|
1984
1961
|
}
|
|
1985
|
-
class
|
|
1962
|
+
class ht extends re {
|
|
1986
1963
|
constructor(e, t) {
|
|
1987
1964
|
super(e), this.semaphore = t;
|
|
1988
1965
|
}
|
|
@@ -1991,18 +1968,18 @@ class dt extends se {
|
|
|
1991
1968
|
return this.isAsync ? this.semaphore.run(() => super.resolve()) : super.resolve();
|
|
1992
1969
|
}
|
|
1993
1970
|
}
|
|
1994
|
-
const
|
|
1995
|
-
function
|
|
1971
|
+
const pt = ["6.2", "6.1", "6.0", "5.9"];
|
|
1972
|
+
function gt(r, {
|
|
1996
1973
|
progress: e = new F(),
|
|
1997
1974
|
semaphore: t = new Y({ concurrency: 3 }),
|
|
1998
1975
|
onStepCompleted: s = () => {
|
|
1999
1976
|
}
|
|
2000
1977
|
} = {}) {
|
|
2001
|
-
const n = (r.steps || []).filter(
|
|
1978
|
+
const n = (r.steps || []).filter(dt), i = n.reduce(
|
|
2002
1979
|
(a, c) => a + (c.progress?.weight || 1),
|
|
2003
1980
|
0
|
|
2004
1981
|
), o = n.map(
|
|
2005
|
-
(a) =>
|
|
1982
|
+
(a) => ft(a, {
|
|
2006
1983
|
semaphore: t,
|
|
2007
1984
|
rootProgressTracker: e,
|
|
2008
1985
|
totalProgressWeight: i
|
|
@@ -2010,14 +1987,14 @@ function Pt(r, {
|
|
|
2010
1987
|
);
|
|
2011
1988
|
return {
|
|
2012
1989
|
versions: {
|
|
2013
|
-
php:
|
|
1990
|
+
php: G(
|
|
2014
1991
|
r.preferredVersions?.php,
|
|
2015
|
-
|
|
2016
|
-
|
|
1992
|
+
X,
|
|
1993
|
+
Be
|
|
2017
1994
|
),
|
|
2018
|
-
wp:
|
|
1995
|
+
wp: G(
|
|
2019
1996
|
r.preferredVersions?.wp,
|
|
2020
|
-
|
|
1997
|
+
pt,
|
|
2021
1998
|
"6.2"
|
|
2022
1999
|
)
|
|
2023
2000
|
},
|
|
@@ -2042,13 +2019,13 @@ function Pt(r, {
|
|
|
2042
2019
|
}
|
|
2043
2020
|
};
|
|
2044
2021
|
}
|
|
2045
|
-
function
|
|
2022
|
+
function G(r, e, t) {
|
|
2046
2023
|
return r && e.includes(r) ? r : t;
|
|
2047
2024
|
}
|
|
2048
|
-
function
|
|
2025
|
+
function dt(r) {
|
|
2049
2026
|
return !!(typeof r == "object" && r);
|
|
2050
2027
|
}
|
|
2051
|
-
function
|
|
2028
|
+
function ft(r, {
|
|
2052
2029
|
semaphore: e,
|
|
2053
2030
|
rootProgressTracker: t,
|
|
2054
2031
|
totalProgressWeight: s
|
|
@@ -2058,15 +2035,15 @@ function wt(r, {
|
|
|
2058
2035
|
), i = {};
|
|
2059
2036
|
for (const h of Object.keys(r)) {
|
|
2060
2037
|
let d = r[h];
|
|
2061
|
-
|
|
2038
|
+
st(d) && (d = g.create(d, {
|
|
2062
2039
|
semaphore: e
|
|
2063
2040
|
})), i[h] = d;
|
|
2064
2041
|
}
|
|
2065
2042
|
const o = async (h) => {
|
|
2066
2043
|
try {
|
|
2067
|
-
return n.fillSlowly(), await
|
|
2044
|
+
return n.fillSlowly(), await Ae[r.step](
|
|
2068
2045
|
h,
|
|
2069
|
-
await
|
|
2046
|
+
await mt(i),
|
|
2070
2047
|
{
|
|
2071
2048
|
tracker: n,
|
|
2072
2049
|
initialCaption: r.progress?.caption
|
|
@@ -2075,60 +2052,59 @@ function wt(r, {
|
|
|
2075
2052
|
} finally {
|
|
2076
2053
|
n.finish();
|
|
2077
2054
|
}
|
|
2078
|
-
}, a =
|
|
2055
|
+
}, a = V(i), c = V(i).filter(
|
|
2079
2056
|
(h) => h.isAsync
|
|
2080
2057
|
), l = 1 / (c.length + 1);
|
|
2081
2058
|
for (const h of c)
|
|
2082
2059
|
h.progress = n.stage(l);
|
|
2083
2060
|
return { run: o, step: r, resources: a };
|
|
2084
2061
|
}
|
|
2085
|
-
function
|
|
2062
|
+
function V(r) {
|
|
2086
2063
|
const e = [];
|
|
2087
2064
|
for (const t in r) {
|
|
2088
2065
|
const s = r[t];
|
|
2089
|
-
s instanceof
|
|
2066
|
+
s instanceof g && e.push(s);
|
|
2090
2067
|
}
|
|
2091
2068
|
return e;
|
|
2092
2069
|
}
|
|
2093
|
-
async function
|
|
2070
|
+
async function mt(r) {
|
|
2094
2071
|
const e = {};
|
|
2095
2072
|
for (const t in r) {
|
|
2096
2073
|
const s = r[t];
|
|
2097
|
-
s instanceof
|
|
2074
|
+
s instanceof g ? e[t] = await s.resolve() : e[t] = s;
|
|
2098
2075
|
}
|
|
2099
2076
|
return e;
|
|
2100
2077
|
}
|
|
2101
|
-
async function
|
|
2078
|
+
async function yt(r, e) {
|
|
2102
2079
|
await r.run(e);
|
|
2103
2080
|
}
|
|
2104
2081
|
export {
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
Te as
|
|
2115
|
-
Fe as
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
ye as
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
he as
|
|
2125
|
-
pe as runPHPWithOptions,
|
|
2082
|
+
ie as activatePlugin,
|
|
2083
|
+
oe as activateTheme,
|
|
2084
|
+
ce as applyWordPressPatches,
|
|
2085
|
+
gt as compileBlueprint,
|
|
2086
|
+
fe as cp,
|
|
2087
|
+
_e as defineSiteUrl,
|
|
2088
|
+
J as defineWpConfigConsts,
|
|
2089
|
+
Se as importFile,
|
|
2090
|
+
xe as installPlugin,
|
|
2091
|
+
Te as installTheme,
|
|
2092
|
+
Fe as login,
|
|
2093
|
+
we as mkdir,
|
|
2094
|
+
me as mv,
|
|
2095
|
+
ve as replaceSite,
|
|
2096
|
+
de as request,
|
|
2097
|
+
ge as rm,
|
|
2098
|
+
ye as rmdir,
|
|
2099
|
+
yt as runBlueprintSteps,
|
|
2100
|
+
ue as runPHP,
|
|
2101
|
+
he as runPHPWithOptions,
|
|
2126
2102
|
ke as runWpInstallationWizard,
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2103
|
+
pe as setPhpIniEntry,
|
|
2104
|
+
wt as setPluginProxyURL,
|
|
2105
|
+
Ce as setSiteOptions,
|
|
2106
|
+
K as unzip,
|
|
2107
|
+
Ue as updateUserMeta,
|
|
2108
|
+
Pe as writeFile,
|
|
2109
|
+
$e as zipEntireSite
|
|
2134
2110
|
};
|