@putkoff/abstract-utilities 1.0.5 → 1.0.19

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 (90) hide show
  1. package/dist/cjs/index.js +45 -27
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/esm/index.js +134 -114
  4. package/dist/esm/index.js.map +1 -1
  5. package/dist/index.d.ts +0 -0
  6. package/dist/types/functions/auth_utils/imports.d.ts +0 -0
  7. package/dist/types/functions/auth_utils/index.d.ts +0 -0
  8. package/dist/types/functions/auth_utils/src/index.d.ts +0 -0
  9. package/dist/types/functions/auth_utils/src/token_utils.d.ts +0 -0
  10. package/dist/types/functions/config_utils/imports.d.ts +1 -1
  11. package/dist/types/functions/config_utils/index.d.ts +0 -0
  12. package/dist/types/functions/config_utils/src/config_utils.d.ts +0 -0
  13. package/dist/types/functions/config_utils/src/index.d.ts +0 -0
  14. package/dist/types/functions/constants_utils/index.d.ts +0 -0
  15. package/dist/types/functions/constants_utils/src/constants.d.ts +0 -0
  16. package/dist/types/functions/constants_utils/src/index.d.ts +0 -0
  17. package/dist/types/functions/env_utils/imports.d.ts +0 -0
  18. package/dist/types/functions/env_utils/index.d.ts +0 -0
  19. package/dist/types/functions/env_utils/src/index.d.ts +0 -0
  20. package/dist/types/functions/env_utils/src/window_utils.d.ts +0 -0
  21. package/dist/types/functions/fetch_utils/imports.d.ts +0 -0
  22. package/dist/types/functions/fetch_utils/index.d.ts +0 -0
  23. package/dist/types/functions/fetch_utils/src/fetch_utils.d.ts +0 -0
  24. package/dist/types/functions/fetch_utils/src/index.d.ts +0 -0
  25. package/dist/types/functions/fetch_utils/src/url_utils.d.ts +0 -0
  26. package/dist/types/functions/fetch_utils/src/utils.d.ts +0 -0
  27. package/dist/types/functions/index.d.ts +0 -0
  28. package/dist/types/functions/math_utils/index.d.ts +0 -0
  29. package/dist/types/functions/math_utils/safe_math.d.ts +0 -0
  30. package/dist/types/functions/path_utils/imports.d.ts +0 -0
  31. package/dist/types/functions/path_utils/index.d.ts +0 -0
  32. package/dist/types/functions/path_utils/src/base_dirs.d.ts +0 -0
  33. package/dist/types/functions/path_utils/src/function_dirs.d.ts +0 -0
  34. package/dist/types/functions/path_utils/src/index.d.ts +0 -0
  35. package/dist/types/functions/path_utils/src/misc_dirs.d.ts +0 -0
  36. package/dist/types/functions/path_utils/src/path_utils.d.ts +0 -0
  37. package/dist/types/functions/path_utils/src/paths.d.ts +0 -0
  38. package/dist/types/functions/path_utils/src/src_dirs.d.ts +0 -0
  39. package/dist/types/functions/read_utils/imports.d.ts +0 -0
  40. package/dist/types/functions/read_utils/index.d.ts +0 -0
  41. package/dist/types/functions/read_utils/src/index.d.ts +0 -0
  42. package/dist/types/functions/read_utils/src/utils.d.ts +0 -0
  43. package/dist/types/functions/rndm_utils/imports.d.ts +0 -0
  44. package/dist/types/functions/rndm_utils/index.d.ts +0 -0
  45. package/dist/types/functions/rndm_utils/src/index.d.ts +0 -0
  46. package/dist/types/functions/rndm_utils/src/utils.d.ts +0 -0
  47. package/dist/types/functions/safe_utils/imports.d.ts +0 -0
  48. package/dist/types/functions/safe_utils/index.d.ts +0 -0
  49. package/dist/types/functions/safe_utils/src/index.d.ts +0 -0
  50. package/dist/types/functions/safe_utils/src/safe_document.d.ts +0 -0
  51. package/dist/types/functions/safe_utils/src/safe_globals.d.ts +0 -0
  52. package/dist/types/functions/safe_utils/src/safe_storage.d.ts +0 -0
  53. package/dist/types/functions/safe_utils/src/safe_window.d.ts +0 -0
  54. package/dist/types/functions/string_utils/index.d.ts +0 -0
  55. package/dist/types/functions/string_utils/src/index.d.ts +0 -0
  56. package/dist/types/functions/string_utils/src/string_utils.d.ts +0 -0
  57. package/dist/types/functions/type_utils/imports.d.ts +0 -0
  58. package/dist/types/functions/type_utils/index.d.ts +0 -0
  59. package/dist/types/functions/type_utils/src/clean_utils.d.ts +0 -0
  60. package/dist/types/functions/type_utils/src/ensure_utils.d.ts +0 -0
  61. package/dist/types/functions/type_utils/src/imports.d.ts +0 -0
  62. package/dist/types/functions/type_utils/src/index.d.ts +0 -0
  63. package/dist/types/functions/type_utils/src/json_utils.d.ts +0 -0
  64. package/dist/types/functions/type_utils/src/mime_utils.d.ts +0 -0
  65. package/dist/types/functions/type_utils/src/type_utils.d.ts +0 -0
  66. package/dist/types/functions/ui_utils/imports.d.ts +0 -0
  67. package/dist/types/functions/ui_utils/index.d.ts +0 -0
  68. package/dist/types/functions/ui_utils/src/button.d.ts +0 -0
  69. package/dist/types/functions/ui_utils/src/checkbox.d.ts +0 -0
  70. package/dist/types/functions/ui_utils/src/index.d.ts +0 -0
  71. package/dist/types/functions/ui_utils/src/input.d.ts +0 -0
  72. package/dist/types/functions/ui_utils/src/spinner.d.ts +0 -0
  73. package/dist/types/functions/variable_utils/imports.d.ts +0 -0
  74. package/dist/types/functions/variable_utils/index.d.ts +0 -0
  75. package/dist/types/functions/variable_utils/src/index.d.ts +0 -0
  76. package/dist/types/functions/variable_utils/src/variable_utils.d.ts +0 -0
  77. package/dist/types/index.d.ts +0 -0
  78. package/dist/types/types/index.d.ts +0 -0
  79. package/dist/types/types/src/ChangePassword.d.ts +0 -0
  80. package/dist/types/types/src/Files.d.ts +0 -0
  81. package/dist/types/types/src/index.d.ts +0 -0
  82. package/dist/types/types/src/login.d.ts +0 -0
  83. package/dist/types/types/src/logout.d.ts +0 -0
  84. package/dist/types/types/src/utils.d.ts +0 -0
  85. package/dist/types/utils/imports.d.ts +0 -0
  86. package/dist/types/utils/index.d.ts +0 -0
  87. package/dist/types/utils/src/Input.d.ts +0 -0
  88. package/dist/types/utils/src/config.d.ts +0 -0
  89. package/dist/types/utils/src/index.d.ts +0 -0
  90. package/package.json +11 -3
package/dist/cjs/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  var react = require('react');
4
- var path = require('path');
5
- var fs = require('node:fs');
4
+ var path$1 = require('path');
5
+ var fs$1 = require('node:fs');
6
6
  var fsp = require('node:fs/promises');
7
- var path$1 = require('node:path');
7
+ var path$2 = require('node:path');
8
8
  var jsxRuntime = require('react/jsx-runtime');
9
9
 
10
10
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
@@ -25,9 +25,9 @@ function _interopNamespaceDefault(e) {
25
25
  return Object.freeze(n);
26
26
  }
27
27
 
28
- var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
28
+ var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs$1);
29
29
  var fsp__namespace = /*#__PURE__*/_interopNamespaceDefault(fsp);
30
- var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path$1);
30
+ var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path$2);
31
31
 
32
32
  function getSafeDocument() {
33
33
  return typeof document !== 'undefined' ? document : undefined;
@@ -348,6 +348,25 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
348
348
  };
349
349
 
350
350
  // src/functions/read_utils/src/read_utils.ts
351
+ let fs = null;
352
+ let path = null;
353
+ function getFsModules() {
354
+ return __awaiter(this, void 0, void 0, function* () {
355
+ var _a;
356
+ if (!fs && !path && typeof process !== "undefined" && ((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node)) {
357
+ try {
358
+ // prevent bundlers from resolving these at build time
359
+ fs = (new Function("return require('fs')"))();
360
+ path = (new Function("return require('path')"))();
361
+ }
362
+ catch (_b) {
363
+ fs = null;
364
+ path = null;
365
+ }
366
+ }
367
+ return { fs, path };
368
+ });
369
+ }
351
370
  /**
352
371
  * Reads a JSON file, either via Node’s fs (if available)
353
372
  * or via window.fetch in the browser. Never throws — returns
@@ -355,37 +374,36 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
355
374
  */
356
375
  function readJsonFile(relativeOrAbsolutePath) {
357
376
  return __awaiter(this, void 0, void 0, function* () {
358
- // 1) Try Node.js fs
359
- if (typeof process !== 'undefined' &&
360
- process.versions != null &&
361
- process.versions.node) {
377
+ var _a;
378
+ // 1) Try Node.js fs (only at runtime, not bundled)
379
+ if (typeof process !== "undefined" && ((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node)) {
362
380
  try {
363
- const fs = yield import('fs');
364
- const path = yield import('path');
365
- const filePath = path.isAbsolute(relativeOrAbsolutePath)
366
- ? relativeOrAbsolutePath
367
- : path.resolve(process.cwd(), relativeOrAbsolutePath);
368
- const text = yield fs.promises.readFile(filePath, 'utf8');
369
- return JSON.parse(text);
381
+ const { fs, path } = yield getFsModules();
382
+ if (fs && path) {
383
+ const filePath = path.isAbsolute(relativeOrAbsolutePath)
384
+ ? relativeOrAbsolutePath
385
+ : path.resolve(process.cwd(), relativeOrAbsolutePath);
386
+ const text = fs.readFileSync(filePath, "utf8");
387
+ return JSON.parse(text);
388
+ }
370
389
  }
371
- catch (_a) {
372
- // swallow and fall back to browser
390
+ catch (_b) {
391
+ // swallow and fall back
373
392
  }
374
393
  }
375
394
  // 2) Try browser fetch
376
- const fetchFn = safeGlobalProp('fetch');
377
- if (typeof fetchFn !== 'function') {
395
+ const fetchFn = safeGlobalProp("fetch");
396
+ if (typeof fetchFn !== "function") {
378
397
  return null;
379
398
  }
380
- // Resolve URL against document.baseURI if possible
381
399
  let url = relativeOrAbsolutePath;
382
- const baseURI = safeGlobalProp('document', 'baseURI');
400
+ const baseURI = safeGlobalProp("document", "baseURI");
383
401
  if (baseURI) {
384
402
  try {
385
403
  url = new URL(relativeOrAbsolutePath, baseURI).href;
386
404
  }
387
- catch (_b) {
388
- // keep url as-is
405
+ catch (_c) {
406
+ /* keep url as-is */
389
407
  }
390
408
  }
391
409
  try {
@@ -394,7 +412,7 @@ function readJsonFile(relativeOrAbsolutePath) {
394
412
  return null;
395
413
  return (yield res.json());
396
414
  }
397
- catch (_c) {
415
+ catch (_d) {
398
416
  return null;
399
417
  }
400
418
  });
@@ -623,7 +641,7 @@ function get_full_path(partial_path, parent_dir = null) {
623
641
  if (typeof partial_path !== 'string') {
624
642
  throw new Error('partial_path must be a string');
625
643
  }
626
- if (path.isAbsolute(partial_path)) {
644
+ if (path$1.isAbsolute(partial_path)) {
627
645
  return partial_path;
628
646
  }
629
647
  return urlJoin(parent_dir, partial_path);
@@ -638,7 +656,7 @@ function path_to_url(filePath, all_paths) {
638
656
  }
639
657
  for (const key in all_paths) {
640
658
  const mapping = all_paths[key];
641
- const normalizedBase = path.normalize(mapping.path);
659
+ const normalizedBase = path$1.normalize(mapping.path);
642
660
  if (filePath.startsWith(normalizedBase)) {
643
661
  const relativePath = filePath.substring(normalizedBase.length);
644
662
  return urlJoin(mapping.url, relativePath.replace(/\\/g, '/'));