@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/esm/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { useCallback, useEffect, useRef, useState } from 'react';
2
+ import path from 'path';
2
3
  import { jsx, jsxs } from 'react/jsx-runtime';
3
4
 
4
5
  function getSafeDocument() {
@@ -408,6 +409,7 @@ function getResult(obj) {
408
409
  }
409
410
  return current;
410
411
  }
412
+ const get_result = getResult;
411
413
  // Determines HTTP method, defaults to GET or POST based on body
412
414
  function getMethod(method = null, body = null) {
413
415
  const validMethods = ['GET', 'POST', 'PUT', 'PATCH', 'PULL'];
@@ -557,6 +559,89 @@ function fetchIndexHtmlContainer(filename_1) {
557
559
  });
558
560
  }
559
561
 
562
+ function urlJoin(...parts) {
563
+ var _a;
564
+ const s = (parts.length === 1 && Array.isArray(parts[0]) ? parts[0] : parts);
565
+ let r = "";
566
+ for (let i = 0; i < s.length; i++) {
567
+ let d = ((_a = s[i]) !== null && _a !== void 0 ? _a : "").toString();
568
+ if (!d)
569
+ continue;
570
+ if (i === 0)
571
+ r = d;
572
+ else {
573
+ d = d.replace(/^\/+/, "");
574
+ r = r.replace(/\/+$/, "");
575
+ r = `${r}/${d}`;
576
+ }
577
+ }
578
+ return r;
579
+ }
580
+ /**
581
+ * Returns a full URL.
582
+ * If partial_url is already absolute (starts with http), it is returned as is.
583
+ * Otherwise, it is combined with the base URL.
584
+ */
585
+ function get_full_url(partial_url, domain = null) {
586
+ if (typeof partial_url !== 'string') {
587
+ throw new Error('partial_url must be a string');
588
+ }
589
+ // If it already starts with http, assume it is absolute.
590
+ if (partial_url.startsWith('http')) {
591
+ return partial_url;
592
+ }
593
+ return urlJoin(domain, partial_url);
594
+ }
595
+ /**
596
+ * Returns a full file system path.
597
+ * If partial_path is already absolute, it is returned as is.
598
+ * Otherwise, it is joined with the base directory.
599
+ */
600
+ function get_full_path(partial_path, parent_dir = null) {
601
+ if (typeof partial_path !== 'string') {
602
+ throw new Error('partial_path must be a string');
603
+ }
604
+ if (path.isAbsolute(partial_path)) {
605
+ return partial_path;
606
+ }
607
+ return urlJoin(parent_dir, partial_path);
608
+ }
609
+ /**
610
+ * Converts a local file system path into its corresponding URL.
611
+ * It checks against the known directories in all_paths and replaces the matching base.
612
+ */
613
+ function path_to_url(filePath, all_paths) {
614
+ if (typeof filePath !== 'string') {
615
+ throw new Error('filePath must be a string');
616
+ }
617
+ for (const key in all_paths) {
618
+ const mapping = all_paths[key];
619
+ const normalizedBase = path.normalize(mapping.path);
620
+ if (filePath.startsWith(normalizedBase)) {
621
+ const relativePath = filePath.substring(normalizedBase.length);
622
+ return urlJoin(mapping.url, relativePath.replace(/\\/g, '/'));
623
+ }
624
+ }
625
+ return null;
626
+ }
627
+ /**
628
+ * Converts a URL into its corresponding local file system path.
629
+ * It checks against the known URL prefixes in all_paths and replaces the matching base.
630
+ */
631
+ function url_to_path(urlStr, all_paths) {
632
+ if (typeof urlStr !== 'string') {
633
+ throw new Error('urlStr must be a string');
634
+ }
635
+ for (const key in all_paths) {
636
+ const mapping = all_paths[key];
637
+ if (urlStr.startsWith(mapping.url)) {
638
+ const relativeUrl = urlStr.substring(mapping.url.length);
639
+ return urlJoin(mapping.path, relativeUrl);
640
+ }
641
+ }
642
+ return null;
643
+ }
644
+
560
645
  function assertPath(path) {
561
646
  if (typeof path !== 'string') {
562
647
  throw new TypeError('Path must be a string. Received ' + JSON.stringify(path));
@@ -1435,6 +1520,13 @@ function sanitizeFilename(filename) {
1435
1520
  .replace(/-+/g, '-') // Collapse multiple hyphens into one
1436
1521
  .replace(/^-|-$/, ''); // Remove leading/trailing hyphens
1437
1522
  }
1523
+ function get_relative_path(directory, fullPath) {
1524
+ return pathBrowserify.relative(directory, fullPath);
1525
+ }
1526
+ // Safer resolver that strips .. at the front only, but prefer server-side checks.
1527
+ function get_safe_path(p) {
1528
+ return pathBrowserify.normalize(p).replace(/^(\.\.[/\\])+/, '');
1529
+ }
1438
1530
  function make_sanitized_path(...paths) {
1439
1531
  let real_path = '';
1440
1532
  for (let i = 0; i < paths.length; i++) {
@@ -1667,5 +1759,5 @@ function roundPercentage(x) {
1667
1759
  return safeDivide(Math.round(pct), 100);
1668
1760
  }
1669
1761
 
1670
- export { API_PREFIX, BASE_URL, Button, Checkbox, DEV_PREFIX, DOMAIN_NAME, Input, PROD_PREFIX, PROTOCOL, SUB_DIR, Spinner, alertIt, alertit, assureArray, assureList, assureNumber, assureString, assure_array, assure_list, assure_number, assure_string, callStorage, callWindowMethod, capitalize, capitalize_str, checkResponse, cleanArray, cleanText, create_list_string, currentUsername, currentUsernames, decodeJwt, eatAll, eatEnd, eatInner, eatOuter, ensureArray, ensureList, ensureNumber, ensureString, ensure_array, ensure_list, ensure_number, ensure_string, fetchIndexHtml, fetchIndexHtmlContainer, fetchIt, formatNumber, geAuthsUtilsDirectory, geBackupsUtilsDirectory, geConstantsUtilsDirectory, geEnvUtilsDirectory, geFetchUtilsDirectory, geFileUtilsDirectory, gePathUtilsDirectory, geStaticDirectory, geStringUtilsDirectory, geTypeUtilsDirectory, get, getAbsDir, getAbsPath, getAlphaNum, getAlphas, getAuthorizationHeader, getBaseDir, getBody, getChar, getCleanArray, getComponentsUtilsDirectory, getConfigContent, getConfigJson, getConfigVar, getDbConfigsPath, getDistDir, getDocumentProp, getEnvDir, getEnvPath, getFetchVars, getFunctionsDir, getFunctionsUtilsDirectory, getHeaders, getHooksUtilsDirectory, getHtmlDirectory, getLibUtilsDirectory, getMethod, getNums, getPublicDir, getResult, getSafeDocument, getSafeLocalStorage, getSafeWindow, getSchemasDirPath, getSchemasPath, getSrcDir, getSubstring, getToken, getWindowHost, getWindowProp, get_basename, get_dirname, get_extname, get_filename, get_key_value, get_keyword_string, get_splitext, get_window, get_window_location, get_window_parts, get_window_pathname, isLoggedIn, isNum, isStrInString, isTokenExpired, isType, make_path, make_sanitized_path, normalizeUrl, parseResult, processKeywords, readJsonFile, removeToken, requireToken, roundPercentage, safeDivide, safeGlobalProp, safeMultiply, safeNums, safeStorage, sanitizeFilename, stripPrefixes, truncateString, tryParse };
1762
+ export { API_PREFIX, BASE_URL, Button, Checkbox, DEV_PREFIX, DOMAIN_NAME, Input, PROD_PREFIX, PROTOCOL, SUB_DIR, Spinner, alertIt, alertit, assureArray, assureList, assureNumber, assureString, assure_array, assure_list, assure_number, assure_string, callStorage, callWindowMethod, capitalize, capitalize_str, checkResponse, cleanArray, cleanText, create_list_string, currentUsername, currentUsernames, decodeJwt, eatAll, eatEnd, eatInner, eatOuter, ensureArray, ensureList, ensureNumber, ensureString, ensure_array, ensure_list, ensure_number, ensure_string, fetchIndexHtml, fetchIndexHtmlContainer, fetchIt, formatNumber, geAuthsUtilsDirectory, geBackupsUtilsDirectory, geConstantsUtilsDirectory, geEnvUtilsDirectory, geFetchUtilsDirectory, geFileUtilsDirectory, gePathUtilsDirectory, geStaticDirectory, geStringUtilsDirectory, geTypeUtilsDirectory, get, getAbsDir, getAbsPath, getAlphaNum, getAlphas, getAuthorizationHeader, getBaseDir, getBody, getChar, getCleanArray, getComponentsUtilsDirectory, getConfigContent, getConfigJson, getConfigVar, getDbConfigsPath, getDistDir, getDocumentProp, getEnvDir, getEnvPath, getFetchVars, getFunctionsDir, getFunctionsUtilsDirectory, getHeaders, getHooksUtilsDirectory, getHtmlDirectory, getLibUtilsDirectory, getMethod, getNums, getPublicDir, getResult, getSafeDocument, getSafeLocalStorage, getSafeWindow, getSchemasDirPath, getSchemasPath, getSrcDir, getSubstring, getToken, getWindowHost, getWindowProp, get_basename, get_dirname, get_extname, get_filename, get_full_path, get_full_url, get_key_value, get_keyword_string, get_relative_path, get_result, get_safe_path, get_splitext, get_window, get_window_location, get_window_parts, get_window_pathname, isLoggedIn, isNum, isStrInString, isTokenExpired, isType, make_path, make_sanitized_path, normalizeUrl, parseResult, path_to_url, processKeywords, readJsonFile, removeToken, requireToken, roundPercentage, safeDivide, safeGlobalProp, safeMultiply, safeNums, safeStorage, sanitizeFilename, stripPrefixes, truncateString, tryParse, urlJoin, url_to_path };
1671
1763
  //# sourceMappingURL=index.js.map