@putkoff/abstract-utilities 0.1.234 → 0.1.236

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 (92) hide show
  1. package/dist/cjs/index.js +100 -0
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/esm/index.js +93 -1
  4. package/dist/esm/index.js.map +1 -1
  5. package/dist/index.d.ts +28 -1
  6. package/dist/types/functions/auth_utils/imports.d.ts +0 -0
  7. package/dist/types/functions/auth_utils/index.d.ts +0 -0
  8. package/dist/types/functions/auth_utils/src/index.d.ts +0 -0
  9. package/dist/types/functions/auth_utils/src/token_utils.d.ts +0 -0
  10. package/dist/types/functions/config_utils/imports.d.ts +0 -0
  11. package/dist/types/functions/config_utils/index.d.ts +0 -0
  12. package/dist/types/functions/config_utils/src/config_utils.d.ts +0 -0
  13. package/dist/types/functions/config_utils/src/index.d.ts +0 -0
  14. package/dist/types/functions/constants_utils/index.d.ts +0 -0
  15. package/dist/types/functions/constants_utils/src/constants.d.ts +0 -0
  16. package/dist/types/functions/constants_utils/src/index.d.ts +0 -0
  17. package/dist/types/functions/env_utils/imports.d.ts +0 -0
  18. package/dist/types/functions/env_utils/index.d.ts +0 -0
  19. package/dist/types/functions/env_utils/src/index.d.ts +0 -0
  20. package/dist/types/functions/env_utils/src/window_utils.d.ts +0 -0
  21. package/dist/types/functions/fetch_utils/imports.d.ts +0 -0
  22. package/dist/types/functions/fetch_utils/index.d.ts +0 -0
  23. package/dist/types/functions/fetch_utils/src/fetch_utils.d.ts +0 -0
  24. package/dist/types/functions/fetch_utils/src/index.d.ts +1 -0
  25. package/dist/types/functions/fetch_utils/src/url_utils.d.ts +23 -0
  26. package/dist/types/functions/fetch_utils/src/utils.d.ts +1 -0
  27. package/dist/types/functions/index.d.ts +0 -0
  28. package/dist/types/functions/math_utils/index.d.ts +0 -0
  29. package/dist/types/functions/math_utils/safe_math.d.ts +0 -0
  30. package/dist/types/functions/path_utils/imports.d.ts +0 -0
  31. package/dist/types/functions/path_utils/index.d.ts +0 -0
  32. package/dist/types/functions/path_utils/src/base_dirs.d.ts +0 -0
  33. package/dist/types/functions/path_utils/src/function_dirs.d.ts +0 -0
  34. package/dist/types/functions/path_utils/src/index.d.ts +0 -0
  35. package/dist/types/functions/path_utils/src/misc_dirs.d.ts +0 -0
  36. package/dist/types/functions/path_utils/src/path_utils.browser.d.ts +0 -0
  37. package/dist/types/functions/path_utils/src/path_utils.d.ts +2 -0
  38. package/dist/types/functions/path_utils/src/path_utils.node.d.ts +0 -0
  39. package/dist/types/functions/path_utils/src/paths.d.ts +0 -0
  40. package/dist/types/functions/path_utils/src/src_dirs.d.ts +0 -0
  41. package/dist/types/functions/read_utils/imports.d.ts +0 -0
  42. package/dist/types/functions/read_utils/index.d.ts +0 -0
  43. package/dist/types/functions/read_utils/src/index.d.ts +0 -0
  44. package/dist/types/functions/read_utils/src/read_utils.browser.d.ts +0 -0
  45. package/dist/types/functions/read_utils/src/utils.browser.d.ts +0 -0
  46. package/dist/types/functions/read_utils/src/utils.d.ts +0 -0
  47. package/dist/types/functions/rndm_utils/imports.d.ts +0 -0
  48. package/dist/types/functions/rndm_utils/index.d.ts +0 -0
  49. package/dist/types/functions/rndm_utils/src/index.d.ts +0 -0
  50. package/dist/types/functions/rndm_utils/src/utils.d.ts +0 -0
  51. package/dist/types/functions/safe_utils/imports.d.ts +0 -0
  52. package/dist/types/functions/safe_utils/index.d.ts +0 -0
  53. package/dist/types/functions/safe_utils/src/index.d.ts +0 -0
  54. package/dist/types/functions/safe_utils/src/safe_document.d.ts +0 -0
  55. package/dist/types/functions/safe_utils/src/safe_globals.d.ts +0 -0
  56. package/dist/types/functions/safe_utils/src/safe_storage.d.ts +0 -0
  57. package/dist/types/functions/safe_utils/src/safe_window.d.ts +0 -0
  58. package/dist/types/functions/string_utils/index.d.ts +0 -0
  59. package/dist/types/functions/string_utils/src/index.d.ts +0 -0
  60. package/dist/types/functions/string_utils/src/string_utils.d.ts +0 -0
  61. package/dist/types/functions/type_utils/imports.d.ts +0 -0
  62. package/dist/types/functions/type_utils/index.d.ts +0 -0
  63. package/dist/types/functions/type_utils/src/clean_utils.d.ts +0 -0
  64. package/dist/types/functions/type_utils/src/ensure_utils.d.ts +0 -0
  65. package/dist/types/functions/type_utils/src/index.d.ts +0 -0
  66. package/dist/types/functions/type_utils/src/json_utils.d.ts +0 -0
  67. package/dist/types/functions/type_utils/src/type_utils.d.ts +0 -0
  68. package/dist/types/functions/ui_utils/imports.d.ts +0 -0
  69. package/dist/types/functions/ui_utils/index.d.ts +0 -0
  70. package/dist/types/functions/ui_utils/src/button.d.ts +0 -0
  71. package/dist/types/functions/ui_utils/src/checkbox.d.ts +0 -0
  72. package/dist/types/functions/ui_utils/src/index.d.ts +0 -0
  73. package/dist/types/functions/ui_utils/src/input.d.ts +0 -0
  74. package/dist/types/functions/ui_utils/src/spinner.d.ts +0 -0
  75. package/dist/types/functions/variable_utils/imports.d.ts +0 -0
  76. package/dist/types/functions/variable_utils/index.d.ts +0 -0
  77. package/dist/types/functions/variable_utils/src/index.d.ts +0 -0
  78. package/dist/types/functions/variable_utils/src/variable_utils.d.ts +0 -0
  79. package/dist/types/index.d.ts +0 -0
  80. package/dist/types/types/index.d.ts +0 -0
  81. package/dist/types/types/src/ChangePassword.d.ts +0 -0
  82. package/dist/types/types/src/Files.d.ts +0 -0
  83. package/dist/types/types/src/index.d.ts +0 -0
  84. package/dist/types/types/src/login.d.ts +0 -0
  85. package/dist/types/types/src/logout.d.ts +0 -0
  86. package/dist/types/types/src/utils.d.ts +0 -0
  87. package/dist/types/utils/imports.d.ts +0 -0
  88. package/dist/types/utils/index.d.ts +0 -0
  89. package/dist/types/utils/src/Input.d.ts +0 -0
  90. package/dist/types/utils/src/config.d.ts +0 -0
  91. package/dist/types/utils/src/index.d.ts +0 -0
  92. package/package.json +1 -1
package/dist/cjs/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var react = require('react');
4
+ var path = require('path');
4
5
  var jsxRuntime = require('react/jsx-runtime');
5
6
 
6
7
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
@@ -411,6 +412,7 @@ function getResult(obj) {
411
412
  }
412
413
  return current;
413
414
  }
415
+ const get_result = getResult;
414
416
  // Determines HTTP method, defaults to GET or POST based on body
415
417
  function getMethod(method = null, body = null) {
416
418
  const validMethods = ['GET', 'POST', 'PUT', 'PATCH', 'PULL'];
@@ -560,6 +562,89 @@ function fetchIndexHtmlContainer(filename_1) {
560
562
  });
561
563
  }
562
564
 
565
+ function urlJoin(...parts) {
566
+ var _a;
567
+ const s = (parts.length === 1 && Array.isArray(parts[0]) ? parts[0] : parts);
568
+ let r = "";
569
+ for (let i = 0; i < s.length; i++) {
570
+ let d = ((_a = s[i]) !== null && _a !== void 0 ? _a : "").toString();
571
+ if (!d)
572
+ continue;
573
+ if (i === 0)
574
+ r = d;
575
+ else {
576
+ d = d.replace(/^\/+/, "");
577
+ r = r.replace(/\/+$/, "");
578
+ r = `${r}/${d}`;
579
+ }
580
+ }
581
+ return r;
582
+ }
583
+ /**
584
+ * Returns a full URL.
585
+ * If partial_url is already absolute (starts with http), it is returned as is.
586
+ * Otherwise, it is combined with the base URL.
587
+ */
588
+ function get_full_url(partial_url, domain = null) {
589
+ if (typeof partial_url !== 'string') {
590
+ throw new Error('partial_url must be a string');
591
+ }
592
+ // If it already starts with http, assume it is absolute.
593
+ if (partial_url.startsWith('http')) {
594
+ return partial_url;
595
+ }
596
+ return urlJoin(domain, partial_url);
597
+ }
598
+ /**
599
+ * Returns a full file system path.
600
+ * If partial_path is already absolute, it is returned as is.
601
+ * Otherwise, it is joined with the base directory.
602
+ */
603
+ function get_full_path(partial_path, parent_dir = null) {
604
+ if (typeof partial_path !== 'string') {
605
+ throw new Error('partial_path must be a string');
606
+ }
607
+ if (path.isAbsolute(partial_path)) {
608
+ return partial_path;
609
+ }
610
+ return urlJoin(parent_dir, partial_path);
611
+ }
612
+ /**
613
+ * Converts a local file system path into its corresponding URL.
614
+ * It checks against the known directories in all_paths and replaces the matching base.
615
+ */
616
+ function path_to_url(filePath, all_paths) {
617
+ if (typeof filePath !== 'string') {
618
+ throw new Error('filePath must be a string');
619
+ }
620
+ for (const key in all_paths) {
621
+ const mapping = all_paths[key];
622
+ const normalizedBase = path.normalize(mapping.path);
623
+ if (filePath.startsWith(normalizedBase)) {
624
+ const relativePath = filePath.substring(normalizedBase.length);
625
+ return urlJoin(mapping.url, relativePath.replace(/\\/g, '/'));
626
+ }
627
+ }
628
+ return null;
629
+ }
630
+ /**
631
+ * Converts a URL into its corresponding local file system path.
632
+ * It checks against the known URL prefixes in all_paths and replaces the matching base.
633
+ */
634
+ function url_to_path(urlStr, all_paths) {
635
+ if (typeof urlStr !== 'string') {
636
+ throw new Error('urlStr must be a string');
637
+ }
638
+ for (const key in all_paths) {
639
+ const mapping = all_paths[key];
640
+ if (urlStr.startsWith(mapping.url)) {
641
+ const relativeUrl = urlStr.substring(mapping.url.length);
642
+ return urlJoin(mapping.path, relativeUrl);
643
+ }
644
+ }
645
+ return null;
646
+ }
647
+
563
648
  function assertPath(path) {
564
649
  if (typeof path !== 'string') {
565
650
  throw new TypeError('Path must be a string. Received ' + JSON.stringify(path));
@@ -1438,6 +1523,13 @@ function sanitizeFilename(filename) {
1438
1523
  .replace(/-+/g, '-') // Collapse multiple hyphens into one
1439
1524
  .replace(/^-|-$/, ''); // Remove leading/trailing hyphens
1440
1525
  }
1526
+ function get_relative_path(directory, fullPath) {
1527
+ return pathBrowserify.relative(directory, fullPath);
1528
+ }
1529
+ // Safer resolver that strips .. at the front only, but prefer server-side checks.
1530
+ function get_safe_path(p) {
1531
+ return pathBrowserify.normalize(p).replace(/^(\.\.[/\\])+/, '');
1532
+ }
1441
1533
  function make_sanitized_path(...paths) {
1442
1534
  let real_path = '';
1443
1535
  for (let i = 0; i < paths.length; i++) {
@@ -1788,8 +1880,13 @@ exports.get_basename = get_basename;
1788
1880
  exports.get_dirname = get_dirname;
1789
1881
  exports.get_extname = get_extname;
1790
1882
  exports.get_filename = get_filename;
1883
+ exports.get_full_path = get_full_path;
1884
+ exports.get_full_url = get_full_url;
1791
1885
  exports.get_key_value = get_key_value;
1792
1886
  exports.get_keyword_string = get_keyword_string;
1887
+ exports.get_relative_path = get_relative_path;
1888
+ exports.get_result = get_result;
1889
+ exports.get_safe_path = get_safe_path;
1793
1890
  exports.get_splitext = get_splitext;
1794
1891
  exports.get_window = get_window;
1795
1892
  exports.get_window_location = get_window_location;
@@ -1804,6 +1901,7 @@ exports.make_path = make_path;
1804
1901
  exports.make_sanitized_path = make_sanitized_path;
1805
1902
  exports.normalizeUrl = normalizeUrl;
1806
1903
  exports.parseResult = parseResult;
1904
+ exports.path_to_url = path_to_url;
1807
1905
  exports.processKeywords = processKeywords;
1808
1906
  exports.readJsonFile = readJsonFile;
1809
1907
  exports.removeToken = removeToken;
@@ -1818,4 +1916,6 @@ exports.sanitizeFilename = sanitizeFilename;
1818
1916
  exports.stripPrefixes = stripPrefixes;
1819
1917
  exports.truncateString = truncateString;
1820
1918
  exports.tryParse = tryParse;
1919
+ exports.urlJoin = urlJoin;
1920
+ exports.url_to_path = url_to_path;
1821
1921
  //# sourceMappingURL=index.js.map