@wp-playground/client 0.1.18 → 0.1.19

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.
Files changed (3) hide show
  1. package/index.d.ts +50 -19
  2. package/index.js +219 -199
  3. package/package.json +2 -2
package/index.d.ts CHANGED
@@ -1,10 +1,6 @@
1
1
  // Generated by dts-bundle-generator v7.2.0
2
2
 
3
- /**
4
- * PHP response. Body is an `ArrayBuffer` because it can
5
- * contain binary data.
6
- */
7
- export declare class PHPResponse {
3
+ export interface PHPResponseData {
8
4
  /**
9
5
  * Response headers.
10
6
  */
@@ -13,7 +9,7 @@ export declare class PHPResponse {
13
9
  * Response body. Contains the output from `echo`,
14
10
  * `print`, inline HTML etc.
15
11
  */
16
- private readonly body;
12
+ readonly bytes: ArrayBuffer;
17
13
  /**
18
14
  * Stderr contents, if any.
19
15
  */
@@ -27,7 +23,28 @@ export declare class PHPResponse {
27
23
  * Response HTTP status code, e.g. 200.
28
24
  */
29
25
  readonly httpStatusCode: number;
26
+ }
27
+ /**
28
+ * PHP response. Body is an `ArrayBuffer` because it can
29
+ * contain binary data.
30
+ *
31
+ * This type is used in Comlink.transferHandlers.set('PHPResponse', { ... })
32
+ * so be sure to update that if you change this type.
33
+ */
34
+ export declare class PHPResponse implements PHPResponseData {
35
+ /** @inheritDoc */
36
+ readonly headers: Record<string, string[]>;
37
+ /** @inheritDoc */
38
+ readonly bytes: ArrayBuffer;
39
+ /** @inheritDoc */
40
+ readonly errors: string;
41
+ /** @inheritDoc */
42
+ readonly exitCode: number;
43
+ /** @inheritDoc */
44
+ readonly httpStatusCode: number;
30
45
  constructor(httpStatusCode: number, headers: Record<string, string[]>, body: ArrayBuffer, errors?: string, exitCode?: number);
46
+ static fromRawData(data: PHPResponseData): PHPResponse;
47
+ toRawData(): PHPResponseData;
31
48
  /**
32
49
  * Response body as JSON.
33
50
  */
@@ -36,20 +53,36 @@ export declare class PHPResponse {
36
53
  * Response body as text.
37
54
  */
38
55
  get text(): string;
56
+ }
57
+ export type HTTPMethod = "GET" | "POST" | "HEAD" | "OPTIONS" | "PATCH" | "PUT" | "DELETE";
58
+ export type PHPRequestHeaders = Record<string, string>;
59
+ export interface PHPRequest {
39
60
  /**
40
- * Response body as bytes.
61
+ * Request method. Default: `GET`.
62
+ */
63
+ method?: HTTPMethod;
64
+ /**
65
+ * Request path or absolute URL.
41
66
  */
42
- get bytes(): ArrayBuffer;
43
- }
44
- export type PHPRequest = Pick<PHPRunOptions, "method" | "headers"> & {
45
67
  url: string;
68
+ /**
69
+ * Request headers.
70
+ */
71
+ headers?: PHPRequestHeaders;
72
+ /**
73
+ * Uploaded files
74
+ */
46
75
  files?: Record<string, File>;
47
- } & ((Pick<PHPRunOptions, "body"> & {
48
- formData?: never;
49
- }) | {
50
- body?: never;
51
- formData: Record<string, unknown>;
52
- });
76
+ /**
77
+ * Request body without the files.
78
+ */
79
+ body?: string;
80
+ /**
81
+ * Form data. If set, the request body will be ignored and
82
+ * the content-type header will be set to `application/x-www-form-urlencoded`.
83
+ */
84
+ formData?: Record<string, unknown>;
85
+ }
53
86
  export interface PHPRequestHandlerConfiguration {
54
87
  /**
55
88
  * The directory in the PHP filesystem where the server will look
@@ -146,7 +179,6 @@ declare class PHPBrowser implements WithRequestHandler {
146
179
  */
147
180
  request(request: PHPRequest, redirects?: number): Promise<PHPResponse>;
148
181
  }
149
- export type PHPRequestHeaders = Record<string, string>;
150
182
  export interface FileInfo {
151
183
  key: string;
152
184
  name: string;
@@ -169,7 +201,7 @@ export interface PHPRunOptions {
169
201
  /**
170
202
  * Request method. Default: `GET`.
171
203
  */
172
- method?: "GET" | "POST" | "HEAD" | "OPTIONS" | "PATCH" | "PUT" | "DELETE";
204
+ method?: HTTPMethod;
173
205
  /**
174
206
  * Request headers.
175
207
  */
@@ -481,7 +513,6 @@ declare class PHP extends BasePHP {
481
513
  * resolves when the PHP instance is ready.
482
514
  *
483
515
  * @see load
484
- * @inheritdoc load
485
516
  */
486
517
  static loadSync(phpVersion: SupportedPHPVersion, options?: PHPWebLoaderOptions): {
487
518
  php: PHP;
package/index.js CHANGED
@@ -35,13 +35,13 @@ class re {
35
35
  }
36
36
  });
37
37
  if (r.headers["set-cookie"] && this.#n(r.headers["set-cookie"]), this.#t.handleRedirects && r.headers.location && n < this.#t.maxRedirects) {
38
- const o = new URL(
38
+ const i = new URL(
39
39
  r.headers.location[0],
40
40
  this.server.absoluteUrl
41
41
  );
42
42
  return this.request(
43
43
  {
44
- url: o.toString(),
44
+ url: i.toString(),
45
45
  method: "GET",
46
46
  headers: {}
47
47
  },
@@ -55,8 +55,8 @@ class re {
55
55
  try {
56
56
  if (!n.includes("="))
57
57
  continue;
58
- const r = n.indexOf("="), o = n.substring(0, r), a = n.substring(r + 1).split(";")[0];
59
- this.#e[o] = a;
58
+ const r = n.indexOf("="), i = n.substring(0, r), a = n.substring(r + 1).split(";")[0];
59
+ this.#e[i] = a;
60
60
  } catch (r) {
61
61
  console.error(r);
62
62
  }
@@ -68,14 +68,14 @@ class re {
68
68
  return e.join("; ");
69
69
  }
70
70
  }
71
- const oe = "http://example.com";
72
- function j(t) {
71
+ const ie = "http://example.com";
72
+ function B(t) {
73
73
  return t.toString().substring(t.origin.length);
74
74
  }
75
- function B(t, e) {
75
+ function j(t, e) {
76
76
  return !e || !t.startsWith(e) ? t : t.substring(e.length);
77
77
  }
78
- function ie(t, e) {
78
+ function oe(t, e) {
79
79
  return !e || t.startsWith(e) ? t : e + t;
80
80
  }
81
81
  class se {
@@ -95,9 +95,27 @@ class se {
95
95
  };
96
96
  }
97
97
  }
98
- class I {
99
- constructor(e, n, r, o = "", a = 0) {
100
- this.httpStatusCode = e, this.headers = n, this.body = r, this.exitCode = a, this.errors = o;
98
+ class E {
99
+ constructor(e, n, r, i = "", a = 0) {
100
+ this.httpStatusCode = e, this.headers = n, this.bytes = r, this.exitCode = a, this.errors = i;
101
+ }
102
+ static fromRawData(e) {
103
+ return new E(
104
+ e.httpStatusCode,
105
+ e.headers,
106
+ e.bytes,
107
+ e.errors,
108
+ e.exitCode
109
+ );
110
+ }
111
+ toRawData() {
112
+ return {
113
+ headers: this.headers,
114
+ bytes: this.bytes,
115
+ errors: this.errors,
116
+ exitCode: this.exitCode,
117
+ httpStatusCode: this.httpStatusCode
118
+ };
101
119
  }
102
120
  /**
103
121
  * Response body as JSON.
@@ -109,13 +127,7 @@ class I {
109
127
  * Response body as text.
110
128
  */
111
129
  get text() {
112
- return new TextDecoder().decode(this.body);
113
- }
114
- /**
115
- * Response body as bytes.
116
- */
117
- get bytes() {
118
- return this.body;
130
+ return new TextDecoder().decode(this.bytes);
119
131
  }
120
132
  }
121
133
  class ae {
@@ -123,8 +135,8 @@ class ae {
123
135
  #t;
124
136
  #n;
125
137
  #r;
126
- #i;
127
138
  #o;
139
+ #i;
128
140
  #s;
129
141
  #a;
130
142
  #l;
@@ -136,20 +148,20 @@ class ae {
136
148
  this.#a = new se({ concurrency: 1 });
137
149
  const {
138
150
  documentRoot: r = "/www/",
139
- absoluteUrl: o = location.origin,
151
+ absoluteUrl: i = location.origin,
140
152
  isStaticFilePath: a = () => !1
141
153
  } = n;
142
154
  this.php = e, this.#e = r, this.#l = a;
143
- const i = new URL(o);
144
- this.#n = i.hostname, this.#r = i.port ? Number(i.port) : i.protocol === "https:" ? 443 : 80, this.#t = (i.protocol || "").replace(":", "");
155
+ const o = new URL(i);
156
+ this.#n = o.hostname, this.#r = o.port ? Number(o.port) : o.protocol === "https:" ? 443 : 80, this.#t = (o.protocol || "").replace(":", "");
145
157
  const d = this.#r !== 443 && this.#r !== 80;
146
- this.#i = [
158
+ this.#o = [
147
159
  this.#n,
148
160
  d ? `:${this.#r}` : ""
149
- ].join(""), this.#o = i.pathname.replace(/\/+$/, ""), this.#s = [
161
+ ].join(""), this.#i = o.pathname.replace(/\/+$/, ""), this.#s = [
150
162
  `${this.#t}://`,
151
- this.#i,
152
- this.#o
163
+ this.#o,
164
+ this.#i
153
165
  ].join("");
154
166
  }
155
167
  /**
@@ -171,7 +183,7 @@ class ae {
171
183
  */
172
184
  internalUrlToPath(e) {
173
185
  const n = new URL(e);
174
- return n.pathname.startsWith(this.#o) && (n.pathname = n.pathname.slice(this.#o.length)), j(n);
186
+ return n.pathname.startsWith(this.#i) && (n.pathname = n.pathname.slice(this.#i.length)), B(n);
175
187
  }
176
188
  get isRequestRunning() {
177
189
  return this.#a.running > 0;
@@ -198,12 +210,12 @@ class ae {
198
210
  async request(e) {
199
211
  const n = e.url.startsWith("http://") || e.url.startsWith("https://"), r = new URL(
200
212
  e.url,
201
- n ? void 0 : oe
202
- ), o = B(
213
+ n ? void 0 : ie
214
+ ), i = j(
203
215
  r.pathname,
204
- this.#o
216
+ this.#i
205
217
  );
206
- return this.#l(o) ? this.#c(o) : await this.#u(e, r);
218
+ return this.#l(i) ? this.#c(i) : await this.#u(e, r);
207
219
  }
208
220
  /**
209
221
  * Serves a static file from the PHP filesystem.
@@ -214,13 +226,13 @@ class ae {
214
226
  #c(e) {
215
227
  const n = `${this.#e}${e}`;
216
228
  if (!this.php.fileExists(n))
217
- return new I(
229
+ return new E(
218
230
  404,
219
231
  {},
220
232
  new TextEncoder().encode("404 File not found")
221
233
  );
222
234
  const r = this.php.readFileAsBuffer(n);
223
- return new I(
235
+ return new E(
224
236
  200,
225
237
  {
226
238
  "content-length": [`${r.byteLength}`],
@@ -248,10 +260,10 @@ class ae {
248
260
  "HTTPS",
249
261
  this.#s.startsWith("https://") ? "on" : ""
250
262
  );
251
- let o = "GET";
263
+ let i = "GET";
252
264
  const a = [];
253
265
  if (e.files) {
254
- o = "POST";
266
+ i = "POST";
255
267
  for (const c in e.files) {
256
268
  const s = e.files[c];
257
269
  a.push({
@@ -262,24 +274,24 @@ class ae {
262
274
  });
263
275
  }
264
276
  }
265
- const i = {
266
- host: this.#i
277
+ const o = {
278
+ host: this.#o
267
279
  };
268
280
  let d;
269
- return e.formData !== void 0 ? (o = "POST", i["content-type"] = "application/x-www-form-urlencoded", d = new URLSearchParams(
281
+ return e.formData !== void 0 ? (i = "POST", o["content-type"] = "application/x-www-form-urlencoded", d = new URLSearchParams(
270
282
  e.formData
271
283
  ).toString()) : d = e.body, await this.php.run({
272
- relativeUri: ie(
273
- j(n),
274
- this.#o
284
+ relativeUri: oe(
285
+ B(n),
286
+ this.#i
275
287
  ),
276
288
  protocol: this.#t,
277
- method: e.method || o,
289
+ method: e.method || i,
278
290
  body: d,
279
291
  fileInfos: a,
280
292
  scriptPath: this.#d(n.pathname),
281
293
  headers: {
282
- ...i,
294
+ ...o,
283
295
  ...e.headers || {}
284
296
  }
285
297
  });
@@ -296,7 +308,7 @@ class ae {
296
308
  * @returns The resolved filesystem path.
297
309
  */
298
310
  #d(e) {
299
- let n = B(e, this.#o);
311
+ let n = j(e, this.#i);
300
312
  n.includes(".php") ? n = n.split(".php")[0] + ".php" : (n.endsWith("/") || (n += "/"), n.endsWith("index.php") || (n += "index.php"));
301
313
  const r = `${this.#e}${n}`;
302
314
  return this.php.fileExists(r) ? r : `${this.#e}/index.php`;
@@ -422,15 +434,15 @@ const W = {
422
434
  76: "Extension: Capabilities insufficient."
423
435
  };
424
436
  function m(t = "") {
425
- return function(n, r, o) {
426
- const a = o.value;
427
- o.value = function(...i) {
437
+ return function(n, r, i) {
438
+ const a = i.value;
439
+ i.value = function(...o) {
428
440
  try {
429
- return a.apply(this, i);
441
+ return a.apply(this, o);
430
442
  } catch (d) {
431
443
  const c = typeof d == "object" ? d?.errno : null;
432
444
  if (c in W) {
433
- const s = W[c], l = typeof i[0] == "string" ? i[0] : null, h = l !== null ? t.replaceAll("{path}", l) : t;
445
+ const s = W[c], l = typeof o[0] == "string" ? o[0] : null, h = l !== null ? t.replaceAll("{path}", l) : t;
434
446
  throw new Error(`${h}: ${s}`, {
435
447
  cause: d
436
448
  });
@@ -441,9 +453,9 @@ function m(t = "") {
441
453
  };
442
454
  }
443
455
  var ce = Object.defineProperty, ue = Object.getOwnPropertyDescriptor, w = (t, e, n, r) => {
444
- for (var o = r > 1 ? void 0 : r ? ue(e, n) : e, a = t.length - 1, i; a >= 0; a--)
445
- (i = t[a]) && (o = (r ? i(e, n, o) : i(o)) || o);
446
- return r && o && ce(e, n, o), o;
456
+ for (var i = r > 1 ? void 0 : r ? ue(e, n) : e, a = t.length - 1, o; a >= 0; a--)
457
+ (o = t[a]) && (i = (r ? o(e, n, i) : o(i)) || i);
458
+ return r && i && ce(e, n, i), i;
447
459
  };
448
460
  const f = "string", y = "number", G = [];
449
461
  (function() {
@@ -496,14 +508,14 @@ class g {
496
508
  }
497
509
  /** @inheritDoc */
498
510
  async run(e = {}) {
499
- this.#n || (this.#r(), this.#n = !0), this.#u(e.scriptPath || ""), this.#o(e.relativeUri || ""), this.#a(e.method || "GET");
511
+ this.#n || (this.#r(), this.#n = !0), this.#u(e.scriptPath || ""), this.#i(e.relativeUri || ""), this.#a(e.method || "GET");
500
512
  const { host: n, ...r } = {
501
513
  host: "example.com:443",
502
514
  ...de(e.headers || {})
503
515
  };
504
516
  if (this.#s(n, e.protocol || "http"), this.#l(r), e.body && this.#c(e.body), e.fileInfos)
505
- for (const o of e.fileInfos)
506
- this.#d(o);
517
+ for (const i of e.fileInfos)
518
+ this.#d(i);
507
519
  return e.code && this.#h(" ?>" + e.code), await this.#p();
508
520
  }
509
521
  #r() {
@@ -526,25 +538,25 @@ class g {
526
538
  this.#e.ccall("wasm_add_cli_arg", null, [f], [n]);
527
539
  return this.#e.ccall("run_cli", null, [], [], { async: !0 });
528
540
  }
529
- #i() {
541
+ #o() {
530
542
  const e = "/tmp/headers.json";
531
543
  if (!this.fileExists(e))
532
544
  throw new Error(
533
545
  "SAPI Error: Could not find response headers file."
534
546
  );
535
547
  const n = JSON.parse(this.readFileAsText(e)), r = {};
536
- for (const o of n.headers) {
537
- if (!o.includes(": "))
548
+ for (const i of n.headers) {
549
+ if (!i.includes(": "))
538
550
  continue;
539
- const a = o.indexOf(": "), i = o.substring(0, a).toLowerCase(), d = o.substring(a + 2);
540
- i in r || (r[i] = []), r[i].push(d);
551
+ const a = i.indexOf(": "), o = i.substring(0, a).toLowerCase(), d = i.substring(a + 2);
552
+ o in r || (r[o] = []), r[o].push(d);
541
553
  }
542
554
  return {
543
555
  headers: r,
544
556
  httpStatusCode: n.status
545
557
  };
546
558
  }
547
- #o(e) {
559
+ #i(e) {
548
560
  if (this.#e.ccall("wasm_set_request_uri", null, [f], [e]), e.includes("?")) {
549
561
  const n = e.substring(e.indexOf("?") + 1);
550
562
  this.#e.ccall(
@@ -627,14 +639,14 @@ class g {
627
639
  * @param fileInfo - File details
628
640
  */
629
641
  #d(e) {
630
- const { key: n, name: r, type: o, data: a } = e, i = `/tmp/${Math.random().toFixed(20)}`;
631
- this.writeFile(i, a);
642
+ const { key: n, name: r, type: i, data: a } = e, o = `/tmp/${Math.random().toFixed(20)}`;
643
+ this.writeFile(o, a);
632
644
  const d = 0;
633
645
  this.#e.ccall(
634
646
  "wasm_add_uploaded_file",
635
647
  null,
636
648
  [f, f, f, f, y, y],
637
- [n, r, o, i, d, a.byteLength]
649
+ [n, r, i, o, d, a.byteLength]
638
650
  );
639
651
  }
640
652
  #h(e) {
@@ -646,8 +658,8 @@ class g {
646
658
  y,
647
659
  [],
648
660
  []
649
- ), { headers: n, httpStatusCode: r } = this.#i();
650
- return new I(
661
+ ), { headers: n, httpStatusCode: r } = this.#o();
662
+ return new E(
651
663
  r,
652
664
  n,
653
665
  this.readFileAsBuffer("/tmp/stdout"),
@@ -739,7 +751,7 @@ function de(t) {
739
751
  * Copyright 2019 Google LLC
740
752
  * SPDX-License-Identifier: Apache-2.0
741
753
  */
742
- const K = Symbol("Comlink.proxy"), he = Symbol("Comlink.endpoint"), pe = Symbol("Comlink.releaseProxy"), U = Symbol("Comlink.finalizer"), C = Symbol("Comlink.thrown"), X = (t) => typeof t == "object" && t !== null || typeof t == "function", fe = {
754
+ const K = Symbol("Comlink.proxy"), he = Symbol("Comlink.endpoint"), pe = Symbol("Comlink.releaseProxy"), I = Symbol("Comlink.finalizer"), O = Symbol("Comlink.thrown"), X = (t) => typeof t == "object" && t !== null || typeof t == "function", fe = {
743
755
  canHandle: (t) => X(t) && t[K],
744
756
  serialize(t) {
745
757
  const { port1: e, port2: n } = new MessageChannel();
@@ -749,7 +761,7 @@ const K = Symbol("Comlink.proxy"), he = Symbol("Comlink.endpoint"), pe = Symbol(
749
761
  return t.start(), M(t);
750
762
  }
751
763
  }, me = {
752
- canHandle: (t) => X(t) && C in t,
764
+ canHandle: (t) => X(t) && O in t,
753
765
  serialize({ value: t }) {
754
766
  let e;
755
767
  return t instanceof Error ? e = {
@@ -764,7 +776,7 @@ const K = Symbol("Comlink.proxy"), he = Symbol("Comlink.endpoint"), pe = Symbol(
764
776
  deserialize(t) {
765
777
  throw t.isError ? Object.assign(new Error(t.value.message), t.value) : t.value;
766
778
  }
767
- }, k = /* @__PURE__ */ new Map([
779
+ }, R = /* @__PURE__ */ new Map([
768
780
  ["proxy", fe],
769
781
  ["throw", me]
770
782
  ]);
@@ -775,23 +787,23 @@ function we(t, e) {
775
787
  return !1;
776
788
  }
777
789
  function N(t, e = globalThis, n = ["*"]) {
778
- e.addEventListener("message", function r(o) {
779
- if (!o || !o.data)
790
+ e.addEventListener("message", function r(i) {
791
+ if (!i || !i.data)
780
792
  return;
781
- if (!we(n, o.origin)) {
782
- console.warn(`Invalid origin '${o.origin}' for comlink proxy`);
793
+ if (!we(n, i.origin)) {
794
+ console.warn(`Invalid origin '${i.origin}' for comlink proxy`);
783
795
  return;
784
796
  }
785
- const { id: a, type: i, path: d } = Object.assign({ path: [] }, o.data), c = (o.data.argumentList || []).map(b);
797
+ const { id: a, type: o, path: d } = Object.assign({ path: [] }, i.data), c = (i.data.argumentList || []).map(b);
786
798
  let s;
787
799
  try {
788
800
  const l = d.slice(0, -1).reduce((u, p) => u[p], t), h = d.reduce((u, p) => u[p], t);
789
- switch (i) {
801
+ switch (o) {
790
802
  case "GET":
791
803
  s = h;
792
804
  break;
793
805
  case "SET":
794
- l[d.slice(-1)[0]] = b(o.data.value), s = !0;
806
+ l[d.slice(-1)[0]] = b(i.data.value), s = !0;
795
807
  break;
796
808
  case "APPLY":
797
809
  s = h.apply(l, c);
@@ -815,15 +827,15 @@ function N(t, e = globalThis, n = ["*"]) {
815
827
  return;
816
828
  }
817
829
  } catch (l) {
818
- s = { value: l, [C]: 0 };
830
+ s = { value: l, [O]: 0 };
819
831
  }
820
- Promise.resolve(s).catch((l) => ({ value: l, [C]: 0 })).then((l) => {
821
- const [h, u] = L(l);
822
- e.postMessage(Object.assign(Object.assign({}, h), { id: a }), u), i === "RELEASE" && (e.removeEventListener("message", r), J(e), U in t && typeof t[U] == "function" && t[U]());
832
+ Promise.resolve(s).catch((l) => ({ value: l, [O]: 0 })).then((l) => {
833
+ const [h, u] = U(l);
834
+ e.postMessage(Object.assign(Object.assign({}, h), { id: a }), u), o === "RELEASE" && (e.removeEventListener("message", r), J(e), I in t && typeof t[I] == "function" && t[I]());
823
835
  }).catch((l) => {
824
- const [h, u] = L({
836
+ const [h, u] = U({
825
837
  value: new TypeError("Unserializable return value"),
826
- [C]: 0
838
+ [O]: 0
827
839
  });
828
840
  e.postMessage(Object.assign(Object.assign({}, h), { id: a }), u);
829
841
  });
@@ -836,9 +848,9 @@ function J(t) {
836
848
  ge(t) && t.close();
837
849
  }
838
850
  function M(t, e) {
839
- return q(t, [], e);
851
+ return D(t, [], e);
840
852
  }
841
- function S(t) {
853
+ function k(t) {
842
854
  if (t)
843
855
  throw new Error("Proxy has been released and is not useable");
844
856
  }
@@ -849,55 +861,55 @@ function Y(t) {
849
861
  J(t);
850
862
  });
851
863
  }
852
- const O = /* @__PURE__ */ new WeakMap(), A = "FinalizationRegistry" in globalThis && new FinalizationRegistry((t) => {
853
- const e = (O.get(t) || 0) - 1;
854
- O.set(t, e), e === 0 && Y(t);
864
+ const A = /* @__PURE__ */ new WeakMap(), L = "FinalizationRegistry" in globalThis && new FinalizationRegistry((t) => {
865
+ const e = (A.get(t) || 0) - 1;
866
+ A.set(t, e), e === 0 && Y(t);
855
867
  });
856
868
  function ye(t, e) {
857
- const n = (O.get(e) || 0) + 1;
858
- O.set(e, n), A && A.register(t, e, t);
869
+ const n = (A.get(e) || 0) + 1;
870
+ A.set(e, n), L && L.register(t, e, t);
859
871
  }
860
872
  function be(t) {
861
- A && A.unregister(t);
873
+ L && L.unregister(t);
862
874
  }
863
- function q(t, e = [], n = function() {
875
+ function D(t, e = [], n = function() {
864
876
  }) {
865
877
  let r = !1;
866
- const o = new Proxy(n, {
867
- get(a, i) {
868
- if (S(r), i === pe)
878
+ const i = new Proxy(n, {
879
+ get(a, o) {
880
+ if (k(r), o === pe)
869
881
  return () => {
870
- be(o), Y(t), r = !0;
882
+ be(i), Y(t), r = !0;
871
883
  };
872
- if (i === "then") {
884
+ if (o === "then") {
873
885
  if (e.length === 0)
874
- return { then: () => o };
886
+ return { then: () => i };
875
887
  const d = P(t, {
876
888
  type: "GET",
877
889
  path: e.map((c) => c.toString())
878
890
  }).then(b);
879
891
  return d.then.bind(d);
880
892
  }
881
- return q(t, [...e, i]);
893
+ return D(t, [...e, o]);
882
894
  },
883
- set(a, i, d) {
884
- S(r);
885
- const [c, s] = L(d);
895
+ set(a, o, d) {
896
+ k(r);
897
+ const [c, s] = U(d);
886
898
  return P(t, {
887
899
  type: "SET",
888
- path: [...e, i].map((l) => l.toString()),
900
+ path: [...e, o].map((l) => l.toString()),
889
901
  value: c
890
902
  }, s).then(b);
891
903
  },
892
- apply(a, i, d) {
893
- S(r);
904
+ apply(a, o, d) {
905
+ k(r);
894
906
  const c = e[e.length - 1];
895
907
  if (c === he)
896
908
  return P(t, {
897
909
  type: "ENDPOINT"
898
910
  }).then(b);
899
911
  if (c === "bind")
900
- return q(t, e.slice(0, -1));
912
+ return D(t, e.slice(0, -1));
901
913
  const [s, l] = V(d);
902
914
  return P(t, {
903
915
  type: "APPLY",
@@ -905,9 +917,9 @@ function q(t, e = [], n = function() {
905
917
  argumentList: s
906
918
  }, l).then(b);
907
919
  },
908
- construct(a, i) {
909
- S(r);
910
- const [d, c] = V(i);
920
+ construct(a, o) {
921
+ k(r);
922
+ const [d, c] = V(o);
911
923
  return P(t, {
912
924
  type: "CONSTRUCT",
913
925
  path: e.map((s) => s.toString()),
@@ -915,13 +927,13 @@ function q(t, e = [], n = function() {
915
927
  }, c).then(b);
916
928
  }
917
929
  });
918
- return ye(o, t), o;
930
+ return ye(i, t), i;
919
931
  }
920
932
  function ve(t) {
921
933
  return Array.prototype.concat.apply([], t);
922
934
  }
923
935
  function V(t) {
924
- const e = t.map(L);
936
+ const e = t.map(U);
925
937
  return [e.map((n) => n[0]), ve(e.map((n) => n[1]))];
926
938
  }
927
939
  const Q = /* @__PURE__ */ new WeakMap();
@@ -933,22 +945,22 @@ function Ee(t) {
933
945
  }
934
946
  function xe(t, e = globalThis, n = "*") {
935
947
  return {
936
- postMessage: (r, o) => t.postMessage(r, n, o),
948
+ postMessage: (r, i) => t.postMessage(r, n, i),
937
949
  addEventListener: e.addEventListener.bind(e),
938
950
  removeEventListener: e.removeEventListener.bind(e)
939
951
  };
940
952
  }
941
- function L(t) {
942
- for (const [e, n] of k)
953
+ function U(t) {
954
+ for (const [e, n] of R)
943
955
  if (n.canHandle(t)) {
944
- const [r, o] = n.serialize(t);
956
+ const [r, i] = n.serialize(t);
945
957
  return [
946
958
  {
947
959
  type: "HANDLER",
948
960
  name: e,
949
961
  value: r
950
962
  },
951
- o
963
+ i
952
964
  ];
953
965
  }
954
966
  return [
@@ -962,17 +974,17 @@ function L(t) {
962
974
  function b(t) {
963
975
  switch (t.type) {
964
976
  case "HANDLER":
965
- return k.get(t.name).deserialize(t.value);
977
+ return R.get(t.name).deserialize(t.value);
966
978
  case "RAW":
967
979
  return t.value;
968
980
  }
969
981
  }
970
982
  function P(t, e, n) {
971
983
  return new Promise((r) => {
972
- const o = $e();
973
- t.addEventListener("message", function a(i) {
974
- !i.data || !i.data.id || i.data.id !== o || (t.removeEventListener("message", a), r(i.data));
975
- }), t.start && t.start(), t.postMessage(Object.assign({ id: o }, e), n);
984
+ const i = $e();
985
+ t.addEventListener("message", function a(o) {
986
+ !o.data || !o.data.id || o.data.id !== i || (t.removeEventListener("message", a), r(o.data));
987
+ }), t.start && t.start(), t.postMessage(Object.assign({ id: i }, e), n);
976
988
  });
977
989
  }
978
990
  function $e() {
@@ -984,7 +996,7 @@ function Fe(t) {
984
996
  return M(e);
985
997
  }
986
998
  function Te() {
987
- k.set("EVENT", {
999
+ R.set("EVENT", {
988
1000
  canHandle: (t) => t instanceof CustomEvent,
989
1001
  serialize: (t) => [
990
1002
  {
@@ -993,7 +1005,7 @@ function Te() {
993
1005
  []
994
1006
  ],
995
1007
  deserialize: (t) => t
996
- }), k.set("FUNCTION", {
1008
+ }), R.set("FUNCTION", {
997
1009
  canHandle: (t) => typeof t == "function",
998
1010
  serialize(t) {
999
1011
  console.debug("[Comlink][Performance] Proxying a function");
@@ -1003,23 +1015,31 @@ function Te() {
1003
1015
  deserialize(t) {
1004
1016
  return t.start(), M(t);
1005
1017
  }
1018
+ }), R.set("PHPResponse", {
1019
+ canHandle: (t) => typeof t == "object" && t !== null && "headers" in t && "bytes" in t && "errors" in t && "exitCode" in t && "httpStatusCode" in t,
1020
+ serialize(t) {
1021
+ return [t.toRawData(), []];
1022
+ },
1023
+ deserialize(t) {
1024
+ return E.fromRawData(t);
1025
+ }
1006
1026
  });
1007
1027
  }
1008
1028
  (function() {
1009
1029
  return navigator.userAgent.toLowerCase().indexOf("firefox") > -1 ? "iframe" : "webworker";
1010
1030
  })();
1011
- var F = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, z = {}, _e = {
1031
+ var T = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, q = {}, Re = {
1012
1032
  get exports() {
1013
- return z;
1033
+ return q;
1014
1034
  },
1015
1035
  set exports(t) {
1016
- z = t;
1036
+ q = t;
1017
1037
  }
1018
1038
  };
1019
1039
  (function(t, e) {
1020
1040
  (function(n, r) {
1021
1041
  r();
1022
- })(F, function() {
1042
+ })(T, function() {
1023
1043
  function n(s, l) {
1024
1044
  return typeof l > "u" ? l = { autoBom: !1 } : typeof l != "object" && (console.warn("Deprecated: Expected third argument to be a object"), l = { autoBom: !l }), l.autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(s.type) ? new Blob(["\uFEFF", s], { type: s.type }) : s;
1025
1045
  }
@@ -1031,7 +1051,7 @@ var F = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : ty
1031
1051
  console.error("could not download file");
1032
1052
  }, u.send();
1033
1053
  }
1034
- function o(s) {
1054
+ function i(s) {
1035
1055
  var l = new XMLHttpRequest();
1036
1056
  l.open("HEAD", s, !1);
1037
1057
  try {
@@ -1048,10 +1068,10 @@ var F = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : ty
1048
1068
  l.initMouseEvent("click", !0, !0, window, 0, 0, 0, 80, 20, !1, !1, !1, !1, 0, null), s.dispatchEvent(l);
1049
1069
  }
1050
1070
  }
1051
- var i = typeof window == "object" && window.window === window ? window : typeof self == "object" && self.self === self ? self : typeof F == "object" && F.global === F ? F : void 0, d = i.navigator && /Macintosh/.test(navigator.userAgent) && /AppleWebKit/.test(navigator.userAgent) && !/Safari/.test(navigator.userAgent), c = i.saveAs || (typeof window != "object" || window !== i ? function() {
1071
+ var o = typeof window == "object" && window.window === window ? window : typeof self == "object" && self.self === self ? self : typeof T == "object" && T.global === T ? T : void 0, d = o.navigator && /Macintosh/.test(navigator.userAgent) && /AppleWebKit/.test(navigator.userAgent) && !/Safari/.test(navigator.userAgent), c = o.saveAs || (typeof window != "object" || window !== o ? function() {
1052
1072
  } : "download" in HTMLAnchorElement.prototype && !d ? function(s, l, h) {
1053
- var u = i.URL || i.webkitURL, p = document.createElement("a");
1054
- l = l || s.name || "download", p.download = l, p.rel = "noopener", typeof s == "string" ? (p.href = s, p.origin === location.origin ? a(p) : o(p.href) ? r(s, l, h) : a(p, p.target = "_blank")) : (p.href = u.createObjectURL(s), setTimeout(function() {
1073
+ var u = o.URL || o.webkitURL, p = document.createElement("a");
1074
+ l = l || s.name || "download", p.download = l, p.rel = "noopener", typeof s == "string" ? (p.href = s, p.origin === location.origin ? a(p) : i(p.href) ? r(s, l, h) : a(p, p.target = "_blank")) : (p.href = u.createObjectURL(s), setTimeout(function() {
1055
1075
  u.revokeObjectURL(p.href);
1056
1076
  }, 4e4), setTimeout(function() {
1057
1077
  a(p);
@@ -1059,7 +1079,7 @@ var F = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : ty
1059
1079
  } : "msSaveOrOpenBlob" in navigator ? function(s, l, h) {
1060
1080
  if (l = l || s.name || "download", typeof s != "string")
1061
1081
  navigator.msSaveOrOpenBlob(n(s, h), l);
1062
- else if (o(s))
1082
+ else if (i(s))
1063
1083
  r(s, l, h);
1064
1084
  else {
1065
1085
  var u = document.createElement("a");
@@ -1070,24 +1090,24 @@ var F = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : ty
1070
1090
  } : function(s, l, h, u) {
1071
1091
  if (u = u || open("", "_blank"), u && (u.document.title = u.document.body.innerText = "downloading..."), typeof s == "string")
1072
1092
  return r(s, l, h);
1073
- var p = s.type === "application/octet-stream", E = /constructor/i.test(i.HTMLElement) || i.safari, _ = /CriOS\/[\d]+/.test(navigator.userAgent);
1074
- if ((_ || p && E || d) && typeof FileReader < "u") {
1075
- var x = new FileReader();
1076
- x.onloadend = function() {
1077
- var $ = x.result;
1078
- $ = _ ? $ : $.replace(/^data:[^;]*;/, "data:attachment/file;"), u ? u.location.href = $ : location = $, u = null;
1079
- }, x.readAsDataURL(s);
1093
+ var p = s.type === "application/octet-stream", x = /constructor/i.test(o.HTMLElement) || o.safari, _ = /CriOS\/[\d]+/.test(navigator.userAgent);
1094
+ if ((_ || p && x || d) && typeof FileReader < "u") {
1095
+ var $ = new FileReader();
1096
+ $.onloadend = function() {
1097
+ var F = $.result;
1098
+ F = _ ? F : F.replace(/^data:[^;]*;/, "data:attachment/file;"), u ? u.location.href = F : location = F, u = null;
1099
+ }, $.readAsDataURL(s);
1080
1100
  } else {
1081
- var R = i.URL || i.webkitURL, v = R.createObjectURL(s);
1101
+ var C = o.URL || o.webkitURL, v = C.createObjectURL(s);
1082
1102
  u ? u.location = v : location.href = v, u = null, setTimeout(function() {
1083
- R.revokeObjectURL(v);
1103
+ C.revokeObjectURL(v);
1084
1104
  }, 4e4);
1085
1105
  }
1086
1106
  });
1087
- i.saveAs = c.saveAs = c, t.exports = c;
1107
+ o.saveAs = c.saveAs = c, t.exports = c;
1088
1108
  });
1089
- })(_e);
1090
- const D = `<?php
1109
+ })(Re);
1110
+ const z = `<?php
1091
1111
 
1092
1112
  function generateZipFile($exportPath, $databasePath, $docRoot) {
1093
1113
  $zip = new ZipArchive;
@@ -1161,13 +1181,13 @@ async function ke(t) {
1161
1181
  url: "/wp-admin/export.php?download=true&content=all"
1162
1182
  })).text;
1163
1183
  await t.writeFile(H, n);
1164
- const r = await t.wordPressVersion, o = await t.phpVersion, a = await t.documentRoot, i = `wordpress-playground--wp${r}--php${o}.zip`, d = `/${i}`, c = await t.run({
1165
- code: D + ` generateZipFile('${d}', '${H}', '${a}');`
1184
+ const r = await t.wordPressVersion, i = await t.phpVersion, a = await t.documentRoot, o = `wordpress-playground--wp${r}--php${i}.zip`, d = `/${o}`, c = await t.run({
1185
+ code: z + ` generateZipFile('${d}', '${H}', '${a}');`
1166
1186
  });
1167
1187
  if (c.exitCode !== 0)
1168
1188
  throw c.errors;
1169
- const s = await t.readFileAsBuffer(i), l = new File([s], i);
1170
- z.saveAs(l);
1189
+ const s = await t.readFileAsBuffer(o), l = new File([s], o);
1190
+ q.saveAs(l);
1171
1191
  }
1172
1192
  async function Oe(t, e) {
1173
1193
  if (
@@ -1177,17 +1197,17 @@ async function Oe(t, e) {
1177
1197
  )
1178
1198
  )
1179
1199
  return !1;
1180
- const n = await e.arrayBuffer(), r = new Uint8Array(n), o = "/import.zip";
1181
- await t.writeFile(o, r);
1200
+ const n = await e.arrayBuffer(), r = new Uint8Array(n), i = "/import.zip";
1201
+ await t.writeFile(i, r);
1182
1202
  const a = await t.run({
1183
- code: D + ` readFileFromZipArchive('${o}', '${H}');`
1203
+ code: z + ` readFileFromZipArchive('${i}', '${H}');`
1184
1204
  });
1185
1205
  if (a.exitCode !== 0)
1186
1206
  throw a.errors;
1187
- const i = new TextDecoder().decode(
1207
+ const o = new TextDecoder().decode(
1188
1208
  a.bytes
1189
1209
  ), d = new File(
1190
- [i],
1210
+ [o],
1191
1211
  ee
1192
1212
  ), c = await t.request({
1193
1213
  url: "/wp-admin/admin.php?import=wordpress"
@@ -1203,26 +1223,26 @@ async function Oe(t, e) {
1203
1223
  "text/html"
1204
1224
  ).querySelector(
1205
1225
  "#wpbody-content form"
1206
- ), E = p?.getAttribute(
1226
+ ), x = p?.getAttribute(
1207
1227
  "action"
1208
1228
  ), _ = (p?.querySelector(
1209
1229
  "input[name='_wpnonce']"
1210
- )).value, x = (p?.querySelector(
1230
+ )).value, $ = (p?.querySelector(
1211
1231
  "input[name='_wp_http_referer']"
1212
- )).value, R = (p?.querySelector(
1232
+ )).value, C = (p?.querySelector(
1213
1233
  "input[name='import_id']"
1214
1234
  )).value;
1215
1235
  await t.request({
1216
- url: E,
1236
+ url: x,
1217
1237
  method: "POST",
1218
1238
  formData: {
1219
1239
  _wpnonce: _,
1220
- _wp_http_referer: x,
1221
- import_id: R
1240
+ _wp_http_referer: $,
1241
+ import_id: C
1222
1242
  }
1223
1243
  });
1224
1244
  const v = await t.run({
1225
- code: D + ` importZipFile('${o}');`
1245
+ code: z + ` importZipFile('${i}');`
1226
1246
  });
1227
1247
  if (v.exitCode !== 0)
1228
1248
  throw v.errors;
@@ -1241,20 +1261,20 @@ async function Ae(t, e = "admin", n = "password") {
1241
1261
  }
1242
1262
  });
1243
1263
  }
1244
- function T(t) {
1264
+ function S(t) {
1245
1265
  return new DOMParser().parseFromString(t.text, "text/html");
1246
1266
  }
1247
1267
  function te(t) {
1248
1268
  const e = t.split(".").shift().replace("-", " ");
1249
1269
  return e.charAt(0).toUpperCase() + e.slice(1).toLowerCase();
1250
1270
  }
1251
- async function Re(t, e, n = {}) {
1252
- const r = "activate" in n ? n.activate : !0, o = await t.request({
1271
+ async function Se(t, e, n = {}) {
1272
+ const r = "activate" in n ? n.activate : !0, i = await t.request({
1253
1273
  url: "/wp-admin/theme-install.php"
1254
- }), a = T(o), i = new FormData(
1274
+ }), a = S(i), o = new FormData(
1255
1275
  a.querySelector(".wp-upload-form")
1256
1276
  ), { themezip: d, ...c } = Object.fromEntries(
1257
- i.entries()
1277
+ o.entries()
1258
1278
  ), s = await t.request({
1259
1279
  url: "/wp-admin/update.php?action=upload-theme",
1260
1280
  method: "POST",
@@ -1262,7 +1282,7 @@ async function Re(t, e, n = {}) {
1262
1282
  files: { themezip: e }
1263
1283
  });
1264
1284
  if (r) {
1265
- const l = T(s), h = l.querySelector(
1285
+ const l = S(s), h = l.querySelector(
1266
1286
  "#wpbody-content > .wrap"
1267
1287
  );
1268
1288
  if (h?.textContent?.includes(
@@ -1278,22 +1298,22 @@ async function Re(t, e, n = {}) {
1278
1298
  console.error('The "activate" button was not found.');
1279
1299
  return;
1280
1300
  }
1281
- const p = u.attributes.getNamedItem("href").value, E = new URL(
1301
+ const p = u.attributes.getNamedItem("href").value, x = new URL(
1282
1302
  p,
1283
1303
  await t.pathToInternalUrl("/wp-admin/")
1284
1304
  ).toString();
1285
1305
  await t.request({
1286
- url: E
1306
+ url: x
1287
1307
  });
1288
1308
  }
1289
1309
  }
1290
- async function Se(t, e, n = {}) {
1291
- const r = "activate" in n ? n.activate : !0, o = await t.request({
1310
+ async function _e(t, e, n = {}) {
1311
+ const r = "activate" in n ? n.activate : !0, i = await t.request({
1292
1312
  url: "/wp-admin/plugin-install.php?tab=upload"
1293
- }), a = T(o), i = new FormData(
1313
+ }), a = S(i), o = new FormData(
1294
1314
  a.querySelector(".wp-upload-form")
1295
1315
  ), { pluginzip: d, ...c } = Object.fromEntries(
1296
- i.entries()
1316
+ o.entries()
1297
1317
  ), s = await t.request({
1298
1318
  url: "/wp-admin/update.php?action=upload-plugin",
1299
1319
  method: "POST",
@@ -1301,7 +1321,7 @@ async function Se(t, e, n = {}) {
1301
1321
  files: { pluginzip: e }
1302
1322
  });
1303
1323
  if (r) {
1304
- const u = T(s).querySelector("#wpbody-content .button.button-primary").attributes.getNamedItem("href").value, p = new URL(
1324
+ const u = S(s).querySelector("#wpbody-content .button.button-primary").attributes.getNamedItem("href").value, p = new URL(
1305
1325
  u,
1306
1326
  await t.pathToInternalUrl("/wp-admin/")
1307
1327
  ).toString();
@@ -1330,7 +1350,7 @@ async function Se(t, e, n = {}) {
1330
1350
  ));
1331
1351
  }
1332
1352
  async function Le(t, e) {
1333
- const o = T(
1353
+ const i = S(
1334
1354
  await t.request({
1335
1355
  url: "/wp-admin/plugins.php"
1336
1356
  })
@@ -1338,18 +1358,18 @@ async function Le(t, e) {
1338
1358
  `tr[data-slug="${e}"] a`
1339
1359
  ).attributes.getNamedItem("href").value;
1340
1360
  await t.request({
1341
- url: "/wp-admin/" + o
1361
+ url: "/wp-admin/" + i
1342
1362
  });
1343
1363
  }
1344
1364
  const Ce = 5 * 1024 * 1024;
1345
1365
  function ne(t, e) {
1346
1366
  const n = t.headers.get("content-length") || "", r = parseInt(n, 10) || Ce;
1347
- function o(a, i) {
1367
+ function i(a, o) {
1348
1368
  e(
1349
1369
  new CustomEvent("progress", {
1350
1370
  detail: {
1351
1371
  loaded: a,
1352
- total: i
1372
+ total: o
1353
1373
  }
1354
1374
  })
1355
1375
  );
@@ -1361,16 +1381,16 @@ function ne(t, e) {
1361
1381
  a.close();
1362
1382
  return;
1363
1383
  }
1364
- const i = t.body.getReader();
1384
+ const o = t.body.getReader();
1365
1385
  let d = 0;
1366
1386
  for (; ; )
1367
1387
  try {
1368
- const { done: c, value: s } = await i.read();
1388
+ const { done: c, value: s } = await o.read();
1369
1389
  if (s && (d += s.byteLength), c) {
1370
- o(d, d), a.close();
1390
+ i(d, d), a.close();
1371
1391
  break;
1372
1392
  } else
1373
- o(d, r), a.enqueue(s);
1393
+ i(d, r), a.enqueue(s);
1374
1394
  } catch (c) {
1375
1395
  console.error({ e: c }), a.error(c);
1376
1396
  break;
@@ -1385,21 +1405,21 @@ function ne(t, e) {
1385
1405
  );
1386
1406
  }
1387
1407
  async function Ue(t, e, n = 100, r) {
1388
- let o = await fetch("/plugin-proxy?theme=" + e);
1389
- if (r && (o = ne(
1390
- o,
1408
+ let i = await fetch("/plugin-proxy?theme=" + e);
1409
+ if (r && (i = ne(
1410
+ i,
1391
1411
  r.partialObserver(
1392
1412
  n / 2,
1393
1413
  `Installing ${te(e)} theme...`
1394
1414
  )
1395
- ), r.slowlyIncrementBy(n / 2)), o.status === 200) {
1396
- const a = new File([await o.blob()], e);
1415
+ ), r.slowlyIncrementBy(n / 2)), i.status === 200) {
1416
+ const a = new File([await i.blob()], e);
1397
1417
  try {
1398
- await Re(t, a);
1399
- } catch (i) {
1418
+ await Se(t, a);
1419
+ } catch (o) {
1400
1420
  console.error(
1401
- `Proceeding without the ${e} theme. Could not install it in wp-admin. The original error was: ${i}`
1402
- ), console.error(i);
1421
+ `Proceeding without the ${e} theme. Could not install it in wp-admin. The original error was: ${o}`
1422
+ ), console.error(o);
1403
1423
  }
1404
1424
  } else
1405
1425
  console.error(
@@ -1407,17 +1427,17 @@ async function Ue(t, e, n = 100, r) {
1407
1427
  );
1408
1428
  }
1409
1429
  async function Ie(t, e, n = 100, r) {
1410
- const o = new Z(), a = new Z(), i = n / e.length;
1430
+ const i = new Z(), a = new Z(), o = n / e.length;
1411
1431
  await new Promise((d) => {
1412
1432
  for (const c of e)
1413
- o.enqueue(async () => {
1433
+ i.enqueue(async () => {
1414
1434
  let s = await fetch(
1415
1435
  "/plugin-proxy?plugin=" + c
1416
1436
  );
1417
1437
  return r && (s = ne(
1418
1438
  s,
1419
1439
  r.partialObserver(
1420
- i * 0.66,
1440
+ o * 0.66,
1421
1441
  `Installing ${te(
1422
1442
  c
1423
1443
  )} plugin...`
@@ -1426,12 +1446,12 @@ async function Ie(t, e, n = 100, r) {
1426
1446
  `Proceeding without the ${c} plugin. Could not download the zip bundle from https://downloads.wordpress.org/plugin/${c} – Is the file name correct?`
1427
1447
  ), null) : new File([await s.blob()], c);
1428
1448
  });
1429
- o.addEventListener("resolved", (c) => {
1449
+ i.addEventListener("resolved", (c) => {
1430
1450
  a.enqueue(async () => {
1431
1451
  if (c.detail) {
1432
- r?.slowlyIncrementBy(i * 0.33);
1452
+ r?.slowlyIncrementBy(o * 0.33);
1433
1453
  try {
1434
- await Se(t, c.detail);
1454
+ await _e(t, c.detail);
1435
1455
  } catch (s) {
1436
1456
  console.error(
1437
1457
  `Proceeding without the ${c.detail.name} plugin. Could not install it in wp-admin. The original error was: ${s}`
@@ -1471,7 +1491,7 @@ class Z extends EventTarget {
1471
1491
  }
1472
1492
  }
1473
1493
  }
1474
- async function qe(t, e) {
1494
+ async function De(t, e) {
1475
1495
  e?.loadRemote && (t.src = e?.loadRemote, await new Promise((r) => {
1476
1496
  t.addEventListener("load", r, !1);
1477
1497
  }));
@@ -1480,12 +1500,12 @@ async function qe(t, e) {
1480
1500
  }
1481
1501
  export {
1482
1502
  Le as activatePlugin,
1483
- qe as connectPlayground,
1503
+ De as connectPlayground,
1484
1504
  ke as exportFile,
1485
1505
  Oe as importFile,
1486
- Se as installPlugin,
1506
+ _e as installPlugin,
1487
1507
  Ie as installPluginsFromDirectory,
1488
- Re as installTheme,
1508
+ Se as installTheme,
1489
1509
  Ue as installThemeFromDirectory,
1490
1510
  Ae as login
1491
1511
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wp-playground/client",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "description": "WordPress Playground client",
5
5
  "repository": {
6
6
  "type": "git",
@@ -29,5 +29,5 @@
29
29
  "type": "module",
30
30
  "main": "index.js",
31
31
  "types": "index.d.ts",
32
- "gitHead": "2de8f9182b249b7e87694efaa06e7f25b64b7bb3"
32
+ "gitHead": "ce0d93a79ad524677200b7e956ae1543d774696e"
33
33
  }