@putkoff/abstract-utilities 0.1.244 → 1.0.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.
- package/dist/cjs/index.js +262 -346
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +261 -330
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +14 -40
- 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 -1
- 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 +6 -2
- 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 +2 -2
- package/dist/types/functions/fetch_utils/src/index.d.ts +0 -0
- package/dist/types/functions/fetch_utils/src/url_utils.d.ts +0 -0
- package/dist/types/functions/fetch_utils/src/utils.d.ts +1 -2
- package/dist/types/functions/index.d.ts +1 -2
- 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.d.ts +0 -4
- 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/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 -1
- 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 -2
- 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/imports.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/mime_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 +89 -72
- package/dist/functions/auth_utils/imports.js +0 -1
- package/dist/functions/auth_utils/index.js +0 -1
- package/dist/functions/auth_utils/src/index.js +0 -1
- package/dist/functions/auth_utils/src/token_utils.js +0 -104
- package/dist/functions/config_utils/imports.js +0 -2
- package/dist/functions/config_utils/index.js +0 -1
- package/dist/functions/config_utils/src/config_utils.js +0 -16
- package/dist/functions/config_utils/src/index.js +0 -1
- package/dist/functions/constants_utils/index.js +0 -1
- package/dist/functions/constants_utils/src/constants.js +0 -7
- package/dist/functions/constants_utils/src/index.js +0 -1
- package/dist/functions/env_utils/imports.js +0 -1
- package/dist/functions/env_utils/index.js +0 -1
- package/dist/functions/env_utils/src/index.js +0 -1
- package/dist/functions/env_utils/src/window_utils.js +0 -47
- package/dist/functions/fetch_utils/imports.js +0 -2
- package/dist/functions/fetch_utils/index.js +0 -1
- package/dist/functions/fetch_utils/src/fetch_utils.js +0 -65
- package/dist/functions/fetch_utils/src/index.js +0 -3
- package/dist/functions/fetch_utils/src/url_utils.js +0 -83
- package/dist/functions/fetch_utils/src/utils.js +0 -101
- package/dist/functions/index.js +0 -17
- package/dist/functions/math_utils/index.js +0 -1
- package/dist/functions/math_utils/safe_math.js +0 -26
- package/dist/functions/path_utils/imports.js +0 -28
- package/dist/functions/path_utils/index.js +0 -1
- package/dist/functions/path_utils/src/base_dirs.js +0 -17
- package/dist/functions/path_utils/src/function_dirs.js +0 -42
- package/dist/functions/path_utils/src/index.js +0 -6
- package/dist/functions/path_utils/src/misc_dirs.js +0 -15
- package/dist/functions/path_utils/src/path_utils.browser.js +0 -3
- package/dist/functions/path_utils/src/path_utils.js +0 -112
- package/dist/functions/path_utils/src/path_utils.node.js +0 -3
- package/dist/functions/path_utils/src/paths.js +0 -12
- package/dist/functions/path_utils/src/src_dirs.js +0 -25
- package/dist/functions/read_utils/imports.js +0 -1
- package/dist/functions/read_utils/index.js +0 -1
- package/dist/functions/read_utils/src/index.js +0 -1
- package/dist/functions/read_utils/src/read_utils.browser.js +0 -17
- package/dist/functions/read_utils/src/utils.browser.js +0 -32
- package/dist/functions/read_utils/src/utils.js +0 -70
- package/dist/functions/rndm_utils/imports.js +0 -1
- package/dist/functions/rndm_utils/index.js +0 -1
- package/dist/functions/rndm_utils/src/index.js +0 -1
- package/dist/functions/rndm_utils/src/utils.js +0 -13
- package/dist/functions/safe_utils/imports.js +0 -1
- package/dist/functions/safe_utils/index.js +0 -1
- package/dist/functions/safe_utils/src/index.js +0 -4
- package/dist/functions/safe_utils/src/safe_document.js +0 -12
- package/dist/functions/safe_utils/src/safe_globals.js +0 -14
- package/dist/functions/safe_utils/src/safe_storage.js +0 -52
- package/dist/functions/safe_utils/src/safe_window.js +0 -42
- package/dist/functions/string_utils/index.js +0 -1
- package/dist/functions/string_utils/src/index.js +0 -1
- package/dist/functions/string_utils/src/string_utils.js +0 -153
- package/dist/functions/type_utils/imports.js +0 -1
- package/dist/functions/type_utils/index.js +0 -1
- package/dist/functions/type_utils/src/clean_utils.js +0 -38
- package/dist/functions/type_utils/src/ensure_utils.js +0 -33
- package/dist/functions/type_utils/src/index.js +0 -5
- package/dist/functions/type_utils/src/json_utils.js +0 -22
- package/dist/functions/type_utils/src/mime_utils.js +0 -311
- package/dist/functions/type_utils/src/type_utils.js +0 -39
- package/dist/functions/ui_utils/imports.js +0 -5
- package/dist/functions/ui_utils/index.js +0 -1
- package/dist/functions/ui_utils/src/button.js +0 -22
- package/dist/functions/ui_utils/src/checkbox.js +0 -6
- package/dist/functions/ui_utils/src/index.js +0 -4
- package/dist/functions/ui_utils/src/input.js +0 -6
- package/dist/functions/ui_utils/src/spinner.js +0 -4
- package/dist/functions/url_utils/index.js +0 -1
- package/dist/functions/url_utils/uri_utils.js +0 -69
- package/dist/functions/variable_utils/imports.js +0 -1
- package/dist/functions/variable_utils/index.js +0 -1
- package/dist/functions/variable_utils/src/index.js +0 -1
- package/dist/functions/variable_utils/src/variable_utils.js +0 -34
- package/dist/functions.json +0 -1727
- package/dist/index.js +0 -2
- package/dist/types/functions/path_utils/src/path_utils.browser.d.ts +0 -2
- package/dist/types/functions/path_utils/src/path_utils.node.d.ts +0 -2
- package/dist/types/functions/read_utils/src/read_utils.browser.d.ts +0 -1
- package/dist/types/functions/read_utils/src/utils.browser.d.ts +0 -3
- package/dist/types/functions/url_utils/index.d.ts +0 -1
- package/dist/types/functions/url_utils/uri_utils.d.ts +0 -19
- package/dist/types/index.js +0 -1
- package/dist/types/src/ChangePassword.js +0 -1
- package/dist/types/src/Files.js +0 -1
- package/dist/types/src/index.js +0 -5
- package/dist/types/src/login.js +0 -1
- package/dist/types/src/logout.js +0 -1
- package/dist/types/src/utils.js +0 -1
- package/dist/utils/imports.js +0 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/src/Input.js +0 -2
- package/dist/utils/src/config.js +0 -12
- package/dist/utils/src/index.js +0 -3
package/dist/esm/index.js
CHANGED
|
@@ -144,17 +144,6 @@ function isLoggedIn() {
|
|
|
144
144
|
const tok = getToken();
|
|
145
145
|
return !!tok && !isTokenExpired(tok !== null && tok !== void 0 ? tok : "");
|
|
146
146
|
}
|
|
147
|
-
function removeToken() {
|
|
148
|
-
let is_logged = isLoggedIn();
|
|
149
|
-
if (is_logged) {
|
|
150
|
-
callStorage('removeItem', "token");
|
|
151
|
-
}
|
|
152
|
-
is_logged = isLoggedIn();
|
|
153
|
-
if (is_logged) {
|
|
154
|
-
return false;
|
|
155
|
-
}
|
|
156
|
-
return true;
|
|
157
|
-
}
|
|
158
147
|
/**
|
|
159
148
|
* Add a Bearer Authorization header.
|
|
160
149
|
* A shallow copy of headers is returned so callers can keep chaining.
|
|
@@ -171,7 +160,7 @@ function requireToken() {
|
|
|
171
160
|
const tok = getToken();
|
|
172
161
|
if (!tok || isTokenExpired(tok)) {
|
|
173
162
|
console.warn("→ No token or expired token, redirecting to login…");
|
|
174
|
-
|
|
163
|
+
localStorage.removeItem("token");
|
|
175
164
|
window.location.href = '/';
|
|
176
165
|
throw new Error("Redirecting to login…");
|
|
177
166
|
}
|
|
@@ -189,13 +178,16 @@ function isTokenExpired(token) {
|
|
|
189
178
|
}
|
|
190
179
|
/** Convenience wrapper: return username from the JWT (or null). */
|
|
191
180
|
function currentUsername() {
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
181
|
+
const tok = getToken();
|
|
182
|
+
if (!tok)
|
|
183
|
+
return null;
|
|
184
|
+
try {
|
|
185
|
+
const { username } = decodeJwt(tok);
|
|
186
|
+
return username !== null && username !== void 0 ? username : null;
|
|
187
|
+
}
|
|
188
|
+
catch (_a) {
|
|
189
|
+
return null;
|
|
197
190
|
}
|
|
198
|
-
return uName;
|
|
199
191
|
}
|
|
200
192
|
function currentUsernames() {
|
|
201
193
|
var _a;
|
|
@@ -339,37 +331,44 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
339
331
|
*/
|
|
340
332
|
function readJsonFile(relativeOrAbsolutePath) {
|
|
341
333
|
return __awaiter(this, void 0, void 0, function* () {
|
|
342
|
-
|
|
334
|
+
// 1) Try Node.js fs
|
|
335
|
+
if (typeof process !== 'undefined' &&
|
|
336
|
+
process.versions != null &&
|
|
337
|
+
process.versions.node) {
|
|
343
338
|
try {
|
|
344
|
-
const
|
|
345
|
-
const
|
|
346
|
-
const filePath = isAbsolute(relativeOrAbsolutePath)
|
|
339
|
+
const fs = yield import('fs');
|
|
340
|
+
const path = yield import('path');
|
|
341
|
+
const filePath = path.isAbsolute(relativeOrAbsolutePath)
|
|
347
342
|
? relativeOrAbsolutePath
|
|
348
|
-
: resolve(
|
|
349
|
-
const text = yield readFile(filePath, 'utf8');
|
|
343
|
+
: path.resolve(process.cwd(), relativeOrAbsolutePath);
|
|
344
|
+
const text = yield fs.promises.readFile(filePath, 'utf8');
|
|
350
345
|
return JSON.parse(text);
|
|
351
346
|
}
|
|
352
347
|
catch (_a) {
|
|
353
|
-
|
|
348
|
+
// swallow and fall back to browser
|
|
354
349
|
}
|
|
355
350
|
}
|
|
356
|
-
//
|
|
351
|
+
// 2) Try browser fetch
|
|
357
352
|
const fetchFn = safeGlobalProp('fetch');
|
|
358
|
-
if (typeof fetchFn !== 'function')
|
|
353
|
+
if (typeof fetchFn !== 'function') {
|
|
359
354
|
return null;
|
|
355
|
+
}
|
|
356
|
+
// Resolve URL against document.baseURI if possible
|
|
360
357
|
let url = relativeOrAbsolutePath;
|
|
361
358
|
const baseURI = safeGlobalProp('document', 'baseURI');
|
|
362
359
|
if (baseURI) {
|
|
363
360
|
try {
|
|
364
361
|
url = new URL(relativeOrAbsolutePath, baseURI).href;
|
|
365
362
|
}
|
|
366
|
-
catch (_b) {
|
|
363
|
+
catch (_b) {
|
|
364
|
+
// keep url as-is
|
|
365
|
+
}
|
|
367
366
|
}
|
|
368
367
|
try {
|
|
369
368
|
const res = yield fetchFn(url);
|
|
370
369
|
if (!res.ok)
|
|
371
370
|
return null;
|
|
372
|
-
return yield res.json();
|
|
371
|
+
return (yield res.json());
|
|
373
372
|
}
|
|
374
373
|
catch (_c) {
|
|
375
374
|
return null;
|
|
@@ -412,7 +411,6 @@ function getResult(obj) {
|
|
|
412
411
|
}
|
|
413
412
|
return current;
|
|
414
413
|
}
|
|
415
|
-
const get_result = getResult;
|
|
416
414
|
// Determines HTTP method, defaults to GET or POST based on body
|
|
417
415
|
function getMethod(method = null, body = null) {
|
|
418
416
|
const validMethods = ['GET', 'POST', 'PUT', 'PATCH', 'PULL'];
|
|
@@ -501,7 +499,7 @@ function checkResponse(res) {
|
|
|
501
499
|
}
|
|
502
500
|
|
|
503
501
|
function fetchIt(endpoint_1) {
|
|
504
|
-
return __awaiter(this, arguments, void 0, function* (endpoint, body = null, method = null, headers = null, blob = false, configUrl = false, withCredentials = true, returnJson = true,
|
|
502
|
+
return __awaiter(this, arguments, void 0, function* (endpoint, body = null, method = null, headers = null, blob = false, configUrl = false, withCredentials = true, returnJson = true, returnReult = true) {
|
|
505
503
|
method = (method || "GET").toUpperCase();
|
|
506
504
|
// 2) choose the URL
|
|
507
505
|
let url = endpoint;
|
|
@@ -517,20 +515,18 @@ function fetchIt(endpoint_1) {
|
|
|
517
515
|
? JSON.stringify(body)
|
|
518
516
|
: undefined,
|
|
519
517
|
};
|
|
520
|
-
|
|
518
|
+
console.debug("➡️ secureFetchIt →", url, opts);
|
|
519
|
+
const res = yield fetch(url, opts);
|
|
521
520
|
if (!res.ok) {
|
|
522
521
|
const err = yield res.text();
|
|
523
522
|
throw new Error(`HTTP ${res.status}: ${err}`);
|
|
524
523
|
}
|
|
525
524
|
if (blob)
|
|
526
525
|
return res.blob();
|
|
527
|
-
if (
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
}
|
|
532
|
-
return JsonRes;
|
|
533
|
-
}
|
|
526
|
+
if (returnReult)
|
|
527
|
+
return getResult(res.json());
|
|
528
|
+
if (returnJson)
|
|
529
|
+
return res.json();
|
|
534
530
|
return res;
|
|
535
531
|
});
|
|
536
532
|
}
|
|
@@ -1146,6 +1142,135 @@ posix.posix = posix;
|
|
|
1146
1142
|
|
|
1147
1143
|
var pathBrowserify = posix;
|
|
1148
1144
|
|
|
1145
|
+
function getSubstring(obj, maxLength = null, minLength = null) {
|
|
1146
|
+
const objLength = obj.length;
|
|
1147
|
+
const effectiveMaxLength = maxLength !== null && maxLength !== void 0 ? maxLength : objLength; // Use nullish coalescing for clarity
|
|
1148
|
+
const effectiveMinLength = minLength !== null && minLength !== void 0 ? minLength : 0;
|
|
1149
|
+
// Ensure bounds are valid
|
|
1150
|
+
const clampedMaxLength = Math.min(Math.max(effectiveMaxLength, 0), objLength);
|
|
1151
|
+
const clampedMinLength = Math.min(Math.max(effectiveMinLength, 0), objLength);
|
|
1152
|
+
// If minLength exceeds maxLength, return empty string or adjust logic as needed
|
|
1153
|
+
if (clampedMinLength >= clampedMaxLength) {
|
|
1154
|
+
return '';
|
|
1155
|
+
}
|
|
1156
|
+
return obj.substring(clampedMinLength, clampedMaxLength);
|
|
1157
|
+
}
|
|
1158
|
+
function truncateString(obj, maxLength = 20) {
|
|
1159
|
+
const objLength = obj.length;
|
|
1160
|
+
if (objLength > maxLength && maxLength) {
|
|
1161
|
+
obj = getSubstring(obj, maxLength) + '...';
|
|
1162
|
+
}
|
|
1163
|
+
return obj;
|
|
1164
|
+
}
|
|
1165
|
+
// string_utils/src/string_utils.ts
|
|
1166
|
+
function stripPrefixes(str, bases = []) {
|
|
1167
|
+
/* NEW: coerce whatever arrives into a string */
|
|
1168
|
+
str = String(str);
|
|
1169
|
+
const prefixes = (Array.isArray(bases) ? bases : [bases])
|
|
1170
|
+
.filter(Boolean)
|
|
1171
|
+
.sort((a, b) => b.length - a.length); // longest first
|
|
1172
|
+
let changed = true;
|
|
1173
|
+
while (changed) {
|
|
1174
|
+
changed = false;
|
|
1175
|
+
for (const prefix of prefixes) {
|
|
1176
|
+
if (str.startsWith(prefix)) {
|
|
1177
|
+
str = str.slice(prefix.length);
|
|
1178
|
+
changed = true;
|
|
1179
|
+
break; // restart from longest prefix
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
return str;
|
|
1184
|
+
}
|
|
1185
|
+
/**
|
|
1186
|
+
* Removes characters from the beginning of the string
|
|
1187
|
+
* if they are found in the list of characters.
|
|
1188
|
+
*
|
|
1189
|
+
* @param str - The input string.
|
|
1190
|
+
* @param listObjects - A string or an array of characters to remove.
|
|
1191
|
+
* @returns The modified string.
|
|
1192
|
+
*/
|
|
1193
|
+
function eatInner(str, listObjects) {
|
|
1194
|
+
if (!Array.isArray(listObjects)) {
|
|
1195
|
+
listObjects = [listObjects];
|
|
1196
|
+
}
|
|
1197
|
+
// Ensure str is a string
|
|
1198
|
+
str = String(str);
|
|
1199
|
+
// Remove characters from the beginning while they are in listObjects
|
|
1200
|
+
while (str.length > 0 && listObjects.includes(str[0])) {
|
|
1201
|
+
str = str.slice(1);
|
|
1202
|
+
}
|
|
1203
|
+
return str;
|
|
1204
|
+
}
|
|
1205
|
+
/**
|
|
1206
|
+
* Removes characters from the end of the string
|
|
1207
|
+
* if they are found in the list of characters.
|
|
1208
|
+
*
|
|
1209
|
+
* @param str - The input string.
|
|
1210
|
+
* @param listObjects - A string or an array of characters to remove.
|
|
1211
|
+
* @returns The modified string.
|
|
1212
|
+
*/
|
|
1213
|
+
function eatOuter(str, listObjects) {
|
|
1214
|
+
if (!Array.isArray(listObjects)) {
|
|
1215
|
+
listObjects = [listObjects];
|
|
1216
|
+
}
|
|
1217
|
+
// Ensure str is a string
|
|
1218
|
+
str = String(str);
|
|
1219
|
+
// Remove characters from the end while they are in listObjects
|
|
1220
|
+
while (str.length > 0 && listObjects.includes(str[str.length - 1])) {
|
|
1221
|
+
str = str.slice(0, -1);
|
|
1222
|
+
}
|
|
1223
|
+
return str;
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
* Removes characters from both the beginning and the end of the string
|
|
1227
|
+
* if they are found in the list of characters.
|
|
1228
|
+
*
|
|
1229
|
+
* @param str - The input string.
|
|
1230
|
+
* @param listObjects - A string or an array of characters to remove.
|
|
1231
|
+
* @returns The modified string.
|
|
1232
|
+
*/
|
|
1233
|
+
function eatAll(str, listObjects) {
|
|
1234
|
+
return eatOuter(eatInner(str, listObjects), listObjects);
|
|
1235
|
+
}
|
|
1236
|
+
function eatEnd(obj, endings = ['/']) {
|
|
1237
|
+
let result = obj;
|
|
1238
|
+
let modified = true;
|
|
1239
|
+
while (modified) {
|
|
1240
|
+
modified = false;
|
|
1241
|
+
for (const ending of endings) {
|
|
1242
|
+
if (result.endsWith(ending)) {
|
|
1243
|
+
result = result.slice(0, -ending.length);
|
|
1244
|
+
modified = true;
|
|
1245
|
+
break;
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
return result;
|
|
1250
|
+
}
|
|
1251
|
+
function tryParse(obj) {
|
|
1252
|
+
try {
|
|
1253
|
+
obj = JSON.stringify(obj);
|
|
1254
|
+
}
|
|
1255
|
+
catch (err) {
|
|
1256
|
+
try {
|
|
1257
|
+
obj = JSON.parse(obj);
|
|
1258
|
+
}
|
|
1259
|
+
catch (err) {
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
return obj;
|
|
1263
|
+
}
|
|
1264
|
+
function create_list_string(array_obj) {
|
|
1265
|
+
let string = '';
|
|
1266
|
+
for (const obj in array_obj) {
|
|
1267
|
+
const array_value = array_obj[obj];
|
|
1268
|
+
const parsed_value = tryParse(array_value);
|
|
1269
|
+
string += `${obj} == ${parsed_value}\n`;
|
|
1270
|
+
}
|
|
1271
|
+
return string;
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1149
1274
|
function ensure_list(obj) {
|
|
1150
1275
|
const objArray = Array.isArray(obj) ? obj : [obj];
|
|
1151
1276
|
return objArray;
|
|
@@ -1586,159 +1711,6 @@ const confirm_type = confirmType;
|
|
|
1586
1711
|
const is_media_type = isMediaType;
|
|
1587
1712
|
const get_mime_type = getMimeType;
|
|
1588
1713
|
|
|
1589
|
-
function getSubstring(obj, maxLength = null, minLength = null) {
|
|
1590
|
-
const objLength = obj.length;
|
|
1591
|
-
const effectiveMaxLength = maxLength !== null && maxLength !== void 0 ? maxLength : objLength; // Use nullish coalescing for clarity
|
|
1592
|
-
const effectiveMinLength = minLength !== null && minLength !== void 0 ? minLength : 0;
|
|
1593
|
-
// Ensure bounds are valid
|
|
1594
|
-
const clampedMaxLength = Math.min(Math.max(effectiveMaxLength, 0), objLength);
|
|
1595
|
-
const clampedMinLength = Math.min(Math.max(effectiveMinLength, 0), objLength);
|
|
1596
|
-
// If minLength exceeds maxLength, return empty string or adjust logic as needed
|
|
1597
|
-
if (clampedMinLength >= clampedMaxLength) {
|
|
1598
|
-
return '';
|
|
1599
|
-
}
|
|
1600
|
-
return obj.substring(clampedMinLength, clampedMaxLength);
|
|
1601
|
-
}
|
|
1602
|
-
function truncateString(obj, maxLength = 20) {
|
|
1603
|
-
const objLength = obj.length;
|
|
1604
|
-
if (objLength > maxLength && maxLength) {
|
|
1605
|
-
obj = getSubstring(obj, maxLength) + '...';
|
|
1606
|
-
}
|
|
1607
|
-
return obj;
|
|
1608
|
-
}
|
|
1609
|
-
function capitalize_str(string) {
|
|
1610
|
-
string = assureString(string);
|
|
1611
|
-
const string_len = string.length;
|
|
1612
|
-
let init_char = string.toUpperCase();
|
|
1613
|
-
if (string_len > 0) {
|
|
1614
|
-
init_char = string[0].toUpperCase();
|
|
1615
|
-
}
|
|
1616
|
-
let rest_chars = '';
|
|
1617
|
-
if (string_len > 1) {
|
|
1618
|
-
rest_chars = string.slice(1).toLowerCase();
|
|
1619
|
-
}
|
|
1620
|
-
const fin_chars = `${init_char}${rest_chars}`;
|
|
1621
|
-
return fin_chars;
|
|
1622
|
-
}
|
|
1623
|
-
function capitalize(string) {
|
|
1624
|
-
let nu_string = '';
|
|
1625
|
-
string = assureString(string);
|
|
1626
|
-
let objs = string.replace('-', '_').split('_');
|
|
1627
|
-
for (const obj of objs) {
|
|
1628
|
-
let str_obj = capitalize_str(obj);
|
|
1629
|
-
nu_string = `${nu_string} ${str_obj}`;
|
|
1630
|
-
}
|
|
1631
|
-
return eatAll(nu_string, [' ']);
|
|
1632
|
-
}
|
|
1633
|
-
// string_utils/src/string_utils.ts
|
|
1634
|
-
function stripPrefixes(str, bases = []) {
|
|
1635
|
-
/* NEW: coerce whatever arrives into a string */
|
|
1636
|
-
str = String(str);
|
|
1637
|
-
const prefixes = (Array.isArray(bases) ? bases : [bases])
|
|
1638
|
-
.filter(Boolean)
|
|
1639
|
-
.sort((a, b) => b.length - a.length); // longest first
|
|
1640
|
-
let changed = true;
|
|
1641
|
-
while (changed) {
|
|
1642
|
-
changed = false;
|
|
1643
|
-
for (const prefix of prefixes) {
|
|
1644
|
-
if (str.startsWith(prefix)) {
|
|
1645
|
-
str = str.slice(prefix.length);
|
|
1646
|
-
changed = true;
|
|
1647
|
-
break; // restart from longest prefix
|
|
1648
|
-
}
|
|
1649
|
-
}
|
|
1650
|
-
}
|
|
1651
|
-
return str;
|
|
1652
|
-
}
|
|
1653
|
-
/**
|
|
1654
|
-
* Removes characters from the beginning of the string
|
|
1655
|
-
* if they are found in the list of characters.
|
|
1656
|
-
*
|
|
1657
|
-
* @param str - The input string.
|
|
1658
|
-
* @param listObjects - A string or an array of characters to remove.
|
|
1659
|
-
* @returns The modified string.
|
|
1660
|
-
*/
|
|
1661
|
-
function eatInner(str, listObjects) {
|
|
1662
|
-
if (!Array.isArray(listObjects)) {
|
|
1663
|
-
listObjects = [listObjects];
|
|
1664
|
-
}
|
|
1665
|
-
// Ensure str is a string
|
|
1666
|
-
str = String(str);
|
|
1667
|
-
// Remove characters from the beginning while they are in listObjects
|
|
1668
|
-
while (str.length > 0 && listObjects.includes(str[0])) {
|
|
1669
|
-
str = str.slice(1);
|
|
1670
|
-
}
|
|
1671
|
-
return str;
|
|
1672
|
-
}
|
|
1673
|
-
/**
|
|
1674
|
-
* Removes characters from the end of the string
|
|
1675
|
-
* if they are found in the list of characters.
|
|
1676
|
-
*
|
|
1677
|
-
* @param str - The input string.
|
|
1678
|
-
* @param listObjects - A string or an array of characters to remove.
|
|
1679
|
-
* @returns The modified string.
|
|
1680
|
-
*/
|
|
1681
|
-
function eatOuter(str, listObjects) {
|
|
1682
|
-
if (!Array.isArray(listObjects)) {
|
|
1683
|
-
listObjects = [listObjects];
|
|
1684
|
-
}
|
|
1685
|
-
// Ensure str is a string
|
|
1686
|
-
str = String(str);
|
|
1687
|
-
// Remove characters from the end while they are in listObjects
|
|
1688
|
-
while (str.length > 0 && listObjects.includes(str[str.length - 1])) {
|
|
1689
|
-
str = str.slice(0, -1);
|
|
1690
|
-
}
|
|
1691
|
-
return str;
|
|
1692
|
-
}
|
|
1693
|
-
/**
|
|
1694
|
-
* Removes characters from both the beginning and the end of the string
|
|
1695
|
-
* if they are found in the list of characters.
|
|
1696
|
-
*
|
|
1697
|
-
* @param str - The input string.
|
|
1698
|
-
* @param listObjects - A string or an array of characters to remove.
|
|
1699
|
-
* @returns The modified string.
|
|
1700
|
-
*/
|
|
1701
|
-
function eatAll(str, listObjects) {
|
|
1702
|
-
return eatOuter(eatInner(str, listObjects), listObjects);
|
|
1703
|
-
}
|
|
1704
|
-
function eatEnd(obj, endings = ['/']) {
|
|
1705
|
-
let result = obj;
|
|
1706
|
-
let modified = true;
|
|
1707
|
-
while (modified) {
|
|
1708
|
-
modified = false;
|
|
1709
|
-
for (const ending of endings) {
|
|
1710
|
-
if (result.endsWith(ending)) {
|
|
1711
|
-
result = result.slice(0, -ending.length);
|
|
1712
|
-
modified = true;
|
|
1713
|
-
break;
|
|
1714
|
-
}
|
|
1715
|
-
}
|
|
1716
|
-
}
|
|
1717
|
-
return result;
|
|
1718
|
-
}
|
|
1719
|
-
function tryParse(obj) {
|
|
1720
|
-
try {
|
|
1721
|
-
obj = JSON.stringify(obj);
|
|
1722
|
-
}
|
|
1723
|
-
catch (err) {
|
|
1724
|
-
try {
|
|
1725
|
-
obj = JSON.parse(obj);
|
|
1726
|
-
}
|
|
1727
|
-
catch (err) {
|
|
1728
|
-
}
|
|
1729
|
-
}
|
|
1730
|
-
return obj;
|
|
1731
|
-
}
|
|
1732
|
-
function create_list_string(array_obj) {
|
|
1733
|
-
let string = '';
|
|
1734
|
-
for (const obj in array_obj) {
|
|
1735
|
-
const array_value = array_obj[obj];
|
|
1736
|
-
const parsed_value = tryParse(array_value);
|
|
1737
|
-
string += `${obj} == ${parsed_value}\n`;
|
|
1738
|
-
}
|
|
1739
|
-
return string;
|
|
1740
|
-
}
|
|
1741
|
-
|
|
1742
1714
|
/**
|
|
1743
1715
|
* In the browser we already have a WHATWG URL constructor on window.
|
|
1744
1716
|
* Here we re-export it as “url” so other modules can import it.
|
|
@@ -1759,12 +1731,9 @@ function fileURLToPath(fileUrl) {
|
|
|
1759
1731
|
}
|
|
1760
1732
|
}
|
|
1761
1733
|
function getAbsolutePath() {
|
|
1762
|
-
if (typeof window !== 'undefined')
|
|
1763
|
-
return '';
|
|
1764
1734
|
return fileURLToPath(import.meta.url);
|
|
1765
1735
|
}
|
|
1766
1736
|
|
|
1767
|
-
// path_utils.browser.ts
|
|
1768
1737
|
function get_dirname(filePath) {
|
|
1769
1738
|
if (!filePath)
|
|
1770
1739
|
return '';
|
|
@@ -1820,23 +1789,6 @@ function make_path(...paths) {
|
|
|
1820
1789
|
}
|
|
1821
1790
|
return real_path;
|
|
1822
1791
|
}
|
|
1823
|
-
function makePath(...paths) {
|
|
1824
|
-
var _a;
|
|
1825
|
-
const pathArray = ensure_list(paths);
|
|
1826
|
-
let real_path = '';
|
|
1827
|
-
for (let i = 0; i < pathArray.length; i++) {
|
|
1828
|
-
let seg = String((_a = pathArray[i]) !== null && _a !== void 0 ? _a : '');
|
|
1829
|
-
if (i === 0) {
|
|
1830
|
-
real_path = seg;
|
|
1831
|
-
}
|
|
1832
|
-
else {
|
|
1833
|
-
seg = eatInner(seg, ['/']);
|
|
1834
|
-
real_path = eatOuter(real_path, ['/']);
|
|
1835
|
-
real_path = `${real_path}/${seg}`;
|
|
1836
|
-
}
|
|
1837
|
-
}
|
|
1838
|
-
return real_path || '';
|
|
1839
|
-
}
|
|
1840
1792
|
function sanitizeFilename(filename) {
|
|
1841
1793
|
return filename
|
|
1842
1794
|
.toLowerCase()
|
|
@@ -1846,13 +1798,6 @@ function sanitizeFilename(filename) {
|
|
|
1846
1798
|
.replace(/-+/g, '-') // Collapse multiple hyphens into one
|
|
1847
1799
|
.replace(/^-|-$/, ''); // Remove leading/trailing hyphens
|
|
1848
1800
|
}
|
|
1849
|
-
function get_relative_path(directory, fullPath) {
|
|
1850
|
-
return pathBrowserify.relative(directory, fullPath);
|
|
1851
|
-
}
|
|
1852
|
-
// Safer resolver that strips .. at the front only, but prefer server-side checks.
|
|
1853
|
-
function get_safe_path(p) {
|
|
1854
|
-
return pathBrowserify.normalize(p).replace(/^(\.\.[/\\])+/, '');
|
|
1855
|
-
}
|
|
1856
1801
|
function make_sanitized_path(...paths) {
|
|
1857
1802
|
let real_path = '';
|
|
1858
1803
|
for (let i = 0; i < paths.length; i++) {
|
|
@@ -1866,13 +1811,13 @@ function make_sanitized_path(...paths) {
|
|
|
1866
1811
|
}
|
|
1867
1812
|
return real_path || '';
|
|
1868
1813
|
}
|
|
1869
|
-
/** FIXED: your regexes were strings. This correctly joins without duplicate slashes. */
|
|
1870
1814
|
function normalizeUrl(base, p) {
|
|
1871
1815
|
if (!p)
|
|
1872
|
-
return base
|
|
1873
|
-
const cleanBase = base.replace(
|
|
1874
|
-
const cleanPath = p.replace(
|
|
1875
|
-
|
|
1816
|
+
return base;
|
|
1817
|
+
const cleanBase = base.replace(/\/+$/, ''); // regex literal
|
|
1818
|
+
const cleanPath = p.replace(/^\/+/, '');
|
|
1819
|
+
// collapse multiple “//” into one, but keep the “://” after protocol
|
|
1820
|
+
return `${cleanBase}/${cleanPath}`.replace(/([^:])\/{2,}/g, '$1/');
|
|
1876
1821
|
}
|
|
1877
1822
|
|
|
1878
1823
|
/**
|
|
@@ -1973,7 +1918,32 @@ function alertit(obj = null) {
|
|
|
1973
1918
|
}
|
|
1974
1919
|
alert(msg);
|
|
1975
1920
|
}
|
|
1976
|
-
|
|
1921
|
+
|
|
1922
|
+
// take N args and coerce them all to numbers
|
|
1923
|
+
function safeNums(...args) {
|
|
1924
|
+
return args.map(ensure_number);
|
|
1925
|
+
}
|
|
1926
|
+
// divide the first value by each of the following
|
|
1927
|
+
function safeDivide(...args) {
|
|
1928
|
+
const [head, ...rest] = safeNums(...args);
|
|
1929
|
+
// if we don’t have a head or any divisor is zero, bail
|
|
1930
|
+
if (head === 0 || rest.some((d) => d === 0))
|
|
1931
|
+
return 0;
|
|
1932
|
+
return rest.reduce((acc, d) => acc / d, head);
|
|
1933
|
+
}
|
|
1934
|
+
// multiply all the values together
|
|
1935
|
+
function safeMultiply(...args) {
|
|
1936
|
+
const nums = safeNums(...args);
|
|
1937
|
+
// if any number is zero, result is zero
|
|
1938
|
+
if (nums.includes(0))
|
|
1939
|
+
return 0;
|
|
1940
|
+
return nums.reduce((acc, n) => acc * n, 1);
|
|
1941
|
+
}
|
|
1942
|
+
// round a value to two decimals by percent
|
|
1943
|
+
function roundPercentage(x) {
|
|
1944
|
+
const pct = safeMultiply(ensure_number(x), 100);
|
|
1945
|
+
return safeDivide(Math.round(pct), 100);
|
|
1946
|
+
}
|
|
1977
1947
|
|
|
1978
1948
|
function Button(_a) {
|
|
1979
1949
|
var { children, color = 'gray', variant = 'default', className = '' } = _a, rest = __rest(_a, ["children", "color", "variant", "className"]);
|
|
@@ -2011,17 +1981,74 @@ function Spinner() {
|
|
|
2011
1981
|
}
|
|
2012
1982
|
|
|
2013
1983
|
// src/functions/config_utils/src/config_utils.ts
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
1984
|
+
let _cachedConfig = null;
|
|
1985
|
+
function loadConfig() {
|
|
1986
|
+
return __awaiter(this, arguments, void 0, function* (filePath = null) {
|
|
1987
|
+
var _a;
|
|
1988
|
+
if (_cachedConfig) {
|
|
1989
|
+
return _cachedConfig;
|
|
1990
|
+
}
|
|
1991
|
+
// 1) figure out where config.json lives
|
|
1992
|
+
let configUrl;
|
|
1993
|
+
if (filePath) {
|
|
1994
|
+
configUrl = filePath;
|
|
1995
|
+
}
|
|
1996
|
+
else if (typeof import.meta !== 'undefined' && typeof import.meta.url === 'string') {
|
|
1997
|
+
// ES module: resolve relative to this file
|
|
1998
|
+
try {
|
|
1999
|
+
configUrl = new URL('./config.json', import.meta.url).href;
|
|
2000
|
+
}
|
|
2001
|
+
catch (_b) {
|
|
2002
|
+
configUrl = 'config.json';
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
else {
|
|
2006
|
+
// browser fallback
|
|
2007
|
+
const baseURI = safeGlobalProp('document', 'baseURI');
|
|
2008
|
+
try {
|
|
2009
|
+
configUrl =
|
|
2010
|
+
typeof baseURI === 'string'
|
|
2011
|
+
? new URL('config.json', baseURI).href
|
|
2012
|
+
: 'config.json';
|
|
2013
|
+
}
|
|
2014
|
+
catch (_c) {
|
|
2015
|
+
configUrl = 'config.json';
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
// 2) if we have a fetch, try HTTP(S)
|
|
2019
|
+
const fetchFn = safeGlobalProp('fetch');
|
|
2020
|
+
if (typeof fetchFn === 'function') {
|
|
2021
|
+
try {
|
|
2022
|
+
const res = yield fetchFn(configUrl);
|
|
2023
|
+
if (res.ok) {
|
|
2024
|
+
const json = yield res.json();
|
|
2025
|
+
// cache & return
|
|
2026
|
+
_cachedConfig = (_a = json) !== null && _a !== void 0 ? _a : {};
|
|
2027
|
+
return _cachedConfig;
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
catch (_d) {
|
|
2031
|
+
/* swallow */
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
// 3) Node fallback: try reading from disk (requires your readJsonFile util)
|
|
2019
2035
|
try {
|
|
2020
|
-
|
|
2036
|
+
const disk = yield readJsonFile(configUrl);
|
|
2037
|
+
_cachedConfig = disk !== null && disk !== void 0 ? disk : {};
|
|
2038
|
+
return _cachedConfig;
|
|
2021
2039
|
}
|
|
2022
|
-
catch (
|
|
2023
|
-
|
|
2040
|
+
catch (_e) {
|
|
2041
|
+
/* swallow */
|
|
2024
2042
|
}
|
|
2043
|
+
// 4) if all else fails, return an empty config
|
|
2044
|
+
_cachedConfig = {};
|
|
2045
|
+
return _cachedConfig;
|
|
2046
|
+
});
|
|
2047
|
+
}
|
|
2048
|
+
function getConfig(key) {
|
|
2049
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2050
|
+
const cfg = yield loadConfig();
|
|
2051
|
+
return key != null ? cfg[key] : cfg;
|
|
2025
2052
|
});
|
|
2026
2053
|
}
|
|
2027
2054
|
|
|
@@ -2059,101 +2086,5 @@ function get_keyword_string(keywords) {
|
|
|
2059
2086
|
return allString;
|
|
2060
2087
|
}
|
|
2061
2088
|
|
|
2062
|
-
|
|
2063
|
-
function safeNums(...args) {
|
|
2064
|
-
return args.map(ensure_number);
|
|
2065
|
-
}
|
|
2066
|
-
// divide the first value by each of the following
|
|
2067
|
-
function safeDivide(...args) {
|
|
2068
|
-
const [head, ...rest] = safeNums(...args);
|
|
2069
|
-
// if we don’t have a head or any divisor is zero, bail
|
|
2070
|
-
if (head === 0 || rest.some((d) => d === 0))
|
|
2071
|
-
return 0;
|
|
2072
|
-
return rest.reduce((acc, d) => acc / d, head);
|
|
2073
|
-
}
|
|
2074
|
-
// multiply all the values together
|
|
2075
|
-
function safeMultiply(...args) {
|
|
2076
|
-
const nums = safeNums(...args);
|
|
2077
|
-
// if any number is zero, result is zero
|
|
2078
|
-
if (nums.includes(0))
|
|
2079
|
-
return 0;
|
|
2080
|
-
return nums.reduce((acc, n) => acc * n, 1);
|
|
2081
|
-
}
|
|
2082
|
-
// round a value to two decimals by percent
|
|
2083
|
-
function roundPercentage(x) {
|
|
2084
|
-
const pct = safeMultiply(ensure_number(x), 100);
|
|
2085
|
-
return safeDivide(Math.round(pct), 100);
|
|
2086
|
-
}
|
|
2087
|
-
|
|
2088
|
-
// urlTools.ts
|
|
2089
|
-
// Minimal, safe encoders/decoders + helpers to build/parse URLs
|
|
2090
|
-
/** Encode a single query value/key safely */
|
|
2091
|
-
const encode = (v) => encodeURIComponent(String(v !== null && v !== void 0 ? v : ""));
|
|
2092
|
-
/** Decode a single query value/key safely (never throws) */
|
|
2093
|
-
const decodeSafe = (v) => {
|
|
2094
|
-
if (v == null)
|
|
2095
|
-
return "";
|
|
2096
|
-
try {
|
|
2097
|
-
return decodeURIComponent(v);
|
|
2098
|
-
}
|
|
2099
|
-
catch (_a) {
|
|
2100
|
-
// handles bad % sequences or already-decoded strings
|
|
2101
|
-
return v;
|
|
2102
|
-
}
|
|
2103
|
-
};
|
|
2104
|
-
/** Decode strings that might be double-encoded (up to 2 passes) */
|
|
2105
|
-
const decodeMaybeDouble = (v) => {
|
|
2106
|
-
const once = decodeSafe(v);
|
|
2107
|
-
const twice = decodeSafe(once);
|
|
2108
|
-
return twice.length < once.length ? twice : once;
|
|
2109
|
-
};
|
|
2110
|
-
/** Convert + to spaces (legacy www-form behavior) then decode */
|
|
2111
|
-
const decodeFormComponent = (v) => decodeSafe(v.replace(/\+/g, " "));
|
|
2112
|
-
/** Build a URL with query params (skips null/undefined) */
|
|
2113
|
-
const buildUrl = (base, params) => {
|
|
2114
|
-
const u = new URL(base, typeof window !== "undefined" ? window.location.origin : "http://localhost");
|
|
2115
|
-
if (params) {
|
|
2116
|
-
for (const [k, val] of Object.entries(params)) {
|
|
2117
|
-
if (val === null || val === undefined)
|
|
2118
|
-
continue;
|
|
2119
|
-
// arrays -> multiple entries
|
|
2120
|
-
if (Array.isArray(val)) {
|
|
2121
|
-
val.forEach(v => u.searchParams.append(k, String(v)));
|
|
2122
|
-
}
|
|
2123
|
-
else {
|
|
2124
|
-
u.searchParams.set(k, String(val));
|
|
2125
|
-
}
|
|
2126
|
-
}
|
|
2127
|
-
}
|
|
2128
|
-
return u.toString();
|
|
2129
|
-
};
|
|
2130
|
-
/** Parse a query string into an object (first value wins; arrays if repeat=true) */
|
|
2131
|
-
const parseQuery = (qs, opts) => {
|
|
2132
|
-
var _a;
|
|
2133
|
-
const { repeat = false, form = false } = opts || {};
|
|
2134
|
-
const out = {};
|
|
2135
|
-
const s = qs.startsWith("?") ? qs.slice(1) : qs;
|
|
2136
|
-
if (!s)
|
|
2137
|
-
return out;
|
|
2138
|
-
for (const part of s.split("&")) {
|
|
2139
|
-
if (!part)
|
|
2140
|
-
continue;
|
|
2141
|
-
const [kRaw, vRaw = ""] = part.split("=");
|
|
2142
|
-
const K = form ? decodeFormComponent(kRaw) : decodeSafe(kRaw);
|
|
2143
|
-
const V = form ? decodeFormComponent(vRaw) : decodeSafe(vRaw);
|
|
2144
|
-
if (repeat) {
|
|
2145
|
-
((_a = out[K]) !== null && _a !== void 0 ? _a : (out[K] = [])).push(V);
|
|
2146
|
-
}
|
|
2147
|
-
else {
|
|
2148
|
-
out[K] = V;
|
|
2149
|
-
}
|
|
2150
|
-
}
|
|
2151
|
-
return out;
|
|
2152
|
-
};
|
|
2153
|
-
/** Quick helper: percent-encode whole strings for placement in URLs */
|
|
2154
|
-
const encodeTextForUrl = (text) => encode(text);
|
|
2155
|
-
/** Quick helper: decode long blobs coming from share-intents/UTMs */
|
|
2156
|
-
const decodeShareBlob = (blob) => decodeMaybeDouble(blob).replace(/\r\n/g, "\n");
|
|
2157
|
-
|
|
2158
|
-
export { API_PREFIX, BASE_URL, Button, Checkbox, DEV_PREFIX, DOMAIN_NAME, Input, MEDIA_TYPES, MIME_TYPES, 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, confirmType, confirm_type, 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, getAllFileTypes, getAllFileTypesSync, getAlphaNum, getAlphas, getAuthorizationHeader, getBaseDir, getBody, getChar, getCleanArray, getComponentsUtilsDirectory, getConfigContent, getConfigJson, getConfigVar, getDbConfigsPath, getDistDir, getDocumentProp, getEnvDir, getEnvPath, getFetchVars, getFunctionsDir, getFunctionsUtilsDirectory, getHeaders, getHooksUtilsDirectory, getHtmlDirectory, getLibUtilsDirectory, getMediaExts, getMediaMap, getMethod, getMimeType, getNums, getPublicDir, getResult, getSafeDocument, getSafeLocalStorage, getSafeWindow, getSchemasDirPath, getSchemasPath, getSrcDir, getSubstring, getToken, getWindowHost, getWindowProp, get_all_file_types, get_basename, get_dirname, get_extname, get_filename, get_full_path, get_full_url, get_key_value, get_keyword_string, get_media_exts, get_media_map, get_mime_type, get_relative_path, get_result, get_safe_path, get_splitext, get_window, get_window_location, get_window_parts, get_window_pathname, isLoggedIn, isMediaType, isNum, isStrInString, isTokenExpired, isType, is_media_type, makePath, 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 };
|
|
2089
|
+
export { API_PREFIX, BASE_URL, Button, Checkbox, DEV_PREFIX, DOMAIN_NAME, Input, MEDIA_TYPES, MIME_TYPES, PROD_PREFIX, PROTOCOL, SUB_DIR, Spinner, alertit, assureArray, assureList, assureNumber, assureString, assure_array, assure_list, assure_number, assure_string, callStorage, callWindowMethod, checkResponse, cleanArray, cleanText, confirmType, confirm_type, 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, getAllFileTypes, getAllFileTypesSync, getAlphaNum, getAlphas, getAuthorizationHeader, getBaseDir, getBody, getChar, getCleanArray, getComponentsUtilsDirectory, getConfig, getConfigContent, getConfigVar, getDbConfigsPath, getDistDir, getDocumentProp, getEnvDir, getEnvPath, getFetchVars, getFunctionsDir, getFunctionsUtilsDirectory, getHeaders, getHooksUtilsDirectory, getHtmlDirectory, getLibUtilsDirectory, getMediaExts, getMediaMap, getMethod, getMimeType, getNums, getPublicDir, getResult, getSafeDocument, getSafeLocalStorage, getSafeWindow, getSchemasDirPath, getSchemasPath, getSrcDir, getSubstring, getToken, getWindowHost, getWindowProp, get_all_file_types, get_basename, get_dirname, get_extname, get_filename, get_full_path, get_full_url, get_key_value, get_keyword_string, get_media_exts, get_media_map, get_mime_type, get_splitext, get_window, get_window_location, get_window_parts, get_window_pathname, isLoggedIn, isMediaType, isNum, isStrInString, isTokenExpired, isType, is_media_type, loadConfig, make_path, make_sanitized_path, normalizeUrl, parseResult, path_to_url, processKeywords, readJsonFile, requireToken, roundPercentage, safeDivide, safeGlobalProp, safeMultiply, safeNums, safeStorage, sanitizeFilename, stripPrefixes, truncateString, tryParse, urlJoin, url_to_path };
|
|
2159
2090
|
//# sourceMappingURL=index.js.map
|