unplugin-https-reverse-proxy 4.0.3 → 4.0.4

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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  hmrSseBridgeClientScript,
3
3
  setupHmrSseBridge
4
- } from "./chunk-RSBXFJ3Z.js";
4
+ } from "./chunk-C5A7XLKL.js";
5
5
  import {
6
6
  chmodRecursive,
7
7
  consola,
@@ -14266,7 +14266,7 @@ var unpluginFactory = (options) => ({
14266
14266
  if (options.https) {
14267
14267
  setupHmrSseBridge(server);
14268
14268
  hmrSseBridgeActive = true;
14269
- consola.info("HMR SSE bridge enabled for iOS Safari WSS workaround");
14269
+ consola.info("HMR SSE bridge enabled for macOS/iOS Safari WSS workaround");
14270
14270
  }
14271
14271
  },
14272
14272
  transformIndexHtml() {
@@ -99,10 +99,16 @@ function handleClientMessage(req, res, server) {
99
99
  }
100
100
  });
101
101
  }
102
+ function shouldUseHmrSseBridge(protocol, userAgent) {
103
+ if (protocol !== "https:")
104
+ return false;
105
+ const isApplePlatform = /Macintosh|iPhone|iPad|iPod/.test(userAgent);
106
+ const isSafari = /Version\//.test(userAgent) && /Safari\//.test(userAgent) && !/(?:Chrome|Chromium|CriOS|Edg|EdgiOS|OPR|OPiOS|Firefox|FxiOS)\//.test(userAgent);
107
+ return isApplePlatform && isSafari;
108
+ }
102
109
  var hmrSseBridgeClientScript = `
103
110
  (function() {
104
- // Activate when served over HTTPS to bypass WSS self-signed cert issues
105
- if (location.protocol !== 'https:') return;
111
+ if (!(${shouldUseHmrSseBridge.toString()})(location.protocol, navigator.userAgent)) return;
106
112
 
107
113
  var OriginalWebSocket = window.WebSocket;
108
114
 
@@ -228,5 +234,6 @@ var hmrSseBridgeClientScript = `
228
234
 
229
235
  export {
230
236
  setupHmrSseBridge,
237
+ shouldUseHmrSseBridge,
231
238
  hmrSseBridgeClientScript
232
239
  };
package/dist/esbuild.cjs CHANGED
@@ -14355,10 +14355,16 @@ function handleClientMessage(req, res, server) {
14355
14355
  }
14356
14356
  });
14357
14357
  }
14358
+ function shouldUseHmrSseBridge(protocol, userAgent) {
14359
+ if (protocol !== "https:")
14360
+ return false;
14361
+ const isApplePlatform = /Macintosh|iPhone|iPad|iPod/.test(userAgent);
14362
+ const isSafari = /Version\//.test(userAgent) && /Safari\//.test(userAgent) && !/(?:Chrome|Chromium|CriOS|Edg|EdgiOS|OPR|OPiOS|Firefox|FxiOS)\//.test(userAgent);
14363
+ return isApplePlatform && isSafari;
14364
+ }
14358
14365
  var hmrSseBridgeClientScript = `
14359
14366
  (function() {
14360
- // Activate when served over HTTPS to bypass WSS self-signed cert issues
14361
- if (location.protocol !== 'https:') return;
14367
+ if (!(${shouldUseHmrSseBridge.toString()})(location.protocol, navigator.userAgent)) return;
14362
14368
 
14363
14369
  var OriginalWebSocket = window.WebSocket;
14364
14370
 
@@ -14575,7 +14581,7 @@ var unpluginFactory = (options) => ({
14575
14581
  if (options.https) {
14576
14582
  setupHmrSseBridge(server);
14577
14583
  hmrSseBridgeActive = true;
14578
- consola.info("HMR SSE bridge enabled for iOS Safari WSS workaround");
14584
+ consola.info("HMR SSE bridge enabled for macOS/iOS Safari WSS workaround");
14579
14585
  }
14580
14586
  },
14581
14587
  transformIndexHtml() {
package/dist/esbuild.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-MD5CVZP7.js";
4
- import "./chunk-RSBXFJ3Z.js";
3
+ } from "./chunk-5R33PUJP.js";
4
+ import "./chunk-C5A7XLKL.js";
5
5
  import "./chunk-2P7SUCQ3.js";
6
6
 
7
7
  // src/esbuild.ts
@@ -21,7 +21,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var hmr_sse_bridge_exports = {};
22
22
  __export(hmr_sse_bridge_exports, {
23
23
  hmrSseBridgeClientScript: () => hmrSseBridgeClientScript,
24
- setupHmrSseBridge: () => setupHmrSseBridge
24
+ setupHmrSseBridge: () => setupHmrSseBridge,
25
+ shouldUseHmrSseBridge: () => shouldUseHmrSseBridge
25
26
  });
26
27
  module.exports = __toCommonJS(hmr_sse_bridge_exports);
27
28
  var SSE_PATH = "/__hmr_sse";
@@ -124,10 +125,16 @@ function handleClientMessage(req, res, server) {
124
125
  }
125
126
  });
126
127
  }
128
+ function shouldUseHmrSseBridge(protocol, userAgent) {
129
+ if (protocol !== "https:")
130
+ return false;
131
+ const isApplePlatform = /Macintosh|iPhone|iPad|iPod/.test(userAgent);
132
+ const isSafari = /Version\//.test(userAgent) && /Safari\//.test(userAgent) && !/(?:Chrome|Chromium|CriOS|Edg|EdgiOS|OPR|OPiOS|Firefox|FxiOS)\//.test(userAgent);
133
+ return isApplePlatform && isSafari;
134
+ }
127
135
  var hmrSseBridgeClientScript = `
128
136
  (function() {
129
- // Activate when served over HTTPS to bypass WSS self-signed cert issues
130
- if (location.protocol !== 'https:') return;
137
+ if (!(${shouldUseHmrSseBridge.toString()})(location.protocol, navigator.userAgent)) return;
131
138
 
132
139
  var OriginalWebSocket = window.WebSocket;
133
140
 
@@ -253,6 +260,7 @@ var hmrSseBridgeClientScript = `
253
260
  // Annotate the CommonJS export names for ESM import in node:
254
261
  0 && (module.exports = {
255
262
  hmrSseBridgeClientScript,
256
- setupHmrSseBridge
263
+ setupHmrSseBridge,
264
+ shouldUseHmrSseBridge
257
265
  });
258
266
  exports.default = module.exports;
@@ -1,10 +1,11 @@
1
1
  import { ViteDevServer } from 'vite';
2
2
 
3
3
  declare function setupHmrSseBridge(server: ViteDevServer): void;
4
+ declare function shouldUseHmrSseBridge(protocol: string, userAgent: string): boolean;
4
5
  /**
5
- * Client-side script that patches WebSocket to use SSE+fetch on iOS Safari.
6
+ * Client-side script that patches WebSocket to use SSE+fetch on macOS/iOS Safari.
6
7
  * This script is injected via Vite's transformIndexHtml hook.
7
8
  */
8
- declare const hmrSseBridgeClientScript = "\n(function() {\n // Activate when served over HTTPS to bypass WSS self-signed cert issues\n if (location.protocol !== 'https:') return;\n\n var OriginalWebSocket = window.WebSocket;\n\n function SseWebSocket(originalUrl) {\n var self = this;\n // WebSocket readyState constants on instance\n self.CONNECTING = 0;\n self.OPEN = 1;\n self.CLOSING = 2;\n self.CLOSED = 3;\n self.readyState = 0;\n self.onopen = null;\n self.onmessage = null;\n self.onclose = null;\n self.onerror = null;\n self.bufferedAmount = 0;\n self.extensions = '';\n self.binaryType = 'blob';\n self.protocol = 'vite-hmr';\n self.url = originalUrl;\n self._listeners = {};\n self._opened = false;\n\n var sseUrl = location.origin + '/__hmr_sse';\n var sendUrl = location.origin + '/__hmr_send';\n self._sendUrl = sendUrl;\n\n var es = new EventSource(sseUrl);\n self._es = es;\n\n es.onopen = function() {\n if (self._opened) return;\n self._opened = true;\n self.readyState = 1;\n var evt = new Event('open');\n if (self.onopen) self.onopen(evt);\n self._emit('open', evt);\n };\n\n es.onmessage = function(e) {\n var evt = new MessageEvent('message', { data: e.data });\n if (self.onmessage) self.onmessage(evt);\n self._emit('message', evt);\n };\n\n es.onerror = function() {\n // EventSource auto-reconnects on error; don't treat as fatal close\n // Only emit error event, never close event (SSE handles reconnect internally)\n if (self.readyState >= 2) return;\n // EventSource auto-reconnects; no action needed\n };\n }\n\n SseWebSocket.prototype.send = function(data) {\n if (this.readyState !== 1) return;\n fetch(this._sendUrl, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: data\n }).catch(function() {});\n };\n\n SseWebSocket.prototype.close = function() {\n if (this.readyState >= 2) return;\n this.readyState = 3;\n if (this._es) this._es.close();\n var evt = new CloseEvent('close', { code: 1000, reason: '', wasClean: true });\n if (this.onclose) this.onclose(evt);\n this._emit('close', evt);\n };\n\n SseWebSocket.prototype.addEventListener = function(type, fn, options) {\n if (!this._listeners[type]) this._listeners[type] = [];\n var entry = { fn: fn, once: !!(options && options.once) };\n this._listeners[type].push(entry);\n };\n\n SseWebSocket.prototype.removeEventListener = function(type, fn) {\n var list = this._listeners[type];\n if (!list) return;\n this._listeners[type] = list.filter(function(e) { return e.fn !== fn; });\n };\n\n SseWebSocket.prototype.dispatchEvent = function(evt) {\n this._emit(evt.type, evt);\n return true;\n };\n\n SseWebSocket.prototype._emit = function(type, evt) {\n var list = this._listeners[type];\n if (!list) return;\n var remaining = [];\n list.forEach(function(entry) {\n entry.fn(evt);\n if (!entry.once) remaining.push(entry);\n });\n this._listeners[type] = remaining;\n };\n\n function PatchedWebSocket(url, protocols) {\n // Only intercept Vite HMR connections (protocol 'vite-hmr')\n var isViteHmr = protocols === 'vite-hmr'\n || (Array.isArray(protocols) && protocols.indexOf('vite-hmr') !== -1);\n if (!isViteHmr) {\n if (protocols !== undefined) {\n return new OriginalWebSocket(url, protocols);\n }\n return new OriginalWebSocket(url);\n }\n return new SseWebSocket(url);\n }\n\n PatchedWebSocket.CONNECTING = 0;\n PatchedWebSocket.OPEN = 1;\n PatchedWebSocket.CLOSING = 2;\n PatchedWebSocket.CLOSED = 3;\n PatchedWebSocket.prototype = Object.create(OriginalWebSocket.prototype);\n PatchedWebSocket.prototype.constructor = PatchedWebSocket;\n\n window.WebSocket = PatchedWebSocket;\n})();\n";
9
+ declare const hmrSseBridgeClientScript: string;
9
10
 
10
- export { hmrSseBridgeClientScript, setupHmrSseBridge };
11
+ export { hmrSseBridgeClientScript, setupHmrSseBridge, shouldUseHmrSseBridge };
@@ -1,10 +1,11 @@
1
1
  import { ViteDevServer } from 'vite';
2
2
 
3
3
  declare function setupHmrSseBridge(server: ViteDevServer): void;
4
+ declare function shouldUseHmrSseBridge(protocol: string, userAgent: string): boolean;
4
5
  /**
5
- * Client-side script that patches WebSocket to use SSE+fetch on iOS Safari.
6
+ * Client-side script that patches WebSocket to use SSE+fetch on macOS/iOS Safari.
6
7
  * This script is injected via Vite's transformIndexHtml hook.
7
8
  */
8
- declare const hmrSseBridgeClientScript = "\n(function() {\n // Activate when served over HTTPS to bypass WSS self-signed cert issues\n if (location.protocol !== 'https:') return;\n\n var OriginalWebSocket = window.WebSocket;\n\n function SseWebSocket(originalUrl) {\n var self = this;\n // WebSocket readyState constants on instance\n self.CONNECTING = 0;\n self.OPEN = 1;\n self.CLOSING = 2;\n self.CLOSED = 3;\n self.readyState = 0;\n self.onopen = null;\n self.onmessage = null;\n self.onclose = null;\n self.onerror = null;\n self.bufferedAmount = 0;\n self.extensions = '';\n self.binaryType = 'blob';\n self.protocol = 'vite-hmr';\n self.url = originalUrl;\n self._listeners = {};\n self._opened = false;\n\n var sseUrl = location.origin + '/__hmr_sse';\n var sendUrl = location.origin + '/__hmr_send';\n self._sendUrl = sendUrl;\n\n var es = new EventSource(sseUrl);\n self._es = es;\n\n es.onopen = function() {\n if (self._opened) return;\n self._opened = true;\n self.readyState = 1;\n var evt = new Event('open');\n if (self.onopen) self.onopen(evt);\n self._emit('open', evt);\n };\n\n es.onmessage = function(e) {\n var evt = new MessageEvent('message', { data: e.data });\n if (self.onmessage) self.onmessage(evt);\n self._emit('message', evt);\n };\n\n es.onerror = function() {\n // EventSource auto-reconnects on error; don't treat as fatal close\n // Only emit error event, never close event (SSE handles reconnect internally)\n if (self.readyState >= 2) return;\n // EventSource auto-reconnects; no action needed\n };\n }\n\n SseWebSocket.prototype.send = function(data) {\n if (this.readyState !== 1) return;\n fetch(this._sendUrl, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: data\n }).catch(function() {});\n };\n\n SseWebSocket.prototype.close = function() {\n if (this.readyState >= 2) return;\n this.readyState = 3;\n if (this._es) this._es.close();\n var evt = new CloseEvent('close', { code: 1000, reason: '', wasClean: true });\n if (this.onclose) this.onclose(evt);\n this._emit('close', evt);\n };\n\n SseWebSocket.prototype.addEventListener = function(type, fn, options) {\n if (!this._listeners[type]) this._listeners[type] = [];\n var entry = { fn: fn, once: !!(options && options.once) };\n this._listeners[type].push(entry);\n };\n\n SseWebSocket.prototype.removeEventListener = function(type, fn) {\n var list = this._listeners[type];\n if (!list) return;\n this._listeners[type] = list.filter(function(e) { return e.fn !== fn; });\n };\n\n SseWebSocket.prototype.dispatchEvent = function(evt) {\n this._emit(evt.type, evt);\n return true;\n };\n\n SseWebSocket.prototype._emit = function(type, evt) {\n var list = this._listeners[type];\n if (!list) return;\n var remaining = [];\n list.forEach(function(entry) {\n entry.fn(evt);\n if (!entry.once) remaining.push(entry);\n });\n this._listeners[type] = remaining;\n };\n\n function PatchedWebSocket(url, protocols) {\n // Only intercept Vite HMR connections (protocol 'vite-hmr')\n var isViteHmr = protocols === 'vite-hmr'\n || (Array.isArray(protocols) && protocols.indexOf('vite-hmr') !== -1);\n if (!isViteHmr) {\n if (protocols !== undefined) {\n return new OriginalWebSocket(url, protocols);\n }\n return new OriginalWebSocket(url);\n }\n return new SseWebSocket(url);\n }\n\n PatchedWebSocket.CONNECTING = 0;\n PatchedWebSocket.OPEN = 1;\n PatchedWebSocket.CLOSING = 2;\n PatchedWebSocket.CLOSED = 3;\n PatchedWebSocket.prototype = Object.create(OriginalWebSocket.prototype);\n PatchedWebSocket.prototype.constructor = PatchedWebSocket;\n\n window.WebSocket = PatchedWebSocket;\n})();\n";
9
+ declare const hmrSseBridgeClientScript: string;
9
10
 
10
- export { hmrSseBridgeClientScript, setupHmrSseBridge };
11
+ export { hmrSseBridgeClientScript, setupHmrSseBridge, shouldUseHmrSseBridge };
@@ -1,8 +1,10 @@
1
1
  import {
2
2
  hmrSseBridgeClientScript,
3
- setupHmrSseBridge
4
- } from "./chunk-RSBXFJ3Z.js";
3
+ setupHmrSseBridge,
4
+ shouldUseHmrSseBridge
5
+ } from "./chunk-C5A7XLKL.js";
5
6
  export {
6
7
  hmrSseBridgeClientScript,
7
- setupHmrSseBridge
8
+ setupHmrSseBridge,
9
+ shouldUseHmrSseBridge
8
10
  };
package/dist/index.cjs CHANGED
@@ -14355,10 +14355,16 @@ function handleClientMessage(req, res, server) {
14355
14355
  }
14356
14356
  });
14357
14357
  }
14358
+ function shouldUseHmrSseBridge(protocol, userAgent) {
14359
+ if (protocol !== "https:")
14360
+ return false;
14361
+ const isApplePlatform = /Macintosh|iPhone|iPad|iPod/.test(userAgent);
14362
+ const isSafari = /Version\//.test(userAgent) && /Safari\//.test(userAgent) && !/(?:Chrome|Chromium|CriOS|Edg|EdgiOS|OPR|OPiOS|Firefox|FxiOS)\//.test(userAgent);
14363
+ return isApplePlatform && isSafari;
14364
+ }
14358
14365
  var hmrSseBridgeClientScript = `
14359
14366
  (function() {
14360
- // Activate when served over HTTPS to bypass WSS self-signed cert issues
14361
- if (location.protocol !== 'https:') return;
14367
+ if (!(${shouldUseHmrSseBridge.toString()})(location.protocol, navigator.userAgent)) return;
14362
14368
 
14363
14369
  var OriginalWebSocket = window.WebSocket;
14364
14370
 
@@ -14575,7 +14581,7 @@ var unpluginFactory = (options) => ({
14575
14581
  if (options.https) {
14576
14582
  setupHmrSseBridge(server);
14577
14583
  hmrSseBridgeActive = true;
14578
- consola.info("HMR SSE bridge enabled for iOS Safari WSS workaround");
14584
+ consola.info("HMR SSE bridge enabled for macOS/iOS Safari WSS workaround");
14579
14585
  }
14580
14586
  },
14581
14587
  transformIndexHtml() {
package/dist/index.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  unplugin,
4
4
  unpluginFactory,
5
5
  vitePrintUrls
6
- } from "./chunk-MD5CVZP7.js";
7
- import "./chunk-RSBXFJ3Z.js";
6
+ } from "./chunk-5R33PUJP.js";
7
+ import "./chunk-C5A7XLKL.js";
8
8
  import "./chunk-2P7SUCQ3.js";
9
9
  export {
10
10
  src_default as default,
package/dist/nuxt.cjs CHANGED
@@ -14259,10 +14259,16 @@ ${line}
14259
14259
  var SSE_PATH = "/__hmr_sse";
14260
14260
  var SEND_PATH = "/__hmr_send";
14261
14261
  var MAX_POST_BODY = 64 * 1024;
14262
+ function shouldUseHmrSseBridge(protocol, userAgent) {
14263
+ if (protocol !== "https:")
14264
+ return false;
14265
+ const isApplePlatform = /Macintosh|iPhone|iPad|iPod/.test(userAgent);
14266
+ const isSafari = /Version\//.test(userAgent) && /Safari\//.test(userAgent) && !/(?:Chrome|Chromium|CriOS|Edg|EdgiOS|OPR|OPiOS|Firefox|FxiOS)\//.test(userAgent);
14267
+ return isApplePlatform && isSafari;
14268
+ }
14262
14269
  var hmrSseBridgeClientScript = `
14263
14270
  (function() {
14264
- // Activate when served over HTTPS to bypass WSS self-signed cert issues
14265
- if (location.protocol !== 'https:') return;
14271
+ if (!(${shouldUseHmrSseBridge.toString()})(location.protocol, navigator.userAgent)) return;
14266
14272
 
14267
14273
  var OriginalWebSocket = window.WebSocket;
14268
14274
 
package/dist/nuxt.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  vitePrintUrls
3
- } from "./chunk-MD5CVZP7.js";
4
- import "./chunk-RSBXFJ3Z.js";
3
+ } from "./chunk-5R33PUJP.js";
4
+ import "./chunk-C5A7XLKL.js";
5
5
  import {
6
6
  consola,
7
7
  isAdmin
package/dist/rollup.cjs CHANGED
@@ -14355,10 +14355,16 @@ function handleClientMessage(req, res, server) {
14355
14355
  }
14356
14356
  });
14357
14357
  }
14358
+ function shouldUseHmrSseBridge(protocol, userAgent) {
14359
+ if (protocol !== "https:")
14360
+ return false;
14361
+ const isApplePlatform = /Macintosh|iPhone|iPad|iPod/.test(userAgent);
14362
+ const isSafari = /Version\//.test(userAgent) && /Safari\//.test(userAgent) && !/(?:Chrome|Chromium|CriOS|Edg|EdgiOS|OPR|OPiOS|Firefox|FxiOS)\//.test(userAgent);
14363
+ return isApplePlatform && isSafari;
14364
+ }
14358
14365
  var hmrSseBridgeClientScript = `
14359
14366
  (function() {
14360
- // Activate when served over HTTPS to bypass WSS self-signed cert issues
14361
- if (location.protocol !== 'https:') return;
14367
+ if (!(${shouldUseHmrSseBridge.toString()})(location.protocol, navigator.userAgent)) return;
14362
14368
 
14363
14369
  var OriginalWebSocket = window.WebSocket;
14364
14370
 
@@ -14575,7 +14581,7 @@ var unpluginFactory = (options) => ({
14575
14581
  if (options.https) {
14576
14582
  setupHmrSseBridge(server);
14577
14583
  hmrSseBridgeActive = true;
14578
- consola.info("HMR SSE bridge enabled for iOS Safari WSS workaround");
14584
+ consola.info("HMR SSE bridge enabled for macOS/iOS Safari WSS workaround");
14579
14585
  }
14580
14586
  },
14581
14587
  transformIndexHtml() {
package/dist/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-MD5CVZP7.js";
4
- import "./chunk-RSBXFJ3Z.js";
3
+ } from "./chunk-5R33PUJP.js";
4
+ import "./chunk-C5A7XLKL.js";
5
5
  import "./chunk-2P7SUCQ3.js";
6
6
 
7
7
  // src/rollup.ts
package/dist/rspack.cjs CHANGED
@@ -14354,10 +14354,16 @@ function handleClientMessage(req, res, server) {
14354
14354
  }
14355
14355
  });
14356
14356
  }
14357
+ function shouldUseHmrSseBridge(protocol, userAgent) {
14358
+ if (protocol !== "https:")
14359
+ return false;
14360
+ const isApplePlatform = /Macintosh|iPhone|iPad|iPod/.test(userAgent);
14361
+ const isSafari = /Version\//.test(userAgent) && /Safari\//.test(userAgent) && !/(?:Chrome|Chromium|CriOS|Edg|EdgiOS|OPR|OPiOS|Firefox|FxiOS)\//.test(userAgent);
14362
+ return isApplePlatform && isSafari;
14363
+ }
14357
14364
  var hmrSseBridgeClientScript = `
14358
14365
  (function() {
14359
- // Activate when served over HTTPS to bypass WSS self-signed cert issues
14360
- if (location.protocol !== 'https:') return;
14366
+ if (!(${shouldUseHmrSseBridge.toString()})(location.protocol, navigator.userAgent)) return;
14361
14367
 
14362
14368
  var OriginalWebSocket = window.WebSocket;
14363
14369
 
@@ -14574,7 +14580,7 @@ var unpluginFactory = (options) => ({
14574
14580
  if (options.https) {
14575
14581
  setupHmrSseBridge(server);
14576
14582
  hmrSseBridgeActive = true;
14577
- consola.info("HMR SSE bridge enabled for iOS Safari WSS workaround");
14583
+ consola.info("HMR SSE bridge enabled for macOS/iOS Safari WSS workaround");
14578
14584
  }
14579
14585
  },
14580
14586
  transformIndexHtml() {
package/dist/rspack.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  src_default
3
- } from "./chunk-MD5CVZP7.js";
4
- import "./chunk-RSBXFJ3Z.js";
3
+ } from "./chunk-5R33PUJP.js";
4
+ import "./chunk-C5A7XLKL.js";
5
5
  import "./chunk-2P7SUCQ3.js";
6
6
 
7
7
  // src/rspack.ts
package/dist/vite.cjs CHANGED
@@ -14355,10 +14355,16 @@ function handleClientMessage(req, res, server) {
14355
14355
  }
14356
14356
  });
14357
14357
  }
14358
+ function shouldUseHmrSseBridge(protocol, userAgent) {
14359
+ if (protocol !== "https:")
14360
+ return false;
14361
+ const isApplePlatform = /Macintosh|iPhone|iPad|iPod/.test(userAgent);
14362
+ const isSafari = /Version\//.test(userAgent) && /Safari\//.test(userAgent) && !/(?:Chrome|Chromium|CriOS|Edg|EdgiOS|OPR|OPiOS|Firefox|FxiOS)\//.test(userAgent);
14363
+ return isApplePlatform && isSafari;
14364
+ }
14358
14365
  var hmrSseBridgeClientScript = `
14359
14366
  (function() {
14360
- // Activate when served over HTTPS to bypass WSS self-signed cert issues
14361
- if (location.protocol !== 'https:') return;
14367
+ if (!(${shouldUseHmrSseBridge.toString()})(location.protocol, navigator.userAgent)) return;
14362
14368
 
14363
14369
  var OriginalWebSocket = window.WebSocket;
14364
14370
 
@@ -14575,7 +14581,7 @@ var unpluginFactory = (options) => ({
14575
14581
  if (options.https) {
14576
14582
  setupHmrSseBridge(server);
14577
14583
  hmrSseBridgeActive = true;
14578
- consola.info("HMR SSE bridge enabled for iOS Safari WSS workaround");
14584
+ consola.info("HMR SSE bridge enabled for macOS/iOS Safari WSS workaround");
14579
14585
  }
14580
14586
  },
14581
14587
  transformIndexHtml() {
package/dist/vite.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-MD5CVZP7.js";
4
- import "./chunk-RSBXFJ3Z.js";
3
+ } from "./chunk-5R33PUJP.js";
4
+ import "./chunk-C5A7XLKL.js";
5
5
  import "./chunk-2P7SUCQ3.js";
6
6
 
7
7
  // src/vite.ts
package/dist/webpack.cjs CHANGED
@@ -14355,10 +14355,16 @@ function handleClientMessage(req, res, server) {
14355
14355
  }
14356
14356
  });
14357
14357
  }
14358
+ function shouldUseHmrSseBridge(protocol, userAgent) {
14359
+ if (protocol !== "https:")
14360
+ return false;
14361
+ const isApplePlatform = /Macintosh|iPhone|iPad|iPod/.test(userAgent);
14362
+ const isSafari = /Version\//.test(userAgent) && /Safari\//.test(userAgent) && !/(?:Chrome|Chromium|CriOS|Edg|EdgiOS|OPR|OPiOS|Firefox|FxiOS)\//.test(userAgent);
14363
+ return isApplePlatform && isSafari;
14364
+ }
14358
14365
  var hmrSseBridgeClientScript = `
14359
14366
  (function() {
14360
- // Activate when served over HTTPS to bypass WSS self-signed cert issues
14361
- if (location.protocol !== 'https:') return;
14367
+ if (!(${shouldUseHmrSseBridge.toString()})(location.protocol, navigator.userAgent)) return;
14362
14368
 
14363
14369
  var OriginalWebSocket = window.WebSocket;
14364
14370
 
@@ -14575,7 +14581,7 @@ var unpluginFactory = (options) => ({
14575
14581
  if (options.https) {
14576
14582
  setupHmrSseBridge(server);
14577
14583
  hmrSseBridgeActive = true;
14578
- consola.info("HMR SSE bridge enabled for iOS Safari WSS workaround");
14584
+ consola.info("HMR SSE bridge enabled for macOS/iOS Safari WSS workaround");
14579
14585
  }
14580
14586
  },
14581
14587
  transformIndexHtml() {
package/dist/webpack.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-MD5CVZP7.js";
4
- import "./chunk-RSBXFJ3Z.js";
3
+ } from "./chunk-5R33PUJP.js";
4
+ import "./chunk-C5A7XLKL.js";
5
5
  import "./chunk-2P7SUCQ3.js";
6
6
 
7
7
  // src/webpack.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unplugin-https-reverse-proxy",
3
3
  "type": "module",
4
- "version": "4.0.3",
4
+ "version": "4.0.4",
5
5
  "description": "",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/zcf0508/unplugin-https-reverse-proxy#readme",
@@ -134,14 +134,25 @@ function handleClientMessage(
134
134
  })
135
135
  }
136
136
 
137
+ export function shouldUseHmrSseBridge(protocol: string, userAgent: string): boolean {
138
+ if (protocol !== 'https:')
139
+ return false
140
+
141
+ const isApplePlatform = /Macintosh|iPhone|iPad|iPod/.test(userAgent)
142
+ const isSafari = /Version\//.test(userAgent)
143
+ && /Safari\//.test(userAgent)
144
+ && !/(?:Chrome|Chromium|CriOS|Edg|EdgiOS|OPR|OPiOS|Firefox|FxiOS)\//.test(userAgent)
145
+
146
+ return isApplePlatform && isSafari
147
+ }
148
+
137
149
  /**
138
- * Client-side script that patches WebSocket to use SSE+fetch on iOS Safari.
150
+ * Client-side script that patches WebSocket to use SSE+fetch on macOS/iOS Safari.
139
151
  * This script is injected via Vite's transformIndexHtml hook.
140
152
  */
141
153
  export const hmrSseBridgeClientScript = `
142
154
  (function() {
143
- // Activate when served over HTTPS to bypass WSS self-signed cert issues
144
- if (location.protocol !== 'https:') return;
155
+ if (!(${shouldUseHmrSseBridge.toString()})(location.protocol, navigator.userAgent)) return;
145
156
 
146
157
  var OriginalWebSocket = window.WebSocket;
147
158
 
package/src/index.ts CHANGED
@@ -123,17 +123,17 @@ export const unpluginFactory: UnpluginFactory<Options> = options => ({
123
123
 
124
124
  server.printUrls = () => vitePrintUrls(options, source, target, base, _printUrls)
125
125
 
126
- // Setup SSE bridge for iOS Safari WSS workaround
126
+ // Setup SSE bridge for macOS/iOS Safari WSS workaround
127
127
  if (options.https) {
128
128
  setupHmrSseBridge(server)
129
129
  hmrSseBridgeActive = true
130
- consola.info('HMR SSE bridge enabled for iOS Safari WSS workaround')
130
+ consola.info('HMR SSE bridge enabled for macOS/iOS Safari WSS workaround')
131
131
  }
132
132
  },
133
133
  transformIndexHtml() {
134
134
  if (!hmrSseBridgeActive)
135
135
  return []
136
- // Inject client-side script to patch WebSocket on iOS Safari
136
+ // Inject client-side script to patch WebSocket on macOS/iOS Safari
137
137
  return [{
138
138
  tag: 'script',
139
139
  children: hmrSseBridgeClientScript,