forked from aurelia/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugins.js
82 lines (70 loc) · 2.28 KB
/
plugins.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
System.register(["aurelia-logging"], function (_export) {
"use strict";
var LogManager, _prototypeProperties, logger, Plugins;
function loadPlugin(aurelia, loader, info) {
logger.debug("Loading plugin " + info.moduleId + ".");
return loader.loadModule(info.moduleId, "").then(function (exportedValue) {
if ("install" in exportedValue) {
var result = exportedValue.install(aurelia, info.config || {});
if (result) {
return result.then(function () {
logger.debug("Installed plugin " + info.moduleId + ".");
});
} else {
logger.debug("Installed plugin " + info.moduleId + ".");
}
} else {
logger.debug("Loaded plugin " + info.moduleId + ".");
}
});
}
return {
setters: [function (_aureliaLogging) {
LogManager = _aureliaLogging;
}],
execute: function () {
_prototypeProperties = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
logger = LogManager.getLogger("aurelia");
Plugins = (function () {
function Plugins(aurelia) {
this.aurelia = aurelia;
this.info = [];
}
_prototypeProperties(Plugins, null, {
install: {
value: function (moduleId, config) {
this.info.push({ moduleId: moduleId, config: config });
return this;
},
writable: true,
enumerable: true,
configurable: true
},
process: {
value: function () {
var aurelia = this.aurelia,
loader = aurelia.loader,
info = this.info,
current;
var next = function () {
if (current = info.shift()) {
return loadPlugin(aurelia, loader, current).then(next);
}
return Promise.resolve();
};
return next();
},
writable: true,
enumerable: true,
configurable: true
}
});
return Plugins;
})();
_export("Plugins", Plugins);
}
};
});