unplugin-https-reverse-proxy 4.1.0-beta.3 → 4.1.0-beta.5

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.
@@ -19,458 +19,21 @@ import {
19
19
  } from "./chunk-RKHJN6KY.js";
20
20
 
21
21
  // src/index.ts
22
- import process8 from "node:process";
22
+ import process9 from "node:process";
23
23
  import { Table } from "console-table-printer";
24
24
  import c from "picocolors";
25
25
  import { createUnplugin } from "unplugin";
26
26
 
27
27
  // src/caddy/index.ts
28
28
  import { execFile } from "node:child_process";
29
- import { chmodSync, createWriteStream, existsSync as existsSync5, mkdirSync, unlinkSync, writeFileSync as writeFileSync2 } from "node:fs";
30
- import { readFile as readFile3, unlink as unlink3, writeFile as writeFile2 } from "node:fs/promises";
29
+ import { chmodSync, createWriteStream, existsSync as existsSync5, mkdirSync, unlinkSync as unlinkSync2 } from "node:fs";
30
+ import { readFile as readFile3, unlink, writeFile as writeFile2 } from "node:fs/promises";
31
31
  import { platform as platform3 } from "node:os";
32
32
  import { join as join6 } from "node:path";
33
- import process7 from "node:process";
34
-
35
- // node_modules/.pnpm/alien-signals@2.0.7/node_modules/alien-signals/esm/system.mjs
36
- var ReactiveFlags;
37
- (function(ReactiveFlags2) {
38
- ReactiveFlags2[ReactiveFlags2["None"] = 0] = "None";
39
- ReactiveFlags2[ReactiveFlags2["Mutable"] = 1] = "Mutable";
40
- ReactiveFlags2[ReactiveFlags2["Watching"] = 2] = "Watching";
41
- ReactiveFlags2[ReactiveFlags2["RecursedCheck"] = 4] = "RecursedCheck";
42
- ReactiveFlags2[ReactiveFlags2["Recursed"] = 8] = "Recursed";
43
- ReactiveFlags2[ReactiveFlags2["Dirty"] = 16] = "Dirty";
44
- ReactiveFlags2[ReactiveFlags2["Pending"] = 32] = "Pending";
45
- })(ReactiveFlags || (ReactiveFlags = {}));
46
- function createReactiveSystem({ update, notify: notify2, unwatched }) {
47
- let currentVersion = 0;
48
- return {
49
- link: link2,
50
- unlink: unlink4,
51
- propagate: propagate2,
52
- checkDirty: checkDirty2,
53
- endTracking: endTracking2,
54
- startTracking: startTracking2,
55
- shallowPropagate: shallowPropagate2
56
- };
57
- function link2(dep, sub) {
58
- const prevDep = sub.depsTail;
59
- if (prevDep !== void 0 && prevDep.dep === dep) {
60
- return;
61
- }
62
- const nextDep = prevDep !== void 0 ? prevDep.nextDep : sub.deps;
63
- if (nextDep !== void 0 && nextDep.dep === dep) {
64
- nextDep.version = currentVersion;
65
- sub.depsTail = nextDep;
66
- return;
67
- }
68
- const prevSub = dep.subsTail;
69
- if (prevSub !== void 0 && prevSub.version === currentVersion && prevSub.sub === sub) {
70
- return;
71
- }
72
- const newLink = sub.depsTail = dep.subsTail = {
73
- version: currentVersion,
74
- dep,
75
- sub,
76
- prevDep,
77
- nextDep,
78
- prevSub,
79
- nextSub: void 0
80
- };
81
- if (nextDep !== void 0) {
82
- nextDep.prevDep = newLink;
83
- }
84
- if (prevDep !== void 0) {
85
- prevDep.nextDep = newLink;
86
- } else {
87
- sub.deps = newLink;
88
- }
89
- if (prevSub !== void 0) {
90
- prevSub.nextSub = newLink;
91
- } else {
92
- dep.subs = newLink;
93
- }
94
- }
95
- function unlink4(link3, sub = link3.sub) {
96
- const dep = link3.dep;
97
- const prevDep = link3.prevDep;
98
- const nextDep = link3.nextDep;
99
- const nextSub = link3.nextSub;
100
- const prevSub = link3.prevSub;
101
- if (nextDep !== void 0) {
102
- nextDep.prevDep = prevDep;
103
- } else {
104
- sub.depsTail = prevDep;
105
- }
106
- if (prevDep !== void 0) {
107
- prevDep.nextDep = nextDep;
108
- } else {
109
- sub.deps = nextDep;
110
- }
111
- if (nextSub !== void 0) {
112
- nextSub.prevSub = prevSub;
113
- } else {
114
- dep.subsTail = prevSub;
115
- }
116
- if (prevSub !== void 0) {
117
- prevSub.nextSub = nextSub;
118
- } else if ((dep.subs = nextSub) === void 0) {
119
- unwatched(dep);
120
- }
121
- return nextDep;
122
- }
123
- function propagate2(link3) {
124
- let next2 = link3.nextSub;
125
- let stack;
126
- top:
127
- do {
128
- const sub = link3.sub;
129
- let flags = sub.flags;
130
- if (!(flags & 60)) {
131
- sub.flags = flags | 32;
132
- } else if (!(flags & 12)) {
133
- flags = 0;
134
- } else if (!(flags & 4)) {
135
- sub.flags = flags & ~8 | 32;
136
- } else if (!(flags & 48) && isValidLink(link3, sub)) {
137
- sub.flags = flags | 40;
138
- flags &= 1;
139
- } else {
140
- flags = 0;
141
- }
142
- if (flags & 2) {
143
- notify2(sub);
144
- }
145
- if (flags & 1) {
146
- const subSubs = sub.subs;
147
- if (subSubs !== void 0) {
148
- const nextSub = (link3 = subSubs).nextSub;
149
- if (nextSub !== void 0) {
150
- stack = { value: next2, prev: stack };
151
- next2 = nextSub;
152
- }
153
- continue;
154
- }
155
- }
156
- if ((link3 = next2) !== void 0) {
157
- next2 = link3.nextSub;
158
- continue;
159
- }
160
- while (stack !== void 0) {
161
- link3 = stack.value;
162
- stack = stack.prev;
163
- if (link3 !== void 0) {
164
- next2 = link3.nextSub;
165
- continue top;
166
- }
167
- }
168
- break;
169
- } while (true);
170
- }
171
- function startTracking2(sub) {
172
- ++currentVersion;
173
- sub.depsTail = void 0;
174
- sub.flags = sub.flags & ~56 | 4;
175
- }
176
- function endTracking2(sub) {
177
- const depsTail = sub.depsTail;
178
- let toRemove = depsTail !== void 0 ? depsTail.nextDep : sub.deps;
179
- while (toRemove !== void 0) {
180
- toRemove = unlink4(toRemove, sub);
181
- }
182
- sub.flags &= ~4;
183
- }
184
- function checkDirty2(link3, sub) {
185
- let stack;
186
- let checkDepth = 0;
187
- top:
188
- do {
189
- const dep = link3.dep;
190
- const flags = dep.flags;
191
- let dirty = false;
192
- if (sub.flags & 16) {
193
- dirty = true;
194
- } else if ((flags & 17) === 17) {
195
- if (update(dep)) {
196
- const subs = dep.subs;
197
- if (subs.nextSub !== void 0) {
198
- shallowPropagate2(subs);
199
- }
200
- dirty = true;
201
- }
202
- } else if ((flags & 33) === 33) {
203
- if (link3.nextSub !== void 0 || link3.prevSub !== void 0) {
204
- stack = { value: link3, prev: stack };
205
- }
206
- link3 = dep.deps;
207
- sub = dep;
208
- ++checkDepth;
209
- continue;
210
- }
211
- if (!dirty) {
212
- const nextDep = link3.nextDep;
213
- if (nextDep !== void 0) {
214
- link3 = nextDep;
215
- continue;
216
- }
217
- }
218
- while (checkDepth--) {
219
- const firstSub = sub.subs;
220
- const hasMultipleSubs = firstSub.nextSub !== void 0;
221
- if (hasMultipleSubs) {
222
- link3 = stack.value;
223
- stack = stack.prev;
224
- } else {
225
- link3 = firstSub;
226
- }
227
- if (dirty) {
228
- if (update(sub)) {
229
- if (hasMultipleSubs) {
230
- shallowPropagate2(firstSub);
231
- }
232
- sub = link3.sub;
233
- continue;
234
- }
235
- } else {
236
- sub.flags &= ~32;
237
- }
238
- sub = link3.sub;
239
- const nextDep = link3.nextDep;
240
- if (nextDep !== void 0) {
241
- link3 = nextDep;
242
- continue top;
243
- }
244
- dirty = false;
245
- }
246
- return dirty;
247
- } while (true);
248
- }
249
- function shallowPropagate2(link3) {
250
- do {
251
- const sub = link3.sub;
252
- const flags = sub.flags;
253
- if ((flags & 48) === 32) {
254
- sub.flags = flags | 16;
255
- if (flags & 2) {
256
- notify2(sub);
257
- }
258
- }
259
- } while ((link3 = link3.nextSub) !== void 0);
260
- }
261
- function isValidLink(checkLink, sub) {
262
- let link3 = sub.depsTail;
263
- while (link3 !== void 0) {
264
- if (link3 === checkLink) {
265
- return true;
266
- }
267
- link3 = link3.prevDep;
268
- }
269
- return false;
270
- }
271
- }
272
-
273
- // node_modules/.pnpm/alien-signals@2.0.7/node_modules/alien-signals/esm/index.mjs
274
- var queuedEffects = [];
275
- var { link, unlink, propagate, checkDirty, endTracking, startTracking, shallowPropagate } = createReactiveSystem({
276
- update(signal2) {
277
- if ("getter" in signal2) {
278
- return updateComputed(signal2);
279
- } else {
280
- return updateSignal(signal2, signal2.value);
281
- }
282
- },
283
- notify,
284
- unwatched(node2) {
285
- if ("getter" in node2) {
286
- let toRemove = node2.deps;
287
- if (toRemove !== void 0) {
288
- node2.flags = 17;
289
- do {
290
- toRemove = unlink(toRemove, node2);
291
- } while (toRemove !== void 0);
292
- }
293
- } else if (!("previousValue" in node2)) {
294
- effectOper.call(node2);
295
- }
296
- }
297
- });
298
- var batchDepth = 0;
299
- var notifyIndex = 0;
300
- var queuedEffectsLength = 0;
301
- var activeSub;
302
- var activeScope;
303
- function setCurrentSub(sub) {
304
- const prevSub = activeSub;
305
- activeSub = sub;
306
- return prevSub;
307
- }
308
- function signal(initialValue) {
309
- return signalOper.bind({
310
- previousValue: initialValue,
311
- value: initialValue,
312
- subs: void 0,
313
- subsTail: void 0,
314
- flags: 1
315
- });
316
- }
317
- function computed(getter) {
318
- return computedOper.bind({
319
- value: void 0,
320
- subs: void 0,
321
- subsTail: void 0,
322
- deps: void 0,
323
- depsTail: void 0,
324
- flags: 17,
325
- getter
326
- });
327
- }
328
- function effect(fn) {
329
- const e = {
330
- fn,
331
- subs: void 0,
332
- subsTail: void 0,
333
- deps: void 0,
334
- depsTail: void 0,
335
- flags: 2
336
- };
337
- if (activeSub !== void 0) {
338
- link(e, activeSub);
339
- } else if (activeScope !== void 0) {
340
- link(e, activeScope);
341
- }
342
- const prev = setCurrentSub(e);
343
- try {
344
- e.fn();
345
- } finally {
346
- setCurrentSub(prev);
347
- }
348
- return effectOper.bind(e);
349
- }
350
- function updateComputed(c2) {
351
- const prevSub = setCurrentSub(c2);
352
- startTracking(c2);
353
- try {
354
- const oldValue = c2.value;
355
- return oldValue !== (c2.value = c2.getter(oldValue));
356
- } finally {
357
- setCurrentSub(prevSub);
358
- endTracking(c2);
359
- }
360
- }
361
- function updateSignal(s, value2) {
362
- s.flags = 1;
363
- return s.previousValue !== (s.previousValue = value2);
364
- }
365
- function notify(e) {
366
- const flags = e.flags;
367
- if (!(flags & 64)) {
368
- e.flags = flags | 64;
369
- const subs = e.subs;
370
- if (subs !== void 0) {
371
- notify(subs.sub);
372
- } else {
373
- queuedEffects[queuedEffectsLength++] = e;
374
- }
375
- }
376
- }
377
- function run(e, flags) {
378
- if (flags & 16 || flags & 32 && checkDirty(e.deps, e)) {
379
- const prev = setCurrentSub(e);
380
- startTracking(e);
381
- try {
382
- e.fn();
383
- } finally {
384
- setCurrentSub(prev);
385
- endTracking(e);
386
- }
387
- return;
388
- } else if (flags & 32) {
389
- e.flags = flags & ~32;
390
- }
391
- let link2 = e.deps;
392
- while (link2 !== void 0) {
393
- const dep = link2.dep;
394
- const depFlags = dep.flags;
395
- if (depFlags & 64) {
396
- run(dep, dep.flags = depFlags & ~64);
397
- }
398
- link2 = link2.nextDep;
399
- }
400
- }
401
- function flush() {
402
- while (notifyIndex < queuedEffectsLength) {
403
- const effect2 = queuedEffects[notifyIndex];
404
- queuedEffects[notifyIndex++] = void 0;
405
- run(effect2, effect2.flags &= ~64);
406
- }
407
- notifyIndex = 0;
408
- queuedEffectsLength = 0;
409
- }
410
- function computedOper() {
411
- const flags = this.flags;
412
- if (flags & 16 || flags & 32 && checkDirty(this.deps, this)) {
413
- if (updateComputed(this)) {
414
- const subs = this.subs;
415
- if (subs !== void 0) {
416
- shallowPropagate(subs);
417
- }
418
- }
419
- } else if (flags & 32) {
420
- this.flags = flags & ~32;
421
- }
422
- if (activeSub !== void 0) {
423
- link(this, activeSub);
424
- } else if (activeScope !== void 0) {
425
- link(this, activeScope);
426
- }
427
- return this.value;
428
- }
429
- function signalOper(...value2) {
430
- if (value2.length) {
431
- if (this.value !== (this.value = value2[0])) {
432
- this.flags = 17;
433
- const subs = this.subs;
434
- if (subs !== void 0) {
435
- propagate(subs);
436
- if (!batchDepth) {
437
- flush();
438
- }
439
- }
440
- }
441
- } else {
442
- const value3 = this.value;
443
- if (this.flags & 16) {
444
- if (updateSignal(this, value3)) {
445
- const subs = this.subs;
446
- if (subs !== void 0) {
447
- shallowPropagate(subs);
448
- }
449
- }
450
- }
451
- if (activeSub !== void 0) {
452
- link(this, activeSub);
453
- }
454
- return value3;
455
- }
456
- }
457
- function effectOper() {
458
- let dep = this.deps;
459
- while (dep !== void 0) {
460
- dep = unlink(dep, this);
461
- }
462
- const sub = this.subs;
463
- if (sub !== void 0) {
464
- unlink(sub);
465
- }
466
- this.flags = 0;
467
- }
468
-
469
- // src/caddy/index.ts
33
+ import process8 from "node:process";
470
34
  import { got } from "got-cjs";
471
35
  import { HttpProxyAgent } from "http-proxy-agent";
472
36
  import { HttpsProxyAgent } from "https-proxy-agent";
473
- import * as lockfile from "proper-lockfile";
474
37
 
475
38
  // node_modules/.pnpm/@ark+util@0.46.0/node_modules/@ark/util/out/arrays.js
476
39
  var liftArray = (data) => Array.isArray(data) ? data : [data];
@@ -13420,8 +12983,9 @@ async function genCaddyfile(ctx) {
13420
12983
  }
13421
12984
 
13422
12985
  // src/caddy/config.ts
13423
- import { existsSync as existsSync2, readFileSync as readFileSync2, watch, writeFileSync } from "node:fs";
13424
- import { unlink as unlink2 } from "node:fs/promises";
12986
+ import { existsSync as existsSync2, readFileSync as readFileSync2, renameSync, unlinkSync, writeFileSync } from "node:fs";
12987
+ import process3 from "node:process";
12988
+ import * as lockfile from "proper-lockfile";
13425
12989
 
13426
12990
  // src/caddy/constants.ts
13427
12991
  import os from "node:os";
@@ -13553,56 +13117,108 @@ var supportList = [
13553
13117
  ];
13554
13118
 
13555
13119
  // src/caddy/config.ts
13556
- function useCaddyConfig() {
13557
- const configContentRef = signal("{}");
13558
- const configJsonRef = computed(() => {
13559
- try {
13560
- return JSON.parse(configContentRef());
13561
- } catch {
13562
- return void 0;
13563
- }
13564
- });
13565
- function setConfigContent() {
13566
- if (!existsSync2(caddyConfigPath)) {
13567
- writeFileSync(caddyConfigPath, "{}");
13568
- }
13569
- try {
13570
- configContentRef(readFileSync2(caddyConfigPath, "utf-8"));
13571
- } catch {
13572
- configContentRef("");
13573
- }
13120
+ function isAlive(pid) {
13121
+ if (pid === void 0)
13122
+ return true;
13123
+ try {
13124
+ process3.kill(pid, 0);
13125
+ return true;
13126
+ } catch {
13127
+ return false;
13574
13128
  }
13575
- if (!existsSync2(caddyConfigPath)) {
13576
- writeFileSync(caddyConfigPath, "{}");
13129
+ }
13130
+ function readConfig() {
13131
+ if (!existsSync2(caddyConfigPath))
13132
+ return {};
13133
+ let parsed2;
13134
+ try {
13135
+ parsed2 = JSON.parse(readFileSync2(caddyConfigPath, "utf-8"));
13136
+ } catch {
13137
+ return {};
13577
13138
  }
13578
- const watchCaddyConfig = watch(caddyConfigPath, () => {
13579
- setConfigContent();
13580
- });
13581
- function writeCaddyConfig(_proxies) {
13582
- const proxies = configJsonRef() || {};
13583
- _proxies.forEach((p) => {
13584
- let base = p.base || "/";
13585
- if (!base.startsWith("/"))
13586
- base = `/${base}`;
13587
- if (base !== "/" && !base.endsWith("/"))
13588
- base = `${base}/`;
13589
- const index = `${p.target}${p.portSuffix}${base}`;
13590
- proxies[index] = { ...p, base };
13591
- });
13592
- const content = JSON.stringify(proxies, null, 2);
13593
- configContentRef(content);
13594
- return writeFileSync(caddyConfigPath, content);
13139
+ const alive = {};
13140
+ for (const [key, entry] of Object.entries(parsed2)) {
13141
+ if (isAlive(entry == null ? void 0 : entry.ownerPid))
13142
+ alive[key] = entry;
13595
13143
  }
13596
- async function cleanUp() {
13597
- await unlink2(caddyConfigPath).catch(() => {
13598
- });
13599
- configContentRef("{}");
13600
- watchCaddyConfig.close();
13144
+ return alive;
13145
+ }
13146
+ function writeConfig(proxies) {
13147
+ const content = JSON.stringify(proxies, null, 2);
13148
+ const temp = `${caddyConfigPath}.${process3.pid}.tmp`;
13149
+ writeFileSync(temp, content);
13150
+ renameSync(temp, caddyConfigPath);
13151
+ }
13152
+ async function mutateConfig(lock3, mutate) {
13153
+ const release = await lock3.acquire();
13154
+ try {
13155
+ const proxies = readConfig();
13156
+ mutate(proxies);
13157
+ writeConfig(proxies);
13158
+ return proxies;
13159
+ } finally {
13160
+ release();
13161
+ }
13162
+ }
13163
+ function useCaddyConfig(options = {}) {
13164
+ const lock3 = options.lock ?? createFileLock();
13165
+ return {
13166
+ configJsonRef: () => existsSync2(caddyConfigPath) ? readConfig() : void 0,
13167
+ async writeCaddyConfig(_proxies, key) {
13168
+ await mutateConfig(lock3, (proxies) => {
13169
+ for (const p of _proxies)
13170
+ proxies[routeKey(p, key)] = { ...p, base: normalizeBase(p.base), ownerPid: process3.pid };
13171
+ });
13172
+ },
13173
+ async removeProxy(key) {
13174
+ const proxies = await mutateConfig(lock3, (current) => {
13175
+ for (const route of Object.keys(current)) {
13176
+ if (route.endsWith(`#${key}`))
13177
+ delete current[route];
13178
+ }
13179
+ });
13180
+ if (Object.keys(proxies).length === 0)
13181
+ removeConfigFile();
13182
+ },
13183
+ readProxies: () => readConfig(),
13184
+ async cleanUp() {
13185
+ removeConfigFile();
13186
+ }
13187
+ };
13188
+ }
13189
+ function removeConfigFile() {
13190
+ try {
13191
+ if (existsSync2(caddyConfigPath))
13192
+ unlinkSync(caddyConfigPath);
13193
+ } catch {
13601
13194
  }
13195
+ }
13196
+ function normalizeBase(base) {
13197
+ let out = base || "/";
13198
+ if (!out.startsWith("/"))
13199
+ out = `/${out}`;
13200
+ if (out !== "/" && !out.endsWith("/"))
13201
+ out = `${out}/`;
13202
+ return out;
13203
+ }
13204
+ function routeKey(proxy, ownerKey) {
13205
+ return `${proxy.target}${proxy.portSuffix}${normalizeBase(proxy.base)}#${ownerKey}`;
13206
+ }
13207
+ function createFileLock() {
13602
13208
  return {
13603
- configJsonRef,
13604
- writeCaddyConfig,
13605
- cleanUp
13209
+ async acquire() {
13210
+ if (!existsSync2(caddyConfigPath))
13211
+ writeFileSync(caddyConfigPath, "{}");
13212
+ const release = await lockfile.lock(caddyConfigPath, {
13213
+ realpath: false,
13214
+ stale: 1e4,
13215
+ retries: { retries: 20, minTimeout: 10, maxTimeout: 100 }
13216
+ });
13217
+ return () => {
13218
+ void release().catch(() => {
13219
+ });
13220
+ };
13221
+ }
13606
13222
  };
13607
13223
  }
13608
13224
 
@@ -13620,15 +13236,15 @@ function isCaddyReloadCancellation(line) {
13620
13236
  import { Buffer as Buffer2 } from "node:buffer";
13621
13237
  import { EventEmitter } from "node:events";
13622
13238
  import { dirname as dirname3, join as join5 } from "node:path";
13623
- import process6 from "node:process";
13239
+ import process7 from "node:process";
13624
13240
  import { fileURLToPath } from "node:url";
13625
13241
 
13626
13242
  // src/privileged/entry.ts
13627
13243
  import { existsSync as existsSync3 } from "node:fs";
13628
13244
  import { dirname as dirname2, join as join3 } from "node:path";
13629
- import process3 from "node:process";
13245
+ import process4 from "node:process";
13630
13246
  function resolveHelperEntry(options) {
13631
- const { moduleDir, nodeBin = process3.execPath, exists: exists2 = existsSync3 } = options;
13247
+ const { moduleDir, nodeBin = process4.execPath, exists: exists2 = existsSync3 } = options;
13632
13248
  for (const name of ["privileged-helper.js", "privileged-helper.cjs", "privileged-helper.mjs"]) {
13633
13249
  const candidate = findUp(moduleDir, name, exists2);
13634
13250
  if (candidate)
@@ -13659,16 +13275,17 @@ import { existsSync as existsSync4 } from "node:fs";
13659
13275
  import { readFile as readFile2, writeFile } from "node:fs/promises";
13660
13276
  import { platform as platform2 } from "node:os";
13661
13277
  import { join as join4 } from "node:path";
13278
+ import * as lockfile2 from "proper-lockfile";
13662
13279
 
13663
13280
  // src/privileged/launch.ts
13664
13281
  import { spawn as spawn2, spawnSync } from "node:child_process";
13665
13282
  import { randomBytes } from "node:crypto";
13666
13283
  import { platform } from "node:os";
13667
- import process5 from "node:process";
13284
+ import process6 from "node:process";
13668
13285
 
13669
13286
  // src/privileged/client.ts
13670
13287
  import { connect } from "node:net";
13671
- import process4 from "node:process";
13288
+ import process5 from "node:process";
13672
13289
  var FORWARDED_ENV_KEYS = [
13673
13290
  "HOME",
13674
13291
  "USER",
@@ -13681,7 +13298,7 @@ var FORWARDED_ENV_KEYS = [
13681
13298
  "NO_PROXY",
13682
13299
  "no_proxy"
13683
13300
  ];
13684
- function collectForwardedEnv(source = process4.env) {
13301
+ function collectForwardedEnv(source = process5.env) {
13685
13302
  const result = {};
13686
13303
  for (const key of FORWARDED_ENV_KEYS) {
13687
13304
  const value2 = source[key];
@@ -13910,24 +13527,42 @@ function describePasswordReason(target, https) {
13910
13527
  "Press Ctrl+C at the prompt to skip the proxy and keep the dev server."
13911
13528
  ];
13912
13529
  }
13913
- function authenticateSudo(sudoCommand = "sudo", options = {}) {
13530
+ async function authenticateSudo(sudoCommand = "sudo", options = {}) {
13914
13531
  if (platform() === "win32")
13915
13532
  return { ok: true };
13916
13533
  if (spawnSync(sudoCommand, ["-n", "true"], { stdio: "ignore" }).status === 0)
13917
13534
  return { ok: true };
13918
13535
  if (options.target) {
13919
13536
  for (const line of describePasswordReason(options.target, options.https ?? false))
13920
- process5.stderr.write(`${line}
13537
+ process6.stderr.write(`${line}
13921
13538
  `);
13922
- process5.stderr.write("\n");
13539
+ process6.stderr.write("\n");
13923
13540
  }
13924
- if (spawnSync(sudoCommand, ["-v"], { stdio: "inherit" }).status === 0)
13925
- return { ok: true };
13926
- return {
13927
- ok: false,
13928
- denied: true,
13929
- message: "administrator permission is required to edit the hosts file and bind ports 80/443"
13541
+ let interrupted = false;
13542
+ const onSigint = () => {
13543
+ interrupted = true;
13930
13544
  };
13545
+ process6.on("SIGINT", onSigint);
13546
+ try {
13547
+ const { status, signal } = await runPrompt(sudoCommand);
13548
+ if (status === 0)
13549
+ return { ok: true };
13550
+ const cancelled = interrupted || signal === "SIGINT";
13551
+ return {
13552
+ ok: false,
13553
+ denied: true,
13554
+ message: cancelled ? "administrator permission was cancelled" : "administrator permission is required to edit the hosts file and bind ports 80/443"
13555
+ };
13556
+ } finally {
13557
+ process6.off("SIGINT", onSigint);
13558
+ }
13559
+ }
13560
+ function runPrompt(sudoCommand) {
13561
+ return new Promise((resolve2) => {
13562
+ const child = spawn2(sudoCommand, ["-v"], { stdio: "inherit" });
13563
+ child.on("error", () => resolve2({ status: 1, signal: null }));
13564
+ child.on("exit", (status, signal) => resolve2({ status, signal }));
13565
+ });
13931
13566
  }
13932
13567
  var PrivilegeDeniedError = class extends Error {
13933
13568
  constructor(message) {
@@ -13945,12 +13580,12 @@ async function startPrivilegedHelper(options) {
13945
13580
  sudoCommand = "sudo",
13946
13581
  skipAuth = false,
13947
13582
  direct = false,
13948
- env: env2 = process5.env,
13583
+ env: env2 = process6.env,
13949
13584
  log,
13950
13585
  connectTimeoutMs = 12e4
13951
13586
  } = options;
13952
13587
  if (!skipAuth && !direct) {
13953
- const auth = authenticateSudo(sudoCommand, options.reason);
13588
+ const auth = await authenticateSudo(sudoCommand, options.reason);
13954
13589
  if (!auth.ok) {
13955
13590
  const message = auth.message ?? "administrator permission is required";
13956
13591
  throw auth.denied ? new PrivilegeDeniedError(message) : new Error(message);
@@ -13964,8 +13599,8 @@ async function startPrivilegedHelper(options) {
13964
13599
  socketPath,
13965
13600
  "--token",
13966
13601
  token,
13967
- ...typeof process5.getuid === "function" ? ["--owner-uid", String(process5.getuid())] : [],
13968
- ...typeof process5.getgid === "function" ? ["--owner-gid", String(process5.getgid())] : [],
13602
+ ...typeof process6.getuid === "function" ? ["--owner-uid", String(process6.getuid())] : [],
13603
+ ...typeof process6.getgid === "function" ? ["--owner-gid", String(process6.getgid())] : [],
13969
13604
  ...options.caddyStoragePath ? ["--caddy-storage", options.caddyStoragePath] : [],
13970
13605
  "--caddy",
13971
13606
  options.caddyBin,
@@ -13974,7 +13609,7 @@ async function startPrivilegedHelper(options) {
13974
13609
  ];
13975
13610
  let child;
13976
13611
  if (!direct && platform() === "win32") {
13977
- await spawnElevatedOnWindows({ file: helperEntry, args: childArgv, cwd: process5.cwd() });
13612
+ await spawnElevatedOnWindows({ file: helperEntry, args: childArgv, cwd: process6.cwd() });
13978
13613
  } else {
13979
13614
  const command = direct ? helperEntry : sudoCommand;
13980
13615
  const spawnArgs = direct ? childArgv : ["-n", "env", ...forwardedArgs, helperEntry, ...childArgv];
@@ -14031,21 +13666,34 @@ function sessionSocketPath(runtimeDir) {
14031
13666
  }
14032
13667
  async function openHelperSession(scope2) {
14033
13668
  const socketPath = sessionSocketPath(scope2.runtimeDir);
14034
- if (existsSync4(socketPath) || platform2() === "win32") {
14035
- const token2 = await readToken(scope2.runtimeDir);
14036
- if (token2) {
14037
- const reused = await connectExistingHelper(socketPath, token2);
14038
- if (reused) {
14039
- return {
14040
- client: reused,
14041
- reused: true,
14042
- close: async () => {
14043
- await reused.close();
14044
- }
14045
- };
14046
- }
14047
- }
13669
+ const release = await acquireStartLock(scope2.runtimeDir);
13670
+ try {
13671
+ const reused = await tryReuse(socketPath, scope2);
13672
+ if (reused)
13673
+ return reused;
13674
+ return await startNew(socketPath, scope2);
13675
+ } finally {
13676
+ release();
14048
13677
  }
13678
+ }
13679
+ async function tryReuse(socketPath, scope2) {
13680
+ if (!existsSync4(socketPath) && platform2() !== "win32")
13681
+ return void 0;
13682
+ const token = await readToken(scope2.runtimeDir);
13683
+ if (!token)
13684
+ return void 0;
13685
+ const reused = await connectExistingHelper(socketPath, token);
13686
+ if (!reused)
13687
+ return void 0;
13688
+ return {
13689
+ client: reused,
13690
+ reused: true,
13691
+ close: async () => {
13692
+ await reused.close();
13693
+ }
13694
+ };
13695
+ }
13696
+ async function startNew(socketPath, scope2) {
14049
13697
  const token = createHelperToken();
14050
13698
  const started = await startPrivilegedHelper({
14051
13699
  socketPath,
@@ -14071,6 +13719,22 @@ async function openHelperSession(scope2) {
14071
13719
  }
14072
13720
  };
14073
13721
  }
13722
+ async function acquireStartLock(runtimeDir) {
13723
+ const lockPath = join4(runtimeDir, "helper.start.lock");
13724
+ try {
13725
+ await writeFile(lockPath, "", { flag: "a" });
13726
+ } catch {
13727
+ }
13728
+ const release = await lockfile2.lock(lockPath, {
13729
+ realpath: false,
13730
+ stale: 3e4,
13731
+ retries: { retries: 100, minTimeout: 50, maxTimeout: 200 }
13732
+ });
13733
+ return () => {
13734
+ void release().catch(() => {
13735
+ });
13736
+ };
13737
+ }
14074
13738
  async function readToken(runtimeDir) {
14075
13739
  try {
14076
13740
  const content = await readFile2(tokenPath(runtimeDir), "utf8");
@@ -14129,7 +13793,7 @@ var HelperCaddyProcess = class extends EventEmitter {
14129
13793
  }
14130
13794
  };
14131
13795
  function caddyStoragePath() {
14132
- return process6.platform === "win32" ? join5(process6.env.AppData ?? "", "Caddy") : join5(process6.env.HOME ?? "", "Library/Application Support/Caddy");
13796
+ return process7.platform === "win32" ? join5(process7.env.AppData ?? "", "Caddy") : join5(process7.env.HOME ?? "", "Library/Application Support/Caddy");
14133
13797
  }
14134
13798
  function openPrivilegedSession(runtimeDir, options) {
14135
13799
  const env2 = resolvePrivilegedEnv();
@@ -14279,15 +13943,15 @@ async function download() {
14279
13943
  const file = createWriteStream(caddyPath);
14280
13944
  let _platform = platform3().toString();
14281
13945
  _platform === "win32" && (_platform = "windows");
14282
- let _arch = process7.arch.toString();
13946
+ let _arch = process8.arch.toString();
14283
13947
  _arch === "x64" && (_arch = "amd64");
14284
13948
  const support = supportList.find((item) => item.platform === _platform && item.arch === _arch);
14285
13949
  if (!support)
14286
13950
  return reject2(new Error("not support"));
14287
13951
  const dowmloadLink = `https://caddyserver.com/api/download?os=${support.platform}&arch=${support.arch}&p=github.com%2Fcaddyserver%2Fforwardproxy`;
14288
- existsSync5(caddyPath) && unlinkSync(caddyPath);
14289
- const httpProxy = process7.env.HTTP_PROXY || process7.env.http_proxy;
14290
- const httpsProxy = process7.env.HTTPS_PROXY || process7.env.https_proxy;
13952
+ existsSync5(caddyPath) && unlinkSync2(caddyPath);
13953
+ const httpProxy = process8.env.HTTP_PROXY || process8.env.http_proxy;
13954
+ const httpsProxy = process8.env.HTTPS_PROXY || process8.env.https_proxy;
14291
13955
  const httpAgent = httpProxy ? new HttpProxyAgent(httpProxy) : void 0;
14292
13956
  const httpsAgent = httpsProxy ? new HttpsProxyAgent(httpsProxy) : void 0;
14293
13957
  const chmodCaddyOnce = once(() => {
@@ -14303,7 +13967,7 @@ async function download() {
14303
13967
  chmodCaddyOnce();
14304
13968
  }).pipe(file).on("finish", () => {
14305
13969
  logProgressOver();
14306
- if (process7.platform === "win32")
13970
+ if (process8.platform === "win32")
14307
13971
  return resolve2(caddyPath);
14308
13972
  chmodSync(caddyPath, 493);
14309
13973
  resolve2(caddyPath);
@@ -14353,26 +14017,17 @@ var defaultDependencies = {
14353
14017
  caddyBin: caddyPath,
14354
14018
  caddyConfigPath: caddyFilePath,
14355
14019
  reason
14356
- })
14020
+ }),
14021
+ config: () => getCaddyConfig()
14357
14022
  };
14358
14023
  var CaddyInstant = class {
14359
14024
  constructor(deps = {}) {
14360
14025
  this.inited = false;
14361
14026
  this.stoped = false;
14362
- /** has locked when start */
14363
- this.locked = false;
14364
14027
  this._stopEffects = [];
14028
+ /** Identifies this instance's routes in the shared config. */
14029
+ this.proxyKey = `${process8.pid}-${Math.random().toString(36).slice(2, 8)}`;
14365
14030
  this.deps = { ...defaultDependencies, ...deps };
14366
- this.locked = this.checkLock();
14367
- }
14368
- checkLock() {
14369
- if (!existsSync5(caddyLockFilePath))
14370
- writeFileSync2(caddyLockFilePath, "");
14371
- try {
14372
- return lockfile.checkSync(caddyLockFilePath);
14373
- } catch {
14374
- return false;
14375
- }
14376
14031
  }
14377
14032
  /**
14378
14033
  * Connects to the privileged helper, starting it once if needed. It is
@@ -14396,7 +14051,7 @@ var CaddyInstant = class {
14396
14051
  }
14397
14052
  get caddyRoot() {
14398
14053
  return join6(
14399
- process7.platform === "win32" ? `${process7.env.AppData}/Caddy` : `${process7.env.HOME}/Library/Application Support/Caddy`,
14054
+ process8.platform === "win32" ? `${process8.env.AppData}/Caddy` : `${process8.env.HOME}/Library/Application Support/Caddy`,
14400
14055
  "./pki/authorities/local"
14401
14056
  );
14402
14057
  }
@@ -14404,7 +14059,7 @@ var CaddyInstant = class {
14404
14059
  return await writeFile2(caddyFilePath, this.caddyfile || "");
14405
14060
  }
14406
14061
  async deleteCaddyfile() {
14407
- return await unlink3(caddyFilePath);
14062
+ return await unlink(caddyFilePath);
14408
14063
  }
14409
14064
  async init() {
14410
14065
  await download();
@@ -14442,9 +14097,15 @@ Run \`${caddyPath} trust\` manually if the browser warns about the certificate.`
14442
14097
  if (!health.healthy)
14443
14098
  throw new Error(formatTlsHealthFailure(targetHost, health));
14444
14099
  }
14100
+ /**
14101
+ * Regenerates the Caddyfile from the config on disk.
14102
+ *
14103
+ * Reading the file rather than a cached view matters here: another project
14104
+ * may have added its route since this instance last looked.
14105
+ */
14445
14106
  async updateCaddyfile() {
14446
- const { configJsonRef } = getCaddyConfig();
14447
- const proxies = Object.values(configJsonRef() || {});
14107
+ const { readProxies } = this.deps.config();
14108
+ const proxies = Object.values(readProxies());
14448
14109
  const ctx = validateTemplateContext({
14449
14110
  caddy_root: this.caddyRoot,
14450
14111
  proxies
@@ -14493,7 +14154,7 @@ Run \`${caddyPath} trust\` manually if the browser warns about the certificate.`
14493
14154
  const session = await this.session({ target: targetHost, https });
14494
14155
  await session.client.call("hosts.add", { ip: sourceHost, host: targetHost });
14495
14156
  consola.success("update host success\n");
14496
- const normalizeBase = (b) => {
14157
+ const normalizeBase2 = (b) => {
14497
14158
  let out = b || "/";
14498
14159
  if (!out.startsWith("/"))
14499
14160
  out = `/${out}`;
@@ -14501,7 +14162,7 @@ Run \`${caddyPath} trust\` manually if the browser warns about the certificate.`
14501
14162
  out = `${out}/`;
14502
14163
  return out;
14503
14164
  };
14504
- const baseNormalized = normalizeBase(base);
14165
+ const baseNormalized = normalizeBase2(base);
14505
14166
  const proxies = [
14506
14167
  {
14507
14168
  target: targetHost,
@@ -14512,27 +14173,12 @@ Run \`${caddyPath} trust\` manually if the browser warns about the certificate.`
14512
14173
  healthCheck
14513
14174
  }
14514
14175
  ];
14515
- const { writeCaddyConfig } = getCaddyConfig();
14516
- writeCaddyConfig(proxies);
14176
+ const { writeCaddyConfig } = this.deps.config();
14177
+ await writeCaddyConfig(proxies, this.proxyKey);
14517
14178
  await this.updateCaddyfile();
14518
- let skipInitialCaddyfileEffect = true;
14519
- this._stopEffects.push(
14520
- effect(() => {
14521
- getCaddyConfig().configJsonRef();
14522
- if (skipInitialCaddyfileEffect) {
14523
- skipInitialCaddyfileEffect = false;
14524
- return;
14525
- }
14526
- void this.updateCaddyfile();
14527
- })
14528
- );
14529
- if (!existsSync5(caddyLockFilePath))
14530
- writeFileSync2(caddyLockFilePath, "");
14531
- if (!this.locked) {
14532
- await session.client.call("port.free", { port: 443 });
14533
- if (process7.platform === "win32" || !https)
14534
- await session.client.call("port.free", { port: 80 });
14535
- }
14179
+ await session.client.call("port.free", { port: 443 });
14180
+ if (process8.platform === "win32" || !https)
14181
+ await session.client.call("port.free", { port: 80 });
14536
14182
  return new Promise((resolve2, reject2) => {
14537
14183
  let startupCheckStarted = false;
14538
14184
  const resolveWhenReady = async () => {
@@ -14546,106 +14192,89 @@ Run \`${caddyPath} trust\` manually if the browser warns about the certificate.`
14546
14192
  }
14547
14193
  resolve2();
14548
14194
  } catch (error) {
14549
- if (!this.locked)
14550
- await this.baseCleanup(restore);
14195
+ await this.baseCleanup(restore);
14551
14196
  reject2(error);
14552
14197
  }
14553
14198
  };
14554
14199
  const setupCleanup = () => {
14555
- process7.on("SIGINT", async () => {
14200
+ process8.on("SIGINT", async () => {
14556
14201
  if (this.stoped)
14557
14202
  return;
14558
- process7.stdin.resume();
14203
+ process8.stdin.resume();
14559
14204
  try {
14560
14205
  await this.baseCleanup(restore);
14561
14206
  } finally {
14562
14207
  this.stoped = true;
14563
- process7.nextTick(() => {
14564
- process7.exit();
14208
+ process8.nextTick(() => {
14209
+ process8.exit();
14565
14210
  });
14566
14211
  }
14567
14212
  });
14568
- const originalExit = process7.exit.bind(process7);
14569
- process7.exit = async (code) => {
14213
+ const originalExit = process8.exit.bind(process8);
14214
+ process8.exit = async (code) => {
14570
14215
  if (this.stoped)
14571
14216
  return originalExit(code);
14572
- process7.stdin.resume();
14217
+ process8.stdin.resume();
14573
14218
  try {
14574
14219
  await this.baseCleanup();
14575
14220
  } finally {
14576
14221
  this.stoped = true;
14577
- process7.nextTick(() => {
14222
+ process8.nextTick(() => {
14578
14223
  originalExit(code);
14579
14224
  });
14580
14225
  }
14581
14226
  };
14582
14227
  };
14583
- if (!this.locked) {
14584
- lockfile.lockSync(caddyLockFilePath);
14585
- setupCleanup();
14586
- void (async () => {
14587
- try {
14588
- const child = new HelperCaddyProcess(session.client);
14589
- this._caddyChild = child;
14590
- await session.client.call("caddy.start");
14591
- child.on("exit", (code) => {
14592
- if (code !== null && code !== 0)
14593
- reject2(new Error(`Caddy exited with code ${code}`));
14594
- });
14595
- child.stderr.on("data", async (data) => {
14596
- const lines = data.toString().split("\n").map((line) => line.trim());
14597
- for (const line of lines) {
14598
- showCaddyLog && line && console.info(line);
14599
- if (isCaddyReloadCancellation(line)) {
14600
- consola.info("Caddy restarted before TLS issuance completed; retrying.\n");
14601
- continue;
14602
- }
14603
- try {
14604
- if (line.includes("Error:") || line && JSON.parse(line).level === "error") {
14605
- if (line.includes("parsing caddyfile tokens")) {
14606
- consola.error("Caddyfile syntax error, please contact the author:\n", `${this.caddyfile}
14228
+ setupCleanup();
14229
+ void (async () => {
14230
+ try {
14231
+ const child = new HelperCaddyProcess(session.client);
14232
+ this._caddyChild = child;
14233
+ await session.client.call("caddy.start");
14234
+ child.on("exit", (code) => {
14235
+ if (code !== null && code !== 0)
14236
+ reject2(new Error(`Caddy exited with code ${code}`));
14237
+ });
14238
+ child.stderr.on("data", async (data) => {
14239
+ const lines = data.toString().split("\n").map((line) => line.trim());
14240
+ for (const line of lines) {
14241
+ showCaddyLog && line && console.info(line);
14242
+ if (isCaddyReloadCancellation(line)) {
14243
+ consola.info("Caddy restarted before TLS issuance completed; retrying.\n");
14244
+ continue;
14245
+ }
14246
+ try {
14247
+ if (line.includes("Error:") || line && JSON.parse(line).level === "error") {
14248
+ if (line.includes("parsing caddyfile tokens")) {
14249
+ consola.error("Caddyfile syntax error, please contact the author:\n", `${this.caddyfile}
14607
14250
 
14608
14251
  ${line}
14609
14252
  `);
14610
- await this.baseCleanup();
14611
- process7.exit();
14612
- } else {
14613
- consola.error(`${line}
14253
+ await this.baseCleanup();
14254
+ process8.exit();
14255
+ } else {
14256
+ consola.error(`${line}
14614
14257
  `);
14615
- return reject2(line);
14616
- }
14258
+ return reject2(line);
14617
14259
  }
14618
- } catch {
14619
14260
  }
14620
- if (line.includes("config file changed"))
14621
- consola.success("Detect added a new reverse proxy config, restarted.\n");
14622
- if (line.includes("caddy proxying") || line.includes("serving initial"))
14623
- void resolveWhenReady();
14261
+ } catch {
14624
14262
  }
14625
- });
14626
- child.stdout.on("data", (data) => {
14627
- consola.info(data.toString());
14628
- void resolveWhenReady();
14629
- });
14630
- } catch (error) {
14631
- if (!this.locked)
14632
- await this.baseCleanup(restore);
14633
- reject2(error);
14634
- }
14635
- })();
14636
- } else {
14637
- consola.info("Caddy is running in another process.");
14638
- void (async () => {
14639
- try {
14640
- if (https)
14641
- await this.ensureTlsReady(targetHost);
14642
- setupCleanup();
14643
- resolve2();
14644
- } catch (error) {
14645
- reject2(error);
14646
- }
14647
- })();
14648
- }
14263
+ if (line.includes("config file changed"))
14264
+ consola.success("Detect added a new reverse proxy config, restarted.\n");
14265
+ if (line.includes("caddy proxying") || line.includes("serving initial"))
14266
+ void resolveWhenReady();
14267
+ }
14268
+ });
14269
+ child.stdout.on("data", (data) => {
14270
+ consola.info(data.toString());
14271
+ void resolveWhenReady();
14272
+ });
14273
+ } catch (error) {
14274
+ await this.baseCleanup(restore);
14275
+ reject2(error);
14276
+ }
14277
+ })();
14649
14278
  });
14650
14279
  }
14651
14280
  async baseCleanup(restore = true) {
@@ -14669,18 +14298,9 @@ ${line}
14669
14298
  consola.fail("Restore host failed.\n");
14670
14299
  }
14671
14300
  }
14672
- if (!this.locked && !this.stoped) {
14673
- await this.stopCaddy();
14301
+ if (!this.stoped) {
14674
14302
  try {
14675
- await lockfile.unlock(caddyLockFilePath).catch(() => {
14676
- });
14677
- await unlink3(caddyFilePath).catch(() => {
14678
- });
14679
- await unlink3(caddyLockFilePath).catch(() => {
14680
- });
14681
- if (caddyConfig) {
14682
- await caddyConfig.cleanUp();
14683
- }
14303
+ await this.deps.config().removeProxy(this.proxyKey);
14684
14304
  } catch (e) {
14685
14305
  consola.error(e);
14686
14306
  }
@@ -14692,7 +14312,7 @@ ${line}
14692
14312
  var config;
14693
14313
  var caddy;
14694
14314
  var hmrSseBridgeActive = false;
14695
- var cwd = process8.cwd();
14315
+ var cwd = process9.cwd();
14696
14316
  function colorUrl(url2) {
14697
14317
  return c.green(url2.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`));
14698
14318
  }
@@ -14803,7 +14423,7 @@ var unpluginFactory = (options) => ({
14803
14423
  },
14804
14424
  webpack(compiler) {
14805
14425
  var _a4, _b3, _c2;
14806
- if (process8.env.NODE_ENV !== "development")
14426
+ if (process9.env.NODE_ENV !== "development")
14807
14427
  return;
14808
14428
  const {
14809
14429
  enable = true,
@@ -14824,7 +14444,7 @@ var unpluginFactory = (options) => ({
14824
14444
  port: 8080,
14825
14445
  ...compiler.options.devServer,
14826
14446
  // @ts-expect-error vuecli
14827
- ...(_a4 = process8.VUE_CLI_SERVICE) == null ? void 0 : _a4.projectOptions.devServer
14447
+ ...(_a4 = process9.VUE_CLI_SERVICE) == null ? void 0 : _a4.projectOptions.devServer
14828
14448
  };
14829
14449
  const source = `${devServer.host}:${devServer.port}`;
14830
14450
  if (isPrivilegeDenied())
@@ -14843,7 +14463,7 @@ var unpluginFactory = (options) => ({
14843
14463
  const _close = (_c2 = compiler.close) == null ? void 0 : _c2.bind(compiler);
14844
14464
  if (_close) {
14845
14465
  compiler.close = async (callback) => {
14846
- process8.on("exit", () => {
14466
+ process9.on("exit", () => {
14847
14467
  _close && _close(callback);
14848
14468
  });
14849
14469
  };
@@ -14874,7 +14494,7 @@ var unpluginFactory = (options) => ({
14874
14494
  },
14875
14495
  async rspack(compiler) {
14876
14496
  var _a4, _b3, _c2, _d2;
14877
- if (process8.env.NODE_ENV !== "development")
14497
+ if (process9.env.NODE_ENV !== "development")
14878
14498
  return;
14879
14499
  const {
14880
14500
  enable = true,