@putkoff/abstract-utilities 0.1.168 → 0.1.169

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 CHANGED
@@ -83,6 +83,19 @@ function getWindowHost() {
83
83
  return getWindowProp('location', 'host');
84
84
  }
85
85
 
86
+ function getSafeDocument() {
87
+ return typeof document !== 'undefined' ? document : undefined;
88
+ }
89
+ function getDocumentProp(...keys) {
90
+ let obj = getSafeDocument();
91
+ for (const k of keys) {
92
+ if (obj == null || typeof obj !== 'object')
93
+ return undefined;
94
+ obj = obj[k];
95
+ }
96
+ return obj;
97
+ }
98
+
86
99
  /**
87
100
  ***Changes**:
88
101
  *- Updated import path for `InputProps` to `../../types/interfaces`.
@@ -1094,7 +1107,7 @@ function loadConfig() {
1094
1107
  // 1. If nobody passed a custom path, we default to "config.json" (relative)
1095
1108
  const relativePath = filePath || 'config.json';
1096
1109
  // 2. Resolve it against the running page’s URL (document.baseURI)
1097
- const configUrl = new URL(relativePath, document.baseURI).href;
1110
+ const configUrl = new URL(relativePath, getDocumentProp('baseURI')).href;
1098
1111
  // 3. Fetch + cache
1099
1112
  if (_cachedConfig)
1100
1113
  return _cachedConfig;
@@ -1505,6 +1518,7 @@ exports.getComponentsUtilsDirectory = getComponentsUtilsDirectory;
1505
1518
  exports.getConfig = getConfig;
1506
1519
  exports.getDbConfigsPath = getDbConfigsPath;
1507
1520
  exports.getDistDir = getDistDir;
1521
+ exports.getDocumentProp = getDocumentProp;
1508
1522
  exports.getEnvDir = getEnvDir;
1509
1523
  exports.getEnvPath = getEnvPath;
1510
1524
  exports.getFetchVars = getFetchVars;
@@ -1517,6 +1531,7 @@ exports.getLibUtilsDirectory = getLibUtilsDirectory;
1517
1531
  exports.getMethod = getMethod;
1518
1532
  exports.getPublicDir = getPublicDir;
1519
1533
  exports.getResult = getResult;
1534
+ exports.getSafeDocument = getSafeDocument;
1520
1535
  exports.getSafeLocalStorage = getSafeLocalStorage;
1521
1536
  exports.getSafeWindow = getSafeWindow;
1522
1537
  exports.getSchemasDirPath = getSchemasDirPath;