@fleetbase/ember-core 0.2.20 → 0.2.21
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/addon/services/universe.js +26 -81
- package/package.json +1 -1
|
@@ -44,6 +44,7 @@ export default class UniverseService extends Service.extend(Evented) {
|
|
|
44
44
|
};
|
|
45
45
|
@tracked hooks = {};
|
|
46
46
|
@tracked bootCallbacks = A([]);
|
|
47
|
+
@tracked initialLocation = { ...window.location };
|
|
47
48
|
|
|
48
49
|
/**
|
|
49
50
|
* Computed property that returns all administrative menu items.
|
|
@@ -137,6 +138,16 @@ export default class UniverseService extends Service.extend(Evented) {
|
|
|
137
138
|
return this.router.transitionTo(route, ...args);
|
|
138
139
|
}
|
|
139
140
|
|
|
141
|
+
/**
|
|
142
|
+
* Initialize the universe service.
|
|
143
|
+
*
|
|
144
|
+
* @memberof UniverseService
|
|
145
|
+
*/
|
|
146
|
+
initialize() {
|
|
147
|
+
this.initialLocation = { ...window.location };
|
|
148
|
+
this.trigger('init', this);
|
|
149
|
+
}
|
|
150
|
+
|
|
140
151
|
/**
|
|
141
152
|
* Sets the application instance.
|
|
142
153
|
*
|
|
@@ -1803,6 +1814,7 @@ export default class UniverseService extends Service.extend(Evented) {
|
|
|
1803
1814
|
}
|
|
1804
1815
|
|
|
1805
1816
|
// Set application instance
|
|
1817
|
+
this.initialize();
|
|
1806
1818
|
this.setApplicationInstance(owner);
|
|
1807
1819
|
|
|
1808
1820
|
const tryBootEngine = (extension) => {
|
|
@@ -1861,6 +1873,9 @@ export default class UniverseService extends Service.extend(Evented) {
|
|
|
1861
1873
|
pending.push(...stillPending);
|
|
1862
1874
|
};
|
|
1863
1875
|
|
|
1876
|
+
// Run pre-boots if any
|
|
1877
|
+
await this.preboot();
|
|
1878
|
+
|
|
1864
1879
|
return loadInstalledExtensions(additionalCoreExtensions).then(async (extensions) => {
|
|
1865
1880
|
for (let i = 0; i < extensions.length; i++) {
|
|
1866
1881
|
const extension = extensions[i];
|
|
@@ -1874,90 +1889,20 @@ export default class UniverseService extends Service.extend(Evented) {
|
|
|
1874
1889
|
}
|
|
1875
1890
|
|
|
1876
1891
|
/**
|
|
1877
|
-
*
|
|
1878
|
-
*
|
|
1879
|
-
* This method loads all installed extensions and then attempts to boot each engine.
|
|
1880
|
-
* For each extension, it loads the engine and, if the engine has a `setupExtension`
|
|
1881
|
-
* method in its base, it calls this method to complete the setup. This function ensures
|
|
1882
|
-
* that dependencies are resolved before booting the engines. If some dependencies are
|
|
1883
|
-
* never booted, an error is logged.
|
|
1892
|
+
* Run engine preboots from all indexed engines.
|
|
1884
1893
|
*
|
|
1885
|
-
* @
|
|
1886
|
-
* @
|
|
1887
|
-
* @return {void}
|
|
1894
|
+
* @param {ApplicationInstance} owner
|
|
1895
|
+
* @memberof UniverseService
|
|
1888
1896
|
*/
|
|
1889
|
-
|
|
1890
|
-
const
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
}
|
|
1897
|
-
|
|
1898
|
-
// Set application instance
|
|
1899
|
-
this.setApplicationInstance(owner);
|
|
1900
|
-
|
|
1901
|
-
const tryBootEngine = (extension) => {
|
|
1902
|
-
return this.loadEngine(extension.name).then((engineInstance) => {
|
|
1903
|
-
if (engineInstance.base && engineInstance.base.setupExtension) {
|
|
1904
|
-
const engineDependencies = getWithDefault(engineInstance.base, 'engineDependencies', []);
|
|
1905
|
-
|
|
1906
|
-
// Check if all dependency engines are booted
|
|
1907
|
-
const allDependenciesBooted = engineDependencies.every((dep) => booted.includes(dep));
|
|
1908
|
-
|
|
1909
|
-
if (!allDependenciesBooted) {
|
|
1910
|
-
pending.push({ extension, engineInstance });
|
|
1911
|
-
return;
|
|
1912
|
-
}
|
|
1913
|
-
|
|
1914
|
-
engineInstance.base.setupExtension(owner, engineInstance, this);
|
|
1915
|
-
booted.push(extension.name);
|
|
1916
|
-
this.bootedExtensions.pushObject(extension.name);
|
|
1917
|
-
this.trigger('extension.booted', extension);
|
|
1918
|
-
debug(`Booted : ${extension.name}`);
|
|
1919
|
-
|
|
1920
|
-
// Try booting pending engines again
|
|
1921
|
-
tryBootPendingEngines();
|
|
1922
|
-
}
|
|
1923
|
-
});
|
|
1924
|
-
};
|
|
1925
|
-
|
|
1926
|
-
const tryBootPendingEngines = () => {
|
|
1927
|
-
const stillPending = [];
|
|
1928
|
-
|
|
1929
|
-
pending.forEach(({ extension, engineInstance }) => {
|
|
1930
|
-
const engineDependencies = getWithDefault(engineInstance.base, 'engineDependencies', []);
|
|
1931
|
-
const allDependenciesBooted = engineDependencies.every((dep) => booted.includes(dep));
|
|
1932
|
-
|
|
1933
|
-
if (allDependenciesBooted) {
|
|
1934
|
-
engineInstance.base.setupExtension(owner, engineInstance, this);
|
|
1935
|
-
booted.push(extension.name);
|
|
1936
|
-
this.bootedExtensions.pushObject(extension.name);
|
|
1937
|
-
this.trigger('extension.booted', extension);
|
|
1938
|
-
debug(`Booted : ${extension.name}`);
|
|
1939
|
-
} else {
|
|
1940
|
-
stillPending.push({ extension, engineInstance });
|
|
1941
|
-
}
|
|
1942
|
-
});
|
|
1943
|
-
|
|
1944
|
-
// If no progress was made, log an error in debug/development mode
|
|
1945
|
-
assert('Some engines have unmet dependencies and cannot be booted:', pending.length === stillPending.length);
|
|
1946
|
-
|
|
1947
|
-
pending.length = 0;
|
|
1948
|
-
pending.push(...stillPending);
|
|
1949
|
-
};
|
|
1950
|
-
|
|
1951
|
-
return loadExtensions().then(async (extensions) => {
|
|
1952
|
-
for (let i = 0; i < extensions.length; i++) {
|
|
1953
|
-
const extension = extensions[i];
|
|
1954
|
-
await tryBootEngine(extension);
|
|
1897
|
+
async preboot(owner) {
|
|
1898
|
+
const extensions = await loadExtensions();
|
|
1899
|
+
for (let i = 0; i < extensions.length; i++) {
|
|
1900
|
+
const extension = extensions[i];
|
|
1901
|
+
const instance = await this.loadEngine(extension.name);
|
|
1902
|
+
if (instance.base && typeof instance.base.preboot === 'function') {
|
|
1903
|
+
instance.base.preboot(owner, instance, this);
|
|
1955
1904
|
}
|
|
1956
|
-
|
|
1957
|
-
this.runBootCallbacks(owner, () => {
|
|
1958
|
-
this.enginesBooted = true;
|
|
1959
|
-
});
|
|
1960
|
-
});
|
|
1905
|
+
}
|
|
1961
1906
|
}
|
|
1962
1907
|
|
|
1963
1908
|
/**
|
package/package.json
CHANGED