diff --git a/bower.json b/bower.json index 405eb57f..cc47f1d0 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "aurelia-framework", - "version": "0.7.0", + "version": "0.8.0", "description": "The aurelia framework brings together all the required core aurelia libraries into a ready-to-go application-building platform.", "keywords": [ "aurelia", diff --git a/dist/amd/aurelia.js b/dist/amd/aurelia.js index aa5bded3..44749a0b 100644 --- a/dist/amd/aurelia.js +++ b/dist/amd/aurelia.js @@ -21,11 +21,9 @@ define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-l slice = Array.prototype.slice; function loadResources(container, resourcesToLoad, appResources) { - var resourceCoordinator = container.get(ResourceCoordinator), current; - - function next() { + var next = function () { if (current = resourcesToLoad.shift()) { - return resourceCoordinator.importResources(current).then(function (resources) { + return resourceCoordinator.importResources(current, current.resourceManifestUrl).then(function (resources) { resources.forEach(function (x) { return x.register(appResources); }); @@ -34,7 +32,10 @@ define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-l } return Promise.resolve(); - } + }; + + var resourceCoordinator = container.get(ResourceCoordinator), + current; return next(); } @@ -45,7 +46,11 @@ define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-l this.container = container || new Container(); this.resources = resources || new ResourceRegistry(); this.resourcesToLoad = []; - this.plugins = new Plugins(this); + this.use = new Plugins(this); + + if (!this.resources.baseResourcePath) { + this.resources.baseResourcePath = System.baseUrl || ""; + } this.withInstance(Aurelia, this); this.withInstance(Loader, this.loader); @@ -54,7 +59,7 @@ define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-l _prototypeProperties(Aurelia, null, { withInstance: { - value: function (type, instance) { + value: function withInstance(type, instance) { this.container.registerInstance(type, instance); return this; }, @@ -63,7 +68,7 @@ define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-l configurable: true }, withSingleton: { - value: function (type, implementation) { + value: function withSingleton(type, implementation) { this.container.registerSingleton(type, implementation); return this; }, @@ -72,13 +77,10 @@ define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-l configurable: true }, withResources: { - value: function (resources) { - if (Array.isArray(resources)) { - this.resourcesToLoad.push(resources); - } else { - this.resourcesToLoad.push(slice.call(arguments)); - } - + value: function withResources(resources) { + var toAdd = Array.isArray(resources) ? resources : slice.call(arguments); + toAdd.resourceManifestUrl = this.currentPluginId; + this.resourcesToLoad.push(toAdd); return this; }, writable: true, @@ -86,16 +88,16 @@ define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-l configurable: true }, start: { - value: function () { + value: function start() { var _this = this; if (this.started) { - return; + return Promise.resolve(this); } this.started = true; logger.info("Aurelia Starting"); - return this.plugins.process().then(function () { + return this.use._process().then(function () { if (!_this.container.hasHandler(BindingLanguage)) { logger.error("You must configure Aurelia with a BindingLanguage implementation."); } @@ -111,9 +113,10 @@ define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-l configurable: true }, setRoot: { - value: function (root, applicationHost) { + value: function setRoot(root, applicationHost) { var _this2 = this; - var compositionEngine, instruction = {}; + var compositionEngine, + instruction = {}; if (!applicationHost || typeof applicationHost == "string") { this.host = document.getElementById(applicationHost || "applicationHost") || document.body; @@ -126,8 +129,9 @@ define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-l compositionEngine = this.container.get(CompositionEngine); instruction.viewModel = root; - instruction.viewSlot = new ViewSlot(this.host, true); instruction.container = instruction.childContainer = this.container; + instruction.viewSlot = new ViewSlot(this.host, true); + instruction.viewSlot.transformChildNodesIntoView(); return compositionEngine.compose(instruction).then(function (root) { _this2.root = root; diff --git a/dist/amd/plugins.js b/dist/amd/plugins.js index 20e74996..45200bc8 100644 --- a/dist/amd/plugins.js +++ b/dist/amd/plugins.js @@ -1,4 +1,4 @@ -define(["exports", "aurelia-logging"], function (exports, _aureliaLogging) { +define(["exports", "aurelia-logging", "aurelia-metadata"], function (exports, _aureliaLogging, _aureliaMetadata) { "use strict"; var _prototypeProperties = function (child, staticProps, instanceProps) { @@ -7,6 +7,7 @@ define(["exports", "aurelia-logging"], function (exports, _aureliaLogging) { }; var LogManager = _aureliaLogging; + var Metadata = _aureliaMetadata.Metadata; var logger = LogManager.getLogger("aurelia"); @@ -14,12 +15,15 @@ define(["exports", "aurelia-logging"], function (exports, _aureliaLogging) { function loadPlugin(aurelia, loader, info) { logger.debug("Loading plugin " + info.moduleId + "."); + aurelia.currentPluginId = 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 () { + aurelia.currentPluginId = null; logger.debug("Installed plugin " + info.moduleId + "."); }); } else { @@ -28,6 +32,8 @@ define(["exports", "aurelia-logging"], function (exports, _aureliaLogging) { } else { logger.debug("Loaded plugin " + info.moduleId + "."); } + + aurelia.currentPluginId = null; }); } @@ -35,30 +41,67 @@ define(["exports", "aurelia-logging"], function (exports, _aureliaLogging) { function Plugins(aurelia) { this.aurelia = aurelia; this.info = []; + this.processed = false; } _prototypeProperties(Plugins, null, { - install: { - value: function (moduleId, config) { - this.info.push({ moduleId: moduleId, config: config }); + plugin: { + value: function plugin(moduleId, config) { + var plugin = { moduleId: moduleId, config: config || {} }; + + if (this.processed) { + loadPlugin(this.aurelia, this.aurelia.loader, plugin); + } else { + this.info.push(plugin); + } + return this; }, writable: true, enumerable: true, configurable: true }, - process: { - value: function () { + es5: { + value: function es5() { + Function.prototype.computed = function (computedProperties) { + for (var key in computedProperties) { + if (computedProperties.hasOwnProperty(key)) { + Object.defineProperty(this.prototype, key, { get: prop[key], enumerable: true }); + } + } + }; + }, + writable: true, + enumerable: true, + configurable: true + }, + atscript: { + value: function atscript() { + this.aurelia.container.supportAtScript(); + Metadata.configure.location("annotate"); + }, + writable: true, + enumerable: true, + configurable: true + }, + _process: { + value: function Process() { + var _this = this; var aurelia = this.aurelia, loader = aurelia.loader, info = this.info, current; + if (this.processed) { + return; + } + var next = function () { if (current = info.shift()) { return loadPlugin(aurelia, loader, current).then(next); } + _this.processed = true; return Promise.resolve(); }; diff --git a/dist/commonjs/aurelia.js b/dist/commonjs/aurelia.js index 03303079..1e458390 100644 --- a/dist/commonjs/aurelia.js +++ b/dist/commonjs/aurelia.js @@ -27,11 +27,9 @@ var logger = LogManager.getLogger("aurelia"), slice = Array.prototype.slice; function loadResources(container, resourcesToLoad, appResources) { - var resourceCoordinator = container.get(ResourceCoordinator), current; - - function next() { + var next = function () { if (current = resourcesToLoad.shift()) { - return resourceCoordinator.importResources(current).then(function (resources) { + return resourceCoordinator.importResources(current, current.resourceManifestUrl).then(function (resources) { resources.forEach(function (x) { return x.register(appResources); }); @@ -40,7 +38,10 @@ function loadResources(container, resourcesToLoad, appResources) { } return Promise.resolve(); - } + }; + + var resourceCoordinator = container.get(ResourceCoordinator), + current; return next(); } @@ -51,7 +52,11 @@ var Aurelia = (function () { this.container = container || new Container(); this.resources = resources || new ResourceRegistry(); this.resourcesToLoad = []; - this.plugins = new Plugins(this); + this.use = new Plugins(this); + + if (!this.resources.baseResourcePath) { + this.resources.baseResourcePath = System.baseUrl || ""; + } this.withInstance(Aurelia, this); this.withInstance(Loader, this.loader); @@ -60,7 +65,7 @@ var Aurelia = (function () { _prototypeProperties(Aurelia, null, { withInstance: { - value: function (type, instance) { + value: function withInstance(type, instance) { this.container.registerInstance(type, instance); return this; }, @@ -69,7 +74,7 @@ var Aurelia = (function () { configurable: true }, withSingleton: { - value: function (type, implementation) { + value: function withSingleton(type, implementation) { this.container.registerSingleton(type, implementation); return this; }, @@ -78,13 +83,10 @@ var Aurelia = (function () { configurable: true }, withResources: { - value: function (resources) { - if (Array.isArray(resources)) { - this.resourcesToLoad.push(resources); - } else { - this.resourcesToLoad.push(slice.call(arguments)); - } - + value: function withResources(resources) { + var toAdd = Array.isArray(resources) ? resources : slice.call(arguments); + toAdd.resourceManifestUrl = this.currentPluginId; + this.resourcesToLoad.push(toAdd); return this; }, writable: true, @@ -92,16 +94,16 @@ var Aurelia = (function () { configurable: true }, start: { - value: function () { + value: function start() { var _this = this; if (this.started) { - return; + return Promise.resolve(this); } this.started = true; logger.info("Aurelia Starting"); - return this.plugins.process().then(function () { + return this.use._process().then(function () { if (!_this.container.hasHandler(BindingLanguage)) { logger.error("You must configure Aurelia with a BindingLanguage implementation."); } @@ -117,9 +119,10 @@ var Aurelia = (function () { configurable: true }, setRoot: { - value: function (root, applicationHost) { + value: function setRoot(root, applicationHost) { var _this2 = this; - var compositionEngine, instruction = {}; + var compositionEngine, + instruction = {}; if (!applicationHost || typeof applicationHost == "string") { this.host = document.getElementById(applicationHost || "applicationHost") || document.body; @@ -132,8 +135,9 @@ var Aurelia = (function () { compositionEngine = this.container.get(CompositionEngine); instruction.viewModel = root; - instruction.viewSlot = new ViewSlot(this.host, true); instruction.container = instruction.childContainer = this.container; + instruction.viewSlot = new ViewSlot(this.host, true); + instruction.viewSlot.transformChildNodesIntoView(); return compositionEngine.compose(instruction).then(function (root) { _this2.root = root; diff --git a/dist/commonjs/plugins.js b/dist/commonjs/plugins.js index d1a42a07..d6f8671b 100644 --- a/dist/commonjs/plugins.js +++ b/dist/commonjs/plugins.js @@ -13,17 +13,23 @@ var _interopRequireWildcard = function (obj) { var LogManager = _interopRequireWildcard(require("aurelia-logging")); +var Metadata = require("aurelia-metadata").Metadata; + + var logger = LogManager.getLogger("aurelia"); function loadPlugin(aurelia, loader, info) { logger.debug("Loading plugin " + info.moduleId + "."); + aurelia.currentPluginId = 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 () { + aurelia.currentPluginId = null; logger.debug("Installed plugin " + info.moduleId + "."); }); } else { @@ -32,6 +38,8 @@ function loadPlugin(aurelia, loader, info) { } else { logger.debug("Loaded plugin " + info.moduleId + "."); } + + aurelia.currentPluginId = null; }); } @@ -39,30 +47,67 @@ var Plugins = (function () { function Plugins(aurelia) { this.aurelia = aurelia; this.info = []; + this.processed = false; } _prototypeProperties(Plugins, null, { - install: { - value: function (moduleId, config) { - this.info.push({ moduleId: moduleId, config: config }); + plugin: { + value: function plugin(moduleId, config) { + var plugin = { moduleId: moduleId, config: config || {} }; + + if (this.processed) { + loadPlugin(this.aurelia, this.aurelia.loader, plugin); + } else { + this.info.push(plugin); + } + return this; }, writable: true, enumerable: true, configurable: true }, - process: { - value: function () { + es5: { + value: function es5() { + Function.prototype.computed = function (computedProperties) { + for (var key in computedProperties) { + if (computedProperties.hasOwnProperty(key)) { + Object.defineProperty(this.prototype, key, { get: prop[key], enumerable: true }); + } + } + }; + }, + writable: true, + enumerable: true, + configurable: true + }, + atscript: { + value: function atscript() { + this.aurelia.container.supportAtScript(); + Metadata.configure.location("annotate"); + }, + writable: true, + enumerable: true, + configurable: true + }, + _process: { + value: function Process() { + var _this = this; var aurelia = this.aurelia, loader = aurelia.loader, info = this.info, current; + if (this.processed) { + return; + } + var next = function () { if (current = info.shift()) { return loadPlugin(aurelia, loader, current).then(next); } + _this.processed = true; return Promise.resolve(); }; diff --git a/dist/es6/aurelia.js b/dist/es6/aurelia.js index e4c4a6b9..58ae058c 100644 --- a/dist/es6/aurelia.js +++ b/dist/es6/aurelia.js @@ -1,13 +1,7 @@ import * as LogManager from 'aurelia-logging'; import {Container} from 'aurelia-dependency-injection'; import {Loader} from 'aurelia-loader'; -import { - BindingLanguage, - ResourceCoordinator, - ViewSlot, - ResourceRegistry, - CompositionEngine -} from 'aurelia-templating'; +import {BindingLanguage, ResourceCoordinator, ViewSlot, ResourceRegistry, CompositionEngine} from 'aurelia-templating'; import {Plugins} from './plugins'; var logger = LogManager.getLogger('aurelia'), @@ -19,7 +13,7 @@ function loadResources(container, resourcesToLoad, appResources){ function next(){ if(current = resourcesToLoad.shift()){ - return resourceCoordinator.importResources(current).then(resources => { + return resourceCoordinator.importResources(current, current.resourceManifestUrl).then(resources => { resources.forEach(x => x.register(appResources)); return next(); }); @@ -31,48 +25,87 @@ function loadResources(container, resourcesToLoad, appResources){ return next(); } +/** + * The framework core that provides the main Aurelia object. + * + * @class Aurelia + * @constructor + * @param {Loader} loader The loader for this Aurelia instance to use. If a loader is not specified, Aurelia will use a defaultLoader. + * @param {Container} container The dependency injection container for this Aurelia instance to use. If a container is not specified, Aurelia will create an empty container. + * @param {ResourceRegistry} resources The resource registry for this Aurelia instance to use. If a resource registry is not specified, Aurelia will create an empty registry. + */ export class Aurelia { constructor(loader, container, resources){ this.loader = loader || Loader.createDefaultLoader(); this.container = container || new Container(); this.resources = resources || new ResourceRegistry(); this.resourcesToLoad = []; - this.plugins = new Plugins(this); + this.use = new Plugins(this); + + if(!this.resources.baseResourcePath){ + this.resources.baseResourcePath = System.baseUrl || ''; + } this.withInstance(Aurelia, this); this.withInstance(Loader, this.loader); this.withInstance(ResourceRegistry, this.resources); } + /** + * Adds an existing object to the framework's dependency injection container. + * + * @method withInstance + * @param {Class} type The object type of the dependency that the framework will inject. + * @param {Object} instance The existing instance of the dependency that the framework will inject. + * @return {Aurelia} Returns the current Aurelia instance. + */ withInstance(type, instance){ this.container.registerInstance(type, instance); return this; } + /** + * Adds a singleton to the framework's dependency injection container. + * + * @method withSingleton + * @param {Class} type The object type of the dependency that the framework will inject. + * @param {Object} implementation The constructor function of the dependency that the framework will inject. + * @return {Aurelia} Returns the current Aurelia instance. + */ withSingleton(type, implementation){ this.container.registerSingleton(type, implementation); return this; } + /** + * Adds a resource to be imported into the Aurelia framework. + * + * @method withResources + * @param {Object|Array} resources The constructor function(s) to use when the dependency needs to be instantiated. + * @return {Aurelia} Returns the current Aurelia instance. + */ withResources(resources){ - if (Array.isArray(resources)) { - this.resourcesToLoad.push(resources); - } else { - this.resourcesToLoad.push(slice.call(arguments)); - } - + var toAdd = Array.isArray(resources) ? resources : slice.call(arguments); + toAdd.resourceManifestUrl = this.currentPluginId; + this.resourcesToLoad.push(toAdd); return this; } + /** + * Loads plugins, then resources, and then starts the Aurelia instance. + * + * @method start + * @return {Aurelia} Returns the started Aurelia instance. + */ start(){ if(this.started){ - return; + return Promise.resolve(this); } this.started = true; logger.info('Aurelia Starting'); - return this.plugins.process().then(() => { + return this.use._process().then(() => { if(!this.container.hasHandler(BindingLanguage)){ logger.error('You must configure Aurelia with a BindingLanguage implementation.'); } @@ -84,6 +117,14 @@ export class Aurelia { }); } + /** + * Instantiates the root view-model and view and add them to the DOM. + * + * @method withSingleton + * @param {Object} root The root view-model to load upon bootstrap. + * @param {string|Object} applicationHost The DOM object that Aurelia will attach to. + * @return {Aurelia} Returns the current Aurelia instance. + */ setRoot(root, applicationHost){ var compositionEngine, instruction = {}; @@ -98,8 +139,9 @@ export class Aurelia { compositionEngine = this.container.get(CompositionEngine); instruction.viewModel = root; - instruction.viewSlot = new ViewSlot(this.host, true); instruction.container = instruction.childContainer = this.container; + instruction.viewSlot = new ViewSlot(this.host, true); + instruction.viewSlot.transformChildNodesIntoView(); return compositionEngine.compose(instruction).then(root => { this.root = root; diff --git a/dist/es6/index.js b/dist/es6/index.js index 19b53a73..16b2b623 100644 --- a/dist/es6/index.js +++ b/dist/es6/index.js @@ -1,3 +1,9 @@ +/** + * The aurelia framework brings together all the required core aurelia libraries into a ready-to-go application-building platform. + * + * @module framework + */ + export {Aurelia} from './aurelia'; export * from 'aurelia-dependency-injection'; export * from 'aurelia-binding'; diff --git a/dist/es6/plugins.js b/dist/es6/plugins.js index d738852b..3e545355 100644 --- a/dist/es6/plugins.js +++ b/dist/es6/plugins.js @@ -1,16 +1,20 @@ import * as LogManager from 'aurelia-logging'; +import {Metadata} from 'aurelia-metadata'; var logger = LogManager.getLogger('aurelia'); function loadPlugin(aurelia, loader, info){ logger.debug(`Loading plugin ${info.moduleId}.`); + aurelia.currentPluginId = info.moduleId; + return loader.loadModule(info.moduleId, '').then(exportedValue => { if('install' in exportedValue){ var result = exportedValue.install(aurelia, info.config || {}); if(result){ return result.then(() =>{ + aurelia.currentPluginId = null; logger.debug(`Installed plugin ${info.moduleId}.`); }); }else{ @@ -19,33 +23,90 @@ function loadPlugin(aurelia, loader, info){ }else{ logger.debug(`Loaded plugin ${info.moduleId}.`); } + + aurelia.currentPluginId = null; }); } +/** + * Manages loading and installing plugins. + * + * @class Plugins + * @constructor + * @param {Aurelia} aurelia An instance of Aurelia. + */ export class Plugins { constructor(aurelia){ this.aurelia = aurelia; this.info = []; + this.processed = false; } - install(moduleId, config){ - this.info.push({moduleId:moduleId, config:config}); + /** + * Installs a plugin before Aurelia starts. + * + * @method plugin + * @param {moduleId} moduleId The ID of the module to install. + * @param {config} config The configuration for the specified module. + * @return {Plugins} Returns the current Plugins instance. + */ + plugin(moduleId, config){ + var plugin = {moduleId:moduleId, config:config || {}}; + + if(this.processed){ + loadPlugin(this.aurelia, this.aurelia.loader, plugin); + }else{ + this.info.push(plugin); + } + return this; } - process(){ + /** + * Installs special support for ES5 authoring. + * + * @method es5 + * @return {Plugins} Returns the current Plugins instance. + */ + es5(){ + Function.prototype.computed = function(computedProperties){ + for(var key in computedProperties){ + if(computedProperties.hasOwnProperty(key)){ + Object.defineProperty(this.prototype, key, { get: prop[key], enumerable: true }); + } + } + } + } + + /** + * Installs special support for AtScript authoring. + * + * @method atscript + * @return {Plugins} Returns the current Plugins instance. + */ + atscript(){ + this.aurelia.container.supportAtScript(); + Metadata.configure.location('annotate'); + } + + _process(){ var aurelia = this.aurelia, loader = aurelia.loader, info = this.info, current; - var next = function(){ + if(this.processed){ + return; + } + + var next = () => { if(current = info.shift()){ return loadPlugin(aurelia, loader, current).then(next); } + this.processed = true; return Promise.resolve(); - } + }; return next(); } diff --git a/dist/system/aurelia.js b/dist/system/aurelia.js index adc3e65e..870846e2 100644 --- a/dist/system/aurelia.js +++ b/dist/system/aurelia.js @@ -5,11 +5,9 @@ System.register(["aurelia-logging", "aurelia-dependency-injection", "aurelia-loa function loadResources(container, resourcesToLoad, appResources) { - var resourceCoordinator = container.get(ResourceCoordinator), current; - - function next() { + var next = function () { if (current = resourcesToLoad.shift()) { - return resourceCoordinator.importResources(current).then(function (resources) { + return resourceCoordinator.importResources(current, current.resourceManifestUrl).then(function (resources) { resources.forEach(function (x) { return x.register(appResources); }); @@ -18,7 +16,10 @@ System.register(["aurelia-logging", "aurelia-dependency-injection", "aurelia-loa } return Promise.resolve(); - } + }; + + var resourceCoordinator = container.get(ResourceCoordinator), + current; return next(); } @@ -53,7 +54,11 @@ System.register(["aurelia-logging", "aurelia-dependency-injection", "aurelia-loa this.container = container || new Container(); this.resources = resources || new ResourceRegistry(); this.resourcesToLoad = []; - this.plugins = new Plugins(this); + this.use = new Plugins(this); + + if (!this.resources.baseResourcePath) { + this.resources.baseResourcePath = System.baseUrl || ""; + } this.withInstance(Aurelia, this); this.withInstance(Loader, this.loader); @@ -62,7 +67,7 @@ System.register(["aurelia-logging", "aurelia-dependency-injection", "aurelia-loa _prototypeProperties(Aurelia, null, { withInstance: { - value: function (type, instance) { + value: function withInstance(type, instance) { this.container.registerInstance(type, instance); return this; }, @@ -71,7 +76,7 @@ System.register(["aurelia-logging", "aurelia-dependency-injection", "aurelia-loa configurable: true }, withSingleton: { - value: function (type, implementation) { + value: function withSingleton(type, implementation) { this.container.registerSingleton(type, implementation); return this; }, @@ -80,13 +85,10 @@ System.register(["aurelia-logging", "aurelia-dependency-injection", "aurelia-loa configurable: true }, withResources: { - value: function (resources) { - if (Array.isArray(resources)) { - this.resourcesToLoad.push(resources); - } else { - this.resourcesToLoad.push(slice.call(arguments)); - } - + value: function withResources(resources) { + var toAdd = Array.isArray(resources) ? resources : slice.call(arguments); + toAdd.resourceManifestUrl = this.currentPluginId; + this.resourcesToLoad.push(toAdd); return this; }, writable: true, @@ -94,16 +96,16 @@ System.register(["aurelia-logging", "aurelia-dependency-injection", "aurelia-loa configurable: true }, start: { - value: function () { + value: function start() { var _this = this; if (this.started) { - return; + return Promise.resolve(this); } this.started = true; logger.info("Aurelia Starting"); - return this.plugins.process().then(function () { + return this.use._process().then(function () { if (!_this.container.hasHandler(BindingLanguage)) { logger.error("You must configure Aurelia with a BindingLanguage implementation."); } @@ -119,9 +121,10 @@ System.register(["aurelia-logging", "aurelia-dependency-injection", "aurelia-loa configurable: true }, setRoot: { - value: function (root, applicationHost) { + value: function setRoot(root, applicationHost) { var _this2 = this; - var compositionEngine, instruction = {}; + var compositionEngine, + instruction = {}; if (!applicationHost || typeof applicationHost == "string") { this.host = document.getElementById(applicationHost || "applicationHost") || document.body; @@ -134,8 +137,9 @@ System.register(["aurelia-logging", "aurelia-dependency-injection", "aurelia-loa compositionEngine = this.container.get(CompositionEngine); instruction.viewModel = root; - instruction.viewSlot = new ViewSlot(this.host, true); instruction.container = instruction.childContainer = this.container; + instruction.viewSlot = new ViewSlot(this.host, true); + instruction.viewSlot.transformChildNodesIntoView(); return compositionEngine.compose(instruction).then(function (root) { _this2.root = root; diff --git a/dist/system/plugins.js b/dist/system/plugins.js index 09e4f0de..d0370a80 100644 --- a/dist/system/plugins.js +++ b/dist/system/plugins.js @@ -1,18 +1,21 @@ -System.register(["aurelia-logging"], function (_export) { +System.register(["aurelia-logging", "aurelia-metadata"], function (_export) { "use strict"; - var LogManager, _prototypeProperties, logger, Plugins; + var LogManager, Metadata, _prototypeProperties, logger, Plugins; function loadPlugin(aurelia, loader, info) { logger.debug("Loading plugin " + info.moduleId + "."); + aurelia.currentPluginId = 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 () { + aurelia.currentPluginId = null; logger.debug("Installed plugin " + info.moduleId + "."); }); } else { @@ -21,12 +24,16 @@ System.register(["aurelia-logging"], function (_export) { } else { logger.debug("Loaded plugin " + info.moduleId + "."); } + + aurelia.currentPluginId = null; }); } return { setters: [function (_aureliaLogging) { LogManager = _aureliaLogging; + }, function (_aureliaMetadata) { + Metadata = _aureliaMetadata.Metadata; }], execute: function () { _prototypeProperties = function (child, staticProps, instanceProps) { @@ -39,30 +46,67 @@ System.register(["aurelia-logging"], function (_export) { function Plugins(aurelia) { this.aurelia = aurelia; this.info = []; + this.processed = false; } _prototypeProperties(Plugins, null, { - install: { - value: function (moduleId, config) { - this.info.push({ moduleId: moduleId, config: config }); + plugin: { + value: function plugin(moduleId, config) { + var plugin = { moduleId: moduleId, config: config || {} }; + + if (this.processed) { + loadPlugin(this.aurelia, this.aurelia.loader, plugin); + } else { + this.info.push(plugin); + } + return this; }, writable: true, enumerable: true, configurable: true }, - process: { - value: function () { + es5: { + value: function es5() { + Function.prototype.computed = function (computedProperties) { + for (var key in computedProperties) { + if (computedProperties.hasOwnProperty(key)) { + Object.defineProperty(this.prototype, key, { get: prop[key], enumerable: true }); + } + } + }; + }, + writable: true, + enumerable: true, + configurable: true + }, + atscript: { + value: function atscript() { + this.aurelia.container.supportAtScript(); + Metadata.configure.location("annotate"); + }, + writable: true, + enumerable: true, + configurable: true + }, + _process: { + value: function Process() { + var _this = this; var aurelia = this.aurelia, loader = aurelia.loader, info = this.info, current; + if (this.processed) { + return; + } + var next = function () { if (current = info.shift()) { return loadPlugin(aurelia, loader, current).then(next); } + _this.processed = true; return Promise.resolve(); }; diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 1d99e7e8..60996970 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -1,3 +1,22 @@ +## 0.8.0 (2015-01-22) + + +#### Bug Fixes + +* **aurelia:** ensure all start code paths return a promise ([02752512](http://github.com/aurelia/framework/commit/0275251243271e30a7a484903ff0dd5a0da8eb80)) +* **package:** update dependencies ([b52b1b05](http://github.com/aurelia/framework/commit/b52b1b050a3d5809f7b0f602ebc8479f3d57eecb)) + + +#### Features + +* **aurelia:** enable splash screen swaps on load ([c2135d41](http://github.com/aurelia/framework/commit/c2135d41333328a2c7a6acfe4e0325d5c6bfb090)) +* **plugins:** + * update atscript helper to use new metadata api ([c9b4fb99](http://github.com/aurelia/framework/commit/c9b4fb99b1ac32fb71a69ad8e945cd4a208ca1eb)) + * enable loading after bootstrapped ([790c9da2](http://github.com/aurelia/framework/commit/790c9da2ba89018d25f1dcf6c929b421f47c0b73)) + * new plugin api including explicit support for es5 and at script ([b5c588bc](http://github.com/aurelia/framework/commit/b5c588bc716955273833ebbeabb33deb431bda5d)) + * track plugin id for relative resource loading without system hack ([3465e849](http://github.com/aurelia/framework/commit/3465e84963e871b713cc4c3ca049eb459023ec9e)) + + ## 0.7.0 (2015-01-12) diff --git a/doc/api.json b/doc/api.json index 6de3c0a9..5837e9ce 100644 --- a/doc/api.json +++ b/doc/api.json @@ -1 +1 @@ -{"classes":[],"methods":[],"properties":[],"events":[]} \ No newline at end of file +{"name":"framework","description":"The aurelia framework brings together all the required core aurelia libraries into a ready-to-go application-building platform.","classes":[{"name":"Aurelia","file":"aurelia/framework/src/aurelia.js","line":28,"description":"The framework core that provides the main Aurelia object.","is_constructor":1,"params":[{"name":"loader","description":"The loader for this Aurelia instance to use. If a loader is not specified, Aurelia will use a defaultLoader.","type":"Loader"},{"name":"container","description":"The dependency injection container for this Aurelia instance to use. If a container is not specified, Aurelia will create an empty container.","type":"Container"},{"name":"resources","description":"The resource registry for this Aurelia instance to use. If a resource registry is not specified, Aurelia will create an empty registry.","type":"ResourceRegistry"}],"methods":[{"line":54,"description":"Adds an existing object to the framework's dependency injection container.","name":"withInstance","params":[{"name":"type","description":"The object type of the dependency that the framework will inject.","type":"Class"},{"name":"instance","description":"The existing instance of the dependency that the framework will inject.","type":"Object"}],"return":{"description":"Returns the current Aurelia instance.","type":"Aurelia"}},{"line":67,"description":"Adds a singleton to the framework's dependency injection container.","name":"withSingleton","params":[{"name":"type","description":"The object type of the dependency that the framework will inject.","type":"Class"},{"name":"implementation","description":"The constructor function of the dependency that the framework will inject.","type":"Object"}],"return":{"description":"Returns the current Aurelia instance.","type":"Aurelia"}},{"line":80,"description":"Adds a resource to be imported into the Aurelia framework.","name":"withResources","params":[{"name":"resources","description":"The constructor function(s) to use when the dependency needs to be instantiated.","type":"Object|Array"}],"return":{"description":"Returns the current Aurelia instance.","type":"Aurelia"}},{"line":94,"description":"Loads plugins, then resources, and then starts the Aurelia instance.","name":"start","return":{"description":"Returns the started Aurelia instance.","type":"Aurelia"}},{"line":120,"description":"Instantiates the root view-model and view and add them to the DOM.","name":"withSingleton","params":[{"name":"root","description":"The root view-model to load upon bootstrap.","type":"Object"},{"name":"applicationHost","description":"The DOM object that Aurelia will attach to.","type":"String|Object"}],"return":{"description":"Returns the current Aurelia instance.","type":"Aurelia"}}],"properties":[],"events":[]},{"name":"Plugins","file":"aurelia/framework/src/plugins.js","line":31,"description":"Manages loading and installing plugins.","is_constructor":1,"params":[{"name":"aurelia","description":"An instance of Aurelia.","type":"Aurelia"}],"methods":[{"line":45,"description":"Installs a plugin before Aurelia starts.","name":"plugin","params":[{"name":"moduleId","description":"The ID of the module to install.","type":"ModuleId"},{"name":"config","description":"The configuration for the specified module.","type":"Config"}],"return":{"description":"Returns the current Plugins instance.","type":"Plugins"}},{"line":65,"description":"Installs special support for ES5 authoring.","name":"es5","return":{"description":"Returns the current Plugins instance.","type":"Plugins"}},{"line":81,"description":"Installs special support for AtScript authoring.","name":"atscript","return":{"description":"Returns the current Plugins instance.","type":"Plugins"}}],"properties":[],"events":[]}],"methods":[],"properties":[],"events":[]} \ No newline at end of file diff --git a/package.json b/package.json index 8e246b08..33f8f605 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aurelia-framework", - "version": "0.7.0", + "version": "0.8.0", "description": "The aurelia framework brings together all the required core aurelia libraries into a ready-to-go application-building platform.", "keywords": [ "aurelia",