@wp-playground/client 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/blueprint-schema.json +7 -30
- package/index.cjs +38 -32
- package/index.d.ts +30 -36
- package/index.js +420 -427
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,25 +1,39 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
`${t.documentRoot}/wp-load.php`,
|
|
5
|
-
`${t.documentRoot}/wp-admin/includes/plugin.php`
|
|
1
|
+
const pe = async (t, { pluginPath: e, pluginName: r }, s) => {
|
|
2
|
+
s?.tracker.setCaption(`Activating ${r || e}`);
|
|
3
|
+
const n = [
|
|
4
|
+
`${await t.documentRoot}/wp-load.php`,
|
|
5
|
+
`${await t.documentRoot}/wp-admin/includes/plugin.php`
|
|
6
6
|
];
|
|
7
|
-
if (!
|
|
8
|
-
(
|
|
7
|
+
if (!n.every(
|
|
8
|
+
(a) => t.fileExists(a)
|
|
9
9
|
))
|
|
10
10
|
throw new Error(
|
|
11
|
-
`Required WordPress files do not exist: ${
|
|
11
|
+
`Required WordPress files do not exist: ${n.join(", ")}`
|
|
12
12
|
);
|
|
13
|
-
await t.run({
|
|
13
|
+
if ((await t.run({
|
|
14
14
|
code: `<?php
|
|
15
|
-
|
|
15
|
+
${n.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
|
+
}, fe = async (t, { themeFolderName: e }, r) => {
|
|
21
35
|
r?.tracker.setCaption(`Activating ${e}`);
|
|
22
|
-
const s = `${t.documentRoot}/wp-load.php`;
|
|
36
|
+
const s = `${await t.documentRoot}/wp-load.php`;
|
|
23
37
|
if (!t.fileExists(s))
|
|
24
38
|
throw new Error(
|
|
25
39
|
`Required WordPress file does not exist: ${s}`
|
|
@@ -31,34 +45,39 @@ const ke = async (t, { pluginPath: e }, r) => {
|
|
|
31
45
|
`
|
|
32
46
|
});
|
|
33
47
|
};
|
|
34
|
-
function F(t) {
|
|
35
|
-
return new DOMParser().parseFromString(t.text, "text/html");
|
|
36
|
-
}
|
|
37
48
|
function L(t) {
|
|
38
|
-
const e = t.split(".").shift().replace(
|
|
49
|
+
const e = t.split(".").shift().replace(/-/g, " ");
|
|
39
50
|
return e.charAt(0).toUpperCase() + e.slice(1).toLowerCase();
|
|
40
51
|
}
|
|
41
|
-
async function
|
|
52
|
+
async function v(t, e, r) {
|
|
42
53
|
let s = "";
|
|
43
54
|
await t.fileExists(e) && (s = await t.readFileAsText(e)), await t.writeFile(e, r(s));
|
|
44
55
|
}
|
|
45
56
|
async function Ae(t) {
|
|
46
57
|
return new Uint8Array(await t.arrayBuffer());
|
|
47
58
|
}
|
|
48
|
-
|
|
49
|
-
|
|
59
|
+
class Le extends File {
|
|
60
|
+
constructor(e, r) {
|
|
61
|
+
super(e, r), this.buffers = e;
|
|
62
|
+
}
|
|
63
|
+
async arrayBuffer() {
|
|
64
|
+
return this.buffers[0];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const I = File.prototype.arrayBuffer instanceof Function ? File : Le, Oe = async (t, e) => {
|
|
68
|
+
const r = new Ne(
|
|
50
69
|
t,
|
|
51
70
|
e.siteUrl,
|
|
52
71
|
e.wordpressPath || "/wordpress"
|
|
53
72
|
);
|
|
54
73
|
e.patchSqlitePlugin !== !1 && await r.patchSqlitePlugin(), e.addPhpInfo !== !1 && await r.addPhpInfo(), e.patchSiteUrl !== !1 && await r.patchSiteUrl(), e.disableSiteHealth !== !1 && await r.disableSiteHealth(), e.disableWpNewBlogNotification !== !1 && await r.disableWpNewBlogNotification();
|
|
55
74
|
};
|
|
56
|
-
class
|
|
75
|
+
class Ne {
|
|
57
76
|
constructor(e, r, s) {
|
|
58
77
|
this.php = e, this.scopedSiteUrl = r, this.wordpressPath = s;
|
|
59
78
|
}
|
|
60
79
|
async patchSqlitePlugin() {
|
|
61
|
-
await
|
|
80
|
+
await v(
|
|
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 v(
|
|
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 v(
|
|
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 v(
|
|
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
|
|
126
|
+
const Ue = async (t, { code: e }) => await t.run({ code: e }), He = async (t, { options: e }) => await t.run(e), We = async (t, { key: e, value: r }) => {
|
|
108
127
|
await t.setPhpIniEntry(e, r);
|
|
109
|
-
},
|
|
128
|
+
}, Ie = async (t, { request: e }) => await t.request(e), ze = async (t, { fromPath: e, toPath: r }) => {
|
|
110
129
|
await t.writeFile(
|
|
111
130
|
r,
|
|
112
131
|
await t.readFileAsBuffer(e)
|
|
113
132
|
);
|
|
114
|
-
},
|
|
133
|
+
}, Me = async (t, { fromPath: e, toPath: r }) => {
|
|
115
134
|
await t.mv(e, r);
|
|
116
|
-
},
|
|
135
|
+
}, De = async (t, { path: e }) => {
|
|
117
136
|
await t.mkdir(e);
|
|
118
|
-
},
|
|
137
|
+
}, qe = async (t, { path: e }) => {
|
|
119
138
|
await t.unlink(e);
|
|
120
139
|
}, je = async (t, { path: e }) => {
|
|
121
140
|
await t.rmdir(e);
|
|
122
|
-
},
|
|
141
|
+
}, me = async (t, { path: e, data: r }) => {
|
|
123
142
|
r instanceof File && (r = await Ae(r)), await t.writeFile(e, r);
|
|
124
|
-
},
|
|
125
|
-
const
|
|
126
|
-
await
|
|
143
|
+
}, Y = "/vfs-blueprints", we = async (t, { consts: e, virtualize: r = !1 }) => {
|
|
144
|
+
const s = await t.documentRoot, n = r ? Y : s, i = `${n}/playground-consts.json`, o = `${n}/wp-config.php`;
|
|
145
|
+
return r && (t.mkdir(Y), t.setPhpIniEntry("auto_prepend_file", o)), await v(
|
|
127
146
|
t,
|
|
128
|
-
|
|
129
|
-
(
|
|
130
|
-
...JSON.parse(
|
|
147
|
+
i,
|
|
148
|
+
(a) => JSON.stringify({
|
|
149
|
+
...JSON.parse(a || "{}"),
|
|
131
150
|
...e
|
|
132
151
|
})
|
|
133
|
-
), await
|
|
134
|
-
|
|
135
|
-
`${r}/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 v(t, o, (a) => a.includes("playground-consts.json") ? a : `<?php
|
|
153
|
+
$consts = json_decode(file_get_contents('${i}'), 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
|
-
}, Ve = async (t, { siteUrl: e }) => await pe(t, {
|
|
159
|
+
?>${a}`), o;
|
|
160
|
+
}, Be = async (t, { siteUrl: e }) => await we(t, {
|
|
146
161
|
consts: {
|
|
147
162
|
WP_HOME: e,
|
|
148
163
|
WP_SITEURL: e
|
|
149
164
|
}
|
|
150
165
|
});
|
|
151
|
-
class
|
|
166
|
+
class ge {
|
|
152
167
|
constructor({ concurrency: e }) {
|
|
153
168
|
this._running = 0, this.concurrency = e, this.queue = [];
|
|
154
169
|
}
|
|
@@ -173,7 +188,7 @@ class fe {
|
|
|
173
188
|
}
|
|
174
189
|
}
|
|
175
190
|
}
|
|
176
|
-
const
|
|
191
|
+
const Ve = Symbol("literal");
|
|
177
192
|
function S(t) {
|
|
178
193
|
if (typeof t == "string")
|
|
179
194
|
return t.startsWith("$") ? t : JSON.stringify(t);
|
|
@@ -184,18 +199,18 @@ function S(t) {
|
|
|
184
199
|
if (t === null)
|
|
185
200
|
return "null";
|
|
186
201
|
if (typeof t == "object")
|
|
187
|
-
return
|
|
202
|
+
return Ve in t ? t.toString() : `array(${Object.entries(t).map(([r, s]) => `${JSON.stringify(r)} => ${S(s)}`).join(", ")})`;
|
|
188
203
|
if (typeof t == "function")
|
|
189
204
|
return t();
|
|
190
205
|
throw new Error(`Unsupported value: ${t}`);
|
|
191
206
|
}
|
|
192
|
-
function
|
|
207
|
+
function z(t) {
|
|
193
208
|
const e = {};
|
|
194
209
|
for (const r in t)
|
|
195
210
|
e[r] = S(t[r]);
|
|
196
211
|
return e;
|
|
197
212
|
}
|
|
198
|
-
const
|
|
213
|
+
const J = `<?php
|
|
199
214
|
|
|
200
215
|
function zipDir($dir, $output, $additionalFiles = array())
|
|
201
216
|
{
|
|
@@ -258,12 +273,12 @@ function delTree($dir)
|
|
|
258
273
|
return rmdir($dir);
|
|
259
274
|
}
|
|
260
275
|
`;
|
|
261
|
-
async function
|
|
262
|
-
const e = "wordpress-playground.zip", r = `/${e}`, s =
|
|
276
|
+
async function Ge(t) {
|
|
277
|
+
const e = "wordpress-playground.zip", r = `/${e}`, s = z({
|
|
263
278
|
zipPath: r,
|
|
264
279
|
documentRoot: await t.documentRoot
|
|
265
280
|
});
|
|
266
|
-
await
|
|
281
|
+
await ye(
|
|
267
282
|
t,
|
|
268
283
|
`zipDir(${s.documentRoot}, ${s.zipPath});`
|
|
269
284
|
);
|
|
@@ -277,9 +292,9 @@ const Ye = async (t, { fullSiteZip: e }) => {
|
|
|
277
292
|
new Uint8Array(await e.arrayBuffer())
|
|
278
293
|
);
|
|
279
294
|
const s = await t.absoluteUrl, n = await t.documentRoot;
|
|
280
|
-
await t.rmdir(n), await
|
|
281
|
-
const i =
|
|
282
|
-
await
|
|
295
|
+
await t.rmdir(n), await M(t, { zipPath: r, extractToPath: "/" });
|
|
296
|
+
const i = z({ absoluteUrl: s });
|
|
297
|
+
await Ze(
|
|
283
298
|
t,
|
|
284
299
|
`${n}/wp-config.php`,
|
|
285
300
|
(o) => `<?php
|
|
@@ -289,16 +304,16 @@ const Ye = async (t, { fullSiteZip: e }) => {
|
|
|
289
304
|
}
|
|
290
305
|
?>${o}`
|
|
291
306
|
);
|
|
292
|
-
},
|
|
293
|
-
const s =
|
|
307
|
+
}, M = async (t, { zipPath: e, extractToPath: r }) => {
|
|
308
|
+
const s = z({
|
|
294
309
|
zipPath: e,
|
|
295
310
|
extractToPath: r
|
|
296
311
|
});
|
|
297
|
-
await
|
|
312
|
+
await ye(
|
|
298
313
|
t,
|
|
299
314
|
`unzip(${s.zipPath}, ${s.extractToPath});`
|
|
300
315
|
);
|
|
301
|
-
},
|
|
316
|
+
}, Je = async (t, { file: e }) => {
|
|
302
317
|
const r = await t.request({
|
|
303
318
|
url: "/wp-admin/admin.php?import=wordpress"
|
|
304
319
|
}), s = K(r).getElementById("import-upload-form")?.getAttribute("action"), n = await t.request({
|
|
@@ -312,7 +327,7 @@ const Ye = async (t, { fullSiteZip: e }) => {
|
|
|
312
327
|
throw console.log(n.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 = Ke(i);
|
|
316
331
|
o.fetch_attachments = "1";
|
|
317
332
|
for (const a in o)
|
|
318
333
|
if (a.startsWith("user_map[")) {
|
|
@@ -328,124 +343,115 @@ const Ye = async (t, { fullSiteZip: e }) => {
|
|
|
328
343
|
function K(t) {
|
|
329
344
|
return new DOMParser().parseFromString(t.text, "text/html");
|
|
330
345
|
}
|
|
331
|
-
function
|
|
346
|
+
function Ke(t) {
|
|
332
347
|
return Object.fromEntries(new FormData(t).entries());
|
|
333
348
|
}
|
|
334
|
-
async function
|
|
349
|
+
async function Ze(t, e, r) {
|
|
335
350
|
await t.writeFile(
|
|
336
351
|
e,
|
|
337
352
|
r(await t.readFileAsText(e))
|
|
338
353
|
);
|
|
339
354
|
}
|
|
340
|
-
async function
|
|
355
|
+
async function ye(t, e) {
|
|
341
356
|
const r = await t.run({
|
|
342
|
-
code:
|
|
357
|
+
code: J + e
|
|
343
358
|
});
|
|
344
359
|
if (r.exitCode !== 0)
|
|
345
|
-
throw console.log(
|
|
360
|
+
throw console.log(J + e), console.log(e + ""), console.log(r.errors), r.errors;
|
|
346
361
|
return r;
|
|
347
362
|
}
|
|
348
|
-
|
|
349
|
-
s
|
|
350
|
-
|
|
351
|
-
);
|
|
363
|
+
async function Pe(t, { targetPath: e, zipFile: r }) {
|
|
364
|
+
const s = r.name, n = s.replace(/\.zip$/, ""), i = `/tmp/assets/${n}`, o = `/tmp/${s}`, a = () => t.rmdir(i, {
|
|
365
|
+
recursive: !0
|
|
366
|
+
});
|
|
367
|
+
await t.fileExists(i) && await a(), await me(t, {
|
|
368
|
+
path: o,
|
|
369
|
+
data: r
|
|
370
|
+
});
|
|
371
|
+
const l = () => Promise.all([a, () => t.unlink(o)]);
|
|
352
372
|
try {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
o.querySelector(".wp-upload-form")
|
|
357
|
-
), { pluginzip: l, ...c } = Object.fromEntries(
|
|
358
|
-
a.entries()
|
|
359
|
-
), u = await t.request({
|
|
360
|
-
url: "/wp-admin/update.php?action=upload-plugin",
|
|
361
|
-
method: "POST",
|
|
362
|
-
formData: c,
|
|
363
|
-
files: { pluginzip: e }
|
|
373
|
+
await M(t, {
|
|
374
|
+
zipPath: o,
|
|
375
|
+
extractToPath: i
|
|
364
376
|
});
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
377
|
+
const c = await t.listFiles(i, {
|
|
378
|
+
prependPath: !0
|
|
379
|
+
}), u = c.length === 1 && await t.isDir(c[0]);
|
|
380
|
+
let d, p = "";
|
|
381
|
+
u ? (p = c[0], d = c[0].split("/").pop()) : (p = i, d = n);
|
|
382
|
+
const y = `${e}/${d}`;
|
|
383
|
+
return await t.mv(p, y), await l(), {
|
|
384
|
+
assetFolderPath: y,
|
|
385
|
+
assetFolderName: d
|
|
386
|
+
};
|
|
387
|
+
} catch (c) {
|
|
388
|
+
throw await l(), c;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
const Qe = async (t, { pluginZipFile: e, options: r = {} }, s) => {
|
|
392
|
+
const n = e.name.split("/").pop() || "plugin.zip", i = L(n);
|
|
393
|
+
s?.tracker.setCaption(`Installing the ${i} plugin`);
|
|
394
|
+
try {
|
|
395
|
+
const { assetFolderPath: o } = await Pe(t, {
|
|
396
|
+
zipFile: e,
|
|
397
|
+
targetPath: `${await t.documentRoot}/wp-content/plugins`
|
|
398
|
+
});
|
|
399
|
+
("activate" in r ? r.activate : !0) && await pe(
|
|
384
400
|
t,
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
));
|
|
391
|
-
} catch (
|
|
401
|
+
{
|
|
402
|
+
pluginPath: o,
|
|
403
|
+
pluginName: i
|
|
404
|
+
},
|
|
405
|
+
s
|
|
406
|
+
), await Xe(t);
|
|
407
|
+
} catch (o) {
|
|
392
408
|
console.error(
|
|
393
|
-
`Proceeding without the ${
|
|
394
|
-
), console.error(
|
|
409
|
+
`Proceeding without the ${i} plugin. Could not install it in wp-admin. The original error was: ${o}`
|
|
410
|
+
), console.error(o);
|
|
395
411
|
}
|
|
396
412
|
};
|
|
397
|
-
async function
|
|
413
|
+
async function Xe(t) {
|
|
414
|
+
await t.isDir("/wordpress/wp-content/plugins/gutenberg") && !await t.fileExists("/wordpress/.gutenberg-patched") && (await t.writeFile("/wordpress/.gutenberg-patched", "1"), await Z(
|
|
415
|
+
t,
|
|
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 Z(
|
|
422
|
+
t,
|
|
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 Z(t, e, r) {
|
|
398
431
|
return await t.writeFile(
|
|
399
432
|
e,
|
|
400
433
|
r(await t.readFileAsText(e))
|
|
401
434
|
);
|
|
402
435
|
}
|
|
403
436
|
const et = async (t, { themeZipFile: e, options: r = {} }, s) => {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
);
|
|
437
|
+
const n = L(e.name);
|
|
438
|
+
s?.tracker.setCaption(`Installing the ${n} theme`);
|
|
407
439
|
try {
|
|
408
|
-
const
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
o.querySelector(".wp-upload-form")
|
|
412
|
-
), { themezip: l, ...c } = Object.fromEntries(
|
|
413
|
-
a.entries()
|
|
414
|
-
), u = await t.request({
|
|
415
|
-
url: "/wp-admin/update.php?action=upload-theme",
|
|
416
|
-
method: "POST",
|
|
417
|
-
formData: c,
|
|
418
|
-
files: { themezip: e }
|
|
440
|
+
const { assetFolderName: i } = await Pe(t, {
|
|
441
|
+
zipFile: e,
|
|
442
|
+
targetPath: `${await t.documentRoot}/wp-content/themes`
|
|
419
443
|
});
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
return;
|
|
429
|
-
}
|
|
430
|
-
const y = d.querySelector(
|
|
431
|
-
"#wpbody-content .activatelink, .update-from-upload-actions .button.button-primary"
|
|
432
|
-
);
|
|
433
|
-
if (!y) {
|
|
434
|
-
console.error('The "activate" button was not found.');
|
|
435
|
-
return;
|
|
436
|
-
}
|
|
437
|
-
const Ce = y.attributes.getNamedItem("href").value, Fe = new URL(
|
|
438
|
-
Ce,
|
|
439
|
-
await t.pathToInternalUrl("/wp-admin/")
|
|
440
|
-
).toString();
|
|
441
|
-
await t.request({
|
|
442
|
-
url: Fe
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
} catch (n) {
|
|
444
|
+
("activate" in r ? r.activate : !0) && await fe(
|
|
445
|
+
t,
|
|
446
|
+
{
|
|
447
|
+
themeFolderName: i
|
|
448
|
+
},
|
|
449
|
+
s
|
|
450
|
+
);
|
|
451
|
+
} catch (i) {
|
|
446
452
|
console.error(
|
|
447
|
-
`Proceeding without the ${
|
|
448
|
-
), console.error(
|
|
453
|
+
`Proceeding without the ${n} theme. Could not install it in wp-admin. The original error was: ${i}`
|
|
454
|
+
), console.error(i);
|
|
449
455
|
}
|
|
450
456
|
}, tt = async (t, { username: e = "admin", password: r = "password" } = {}, s) => {
|
|
451
457
|
s?.tracker.setCaption(s?.initialCaption || "Logging in"), await t.request({
|
|
@@ -487,7 +493,7 @@ const et = async (t, { themeZipFile: e, options: r = {} }, s) => {
|
|
|
487
493
|
`, s = await t.run({
|
|
488
494
|
code: r
|
|
489
495
|
});
|
|
490
|
-
return
|
|
496
|
+
return be(s), { code: r, result: s };
|
|
491
497
|
}, nt = async (t, { meta: e, userId: r }) => {
|
|
492
498
|
const s = `<?php
|
|
493
499
|
include 'wordpress/wp-load.php';
|
|
@@ -499,61 +505,42 @@ const et = async (t, { themeZipFile: e, options: r = {} }, s) => {
|
|
|
499
505
|
`, n = await t.run({
|
|
500
506
|
code: s
|
|
501
507
|
});
|
|
502
|
-
return
|
|
508
|
+
return be(n), { code: s, result: n };
|
|
503
509
|
};
|
|
504
|
-
async function
|
|
510
|
+
async function be(t) {
|
|
505
511
|
if (t.text !== "Success")
|
|
506
512
|
throw console.log(t), new Error(`Failed to run code: ${t.text} ${t.errors}`);
|
|
507
513
|
}
|
|
508
|
-
const it =
|
|
509
|
-
t.mkdir(G);
|
|
510
|
-
const r = `${G}/playground-consts.json`;
|
|
511
|
-
return await P(
|
|
512
|
-
t,
|
|
513
|
-
r,
|
|
514
|
-
(s) => JSON.stringify({
|
|
515
|
-
...JSON.parse(s || "{}"),
|
|
516
|
-
...e
|
|
517
|
-
})
|
|
518
|
-
), await P(t, J, (s) => s.includes("playground-consts.json") ? s : `<?php
|
|
519
|
-
$consts = json_decode(file_get_contents('${r}'), true);
|
|
520
|
-
foreach ($consts as $const => $value) {
|
|
521
|
-
if (!defined($const)) {
|
|
522
|
-
define($const, $value);
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
?>${s}`), J;
|
|
526
|
-
}, ot = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
514
|
+
const it = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
527
515
|
__proto__: null,
|
|
528
|
-
activatePlugin:
|
|
529
|
-
activateTheme:
|
|
530
|
-
applyWordPressPatches:
|
|
531
|
-
cp:
|
|
532
|
-
defineSiteUrl:
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
installPlugin: Ze,
|
|
516
|
+
activatePlugin: pe,
|
|
517
|
+
activateTheme: fe,
|
|
518
|
+
applyWordPressPatches: Oe,
|
|
519
|
+
cp: ze,
|
|
520
|
+
defineSiteUrl: Be,
|
|
521
|
+
defineWpConfigConsts: we,
|
|
522
|
+
importFile: Je,
|
|
523
|
+
installPlugin: Qe,
|
|
537
524
|
installTheme: et,
|
|
538
525
|
login: tt,
|
|
539
|
-
mkdir:
|
|
540
|
-
mv:
|
|
526
|
+
mkdir: De,
|
|
527
|
+
mv: Me,
|
|
541
528
|
replaceSite: Ye,
|
|
542
|
-
request:
|
|
543
|
-
rm:
|
|
529
|
+
request: Ie,
|
|
530
|
+
rm: qe,
|
|
544
531
|
rmdir: je,
|
|
545
|
-
runPHP:
|
|
546
|
-
runPHPWithOptions:
|
|
532
|
+
runPHP: Ue,
|
|
533
|
+
runPHPWithOptions: He,
|
|
547
534
|
runWpInstallationWizard: rt,
|
|
548
|
-
setPhpIniEntry:
|
|
535
|
+
setPhpIniEntry: We,
|
|
549
536
|
setSiteOptions: st,
|
|
550
|
-
unzip:
|
|
537
|
+
unzip: M,
|
|
551
538
|
updateUserMeta: nt,
|
|
552
|
-
writeFile:
|
|
553
|
-
zipEntireSite:
|
|
554
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
555
|
-
function
|
|
556
|
-
const r = t.headers.get("content-length") || "", s = parseInt(r, 10) ||
|
|
539
|
+
writeFile: me,
|
|
540
|
+
zipEntireSite: Ge
|
|
541
|
+
}, Symbol.toStringTag, { value: "Module" })), ot = 5 * 1024 * 1024;
|
|
542
|
+
function at(t, e) {
|
|
543
|
+
const r = t.headers.get("content-length") || "", s = parseInt(r, 10) || ot;
|
|
557
544
|
function n(i, o) {
|
|
558
545
|
e(
|
|
559
546
|
new CustomEvent("progress", {
|
|
@@ -594,8 +581,8 @@ function ct(t, e) {
|
|
|
594
581
|
}
|
|
595
582
|
);
|
|
596
583
|
}
|
|
597
|
-
const
|
|
598
|
-
class
|
|
584
|
+
const N = 1e-5;
|
|
585
|
+
class O extends EventTarget {
|
|
599
586
|
constructor({
|
|
600
587
|
weight: e = 1,
|
|
601
588
|
caption: r = "",
|
|
@@ -639,12 +626,12 @@ class U extends EventTarget {
|
|
|
639
626
|
* ```
|
|
640
627
|
*/
|
|
641
628
|
stage(e, r = "") {
|
|
642
|
-
if (e || (e = this._selfWeight), this._selfWeight - e < -
|
|
629
|
+
if (e || (e = this._selfWeight), this._selfWeight - e < -N)
|
|
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 s = new
|
|
634
|
+
const s = new O({
|
|
648
635
|
caption: r,
|
|
649
636
|
weight: e,
|
|
650
637
|
fillTime: this._fillTime
|
|
@@ -681,7 +668,7 @@ class U extends EventTarget {
|
|
|
681
668
|
}, s);
|
|
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 + N >= 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,7 +686,7 @@ class U extends EventTarget {
|
|
|
699
686
|
this._selfCaption = e, this.notifyProgress();
|
|
700
687
|
}
|
|
701
688
|
get done() {
|
|
702
|
-
return this.progress +
|
|
689
|
+
return this.progress + N >= 100;
|
|
703
690
|
}
|
|
704
691
|
get progress() {
|
|
705
692
|
if (this._selfDone)
|
|
@@ -761,7 +748,7 @@ class U extends EventTarget {
|
|
|
761
748
|
this.dispatchEvent(new CustomEvent("done"));
|
|
762
749
|
}
|
|
763
750
|
}
|
|
764
|
-
const
|
|
751
|
+
const Q = Symbol("error"), X = Symbol("message");
|
|
765
752
|
class D extends Event {
|
|
766
753
|
/**
|
|
767
754
|
* Create a new `ErrorEvent`.
|
|
@@ -771,19 +758,19 @@ class D extends Event {
|
|
|
771
758
|
* attributes via object members of the same name.
|
|
772
759
|
*/
|
|
773
760
|
constructor(e, r = {}) {
|
|
774
|
-
super(e), this[
|
|
761
|
+
super(e), this[Q] = r.error === void 0 ? null : r.error, this[X] = r.message === void 0 ? "" : r.message;
|
|
775
762
|
}
|
|
776
763
|
get error() {
|
|
777
|
-
return this[
|
|
764
|
+
return this[Q];
|
|
778
765
|
}
|
|
779
766
|
get message() {
|
|
780
|
-
return this[
|
|
767
|
+
return this[X];
|
|
781
768
|
}
|
|
782
769
|
}
|
|
783
770
|
Object.defineProperty(D.prototype, "error", { enumerable: !0 });
|
|
784
771
|
Object.defineProperty(D.prototype, "message", { enumerable: !0 });
|
|
785
|
-
const
|
|
786
|
-
class
|
|
772
|
+
const ct = typeof globalThis.ErrorEvent == "function" ? globalThis.ErrorEvent : D;
|
|
773
|
+
class lt extends EventTarget {
|
|
787
774
|
constructor() {
|
|
788
775
|
super(...arguments), this.listenersCount = 0;
|
|
789
776
|
}
|
|
@@ -797,11 +784,11 @@ class ut extends EventTarget {
|
|
|
797
784
|
return this.listenersCount > 0;
|
|
798
785
|
}
|
|
799
786
|
}
|
|
800
|
-
function
|
|
787
|
+
function ut(t) {
|
|
801
788
|
t.asm = {
|
|
802
789
|
...t.asm
|
|
803
790
|
};
|
|
804
|
-
const e = new
|
|
791
|
+
const e = new lt();
|
|
805
792
|
for (const r in t.asm)
|
|
806
793
|
if (typeof t.asm[r] == "function") {
|
|
807
794
|
const s = t.asm[r];
|
|
@@ -813,14 +800,14 @@ function ht(t) {
|
|
|
813
800
|
throw i;
|
|
814
801
|
if ("exitCode" in i && i?.exitCode === 0)
|
|
815
802
|
return;
|
|
816
|
-
const o =
|
|
803
|
+
const o = dt(
|
|
817
804
|
i,
|
|
818
805
|
t.lastAsyncifyStackSource?.stack
|
|
819
806
|
);
|
|
820
807
|
if (t.lastAsyncifyStackSource && (i.cause = t.lastAsyncifyStackSource), !e.hasListeners())
|
|
821
|
-
throw
|
|
808
|
+
throw mt(o), i;
|
|
822
809
|
e.dispatchEvent(
|
|
823
|
-
new
|
|
810
|
+
new ct("error", {
|
|
824
811
|
error: i,
|
|
825
812
|
message: o
|
|
826
813
|
})
|
|
@@ -830,29 +817,29 @@ function ht(t) {
|
|
|
830
817
|
}
|
|
831
818
|
return e;
|
|
832
819
|
}
|
|
833
|
-
let
|
|
834
|
-
function
|
|
835
|
-
return
|
|
820
|
+
let H = [];
|
|
821
|
+
function ht() {
|
|
822
|
+
return H;
|
|
836
823
|
}
|
|
837
|
-
function
|
|
824
|
+
function dt(t, e) {
|
|
838
825
|
if (t.message === "unreachable") {
|
|
839
|
-
let r =
|
|
826
|
+
let r = pt;
|
|
840
827
|
e || (r += `
|
|
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
|
-
`),
|
|
832
|
+
`), H = wt(
|
|
846
833
|
e || t.stack || ""
|
|
847
834
|
);
|
|
848
|
-
for (const s of
|
|
835
|
+
for (const s of H)
|
|
849
836
|
r += ` * ${s}
|
|
850
837
|
`;
|
|
851
838
|
return r;
|
|
852
839
|
}
|
|
853
840
|
return t.message;
|
|
854
841
|
}
|
|
855
|
-
const
|
|
842
|
+
const pt = `
|
|
856
843
|
"unreachable" WASM instruction executed.
|
|
857
844
|
|
|
858
845
|
The typical reason is a PHP function missing from the ASYNCIFY_ONLY
|
|
@@ -876,20 +863,20 @@ 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
|
-
`, ee = "\x1B[41m",
|
|
866
|
+
`, ee = "\x1B[41m", ft = "\x1B[1m", te = "\x1B[0m", re = "\x1B[K";
|
|
880
867
|
let se = !1;
|
|
881
|
-
function
|
|
868
|
+
function mt(t) {
|
|
882
869
|
if (!se) {
|
|
883
870
|
se = !0, console.log(`${ee}
|
|
884
871
|
${re}
|
|
885
|
-
${
|
|
872
|
+
${ft} WASM ERROR${te}${ee}`);
|
|
886
873
|
for (const e of t.split(`
|
|
887
874
|
`))
|
|
888
875
|
console.log(`${re} ${e} `);
|
|
889
876
|
console.log(`${te}`);
|
|
890
877
|
}
|
|
891
878
|
}
|
|
892
|
-
function
|
|
879
|
+
function wt(t) {
|
|
893
880
|
try {
|
|
894
881
|
const e = t.split(`
|
|
895
882
|
`).slice(1).map((r) => {
|
|
@@ -906,12 +893,12 @@ function gt(t) {
|
|
|
906
893
|
return [];
|
|
907
894
|
}
|
|
908
895
|
}
|
|
909
|
-
class
|
|
896
|
+
class b {
|
|
910
897
|
constructor(e, r, s, n = "", i = 0) {
|
|
911
898
|
this.httpStatusCode = e, this.headers = r, this.bytes = s, this.exitCode = i, this.errors = n;
|
|
912
899
|
}
|
|
913
900
|
static fromRawData(e) {
|
|
914
|
-
return new
|
|
901
|
+
return new b(
|
|
915
902
|
e.httpStatusCode,
|
|
916
903
|
e.headers,
|
|
917
904
|
e.bytes,
|
|
@@ -951,8 +938,8 @@ const q = [
|
|
|
951
938
|
"7.1",
|
|
952
939
|
"7.0",
|
|
953
940
|
"5.6"
|
|
954
|
-
],
|
|
955
|
-
class
|
|
941
|
+
], gt = q[0], ir = q;
|
|
942
|
+
class yt {
|
|
956
943
|
#e;
|
|
957
944
|
#t;
|
|
958
945
|
/**
|
|
@@ -1038,17 +1025,17 @@ class Pt {
|
|
|
1038
1025
|
return e.join("; ");
|
|
1039
1026
|
}
|
|
1040
1027
|
}
|
|
1041
|
-
const
|
|
1028
|
+
const Pt = "http://example.com";
|
|
1042
1029
|
function ne(t) {
|
|
1043
1030
|
return t.toString().substring(t.origin.length);
|
|
1044
1031
|
}
|
|
1045
1032
|
function ie(t, e) {
|
|
1046
1033
|
return !e || !t.startsWith(e) ? t : t.substring(e.length);
|
|
1047
1034
|
}
|
|
1048
|
-
function
|
|
1035
|
+
function bt(t, e) {
|
|
1049
1036
|
return !e || t.startsWith(e) ? t : e + t;
|
|
1050
1037
|
}
|
|
1051
|
-
class
|
|
1038
|
+
class _t {
|
|
1052
1039
|
#e;
|
|
1053
1040
|
#t;
|
|
1054
1041
|
#s;
|
|
@@ -1063,7 +1050,7 @@ class $t {
|
|
|
1063
1050
|
* @param config - Request Handler configuration.
|
|
1064
1051
|
*/
|
|
1065
1052
|
constructor(e, r = {}) {
|
|
1066
|
-
this.#a = new
|
|
1053
|
+
this.#a = new ge({ concurrency: 1 });
|
|
1067
1054
|
const {
|
|
1068
1055
|
documentRoot: s = "/www/",
|
|
1069
1056
|
absoluteUrl: n = typeof location == "object" ? location?.href : "",
|
|
@@ -1106,7 +1093,7 @@ class $t {
|
|
|
1106
1093
|
async request(e) {
|
|
1107
1094
|
const r = e.url.startsWith("http://") || e.url.startsWith("https://"), s = new URL(
|
|
1108
1095
|
e.url,
|
|
1109
|
-
r ? void 0 :
|
|
1096
|
+
r ? void 0 : Pt
|
|
1110
1097
|
), n = ie(
|
|
1111
1098
|
s.pathname,
|
|
1112
1099
|
this.#n
|
|
@@ -1122,20 +1109,20 @@ class $t {
|
|
|
1122
1109
|
#l(e) {
|
|
1123
1110
|
const r = `${this.#e}${e}`;
|
|
1124
1111
|
if (!this.php.fileExists(r))
|
|
1125
|
-
return new
|
|
1112
|
+
return new b(
|
|
1126
1113
|
404,
|
|
1127
1114
|
{},
|
|
1128
1115
|
new TextEncoder().encode("404 File not found")
|
|
1129
1116
|
);
|
|
1130
1117
|
const s = this.php.readFileAsBuffer(r);
|
|
1131
|
-
return new
|
|
1118
|
+
return new b(
|
|
1132
1119
|
200,
|
|
1133
1120
|
{
|
|
1134
1121
|
"content-length": [`${s.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": [Et(r)],
|
|
1139
1126
|
"accept-ranges": ["bytes"],
|
|
1140
1127
|
"cache-control": ["public, max-age=0"]
|
|
1141
1128
|
},
|
|
@@ -1159,7 +1146,7 @@ class $t {
|
|
|
1159
1146
|
let n = "GET";
|
|
1160
1147
|
const i = {
|
|
1161
1148
|
host: this.#i,
|
|
1162
|
-
...
|
|
1149
|
+
..._e(e.headers || {})
|
|
1163
1150
|
}, o = [];
|
|
1164
1151
|
if (e.files && Object.keys(e.files).length) {
|
|
1165
1152
|
n = "POST";
|
|
@@ -1172,7 +1159,7 @@ class $t {
|
|
|
1172
1159
|
data: new Uint8Array(await u.arrayBuffer())
|
|
1173
1160
|
});
|
|
1174
1161
|
}
|
|
1175
|
-
i["content-type"]?.startsWith("multipart/form-data") && (e.formData =
|
|
1162
|
+
i["content-type"]?.startsWith("multipart/form-data") && (e.formData = $t(
|
|
1176
1163
|
e.body || ""
|
|
1177
1164
|
), i["content-type"] = "application/x-www-form-urlencoded", delete e.body);
|
|
1178
1165
|
}
|
|
@@ -1184,14 +1171,14 @@ class $t {
|
|
|
1184
1171
|
try {
|
|
1185
1172
|
l = this.#h(r.pathname);
|
|
1186
1173
|
} catch {
|
|
1187
|
-
return new
|
|
1174
|
+
return new b(
|
|
1188
1175
|
404,
|
|
1189
1176
|
{},
|
|
1190
1177
|
new TextEncoder().encode("404 File not found")
|
|
1191
1178
|
);
|
|
1192
1179
|
}
|
|
1193
1180
|
return await this.php.run({
|
|
1194
|
-
relativeUri:
|
|
1181
|
+
relativeUri: bt(
|
|
1195
1182
|
ne(r),
|
|
1196
1183
|
this.#n
|
|
1197
1184
|
),
|
|
@@ -1226,7 +1213,7 @@ class $t {
|
|
|
1226
1213
|
return `${this.#e}/index.php`;
|
|
1227
1214
|
}
|
|
1228
1215
|
}
|
|
1229
|
-
function
|
|
1216
|
+
function $t(t) {
|
|
1230
1217
|
const e = {}, r = t.match(/--(.*)\r\n/);
|
|
1231
1218
|
if (!r)
|
|
1232
1219
|
return e;
|
|
@@ -1241,7 +1228,7 @@ function Et(t) {
|
|
|
1241
1228
|
}
|
|
1242
1229
|
}), e;
|
|
1243
1230
|
}
|
|
1244
|
-
function
|
|
1231
|
+
function Et(t) {
|
|
1245
1232
|
switch (t.split(".").pop()) {
|
|
1246
1233
|
case "css":
|
|
1247
1234
|
return "text/css";
|
|
@@ -1379,19 +1366,19 @@ function m(t = "") {
|
|
|
1379
1366
|
};
|
|
1380
1367
|
};
|
|
1381
1368
|
}
|
|
1382
|
-
const
|
|
1383
|
-
function
|
|
1384
|
-
return
|
|
1369
|
+
const vt = [];
|
|
1370
|
+
function St(t) {
|
|
1371
|
+
return vt[t];
|
|
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 n = s > 1 ? void 0 : s ?
|
|
1376
|
+
var Rt = Object.defineProperty, xt = Object.getOwnPropertyDescriptor, w = (t, e, r, s) => {
|
|
1377
|
+
for (var n = s > 1 ? void 0 : s ? xt(e, r) : e, i = t.length - 1, o; i >= 0; i--)
|
|
1391
1378
|
(o = t[i]) && (n = (s ? o(e, r, n) : o(n)) || n);
|
|
1392
|
-
return s && n &&
|
|
1379
|
+
return s && n && Rt(e, r, n), n;
|
|
1393
1380
|
};
|
|
1394
|
-
const f = "string",
|
|
1381
|
+
const f = "string", $ = "number", h = Symbol("__private__dont__use");
|
|
1395
1382
|
class g {
|
|
1396
1383
|
/**
|
|
1397
1384
|
* Initializes a PHP runtime.
|
|
@@ -1401,8 +1388,8 @@ class g {
|
|
|
1401
1388
|
* @param serverOptions - Optional. Options for the PHPRequestHandler. If undefined, no request handler will be initialized.
|
|
1402
1389
|
*/
|
|
1403
1390
|
constructor(e, r) {
|
|
1404
|
-
this.#e = [], this.#t = !1, this.#s = null, this.#r = {}, e !== void 0 && this.initializeRuntime(e), r && (this.requestHandler = new
|
|
1405
|
-
new
|
|
1391
|
+
this.#e = [], this.#t = !1, this.#s = null, this.#r = {}, e !== void 0 && this.initializeRuntime(e), r && (this.requestHandler = new yt(
|
|
1392
|
+
new _t(this, r)
|
|
1406
1393
|
));
|
|
1407
1394
|
}
|
|
1408
1395
|
#e;
|
|
@@ -1430,10 +1417,10 @@ class g {
|
|
|
1430
1417
|
initializeRuntime(e) {
|
|
1431
1418
|
if (this[h])
|
|
1432
1419
|
throw new Error("PHP runtime already initialized.");
|
|
1433
|
-
const r =
|
|
1420
|
+
const r = St(e);
|
|
1434
1421
|
if (!r)
|
|
1435
1422
|
throw new Error("Invalid PHP runtime id.");
|
|
1436
|
-
this[h] = r, this.#s =
|
|
1423
|
+
this[h] = r, this.#s = ut(r);
|
|
1437
1424
|
}
|
|
1438
1425
|
/** @inheritDoc */
|
|
1439
1426
|
setPhpIniPath(e) {
|
|
@@ -1467,7 +1454,7 @@ class g {
|
|
|
1467
1454
|
this.#t || (this.#i(), this.#t = !0), this.#h(e.scriptPath || ""), this.#o(e.relativeUri || ""), this.#c(e.method || "GET");
|
|
1468
1455
|
const { host: r, ...s } = {
|
|
1469
1456
|
host: "example.com:443",
|
|
1470
|
-
...
|
|
1457
|
+
..._e(e.headers || {})
|
|
1471
1458
|
};
|
|
1472
1459
|
if (this.#a(r, e.protocol || "http"), this.#l(s), e.body && this.#u(e.body), e.fileInfos)
|
|
1473
1460
|
for (const n of e.fileInfos)
|
|
@@ -1538,7 +1525,7 @@ class g {
|
|
|
1538
1525
|
(!s || isNaN(s) || s === 80) && (s = r === "https" ? 443 : 80), this[h].ccall(
|
|
1539
1526
|
"wasm_set_request_port",
|
|
1540
1527
|
null,
|
|
1541
|
-
[
|
|
1528
|
+
[$],
|
|
1542
1529
|
[s]
|
|
1543
1530
|
), (r === "https" || !r && s === 443) && this.addServerGlobalEntry("HTTPS", "on");
|
|
1544
1531
|
}
|
|
@@ -1564,14 +1551,16 @@ class g {
|
|
|
1564
1551
|
), e["content-length"] && this[h].ccall(
|
|
1565
1552
|
"wasm_set_content_length",
|
|
1566
1553
|
null,
|
|
1567
|
-
[
|
|
1554
|
+
[$],
|
|
1568
1555
|
[parseInt(e["content-length"], 10)]
|
|
1569
1556
|
);
|
|
1570
|
-
for (const r in e)
|
|
1571
|
-
|
|
1572
|
-
|
|
1557
|
+
for (const r in e) {
|
|
1558
|
+
let s = "HTTP_";
|
|
1559
|
+
["content-type", "content-length"].includes(r.toLowerCase()) && (s = ""), this.addServerGlobalEntry(
|
|
1560
|
+
`${s}${r.toUpperCase().replace(/-/g, "_")}`,
|
|
1573
1561
|
e[r]
|
|
1574
1562
|
);
|
|
1563
|
+
}
|
|
1575
1564
|
}
|
|
1576
1565
|
#u(e) {
|
|
1577
1566
|
this[h].ccall(
|
|
@@ -1582,7 +1571,7 @@ class g {
|
|
|
1582
1571
|
), this[h].ccall(
|
|
1583
1572
|
"wasm_set_content_length",
|
|
1584
1573
|
null,
|
|
1585
|
-
[
|
|
1574
|
+
[$],
|
|
1586
1575
|
[new TextEncoder().encode(e).length]
|
|
1587
1576
|
);
|
|
1588
1577
|
}
|
|
@@ -1622,7 +1611,7 @@ class g {
|
|
|
1622
1611
|
this[h].ccall(
|
|
1623
1612
|
"wasm_add_uploaded_file",
|
|
1624
1613
|
null,
|
|
1625
|
-
[f, f, f, f,
|
|
1614
|
+
[f, f, f, f, $, $],
|
|
1626
1615
|
[r, s, n, o, a, i.byteLength]
|
|
1627
1616
|
);
|
|
1628
1617
|
}
|
|
@@ -1647,7 +1636,7 @@ class g {
|
|
|
1647
1636
|
);
|
|
1648
1637
|
const a = this[h].ccall(
|
|
1649
1638
|
"wasm_sapi_handle_request",
|
|
1650
|
-
|
|
1639
|
+
$,
|
|
1651
1640
|
[],
|
|
1652
1641
|
[]
|
|
1653
1642
|
);
|
|
@@ -1660,14 +1649,14 @@ class g {
|
|
|
1660
1649
|
"PHP runtime has crashed – see the earlier error for details."
|
|
1661
1650
|
);
|
|
1662
1651
|
});
|
|
1663
|
-
this.functionsMaybeMissingFromAsyncify =
|
|
1652
|
+
this.functionsMaybeMissingFromAsyncify = ht();
|
|
1664
1653
|
const o = i, a = "betterMessage" in o ? o.betterMessage : o.message, l = new Error(a);
|
|
1665
1654
|
throw l.cause = o, l;
|
|
1666
1655
|
} finally {
|
|
1667
1656
|
this.#s?.removeEventListener("error", r), this.#r = {};
|
|
1668
1657
|
}
|
|
1669
1658
|
const { headers: s, httpStatusCode: n } = this.#n();
|
|
1670
|
-
return new
|
|
1659
|
+
return new b(
|
|
1671
1660
|
n,
|
|
1672
1661
|
s,
|
|
1673
1662
|
this.readFileAsBuffer("/tmp/stdout"),
|
|
@@ -1694,7 +1683,7 @@ class g {
|
|
|
1694
1683
|
this[h].FS.unlink(e);
|
|
1695
1684
|
}
|
|
1696
1685
|
mv(e, r) {
|
|
1697
|
-
this[h].FS.
|
|
1686
|
+
this[h].FS.rename(e, r);
|
|
1698
1687
|
}
|
|
1699
1688
|
rmdir(e, r = { recursive: !0 }) {
|
|
1700
1689
|
r?.recursive && this.listFiles(e).forEach((s) => {
|
|
@@ -1702,15 +1691,20 @@ class g {
|
|
|
1702
1691
|
this.isDir(n) ? this.rmdir(n, r) : this.unlink(n);
|
|
1703
1692
|
}), this[h].FS.rmdir(e);
|
|
1704
1693
|
}
|
|
1705
|
-
listFiles(e) {
|
|
1694
|
+
listFiles(e, r = { prependPath: !1 }) {
|
|
1706
1695
|
if (!this.fileExists(e))
|
|
1707
1696
|
return [];
|
|
1708
1697
|
try {
|
|
1709
|
-
|
|
1710
|
-
(
|
|
1698
|
+
const s = this[h].FS.readdir(e).filter(
|
|
1699
|
+
(n) => n !== "." && n !== ".."
|
|
1711
1700
|
);
|
|
1712
|
-
|
|
1713
|
-
|
|
1701
|
+
if (r.prependPath) {
|
|
1702
|
+
const n = e.replace(/\/$/, "");
|
|
1703
|
+
return s.map((i) => `${n}/${i}`);
|
|
1704
|
+
}
|
|
1705
|
+
return s;
|
|
1706
|
+
} catch (s) {
|
|
1707
|
+
return console.error(s, { path: e }), [];
|
|
1714
1708
|
}
|
|
1715
1709
|
}
|
|
1716
1710
|
isDir(e) {
|
|
@@ -1759,13 +1753,13 @@ w([
|
|
|
1759
1753
|
w([
|
|
1760
1754
|
m('Could not stat "{path}"')
|
|
1761
1755
|
], g.prototype, "fileExists", 1);
|
|
1762
|
-
function
|
|
1756
|
+
function _e(t) {
|
|
1763
1757
|
const e = {};
|
|
1764
1758
|
for (const r in t)
|
|
1765
1759
|
e[r.toLowerCase()] = t[r];
|
|
1766
1760
|
return e;
|
|
1767
1761
|
}
|
|
1768
|
-
const
|
|
1762
|
+
const Tt = [
|
|
1769
1763
|
"vfs",
|
|
1770
1764
|
"literal",
|
|
1771
1765
|
"wordpress.org/themes",
|
|
@@ -1773,9 +1767,9 @@ const Ct = [
|
|
|
1773
1767
|
"url"
|
|
1774
1768
|
];
|
|
1775
1769
|
function Ft(t) {
|
|
1776
|
-
return t && typeof t == "object" && typeof t.resource == "string" &&
|
|
1770
|
+
return t && typeof t == "object" && typeof t.resource == "string" && Tt.includes(t.resource);
|
|
1777
1771
|
}
|
|
1778
|
-
class
|
|
1772
|
+
class _ {
|
|
1779
1773
|
/**
|
|
1780
1774
|
* Creates a new Resource based on the given file reference
|
|
1781
1775
|
*
|
|
@@ -1787,16 +1781,16 @@ class $ {
|
|
|
1787
1781
|
let n;
|
|
1788
1782
|
switch (e.resource) {
|
|
1789
1783
|
case "vfs":
|
|
1790
|
-
n = new
|
|
1784
|
+
n = new Ct(e, s);
|
|
1791
1785
|
break;
|
|
1792
1786
|
case "literal":
|
|
1793
|
-
n = new
|
|
1787
|
+
n = new kt(e, s);
|
|
1794
1788
|
break;
|
|
1795
1789
|
case "wordpress.org/themes":
|
|
1796
|
-
n = new
|
|
1790
|
+
n = new Ot(e, s);
|
|
1797
1791
|
break;
|
|
1798
1792
|
case "wordpress.org/plugins":
|
|
1799
|
-
n = new
|
|
1793
|
+
n = new Nt(e, s);
|
|
1800
1794
|
break;
|
|
1801
1795
|
case "url":
|
|
1802
1796
|
n = new Lt(e, s);
|
|
@@ -1804,7 +1798,7 @@ class $ {
|
|
|
1804
1798
|
default:
|
|
1805
1799
|
throw new Error(`Invalid resource: ${e}`);
|
|
1806
1800
|
}
|
|
1807
|
-
return n = new
|
|
1801
|
+
return n = new Ut(n), r && (n = new Ht(n, r)), n;
|
|
1808
1802
|
}
|
|
1809
1803
|
setPlayground(e) {
|
|
1810
1804
|
this.playground = e;
|
|
@@ -1814,7 +1808,7 @@ class $ {
|
|
|
1814
1808
|
return !1;
|
|
1815
1809
|
}
|
|
1816
1810
|
}
|
|
1817
|
-
class
|
|
1811
|
+
class Ct extends _ {
|
|
1818
1812
|
/**
|
|
1819
1813
|
* Creates a new instance of `VFSResource`.
|
|
1820
1814
|
* @param playground The playground client.
|
|
@@ -1829,14 +1823,14 @@ class kt extends $ {
|
|
|
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 I([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 kt extends _ {
|
|
1840
1834
|
/**
|
|
1841
1835
|
* Creates a new instance of `LiteralResource`.
|
|
1842
1836
|
* @param resource The literal reference.
|
|
@@ -1847,14 +1841,14 @@ class Ot extends $ {
|
|
|
1847
1841
|
}
|
|
1848
1842
|
/** @inheritDoc */
|
|
1849
1843
|
async resolve() {
|
|
1850
|
-
return this.progress?.set(100), new
|
|
1844
|
+
return this.progress?.set(100), new I([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 j extends _ {
|
|
1858
1852
|
/**
|
|
1859
1853
|
* Creates a new instance of `FetchResource`.
|
|
1860
1854
|
* @param progress The progress tracker.
|
|
@@ -1867,12 +1861,12 @@ class z extends $ {
|
|
|
1867
1861
|
this.progress?.setCaption(this.caption);
|
|
1868
1862
|
const e = this.getURL();
|
|
1869
1863
|
let r = await fetch(e);
|
|
1870
|
-
if (r = await
|
|
1864
|
+
if (r = await at(
|
|
1871
1865
|
r,
|
|
1872
1866
|
this.progress?.loadingListener ?? At
|
|
1873
1867
|
), r.status !== 200)
|
|
1874
1868
|
throw new Error(`Could not download "${e}"`);
|
|
1875
|
-
return new
|
|
1869
|
+
return new I([await r.blob()], this.name);
|
|
1876
1870
|
}
|
|
1877
1871
|
/**
|
|
1878
1872
|
* Gets the caption for the progress tracker.
|
|
@@ -1896,7 +1890,7 @@ class z extends $ {
|
|
|
1896
1890
|
}
|
|
1897
1891
|
const At = () => {
|
|
1898
1892
|
};
|
|
1899
|
-
class Lt extends
|
|
1893
|
+
class Lt extends j {
|
|
1900
1894
|
/**
|
|
1901
1895
|
* Creates a new instance of `UrlResource`.
|
|
1902
1896
|
* @param resource The URL reference.
|
|
@@ -1914,11 +1908,11 @@ class Lt extends z {
|
|
|
1914
1908
|
return this.resource.caption ?? super.caption;
|
|
1915
1909
|
}
|
|
1916
1910
|
}
|
|
1917
|
-
let
|
|
1918
|
-
function
|
|
1919
|
-
|
|
1911
|
+
let B = "https://playground.wordpress.net/plugin-proxy";
|
|
1912
|
+
function or(t) {
|
|
1913
|
+
B = t;
|
|
1920
1914
|
}
|
|
1921
|
-
class
|
|
1915
|
+
class Ot extends j {
|
|
1922
1916
|
constructor(e, r) {
|
|
1923
1917
|
super(r), this.resource = e;
|
|
1924
1918
|
}
|
|
@@ -1926,11 +1920,11 @@ class Ut extends z {
|
|
|
1926
1920
|
return L(this.resource.slug);
|
|
1927
1921
|
}
|
|
1928
1922
|
getURL() {
|
|
1929
|
-
const e =
|
|
1930
|
-
return `${
|
|
1923
|
+
const e = $e(this.resource.slug);
|
|
1924
|
+
return `${B}?theme=` + e;
|
|
1931
1925
|
}
|
|
1932
1926
|
}
|
|
1933
|
-
class
|
|
1927
|
+
class Nt extends j {
|
|
1934
1928
|
constructor(e, r) {
|
|
1935
1929
|
super(r), this.resource = e;
|
|
1936
1930
|
}
|
|
@@ -1940,14 +1934,14 @@ class Ht extends z {
|
|
|
1940
1934
|
}
|
|
1941
1935
|
/** @inheritDoc */
|
|
1942
1936
|
getURL() {
|
|
1943
|
-
const e =
|
|
1944
|
-
return `${
|
|
1937
|
+
const e = $e(this.resource.slug);
|
|
1938
|
+
return `${B}?plugin=` + e;
|
|
1945
1939
|
}
|
|
1946
1940
|
}
|
|
1947
|
-
function
|
|
1941
|
+
function $e(t) {
|
|
1948
1942
|
return !t || t.endsWith(".zip") ? t : t + ".latest-stable.zip";
|
|
1949
1943
|
}
|
|
1950
|
-
class
|
|
1944
|
+
class Ee extends _ {
|
|
1951
1945
|
constructor(e) {
|
|
1952
1946
|
super(), this.resource = e;
|
|
1953
1947
|
}
|
|
@@ -1976,13 +1970,13 @@ class be extends $ {
|
|
|
1976
1970
|
return this.resource.isAsync;
|
|
1977
1971
|
}
|
|
1978
1972
|
}
|
|
1979
|
-
class
|
|
1973
|
+
class Ut extends Ee {
|
|
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 Ht extends Ee {
|
|
1986
1980
|
constructor(e, r) {
|
|
1987
1981
|
super(e), this.semaphore = r;
|
|
1988
1982
|
}
|
|
@@ -1992,17 +1986,17 @@ class Nt extends be {
|
|
|
1992
1986
|
}
|
|
1993
1987
|
}
|
|
1994
1988
|
const Wt = ["6.2", "6.1", "6.0", "5.9"];
|
|
1995
|
-
function
|
|
1996
|
-
progress: e = new
|
|
1997
|
-
semaphore: r = new
|
|
1989
|
+
function It(t, {
|
|
1990
|
+
progress: e = new O(),
|
|
1991
|
+
semaphore: r = new ge({ concurrency: 3 }),
|
|
1998
1992
|
onStepCompleted: s = () => {
|
|
1999
1993
|
}
|
|
2000
1994
|
} = {}) {
|
|
2001
|
-
const n = (t.steps || []).filter(
|
|
1995
|
+
const n = (t.steps || []).filter(zt), i = n.reduce(
|
|
2002
1996
|
(a, l) => a + (l.progress?.weight || 1),
|
|
2003
1997
|
0
|
|
2004
1998
|
), o = n.map(
|
|
2005
|
-
(a) =>
|
|
1999
|
+
(a) => Mt(a, {
|
|
2006
2000
|
semaphore: r,
|
|
2007
2001
|
rootProgressTracker: e,
|
|
2008
2002
|
totalProgressWeight: i
|
|
@@ -2013,7 +2007,7 @@ function Mt(t, {
|
|
|
2013
2007
|
php: ae(
|
|
2014
2008
|
t.preferredVersions?.php,
|
|
2015
2009
|
q,
|
|
2016
|
-
|
|
2010
|
+
gt
|
|
2017
2011
|
),
|
|
2018
2012
|
wp: ae(
|
|
2019
2013
|
t.preferredVersions?.wp,
|
|
@@ -2045,10 +2039,10 @@ function Mt(t, {
|
|
|
2045
2039
|
function ae(t, e, r) {
|
|
2046
2040
|
return t && e.includes(t) ? t : r;
|
|
2047
2041
|
}
|
|
2048
|
-
function
|
|
2042
|
+
function zt(t) {
|
|
2049
2043
|
return !!(typeof t == "object" && t);
|
|
2050
2044
|
}
|
|
2051
|
-
function
|
|
2045
|
+
function Mt(t, {
|
|
2052
2046
|
semaphore: e,
|
|
2053
2047
|
rootProgressTracker: r,
|
|
2054
2048
|
totalProgressWeight: s
|
|
@@ -2058,15 +2052,15 @@ function qt(t, {
|
|
|
2058
2052
|
), i = {};
|
|
2059
2053
|
for (const u of Object.keys(t)) {
|
|
2060
2054
|
let d = t[u];
|
|
2061
|
-
Ft(d) && (d =
|
|
2055
|
+
Ft(d) && (d = _.create(d, {
|
|
2062
2056
|
semaphore: e
|
|
2063
2057
|
})), i[u] = d;
|
|
2064
2058
|
}
|
|
2065
2059
|
const o = async (u) => {
|
|
2066
2060
|
try {
|
|
2067
|
-
return n.fillSlowly(), await
|
|
2061
|
+
return n.fillSlowly(), await it[t.step](
|
|
2068
2062
|
u,
|
|
2069
|
-
await
|
|
2063
|
+
await Dt(i),
|
|
2070
2064
|
{
|
|
2071
2065
|
tracker: n,
|
|
2072
2066
|
initialCaption: t.progress?.caption
|
|
@@ -2086,19 +2080,19 @@ function ce(t) {
|
|
|
2086
2080
|
const e = [];
|
|
2087
2081
|
for (const r in t) {
|
|
2088
2082
|
const s = t[r];
|
|
2089
|
-
s instanceof
|
|
2083
|
+
s instanceof _ && e.push(s);
|
|
2090
2084
|
}
|
|
2091
2085
|
return e;
|
|
2092
2086
|
}
|
|
2093
|
-
async function
|
|
2087
|
+
async function Dt(t) {
|
|
2094
2088
|
const e = {};
|
|
2095
2089
|
for (const r in t) {
|
|
2096
2090
|
const s = t[r];
|
|
2097
|
-
s instanceof
|
|
2091
|
+
s instanceof _ ? e[r] = await s.resolve() : e[r] = s;
|
|
2098
2092
|
}
|
|
2099
2093
|
return e;
|
|
2100
2094
|
}
|
|
2101
|
-
async function
|
|
2095
|
+
async function qt(t, e) {
|
|
2102
2096
|
await t.run(e);
|
|
2103
2097
|
}
|
|
2104
2098
|
/**
|
|
@@ -2106,17 +2100,17 @@ async function jt(t, e) {
|
|
|
2106
2100
|
* Copyright 2019 Google LLC
|
|
2107
2101
|
* SPDX-License-Identifier: Apache-2.0
|
|
2108
2102
|
*/
|
|
2109
|
-
const
|
|
2110
|
-
canHandle: (t) =>
|
|
2103
|
+
const ve = Symbol("Comlink.proxy"), jt = Symbol("Comlink.endpoint"), Bt = Symbol("Comlink.releaseProxy"), U = Symbol("Comlink.finalizer"), T = Symbol("Comlink.thrown"), Se = (t) => typeof t == "object" && t !== null || typeof t == "function", Vt = {
|
|
2104
|
+
canHandle: (t) => Se(t) && t[ve],
|
|
2111
2105
|
serialize(t) {
|
|
2112
2106
|
const { port1: e, port2: r } = new MessageChannel();
|
|
2113
|
-
return
|
|
2107
|
+
return V(t, e), [r, [r]];
|
|
2114
2108
|
},
|
|
2115
2109
|
deserialize(t) {
|
|
2116
|
-
return t.start(),
|
|
2110
|
+
return t.start(), G(t);
|
|
2117
2111
|
}
|
|
2118
|
-
},
|
|
2119
|
-
canHandle: (t) =>
|
|
2112
|
+
}, Gt = {
|
|
2113
|
+
canHandle: (t) => Se(t) && T in t,
|
|
2120
2114
|
serialize({ value: t }) {
|
|
2121
2115
|
let e;
|
|
2122
2116
|
return t instanceof Error ? e = {
|
|
@@ -2132,8 +2126,8 @@ const _e = Symbol("Comlink.proxy"), Bt = Symbol("Comlink.endpoint"), Vt = Symbol
|
|
|
2132
2126
|
throw t.isError ? Object.assign(new Error(t.value.message), t.value) : t.value;
|
|
2133
2127
|
}
|
|
2134
2128
|
}, R = /* @__PURE__ */ new Map([
|
|
2135
|
-
["proxy",
|
|
2136
|
-
["throw",
|
|
2129
|
+
["proxy", Vt],
|
|
2130
|
+
["throw", Gt]
|
|
2137
2131
|
]);
|
|
2138
2132
|
function Yt(t, e) {
|
|
2139
2133
|
for (const r of t)
|
|
@@ -2141,7 +2135,7 @@ function Yt(t, e) {
|
|
|
2141
2135
|
return !0;
|
|
2142
2136
|
return !1;
|
|
2143
2137
|
}
|
|
2144
|
-
function
|
|
2138
|
+
function V(t, e = globalThis, r = ["*"]) {
|
|
2145
2139
|
e.addEventListener("message", function s(n) {
|
|
2146
2140
|
if (!n || !n.data)
|
|
2147
2141
|
return;
|
|
@@ -2149,7 +2143,7 @@ function B(t, e = globalThis, r = ["*"]) {
|
|
|
2149
2143
|
console.warn(`Invalid origin '${n.origin}' for comlink proxy`);
|
|
2150
2144
|
return;
|
|
2151
2145
|
}
|
|
2152
|
-
const { id: i, type: o, path: a } = Object.assign({ path: [] }, n.data), l = (n.data.argumentList || []).map(
|
|
2146
|
+
const { id: i, type: o, path: a } = Object.assign({ path: [] }, n.data), l = (n.data.argumentList || []).map(P);
|
|
2153
2147
|
let c;
|
|
2154
2148
|
try {
|
|
2155
2149
|
const u = a.slice(0, -1).reduce((p, y) => p[y], t), d = a.reduce((p, y) => p[y], t);
|
|
@@ -2158,7 +2152,7 @@ function B(t, e = globalThis, r = ["*"]) {
|
|
|
2158
2152
|
c = d;
|
|
2159
2153
|
break;
|
|
2160
2154
|
case "SET":
|
|
2161
|
-
u[a.slice(-1)[0]] =
|
|
2155
|
+
u[a.slice(-1)[0]] = P(n.data.value), c = !0;
|
|
2162
2156
|
break;
|
|
2163
2157
|
case "APPLY":
|
|
2164
2158
|
c = d.apply(u, l);
|
|
@@ -2166,13 +2160,13 @@ function B(t, e = globalThis, r = ["*"]) {
|
|
|
2166
2160
|
case "CONSTRUCT":
|
|
2167
2161
|
{
|
|
2168
2162
|
const p = new d(...l);
|
|
2169
|
-
c =
|
|
2163
|
+
c = Fe(p);
|
|
2170
2164
|
}
|
|
2171
2165
|
break;
|
|
2172
2166
|
case "ENDPOINT":
|
|
2173
2167
|
{
|
|
2174
2168
|
const { port1: p, port2: y } = new MessageChannel();
|
|
2175
|
-
|
|
2169
|
+
V(t, y), c = Xt(p, [p]);
|
|
2176
2170
|
}
|
|
2177
2171
|
break;
|
|
2178
2172
|
case "RELEASE":
|
|
@@ -2186,7 +2180,7 @@ function B(t, e = globalThis, r = ["*"]) {
|
|
|
2186
2180
|
}
|
|
2187
2181
|
Promise.resolve(c).catch((u) => ({ value: u, [T]: 0 })).then((u) => {
|
|
2188
2182
|
const [d, p] = A(u);
|
|
2189
|
-
e.postMessage(Object.assign(Object.assign({}, d), { id: i }), p), o === "RELEASE" && (e.removeEventListener("message", s),
|
|
2183
|
+
e.postMessage(Object.assign(Object.assign({}, d), { id: i }), p), o === "RELEASE" && (e.removeEventListener("message", s), Re(e), U in t && typeof t[U] == "function" && t[U]());
|
|
2190
2184
|
}).catch((u) => {
|
|
2191
2185
|
const [d, p] = A({
|
|
2192
2186
|
value: new TypeError("Unserializable return value"),
|
|
@@ -2196,53 +2190,53 @@ function B(t, e = globalThis, r = ["*"]) {
|
|
|
2196
2190
|
});
|
|
2197
2191
|
}), e.start && e.start();
|
|
2198
2192
|
}
|
|
2199
|
-
function
|
|
2193
|
+
function Jt(t) {
|
|
2200
2194
|
return t.constructor.name === "MessagePort";
|
|
2201
2195
|
}
|
|
2202
|
-
function
|
|
2203
|
-
|
|
2196
|
+
function Re(t) {
|
|
2197
|
+
Jt(t) && t.close();
|
|
2204
2198
|
}
|
|
2205
|
-
function
|
|
2199
|
+
function G(t, e) {
|
|
2206
2200
|
return W(t, [], e);
|
|
2207
2201
|
}
|
|
2208
2202
|
function x(t) {
|
|
2209
2203
|
if (t)
|
|
2210
2204
|
throw new Error("Proxy has been released and is not useable");
|
|
2211
2205
|
}
|
|
2212
|
-
function
|
|
2213
|
-
return
|
|
2206
|
+
function xe(t) {
|
|
2207
|
+
return E(t, {
|
|
2214
2208
|
type: "RELEASE"
|
|
2215
2209
|
}).then(() => {
|
|
2216
|
-
|
|
2210
|
+
Re(t);
|
|
2217
2211
|
});
|
|
2218
2212
|
}
|
|
2219
|
-
const
|
|
2220
|
-
const e = (
|
|
2221
|
-
|
|
2213
|
+
const C = /* @__PURE__ */ new WeakMap(), k = "FinalizationRegistry" in globalThis && new FinalizationRegistry((t) => {
|
|
2214
|
+
const e = (C.get(t) || 0) - 1;
|
|
2215
|
+
C.set(t, e), e === 0 && xe(t);
|
|
2222
2216
|
});
|
|
2223
|
-
function
|
|
2224
|
-
const r = (
|
|
2225
|
-
|
|
2217
|
+
function Kt(t, e) {
|
|
2218
|
+
const r = (C.get(e) || 0) + 1;
|
|
2219
|
+
C.set(e, r), k && k.register(t, e, t);
|
|
2226
2220
|
}
|
|
2227
|
-
function
|
|
2228
|
-
|
|
2221
|
+
function Zt(t) {
|
|
2222
|
+
k && k.unregister(t);
|
|
2229
2223
|
}
|
|
2230
2224
|
function W(t, e = [], r = function() {
|
|
2231
2225
|
}) {
|
|
2232
2226
|
let s = !1;
|
|
2233
2227
|
const n = new Proxy(r, {
|
|
2234
2228
|
get(i, o) {
|
|
2235
|
-
if (x(s), o ===
|
|
2229
|
+
if (x(s), o === Bt)
|
|
2236
2230
|
return () => {
|
|
2237
|
-
|
|
2231
|
+
Zt(n), xe(t), s = !0;
|
|
2238
2232
|
};
|
|
2239
2233
|
if (o === "then") {
|
|
2240
2234
|
if (e.length === 0)
|
|
2241
2235
|
return { then: () => n };
|
|
2242
|
-
const a =
|
|
2236
|
+
const a = E(t, {
|
|
2243
2237
|
type: "GET",
|
|
2244
2238
|
path: e.map((l) => l.toString())
|
|
2245
|
-
}).then(
|
|
2239
|
+
}).then(P);
|
|
2246
2240
|
return a.then.bind(a);
|
|
2247
2241
|
}
|
|
2248
2242
|
return W(t, [...e, o]);
|
|
@@ -2250,55 +2244,55 @@ function W(t, e = [], r = function() {
|
|
|
2250
2244
|
set(i, o, a) {
|
|
2251
2245
|
x(s);
|
|
2252
2246
|
const [l, c] = A(a);
|
|
2253
|
-
return
|
|
2247
|
+
return E(t, {
|
|
2254
2248
|
type: "SET",
|
|
2255
2249
|
path: [...e, o].map((u) => u.toString()),
|
|
2256
2250
|
value: l
|
|
2257
|
-
}, c).then(
|
|
2251
|
+
}, c).then(P);
|
|
2258
2252
|
},
|
|
2259
2253
|
apply(i, o, a) {
|
|
2260
2254
|
x(s);
|
|
2261
2255
|
const l = e[e.length - 1];
|
|
2262
|
-
if (l ===
|
|
2263
|
-
return
|
|
2256
|
+
if (l === jt)
|
|
2257
|
+
return E(t, {
|
|
2264
2258
|
type: "ENDPOINT"
|
|
2265
|
-
}).then(
|
|
2259
|
+
}).then(P);
|
|
2266
2260
|
if (l === "bind")
|
|
2267
2261
|
return W(t, e.slice(0, -1));
|
|
2268
2262
|
const [c, u] = le(a);
|
|
2269
|
-
return
|
|
2263
|
+
return E(t, {
|
|
2270
2264
|
type: "APPLY",
|
|
2271
2265
|
path: e.map((d) => d.toString()),
|
|
2272
2266
|
argumentList: c
|
|
2273
|
-
}, u).then(
|
|
2267
|
+
}, u).then(P);
|
|
2274
2268
|
},
|
|
2275
2269
|
construct(i, o) {
|
|
2276
2270
|
x(s);
|
|
2277
2271
|
const [a, l] = le(o);
|
|
2278
|
-
return
|
|
2272
|
+
return E(t, {
|
|
2279
2273
|
type: "CONSTRUCT",
|
|
2280
2274
|
path: e.map((c) => c.toString()),
|
|
2281
2275
|
argumentList: a
|
|
2282
|
-
}, l).then(
|
|
2276
|
+
}, l).then(P);
|
|
2283
2277
|
}
|
|
2284
2278
|
});
|
|
2285
|
-
return
|
|
2279
|
+
return Kt(n, t), n;
|
|
2286
2280
|
}
|
|
2287
|
-
function
|
|
2281
|
+
function Qt(t) {
|
|
2288
2282
|
return Array.prototype.concat.apply([], t);
|
|
2289
2283
|
}
|
|
2290
2284
|
function le(t) {
|
|
2291
2285
|
const e = t.map(A);
|
|
2292
|
-
return [e.map((r) => r[0]),
|
|
2286
|
+
return [e.map((r) => r[0]), Qt(e.map((r) => r[1]))];
|
|
2293
2287
|
}
|
|
2294
|
-
const
|
|
2295
|
-
function
|
|
2296
|
-
return
|
|
2288
|
+
const Te = /* @__PURE__ */ new WeakMap();
|
|
2289
|
+
function Xt(t, e) {
|
|
2290
|
+
return Te.set(t, e), t;
|
|
2297
2291
|
}
|
|
2298
|
-
function
|
|
2299
|
-
return Object.assign(t, { [
|
|
2292
|
+
function Fe(t) {
|
|
2293
|
+
return Object.assign(t, { [ve]: !0 });
|
|
2300
2294
|
}
|
|
2301
|
-
function
|
|
2295
|
+
function er(t, e = globalThis, r = "*") {
|
|
2302
2296
|
return {
|
|
2303
2297
|
postMessage: (s, n) => t.postMessage(s, r, n),
|
|
2304
2298
|
addEventListener: e.addEventListener.bind(e),
|
|
@@ -2323,10 +2317,10 @@ function A(t) {
|
|
|
2323
2317
|
type: "RAW",
|
|
2324
2318
|
value: t
|
|
2325
2319
|
},
|
|
2326
|
-
|
|
2320
|
+
Te.get(t) || []
|
|
2327
2321
|
];
|
|
2328
2322
|
}
|
|
2329
|
-
function
|
|
2323
|
+
function P(t) {
|
|
2330
2324
|
switch (t.type) {
|
|
2331
2325
|
case "HANDLER":
|
|
2332
2326
|
return R.get(t.name).deserialize(t.value);
|
|
@@ -2334,26 +2328,26 @@ function b(t) {
|
|
|
2334
2328
|
return t.value;
|
|
2335
2329
|
}
|
|
2336
2330
|
}
|
|
2337
|
-
function
|
|
2331
|
+
function E(t, e, r) {
|
|
2338
2332
|
return new Promise((s) => {
|
|
2339
|
-
const n =
|
|
2333
|
+
const n = tr();
|
|
2340
2334
|
t.addEventListener("message", function i(o) {
|
|
2341
2335
|
!o.data || !o.data.id || o.data.id !== n || (t.removeEventListener("message", i), s(o.data));
|
|
2342
2336
|
}), t.start && t.start(), t.postMessage(Object.assign({ id: n }, e), r);
|
|
2343
2337
|
});
|
|
2344
2338
|
}
|
|
2345
|
-
function
|
|
2339
|
+
function tr() {
|
|
2346
2340
|
return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
|
|
2347
2341
|
}
|
|
2348
|
-
function
|
|
2349
|
-
|
|
2350
|
-
const e = t instanceof Worker ? t :
|
|
2342
|
+
function Ce(t) {
|
|
2343
|
+
rr();
|
|
2344
|
+
const e = t instanceof Worker ? t : er(t), r = G(e), s = ke(r);
|
|
2351
2345
|
return new Proxy(s, {
|
|
2352
2346
|
get: (n, i) => i === "isConnected" ? () => r.isConnected() : r[i]
|
|
2353
2347
|
});
|
|
2354
2348
|
}
|
|
2355
2349
|
let ue = !1;
|
|
2356
|
-
function
|
|
2350
|
+
function rr() {
|
|
2357
2351
|
ue || (ue = !0, R.set("EVENT", {
|
|
2358
2352
|
canHandle: (t) => t instanceof CustomEvent,
|
|
2359
2353
|
serialize: (t) => [
|
|
@@ -2368,10 +2362,10 @@ function sr() {
|
|
|
2368
2362
|
serialize(t) {
|
|
2369
2363
|
console.debug("[Comlink][Performance] Proxying a function");
|
|
2370
2364
|
const { port1: e, port2: r } = new MessageChannel();
|
|
2371
|
-
return
|
|
2365
|
+
return V(t, e), [r, [r]];
|
|
2372
2366
|
},
|
|
2373
2367
|
deserialize(t) {
|
|
2374
|
-
return t.start(),
|
|
2368
|
+
return t.start(), G(t);
|
|
2375
2369
|
}
|
|
2376
2370
|
}), R.set("PHPResponse", {
|
|
2377
2371
|
canHandle: (t) => typeof t == "object" && t !== null && "headers" in t && "bytes" in t && "errors" in t && "exitCode" in t && "httpStatusCode" in t,
|
|
@@ -2379,24 +2373,24 @@ function sr() {
|
|
|
2379
2373
|
return [t.toRawData(), []];
|
|
2380
2374
|
},
|
|
2381
2375
|
deserialize(t) {
|
|
2382
|
-
return
|
|
2376
|
+
return b.fromRawData(t);
|
|
2383
2377
|
}
|
|
2384
2378
|
}));
|
|
2385
2379
|
}
|
|
2386
|
-
function
|
|
2380
|
+
function ke(t) {
|
|
2387
2381
|
return new Proxy(t, {
|
|
2388
2382
|
get(e, r) {
|
|
2389
2383
|
switch (typeof e[r]) {
|
|
2390
2384
|
case "function":
|
|
2391
2385
|
return (...s) => e[r](...s);
|
|
2392
2386
|
case "object":
|
|
2393
|
-
return e[r] === null ? e[r] :
|
|
2387
|
+
return e[r] === null ? e[r] : ke(e[r]);
|
|
2394
2388
|
case "undefined":
|
|
2395
2389
|
case "number":
|
|
2396
2390
|
case "string":
|
|
2397
2391
|
return e[r];
|
|
2398
2392
|
default:
|
|
2399
|
-
return
|
|
2393
|
+
return Fe(e[r]);
|
|
2400
2394
|
}
|
|
2401
2395
|
}
|
|
2402
2396
|
});
|
|
@@ -2404,19 +2398,19 @@ function Te(t) {
|
|
|
2404
2398
|
(function() {
|
|
2405
2399
|
return typeof navigator < "u" && navigator?.userAgent?.toLowerCase().indexOf("firefox") > -1 ? "iframe" : "webworker";
|
|
2406
2400
|
})();
|
|
2407
|
-
async function
|
|
2401
|
+
async function sr({
|
|
2408
2402
|
iframe: t,
|
|
2409
2403
|
blueprint: e,
|
|
2410
2404
|
remoteUrl: r,
|
|
2411
|
-
progressTracker: s = new
|
|
2405
|
+
progressTracker: s = new O(),
|
|
2412
2406
|
disableProgressBar: n,
|
|
2413
2407
|
onBlueprintStepCompleted: i
|
|
2414
2408
|
}) {
|
|
2415
|
-
if (
|
|
2409
|
+
if (nr(r), r = de(r, {
|
|
2416
2410
|
progressbar: !n
|
|
2417
2411
|
}), s.setCaption("Preparing WordPress"), !e)
|
|
2418
2412
|
return he(t, r, s);
|
|
2419
|
-
const o =
|
|
2413
|
+
const o = It(e, {
|
|
2420
2414
|
progress: s.stage(0.5),
|
|
2421
2415
|
onStepCompleted: i
|
|
2422
2416
|
}), a = await he(
|
|
@@ -2427,81 +2421,80 @@ async function nr({
|
|
|
2427
2421
|
}),
|
|
2428
2422
|
s
|
|
2429
2423
|
);
|
|
2430
|
-
return await
|
|
2424
|
+
return await qt(o, a), s.finish(), a;
|
|
2431
2425
|
}
|
|
2432
2426
|
async function he(t, e, r) {
|
|
2433
2427
|
await new Promise((i) => {
|
|
2434
2428
|
t.src = e, t.addEventListener("load", i, !1);
|
|
2435
2429
|
});
|
|
2436
|
-
const s =
|
|
2430
|
+
const s = Ce(
|
|
2437
2431
|
t.contentWindow
|
|
2438
2432
|
);
|
|
2439
2433
|
await s.isConnected(), r.pipe(s);
|
|
2440
2434
|
const n = r.stage();
|
|
2441
2435
|
return await s.onDownloadProgress(n.loadingListener), await s.isReady(), n.finish(), s;
|
|
2442
2436
|
}
|
|
2443
|
-
const
|
|
2444
|
-
function
|
|
2445
|
-
const e = new URL(t,
|
|
2446
|
-
if ((e.origin ===
|
|
2437
|
+
const F = "https://playground.wordpress.net";
|
|
2438
|
+
function nr(t) {
|
|
2439
|
+
const e = new URL(t, F);
|
|
2440
|
+
if ((e.origin === F || e.hostname === "localhost") && e.pathname !== "/remote.html")
|
|
2447
2441
|
throw new Error(
|
|
2448
|
-
`Invalid remote URL: ${e}. Expected origin to be ${
|
|
2442
|
+
`Invalid remote URL: ${e}. Expected origin to be ${F}/remote.html.`
|
|
2449
2443
|
);
|
|
2450
2444
|
}
|
|
2451
2445
|
function de(t, e) {
|
|
2452
|
-
const r = new URL(t,
|
|
2446
|
+
const r = new URL(t, F), s = new URLSearchParams(r.search);
|
|
2453
2447
|
for (const [n, i] of Object.entries(e))
|
|
2454
2448
|
i != null && i !== !1 && s.set(n, i.toString());
|
|
2455
2449
|
return r.search = s.toString(), r.toString();
|
|
2456
2450
|
}
|
|
2457
|
-
async function
|
|
2451
|
+
async function ar(t, e) {
|
|
2458
2452
|
if (console.warn(
|
|
2459
2453
|
"`connectPlayground` is deprecated and will be removed. Use `startPlayground` instead."
|
|
2460
2454
|
), e?.loadRemote)
|
|
2461
|
-
return
|
|
2455
|
+
return sr({
|
|
2462
2456
|
iframe: t,
|
|
2463
2457
|
remoteUrl: e.loadRemote
|
|
2464
2458
|
});
|
|
2465
|
-
const r =
|
|
2459
|
+
const r = Ce(
|
|
2466
2460
|
t.contentWindow
|
|
2467
2461
|
);
|
|
2468
2462
|
return await r.isConnected(), r;
|
|
2469
2463
|
}
|
|
2470
2464
|
export {
|
|
2471
|
-
|
|
2465
|
+
gt as LatestSupportedPHPVersion,
|
|
2472
2466
|
q as SupportedPHPVersions,
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
Ze as installPlugin,
|
|
2467
|
+
ir as SupportedPHPVersionsList,
|
|
2468
|
+
pe as activatePlugin,
|
|
2469
|
+
fe as activateTheme,
|
|
2470
|
+
Oe as applyWordPressPatches,
|
|
2471
|
+
It as compileBlueprint,
|
|
2472
|
+
ar as connectPlayground,
|
|
2473
|
+
ze as cp,
|
|
2474
|
+
Be as defineSiteUrl,
|
|
2475
|
+
we as defineWpConfigConsts,
|
|
2476
|
+
Je as importFile,
|
|
2477
|
+
Qe as installPlugin,
|
|
2485
2478
|
et as installTheme,
|
|
2486
2479
|
tt as login,
|
|
2487
|
-
|
|
2488
|
-
|
|
2480
|
+
De as mkdir,
|
|
2481
|
+
Me as mv,
|
|
2489
2482
|
S as phpVar,
|
|
2490
|
-
|
|
2483
|
+
z as phpVars,
|
|
2491
2484
|
Ye as replaceSite,
|
|
2492
|
-
|
|
2493
|
-
|
|
2485
|
+
Ie as request,
|
|
2486
|
+
qe as rm,
|
|
2494
2487
|
je as rmdir,
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2488
|
+
qt as runBlueprintSteps,
|
|
2489
|
+
Ue as runPHP,
|
|
2490
|
+
He as runPHPWithOptions,
|
|
2498
2491
|
rt as runWpInstallationWizard,
|
|
2499
|
-
|
|
2500
|
-
|
|
2492
|
+
We as setPhpIniEntry,
|
|
2493
|
+
or as setPluginProxyURL,
|
|
2501
2494
|
st as setSiteOptions,
|
|
2502
|
-
|
|
2503
|
-
|
|
2495
|
+
sr as startPlaygroundWeb,
|
|
2496
|
+
M as unzip,
|
|
2504
2497
|
nt as updateUserMeta,
|
|
2505
|
-
|
|
2506
|
-
|
|
2498
|
+
me as writeFile,
|
|
2499
|
+
Ge as zipEntireSite
|
|
2507
2500
|
};
|