unplugin-https-reverse-proxy 2.0.3-beta.2 → 3.0.0

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.
@@ -13352,11 +13352,11 @@ var Liquid = class _Liquid {
13352
13352
  // src/caddy/caddyfile.ts
13353
13353
  var ProxyType = type({
13354
13354
  target: "string",
13355
- port_suffix: "string",
13355
+ portSuffix: "string",
13356
13356
  tls: "string",
13357
13357
  source: "string",
13358
13358
  base: "string",
13359
- health_check: "boolean"
13359
+ healthCheck: "boolean"
13360
13360
  });
13361
13361
  var CaddyContext = type({
13362
13362
  caddy_root: "string",
@@ -13392,9 +13392,9 @@ var caddyTemplate = `{
13392
13392
  }
13393
13393
 
13394
13394
  {% for p in proxies %}
13395
- {{ p.target }}{{ p.port_suffix }} {
13395
+ {{ p.target }}{{ p.portSuffix }} {
13396
13396
  {{ p.tls }}
13397
- reverse_proxy http://{{ p.source }} {% if p.health_check %} {
13397
+ reverse_proxy http://{{ p.source }} {% if p.healthCheck %} {
13398
13398
  health_uri {{ p.base }}
13399
13399
  health_interval 2s
13400
13400
  health_timeout 5s
@@ -13556,7 +13556,7 @@ var supportList = [
13556
13556
  // src/caddy/config.ts
13557
13557
  function useCaddyConfig() {
13558
13558
  const configContentRef = signal("{}");
13559
- const configJsonRef2 = computed(() => {
13559
+ const configJsonRef = computed(() => {
13560
13560
  try {
13561
13561
  return JSON.parse(configContentRef());
13562
13562
  } catch {
@@ -13579,26 +13579,26 @@ function useCaddyConfig() {
13579
13579
  const watchCaddyConfig = watch(caddyConfigPath, () => {
13580
13580
  setConfigContent();
13581
13581
  });
13582
- function writeCaddyConfig2(_proxies) {
13583
- const proxies = configJsonRef2() || {};
13582
+ function writeCaddyConfig(_proxies) {
13583
+ const proxies = configJsonRef() || {};
13584
13584
  _proxies.forEach((p) => {
13585
- const index = `${p.target}${p.port_suffix}`;
13585
+ const index = `${p.target}${p.portSuffix}`;
13586
13586
  proxies[index] = p;
13587
13587
  });
13588
13588
  const content = JSON.stringify(proxies, null, 2);
13589
13589
  configContentRef(content);
13590
13590
  return writeFileSync(caddyConfigPath, content);
13591
13591
  }
13592
- async function cleanUp2() {
13592
+ async function cleanUp() {
13593
13593
  await unlink2(caddyConfigPath).catch(() => {
13594
13594
  });
13595
13595
  configContentRef("{}");
13596
13596
  watchCaddyConfig.close();
13597
13597
  }
13598
13598
  return {
13599
- configJsonRef: configJsonRef2,
13600
- writeCaddyConfig: writeCaddyConfig2,
13601
- cleanUp: cleanUp2
13599
+ configJsonRef,
13600
+ writeCaddyConfig,
13601
+ cleanUp
13602
13602
  };
13603
13603
  }
13604
13604
 
@@ -13732,7 +13732,13 @@ function testCaddy() {
13732
13732
  });
13733
13733
  });
13734
13734
  }
13735
- var { cleanUp, configJsonRef, writeCaddyConfig } = useCaddyConfig();
13735
+ var caddyConfig;
13736
+ function getCaddyConfig() {
13737
+ if (!caddyConfig) {
13738
+ caddyConfig = useCaddyConfig();
13739
+ }
13740
+ return caddyConfig;
13741
+ }
13736
13742
  var CaddyInstant = class {
13737
13743
  constructor() {
13738
13744
  this.inited = false;
@@ -13785,7 +13791,7 @@ var CaddyInstant = class {
13785
13791
  base = "/",
13786
13792
  showCaddyLog = false,
13787
13793
  https = false,
13788
- health_check = true
13794
+ healthCheck = true
13789
13795
  } = options || {};
13790
13796
  this._source = source;
13791
13797
  this._target = target;
@@ -13798,16 +13804,18 @@ var CaddyInstant = class {
13798
13804
  const proxies = [
13799
13805
  {
13800
13806
  target: targetHost,
13801
- port_suffix: https ? "" : ":80",
13807
+ portSuffix: https ? "" : ":80",
13802
13808
  tls: https ? "tls internal" : "",
13803
13809
  source,
13804
13810
  base,
13805
- health_check
13811
+ healthCheck
13806
13812
  }
13807
13813
  ];
13814
+ const { writeCaddyConfig } = getCaddyConfig();
13808
13815
  writeCaddyConfig(proxies);
13809
13816
  this._stopEffects.push(
13810
13817
  effect(async () => {
13818
+ const { configJsonRef } = getCaddyConfig();
13811
13819
  const proxies2 = Object.values(configJsonRef() || {});
13812
13820
  if (!(this.caddyfile || "").includes(`${target.split(":")[0]}${https ? "" : ":80"}`)) {
13813
13821
  const ctx = validateTemplateContext({
@@ -13942,7 +13950,9 @@ ${line}
13942
13950
  });
13943
13951
  await unlink3(caddyLockFilePath).catch(() => {
13944
13952
  });
13945
- await cleanUp();
13953
+ if (caddyConfig) {
13954
+ await caddyConfig.cleanUp();
13955
+ }
13946
13956
  } catch (e) {
13947
13957
  consola.error(e);
13948
13958
  }
package/dist/esbuild.cjs CHANGED
@@ -13437,11 +13437,11 @@ var Liquid = class _Liquid {
13437
13437
  // src/caddy/caddyfile.ts
13438
13438
  var ProxyType = type({
13439
13439
  target: "string",
13440
- port_suffix: "string",
13440
+ portSuffix: "string",
13441
13441
  tls: "string",
13442
13442
  source: "string",
13443
13443
  base: "string",
13444
- health_check: "boolean"
13444
+ healthCheck: "boolean"
13445
13445
  });
13446
13446
  var CaddyContext = type({
13447
13447
  caddy_root: "string",
@@ -13477,9 +13477,9 @@ var caddyTemplate = `{
13477
13477
  }
13478
13478
 
13479
13479
  {% for p in proxies %}
13480
- {{ p.target }}{{ p.port_suffix }} {
13480
+ {{ p.target }}{{ p.portSuffix }} {
13481
13481
  {{ p.tls }}
13482
- reverse_proxy http://{{ p.source }} {% if p.health_check %} {
13482
+ reverse_proxy http://{{ p.source }} {% if p.healthCheck %} {
13483
13483
  health_uri {{ p.base }}
13484
13484
  health_interval 2s
13485
13485
  health_timeout 5s
@@ -13641,7 +13641,7 @@ var supportList = [
13641
13641
  // src/caddy/config.ts
13642
13642
  function useCaddyConfig() {
13643
13643
  const configContentRef = signal("{}");
13644
- const configJsonRef2 = computed(() => {
13644
+ const configJsonRef = computed(() => {
13645
13645
  try {
13646
13646
  return JSON.parse(configContentRef());
13647
13647
  } catch {
@@ -13664,26 +13664,26 @@ function useCaddyConfig() {
13664
13664
  const watchCaddyConfig = (0, import_node_fs2.watch)(caddyConfigPath, () => {
13665
13665
  setConfigContent();
13666
13666
  });
13667
- function writeCaddyConfig2(_proxies) {
13668
- const proxies = configJsonRef2() || {};
13667
+ function writeCaddyConfig(_proxies) {
13668
+ const proxies = configJsonRef() || {};
13669
13669
  _proxies.forEach((p) => {
13670
- const index = `${p.target}${p.port_suffix}`;
13670
+ const index = `${p.target}${p.portSuffix}`;
13671
13671
  proxies[index] = p;
13672
13672
  });
13673
13673
  const content = JSON.stringify(proxies, null, 2);
13674
13674
  configContentRef(content);
13675
13675
  return (0, import_node_fs2.writeFileSync)(caddyConfigPath, content);
13676
13676
  }
13677
- async function cleanUp2() {
13677
+ async function cleanUp() {
13678
13678
  await (0, import_promises2.unlink)(caddyConfigPath).catch(() => {
13679
13679
  });
13680
13680
  configContentRef("{}");
13681
13681
  watchCaddyConfig.close();
13682
13682
  }
13683
13683
  return {
13684
- configJsonRef: configJsonRef2,
13685
- writeCaddyConfig: writeCaddyConfig2,
13686
- cleanUp: cleanUp2
13684
+ configJsonRef,
13685
+ writeCaddyConfig,
13686
+ cleanUp
13687
13687
  };
13688
13688
  }
13689
13689
 
@@ -13817,7 +13817,13 @@ function testCaddy() {
13817
13817
  });
13818
13818
  });
13819
13819
  }
13820
- var { cleanUp, configJsonRef, writeCaddyConfig } = useCaddyConfig();
13820
+ var caddyConfig;
13821
+ function getCaddyConfig() {
13822
+ if (!caddyConfig) {
13823
+ caddyConfig = useCaddyConfig();
13824
+ }
13825
+ return caddyConfig;
13826
+ }
13821
13827
  var CaddyInstant = class {
13822
13828
  constructor() {
13823
13829
  this.inited = false;
@@ -13870,7 +13876,7 @@ var CaddyInstant = class {
13870
13876
  base = "/",
13871
13877
  showCaddyLog = false,
13872
13878
  https = false,
13873
- health_check = true
13879
+ healthCheck = true
13874
13880
  } = options || {};
13875
13881
  this._source = source;
13876
13882
  this._target = target;
@@ -13883,16 +13889,18 @@ var CaddyInstant = class {
13883
13889
  const proxies = [
13884
13890
  {
13885
13891
  target: targetHost,
13886
- port_suffix: https ? "" : ":80",
13892
+ portSuffix: https ? "" : ":80",
13887
13893
  tls: https ? "tls internal" : "",
13888
13894
  source,
13889
13895
  base,
13890
- health_check
13896
+ healthCheck
13891
13897
  }
13892
13898
  ];
13899
+ const { writeCaddyConfig } = getCaddyConfig();
13893
13900
  writeCaddyConfig(proxies);
13894
13901
  this._stopEffects.push(
13895
13902
  effect(async () => {
13903
+ const { configJsonRef } = getCaddyConfig();
13896
13904
  const proxies2 = Object.values(configJsonRef() || {});
13897
13905
  if (!(this.caddyfile || "").includes(`${target.split(":")[0]}${https ? "" : ":80"}`)) {
13898
13906
  const ctx = validateTemplateContext({
@@ -14027,7 +14035,9 @@ ${line}
14027
14035
  });
14028
14036
  await (0, import_promises3.unlink)(caddyLockFilePath).catch(() => {
14029
14037
  });
14030
- await cleanUp();
14038
+ if (caddyConfig) {
14039
+ await caddyConfig.cleanUp();
14040
+ }
14031
14041
  } catch (e) {
14032
14042
  consola.error(e);
14033
14043
  }
package/dist/esbuild.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-XGTVAT6M.js";
3
+ } from "./chunk-5MC5SB7O.js";
4
4
  import "./chunk-2P7SUCQ3.js";
5
5
 
6
6
  // src/esbuild.ts
package/dist/index.cjs CHANGED
@@ -13437,11 +13437,11 @@ var Liquid = class _Liquid {
13437
13437
  // src/caddy/caddyfile.ts
13438
13438
  var ProxyType = type({
13439
13439
  target: "string",
13440
- port_suffix: "string",
13440
+ portSuffix: "string",
13441
13441
  tls: "string",
13442
13442
  source: "string",
13443
13443
  base: "string",
13444
- health_check: "boolean"
13444
+ healthCheck: "boolean"
13445
13445
  });
13446
13446
  var CaddyContext = type({
13447
13447
  caddy_root: "string",
@@ -13477,9 +13477,9 @@ var caddyTemplate = `{
13477
13477
  }
13478
13478
 
13479
13479
  {% for p in proxies %}
13480
- {{ p.target }}{{ p.port_suffix }} {
13480
+ {{ p.target }}{{ p.portSuffix }} {
13481
13481
  {{ p.tls }}
13482
- reverse_proxy http://{{ p.source }} {% if p.health_check %} {
13482
+ reverse_proxy http://{{ p.source }} {% if p.healthCheck %} {
13483
13483
  health_uri {{ p.base }}
13484
13484
  health_interval 2s
13485
13485
  health_timeout 5s
@@ -13641,7 +13641,7 @@ var supportList = [
13641
13641
  // src/caddy/config.ts
13642
13642
  function useCaddyConfig() {
13643
13643
  const configContentRef = signal("{}");
13644
- const configJsonRef2 = computed(() => {
13644
+ const configJsonRef = computed(() => {
13645
13645
  try {
13646
13646
  return JSON.parse(configContentRef());
13647
13647
  } catch {
@@ -13664,26 +13664,26 @@ function useCaddyConfig() {
13664
13664
  const watchCaddyConfig = (0, import_node_fs2.watch)(caddyConfigPath, () => {
13665
13665
  setConfigContent();
13666
13666
  });
13667
- function writeCaddyConfig2(_proxies) {
13668
- const proxies = configJsonRef2() || {};
13667
+ function writeCaddyConfig(_proxies) {
13668
+ const proxies = configJsonRef() || {};
13669
13669
  _proxies.forEach((p) => {
13670
- const index = `${p.target}${p.port_suffix}`;
13670
+ const index = `${p.target}${p.portSuffix}`;
13671
13671
  proxies[index] = p;
13672
13672
  });
13673
13673
  const content = JSON.stringify(proxies, null, 2);
13674
13674
  configContentRef(content);
13675
13675
  return (0, import_node_fs2.writeFileSync)(caddyConfigPath, content);
13676
13676
  }
13677
- async function cleanUp2() {
13677
+ async function cleanUp() {
13678
13678
  await (0, import_promises2.unlink)(caddyConfigPath).catch(() => {
13679
13679
  });
13680
13680
  configContentRef("{}");
13681
13681
  watchCaddyConfig.close();
13682
13682
  }
13683
13683
  return {
13684
- configJsonRef: configJsonRef2,
13685
- writeCaddyConfig: writeCaddyConfig2,
13686
- cleanUp: cleanUp2
13684
+ configJsonRef,
13685
+ writeCaddyConfig,
13686
+ cleanUp
13687
13687
  };
13688
13688
  }
13689
13689
 
@@ -13817,7 +13817,13 @@ function testCaddy() {
13817
13817
  });
13818
13818
  });
13819
13819
  }
13820
- var { cleanUp, configJsonRef, writeCaddyConfig } = useCaddyConfig();
13820
+ var caddyConfig;
13821
+ function getCaddyConfig() {
13822
+ if (!caddyConfig) {
13823
+ caddyConfig = useCaddyConfig();
13824
+ }
13825
+ return caddyConfig;
13826
+ }
13821
13827
  var CaddyInstant = class {
13822
13828
  constructor() {
13823
13829
  this.inited = false;
@@ -13870,7 +13876,7 @@ var CaddyInstant = class {
13870
13876
  base = "/",
13871
13877
  showCaddyLog = false,
13872
13878
  https = false,
13873
- health_check = true
13879
+ healthCheck = true
13874
13880
  } = options || {};
13875
13881
  this._source = source;
13876
13882
  this._target = target;
@@ -13883,16 +13889,18 @@ var CaddyInstant = class {
13883
13889
  const proxies = [
13884
13890
  {
13885
13891
  target: targetHost,
13886
- port_suffix: https ? "" : ":80",
13892
+ portSuffix: https ? "" : ":80",
13887
13893
  tls: https ? "tls internal" : "",
13888
13894
  source,
13889
13895
  base,
13890
- health_check
13896
+ healthCheck
13891
13897
  }
13892
13898
  ];
13899
+ const { writeCaddyConfig } = getCaddyConfig();
13893
13900
  writeCaddyConfig(proxies);
13894
13901
  this._stopEffects.push(
13895
13902
  effect(async () => {
13903
+ const { configJsonRef } = getCaddyConfig();
13896
13904
  const proxies2 = Object.values(configJsonRef() || {});
13897
13905
  if (!(this.caddyfile || "").includes(`${target.split(":")[0]}${https ? "" : ":80"}`)) {
13898
13906
  const ctx = validateTemplateContext({
@@ -14027,7 +14035,9 @@ ${line}
14027
14035
  });
14028
14036
  await (0, import_promises3.unlink)(caddyLockFilePath).catch(() => {
14029
14037
  });
14030
- await cleanUp();
14038
+ if (caddyConfig) {
14039
+ await caddyConfig.cleanUp();
14040
+ }
14031
14041
  } catch (e) {
14032
14042
  consola.error(e);
14033
14043
  }
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  unplugin,
4
4
  unpluginFactory,
5
5
  vitePrintUrls
6
- } from "./chunk-XGTVAT6M.js";
6
+ } from "./chunk-5MC5SB7O.js";
7
7
  import "./chunk-2P7SUCQ3.js";
8
8
  export {
9
9
  src_default as default,
package/dist/nuxt.cjs CHANGED
@@ -13438,11 +13438,11 @@ var Liquid = class _Liquid {
13438
13438
  // src/caddy/caddyfile.ts
13439
13439
  var ProxyType = type({
13440
13440
  target: "string",
13441
- port_suffix: "string",
13441
+ portSuffix: "string",
13442
13442
  tls: "string",
13443
13443
  source: "string",
13444
13444
  base: "string",
13445
- health_check: "boolean"
13445
+ healthCheck: "boolean"
13446
13446
  });
13447
13447
  var CaddyContext = type({
13448
13448
  caddy_root: "string",
@@ -13478,9 +13478,9 @@ var caddyTemplate = `{
13478
13478
  }
13479
13479
 
13480
13480
  {% for p in proxies %}
13481
- {{ p.target }}{{ p.port_suffix }} {
13481
+ {{ p.target }}{{ p.portSuffix }} {
13482
13482
  {{ p.tls }}
13483
- reverse_proxy http://{{ p.source }} {% if p.health_check %} {
13483
+ reverse_proxy http://{{ p.source }} {% if p.healthCheck %} {
13484
13484
  health_uri {{ p.base }}
13485
13485
  health_interval 2s
13486
13486
  health_timeout 5s
@@ -13642,7 +13642,7 @@ var supportList = [
13642
13642
  // src/caddy/config.ts
13643
13643
  function useCaddyConfig() {
13644
13644
  const configContentRef = signal("{}");
13645
- const configJsonRef2 = computed(() => {
13645
+ const configJsonRef = computed(() => {
13646
13646
  try {
13647
13647
  return JSON.parse(configContentRef());
13648
13648
  } catch {
@@ -13665,26 +13665,26 @@ function useCaddyConfig() {
13665
13665
  const watchCaddyConfig = (0, import_node_fs2.watch)(caddyConfigPath, () => {
13666
13666
  setConfigContent();
13667
13667
  });
13668
- function writeCaddyConfig2(_proxies) {
13669
- const proxies = configJsonRef2() || {};
13668
+ function writeCaddyConfig(_proxies) {
13669
+ const proxies = configJsonRef() || {};
13670
13670
  _proxies.forEach((p) => {
13671
- const index = `${p.target}${p.port_suffix}`;
13671
+ const index = `${p.target}${p.portSuffix}`;
13672
13672
  proxies[index] = p;
13673
13673
  });
13674
13674
  const content = JSON.stringify(proxies, null, 2);
13675
13675
  configContentRef(content);
13676
13676
  return (0, import_node_fs2.writeFileSync)(caddyConfigPath, content);
13677
13677
  }
13678
- async function cleanUp2() {
13678
+ async function cleanUp() {
13679
13679
  await (0, import_promises2.unlink)(caddyConfigPath).catch(() => {
13680
13680
  });
13681
13681
  configContentRef("{}");
13682
13682
  watchCaddyConfig.close();
13683
13683
  }
13684
13684
  return {
13685
- configJsonRef: configJsonRef2,
13686
- writeCaddyConfig: writeCaddyConfig2,
13687
- cleanUp: cleanUp2
13685
+ configJsonRef,
13686
+ writeCaddyConfig,
13687
+ cleanUp
13688
13688
  };
13689
13689
  }
13690
13690
 
@@ -13818,7 +13818,13 @@ function testCaddy() {
13818
13818
  });
13819
13819
  });
13820
13820
  }
13821
- var { cleanUp, configJsonRef, writeCaddyConfig } = useCaddyConfig();
13821
+ var caddyConfig;
13822
+ function getCaddyConfig() {
13823
+ if (!caddyConfig) {
13824
+ caddyConfig = useCaddyConfig();
13825
+ }
13826
+ return caddyConfig;
13827
+ }
13822
13828
  var CaddyInstant = class {
13823
13829
  constructor() {
13824
13830
  this.inited = false;
@@ -13871,7 +13877,7 @@ var CaddyInstant = class {
13871
13877
  base = "/",
13872
13878
  showCaddyLog = false,
13873
13879
  https = false,
13874
- health_check = true
13880
+ healthCheck = true
13875
13881
  } = options || {};
13876
13882
  this._source = source;
13877
13883
  this._target = target;
@@ -13884,16 +13890,18 @@ var CaddyInstant = class {
13884
13890
  const proxies = [
13885
13891
  {
13886
13892
  target: targetHost,
13887
- port_suffix: https ? "" : ":80",
13893
+ portSuffix: https ? "" : ":80",
13888
13894
  tls: https ? "tls internal" : "",
13889
13895
  source,
13890
13896
  base,
13891
- health_check
13897
+ healthCheck
13892
13898
  }
13893
13899
  ];
13900
+ const { writeCaddyConfig } = getCaddyConfig();
13894
13901
  writeCaddyConfig(proxies);
13895
13902
  this._stopEffects.push(
13896
13903
  effect(async () => {
13904
+ const { configJsonRef } = getCaddyConfig();
13897
13905
  const proxies2 = Object.values(configJsonRef() || {});
13898
13906
  if (!(this.caddyfile || "").includes(`${target.split(":")[0]}${https ? "" : ":80"}`)) {
13899
13907
  const ctx = validateTemplateContext({
@@ -14028,7 +14036,9 @@ ${line}
14028
14036
  });
14029
14037
  await (0, import_promises3.unlink)(caddyLockFilePath).catch(() => {
14030
14038
  });
14031
- await cleanUp();
14039
+ if (caddyConfig) {
14040
+ await caddyConfig.cleanUp();
14041
+ }
14032
14042
  } catch (e) {
14033
14043
  consola.error(e);
14034
14044
  }
package/dist/nuxt.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  vitePrintUrls
3
- } from "./chunk-XGTVAT6M.js";
3
+ } from "./chunk-5MC5SB7O.js";
4
4
  import {
5
5
  consola,
6
6
  isAdmin
package/dist/rollup.cjs CHANGED
@@ -13437,11 +13437,11 @@ var Liquid = class _Liquid {
13437
13437
  // src/caddy/caddyfile.ts
13438
13438
  var ProxyType = type({
13439
13439
  target: "string",
13440
- port_suffix: "string",
13440
+ portSuffix: "string",
13441
13441
  tls: "string",
13442
13442
  source: "string",
13443
13443
  base: "string",
13444
- health_check: "boolean"
13444
+ healthCheck: "boolean"
13445
13445
  });
13446
13446
  var CaddyContext = type({
13447
13447
  caddy_root: "string",
@@ -13477,9 +13477,9 @@ var caddyTemplate = `{
13477
13477
  }
13478
13478
 
13479
13479
  {% for p in proxies %}
13480
- {{ p.target }}{{ p.port_suffix }} {
13480
+ {{ p.target }}{{ p.portSuffix }} {
13481
13481
  {{ p.tls }}
13482
- reverse_proxy http://{{ p.source }} {% if p.health_check %} {
13482
+ reverse_proxy http://{{ p.source }} {% if p.healthCheck %} {
13483
13483
  health_uri {{ p.base }}
13484
13484
  health_interval 2s
13485
13485
  health_timeout 5s
@@ -13641,7 +13641,7 @@ var supportList = [
13641
13641
  // src/caddy/config.ts
13642
13642
  function useCaddyConfig() {
13643
13643
  const configContentRef = signal("{}");
13644
- const configJsonRef2 = computed(() => {
13644
+ const configJsonRef = computed(() => {
13645
13645
  try {
13646
13646
  return JSON.parse(configContentRef());
13647
13647
  } catch {
@@ -13664,26 +13664,26 @@ function useCaddyConfig() {
13664
13664
  const watchCaddyConfig = (0, import_node_fs2.watch)(caddyConfigPath, () => {
13665
13665
  setConfigContent();
13666
13666
  });
13667
- function writeCaddyConfig2(_proxies) {
13668
- const proxies = configJsonRef2() || {};
13667
+ function writeCaddyConfig(_proxies) {
13668
+ const proxies = configJsonRef() || {};
13669
13669
  _proxies.forEach((p) => {
13670
- const index = `${p.target}${p.port_suffix}`;
13670
+ const index = `${p.target}${p.portSuffix}`;
13671
13671
  proxies[index] = p;
13672
13672
  });
13673
13673
  const content = JSON.stringify(proxies, null, 2);
13674
13674
  configContentRef(content);
13675
13675
  return (0, import_node_fs2.writeFileSync)(caddyConfigPath, content);
13676
13676
  }
13677
- async function cleanUp2() {
13677
+ async function cleanUp() {
13678
13678
  await (0, import_promises2.unlink)(caddyConfigPath).catch(() => {
13679
13679
  });
13680
13680
  configContentRef("{}");
13681
13681
  watchCaddyConfig.close();
13682
13682
  }
13683
13683
  return {
13684
- configJsonRef: configJsonRef2,
13685
- writeCaddyConfig: writeCaddyConfig2,
13686
- cleanUp: cleanUp2
13684
+ configJsonRef,
13685
+ writeCaddyConfig,
13686
+ cleanUp
13687
13687
  };
13688
13688
  }
13689
13689
 
@@ -13817,7 +13817,13 @@ function testCaddy() {
13817
13817
  });
13818
13818
  });
13819
13819
  }
13820
- var { cleanUp, configJsonRef, writeCaddyConfig } = useCaddyConfig();
13820
+ var caddyConfig;
13821
+ function getCaddyConfig() {
13822
+ if (!caddyConfig) {
13823
+ caddyConfig = useCaddyConfig();
13824
+ }
13825
+ return caddyConfig;
13826
+ }
13821
13827
  var CaddyInstant = class {
13822
13828
  constructor() {
13823
13829
  this.inited = false;
@@ -13870,7 +13876,7 @@ var CaddyInstant = class {
13870
13876
  base = "/",
13871
13877
  showCaddyLog = false,
13872
13878
  https = false,
13873
- health_check = true
13879
+ healthCheck = true
13874
13880
  } = options || {};
13875
13881
  this._source = source;
13876
13882
  this._target = target;
@@ -13883,16 +13889,18 @@ var CaddyInstant = class {
13883
13889
  const proxies = [
13884
13890
  {
13885
13891
  target: targetHost,
13886
- port_suffix: https ? "" : ":80",
13892
+ portSuffix: https ? "" : ":80",
13887
13893
  tls: https ? "tls internal" : "",
13888
13894
  source,
13889
13895
  base,
13890
- health_check
13896
+ healthCheck
13891
13897
  }
13892
13898
  ];
13899
+ const { writeCaddyConfig } = getCaddyConfig();
13893
13900
  writeCaddyConfig(proxies);
13894
13901
  this._stopEffects.push(
13895
13902
  effect(async () => {
13903
+ const { configJsonRef } = getCaddyConfig();
13896
13904
  const proxies2 = Object.values(configJsonRef() || {});
13897
13905
  if (!(this.caddyfile || "").includes(`${target.split(":")[0]}${https ? "" : ":80"}`)) {
13898
13906
  const ctx = validateTemplateContext({
@@ -14027,7 +14035,9 @@ ${line}
14027
14035
  });
14028
14036
  await (0, import_promises3.unlink)(caddyLockFilePath).catch(() => {
14029
14037
  });
14030
- await cleanUp();
14038
+ if (caddyConfig) {
14039
+ await caddyConfig.cleanUp();
14040
+ }
14031
14041
  } catch (e) {
14032
14042
  consola.error(e);
14033
14043
  }
package/dist/rollup.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-XGTVAT6M.js";
3
+ } from "./chunk-5MC5SB7O.js";
4
4
  import "./chunk-2P7SUCQ3.js";
5
5
 
6
6
  // src/rollup.ts
package/dist/rspack.cjs CHANGED
@@ -13436,11 +13436,11 @@ var Liquid = class _Liquid {
13436
13436
  // src/caddy/caddyfile.ts
13437
13437
  var ProxyType = type({
13438
13438
  target: "string",
13439
- port_suffix: "string",
13439
+ portSuffix: "string",
13440
13440
  tls: "string",
13441
13441
  source: "string",
13442
13442
  base: "string",
13443
- health_check: "boolean"
13443
+ healthCheck: "boolean"
13444
13444
  });
13445
13445
  var CaddyContext = type({
13446
13446
  caddy_root: "string",
@@ -13476,9 +13476,9 @@ var caddyTemplate = `{
13476
13476
  }
13477
13477
 
13478
13478
  {% for p in proxies %}
13479
- {{ p.target }}{{ p.port_suffix }} {
13479
+ {{ p.target }}{{ p.portSuffix }} {
13480
13480
  {{ p.tls }}
13481
- reverse_proxy http://{{ p.source }} {% if p.health_check %} {
13481
+ reverse_proxy http://{{ p.source }} {% if p.healthCheck %} {
13482
13482
  health_uri {{ p.base }}
13483
13483
  health_interval 2s
13484
13484
  health_timeout 5s
@@ -13640,7 +13640,7 @@ var supportList = [
13640
13640
  // src/caddy/config.ts
13641
13641
  function useCaddyConfig() {
13642
13642
  const configContentRef = signal("{}");
13643
- const configJsonRef2 = computed(() => {
13643
+ const configJsonRef = computed(() => {
13644
13644
  try {
13645
13645
  return JSON.parse(configContentRef());
13646
13646
  } catch {
@@ -13663,26 +13663,26 @@ function useCaddyConfig() {
13663
13663
  const watchCaddyConfig = (0, import_node_fs2.watch)(caddyConfigPath, () => {
13664
13664
  setConfigContent();
13665
13665
  });
13666
- function writeCaddyConfig2(_proxies) {
13667
- const proxies = configJsonRef2() || {};
13666
+ function writeCaddyConfig(_proxies) {
13667
+ const proxies = configJsonRef() || {};
13668
13668
  _proxies.forEach((p) => {
13669
- const index = `${p.target}${p.port_suffix}`;
13669
+ const index = `${p.target}${p.portSuffix}`;
13670
13670
  proxies[index] = p;
13671
13671
  });
13672
13672
  const content = JSON.stringify(proxies, null, 2);
13673
13673
  configContentRef(content);
13674
13674
  return (0, import_node_fs2.writeFileSync)(caddyConfigPath, content);
13675
13675
  }
13676
- async function cleanUp2() {
13676
+ async function cleanUp() {
13677
13677
  await (0, import_promises2.unlink)(caddyConfigPath).catch(() => {
13678
13678
  });
13679
13679
  configContentRef("{}");
13680
13680
  watchCaddyConfig.close();
13681
13681
  }
13682
13682
  return {
13683
- configJsonRef: configJsonRef2,
13684
- writeCaddyConfig: writeCaddyConfig2,
13685
- cleanUp: cleanUp2
13683
+ configJsonRef,
13684
+ writeCaddyConfig,
13685
+ cleanUp
13686
13686
  };
13687
13687
  }
13688
13688
 
@@ -13816,7 +13816,13 @@ function testCaddy() {
13816
13816
  });
13817
13817
  });
13818
13818
  }
13819
- var { cleanUp, configJsonRef, writeCaddyConfig } = useCaddyConfig();
13819
+ var caddyConfig;
13820
+ function getCaddyConfig() {
13821
+ if (!caddyConfig) {
13822
+ caddyConfig = useCaddyConfig();
13823
+ }
13824
+ return caddyConfig;
13825
+ }
13820
13826
  var CaddyInstant = class {
13821
13827
  constructor() {
13822
13828
  this.inited = false;
@@ -13869,7 +13875,7 @@ var CaddyInstant = class {
13869
13875
  base = "/",
13870
13876
  showCaddyLog = false,
13871
13877
  https = false,
13872
- health_check = true
13878
+ healthCheck = true
13873
13879
  } = options || {};
13874
13880
  this._source = source;
13875
13881
  this._target = target;
@@ -13882,16 +13888,18 @@ var CaddyInstant = class {
13882
13888
  const proxies = [
13883
13889
  {
13884
13890
  target: targetHost,
13885
- port_suffix: https ? "" : ":80",
13891
+ portSuffix: https ? "" : ":80",
13886
13892
  tls: https ? "tls internal" : "",
13887
13893
  source,
13888
13894
  base,
13889
- health_check
13895
+ healthCheck
13890
13896
  }
13891
13897
  ];
13898
+ const { writeCaddyConfig } = getCaddyConfig();
13892
13899
  writeCaddyConfig(proxies);
13893
13900
  this._stopEffects.push(
13894
13901
  effect(async () => {
13902
+ const { configJsonRef } = getCaddyConfig();
13895
13903
  const proxies2 = Object.values(configJsonRef() || {});
13896
13904
  if (!(this.caddyfile || "").includes(`${target.split(":")[0]}${https ? "" : ":80"}`)) {
13897
13905
  const ctx = validateTemplateContext({
@@ -14026,7 +14034,9 @@ ${line}
14026
14034
  });
14027
14035
  await (0, import_promises3.unlink)(caddyLockFilePath).catch(() => {
14028
14036
  });
14029
- await cleanUp();
14037
+ if (caddyConfig) {
14038
+ await caddyConfig.cleanUp();
14039
+ }
14030
14040
  } catch (e) {
14031
14041
  consola.error(e);
14032
14042
  }
package/dist/rspack.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  src_default
3
- } from "./chunk-XGTVAT6M.js";
3
+ } from "./chunk-5MC5SB7O.js";
4
4
  import "./chunk-2P7SUCQ3.js";
5
5
 
6
6
  // src/rspack.ts
package/dist/types.d.cts CHANGED
@@ -4,7 +4,7 @@ interface Options {
4
4
  showCaddyLog?: boolean;
5
5
  /** default `false` */
6
6
  https?: boolean;
7
- health_check?: boolean;
7
+ healthCheck?: boolean;
8
8
  }
9
9
 
10
10
  export type { Options };
package/dist/types.d.ts CHANGED
@@ -4,7 +4,7 @@ interface Options {
4
4
  showCaddyLog?: boolean;
5
5
  /** default `false` */
6
6
  https?: boolean;
7
- health_check?: boolean;
7
+ healthCheck?: boolean;
8
8
  }
9
9
 
10
10
  export type { Options };
package/dist/vite.cjs CHANGED
@@ -13437,11 +13437,11 @@ var Liquid = class _Liquid {
13437
13437
  // src/caddy/caddyfile.ts
13438
13438
  var ProxyType = type({
13439
13439
  target: "string",
13440
- port_suffix: "string",
13440
+ portSuffix: "string",
13441
13441
  tls: "string",
13442
13442
  source: "string",
13443
13443
  base: "string",
13444
- health_check: "boolean"
13444
+ healthCheck: "boolean"
13445
13445
  });
13446
13446
  var CaddyContext = type({
13447
13447
  caddy_root: "string",
@@ -13477,9 +13477,9 @@ var caddyTemplate = `{
13477
13477
  }
13478
13478
 
13479
13479
  {% for p in proxies %}
13480
- {{ p.target }}{{ p.port_suffix }} {
13480
+ {{ p.target }}{{ p.portSuffix }} {
13481
13481
  {{ p.tls }}
13482
- reverse_proxy http://{{ p.source }} {% if p.health_check %} {
13482
+ reverse_proxy http://{{ p.source }} {% if p.healthCheck %} {
13483
13483
  health_uri {{ p.base }}
13484
13484
  health_interval 2s
13485
13485
  health_timeout 5s
@@ -13641,7 +13641,7 @@ var supportList = [
13641
13641
  // src/caddy/config.ts
13642
13642
  function useCaddyConfig() {
13643
13643
  const configContentRef = signal("{}");
13644
- const configJsonRef2 = computed(() => {
13644
+ const configJsonRef = computed(() => {
13645
13645
  try {
13646
13646
  return JSON.parse(configContentRef());
13647
13647
  } catch {
@@ -13664,26 +13664,26 @@ function useCaddyConfig() {
13664
13664
  const watchCaddyConfig = (0, import_node_fs2.watch)(caddyConfigPath, () => {
13665
13665
  setConfigContent();
13666
13666
  });
13667
- function writeCaddyConfig2(_proxies) {
13668
- const proxies = configJsonRef2() || {};
13667
+ function writeCaddyConfig(_proxies) {
13668
+ const proxies = configJsonRef() || {};
13669
13669
  _proxies.forEach((p) => {
13670
- const index = `${p.target}${p.port_suffix}`;
13670
+ const index = `${p.target}${p.portSuffix}`;
13671
13671
  proxies[index] = p;
13672
13672
  });
13673
13673
  const content = JSON.stringify(proxies, null, 2);
13674
13674
  configContentRef(content);
13675
13675
  return (0, import_node_fs2.writeFileSync)(caddyConfigPath, content);
13676
13676
  }
13677
- async function cleanUp2() {
13677
+ async function cleanUp() {
13678
13678
  await (0, import_promises2.unlink)(caddyConfigPath).catch(() => {
13679
13679
  });
13680
13680
  configContentRef("{}");
13681
13681
  watchCaddyConfig.close();
13682
13682
  }
13683
13683
  return {
13684
- configJsonRef: configJsonRef2,
13685
- writeCaddyConfig: writeCaddyConfig2,
13686
- cleanUp: cleanUp2
13684
+ configJsonRef,
13685
+ writeCaddyConfig,
13686
+ cleanUp
13687
13687
  };
13688
13688
  }
13689
13689
 
@@ -13817,7 +13817,13 @@ function testCaddy() {
13817
13817
  });
13818
13818
  });
13819
13819
  }
13820
- var { cleanUp, configJsonRef, writeCaddyConfig } = useCaddyConfig();
13820
+ var caddyConfig;
13821
+ function getCaddyConfig() {
13822
+ if (!caddyConfig) {
13823
+ caddyConfig = useCaddyConfig();
13824
+ }
13825
+ return caddyConfig;
13826
+ }
13821
13827
  var CaddyInstant = class {
13822
13828
  constructor() {
13823
13829
  this.inited = false;
@@ -13870,7 +13876,7 @@ var CaddyInstant = class {
13870
13876
  base = "/",
13871
13877
  showCaddyLog = false,
13872
13878
  https = false,
13873
- health_check = true
13879
+ healthCheck = true
13874
13880
  } = options || {};
13875
13881
  this._source = source;
13876
13882
  this._target = target;
@@ -13883,16 +13889,18 @@ var CaddyInstant = class {
13883
13889
  const proxies = [
13884
13890
  {
13885
13891
  target: targetHost,
13886
- port_suffix: https ? "" : ":80",
13892
+ portSuffix: https ? "" : ":80",
13887
13893
  tls: https ? "tls internal" : "",
13888
13894
  source,
13889
13895
  base,
13890
- health_check
13896
+ healthCheck
13891
13897
  }
13892
13898
  ];
13899
+ const { writeCaddyConfig } = getCaddyConfig();
13893
13900
  writeCaddyConfig(proxies);
13894
13901
  this._stopEffects.push(
13895
13902
  effect(async () => {
13903
+ const { configJsonRef } = getCaddyConfig();
13896
13904
  const proxies2 = Object.values(configJsonRef() || {});
13897
13905
  if (!(this.caddyfile || "").includes(`${target.split(":")[0]}${https ? "" : ":80"}`)) {
13898
13906
  const ctx = validateTemplateContext({
@@ -14027,7 +14035,9 @@ ${line}
14027
14035
  });
14028
14036
  await (0, import_promises3.unlink)(caddyLockFilePath).catch(() => {
14029
14037
  });
14030
- await cleanUp();
14038
+ if (caddyConfig) {
14039
+ await caddyConfig.cleanUp();
14040
+ }
14031
14041
  } catch (e) {
14032
14042
  consola.error(e);
14033
14043
  }
package/dist/vite.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-XGTVAT6M.js";
3
+ } from "./chunk-5MC5SB7O.js";
4
4
  import "./chunk-2P7SUCQ3.js";
5
5
 
6
6
  // src/vite.ts
package/dist/webpack.cjs CHANGED
@@ -13437,11 +13437,11 @@ var Liquid = class _Liquid {
13437
13437
  // src/caddy/caddyfile.ts
13438
13438
  var ProxyType = type({
13439
13439
  target: "string",
13440
- port_suffix: "string",
13440
+ portSuffix: "string",
13441
13441
  tls: "string",
13442
13442
  source: "string",
13443
13443
  base: "string",
13444
- health_check: "boolean"
13444
+ healthCheck: "boolean"
13445
13445
  });
13446
13446
  var CaddyContext = type({
13447
13447
  caddy_root: "string",
@@ -13477,9 +13477,9 @@ var caddyTemplate = `{
13477
13477
  }
13478
13478
 
13479
13479
  {% for p in proxies %}
13480
- {{ p.target }}{{ p.port_suffix }} {
13480
+ {{ p.target }}{{ p.portSuffix }} {
13481
13481
  {{ p.tls }}
13482
- reverse_proxy http://{{ p.source }} {% if p.health_check %} {
13482
+ reverse_proxy http://{{ p.source }} {% if p.healthCheck %} {
13483
13483
  health_uri {{ p.base }}
13484
13484
  health_interval 2s
13485
13485
  health_timeout 5s
@@ -13641,7 +13641,7 @@ var supportList = [
13641
13641
  // src/caddy/config.ts
13642
13642
  function useCaddyConfig() {
13643
13643
  const configContentRef = signal("{}");
13644
- const configJsonRef2 = computed(() => {
13644
+ const configJsonRef = computed(() => {
13645
13645
  try {
13646
13646
  return JSON.parse(configContentRef());
13647
13647
  } catch {
@@ -13664,26 +13664,26 @@ function useCaddyConfig() {
13664
13664
  const watchCaddyConfig = (0, import_node_fs2.watch)(caddyConfigPath, () => {
13665
13665
  setConfigContent();
13666
13666
  });
13667
- function writeCaddyConfig2(_proxies) {
13668
- const proxies = configJsonRef2() || {};
13667
+ function writeCaddyConfig(_proxies) {
13668
+ const proxies = configJsonRef() || {};
13669
13669
  _proxies.forEach((p) => {
13670
- const index = `${p.target}${p.port_suffix}`;
13670
+ const index = `${p.target}${p.portSuffix}`;
13671
13671
  proxies[index] = p;
13672
13672
  });
13673
13673
  const content = JSON.stringify(proxies, null, 2);
13674
13674
  configContentRef(content);
13675
13675
  return (0, import_node_fs2.writeFileSync)(caddyConfigPath, content);
13676
13676
  }
13677
- async function cleanUp2() {
13677
+ async function cleanUp() {
13678
13678
  await (0, import_promises2.unlink)(caddyConfigPath).catch(() => {
13679
13679
  });
13680
13680
  configContentRef("{}");
13681
13681
  watchCaddyConfig.close();
13682
13682
  }
13683
13683
  return {
13684
- configJsonRef: configJsonRef2,
13685
- writeCaddyConfig: writeCaddyConfig2,
13686
- cleanUp: cleanUp2
13684
+ configJsonRef,
13685
+ writeCaddyConfig,
13686
+ cleanUp
13687
13687
  };
13688
13688
  }
13689
13689
 
@@ -13817,7 +13817,13 @@ function testCaddy() {
13817
13817
  });
13818
13818
  });
13819
13819
  }
13820
- var { cleanUp, configJsonRef, writeCaddyConfig } = useCaddyConfig();
13820
+ var caddyConfig;
13821
+ function getCaddyConfig() {
13822
+ if (!caddyConfig) {
13823
+ caddyConfig = useCaddyConfig();
13824
+ }
13825
+ return caddyConfig;
13826
+ }
13821
13827
  var CaddyInstant = class {
13822
13828
  constructor() {
13823
13829
  this.inited = false;
@@ -13870,7 +13876,7 @@ var CaddyInstant = class {
13870
13876
  base = "/",
13871
13877
  showCaddyLog = false,
13872
13878
  https = false,
13873
- health_check = true
13879
+ healthCheck = true
13874
13880
  } = options || {};
13875
13881
  this._source = source;
13876
13882
  this._target = target;
@@ -13883,16 +13889,18 @@ var CaddyInstant = class {
13883
13889
  const proxies = [
13884
13890
  {
13885
13891
  target: targetHost,
13886
- port_suffix: https ? "" : ":80",
13892
+ portSuffix: https ? "" : ":80",
13887
13893
  tls: https ? "tls internal" : "",
13888
13894
  source,
13889
13895
  base,
13890
- health_check
13896
+ healthCheck
13891
13897
  }
13892
13898
  ];
13899
+ const { writeCaddyConfig } = getCaddyConfig();
13893
13900
  writeCaddyConfig(proxies);
13894
13901
  this._stopEffects.push(
13895
13902
  effect(async () => {
13903
+ const { configJsonRef } = getCaddyConfig();
13896
13904
  const proxies2 = Object.values(configJsonRef() || {});
13897
13905
  if (!(this.caddyfile || "").includes(`${target.split(":")[0]}${https ? "" : ":80"}`)) {
13898
13906
  const ctx = validateTemplateContext({
@@ -14027,7 +14035,9 @@ ${line}
14027
14035
  });
14028
14036
  await (0, import_promises3.unlink)(caddyLockFilePath).catch(() => {
14029
14037
  });
14030
- await cleanUp();
14038
+ if (caddyConfig) {
14039
+ await caddyConfig.cleanUp();
14040
+ }
14031
14041
  } catch (e) {
14032
14042
  consola.error(e);
14033
14043
  }
package/dist/webpack.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-XGTVAT6M.js";
3
+ } from "./chunk-5MC5SB7O.js";
4
4
  import "./chunk-2P7SUCQ3.js";
5
5
 
6
6
  // 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": "2.0.3-beta.2",
4
+ "version": "3.0.0",
5
5
  "description": "",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/zcf0508/unplugin-https-reverse-proxy#readme",
@@ -163,6 +163,7 @@
163
163
  "dev": "tsup --watch src",
164
164
  "build:fix": "tsx scripts/postbuild.ts",
165
165
  "lint": "eslint .",
166
+ "typecheck": "tsc --noEmit",
166
167
  "play": "npm -C examples/vite run dev",
167
168
  "play:rsbuild": "npm -C examples/rsbuild run dev",
168
169
  "play:nuxt": "npm -C examples/nuxt run dev",
@@ -3,11 +3,11 @@ import { Liquid } from 'liquidjs'
3
3
 
4
4
  export const ProxyType = type({
5
5
  target: 'string',
6
- port_suffix: 'string',
6
+ portSuffix: 'string',
7
7
  tls: 'string',
8
8
  source: 'string',
9
9
  base: 'string',
10
- health_check: 'boolean',
10
+ healthCheck: 'boolean',
11
11
  })
12
12
 
13
13
  const CaddyContext = type({
@@ -47,9 +47,9 @@ export const caddyTemplate = `{
47
47
  }
48
48
 
49
49
  {% for p in proxies %}
50
- {{ p.target }}{{ p.port_suffix }} {
50
+ {{ p.target }}{{ p.portSuffix }} {
51
51
  {{ p.tls }}
52
- reverse_proxy http://{{ p.source }} {% if p.health_check %} {
52
+ reverse_proxy http://{{ p.source }} {% if p.healthCheck %} {
53
53
  health_uri {{ p.base }}
54
54
  health_interval 2s
55
55
  health_timeout 5s
@@ -44,7 +44,7 @@ export function useCaddyConfig(): {
44
44
  const proxies = configJsonRef() || {}
45
45
 
46
46
  _proxies.forEach((p) => {
47
- const index = `${p.target}${p.port_suffix}`
47
+ const index = `${p.target}${p.portSuffix}`
48
48
  proxies[index] = p
49
49
  })
50
50
 
@@ -102,10 +102,17 @@ interface RunOptions {
102
102
  base: string
103
103
  showCaddyLog: boolean
104
104
  https: boolean
105
- health_check?: boolean
105
+ healthCheck?: boolean
106
106
  }
107
107
 
108
- const { cleanUp, configJsonRef, writeCaddyConfig } = useCaddyConfig()
108
+ let caddyConfig: ReturnType<typeof useCaddyConfig> | undefined
109
+
110
+ function getCaddyConfig(): ReturnType<typeof useCaddyConfig> {
111
+ if (!caddyConfig) {
112
+ caddyConfig = useCaddyConfig()
113
+ }
114
+ return caddyConfig
115
+ }
109
116
 
110
117
  export class CaddyInstant {
111
118
  private inited = false
@@ -178,7 +185,7 @@ export class CaddyInstant {
178
185
  base = '/',
179
186
  showCaddyLog = false,
180
187
  https = false,
181
- health_check = true,
188
+ healthCheck = true,
182
189
  } = options || {}
183
190
 
184
191
  this._source = source
@@ -196,18 +203,20 @@ export class CaddyInstant {
196
203
  const proxies = [
197
204
  {
198
205
  target: targetHost,
199
- port_suffix: https ? '' : ':80',
206
+ portSuffix: https ? '' : ':80',
200
207
  tls: https ? 'tls internal' : '',
201
208
  source,
202
209
  base,
203
- health_check,
210
+ healthCheck,
204
211
  },
205
212
  ]
206
213
 
214
+ const { writeCaddyConfig } = getCaddyConfig()
207
215
  writeCaddyConfig(proxies)
208
216
 
209
217
  this._stopEffects.push(
210
218
  effect(async () => {
219
+ const { configJsonRef } = getCaddyConfig()
211
220
  const proxies = Object.values(configJsonRef() || {})
212
221
  if (!(this.caddyfile || '').includes(`${target.split(':')[0]}${https ? '' : ':80'}`)) {
213
222
  const ctx = validateTemplateContext({
@@ -368,7 +377,9 @@ export class CaddyInstant {
368
377
  await lockfile.unlock(caddyLockFilePath).catch(() => { })
369
378
  await unlink(caddyFilePath).catch(() => { })
370
379
  await unlink(caddyLockFilePath).catch(() => { })
371
- await cleanUp()
380
+ if (caddyConfig) {
381
+ await caddyConfig.cleanUp()
382
+ }
372
383
  }
373
384
  catch (e) {
374
385
  consola.error(e)
package/src/types.ts CHANGED
@@ -5,5 +5,5 @@ export interface Options {
5
5
  showCaddyLog?: boolean
6
6
  /** default `false` */
7
7
  https?: boolean
8
- health_check?: boolean
8
+ healthCheck?: boolean
9
9
  }