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

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 +133 -115
  3. package/package.json +7 -6
package/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("@php-wasm/scopes"),L=25e3;let P=0;function T(e,t,...o){const s=w();return e.postMessage({...t,requestId:s},...o),s}function w(){return++P}function m(e,t,o=L){return new Promise((s,n)=>{const r=i=>{i.data.type==="response"&&i.data.requestId===t&&(e.removeEventListener("message",r),clearTimeout(a),s(i.data.response))},a=setTimeout(()=>{n(new Error("Request timed out")),e.removeEventListener("message",r)},o);e.addEventListener("message",r)})}function U(e,t){return{type:"response",requestId:e,response:t}}async function x(e){let t=new URL(e.request.url);if(!y.isURLScoped(t))try{const c=new URL(e.request.referrer);t=y.setURLScope(t,y.getURLScope(c))}catch{}const o=e.request.headers.get("content-type"),s=e.request.method==="POST"?new Uint8Array(await e.request.clone().arrayBuffer()):void 0,n={};for(const c of e.request.headers.entries())n[c[0]]=c[1];let r;try{const c={method:"request",args:[{body:s,url:t.toString(),method:e.request.method,headers:{...n,Host:t.host,"User-agent":self.navigator.userAgent,"Content-type":o}}]},d=y.getURLScope(t);if(d===null)throw new Error(`The URL ${t.toString()} is not scoped. This should not happen.`);const p=await R(c,d);if(r=await m(self,p),delete r.headers["x-frame-options"],r.headers["content-security-policy"]){const l=r.headers["content-security-policy"].map(u=>E("frame-ancestors",u)).filter(u=>u.trim().length>0);l.length>0?r.headers["content-security-policy"]=l:delete r.headers["content-security-policy"]}}catch(c){throw console.error(c,{url:t.toString()}),c}if(r.httpStatusCode>=300&&r.httpStatusCode<=399&&r.headers.location)return Response.redirect(new URL(r.headers.location[0],t.toString()),r.httpStatusCode);const i=[101,103,204,205,304].includes(r.httpStatusCode)?null:r.bytes;return new Response(i,{headers:r.headers,status:r.httpStatusCode})}async function R(e,t){const o=w();for(const s of await self.clients.matchAll({includeUncontrolled:!0}))s.postMessage({...e,scope:t,requestId:o});return o}async function h(e,t){let o;return["GET","HEAD"].includes(e.method)||"body"in t?o=void 0:!e.bodyUsed&&e.body?o=e.body:o=await e.arrayBuffer(),new Request(t.url||e.url,{body:o,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,...o&&{duplex:"half"},...t})}async function g(e){if(!e.body)return[e,e];const[t,o]=e.body.tee();return[await h(e,{body:t,duplex:"half"}),await h(e,{body:o,duplex:"half"})]}function q(e){const t={};return e.headers.forEach((o,s)=>{t[s]=o}),t}function E(e,t){const o=/^[\u{9}\u{A}\u{C}\u{D}\u{20}]+/u,s=/[\u{9}\u{A}\u{C}\u{D}\u{20}]+$/u,n=/[\u{9}\u{A}\u{C}\u{D}\u{20}]/u;return t.split(";").filter(r=>{const a=r.replace(o,"").replace(s,""),[i]=a.split(n,1);return i.toLowerCase()!==e.toLowerCase()}).join(";")}class b extends Error{constructor(t,o,s){super(`Could not fetch ${t} – your network appears to be blocking this request (HTTP ${o}). 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=o,this.statusText=s}}const H="X-Playground-Cors-Proxy";async function A(e,t,o,s){var p;let n=typeof e=="string"?new Request(e,t):e;const r=s?new URL(s):null;let a=r?new URL(n.url,r):new URL(n.url);if(a.hostname==="localhost"||a.hostname==="127.0.0.1"||a.hostname==="[::1]"||a.hostname==="::1")return await fetch(n);if(a.protocol==="http:"){a.protocol="https:";const l=a.toString();n=await h(n,{url:l}),a=new URL(l)}if(!o)return await fetch(n);if(r&&a.protocol===r.protocol&&a.hostname===r.hostname&&a.port===r.port&&a.pathname.startsWith(r.pathname))return await fetch(n);const[c,d]=await g(n);try{return await fetch(c)}catch{const u=((p=new Headers(d.headers).get("x-cors-proxy-allowed-request-headers"))==null?void 0:p.split(","))||[],C=u.includes("authorization")||u.includes("cookie"),S=await h(d,{url:`${o}${n.url}`,...C&&{credentials:"include"}}),f=await fetch(S,t);if(!f.headers.has(H))throw new b(n.url,f.status,f.statusText);return f}}exports.FirewallInterferenceError=b;exports.awaitReply=m;exports.broadcastMessageExpectReply=R;exports.cloneRequest=h;exports.convertFetchEventToPHPRequest=x;exports.fetchWithCorsProxy=A;exports.getNextRequestId=w;exports.getRequestHeaders=q;exports.postMessageExpectReply=T;exports.removeContentSecurityPolicyDirective=E;exports.responseTo=U;exports.teeRequest=g;
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;
package/index.js CHANGED
@@ -1,50 +1,51 @@
1
- import { isURLScoped as R, setURLScope as C, getURLScope as y } from "@php-wasm/scopes";
2
- const E = 25e3;
3
- let b = 0;
4
- function H(e, t, ...o) {
5
- const s = w();
1
+ import { isURLScoped as m, setURLScope as R, getURLScope as w } from "@php-wasm/scopes";
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();
6
7
  return e.postMessage(
7
8
  {
8
9
  ...t,
9
10
  requestId: s
10
11
  },
11
- ...o
12
+ ...r
12
13
  ), s;
13
14
  }
14
- function w() {
15
- return ++b;
15
+ function g() {
16
+ return ++U;
16
17
  }
17
- function L(e, t, o = E) {
18
- return new Promise((s, n) => {
19
- const r = (i) => {
20
- i.data.type === "response" && i.data.requestId === t && (e.removeEventListener("message", r), clearTimeout(a), s(i.data.response));
21
- }, a = setTimeout(() => {
22
- n(new Error("Request timed out")), e.removeEventListener("message", r);
23
- }, o);
24
- e.addEventListener("message", r);
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(() => {
23
+ a(new Error("Request timed out")), e.removeEventListener("message", o);
24
+ }, r);
25
+ e.addEventListener("message", o);
25
26
  });
26
27
  }
27
- function q(e, t) {
28
+ function D(e, t) {
28
29
  return {
29
30
  type: "response",
30
31
  requestId: e,
31
32
  response: t
32
33
  };
33
34
  }
34
- async function I(e) {
35
+ async function v(e) {
35
36
  let t = new URL(e.request.url);
36
- if (!R(t))
37
+ if (!m(t))
37
38
  try {
38
- const c = new URL(e.request.referrer);
39
- t = C(t, y(c));
39
+ const i = new URL(e.request.referrer);
40
+ t = R(t, w(i));
40
41
  } catch {
41
42
  }
42
- const o = e.request.headers.get("content-type"), s = e.request.method === "POST" ? new Uint8Array(await e.request.clone().arrayBuffer()) : void 0, n = {};
43
- for (const c of e.request.headers.entries())
44
- n[c[0]] = c[1];
45
- let r;
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];
46
+ let o;
46
47
  try {
47
- const c = {
48
+ const i = {
48
49
  method: "request",
49
50
  args: [
50
51
  {
@@ -52,48 +53,55 @@ async function I(e) {
52
53
  url: t.toString(),
53
54
  method: e.request.method,
54
55
  headers: {
55
- ...n,
56
+ ...a,
56
57
  Host: t.host,
57
58
  // Safari and Firefox don't make the User-Agent header
58
59
  // available in the fetch event. Let's add it manually:
59
60
  "User-agent": self.navigator.userAgent,
60
- "Content-type": o
61
+ "Content-type": r
61
62
  }
62
63
  }
63
64
  ]
64
- }, d = y(t);
65
- if (d === null)
65
+ }, l = w(t);
66
+ if (l === null)
66
67
  throw new Error(
67
68
  `The URL ${t.toString()} is not scoped. This should not happen.`
68
69
  );
69
- const h = await U(c, d);
70
- if (r = await L(self, h), delete r.headers["x-frame-options"], r.headers["content-security-policy"]) {
71
- const l = r.headers["content-security-policy"].map(
72
- (u) => T(
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(
73
74
  "frame-ancestors",
74
- u
75
+ d
75
76
  )
76
- ).filter((u) => u.trim().length > 0);
77
- l.length > 0 ? r.headers["content-security-policy"] = l : delete r.headers["content-security-policy"];
77
+ ).filter((d) => d.trim().length > 0);
78
+ u.length > 0 ? o.headers["content-security-policy"] = u : delete o.headers["content-security-policy"];
78
79
  }
79
- } catch (c) {
80
- throw console.error(c, { url: t.toString() }), c;
80
+ } catch (i) {
81
+ throw console.error(i, { url: t.toString() }), i;
81
82
  }
82
- if (r.httpStatusCode >= 300 && r.httpStatusCode <= 399 && r.headers.location)
83
- return Response.redirect(
84
- new URL(r.headers.location[0], t.toString()),
85
- r.httpStatusCode
83
+ if (o.httpStatusCode >= 300 && o.httpStatusCode <= 399 && o.headers.location) {
84
+ const i = w(t);
85
+ let l = new URL(
86
+ o.headers.location[0],
87
+ t.toString()
88
+ );
89
+ return i && !m(l) && (l = R(l, i)), Response.redirect(
90
+ l.toString(),
91
+ o.httpStatusCode
86
92
  );
87
- const i = [101, 103, 204, 205, 304].includes(
88
- r.httpStatusCode
89
- ) ? null : r.bytes;
90
- return new Response(i, {
91
- headers: r.headers,
92
- status: r.httpStatusCode
93
+ }
94
+ const n = [101, 103, 204, 205, 304].includes(
95
+ o.httpStatusCode
96
+ );
97
+ let c = null;
98
+ return n || (o.bodyPort ? c = E(o.bodyPort) : c = o.bytes), new Response(c, {
99
+ headers: o.headers,
100
+ status: o.httpStatusCode
93
101
  });
94
102
  }
95
- async function U(e, t) {
96
- const o = w();
103
+ async function T(e, t) {
104
+ const r = g();
97
105
  for (const s of await self.clients.matchAll({
98
106
  // Sometimes the client that triggered the current fetch()
99
107
  // event is considered uncontrolled in Google Chrome. This
@@ -111,14 +119,14 @@ async function U(e, t) {
111
119
  * helps WASM workers ignore requests meant for other WASM workers.
112
120
  */
113
121
  scope: t,
114
- requestId: o
122
+ requestId: r
115
123
  });
116
- return o;
124
+ return r;
117
125
  }
118
- async function f(e, t) {
119
- let o;
120
- return ["GET", "HEAD"].includes(e.method) || "body" in t ? o = void 0 : !e.bodyUsed && e.body ? o = e.body : o = await e.arrayBuffer(), new Request(t.url || e.url, {
121
- body: o,
126
+ async function p(e, t) {
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, {
129
+ body: r,
122
130
  method: e.method,
123
131
  headers: e.headers,
124
132
  referrer: e.referrer,
@@ -128,88 +136,98 @@ async function f(e, t) {
128
136
  cache: e.cache,
129
137
  redirect: e.redirect,
130
138
  integrity: e.integrity,
131
- ...o && { duplex: "half" },
139
+ ...r instanceof ReadableStream && { duplex: "half" },
132
140
  ...t
133
141
  });
134
142
  }
135
- async function S(e) {
143
+ async function P(e) {
136
144
  if (!e.body)
137
145
  return [e, e];
138
- const [t, o] = e.body.tee();
146
+ const [t, r] = e.body.tee();
139
147
  return [
140
- await f(e, { body: t, duplex: "half" }),
141
- await f(e, { body: o, duplex: "half" })
148
+ await p(e, { body: t, duplex: "half" }),
149
+ await p(e, { body: r, duplex: "half" })
142
150
  ];
143
151
  }
144
- function O(e) {
152
+ function $(e) {
145
153
  const t = {};
146
- return e.headers.forEach((o, s) => {
147
- t[s] = o;
154
+ return e.headers.forEach((r, s) => {
155
+ t[s] = r;
148
156
  }), t;
149
157
  }
150
- function T(e, t) {
151
- const o = /^[\u{9}\u{A}\u{C}\u{D}\u{20}]+/u, s = /[\u{9}\u{A}\u{C}\u{D}\u{20}]+$/u, n = /[\u{9}\u{A}\u{C}\u{D}\u{20}]/u;
152
- return t.split(";").filter((r) => {
153
- const a = r.replace(o, "").replace(s, ""), [i] = a.split(
154
- n,
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;
160
+ return t.split(";").filter((o) => {
161
+ const n = o.replace(r, "").replace(s, ""), [c] = n.split(
162
+ a,
155
163
  // The directive name is the first token.
156
164
  1
157
165
  );
158
- return i.toLowerCase() !== e.toLowerCase();
166
+ return c.toLowerCase() !== e.toLowerCase();
159
167
  }).join(";");
160
168
  }
161
- class x extends Error {
162
- constructor(t, o, s) {
169
+ class A extends Error {
170
+ constructor(t, r, s) {
163
171
  super(
164
- `Could not fetch ${t} – your network appears to be blocking this request (HTTP ${o}). This often happens on school, university, or corporate networks. Try switching to a different network or using a VPN.`
165
- ), this.name = "FirewallInterferenceError", this.url = t, this.status = o, this.statusText = s;
172
+ `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;
166
174
  }
167
175
  }
168
- const P = "X-Playground-Cors-Proxy";
169
- async function D(e, t, o, s) {
170
- var h;
171
- let n = typeof e == "string" ? new Request(e, t) : e;
172
- const r = s ? new URL(s) : null;
173
- let a = r ? new URL(n.url, r) : new URL(n.url);
174
- if (a.hostname === "localhost" || a.hostname === "127.0.0.1" || a.hostname === "[::1]" || a.hostname === "::1")
175
- return await fetch(n);
176
- if (a.protocol === "http:") {
177
- a.protocol = "https:";
178
- const l = a.toString();
179
- n = await f(n, { url: l }), a = new URL(l);
176
+ const q = "X-Playground-Cors-Proxy";
177
+ async function k(e, t, r, s) {
178
+ var f;
179
+ 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);
180
188
  }
181
- if (!o)
182
- return await fetch(n);
183
- if (r && a.protocol === r.protocol && a.hostname === r.hostname && a.port === r.port && a.pathname.startsWith(r.pathname))
184
- return await fetch(n);
185
- const [c, d] = await S(n);
189
+ 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);
186
194
  try {
187
- return await fetch(c);
195
+ return await h(i);
188
196
  } catch {
189
- const u = ((h = new Headers(d.headers).get("x-cors-proxy-allowed-request-headers")) == null ? void 0 : h.split(",")) || [], m = u.includes("authorization") || u.includes("cookie"), g = await f(d, {
190
- url: `${o}${n.url}`,
191
- ...m && { credentials: "include" }
192
- }), p = await fetch(g, t);
193
- if (!p.headers.has(P))
194
- throw new x(
195
- n.url,
196
- p.status,
197
- p.statusText
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, {
198
+ url: `${r}${a.url}`,
199
+ ...b && { credentials: "include" }
200
+ }), y = await h(S, t);
201
+ if (!y.headers.has(q))
202
+ throw new A(
203
+ a.url,
204
+ y.status,
205
+ y.statusText
198
206
  );
199
- return p;
207
+ return y;
208
+ }
209
+ }
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
+ });
200
217
  }
218
+ return fetch(r);
201
219
  }
202
220
  export {
203
- x as FirewallInterferenceError,
204
- L as awaitReply,
205
- U as broadcastMessageExpectReply,
206
- f as cloneRequest,
207
- I as convertFetchEventToPHPRequest,
208
- D as fetchWithCorsProxy,
209
- w as getNextRequestId,
210
- O as getRequestHeaders,
211
- H as postMessageExpectReply,
212
- T as removeContentSecurityPolicyDirective,
213
- q as responseTo,
214
- S as teeRequest
221
+ A as FirewallInterferenceError,
222
+ C as awaitReply,
223
+ T as broadcastMessageExpectReply,
224
+ p as cloneRequest,
225
+ 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
215
233
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@php-wasm/web-service-worker",
3
- "version": "3.1.4",
3
+ "version": "3.1.8",
4
4
  "description": "PHP.wasm – service worker utils",
5
5
  "repository": {
6
6
  "type": "git",
@@ -31,11 +31,16 @@
31
31
  "main": "./index.cjs",
32
32
  "module": "./index.js",
33
33
  "license": "GPL-2.0-or-later",
34
- "gitHead": "a7cde6f2a2d3cef27f51f24e9ddadbe5ca05344b",
34
+ "gitHead": "ba6a9509c9db4e0b7af6f155cf31162a6b659b5f",
35
35
  "engines": {
36
36
  "node": ">=20.10.0",
37
37
  "npm": ">=10.2.3"
38
38
  },
39
+ "dependencies": {
40
+ "ini": "4.1.2",
41
+ "@php-wasm/scopes": "3.1.8",
42
+ "@php-wasm/universal": "3.1.8"
43
+ },
39
44
  "packageManager": "npm@10.9.2",
40
45
  "overrides": {
41
46
  "rollup": "^4.34.6",
@@ -43,13 +48,9 @@
43
48
  "react-dom": "18.3.1",
44
49
  "typescript": "5.4.5",
45
50
  "@playwright/test": "1.55.1",
46
- "ws": "8.18.3",
47
51
  "tmp": "0.2.5",
48
52
  "form-data": "^4.0.4",
49
53
  "lodash": "^4.17.23",
50
54
  "glob": "^9.3.0"
51
- },
52
- "dependencies": {
53
- "@php-wasm/scopes": "3.1.4"
54
55
  }
55
56
  }