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