@putkoff/abstract-utilities 1.0.103 → 1.0.113

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 (188) hide show
  1. package/dist/cjs/client.js.map +1 -1
  2. package/dist/cjs/print_utils-DzyRoj6m.js.map +1 -1
  3. package/dist/cjs/safe_storage-CJgWghnh.js.map +1 -1
  4. package/dist/esm/client.js.map +1 -1
  5. package/dist/esm/print_utils-qqcMhSul.js.map +1 -1
  6. package/dist/esm/safe_storage-CMuv35Vo.js.map +1 -1
  7. package/dist/types/client/auth/index.d.ts +1 -1
  8. package/dist/types/client/auth/index.js +3 -0
  9. package/dist/types/client/auth/src/index.d.ts +1 -1
  10. package/dist/types/client/auth/src/index.js +3 -0
  11. package/dist/types/client/auth/src/token_client.js +73 -0
  12. package/dist/types/client/fetch/src/fetch_auth.d.ts +1 -1
  13. package/dist/types/client/fetch/src/fetch_auth.js +26 -0
  14. package/dist/types/client/fetch/src/index.d.ts +1 -1
  15. package/dist/types/client/fetch/src/index.js +2 -0
  16. package/dist/types/client/index.d.ts +2 -2
  17. package/dist/types/client/index.js +4 -0
  18. package/dist/types/client/ui_utils/index.d.ts +1 -1
  19. package/dist/types/client/ui_utils/index.js +2 -0
  20. package/dist/types/client/ui_utils/src/button.js +34 -0
  21. package/dist/types/client/ui_utils/src/checkbox.js +18 -0
  22. package/dist/types/client/ui_utils/src/index.d.ts +4 -4
  23. package/dist/types/client/ui_utils/src/index.js +4 -0
  24. package/dist/types/client/ui_utils/src/input.js +18 -0
  25. package/dist/types/client/ui_utils/src/spinner.js +5 -0
  26. package/dist/types/functions/auth_utils/imports.d.ts +2 -2
  27. package/dist/types/functions/auth_utils/imports.js +1 -0
  28. package/dist/types/functions/auth_utils/index.d.ts +1 -1
  29. package/dist/types/functions/auth_utils/index.js +1 -0
  30. package/dist/types/functions/auth_utils/src/index.d.ts +1 -1
  31. package/dist/types/functions/auth_utils/src/index.js +1 -0
  32. package/dist/types/functions/auth_utils/src/jwt_core.d.ts +1 -1
  33. package/dist/types/functions/auth_utils/src/jwt_core.js +25 -0
  34. package/dist/types/functions/auth_utils/src/token_utils (Copy).d.ts +1 -1
  35. package/dist/types/functions/auth_utils/src/token_utils (Copy).js +25 -0
  36. package/dist/types/functions/auth_utils/src/token_utils.d.ts +1 -1
  37. package/dist/types/functions/auth_utils/src/token_utils.js +105 -0
  38. package/dist/types/functions/config_utils/imports.d.ts +3 -3
  39. package/dist/types/functions/config_utils/imports.js +2 -0
  40. package/dist/types/functions/config_utils/index.d.ts +1 -1
  41. package/dist/types/functions/config_utils/index.js +1 -0
  42. package/dist/types/functions/config_utils/src/config_utils.d.ts +1 -1
  43. package/dist/types/functions/config_utils/src/config_utils.js +83 -0
  44. package/dist/types/functions/config_utils/src/index.d.ts +1 -1
  45. package/dist/types/functions/config_utils/src/index.js +1 -0
  46. package/dist/types/functions/constants_utils/index.d.ts +1 -1
  47. package/dist/types/functions/constants_utils/index.js +1 -0
  48. package/dist/types/functions/constants_utils/src/constants.js +7 -0
  49. package/dist/types/functions/constants_utils/src/index.d.ts +1 -1
  50. package/dist/types/functions/constants_utils/src/index.js +1 -0
  51. package/dist/types/functions/env_utils/imports.d.ts +1 -1
  52. package/dist/types/functions/env_utils/imports.js +1 -0
  53. package/dist/types/functions/env_utils/index.d.ts +1 -1
  54. package/dist/types/functions/env_utils/index.js +1 -0
  55. package/dist/types/functions/env_utils/src/index.d.ts +1 -1
  56. package/dist/types/functions/env_utils/src/index.js +1 -0
  57. package/dist/types/functions/env_utils/src/window_utils.js +47 -0
  58. package/dist/types/functions/fetch_utils/imports.d.ts +2 -2
  59. package/dist/types/functions/fetch_utils/imports.js +1 -0
  60. package/dist/types/functions/fetch_utils/index.d.ts +1 -1
  61. package/dist/types/functions/fetch_utils/index.js +1 -0
  62. package/dist/types/functions/fetch_utils/src/fetch_utils.js +70 -0
  63. package/dist/types/functions/fetch_utils/src/index.d.ts +3 -3
  64. package/dist/types/functions/fetch_utils/src/index.js +3 -0
  65. package/dist/types/functions/fetch_utils/src/url_utils.js +86 -0
  66. package/dist/types/functions/fetch_utils/src/utils.d.ts +1 -1
  67. package/dist/types/functions/fetch_utils/src/utils.js +102 -0
  68. package/dist/types/functions/index.d.ts +17 -17
  69. package/dist/types/functions/index.js +17 -0
  70. package/dist/types/functions/inspect_utils/imports.js +1 -0
  71. package/dist/types/functions/inspect_utils/index.d.ts +2 -2
  72. package/dist/types/functions/inspect_utils/index.js +2 -0
  73. package/dist/types/functions/inspect_utils/src/caller_utils.js +28 -0
  74. package/dist/types/functions/inspect_utils/src/index.d.ts +1 -1
  75. package/dist/types/functions/inspect_utils/src/index.js +1 -0
  76. package/dist/types/functions/math_utils/bigint_utils.js +36 -0
  77. package/dist/types/functions/math_utils/constants.js +37 -0
  78. package/dist/types/functions/math_utils/conversions.d.ts +1 -1
  79. package/dist/types/functions/math_utils/conversions.js +129 -0
  80. package/dist/types/functions/math_utils/index.d.ts +6 -6
  81. package/dist/types/functions/math_utils/index.js +6 -0
  82. package/dist/types/functions/math_utils/safe_math.js +35 -0
  83. package/dist/types/functions/math_utils/scaleInterfaces.js +3 -0
  84. package/dist/types/functions/math_utils/time_utils.js +4 -0
  85. package/dist/types/functions/path_utils/imports.d.ts +2 -2
  86. package/dist/types/functions/path_utils/imports.js +27 -0
  87. package/dist/types/functions/path_utils/index.d.ts +1 -1
  88. package/dist/types/functions/path_utils/index.js +1 -0
  89. package/dist/types/functions/path_utils/src/base_dirs.js +17 -0
  90. package/dist/types/functions/path_utils/src/function_dirs.js +42 -0
  91. package/dist/types/functions/path_utils/src/index.d.ts +6 -6
  92. package/dist/types/functions/path_utils/src/index.js +6 -0
  93. package/dist/types/functions/path_utils/src/misc_dirs.js +15 -0
  94. package/dist/types/functions/path_utils/src/path_utils.js +160 -0
  95. package/dist/types/functions/path_utils/src/paths.js +12 -0
  96. package/dist/types/functions/path_utils/src/src_dirs.js +25 -0
  97. package/dist/types/functions/print_utils/imports.d.ts +1 -1
  98. package/dist/types/functions/print_utils/imports.js +1 -0
  99. package/dist/types/functions/print_utils/index.d.ts +1 -1
  100. package/dist/types/functions/print_utils/index.js +1 -0
  101. package/dist/types/functions/print_utils/src/index.d.ts +1 -1
  102. package/dist/types/functions/print_utils/src/index.js +1 -0
  103. package/dist/types/functions/print_utils/src/print_utils.js +14 -0
  104. package/dist/types/functions/read_utils/imports.d.ts +1 -1
  105. package/dist/types/functions/read_utils/imports.js +1 -0
  106. package/dist/types/functions/read_utils/index.d.ts +1 -1
  107. package/dist/types/functions/read_utils/index.js +1 -0
  108. package/dist/types/functions/read_utils/src/index.d.ts +3 -3
  109. package/dist/types/functions/read_utils/src/index.js +3 -0
  110. package/dist/types/functions/read_utils/src/readJsonFile.browser.js +26 -0
  111. package/dist/types/functions/read_utils/src/readJsonFile.js +35 -0
  112. package/dist/types/functions/read_utils/src/readJsonFile.node.js +13 -0
  113. package/dist/types/functions/rndm_utils/imports.d.ts +1 -0
  114. package/dist/types/functions/rndm_utils/imports.js +1 -0
  115. package/dist/types/functions/rndm_utils/index.d.ts +1 -1
  116. package/dist/types/functions/rndm_utils/index.js +1 -0
  117. package/dist/types/functions/rndm_utils/src/index.d.ts +1 -1
  118. package/dist/types/functions/rndm_utils/src/index.js +1 -0
  119. package/dist/types/functions/rndm_utils/src/utils.js +12 -0
  120. package/dist/types/functions/safe_utils/imports.d.ts +1 -1
  121. package/dist/types/functions/safe_utils/imports.js +1 -0
  122. package/dist/types/functions/safe_utils/index.d.ts +1 -1
  123. package/dist/types/functions/safe_utils/index.js +1 -0
  124. package/dist/types/functions/safe_utils/src/index.d.ts +4 -4
  125. package/dist/types/functions/safe_utils/src/index.js +4 -0
  126. package/dist/types/functions/safe_utils/src/safe_document.js +12 -0
  127. package/dist/types/functions/safe_utils/src/safe_globals.js +14 -0
  128. package/dist/types/functions/safe_utils/src/safe_storage.js +50 -0
  129. package/dist/types/functions/safe_utils/src/safe_window.js +42 -0
  130. package/dist/types/functions/size_utils/index.d.ts +1 -1
  131. package/dist/types/functions/size_utils/index.js +1 -0
  132. package/dist/types/functions/size_utils/src/index.d.ts +1 -1
  133. package/dist/types/functions/size_utils/src/index.js +1 -0
  134. package/dist/types/functions/size_utils/src/sizeUtils.js +44 -0
  135. package/dist/types/functions/string_utils/index.d.ts +1 -1
  136. package/dist/types/functions/string_utils/index.js +1 -0
  137. package/dist/types/functions/string_utils/src/index.d.ts +2 -2
  138. package/dist/types/functions/string_utils/src/index.js +2 -0
  139. package/dist/types/functions/string_utils/src/quote_utils.js +17 -0
  140. package/dist/types/functions/string_utils/src/string_utils.js +186 -0
  141. package/dist/types/functions/type_utils/imports.d.ts +1 -0
  142. package/dist/types/functions/type_utils/imports.js +1 -0
  143. package/dist/types/functions/type_utils/index.d.ts +1 -1
  144. package/dist/types/functions/type_utils/index.js +1 -0
  145. package/dist/types/functions/type_utils/src/clean_utils.js +38 -0
  146. package/dist/types/functions/type_utils/src/ensure_utils.js +84 -0
  147. package/dist/types/functions/type_utils/src/imports.d.ts +1 -0
  148. package/dist/types/functions/type_utils/src/imports.js +1 -0
  149. package/dist/types/functions/type_utils/src/index.d.ts +6 -6
  150. package/dist/types/functions/type_utils/src/index.js +6 -0
  151. package/dist/types/functions/type_utils/src/json_utils.js +93 -0
  152. package/dist/types/functions/type_utils/src/list_utils.js +83 -0
  153. package/dist/types/functions/type_utils/src/mime_utils.js +314 -0
  154. package/dist/types/functions/type_utils/src/null_utils.js +21 -0
  155. package/dist/types/functions/type_utils/src/type_utils.js +39 -0
  156. package/dist/types/functions/variable_utils/imports.d.ts +1 -1
  157. package/dist/types/functions/variable_utils/imports.js +1 -0
  158. package/dist/types/functions/variable_utils/index.d.ts +1 -1
  159. package/dist/types/functions/variable_utils/index.js +1 -0
  160. package/dist/types/functions/variable_utils/src/index.d.ts +1 -1
  161. package/dist/types/functions/variable_utils/src/index.js +1 -0
  162. package/dist/types/functions/variable_utils/src/variable_utils.js +34 -0
  163. package/dist/types/index.d.ts +2 -2
  164. package/dist/types/index.js +2 -0
  165. package/dist/types/server/index.d.ts +1 -1
  166. package/dist/types/server/index.js +2 -0
  167. package/dist/types/server/src/index.d.ts +1 -1
  168. package/dist/types/server/src/index.js +2 -0
  169. package/dist/types/server/src/mime_utils.js +314 -0
  170. package/dist/types/types/index.d.ts +1 -1
  171. package/dist/types/types/index.js +1 -0
  172. package/dist/types/types/path-browserify.d.ts +3 -2
  173. package/dist/types/types/path-browserify.js +1 -0
  174. package/dist/types/types/src/Files.js +1 -0
  175. package/dist/types/types/src/index.d.ts +4 -4
  176. package/dist/types/types/src/index.js +4 -0
  177. package/dist/types/types/src/login.js +1 -0
  178. package/dist/types/types/src/logout.js +1 -0
  179. package/dist/types/types/src/utils.js +1 -0
  180. package/dist/types/utils/imports.d.ts +1 -1
  181. package/dist/types/utils/imports.js +1 -0
  182. package/dist/types/utils/index.d.ts +1 -1
  183. package/dist/types/utils/index.js +1 -0
  184. package/dist/types/utils/src/Input.js +2 -0
  185. package/dist/types/utils/src/config.js +27 -0
  186. package/dist/types/utils/src/index.d.ts +2 -2
  187. package/dist/types/utils/src/index.js +2 -0
  188. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
- export * from './safe_math';
2
- export * from './conversions';
3
- export * from './constants';
4
- export * from './scaleInterfaces';
5
- export * from './time_utils';
6
- export * from './bigint_utils';
1
+ export * from './safe_math.js';
2
+ export * from './conversions.js';
3
+ export * from './constants.js';
4
+ export * from './scaleInterfaces.js';
5
+ export * from './time_utils.js';
6
+ export * from './bigint_utils.js';
@@ -0,0 +1,6 @@
1
+ export * from './safe_math';
2
+ export * from './conversions';
3
+ export * from './constants';
4
+ export * from './scaleInterfaces';
5
+ export * from './time_utils';
6
+ export * from './bigint_utils';
@@ -0,0 +1,35 @@
1
+ import { ensure_number } from './../type_utils';
2
+ // take N args and coerce them all to numbers
3
+ export function safeNums(...args) {
4
+ return args.map(ensure_number);
5
+ }
6
+ // divide the first value by each of the following
7
+ export function safeDivide(...args) {
8
+ const [head, ...rest] = safeNums(...args);
9
+ // if we don’t have a head or any divisor is zero, bail
10
+ if (head === 0 || rest.some((d) => d === 0))
11
+ return 0;
12
+ return rest.reduce((acc, d) => acc / d, head);
13
+ }
14
+ // multiply all the values together
15
+ export function safeMultiply(...args) {
16
+ const nums = safeNums(...args);
17
+ // if any number is zero, result is zero
18
+ if (nums.includes(0))
19
+ return 0;
20
+ return nums.reduce((acc, n) => acc * n, 1);
21
+ }
22
+ // round a value to two decimals by percent
23
+ export function roundPercentage(x) {
24
+ const pct = safeMultiply(ensure_number(x), 100);
25
+ return safeDivide(Math.round(pct), 100);
26
+ }
27
+ export function exponential(i, k) {
28
+ return i * (10 ** (k));
29
+ }
30
+ export function isZero(obj) {
31
+ if (obj == 0) {
32
+ return true;
33
+ }
34
+ return false;
35
+ }
@@ -0,0 +1,3 @@
1
+ // DO NOT import TimeUnit from chart.js
2
+ // import { TimeUnit } from 'chart.js' // ❌ remove
3
+ export {};
@@ -0,0 +1,4 @@
1
+ // Function to check time interval
2
+ export function isTimeInterval(timeObj, interval) {
3
+ return (Date.now() / 1000 - timeObj) < (interval - 1);
4
+ }
@@ -16,6 +16,6 @@ export { _url as url };
16
16
  * If you only ever need to strip off “file://” in development, this is enough.
17
17
  */
18
18
  export declare function fileURLToPath(fileUrl: string): string;
19
- export { eatOuter, eatInner } from './../string_utils';
20
- export { ensure_list } from './../type_utils';
19
+ export { eatOuter, eatInner } from './../string_utils/index.js';
20
+ export { ensure_list } from './../type_utils/index.js';
21
21
  export declare function getAbsolutePath(): string;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * In the browser we already have a WHATWG URL constructor on window.
3
+ * Here we re-export it as “url” so other modules can import it.
4
+ */
5
+ const _url = typeof window !== 'undefined' ? window.URL : undefined;
6
+ export { _url as url };
7
+ /**
8
+ * Minimal fileURLToPath implementation for browser-side code.
9
+ * If you only ever need to strip off “file://” in development, this is enough.
10
+ */
11
+ export function fileURLToPath(fileUrl) {
12
+ // e.g. fileUrl = "file:///Users/foo/bar.txt"
13
+ try {
14
+ const u = new URL(fileUrl);
15
+ return u.pathname;
16
+ }
17
+ catch (_a) {
18
+ // fallback: just strip file://
19
+ return fileUrl.replace(/^file:\/\//, '');
20
+ }
21
+ }
22
+ export { eatOuter, eatInner } from './../string_utils';
23
+ export { ensure_list } from './../type_utils';
24
+ export function getAbsolutePath() {
25
+ return fileURLToPath(import.meta.url);
26
+ }
27
+ ;
@@ -1 +1 @@
1
- export * from './src';
1
+ export * from './src/index.js';
@@ -0,0 +1 @@
1
+ export * from './src';
@@ -0,0 +1,17 @@
1
+ import { make_path, get_dirname } from './path_utils';
2
+ import { getSrcDir } from './src_dirs';
3
+ export function getBaseDir() {
4
+ return get_dirname(getSrcDir());
5
+ }
6
+ export function getPublicDir() {
7
+ return make_path(getBaseDir(), 'public');
8
+ }
9
+ ;
10
+ export function getDistDir() {
11
+ return make_path(getBaseDir(), 'dist');
12
+ }
13
+ ;
14
+ export function getEnvDir() {
15
+ return make_path(getBaseDir(), '.env');
16
+ }
17
+ ;
@@ -0,0 +1,42 @@
1
+ import { make_path, get_dirname } from './path_utils';
2
+ import { getAbsDir } from './paths';
3
+ export function getFunctionsDir() {
4
+ return get_dirname(getAbsDir());
5
+ }
6
+ ;
7
+ export function geAuthsUtilsDirectory() {
8
+ return make_path(getFunctionsDir(), 'auths');
9
+ }
10
+ ;
11
+ export function geBackupsUtilsDirectory() {
12
+ return make_path(getFunctionsDir(), 'backups');
13
+ }
14
+ ;
15
+ export function geConstantsUtilsDirectory() {
16
+ return make_path(getFunctionsDir(), 'constants');
17
+ }
18
+ ;
19
+ export function geEnvUtilsDirectory() {
20
+ return make_path(getFunctionsDir(), 'env_utils');
21
+ }
22
+ ;
23
+ export function geFetchUtilsDirectory() {
24
+ return make_path(getFunctionsDir(), 'fetch_utils');
25
+ }
26
+ ;
27
+ export function geFileUtilsDirectory() {
28
+ return make_path(getFunctionsDir(), 'file_utils');
29
+ }
30
+ ;
31
+ export function gePathUtilsDirectory() {
32
+ return make_path(getFunctionsDir(), 'path_utils');
33
+ }
34
+ ;
35
+ export function geStringUtilsDirectory() {
36
+ return make_path(getFunctionsDir(), 'string_utils');
37
+ }
38
+ ;
39
+ export function geTypeUtilsDirectory() {
40
+ return make_path(getFunctionsDir(), 'type_utils');
41
+ }
42
+ ;
@@ -1,6 +1,6 @@
1
- export * from './path_utils';
2
- export * from './paths';
3
- export * from './function_dirs';
4
- export * from './src_dirs';
5
- export * from './base_dirs';
6
- export * from './misc_dirs';
1
+ export * from './path_utils.js';
2
+ export * from './paths.js';
3
+ export * from './function_dirs.js';
4
+ export * from './src_dirs.js';
5
+ export * from './base_dirs.js';
6
+ export * from './misc_dirs.js';
@@ -0,0 +1,6 @@
1
+ export * from './path_utils';
2
+ export * from './paths';
3
+ export * from './function_dirs';
4
+ export * from './src_dirs';
5
+ export * from './base_dirs';
6
+ export * from './misc_dirs';
@@ -0,0 +1,15 @@
1
+ import { getBaseDir, getEnvDir } from './base_dirs';
2
+ import { make_path } from './path_utils';
3
+ export function getEnvPath(string = '.env') {
4
+ return make_path(getEnvDir(), string);
5
+ }
6
+ ;
7
+ export function getDbConfigsPath() {
8
+ return make_path(getBaseDir(), 'dbConfigs');
9
+ }
10
+ export function getSchemasPath() {
11
+ return make_path(getDbConfigsPath(), 'schemas');
12
+ }
13
+ export function getSchemasDirPath(subPath) {
14
+ return make_path(getSchemasPath(), subPath);
15
+ }
@@ -0,0 +1,160 @@
1
+ import * as path from 'path-browserify';
2
+ import { eatOuter, eatInner, ensure_list } from './../imports';
3
+ export function get_dirname(filePath) {
4
+ if (!filePath)
5
+ return '';
6
+ return path.dirname(filePath);
7
+ }
8
+ export function get_basename(filePath) {
9
+ if (!filePath)
10
+ return '';
11
+ return path.basename(filePath);
12
+ }
13
+ export function get_filename(filePath) {
14
+ if (!filePath)
15
+ return '';
16
+ const ext = path.extname(filePath);
17
+ return path.basename(filePath, ext);
18
+ }
19
+ export function get_extname(filePath) {
20
+ if (!filePath)
21
+ return '';
22
+ return path.extname(filePath);
23
+ }
24
+ export function get_splitext(filePath) {
25
+ if (!filePath)
26
+ return { filename: '', extname: '' };
27
+ const ext = path.extname(filePath);
28
+ // Get the basename without the extension
29
+ const filename = path.basename(filePath, ext);
30
+ return { filename, ext };
31
+ }
32
+ /**
33
+ * Returns the path of `targetPath` relative to `basePath`.
34
+ * Normalizes separators for consistent web and server environments.
35
+ *
36
+ * @param basePath - The base directory you want to compare from.
37
+ * @param targetPath - The full path of the file/directory.
38
+ * @returns A normalized relative path (e.g., "subdir/file.txt").
39
+ */
40
+ export function get_relative_path(basePath, targetPath) {
41
+ try {
42
+ // Compute the relative path using Node's native path.relative
43
+ let rel = path.relative(basePath, targetPath);
44
+ // Normalize to POSIX-style slashes for consistency (especially on Windows)
45
+ rel = rel.split(path.sep).join('/');
46
+ // Avoid empty string (happens if both paths are identical)
47
+ return rel || '.';
48
+ }
49
+ catch (err) {
50
+ console.error(`[get_relative_path] Error computing relative path`, err);
51
+ return targetPath;
52
+ }
53
+ }
54
+ /**
55
+ * Join multiple path segments — clean, predictable, bulletproof.
56
+ *
57
+ * Accepts ANYTHING that ensure_list can handle:
58
+ * • 'a,b,c'
59
+ * • ['a', 'b,c']
60
+ * • 'a/b/c'
61
+ * • '/a/', 'b//c'
62
+ * • mixed arrays, comma strings, whatever
63
+ *
64
+ * Always returns a clean POSIX path string. Never a list.
65
+ */
66
+ export function make_path(...parts) {
67
+ // Normalize incoming segments into a flat list
68
+ const segments = ensure_list(parts).map(x => String(x));
69
+ let out = "";
70
+ for (let i = 0; i < segments.length; i++) {
71
+ const seg = segments[i];
72
+ // Normalize a segment:
73
+ let cleaned = eatOuter(seg, "/"); // trim trailing slashes
74
+ if (!cleaned)
75
+ continue;
76
+ if (out === "") {
77
+ out = cleaned;
78
+ }
79
+ else {
80
+ cleaned = eatInner(cleaned, "/"); // trim leading slashes
81
+ out = `${out}/${cleaned}`;
82
+ }
83
+ }
84
+ return out;
85
+ }
86
+ export function sanitizeFilename(filename) {
87
+ return filename
88
+ .toLowerCase()
89
+ .replace(/\s+|-/g, '-') // Replace spaces and hyphens with single hyphen
90
+ .replace(/_/g, '-') // Replace underscores with hyphens
91
+ .replace(/[^a-z0-9-.]/g, '') // Remove all non-alphanumeric chars except hyphen and dot
92
+ .replace(/-+/g, '-') // Collapse multiple hyphens into one
93
+ .replace(/^-|-$/, ''); // Remove leading/trailing hyphens
94
+ }
95
+ export function make_sanitized_path(...paths) {
96
+ let real_path = '';
97
+ for (let i = 0; i < paths.length; i++) {
98
+ const sanitized = sanitizeFilename(eatOuter(paths[i], '/'));
99
+ if (i === 0) {
100
+ real_path = sanitized;
101
+ }
102
+ else if (sanitized) { // Only append if there's a non-empty segment
103
+ real_path = `${real_path}/${sanitized}`;
104
+ }
105
+ }
106
+ return real_path || '';
107
+ }
108
+ export function normalizeUrl(base, p) {
109
+ if (!p)
110
+ return base;
111
+ const cleanBase = base.replace(/\/+$/, ''); // regex literal
112
+ const cleanPath = p.replace(/^\/+/, '');
113
+ // collapse multiple “//” into one, but keep the “://” after protocol
114
+ return `${cleanBase}/${cleanPath}`.replace(/([^:])\/{2,}/g, '$1/');
115
+ }
116
+ export function pathjoin(...parts) {
117
+ return make_path(...parts);
118
+ }
119
+ export function pathJoin(...parts) {
120
+ return make_path(...parts);
121
+ }
122
+ export function makepath(...parts) {
123
+ return make_path(...parts);
124
+ }
125
+ export function makePath(...parts) {
126
+ return make_path(...parts);
127
+ }
128
+ export function path_join(...parts) {
129
+ return make_path(...parts);
130
+ }
131
+ export function getSplitext(filePath) {
132
+ return get_splitext(filePath);
133
+ }
134
+ export function getsplitext(filePath) {
135
+ return get_splitext(filePath);
136
+ }
137
+ export function getextname(filePath) {
138
+ return get_extname(filePath);
139
+ }
140
+ export function getExtname(filePath) {
141
+ return get_extname(filePath);
142
+ }
143
+ export function getfilename(filePath) {
144
+ return get_filename(filePath);
145
+ }
146
+ export function getFilename(filePath) {
147
+ return get_filename(filePath);
148
+ }
149
+ export function getbasename(filePath) {
150
+ return get_basename(filePath);
151
+ }
152
+ export function getBasename(filePath) {
153
+ return get_basename(filePath);
154
+ }
155
+ export function getdirname(filePath) {
156
+ return get_dirname(filePath);
157
+ }
158
+ export function getDirname(filePath) {
159
+ return get_dirname(filePath);
160
+ }
@@ -0,0 +1,12 @@
1
+ import { getAbsolutePath } from './../imports';
2
+ import { get_dirname, make_path } from './path_utils';
3
+ /**
4
+ * Returns the absolute path of the current file.
5
+ */
6
+ export function getAbsDir() {
7
+ return get_dirname(getAbsolutePath());
8
+ }
9
+ ;
10
+ export function getAbsPath(subPath) {
11
+ return make_path(getAbsDir(), subPath);
12
+ }
@@ -0,0 +1,25 @@
1
+ import { make_path, get_dirname } from './path_utils';
2
+ import { getFunctionsDir } from './function_dirs';
3
+ export function getSrcDir() {
4
+ return get_dirname(getFunctionsDir());
5
+ }
6
+ ;
7
+ export function geStaticDirectory() {
8
+ return make_path(getSrcDir(), 'static');
9
+ }
10
+ ;
11
+ export function getLibUtilsDirectory() {
12
+ return make_path(getSrcDir(), 'lib');
13
+ }
14
+ export function getHooksUtilsDirectory() {
15
+ return make_path(getSrcDir(), 'hooks');
16
+ }
17
+ ;
18
+ export function getFunctionsUtilsDirectory() {
19
+ return make_path(getSrcDir(), 'functions');
20
+ }
21
+ ;
22
+ export function getComponentsUtilsDirectory() {
23
+ return make_path(getSrcDir(), 'components');
24
+ }
25
+ ;
@@ -1 +1 @@
1
- export * from './../inspect_utils';
1
+ export * from './../inspect_utils/index.js';
@@ -0,0 +1 @@
1
+ export * from './../inspect_utils';
@@ -1 +1 @@
1
- export * from './src';
1
+ export * from './src/index.js';
@@ -0,0 +1 @@
1
+ export * from './src';
@@ -1 +1 @@
1
- export * from './print_utils';
1
+ export * from './print_utils.js';
@@ -0,0 +1 @@
1
+ export * from './print_utils';
@@ -0,0 +1,14 @@
1
+ import { getLastCaller, inspect } from './../imports';
2
+ export function debugPrint(value, label = null) {
3
+ const caller = getLastCaller();
4
+ const header = label !== null && label !== void 0 ? label : (caller
5
+ ? `${caller.functionName} @ ${caller.file}:${caller.line}`
6
+ : "object");
7
+ console.log(`\n🔍 ${header}`);
8
+ console.log(inspect(value, {
9
+ depth: null,
10
+ colors: true,
11
+ compact: false,
12
+ maxArrayLength: null,
13
+ }));
14
+ }
@@ -1 +1 @@
1
- export { safeGlobalProp } from './../safe_utils';
1
+ export { safeGlobalProp } from './../safe_utils/index.js';
@@ -0,0 +1 @@
1
+ export { safeGlobalProp } from './../safe_utils';
@@ -1 +1 @@
1
- export * from './src';
1
+ export * from './src/index.js';
@@ -0,0 +1 @@
1
+ export * from './src';
@@ -1,3 +1,3 @@
1
- export * from './readJsonFile.browser';
2
- export * from './readJsonFile.node';
3
- export * from './readJsonFile';
1
+ export * from './readJsonFile.browser.js';
2
+ export * from './readJsonFile.node.js';
3
+ export * from './readJsonFile.js';
@@ -0,0 +1,3 @@
1
+ export * from './readJsonFile.browser';
2
+ export * from './readJsonFile.node';
3
+ export * from './readJsonFile';
@@ -0,0 +1,26 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { safeGlobalProp } from "./../imports";
11
+ export function readJsonFileBrowser(url) {
12
+ return __awaiter(this, void 0, void 0, function* () {
13
+ const fetchFn = safeGlobalProp("fetch");
14
+ if (typeof fetchFn !== "function")
15
+ return null;
16
+ try {
17
+ const res = yield fetchFn(url);
18
+ if (!res.ok)
19
+ return null;
20
+ return (yield res.json());
21
+ }
22
+ catch (_a) {
23
+ return null;
24
+ }
25
+ });
26
+ }
@@ -0,0 +1,35 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ export function readJsonFile(relativeOrAbsolutePath) {
11
+ return __awaiter(this, void 0, void 0, function* () {
12
+ var _a;
13
+ if (typeof process !== "undefined" && ((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node)) {
14
+ const mod = yield import("./readJsonFile.node");
15
+ return mod.readJsonFileNode(relativeOrAbsolutePath);
16
+ }
17
+ else {
18
+ const mod = yield import("./readJsonFile.browser");
19
+ return mod.readJsonFileBrowser(relativeOrAbsolutePath);
20
+ }
21
+ });
22
+ }
23
+ export function getConfigContent() {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ try {
26
+ // `readJsonFile` should throw if the file isn’t there or isn’t valid JSON
27
+ const cfg = yield readJsonFile('./config.json');
28
+ return cfg;
29
+ }
30
+ catch (_a) {
31
+ // swallow errors & return null so callers can detect “no config”
32
+ return null;
33
+ }
34
+ });
35
+ }
@@ -0,0 +1,13 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { resolve, isAbsolute } from "node:path";
3
+ export function readJsonFileNode(relativeOrAbsolutePath) {
4
+ try {
5
+ const filePath = isAbsolute(relativeOrAbsolutePath)
6
+ ? relativeOrAbsolutePath
7
+ : resolve(process.cwd(), relativeOrAbsolutePath);
8
+ return JSON.parse(readFileSync(filePath, "utf8"));
9
+ }
10
+ catch (_a) {
11
+ return null;
12
+ }
13
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ "use strict";
@@ -1 +1 @@
1
- export * from './src';
1
+ export * from './src/index.js';
@@ -0,0 +1 @@
1
+ export * from './src';
@@ -1 +1 @@
1
- export * from './utils';
1
+ export * from './utils.js';
@@ -0,0 +1 @@
1
+ export * from './utils';
@@ -0,0 +1,12 @@
1
+ // src/functions/rndm_utils/utils.ts
2
+ export function alertit(obj = null) {
3
+ let msg;
4
+ try {
5
+ msg = JSON.stringify(obj);
6
+ }
7
+ catch (_a) {
8
+ // If JSON.stringify fails (circular refs, etc.), fall back to a simple string
9
+ msg = String(obj);
10
+ }
11
+ alert(msg);
12
+ }
@@ -1 +1 @@
1
- export * from './src';
1
+ export * from './src/index.js';
@@ -0,0 +1 @@
1
+ export * from './src';
@@ -1 +1 @@
1
- export * from './src';
1
+ export * from './src/index.js';
@@ -0,0 +1 @@
1
+ export * from './src';
@@ -1,4 +1,4 @@
1
- export * from './safe_document';
2
- export * from './safe_storage';
3
- export * from './safe_globals';
4
- export * from './safe_window';
1
+ export * from './safe_document.js';
2
+ export * from './safe_storage.js';
3
+ export * from './safe_globals.js';
4
+ export * from './safe_window.js';
@@ -0,0 +1,4 @@
1
+ export * from './safe_document';
2
+ export * from './safe_storage';
3
+ export * from './safe_globals';
4
+ export * from './safe_window';
@@ -0,0 +1,12 @@
1
+ export function getSafeDocument() {
2
+ return typeof document !== 'undefined' ? document : undefined;
3
+ }
4
+ export function getDocumentProp(...keys) {
5
+ let obj = getSafeDocument();
6
+ for (const k of keys) {
7
+ if (obj == null || typeof obj !== 'object')
8
+ return undefined;
9
+ obj = obj[k];
10
+ }
11
+ return obj;
12
+ }