unplugin-https-reverse-proxy 4.1.0-beta.7 → 4.1.0-beta.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.
@@ -13575,19 +13575,22 @@ function takeBackTerminal() {
13575
13575
  return () => {
13576
13576
  };
13577
13577
  const wasRaw = stdin.isRaw === true;
13578
+ stdin.pause();
13578
13579
  try {
13579
13580
  stdin.setRawMode(false);
13580
13581
  } catch {
13582
+ stdin.resume();
13581
13583
  return () => {
13582
13584
  };
13583
13585
  }
13584
13586
  return () => {
13585
- if (!wasRaw)
13586
- return;
13587
- try {
13588
- stdin.setRawMode(true);
13589
- } catch {
13587
+ if (wasRaw) {
13588
+ try {
13589
+ stdin.setRawMode(true);
13590
+ } catch {
13591
+ }
13590
13592
  }
13593
+ stdin.resume();
13591
13594
  };
13592
13595
  }
13593
13596
  var PrivilegeDeniedError = class extends Error {
package/dist/esbuild.cjs CHANGED
@@ -13674,19 +13674,22 @@ function takeBackTerminal() {
13674
13674
  return () => {
13675
13675
  };
13676
13676
  const wasRaw = stdin.isRaw === true;
13677
+ stdin.pause();
13677
13678
  try {
13678
13679
  stdin.setRawMode(false);
13679
13680
  } catch {
13681
+ stdin.resume();
13680
13682
  return () => {
13681
13683
  };
13682
13684
  }
13683
13685
  return () => {
13684
- if (!wasRaw)
13685
- return;
13686
- try {
13687
- stdin.setRawMode(true);
13688
- } catch {
13686
+ if (wasRaw) {
13687
+ try {
13688
+ stdin.setRawMode(true);
13689
+ } catch {
13690
+ }
13689
13691
  }
13692
+ stdin.resume();
13690
13693
  };
13691
13694
  }
13692
13695
  var PrivilegeDeniedError = class extends Error {
package/dist/esbuild.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-FNF6HQJB.js";
3
+ } from "./chunk-ICH7VY4H.js";
4
4
  import "./chunk-EY3HXBJ4.js";
5
5
  import "./chunk-C5A7XLKL.js";
6
6
  import "./chunk-WOMR3ZLM.js";
package/dist/index.cjs CHANGED
@@ -13674,19 +13674,22 @@ function takeBackTerminal() {
13674
13674
  return () => {
13675
13675
  };
13676
13676
  const wasRaw = stdin.isRaw === true;
13677
+ stdin.pause();
13677
13678
  try {
13678
13679
  stdin.setRawMode(false);
13679
13680
  } catch {
13681
+ stdin.resume();
13680
13682
  return () => {
13681
13683
  };
13682
13684
  }
13683
13685
  return () => {
13684
- if (!wasRaw)
13685
- return;
13686
- try {
13687
- stdin.setRawMode(true);
13688
- } catch {
13686
+ if (wasRaw) {
13687
+ try {
13688
+ stdin.setRawMode(true);
13689
+ } catch {
13690
+ }
13689
13691
  }
13692
+ stdin.resume();
13690
13693
  };
13691
13694
  }
13692
13695
  var PrivilegeDeniedError = class extends Error {
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  unplugin,
4
4
  unpluginFactory,
5
5
  vitePrintUrls
6
- } from "./chunk-FNF6HQJB.js";
6
+ } from "./chunk-ICH7VY4H.js";
7
7
  import "./chunk-EY3HXBJ4.js";
8
8
  import "./chunk-C5A7XLKL.js";
9
9
  import "./chunk-WOMR3ZLM.js";
package/dist/nuxt.cjs CHANGED
@@ -13675,19 +13675,22 @@ function takeBackTerminal() {
13675
13675
  return () => {
13676
13676
  };
13677
13677
  const wasRaw = stdin.isRaw === true;
13678
+ stdin.pause();
13678
13679
  try {
13679
13680
  stdin.setRawMode(false);
13680
13681
  } catch {
13682
+ stdin.resume();
13681
13683
  return () => {
13682
13684
  };
13683
13685
  }
13684
13686
  return () => {
13685
- if (!wasRaw)
13686
- return;
13687
- try {
13688
- stdin.setRawMode(true);
13689
- } catch {
13687
+ if (wasRaw) {
13688
+ try {
13689
+ stdin.setRawMode(true);
13690
+ } catch {
13691
+ }
13690
13692
  }
13693
+ stdin.resume();
13691
13694
  };
13692
13695
  }
13693
13696
  var PrivilegeDeniedError = class extends Error {
package/dist/nuxt.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  vitePrintUrls
3
- } from "./chunk-FNF6HQJB.js";
3
+ } from "./chunk-ICH7VY4H.js";
4
4
  import {
5
5
  consola
6
6
  } from "./chunk-EY3HXBJ4.js";
package/dist/rollup.cjs CHANGED
@@ -13674,19 +13674,22 @@ function takeBackTerminal() {
13674
13674
  return () => {
13675
13675
  };
13676
13676
  const wasRaw = stdin.isRaw === true;
13677
+ stdin.pause();
13677
13678
  try {
13678
13679
  stdin.setRawMode(false);
13679
13680
  } catch {
13681
+ stdin.resume();
13680
13682
  return () => {
13681
13683
  };
13682
13684
  }
13683
13685
  return () => {
13684
- if (!wasRaw)
13685
- return;
13686
- try {
13687
- stdin.setRawMode(true);
13688
- } catch {
13686
+ if (wasRaw) {
13687
+ try {
13688
+ stdin.setRawMode(true);
13689
+ } catch {
13690
+ }
13689
13691
  }
13692
+ stdin.resume();
13690
13693
  };
13691
13694
  }
13692
13695
  var PrivilegeDeniedError = class extends Error {
package/dist/rollup.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-FNF6HQJB.js";
3
+ } from "./chunk-ICH7VY4H.js";
4
4
  import "./chunk-EY3HXBJ4.js";
5
5
  import "./chunk-C5A7XLKL.js";
6
6
  import "./chunk-WOMR3ZLM.js";
package/dist/rspack.cjs CHANGED
@@ -13673,19 +13673,22 @@ function takeBackTerminal() {
13673
13673
  return () => {
13674
13674
  };
13675
13675
  const wasRaw = stdin.isRaw === true;
13676
+ stdin.pause();
13676
13677
  try {
13677
13678
  stdin.setRawMode(false);
13678
13679
  } catch {
13680
+ stdin.resume();
13679
13681
  return () => {
13680
13682
  };
13681
13683
  }
13682
13684
  return () => {
13683
- if (!wasRaw)
13684
- return;
13685
- try {
13686
- stdin.setRawMode(true);
13687
- } catch {
13685
+ if (wasRaw) {
13686
+ try {
13687
+ stdin.setRawMode(true);
13688
+ } catch {
13689
+ }
13688
13690
  }
13691
+ stdin.resume();
13689
13692
  };
13690
13693
  }
13691
13694
  var PrivilegeDeniedError = class extends Error {
package/dist/rspack.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  src_default
3
- } from "./chunk-FNF6HQJB.js";
3
+ } from "./chunk-ICH7VY4H.js";
4
4
  import "./chunk-EY3HXBJ4.js";
5
5
  import "./chunk-C5A7XLKL.js";
6
6
  import "./chunk-WOMR3ZLM.js";
package/dist/vite.cjs CHANGED
@@ -13674,19 +13674,22 @@ function takeBackTerminal() {
13674
13674
  return () => {
13675
13675
  };
13676
13676
  const wasRaw = stdin.isRaw === true;
13677
+ stdin.pause();
13677
13678
  try {
13678
13679
  stdin.setRawMode(false);
13679
13680
  } catch {
13681
+ stdin.resume();
13680
13682
  return () => {
13681
13683
  };
13682
13684
  }
13683
13685
  return () => {
13684
- if (!wasRaw)
13685
- return;
13686
- try {
13687
- stdin.setRawMode(true);
13688
- } catch {
13686
+ if (wasRaw) {
13687
+ try {
13688
+ stdin.setRawMode(true);
13689
+ } catch {
13690
+ }
13689
13691
  }
13692
+ stdin.resume();
13690
13693
  };
13691
13694
  }
13692
13695
  var PrivilegeDeniedError = class extends Error {
package/dist/vite.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-FNF6HQJB.js";
3
+ } from "./chunk-ICH7VY4H.js";
4
4
  import "./chunk-EY3HXBJ4.js";
5
5
  import "./chunk-C5A7XLKL.js";
6
6
  import "./chunk-WOMR3ZLM.js";
package/dist/webpack.cjs CHANGED
@@ -13674,19 +13674,22 @@ function takeBackTerminal() {
13674
13674
  return () => {
13675
13675
  };
13676
13676
  const wasRaw = stdin.isRaw === true;
13677
+ stdin.pause();
13677
13678
  try {
13678
13679
  stdin.setRawMode(false);
13679
13680
  } catch {
13681
+ stdin.resume();
13680
13682
  return () => {
13681
13683
  };
13682
13684
  }
13683
13685
  return () => {
13684
- if (!wasRaw)
13685
- return;
13686
- try {
13687
- stdin.setRawMode(true);
13688
- } catch {
13686
+ if (wasRaw) {
13687
+ try {
13688
+ stdin.setRawMode(true);
13689
+ } catch {
13690
+ }
13689
13691
  }
13692
+ stdin.resume();
13690
13693
  };
13691
13694
  }
13692
13695
  var PrivilegeDeniedError = class extends Error {
package/dist/webpack.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-FNF6HQJB.js";
3
+ } from "./chunk-ICH7VY4H.js";
4
4
  import "./chunk-EY3HXBJ4.js";
5
5
  import "./chunk-C5A7XLKL.js";
6
6
  import "./chunk-WOMR3ZLM.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unplugin-https-reverse-proxy",
3
3
  "type": "module",
4
- "version": "4.1.0-beta.7",
4
+ "version": "4.1.0-beta.8",
5
5
  "description": "",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/zcf0508/unplugin-https-reverse-proxy#readme",
@@ -146,13 +146,18 @@ function runPrompt(sudoCommand: string): Promise<{ status: number | null, signal
146
146
  }
147
147
 
148
148
  /**
149
- * Returns the terminal to cooked mode for the duration of the prompt.
149
+ * Gives the terminal to `sudo` for the duration of the prompt.
150
150
  *
151
- * Vite leaves stdin in raw mode while it listens for its own shortcuts. In raw
152
- * mode the tty does no line editing, so the Enter that should submit the
153
- * password only reaches sudo as a bare carriage return and the read does not
154
- * complete. The returned function puts the previous state back, so Vite's
155
- * shortcuts keep working afterwards.
151
+ * Vite keeps stdin in raw mode with a `data` listener attached, so that every
152
+ * keystroke reaches its shortcut handler. Two things break the password read:
153
+ *
154
+ * 1. Raw mode does no line editing, so Enter never terminates the line sudo is
155
+ * waiting for.
156
+ * 2. The `data` listener is resumed, so it consumes the characters before sudo
157
+ * can see them. sudo then reads nothing and reports a wrong password.
158
+ *
159
+ * Both are undone here and restored afterwards, so Vite's shortcuts keep
160
+ * working once the prompt is over.
156
161
  */
157
162
  function takeBackTerminal(): () => void {
158
163
  const stdin = process.stdin
@@ -160,20 +165,28 @@ function takeBackTerminal(): () => void {
160
165
  return () => {}
161
166
 
162
167
  const wasRaw = stdin.isRaw === true
168
+
169
+ // `pause` detaches the stream from the tty without removing Vite's listener,
170
+ // so the same handler still works when the stream is resumed later.
171
+ stdin.pause()
172
+
163
173
  try {
164
174
  stdin.setRawMode(false)
165
175
  }
166
176
  catch {
177
+ stdin.resume()
167
178
  return () => {}
168
179
  }
169
180
 
170
181
  return () => {
171
- if (!wasRaw)
172
- return
173
- try {
174
- stdin.setRawMode(true)
182
+ if (wasRaw) {
183
+ try {
184
+ stdin.setRawMode(true)
185
+ }
186
+ catch {}
175
187
  }
176
- catch {}
188
+ // Resume last: Vite's listener is still attached and expects a live stream.
189
+ stdin.resume()
177
190
  }
178
191
  }
179
192