@php-wasm/web 3.1.21 → 3.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,12 +1,13 @@
1
- import { LatestSupportedPHPVersion as V, FSHelpers as L, isLegacyPHPVersion as ge, createLegacyPhpIniPreRunStep as Ie, loadPHPRuntime as Ke, __private__dont__use as O } from "@php-wasm/universal";
2
- import { consumeAPI as Dt, exposeAPI as Wt } from "@php-wasm/universal";
3
- import { concatArrayBuffers as v, concatUint8Arrays as H, Semaphore as De, joinPaths as oe, basename as We } from "@php-wasm/util";
4
- import { logger as U } from "@php-wasm/logger";
5
- import { fetchWithCorsProxy as Pe } from "@php-wasm/web-service-worker";
6
- import { FirewallInterferenceError as bt, fetchWithCorsProxy as Rt } from "@php-wasm/web-service-worker";
7
- import { createMemoizedFetch as be } from "@wp-playground/common";
8
- import { journalFSEvents as Re, normalizeFilesystemOperations as Be } from "@php-wasm/fs-journal";
9
- async function Ue(i = V) {
1
+ import { LatestSupportedPHPVersion as oe, withResolvedPHPExtensions as Ie, resolvePHPExtension as Y, isLegacyPHPVersion as Ke, createLegacyPhpIniPreRunStep as De, loadPHPRuntime as We, FSHelpers as M, __private__dont__use as O } from "@php-wasm/universal";
2
+ import { consumeAPI as Ut, exposeAPI as vt } from "@php-wasm/universal";
3
+ import { concatArrayBuffers as v, concatUint8Arrays as H, Semaphore as Pe, joinPaths as ce, basename as be } from "@php-wasm/util";
4
+ import { logger as B } from "@php-wasm/logger";
5
+ import { fetchWithCorsProxy as Re } from "@php-wasm/web-service-worker";
6
+ import { FirewallInterferenceError as xt, fetchWithCorsProxy as Nt } from "@php-wasm/web-service-worker";
7
+ import { createMemoizedFetch as Be } from "@wp-playground/common";
8
+ import { jspi as Ue } from "wasm-feature-detect";
9
+ import { journalFSEvents as ve, normalizeFilesystemOperations as Me } from "@php-wasm/fs-journal";
10
+ async function xe(i = oe) {
10
11
  switch (i) {
11
12
  case "8.5":
12
13
  return (await import("@php-wasm/web-8-5")).getPHPLoaderModule();
@@ -30,7 +31,7 @@ async function Ue(i = V) {
30
31
  function p(i) {
31
32
  return Object.fromEntries(Object.entries(i).map(([e, t]) => [t, e]));
32
33
  }
33
- function W(i) {
34
+ function D(i) {
34
35
  return new Uint8Array([i >> 8 & 255, i & 255]);
35
36
  }
36
37
  function m(i) {
@@ -44,7 +45,7 @@ function Z(i) {
44
45
  const e = new ArrayBuffer(8);
45
46
  return new DataView(e).setBigUint64(0, BigInt(i), !1), new Uint8Array(e);
46
47
  }
47
- class I {
48
+ class g {
48
49
  constructor(e) {
49
50
  this.offset = 0, this.buffer = e, this.view = new DataView(e);
50
51
  }
@@ -85,7 +86,7 @@ class N {
85
86
  this.uint8Array.set(e, this.offset), this.offset += e.length;
86
87
  }
87
88
  }
88
- const P = {
89
+ const W = {
89
90
  server_name: 0,
90
91
  max_fragment_length: 1,
91
92
  client_certificate_url: 2,
@@ -140,10 +141,10 @@ const P = {
140
141
  transparency_info: 52,
141
142
  connection_id: 54,
142
143
  renegotiation_info: 65281
143
- }, xe = p(P), ce = {
144
+ }, Ne = p(W), Se = {
144
145
  host_name: 0
145
- }, ve = p(ce);
146
- class Se {
146
+ }, ke = p(Se);
147
+ class Ce {
147
148
  static decodeFromClient(e) {
148
149
  const t = new DataView(e.buffer);
149
150
  let n = 0;
@@ -155,13 +156,13 @@ class Se {
155
156
  n += 1;
156
157
  const _ = t.getUint16(n);
157
158
  n += 2;
158
- const S = e.slice(n, n + _);
159
+ const c = e.slice(n, n + _);
159
160
  switch (n += _, a) {
160
- case ce.host_name:
161
+ case Se.host_name:
161
162
  s.push({
162
- name_type: ve[a],
163
+ name_type: ke[a],
163
164
  name: {
164
- host_name: new TextDecoder().decode(S)
165
+ host_name: new TextDecoder().decode(c)
165
166
  }
166
167
  });
167
168
  break;
@@ -188,15 +189,15 @@ class Se {
188
189
  "Encoding non-empty lists for ClientHello is not supported yet. Only empty lists meant for ServerHello are supported today."
189
190
  );
190
191
  const t = new N(4);
191
- return t.writeUint16(P.server_name), t.writeUint16(0), t.uint8Array;
192
+ return t.writeUint16(W.server_name), t.writeUint16(0), t.uint8Array;
192
193
  }
193
194
  }
194
- const Ce = {
195
+ const le = {
195
196
  uncompressed: 0,
196
197
  ansiX962_compressed_prime: 1,
197
198
  ansiX962_compressed_char2: 2
198
- }, X = p(Ce);
199
- class le {
199
+ }, X = p(le);
200
+ class he {
200
201
  /**
201
202
  * +--------------------------------------------------+
202
203
  * | Payload Length [2B] |
@@ -213,7 +214,7 @@ class le {
213
214
  * +--------------------------------------------------+
214
215
  */
215
216
  static decodeFromClient(e) {
216
- const t = new I(e.buffer), n = t.readUint8(), r = [];
217
+ const t = new g(e.buffer), n = t.readUint8(), r = [];
217
218
  for (let s = 0; s < n; s++) {
218
219
  const a = t.readUint8();
219
220
  a in X && r.push(X[a]);
@@ -236,10 +237,10 @@ class le {
236
237
  */
237
238
  static encodeForClient(e) {
238
239
  const t = new N(6);
239
- return t.writeUint16(P.ec_point_formats), t.writeUint16(2), t.writeUint8(1), t.writeUint8(Ce[e]), t.uint8Array;
240
+ return t.writeUint16(W.ec_point_formats), t.writeUint16(2), t.writeUint8(1), t.writeUint8(le[e]), t.uint8Array;
240
241
  }
241
242
  }
242
- const he = {
243
+ const Ae = {
243
244
  decodeFromClient(i) {
244
245
  const e = i[0] ?? 0;
245
246
  return {
@@ -251,7 +252,7 @@ const he = {
251
252
  * with an empty renegotiated_connection field.
252
253
  */
253
254
  encodeForClient() {
254
- const i = P.renegotiation_info, e = new Uint8Array([0]);
255
+ const i = W.renegotiation_info, e = new Uint8Array([0]);
255
256
  return new Uint8Array([
256
257
  i >> 8 & 255,
257
258
  i & 255,
@@ -260,7 +261,7 @@ const he = {
260
261
  ...e
261
262
  ]);
262
263
  }
263
- }, Ae = {
264
+ }, ue = {
264
265
  TLS1_CK_PSK_WITH_RC4_128_SHA: 138,
265
266
  TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA: 139,
266
267
  TLS1_CK_PSK_WITH_AES_128_CBC_SHA: 140,
@@ -463,14 +464,14 @@ const he = {
463
464
  TLS1_CK_ECDHE_PSK_WITH_CHACHA20_POLY1305: 52396,
464
465
  TLS1_CK_DHE_PSK_WITH_CHACHA20_POLY1305: 52397,
465
466
  TLS1_CK_RSA_PSK_WITH_CHACHA20_POLY1305: 52398
466
- }, J = p(Ae), ue = {
467
+ }, J = p(ue), He = {
467
468
  secp256r1: 23,
468
469
  secp384r1: 24,
469
470
  secp521r1: 25,
470
471
  x25519: 29,
471
472
  x448: 30
472
- }, Q = p(ue);
473
- class Me {
473
+ }, Q = p(He);
474
+ class Fe {
474
475
  /**
475
476
  * +--------------------------------------------------+
476
477
  * | Payload Length [2B] |
@@ -487,7 +488,7 @@ class Me {
487
488
  * +--------------------------------------------------+
488
489
  */
489
490
  static decodeFromClient(e) {
490
- const t = new I(e.buffer);
491
+ const t = new g(e.buffer);
491
492
  t.readUint16();
492
493
  const n = [];
493
494
  for (; !t.isFinished(); ) {
@@ -508,15 +509,15 @@ class Me {
508
509
  */
509
510
  static encodeForClient(e) {
510
511
  const t = new N(6);
511
- return t.writeUint16(P.supported_groups), t.writeUint16(2), t.writeUint16(ue[e]), t.uint8Array;
512
+ return t.writeUint16(W.supported_groups), t.writeUint16(2), t.writeUint16(He[e]), t.uint8Array;
512
513
  }
513
514
  }
514
- const z = {
515
+ const V = {
515
516
  anonymous: 0,
516
517
  rsa: 1,
517
518
  dsa: 2,
518
519
  ecdsa: 3
519
- }, ee = p(z), Y = {
520
+ }, ee = p(V), z = {
520
521
  none: 0,
521
522
  md5: 1,
522
523
  sha1: 2,
@@ -524,8 +525,8 @@ const z = {
524
525
  sha256: 4,
525
526
  sha384: 5,
526
527
  sha512: 6
527
- }, te = p(Y);
528
- class Ne {
528
+ }, te = p(z);
529
+ class qe {
529
530
  /**
530
531
  * Binary layout:
531
532
  *
@@ -542,14 +543,14 @@ class Ne {
542
543
  * +------------------------------------+
543
544
  */
544
545
  static decodeFromClient(e) {
545
- const t = new I(e.buffer);
546
+ const t = new g(e.buffer);
546
547
  t.readUint16();
547
548
  const n = [];
548
549
  for (; !t.isFinished(); ) {
549
550
  const r = t.readUint8(), s = t.readUint8();
550
551
  if (ee[s]) {
551
552
  if (!te[r]) {
552
- U.warn(`Unknown hash algorithm: ${r}`);
553
+ B.warn(`Unknown hash algorithm: ${r}`);
553
554
  continue;
554
555
  }
555
556
  n.push({
@@ -573,26 +574,26 @@ class Ne {
573
574
  */
574
575
  static encodeforClient(e, t) {
575
576
  const n = new N(6);
576
- return n.writeUint16(P.signature_algorithms), n.writeUint16(2), n.writeUint8(Y[e]), n.writeUint8(z[t]), n.uint8Array;
577
+ return n.writeUint16(W.signature_algorithms), n.writeUint16(2), n.writeUint8(z[e]), n.writeUint8(V[t]), n.uint8Array;
577
578
  }
578
579
  }
579
580
  const ne = {
580
- server_name: Se,
581
- signature_algorithms: Ne,
582
- supported_groups: Me,
583
- ec_point_formats: le,
584
- renegotiation_info: he
581
+ server_name: Ce,
582
+ signature_algorithms: qe,
583
+ supported_groups: Fe,
584
+ ec_point_formats: he,
585
+ renegotiation_info: Ae
585
586
  };
586
- function ke(i) {
587
- const e = new I(i.buffer), t = [];
587
+ function Oe(i) {
588
+ const e = new g(i.buffer), t = [];
588
589
  for (; !e.isFinished(); ) {
589
- const n = e.offset, r = e.readUint16(), s = xe[r], a = e.readUint16(), _ = e.readUint8Array(a);
590
+ const n = e.offset, r = e.readUint16(), s = Ne[r], a = e.readUint16(), _ = e.readUint8Array(a);
590
591
  if (!(s in ne))
591
592
  continue;
592
- const S = ne[s];
593
+ const c = ne[s];
593
594
  t.push({
594
595
  type: s,
595
- data: S.decodeFromClient(_),
596
+ data: c.decodeFromClient(_),
596
597
  raw: i.slice(n, n + 4 + a)
597
598
  });
598
599
  }
@@ -610,7 +611,7 @@ async function G(i, e, t, n) {
610
611
  const _ = [];
611
612
  for (; v(_).byteLength < n; ) {
612
613
  a = await re(s, a);
613
- const c = v([a, r]), C = await re(s, c);
614
+ const S = v([a, r]), C = await re(s, S);
614
615
  _.push(C);
615
616
  }
616
617
  return v(_).slice(0, n);
@@ -622,12 +623,12 @@ async function re(i, e) {
622
623
  e
623
624
  );
624
625
  }
625
- const Fe = {
626
+ const je = {
626
627
  Null: 0
627
- }, He = {
628
+ }, de = {
628
629
  Warning: 1,
629
630
  Fatal: 2
630
- }, de = p(He), fe = {
631
+ }, fe = p(de), Ee = {
631
632
  CloseNotify: 0,
632
633
  UnexpectedMessage: 10,
633
634
  BadRecordMac: 20,
@@ -653,7 +654,7 @@ const Fe = {
653
654
  UserCanceled: 90,
654
655
  NoRenegotiation: 100,
655
656
  UnsupportedExtension: 110
656
- }, Ee = p(fe), l = {
657
+ }, Te = p(Ee), l = {
657
658
  ChangeCipherSpec: 20,
658
659
  Alert: 21,
659
660
  Handshake: 22,
@@ -667,7 +668,7 @@ const Fe = {
667
668
  ServerHelloDone: 14,
668
669
  ClientKeyExchange: 16,
669
670
  Finished: 20
670
- }, qe = {
671
+ }, Ge = {
671
672
  /**
672
673
  * Indicates that a named curve is used. This option
673
674
  * SHOULD be used when applicable.
@@ -676,12 +677,12 @@ const Fe = {
676
677
  /**
677
678
  * Values 248 through 255 are reserved for private use.
678
679
  */
679
- }, Oe = {
680
+ }, $e = {
680
681
  secp256r1: 23
681
682
  };
682
683
  class j extends Error {
683
684
  }
684
- const M = new Uint8Array([3, 3]), je = crypto.subtle.generateKey(
685
+ const x = new Uint8Array([3, 3]), Ve = crypto.subtle.generateKey(
685
686
  {
686
687
  name: "ECDH",
687
688
  namedCurve: "P-256"
@@ -692,7 +693,7 @@ const M = new Uint8Array([3, 3]), je = crypto.subtle.generateKey(
692
693
  ["deriveKey", "deriveBits"]
693
694
  // Key usage
694
695
  );
695
- class Ge {
696
+ class ze {
696
697
  constructor() {
697
698
  this.receivedRecordSequenceNumber = 0, this.sentRecordSequenceNumber = 0, this.closed = !1, this.receivedBytesBuffer = new Uint8Array(), this.receivedTLSRecords = [], this.partialTLSMessages = {}, this.handshakeMessages = [], this.MAX_CHUNK_SIZE = 1024 * 16, this.clientEnd = {
698
699
  // We don't need to chunk the encrypted data.
@@ -709,7 +710,7 @@ class Ge {
709
710
  * This will spread some messages across multiple records,
710
711
  * but TLS supports it so that's fine.
711
712
  */
712
- downstream: $e(this.MAX_CHUNK_SIZE)
713
+ downstream: Ye(this.MAX_CHUNK_SIZE)
713
714
  }, this.serverUpstreamWriter = this.serverEnd.upstream.writable.getWriter();
714
715
  const e = this;
715
716
  this.serverEnd.downstream.readable.pipeTo(
@@ -775,16 +776,16 @@ class Ge {
775
776
  const r = crypto.getRandomValues(new Uint8Array(32));
776
777
  await this.writeTLSRecord(
777
778
  l.Handshake,
778
- D.serverHello(
779
+ K.serverHello(
779
780
  n.body,
780
781
  r,
781
- Fe.Null
782
+ je.Null
782
783
  )
783
784
  ), await this.writeTLSRecord(
784
785
  l.Handshake,
785
- D.certificate(t)
786
+ K.certificate(t)
786
787
  );
787
- const s = await je, a = n.body.random, _ = await D.ECDHEServerKeyExchange(
788
+ const s = await Ve, a = n.body.random, _ = await K.ECDHEServerKeyExchange(
788
789
  a,
789
790
  r,
790
791
  s,
@@ -792,9 +793,9 @@ class Ge {
792
793
  );
793
794
  await this.writeTLSRecord(l.Handshake, _), await this.writeTLSRecord(
794
795
  l.Handshake,
795
- D.serverHelloDone()
796
+ K.serverHelloDone()
796
797
  );
797
- const S = await this.readNextHandshakeMessage(
798
+ const c = await this.readNextHandshakeMessage(
798
799
  f.ClientKeyExchange
799
800
  );
800
801
  await this.readNextMessage(l.ChangeCipherSpec), this.sessionKeys = await this.deriveSessionKeys({
@@ -803,17 +804,17 @@ class Ge {
803
804
  serverPrivateKey: s.privateKey,
804
805
  clientPublicKey: await crypto.subtle.importKey(
805
806
  "raw",
806
- S.body.exchange_keys,
807
+ c.body.exchange_keys,
807
808
  { name: "ECDH", namedCurve: "P-256" },
808
809
  !1,
809
810
  []
810
811
  )
811
812
  }), await this.readNextHandshakeMessage(f.Finished), await this.writeTLSRecord(
812
813
  l.ChangeCipherSpec,
813
- D.changeCipherSpec()
814
+ K.changeCipherSpec()
814
815
  ), await this.writeTLSRecord(
815
816
  l.Handshake,
816
- await D.createFinishedMessage(
817
+ await K.createFinishedMessage(
817
818
  this.handshakeMessages,
818
819
  this.sessionKeys.masterSecret
819
820
  )
@@ -850,12 +851,12 @@ class Ge {
850
851
  H([t, e]),
851
852
  // Client key, server key, client IV, server IV
852
853
  40
853
- ), S = new I(_), c = S.readUint8Array(16), C = S.readUint8Array(16), h = S.readUint8Array(4), A = S.readUint8Array(4);
854
+ ), c = new g(_), S = c.readUint8Array(16), C = c.readUint8Array(16), h = c.readUint8Array(4), A = c.readUint8Array(4);
854
855
  return {
855
856
  masterSecret: a,
856
857
  clientWriteKey: await crypto.subtle.importKey(
857
858
  "raw",
858
- c,
859
+ S,
859
860
  { name: "AES-GCM" },
860
861
  !1,
861
862
  ["encrypt", "decrypt"]
@@ -891,9 +892,9 @@ class Ge {
891
892
  async readNextTLSRecord(e) {
892
893
  for (; ; ) {
893
894
  for (let _ = 0; _ < this.receivedTLSRecords.length; _++) {
894
- const S = this.receivedTLSRecords[_];
895
- if (S.type === e)
896
- return this.receivedTLSRecords.splice(_, 1), S;
895
+ const c = this.receivedTLSRecords[_];
896
+ if (c.type === e)
897
+ return this.receivedTLSRecords.splice(_, 1), c;
897
898
  }
898
899
  const t = await this.pollBytes(5), n = t[3] << 8 | t[4], r = t[0], s = await this.pollBytes(n), a = {
899
900
  type: r,
@@ -905,11 +906,11 @@ class Ge {
905
906
  fragment: this.sessionKeys && r !== l.ChangeCipherSpec ? await this.decryptData(r, s) : s
906
907
  };
907
908
  if (a.type === l.Alert) {
908
- const _ = a.fragment[0], S = a.fragment[1], c = de[_], C = Ee[S];
909
- throw _ === He.Warning && S === fe.CloseNotify ? new j(
909
+ const _ = a.fragment[0], c = a.fragment[1], S = fe[_], C = Te[c];
910
+ throw _ === de.Warning && c === Ee.CloseNotify ? new j(
910
911
  "TLS connection closed by peer (CloseNotify)"
911
912
  ) : new Error(
912
- `TLS alert received: ${c} ${C}`
913
+ `TLS alert received: ${S} ${C}`
913
914
  );
914
915
  }
915
916
  this.receivedTLSRecords.push(a);
@@ -964,9 +965,9 @@ class Ge {
964
965
  additionalData: new Uint8Array([
965
966
  ...Z(this.receivedRecordSequenceNumber),
966
967
  e,
967
- ...M,
968
+ ...x,
968
969
  // Payload length without IV and tag
969
- ...W(t.length - 8 - 16)
970
+ ...D(t.length - 8 - 16)
970
971
  ]),
971
972
  tagLength: 128
972
973
  },
@@ -1013,7 +1014,7 @@ class Ge {
1013
1014
  */
1014
1015
  async writeTLSRecord(e, t) {
1015
1016
  e === l.Handshake && this.handshakeMessages.push(t), this.sessionKeys && e !== l.ChangeCipherSpec && (t = await this.encryptData(e, t));
1016
- const n = M, r = t.length, s = new Uint8Array(5);
1017
+ const n = x, r = t.length, s = new Uint8Array(5);
1017
1018
  s[0] = e, s[1] = n[0], s[2] = n[1], s[3] = r >> 8 & 255, s[4] = r & 255;
1018
1019
  const a = H([s, t]);
1019
1020
  this.clientDownstreamWriter.write(a);
@@ -1026,9 +1027,9 @@ class Ge {
1026
1027
  const n = this.sessionKeys.serverIV, r = crypto.getRandomValues(new Uint8Array(8)), s = new Uint8Array([...n, ...r]), a = new Uint8Array([
1027
1028
  ...Z(this.sentRecordSequenceNumber),
1028
1029
  e,
1029
- ...M,
1030
+ ...x,
1030
1031
  // Payload length without IV and tag
1031
- ...W(t.length)
1032
+ ...D(t.length)
1032
1033
  ]), _ = await crypto.subtle.encrypt(
1033
1034
  {
1034
1035
  name: "AES-GCM",
@@ -1084,7 +1085,7 @@ class E {
1084
1085
  * https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4
1085
1086
  */
1086
1087
  static parseCipherSuites(e) {
1087
- const t = new I(e);
1088
+ const t = new g(e);
1088
1089
  t.readUint16();
1089
1090
  const n = [];
1090
1091
  for (; !t.isFinished(); ) {
@@ -1108,8 +1109,8 @@ class E {
1108
1109
  static alert(e) {
1109
1110
  return {
1110
1111
  type: l.Alert,
1111
- level: de[e[0]],
1112
- description: Ee[e[1]]
1112
+ level: fe[e[0]],
1113
+ description: Te[e[1]]
1113
1114
  };
1114
1115
  }
1115
1116
  static clientHandshake(e) {
@@ -1182,7 +1183,7 @@ class E {
1182
1183
  * +------+------+---------------------------+
1183
1184
  */
1184
1185
  static clientHelloPayload(e) {
1185
- const t = new I(e.buffer), n = {
1186
+ const t = new g(e.buffer), n = {
1186
1187
  client_version: t.readUint8Array(2),
1187
1188
  /**
1188
1189
  * Technically this consists of a GMT timestamp
@@ -1201,7 +1202,7 @@ class E {
1201
1202
  a
1202
1203
  );
1203
1204
  const _ = t.readUint16();
1204
- return n.extensions = ke(
1205
+ return n.extensions = Oe(
1205
1206
  t.readUint8Array(_)
1206
1207
  ), n;
1207
1208
  }
@@ -1226,7 +1227,7 @@ class E {
1226
1227
  };
1227
1228
  }
1228
1229
  }
1229
- function $e(i) {
1230
+ function Ye(i) {
1230
1231
  return new TransformStream({
1231
1232
  transform(e, t) {
1232
1233
  for (; e.length > 0; )
@@ -1234,7 +1235,7 @@ function $e(i) {
1234
1235
  }
1235
1236
  });
1236
1237
  }
1237
- class D {
1238
+ class K {
1238
1239
  static certificate(e) {
1239
1240
  const t = [];
1240
1241
  for (const s of e)
@@ -1287,9 +1288,9 @@ class D {
1287
1288
  await crypto.subtle.exportKey("raw", n.publicKey)
1288
1289
  ), a = new Uint8Array([
1289
1290
  // Curve type (1 byte)
1290
- qe.NamedCurve,
1291
+ Ge.NamedCurve,
1291
1292
  // Curve name (2 bytes)
1292
- ...W(Oe.secp256r1),
1293
+ ...D($e.secp256r1),
1293
1294
  // Public key length (1 byte)
1294
1295
  s.byteLength,
1295
1296
  // Public key (65 bytes, uncompressed format)
@@ -1301,14 +1302,14 @@ class D {
1301
1302
  },
1302
1303
  r,
1303
1304
  new Uint8Array([...e, ...t, ...a])
1304
- ), S = new Uint8Array(_), c = new Uint8Array([
1305
- Y.sha256,
1306
- z.rsa
1305
+ ), c = new Uint8Array(_), S = new Uint8Array([
1306
+ z.sha256,
1307
+ V.rsa
1307
1308
  ]), C = new Uint8Array([
1308
1309
  ...a,
1309
- ...c,
1310
- ...W(S.length),
1311
- ...S
1310
+ ...S,
1311
+ ...D(c.length),
1312
+ ...c
1312
1313
  ]);
1313
1314
  return new Uint8Array([
1314
1315
  f.ServerKeyExchange,
@@ -1358,24 +1359,24 @@ class D {
1358
1359
  const r = e.extensions.map((_) => {
1359
1360
  switch (_.type) {
1360
1361
  case "server_name":
1361
- return Se.encodeForClient();
1362
+ return Ce.encodeForClient();
1362
1363
  case "ec_point_formats":
1363
- return le.encodeForClient(
1364
+ return he.encodeForClient(
1364
1365
  "uncompressed"
1365
1366
  );
1366
1367
  case "renegotiation_info":
1367
- return he.encodeForClient();
1368
+ return Ae.encodeForClient();
1368
1369
  }
1369
1370
  }).filter((_) => _ !== void 0), s = H(r), a = new Uint8Array([
1370
1371
  // Version field – 0x03, 0x03 means TLS 1.2
1371
- ...M,
1372
+ ...x,
1372
1373
  ...t,
1373
1374
  e.session_id.length,
1374
1375
  ...e.session_id,
1375
- ...W(Ae.TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256),
1376
+ ...D(ue.TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256),
1376
1377
  n,
1377
1378
  // Extensions length (2 bytes)
1378
- ...W(s.length),
1379
+ ...D(s.length),
1379
1380
  ...s
1380
1381
  ]);
1381
1382
  return new Uint8Array([
@@ -1428,25 +1429,25 @@ class D {
1428
1429
  return new Uint8Array([1]);
1429
1430
  }
1430
1431
  }
1431
- function Ve(i, e) {
1432
- return ze.generateCertificate(i, e);
1432
+ function Ze(i, e) {
1433
+ return Xe.generateCertificate(i, e);
1433
1434
  }
1434
- function Tt(i) {
1435
+ function gt(i) {
1435
1436
  return `-----BEGIN CERTIFICATE-----
1436
- ${pe(
1437
- Te(i.buffer)
1437
+ ${we(
1438
+ pe(i.buffer)
1438
1439
  )}
1439
1440
  -----END CERTIFICATE-----`;
1440
1441
  }
1441
- async function pt(i) {
1442
+ async function It(i) {
1442
1443
  const e = await crypto.subtle.exportKey("pkcs8", i);
1443
1444
  return `-----BEGIN PRIVATE KEY-----
1444
- ${pe(
1445
- Te(e)
1445
+ ${we(
1446
+ pe(e)
1446
1447
  )}
1447
1448
  -----END PRIVATE KEY-----`;
1448
1449
  }
1449
- class ze {
1450
+ class Xe {
1450
1451
  static async generateCertificate(e, t) {
1451
1452
  const n = await crypto.subtle.generateKey(
1452
1453
  {
@@ -1552,7 +1553,7 @@ class ze {
1552
1553
  d.UTCTime,
1553
1554
  new TextEncoder().encode(
1554
1555
  ie(
1555
- (e == null ? void 0 : e.notAfter) ?? Ze(/* @__PURE__ */ new Date(), 10)
1556
+ (e == null ? void 0 : e.notAfter) ?? Qe(/* @__PURE__ */ new Date(), 10)
1556
1557
  )
1557
1558
  )
1558
1559
  )
@@ -1603,11 +1604,11 @@ class ze {
1603
1604
  static subjectAltName(e) {
1604
1605
  var s, a;
1605
1606
  const t = ((s = e.dnsNames) == null ? void 0 : s.map((_) => {
1606
- const S = o.ia5String(_);
1607
- return o.contextSpecific(2, S);
1607
+ const c = o.ia5String(_);
1608
+ return o.contextSpecific(2, c);
1608
1609
  })) || [], n = ((a = e.ipAddresses) == null ? void 0 : a.map((_) => {
1609
- const S = o.ia5String(_);
1610
- return o.contextSpecific(7, S);
1610
+ const c = o.ia5String(_);
1611
+ return o.contextSpecific(7, c);
1611
1612
  })) || [], r = o.octetString(
1612
1613
  o.sequence([...t, ...n])
1613
1614
  );
@@ -1618,7 +1619,7 @@ class ze {
1618
1619
  ]);
1619
1620
  }
1620
1621
  }
1621
- const Ye = {
1622
+ const Je = {
1622
1623
  // Algorithm OIDs
1623
1624
  "1.2.840.113549.1.1.1": "rsaEncryption",
1624
1625
  "1.2.840.113549.1.1.4": "md5WithRSAEncryption",
@@ -1729,7 +1730,7 @@ const Ye = {
1729
1730
  "1.3.6.1.5.5.7.3.8": "timeStamping"
1730
1731
  };
1731
1732
  function w(i) {
1732
- for (const [e, t] of Object.entries(Ye))
1733
+ for (const [e, t] of Object.entries(Je))
1733
1734
  if (t === i)
1734
1735
  return e;
1735
1736
  throw new Error(`OID not found for name: ${i}`);
@@ -1770,9 +1771,12 @@ class o {
1770
1771
  return r[0] = e, r.set(n, 1), r.set(t, 1 + n.length), r;
1771
1772
  }
1772
1773
  static integer(e) {
1773
- if (e[0] > 127) {
1774
- const t = new Uint8Array(e.length + 1);
1775
- t[0] = 0, t.set(e, 1), e = t;
1774
+ let t = 0;
1775
+ for (; t < e.length - 1 && e[t] === 0 && e[t + 1] < 128; )
1776
+ t++;
1777
+ if (t > 0 && (e = e.subarray(t)), e[0] > 127) {
1778
+ const n = new Uint8Array(e.length + 1);
1779
+ n[0] = 0, n.set(e, 1), e = n;
1776
1780
  }
1777
1781
  return o.ASN1(d.Integer, e);
1778
1782
  }
@@ -1794,8 +1798,8 @@ class o {
1794
1798
  do
1795
1799
  _.unshift(a & 127), a >>= 7;
1796
1800
  while (a > 0);
1797
- for (let S = 0; S < _.length - 1; S++)
1798
- _[S] |= 128;
1801
+ for (let c = 0; c < _.length - 1; c++)
1802
+ _[c] |= 128;
1799
1803
  r.push(..._);
1800
1804
  }
1801
1805
  return o.ASN1(d.OID, new Uint8Array(r));
@@ -1829,26 +1833,26 @@ class o {
1829
1833
  );
1830
1834
  }
1831
1835
  }
1832
- function Te(i) {
1836
+ function pe(i) {
1833
1837
  return btoa(String.fromCodePoint(...new Uint8Array(i)));
1834
1838
  }
1835
- function pe(i) {
1839
+ function we(i) {
1836
1840
  var e;
1837
1841
  return ((e = i.match(/.{1,64}/g)) == null ? void 0 : e.join(`
1838
1842
  `)) || i;
1839
1843
  }
1840
1844
  function ie(i) {
1841
- const e = i.getUTCFullYear().toString().substr(2), t = B(i.getUTCMonth() + 1), n = B(i.getUTCDate()), r = B(i.getUTCHours()), s = B(i.getUTCMinutes()), a = B(i.getUTCSeconds());
1845
+ const e = i.getUTCFullYear().toString().substr(2), t = R(i.getUTCMonth() + 1), n = R(i.getUTCDate()), r = R(i.getUTCHours()), s = R(i.getUTCMinutes()), a = R(i.getUTCSeconds());
1842
1846
  return `${e}${t}${n}${r}${s}${a}Z`;
1843
1847
  }
1844
- function B(i) {
1848
+ function R(i) {
1845
1849
  return i.toString().padStart(2, "0");
1846
1850
  }
1847
- function Ze(i, e) {
1851
+ function Qe(i, e) {
1848
1852
  const t = new Date(i);
1849
1853
  return t.setUTCFullYear(t.getUTCFullYear() + e), t;
1850
1854
  }
1851
- class Xe extends TransformStream {
1855
+ class et extends TransformStream {
1852
1856
  constructor() {
1853
1857
  let e = new Uint8Array(0), t = "SCAN_CHUNK_SIZE", n = 0;
1854
1858
  super({
@@ -1859,10 +1863,10 @@ class Xe extends TransformStream {
1859
1863
  return;
1860
1864
  let a = 0;
1861
1865
  for (; a < e.length; ) {
1862
- const c = e[a];
1863
- if (!(c >= 48 && c <= 57 || // 0-9
1864
- c >= 97 && c <= 102 || // a-f
1865
- c >= 65 && c <= 70)) break;
1866
+ const S = e[a];
1867
+ if (!(S >= 48 && S <= 57 || // 0-9
1868
+ S >= 97 && S <= 102 || // a-f
1869
+ S >= 65 && S <= 70)) break;
1866
1870
  a++;
1867
1871
  }
1868
1872
  if (a === 0)
@@ -1876,12 +1880,12 @@ class Xe extends TransformStream {
1876
1880
  );
1877
1881
  const _ = new TextDecoder().decode(
1878
1882
  e.slice(0, a)
1879
- ), S = parseInt(_, 16);
1880
- if (e = e.slice(a + 2), S === 0) {
1883
+ ), c = parseInt(_, 16);
1884
+ if (e = e.slice(a + 2), c === 0) {
1881
1885
  t = "SCAN_FINAL_CHUNK", s.terminate();
1882
1886
  return;
1883
1887
  }
1884
- n = S, t = "SCAN_CHUNK_DATA";
1888
+ n = c, t = "SCAN_CHUNK_DATA";
1885
1889
  } else if (t === "SCAN_CHUNK_DATA") {
1886
1890
  const a = Math.min(
1887
1891
  n,
@@ -1901,7 +1905,7 @@ class Xe extends TransformStream {
1901
1905
  });
1902
1906
  }
1903
1907
  }
1904
- const Je = (i, e) => ({
1908
+ const tt = (i, e) => ({
1905
1909
  ...i,
1906
1910
  websocket: {
1907
1911
  url: (t, n, r) => `ws://playground.internal/?${new URLSearchParams({
@@ -1909,7 +1913,7 @@ const Je = (i, e) => ({
1909
1913
  port: r
1910
1914
  }).toString()}`,
1911
1915
  subprotocol: "binary",
1912
- decorator: () => class extends Qe {
1916
+ decorator: () => class extends nt {
1913
1917
  constructor(t, n) {
1914
1918
  super(t, n, {
1915
1919
  CAroot: e.CAroot,
@@ -1919,7 +1923,7 @@ const Je = (i, e) => ({
1919
1923
  }
1920
1924
  }
1921
1925
  });
1922
- class Qe {
1926
+ class nt {
1923
1927
  constructor(e, t, {
1924
1928
  CAroot: n,
1925
1929
  corsProxyUrl: r,
@@ -1990,7 +1994,7 @@ class Qe {
1990
1994
  switch (this.bufferedBytesFromClient = H([
1991
1995
  this.bufferedBytesFromClient,
1992
1996
  new Uint8Array(e)
1993
- ]), tt(this.port, this.bufferedBytesFromClient)) {
1997
+ ]), st(this.port, this.bufferedBytesFromClient)) {
1994
1998
  case !1:
1995
1999
  return;
1996
2000
  case "other":
@@ -2009,7 +2013,7 @@ class Qe {
2009
2013
  throw new Error(
2010
2014
  "TLS protocol is only supported when the TCPOverFetchWebsocket is instantiated with a CAroot"
2011
2015
  );
2012
- const e = await Ve(
2016
+ const e = await Ze(
2013
2017
  {
2014
2018
  subject: {
2015
2019
  commonName: this.host,
@@ -2019,14 +2023,14 @@ class Qe {
2019
2023
  issuer: this.CAroot.tbsDescription.subject
2020
2024
  },
2021
2025
  this.CAroot.keyPair
2022
- ), t = new Ge();
2026
+ ), t = new ze();
2023
2027
  this.clientUpstream.readable.pipeTo(t.clientEnd.upstream.writable).catch(() => {
2024
2028
  }), t.clientEnd.downstream.readable.pipeTo(this.clientDownstream.writable).catch(() => {
2025
2029
  }), await t.TLSHandshake(e.keyPair.privateKey, [
2026
2030
  e.certificate,
2027
2031
  this.CAroot.certificate
2028
2032
  ]);
2029
- const { request: n, expectsContinue: r } = await g.parseHttpRequest(
2033
+ const { request: n, expectsContinue: r } = await L.parseHttpRequest(
2030
2034
  t.serverEnd.upstream.readable,
2031
2035
  this.host,
2032
2036
  "https"
@@ -2040,7 +2044,7 @@ class Qe {
2040
2044
  ), s.releaseLock();
2041
2045
  }
2042
2046
  try {
2043
- await g.fetchRawResponseBytes(
2047
+ await L.fetchRawResponseBytes(
2044
2048
  n,
2045
2049
  this.corsProxyUrl
2046
2050
  ).pipeTo(t.serverEnd.downstream.writable);
@@ -2048,7 +2052,7 @@ class Qe {
2048
2052
  }
2049
2053
  }
2050
2054
  async fetchOverHTTP() {
2051
- const { request: e, expectsContinue: t } = await g.parseHttpRequest(
2055
+ const { request: e, expectsContinue: t } = await L.parseHttpRequest(
2052
2056
  this.clientUpstream.readable,
2053
2057
  this.host,
2054
2058
  "http"
@@ -2062,7 +2066,7 @@ class Qe {
2062
2066
  ), n.releaseLock();
2063
2067
  }
2064
2068
  try {
2065
- await g.fetchRawResponseBytes(
2069
+ await L.fetchRawResponseBytes(
2066
2070
  e,
2067
2071
  this.corsProxyUrl
2068
2072
  ).pipeTo(this.clientDownstream.writable);
@@ -2073,7 +2077,7 @@ class Qe {
2073
2077
  this.emit("message", { data: new Uint8Array(0) }), this.readyState = this.CLOSING, this.emit("close"), this.readyState = this.CLOSED;
2074
2078
  }
2075
2079
  }
2076
- const et = [
2080
+ const rt = [
2077
2081
  "GET",
2078
2082
  "POST",
2079
2083
  "HEAD",
@@ -2083,7 +2087,7 @@ const et = [
2083
2087
  "PUT",
2084
2088
  "TRACE"
2085
2089
  ];
2086
- function tt(i, e) {
2090
+ function st(i, e) {
2087
2091
  if (e.length < 8)
2088
2092
  return !1;
2089
2093
  if (i === 443 && e[0] === l.Handshake && // TLS versions between 1.0 and 1.2
@@ -2092,11 +2096,11 @@ function tt(i, e) {
2092
2096
  const n = new TextDecoder("latin1", {
2093
2097
  fatal: !0
2094
2098
  }).decode(e);
2095
- return et.some(
2099
+ return rt.some(
2096
2100
  (s) => n.startsWith(s + " ")
2097
2101
  ) ? "http" : "other";
2098
2102
  }
2099
- class g {
2103
+ class L {
2100
2104
  /**
2101
2105
  * Streams a HTTP response including the status line and headers.
2102
2106
  */
@@ -2106,12 +2110,12 @@ class g {
2106
2110
  var _;
2107
2111
  let r;
2108
2112
  try {
2109
- r = await Pe(
2113
+ r = await Re(
2110
2114
  e,
2111
2115
  void 0,
2112
2116
  t
2113
2117
  );
2114
- } catch (S) {
2118
+ } catch (c) {
2115
2119
  n.enqueue(
2116
2120
  new TextEncoder().encode(
2117
2121
  `HTTP/1.1 400 Bad Request\r
@@ -2119,10 +2123,10 @@ Content-Length: 0\r
2119
2123
  \r
2120
2124
  `
2121
2125
  )
2122
- ), n.error(S);
2126
+ ), n.error(c);
2123
2127
  return;
2124
2128
  }
2125
- n.enqueue(g.headersAsBytes(r));
2129
+ n.enqueue(L.headersAsBytes(r));
2126
2130
  const s = (_ = r.body) == null ? void 0 : _.getReader();
2127
2131
  if (!s) {
2128
2132
  n.close();
@@ -2130,12 +2134,12 @@ Content-Length: 0\r
2130
2134
  }
2131
2135
  const a = new TextEncoder();
2132
2136
  for (; ; ) {
2133
- const { done: S, value: c } = await s.read();
2134
- if (c && (n.enqueue(
2135
- a.encode(`${c.length.toString(16)}\r
2137
+ const { done: c, value: S } = await s.read();
2138
+ if (S && (n.enqueue(
2139
+ a.encode(`${S.length.toString(16)}\r
2136
2140
  `)
2137
- ), n.enqueue(c), n.enqueue(a.encode(`\r
2138
- `))), S) {
2141
+ ), n.enqueue(S), n.enqueue(a.encode(`\r
2142
+ `))), c) {
2139
2143
  n.enqueue(a.encode(`0\r
2140
2144
  \r
2141
2145
  `)), n.close();
@@ -2167,81 +2171,81 @@ Content-Length: 0\r
2167
2171
  let r = new Uint8Array(0), s = !1, a = -1;
2168
2172
  const _ = e.getReader();
2169
2173
  for (; a === -1; ) {
2170
- const { done: k, value: b } = await _.read();
2174
+ const { done: k, value: P } = await _.read();
2171
2175
  if (k) {
2172
2176
  s = !0;
2173
2177
  break;
2174
2178
  }
2175
- r = H([r, b]), a = nt(
2179
+ r = H([r, P]), a = it(
2176
2180
  r,
2177
2181
  new Uint8Array([13, 10, 13, 10])
2178
2182
  );
2179
2183
  }
2180
2184
  _.releaseLock();
2181
- const S = r.slice(0, a), c = g.parseRequestHeaders(S), C = c.headers.get("Transfer-Encoding") !== null ? "chunked" : "content-length", h = c.headers.get("Content-Length") !== null ? parseInt(c.headers.get("Content-Length"), 10) : void 0, A = r.slice(
2185
+ const c = r.slice(0, a), S = L.parseRequestHeaders(c), C = S.headers.get("Transfer-Encoding") !== null ? "chunked" : "content-length", h = S.headers.get("Content-Length") !== null ? parseInt(S.headers.get("Content-Length"), 10) : void 0, A = r.slice(
2182
2186
  a + 4
2183
2187
  /* Skip \r\n\r\n */
2184
2188
  );
2185
2189
  let u;
2186
- if (c.method !== "GET") {
2190
+ if (S.method !== "GET") {
2187
2191
  const k = e.getReader();
2188
- let b = A.length, F = A.slice(-6);
2189
- const Le = new TextEncoder().encode(`0\r
2192
+ let P = A.length, F = A.slice(-6);
2193
+ const me = new TextEncoder().encode(`0\r
2190
2194
  \r
2191
2195
  `);
2192
2196
  u = new ReadableStream({
2193
- async start(R) {
2194
- A.length > 0 && R.enqueue(A);
2195
- const q = C === "content-length" && h !== void 0 && b >= h;
2196
- (s || q) && R.close();
2197
+ async start(b) {
2198
+ A.length > 0 && b.enqueue(A);
2199
+ const q = C === "content-length" && h !== void 0 && P >= h;
2200
+ (s || q) && b.close();
2197
2201
  },
2198
- async pull(R) {
2199
- const { done: q, value: K } = await k.read();
2200
- if (b += (K == null ? void 0 : K.length) || 0, K && (R.enqueue(K), F = H([
2202
+ async pull(b) {
2203
+ const { done: q, value: I } = await k.read();
2204
+ if (P += (I == null ? void 0 : I.length) || 0, I && (b.enqueue(I), F = H([
2201
2205
  F,
2202
- K || new Uint8Array()
2203
- ]).slice(-5)), q || C === "content-length" && h !== void 0 && b >= h || C === "chunked" && F.every(
2204
- (ye, me) => ye === Le[me]
2206
+ I || new Uint8Array()
2207
+ ]).slice(-5)), q || C === "content-length" && h !== void 0 && P >= h || C === "chunked" && F.every(
2208
+ (Le, ge) => Le === me[ge]
2205
2209
  )) {
2206
- R.close();
2210
+ b.close();
2207
2211
  return;
2208
2212
  }
2209
2213
  }
2210
2214
  }), C === "chunked" && (u = u.pipeThrough(
2211
- new Xe()
2215
+ new et()
2212
2216
  ));
2213
2217
  }
2214
- const T = c.headers.get("Host") ?? t, y = new URL(c.path, n + "://" + T);
2218
+ const T = S.headers.get("Host") ?? t, y = new URL(S.path, n + "://" + T);
2215
2219
  return {
2216
2220
  request: new Request(y.toString(), {
2217
- method: c.method,
2218
- headers: c.headers,
2221
+ method: S.method,
2222
+ headers: S.headers,
2219
2223
  body: u,
2220
2224
  // @ts-expect-error duplex is required for streaming request bodies
2221
2225
  duplex: u ? "half" : void 0
2222
2226
  }),
2223
- expectsContinue: c.expectsContinue
2227
+ expectsContinue: S.expectsContinue
2224
2228
  };
2225
2229
  }
2226
2230
  static parseRequestHeaders(e) {
2227
- var S;
2231
+ var c;
2228
2232
  const t = new TextDecoder().decode(e), n = t.split(`
2229
2233
  `)[0], [r, s] = n.split(" "), a = new Headers();
2230
- for (const c of t.split(`\r
2234
+ for (const S of t.split(`\r
2231
2235
  `).slice(1)) {
2232
- if (c === "")
2236
+ if (S === "")
2233
2237
  break;
2234
- const C = c.indexOf(":");
2238
+ const C = S.indexOf(":");
2235
2239
  if (C === -1)
2236
2240
  continue;
2237
- const h = c.slice(0, C).trim(), A = c.slice(C + 1).trimStart();
2241
+ const h = S.slice(0, C).trim(), A = S.slice(C + 1).trimStart();
2238
2242
  h !== "" && a.set(h, A);
2239
2243
  }
2240
- const _ = ((S = a.get("Expect")) == null ? void 0 : S.toLowerCase()) === "100-continue";
2244
+ const _ = ((c = a.get("Expect")) == null ? void 0 : c.toLowerCase()) === "100-continue";
2241
2245
  return a.delete("Expect"), { method: r, path: s, headers: a, expectsContinue: _ };
2242
2246
  }
2243
2247
  }
2244
- function nt(i, e) {
2248
+ function it(i, e) {
2245
2249
  const t = i.length, n = e.length, r = t - n;
2246
2250
  for (let s = 0; s <= r; s++) {
2247
2251
  let a = !0;
@@ -2255,7 +2259,7 @@ function nt(i, e) {
2255
2259
  }
2256
2260
  return -1;
2257
2261
  }
2258
- async function rt(i = V) {
2262
+ async function at(i = oe) {
2259
2263
  switch (i) {
2260
2264
  case "8.5":
2261
2265
  return (await import("@php-wasm/web-8-5")).getIntlExtensionPath();
@@ -2274,48 +2278,57 @@ async function rt(i = V) {
2274
2278
  }
2275
2279
  throw new Error(`Unsupported PHP version ${i}`);
2276
2280
  }
2277
- async function st(i = V, e) {
2278
- const t = be(fetch), n = "intl.so", r = "icu.dat", s = await rt(i), a = (await import("./shared/icu.dat")).default, [_, S] = await Promise.all([
2279
- t(s).then((c) => c.arrayBuffer()),
2280
- t(a).then((c) => c.arrayBuffer())
2281
- ]);
2282
- return {
2283
- ...e,
2284
- ENV: {
2285
- ...e.ENV,
2286
- PHP_INI_SCAN_DIR: "/internal/shared/extensions",
2281
+ async function _t(i, e, t, n = []) {
2282
+ if (!n.length)
2283
+ return t;
2284
+ const r = await Promise.all(
2285
+ n.map(
2286
+ (s) => ot(i, e, s)
2287
+ )
2288
+ );
2289
+ return Ie(t, r);
2290
+ }
2291
+ async function ot(i, e, t) {
2292
+ if (typeof t == "object" && "source" in t)
2293
+ return await Y({
2294
+ ...t,
2295
+ phpVersion: i,
2296
+ asyncMode: e
2297
+ });
2298
+ const n = typeof t == "string" ? t : t.name;
2299
+ if (n !== "intl")
2300
+ throw new Error(`Unknown bundled PHP web extension: ${String(n)}.`);
2301
+ const r = Be(fetch), s = await at(i), a = (await import("../intl/shared/icu.dat")).default, [_, c] = await Promise.all(
2302
+ [s, a].map(async (S) => {
2303
+ const C = await r(S);
2304
+ if (!C.ok)
2305
+ throw new Error(
2306
+ `Failed to fetch bundled PHP web extension asset: ${C.url || S} (${C.status} ${C.statusText}).`
2307
+ );
2308
+ return await C.arrayBuffer();
2309
+ })
2310
+ );
2311
+ return await Y({
2312
+ source: {
2313
+ format: "so",
2314
+ name: "intl",
2315
+ bytes: new Uint8Array(_)
2316
+ },
2317
+ phpVersion: i,
2318
+ asyncMode: e,
2319
+ env: {
2287
2320
  ICU_DATA: "/internal/shared"
2288
2321
  },
2289
- onRuntimeInitialized: (c) => {
2290
- e.onRuntimeInitialized && e.onRuntimeInitialized(c), L.fileExists(
2291
- c.FS,
2292
- "/internal/shared/extensions"
2293
- ) || c.FS.mkdirTree("/internal/shared/extensions"), L.fileExists(
2294
- c.FS,
2295
- `/internal/shared/extensions/${n}`
2296
- ) || c.FS.writeFile(
2297
- `/internal/shared/extensions/${n}`,
2298
- new Uint8Array(_)
2299
- ), L.fileExists(
2300
- c.FS,
2301
- "/internal/shared/extensions/intl.ini"
2302
- ) || c.FS.writeFile(
2303
- "/internal/shared/extensions/intl.ini",
2304
- [
2305
- `extension=/internal/shared/extensions/${n}`
2306
- ].join(`
2307
- `)
2308
- ), L.fileExists(
2309
- c.FS,
2310
- `${c.ENV.ICU_DATA}/${r}`
2311
- ) || (c.FS.mkdirTree(c.ENV.ICU_DATA), c.FS.writeFile(
2312
- `${c.ENV.ICU_DATA}/icudt74l.dat`,
2313
- new Uint8Array(S)
2314
- ));
2322
+ extraFiles: {
2323
+ targetPath: "/internal/shared",
2324
+ files: {
2325
+ // The Intl extension looks for the hard-coded ICU data name.
2326
+ "icudt74l.dat": new Uint8Array(c)
2327
+ }
2315
2328
  }
2316
- };
2329
+ });
2317
2330
  }
2318
- const it = () => ({
2331
+ const ct = () => ({
2319
2332
  websocket: {
2320
2333
  decorator: (i) => class extends i {
2321
2334
  constructor() {
@@ -2330,40 +2343,47 @@ const it = () => ({
2330
2343
  }
2331
2344
  }
2332
2345
  });
2333
- async function Lt(i, e = {}) {
2334
- var a;
2335
- "setImmediate" in globalThis || (globalThis.setImmediate = (_) => setTimeout(_, 0));
2336
- let t = {
2337
- ...it(),
2338
- ...e.emscriptenOptions || {}
2346
+ async function Dt(i, e = {}) {
2347
+ var c;
2348
+ "setImmediate" in globalThis || (globalThis.setImmediate = (S) => setTimeout(S, 0));
2349
+ const t = await Ue() ? "jspi" : "asyncify";
2350
+ let n = {
2351
+ ...ct(),
2352
+ ...e.emscriptenOptions || {},
2353
+ phpWasmAsyncMode: t
2339
2354
  };
2340
- e.tcpOverFetch && (t = Je(
2341
- t,
2355
+ e.tcpOverFetch && (n = tt(
2356
+ n,
2342
2357
  e.tcpOverFetch
2343
2358
  ));
2344
- const n = ge(i);
2345
- if (n) {
2346
- const _ = await t, S = _.preRun || [];
2347
- t = {
2348
- ..._,
2349
- preRun: [...S, Ie()]
2359
+ const r = Ke(i), s = [...e.extensions ?? []];
2360
+ if (e.withIntl && !St(s, "intl") && s.push("intl"), r) {
2361
+ const S = await n, C = S.preRun || [];
2362
+ n = {
2363
+ ...S,
2364
+ preRun: [...C, De()]
2350
2365
  };
2351
2366
  }
2352
- if (n && e.withIntl)
2367
+ if (r && s.length)
2353
2368
  throw new Error(
2354
- `The intl extension is not available for legacy PHP ${i}.`
2369
+ `Extensions are not available for legacy PHP ${i}.`
2355
2370
  );
2356
- n || e.withIntl && (t = st(
2371
+ r || (n = _t(
2357
2372
  i,
2358
- t
2373
+ t,
2374
+ await n,
2375
+ s
2359
2376
  ));
2360
- const [r, s] = await Promise.all([
2361
- Ue(i),
2362
- t
2377
+ const [a, _] = await Promise.all([
2378
+ xe(i),
2379
+ n
2363
2380
  ]);
2364
- return (a = e.onPhpLoaderModuleLoaded) == null || a.call(e, r), await Ke(r, s);
2381
+ return (c = e.onPhpLoaderModuleLoaded) == null || c.call(e, a), await We(a, _);
2382
+ }
2383
+ function St(i, e) {
2384
+ return i.some((t) => typeof t == "string" ? t === e : !("source" in t) && t.name === e);
2365
2385
  }
2366
- function yt(i, e) {
2386
+ function Wt(i, e) {
2367
2387
  window.addEventListener("message", (t) => {
2368
2388
  t.source === i.contentWindow && (e && t.origin !== e || typeof t.data != "object" || t.data.type !== "relay" || window.parent.postMessage(t.data, "*"));
2369
2389
  }), window.addEventListener("message", (t) => {
@@ -2371,7 +2391,7 @@ function yt(i, e) {
2371
2391
  t.source === window.parent && (typeof t.data != "object" || t.data.type !== "relay" || (n = i == null ? void 0 : i.contentWindow) == null || n.postMessage(t.data));
2372
2392
  });
2373
2393
  }
2374
- async function mt(i) {
2394
+ async function Pt(i) {
2375
2395
  const e = new Worker(i, { type: "module" });
2376
2396
  return new Promise((t, n) => {
2377
2397
  e.onerror = (s) => {
@@ -2386,8 +2406,8 @@ async function mt(i) {
2386
2406
  e.addEventListener("message", r);
2387
2407
  });
2388
2408
  }
2389
- const at = 1e3;
2390
- function gt(i, e = { initialSync: {} }) {
2409
+ const Ct = 1e3;
2410
+ function bt(i, e = { initialSync: {} }) {
2391
2411
  return e = {
2392
2412
  ...e,
2393
2413
  initialSync: {
@@ -2396,59 +2416,59 @@ function gt(i, e = { initialSync: {} }) {
2396
2416
  }
2397
2417
  }, async function(t, n, r) {
2398
2418
  var a;
2399
- e.initialSync.direction === "opfs-to-memfs" ? (L.fileExists(n, r) && L.rmdir(n, r), L.mkdir(n, r), await _t(n, i, r)) : await we(
2419
+ e.initialSync.direction === "opfs-to-memfs" ? (M.fileExists(n, r) && M.rmdir(n, r), M.mkdir(n, r), await lt(n, i, r)) : await ye(
2400
2420
  n,
2401
2421
  i,
2402
2422
  r,
2403
2423
  e.initialSync.onProgress
2404
2424
  );
2405
- const s = ct(t, i, r);
2425
+ const s = At(t, i, r);
2406
2426
  return (a = e.onMount) == null || a.call(e, s), s.unmount;
2407
2427
  };
2408
2428
  }
2409
- async function _t(i, e, t) {
2410
- L.mkdir(i, t);
2411
- const n = new De({
2429
+ async function lt(i, e, t) {
2430
+ M.mkdir(i, t);
2431
+ const n = new Pe({
2412
2432
  concurrency: 40
2413
2433
  }), r = [], s = [
2414
2434
  [e, t]
2415
2435
  ];
2416
2436
  for (; s.length > 0; ) {
2417
2437
  const [a, _] = s.pop();
2418
- for await (const S of a.values()) {
2419
- const c = n.run(async () => {
2420
- const C = oe(
2438
+ for await (const c of a.values()) {
2439
+ const S = n.run(async () => {
2440
+ const C = ce(
2421
2441
  _,
2422
- S.name
2442
+ c.name
2423
2443
  );
2424
- if (S.kind === "directory") {
2444
+ if (c.kind === "directory") {
2425
2445
  try {
2426
2446
  i.mkdir(C);
2427
2447
  } catch (h) {
2428
2448
  if ((h == null ? void 0 : h.errno) !== 20)
2429
- throw U.error(h), h;
2449
+ throw B.error(h), h;
2430
2450
  }
2431
- s.push([S, C]);
2432
- } else if (S.kind === "file") {
2433
- const h = await S.getFile(), A = new Uint8Array(await h.arrayBuffer());
2451
+ s.push([c, C]);
2452
+ } else if (c.kind === "file") {
2453
+ const h = await c.getFile(), A = new Uint8Array(await h.arrayBuffer());
2434
2454
  i.createDataFile(
2435
2455
  _,
2436
- S.name,
2456
+ c.name,
2437
2457
  A,
2438
2458
  !0,
2439
2459
  !0,
2440
2460
  !0
2441
2461
  );
2442
2462
  }
2443
- r.splice(r.indexOf(c), 1);
2463
+ r.splice(r.indexOf(S), 1);
2444
2464
  });
2445
- r.push(c);
2465
+ r.push(S);
2446
2466
  }
2447
2467
  for (; s.length === 0 && r.length > 0; )
2448
2468
  await Promise.any(r);
2449
2469
  }
2450
2470
  }
2451
- async function we(i, e, t, n) {
2471
+ async function ye(i, e, t, n) {
2452
2472
  i.mkdirTree(t);
2453
2473
  const r = [];
2454
2474
  async function s(C, h) {
@@ -2456,8 +2476,8 @@ async function we(i, e, t, n) {
2456
2476
  i.readdir(C).filter(
2457
2477
  (A) => A !== "." && A !== ".."
2458
2478
  ).map(async (A) => {
2459
- const u = oe(C, A);
2460
- if (!ot(i, u)) {
2479
+ const u = ce(C, A);
2480
+ if (!ht(i, u)) {
2461
2481
  r.push([h, u, A]);
2462
2482
  return;
2463
2483
  }
@@ -2470,7 +2490,7 @@ async function we(i, e, t, n) {
2470
2490
  }
2471
2491
  await s(t, e);
2472
2492
  let a = 0;
2473
- const _ = n && lt(n, 100), S = 100, c = /* @__PURE__ */ new Set();
2493
+ const _ = n && dt(n, 100), c = 100, S = /* @__PURE__ */ new Set();
2474
2494
  try {
2475
2495
  for (const [C, h, A] of r) {
2476
2496
  const u = $(
@@ -2479,21 +2499,21 @@ async function we(i, e, t, n) {
2479
2499
  i,
2480
2500
  h
2481
2501
  ).then(() => {
2482
- a++, c.delete(u), _ == null || _({
2502
+ a++, S.delete(u), _ == null || _({
2483
2503
  files: a,
2484
2504
  total: r.length
2485
2505
  });
2486
2506
  });
2487
- c.add(u), c.size >= S && (await Promise.race(c), _ == null || _({
2507
+ S.add(u), S.size >= c && (await Promise.race(S), _ == null || _({
2488
2508
  files: a,
2489
2509
  total: r.length
2490
2510
  }));
2491
2511
  }
2492
2512
  } finally {
2493
- await Promise.allSettled(c);
2513
+ await Promise.allSettled(S);
2494
2514
  }
2495
2515
  }
2496
- function ot(i, e) {
2516
+ function ht(i, e) {
2497
2517
  return i.isDir(i.lookupPath(e, { follow: !0 }).node.mode);
2498
2518
  }
2499
2519
  async function $(i, e, t, n) {
@@ -2518,35 +2538,35 @@ async function $(i, e, t, n) {
2518
2538
  await a.close();
2519
2539
  }
2520
2540
  }
2521
- function ct(i, e, t, n = {}) {
2522
- const r = [], s = Re(i, t, (u) => {
2541
+ function At(i, e, t, n = {}) {
2542
+ const r = [], s = ve(i, t, (u) => {
2523
2543
  r.push(u);
2524
- }), a = new St(i, e, t);
2544
+ }), a = new ut(i, e, t);
2525
2545
  let _;
2526
- function S() {
2546
+ function c() {
2527
2547
  return _ === void 0 && (_ = h().finally(() => {
2528
2548
  _ = void 0;
2529
2549
  })), _;
2530
2550
  }
2531
- async function c() {
2551
+ async function S() {
2532
2552
  try {
2533
- await S();
2553
+ await c();
2534
2554
  } finally {
2535
2555
  s(), i.removeEventListener("request.end", C), i.removeEventListener("filesystem.write", C);
2536
2556
  }
2537
2557
  }
2538
2558
  function C() {
2539
- S().catch((u) => {
2540
- U.error(u);
2559
+ c().catch((u) => {
2560
+ B.error(u);
2541
2561
  });
2542
2562
  }
2543
2563
  async function h() {
2544
- const u = n.maxFlushPasses ?? at;
2564
+ const u = n.maxFlushPasses ?? Ct;
2545
2565
  for (let T = 0; r.length > 0; T++) {
2546
2566
  if (T >= u) {
2547
- const y = r.length, x = y === 1 ? `${y} journal entry remains` : `${y} journal entries remain`;
2567
+ const y = r.length, U = y === 1 ? `${y} journal entry remains` : `${y} journal entries remain`;
2548
2568
  throw new Error(
2549
- `OPFS flush for "${t}" did not settle after ${u} journal batches; ${x}. This can happen when filesystem writes are continuously enqueued while flushing.`
2569
+ `OPFS flush for "${t}" did not settle after ${u} journal batches; ${U}. This can happen when filesystem writes are continuously enqueued while flushing.`
2550
2570
  );
2551
2571
  }
2552
2572
  await A();
@@ -2557,20 +2577,20 @@ function ct(i, e, t, n = {}) {
2557
2577
  return;
2558
2578
  const u = await i.semaphore.acquire(), T = [...r];
2559
2579
  r.splice(0, T.length);
2560
- const y = Be(T);
2580
+ const y = Me(T);
2561
2581
  try {
2562
- for (const x of y)
2563
- await a.processEntry(x);
2582
+ for (const U of y)
2583
+ await a.processEntry(U);
2564
2584
  } finally {
2565
2585
  u();
2566
2586
  }
2567
2587
  }
2568
2588
  return i.addEventListener("request.end", C), i.addEventListener("filesystem.write", C), {
2569
- flush: S,
2570
- unmount: c
2589
+ flush: c,
2590
+ unmount: S
2571
2591
  };
2572
2592
  }
2573
- class St {
2593
+ class ut {
2574
2594
  constructor(e, t, n) {
2575
2595
  this.php = e, this.opfs = t, this.memfsRoot = ae(n);
2576
2596
  }
@@ -2580,7 +2600,7 @@ class St {
2580
2600
  async processEntry(e) {
2581
2601
  if (!e.path.startsWith(this.memfsRoot) || e.path === this.memfsRoot)
2582
2602
  return;
2583
- const t = this.toOpfsPath(e.path), n = await _e(this.opfs, t), r = Ct(t);
2603
+ const t = this.toOpfsPath(e.path), n = await _e(this.opfs, t), r = Ht(t);
2584
2604
  if (r)
2585
2605
  try {
2586
2606
  if (e.operation === "DELETE")
@@ -2615,7 +2635,7 @@ class St {
2615
2635
  create: !0
2616
2636
  }
2617
2637
  );
2618
- await we(
2638
+ await ye(
2619
2639
  this.php[O].FS,
2620
2640
  _,
2621
2641
  e.toPath
@@ -2629,21 +2649,21 @@ class St {
2629
2649
  }
2630
2650
  await $(
2631
2651
  a,
2632
- We(s),
2652
+ be(s),
2633
2653
  this.php[O].FS,
2634
2654
  e.toPath
2635
2655
  );
2636
2656
  }
2637
2657
  }
2638
2658
  } catch (s) {
2639
- throw U.log({ entry: e, name: r }), U.error(s), s;
2659
+ throw B.log({ entry: e, name: r }), B.error(s), s;
2640
2660
  }
2641
2661
  }
2642
2662
  }
2643
2663
  function ae(i) {
2644
2664
  return i.replace(/\/$/, "").replace(/\/\/+/g, "/");
2645
2665
  }
2646
- function Ct(i) {
2666
+ function Ht(i) {
2647
2667
  return i.substring(i.lastIndexOf("/") + 1);
2648
2668
  }
2649
2669
  async function _e(i, e) {
@@ -2658,31 +2678,31 @@ async function _e(i, e) {
2658
2678
  }
2659
2679
  return r;
2660
2680
  }
2661
- function lt(i, e) {
2681
+ function dt(i, e) {
2662
2682
  let t = 0, n, r;
2663
2683
  return function(...a) {
2664
2684
  r = a;
2665
2685
  const _ = Date.now() - t;
2666
2686
  if (n === void 0) {
2667
- const S = Math.max(0, e - _);
2687
+ const c = Math.max(0, e - _);
2668
2688
  n = setTimeout(() => {
2669
2689
  n = void 0, t = Date.now(), i(...r);
2670
- }, S);
2690
+ }, c);
2671
2691
  }
2672
2692
  };
2673
2693
  }
2674
2694
  export {
2675
- bt as FirewallInterferenceError,
2676
- Tt as certificateToPEM,
2677
- Dt as consumeAPI,
2678
- gt as createDirectoryHandleMountHandler,
2679
- Wt as exposeAPI,
2680
- Rt as fetchWithCorsProxy,
2681
- Ve as generateCertificate,
2682
- Ue as getPHPLoaderModule,
2683
- Lt as loadWebRuntime,
2684
- pt as privateKeyToPEM,
2685
- yt as setupPostMessageRelay,
2686
- mt as spawnPHPWorkerThread
2695
+ xt as FirewallInterferenceError,
2696
+ gt as certificateToPEM,
2697
+ Ut as consumeAPI,
2698
+ bt as createDirectoryHandleMountHandler,
2699
+ vt as exposeAPI,
2700
+ Nt as fetchWithCorsProxy,
2701
+ Ze as generateCertificate,
2702
+ xe as getPHPLoaderModule,
2703
+ Dt as loadWebRuntime,
2704
+ It as privateKeyToPEM,
2705
+ Wt as setupPostMessageRelay,
2706
+ Pt as spawnPHPWorkerThread
2687
2707
  };
2688
2708
  //# sourceMappingURL=index.js.map