@wp-playground/blueprints 0.1.56 → 0.1.59
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 +37 -24
- package/index.js +668 -651
- package/lib/steps/activate-plugin.d.ts +1 -1
- package/lib/steps/client-methods.d.ts +1 -1
- package/lib/steps/common.d.ts +6 -3
- package/lib/steps/index.d.ts +7 -7
- package/lib/steps/install-asset.d.ts +23 -0
- package/lib/steps/install-plugin.d.ts +0 -2
- package/lib/steps/install-theme.d.ts +0 -2
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,61 +1,80 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
`${
|
|
5
|
-
`${
|
|
1
|
+
const J = async (s, { pluginPath: e, pluginName: t }, r) => {
|
|
2
|
+
r?.tracker.setCaption(`Activating ${t || e}`);
|
|
3
|
+
const i = [
|
|
4
|
+
`${await s.documentRoot}/wp-load.php`,
|
|
5
|
+
`${await s.documentRoot}/wp-admin/includes/plugin.php`
|
|
6
6
|
];
|
|
7
|
-
if (!
|
|
8
|
-
(
|
|
7
|
+
if (!i.every(
|
|
8
|
+
(a) => s.fileExists(a)
|
|
9
9
|
))
|
|
10
10
|
throw new Error(
|
|
11
|
-
`Required WordPress files do not exist: ${
|
|
11
|
+
`Required WordPress files do not exist: ${i.join(", ")}`
|
|
12
12
|
);
|
|
13
|
-
await
|
|
13
|
+
if ((await s.run({
|
|
14
14
|
code: `<?php
|
|
15
|
-
|
|
15
|
+
${i.map((a) => `require_once( '${a}' );`).join(`
|
|
16
16
|
`)}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
$plugin_path = '${e}';
|
|
18
|
+
if (!is_dir($plugin_path)) {
|
|
19
|
+
activate_plugin($plugin_path);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
// Find plugin entry file
|
|
23
|
+
foreach ( ( glob( $plugin_path . '/*.php' ) ?: array() ) as $file ) {
|
|
24
|
+
$info = get_plugin_data( $file, false, false );
|
|
25
|
+
if ( ! empty( $info['Name'] ) ) {
|
|
26
|
+
activate_plugin( $file );
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
echo 'NO_ENTRY_FILE';
|
|
31
|
+
`
|
|
32
|
+
})).text.endsWith("NO_ENTRY_FILE"))
|
|
33
|
+
throw new Error("Could not find plugin entry file.");
|
|
34
|
+
}, K = async (s, { themeFolderName: e }, t) => {
|
|
21
35
|
t?.tracker.setCaption(`Activating ${e}`);
|
|
22
|
-
const
|
|
23
|
-
if (!
|
|
36
|
+
const r = `${await s.documentRoot}/wp-load.php`;
|
|
37
|
+
if (!s.fileExists(r))
|
|
24
38
|
throw new Error(
|
|
25
|
-
`Required WordPress file does not exist: ${
|
|
39
|
+
`Required WordPress file does not exist: ${r}`
|
|
26
40
|
);
|
|
27
|
-
await
|
|
41
|
+
await s.run({
|
|
28
42
|
code: `<?php
|
|
29
|
-
require_once( '${
|
|
43
|
+
require_once( '${r}' );
|
|
30
44
|
switch_theme( '${e}' );
|
|
31
45
|
`
|
|
32
46
|
});
|
|
33
47
|
};
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
function E(r) {
|
|
38
|
-
const e = r.split(".").shift().replace("-", " ");
|
|
48
|
+
function b(s) {
|
|
49
|
+
const e = s.split(".").shift().replace(/-/g, " ");
|
|
39
50
|
return e.charAt(0).toUpperCase() + e.slice(1).toLowerCase();
|
|
40
51
|
}
|
|
41
|
-
async function P(
|
|
42
|
-
let
|
|
43
|
-
await
|
|
52
|
+
async function P(s, e, t) {
|
|
53
|
+
let r = "";
|
|
54
|
+
await s.fileExists(e) && (r = await s.readFileAsText(e)), await s.writeFile(e, t(r));
|
|
44
55
|
}
|
|
45
|
-
async function ae(
|
|
46
|
-
return new Uint8Array(await
|
|
56
|
+
async function ae(s) {
|
|
57
|
+
return new Uint8Array(await s.arrayBuffer());
|
|
47
58
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
59
|
+
class ce extends File {
|
|
60
|
+
constructor(e, t) {
|
|
61
|
+
super(e, t), this.buffers = e;
|
|
62
|
+
}
|
|
63
|
+
async arrayBuffer() {
|
|
64
|
+
return this.buffers[0];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const R = File.prototype.arrayBuffer instanceof Function ? File : ce, le = async (s, e) => {
|
|
68
|
+
const t = new he(
|
|
69
|
+
s,
|
|
51
70
|
e.siteUrl,
|
|
52
71
|
e.wordpressPath || "/wordpress"
|
|
53
72
|
);
|
|
54
73
|
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
74
|
};
|
|
56
|
-
class
|
|
57
|
-
constructor(e, t,
|
|
58
|
-
this.php = e, this.scopedSiteUrl = t, this.wordpressPath =
|
|
75
|
+
class he {
|
|
76
|
+
constructor(e, t, r) {
|
|
77
|
+
this.php = e, this.scopedSiteUrl = t, this.wordpressPath = r;
|
|
59
78
|
}
|
|
60
79
|
async patchSqlitePlugin() {
|
|
61
80
|
await P(
|
|
@@ -104,47 +123,47 @@ class le {
|
|
|
104
123
|
);
|
|
105
124
|
}
|
|
106
125
|
}
|
|
107
|
-
const ue = async (
|
|
108
|
-
await
|
|
109
|
-
},
|
|
110
|
-
await
|
|
126
|
+
const ue = async (s, { code: e }) => await s.run({ code: e }), pe = async (s, { options: e }) => await s.run(e), de = async (s, { key: e, value: t }) => {
|
|
127
|
+
await s.setPhpIniEntry(e, t);
|
|
128
|
+
}, fe = async (s, { request: e }) => await s.request(e), me = async (s, { fromPath: e, toPath: t }) => {
|
|
129
|
+
await s.writeFile(
|
|
111
130
|
t,
|
|
112
|
-
await
|
|
131
|
+
await s.readFileAsBuffer(e)
|
|
113
132
|
);
|
|
114
|
-
},
|
|
115
|
-
await
|
|
116
|
-
},
|
|
117
|
-
await
|
|
118
|
-
},
|
|
119
|
-
await
|
|
120
|
-
},
|
|
121
|
-
await
|
|
122
|
-
},
|
|
123
|
-
t instanceof File && (t = await ae(t)), await
|
|
124
|
-
},
|
|
125
|
-
const
|
|
126
|
-
return t && (
|
|
127
|
-
|
|
128
|
-
|
|
133
|
+
}, we = async (s, { fromPath: e, toPath: t }) => {
|
|
134
|
+
await s.mv(e, t);
|
|
135
|
+
}, ge = async (s, { path: e }) => {
|
|
136
|
+
await s.mkdir(e);
|
|
137
|
+
}, ye = async (s, { path: e }) => {
|
|
138
|
+
await s.unlink(e);
|
|
139
|
+
}, Pe = async (s, { path: e }) => {
|
|
140
|
+
await s.rmdir(e);
|
|
141
|
+
}, Z = async (s, { path: e, data: t }) => {
|
|
142
|
+
t instanceof File && (t = await ae(t)), await s.writeFile(e, t);
|
|
143
|
+
}, O = "/vfs-blueprints", Q = async (s, { consts: e, virtualize: t = !1 }) => {
|
|
144
|
+
const r = await s.documentRoot, i = t ? O : r, n = `${i}/playground-consts.json`, o = `${i}/wp-config.php`;
|
|
145
|
+
return t && (s.mkdir(O), s.setPhpIniEntry("auto_prepend_file", o)), await P(
|
|
146
|
+
s,
|
|
147
|
+
n,
|
|
129
148
|
(a) => JSON.stringify({
|
|
130
149
|
...JSON.parse(a || "{}"),
|
|
131
150
|
...e
|
|
132
151
|
})
|
|
133
|
-
), await P(
|
|
134
|
-
$consts = json_decode(file_get_contents('${
|
|
152
|
+
), await P(s, o, (a) => a.includes("playground-consts.json") ? a : `<?php
|
|
153
|
+
$consts = json_decode(file_get_contents('${n}'), true);
|
|
135
154
|
foreach ($consts as $const => $value) {
|
|
136
155
|
if (!defined($const)) {
|
|
137
156
|
define($const, $value);
|
|
138
157
|
}
|
|
139
158
|
}
|
|
140
159
|
?>${a}`), o;
|
|
141
|
-
}, _e = async (
|
|
160
|
+
}, _e = async (s, { siteUrl: e }) => await Q(s, {
|
|
142
161
|
consts: {
|
|
143
162
|
WP_HOME: e,
|
|
144
163
|
WP_SITEURL: e
|
|
145
164
|
}
|
|
146
165
|
});
|
|
147
|
-
class
|
|
166
|
+
class X {
|
|
148
167
|
constructor({ concurrency: e }) {
|
|
149
168
|
this._running = 0, this.concurrency = e, this.queue = [];
|
|
150
169
|
}
|
|
@@ -169,29 +188,29 @@ class Y {
|
|
|
169
188
|
}
|
|
170
189
|
}
|
|
171
190
|
}
|
|
172
|
-
const
|
|
173
|
-
function
|
|
174
|
-
if (typeof
|
|
175
|
-
return
|
|
176
|
-
if (typeof
|
|
177
|
-
return
|
|
178
|
-
if (Array.isArray(
|
|
179
|
-
return `array(${
|
|
180
|
-
if (
|
|
191
|
+
const $e = Symbol("literal");
|
|
192
|
+
function $(s) {
|
|
193
|
+
if (typeof s == "string")
|
|
194
|
+
return s.startsWith("$") ? s : JSON.stringify(s);
|
|
195
|
+
if (typeof s == "number")
|
|
196
|
+
return s.toString();
|
|
197
|
+
if (Array.isArray(s))
|
|
198
|
+
return `array(${s.map($).join(", ")})`;
|
|
199
|
+
if (s === null)
|
|
181
200
|
return "null";
|
|
182
|
-
if (typeof
|
|
183
|
-
return
|
|
184
|
-
if (typeof
|
|
185
|
-
return
|
|
186
|
-
throw new Error(`Unsupported value: ${
|
|
201
|
+
if (typeof s == "object")
|
|
202
|
+
return $e in s ? s.toString() : `array(${Object.entries(s).map(([t, r]) => `${JSON.stringify(t)} => ${$(r)}`).join(", ")})`;
|
|
203
|
+
if (typeof s == "function")
|
|
204
|
+
return s();
|
|
205
|
+
throw new Error(`Unsupported value: ${s}`);
|
|
187
206
|
}
|
|
188
|
-
function
|
|
207
|
+
function x(s) {
|
|
189
208
|
const e = {};
|
|
190
|
-
for (const t in
|
|
191
|
-
e[t] =
|
|
209
|
+
for (const t in s)
|
|
210
|
+
e[t] = $(s[t]);
|
|
192
211
|
return e;
|
|
193
212
|
}
|
|
194
|
-
const
|
|
213
|
+
const N = `<?php
|
|
195
214
|
|
|
196
215
|
function zipDir($dir, $output, $additionalFiles = array())
|
|
197
216
|
{
|
|
@@ -254,199 +273,190 @@ function delTree($dir)
|
|
|
254
273
|
return rmdir($dir);
|
|
255
274
|
}
|
|
256
275
|
`;
|
|
257
|
-
async function
|
|
258
|
-
const e = "wordpress-playground.zip", t = `/${e}`,
|
|
276
|
+
async function be(s) {
|
|
277
|
+
const e = "wordpress-playground.zip", t = `/${e}`, r = x({
|
|
259
278
|
zipPath: t,
|
|
260
|
-
documentRoot: await
|
|
279
|
+
documentRoot: await s.documentRoot
|
|
261
280
|
});
|
|
262
|
-
await
|
|
263
|
-
|
|
264
|
-
`zipDir(${
|
|
281
|
+
await ee(
|
|
282
|
+
s,
|
|
283
|
+
`zipDir(${r.documentRoot}, ${r.zipPath});`
|
|
265
284
|
);
|
|
266
|
-
const
|
|
267
|
-
return
|
|
285
|
+
const i = await s.readFileAsBuffer(t);
|
|
286
|
+
return s.unlink(t), new File([i], e);
|
|
268
287
|
}
|
|
269
|
-
const ve = async (
|
|
288
|
+
const ve = async (s, { fullSiteZip: e }) => {
|
|
270
289
|
const t = "/import.zip";
|
|
271
|
-
await
|
|
290
|
+
await s.writeFile(
|
|
272
291
|
t,
|
|
273
292
|
new Uint8Array(await e.arrayBuffer())
|
|
274
293
|
);
|
|
275
|
-
const
|
|
276
|
-
await
|
|
277
|
-
const
|
|
294
|
+
const r = await s.absoluteUrl, i = await s.documentRoot;
|
|
295
|
+
await s.rmdir(i), await F(s, { zipPath: t, extractToPath: "/" });
|
|
296
|
+
const n = x({ absoluteUrl: r });
|
|
278
297
|
await Re(
|
|
279
|
-
|
|
280
|
-
`${
|
|
298
|
+
s,
|
|
299
|
+
`${i}/wp-config.php`,
|
|
281
300
|
(o) => `<?php
|
|
282
301
|
if(!defined('WP_HOME')) {
|
|
283
|
-
define('WP_HOME', ${
|
|
284
|
-
define('WP_SITEURL', ${
|
|
302
|
+
define('WP_HOME', ${n.absoluteUrl});
|
|
303
|
+
define('WP_SITEURL', ${n.absoluteUrl});
|
|
285
304
|
}
|
|
286
305
|
?>${o}`
|
|
287
306
|
);
|
|
288
|
-
},
|
|
289
|
-
const
|
|
307
|
+
}, F = async (s, { zipPath: e, extractToPath: t }) => {
|
|
308
|
+
const r = x({
|
|
290
309
|
zipPath: e,
|
|
291
310
|
extractToPath: t
|
|
292
311
|
});
|
|
293
|
-
await
|
|
294
|
-
|
|
295
|
-
`unzip(${
|
|
312
|
+
await ee(
|
|
313
|
+
s,
|
|
314
|
+
`unzip(${r.zipPath}, ${r.extractToPath});`
|
|
296
315
|
);
|
|
297
|
-
},
|
|
298
|
-
const t = await
|
|
316
|
+
}, Ee = async (s, { file: e }) => {
|
|
317
|
+
const t = await s.request({
|
|
299
318
|
url: "/wp-admin/admin.php?import=wordpress"
|
|
300
|
-
}),
|
|
301
|
-
url: `/wp-admin/${
|
|
319
|
+
}), r = L(t).getElementById("import-upload-form")?.getAttribute("action"), i = await s.request({
|
|
320
|
+
url: `/wp-admin/${r}`,
|
|
302
321
|
method: "POST",
|
|
303
322
|
files: { import: e }
|
|
304
|
-
}),
|
|
323
|
+
}), n = L(i).querySelector(
|
|
305
324
|
"#wpbody-content form"
|
|
306
325
|
);
|
|
307
|
-
if (!
|
|
308
|
-
throw console.log(
|
|
326
|
+
if (!n)
|
|
327
|
+
throw console.log(i.text), new Error(
|
|
309
328
|
"Could not find an importer form in response. See the response text above for details."
|
|
310
329
|
);
|
|
311
|
-
const o =
|
|
330
|
+
const o = Se(n);
|
|
312
331
|
o.fetch_attachments = "1";
|
|
313
332
|
for (const a in o)
|
|
314
333
|
if (a.startsWith("user_map[")) {
|
|
315
|
-
const
|
|
316
|
-
o[
|
|
334
|
+
const l = "user_new[" + a.slice(9, -1) + "]";
|
|
335
|
+
o[l] = "1";
|
|
317
336
|
}
|
|
318
|
-
await
|
|
319
|
-
url:
|
|
337
|
+
await s.request({
|
|
338
|
+
url: n.action,
|
|
320
339
|
method: "POST",
|
|
321
340
|
formData: o
|
|
322
341
|
});
|
|
323
342
|
};
|
|
324
|
-
function
|
|
325
|
-
return new DOMParser().parseFromString(
|
|
343
|
+
function L(s) {
|
|
344
|
+
return new DOMParser().parseFromString(s.text, "text/html");
|
|
326
345
|
}
|
|
327
|
-
function
|
|
328
|
-
return Object.fromEntries(new FormData(
|
|
346
|
+
function Se(s) {
|
|
347
|
+
return Object.fromEntries(new FormData(s).entries());
|
|
329
348
|
}
|
|
330
|
-
async function Re(
|
|
331
|
-
await
|
|
349
|
+
async function Re(s, e, t) {
|
|
350
|
+
await s.writeFile(
|
|
332
351
|
e,
|
|
333
|
-
t(await
|
|
352
|
+
t(await s.readFileAsText(e))
|
|
334
353
|
);
|
|
335
354
|
}
|
|
336
|
-
async function
|
|
337
|
-
const t = await
|
|
338
|
-
code:
|
|
355
|
+
async function ee(s, e) {
|
|
356
|
+
const t = await s.run({
|
|
357
|
+
code: N + e
|
|
339
358
|
});
|
|
340
359
|
if (t.exitCode !== 0)
|
|
341
|
-
throw console.log(
|
|
360
|
+
throw console.log(N + e), console.log(e + ""), console.log(t.errors), t.errors;
|
|
342
361
|
return t;
|
|
343
362
|
}
|
|
344
|
-
|
|
345
|
-
s
|
|
346
|
-
|
|
347
|
-
);
|
|
363
|
+
async function te(s, { targetPath: e, zipFile: t }) {
|
|
364
|
+
const r = t.name, i = r.replace(/\.zip$/, ""), n = `/tmp/assets/${i}`, o = `/tmp/${r}`, a = () => s.rmdir(n, {
|
|
365
|
+
recursive: !0
|
|
366
|
+
});
|
|
367
|
+
await s.fileExists(n) && await a(), await Z(s, {
|
|
368
|
+
path: o,
|
|
369
|
+
data: t
|
|
370
|
+
});
|
|
371
|
+
const l = () => Promise.all([a, () => s.unlink(o)]);
|
|
348
372
|
try {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
o.querySelector(".wp-upload-form")
|
|
353
|
-
), { pluginzip: c, ...l } = Object.fromEntries(
|
|
354
|
-
a.entries()
|
|
355
|
-
), h = await r.request({
|
|
356
|
-
url: "/wp-admin/update.php?action=upload-plugin",
|
|
357
|
-
method: "POST",
|
|
358
|
-
formData: l,
|
|
359
|
-
files: { pluginzip: e }
|
|
373
|
+
await F(s, {
|
|
374
|
+
zipPath: o,
|
|
375
|
+
extractToPath: n
|
|
360
376
|
});
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
377
|
+
const c = await s.listFiles(n, {
|
|
378
|
+
prependPath: !0
|
|
379
|
+
}), u = c.length === 1 && await s.isDir(c[0]);
|
|
380
|
+
let d, v = "";
|
|
381
|
+
u ? (v = c[0], d = c[0].split("/").pop()) : (v = n, d = i);
|
|
382
|
+
const U = `${e}/${d}`;
|
|
383
|
+
return await s.mv(v, U), await l(), {
|
|
384
|
+
assetFolderPath: U,
|
|
385
|
+
assetFolderName: d
|
|
386
|
+
};
|
|
387
|
+
} catch (c) {
|
|
388
|
+
throw await l(), c;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
const xe = async (s, { pluginZipFile: e, options: t = {} }, r) => {
|
|
392
|
+
const i = e.name.split("/").pop() || "plugin.zip", n = b(i);
|
|
393
|
+
r?.tracker.setCaption(`Installing the ${n} plugin`);
|
|
394
|
+
try {
|
|
395
|
+
const { assetFolderPath: o } = await te(s, {
|
|
396
|
+
zipFile: e,
|
|
397
|
+
targetPath: `${await s.documentRoot}/wp-content/plugins`
|
|
398
|
+
});
|
|
399
|
+
("activate" in t ? t.activate : !0) && await J(
|
|
400
|
+
s,
|
|
401
|
+
{
|
|
402
|
+
pluginPath: o,
|
|
403
|
+
pluginName: n
|
|
404
|
+
},
|
|
405
|
+
r
|
|
406
|
+
), await Fe(s);
|
|
407
|
+
} catch (o) {
|
|
388
408
|
console.error(
|
|
389
|
-
`Proceeding without the ${
|
|
390
|
-
), console.error(
|
|
409
|
+
`Proceeding without the ${n} plugin. Could not install it in wp-admin. The original error was: ${o}`
|
|
410
|
+
), console.error(o);
|
|
391
411
|
}
|
|
392
412
|
};
|
|
393
|
-
async function
|
|
394
|
-
|
|
413
|
+
async function Fe(s) {
|
|
414
|
+
await s.isDir("/wordpress/wp-content/plugins/gutenberg") && !await s.fileExists("/wordpress/.gutenberg-patched") && (await s.writeFile("/wordpress/.gutenberg-patched", "1"), await H(
|
|
415
|
+
s,
|
|
416
|
+
"/wordpress/wp-content/plugins/gutenberg/build/block-editor/index.js",
|
|
417
|
+
(e) => e.replace(
|
|
418
|
+
/srcDoc:("[^"]+"|[^,]+)/g,
|
|
419
|
+
'src:"/wp-includes/empty.html"'
|
|
420
|
+
)
|
|
421
|
+
), await H(
|
|
422
|
+
s,
|
|
423
|
+
"/wordpress/wp-content/plugins/gutenberg/build/block-editor/index.min.js",
|
|
424
|
+
(e) => e.replace(
|
|
425
|
+
/srcDoc:("[^"]+"|[^,]+)/g,
|
|
426
|
+
'src:"/wp-includes/empty.html"'
|
|
427
|
+
)
|
|
428
|
+
));
|
|
429
|
+
}
|
|
430
|
+
async function H(s, e, t) {
|
|
431
|
+
return await s.writeFile(
|
|
395
432
|
e,
|
|
396
|
-
t(await
|
|
433
|
+
t(await s.readFileAsText(e))
|
|
397
434
|
);
|
|
398
435
|
}
|
|
399
|
-
const Te = async (
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
);
|
|
436
|
+
const Te = async (s, { themeZipFile: e, options: t = {} }, r) => {
|
|
437
|
+
const i = b(e.name);
|
|
438
|
+
r?.tracker.setCaption(`Installing the ${i} theme`);
|
|
403
439
|
try {
|
|
404
|
-
const
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
o.querySelector(".wp-upload-form")
|
|
408
|
-
), { themezip: c, ...l } = Object.fromEntries(
|
|
409
|
-
a.entries()
|
|
410
|
-
), h = await r.request({
|
|
411
|
-
url: "/wp-admin/update.php?action=upload-theme",
|
|
412
|
-
method: "POST",
|
|
413
|
-
formData: l,
|
|
414
|
-
files: { themezip: e }
|
|
440
|
+
const { assetFolderName: n } = await te(s, {
|
|
441
|
+
zipFile: e,
|
|
442
|
+
targetPath: `${await s.documentRoot}/wp-content/themes`
|
|
415
443
|
});
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
console.error($?.textContent);
|
|
424
|
-
return;
|
|
425
|
-
}
|
|
426
|
-
const v = d.querySelector(
|
|
427
|
-
"#wpbody-content .activatelink, .update-from-upload-actions .button.button-primary"
|
|
428
|
-
);
|
|
429
|
-
if (!v) {
|
|
430
|
-
console.error('The "activate" button was not found.');
|
|
431
|
-
return;
|
|
432
|
-
}
|
|
433
|
-
const se = v.attributes.getNamedItem("href").value, ne = new URL(
|
|
434
|
-
se,
|
|
435
|
-
await r.pathToInternalUrl("/wp-admin/")
|
|
436
|
-
).toString();
|
|
437
|
-
await r.request({
|
|
438
|
-
url: ne
|
|
439
|
-
});
|
|
440
|
-
}
|
|
444
|
+
("activate" in t ? t.activate : !0) && await K(
|
|
445
|
+
s,
|
|
446
|
+
{
|
|
447
|
+
themeFolderName: n
|
|
448
|
+
},
|
|
449
|
+
r
|
|
450
|
+
);
|
|
441
451
|
} catch (n) {
|
|
442
452
|
console.error(
|
|
443
|
-
`Proceeding without the ${
|
|
453
|
+
`Proceeding without the ${i} theme. Could not install it in wp-admin. The original error was: ${n}`
|
|
444
454
|
), console.error(n);
|
|
445
455
|
}
|
|
446
|
-
},
|
|
447
|
-
|
|
456
|
+
}, ke = async (s, { username: e = "admin", password: t = "password" } = {}, r) => {
|
|
457
|
+
r?.tracker.setCaption(r?.initialCaption || "Logging in"), await s.request({
|
|
448
458
|
url: "/wp-login.php"
|
|
449
|
-
}), await
|
|
459
|
+
}), await s.request({
|
|
450
460
|
url: "/wp-login.php",
|
|
451
461
|
method: "POST",
|
|
452
462
|
formData: {
|
|
@@ -455,8 +465,8 @@ const Te = async (r, { themeZipFile: e, options: t = {} }, s) => {
|
|
|
455
465
|
rememberme: "forever"
|
|
456
466
|
}
|
|
457
467
|
});
|
|
458
|
-
},
|
|
459
|
-
await
|
|
468
|
+
}, Ce = async (s, { options: e }) => {
|
|
469
|
+
await s.request({
|
|
460
470
|
url: "/wp-admin/install.php?step=2",
|
|
461
471
|
method: "POST",
|
|
462
472
|
formData: {
|
|
@@ -472,70 +482,70 @@ const Te = async (r, { themeZipFile: e, options: t = {} }, s) => {
|
|
|
472
482
|
admin_email: "admin@localhost.com"
|
|
473
483
|
}
|
|
474
484
|
});
|
|
475
|
-
},
|
|
485
|
+
}, Ae = async (s, { options: e }) => {
|
|
476
486
|
const t = `<?php
|
|
477
487
|
include 'wordpress/wp-load.php';
|
|
478
|
-
$site_options = ${
|
|
488
|
+
$site_options = ${$(e)};
|
|
479
489
|
foreach($site_options as $name => $value) {
|
|
480
490
|
update_option($name, $value);
|
|
481
491
|
}
|
|
482
492
|
echo "Success";
|
|
483
|
-
`,
|
|
493
|
+
`, r = await s.run({
|
|
484
494
|
code: t
|
|
485
495
|
});
|
|
486
|
-
return
|
|
487
|
-
}, Ue = async (
|
|
488
|
-
const
|
|
496
|
+
return se(r), { code: t, result: r };
|
|
497
|
+
}, Ue = async (s, { meta: e, userId: t }) => {
|
|
498
|
+
const r = `<?php
|
|
489
499
|
include 'wordpress/wp-load.php';
|
|
490
|
-
$meta = ${
|
|
500
|
+
$meta = ${$(e)};
|
|
491
501
|
foreach($meta as $name => $value) {
|
|
492
|
-
update_user_meta(${
|
|
502
|
+
update_user_meta(${$(t)}, $name, $value);
|
|
493
503
|
}
|
|
494
504
|
echo "Success";
|
|
495
|
-
`,
|
|
496
|
-
code:
|
|
505
|
+
`, i = await s.run({
|
|
506
|
+
code: r
|
|
497
507
|
});
|
|
498
|
-
return
|
|
508
|
+
return se(i), { code: r, result: i };
|
|
499
509
|
};
|
|
500
|
-
async function
|
|
501
|
-
if (
|
|
502
|
-
throw console.log(
|
|
510
|
+
async function se(s) {
|
|
511
|
+
if (s.text !== "Success")
|
|
512
|
+
throw console.log(s), new Error(`Failed to run code: ${s.text} ${s.errors}`);
|
|
503
513
|
}
|
|
504
|
-
const
|
|
514
|
+
const Oe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
505
515
|
__proto__: null,
|
|
506
|
-
activatePlugin:
|
|
507
|
-
activateTheme:
|
|
508
|
-
applyWordPressPatches:
|
|
509
|
-
cp:
|
|
516
|
+
activatePlugin: J,
|
|
517
|
+
activateTheme: K,
|
|
518
|
+
applyWordPressPatches: le,
|
|
519
|
+
cp: me,
|
|
510
520
|
defineSiteUrl: _e,
|
|
511
|
-
defineWpConfigConsts:
|
|
512
|
-
importFile:
|
|
521
|
+
defineWpConfigConsts: Q,
|
|
522
|
+
importFile: Ee,
|
|
513
523
|
installPlugin: xe,
|
|
514
524
|
installTheme: Te,
|
|
515
|
-
login:
|
|
516
|
-
mkdir:
|
|
517
|
-
mv:
|
|
525
|
+
login: ke,
|
|
526
|
+
mkdir: ge,
|
|
527
|
+
mv: we,
|
|
518
528
|
replaceSite: ve,
|
|
519
|
-
request:
|
|
520
|
-
rm:
|
|
521
|
-
rmdir:
|
|
529
|
+
request: fe,
|
|
530
|
+
rm: ye,
|
|
531
|
+
rmdir: Pe,
|
|
522
532
|
runPHP: ue,
|
|
523
|
-
runPHPWithOptions:
|
|
524
|
-
runWpInstallationWizard:
|
|
525
|
-
setPhpIniEntry:
|
|
526
|
-
setSiteOptions:
|
|
527
|
-
unzip:
|
|
533
|
+
runPHPWithOptions: pe,
|
|
534
|
+
runWpInstallationWizard: Ce,
|
|
535
|
+
setPhpIniEntry: de,
|
|
536
|
+
setSiteOptions: Ae,
|
|
537
|
+
unzip: F,
|
|
528
538
|
updateUserMeta: Ue,
|
|
529
|
-
writeFile:
|
|
530
|
-
zipEntireSite:
|
|
531
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
532
|
-
function
|
|
533
|
-
const t =
|
|
534
|
-
function n
|
|
539
|
+
writeFile: Z,
|
|
540
|
+
zipEntireSite: be
|
|
541
|
+
}, Symbol.toStringTag, { value: "Module" })), Ne = 5 * 1024 * 1024;
|
|
542
|
+
function Le(s, e) {
|
|
543
|
+
const t = s.headers.get("content-length") || "", r = parseInt(t, 10) || Ne;
|
|
544
|
+
function i(n, o) {
|
|
535
545
|
e(
|
|
536
546
|
new CustomEvent("progress", {
|
|
537
547
|
detail: {
|
|
538
|
-
loaded:
|
|
548
|
+
loaded: n,
|
|
539
549
|
total: o
|
|
540
550
|
}
|
|
541
551
|
})
|
|
@@ -543,42 +553,42 @@ function Ie(r, e) {
|
|
|
543
553
|
}
|
|
544
554
|
return new Response(
|
|
545
555
|
new ReadableStream({
|
|
546
|
-
async start(
|
|
547
|
-
if (!
|
|
548
|
-
|
|
556
|
+
async start(n) {
|
|
557
|
+
if (!s.body) {
|
|
558
|
+
n.close();
|
|
549
559
|
return;
|
|
550
560
|
}
|
|
551
|
-
const o =
|
|
561
|
+
const o = s.body.getReader();
|
|
552
562
|
let a = 0;
|
|
553
563
|
for (; ; )
|
|
554
564
|
try {
|
|
555
|
-
const { done:
|
|
556
|
-
if (
|
|
557
|
-
|
|
565
|
+
const { done: l, value: c } = await o.read();
|
|
566
|
+
if (c && (a += c.byteLength), l) {
|
|
567
|
+
i(a, a), n.close();
|
|
558
568
|
break;
|
|
559
569
|
} else
|
|
560
|
-
|
|
561
|
-
} catch (
|
|
562
|
-
console.error({ e:
|
|
570
|
+
i(a, r), n.enqueue(c);
|
|
571
|
+
} catch (l) {
|
|
572
|
+
console.error({ e: l }), n.error(l);
|
|
563
573
|
break;
|
|
564
574
|
}
|
|
565
575
|
}
|
|
566
576
|
}),
|
|
567
577
|
{
|
|
568
|
-
status:
|
|
569
|
-
statusText:
|
|
570
|
-
headers:
|
|
578
|
+
status: s.status,
|
|
579
|
+
statusText: s.statusText,
|
|
580
|
+
headers: s.headers
|
|
571
581
|
}
|
|
572
582
|
);
|
|
573
583
|
}
|
|
574
|
-
const
|
|
575
|
-
class
|
|
584
|
+
const E = 1e-5;
|
|
585
|
+
class T extends EventTarget {
|
|
576
586
|
constructor({
|
|
577
587
|
weight: e = 1,
|
|
578
588
|
caption: t = "",
|
|
579
|
-
fillTime:
|
|
589
|
+
fillTime: r = 4
|
|
580
590
|
} = {}) {
|
|
581
|
-
super(), this._selfWeight = 1, this._selfDone = !1, this._selfProgress = 0, this._selfCaption = "", this._isFilling = !1, this._subTrackers = [], this._weight = e, this._selfCaption = t, this._fillTime =
|
|
591
|
+
super(), this._selfWeight = 1, this._selfDone = !1, this._selfProgress = 0, this._selfCaption = "", this._isFilling = !1, this._subTrackers = [], this._weight = e, this._selfCaption = t, this._fillTime = r;
|
|
582
592
|
}
|
|
583
593
|
/**
|
|
584
594
|
* Creates a new sub-tracker with a specific weight.
|
|
@@ -616,19 +626,19 @@ class F extends EventTarget {
|
|
|
616
626
|
* ```
|
|
617
627
|
*/
|
|
618
628
|
stage(e, t = "") {
|
|
619
|
-
if (e || (e = this._selfWeight), this._selfWeight - e < -
|
|
629
|
+
if (e || (e = this._selfWeight), this._selfWeight - e < -E)
|
|
620
630
|
throw new Error(
|
|
621
631
|
`Cannot add a stage with weight ${e} as the total weight of registered stages would exceed 1.`
|
|
622
632
|
);
|
|
623
633
|
this._selfWeight -= e;
|
|
624
|
-
const
|
|
634
|
+
const r = new T({
|
|
625
635
|
caption: t,
|
|
626
636
|
weight: e,
|
|
627
637
|
fillTime: this._fillTime
|
|
628
638
|
});
|
|
629
|
-
return this._subTrackers.push(
|
|
639
|
+
return this._subTrackers.push(r), r.addEventListener("progress", () => this.notifyProgress()), r.addEventListener("done", () => {
|
|
630
640
|
this.done && this.notifyDone();
|
|
631
|
-
}),
|
|
641
|
+
}), r;
|
|
632
642
|
}
|
|
633
643
|
/**
|
|
634
644
|
* Fills the progress bar slowly over time, simulating progress.
|
|
@@ -652,13 +662,13 @@ class F extends EventTarget {
|
|
|
652
662
|
if (this._isFilling)
|
|
653
663
|
return;
|
|
654
664
|
this._isFilling = !0;
|
|
655
|
-
const t = 100,
|
|
665
|
+
const t = 100, r = this._fillTime / t;
|
|
656
666
|
this._fillInterval = setInterval(() => {
|
|
657
667
|
this.set(this._selfProgress + 1), e && this._selfProgress >= 99 && clearInterval(this._fillInterval);
|
|
658
|
-
},
|
|
668
|
+
}, r);
|
|
659
669
|
}
|
|
660
670
|
set(e) {
|
|
661
|
-
this._selfProgress = Math.min(e, 100), this.notifyProgress(), this._selfProgress +
|
|
671
|
+
this._selfProgress = Math.min(e, 100), this.notifyProgress(), this._selfProgress + E >= 100 && this.finish();
|
|
662
672
|
}
|
|
663
673
|
finish() {
|
|
664
674
|
this._fillInterval && clearInterval(this._fillInterval), this._selfDone = !0, this._selfProgress = 100, this._isFilling = !1, this._fillInterval = void 0, this.notifyProgress(), this.notifyDone();
|
|
@@ -676,13 +686,13 @@ class F extends EventTarget {
|
|
|
676
686
|
this._selfCaption = e, this.notifyProgress();
|
|
677
687
|
}
|
|
678
688
|
get done() {
|
|
679
|
-
return this.progress +
|
|
689
|
+
return this.progress + E >= 100;
|
|
680
690
|
}
|
|
681
691
|
get progress() {
|
|
682
692
|
if (this._selfDone)
|
|
683
693
|
return 100;
|
|
684
694
|
const e = this._subTrackers.reduce(
|
|
685
|
-
(t,
|
|
695
|
+
(t, r) => t + r.progress * r.weight,
|
|
686
696
|
this._selfProgress * this._selfWeight
|
|
687
697
|
);
|
|
688
698
|
return Math.round(e * 1e4) / 1e4;
|
|
@@ -738,7 +748,7 @@ class F extends EventTarget {
|
|
|
738
748
|
this.dispatchEvent(new CustomEvent("done"));
|
|
739
749
|
}
|
|
740
750
|
}
|
|
741
|
-
const
|
|
751
|
+
const I = Symbol("error"), W = Symbol("message");
|
|
742
752
|
class k extends Event {
|
|
743
753
|
/**
|
|
744
754
|
* Create a new `ErrorEvent`.
|
|
@@ -748,19 +758,19 @@ class k extends Event {
|
|
|
748
758
|
* attributes via object members of the same name.
|
|
749
759
|
*/
|
|
750
760
|
constructor(e, t = {}) {
|
|
751
|
-
super(e), this[
|
|
761
|
+
super(e), this[I] = t.error === void 0 ? null : t.error, this[W] = t.message === void 0 ? "" : t.message;
|
|
752
762
|
}
|
|
753
763
|
get error() {
|
|
754
|
-
return this[
|
|
764
|
+
return this[I];
|
|
755
765
|
}
|
|
756
766
|
get message() {
|
|
757
|
-
return this[
|
|
767
|
+
return this[W];
|
|
758
768
|
}
|
|
759
769
|
}
|
|
760
770
|
Object.defineProperty(k.prototype, "error", { enumerable: !0 });
|
|
761
771
|
Object.defineProperty(k.prototype, "message", { enumerable: !0 });
|
|
762
|
-
const
|
|
763
|
-
class
|
|
772
|
+
const He = typeof globalThis.ErrorEvent == "function" ? globalThis.ErrorEvent : k;
|
|
773
|
+
class Ie extends EventTarget {
|
|
764
774
|
constructor() {
|
|
765
775
|
super(...arguments), this.listenersCount = 0;
|
|
766
776
|
}
|
|
@@ -774,31 +784,31 @@ class He extends EventTarget {
|
|
|
774
784
|
return this.listenersCount > 0;
|
|
775
785
|
}
|
|
776
786
|
}
|
|
777
|
-
function
|
|
778
|
-
|
|
779
|
-
...
|
|
787
|
+
function We(s) {
|
|
788
|
+
s.asm = {
|
|
789
|
+
...s.asm
|
|
780
790
|
};
|
|
781
|
-
const e = new
|
|
782
|
-
for (const t in
|
|
783
|
-
if (typeof
|
|
784
|
-
const
|
|
785
|
-
|
|
791
|
+
const e = new Ie();
|
|
792
|
+
for (const t in s.asm)
|
|
793
|
+
if (typeof s.asm[t] == "function") {
|
|
794
|
+
const r = s.asm[t];
|
|
795
|
+
s.asm[t] = function(...i) {
|
|
786
796
|
try {
|
|
787
|
-
return
|
|
788
|
-
} catch (
|
|
789
|
-
if (!(
|
|
790
|
-
throw
|
|
791
|
-
if ("exitCode" in
|
|
797
|
+
return r(...i);
|
|
798
|
+
} catch (n) {
|
|
799
|
+
if (!(n instanceof Error))
|
|
800
|
+
throw n;
|
|
801
|
+
if ("exitCode" in n && n?.exitCode === 0)
|
|
792
802
|
return;
|
|
793
|
-
const o =
|
|
794
|
-
|
|
795
|
-
|
|
803
|
+
const o = ze(
|
|
804
|
+
n,
|
|
805
|
+
s.lastAsyncifyStackSource?.stack
|
|
796
806
|
);
|
|
797
|
-
if (
|
|
798
|
-
throw
|
|
807
|
+
if (s.lastAsyncifyStackSource && (n.cause = s.lastAsyncifyStackSource), !e.hasListeners())
|
|
808
|
+
throw Be(o), n;
|
|
799
809
|
e.dispatchEvent(
|
|
800
|
-
new
|
|
801
|
-
error:
|
|
810
|
+
new He("error", {
|
|
811
|
+
error: n,
|
|
802
812
|
message: o
|
|
803
813
|
})
|
|
804
814
|
);
|
|
@@ -807,29 +817,29 @@ function qe(r) {
|
|
|
807
817
|
}
|
|
808
818
|
return e;
|
|
809
819
|
}
|
|
810
|
-
let
|
|
811
|
-
function
|
|
812
|
-
return
|
|
820
|
+
let S = [];
|
|
821
|
+
function qe() {
|
|
822
|
+
return S;
|
|
813
823
|
}
|
|
814
|
-
function
|
|
815
|
-
if (
|
|
816
|
-
let t =
|
|
824
|
+
function ze(s, e) {
|
|
825
|
+
if (s.message === "unreachable") {
|
|
826
|
+
let t = De;
|
|
817
827
|
e || (t += `
|
|
818
828
|
|
|
819
829
|
This stack trace is lacking. For a better one initialize
|
|
820
830
|
the PHP runtime with { debug: true }, e.g. PHPNode.load('8.1', { debug: true }).
|
|
821
831
|
|
|
822
|
-
`),
|
|
823
|
-
e ||
|
|
832
|
+
`), S = je(
|
|
833
|
+
e || s.stack || ""
|
|
824
834
|
);
|
|
825
|
-
for (const
|
|
826
|
-
t += ` * ${
|
|
835
|
+
for (const r of S)
|
|
836
|
+
t += ` * ${r}
|
|
827
837
|
`;
|
|
828
838
|
return t;
|
|
829
839
|
}
|
|
830
|
-
return
|
|
840
|
+
return s.message;
|
|
831
841
|
}
|
|
832
|
-
const
|
|
842
|
+
const De = `
|
|
833
843
|
"unreachable" WASM instruction executed.
|
|
834
844
|
|
|
835
845
|
The typical reason is a PHP function missing from the ASYNCIFY_ONLY
|
|
@@ -853,30 +863,30 @@ the Dockerfile, you'll need to trigger this error again with long stack
|
|
|
853
863
|
traces enabled. In node.js, you can do it using the --stack-trace-limit=100
|
|
854
864
|
CLI option:
|
|
855
865
|
|
|
856
|
-
`,
|
|
866
|
+
`, q = "\x1B[41m", Me = "\x1B[1m", z = "\x1B[0m", D = "\x1B[K";
|
|
857
867
|
let M = !1;
|
|
858
|
-
function
|
|
868
|
+
function Be(s) {
|
|
859
869
|
if (!M) {
|
|
860
|
-
M = !0, console.log(`${
|
|
861
|
-
${
|
|
862
|
-
${Me} WASM ERROR${
|
|
863
|
-
for (const e of
|
|
870
|
+
M = !0, console.log(`${q}
|
|
871
|
+
${D}
|
|
872
|
+
${Me} WASM ERROR${z}${q}`);
|
|
873
|
+
for (const e of s.split(`
|
|
864
874
|
`))
|
|
865
|
-
console.log(`${
|
|
866
|
-
console.log(`${
|
|
875
|
+
console.log(`${D} ${e} `);
|
|
876
|
+
console.log(`${z}`);
|
|
867
877
|
}
|
|
868
878
|
}
|
|
869
|
-
function
|
|
879
|
+
function je(s) {
|
|
870
880
|
try {
|
|
871
|
-
const e =
|
|
881
|
+
const e = s.split(`
|
|
872
882
|
`).slice(1).map((t) => {
|
|
873
|
-
const
|
|
883
|
+
const r = t.trim().substring(3).split(" ");
|
|
874
884
|
return {
|
|
875
|
-
fn:
|
|
885
|
+
fn: r.length >= 2 ? r[0] : "<unknown>",
|
|
876
886
|
isWasm: t.includes("wasm://")
|
|
877
887
|
};
|
|
878
888
|
}).filter(
|
|
879
|
-
({ fn: t, isWasm:
|
|
889
|
+
({ fn: t, isWasm: r }) => r && !t.startsWith("dynCall_") && !t.startsWith("invoke_")
|
|
880
890
|
).map(({ fn: t }) => t);
|
|
881
891
|
return Array.from(new Set(e));
|
|
882
892
|
} catch {
|
|
@@ -884,8 +894,8 @@ function ze(r) {
|
|
|
884
894
|
}
|
|
885
895
|
}
|
|
886
896
|
class _ {
|
|
887
|
-
constructor(e, t,
|
|
888
|
-
this.httpStatusCode = e, this.headers = t, this.bytes =
|
|
897
|
+
constructor(e, t, r, i = "", n = 0) {
|
|
898
|
+
this.httpStatusCode = e, this.headers = t, this.bytes = r, this.exitCode = n, this.errors = i;
|
|
889
899
|
}
|
|
890
900
|
static fromRawData(e) {
|
|
891
901
|
return new _(
|
|
@@ -918,7 +928,7 @@ class _ {
|
|
|
918
928
|
return new TextDecoder().decode(this.bytes);
|
|
919
929
|
}
|
|
920
930
|
}
|
|
921
|
-
const
|
|
931
|
+
const re = [
|
|
922
932
|
"8.2",
|
|
923
933
|
"8.1",
|
|
924
934
|
"8.0",
|
|
@@ -928,8 +938,8 @@ const X = [
|
|
|
928
938
|
"7.1",
|
|
929
939
|
"7.0",
|
|
930
940
|
"5.6"
|
|
931
|
-
],
|
|
932
|
-
class
|
|
941
|
+
], Ge = re[0];
|
|
942
|
+
class Ve {
|
|
933
943
|
#e;
|
|
934
944
|
#t;
|
|
935
945
|
/**
|
|
@@ -958,28 +968,28 @@ class Ge {
|
|
|
958
968
|
* @returns PHPRequestHandler response.
|
|
959
969
|
*/
|
|
960
970
|
async request(e, t = 0) {
|
|
961
|
-
const
|
|
971
|
+
const r = await this.requestHandler.request({
|
|
962
972
|
...e,
|
|
963
973
|
headers: {
|
|
964
974
|
...e.headers,
|
|
965
|
-
cookie: this.#
|
|
975
|
+
cookie: this.#s()
|
|
966
976
|
}
|
|
967
977
|
});
|
|
968
|
-
if (
|
|
969
|
-
const
|
|
970
|
-
|
|
978
|
+
if (r.headers["set-cookie"] && this.#r(r.headers["set-cookie"]), this.#t.handleRedirects && r.headers.location && t < this.#t.maxRedirects) {
|
|
979
|
+
const i = new URL(
|
|
980
|
+
r.headers.location[0],
|
|
971
981
|
this.requestHandler.absoluteUrl
|
|
972
982
|
);
|
|
973
983
|
return this.request(
|
|
974
984
|
{
|
|
975
|
-
url:
|
|
985
|
+
url: i.toString(),
|
|
976
986
|
method: "GET",
|
|
977
987
|
headers: {}
|
|
978
988
|
},
|
|
979
989
|
t + 1
|
|
980
990
|
);
|
|
981
991
|
}
|
|
982
|
-
return
|
|
992
|
+
return r;
|
|
983
993
|
}
|
|
984
994
|
/** @inheritDoc */
|
|
985
995
|
pathToInternalUrl(e) {
|
|
@@ -997,41 +1007,41 @@ class Ge {
|
|
|
997
1007
|
get documentRoot() {
|
|
998
1008
|
return this.requestHandler.documentRoot;
|
|
999
1009
|
}
|
|
1000
|
-
#
|
|
1010
|
+
#r(e) {
|
|
1001
1011
|
for (const t of e)
|
|
1002
1012
|
try {
|
|
1003
1013
|
if (!t.includes("="))
|
|
1004
1014
|
continue;
|
|
1005
|
-
const
|
|
1006
|
-
this.#e[
|
|
1007
|
-
} catch (
|
|
1008
|
-
console.error(
|
|
1015
|
+
const r = t.indexOf("="), i = t.substring(0, r), n = t.substring(r + 1).split(";")[0];
|
|
1016
|
+
this.#e[i] = n;
|
|
1017
|
+
} catch (r) {
|
|
1018
|
+
console.error(r);
|
|
1009
1019
|
}
|
|
1010
1020
|
}
|
|
1011
|
-
#
|
|
1021
|
+
#s() {
|
|
1012
1022
|
const e = [];
|
|
1013
1023
|
for (const t in this.#e)
|
|
1014
1024
|
e.push(`${t}=${this.#e[t]}`);
|
|
1015
1025
|
return e.join("; ");
|
|
1016
1026
|
}
|
|
1017
1027
|
}
|
|
1018
|
-
const
|
|
1019
|
-
function
|
|
1020
|
-
return
|
|
1028
|
+
const Ye = "http://example.com";
|
|
1029
|
+
function B(s) {
|
|
1030
|
+
return s.toString().substring(s.origin.length);
|
|
1021
1031
|
}
|
|
1022
|
-
function
|
|
1023
|
-
return !e || !
|
|
1032
|
+
function j(s, e) {
|
|
1033
|
+
return !e || !s.startsWith(e) ? s : s.substring(e.length);
|
|
1024
1034
|
}
|
|
1025
|
-
function Je(
|
|
1026
|
-
return !e ||
|
|
1035
|
+
function Je(s, e) {
|
|
1036
|
+
return !e || s.startsWith(e) ? s : e + s;
|
|
1027
1037
|
}
|
|
1028
|
-
class
|
|
1038
|
+
class Ke {
|
|
1029
1039
|
#e;
|
|
1030
1040
|
#t;
|
|
1031
|
-
#s;
|
|
1032
1041
|
#r;
|
|
1033
|
-
#
|
|
1042
|
+
#s;
|
|
1034
1043
|
#n;
|
|
1044
|
+
#i;
|
|
1035
1045
|
#o;
|
|
1036
1046
|
#a;
|
|
1037
1047
|
#c;
|
|
@@ -1040,23 +1050,23 @@ class Ye {
|
|
|
1040
1050
|
* @param config - Request Handler configuration.
|
|
1041
1051
|
*/
|
|
1042
1052
|
constructor(e, t = {}) {
|
|
1043
|
-
this.#a = new
|
|
1053
|
+
this.#a = new X({ concurrency: 1 });
|
|
1044
1054
|
const {
|
|
1045
|
-
documentRoot:
|
|
1046
|
-
absoluteUrl:
|
|
1047
|
-
isStaticFilePath:
|
|
1055
|
+
documentRoot: r = "/www/",
|
|
1056
|
+
absoluteUrl: i = typeof location == "object" ? location?.href : "",
|
|
1057
|
+
isStaticFilePath: n = () => !1
|
|
1048
1058
|
} = t;
|
|
1049
|
-
this.php = e, this.#e =
|
|
1050
|
-
const o = new URL(
|
|
1051
|
-
this.#
|
|
1052
|
-
const a = this.#
|
|
1053
|
-
this.#
|
|
1054
|
-
this.#
|
|
1055
|
-
a ? `:${this.#
|
|
1056
|
-
].join(""), this.#
|
|
1059
|
+
this.php = e, this.#e = r, this.#c = n;
|
|
1060
|
+
const o = new URL(i);
|
|
1061
|
+
this.#r = o.hostname, this.#s = o.port ? Number(o.port) : o.protocol === "https:" ? 443 : 80, this.#t = (o.protocol || "").replace(":", "");
|
|
1062
|
+
const a = this.#s !== 443 && this.#s !== 80;
|
|
1063
|
+
this.#n = [
|
|
1064
|
+
this.#r,
|
|
1065
|
+
a ? `:${this.#s}` : ""
|
|
1066
|
+
].join(""), this.#i = o.pathname.replace(/\/+$/, ""), this.#o = [
|
|
1057
1067
|
`${this.#t}://`,
|
|
1058
|
-
this.#
|
|
1059
|
-
this.#
|
|
1068
|
+
this.#n,
|
|
1069
|
+
this.#i
|
|
1060
1070
|
].join("");
|
|
1061
1071
|
}
|
|
1062
1072
|
/** @inheritDoc */
|
|
@@ -1066,7 +1076,7 @@ class Ye {
|
|
|
1066
1076
|
/** @inheritDoc */
|
|
1067
1077
|
internalUrlToPath(e) {
|
|
1068
1078
|
const t = new URL(e);
|
|
1069
|
-
return t.pathname.startsWith(this.#
|
|
1079
|
+
return t.pathname.startsWith(this.#i) && (t.pathname = t.pathname.slice(this.#i.length)), B(t);
|
|
1070
1080
|
}
|
|
1071
1081
|
get isRequestRunning() {
|
|
1072
1082
|
return this.#a.running > 0;
|
|
@@ -1081,14 +1091,14 @@ class Ye {
|
|
|
1081
1091
|
}
|
|
1082
1092
|
/** @inheritDoc */
|
|
1083
1093
|
async request(e) {
|
|
1084
|
-
const t = e.url.startsWith("http://") || e.url.startsWith("https://"),
|
|
1094
|
+
const t = e.url.startsWith("http://") || e.url.startsWith("https://"), r = new URL(
|
|
1085
1095
|
e.url,
|
|
1086
|
-
t ? void 0 :
|
|
1087
|
-
),
|
|
1088
|
-
|
|
1089
|
-
this.#
|
|
1096
|
+
t ? void 0 : Ye
|
|
1097
|
+
), i = j(
|
|
1098
|
+
r.pathname,
|
|
1099
|
+
this.#i
|
|
1090
1100
|
);
|
|
1091
|
-
return this.#c(
|
|
1101
|
+
return this.#c(i) ? this.#l(i) : await this.#h(e, r);
|
|
1092
1102
|
}
|
|
1093
1103
|
/**
|
|
1094
1104
|
* Serves a static file from the PHP filesystem.
|
|
@@ -1104,19 +1114,19 @@ class Ye {
|
|
|
1104
1114
|
{},
|
|
1105
1115
|
new TextEncoder().encode("404 File not found")
|
|
1106
1116
|
);
|
|
1107
|
-
const
|
|
1117
|
+
const r = this.php.readFileAsBuffer(t);
|
|
1108
1118
|
return new _(
|
|
1109
1119
|
200,
|
|
1110
1120
|
{
|
|
1111
|
-
"content-length": [`${
|
|
1121
|
+
"content-length": [`${r.byteLength}`],
|
|
1112
1122
|
// @TODO: Infer the content-type from the arrayBuffer instead of the file path.
|
|
1113
1123
|
// The code below won't return the correct mime-type if the extension
|
|
1114
1124
|
// was tampered with.
|
|
1115
|
-
"content-type": [
|
|
1125
|
+
"content-type": [Qe(t)],
|
|
1116
1126
|
"accept-ranges": ["bytes"],
|
|
1117
1127
|
"cache-control": ["public, max-age=0"]
|
|
1118
1128
|
},
|
|
1119
|
-
|
|
1129
|
+
r
|
|
1120
1130
|
);
|
|
1121
1131
|
}
|
|
1122
1132
|
/**
|
|
@@ -1126,40 +1136,40 @@ class Ye {
|
|
|
1126
1136
|
* @param request - The request.
|
|
1127
1137
|
* @returns The response.
|
|
1128
1138
|
*/
|
|
1129
|
-
async #
|
|
1130
|
-
const
|
|
1139
|
+
async #h(e, t) {
|
|
1140
|
+
const r = await this.#a.acquire();
|
|
1131
1141
|
try {
|
|
1132
1142
|
this.php.addServerGlobalEntry("DOCUMENT_ROOT", this.#e), this.php.addServerGlobalEntry(
|
|
1133
1143
|
"HTTPS",
|
|
1134
1144
|
this.#o.startsWith("https://") ? "on" : ""
|
|
1135
1145
|
);
|
|
1136
|
-
let
|
|
1137
|
-
const
|
|
1138
|
-
host: this.#
|
|
1139
|
-
...
|
|
1146
|
+
let i = "GET";
|
|
1147
|
+
const n = {
|
|
1148
|
+
host: this.#n,
|
|
1149
|
+
...ie(e.headers || {})
|
|
1140
1150
|
}, o = [];
|
|
1141
1151
|
if (e.files && Object.keys(e.files).length) {
|
|
1142
|
-
|
|
1143
|
-
for (const
|
|
1144
|
-
const
|
|
1152
|
+
i = "POST";
|
|
1153
|
+
for (const c in e.files) {
|
|
1154
|
+
const u = e.files[c];
|
|
1145
1155
|
o.push({
|
|
1146
|
-
key:
|
|
1147
|
-
name:
|
|
1148
|
-
type:
|
|
1149
|
-
data: new Uint8Array(await
|
|
1156
|
+
key: c,
|
|
1157
|
+
name: u.name,
|
|
1158
|
+
type: u.type,
|
|
1159
|
+
data: new Uint8Array(await u.arrayBuffer())
|
|
1150
1160
|
});
|
|
1151
1161
|
}
|
|
1152
|
-
|
|
1162
|
+
n["content-type"]?.startsWith("multipart/form-data") && (e.formData = Ze(
|
|
1153
1163
|
e.body || ""
|
|
1154
|
-
),
|
|
1164
|
+
), n["content-type"] = "application/x-www-form-urlencoded", delete e.body);
|
|
1155
1165
|
}
|
|
1156
1166
|
let a;
|
|
1157
|
-
e.formData !== void 0 ? (
|
|
1167
|
+
e.formData !== void 0 ? (i = "POST", n["content-type"] = n["content-type"] || "application/x-www-form-urlencoded", a = new URLSearchParams(
|
|
1158
1168
|
e.formData
|
|
1159
1169
|
).toString()) : a = e.body;
|
|
1160
|
-
let
|
|
1170
|
+
let l;
|
|
1161
1171
|
try {
|
|
1162
|
-
|
|
1172
|
+
l = this.#u(t.pathname);
|
|
1163
1173
|
} catch {
|
|
1164
1174
|
return new _(
|
|
1165
1175
|
404,
|
|
@@ -1169,18 +1179,18 @@ class Ye {
|
|
|
1169
1179
|
}
|
|
1170
1180
|
return await this.php.run({
|
|
1171
1181
|
relativeUri: Je(
|
|
1172
|
-
|
|
1173
|
-
this.#
|
|
1182
|
+
B(t),
|
|
1183
|
+
this.#i
|
|
1174
1184
|
),
|
|
1175
1185
|
protocol: this.#t,
|
|
1176
|
-
method: e.method ||
|
|
1186
|
+
method: e.method || i,
|
|
1177
1187
|
body: a,
|
|
1178
1188
|
fileInfos: o,
|
|
1179
|
-
scriptPath:
|
|
1180
|
-
headers:
|
|
1189
|
+
scriptPath: l,
|
|
1190
|
+
headers: n
|
|
1181
1191
|
});
|
|
1182
1192
|
} finally {
|
|
1183
|
-
|
|
1193
|
+
r();
|
|
1184
1194
|
}
|
|
1185
1195
|
}
|
|
1186
1196
|
/**
|
|
@@ -1192,34 +1202,34 @@ class Ye {
|
|
|
1192
1202
|
* @throws {Error} If the requested path doesn't exist.
|
|
1193
1203
|
* @returns The resolved filesystem path.
|
|
1194
1204
|
*/
|
|
1195
|
-
#
|
|
1196
|
-
let t =
|
|
1205
|
+
#u(e) {
|
|
1206
|
+
let t = j(e, this.#i);
|
|
1197
1207
|
t.includes(".php") ? t = t.split(".php")[0] + ".php" : (t.endsWith("/") || (t += "/"), t.endsWith("index.php") || (t += "index.php"));
|
|
1198
|
-
const
|
|
1199
|
-
if (this.php.fileExists(
|
|
1200
|
-
return
|
|
1208
|
+
const r = `${this.#e}${t}`;
|
|
1209
|
+
if (this.php.fileExists(r))
|
|
1210
|
+
return r;
|
|
1201
1211
|
if (!this.php.fileExists(`${this.#e}/index.php`))
|
|
1202
|
-
throw new Error(`File not found: ${
|
|
1212
|
+
throw new Error(`File not found: ${r}`);
|
|
1203
1213
|
return `${this.#e}/index.php`;
|
|
1204
1214
|
}
|
|
1205
1215
|
}
|
|
1206
|
-
function
|
|
1207
|
-
const e = {}, t =
|
|
1216
|
+
function Ze(s) {
|
|
1217
|
+
const e = {}, t = s.match(/--(.*)\r\n/);
|
|
1208
1218
|
if (!t)
|
|
1209
1219
|
return e;
|
|
1210
|
-
const
|
|
1211
|
-
return
|
|
1212
|
-
const o =
|
|
1220
|
+
const r = t[1], i = s.split(`--${r}`);
|
|
1221
|
+
return i.shift(), i.pop(), i.forEach((n) => {
|
|
1222
|
+
const o = n.indexOf(`\r
|
|
1213
1223
|
\r
|
|
1214
|
-
`), a =
|
|
1215
|
-
if (
|
|
1216
|
-
const
|
|
1217
|
-
e[
|
|
1224
|
+
`), a = n.substring(0, o).trim(), l = n.substring(o + 4).trim(), c = a.match(/name="([^"]+)"/);
|
|
1225
|
+
if (c) {
|
|
1226
|
+
const u = c[1];
|
|
1227
|
+
e[u] = l;
|
|
1218
1228
|
}
|
|
1219
1229
|
}), e;
|
|
1220
1230
|
}
|
|
1221
|
-
function
|
|
1222
|
-
switch (
|
|
1231
|
+
function Qe(s) {
|
|
1232
|
+
switch (s.split(".").pop()) {
|
|
1223
1233
|
case "css":
|
|
1224
1234
|
return "text/css";
|
|
1225
1235
|
case "js":
|
|
@@ -1258,7 +1268,7 @@ function Ze(r) {
|
|
|
1258
1268
|
return "application-octet-stream";
|
|
1259
1269
|
}
|
|
1260
1270
|
}
|
|
1261
|
-
const
|
|
1271
|
+
const G = {
|
|
1262
1272
|
0: "No error occurred. System call completed successfully.",
|
|
1263
1273
|
1: "Argument list too long.",
|
|
1264
1274
|
2: "Permission denied.",
|
|
@@ -1337,17 +1347,17 @@ const B = {
|
|
|
1337
1347
|
75: "Cross-device link.",
|
|
1338
1348
|
76: "Extension: Capabilities insufficient."
|
|
1339
1349
|
};
|
|
1340
|
-
function f(
|
|
1341
|
-
return function(t,
|
|
1342
|
-
const
|
|
1343
|
-
|
|
1350
|
+
function f(s = "") {
|
|
1351
|
+
return function(t, r, i) {
|
|
1352
|
+
const n = i.value;
|
|
1353
|
+
i.value = function(...o) {
|
|
1344
1354
|
try {
|
|
1345
|
-
return
|
|
1355
|
+
return n.apply(this, o);
|
|
1346
1356
|
} catch (a) {
|
|
1347
|
-
const
|
|
1348
|
-
if (
|
|
1349
|
-
const
|
|
1350
|
-
throw new Error(`${d}: ${
|
|
1357
|
+
const l = typeof a == "object" ? a?.errno : null;
|
|
1358
|
+
if (l in G) {
|
|
1359
|
+
const c = G[l], u = typeof o[0] == "string" ? o[0] : null, d = u !== null ? s.replaceAll("{path}", u) : s;
|
|
1360
|
+
throw new Error(`${d}: ${c}`, {
|
|
1351
1361
|
cause: a
|
|
1352
1362
|
});
|
|
1353
1363
|
}
|
|
@@ -1356,19 +1366,19 @@ function f(r = "") {
|
|
|
1356
1366
|
};
|
|
1357
1367
|
};
|
|
1358
1368
|
}
|
|
1359
|
-
const
|
|
1360
|
-
function
|
|
1361
|
-
return
|
|
1369
|
+
const Xe = [];
|
|
1370
|
+
function et(s) {
|
|
1371
|
+
return Xe[s];
|
|
1362
1372
|
}
|
|
1363
1373
|
(function() {
|
|
1364
1374
|
return typeof process < "u" && process.release?.name === "node" ? "NODE" : typeof window < "u" ? "WEB" : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? "WORKER" : "NODE";
|
|
1365
1375
|
})();
|
|
1366
|
-
var
|
|
1367
|
-
for (var
|
|
1368
|
-
(o =
|
|
1369
|
-
return
|
|
1376
|
+
var tt = Object.defineProperty, st = Object.getOwnPropertyDescriptor, m = (s, e, t, r) => {
|
|
1377
|
+
for (var i = r > 1 ? void 0 : r ? st(e, t) : e, n = s.length - 1, o; n >= 0; n--)
|
|
1378
|
+
(o = s[n]) && (i = (r ? o(e, t, i) : o(i)) || i);
|
|
1379
|
+
return r && i && tt(e, t, i), i;
|
|
1370
1380
|
};
|
|
1371
|
-
const p = "string", y = "number",
|
|
1381
|
+
const p = "string", y = "number", h = Symbol("__private__dont__use");
|
|
1372
1382
|
class w {
|
|
1373
1383
|
/**
|
|
1374
1384
|
* Initializes a PHP runtime.
|
|
@@ -1378,14 +1388,14 @@ class w {
|
|
|
1378
1388
|
* @param serverOptions - Optional. Options for the PHPRequestHandler. If undefined, no request handler will be initialized.
|
|
1379
1389
|
*/
|
|
1380
1390
|
constructor(e, t) {
|
|
1381
|
-
this.#e = [], this.#t = !1, this.#
|
|
1382
|
-
new
|
|
1391
|
+
this.#e = [], this.#t = !1, this.#r = null, this.#s = {}, e !== void 0 && this.initializeRuntime(e), t && (this.requestHandler = new Ve(
|
|
1392
|
+
new Ke(this, t)
|
|
1383
1393
|
));
|
|
1384
1394
|
}
|
|
1385
1395
|
#e;
|
|
1386
1396
|
#t;
|
|
1387
|
-
#s;
|
|
1388
1397
|
#r;
|
|
1398
|
+
#s;
|
|
1389
1399
|
/** @inheritDoc */
|
|
1390
1400
|
get absoluteUrl() {
|
|
1391
1401
|
return this.requestHandler.requestHandler.absoluteUrl;
|
|
@@ -1405,18 +1415,18 @@ class w {
|
|
|
1405
1415
|
);
|
|
1406
1416
|
}
|
|
1407
1417
|
initializeRuntime(e) {
|
|
1408
|
-
if (this[
|
|
1418
|
+
if (this[h])
|
|
1409
1419
|
throw new Error("PHP runtime already initialized.");
|
|
1410
|
-
const t =
|
|
1420
|
+
const t = et(e);
|
|
1411
1421
|
if (!t)
|
|
1412
1422
|
throw new Error("Invalid PHP runtime id.");
|
|
1413
|
-
this[
|
|
1423
|
+
this[h] = t, this.#r = We(t);
|
|
1414
1424
|
}
|
|
1415
1425
|
/** @inheritDoc */
|
|
1416
1426
|
setPhpIniPath(e) {
|
|
1417
1427
|
if (this.#t)
|
|
1418
1428
|
throw new Error("Cannot set PHP ini path after calling run().");
|
|
1419
|
-
this[
|
|
1429
|
+
this[h].ccall(
|
|
1420
1430
|
"wasm_set_phpini_path",
|
|
1421
1431
|
null,
|
|
1422
1432
|
["string"],
|
|
@@ -1431,7 +1441,7 @@ class w {
|
|
|
1431
1441
|
}
|
|
1432
1442
|
/** @inheritDoc */
|
|
1433
1443
|
chdir(e) {
|
|
1434
|
-
this[
|
|
1444
|
+
this[h].FS.chdir(e);
|
|
1435
1445
|
}
|
|
1436
1446
|
/** @inheritDoc */
|
|
1437
1447
|
async request(e, t) {
|
|
@@ -1441,58 +1451,58 @@ class w {
|
|
|
1441
1451
|
}
|
|
1442
1452
|
/** @inheritDoc */
|
|
1443
1453
|
async run(e) {
|
|
1444
|
-
this.#t || (this.#
|
|
1445
|
-
const { host: t, ...
|
|
1454
|
+
this.#t || (this.#n(), this.#t = !0), this.#u(e.scriptPath || ""), this.#o(e.relativeUri || ""), this.#c(e.method || "GET");
|
|
1455
|
+
const { host: t, ...r } = {
|
|
1446
1456
|
host: "example.com:443",
|
|
1447
|
-
...
|
|
1457
|
+
...ie(e.headers || {})
|
|
1448
1458
|
};
|
|
1449
|
-
if (this.#a(t, e.protocol || "http"), this.#l(
|
|
1450
|
-
for (const
|
|
1451
|
-
this.#d(
|
|
1459
|
+
if (this.#a(t, e.protocol || "http"), this.#l(r), e.body && this.#h(e.body), e.fileInfos)
|
|
1460
|
+
for (const i of e.fileInfos)
|
|
1461
|
+
this.#d(i);
|
|
1452
1462
|
return e.code && this.#f(" ?>" + e.code), this.#p(), await this.#m();
|
|
1453
1463
|
}
|
|
1454
|
-
#
|
|
1464
|
+
#n() {
|
|
1455
1465
|
if (this.#e.length > 0) {
|
|
1456
|
-
const e = this.#e.map(([t,
|
|
1466
|
+
const e = this.#e.map(([t, r]) => `${t}=${r}`).join(`
|
|
1457
1467
|
`) + `
|
|
1458
1468
|
|
|
1459
1469
|
`;
|
|
1460
|
-
this[
|
|
1470
|
+
this[h].ccall(
|
|
1461
1471
|
"wasm_set_phpini_entries",
|
|
1462
1472
|
null,
|
|
1463
1473
|
[p],
|
|
1464
1474
|
[e]
|
|
1465
1475
|
);
|
|
1466
1476
|
}
|
|
1467
|
-
this[
|
|
1477
|
+
this[h].ccall("php_wasm_init", null, [], []);
|
|
1468
1478
|
}
|
|
1469
|
-
#
|
|
1479
|
+
#i() {
|
|
1470
1480
|
const e = "/tmp/headers.json";
|
|
1471
1481
|
if (!this.fileExists(e))
|
|
1472
1482
|
throw new Error(
|
|
1473
1483
|
"SAPI Error: Could not find response headers file."
|
|
1474
1484
|
);
|
|
1475
|
-
const t = JSON.parse(this.readFileAsText(e)),
|
|
1476
|
-
for (const
|
|
1477
|
-
if (!
|
|
1485
|
+
const t = JSON.parse(this.readFileAsText(e)), r = {};
|
|
1486
|
+
for (const i of t.headers) {
|
|
1487
|
+
if (!i.includes(": "))
|
|
1478
1488
|
continue;
|
|
1479
|
-
const
|
|
1480
|
-
o in
|
|
1489
|
+
const n = i.indexOf(": "), o = i.substring(0, n).toLowerCase(), a = i.substring(n + 2);
|
|
1490
|
+
o in r || (r[o] = []), r[o].push(a);
|
|
1481
1491
|
}
|
|
1482
1492
|
return {
|
|
1483
|
-
headers:
|
|
1493
|
+
headers: r,
|
|
1484
1494
|
httpStatusCode: t.status
|
|
1485
1495
|
};
|
|
1486
1496
|
}
|
|
1487
1497
|
#o(e) {
|
|
1488
|
-
if (this[
|
|
1498
|
+
if (this[h].ccall(
|
|
1489
1499
|
"wasm_set_request_uri",
|
|
1490
1500
|
null,
|
|
1491
1501
|
[p],
|
|
1492
1502
|
[e]
|
|
1493
1503
|
), e.includes("?")) {
|
|
1494
1504
|
const t = e.substring(e.indexOf("?") + 1);
|
|
1495
|
-
this[
|
|
1505
|
+
this[h].ccall(
|
|
1496
1506
|
"wasm_set_query_string",
|
|
1497
1507
|
null,
|
|
1498
1508
|
[p],
|
|
@@ -1501,26 +1511,26 @@ class w {
|
|
|
1501
1511
|
}
|
|
1502
1512
|
}
|
|
1503
1513
|
#a(e, t) {
|
|
1504
|
-
this[
|
|
1514
|
+
this[h].ccall(
|
|
1505
1515
|
"wasm_set_request_host",
|
|
1506
1516
|
null,
|
|
1507
1517
|
[p],
|
|
1508
1518
|
[e]
|
|
1509
1519
|
);
|
|
1510
|
-
let
|
|
1520
|
+
let r;
|
|
1511
1521
|
try {
|
|
1512
|
-
|
|
1522
|
+
r = parseInt(new URL(e).port, 10);
|
|
1513
1523
|
} catch {
|
|
1514
1524
|
}
|
|
1515
|
-
(!
|
|
1525
|
+
(!r || isNaN(r) || r === 80) && (r = t === "https" ? 443 : 80), this[h].ccall(
|
|
1516
1526
|
"wasm_set_request_port",
|
|
1517
1527
|
null,
|
|
1518
1528
|
[y],
|
|
1519
|
-
[
|
|
1520
|
-
), (t === "https" || !t &&
|
|
1529
|
+
[r]
|
|
1530
|
+
), (t === "https" || !t && r === 443) && this.addServerGlobalEntry("HTTPS", "on");
|
|
1521
1531
|
}
|
|
1522
1532
|
#c(e) {
|
|
1523
|
-
this[
|
|
1533
|
+
this[h].ccall(
|
|
1524
1534
|
"wasm_set_request_method",
|
|
1525
1535
|
null,
|
|
1526
1536
|
[p],
|
|
@@ -1528,43 +1538,45 @@ class w {
|
|
|
1528
1538
|
);
|
|
1529
1539
|
}
|
|
1530
1540
|
#l(e) {
|
|
1531
|
-
e.cookie && this[
|
|
1541
|
+
e.cookie && this[h].ccall(
|
|
1532
1542
|
"wasm_set_cookies",
|
|
1533
1543
|
null,
|
|
1534
1544
|
[p],
|
|
1535
1545
|
[e.cookie]
|
|
1536
|
-
), e["content-type"] && this[
|
|
1546
|
+
), e["content-type"] && this[h].ccall(
|
|
1537
1547
|
"wasm_set_content_type",
|
|
1538
1548
|
null,
|
|
1539
1549
|
[p],
|
|
1540
1550
|
[e["content-type"]]
|
|
1541
|
-
), e["content-length"] && this[
|
|
1551
|
+
), e["content-length"] && this[h].ccall(
|
|
1542
1552
|
"wasm_set_content_length",
|
|
1543
1553
|
null,
|
|
1544
1554
|
[y],
|
|
1545
1555
|
[parseInt(e["content-length"], 10)]
|
|
1546
1556
|
);
|
|
1547
|
-
for (const t in e)
|
|
1548
|
-
|
|
1549
|
-
|
|
1557
|
+
for (const t in e) {
|
|
1558
|
+
let r = "HTTP_";
|
|
1559
|
+
["content-type", "content-length"].includes(t.toLowerCase()) && (r = ""), this.addServerGlobalEntry(
|
|
1560
|
+
`${r}${t.toUpperCase().replace(/-/g, "_")}`,
|
|
1550
1561
|
e[t]
|
|
1551
1562
|
);
|
|
1563
|
+
}
|
|
1552
1564
|
}
|
|
1553
|
-
#
|
|
1554
|
-
this[
|
|
1565
|
+
#h(e) {
|
|
1566
|
+
this[h].ccall(
|
|
1555
1567
|
"wasm_set_request_body",
|
|
1556
1568
|
null,
|
|
1557
1569
|
[p],
|
|
1558
1570
|
[e]
|
|
1559
|
-
), this[
|
|
1571
|
+
), this[h].ccall(
|
|
1560
1572
|
"wasm_set_content_length",
|
|
1561
1573
|
null,
|
|
1562
1574
|
[y],
|
|
1563
1575
|
[new TextEncoder().encode(e).length]
|
|
1564
1576
|
);
|
|
1565
1577
|
}
|
|
1566
|
-
#
|
|
1567
|
-
this[
|
|
1578
|
+
#u(e) {
|
|
1579
|
+
this[h].ccall(
|
|
1568
1580
|
"wasm_set_path_translated",
|
|
1569
1581
|
null,
|
|
1570
1582
|
[p],
|
|
@@ -1572,15 +1584,15 @@ class w {
|
|
|
1572
1584
|
);
|
|
1573
1585
|
}
|
|
1574
1586
|
addServerGlobalEntry(e, t) {
|
|
1575
|
-
this.#
|
|
1587
|
+
this.#s[e] = t;
|
|
1576
1588
|
}
|
|
1577
1589
|
#p() {
|
|
1578
|
-
for (const e in this.#
|
|
1579
|
-
this[
|
|
1590
|
+
for (const e in this.#s)
|
|
1591
|
+
this[h].ccall(
|
|
1580
1592
|
"wasm_add_SERVER_entry",
|
|
1581
1593
|
null,
|
|
1582
1594
|
[p, p],
|
|
1583
|
-
[e, this.#
|
|
1595
|
+
[e, this.#s[e]]
|
|
1584
1596
|
);
|
|
1585
1597
|
}
|
|
1586
1598
|
/**
|
|
@@ -1593,18 +1605,18 @@ class w {
|
|
|
1593
1605
|
* @param fileInfo - File details
|
|
1594
1606
|
*/
|
|
1595
1607
|
#d(e) {
|
|
1596
|
-
const { key: t, name:
|
|
1597
|
-
this.writeFile(o,
|
|
1608
|
+
const { key: t, name: r, type: i, data: n } = e, o = `/tmp/${Math.random().toFixed(20)}`;
|
|
1609
|
+
this.writeFile(o, n);
|
|
1598
1610
|
const a = 0;
|
|
1599
|
-
this[
|
|
1611
|
+
this[h].ccall(
|
|
1600
1612
|
"wasm_add_uploaded_file",
|
|
1601
1613
|
null,
|
|
1602
1614
|
[p, p, p, p, y, y],
|
|
1603
|
-
[t,
|
|
1615
|
+
[t, r, i, o, a, n.byteLength]
|
|
1604
1616
|
);
|
|
1605
1617
|
}
|
|
1606
1618
|
#f(e) {
|
|
1607
|
-
this[
|
|
1619
|
+
this[h].ccall(
|
|
1608
1620
|
"wasm_set_php_code",
|
|
1609
1621
|
null,
|
|
1610
1622
|
[p],
|
|
@@ -1614,46 +1626,46 @@ class w {
|
|
|
1614
1626
|
async #m() {
|
|
1615
1627
|
let e, t;
|
|
1616
1628
|
try {
|
|
1617
|
-
e = await new Promise((
|
|
1618
|
-
t = (
|
|
1619
|
-
const
|
|
1620
|
-
|
|
1621
|
-
}, this.#
|
|
1629
|
+
e = await new Promise((n, o) => {
|
|
1630
|
+
t = (l) => {
|
|
1631
|
+
const c = new Error("Rethrown");
|
|
1632
|
+
c.cause = l.error, c.betterMessage = l.message, o(c);
|
|
1633
|
+
}, this.#r?.addEventListener(
|
|
1622
1634
|
"error",
|
|
1623
1635
|
t
|
|
1624
1636
|
);
|
|
1625
|
-
const a = this[
|
|
1637
|
+
const a = this[h].ccall(
|
|
1626
1638
|
"wasm_sapi_handle_request",
|
|
1627
1639
|
y,
|
|
1628
1640
|
[],
|
|
1629
1641
|
[]
|
|
1630
1642
|
);
|
|
1631
|
-
return a instanceof Promise ? a.then(
|
|
1643
|
+
return a instanceof Promise ? a.then(n, o) : n(a);
|
|
1632
1644
|
});
|
|
1633
|
-
} catch (
|
|
1634
|
-
for (const
|
|
1635
|
-
typeof this[
|
|
1645
|
+
} catch (n) {
|
|
1646
|
+
for (const c in this)
|
|
1647
|
+
typeof this[c] == "function" && (this[c] = () => {
|
|
1636
1648
|
throw new Error(
|
|
1637
1649
|
"PHP runtime has crashed – see the earlier error for details."
|
|
1638
1650
|
);
|
|
1639
1651
|
});
|
|
1640
|
-
this.functionsMaybeMissingFromAsyncify =
|
|
1641
|
-
const o =
|
|
1642
|
-
throw
|
|
1652
|
+
this.functionsMaybeMissingFromAsyncify = qe();
|
|
1653
|
+
const o = n, a = "betterMessage" in o ? o.betterMessage : o.message, l = new Error(a);
|
|
1654
|
+
throw l.cause = o, l;
|
|
1643
1655
|
} finally {
|
|
1644
|
-
this.#
|
|
1656
|
+
this.#r?.removeEventListener("error", t), this.#s = {};
|
|
1645
1657
|
}
|
|
1646
|
-
const { headers:
|
|
1658
|
+
const { headers: r, httpStatusCode: i } = this.#i();
|
|
1647
1659
|
return new _(
|
|
1648
|
-
|
|
1649
|
-
|
|
1660
|
+
i,
|
|
1661
|
+
r,
|
|
1650
1662
|
this.readFileAsBuffer("/tmp/stdout"),
|
|
1651
1663
|
this.readFileAsText("/tmp/stderr"),
|
|
1652
1664
|
e
|
|
1653
1665
|
);
|
|
1654
1666
|
}
|
|
1655
1667
|
mkdir(e) {
|
|
1656
|
-
this[
|
|
1668
|
+
this[h].FS.mkdirTree(e);
|
|
1657
1669
|
}
|
|
1658
1670
|
mkdirTree(e) {
|
|
1659
1671
|
this.mkdir(e);
|
|
@@ -1662,42 +1674,47 @@ class w {
|
|
|
1662
1674
|
return new TextDecoder().decode(this.readFileAsBuffer(e));
|
|
1663
1675
|
}
|
|
1664
1676
|
readFileAsBuffer(e) {
|
|
1665
|
-
return this[
|
|
1677
|
+
return this[h].FS.readFile(e);
|
|
1666
1678
|
}
|
|
1667
1679
|
writeFile(e, t) {
|
|
1668
|
-
this[
|
|
1680
|
+
this[h].FS.writeFile(e, t);
|
|
1669
1681
|
}
|
|
1670
1682
|
unlink(e) {
|
|
1671
|
-
this[
|
|
1683
|
+
this[h].FS.unlink(e);
|
|
1672
1684
|
}
|
|
1673
1685
|
mv(e, t) {
|
|
1674
|
-
this[
|
|
1686
|
+
this[h].FS.rename(e, t);
|
|
1675
1687
|
}
|
|
1676
1688
|
rmdir(e, t = { recursive: !0 }) {
|
|
1677
|
-
t?.recursive && this.listFiles(e).forEach((
|
|
1678
|
-
const
|
|
1679
|
-
this.isDir(
|
|
1680
|
-
}), this[
|
|
1689
|
+
t?.recursive && this.listFiles(e).forEach((r) => {
|
|
1690
|
+
const i = `${e}/${r}`;
|
|
1691
|
+
this.isDir(i) ? this.rmdir(i, t) : this.unlink(i);
|
|
1692
|
+
}), this[h].FS.rmdir(e);
|
|
1681
1693
|
}
|
|
1682
|
-
listFiles(e) {
|
|
1694
|
+
listFiles(e, t = { prependPath: !1 }) {
|
|
1683
1695
|
if (!this.fileExists(e))
|
|
1684
1696
|
return [];
|
|
1685
1697
|
try {
|
|
1686
|
-
|
|
1687
|
-
(
|
|
1698
|
+
const r = this[h].FS.readdir(e).filter(
|
|
1699
|
+
(i) => i !== "." && i !== ".."
|
|
1688
1700
|
);
|
|
1689
|
-
|
|
1690
|
-
|
|
1701
|
+
if (t.prependPath) {
|
|
1702
|
+
const i = e.replace(/\/$/, "");
|
|
1703
|
+
return r.map((n) => `${i}/${n}`);
|
|
1704
|
+
}
|
|
1705
|
+
return r;
|
|
1706
|
+
} catch (r) {
|
|
1707
|
+
return console.error(r, { path: e }), [];
|
|
1691
1708
|
}
|
|
1692
1709
|
}
|
|
1693
1710
|
isDir(e) {
|
|
1694
|
-
return this.fileExists(e) ? this[
|
|
1695
|
-
this[
|
|
1711
|
+
return this.fileExists(e) ? this[h].FS.isDir(
|
|
1712
|
+
this[h].FS.lookupPath(e).node.mode
|
|
1696
1713
|
) : !1;
|
|
1697
1714
|
}
|
|
1698
1715
|
fileExists(e) {
|
|
1699
1716
|
try {
|
|
1700
|
-
return this[
|
|
1717
|
+
return this[h].FS.lookupPath(e), !0;
|
|
1701
1718
|
} catch {
|
|
1702
1719
|
return !1;
|
|
1703
1720
|
}
|
|
@@ -1736,10 +1753,10 @@ m([
|
|
|
1736
1753
|
m([
|
|
1737
1754
|
f('Could not stat "{path}"')
|
|
1738
1755
|
], w.prototype, "fileExists", 1);
|
|
1739
|
-
function
|
|
1756
|
+
function ie(s) {
|
|
1740
1757
|
const e = {};
|
|
1741
|
-
for (const t in
|
|
1742
|
-
e[t.toLowerCase()] =
|
|
1758
|
+
for (const t in s)
|
|
1759
|
+
e[t.toLowerCase()] = s[t];
|
|
1743
1760
|
return e;
|
|
1744
1761
|
}
|
|
1745
1762
|
const rt = [
|
|
@@ -1749,8 +1766,8 @@ const rt = [
|
|
|
1749
1766
|
"wordpress.org/plugins",
|
|
1750
1767
|
"url"
|
|
1751
1768
|
];
|
|
1752
|
-
function
|
|
1753
|
-
return
|
|
1769
|
+
function it(s) {
|
|
1770
|
+
return s && typeof s == "object" && typeof s.resource == "string" && rt.includes(s.resource);
|
|
1754
1771
|
}
|
|
1755
1772
|
class g {
|
|
1756
1773
|
/**
|
|
@@ -1760,28 +1777,28 @@ class g {
|
|
|
1760
1777
|
* @param options Additional options for the Resource
|
|
1761
1778
|
* @returns A new Resource instance
|
|
1762
1779
|
*/
|
|
1763
|
-
static create(e, { semaphore: t, progress:
|
|
1764
|
-
let
|
|
1780
|
+
static create(e, { semaphore: t, progress: r }) {
|
|
1781
|
+
let i;
|
|
1765
1782
|
switch (e.resource) {
|
|
1766
1783
|
case "vfs":
|
|
1767
|
-
|
|
1784
|
+
i = new nt(e, r);
|
|
1768
1785
|
break;
|
|
1769
1786
|
case "literal":
|
|
1770
|
-
|
|
1787
|
+
i = new ot(e, r);
|
|
1771
1788
|
break;
|
|
1772
1789
|
case "wordpress.org/themes":
|
|
1773
|
-
|
|
1790
|
+
i = new lt(e, r);
|
|
1774
1791
|
break;
|
|
1775
1792
|
case "wordpress.org/plugins":
|
|
1776
|
-
|
|
1793
|
+
i = new ht(e, r);
|
|
1777
1794
|
break;
|
|
1778
1795
|
case "url":
|
|
1779
|
-
|
|
1796
|
+
i = new ct(e, r);
|
|
1780
1797
|
break;
|
|
1781
1798
|
default:
|
|
1782
1799
|
throw new Error(`Invalid resource: ${e}`);
|
|
1783
1800
|
}
|
|
1784
|
-
return
|
|
1801
|
+
return i = new ut(i), t && (i = new pt(i, t)), i;
|
|
1785
1802
|
}
|
|
1786
1803
|
setPlayground(e) {
|
|
1787
1804
|
this.playground = e;
|
|
@@ -1806,14 +1823,14 @@ class nt extends g {
|
|
|
1806
1823
|
const e = await this.playground.readFileAsBuffer(
|
|
1807
1824
|
this.resource.path
|
|
1808
1825
|
);
|
|
1809
|
-
return this.progress?.set(100), new
|
|
1826
|
+
return this.progress?.set(100), new R([e], this.name);
|
|
1810
1827
|
}
|
|
1811
1828
|
/** @inheritDoc */
|
|
1812
1829
|
get name() {
|
|
1813
|
-
return this.resource.path;
|
|
1830
|
+
return this.resource.path.split("/").pop() || "";
|
|
1814
1831
|
}
|
|
1815
1832
|
}
|
|
1816
|
-
class
|
|
1833
|
+
class ot extends g {
|
|
1817
1834
|
/**
|
|
1818
1835
|
* Creates a new instance of `LiteralResource`.
|
|
1819
1836
|
* @param resource The literal reference.
|
|
@@ -1824,7 +1841,7 @@ class it extends g {
|
|
|
1824
1841
|
}
|
|
1825
1842
|
/** @inheritDoc */
|
|
1826
1843
|
async resolve() {
|
|
1827
|
-
return this.progress?.set(100), new
|
|
1844
|
+
return this.progress?.set(100), new R([this.resource.contents], this.resource.name);
|
|
1828
1845
|
}
|
|
1829
1846
|
/** @inheritDoc */
|
|
1830
1847
|
get name() {
|
|
@@ -1844,12 +1861,12 @@ class C extends g {
|
|
|
1844
1861
|
this.progress?.setCaption(this.caption);
|
|
1845
1862
|
const e = this.getURL();
|
|
1846
1863
|
let t = await fetch(e);
|
|
1847
|
-
if (t = await
|
|
1864
|
+
if (t = await Le(
|
|
1848
1865
|
t,
|
|
1849
|
-
this.progress?.loadingListener ??
|
|
1866
|
+
this.progress?.loadingListener ?? at
|
|
1850
1867
|
), t.status !== 200)
|
|
1851
1868
|
throw new Error(`Could not download "${e}"`);
|
|
1852
|
-
return new
|
|
1869
|
+
return new R([await t.blob()], this.name);
|
|
1853
1870
|
}
|
|
1854
1871
|
/**
|
|
1855
1872
|
* Gets the caption for the progress tracker.
|
|
@@ -1871,9 +1888,9 @@ class C extends g {
|
|
|
1871
1888
|
return !0;
|
|
1872
1889
|
}
|
|
1873
1890
|
}
|
|
1874
|
-
const
|
|
1891
|
+
const at = () => {
|
|
1875
1892
|
};
|
|
1876
|
-
class
|
|
1893
|
+
class ct extends C {
|
|
1877
1894
|
/**
|
|
1878
1895
|
* Creates a new instance of `UrlResource`.
|
|
1879
1896
|
* @param resource The URL reference.
|
|
@@ -1891,40 +1908,40 @@ class at extends C {
|
|
|
1891
1908
|
return this.resource.caption ?? super.caption;
|
|
1892
1909
|
}
|
|
1893
1910
|
}
|
|
1894
|
-
let
|
|
1895
|
-
function
|
|
1896
|
-
|
|
1911
|
+
let A = "https://playground.wordpress.net/plugin-proxy";
|
|
1912
|
+
function gt(s) {
|
|
1913
|
+
A = s;
|
|
1897
1914
|
}
|
|
1898
|
-
class
|
|
1915
|
+
class lt extends C {
|
|
1899
1916
|
constructor(e, t) {
|
|
1900
1917
|
super(t), this.resource = e;
|
|
1901
1918
|
}
|
|
1902
1919
|
get name() {
|
|
1903
|
-
return
|
|
1920
|
+
return b(this.resource.slug);
|
|
1904
1921
|
}
|
|
1905
1922
|
getURL() {
|
|
1906
|
-
const e =
|
|
1907
|
-
return `${
|
|
1923
|
+
const e = ne(this.resource.slug);
|
|
1924
|
+
return `${A}?theme=` + e;
|
|
1908
1925
|
}
|
|
1909
1926
|
}
|
|
1910
|
-
class
|
|
1927
|
+
class ht extends C {
|
|
1911
1928
|
constructor(e, t) {
|
|
1912
1929
|
super(t), this.resource = e;
|
|
1913
1930
|
}
|
|
1914
1931
|
/** @inheritDoc */
|
|
1915
1932
|
get name() {
|
|
1916
|
-
return
|
|
1933
|
+
return b(this.resource.slug);
|
|
1917
1934
|
}
|
|
1918
1935
|
/** @inheritDoc */
|
|
1919
1936
|
getURL() {
|
|
1920
|
-
const e =
|
|
1921
|
-
return `${
|
|
1937
|
+
const e = ne(this.resource.slug);
|
|
1938
|
+
return `${A}?plugin=` + e;
|
|
1922
1939
|
}
|
|
1923
1940
|
}
|
|
1924
|
-
function
|
|
1925
|
-
return !
|
|
1941
|
+
function ne(s) {
|
|
1942
|
+
return !s || s.endsWith(".zip") ? s : s + ".latest-stable.zip";
|
|
1926
1943
|
}
|
|
1927
|
-
class
|
|
1944
|
+
class oe extends g {
|
|
1928
1945
|
constructor(e) {
|
|
1929
1946
|
super(), this.resource = e;
|
|
1930
1947
|
}
|
|
@@ -1953,13 +1970,13 @@ class re extends g {
|
|
|
1953
1970
|
return this.resource.isAsync;
|
|
1954
1971
|
}
|
|
1955
1972
|
}
|
|
1956
|
-
class ut extends
|
|
1973
|
+
class ut extends oe {
|
|
1957
1974
|
/** @inheritDoc */
|
|
1958
1975
|
async resolve() {
|
|
1959
1976
|
return this.promise || (this.promise = super.resolve()), this.promise;
|
|
1960
1977
|
}
|
|
1961
1978
|
}
|
|
1962
|
-
class
|
|
1979
|
+
class pt extends oe {
|
|
1963
1980
|
constructor(e, t) {
|
|
1964
1981
|
super(e), this.semaphore = t;
|
|
1965
1982
|
}
|
|
@@ -1968,48 +1985,48 @@ class ht extends re {
|
|
|
1968
1985
|
return this.isAsync ? this.semaphore.run(() => super.resolve()) : super.resolve();
|
|
1969
1986
|
}
|
|
1970
1987
|
}
|
|
1971
|
-
const
|
|
1972
|
-
function
|
|
1973
|
-
progress: e = new
|
|
1974
|
-
semaphore: t = new
|
|
1975
|
-
onStepCompleted:
|
|
1988
|
+
const dt = ["6.2", "6.1", "6.0", "5.9"];
|
|
1989
|
+
function yt(s, {
|
|
1990
|
+
progress: e = new T(),
|
|
1991
|
+
semaphore: t = new X({ concurrency: 3 }),
|
|
1992
|
+
onStepCompleted: r = () => {
|
|
1976
1993
|
}
|
|
1977
1994
|
} = {}) {
|
|
1978
|
-
const
|
|
1979
|
-
(a,
|
|
1995
|
+
const i = (s.steps || []).filter(ft), n = i.reduce(
|
|
1996
|
+
(a, l) => a + (l.progress?.weight || 1),
|
|
1980
1997
|
0
|
|
1981
|
-
), o =
|
|
1982
|
-
(a) =>
|
|
1998
|
+
), o = i.map(
|
|
1999
|
+
(a) => mt(a, {
|
|
1983
2000
|
semaphore: t,
|
|
1984
2001
|
rootProgressTracker: e,
|
|
1985
|
-
totalProgressWeight:
|
|
2002
|
+
totalProgressWeight: n
|
|
1986
2003
|
})
|
|
1987
2004
|
);
|
|
1988
2005
|
return {
|
|
1989
2006
|
versions: {
|
|
1990
|
-
php:
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
2007
|
+
php: V(
|
|
2008
|
+
s.preferredVersions?.php,
|
|
2009
|
+
re,
|
|
2010
|
+
Ge
|
|
1994
2011
|
),
|
|
1995
|
-
wp:
|
|
1996
|
-
|
|
1997
|
-
|
|
2012
|
+
wp: V(
|
|
2013
|
+
s.preferredVersions?.wp,
|
|
2014
|
+
dt,
|
|
1998
2015
|
"6.2"
|
|
1999
2016
|
)
|
|
2000
2017
|
},
|
|
2001
2018
|
run: async (a) => {
|
|
2002
2019
|
try {
|
|
2003
|
-
for (const { resources:
|
|
2004
|
-
for (const
|
|
2005
|
-
|
|
2006
|
-
for (const { run:
|
|
2007
|
-
const
|
|
2008
|
-
|
|
2020
|
+
for (const { resources: l } of o)
|
|
2021
|
+
for (const c of l)
|
|
2022
|
+
c.setPlayground(a), c.isAsync && c.resolve();
|
|
2023
|
+
for (const { run: l, step: c } of o) {
|
|
2024
|
+
const u = await l(a);
|
|
2025
|
+
r(u, c);
|
|
2009
2026
|
}
|
|
2010
2027
|
try {
|
|
2011
2028
|
await a.goTo(
|
|
2012
|
-
|
|
2029
|
+
s.landingPage || "/"
|
|
2013
2030
|
);
|
|
2014
2031
|
} catch {
|
|
2015
2032
|
}
|
|
@@ -2019,92 +2036,92 @@ function gt(r, {
|
|
|
2019
2036
|
}
|
|
2020
2037
|
};
|
|
2021
2038
|
}
|
|
2022
|
-
function
|
|
2023
|
-
return
|
|
2039
|
+
function V(s, e, t) {
|
|
2040
|
+
return s && e.includes(s) ? s : t;
|
|
2024
2041
|
}
|
|
2025
|
-
function
|
|
2026
|
-
return !!(typeof
|
|
2042
|
+
function ft(s) {
|
|
2043
|
+
return !!(typeof s == "object" && s);
|
|
2027
2044
|
}
|
|
2028
|
-
function
|
|
2045
|
+
function mt(s, {
|
|
2029
2046
|
semaphore: e,
|
|
2030
2047
|
rootProgressTracker: t,
|
|
2031
|
-
totalProgressWeight:
|
|
2048
|
+
totalProgressWeight: r
|
|
2032
2049
|
}) {
|
|
2033
|
-
const
|
|
2034
|
-
(
|
|
2035
|
-
),
|
|
2036
|
-
for (const
|
|
2037
|
-
let d =
|
|
2038
|
-
|
|
2050
|
+
const i = t.stage(
|
|
2051
|
+
(s.progress?.weight || 1) / r
|
|
2052
|
+
), n = {};
|
|
2053
|
+
for (const u of Object.keys(s)) {
|
|
2054
|
+
let d = s[u];
|
|
2055
|
+
it(d) && (d = g.create(d, {
|
|
2039
2056
|
semaphore: e
|
|
2040
|
-
})),
|
|
2057
|
+
})), n[u] = d;
|
|
2041
2058
|
}
|
|
2042
|
-
const o = async (
|
|
2059
|
+
const o = async (u) => {
|
|
2043
2060
|
try {
|
|
2044
|
-
return
|
|
2045
|
-
|
|
2046
|
-
await
|
|
2061
|
+
return i.fillSlowly(), await Oe[s.step](
|
|
2062
|
+
u,
|
|
2063
|
+
await wt(n),
|
|
2047
2064
|
{
|
|
2048
|
-
tracker:
|
|
2049
|
-
initialCaption:
|
|
2065
|
+
tracker: i,
|
|
2066
|
+
initialCaption: s.progress?.caption
|
|
2050
2067
|
}
|
|
2051
2068
|
);
|
|
2052
2069
|
} finally {
|
|
2053
|
-
|
|
2070
|
+
i.finish();
|
|
2054
2071
|
}
|
|
2055
|
-
}, a =
|
|
2056
|
-
(
|
|
2057
|
-
),
|
|
2058
|
-
for (const
|
|
2059
|
-
|
|
2060
|
-
return { run: o, step:
|
|
2072
|
+
}, a = Y(n), l = Y(n).filter(
|
|
2073
|
+
(u) => u.isAsync
|
|
2074
|
+
), c = 1 / (l.length + 1);
|
|
2075
|
+
for (const u of l)
|
|
2076
|
+
u.progress = i.stage(c);
|
|
2077
|
+
return { run: o, step: s, resources: a };
|
|
2061
2078
|
}
|
|
2062
|
-
function
|
|
2079
|
+
function Y(s) {
|
|
2063
2080
|
const e = [];
|
|
2064
|
-
for (const t in
|
|
2065
|
-
const
|
|
2066
|
-
|
|
2081
|
+
for (const t in s) {
|
|
2082
|
+
const r = s[t];
|
|
2083
|
+
r instanceof g && e.push(r);
|
|
2067
2084
|
}
|
|
2068
2085
|
return e;
|
|
2069
2086
|
}
|
|
2070
|
-
async function
|
|
2087
|
+
async function wt(s) {
|
|
2071
2088
|
const e = {};
|
|
2072
|
-
for (const t in
|
|
2073
|
-
const
|
|
2074
|
-
|
|
2089
|
+
for (const t in s) {
|
|
2090
|
+
const r = s[t];
|
|
2091
|
+
r instanceof g ? e[t] = await r.resolve() : e[t] = r;
|
|
2075
2092
|
}
|
|
2076
2093
|
return e;
|
|
2077
2094
|
}
|
|
2078
|
-
async function
|
|
2079
|
-
await
|
|
2095
|
+
async function Pt(s, e) {
|
|
2096
|
+
await s.run(e);
|
|
2080
2097
|
}
|
|
2081
2098
|
export {
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2099
|
+
J as activatePlugin,
|
|
2100
|
+
K as activateTheme,
|
|
2101
|
+
le as applyWordPressPatches,
|
|
2102
|
+
yt as compileBlueprint,
|
|
2103
|
+
me as cp,
|
|
2087
2104
|
_e as defineSiteUrl,
|
|
2088
|
-
|
|
2089
|
-
|
|
2105
|
+
Q as defineWpConfigConsts,
|
|
2106
|
+
Ee as importFile,
|
|
2090
2107
|
xe as installPlugin,
|
|
2091
2108
|
Te as installTheme,
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2109
|
+
ke as login,
|
|
2110
|
+
ge as mkdir,
|
|
2111
|
+
we as mv,
|
|
2095
2112
|
ve as replaceSite,
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2113
|
+
fe as request,
|
|
2114
|
+
ye as rm,
|
|
2115
|
+
Pe as rmdir,
|
|
2116
|
+
Pt as runBlueprintSteps,
|
|
2100
2117
|
ue as runPHP,
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2118
|
+
pe as runPHPWithOptions,
|
|
2119
|
+
Ce as runWpInstallationWizard,
|
|
2120
|
+
de as setPhpIniEntry,
|
|
2121
|
+
gt as setPluginProxyURL,
|
|
2122
|
+
Ae as setSiteOptions,
|
|
2123
|
+
F as unzip,
|
|
2107
2124
|
Ue as updateUserMeta,
|
|
2108
|
-
|
|
2109
|
-
|
|
2125
|
+
Z as writeFile,
|
|
2126
|
+
be as zipEntireSite
|
|
2110
2127
|
};
|