@putkoff/abstract-utilities 0.1.236 → 0.1.238

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/esm/index.js CHANGED
@@ -1759,5 +1759,75 @@ function roundPercentage(x) {
1759
1759
  return safeDivide(Math.round(pct), 100);
1760
1760
  }
1761
1761
 
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 };
1762
+ // urlTools.ts
1763
+ // Minimal, safe encoders/decoders + helpers to build/parse URLs
1764
+ /** Encode a single query value/key safely */
1765
+ const encode = (v) => encodeURIComponent(String(v !== null && v !== void 0 ? v : ""));
1766
+ /** Decode a single query value/key safely (never throws) */
1767
+ const decodeSafe = (v) => {
1768
+ if (v == null)
1769
+ return "";
1770
+ try {
1771
+ return decodeURIComponent(v);
1772
+ }
1773
+ catch (_a) {
1774
+ // handles bad % sequences or already-decoded strings
1775
+ return v;
1776
+ }
1777
+ };
1778
+ /** Decode strings that might be double-encoded (up to 2 passes) */
1779
+ const decodeMaybeDouble = (v) => {
1780
+ const once = decodeSafe(v);
1781
+ const twice = decodeSafe(once);
1782
+ return twice.length < once.length ? twice : once;
1783
+ };
1784
+ /** Convert + to spaces (legacy www-form behavior) then decode */
1785
+ const decodeFormComponent = (v) => decodeSafe(v.replace(/\+/g, " "));
1786
+ /** Build a URL with query params (skips null/undefined) */
1787
+ const buildUrl = (base, params) => {
1788
+ const u = new URL(base, typeof window !== "undefined" ? window.location.origin : "http://localhost");
1789
+ if (params) {
1790
+ for (const [k, val] of Object.entries(params)) {
1791
+ if (val === null || val === undefined)
1792
+ continue;
1793
+ // arrays -> multiple entries
1794
+ if (Array.isArray(val)) {
1795
+ val.forEach(v => u.searchParams.append(k, String(v)));
1796
+ }
1797
+ else {
1798
+ u.searchParams.set(k, String(val));
1799
+ }
1800
+ }
1801
+ }
1802
+ return u.toString();
1803
+ };
1804
+ /** Parse a query string into an object (first value wins; arrays if repeat=true) */
1805
+ const parseQuery = (qs, opts) => {
1806
+ var _a;
1807
+ const { repeat = false, form = false } = opts || {};
1808
+ const out = {};
1809
+ const s = qs.startsWith("?") ? qs.slice(1) : qs;
1810
+ if (!s)
1811
+ return out;
1812
+ for (const part of s.split("&")) {
1813
+ if (!part)
1814
+ continue;
1815
+ const [kRaw, vRaw = ""] = part.split("=");
1816
+ const K = form ? decodeFormComponent(kRaw) : decodeSafe(kRaw);
1817
+ const V = form ? decodeFormComponent(vRaw) : decodeSafe(vRaw);
1818
+ if (repeat) {
1819
+ ((_a = out[K]) !== null && _a !== void 0 ? _a : (out[K] = [])).push(V);
1820
+ }
1821
+ else {
1822
+ out[K] = V;
1823
+ }
1824
+ }
1825
+ return out;
1826
+ };
1827
+ /** Quick helper: percent-encode whole strings for placement in URLs */
1828
+ const encodeTextForUrl = (text) => encode(text);
1829
+ /** Quick helper: decode long blobs coming from share-intents/UTMs */
1830
+ const decodeShareBlob = (blob) => decodeMaybeDouble(blob).replace(/\r\n/g, "\n");
1831
+
1832
+ 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, buildUrl, callStorage, callWindowMethod, capitalize, capitalize_str, checkResponse, cleanArray, cleanText, create_list_string, currentUsername, currentUsernames, decodeFormComponent, decodeJwt, decodeMaybeDouble, decodeSafe, decodeShareBlob, eatAll, eatEnd, eatInner, eatOuter, encode, encodeTextForUrl, 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, parseQuery, parseResult, path_to_url, processKeywords, readJsonFile, removeToken, requireToken, roundPercentage, safeDivide, safeGlobalProp, safeMultiply, safeNums, safeStorage, sanitizeFilename, stripPrefixes, truncateString, tryParse, urlJoin, url_to_path };
1763
1833
  //# sourceMappingURL=index.js.map