postboy-tui 1.3.0 → 1.3.1

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.
Files changed (2) hide show
  1. package/dist/cli.js +260 -105
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -33270,11 +33270,11 @@ var require__toKey = __commonJS((exports, module) => {
33270
33270
  var require__baseGet = __commonJS((exports, module) => {
33271
33271
  var castPath = require__castPath();
33272
33272
  var toKey = require__toKey();
33273
- function baseGet(object, path2) {
33274
- path2 = castPath(path2, object);
33275
- var index = 0, length = path2.length;
33273
+ function baseGet(object, path3) {
33274
+ path3 = castPath(path3, object);
33275
+ var index = 0, length = path3.length;
33276
33276
  while (object != null && index < length) {
33277
- object = object[toKey(path2[index++])];
33277
+ object = object[toKey(path3[index++])];
33278
33278
  }
33279
33279
  return index && index == length ? object : undefined;
33280
33280
  }
@@ -33284,8 +33284,8 @@ var require__baseGet = __commonJS((exports, module) => {
33284
33284
  // node_modules/lodash/get.js
33285
33285
  var require_get = __commonJS((exports, module) => {
33286
33286
  var baseGet = require__baseGet();
33287
- function get(object, path2, defaultValue) {
33288
- var result = object == null ? undefined : baseGet(object, path2);
33287
+ function get(object, path3, defaultValue) {
33288
+ var result = object == null ? undefined : baseGet(object, path3);
33289
33289
  return result === undefined ? defaultValue : result;
33290
33290
  }
33291
33291
  module.exports = get;
@@ -33356,14 +33356,14 @@ var require__baseSet = __commonJS((exports, module) => {
33356
33356
  var isIndex = require__isIndex();
33357
33357
  var isObject = require_isObject();
33358
33358
  var toKey = require__toKey();
33359
- function baseSet(object, path2, value, customizer) {
33359
+ function baseSet(object, path3, value, customizer) {
33360
33360
  if (!isObject(object)) {
33361
33361
  return object;
33362
33362
  }
33363
- path2 = castPath(path2, object);
33364
- var index = -1, length = path2.length, lastIndex = length - 1, nested = object;
33363
+ path3 = castPath(path3, object);
33364
+ var index = -1, length = path3.length, lastIndex = length - 1, nested = object;
33365
33365
  while (nested != null && ++index < length) {
33366
- var key = toKey(path2[index]), newValue = value;
33366
+ var key = toKey(path3[index]), newValue = value;
33367
33367
  if (key === "__proto__" || key === "constructor" || key === "prototype") {
33368
33368
  return object;
33369
33369
  }
@@ -33371,7 +33371,7 @@ var require__baseSet = __commonJS((exports, module) => {
33371
33371
  var objValue = nested[key];
33372
33372
  newValue = customizer ? customizer(objValue, key, nested) : undefined;
33373
33373
  if (newValue === undefined) {
33374
- newValue = isObject(objValue) ? objValue : isIndex(path2[index + 1]) ? [] : {};
33374
+ newValue = isObject(objValue) ? objValue : isIndex(path3[index + 1]) ? [] : {};
33375
33375
  }
33376
33376
  }
33377
33377
  assignValue(nested, key, newValue);
@@ -33385,8 +33385,8 @@ var require__baseSet = __commonJS((exports, module) => {
33385
33385
  // node_modules/lodash/set.js
33386
33386
  var require_set = __commonJS((exports, module) => {
33387
33387
  var baseSet = require__baseSet();
33388
- function set(object, path2, value) {
33389
- return object == null ? object : baseSet(object, path2, value);
33388
+ function set(object, path3, value) {
33389
+ return object == null ? object : baseSet(object, path3, value);
33390
33390
  }
33391
33391
  module.exports = set;
33392
33392
  });
@@ -44730,11 +44730,11 @@ var require__hasPath = __commonJS((exports, module) => {
44730
44730
  var isIndex = require__isIndex();
44731
44731
  var isLength = require_isLength();
44732
44732
  var toKey = require__toKey();
44733
- function hasPath(object, path2, hasFunc) {
44734
- path2 = castPath(path2, object);
44735
- var index = -1, length = path2.length, result = false;
44733
+ function hasPath(object, path3, hasFunc) {
44734
+ path3 = castPath(path3, object);
44735
+ var index = -1, length = path3.length, result = false;
44736
44736
  while (++index < length) {
44737
- var key = toKey(path2[index]);
44737
+ var key = toKey(path3[index]);
44738
44738
  if (!(result = object != null && hasFunc(object, key))) {
44739
44739
  break;
44740
44740
  }
@@ -44753,8 +44753,8 @@ var require__hasPath = __commonJS((exports, module) => {
44753
44753
  var require_hasIn = __commonJS((exports, module) => {
44754
44754
  var baseHasIn = require__baseHasIn();
44755
44755
  var hasPath = require__hasPath();
44756
- function hasIn(object, path2) {
44757
- return object != null && hasPath(object, path2, baseHasIn);
44756
+ function hasIn(object, path3) {
44757
+ return object != null && hasPath(object, path3, baseHasIn);
44758
44758
  }
44759
44759
  module.exports = hasIn;
44760
44760
  });
@@ -44770,13 +44770,13 @@ var require__baseMatchesProperty = __commonJS((exports, module) => {
44770
44770
  var toKey = require__toKey();
44771
44771
  var COMPARE_PARTIAL_FLAG = 1;
44772
44772
  var COMPARE_UNORDERED_FLAG = 2;
44773
- function baseMatchesProperty(path2, srcValue) {
44774
- if (isKey(path2) && isStrictComparable(srcValue)) {
44775
- return matchesStrictComparable(toKey(path2), srcValue);
44773
+ function baseMatchesProperty(path3, srcValue) {
44774
+ if (isKey(path3) && isStrictComparable(srcValue)) {
44775
+ return matchesStrictComparable(toKey(path3), srcValue);
44776
44776
  }
44777
44777
  return function(object) {
44778
- var objValue = get(object, path2);
44779
- return objValue === undefined && objValue === srcValue ? hasIn(object, path2) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
44778
+ var objValue = get(object, path3);
44779
+ return objValue === undefined && objValue === srcValue ? hasIn(object, path3) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
44780
44780
  };
44781
44781
  }
44782
44782
  module.exports = baseMatchesProperty;
@@ -44795,9 +44795,9 @@ var require__baseProperty = __commonJS((exports, module) => {
44795
44795
  // node_modules/lodash/_basePropertyDeep.js
44796
44796
  var require__basePropertyDeep = __commonJS((exports, module) => {
44797
44797
  var baseGet = require__baseGet();
44798
- function basePropertyDeep(path2) {
44798
+ function basePropertyDeep(path3) {
44799
44799
  return function(object) {
44800
- return baseGet(object, path2);
44800
+ return baseGet(object, path3);
44801
44801
  };
44802
44802
  }
44803
44803
  module.exports = basePropertyDeep;
@@ -44809,8 +44809,8 @@ var require_property = __commonJS((exports, module) => {
44809
44809
  var basePropertyDeep = require__basePropertyDeep();
44810
44810
  var isKey = require__isKey();
44811
44811
  var toKey = require__toKey();
44812
- function property(path2) {
44813
- return isKey(path2) ? baseProperty(toKey(path2)) : basePropertyDeep(path2);
44812
+ function property(path3) {
44813
+ return isKey(path3) ? baseProperty(toKey(path3)) : basePropertyDeep(path3);
44814
44814
  }
44815
44815
  module.exports = property;
44816
44816
  });
@@ -57264,7 +57264,7 @@ var require_iso2022 = __commonJS((exports, module) => {
57264
57264
 
57265
57265
  // node_modules/chardet/index.js
57266
57266
  var require_chardet = __commonJS((exports, module) => {
57267
- var fs3 = __require("fs");
57267
+ var fs4 = __require("fs");
57268
57268
  var utf8 = require_utf8();
57269
57269
  var unicode = require_unicode();
57270
57270
  var mbcs = require_mbcs();
@@ -57338,29 +57338,29 @@ var require_chardet = __commonJS((exports, module) => {
57338
57338
  var fd;
57339
57339
  var handler = function(err, buffer) {
57340
57340
  if (fd) {
57341
- fs3.closeSync(fd);
57341
+ fs4.closeSync(fd);
57342
57342
  }
57343
57343
  if (err)
57344
57344
  return cb(err, null);
57345
57345
  cb(null, self2.detect(buffer, opts));
57346
57346
  };
57347
57347
  if (opts && opts.sampleSize) {
57348
- fd = fs3.openSync(filepath, "r"), sample = Buffer.allocUnsafe(opts.sampleSize);
57349
- fs3.read(fd, sample, 0, opts.sampleSize, null, function(err) {
57348
+ fd = fs4.openSync(filepath, "r"), sample = Buffer.allocUnsafe(opts.sampleSize);
57349
+ fs4.read(fd, sample, 0, opts.sampleSize, null, function(err) {
57350
57350
  handler(err, sample);
57351
57351
  });
57352
57352
  return;
57353
57353
  }
57354
- fs3.readFile(filepath, handler);
57354
+ fs4.readFile(filepath, handler);
57355
57355
  };
57356
57356
  module.exports.detectFileSync = function(filepath, opts) {
57357
57357
  if (opts && opts.sampleSize) {
57358
- var fd = fs3.openSync(filepath, "r"), sample2 = Buffer.allocUnsafe(opts.sampleSize);
57359
- fs3.readSync(fd, sample2, 0, opts.sampleSize);
57360
- fs3.closeSync(fd);
57358
+ var fd = fs4.openSync(filepath, "r"), sample2 = Buffer.allocUnsafe(opts.sampleSize);
57359
+ fs4.readSync(fd, sample2, 0, opts.sampleSize);
57360
+ fs4.closeSync(fd);
57361
57361
  return self2.detect(sample2, opts);
57362
57362
  }
57363
- return self2.detect(fs3.readFileSync(filepath), opts);
57363
+ return self2.detect(fs4.readFileSync(filepath), opts);
57364
57364
  };
57365
57365
  module.exports.detectAll = function(buffer, opts) {
57366
57366
  if (typeof opts !== "object") {
@@ -60700,16 +60700,16 @@ var require_os_tmpdir = __commonJS((exports, module) => {
60700
60700
  var isWindows3 = process.platform === "win32";
60701
60701
  var trailingSlashRe = isWindows3 ? /[^:]\\$/ : /.\/$/;
60702
60702
  module.exports = function() {
60703
- var path2;
60703
+ var path3;
60704
60704
  if (isWindows3) {
60705
- path2 = process.env.TEMP || process.env.TMP || (process.env.SystemRoot || process.env.windir) + "\\temp";
60705
+ path3 = process.env.TEMP || process.env.TMP || (process.env.SystemRoot || process.env.windir) + "\\temp";
60706
60706
  } else {
60707
- path2 = process.env.TMPDIR || process.env.TMP || process.env.TEMP || "/tmp";
60707
+ path3 = process.env.TMPDIR || process.env.TMP || process.env.TEMP || "/tmp";
60708
60708
  }
60709
- if (trailingSlashRe.test(path2)) {
60710
- path2 = path2.slice(0, -1);
60709
+ if (trailingSlashRe.test(path3)) {
60710
+ path3 = path3.slice(0, -1);
60711
60711
  }
60712
- return path2;
60712
+ return path3;
60713
60713
  };
60714
60714
  });
60715
60715
 
@@ -60722,8 +60722,8 @@ var require_tmp = __commonJS((exports, module) => {
60722
60722
  *
60723
60723
  * MIT Licensed
60724
60724
  */
60725
- var fs3 = __require("fs");
60726
- var path2 = __require("path");
60725
+ var fs4 = __require("fs");
60726
+ var path3 = __require("path");
60727
60727
  var crypto = __require("crypto");
60728
60728
  var osTmpDir = require_os_tmpdir();
60729
60729
  var _c = process.binding("constants");
@@ -60765,7 +60765,7 @@ var require_tmp = __commonJS((exports, module) => {
60765
60765
  }
60766
60766
  function _generateTmpName(opts) {
60767
60767
  if (opts.name) {
60768
- return path2.join(opts.dir || tmpDir, opts.name);
60768
+ return path3.join(opts.dir || tmpDir, opts.name);
60769
60769
  }
60770
60770
  if (opts.template) {
60771
60771
  return opts.template.replace(TEMPLATE_PATTERN, _randomChars(6));
@@ -60776,7 +60776,7 @@ var require_tmp = __commonJS((exports, module) => {
60776
60776
  _randomChars(12),
60777
60777
  opts.postfix || ""
60778
60778
  ].join("");
60779
- return path2.join(opts.dir || tmpDir, name);
60779
+ return path3.join(opts.dir || tmpDir, name);
60780
60780
  }
60781
60781
  function tmpName(options, callback) {
60782
60782
  var args = _parseArguments(options, callback), opts = args[0], cb = args[1], tries = opts.name ? 1 : opts.tries || DEFAULT_TRIES;
@@ -60786,7 +60786,7 @@ var require_tmp = __commonJS((exports, module) => {
60786
60786
  return cb(new Error("Invalid template provided"));
60787
60787
  (function _getUniqueName() {
60788
60788
  const name = _generateTmpName(opts);
60789
- fs3.stat(name, function(err) {
60789
+ fs4.stat(name, function(err) {
60790
60790
  if (!err) {
60791
60791
  if (tries-- > 0)
60792
60792
  return _getUniqueName();
@@ -60805,7 +60805,7 @@ var require_tmp = __commonJS((exports, module) => {
60805
60805
  do {
60806
60806
  const name = _generateTmpName(opts);
60807
60807
  try {
60808
- fs3.statSync(name);
60808
+ fs4.statSync(name);
60809
60809
  } catch (e) {
60810
60810
  return name;
60811
60811
  }
@@ -60818,14 +60818,14 @@ var require_tmp = __commonJS((exports, module) => {
60818
60818
  tmpName(opts, function _tmpNameCreated(err, name) {
60819
60819
  if (err)
60820
60820
  return cb(err);
60821
- fs3.open(name, CREATE_FLAGS, opts.mode || FILE_MODE, function _fileCreated(err2, fd) {
60821
+ fs4.open(name, CREATE_FLAGS, opts.mode || FILE_MODE, function _fileCreated(err2, fd) {
60822
60822
  if (err2)
60823
60823
  return cb(err2);
60824
60824
  if (opts.discardDescriptor) {
60825
- return fs3.close(fd, function _discardCallback(err3) {
60825
+ return fs4.close(fd, function _discardCallback(err3) {
60826
60826
  if (err3) {
60827
60827
  try {
60828
- fs3.unlinkSync(name);
60828
+ fs4.unlinkSync(name);
60829
60829
  } catch (e) {
60830
60830
  if (!isENOENT(e)) {
60831
60831
  err3 = e;
@@ -60848,9 +60848,9 @@ var require_tmp = __commonJS((exports, module) => {
60848
60848
  opts.postfix = opts.postfix || ".tmp";
60849
60849
  const discardOrDetachDescriptor = opts.discardDescriptor || opts.detachDescriptor;
60850
60850
  const name = tmpNameSync(opts);
60851
- var fd = fs3.openSync(name, CREATE_FLAGS, opts.mode || FILE_MODE);
60851
+ var fd = fs4.openSync(name, CREATE_FLAGS, opts.mode || FILE_MODE);
60852
60852
  if (opts.discardDescriptor) {
60853
- fs3.closeSync(fd);
60853
+ fs4.closeSync(fd);
60854
60854
  fd = undefined;
60855
60855
  }
60856
60856
  return {
@@ -60862,9 +60862,9 @@ var require_tmp = __commonJS((exports, module) => {
60862
60862
  function _rmdirRecursiveSync(root) {
60863
60863
  const dirs = [root];
60864
60864
  do {
60865
- var dir2 = dirs.pop(), deferred = false, files = fs3.readdirSync(dir2);
60865
+ var dir2 = dirs.pop(), deferred = false, files = fs4.readdirSync(dir2);
60866
60866
  for (var i = 0, length = files.length;i < length; i++) {
60867
- var file2 = path2.join(dir2, files[i]), stat = fs3.lstatSync(file2);
60867
+ var file2 = path3.join(dir2, files[i]), stat = fs4.lstatSync(file2);
60868
60868
  if (stat.isDirectory()) {
60869
60869
  if (!deferred) {
60870
60870
  deferred = true;
@@ -60872,11 +60872,11 @@ var require_tmp = __commonJS((exports, module) => {
60872
60872
  }
60873
60873
  dirs.push(file2);
60874
60874
  } else {
60875
- fs3.unlinkSync(file2);
60875
+ fs4.unlinkSync(file2);
60876
60876
  }
60877
60877
  }
60878
60878
  if (!deferred) {
60879
- fs3.rmdirSync(dir2);
60879
+ fs4.rmdirSync(dir2);
60880
60880
  }
60881
60881
  } while (dirs.length !== 0);
60882
60882
  }
@@ -60885,7 +60885,7 @@ var require_tmp = __commonJS((exports, module) => {
60885
60885
  tmpName(opts, function _tmpNameCreated(err, name) {
60886
60886
  if (err)
60887
60887
  return cb(err);
60888
- fs3.mkdir(name, opts.mode || DIR_MODE, function _dirCreated(err2) {
60888
+ fs4.mkdir(name, opts.mode || DIR_MODE, function _dirCreated(err2) {
60889
60889
  if (err2)
60890
60890
  return cb(err2);
60891
60891
  cb(null, name, _prepareTmpDirRemoveCallback(name, opts));
@@ -60895,7 +60895,7 @@ var require_tmp = __commonJS((exports, module) => {
60895
60895
  function dirSync(options) {
60896
60896
  var args = _parseArguments(options), opts = args[0];
60897
60897
  const name = tmpNameSync(opts);
60898
- fs3.mkdirSync(name, opts.mode || DIR_MODE);
60898
+ fs4.mkdirSync(name, opts.mode || DIR_MODE);
60899
60899
  return {
60900
60900
  name,
60901
60901
  removeCallback: _prepareTmpDirRemoveCallback(name, opts)
@@ -60905,7 +60905,7 @@ var require_tmp = __commonJS((exports, module) => {
60905
60905
  const removeCallback = _prepareRemoveCallback(function _removeCallback(fdPath) {
60906
60906
  try {
60907
60907
  if (0 <= fdPath[0]) {
60908
- fs3.closeSync(fdPath[0]);
60908
+ fs4.closeSync(fdPath[0]);
60909
60909
  }
60910
60910
  } catch (e) {
60911
60911
  if (!isEBADF(e) && !isENOENT(e)) {
@@ -60913,7 +60913,7 @@ var require_tmp = __commonJS((exports, module) => {
60913
60913
  }
60914
60914
  }
60915
60915
  try {
60916
- fs3.unlinkSync(fdPath[1]);
60916
+ fs4.unlinkSync(fdPath[1]);
60917
60917
  } catch (e) {
60918
60918
  if (!isENOENT(e)) {
60919
60919
  throw e;
@@ -60926,7 +60926,7 @@ var require_tmp = __commonJS((exports, module) => {
60926
60926
  return removeCallback;
60927
60927
  }
60928
60928
  function _prepareTmpDirRemoveCallback(name, opts) {
60929
- const removeFunction = opts.unsafeCleanup ? _rmdirRecursiveSync : fs3.rmdirSync.bind(fs3);
60929
+ const removeFunction = opts.unsafeCleanup ? _rmdirRecursiveSync : fs4.rmdirSync.bind(fs4);
60930
60930
  const removeCallback = _prepareRemoveCallback(removeFunction, name);
60931
60931
  if (!opts.keep) {
60932
60932
  _removeObjects.unshift(removeCallback);
@@ -67922,11 +67922,11 @@ var TabItem = ({ name, label, isActive, onChange, theme }) => {
67922
67922
  return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
67923
67923
  borderStyle: "classic",
67924
67924
  borderTopColor: "grey",
67925
- borderColor: isActive ? theme.accent : isFocused ? theme.primary : "transparent",
67925
+ borderColor: isActive ? theme.colors.accent : isFocused ? theme.colors.primary : "transparent",
67926
67926
  paddingX: 1,
67927
67927
  marginRight: 1,
67928
67928
  children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
67929
- color: isActive ? theme.accent : isFocused ? theme.primary : theme.white,
67929
+ color: isActive ? theme.colors.accent : isFocused ? theme.colors.primary : theme.colors.white,
67930
67930
  bold: isActive || isFocused,
67931
67931
  children: label
67932
67932
  }, undefined, false, undefined, this)
@@ -67947,12 +67947,12 @@ var import_react25 = __toESM(require_react(), 1);
67947
67947
  // src/utils/colors.ts
67948
67948
  var getStatusColor = (status, theme) => {
67949
67949
  if (status.startsWith("2"))
67950
- return theme.success;
67950
+ return theme.colors.success;
67951
67951
  if (status.startsWith("4"))
67952
- return theme.error;
67952
+ return theme.colors.error;
67953
67953
  if (status.startsWith("5"))
67954
- return theme.error;
67955
- return theme.accent;
67954
+ return theme.colors.error;
67955
+ return theme.colors.accent;
67956
67956
  };
67957
67957
 
67958
67958
  // src/ui/app/components/historylist.tsx
@@ -67967,10 +67967,10 @@ var HistoryListItem = ({ item, isSelected, theme }) => {
67967
67967
  return url.length > 30 ? `${url.slice(0, 27)}...` : url;
67968
67968
  }
67969
67969
  };
67970
- const statusColor = item.responseStatus ? getStatusColor(item.responseStatus.toString(), theme) : theme.muted;
67970
+ const statusColor = item.responseStatus ? getStatusColor(item.responseStatus.toString(), theme) : theme.colors.muted;
67971
67971
  return /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Box_default, {
67972
67972
  paddingX: 1,
67973
- borderColor: isSelected ? theme.accent : "transparent",
67973
+ borderColor: isSelected ? theme.colors.accent : "transparent",
67974
67974
  children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Box_default, {
67975
67975
  flexDirection: "column",
67976
67976
  children: [
@@ -67988,7 +67988,7 @@ var HistoryListItem = ({ item, isSelected, theme }) => {
67988
67988
  /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Box_default, {
67989
67989
  width: 7,
67990
67990
  children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
67991
- color: isSelected ? theme.accent : theme.primary,
67991
+ color: isSelected ? theme.colors.accent : theme.colors.primary,
67992
67992
  bold: isSelected,
67993
67993
  children: item.method.padEnd(7)
67994
67994
  }, undefined, false, undefined, this)
@@ -67996,7 +67996,7 @@ var HistoryListItem = ({ item, isSelected, theme }) => {
67996
67996
  /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Box_default, {
67997
67997
  flexGrow: 1,
67998
67998
  children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
67999
- color: isSelected ? theme.white : theme.muted,
67999
+ color: isSelected ? theme.colors.white : theme.colors.muted,
68000
68000
  children: shortenUrl(item.url)
68001
68001
  }, undefined, false, undefined, this)
68002
68002
  }, undefined, false, undefined, this)
@@ -68005,7 +68005,7 @@ var HistoryListItem = ({ item, isSelected, theme }) => {
68005
68005
  /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Box_default, {
68006
68006
  paddingLeft: 13,
68007
68007
  children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
68008
- color: theme.muted,
68008
+ color: theme.colors.muted,
68009
68009
  dimColor: !isSelected,
68010
68010
  children: [
68011
68011
  item.responseTime ? `${Math.round(item.responseTime)}ms ` : "",
@@ -68093,8 +68093,46 @@ var Footer = import_react26.default.memo(({ theme }) => {
68093
68093
  // src/ui/app/components/themeselector.tsx
68094
68094
  var import_react27 = __toESM(require_react(), 1);
68095
68095
  var jsx_dev_runtime6 = __toESM(require_jsx_dev_runtime(), 1);
68096
+ var getIndex = (theme) => {
68097
+ let index = 0;
68098
+ switch (theme) {
68099
+ case "Catppuccin":
68100
+ index = 0;
68101
+ break;
68102
+ case "Dracula":
68103
+ index = 1;
68104
+ break;
68105
+ case "Nord":
68106
+ index = 2;
68107
+ break;
68108
+ case "Gruvbox":
68109
+ index = 3;
68110
+ break;
68111
+ case "Tokyo Night":
68112
+ index = 4;
68113
+ break;
68114
+ case "Ayu":
68115
+ index = 5;
68116
+ break;
68117
+ case "Monokai":
68118
+ index = 6;
68119
+ break;
68120
+ case "Solarized Dark":
68121
+ index = 7;
68122
+ break;
68123
+ case "One Dark":
68124
+ index = 8;
68125
+ break;
68126
+ case "Palenight":
68127
+ index = 9;
68128
+ break;
68129
+ default:
68130
+ index = 0;
68131
+ }
68132
+ return index;
68133
+ };
68096
68134
  var ThemeSelector = ({ onThemeChange, theme }) => {
68097
- const [selectedIndex, setSelectedIndex] = import_react27.useState(0);
68135
+ const [selectedIndex, setSelectedIndex] = import_react27.useState(getIndex(theme.name));
68098
68136
  const themeNames = Object.keys(themes);
68099
68137
  import_react27.useEffect(() => {
68100
68138
  const currentThemeIndex = themeNames.findIndex((name) => {
@@ -68125,12 +68163,14 @@ var ThemeSelector = ({ onThemeChange, theme }) => {
68125
68163
  flexDirection: "column",
68126
68164
  padding: 1,
68127
68165
  borderStyle: "classic",
68128
- borderColor: theme.accent,
68166
+ borderColor: theme.colors.accent,
68167
+ width: "50%",
68168
+ alignSelf: "center",
68129
68169
  children: [
68130
68170
  /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
68131
68171
  marginBottom: 1,
68132
68172
  children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
68133
- color: theme.primary,
68173
+ color: theme.colors.primary,
68134
68174
  bold: true,
68135
68175
  children: "Theme Menu (↑/↓ to change, Esc to close)"
68136
68176
  }, undefined, false, undefined, this)
@@ -68138,7 +68178,7 @@ var ThemeSelector = ({ onThemeChange, theme }) => {
68138
68178
  themeNames.map((name, idx) => /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
68139
68179
  paddingX: 1,
68140
68180
  children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
68141
- color: idx === selectedIndex ? theme.accent : theme.muted,
68181
+ color: idx === selectedIndex ? theme.colors.accent : theme.colors.muted,
68142
68182
  children: [
68143
68183
  idx === selectedIndex ? "▶ " : " ",
68144
68184
  themes[name].name
@@ -68224,27 +68264,27 @@ var JsonSyntaxHighlight = import_react29.default.memo(({ jsonString, theme }) =>
68224
68264
  let valueNode;
68225
68265
  if (valueString.startsWith('"')) {
68226
68266
  valueNode = /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Text, {
68227
- color: theme.success,
68267
+ color: theme.colors.success,
68228
68268
  children: valueString
68229
68269
  }, undefined, false, undefined, this);
68230
68270
  } else if (valueString === "true" || valueString === "false") {
68231
68271
  valueNode = /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Text, {
68232
- color: theme.accent,
68272
+ color: theme.colors.accent,
68233
68273
  children: valueString
68234
68274
  }, undefined, false, undefined, this);
68235
68275
  } else if (valueString === "null") {
68236
68276
  valueNode = /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Text, {
68237
- color: theme.muted,
68277
+ color: theme.colors.muted,
68238
68278
  children: valueString
68239
68279
  }, undefined, false, undefined, this);
68240
68280
  } else if (["{", "["].includes(valueString)) {
68241
68281
  valueNode = /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Text, {
68242
- color: theme.muted,
68282
+ color: theme.colors.muted,
68243
68283
  children: valueString
68244
68284
  }, undefined, false, undefined, this);
68245
68285
  } else {
68246
68286
  valueNode = /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Text, {
68247
- color: theme.secondary,
68287
+ color: theme.colors.secondary,
68248
68288
  children: valueString
68249
68289
  }, undefined, false, undefined, this);
68250
68290
  }
@@ -68254,7 +68294,7 @@ var JsonSyntaxHighlight = import_react29.default.memo(({ jsonString, theme }) =>
68254
68294
  children: indent
68255
68295
  }, undefined, false, undefined, this),
68256
68296
  /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Text, {
68257
- color: theme.primary,
68297
+ color: theme.colors.primary,
68258
68298
  children: [
68259
68299
  '"',
68260
68300
  key,
@@ -68290,7 +68330,7 @@ var JsonSyntaxHighlight = import_react29.default.memo(({ jsonString, theme }) =>
68290
68330
  children: indent
68291
68331
  }, undefined, false, undefined, this),
68292
68332
  /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Text, {
68293
- color: theme[color],
68333
+ color: theme.colors[color],
68294
68334
  children: value
68295
68335
  }, undefined, false, undefined, this),
68296
68336
  hasComma && /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Text, {
@@ -68302,7 +68342,7 @@ var JsonSyntaxHighlight = import_react29.default.memo(({ jsonString, theme }) =>
68302
68342
  }, undefined, false, undefined, this);
68303
68343
  } catch (e) {
68304
68344
  return /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Text, {
68305
- color: theme.error,
68345
+ color: theme.colors.error,
68306
68346
  children: jsonString
68307
68347
  }, undefined, false, undefined, this);
68308
68348
  }
@@ -68321,7 +68361,7 @@ var ResponsePanel = import_react30.default.memo(({ response, theme }) => /* @__P
68321
68361
  /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
68322
68362
  width: 8,
68323
68363
  children: /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
68324
- color: theme.primary,
68364
+ color: theme.colors.primary,
68325
68365
  children: "STATUS:"
68326
68366
  }, undefined, false, undefined, this)
68327
68367
  }, undefined, false, undefined, this),
@@ -68341,7 +68381,7 @@ var ResponsePanel = import_react30.default.memo(({ response, theme }) => /* @__P
68341
68381
  /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
68342
68382
  width: 8,
68343
68383
  children: /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
68344
- color: theme.primary,
68384
+ color: theme.colors.primary,
68345
68385
  children: "HEADERS:"
68346
68386
  }, undefined, false, undefined, this)
68347
68387
  }, undefined, false, undefined, this),
@@ -68350,15 +68390,15 @@ var ResponsePanel = import_react30.default.memo(({ response, theme }) => /* @__P
68350
68390
  children: Object.entries(JSON.parse(response.headers || "{}")).map(([key, value]) => /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
68351
68391
  children: [
68352
68392
  /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
68353
- color: theme.accent,
68393
+ color: theme.colors.accent,
68354
68394
  children: key
68355
68395
  }, undefined, false, undefined, this),
68356
68396
  /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
68357
- color: theme.muted,
68397
+ color: theme.colors.muted,
68358
68398
  children: ": "
68359
68399
  }, undefined, false, undefined, this),
68360
68400
  /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
68361
- color: theme.success,
68401
+ color: theme.colors.success,
68362
68402
  children: String(value)
68363
68403
  }, undefined, false, undefined, this)
68364
68404
  ]
@@ -68371,7 +68411,7 @@ var ResponsePanel = import_react30.default.memo(({ response, theme }) => /* @__P
68371
68411
  /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
68372
68412
  width: 8,
68373
68413
  children: /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
68374
- color: theme.primary,
68414
+ color: theme.colors.primary,
68375
68415
  children: "PAYLOAD:"
68376
68416
  }, undefined, false, undefined, this)
68377
68417
  }, undefined, false, undefined, this),
@@ -68389,6 +68429,108 @@ var ResponsePanel = import_react30.default.memo(({ response, theme }) => /* @__P
68389
68429
  }, undefined, true, undefined, this)
68390
68430
  }, undefined, false, undefined, this));
68391
68431
 
68432
+ // src/utils/themeManager.ts
68433
+ import { promises as fs3 } from "fs";
68434
+ import path2 from "path";
68435
+ import os3 from "os";
68436
+
68437
+ class ThemeManager {
68438
+ themeFile;
68439
+ constructor() {
68440
+ const homeDir = os3.homedir();
68441
+ const configDir = path2.join(homeDir, ".postboy");
68442
+ this.themeFile = path2.join(configDir, "theme.json");
68443
+ }
68444
+ async ensureConfigDir() {
68445
+ const configDir = path2.dirname(this.themeFile);
68446
+ try {
68447
+ await fs3.access(configDir);
68448
+ return;
68449
+ } catch (e) {
68450
+ if (e.code === "ENOENT") {
68451
+ await fs3.mkdir(configDir, { recursive: true });
68452
+ } else {
68453
+ throw e;
68454
+ }
68455
+ }
68456
+ }
68457
+ async saveTheme(theme) {
68458
+ await this.ensureConfigDir();
68459
+ await fs3.writeFile(this.themeFile, JSON.stringify(theme, null, 2));
68460
+ }
68461
+ async loadCurrTheme() {
68462
+ try {
68463
+ await this.ensureConfigDir();
68464
+ try {
68465
+ await fs3.access(this.themeFile);
68466
+ } catch (e) {
68467
+ if (e.code === "ENOENT") {
68468
+ const defaultTheme = {
68469
+ name: "Tokyo Night",
68470
+ colors: {
68471
+ background: "#1a1b26",
68472
+ primary: "#7aa2f7",
68473
+ secondary: "#bb9af7",
68474
+ accent: "#2ac3de",
68475
+ success: "#9ece6a",
68476
+ error: "#f7768e",
68477
+ muted: "#565f89",
68478
+ white: "#a9b1d6",
68479
+ cool: "#7dcfff"
68480
+ }
68481
+ };
68482
+ await this.saveTheme(defaultTheme);
68483
+ return defaultTheme;
68484
+ }
68485
+ throw e;
68486
+ }
68487
+ const theme = await fs3.readFile(this.themeFile, "utf-8");
68488
+ try {
68489
+ const parsedTheme = JSON.parse(theme);
68490
+ return parsedTheme;
68491
+ } catch (e) {
68492
+ const emptyTheme = {
68493
+ name: "",
68494
+ colors: {
68495
+ background: "1a1b26",
68496
+ primary: "#7aa2f7",
68497
+ secondary: "#bb9af7",
68498
+ accent: "#2ac3de",
68499
+ success: "#9ece6a",
68500
+ error: "#f7768e",
68501
+ muted: "#565f89",
68502
+ white: "#a9b1d6",
68503
+ cool: "#7dcfff"
68504
+ }
68505
+ };
68506
+ await this.saveTheme(emptyTheme);
68507
+ return emptyTheme;
68508
+ }
68509
+ } catch (e) {
68510
+ console.error("Failed to load history:", e);
68511
+ return {
68512
+ name: "",
68513
+ colors: {
68514
+ background: "1a1b26",
68515
+ primary: "#7aa2f7",
68516
+ secondary: "#bb9af7",
68517
+ accent: "#2ac3de",
68518
+ success: "#9ece6a",
68519
+ error: "#f7768e",
68520
+ muted: "#565f89",
68521
+ white: "#a9b1d6",
68522
+ cool: "#7dcfff"
68523
+ }
68524
+ };
68525
+ }
68526
+ }
68527
+ async ChangeTheme(theme) {
68528
+ await this.ensureConfigDir();
68529
+ await this.saveTheme(theme);
68530
+ }
68531
+ }
68532
+ var themeManager = new ThemeManager;
68533
+
68392
68534
  // src/ui/app/ui.tsx
68393
68535
  var jsx_dev_runtime10 = __toESM(require_jsx_dev_runtime(), 1);
68394
68536
  var SendButton = ({ onPress, loading, theme }) => {
@@ -68458,7 +68600,7 @@ var RequestPanel = import_react31.default.memo(({ request, onMethodChange, onUrl
68458
68600
  ]
68459
68601
  }, undefined, true, undefined, this));
68460
68602
  var UI = () => {
68461
- const [theme, setTheme] = import_react31.useState(themes.catppuccin.colors);
68603
+ const [theme, setTheme] = import_react31.useState(themes.catppuccin);
68462
68604
  const { exit } = use_app_default();
68463
68605
  const [activeTab, setActiveTab] = import_react31.useState("request");
68464
68606
  const [request, setRequest] = import_react31.useState({ method: "GET", url: "", headers: "", body: "" });
@@ -68471,6 +68613,13 @@ var UI = () => {
68471
68613
  const loadHistory = async () => setHistory((await historyManager.loadHistory()).entries);
68472
68614
  loadHistory();
68473
68615
  }, []);
68616
+ import_react31.useEffect(() => {
68617
+ const loadTheme = async () => {
68618
+ const loadedTheme = await themeManager.loadCurrTheme();
68619
+ setTheme(loadedTheme);
68620
+ };
68621
+ loadTheme();
68622
+ }, []);
68474
68623
  const handleSend = import_react31.useCallback(async () => {
68475
68624
  setLoading(true);
68476
68625
  const startTime = Date.now();
@@ -68508,6 +68657,10 @@ var UI = () => {
68508
68657
  setLoading(false);
68509
68658
  }
68510
68659
  }, []);
68660
+ const handleThemeChange = (theme2) => {
68661
+ themeManager.ChangeTheme(theme2);
68662
+ setTheme(theme2);
68663
+ };
68511
68664
  const handleHistoryClick = import_react31.useCallback((item) => {
68512
68665
  setRequest({
68513
68666
  method: item.method,
@@ -68550,14 +68703,16 @@ var UI = () => {
68550
68703
  marginBottom: 1,
68551
68704
  children: /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemeSelector, {
68552
68705
  theme,
68553
- onThemeChange: (themeName) => setTheme(themes[themeName].colors)
68706
+ onThemeChange: (themeName) => {
68707
+ handleThemeChange(themes[themeName]);
68708
+ }
68554
68709
  }, undefined, false, undefined, this)
68555
68710
  }, undefined, false, undefined, this),
68556
68711
  /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Box_default, {
68557
68712
  alignSelf: "center",
68558
68713
  marginBottom: 1,
68559
68714
  children: /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
68560
- color: theme.accent,
68715
+ color: theme.colors.accent,
68561
68716
  bold: true,
68562
68717
  children: `┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓`
68563
68718
  }, undefined, false, undefined, this)
@@ -68566,7 +68721,7 @@ var UI = () => {
68566
68721
  alignSelf: "center",
68567
68722
  marginBottom: 1,
68568
68723
  children: /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
68569
- color: theme.primary,
68724
+ color: theme.colors.primary,
68570
68725
  bold: true,
68571
68726
  children: `┃ \uD83D\uDEF0️ Welcome to PostBoy — The Modern Terminal API Client ┃`
68572
68727
  }, undefined, false, undefined, this)
@@ -68575,7 +68730,7 @@ var UI = () => {
68575
68730
  alignSelf: "center",
68576
68731
  marginBottom: 1,
68577
68732
  children: /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
68578
- color: theme.accent,
68733
+ color: theme.colors.accent,
68579
68734
  bold: true,
68580
68735
  children: `┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛`
68581
68736
  }, undefined, false, undefined, this)
@@ -68586,18 +68741,18 @@ var UI = () => {
68586
68741
  /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Box_default, {
68587
68742
  width: "40%",
68588
68743
  borderStyle: "classic",
68589
- borderColor: theme.muted,
68744
+ borderColor: theme.colors.muted,
68590
68745
  flexDirection: "column",
68591
68746
  marginRight: 1,
68592
68747
  children: [
68593
68748
  /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Box_default, {
68594
68749
  borderStyle: "classic",
68595
68750
  borderTopColor: "grey",
68596
- borderColor: theme.secondary,
68751
+ borderColor: theme.colors.secondary,
68597
68752
  paddingX: 1,
68598
68753
  alignSelf: "center",
68599
68754
  children: /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
68600
- color: theme.accent,
68755
+ color: theme.colors.accent,
68601
68756
  bold: true,
68602
68757
  children: "\uD83D\uDCDC History"
68603
68758
  }, undefined, false, undefined, this)
@@ -68608,7 +68763,7 @@ var UI = () => {
68608
68763
  children: history.length === 0 ? /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Box_default, {
68609
68764
  padding: 1,
68610
68765
  children: /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
68611
- color: theme.muted,
68766
+ color: theme.colors.muted,
68612
68767
  children: "No requests yet..."
68613
68768
  }, undefined, false, undefined, this)
68614
68769
  }, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(HistoryList, {
@@ -68622,7 +68777,7 @@ var UI = () => {
68622
68777
  /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Box_default, {
68623
68778
  width: "60%",
68624
68779
  borderStyle: "classic",
68625
- borderColor: theme.muted,
68780
+ borderColor: theme.colors.muted,
68626
68781
  padding: 1,
68627
68782
  flexDirection: "column",
68628
68783
  children: [
@@ -68648,7 +68803,7 @@ var UI = () => {
68648
68803
  onBodyChange,
68649
68804
  onSend: handleSend,
68650
68805
  loading,
68651
- theme,
68806
+ theme: theme.colors,
68652
68807
  historyUrls
68653
68808
  }, undefined, false, undefined, this)
68654
68809
  }, undefined, false, undefined, this),
@@ -68667,7 +68822,7 @@ var UI = () => {
68667
68822
  ]
68668
68823
  }, undefined, true, undefined, this),
68669
68824
  /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Footer, {
68670
- theme
68825
+ theme: theme.colors
68671
68826
  }, undefined, false, undefined, this)
68672
68827
  ]
68673
68828
  }, undefined, true, undefined, this);
@@ -68870,7 +69025,7 @@ async function mockApis() {
68870
69025
 
68871
69026
  // src/index.ts
68872
69027
  var program2 = new Command;
68873
- program2.version("1.3.0").description(import_chalk8.default.yellow("PostBoy CLI - Test your APIs with ease"));
69028
+ program2.version("1.3.1").description(import_chalk8.default.yellow("PostBoy CLI - Test your APIs with ease"));
68874
69029
  program2.command("run").description("Run a test API request").action(testCommand);
68875
69030
  program2.command("mock-list").description("List the mock API servers").action(mockApis);
68876
69031
  program2.command("ui").description("UI for PostBoy").action(uiCommand);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postboy-tui",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "main": "dist/cli.js",
5
5
  "bin": {
6
6
  "postboy-tui": "dist/cli.js"