@putkoff/abstract-utilities 1.0.102 → 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 +13 -2
@@ -0,0 +1,314 @@
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
+ // mediaTypes.ts
11
+ import * as fs from "node:fs";
12
+ import * as fsp from "node:fs/promises";
13
+ import * as path from "node:path";
14
+ /** ---- Data: large but explicit, mirrors your Python mapping ---- */
15
+ export const MIME_TYPES = {
16
+ image: {
17
+ ".jpg": "image/jpeg",
18
+ ".jpeg": "image/jpeg",
19
+ ".png": "image/png",
20
+ ".gif": "image/gif",
21
+ ".bmp": "image/bmp",
22
+ ".tiff": "image/tiff",
23
+ ".webp": "image/webp",
24
+ ".svg": "image/svg+xml",
25
+ ".ico": "image/vnd.microsoft.icon",
26
+ ".heic": "image/heic",
27
+ ".psd": "image/vnd.adobe.photoshop",
28
+ ".raw": "image/x-raw",
29
+ },
30
+ video: {
31
+ ".mp4": "video/mp4",
32
+ ".webm": "video/webm",
33
+ ".ogg": "video/ogg",
34
+ ".mov": "video/quicktime",
35
+ ".avi": "video/x-msvideo",
36
+ ".mkv": "video/x-matroska",
37
+ ".flv": "video/x-flv",
38
+ ".wmv": "video/x-ms-wmv",
39
+ ".3gp": "video/3gpp",
40
+ ".ts": "video/mp2t",
41
+ ".mpeg": "video/mpeg",
42
+ ".mpg": "video/mpg",
43
+ },
44
+ audio: {
45
+ ".mp3": "audio/mpeg",
46
+ ".wav": "audio/wav",
47
+ ".flac": "audio/flac",
48
+ ".aac": "audio/aac",
49
+ ".ogg": "audio/ogg",
50
+ ".m4a": "audio/mp4",
51
+ ".opus": "audio/opus",
52
+ },
53
+ document: {
54
+ ".pdf": "application/pdf",
55
+ ".doc": "application/msword",
56
+ ".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
57
+ ".odt": "application/vnd.oasis.opendocument.text",
58
+ ".txt": "text/plain",
59
+ ".rtf": "application/rtf",
60
+ ".md": "text/markdown",
61
+ ".markdown": "text/markdown",
62
+ ".tex": "application/x-tex",
63
+ ".log": "text/plain",
64
+ ".json": "application/json",
65
+ ".xml": "application/xml",
66
+ ".yaml": "application/x-yaml",
67
+ ".yml": "application/x-yaml",
68
+ ".ini": "text/plain",
69
+ ".cfg": "text/plain",
70
+ ".toml": "application/toml",
71
+ ".csv": "text/csv",
72
+ ".tsv": "text/tab-separated-values",
73
+ },
74
+ presentation: {
75
+ ".ppt": "application/vnd.ms-powerpoint",
76
+ ".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
77
+ ".odp": "application/vnd.oasis.opendocument.presentation",
78
+ },
79
+ spreadsheet: {
80
+ ".xls": "application/vnd.ms-excel",
81
+ ".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
82
+ ".ods": "application/vnd.oasis.opendocument.spreadsheet",
83
+ ".csv": "text/csv",
84
+ ".tsv": "text/tab-separated-values",
85
+ },
86
+ code: {
87
+ ".py": "text/x-python",
88
+ ".java": "text/x-java-source",
89
+ ".c": "text/x-c",
90
+ ".cpp": "text/x-c++",
91
+ ".h": "text/x-c",
92
+ ".hpp": "text/x-c++",
93
+ ".js": "application/javascript",
94
+ ".cjs": "application/javascript",
95
+ ".mjs": "application/javascript",
96
+ ".jsx": "application/javascript",
97
+ ".ts": "application/typescript",
98
+ ".tsx": "application/typescript",
99
+ ".rb": "text/x-ruby",
100
+ ".php": "application/x-php",
101
+ ".go": "text/x-go",
102
+ ".rs": "text/rust",
103
+ ".swift": "text/x-swift",
104
+ ".kt": "text/x-kotlin",
105
+ ".sh": "application/x-shellscript",
106
+ ".bash": "application/x-shellscript",
107
+ ".ps1": "application/x-powershell",
108
+ ".sql": "application/sql",
109
+ ".yml": "application/x-yaml",
110
+ ".coffee": "text/coffeescript",
111
+ ".lua": "text/x-lua",
112
+ },
113
+ archive: {
114
+ ".zip": "application/zip",
115
+ ".tar": "application/x-tar",
116
+ ".gz": "application/gzip",
117
+ ".tgz": "application/gzip",
118
+ ".bz2": "application/x-bzip2",
119
+ ".xz": "application/x-xz",
120
+ ".rar": "application/vnd.rar",
121
+ ".7z": "application/x-7z-compressed",
122
+ ".iso": "application/x-iso9660-image",
123
+ ".dmg": "application/x-apple-diskimage",
124
+ ".jar": "application/java-archive",
125
+ ".war": "application/java-archive",
126
+ ".whl": "application/python-wheel",
127
+ ".egg": "application/python-egg",
128
+ },
129
+ font: {
130
+ ".ttf": "font/ttf",
131
+ ".otf": "font/otf",
132
+ ".woff": "font/woff",
133
+ ".woff2": "font/woff2",
134
+ ".eot": "application/vnd.ms-fontobject",
135
+ },
136
+ executable: {
137
+ ".exe": "application/vnd.microsoft.portable-executable",
138
+ ".dll": "application/vnd.microsoft.portable-executable",
139
+ ".bin": "application/octet-stream",
140
+ ".deb": "application/vnd.debian.binary-package",
141
+ ".rpm": "application/x-rpm",
142
+ },
143
+ };
144
+ /** Mirror of MEDIA_TYPES in Python: category -> Set of extensions */
145
+ export const MEDIA_TYPES = Object.fromEntries(Object.entries(MIME_TYPES).map(([cat, mapping]) => [
146
+ cat,
147
+ new Set(Object.keys(mapping)),
148
+ ]));
149
+ /** ---- Helpers ---- */
150
+ function toCategorySet(categories) {
151
+ const allCats = new Set(Object.keys(MIME_TYPES));
152
+ if (!categories) {
153
+ // all categories
154
+ return new Set(allCats);
155
+ }
156
+ const out = new Set();
157
+ for (const c of categories) {
158
+ const key = String(c);
159
+ if (allCats.has(key))
160
+ out.add(key);
161
+ }
162
+ return out.size ? out : new Set(allCats);
163
+ }
164
+ function normalizeCategories(categories, opts) {
165
+ var _a;
166
+ const selected = (_a = categories !== null && categories !== void 0 ? categories : opts === null || opts === void 0 ? void 0 : opts.media_types) !== null && _a !== void 0 ? _a : null;
167
+ return toCategorySet(selected);
168
+ }
169
+ function extOf(input) {
170
+ // Behaves like pathlib.Path(...).suffix.lower(): last extension only; lowercased.
171
+ let ext = path.extname(input || "");
172
+ if (!ext && input && input.startsWith(".")) {
173
+ // user passed ".jpg" directly
174
+ ext = input;
175
+ }
176
+ return (ext || "").toLowerCase();
177
+ }
178
+ function unionExts(categories) {
179
+ const out = new Set();
180
+ for (const c of categories) {
181
+ const set = MEDIA_TYPES[c];
182
+ for (const e of set)
183
+ out.add(e);
184
+ }
185
+ return out;
186
+ }
187
+ /** ---- API (Python parity) ---- */
188
+ /**
189
+ * Return a sub-map of MEDIA_TYPES for the given categories.
190
+ * If categories is falsy, returns all categories.
191
+ */
192
+ export function getMediaMap(categories, opts) {
193
+ const cats = normalizeCategories(categories, opts);
194
+ const result = {};
195
+ for (const c of cats)
196
+ result[c] = new Set(MEDIA_TYPES[c]);
197
+ return result;
198
+ }
199
+ /**
200
+ * Return a flat, sorted list of all extensions for the given categories.
201
+ */
202
+ export function getMediaExts(categories, opts) {
203
+ const cats = normalizeCategories(categories, opts);
204
+ return Array.from(unionExts(cats)).sort();
205
+ }
206
+ /**
207
+ * Given a file path or extension, return its media category (e.g. "image") or null.
208
+ * Mirrors Python's confirm_type.
209
+ */
210
+ export function confirmType(pathOrExt, categories, opts) {
211
+ const cats = normalizeCategories(categories, opts);
212
+ const ext = extOf(pathOrExt);
213
+ // Preserve object insertion order like Python dict iteration
214
+ for (const [category, exts] of Object.entries(MEDIA_TYPES)) {
215
+ if (!cats.has(category))
216
+ continue;
217
+ if (ext && exts.has(ext))
218
+ return category;
219
+ }
220
+ return null;
221
+ }
222
+ /**
223
+ * True if the given file path or extension belongs to one of the categories.
224
+ */
225
+ export function isMediaType(pathOrExt, categories, opts) {
226
+ return confirmType(pathOrExt, categories, opts) !== null;
227
+ }
228
+ /**
229
+ * Look up the MIME type by extension; fall back to 'application/octet-stream'.
230
+ */
231
+ export function getMimeType(pathOrExt) {
232
+ const ext = extOf(pathOrExt);
233
+ for (const mapping of Object.values(MIME_TYPES)) {
234
+ if (ext && mapping[ext]) {
235
+ return mapping[ext];
236
+ }
237
+ }
238
+ return "application/octet-stream";
239
+ }
240
+ export function getAllFileTypesSync(directory, categories, opts) {
241
+ // 🧩 Skip entirely if fs isn't available
242
+ if (!fs || !path)
243
+ return [];
244
+ try {
245
+ const stat = fs.statSync(directory);
246
+ if (!stat.isDirectory())
247
+ return [];
248
+ const cats = normalizeCategories(categories, opts);
249
+ const wanted = unionExts(cats);
250
+ const results = [];
251
+ function walkSync(dir) {
252
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
253
+ for (const ent of entries) {
254
+ const full = path.join(dir, ent.name);
255
+ if (ent.isDirectory()) {
256
+ walkSync(full);
257
+ }
258
+ else if (ent.isFile()) {
259
+ const ext = path.extname(ent.name).toLowerCase();
260
+ if (wanted.has(ext))
261
+ results.push(full);
262
+ }
263
+ }
264
+ }
265
+ walkSync(directory);
266
+ return results;
267
+ }
268
+ catch (_a) {
269
+ return [];
270
+ }
271
+ }
272
+ export function getAllFileTypes(directory, categories, opts) {
273
+ return __awaiter(this, void 0, void 0, function* () {
274
+ // 🧩 Skip entirely if fsp isn't available
275
+ if (!fsp || !path)
276
+ return [];
277
+ try {
278
+ const stat = yield fsp.stat(directory);
279
+ if (!stat.isDirectory())
280
+ return [];
281
+ const cats = normalizeCategories(categories, opts);
282
+ const wanted = unionExts(cats);
283
+ const results = [];
284
+ function walkAsync(dir) {
285
+ return __awaiter(this, void 0, void 0, function* () {
286
+ const entries = yield fsp.readdir(dir, { withFileTypes: true });
287
+ for (const ent of entries) {
288
+ const full = path.join(dir, ent.name);
289
+ if (ent.isDirectory()) {
290
+ yield walkAsync(full);
291
+ }
292
+ else if (ent.isFile()) {
293
+ const ext = path.extname(ent.name).toLowerCase();
294
+ if (wanted.has(ext))
295
+ results.push(full);
296
+ }
297
+ }
298
+ });
299
+ }
300
+ yield walkAsync(directory);
301
+ return results;
302
+ }
303
+ catch (_a) {
304
+ return [];
305
+ }
306
+ });
307
+ }
308
+ /** Optional convenience re-exports that mirror your Python names */
309
+ export const get_all_file_types = getAllFileTypes;
310
+ export const get_media_map = getMediaMap;
311
+ export const get_media_exts = getMediaExts;
312
+ export const confirm_type = confirmType;
313
+ export const is_media_type = isMediaType;
314
+ export const get_mime_type = getMimeType;
@@ -1 +1 @@
1
- export * from './src';
1
+ export * from './src/index.js';
@@ -0,0 +1 @@
1
+ export * from './src';
@@ -1,4 +1,5 @@
1
1
  declare module 'path-browserify' {
2
- import * as path from 'path';
3
- export = path;
2
+ const path: typeof import("path");
3
+ export default path;
4
4
  }
5
+ export {};
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- export * from './Files';
2
- export * from './utils';
3
- export * from './logout';
4
- export * from './login';
1
+ export * from './Files.js';
2
+ export * from './utils.js';
3
+ export * from './logout.js';
4
+ export * from './login.js';
@@ -0,0 +1,4 @@
1
+ export * from './Files';
2
+ export * from './utils';
3
+ export * from './logout';
4
+ export * from './login';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1 @@
1
- export type { InputProps } from "./../types";
1
+ export type { InputProps } from "./../types/index.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1 @@
1
- export * from './src';
1
+ export * from './src/index.js';
@@ -0,0 +1 @@
1
+ export * from './src';
@@ -0,0 +1,2 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ export const Input = ({ label, type, value, onValueChange, placeholder, disabled, error, directory, multiple, accept, }) => (_jsxs("label", { className: "block", children: [_jsx("span", { className: "text-sm", children: label }), _jsx("input", Object.assign({ type: type, className: `mt-1 w-full border rounded px-2 py-1 ${error ? "border-red-500" : ""}`, value: value, onChange: (e) => onValueChange(e.target.value), placeholder: placeholder, disabled: disabled }, (type === "file" && directory ? { webkitdirectory: "true", directory: "" } : {}), (type === "file" && multiple ? { multiple: true } : {}), (type === "file" && accept ? { accept } : {}))), error && _jsx("p", { className: "text-sm text-red-600", children: error })] }));
@@ -0,0 +1,27 @@
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
+ let _cachedConfig = null;
11
+ export function loadConfig() {
12
+ return __awaiter(this, void 0, void 0, function* () {
13
+ var _a;
14
+ if (_cachedConfig)
15
+ return _cachedConfig;
16
+ try {
17
+ // Use a dynamic expression so bundlers don’t resolve at build time
18
+ const mod = yield (new Function("return import('./config.json').catch(() => ({}))"))();
19
+ _cachedConfig = (_a = mod.default) !== null && _a !== void 0 ? _a : {};
20
+ return _cachedConfig;
21
+ }
22
+ catch (_b) {
23
+ _cachedConfig = {};
24
+ return _cachedConfig;
25
+ }
26
+ });
27
+ }
@@ -1,2 +1,2 @@
1
- export * from "./Input";
2
- export * from './config';
1
+ export * from "./Input.js";
2
+ export * from './config.js';
@@ -0,0 +1,2 @@
1
+ export * from "./Input";
2
+ export * from './config';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putkoff/abstract-utilities",
3
- "version": "1.0.102",
3
+ "version": "1.0.113",
4
4
  "type": "module",
5
5
  "description": "A reusable React Login component with JWT authentication",
6
6
  "main": "dist/cjs/index.js",
@@ -19,7 +19,18 @@
19
19
  "jwt",
20
20
  "authentication"
21
21
  ],
22
- "author": "Your Name",
22
+ "rules": {
23
+ "import/extensions": [
24
+ "error",
25
+ "ignorePackages",
26
+ {
27
+ "ts": "never",
28
+ "tsx": "never",
29
+ "js": "always"
30
+ }
31
+ ]
32
+ },
33
+ "author": "putkoff",
23
34
  "license": "MIT",
24
35
  "peerDependencies": {
25
36
  "react": "^17.0.0 || ^18.0.0 || ^19.0.0",