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