unplugin-https-reverse-proxy 4.0.0 → 4.0.2
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/dist/{chunk-K7HSLE6X.js → chunk-JA3D5AWS.js} +40 -4
- package/dist/chunk-RSBXFJ3Z.js +232 -0
- package/dist/esbuild.cjs +264 -4
- package/dist/esbuild.js +2 -1
- package/dist/hmr-sse-bridge.cjs +258 -0
- package/dist/hmr-sse-bridge.d.cts +10 -0
- package/dist/hmr-sse-bridge.d.ts +10 -0
- package/dist/hmr-sse-bridge.js +8 -0
- package/dist/index.cjs +264 -4
- package/dist/index.js +2 -1
- package/dist/nuxt.cjs +152 -4
- package/dist/nuxt.js +2 -1
- package/dist/rollup.cjs +264 -4
- package/dist/rollup.js +2 -1
- package/dist/rspack.cjs +264 -4
- package/dist/rspack.js +2 -1
- package/dist/vite.cjs +264 -4
- package/dist/vite.js +2 -1
- package/dist/webpack.cjs +264 -4
- package/dist/webpack.js +2 -1
- package/package.json +1 -1
- package/src/caddy/index.ts +24 -5
- package/src/hmr-sse-bridge.ts +266 -0
- package/src/index.ts +20 -0
package/src/index.ts
CHANGED
|
@@ -6,12 +6,15 @@ import { Table } from 'console-table-printer'
|
|
|
6
6
|
import c from 'picocolors'
|
|
7
7
|
import { createUnplugin } from 'unplugin'
|
|
8
8
|
import { CaddyInstant } from './caddy'
|
|
9
|
+
import { hmrSseBridgeClientScript, setupHmrSseBridge } from './hmr-sse-bridge'
|
|
9
10
|
import { consola, generateQrcode, getIpv4List, isAdmin, once } from './utils'
|
|
10
11
|
|
|
11
12
|
let config: ResolvedConfig
|
|
12
13
|
|
|
13
14
|
let caddy: CaddyInstant
|
|
14
15
|
|
|
16
|
+
let hmrSseBridgeActive = false
|
|
17
|
+
|
|
15
18
|
const cwd = process.cwd()
|
|
16
19
|
|
|
17
20
|
function colorUrl(url: string): string {
|
|
@@ -119,6 +122,23 @@ export const unpluginFactory: UnpluginFactory<Options> = options => ({
|
|
|
119
122
|
const base = server.config.base || '/'
|
|
120
123
|
|
|
121
124
|
server.printUrls = () => vitePrintUrls(options, source, target, base, _printUrls)
|
|
125
|
+
|
|
126
|
+
// Setup SSE bridge for iOS Safari WSS workaround
|
|
127
|
+
if (options.https) {
|
|
128
|
+
setupHmrSseBridge(server)
|
|
129
|
+
hmrSseBridgeActive = true
|
|
130
|
+
consola.info('HMR SSE bridge enabled for iOS Safari WSS workaround')
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
transformIndexHtml() {
|
|
134
|
+
if (!hmrSseBridgeActive)
|
|
135
|
+
return []
|
|
136
|
+
// Inject client-side script to patch WebSocket on iOS Safari
|
|
137
|
+
return [{
|
|
138
|
+
tag: 'script',
|
|
139
|
+
children: hmrSseBridgeClientScript,
|
|
140
|
+
injectTo: 'head-prepend',
|
|
141
|
+
}]
|
|
122
142
|
},
|
|
123
143
|
},
|
|
124
144
|
webpack(compiler) {
|