@php-wasm/web 0.1.20 → 0.1.23

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.
@@ -300,7 +300,7 @@ class ee {
300
300
  method: e.method || s,
301
301
  body: o,
302
302
  fileInfos: a,
303
- scriptPath: this.#h(r.pathname),
303
+ scriptPath: this.#d(r.pathname),
304
304
  headers: {
305
305
  ...i,
306
306
  ...e.headers || {}
@@ -318,7 +318,7 @@ class ee {
318
318
  * @param requestedPath - The requested pathname.
319
319
  * @returns The resolved filesystem path.
320
320
  */
321
- #h(e) {
321
+ #d(e) {
322
322
  let r = M(e, this.#n);
323
323
  r.includes(".php") ? r = r.split(".php")[0] + ".php" : (r.endsWith("/") || (r += "/"), r.endsWith("index.php") || (r += "index.php"));
324
324
  const n = `${this.#e}${r}`;
@@ -468,7 +468,7 @@ var re = Object.defineProperty, ne = Object.getOwnPropertyDescriptor, g = (t, e,
468
468
  (i = t[a]) && (s = (n ? i(e, r, s) : i(s)) || s);
469
469
  return n && s && re(e, r, s), s;
470
470
  };
471
- const d = "string", w = "number", x = [], se = function() {
471
+ const h = "string", w = "number", x = [], se = function() {
472
472
  return typeof window < "u" && !{}.TEST ? "WEB" : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? "WORKER" : "NODE";
473
473
  }();
474
474
  class m {
@@ -525,8 +525,8 @@ class m {
525
525
  };
526
526
  if (this.#o(r, e.protocol || "http"), this.#c(n), e.body && this.#l(e.body), e.fileInfos)
527
527
  for (const s of e.fileInfos)
528
- this.#h(s);
529
- return e.code && this.#d(" ?>" + e.code), await this.#f();
528
+ this.#d(s);
529
+ return e.code && this.#h(" ?>" + e.code), await this.#f();
530
530
  }
531
531
  #s() {
532
532
  if (this.#t.length > 0) {
@@ -537,7 +537,7 @@ class m {
537
537
  this.#e.ccall(
538
538
  "wasm_set_phpini_entries",
539
539
  null,
540
- [d],
540
+ [h],
541
541
  [e]
542
542
  );
543
543
  }
@@ -545,7 +545,7 @@ class m {
545
545
  }
546
546
  cli(e) {
547
547
  for (const r of e)
548
- this.#e.ccall("wasm_add_cli_arg", null, [d], [r]);
548
+ this.#e.ccall("wasm_add_cli_arg", null, [h], [r]);
549
549
  return this.#e.ccall("run_cli", null, [], [], { async: !0 });
550
550
  }
551
551
  #i() {
@@ -567,18 +567,18 @@ class m {
567
567
  };
568
568
  }
569
569
  #n(e) {
570
- if (this.#e.ccall("wasm_set_request_uri", null, [d], [e]), e.includes("?")) {
570
+ if (this.#e.ccall("wasm_set_request_uri", null, [h], [e]), e.includes("?")) {
571
571
  const r = e.substring(e.indexOf("?") + 1);
572
572
  this.#e.ccall(
573
573
  "wasm_set_query_string",
574
574
  null,
575
- [d],
575
+ [h],
576
576
  [r]
577
577
  );
578
578
  }
579
579
  }
580
580
  #o(e, r) {
581
- this.#e.ccall("wasm_set_request_host", null, [d], [e]);
581
+ this.#e.ccall("wasm_set_request_host", null, [h], [e]);
582
582
  let n;
583
583
  try {
584
584
  n = parseInt(new URL(e).port, 10);
@@ -587,7 +587,7 @@ class m {
587
587
  (!n || isNaN(n) || n === 80) && (n = r === "https" ? 443 : 80), this.#e.ccall("wasm_set_request_port", null, [w], [n]), (r === "https" || !r && n === 443) && this.addServerGlobalEntry("HTTPS", "on");
588
588
  }
589
589
  #a(e) {
590
- this.#e.ccall("wasm_set_request_method", null, [d], [e]);
590
+ this.#e.ccall("wasm_set_request_method", null, [h], [e]);
591
591
  }
592
592
  setSkipShebang(e) {
593
593
  this.#e.ccall(
@@ -601,12 +601,12 @@ class m {
601
601
  e.cookie && this.#e.ccall(
602
602
  "wasm_set_cookies",
603
603
  null,
604
- [d],
604
+ [h],
605
605
  [e.cookie]
606
606
  ), e["content-type"] && this.#e.ccall(
607
607
  "wasm_set_content_type",
608
608
  null,
609
- [d],
609
+ [h],
610
610
  [e["content-type"]]
611
611
  ), e["content-length"] && this.#e.ccall(
612
612
  "wasm_set_content_length",
@@ -621,7 +621,7 @@ class m {
621
621
  );
622
622
  }
623
623
  #l(e) {
624
- this.#e.ccall("wasm_set_request_body", null, [d], [e]), this.#e.ccall(
624
+ this.#e.ccall("wasm_set_request_body", null, [h], [e]), this.#e.ccall(
625
625
  "wasm_set_content_length",
626
626
  null,
627
627
  [w],
@@ -629,13 +629,13 @@ class m {
629
629
  );
630
630
  }
631
631
  #u(e) {
632
- this.#e.ccall("wasm_set_path_translated", null, [d], [e]);
632
+ this.#e.ccall("wasm_set_path_translated", null, [h], [e]);
633
633
  }
634
634
  addServerGlobalEntry(e, r) {
635
635
  this.#e.ccall(
636
636
  "wasm_add_SERVER_entry",
637
637
  null,
638
- [d, d],
638
+ [h, h],
639
639
  [e, r]
640
640
  );
641
641
  }
@@ -648,19 +648,19 @@ class m {
648
648
  *
649
649
  * @param fileInfo - File details
650
650
  */
651
- #h(e) {
651
+ #d(e) {
652
652
  const { key: r, name: n, type: s, data: a } = e, i = `/tmp/${Math.random().toFixed(20)}`;
653
653
  this.writeFile(i, a);
654
654
  const o = 0;
655
655
  this.#e.ccall(
656
656
  "wasm_add_uploaded_file",
657
657
  null,
658
- [d, d, d, d, w, w],
658
+ [h, h, h, h, w, w],
659
659
  [r, n, s, i, o, a.byteLength]
660
660
  );
661
661
  }
662
- #d(e) {
663
- this.#e.ccall("wasm_set_php_code", null, [d], [e]);
662
+ #h(e) {
663
+ this.#e.ccall("wasm_set_php_code", null, [h], [e]);
664
664
  }
665
665
  async #f() {
666
666
  const e = await await this.#e.ccall(
@@ -824,7 +824,7 @@ const D = Symbol("Comlink.proxy"), ae = Symbol("Comlink.endpoint"), ce = Symbol(
824
824
  ["proxy", le],
825
825
  ["throw", ue]
826
826
  ]);
827
- function he(t, e) {
827
+ function de(t, e) {
828
828
  for (const r of t)
829
829
  if (e === r || r === "*" || r instanceof RegExp && r.test(e))
830
830
  return !0;
@@ -834,7 +834,7 @@ function F(t, e = globalThis, r = ["*"]) {
834
834
  e.addEventListener("message", function n(s) {
835
835
  if (!s || !s.data)
836
836
  return;
837
- if (!he(r, s.origin)) {
837
+ if (!de(r, s.origin)) {
838
838
  console.warn(`Invalid origin '${s.origin}' for comlink proxy`);
839
839
  return;
840
840
  }
@@ -885,11 +885,11 @@ function F(t, e = globalThis, r = ["*"]) {
885
885
  });
886
886
  }), e.start && e.start();
887
887
  }
888
- function de(t) {
888
+ function he(t) {
889
889
  return t.constructor.name === "MessagePort";
890
890
  }
891
891
  function $(t) {
892
- de(t) && t.close();
892
+ he(t) && t.close();
893
893
  }
894
894
  function L(t, e) {
895
895
  return H(t, [], e);
@@ -1170,11 +1170,11 @@ class A extends m {
1170
1170
  };
1171
1171
  }
1172
1172
  }
1173
- const h = /* @__PURE__ */ new WeakMap();
1173
+ const d = /* @__PURE__ */ new WeakMap();
1174
1174
  class xe {
1175
1175
  /** @inheritDoc */
1176
1176
  constructor(e, r) {
1177
- h.set(this, {
1177
+ d.set(this, {
1178
1178
  php: e,
1179
1179
  monitor: r
1180
1180
  }), this.absoluteUrl = Promise.resolve(
@@ -1185,70 +1185,70 @@ class xe {
1185
1185
  }
1186
1186
  /** @inheritDoc @php-wasm/web!PHPRequestHandler.pathToInternalUrl */
1187
1187
  async pathToInternalUrl(e) {
1188
- return h.get(this).php.requestHandler.server.pathToInternalUrl(e);
1188
+ return d.get(this).php.requestHandler.server.pathToInternalUrl(e);
1189
1189
  }
1190
1190
  /** @inheritDoc @php-wasm/web!PHPRequestHandler.internalUrlToPath */
1191
1191
  async internalUrlToPath(e) {
1192
- return h.get(this).php.requestHandler.server.internalUrlToPath(e);
1192
+ return d.get(this).php.requestHandler.server.internalUrlToPath(e);
1193
1193
  }
1194
1194
  async onDownloadProgress(e) {
1195
- h.get(this).monitor?.addEventListener("progress", e);
1195
+ d.get(this).monitor?.addEventListener("progress", e);
1196
1196
  }
1197
1197
  /** @inheritDoc @php-wasm/web!PHPRequestHandler.request */
1198
1198
  request(e, r) {
1199
- return h.get(this).php.request(e, r);
1199
+ return d.get(this).php.request(e, r);
1200
1200
  }
1201
1201
  /** @inheritDoc @php-wasm/web!PHP.run */
1202
1202
  async run(e) {
1203
- return h.get(this).php.run(e);
1203
+ return d.get(this).php.run(e);
1204
1204
  }
1205
1205
  /** @inheritDoc @php-wasm/web!PHP.chdir */
1206
1206
  chdir(e) {
1207
- return h.get(this).php.chdir(e);
1207
+ return d.get(this).php.chdir(e);
1208
1208
  }
1209
1209
  /** @inheritDoc @php-wasm/web!PHP.setPhpIniPath */
1210
1210
  setPhpIniPath(e) {
1211
- return h.get(this).php.setPhpIniPath(e);
1211
+ return d.get(this).php.setPhpIniPath(e);
1212
1212
  }
1213
1213
  /** @inheritDoc @php-wasm/web!PHP.setPhpIniEntry */
1214
1214
  setPhpIniEntry(e, r) {
1215
- h.get(this).php.setPhpIniEntry(e, r);
1215
+ d.get(this).php.setPhpIniEntry(e, r);
1216
1216
  }
1217
1217
  /** @inheritDoc @php-wasm/web!PHP.mkdir */
1218
1218
  mkdir(e) {
1219
- h.get(this).php.mkdir(e);
1219
+ d.get(this).php.mkdir(e);
1220
1220
  }
1221
1221
  /** @inheritDoc @php-wasm/web!PHP.mkdirTree */
1222
1222
  mkdirTree(e) {
1223
- h.get(this).php.mkdirTree(e);
1223
+ d.get(this).php.mkdirTree(e);
1224
1224
  }
1225
1225
  /** @inheritDoc @php-wasm/web!PHP.readFileAsText */
1226
1226
  async readFileAsText(e) {
1227
- return h.get(this).php.readFileAsText(e);
1227
+ return d.get(this).php.readFileAsText(e);
1228
1228
  }
1229
1229
  /** @inheritDoc @php-wasm/web!PHP.readFileAsBuffer */
1230
1230
  async readFileAsBuffer(e) {
1231
- return h.get(this).php.readFileAsBuffer(e);
1231
+ return d.get(this).php.readFileAsBuffer(e);
1232
1232
  }
1233
1233
  /** @inheritDoc @php-wasm/web!PHP.writeFile */
1234
1234
  writeFile(e, r) {
1235
- h.get(this).php.writeFile(e, r);
1235
+ d.get(this).php.writeFile(e, r);
1236
1236
  }
1237
1237
  /** @inheritDoc @php-wasm/web!PHP.unlink */
1238
1238
  unlink(e) {
1239
- h.get(this).php.unlink(e);
1239
+ d.get(this).php.unlink(e);
1240
1240
  }
1241
1241
  /** @inheritDoc @php-wasm/web!PHP.listFiles */
1242
1242
  async listFiles(e) {
1243
- return h.get(this).php.listFiles(e);
1243
+ return d.get(this).php.listFiles(e);
1244
1244
  }
1245
1245
  /** @inheritDoc @php-wasm/web!PHP.isDir */
1246
1246
  async isDir(e) {
1247
- return h.get(this).php.isDir(e);
1247
+ return d.get(this).php.isDir(e);
1248
1248
  }
1249
1249
  /** @inheritDoc @php-wasm/web!PHP.fileExists */
1250
1250
  async fileExists(e) {
1251
- return h.get(this).php.fileExists(e);
1251
+ return d.get(this).php.fileExists(e);
1252
1252
  }
1253
1253
  }
1254
1254
  function Pe(t, e) {
@@ -1310,7 +1310,7 @@ function Te() {
1310
1310
  }), t;
1311
1311
  }
1312
1312
  const Ce = function() {
1313
- return navigator.userAgent.toLowerCase().indexOf("firefox") > -1 ? "iframe" : "webworker";
1313
+ return typeof navigator < "u" && navigator?.userAgent?.toLowerCase().indexOf("firefox") > -1 ? "iframe" : "webworker";
1314
1314
  }();
1315
1315
  async function Fe(t, e = "webworker", r = {}) {
1316
1316
  if (t = Ee(t, r), e === "webworker")
package/package.json CHANGED
@@ -1,33 +1,38 @@
1
1
  {
2
- "name": "@php-wasm/web",
3
- "version": "0.1.20",
4
- "description": "PHP.wasm for the web",
5
- "repository": {
6
- "type": "git",
7
- "url": "https://github.com/WordPress/wordpress-playground"
8
- },
9
- "homepage": "https://developer.wordpress.org/playground",
10
- "author": "The WordPress contributors",
11
- "contributors": [
12
- {
13
- "name": "Adam Zielinski",
14
- "email": "adam@adamziel.com",
15
- "url": "https://github.com/adamziel"
16
- }
17
- ],
18
- "typedoc": {
19
- "entryPoint": "./src/index.ts",
20
- "readmeFile": "./README.md",
21
- "displayName": "@php-wasm/web",
22
- "tsconfig": "./tsconfig.lib.json"
23
- },
24
- "publishConfig": {
25
- "access": "public",
26
- "directory": "../../../dist/packages/php-wasm/web"
27
- },
28
- "license": "(GPL-2.0-or-later OR MPL-2.0)",
29
- "type": "module",
30
- "main": "index.js",
31
- "types": "index.d.ts",
32
- "gitHead": "bbe56ef04fa9740506efed428ef8c89de7223d96"
2
+ "name": "@php-wasm/web",
3
+ "version": "0.1.23",
4
+ "description": "PHP.wasm for the web",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/WordPress/wordpress-playground"
8
+ },
9
+ "homepage": "https://developer.wordpress.org/playground",
10
+ "author": "The WordPress contributors",
11
+ "contributors": [
12
+ {
13
+ "name": "Adam Zielinski",
14
+ "email": "adam@adamziel.com",
15
+ "url": "https://github.com/adamziel"
16
+ }
17
+ ],
18
+ "typedoc": {
19
+ "entryPoint": "./src/index.ts",
20
+ "readmeFile": "./README.md",
21
+ "displayName": "@php-wasm/web",
22
+ "tsconfig": "./tsconfig.lib.json"
23
+ },
24
+ "publishConfig": {
25
+ "access": "public",
26
+ "directory": "../../../dist/packages/php-wasm/web"
27
+ },
28
+ "license": "(GPL-2.0-or-later OR MPL-2.0)",
29
+ "type": "module",
30
+ "main": "index.js",
31
+ "types": "index.d.ts",
32
+ "gitHead": "f266abc85340fffde571d974921fbd1da6b51ffb",
33
+ "dependencies": {
34
+ "comlink": "4.4.1",
35
+ "@php-wasm/progress": "0.1.18",
36
+ "@php-wasm/web-service-worker": "0.1.19"
37
+ }
33
38
  }