@php-wasm/web-service-worker 3.1.8 → 3.1.9

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.cjs +1 -1
  2. package/index.js +111 -100
  3. package/package.json +4 -4
package/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@php-wasm/scopes"),P=require("@php-wasm/universal"),T=25e3;let C=0;function x(e,t,...r){const s=R();return e.postMessage({...t,requestId:s},...r),s}function R(){return++C}function m(e,t,r=T){return new Promise((s,a)=>{const o=i=>{i.data.type==="response"&&i.data.requestId===t&&(e.removeEventListener("message",o),clearTimeout(n),s(i.data.response))},n=setTimeout(()=>{a(new Error("Request timed out")),e.removeEventListener("message",o)},r);e.addEventListener("message",o)})}function q(e,t){return{type:"response",requestId:e,response:t}}async function v(e){let t=new URL(e.request.url);if(!u.isURLScoped(t))try{const c=new URL(e.request.referrer);t=u.setURLScope(t,u.getURLScope(c))}catch{}const r=e.request.headers.get("content-type"),s=e.request.method==="POST"?new Uint8Array(await e.request.clone().arrayBuffer()):void 0,a={};for(const c of e.request.headers.entries())a[c[0]]=c[1];let o;try{const c={method:"request",args:[{body:s,url:t.toString(),method:e.request.method,headers:{...a,Host:t.host,"User-agent":self.navigator.userAgent,"Content-type":r}}]},l=u.getURLScope(t);if(l===null)throw new Error(`The URL ${t.toString()} is not scoped. This should not happen.`);const y=await g(c,l);if(o=await m(self,y),delete o.headers["x-frame-options"],o.headers["content-security-policy"]){const d=o.headers["content-security-policy"].map(h=>b("frame-ancestors",h)).filter(h=>h.trim().length>0);d.length>0?o.headers["content-security-policy"]=d:delete o.headers["content-security-policy"]}}catch(c){throw console.error(c,{url:t.toString()}),c}if(o.httpStatusCode>=300&&o.httpStatusCode<=399&&o.headers.location){const c=u.getURLScope(t);let l=new URL(o.headers.location[0],t.toString());return c&&!u.isURLScoped(l)&&(l=u.setURLScope(l,c)),Response.redirect(l.toString(),o.httpStatusCode)}const n=[101,103,204,205,304].includes(o.httpStatusCode);let i=null;return n||(o.bodyPort?i=P.portToStream(o.bodyPort):i=o.bytes),new Response(i,{headers:o.headers,status:o.httpStatusCode})}async function g(e,t){const r=R();for(const s of await self.clients.matchAll({includeUncontrolled:!0}))s.postMessage({...e,scope:t,requestId:r});return r}async function p(e,t){let r;return["GET","HEAD"].includes(e.method)||"body"in t?r=void 0:!e.bodyUsed&&e.body?r=e.body:r=await e.arrayBuffer(),new Request(t.url||e.url,{body:r,method:e.method,headers:e.headers,referrer:e.referrer,referrerPolicy:e.referrerPolicy,mode:e.mode==="navigate"?"same-origin":e.mode,credentials:e.credentials,cache:e.cache,redirect:e.redirect,integrity:e.integrity,...r instanceof ReadableStream&&{duplex:"half"},...t})}async function S(e){if(!e.body)return[e,e];const[t,r]=e.body.tee();return[await p(e,{body:t,duplex:"half"}),await p(e,{body:r,duplex:"half"})]}function H(e){const t={};return e.headers.forEach((r,s)=>{t[s]=r}),t}function b(e,t){const r=/^[\u{9}\u{A}\u{C}\u{D}\u{20}]+/u,s=/[\u{9}\u{A}\u{C}\u{D}\u{20}]+$/u,a=/[\u{9}\u{A}\u{C}\u{D}\u{20}]/u;return t.split(";").filter(o=>{const n=o.replace(r,"").replace(s,""),[i]=n.split(a,1);return i.toLowerCase()!==e.toLowerCase()}).join(";")}class E extends Error{constructor(t,r,s){super(`Could not fetch ${t} – your network appears to be blocking this request (HTTP ${r}). This often happens on school, university, or corporate networks. Try switching to a different network or using a VPN.`),this.name="FirewallInterferenceError",this.url=t,this.status=r,this.statusText=s}}const A="X-Playground-Cors-Proxy";async function I(e,t,r,s){var y;let a=typeof e=="string"?new Request(e,t):e;const o=s?new URL(s):null;let n=o?new URL(a.url,o):new URL(a.url);if(n.hostname==="localhost"||n.hostname==="127.0.0.1"||n.hostname==="[::1]"||n.hostname==="::1")return await f(a);if(n.protocol==="http:"){n.protocol="https:";const d=n.toString();a=await p(a,{url:d}),n=new URL(d)}if(!r)return await f(a);if(o&&n.protocol===o.protocol&&n.hostname===o.hostname&&n.port===o.port&&n.pathname.startsWith(o.pathname))return await f(a);const[c,l]=await S(a);try{return await f(c)}catch{const h=((y=new Headers(l.headers).get("x-cors-proxy-allowed-request-headers"))==null?void 0:y.split(","))||[],L=h.includes("authorization")||h.includes("cookie"),U=await p(l,{url:`${r}${a.url}`,...L&&{credentials:"include"}}),w=await f(U,t);if(!w.headers.has(A))throw new E(a.url,w.status,w.statusText);return w}}async function f(e,t){let r=t?new Request(e,t):e;if(new URL(r.url).protocol==="http:"&&r.body){const s=await new Response(r.body).arrayBuffer();r=await p(r,{body:s})}return fetch(r)}exports.FirewallInterferenceError=E;exports.awaitReply=m;exports.broadcastMessageExpectReply=g;exports.cloneRequest=p;exports.convertFetchEventToPHPRequest=v;exports.fetchWithCorsProxy=I;exports.getNextRequestId=R;exports.getRequestHeaders=H;exports.postMessageExpectReply=x;exports.removeContentSecurityPolicyDirective=b;exports.responseTo=q;exports.teeRequest=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("@php-wasm/scopes"),q=require("@php-wasm/universal");var g=typeof document<"u"?document.currentScript:null;const I=25e3;let H=0;function v(e,t,...r){const n=S();return e.postMessage({...t,requestId:n},...r),n}function S(){return++H}function U(e,t,r=I){return new Promise((n,a)=>{const o=u=>{u.data.type==="response"&&u.data.requestId===t&&(e.removeEventListener("message",o),clearTimeout(s),n(u.data.response))},s=setTimeout(()=>{a(new Error("Request timed out")),e.removeEventListener("message",o)},r);e.addEventListener("message",o)})}function A(e,t){return{type:"response",requestId:e,response:t}}async function O(e){let t=new URL(e.request.url);if(!d.isURLScoped(t))try{const c=new URL(e.request.referrer);t=d.setURLScope(t,d.getURLScope(c))}catch{}const r=e.request.headers.get("content-type"),n=e.request.method==="POST"?new Uint8Array(await e.request.clone().arrayBuffer()):void 0,a={};for(const c of e.request.headers.entries())a[c[0]]=c[1];let o;try{const c={method:"request",args:[{body:n,url:t.toString(),method:e.request.method,headers:{...a,Host:t.host,"User-agent":self.navigator.userAgent,"Content-type":r}}]},i=d.getURLScope(t);if(i===null)throw new Error(`The URL ${t.toString()} is not scoped. This should not happen.`);const f=await b(c,i);if(o=await U(self,f),delete o.headers["x-frame-options"],o.headers["content-security-policy"]){const l=o.headers["content-security-policy"].map(p=>C("frame-ancestors",p)).filter(p=>p.trim().length>0);l.length>0?o.headers["content-security-policy"]=l:delete o.headers["content-security-policy"]}}catch(c){throw console.error(c,{url:t.toString()}),c}if(o.httpStatusCode>=300&&o.httpStatusCode<=399&&o.headers.location){const c=d.getURLScope(t);let i=new URL(o.headers.location[0],t.toString());return c&&!d.isURLScoped(i)&&(i=d.setURLScope(i,c)),Response.redirect(i.toString(),o.httpStatusCode)}const s=[101,103,204,205,304].includes(o.httpStatusCode);let u=null;return s||(o.bodyPort?u=q.portToStream(o.bodyPort):u=o.bytes),new Response(u,{headers:o.headers,status:o.httpStatusCode})}async function b(e,t){const r=S();for(const n of await self.clients.matchAll({includeUncontrolled:!0}))n.postMessage({...e,scope:t,requestId:r});return r}async function h(e,t){let r;return["GET","HEAD"].includes(e.method)?r=void 0:"body"in t?r=t.body:!e.bodyUsed&&e.body?r=e.body:r=await e.arrayBuffer(),new Request(t.url||e.url,{body:r,method:e.method,headers:e.headers,referrer:e.referrer,referrerPolicy:e.referrerPolicy,mode:e.mode==="navigate"?"same-origin":e.mode,credentials:e.credentials,cache:e.cache,redirect:e.redirect,integrity:e.integrity,...r instanceof ReadableStream&&{duplex:"half"},...t})}async function L(e){if(!e.body)return[e,e];const[t,r]=e.body.tee();return[await h(e,{body:t,duplex:"half"}),await h(e,{body:r,duplex:"half"})]}function D(e){const t={};return e.headers.forEach((r,n)=>{t[n]=r}),t}function C(e,t){const r=/^[\u{9}\u{A}\u{C}\u{D}\u{20}]+/u,n=/[\u{9}\u{A}\u{C}\u{D}\u{20}]+$/u,a=/[\u{9}\u{A}\u{C}\u{D}\u{20}]/u;return t.split(";").filter(o=>{const s=o.replace(r,"").replace(n,""),[u]=s.split(a,1);return u.toLowerCase()!==e.toLowerCase()}).join(";")}class T extends Error{constructor(t,r,n){super(`Could not fetch ${t} – your network appears to be blocking this request (HTTP ${r}). This often happens on school, university, or corporate networks. Try switching to a different network or using a VPN.`),this.name="FirewallInterferenceError",this.url=t,this.status=r,this.statusText=n}}const M="X-Playground-Cors-Proxy";async function j(e,t,r,n){var f;let a=typeof e=="string"?new Request(e,t):e;const o=n?new URL(n):null;let s=o?new URL(a.url,o):new URL(a.url);if(s.hostname==="localhost"||s.hostname==="127.0.0.1"||s.hostname==="[::1]"||s.hostname==="::1")return await fetch(a);if(s.protocol==="http:"){s.protocol="https:";const l=s.toString();a=await h(a,{url:l}),s=new URL(l)}if(!r)return await fetch(a);if(o&&s.protocol===o.protocol&&s.hostname===o.hostname&&s.port===o.port&&s.pathname.startsWith(o.pathname))return await fetch(a);const[c,i]=await L(a);try{return await fetch(c)}catch{const l=new Headers(i.headers),p=((f=l.get("x-cors-proxy-allowed-request-headers"))==null?void 0:f.split(","))||[],E=p.includes("authorization")||p.includes("cookie"),m=l.get("content-type");m&&m.toLowerCase().includes("multipart/form-data")&&(l.set("x-cors-proxy-content-type",m),l.set("content-type","application/octet-stream"));const y=new URL(typeof document>"u"?require("url").pathToFileURL(__filename).href:g&&g.tagName.toUpperCase()==="SCRIPT"&&g.src||new URL("index.cjs",document.baseURI).href);y.pathname="",y.search="",y.hash="";const P=new URL(r,y.toString());let w=i.body;w&&new URL(P).protocol==="http:"&&(w=await new Response(w).arrayBuffer());const x=await h(i,{url:`${r}${a.url}`,headers:l,body:w,...E&&{credentials:"include"}}),R=await fetch(x);if(!R.headers.has(M))throw new T(a.url,R.status,R.statusText);return R}}exports.FirewallInterferenceError=T;exports.awaitReply=U;exports.broadcastMessageExpectReply=b;exports.cloneRequest=h;exports.convertFetchEventToPHPRequest=O;exports.fetchWithCorsProxy=j;exports.getNextRequestId=S;exports.getRequestHeaders=D;exports.postMessageExpectReply=v;exports.removeContentSecurityPolicyDirective=C;exports.responseTo=A;exports.teeRequest=L;
package/index.js CHANGED
@@ -1,31 +1,31 @@
1
- import { isURLScoped as m, setURLScope as R, getURLScope as w } from "@php-wasm/scopes";
1
+ import { isURLScoped as g, setURLScope as b, getURLScope as R } from "@php-wasm/scopes";
2
2
  import { portToStream as E } from "@php-wasm/universal";
3
- const L = 25e3;
4
- let U = 0;
5
- function O(e, t, ...r) {
6
- const s = g();
3
+ const T = 25e3;
4
+ let x = 0;
5
+ function j(e, t, ...r) {
6
+ const n = L();
7
7
  return e.postMessage(
8
8
  {
9
9
  ...t,
10
- requestId: s
10
+ requestId: n
11
11
  },
12
12
  ...r
13
- ), s;
13
+ ), n;
14
14
  }
15
- function g() {
16
- return ++U;
15
+ function L() {
16
+ return ++x;
17
17
  }
18
- function C(e, t, r = L) {
19
- return new Promise((s, a) => {
20
- const o = (c) => {
21
- c.data.type === "response" && c.data.requestId === t && (e.removeEventListener("message", o), clearTimeout(n), s(c.data.response));
22
- }, n = setTimeout(() => {
18
+ function P(e, t, r = T) {
19
+ return new Promise((n, a) => {
20
+ const o = (u) => {
21
+ u.data.type === "response" && u.data.requestId === t && (e.removeEventListener("message", o), clearTimeout(s), n(u.data.response));
22
+ }, s = setTimeout(() => {
23
23
  a(new Error("Request timed out")), e.removeEventListener("message", o);
24
24
  }, r);
25
25
  e.addEventListener("message", o);
26
26
  });
27
27
  }
28
- function D(e, t) {
28
+ function k(e, t) {
29
29
  return {
30
30
  type: "response",
31
31
  requestId: e,
@@ -34,22 +34,22 @@ function D(e, t) {
34
34
  }
35
35
  async function v(e) {
36
36
  let t = new URL(e.request.url);
37
- if (!m(t))
37
+ if (!g(t))
38
38
  try {
39
- const i = new URL(e.request.referrer);
40
- t = R(t, w(i));
39
+ const c = new URL(e.request.referrer);
40
+ t = b(t, R(c));
41
41
  } catch {
42
42
  }
43
- const r = e.request.headers.get("content-type"), s = e.request.method === "POST" ? new Uint8Array(await e.request.clone().arrayBuffer()) : void 0, a = {};
44
- for (const i of e.request.headers.entries())
45
- a[i[0]] = i[1];
43
+ const r = e.request.headers.get("content-type"), n = e.request.method === "POST" ? new Uint8Array(await e.request.clone().arrayBuffer()) : void 0, a = {};
44
+ for (const c of e.request.headers.entries())
45
+ a[c[0]] = c[1];
46
46
  let o;
47
47
  try {
48
- const i = {
48
+ const c = {
49
49
  method: "request",
50
50
  args: [
51
51
  {
52
- body: s,
52
+ body: n,
53
53
  url: t.toString(),
54
54
  method: e.request.method,
55
55
  headers: {
@@ -62,54 +62,54 @@ async function v(e) {
62
62
  }
63
63
  }
64
64
  ]
65
- }, l = w(t);
66
- if (l === null)
65
+ }, i = R(t);
66
+ if (i === null)
67
67
  throw new Error(
68
68
  `The URL ${t.toString()} is not scoped. This should not happen.`
69
69
  );
70
- const f = await T(i, l);
71
- if (o = await C(self, f), delete o.headers["x-frame-options"], o.headers["content-security-policy"]) {
72
- const u = o.headers["content-security-policy"].map(
73
- (d) => x(
70
+ const h = await A(c, i);
71
+ if (o = await P(self, h), delete o.headers["x-frame-options"], o.headers["content-security-policy"]) {
72
+ const l = o.headers["content-security-policy"].map(
73
+ (d) => q(
74
74
  "frame-ancestors",
75
75
  d
76
76
  )
77
77
  ).filter((d) => d.trim().length > 0);
78
- u.length > 0 ? o.headers["content-security-policy"] = u : delete o.headers["content-security-policy"];
78
+ l.length > 0 ? o.headers["content-security-policy"] = l : delete o.headers["content-security-policy"];
79
79
  }
80
- } catch (i) {
81
- throw console.error(i, { url: t.toString() }), i;
80
+ } catch (c) {
81
+ throw console.error(c, { url: t.toString() }), c;
82
82
  }
83
83
  if (o.httpStatusCode >= 300 && o.httpStatusCode <= 399 && o.headers.location) {
84
- const i = w(t);
85
- let l = new URL(
84
+ const c = R(t);
85
+ let i = new URL(
86
86
  o.headers.location[0],
87
87
  t.toString()
88
88
  );
89
- return i && !m(l) && (l = R(l, i)), Response.redirect(
90
- l.toString(),
89
+ return c && !g(i) && (i = b(i, c)), Response.redirect(
90
+ i.toString(),
91
91
  o.httpStatusCode
92
92
  );
93
93
  }
94
- const n = [101, 103, 204, 205, 304].includes(
94
+ const s = [101, 103, 204, 205, 304].includes(
95
95
  o.httpStatusCode
96
96
  );
97
- let c = null;
98
- return n || (o.bodyPort ? c = E(o.bodyPort) : c = o.bytes), new Response(c, {
97
+ let u = null;
98
+ return s || (o.bodyPort ? u = E(o.bodyPort) : u = o.bytes), new Response(u, {
99
99
  headers: o.headers,
100
100
  status: o.httpStatusCode
101
101
  });
102
102
  }
103
- async function T(e, t) {
104
- const r = g();
105
- for (const s of await self.clients.matchAll({
103
+ async function A(e, t) {
104
+ const r = L();
105
+ for (const n of await self.clients.matchAll({
106
106
  // Sometimes the client that triggered the current fetch()
107
107
  // event is considered uncontrolled in Google Chrome. This
108
108
  // only happens on the first few fetches() after the initial
109
109
  // registration of the service worker.
110
110
  includeUncontrolled: !0
111
111
  }))
112
- s.postMessage({
112
+ n.postMessage({
113
113
  ...e,
114
114
  /**
115
115
  * Attach the scope with a URL starting with `/scope:` to this message.
@@ -123,9 +123,9 @@ async function T(e, t) {
123
123
  });
124
124
  return r;
125
125
  }
126
- async function p(e, t) {
126
+ async function w(e, t) {
127
127
  let r;
128
- return ["GET", "HEAD"].includes(e.method) || "body" in t ? r = void 0 : !e.bodyUsed && e.body ? r = e.body : r = await e.arrayBuffer(), new Request(t.url || e.url, {
128
+ return ["GET", "HEAD"].includes(e.method) ? r = void 0 : "body" in t ? r = t.body : !e.bodyUsed && e.body ? r = e.body : r = await e.arrayBuffer(), new Request(t.url || e.url, {
129
129
  body: r,
130
130
  method: e.method,
131
131
  headers: e.headers,
@@ -136,70 +136,91 @@ async function p(e, t) {
136
136
  cache: e.cache,
137
137
  redirect: e.redirect,
138
138
  integrity: e.integrity,
139
+ /**
140
+ * Infer the duplex value in a way that's consistent across browsers. Web browsers
141
+ * only support 'half' as of January 2026, but other values may be supported in the future.
142
+ * Unfortunately, also as of January 2026, we cannot read the duplex value directly from the
143
+ * request object:
144
+ *
145
+ * > Although duplex can be passed as an option when constructing a Request,
146
+ * > it is not currently exposed as a readable property on the resulting Request
147
+ * > object in all browsers.
148
+ *
149
+ * See MDN: https://developer.mozilla.org/en-US/docs/Web/API/Request/duplex
150
+ */
139
151
  ...r instanceof ReadableStream && { duplex: "half" },
140
152
  ...t
141
153
  });
142
154
  }
143
- async function P(e) {
155
+ async function H(e) {
144
156
  if (!e.body)
145
157
  return [e, e];
146
158
  const [t, r] = e.body.tee();
147
159
  return [
148
- await p(e, { body: t, duplex: "half" }),
149
- await p(e, { body: r, duplex: "half" })
160
+ await w(e, { body: t, duplex: "half" }),
161
+ await w(e, { body: r, duplex: "half" })
150
162
  ];
151
163
  }
152
- function $(e) {
164
+ function B(e) {
153
165
  const t = {};
154
- return e.headers.forEach((r, s) => {
155
- t[s] = r;
166
+ return e.headers.forEach((r, n) => {
167
+ t[n] = r;
156
168
  }), t;
157
169
  }
158
- function x(e, t) {
159
- const r = /^[\u{9}\u{A}\u{C}\u{D}\u{20}]+/u, s = /[\u{9}\u{A}\u{C}\u{D}\u{20}]+$/u, a = /[\u{9}\u{A}\u{C}\u{D}\u{20}]/u;
170
+ function q(e, t) {
171
+ const r = /^[\u{9}\u{A}\u{C}\u{D}\u{20}]+/u, n = /[\u{9}\u{A}\u{C}\u{D}\u{20}]+$/u, a = /[\u{9}\u{A}\u{C}\u{D}\u{20}]/u;
160
172
  return t.split(";").filter((o) => {
161
- const n = o.replace(r, "").replace(s, ""), [c] = n.split(
173
+ const s = o.replace(r, "").replace(n, ""), [u] = s.split(
162
174
  a,
163
175
  // The directive name is the first token.
164
176
  1
165
177
  );
166
- return c.toLowerCase() !== e.toLowerCase();
178
+ return u.toLowerCase() !== e.toLowerCase();
167
179
  }).join(";");
168
180
  }
169
- class A extends Error {
170
- constructor(t, r, s) {
181
+ class I extends Error {
182
+ constructor(t, r, n) {
171
183
  super(
172
184
  `Could not fetch ${t} – your network appears to be blocking this request (HTTP ${r}). This often happens on school, university, or corporate networks. Try switching to a different network or using a VPN.`
173
- ), this.name = "FirewallInterferenceError", this.url = t, this.status = r, this.statusText = s;
185
+ ), this.name = "FirewallInterferenceError", this.url = t, this.status = r, this.statusText = n;
174
186
  }
175
187
  }
176
- const q = "X-Playground-Cors-Proxy";
177
- async function k(e, t, r, s) {
178
- var f;
188
+ const O = "X-Playground-Cors-Proxy";
189
+ async function M(e, t, r, n) {
190
+ var h;
179
191
  let a = typeof e == "string" ? new Request(e, t) : e;
180
- const o = s ? new URL(s) : null;
181
- let n = o ? new URL(a.url, o) : new URL(a.url);
182
- if (n.hostname === "localhost" || n.hostname === "127.0.0.1" || n.hostname === "[::1]" || n.hostname === "::1")
183
- return await h(a);
184
- if (n.protocol === "http:") {
185
- n.protocol = "https:";
186
- const u = n.toString();
187
- a = await p(a, { url: u }), n = new URL(u);
192
+ const o = n ? new URL(n) : null;
193
+ let s = o ? new URL(a.url, o) : new URL(a.url);
194
+ if (s.hostname === "localhost" || s.hostname === "127.0.0.1" || s.hostname === "[::1]" || s.hostname === "::1")
195
+ return await fetch(a);
196
+ if (s.protocol === "http:") {
197
+ s.protocol = "https:";
198
+ const l = s.toString();
199
+ a = await w(a, { url: l }), s = new URL(l);
188
200
  }
189
201
  if (!r)
190
- return await h(a);
191
- if (o && n.protocol === o.protocol && n.hostname === o.hostname && n.port === o.port && n.pathname.startsWith(o.pathname))
192
- return await h(a);
193
- const [i, l] = await P(a);
202
+ return await fetch(a);
203
+ if (o && s.protocol === o.protocol && s.hostname === o.hostname && s.port === o.port && s.pathname.startsWith(o.pathname))
204
+ return await fetch(a);
205
+ const [c, i] = await H(a);
194
206
  try {
195
- return await h(i);
207
+ return await fetch(c);
196
208
  } catch {
197
- const d = ((f = new Headers(l.headers).get("x-cors-proxy-allowed-request-headers")) == null ? void 0 : f.split(",")) || [], b = d.includes("authorization") || d.includes("cookie"), S = await p(l, {
209
+ const l = new Headers(i.headers), d = ((h = l.get("x-cors-proxy-allowed-request-headers")) == null ? void 0 : h.split(",")) || [], U = d.includes("authorization") || d.includes("cookie"), m = l.get("content-type");
210
+ m && m.toLowerCase().includes("multipart/form-data") && (l.set("x-cors-proxy-content-type", m), l.set("content-type", "application/octet-stream"));
211
+ const p = new URL(import.meta.url);
212
+ p.pathname = "", p.search = "", p.hash = "";
213
+ const S = new URL(r, p.toString());
214
+ let f = i.body;
215
+ f && new URL(S).protocol === "http:" && (f = await new Response(f).arrayBuffer());
216
+ const C = await w(i, {
198
217
  url: `${r}${a.url}`,
199
- ...b && { credentials: "include" }
200
- }), y = await h(S, t);
201
- if (!y.headers.has(q))
202
- throw new A(
218
+ headers: l,
219
+ body: f,
220
+ ...U && { credentials: "include" }
221
+ }), y = await fetch(C);
222
+ if (!y.headers.has(O))
223
+ throw new I(
203
224
  a.url,
204
225
  y.status,
205
226
  y.statusText
@@ -207,27 +228,17 @@ async function k(e, t, r, s) {
207
228
  return y;
208
229
  }
209
230
  }
210
- async function h(e, t) {
211
- let r = t ? new Request(e, t) : e;
212
- if (new URL(r.url).protocol === "http:" && r.body) {
213
- const s = await new Response(r.body).arrayBuffer();
214
- r = await p(r, {
215
- body: s
216
- });
217
- }
218
- return fetch(r);
219
- }
220
231
  export {
221
- A as FirewallInterferenceError,
222
- C as awaitReply,
223
- T as broadcastMessageExpectReply,
224
- p as cloneRequest,
232
+ I as FirewallInterferenceError,
233
+ P as awaitReply,
234
+ A as broadcastMessageExpectReply,
235
+ w as cloneRequest,
225
236
  v as convertFetchEventToPHPRequest,
226
- k as fetchWithCorsProxy,
227
- g as getNextRequestId,
228
- $ as getRequestHeaders,
229
- O as postMessageExpectReply,
230
- x as removeContentSecurityPolicyDirective,
231
- D as responseTo,
232
- P as teeRequest
237
+ M as fetchWithCorsProxy,
238
+ L as getNextRequestId,
239
+ B as getRequestHeaders,
240
+ j as postMessageExpectReply,
241
+ q as removeContentSecurityPolicyDirective,
242
+ k as responseTo,
243
+ H as teeRequest
233
244
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@php-wasm/web-service-worker",
3
- "version": "3.1.8",
3
+ "version": "3.1.9",
4
4
  "description": "PHP.wasm – service worker utils",
5
5
  "repository": {
6
6
  "type": "git",
@@ -31,15 +31,15 @@
31
31
  "main": "./index.cjs",
32
32
  "module": "./index.js",
33
33
  "license": "GPL-2.0-or-later",
34
- "gitHead": "ba6a9509c9db4e0b7af6f155cf31162a6b659b5f",
34
+ "gitHead": "97cf88501a336453baaac9a860a17329235a71fb",
35
35
  "engines": {
36
36
  "node": ">=20.10.0",
37
37
  "npm": ">=10.2.3"
38
38
  },
39
39
  "dependencies": {
40
40
  "ini": "4.1.2",
41
- "@php-wasm/scopes": "3.1.8",
42
- "@php-wasm/universal": "3.1.8"
41
+ "@php-wasm/scopes": "3.1.9",
42
+ "@php-wasm/universal": "3.1.9"
43
43
  },
44
44
  "packageManager": "npm@10.9.2",
45
45
  "overrides": {