@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.
- package/dist/cjs/index.js +45 -27
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +134 -114
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +0 -0
- 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 -0
- package/dist/types/functions/config_utils/imports.d.ts +1 -1
- package/dist/types/functions/config_utils/index.d.ts +0 -0
- package/dist/types/functions/config_utils/src/config_utils.d.ts +0 -0
- 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 +0 -0
- 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 +0 -0
- package/dist/types/functions/index.d.ts +0 -0
- 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 -0
- 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 -0
- 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 -0
- 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 +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$
|
|
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$
|
|
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
|
-
|
|
359
|
-
|
|
360
|
-
|
|
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
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
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 (
|
|
372
|
-
// swallow and fall back
|
|
390
|
+
catch (_b) {
|
|
391
|
+
// swallow and fall back
|
|
373
392
|
}
|
|
374
393
|
}
|
|
375
394
|
// 2) Try browser fetch
|
|
376
|
-
const fetchFn = safeGlobalProp(
|
|
377
|
-
if (typeof fetchFn !==
|
|
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(
|
|
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 (
|
|
388
|
-
|
|
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 (
|
|
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, '/'));
|