@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.
- package/dist/cjs/index.js +100 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +93 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +28 -1
- package/dist/types/functions/auth_utils/imports.d.ts +0 -0
- package/dist/types/functions/auth_utils/index.d.ts +0 -0
- package/dist/types/functions/auth_utils/src/index.d.ts +0 -0
- package/dist/types/functions/auth_utils/src/token_utils.d.ts +0 -0
- package/dist/types/functions/config_utils/imports.d.ts +0 -0
- package/dist/types/functions/config_utils/index.d.ts +0 -0
- package/dist/types/functions/config_utils/src/config_utils.d.ts +0 -0
- package/dist/types/functions/config_utils/src/index.d.ts +0 -0
- package/dist/types/functions/constants_utils/index.d.ts +0 -0
- package/dist/types/functions/constants_utils/src/constants.d.ts +0 -0
- package/dist/types/functions/constants_utils/src/index.d.ts +0 -0
- package/dist/types/functions/env_utils/imports.d.ts +0 -0
- package/dist/types/functions/env_utils/index.d.ts +0 -0
- package/dist/types/functions/env_utils/src/index.d.ts +0 -0
- package/dist/types/functions/env_utils/src/window_utils.d.ts +0 -0
- package/dist/types/functions/fetch_utils/imports.d.ts +0 -0
- package/dist/types/functions/fetch_utils/index.d.ts +0 -0
- package/dist/types/functions/fetch_utils/src/fetch_utils.d.ts +0 -0
- package/dist/types/functions/fetch_utils/src/index.d.ts +1 -0
- package/dist/types/functions/fetch_utils/src/url_utils.d.ts +23 -0
- package/dist/types/functions/fetch_utils/src/utils.d.ts +1 -0
- package/dist/types/functions/index.d.ts +0 -0
- package/dist/types/functions/math_utils/index.d.ts +0 -0
- package/dist/types/functions/math_utils/safe_math.d.ts +0 -0
- package/dist/types/functions/path_utils/imports.d.ts +0 -0
- package/dist/types/functions/path_utils/index.d.ts +0 -0
- package/dist/types/functions/path_utils/src/base_dirs.d.ts +0 -0
- package/dist/types/functions/path_utils/src/function_dirs.d.ts +0 -0
- package/dist/types/functions/path_utils/src/index.d.ts +0 -0
- package/dist/types/functions/path_utils/src/misc_dirs.d.ts +0 -0
- package/dist/types/functions/path_utils/src/path_utils.browser.d.ts +0 -0
- package/dist/types/functions/path_utils/src/path_utils.d.ts +2 -0
- package/dist/types/functions/path_utils/src/path_utils.node.d.ts +0 -0
- package/dist/types/functions/path_utils/src/paths.d.ts +0 -0
- package/dist/types/functions/path_utils/src/src_dirs.d.ts +0 -0
- package/dist/types/functions/read_utils/imports.d.ts +0 -0
- package/dist/types/functions/read_utils/index.d.ts +0 -0
- package/dist/types/functions/read_utils/src/index.d.ts +0 -0
- package/dist/types/functions/read_utils/src/read_utils.browser.d.ts +0 -0
- package/dist/types/functions/read_utils/src/utils.browser.d.ts +0 -0
- package/dist/types/functions/read_utils/src/utils.d.ts +0 -0
- package/dist/types/functions/rndm_utils/imports.d.ts +0 -0
- package/dist/types/functions/rndm_utils/index.d.ts +0 -0
- package/dist/types/functions/rndm_utils/src/index.d.ts +0 -0
- package/dist/types/functions/rndm_utils/src/utils.d.ts +0 -0
- package/dist/types/functions/safe_utils/imports.d.ts +0 -0
- package/dist/types/functions/safe_utils/index.d.ts +0 -0
- package/dist/types/functions/safe_utils/src/index.d.ts +0 -0
- package/dist/types/functions/safe_utils/src/safe_document.d.ts +0 -0
- package/dist/types/functions/safe_utils/src/safe_globals.d.ts +0 -0
- package/dist/types/functions/safe_utils/src/safe_storage.d.ts +0 -0
- package/dist/types/functions/safe_utils/src/safe_window.d.ts +0 -0
- package/dist/types/functions/string_utils/index.d.ts +0 -0
- package/dist/types/functions/string_utils/src/index.d.ts +0 -0
- package/dist/types/functions/string_utils/src/string_utils.d.ts +0 -0
- package/dist/types/functions/type_utils/imports.d.ts +0 -0
- package/dist/types/functions/type_utils/index.d.ts +0 -0
- package/dist/types/functions/type_utils/src/clean_utils.d.ts +0 -0
- package/dist/types/functions/type_utils/src/ensure_utils.d.ts +0 -0
- package/dist/types/functions/type_utils/src/index.d.ts +0 -0
- package/dist/types/functions/type_utils/src/json_utils.d.ts +0 -0
- package/dist/types/functions/type_utils/src/type_utils.d.ts +0 -0
- package/dist/types/functions/ui_utils/imports.d.ts +0 -0
- package/dist/types/functions/ui_utils/index.d.ts +0 -0
- package/dist/types/functions/ui_utils/src/button.d.ts +0 -0
- package/dist/types/functions/ui_utils/src/checkbox.d.ts +0 -0
- package/dist/types/functions/ui_utils/src/index.d.ts +0 -0
- package/dist/types/functions/ui_utils/src/input.d.ts +0 -0
- package/dist/types/functions/ui_utils/src/spinner.d.ts +0 -0
- package/dist/types/functions/variable_utils/imports.d.ts +0 -0
- package/dist/types/functions/variable_utils/index.d.ts +0 -0
- package/dist/types/functions/variable_utils/src/index.d.ts +0 -0
- package/dist/types/functions/variable_utils/src/variable_utils.d.ts +0 -0
- package/dist/types/index.d.ts +0 -0
- package/dist/types/types/index.d.ts +0 -0
- package/dist/types/types/src/ChangePassword.d.ts +0 -0
- package/dist/types/types/src/Files.d.ts +0 -0
- package/dist/types/types/src/index.d.ts +0 -0
- package/dist/types/types/src/login.d.ts +0 -0
- package/dist/types/types/src/logout.d.ts +0 -0
- package/dist/types/types/src/utils.d.ts +0 -0
- package/dist/types/utils/imports.d.ts +0 -0
- package/dist/types/utils/index.d.ts +0 -0
- package/dist/types/utils/src/Input.d.ts +0 -0
- package/dist/types/utils/src/config.d.ts +0 -0
- package/dist/types/utils/src/index.d.ts +0 -0
- 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
|