Skip to content

Commit 82f4e9b

Browse files
author
craigparra
committed
1.0.9 / 2021-08-04
================== * boot refactoring - @craigparra
1 parent 055c6dc commit 82f4e9b

File tree

9 files changed

+74
-5465
lines changed

9 files changed

+74
-5465
lines changed

.nycrc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"cache": false,
3+
"check-coverage": true,
4+
"lines": 90,
5+
"statements": 90,
6+
"functions": 90,
7+
"branches": 80,
8+
"reporter": [
9+
"html",
10+
"text",
11+
"text-summary"
12+
],
13+
"all": true,
14+
"instrument": true
15+
}

ConfigFactory.js

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,26 @@ const PrefixSelector = require('./PrefixSelector');
88
const URLResolver = require('./URLResolver');
99

1010
module.exports = class ConfigFactory {
11+
12+
static getGlobalRef() {
13+
let $globalref = null;
14+
if (ConfigFactory.detectBrowser()) {
15+
$globalref = window;
16+
} else {
17+
$globalref = global;
18+
}
19+
return $globalref;
20+
}
21+
22+
static getGlobalRoot(key) {
23+
const $globalref = ConfigFactory.getGlobalRef();
24+
let $key = ($globalref && $globalref.boot);
25+
$key = $key && $key.contexts;
26+
$key = $key && $key.root;
27+
$key = $key && $key[`${key}`];
28+
return $key;
29+
}
30+
1131
static detectBrowser() {
1232
const browser = !(typeof window === 'undefined');
1333
return browser;
@@ -19,14 +39,8 @@ module.exports = class ConfigFactory {
1939
// eslint-disable-next-line no-undef
2040
$fetch = fetch;
2141
}
22-
if (global?.boot?.contexts?.root?.fetch) {
23-
$fetch = global.boot.contexts.root.fetch;
24-
}
25-
if (ConfigFactory.detectBrowser() && window?.fetch) {
26-
$fetch = window.fetch;
27-
}
28-
if (ConfigFactory.detectBrowser() && window?.boot?.contexts?.root?.fetch) {
29-
$fetch = window.boot.contexts.root.fetch;
42+
if (ConfigFactory.getGlobalRoot('fetch')) {
43+
$fetch = ConfigFactory.getGlobalRoot('fetch');
3044
}
3145
$fetch = fetchArg || $fetch;
3246
return $fetch;

History.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
1.0.9 / 2021-08-04
2+
==================
3+
4+
* boot refactoring - @craigparra
5+
16
1.0.8 / 2021-07-30
27
==================
38

0 commit comments

Comments
 (0)