@wp-playground/client 0.1.49 → 0.1.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/blueprint-schema.json +4 -30
- package/index.cjs +23 -30
- package/index.d.ts +10 -20
- package/index.js +317 -341
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Fe = async (t, { pluginPath: e }, r) => {
|
|
2
2
|
r?.tracker.setCaption(`Activating ${e}`);
|
|
3
3
|
const s = [
|
|
4
4
|
`${t.documentRoot}/wp-load.php`,
|
|
@@ -17,7 +17,7 @@ const ke = async (t, { pluginPath: e }, r) => {
|
|
|
17
17
|
activate_plugin('${e}');
|
|
18
18
|
`
|
|
19
19
|
});
|
|
20
|
-
},
|
|
20
|
+
}, ke = async (t, { themeFolderName: e }, r) => {
|
|
21
21
|
r?.tracker.setCaption(`Activating ${e}`);
|
|
22
22
|
const s = `${t.documentRoot}/wp-load.php`;
|
|
23
23
|
if (!t.fileExists(s))
|
|
@@ -38,27 +38,27 @@ function L(t) {
|
|
|
38
38
|
const e = t.split(".").shift().replace("-", " ");
|
|
39
39
|
return e.charAt(0).toUpperCase() + e.slice(1).toLowerCase();
|
|
40
40
|
}
|
|
41
|
-
async function
|
|
41
|
+
async function v(t, e, r) {
|
|
42
42
|
let s = "";
|
|
43
43
|
await t.fileExists(e) && (s = await t.readFileAsText(e)), await t.writeFile(e, r(s));
|
|
44
44
|
}
|
|
45
|
-
async function
|
|
45
|
+
async function Oe(t) {
|
|
46
46
|
return new Uint8Array(await t.arrayBuffer());
|
|
47
47
|
}
|
|
48
|
-
const
|
|
49
|
-
const r = new
|
|
48
|
+
const Ae = async (t, e) => {
|
|
49
|
+
const r = new Le(
|
|
50
50
|
t,
|
|
51
51
|
e.siteUrl,
|
|
52
52
|
e.wordpressPath || "/wordpress"
|
|
53
53
|
);
|
|
54
54
|
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
55
|
};
|
|
56
|
-
class
|
|
56
|
+
class Le {
|
|
57
57
|
constructor(e, r, s) {
|
|
58
58
|
this.php = e, this.scopedSiteUrl = r, this.wordpressPath = s;
|
|
59
59
|
}
|
|
60
60
|
async patchSqlitePlugin() {
|
|
61
|
-
await
|
|
61
|
+
await v(
|
|
62
62
|
this.php,
|
|
63
63
|
`${this.wordpressPath}/wp-content/plugins/sqlite-database-integration/wp-includes/sqlite/class-wp-sqlite-translator.php`,
|
|
64
64
|
(e) => e.replace(
|
|
@@ -74,7 +74,7 @@ class Ue {
|
|
|
74
74
|
);
|
|
75
75
|
}
|
|
76
76
|
async patchSiteUrl() {
|
|
77
|
-
await
|
|
77
|
+
await v(
|
|
78
78
|
this.php,
|
|
79
79
|
`${this.wordpressPath}/wp-config.php`,
|
|
80
80
|
(e) => `<?php
|
|
@@ -86,7 +86,7 @@ class Ue {
|
|
|
86
86
|
);
|
|
87
87
|
}
|
|
88
88
|
async disableSiteHealth() {
|
|
89
|
-
await
|
|
89
|
+
await v(
|
|
90
90
|
this.php,
|
|
91
91
|
`${this.wordpressPath}/wp-includes/default-filters.php`,
|
|
92
92
|
(e) => e.replace(
|
|
@@ -96,7 +96,7 @@ class Ue {
|
|
|
96
96
|
);
|
|
97
97
|
}
|
|
98
98
|
async disableWpNewBlogNotification() {
|
|
99
|
-
await
|
|
99
|
+
await v(
|
|
100
100
|
this.php,
|
|
101
101
|
`${this.wordpressPath}/wp-config.php`,
|
|
102
102
|
// The original version of this function crashes WASM PHP, let's define an empty one instead.
|
|
@@ -104,51 +104,47 @@ class Ue {
|
|
|
104
104
|
);
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
const
|
|
107
|
+
const Ue = async (t, { code: e }) => await t.run({ code: e }), He = async (t, { options: e }) => await t.run(e), Ie = async (t, { key: e, value: r }) => {
|
|
108
108
|
await t.setPhpIniEntry(e, r);
|
|
109
|
-
},
|
|
109
|
+
}, Ne = async (t, { request: e }) => await t.request(e), We = async (t, { fromPath: e, toPath: r }) => {
|
|
110
110
|
await t.writeFile(
|
|
111
111
|
r,
|
|
112
112
|
await t.readFileAsBuffer(e)
|
|
113
113
|
);
|
|
114
|
-
},
|
|
114
|
+
}, Me = async (t, { fromPath: e, toPath: r }) => {
|
|
115
115
|
await t.mv(e, r);
|
|
116
|
-
},
|
|
116
|
+
}, De = async (t, { path: e }) => {
|
|
117
117
|
await t.mkdir(e);
|
|
118
|
-
},
|
|
118
|
+
}, qe = async (t, { path: e }) => {
|
|
119
119
|
await t.unlink(e);
|
|
120
|
-
},
|
|
120
|
+
}, ze = async (t, { path: e }) => {
|
|
121
121
|
await t.rmdir(e);
|
|
122
|
-
},
|
|
123
|
-
r instanceof File && (r = await
|
|
124
|
-
},
|
|
125
|
-
const
|
|
126
|
-
await
|
|
122
|
+
}, je = async (t, { path: e, data: r }) => {
|
|
123
|
+
r instanceof File && (r = await Oe(r)), await t.writeFile(e, r);
|
|
124
|
+
}, G = "/vfs-blueprints", de = async (t, { consts: e, virtualize: r = !1 }) => {
|
|
125
|
+
const s = await t.documentRoot, n = r ? G : s, i = `${n}/playground-consts.json`, o = `${n}/wp-config.php`;
|
|
126
|
+
return r && (t.mkdir(G), t.setPhpIniEntry("auto_prepend_file", o)), await v(
|
|
127
127
|
t,
|
|
128
|
-
|
|
129
|
-
(
|
|
130
|
-
...JSON.parse(
|
|
128
|
+
i,
|
|
129
|
+
(a) => JSON.stringify({
|
|
130
|
+
...JSON.parse(a || "{}"),
|
|
131
131
|
...e
|
|
132
132
|
})
|
|
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);
|
|
133
|
+
), await v(t, o, (a) => a.includes("playground-consts.json") ? a : `<?php
|
|
134
|
+
$consts = json_decode(file_get_contents('${i}'), true);
|
|
138
135
|
foreach ($consts as $const => $value) {
|
|
139
136
|
if (!defined($const)) {
|
|
140
137
|
define($const, $value);
|
|
141
138
|
}
|
|
142
139
|
}
|
|
143
|
-
?>${
|
|
144
|
-
|
|
145
|
-
}, Ve = async (t, { siteUrl: e }) => await pe(t, {
|
|
140
|
+
?>${a}`), o;
|
|
141
|
+
}, Be = async (t, { siteUrl: e }) => await de(t, {
|
|
146
142
|
consts: {
|
|
147
143
|
WP_HOME: e,
|
|
148
144
|
WP_SITEURL: e
|
|
149
145
|
}
|
|
150
146
|
});
|
|
151
|
-
class
|
|
147
|
+
class pe {
|
|
152
148
|
constructor({ concurrency: e }) {
|
|
153
149
|
this._running = 0, this.concurrency = e, this.queue = [];
|
|
154
150
|
}
|
|
@@ -173,7 +169,7 @@ class fe {
|
|
|
173
169
|
}
|
|
174
170
|
}
|
|
175
171
|
}
|
|
176
|
-
const
|
|
172
|
+
const Ve = Symbol("literal");
|
|
177
173
|
function S(t) {
|
|
178
174
|
if (typeof t == "string")
|
|
179
175
|
return t.startsWith("$") ? t : JSON.stringify(t);
|
|
@@ -184,7 +180,7 @@ function S(t) {
|
|
|
184
180
|
if (t === null)
|
|
185
181
|
return "null";
|
|
186
182
|
if (typeof t == "object")
|
|
187
|
-
return
|
|
183
|
+
return Ve in t ? t.toString() : `array(${Object.entries(t).map(([r, s]) => `${JSON.stringify(r)} => ${S(s)}`).join(", ")})`;
|
|
188
184
|
if (typeof t == "function")
|
|
189
185
|
return t();
|
|
190
186
|
throw new Error(`Unsupported value: ${t}`);
|
|
@@ -258,12 +254,12 @@ function delTree($dir)
|
|
|
258
254
|
return rmdir($dir);
|
|
259
255
|
}
|
|
260
256
|
`;
|
|
261
|
-
async function
|
|
257
|
+
async function Ge(t) {
|
|
262
258
|
const e = "wordpress-playground.zip", r = `/${e}`, s = M({
|
|
263
259
|
zipPath: r,
|
|
264
260
|
documentRoot: await t.documentRoot
|
|
265
261
|
});
|
|
266
|
-
await
|
|
262
|
+
await me(
|
|
267
263
|
t,
|
|
268
264
|
`zipDir(${s.documentRoot}, ${s.zipPath});`
|
|
269
265
|
);
|
|
@@ -277,9 +273,9 @@ const Ye = async (t, { fullSiteZip: e }) => {
|
|
|
277
273
|
new Uint8Array(await e.arrayBuffer())
|
|
278
274
|
);
|
|
279
275
|
const s = await t.absoluteUrl, n = await t.documentRoot;
|
|
280
|
-
await t.rmdir(n), await
|
|
276
|
+
await t.rmdir(n), await fe(t, { zipPath: r, extractToPath: "/" });
|
|
281
277
|
const i = M({ absoluteUrl: s });
|
|
282
|
-
await
|
|
278
|
+
await Qe(
|
|
283
279
|
t,
|
|
284
280
|
`${n}/wp-config.php`,
|
|
285
281
|
(o) => `<?php
|
|
@@ -289,30 +285,30 @@ const Ye = async (t, { fullSiteZip: e }) => {
|
|
|
289
285
|
}
|
|
290
286
|
?>${o}`
|
|
291
287
|
);
|
|
292
|
-
},
|
|
288
|
+
}, fe = async (t, { zipPath: e, extractToPath: r }) => {
|
|
293
289
|
const s = M({
|
|
294
290
|
zipPath: e,
|
|
295
291
|
extractToPath: r
|
|
296
292
|
});
|
|
297
|
-
await
|
|
293
|
+
await me(
|
|
298
294
|
t,
|
|
299
295
|
`unzip(${s.zipPath}, ${s.extractToPath});`
|
|
300
296
|
);
|
|
301
|
-
},
|
|
297
|
+
}, Je = async (t, { file: e }) => {
|
|
302
298
|
const r = await t.request({
|
|
303
299
|
url: "/wp-admin/admin.php?import=wordpress"
|
|
304
|
-
}), s =
|
|
300
|
+
}), s = J(r).getElementById("import-upload-form")?.getAttribute("action"), n = await t.request({
|
|
305
301
|
url: `/wp-admin/${s}`,
|
|
306
302
|
method: "POST",
|
|
307
303
|
files: { import: e }
|
|
308
|
-
}), i =
|
|
304
|
+
}), i = J(n).querySelector(
|
|
309
305
|
"#wpbody-content form"
|
|
310
306
|
);
|
|
311
307
|
if (!i)
|
|
312
308
|
throw console.log(n.text), new Error(
|
|
313
309
|
"Could not find an importer form in response. See the response text above for details."
|
|
314
310
|
);
|
|
315
|
-
const o =
|
|
311
|
+
const o = Ke(i);
|
|
316
312
|
o.fetch_attachments = "1";
|
|
317
313
|
for (const a in o)
|
|
318
314
|
if (a.startsWith("user_map[")) {
|
|
@@ -325,19 +321,19 @@ const Ye = async (t, { fullSiteZip: e }) => {
|
|
|
325
321
|
formData: o
|
|
326
322
|
});
|
|
327
323
|
};
|
|
328
|
-
function
|
|
324
|
+
function J(t) {
|
|
329
325
|
return new DOMParser().parseFromString(t.text, "text/html");
|
|
330
326
|
}
|
|
331
|
-
function
|
|
327
|
+
function Ke(t) {
|
|
332
328
|
return Object.fromEntries(new FormData(t).entries());
|
|
333
329
|
}
|
|
334
|
-
async function
|
|
330
|
+
async function Qe(t, e, r) {
|
|
335
331
|
await t.writeFile(
|
|
336
332
|
e,
|
|
337
333
|
r(await t.readFileAsText(e))
|
|
338
334
|
);
|
|
339
335
|
}
|
|
340
|
-
async function
|
|
336
|
+
async function me(t, e) {
|
|
341
337
|
const r = await t.run({
|
|
342
338
|
code: Y + e
|
|
343
339
|
});
|
|
@@ -345,7 +341,7 @@ async function we(t, e) {
|
|
|
345
341
|
throw console.log(Y + e), console.log(e + ""), console.log(r.errors), r.errors;
|
|
346
342
|
return r;
|
|
347
343
|
}
|
|
348
|
-
const
|
|
344
|
+
const Xe = async (t, { pluginZipFile: e, options: r = {} }, s) => {
|
|
349
345
|
s?.tracker.setCaption(
|
|
350
346
|
`Installing the ${L(e?.name)} plugin`
|
|
351
347
|
);
|
|
@@ -373,14 +369,14 @@ const Ze = async (t, { pluginZipFile: e, options: r = {} }, s) => {
|
|
|
373
369
|
}
|
|
374
370
|
await t.isDir(
|
|
375
371
|
"/wordpress/wp-content/plugins/gutenberg"
|
|
376
|
-
) && !await t.fileExists("/wordpress/.gutenberg-patched") && (await t.writeFile("/wordpress/.gutenberg-patched", "1"), await
|
|
372
|
+
) && !await t.fileExists("/wordpress/.gutenberg-patched") && (await t.writeFile("/wordpress/.gutenberg-patched", "1"), await K(
|
|
377
373
|
t,
|
|
378
374
|
"/wordpress/wp-content/plugins/gutenberg/build/block-editor/index.js",
|
|
379
375
|
(d) => d.replace(
|
|
380
376
|
/srcDoc:("[^"]+"|[^,]+)/g,
|
|
381
377
|
'src:"/wp-includes/empty.html"'
|
|
382
378
|
)
|
|
383
|
-
), await
|
|
379
|
+
), await K(
|
|
384
380
|
t,
|
|
385
381
|
"/wordpress/wp-content/plugins/gutenberg/build/block-editor/index.min.js",
|
|
386
382
|
(d) => d.replace(
|
|
@@ -394,13 +390,13 @@ const Ze = async (t, { pluginZipFile: e, options: r = {} }, s) => {
|
|
|
394
390
|
), console.error(n);
|
|
395
391
|
}
|
|
396
392
|
};
|
|
397
|
-
async function
|
|
393
|
+
async function K(t, e, r) {
|
|
398
394
|
return await t.writeFile(
|
|
399
395
|
e,
|
|
400
396
|
r(await t.readFileAsText(e))
|
|
401
397
|
);
|
|
402
398
|
}
|
|
403
|
-
const
|
|
399
|
+
const Ze = async (t, { themeZipFile: e, options: r = {} }, s) => {
|
|
404
400
|
s?.tracker.setCaption(
|
|
405
401
|
`Installing the ${L(e.name)} theme`
|
|
406
402
|
);
|
|
@@ -434,12 +430,12 @@ const et = async (t, { themeZipFile: e, options: r = {} }, s) => {
|
|
|
434
430
|
console.error('The "activate" button was not found.');
|
|
435
431
|
return;
|
|
436
432
|
}
|
|
437
|
-
const
|
|
438
|
-
|
|
433
|
+
const Te = y.attributes.getNamedItem("href").value, Ce = new URL(
|
|
434
|
+
Te,
|
|
439
435
|
await t.pathToInternalUrl("/wp-admin/")
|
|
440
436
|
).toString();
|
|
441
437
|
await t.request({
|
|
442
|
-
url:
|
|
438
|
+
url: Ce
|
|
443
439
|
});
|
|
444
440
|
}
|
|
445
441
|
} catch (n) {
|
|
@@ -447,7 +443,7 @@ const et = async (t, { themeZipFile: e, options: r = {} }, s) => {
|
|
|
447
443
|
`Proceeding without the ${e.name} theme. Could not install it in wp-admin. The original error was: ${n}`
|
|
448
444
|
), console.error(n);
|
|
449
445
|
}
|
|
450
|
-
},
|
|
446
|
+
}, et = async (t, { username: e = "admin", password: r = "password" } = {}, s) => {
|
|
451
447
|
s?.tracker.setCaption(s?.initialCaption || "Logging in"), await t.request({
|
|
452
448
|
url: "/wp-login.php"
|
|
453
449
|
}), await t.request({
|
|
@@ -459,7 +455,7 @@ const et = async (t, { themeZipFile: e, options: r = {} }, s) => {
|
|
|
459
455
|
rememberme: "forever"
|
|
460
456
|
}
|
|
461
457
|
});
|
|
462
|
-
},
|
|
458
|
+
}, tt = async (t, { options: e }) => {
|
|
463
459
|
await t.request({
|
|
464
460
|
url: "/wp-admin/install.php?step=2",
|
|
465
461
|
method: "POST",
|
|
@@ -476,7 +472,7 @@ const et = async (t, { themeZipFile: e, options: r = {} }, s) => {
|
|
|
476
472
|
admin_email: "admin@localhost.com"
|
|
477
473
|
}
|
|
478
474
|
});
|
|
479
|
-
},
|
|
475
|
+
}, rt = async (t, { options: e }) => {
|
|
480
476
|
const r = `<?php
|
|
481
477
|
include 'wordpress/wp-load.php';
|
|
482
478
|
$site_options = ${S(e)};
|
|
@@ -487,8 +483,8 @@ const et = async (t, { themeZipFile: e, options: r = {} }, s) => {
|
|
|
487
483
|
`, s = await t.run({
|
|
488
484
|
code: r
|
|
489
485
|
});
|
|
490
|
-
return
|
|
491
|
-
},
|
|
486
|
+
return we(s), { code: r, result: s };
|
|
487
|
+
}, st = async (t, { meta: e, userId: r }) => {
|
|
492
488
|
const s = `<?php
|
|
493
489
|
include 'wordpress/wp-load.php';
|
|
494
490
|
$meta = ${S(e)};
|
|
@@ -499,61 +495,42 @@ const et = async (t, { themeZipFile: e, options: r = {} }, s) => {
|
|
|
499
495
|
`, n = await t.run({
|
|
500
496
|
code: s
|
|
501
497
|
});
|
|
502
|
-
return
|
|
498
|
+
return we(n), { code: s, result: n };
|
|
503
499
|
};
|
|
504
|
-
async function
|
|
500
|
+
async function we(t) {
|
|
505
501
|
if (t.text !== "Success")
|
|
506
502
|
throw console.log(t), new Error(`Failed to run code: ${t.text} ${t.errors}`);
|
|
507
503
|
}
|
|
508
|
-
const
|
|
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({
|
|
504
|
+
const nt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
527
505
|
__proto__: null,
|
|
528
|
-
activatePlugin:
|
|
529
|
-
activateTheme:
|
|
530
|
-
applyWordPressPatches:
|
|
531
|
-
cp:
|
|
532
|
-
defineSiteUrl:
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
mv: De,
|
|
506
|
+
activatePlugin: Fe,
|
|
507
|
+
activateTheme: ke,
|
|
508
|
+
applyWordPressPatches: Ae,
|
|
509
|
+
cp: We,
|
|
510
|
+
defineSiteUrl: Be,
|
|
511
|
+
defineWpConfigConsts: de,
|
|
512
|
+
importFile: Je,
|
|
513
|
+
installPlugin: Xe,
|
|
514
|
+
installTheme: Ze,
|
|
515
|
+
login: et,
|
|
516
|
+
mkdir: De,
|
|
517
|
+
mv: Me,
|
|
541
518
|
replaceSite: Ye,
|
|
542
|
-
request:
|
|
543
|
-
rm:
|
|
544
|
-
rmdir:
|
|
545
|
-
runPHP:
|
|
546
|
-
runPHPWithOptions:
|
|
547
|
-
runWpInstallationWizard:
|
|
548
|
-
setPhpIniEntry:
|
|
549
|
-
setSiteOptions:
|
|
550
|
-
unzip:
|
|
551
|
-
updateUserMeta:
|
|
552
|
-
writeFile:
|
|
553
|
-
zipEntireSite:
|
|
554
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
555
|
-
function
|
|
556
|
-
const r = t.headers.get("content-length") || "", s = parseInt(r, 10) ||
|
|
519
|
+
request: Ne,
|
|
520
|
+
rm: qe,
|
|
521
|
+
rmdir: ze,
|
|
522
|
+
runPHP: Ue,
|
|
523
|
+
runPHPWithOptions: He,
|
|
524
|
+
runWpInstallationWizard: tt,
|
|
525
|
+
setPhpIniEntry: Ie,
|
|
526
|
+
setSiteOptions: rt,
|
|
527
|
+
unzip: fe,
|
|
528
|
+
updateUserMeta: st,
|
|
529
|
+
writeFile: je,
|
|
530
|
+
zipEntireSite: Ge
|
|
531
|
+
}, Symbol.toStringTag, { value: "Module" })), it = 5 * 1024 * 1024;
|
|
532
|
+
function ot(t, e) {
|
|
533
|
+
const r = t.headers.get("content-length") || "", s = parseInt(r, 10) || it;
|
|
557
534
|
function n(i, o) {
|
|
558
535
|
e(
|
|
559
536
|
new CustomEvent("progress", {
|
|
@@ -761,7 +738,7 @@ class U extends EventTarget {
|
|
|
761
738
|
this.dispatchEvent(new CustomEvent("done"));
|
|
762
739
|
}
|
|
763
740
|
}
|
|
764
|
-
const
|
|
741
|
+
const Q = Symbol("error"), X = Symbol("message");
|
|
765
742
|
class D extends Event {
|
|
766
743
|
/**
|
|
767
744
|
* Create a new `ErrorEvent`.
|
|
@@ -771,19 +748,19 @@ class D extends Event {
|
|
|
771
748
|
* attributes via object members of the same name.
|
|
772
749
|
*/
|
|
773
750
|
constructor(e, r = {}) {
|
|
774
|
-
super(e), this[
|
|
751
|
+
super(e), this[Q] = r.error === void 0 ? null : r.error, this[X] = r.message === void 0 ? "" : r.message;
|
|
775
752
|
}
|
|
776
753
|
get error() {
|
|
777
|
-
return this[
|
|
754
|
+
return this[Q];
|
|
778
755
|
}
|
|
779
756
|
get message() {
|
|
780
|
-
return this[
|
|
757
|
+
return this[X];
|
|
781
758
|
}
|
|
782
759
|
}
|
|
783
760
|
Object.defineProperty(D.prototype, "error", { enumerable: !0 });
|
|
784
761
|
Object.defineProperty(D.prototype, "message", { enumerable: !0 });
|
|
785
|
-
const
|
|
786
|
-
class
|
|
762
|
+
const at = typeof globalThis.ErrorEvent == "function" ? globalThis.ErrorEvent : D;
|
|
763
|
+
class ct extends EventTarget {
|
|
787
764
|
constructor() {
|
|
788
765
|
super(...arguments), this.listenersCount = 0;
|
|
789
766
|
}
|
|
@@ -797,11 +774,11 @@ class ut extends EventTarget {
|
|
|
797
774
|
return this.listenersCount > 0;
|
|
798
775
|
}
|
|
799
776
|
}
|
|
800
|
-
function
|
|
777
|
+
function lt(t) {
|
|
801
778
|
t.asm = {
|
|
802
779
|
...t.asm
|
|
803
780
|
};
|
|
804
|
-
const e = new
|
|
781
|
+
const e = new ct();
|
|
805
782
|
for (const r in t.asm)
|
|
806
783
|
if (typeof t.asm[r] == "function") {
|
|
807
784
|
const s = t.asm[r];
|
|
@@ -813,14 +790,14 @@ function ht(t) {
|
|
|
813
790
|
throw i;
|
|
814
791
|
if ("exitCode" in i && i?.exitCode === 0)
|
|
815
792
|
return;
|
|
816
|
-
const o =
|
|
793
|
+
const o = ht(
|
|
817
794
|
i,
|
|
818
795
|
t.lastAsyncifyStackSource?.stack
|
|
819
796
|
);
|
|
820
797
|
if (t.lastAsyncifyStackSource && (i.cause = t.lastAsyncifyStackSource), !e.hasListeners())
|
|
821
|
-
throw
|
|
798
|
+
throw ft(o), i;
|
|
822
799
|
e.dispatchEvent(
|
|
823
|
-
new
|
|
800
|
+
new at("error", {
|
|
824
801
|
error: i,
|
|
825
802
|
message: o
|
|
826
803
|
})
|
|
@@ -831,18 +808,18 @@ function ht(t) {
|
|
|
831
808
|
return e;
|
|
832
809
|
}
|
|
833
810
|
let N = [];
|
|
834
|
-
function
|
|
811
|
+
function ut() {
|
|
835
812
|
return N;
|
|
836
813
|
}
|
|
837
|
-
function
|
|
814
|
+
function ht(t, e) {
|
|
838
815
|
if (t.message === "unreachable") {
|
|
839
|
-
let r =
|
|
816
|
+
let r = dt;
|
|
840
817
|
e || (r += `
|
|
841
818
|
|
|
842
819
|
This stack trace is lacking. For a better one initialize
|
|
843
820
|
the PHP runtime with { debug: true }, e.g. PHPNode.load('8.1', { debug: true }).
|
|
844
821
|
|
|
845
|
-
`), N =
|
|
822
|
+
`), N = mt(
|
|
846
823
|
e || t.stack || ""
|
|
847
824
|
);
|
|
848
825
|
for (const s of N)
|
|
@@ -852,7 +829,7 @@ the PHP runtime with { debug: true }, e.g. PHPNode.load('8.1', { debug: true }).
|
|
|
852
829
|
}
|
|
853
830
|
return t.message;
|
|
854
831
|
}
|
|
855
|
-
const
|
|
832
|
+
const dt = `
|
|
856
833
|
"unreachable" WASM instruction executed.
|
|
857
834
|
|
|
858
835
|
The typical reason is a PHP function missing from the ASYNCIFY_ONLY
|
|
@@ -876,20 +853,20 @@ the Dockerfile, you'll need to trigger this error again with long stack
|
|
|
876
853
|
traces enabled. In node.js, you can do it using the --stack-trace-limit=100
|
|
877
854
|
CLI option:
|
|
878
855
|
|
|
879
|
-
`,
|
|
880
|
-
let
|
|
881
|
-
function
|
|
882
|
-
if (!
|
|
883
|
-
|
|
884
|
-
${
|
|
885
|
-
${
|
|
856
|
+
`, Z = "\x1B[41m", pt = "\x1B[1m", ee = "\x1B[0m", te = "\x1B[K";
|
|
857
|
+
let re = !1;
|
|
858
|
+
function ft(t) {
|
|
859
|
+
if (!re) {
|
|
860
|
+
re = !0, console.log(`${Z}
|
|
861
|
+
${te}
|
|
862
|
+
${pt} WASM ERROR${ee}${Z}`);
|
|
886
863
|
for (const e of t.split(`
|
|
887
864
|
`))
|
|
888
|
-
console.log(`${
|
|
889
|
-
console.log(`${
|
|
865
|
+
console.log(`${te} ${e} `);
|
|
866
|
+
console.log(`${ee}`);
|
|
890
867
|
}
|
|
891
868
|
}
|
|
892
|
-
function
|
|
869
|
+
function mt(t) {
|
|
893
870
|
try {
|
|
894
871
|
const e = t.split(`
|
|
895
872
|
`).slice(1).map((r) => {
|
|
@@ -906,12 +883,12 @@ function gt(t) {
|
|
|
906
883
|
return [];
|
|
907
884
|
}
|
|
908
885
|
}
|
|
909
|
-
class
|
|
886
|
+
class b {
|
|
910
887
|
constructor(e, r, s, n = "", i = 0) {
|
|
911
888
|
this.httpStatusCode = e, this.headers = r, this.bytes = s, this.exitCode = i, this.errors = n;
|
|
912
889
|
}
|
|
913
890
|
static fromRawData(e) {
|
|
914
|
-
return new
|
|
891
|
+
return new b(
|
|
915
892
|
e.httpStatusCode,
|
|
916
893
|
e.headers,
|
|
917
894
|
e.bytes,
|
|
@@ -951,8 +928,8 @@ const q = [
|
|
|
951
928
|
"7.1",
|
|
952
929
|
"7.0",
|
|
953
930
|
"5.6"
|
|
954
|
-
],
|
|
955
|
-
class
|
|
931
|
+
], wt = q[0], nr = q;
|
|
932
|
+
class gt {
|
|
956
933
|
#e;
|
|
957
934
|
#t;
|
|
958
935
|
/**
|
|
@@ -1038,17 +1015,17 @@ class Pt {
|
|
|
1038
1015
|
return e.join("; ");
|
|
1039
1016
|
}
|
|
1040
1017
|
}
|
|
1041
|
-
const
|
|
1042
|
-
function
|
|
1018
|
+
const yt = "http://example.com";
|
|
1019
|
+
function se(t) {
|
|
1043
1020
|
return t.toString().substring(t.origin.length);
|
|
1044
1021
|
}
|
|
1045
|
-
function
|
|
1022
|
+
function ne(t, e) {
|
|
1046
1023
|
return !e || !t.startsWith(e) ? t : t.substring(e.length);
|
|
1047
1024
|
}
|
|
1048
|
-
function
|
|
1025
|
+
function Pt(t, e) {
|
|
1049
1026
|
return !e || t.startsWith(e) ? t : e + t;
|
|
1050
1027
|
}
|
|
1051
|
-
class
|
|
1028
|
+
class bt {
|
|
1052
1029
|
#e;
|
|
1053
1030
|
#t;
|
|
1054
1031
|
#s;
|
|
@@ -1063,7 +1040,7 @@ class $t {
|
|
|
1063
1040
|
* @param config - Request Handler configuration.
|
|
1064
1041
|
*/
|
|
1065
1042
|
constructor(e, r = {}) {
|
|
1066
|
-
this.#a = new
|
|
1043
|
+
this.#a = new pe({ concurrency: 1 });
|
|
1067
1044
|
const {
|
|
1068
1045
|
documentRoot: s = "/www/",
|
|
1069
1046
|
absoluteUrl: n = typeof location == "object" ? location?.href : "",
|
|
@@ -1089,7 +1066,7 @@ class $t {
|
|
|
1089
1066
|
/** @inheritDoc */
|
|
1090
1067
|
internalUrlToPath(e) {
|
|
1091
1068
|
const r = new URL(e);
|
|
1092
|
-
return r.pathname.startsWith(this.#n) && (r.pathname = r.pathname.slice(this.#n.length)),
|
|
1069
|
+
return r.pathname.startsWith(this.#n) && (r.pathname = r.pathname.slice(this.#n.length)), se(r);
|
|
1093
1070
|
}
|
|
1094
1071
|
get isRequestRunning() {
|
|
1095
1072
|
return this.#a.running > 0;
|
|
@@ -1106,8 +1083,8 @@ class $t {
|
|
|
1106
1083
|
async request(e) {
|
|
1107
1084
|
const r = e.url.startsWith("http://") || e.url.startsWith("https://"), s = new URL(
|
|
1108
1085
|
e.url,
|
|
1109
|
-
r ? void 0 :
|
|
1110
|
-
), n =
|
|
1086
|
+
r ? void 0 : yt
|
|
1087
|
+
), n = ne(
|
|
1111
1088
|
s.pathname,
|
|
1112
1089
|
this.#n
|
|
1113
1090
|
);
|
|
@@ -1122,20 +1099,20 @@ class $t {
|
|
|
1122
1099
|
#l(e) {
|
|
1123
1100
|
const r = `${this.#e}${e}`;
|
|
1124
1101
|
if (!this.php.fileExists(r))
|
|
1125
|
-
return new
|
|
1102
|
+
return new b(
|
|
1126
1103
|
404,
|
|
1127
1104
|
{},
|
|
1128
1105
|
new TextEncoder().encode("404 File not found")
|
|
1129
1106
|
);
|
|
1130
1107
|
const s = this.php.readFileAsBuffer(r);
|
|
1131
|
-
return new
|
|
1108
|
+
return new b(
|
|
1132
1109
|
200,
|
|
1133
1110
|
{
|
|
1134
1111
|
"content-length": [`${s.byteLength}`],
|
|
1135
1112
|
// @TODO: Infer the content-type from the arrayBuffer instead of the file path.
|
|
1136
1113
|
// The code below won't return the correct mime-type if the extension
|
|
1137
1114
|
// was tampered with.
|
|
1138
|
-
"content-type": [
|
|
1115
|
+
"content-type": [$t(r)],
|
|
1139
1116
|
"accept-ranges": ["bytes"],
|
|
1140
1117
|
"cache-control": ["public, max-age=0"]
|
|
1141
1118
|
},
|
|
@@ -1159,7 +1136,7 @@ class $t {
|
|
|
1159
1136
|
let n = "GET";
|
|
1160
1137
|
const i = {
|
|
1161
1138
|
host: this.#i,
|
|
1162
|
-
...
|
|
1139
|
+
...ge(e.headers || {})
|
|
1163
1140
|
}, o = [];
|
|
1164
1141
|
if (e.files && Object.keys(e.files).length) {
|
|
1165
1142
|
n = "POST";
|
|
@@ -1172,7 +1149,7 @@ class $t {
|
|
|
1172
1149
|
data: new Uint8Array(await u.arrayBuffer())
|
|
1173
1150
|
});
|
|
1174
1151
|
}
|
|
1175
|
-
i["content-type"]?.startsWith("multipart/form-data") && (e.formData =
|
|
1152
|
+
i["content-type"]?.startsWith("multipart/form-data") && (e.formData = _t(
|
|
1176
1153
|
e.body || ""
|
|
1177
1154
|
), i["content-type"] = "application/x-www-form-urlencoded", delete e.body);
|
|
1178
1155
|
}
|
|
@@ -1184,15 +1161,15 @@ class $t {
|
|
|
1184
1161
|
try {
|
|
1185
1162
|
l = this.#h(r.pathname);
|
|
1186
1163
|
} catch {
|
|
1187
|
-
return new
|
|
1164
|
+
return new b(
|
|
1188
1165
|
404,
|
|
1189
1166
|
{},
|
|
1190
1167
|
new TextEncoder().encode("404 File not found")
|
|
1191
1168
|
);
|
|
1192
1169
|
}
|
|
1193
1170
|
return await this.php.run({
|
|
1194
|
-
relativeUri:
|
|
1195
|
-
|
|
1171
|
+
relativeUri: Pt(
|
|
1172
|
+
se(r),
|
|
1196
1173
|
this.#n
|
|
1197
1174
|
),
|
|
1198
1175
|
protocol: this.#t,
|
|
@@ -1216,7 +1193,7 @@ class $t {
|
|
|
1216
1193
|
* @returns The resolved filesystem path.
|
|
1217
1194
|
*/
|
|
1218
1195
|
#h(e) {
|
|
1219
|
-
let r =
|
|
1196
|
+
let r = ne(e, this.#n);
|
|
1220
1197
|
r.includes(".php") ? r = r.split(".php")[0] + ".php" : (r.endsWith("/") || (r += "/"), r.endsWith("index.php") || (r += "index.php"));
|
|
1221
1198
|
const s = `${this.#e}${r}`;
|
|
1222
1199
|
if (this.php.fileExists(s))
|
|
@@ -1226,7 +1203,7 @@ class $t {
|
|
|
1226
1203
|
return `${this.#e}/index.php`;
|
|
1227
1204
|
}
|
|
1228
1205
|
}
|
|
1229
|
-
function
|
|
1206
|
+
function _t(t) {
|
|
1230
1207
|
const e = {}, r = t.match(/--(.*)\r\n/);
|
|
1231
1208
|
if (!r)
|
|
1232
1209
|
return e;
|
|
@@ -1241,7 +1218,7 @@ function Et(t) {
|
|
|
1241
1218
|
}
|
|
1242
1219
|
}), e;
|
|
1243
1220
|
}
|
|
1244
|
-
function
|
|
1221
|
+
function $t(t) {
|
|
1245
1222
|
switch (t.split(".").pop()) {
|
|
1246
1223
|
case "css":
|
|
1247
1224
|
return "text/css";
|
|
@@ -1281,7 +1258,7 @@ function vt(t) {
|
|
|
1281
1258
|
return "application-octet-stream";
|
|
1282
1259
|
}
|
|
1283
1260
|
}
|
|
1284
|
-
const
|
|
1261
|
+
const ie = {
|
|
1285
1262
|
0: "No error occurred. System call completed successfully.",
|
|
1286
1263
|
1: "Argument list too long.",
|
|
1287
1264
|
2: "Permission denied.",
|
|
@@ -1368,8 +1345,8 @@ function m(t = "") {
|
|
|
1368
1345
|
return i.apply(this, o);
|
|
1369
1346
|
} catch (a) {
|
|
1370
1347
|
const l = typeof a == "object" ? a?.errno : null;
|
|
1371
|
-
if (l in
|
|
1372
|
-
const c =
|
|
1348
|
+
if (l in ie) {
|
|
1349
|
+
const c = ie[l], u = typeof o[0] == "string" ? o[0] : null, d = u !== null ? t.replaceAll("{path}", u) : t;
|
|
1373
1350
|
throw new Error(`${d}: ${c}`, {
|
|
1374
1351
|
cause: a
|
|
1375
1352
|
});
|
|
@@ -1379,19 +1356,19 @@ function m(t = "") {
|
|
|
1379
1356
|
};
|
|
1380
1357
|
};
|
|
1381
1358
|
}
|
|
1382
|
-
const
|
|
1383
|
-
function
|
|
1384
|
-
return
|
|
1359
|
+
const Et = [];
|
|
1360
|
+
function vt(t) {
|
|
1361
|
+
return Et[t];
|
|
1385
1362
|
}
|
|
1386
1363
|
(function() {
|
|
1387
1364
|
return typeof process < "u" && process.release?.name === "node" ? "NODE" : typeof window < "u" ? "WEB" : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? "WORKER" : "NODE";
|
|
1388
1365
|
})();
|
|
1389
|
-
var
|
|
1390
|
-
for (var n = s > 1 ? void 0 : s ?
|
|
1366
|
+
var St = Object.defineProperty, Rt = Object.getOwnPropertyDescriptor, w = (t, e, r, s) => {
|
|
1367
|
+
for (var n = s > 1 ? void 0 : s ? Rt(e, r) : e, i = t.length - 1, o; i >= 0; i--)
|
|
1391
1368
|
(o = t[i]) && (n = (s ? o(e, r, n) : o(n)) || n);
|
|
1392
|
-
return s && n &&
|
|
1369
|
+
return s && n && St(e, r, n), n;
|
|
1393
1370
|
};
|
|
1394
|
-
const f = "string",
|
|
1371
|
+
const f = "string", $ = "number", h = Symbol("__private__dont__use");
|
|
1395
1372
|
class g {
|
|
1396
1373
|
/**
|
|
1397
1374
|
* Initializes a PHP runtime.
|
|
@@ -1401,8 +1378,8 @@ class g {
|
|
|
1401
1378
|
* @param serverOptions - Optional. Options for the PHPRequestHandler. If undefined, no request handler will be initialized.
|
|
1402
1379
|
*/
|
|
1403
1380
|
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
|
|
1381
|
+
this.#e = [], this.#t = !1, this.#s = null, this.#r = {}, e !== void 0 && this.initializeRuntime(e), r && (this.requestHandler = new gt(
|
|
1382
|
+
new bt(this, r)
|
|
1406
1383
|
));
|
|
1407
1384
|
}
|
|
1408
1385
|
#e;
|
|
@@ -1430,10 +1407,10 @@ class g {
|
|
|
1430
1407
|
initializeRuntime(e) {
|
|
1431
1408
|
if (this[h])
|
|
1432
1409
|
throw new Error("PHP runtime already initialized.");
|
|
1433
|
-
const r =
|
|
1410
|
+
const r = vt(e);
|
|
1434
1411
|
if (!r)
|
|
1435
1412
|
throw new Error("Invalid PHP runtime id.");
|
|
1436
|
-
this[h] = r, this.#s =
|
|
1413
|
+
this[h] = r, this.#s = lt(r);
|
|
1437
1414
|
}
|
|
1438
1415
|
/** @inheritDoc */
|
|
1439
1416
|
setPhpIniPath(e) {
|
|
@@ -1467,7 +1444,7 @@ class g {
|
|
|
1467
1444
|
this.#t || (this.#i(), this.#t = !0), this.#h(e.scriptPath || ""), this.#o(e.relativeUri || ""), this.#c(e.method || "GET");
|
|
1468
1445
|
const { host: r, ...s } = {
|
|
1469
1446
|
host: "example.com:443",
|
|
1470
|
-
...
|
|
1447
|
+
...ge(e.headers || {})
|
|
1471
1448
|
};
|
|
1472
1449
|
if (this.#a(r, e.protocol || "http"), this.#l(s), e.body && this.#u(e.body), e.fileInfos)
|
|
1473
1450
|
for (const n of e.fileInfos)
|
|
@@ -1538,7 +1515,7 @@ class g {
|
|
|
1538
1515
|
(!s || isNaN(s) || s === 80) && (s = r === "https" ? 443 : 80), this[h].ccall(
|
|
1539
1516
|
"wasm_set_request_port",
|
|
1540
1517
|
null,
|
|
1541
|
-
[
|
|
1518
|
+
[$],
|
|
1542
1519
|
[s]
|
|
1543
1520
|
), (r === "https" || !r && s === 443) && this.addServerGlobalEntry("HTTPS", "on");
|
|
1544
1521
|
}
|
|
@@ -1564,7 +1541,7 @@ class g {
|
|
|
1564
1541
|
), e["content-length"] && this[h].ccall(
|
|
1565
1542
|
"wasm_set_content_length",
|
|
1566
1543
|
null,
|
|
1567
|
-
[
|
|
1544
|
+
[$],
|
|
1568
1545
|
[parseInt(e["content-length"], 10)]
|
|
1569
1546
|
);
|
|
1570
1547
|
for (const r in e)
|
|
@@ -1582,7 +1559,7 @@ class g {
|
|
|
1582
1559
|
), this[h].ccall(
|
|
1583
1560
|
"wasm_set_content_length",
|
|
1584
1561
|
null,
|
|
1585
|
-
[
|
|
1562
|
+
[$],
|
|
1586
1563
|
[new TextEncoder().encode(e).length]
|
|
1587
1564
|
);
|
|
1588
1565
|
}
|
|
@@ -1622,7 +1599,7 @@ class g {
|
|
|
1622
1599
|
this[h].ccall(
|
|
1623
1600
|
"wasm_add_uploaded_file",
|
|
1624
1601
|
null,
|
|
1625
|
-
[f, f, f, f,
|
|
1602
|
+
[f, f, f, f, $, $],
|
|
1626
1603
|
[r, s, n, o, a, i.byteLength]
|
|
1627
1604
|
);
|
|
1628
1605
|
}
|
|
@@ -1647,7 +1624,7 @@ class g {
|
|
|
1647
1624
|
);
|
|
1648
1625
|
const a = this[h].ccall(
|
|
1649
1626
|
"wasm_sapi_handle_request",
|
|
1650
|
-
|
|
1627
|
+
$,
|
|
1651
1628
|
[],
|
|
1652
1629
|
[]
|
|
1653
1630
|
);
|
|
@@ -1660,14 +1637,14 @@ class g {
|
|
|
1660
1637
|
"PHP runtime has crashed – see the earlier error for details."
|
|
1661
1638
|
);
|
|
1662
1639
|
});
|
|
1663
|
-
this.functionsMaybeMissingFromAsyncify =
|
|
1640
|
+
this.functionsMaybeMissingFromAsyncify = ut();
|
|
1664
1641
|
const o = i, a = "betterMessage" in o ? o.betterMessage : o.message, l = new Error(a);
|
|
1665
1642
|
throw l.cause = o, l;
|
|
1666
1643
|
} finally {
|
|
1667
1644
|
this.#s?.removeEventListener("error", r), this.#r = {};
|
|
1668
1645
|
}
|
|
1669
1646
|
const { headers: s, httpStatusCode: n } = this.#n();
|
|
1670
|
-
return new
|
|
1647
|
+
return new b(
|
|
1671
1648
|
n,
|
|
1672
1649
|
s,
|
|
1673
1650
|
this.readFileAsBuffer("/tmp/stdout"),
|
|
@@ -1694,7 +1671,7 @@ class g {
|
|
|
1694
1671
|
this[h].FS.unlink(e);
|
|
1695
1672
|
}
|
|
1696
1673
|
mv(e, r) {
|
|
1697
|
-
this[h].FS.
|
|
1674
|
+
this[h].FS.rename(e, r);
|
|
1698
1675
|
}
|
|
1699
1676
|
rmdir(e, r = { recursive: !0 }) {
|
|
1700
1677
|
r?.recursive && this.listFiles(e).forEach((s) => {
|
|
@@ -1759,23 +1736,23 @@ w([
|
|
|
1759
1736
|
w([
|
|
1760
1737
|
m('Could not stat "{path}"')
|
|
1761
1738
|
], g.prototype, "fileExists", 1);
|
|
1762
|
-
function
|
|
1739
|
+
function ge(t) {
|
|
1763
1740
|
const e = {};
|
|
1764
1741
|
for (const r in t)
|
|
1765
1742
|
e[r.toLowerCase()] = t[r];
|
|
1766
1743
|
return e;
|
|
1767
1744
|
}
|
|
1768
|
-
const
|
|
1745
|
+
const xt = [
|
|
1769
1746
|
"vfs",
|
|
1770
1747
|
"literal",
|
|
1771
1748
|
"wordpress.org/themes",
|
|
1772
1749
|
"wordpress.org/plugins",
|
|
1773
1750
|
"url"
|
|
1774
1751
|
];
|
|
1775
|
-
function
|
|
1776
|
-
return t && typeof t == "object" && typeof t.resource == "string" &&
|
|
1752
|
+
function Tt(t) {
|
|
1753
|
+
return t && typeof t == "object" && typeof t.resource == "string" && xt.includes(t.resource);
|
|
1777
1754
|
}
|
|
1778
|
-
class
|
|
1755
|
+
class _ {
|
|
1779
1756
|
/**
|
|
1780
1757
|
* Creates a new Resource based on the given file reference
|
|
1781
1758
|
*
|
|
@@ -1787,24 +1764,24 @@ class $ {
|
|
|
1787
1764
|
let n;
|
|
1788
1765
|
switch (e.resource) {
|
|
1789
1766
|
case "vfs":
|
|
1790
|
-
n = new
|
|
1767
|
+
n = new Ct(e, s);
|
|
1791
1768
|
break;
|
|
1792
1769
|
case "literal":
|
|
1793
|
-
n = new
|
|
1770
|
+
n = new Ft(e, s);
|
|
1794
1771
|
break;
|
|
1795
1772
|
case "wordpress.org/themes":
|
|
1796
|
-
n = new
|
|
1773
|
+
n = new At(e, s);
|
|
1797
1774
|
break;
|
|
1798
1775
|
case "wordpress.org/plugins":
|
|
1799
|
-
n = new
|
|
1776
|
+
n = new Lt(e, s);
|
|
1800
1777
|
break;
|
|
1801
1778
|
case "url":
|
|
1802
|
-
n = new
|
|
1779
|
+
n = new Ot(e, s);
|
|
1803
1780
|
break;
|
|
1804
1781
|
default:
|
|
1805
1782
|
throw new Error(`Invalid resource: ${e}`);
|
|
1806
1783
|
}
|
|
1807
|
-
return n = new
|
|
1784
|
+
return n = new Ut(n), r && (n = new Ht(n, r)), n;
|
|
1808
1785
|
}
|
|
1809
1786
|
setPlayground(e) {
|
|
1810
1787
|
this.playground = e;
|
|
@@ -1814,7 +1791,7 @@ class $ {
|
|
|
1814
1791
|
return !1;
|
|
1815
1792
|
}
|
|
1816
1793
|
}
|
|
1817
|
-
class
|
|
1794
|
+
class Ct extends _ {
|
|
1818
1795
|
/**
|
|
1819
1796
|
* Creates a new instance of `VFSResource`.
|
|
1820
1797
|
* @param playground The playground client.
|
|
@@ -1836,7 +1813,7 @@ class kt extends $ {
|
|
|
1836
1813
|
return this.resource.path;
|
|
1837
1814
|
}
|
|
1838
1815
|
}
|
|
1839
|
-
class
|
|
1816
|
+
class Ft extends _ {
|
|
1840
1817
|
/**
|
|
1841
1818
|
* Creates a new instance of `LiteralResource`.
|
|
1842
1819
|
* @param resource The literal reference.
|
|
@@ -1854,7 +1831,7 @@ class Ot extends $ {
|
|
|
1854
1831
|
return this.resource.name;
|
|
1855
1832
|
}
|
|
1856
1833
|
}
|
|
1857
|
-
class z extends
|
|
1834
|
+
class z extends _ {
|
|
1858
1835
|
/**
|
|
1859
1836
|
* Creates a new instance of `FetchResource`.
|
|
1860
1837
|
* @param progress The progress tracker.
|
|
@@ -1867,9 +1844,9 @@ class z extends $ {
|
|
|
1867
1844
|
this.progress?.setCaption(this.caption);
|
|
1868
1845
|
const e = this.getURL();
|
|
1869
1846
|
let r = await fetch(e);
|
|
1870
|
-
if (r = await
|
|
1847
|
+
if (r = await ot(
|
|
1871
1848
|
r,
|
|
1872
|
-
this.progress?.loadingListener ??
|
|
1849
|
+
this.progress?.loadingListener ?? kt
|
|
1873
1850
|
), r.status !== 200)
|
|
1874
1851
|
throw new Error(`Could not download "${e}"`);
|
|
1875
1852
|
return new File([await r.blob()], this.name);
|
|
@@ -1894,9 +1871,9 @@ class z extends $ {
|
|
|
1894
1871
|
return !0;
|
|
1895
1872
|
}
|
|
1896
1873
|
}
|
|
1897
|
-
const
|
|
1874
|
+
const kt = () => {
|
|
1898
1875
|
};
|
|
1899
|
-
class
|
|
1876
|
+
class Ot extends z {
|
|
1900
1877
|
/**
|
|
1901
1878
|
* Creates a new instance of `UrlResource`.
|
|
1902
1879
|
* @param resource The URL reference.
|
|
@@ -1915,10 +1892,10 @@ class Lt extends z {
|
|
|
1915
1892
|
}
|
|
1916
1893
|
}
|
|
1917
1894
|
let j = "https://playground.wordpress.net/plugin-proxy";
|
|
1918
|
-
function
|
|
1895
|
+
function ir(t) {
|
|
1919
1896
|
j = t;
|
|
1920
1897
|
}
|
|
1921
|
-
class
|
|
1898
|
+
class At extends z {
|
|
1922
1899
|
constructor(e, r) {
|
|
1923
1900
|
super(r), this.resource = e;
|
|
1924
1901
|
}
|
|
@@ -1926,11 +1903,11 @@ class Ut extends z {
|
|
|
1926
1903
|
return L(this.resource.slug);
|
|
1927
1904
|
}
|
|
1928
1905
|
getURL() {
|
|
1929
|
-
const e =
|
|
1906
|
+
const e = ye(this.resource.slug);
|
|
1930
1907
|
return `${j}?theme=` + e;
|
|
1931
1908
|
}
|
|
1932
1909
|
}
|
|
1933
|
-
class
|
|
1910
|
+
class Lt extends z {
|
|
1934
1911
|
constructor(e, r) {
|
|
1935
1912
|
super(r), this.resource = e;
|
|
1936
1913
|
}
|
|
@@ -1940,14 +1917,14 @@ class Ht extends z {
|
|
|
1940
1917
|
}
|
|
1941
1918
|
/** @inheritDoc */
|
|
1942
1919
|
getURL() {
|
|
1943
|
-
const e =
|
|
1920
|
+
const e = ye(this.resource.slug);
|
|
1944
1921
|
return `${j}?plugin=` + e;
|
|
1945
1922
|
}
|
|
1946
1923
|
}
|
|
1947
|
-
function
|
|
1924
|
+
function ye(t) {
|
|
1948
1925
|
return !t || t.endsWith(".zip") ? t : t + ".latest-stable.zip";
|
|
1949
1926
|
}
|
|
1950
|
-
class
|
|
1927
|
+
class Pe extends _ {
|
|
1951
1928
|
constructor(e) {
|
|
1952
1929
|
super(), this.resource = e;
|
|
1953
1930
|
}
|
|
@@ -1976,13 +1953,13 @@ class be extends $ {
|
|
|
1976
1953
|
return this.resource.isAsync;
|
|
1977
1954
|
}
|
|
1978
1955
|
}
|
|
1979
|
-
class
|
|
1956
|
+
class Ut extends Pe {
|
|
1980
1957
|
/** @inheritDoc */
|
|
1981
1958
|
async resolve() {
|
|
1982
1959
|
return this.promise || (this.promise = super.resolve()), this.promise;
|
|
1983
1960
|
}
|
|
1984
1961
|
}
|
|
1985
|
-
class
|
|
1962
|
+
class Ht extends Pe {
|
|
1986
1963
|
constructor(e, r) {
|
|
1987
1964
|
super(e), this.semaphore = r;
|
|
1988
1965
|
}
|
|
@@ -1991,18 +1968,18 @@ class Nt extends be {
|
|
|
1991
1968
|
return this.isAsync ? this.semaphore.run(() => super.resolve()) : super.resolve();
|
|
1992
1969
|
}
|
|
1993
1970
|
}
|
|
1994
|
-
const
|
|
1995
|
-
function
|
|
1971
|
+
const It = ["6.2", "6.1", "6.0", "5.9"];
|
|
1972
|
+
function Nt(t, {
|
|
1996
1973
|
progress: e = new U(),
|
|
1997
|
-
semaphore: r = new
|
|
1974
|
+
semaphore: r = new pe({ concurrency: 3 }),
|
|
1998
1975
|
onStepCompleted: s = () => {
|
|
1999
1976
|
}
|
|
2000
1977
|
} = {}) {
|
|
2001
|
-
const n = (t.steps || []).filter(
|
|
1978
|
+
const n = (t.steps || []).filter(Wt), i = n.reduce(
|
|
2002
1979
|
(a, l) => a + (l.progress?.weight || 1),
|
|
2003
1980
|
0
|
|
2004
1981
|
), o = n.map(
|
|
2005
|
-
(a) =>
|
|
1982
|
+
(a) => Mt(a, {
|
|
2006
1983
|
semaphore: r,
|
|
2007
1984
|
rootProgressTracker: e,
|
|
2008
1985
|
totalProgressWeight: i
|
|
@@ -2010,14 +1987,14 @@ function Mt(t, {
|
|
|
2010
1987
|
);
|
|
2011
1988
|
return {
|
|
2012
1989
|
versions: {
|
|
2013
|
-
php:
|
|
1990
|
+
php: oe(
|
|
2014
1991
|
t.preferredVersions?.php,
|
|
2015
1992
|
q,
|
|
2016
|
-
|
|
1993
|
+
wt
|
|
2017
1994
|
),
|
|
2018
|
-
wp:
|
|
1995
|
+
wp: oe(
|
|
2019
1996
|
t.preferredVersions?.wp,
|
|
2020
|
-
|
|
1997
|
+
It,
|
|
2021
1998
|
"6.2"
|
|
2022
1999
|
)
|
|
2023
2000
|
},
|
|
@@ -2042,13 +2019,13 @@ function Mt(t, {
|
|
|
2042
2019
|
}
|
|
2043
2020
|
};
|
|
2044
2021
|
}
|
|
2045
|
-
function
|
|
2022
|
+
function oe(t, e, r) {
|
|
2046
2023
|
return t && e.includes(t) ? t : r;
|
|
2047
2024
|
}
|
|
2048
|
-
function
|
|
2025
|
+
function Wt(t) {
|
|
2049
2026
|
return !!(typeof t == "object" && t);
|
|
2050
2027
|
}
|
|
2051
|
-
function
|
|
2028
|
+
function Mt(t, {
|
|
2052
2029
|
semaphore: e,
|
|
2053
2030
|
rootProgressTracker: r,
|
|
2054
2031
|
totalProgressWeight: s
|
|
@@ -2058,15 +2035,15 @@ function qt(t, {
|
|
|
2058
2035
|
), i = {};
|
|
2059
2036
|
for (const u of Object.keys(t)) {
|
|
2060
2037
|
let d = t[u];
|
|
2061
|
-
|
|
2038
|
+
Tt(d) && (d = _.create(d, {
|
|
2062
2039
|
semaphore: e
|
|
2063
2040
|
})), i[u] = d;
|
|
2064
2041
|
}
|
|
2065
2042
|
const o = async (u) => {
|
|
2066
2043
|
try {
|
|
2067
|
-
return n.fillSlowly(), await
|
|
2044
|
+
return n.fillSlowly(), await nt[t.step](
|
|
2068
2045
|
u,
|
|
2069
|
-
await
|
|
2046
|
+
await Dt(i),
|
|
2070
2047
|
{
|
|
2071
2048
|
tracker: n,
|
|
2072
2049
|
initialCaption: t.progress?.caption
|
|
@@ -2075,30 +2052,30 @@ function qt(t, {
|
|
|
2075
2052
|
} finally {
|
|
2076
2053
|
n.finish();
|
|
2077
2054
|
}
|
|
2078
|
-
}, a =
|
|
2055
|
+
}, a = ae(i), l = ae(i).filter(
|
|
2079
2056
|
(u) => u.isAsync
|
|
2080
2057
|
), c = 1 / (l.length + 1);
|
|
2081
2058
|
for (const u of l)
|
|
2082
2059
|
u.progress = n.stage(c);
|
|
2083
2060
|
return { run: o, step: t, resources: a };
|
|
2084
2061
|
}
|
|
2085
|
-
function
|
|
2062
|
+
function ae(t) {
|
|
2086
2063
|
const e = [];
|
|
2087
2064
|
for (const r in t) {
|
|
2088
2065
|
const s = t[r];
|
|
2089
|
-
s instanceof
|
|
2066
|
+
s instanceof _ && e.push(s);
|
|
2090
2067
|
}
|
|
2091
2068
|
return e;
|
|
2092
2069
|
}
|
|
2093
|
-
async function
|
|
2070
|
+
async function Dt(t) {
|
|
2094
2071
|
const e = {};
|
|
2095
2072
|
for (const r in t) {
|
|
2096
2073
|
const s = t[r];
|
|
2097
|
-
s instanceof
|
|
2074
|
+
s instanceof _ ? e[r] = await s.resolve() : e[r] = s;
|
|
2098
2075
|
}
|
|
2099
2076
|
return e;
|
|
2100
2077
|
}
|
|
2101
|
-
async function
|
|
2078
|
+
async function qt(t, e) {
|
|
2102
2079
|
await t.run(e);
|
|
2103
2080
|
}
|
|
2104
2081
|
/**
|
|
@@ -2106,8 +2083,8 @@ async function jt(t, e) {
|
|
|
2106
2083
|
* Copyright 2019 Google LLC
|
|
2107
2084
|
* SPDX-License-Identifier: Apache-2.0
|
|
2108
2085
|
*/
|
|
2109
|
-
const
|
|
2110
|
-
canHandle: (t) =>
|
|
2086
|
+
const be = Symbol("Comlink.proxy"), zt = Symbol("Comlink.endpoint"), jt = Symbol("Comlink.releaseProxy"), I = Symbol("Comlink.finalizer"), T = Symbol("Comlink.thrown"), _e = (t) => typeof t == "object" && t !== null || typeof t == "function", Bt = {
|
|
2087
|
+
canHandle: (t) => _e(t) && t[be],
|
|
2111
2088
|
serialize(t) {
|
|
2112
2089
|
const { port1: e, port2: r } = new MessageChannel();
|
|
2113
2090
|
return B(t, e), [r, [r]];
|
|
@@ -2115,8 +2092,8 @@ const _e = Symbol("Comlink.proxy"), Bt = Symbol("Comlink.endpoint"), Vt = Symbol
|
|
|
2115
2092
|
deserialize(t) {
|
|
2116
2093
|
return t.start(), V(t);
|
|
2117
2094
|
}
|
|
2118
|
-
},
|
|
2119
|
-
canHandle: (t) =>
|
|
2095
|
+
}, Vt = {
|
|
2096
|
+
canHandle: (t) => _e(t) && T in t,
|
|
2120
2097
|
serialize({ value: t }) {
|
|
2121
2098
|
let e;
|
|
2122
2099
|
return t instanceof Error ? e = {
|
|
@@ -2132,10 +2109,10 @@ const _e = Symbol("Comlink.proxy"), Bt = Symbol("Comlink.endpoint"), Vt = Symbol
|
|
|
2132
2109
|
throw t.isError ? Object.assign(new Error(t.value.message), t.value) : t.value;
|
|
2133
2110
|
}
|
|
2134
2111
|
}, R = /* @__PURE__ */ new Map([
|
|
2135
|
-
["proxy",
|
|
2136
|
-
["throw",
|
|
2112
|
+
["proxy", Bt],
|
|
2113
|
+
["throw", Vt]
|
|
2137
2114
|
]);
|
|
2138
|
-
function
|
|
2115
|
+
function Gt(t, e) {
|
|
2139
2116
|
for (const r of t)
|
|
2140
2117
|
if (e === r || r === "*" || r instanceof RegExp && r.test(e))
|
|
2141
2118
|
return !0;
|
|
@@ -2145,11 +2122,11 @@ function B(t, e = globalThis, r = ["*"]) {
|
|
|
2145
2122
|
e.addEventListener("message", function s(n) {
|
|
2146
2123
|
if (!n || !n.data)
|
|
2147
2124
|
return;
|
|
2148
|
-
if (!
|
|
2125
|
+
if (!Gt(r, n.origin)) {
|
|
2149
2126
|
console.warn(`Invalid origin '${n.origin}' for comlink proxy`);
|
|
2150
2127
|
return;
|
|
2151
2128
|
}
|
|
2152
|
-
const { id: i, type: o, path: a } = Object.assign({ path: [] }, n.data), l = (n.data.argumentList || []).map(
|
|
2129
|
+
const { id: i, type: o, path: a } = Object.assign({ path: [] }, n.data), l = (n.data.argumentList || []).map(P);
|
|
2153
2130
|
let c;
|
|
2154
2131
|
try {
|
|
2155
2132
|
const u = a.slice(0, -1).reduce((p, y) => p[y], t), d = a.reduce((p, y) => p[y], t);
|
|
@@ -2158,7 +2135,7 @@ function B(t, e = globalThis, r = ["*"]) {
|
|
|
2158
2135
|
c = d;
|
|
2159
2136
|
break;
|
|
2160
2137
|
case "SET":
|
|
2161
|
-
u[a.slice(-1)[0]] =
|
|
2138
|
+
u[a.slice(-1)[0]] = P(n.data.value), c = !0;
|
|
2162
2139
|
break;
|
|
2163
2140
|
case "APPLY":
|
|
2164
2141
|
c = d.apply(u, l);
|
|
@@ -2166,13 +2143,13 @@ function B(t, e = globalThis, r = ["*"]) {
|
|
|
2166
2143
|
case "CONSTRUCT":
|
|
2167
2144
|
{
|
|
2168
2145
|
const p = new d(...l);
|
|
2169
|
-
c =
|
|
2146
|
+
c = Se(p);
|
|
2170
2147
|
}
|
|
2171
2148
|
break;
|
|
2172
2149
|
case "ENDPOINT":
|
|
2173
2150
|
{
|
|
2174
2151
|
const { port1: p, port2: y } = new MessageChannel();
|
|
2175
|
-
B(t, y), c =
|
|
2152
|
+
B(t, y), c = Xt(p, [p]);
|
|
2176
2153
|
}
|
|
2177
2154
|
break;
|
|
2178
2155
|
case "RELEASE":
|
|
@@ -2186,7 +2163,7 @@ function B(t, e = globalThis, r = ["*"]) {
|
|
|
2186
2163
|
}
|
|
2187
2164
|
Promise.resolve(c).catch((u) => ({ value: u, [T]: 0 })).then((u) => {
|
|
2188
2165
|
const [d, p] = A(u);
|
|
2189
|
-
e.postMessage(Object.assign(Object.assign({}, d), { id: i }), p), o === "RELEASE" && (e.removeEventListener("message", s),
|
|
2166
|
+
e.postMessage(Object.assign(Object.assign({}, d), { id: i }), p), o === "RELEASE" && (e.removeEventListener("message", s), $e(e), I in t && typeof t[I] == "function" && t[I]());
|
|
2190
2167
|
}).catch((u) => {
|
|
2191
2168
|
const [d, p] = A({
|
|
2192
2169
|
value: new TypeError("Unserializable return value"),
|
|
@@ -2196,11 +2173,11 @@ function B(t, e = globalThis, r = ["*"]) {
|
|
|
2196
2173
|
});
|
|
2197
2174
|
}), e.start && e.start();
|
|
2198
2175
|
}
|
|
2199
|
-
function
|
|
2176
|
+
function Yt(t) {
|
|
2200
2177
|
return t.constructor.name === "MessagePort";
|
|
2201
2178
|
}
|
|
2202
|
-
function
|
|
2203
|
-
|
|
2179
|
+
function $e(t) {
|
|
2180
|
+
Yt(t) && t.close();
|
|
2204
2181
|
}
|
|
2205
2182
|
function V(t, e) {
|
|
2206
2183
|
return W(t, [], e);
|
|
@@ -2209,22 +2186,22 @@ function x(t) {
|
|
|
2209
2186
|
if (t)
|
|
2210
2187
|
throw new Error("Proxy has been released and is not useable");
|
|
2211
2188
|
}
|
|
2212
|
-
function
|
|
2213
|
-
return
|
|
2189
|
+
function Ee(t) {
|
|
2190
|
+
return E(t, {
|
|
2214
2191
|
type: "RELEASE"
|
|
2215
2192
|
}).then(() => {
|
|
2216
|
-
|
|
2193
|
+
$e(t);
|
|
2217
2194
|
});
|
|
2218
2195
|
}
|
|
2219
2196
|
const k = /* @__PURE__ */ new WeakMap(), O = "FinalizationRegistry" in globalThis && new FinalizationRegistry((t) => {
|
|
2220
2197
|
const e = (k.get(t) || 0) - 1;
|
|
2221
|
-
k.set(t, e), e === 0 &&
|
|
2198
|
+
k.set(t, e), e === 0 && Ee(t);
|
|
2222
2199
|
});
|
|
2223
|
-
function
|
|
2200
|
+
function Jt(t, e) {
|
|
2224
2201
|
const r = (k.get(e) || 0) + 1;
|
|
2225
2202
|
k.set(e, r), O && O.register(t, e, t);
|
|
2226
2203
|
}
|
|
2227
|
-
function
|
|
2204
|
+
function Kt(t) {
|
|
2228
2205
|
O && O.unregister(t);
|
|
2229
2206
|
}
|
|
2230
2207
|
function W(t, e = [], r = function() {
|
|
@@ -2232,17 +2209,17 @@ function W(t, e = [], r = function() {
|
|
|
2232
2209
|
let s = !1;
|
|
2233
2210
|
const n = new Proxy(r, {
|
|
2234
2211
|
get(i, o) {
|
|
2235
|
-
if (x(s), o ===
|
|
2212
|
+
if (x(s), o === jt)
|
|
2236
2213
|
return () => {
|
|
2237
|
-
|
|
2214
|
+
Kt(n), Ee(t), s = !0;
|
|
2238
2215
|
};
|
|
2239
2216
|
if (o === "then") {
|
|
2240
2217
|
if (e.length === 0)
|
|
2241
2218
|
return { then: () => n };
|
|
2242
|
-
const a =
|
|
2219
|
+
const a = E(t, {
|
|
2243
2220
|
type: "GET",
|
|
2244
2221
|
path: e.map((l) => l.toString())
|
|
2245
|
-
}).then(
|
|
2222
|
+
}).then(P);
|
|
2246
2223
|
return a.then.bind(a);
|
|
2247
2224
|
}
|
|
2248
2225
|
return W(t, [...e, o]);
|
|
@@ -2250,55 +2227,55 @@ function W(t, e = [], r = function() {
|
|
|
2250
2227
|
set(i, o, a) {
|
|
2251
2228
|
x(s);
|
|
2252
2229
|
const [l, c] = A(a);
|
|
2253
|
-
return
|
|
2230
|
+
return E(t, {
|
|
2254
2231
|
type: "SET",
|
|
2255
2232
|
path: [...e, o].map((u) => u.toString()),
|
|
2256
2233
|
value: l
|
|
2257
|
-
}, c).then(
|
|
2234
|
+
}, c).then(P);
|
|
2258
2235
|
},
|
|
2259
2236
|
apply(i, o, a) {
|
|
2260
2237
|
x(s);
|
|
2261
2238
|
const l = e[e.length - 1];
|
|
2262
|
-
if (l ===
|
|
2263
|
-
return
|
|
2239
|
+
if (l === zt)
|
|
2240
|
+
return E(t, {
|
|
2264
2241
|
type: "ENDPOINT"
|
|
2265
|
-
}).then(
|
|
2242
|
+
}).then(P);
|
|
2266
2243
|
if (l === "bind")
|
|
2267
2244
|
return W(t, e.slice(0, -1));
|
|
2268
|
-
const [c, u] =
|
|
2269
|
-
return
|
|
2245
|
+
const [c, u] = ce(a);
|
|
2246
|
+
return E(t, {
|
|
2270
2247
|
type: "APPLY",
|
|
2271
2248
|
path: e.map((d) => d.toString()),
|
|
2272
2249
|
argumentList: c
|
|
2273
|
-
}, u).then(
|
|
2250
|
+
}, u).then(P);
|
|
2274
2251
|
},
|
|
2275
2252
|
construct(i, o) {
|
|
2276
2253
|
x(s);
|
|
2277
|
-
const [a, l] =
|
|
2278
|
-
return
|
|
2254
|
+
const [a, l] = ce(o);
|
|
2255
|
+
return E(t, {
|
|
2279
2256
|
type: "CONSTRUCT",
|
|
2280
2257
|
path: e.map((c) => c.toString()),
|
|
2281
2258
|
argumentList: a
|
|
2282
|
-
}, l).then(
|
|
2259
|
+
}, l).then(P);
|
|
2283
2260
|
}
|
|
2284
2261
|
});
|
|
2285
|
-
return
|
|
2262
|
+
return Jt(n, t), n;
|
|
2286
2263
|
}
|
|
2287
|
-
function
|
|
2264
|
+
function Qt(t) {
|
|
2288
2265
|
return Array.prototype.concat.apply([], t);
|
|
2289
2266
|
}
|
|
2290
|
-
function
|
|
2267
|
+
function ce(t) {
|
|
2291
2268
|
const e = t.map(A);
|
|
2292
|
-
return [e.map((r) => r[0]),
|
|
2269
|
+
return [e.map((r) => r[0]), Qt(e.map((r) => r[1]))];
|
|
2293
2270
|
}
|
|
2294
|
-
const
|
|
2295
|
-
function
|
|
2296
|
-
return
|
|
2271
|
+
const ve = /* @__PURE__ */ new WeakMap();
|
|
2272
|
+
function Xt(t, e) {
|
|
2273
|
+
return ve.set(t, e), t;
|
|
2297
2274
|
}
|
|
2298
|
-
function
|
|
2299
|
-
return Object.assign(t, { [
|
|
2275
|
+
function Se(t) {
|
|
2276
|
+
return Object.assign(t, { [be]: !0 });
|
|
2300
2277
|
}
|
|
2301
|
-
function
|
|
2278
|
+
function Zt(t, e = globalThis, r = "*") {
|
|
2302
2279
|
return {
|
|
2303
2280
|
postMessage: (s, n) => t.postMessage(s, r, n),
|
|
2304
2281
|
addEventListener: e.addEventListener.bind(e),
|
|
@@ -2323,10 +2300,10 @@ function A(t) {
|
|
|
2323
2300
|
type: "RAW",
|
|
2324
2301
|
value: t
|
|
2325
2302
|
},
|
|
2326
|
-
|
|
2303
|
+
ve.get(t) || []
|
|
2327
2304
|
];
|
|
2328
2305
|
}
|
|
2329
|
-
function
|
|
2306
|
+
function P(t) {
|
|
2330
2307
|
switch (t.type) {
|
|
2331
2308
|
case "HANDLER":
|
|
2332
2309
|
return R.get(t.name).deserialize(t.value);
|
|
@@ -2334,27 +2311,27 @@ function b(t) {
|
|
|
2334
2311
|
return t.value;
|
|
2335
2312
|
}
|
|
2336
2313
|
}
|
|
2337
|
-
function
|
|
2314
|
+
function E(t, e, r) {
|
|
2338
2315
|
return new Promise((s) => {
|
|
2339
|
-
const n =
|
|
2316
|
+
const n = er();
|
|
2340
2317
|
t.addEventListener("message", function i(o) {
|
|
2341
2318
|
!o.data || !o.data.id || o.data.id !== n || (t.removeEventListener("message", i), s(o.data));
|
|
2342
2319
|
}), t.start && t.start(), t.postMessage(Object.assign({ id: n }, e), r);
|
|
2343
2320
|
});
|
|
2344
2321
|
}
|
|
2345
|
-
function
|
|
2322
|
+
function er() {
|
|
2346
2323
|
return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
|
|
2347
2324
|
}
|
|
2348
|
-
function
|
|
2349
|
-
|
|
2350
|
-
const e = t instanceof Worker ? t :
|
|
2325
|
+
function Re(t) {
|
|
2326
|
+
tr();
|
|
2327
|
+
const e = t instanceof Worker ? t : Zt(t), r = V(e), s = xe(r);
|
|
2351
2328
|
return new Proxy(s, {
|
|
2352
2329
|
get: (n, i) => i === "isConnected" ? () => r.isConnected() : r[i]
|
|
2353
2330
|
});
|
|
2354
2331
|
}
|
|
2355
|
-
let
|
|
2356
|
-
function
|
|
2357
|
-
|
|
2332
|
+
let le = !1;
|
|
2333
|
+
function tr() {
|
|
2334
|
+
le || (le = !0, R.set("EVENT", {
|
|
2358
2335
|
canHandle: (t) => t instanceof CustomEvent,
|
|
2359
2336
|
serialize: (t) => [
|
|
2360
2337
|
{
|
|
@@ -2379,24 +2356,24 @@ function sr() {
|
|
|
2379
2356
|
return [t.toRawData(), []];
|
|
2380
2357
|
},
|
|
2381
2358
|
deserialize(t) {
|
|
2382
|
-
return
|
|
2359
|
+
return b.fromRawData(t);
|
|
2383
2360
|
}
|
|
2384
2361
|
}));
|
|
2385
2362
|
}
|
|
2386
|
-
function
|
|
2363
|
+
function xe(t) {
|
|
2387
2364
|
return new Proxy(t, {
|
|
2388
2365
|
get(e, r) {
|
|
2389
2366
|
switch (typeof e[r]) {
|
|
2390
2367
|
case "function":
|
|
2391
2368
|
return (...s) => e[r](...s);
|
|
2392
2369
|
case "object":
|
|
2393
|
-
return e[r] === null ? e[r] :
|
|
2370
|
+
return e[r] === null ? e[r] : xe(e[r]);
|
|
2394
2371
|
case "undefined":
|
|
2395
2372
|
case "number":
|
|
2396
2373
|
case "string":
|
|
2397
2374
|
return e[r];
|
|
2398
2375
|
default:
|
|
2399
|
-
return
|
|
2376
|
+
return Se(e[r]);
|
|
2400
2377
|
}
|
|
2401
2378
|
}
|
|
2402
2379
|
});
|
|
@@ -2404,7 +2381,7 @@ function Te(t) {
|
|
|
2404
2381
|
(function() {
|
|
2405
2382
|
return typeof navigator < "u" && navigator?.userAgent?.toLowerCase().indexOf("firefox") > -1 ? "iframe" : "webworker";
|
|
2406
2383
|
})();
|
|
2407
|
-
async function
|
|
2384
|
+
async function rr({
|
|
2408
2385
|
iframe: t,
|
|
2409
2386
|
blueprint: e,
|
|
2410
2387
|
remoteUrl: r,
|
|
@@ -2412,28 +2389,28 @@ async function nr({
|
|
|
2412
2389
|
disableProgressBar: n,
|
|
2413
2390
|
onBlueprintStepCompleted: i
|
|
2414
2391
|
}) {
|
|
2415
|
-
if (
|
|
2392
|
+
if (sr(r), r = he(r, {
|
|
2416
2393
|
progressbar: !n
|
|
2417
2394
|
}), s.setCaption("Preparing WordPress"), !e)
|
|
2418
|
-
return
|
|
2419
|
-
const o =
|
|
2395
|
+
return ue(t, r, s);
|
|
2396
|
+
const o = Nt(e, {
|
|
2420
2397
|
progress: s.stage(0.5),
|
|
2421
2398
|
onStepCompleted: i
|
|
2422
|
-
}), a = await
|
|
2399
|
+
}), a = await ue(
|
|
2423
2400
|
t,
|
|
2424
|
-
|
|
2401
|
+
he(r, {
|
|
2425
2402
|
php: o.versions.php,
|
|
2426
2403
|
wp: o.versions.wp
|
|
2427
2404
|
}),
|
|
2428
2405
|
s
|
|
2429
2406
|
);
|
|
2430
|
-
return await
|
|
2407
|
+
return await qt(o, a), s.finish(), a;
|
|
2431
2408
|
}
|
|
2432
|
-
async function
|
|
2409
|
+
async function ue(t, e, r) {
|
|
2433
2410
|
await new Promise((i) => {
|
|
2434
2411
|
t.src = e, t.addEventListener("load", i, !1);
|
|
2435
2412
|
});
|
|
2436
|
-
const s =
|
|
2413
|
+
const s = Re(
|
|
2437
2414
|
t.contentWindow
|
|
2438
2415
|
);
|
|
2439
2416
|
await s.isConnected(), r.pipe(s);
|
|
@@ -2441,67 +2418,66 @@ async function he(t, e, r) {
|
|
|
2441
2418
|
return await s.onDownloadProgress(n.loadingListener), await s.isReady(), n.finish(), s;
|
|
2442
2419
|
}
|
|
2443
2420
|
const C = "https://playground.wordpress.net";
|
|
2444
|
-
function
|
|
2421
|
+
function sr(t) {
|
|
2445
2422
|
const e = new URL(t, C);
|
|
2446
2423
|
if ((e.origin === C || e.hostname === "localhost") && e.pathname !== "/remote.html")
|
|
2447
2424
|
throw new Error(
|
|
2448
2425
|
`Invalid remote URL: ${e}. Expected origin to be ${C}/remote.html.`
|
|
2449
2426
|
);
|
|
2450
2427
|
}
|
|
2451
|
-
function
|
|
2428
|
+
function he(t, e) {
|
|
2452
2429
|
const r = new URL(t, C), s = new URLSearchParams(r.search);
|
|
2453
2430
|
for (const [n, i] of Object.entries(e))
|
|
2454
2431
|
i != null && i !== !1 && s.set(n, i.toString());
|
|
2455
2432
|
return r.search = s.toString(), r.toString();
|
|
2456
2433
|
}
|
|
2457
|
-
async function
|
|
2434
|
+
async function or(t, e) {
|
|
2458
2435
|
if (console.warn(
|
|
2459
2436
|
"`connectPlayground` is deprecated and will be removed. Use `startPlayground` instead."
|
|
2460
2437
|
), e?.loadRemote)
|
|
2461
|
-
return
|
|
2438
|
+
return rr({
|
|
2462
2439
|
iframe: t,
|
|
2463
2440
|
remoteUrl: e.loadRemote
|
|
2464
2441
|
});
|
|
2465
|
-
const r =
|
|
2442
|
+
const r = Re(
|
|
2466
2443
|
t.contentWindow
|
|
2467
2444
|
);
|
|
2468
2445
|
return await r.isConnected(), r;
|
|
2469
2446
|
}
|
|
2470
2447
|
export {
|
|
2471
|
-
|
|
2448
|
+
wt as LatestSupportedPHPVersion,
|
|
2472
2449
|
q as SupportedPHPVersions,
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
Ze as
|
|
2485
|
-
et as
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
De as mv,
|
|
2450
|
+
nr as SupportedPHPVersionsList,
|
|
2451
|
+
Fe as activatePlugin,
|
|
2452
|
+
ke as activateTheme,
|
|
2453
|
+
Ae as applyWordPressPatches,
|
|
2454
|
+
Nt as compileBlueprint,
|
|
2455
|
+
or as connectPlayground,
|
|
2456
|
+
We as cp,
|
|
2457
|
+
Be as defineSiteUrl,
|
|
2458
|
+
de as defineWpConfigConsts,
|
|
2459
|
+
Je as importFile,
|
|
2460
|
+
Xe as installPlugin,
|
|
2461
|
+
Ze as installTheme,
|
|
2462
|
+
et as login,
|
|
2463
|
+
De as mkdir,
|
|
2464
|
+
Me as mv,
|
|
2489
2465
|
S as phpVar,
|
|
2490
2466
|
M as phpVars,
|
|
2491
2467
|
Ye as replaceSite,
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2468
|
+
Ne as request,
|
|
2469
|
+
qe as rm,
|
|
2470
|
+
ze as rmdir,
|
|
2471
|
+
qt as runBlueprintSteps,
|
|
2472
|
+
Ue as runPHP,
|
|
2473
|
+
He as runPHPWithOptions,
|
|
2474
|
+
tt as runWpInstallationWizard,
|
|
2475
|
+
Ie as setPhpIniEntry,
|
|
2476
|
+
ir as setPluginProxyURL,
|
|
2477
|
+
rt as setSiteOptions,
|
|
2478
|
+
rr as startPlaygroundWeb,
|
|
2479
|
+
fe as unzip,
|
|
2480
|
+
st as updateUserMeta,
|
|
2481
|
+
je as writeFile,
|
|
2482
|
+
Ge as zipEntireSite
|
|
2507
2483
|
};
|