mirror of
https://github.com/nasa/openmct.git
synced 2024-12-20 05:37:53 +00:00
[Framework] Begin work on extension resolution
Begin work on extension resolution phase of the framework layer. WTD-518. Introduce an implementation loader which wraps RequireJS, and a skeleton class for extension resolution.
This commit is contained in:
parent
0e82250c84
commit
a940d1a460
@ -95,6 +95,9 @@ define(
|
|||||||
return new Extension(self, category, extDefinition);
|
return new Extension(self, category, extDefinition);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
getExtensionCategories: function () {
|
||||||
|
return Object.keys(definition.extensions);
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @memberof Bundle#
|
* @memberof Bundle#
|
||||||
|
@ -48,6 +48,13 @@ define(
|
|||||||
getCategory: function () {
|
getCategory: function () {
|
||||||
return category;
|
return category;
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Check whether or not this
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
hasImplementation: function () {
|
||||||
|
return definition.implementation !== undefined;
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Get the path to the AMD module which implements this
|
* Get the path to the AMD module which implements this
|
||||||
* extension. Will return undefined if there is no
|
* extension. Will return undefined if there is no
|
||||||
|
23
platform/framework/src/ExtensionResolver.js
Normal file
23
platform/framework/src/ExtensionResolver.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/*global define,Promise*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module defining ExtensionResolver. Created by vwoeltje on 11/3/14.
|
||||||
|
*/
|
||||||
|
define(
|
||||||
|
[],
|
||||||
|
function () {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function ExtensionResolver(require) {
|
||||||
|
return {
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return ExtensionResolver;
|
||||||
|
}
|
||||||
|
);
|
46
platform/framework/src/ImplementationLoader.js
Normal file
46
platform/framework/src/ImplementationLoader.js
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/*global define,Promise*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module defining ImplementationLoader. Created by vwoeltje on 11/3/14.
|
||||||
|
*/
|
||||||
|
define(
|
||||||
|
[],
|
||||||
|
function () {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Responsible for loading extension implementations
|
||||||
|
* (AMD modules.) Acts as a wrapper around RequireJS to
|
||||||
|
* provide a promise-like API.
|
||||||
|
* @constructor
|
||||||
|
* @param {*} require RequireJS, or an object with similar API
|
||||||
|
* @param {*} $log Angular's logging service
|
||||||
|
*/
|
||||||
|
function ImplementationLoader(require) {
|
||||||
|
function loadModule(path) {
|
||||||
|
return new Promise(function (fulfill, reject) {
|
||||||
|
require(path, fulfill, reject);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
/**
|
||||||
|
* Load an extension's implementation; or, equivalently,
|
||||||
|
* load an AMD module. This is fundamentally similar
|
||||||
|
* to a call to RequireJS, except that the result is
|
||||||
|
* wrapped in a promise. The promise will be fulfilled
|
||||||
|
* with the loaded module, or rejected with the error
|
||||||
|
* reported by Require.
|
||||||
|
*
|
||||||
|
* @method
|
||||||
|
* @memberof ImplementationLoader#
|
||||||
|
* @param {string} path the path to the module to load
|
||||||
|
* @returns {Promise} a promise for the specified module.
|
||||||
|
*/
|
||||||
|
load: loadModule
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return ImplementationLoader;
|
||||||
|
}
|
||||||
|
);
|
Loading…
Reference in New Issue
Block a user