From 10cc026ee95c4124ae3a8c12e358d7cce0f545a7 Mon Sep 17 00:00:00 2001 From: Rob Eisenberg Date: Wed, 25 Mar 2015 02:25:55 -0400 Subject: [PATCH] chore(all): prepare release 0.9.0 --- README.md | 2 +- bower.json | 19 ++++---- config.js | 44 +++++++++-------- dist/amd/aurelia.js | 96 ++++++++++++++++++++++--------------- dist/amd/plugins.js | 4 +- dist/commonjs/aurelia.js | 99 +++++++++++++++++++++++--------------- dist/commonjs/plugins.js | 4 +- dist/es6/aurelia.js | 82 ++++++++++++++++++------------- dist/es6/plugins.js | 6 +-- dist/system/aurelia.js | 101 +++++++++++++++++++++++---------------- dist/system/plugins.js | 4 +- doc/CHANGELOG.md | 17 +++++++ doc/api.json | 2 +- package.json | 16 +++---- 14 files changed, 291 insertions(+), 205 deletions(-) diff --git a/README.md b/README.md index 55bbc07e..9a5792a5 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This library is part of the [Aurelia](http://www.aurelia.io/) platform and contains the aurelia framework which brings together all the required core aurelia libraries into a ready-to-go application-building platform. -> To keep up to date on [Aurelia](http://www.aurelia.io/), please visit and subscribe to [the official blog](http://blog.durandal.io/). If you have questions, we invite you to join us on [our Gitter Channel](https://gitter.im/aurelia/discuss). +> To keep up to date on [Aurelia](http://www.aurelia.io/), please visit and subscribe to [the official blog](http://blog.durandal.io/). If you have questions, we invite you to join us on [![Join the chat at https://gitter.im/aurelia/discuss](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/aurelia/discuss?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge). ## Dependencies diff --git a/bower.json b/bower.json index 12d4541e..cd11f7e1 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "aurelia-framework", - "version": "0.8.8", + "version": "0.9.0", "description": "The aurelia framework brings together all the required core aurelia libraries into a ready-to-go application-building platform.", "keywords": [ "aurelia", @@ -17,12 +17,13 @@ "url": "http://github.com/aurelia/framework" }, "dependencies": { - "aurelia-binding": "^0.3.2", - "aurelia-dependency-injection": "^0.4.1", - "aurelia-loader": "^0.3.3", - "aurelia-logging": "^0.2.2", - "aurelia-metadata": "^0.3.0", - "aurelia-task-queue": "^0.2.2", - "aurelia-templating": "^0.8.4" + "aurelia-binding": "^0.4.0", + "aurelia-dependency-injection": "^0.5.0", + "aurelia-loader": "^0.4.0", + "aurelia-logging": "^0.2.6", + "aurelia-metadata": "^0.3.4", + "aurelia-path": "^0.4.6", + "aurelia-task-queue": "^0.2.5", + "aurelia-templating": "^0.9.0" } -} \ No newline at end of file +} diff --git a/config.js b/config.js index 91ae2199..07e39f12 100644 --- a/config.js +++ b/config.js @@ -9,41 +9,43 @@ System.config({ System.config({ "map": { - "aurelia-binding": "github:aurelia/binding@0.3.7", - "aurelia-dependency-injection": "github:aurelia/dependency-injection@0.4.5", - "aurelia-loader": "github:aurelia/loader@0.3.5", - "aurelia-logging": "github:aurelia/logging@0.2.5", - "aurelia-metadata": "github:aurelia/metadata@0.3.3", - "aurelia-path": "github:aurelia/path@0.4.5", + "aurelia-binding": "github:aurelia/binding@0.4.0", + "aurelia-dependency-injection": "github:aurelia/dependency-injection@0.5.0", + "aurelia-loader": "github:aurelia/loader@0.4.0", + "aurelia-logging": "github:aurelia/logging@0.2.6", + "aurelia-metadata": "github:aurelia/metadata@0.3.4", + "aurelia-path": "github:aurelia/path@0.4.6", "aurelia-task-queue": "github:aurelia/task-queue@0.2.5", - "aurelia-templating": "github:aurelia/templating@0.8.14", - "github:aurelia/binding@0.3.7": { - "aurelia-dependency-injection": "github:aurelia/dependency-injection@0.4.5", - "aurelia-metadata": "github:aurelia/metadata@0.3.3", + "aurelia-templating": "github:aurelia/templating@0.9.0", + "github:aurelia/binding@0.4.0": { + "aurelia-dependency-injection": "github:aurelia/dependency-injection@0.5.0", + "aurelia-metadata": "github:aurelia/metadata@0.3.4", "aurelia-task-queue": "github:aurelia/task-queue@0.2.5" }, - "github:aurelia/dependency-injection@0.4.5": { - "aurelia-metadata": "github:aurelia/metadata@0.3.3", + "github:aurelia/dependency-injection@0.5.0": { + "aurelia-logging": "github:aurelia/logging@0.2.6", + "aurelia-metadata": "github:aurelia/metadata@0.3.4", "core-js": "npm:core-js@0.4.10" }, - "github:aurelia/loader@0.3.5": { + "github:aurelia/loader@0.4.0": { "aurelia-html-template-element": "github:aurelia/html-template-element@0.1.3", + "aurelia-path": "github:aurelia/path@0.4.6", "core-js": "npm:core-js@0.4.10", "webcomponentsjs": "github:webcomponents/webcomponentsjs@0.5.5" }, - "github:aurelia/templating@0.8.14": { - "aurelia-binding": "github:aurelia/binding@0.3.7", - "aurelia-dependency-injection": "github:aurelia/dependency-injection@0.4.5", + "github:aurelia/templating@0.9.0": { + "aurelia-binding": "github:aurelia/binding@0.4.0", + "aurelia-dependency-injection": "github:aurelia/dependency-injection@0.5.0", "aurelia-html-template-element": "github:aurelia/html-template-element@0.1.3", - "aurelia-loader": "github:aurelia/loader@0.3.5", - "aurelia-logging": "github:aurelia/logging@0.2.5", - "aurelia-metadata": "github:aurelia/metadata@0.3.3", - "aurelia-path": "github:aurelia/path@0.4.5", + "aurelia-loader": "github:aurelia/loader@0.4.0", + "aurelia-logging": "github:aurelia/logging@0.2.6", + "aurelia-metadata": "github:aurelia/metadata@0.3.4", + "aurelia-path": "github:aurelia/path@0.4.6", "aurelia-task-queue": "github:aurelia/task-queue@0.2.5", "core-js": "npm:core-js@0.4.10" }, "github:jspm/nodelibs-process@0.1.1": { - "process": "npm:process@0.10.0" + "process": "npm:process@0.10.1" }, "npm:core-js@0.4.10": { "process": "github:jspm/nodelibs-process@0.1.1" diff --git a/dist/amd/aurelia.js b/dist/amd/aurelia.js index 345aae6c..26ae9a0f 100644 --- a/dist/amd/aurelia.js +++ b/dist/amd/aurelia.js @@ -1,4 +1,4 @@ -define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-loader", "aurelia-templating", "./plugins"], function (exports, _aureliaLogging, _aureliaDependencyInjection, _aureliaLoader, _aureliaTemplating, _plugins) { +define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-loader", "aurelia-path", "./plugins", "aurelia-templating"], function (exports, _aureliaLogging, _aureliaDependencyInjection, _aureliaLoader, _aureliaPath, _plugins, _aureliaTemplating) { "use strict"; var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; @@ -8,13 +8,15 @@ define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-l var LogManager = _aureliaLogging; var Container = _aureliaDependencyInjection.Container; var Loader = _aureliaLoader.Loader; + var join = _aureliaPath.join; + var relativeToFile = _aureliaPath.relativeToFile; + var Plugins = _plugins.Plugins; var BindingLanguage = _aureliaTemplating.BindingLanguage; - var ResourceCoordinator = _aureliaTemplating.ResourceCoordinator; + var ViewEngine = _aureliaTemplating.ViewEngine; var ViewSlot = _aureliaTemplating.ViewSlot; var ResourceRegistry = _aureliaTemplating.ResourceRegistry; var CompositionEngine = _aureliaTemplating.CompositionEngine; var Animator = _aureliaTemplating.Animator; - var Plugins = _plugins.Plugins; var logger = LogManager.getLogger("aurelia"), slice = Array.prototype.slice; @@ -48,23 +50,17 @@ define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-l } function loadResources(container, resourcesToLoad, appResources) { - var resourceCoordinator = container.get(ResourceCoordinator), - current; - - function next() { - if (current = resourcesToLoad.shift()) { - return resourceCoordinator.importResources(current, current.resourceManifestUrl).then(function (resources) { - resources.forEach(function (x) { - return x.register(appResources); - }); - return next(); - }); - } - - return Promise.resolve(); + var viewEngine = container.get(ViewEngine), + importIds = Object.keys(resourcesToLoad), + names = new Array(importIds.length), + i, + ii; + + for (i = 0, ii = importIds.length; i < ii; ++i) { + names[i] = resourcesToLoad[importIds[i]]; } - return next(); + return viewEngine.importViewResources(importIds, names, appResources); } /** @@ -81,15 +77,11 @@ define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-l function Aurelia(loader, container, resources) { _classCallCheck(this, Aurelia); - this.loader = loader || Loader.createDefaultLoader(); + this.loader = loader || new window.AureliaLoader(); this.container = container || new Container(); this.resources = resources || new ResourceRegistry(); - this.resourcesToLoad = []; this.use = new Plugins(this); - - if (!this.resources.baseResourcePath) { - this.resources.baseResourcePath = System.baseUrl || ""; - } + this.resourcesToLoad = {}; this.withInstance(Aurelia, this); this.withInstance(Loader, this.loader); @@ -133,20 +125,48 @@ define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-l writable: true, configurable: true }, - withResources: { + globalizeResources: { /** - * Adds a resource to be imported into the Aurelia framework. + * Adds globally available view resources 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. + * @method globalizeResources + * @param {Object|Array} resources The relative module id to the resource. (Relative to the plugin's installer.) * @return {Aurelia} Returns the current Aurelia instance. */ - value: function withResources(resources) { - var toAdd = Array.isArray(resources) ? resources : slice.call(arguments); - toAdd.resourceManifestUrl = this.currentPluginId; - this.resourcesToLoad.push(toAdd); + value: function globalizeResources(resources) { + var toAdd = Array.isArray(resources) ? resources : arguments, + i, + ii, + pluginPath = this.currentPluginId || "", + path, + internalPlugin = pluginPath.startsWith("./"); + + for (i = 0, ii = toAdd.length; i < ii; ++i) { + path = internalPlugin ? relativeToFile(toAdd[i], pluginPath) : join(pluginPath, toAdd[i]); + + this.resourcesToLoad[path] = this.resourcesToLoad[path]; + } + + return this; + }, + writable: true, + configurable: true + }, + renameGlobalResource: { + + /** + * Renames a global resource that was imported. + * + * @method renameGlobalResource + * @param {String} resourcePath The path to the resource. + * @param {String} newName The new name. + * @return {Aurelia} Returns the current Aurelia instance. + */ + + value: function renameGlobalResource(resourcePath, newName) { + this.resourcesToLoad[resourcePath] = newName; return this; }, writable: true, @@ -173,9 +193,6 @@ define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-l preventActionlessFormSubmit(); - var resourcesToLoad = this.resourcesToLoad; - this.resourcesToLoad = []; - return this.use._process().then(function () { if (!_this.container.hasHandler(BindingLanguage)) { var message = "You must configure Aurelia with a BindingLanguage implementation."; @@ -184,11 +201,9 @@ define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-l } if (!_this.container.hasHandler(Animator)) { - _this.withInstance(Animator, new Animator()); + Animator.configureDefault(_this.container); } - _this.resourcesToLoad = _this.resourcesToLoad.concat(resourcesToLoad); - return loadResources(_this.container, _this.resourcesToLoad, _this.resources).then(function () { logger.info("Aurelia Started"); var evt = new window.CustomEvent("aurelia-started", { bubbles: true, cancelable: true }); @@ -211,9 +226,12 @@ define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-l * @return {Aurelia} Returns the current Aurelia instance. */ - value: function setRoot(root, applicationHost) { + value: function setRoot() { var _this = this; + var root = arguments[0] === undefined ? "app" : arguments[0]; + var applicationHost = arguments[1] === undefined ? null : arguments[1]; + var compositionEngine, instruction = {}; diff --git a/dist/amd/plugins.js b/dist/amd/plugins.js index 37fcd4cc..0cfda78b 100644 --- a/dist/amd/plugins.js +++ b/dist/amd/plugins.js @@ -15,9 +15,7 @@ define(["exports", "aurelia-logging", "aurelia-metadata"], function (exports, _a aurelia.currentPluginId = info.moduleId; - var baseUrl = info.moduleId.indexOf("./") === 0 ? undefined : ""; - - return loader.loadModule(info.moduleId, baseUrl).then(function (exportedValue) { + return loader.loadModule(info.moduleId).then(function (exportedValue) { if ("install" in exportedValue) { var result = exportedValue.install(aurelia, info.config || {}); diff --git a/dist/commonjs/aurelia.js b/dist/commonjs/aurelia.js index 9d67834a..62eab6a3 100644 --- a/dist/commonjs/aurelia.js +++ b/dist/commonjs/aurelia.js @@ -12,17 +12,22 @@ var Container = require("aurelia-dependency-injection").Container; var Loader = require("aurelia-loader").Loader; +var _aureliaPath = require("aurelia-path"); + +var join = _aureliaPath.join; +var relativeToFile = _aureliaPath.relativeToFile; + +var Plugins = require("./plugins").Plugins; + var _aureliaTemplating = require("aurelia-templating"); var BindingLanguage = _aureliaTemplating.BindingLanguage; -var ResourceCoordinator = _aureliaTemplating.ResourceCoordinator; +var ViewEngine = _aureliaTemplating.ViewEngine; var ViewSlot = _aureliaTemplating.ViewSlot; var ResourceRegistry = _aureliaTemplating.ResourceRegistry; var CompositionEngine = _aureliaTemplating.CompositionEngine; var Animator = _aureliaTemplating.Animator; -var Plugins = require("./plugins").Plugins; - var logger = LogManager.getLogger("aurelia"), slice = Array.prototype.slice; @@ -55,23 +60,17 @@ function preventActionlessFormSubmit() { } function loadResources(container, resourcesToLoad, appResources) { - var resourceCoordinator = container.get(ResourceCoordinator), - current; - - function next() { - if (current = resourcesToLoad.shift()) { - return resourceCoordinator.importResources(current, current.resourceManifestUrl).then(function (resources) { - resources.forEach(function (x) { - return x.register(appResources); - }); - return next(); - }); - } - - return Promise.resolve(); + var viewEngine = container.get(ViewEngine), + importIds = Object.keys(resourcesToLoad), + names = new Array(importIds.length), + i, + ii; + + for (i = 0, ii = importIds.length; i < ii; ++i) { + names[i] = resourcesToLoad[importIds[i]]; } - return next(); + return viewEngine.importViewResources(importIds, names, appResources); } /** @@ -88,15 +87,11 @@ var Aurelia = exports.Aurelia = (function () { function Aurelia(loader, container, resources) { _classCallCheck(this, Aurelia); - this.loader = loader || Loader.createDefaultLoader(); + this.loader = loader || new window.AureliaLoader(); this.container = container || new Container(); this.resources = resources || new ResourceRegistry(); - this.resourcesToLoad = []; this.use = new Plugins(this); - - if (!this.resources.baseResourcePath) { - this.resources.baseResourcePath = System.baseUrl || ""; - } + this.resourcesToLoad = {}; this.withInstance(Aurelia, this); this.withInstance(Loader, this.loader); @@ -140,20 +135,48 @@ var Aurelia = exports.Aurelia = (function () { writable: true, configurable: true }, - withResources: { + globalizeResources: { /** - * Adds a resource to be imported into the Aurelia framework. + * Adds globally available view resources 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. + * @method globalizeResources + * @param {Object|Array} resources The relative module id to the resource. (Relative to the plugin's installer.) * @return {Aurelia} Returns the current Aurelia instance. */ - value: function withResources(resources) { - var toAdd = Array.isArray(resources) ? resources : slice.call(arguments); - toAdd.resourceManifestUrl = this.currentPluginId; - this.resourcesToLoad.push(toAdd); + value: function globalizeResources(resources) { + var toAdd = Array.isArray(resources) ? resources : arguments, + i, + ii, + pluginPath = this.currentPluginId || "", + path, + internalPlugin = pluginPath.startsWith("./"); + + for (i = 0, ii = toAdd.length; i < ii; ++i) { + path = internalPlugin ? relativeToFile(toAdd[i], pluginPath) : join(pluginPath, toAdd[i]); + + this.resourcesToLoad[path] = this.resourcesToLoad[path]; + } + + return this; + }, + writable: true, + configurable: true + }, + renameGlobalResource: { + + /** + * Renames a global resource that was imported. + * + * @method renameGlobalResource + * @param {String} resourcePath The path to the resource. + * @param {String} newName The new name. + * @return {Aurelia} Returns the current Aurelia instance. + */ + + value: function renameGlobalResource(resourcePath, newName) { + this.resourcesToLoad[resourcePath] = newName; return this; }, writable: true, @@ -180,9 +203,6 @@ var Aurelia = exports.Aurelia = (function () { preventActionlessFormSubmit(); - var resourcesToLoad = this.resourcesToLoad; - this.resourcesToLoad = []; - return this.use._process().then(function () { if (!_this.container.hasHandler(BindingLanguage)) { var message = "You must configure Aurelia with a BindingLanguage implementation."; @@ -191,11 +211,9 @@ var Aurelia = exports.Aurelia = (function () { } if (!_this.container.hasHandler(Animator)) { - _this.withInstance(Animator, new Animator()); + Animator.configureDefault(_this.container); } - _this.resourcesToLoad = _this.resourcesToLoad.concat(resourcesToLoad); - return loadResources(_this.container, _this.resourcesToLoad, _this.resources).then(function () { logger.info("Aurelia Started"); var evt = new window.CustomEvent("aurelia-started", { bubbles: true, cancelable: true }); @@ -218,9 +236,12 @@ var Aurelia = exports.Aurelia = (function () { * @return {Aurelia} Returns the current Aurelia instance. */ - value: function setRoot(root, applicationHost) { + value: function setRoot() { var _this = this; + var root = arguments[0] === undefined ? "app" : arguments[0]; + var applicationHost = arguments[1] === undefined ? null : arguments[1]; + var compositionEngine, instruction = {}; diff --git a/dist/commonjs/plugins.js b/dist/commonjs/plugins.js index 331fee43..4776738b 100644 --- a/dist/commonjs/plugins.js +++ b/dist/commonjs/plugins.js @@ -17,9 +17,7 @@ function loadPlugin(aurelia, loader, info) { aurelia.currentPluginId = info.moduleId; - var baseUrl = info.moduleId.indexOf("./") === 0 ? undefined : ""; - - return loader.loadModule(info.moduleId, baseUrl).then(function (exportedValue) { + return loader.loadModule(info.moduleId).then(function (exportedValue) { if ("install" in exportedValue) { var result = exportedValue.install(aurelia, info.config || {}); diff --git a/dist/es6/aurelia.js b/dist/es6/aurelia.js index e036b119..374e70a4 100644 --- a/dist/es6/aurelia.js +++ b/dist/es6/aurelia.js @@ -1,8 +1,16 @@ import * as LogManager from 'aurelia-logging'; import {Container} from 'aurelia-dependency-injection'; import {Loader} from 'aurelia-loader'; -import {BindingLanguage, ResourceCoordinator, ViewSlot, ResourceRegistry, CompositionEngine, Animator} from 'aurelia-templating'; +import {join,relativeToFile} from 'aurelia-path'; import {Plugins} from './plugins'; +import { + BindingLanguage, + ViewEngine, + ViewSlot, + ResourceRegistry, + CompositionEngine, + Animator +} from 'aurelia-templating'; var logger = LogManager.getLogger('aurelia'), slice = Array.prototype.slice; @@ -36,21 +44,16 @@ function preventActionlessFormSubmit() { } function loadResources(container, resourcesToLoad, appResources){ - var resourceCoordinator = container.get(ResourceCoordinator), - current; - - function next(){ - if(current = resourcesToLoad.shift()){ - return resourceCoordinator.importResources(current, current.resourceManifestUrl).then(resources => { - resources.forEach(x => x.register(appResources)); - return next(); - }); - } + var viewEngine = container.get(ViewEngine), + importIds = Object.keys(resourcesToLoad), + names = new Array(importIds.length), + i, ii; - return Promise.resolve(); + for(i = 0, ii = importIds.length; i < ii; ++i){ + names[i] = resourcesToLoad[importIds[i]]; } - return next(); + return viewEngine.importViewResources(importIds, names, appResources); } /** @@ -64,15 +67,11 @@ function loadResources(container, resourcesToLoad, appResources){ */ export class Aurelia { constructor(loader, container, resources){ - this.loader = loader || Loader.createDefaultLoader(); + this.loader = loader || new window.AureliaLoader(); this.container = container || new Container(); this.resources = resources || new ResourceRegistry(); - this.resourcesToLoad = []; this.use = new Plugins(this); - - if(!this.resources.baseResourcePath){ - this.resources.baseResourcePath = System.baseUrl || ''; - } + this.resourcesToLoad = {}; this.withInstance(Aurelia, this); this.withInstance(Loader, this.loader); @@ -106,16 +105,38 @@ export class Aurelia { } /** - * Adds a resource to be imported into the Aurelia framework. + * Adds globally available view resources 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. + * @method globalizeResources + * @param {Object|Array} resources The relative module id to the resource. (Relative to the plugin's installer.) * @return {Aurelia} Returns the current Aurelia instance. */ - withResources(resources){ - var toAdd = Array.isArray(resources) ? resources : slice.call(arguments); - toAdd.resourceManifestUrl = this.currentPluginId; - this.resourcesToLoad.push(toAdd); + globalizeResources(resources){ + var toAdd = Array.isArray(resources) ? resources : arguments, + i, ii, pluginPath = this.currentPluginId || '', path, + internalPlugin = pluginPath.startsWith('./'); + + for(i = 0, ii = toAdd.length; i < ii; ++i){ + path = internalPlugin + ? relativeToFile(toAdd[i], pluginPath) + : join(pluginPath, toAdd[i]); + + this.resourcesToLoad[path] = this.resourcesToLoad[path]; + } + + return this; + } + + /** + * Renames a global resource that was imported. + * + * @method renameGlobalResource + * @param {String} resourcePath The path to the resource. + * @param {String} newName The new name. + * @return {Aurelia} Returns the current Aurelia instance. + */ + renameGlobalResource(resourcePath, newName){ + this.resourcesToLoad[resourcePath] = newName; return this; } @@ -135,9 +156,6 @@ export class Aurelia { preventActionlessFormSubmit(); - var resourcesToLoad = this.resourcesToLoad; - this.resourcesToLoad = []; - return this.use._process().then(() => { if(!this.container.hasHandler(BindingLanguage)){ var message = 'You must configure Aurelia with a BindingLanguage implementation.'; @@ -146,11 +164,9 @@ export class Aurelia { } if(!this.container.hasHandler(Animator)){ - this.withInstance(Animator, new Animator()); + Animator.configureDefault(this.container); } - this.resourcesToLoad = this.resourcesToLoad.concat(resourcesToLoad); - return loadResources(this.container, this.resourcesToLoad, this.resources).then(() => { logger.info('Aurelia Started'); var evt = new window.CustomEvent('aurelia-started', { bubbles: true, cancelable: true }); @@ -168,7 +184,7 @@ export class Aurelia { * @param {string|Object} applicationHost The DOM object that Aurelia will attach to. * @return {Aurelia} Returns the current Aurelia instance. */ - setRoot(root, applicationHost){ + setRoot(root='app', applicationHost=null){ var compositionEngine, instruction = {}; if (!applicationHost || typeof applicationHost == 'string') { diff --git a/dist/es6/plugins.js b/dist/es6/plugins.js index 9539d177..1eb79183 100644 --- a/dist/es6/plugins.js +++ b/dist/es6/plugins.js @@ -8,9 +8,7 @@ function loadPlugin(aurelia, loader, info){ aurelia.currentPluginId = info.moduleId; - var baseUrl = info.moduleId.indexOf('./') === 0 ? undefined : ""; - - return loader.loadModule(info.moduleId, baseUrl).then(exportedValue => { + return loader.loadModule(info.moduleId).then(exportedValue => { if('install' in exportedValue){ var result = exportedValue.install(aurelia, info.config || {}); @@ -74,7 +72,7 @@ export class Plugins { Function.prototype.computed = function(computedProperties){ for(var key in computedProperties){ if(computedProperties.hasOwnProperty(key)){ - Object.defineProperty(this.prototype, key, { get: computedProperties[key], enumerable: true }); + Object.defineProperty(this.prototype, key, { get: computedProperties[key], enumerable: true }); } } }; diff --git a/dist/system/aurelia.js b/dist/system/aurelia.js index 2a515c5c..2a221144 100644 --- a/dist/system/aurelia.js +++ b/dist/system/aurelia.js @@ -1,5 +1,5 @@ -System.register(["aurelia-logging", "aurelia-dependency-injection", "aurelia-loader", "aurelia-templating", "./plugins"], function (_export) { - var LogManager, Container, Loader, BindingLanguage, ResourceCoordinator, ViewSlot, ResourceRegistry, CompositionEngine, Animator, Plugins, _prototypeProperties, _classCallCheck, logger, slice, CustomEvent, Aurelia; +System.register(["aurelia-logging", "aurelia-dependency-injection", "aurelia-loader", "aurelia-path", "./plugins", "aurelia-templating"], function (_export) { + var LogManager, Container, Loader, join, relativeToFile, Plugins, BindingLanguage, ViewEngine, ViewSlot, ResourceRegistry, CompositionEngine, Animator, _prototypeProperties, _classCallCheck, logger, slice, CustomEvent, Aurelia; function preventActionlessFormSubmit() { document.body.addEventListener("submit", function (evt) { @@ -13,23 +13,17 @@ System.register(["aurelia-logging", "aurelia-dependency-injection", "aurelia-loa } function loadResources(container, resourcesToLoad, appResources) { - var resourceCoordinator = container.get(ResourceCoordinator), - current; - - function next() { - if (current = resourcesToLoad.shift()) { - return resourceCoordinator.importResources(current, current.resourceManifestUrl).then(function (resources) { - resources.forEach(function (x) { - return x.register(appResources); - }); - return next(); - }); - } - - return Promise.resolve(); + var viewEngine = container.get(ViewEngine), + importIds = Object.keys(resourcesToLoad), + names = new Array(importIds.length), + i, + ii; + + for (i = 0, ii = importIds.length; i < ii; ++i) { + names[i] = resourcesToLoad[importIds[i]]; } - return next(); + return viewEngine.importViewResources(importIds, names, appResources); } return { @@ -39,15 +33,18 @@ System.register(["aurelia-logging", "aurelia-dependency-injection", "aurelia-loa Container = _aureliaDependencyInjection.Container; }, function (_aureliaLoader) { Loader = _aureliaLoader.Loader; + }, function (_aureliaPath) { + join = _aureliaPath.join; + relativeToFile = _aureliaPath.relativeToFile; + }, function (_plugins) { + Plugins = _plugins.Plugins; }, function (_aureliaTemplating) { BindingLanguage = _aureliaTemplating.BindingLanguage; - ResourceCoordinator = _aureliaTemplating.ResourceCoordinator; + ViewEngine = _aureliaTemplating.ViewEngine; ViewSlot = _aureliaTemplating.ViewSlot; ResourceRegistry = _aureliaTemplating.ResourceRegistry; CompositionEngine = _aureliaTemplating.CompositionEngine; Animator = _aureliaTemplating.Animator; - }, function (_plugins) { - Plugins = _plugins.Plugins; }], execute: function () { "use strict"; @@ -87,15 +84,11 @@ System.register(["aurelia-logging", "aurelia-dependency-injection", "aurelia-loa function Aurelia(loader, container, resources) { _classCallCheck(this, Aurelia); - this.loader = loader || Loader.createDefaultLoader(); + this.loader = loader || new window.AureliaLoader(); this.container = container || new Container(); this.resources = resources || new ResourceRegistry(); - this.resourcesToLoad = []; this.use = new Plugins(this); - - if (!this.resources.baseResourcePath) { - this.resources.baseResourcePath = System.baseUrl || ""; - } + this.resourcesToLoad = {}; this.withInstance(Aurelia, this); this.withInstance(Loader, this.loader); @@ -139,20 +132,48 @@ System.register(["aurelia-logging", "aurelia-dependency-injection", "aurelia-loa writable: true, configurable: true }, - withResources: { + globalizeResources: { /** - * Adds a resource to be imported into the Aurelia framework. + * Adds globally available view resources 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. + * @method globalizeResources + * @param {Object|Array} resources The relative module id to the resource. (Relative to the plugin's installer.) * @return {Aurelia} Returns the current Aurelia instance. */ - value: function withResources(resources) { - var toAdd = Array.isArray(resources) ? resources : slice.call(arguments); - toAdd.resourceManifestUrl = this.currentPluginId; - this.resourcesToLoad.push(toAdd); + value: function globalizeResources(resources) { + var toAdd = Array.isArray(resources) ? resources : arguments, + i, + ii, + pluginPath = this.currentPluginId || "", + path, + internalPlugin = pluginPath.startsWith("./"); + + for (i = 0, ii = toAdd.length; i < ii; ++i) { + path = internalPlugin ? relativeToFile(toAdd[i], pluginPath) : join(pluginPath, toAdd[i]); + + this.resourcesToLoad[path] = this.resourcesToLoad[path]; + } + + return this; + }, + writable: true, + configurable: true + }, + renameGlobalResource: { + + /** + * Renames a global resource that was imported. + * + * @method renameGlobalResource + * @param {String} resourcePath The path to the resource. + * @param {String} newName The new name. + * @return {Aurelia} Returns the current Aurelia instance. + */ + + value: function renameGlobalResource(resourcePath, newName) { + this.resourcesToLoad[resourcePath] = newName; return this; }, writable: true, @@ -179,9 +200,6 @@ System.register(["aurelia-logging", "aurelia-dependency-injection", "aurelia-loa preventActionlessFormSubmit(); - var resourcesToLoad = this.resourcesToLoad; - this.resourcesToLoad = []; - return this.use._process().then(function () { if (!_this.container.hasHandler(BindingLanguage)) { var message = "You must configure Aurelia with a BindingLanguage implementation."; @@ -190,11 +208,9 @@ System.register(["aurelia-logging", "aurelia-dependency-injection", "aurelia-loa } if (!_this.container.hasHandler(Animator)) { - _this.withInstance(Animator, new Animator()); + Animator.configureDefault(_this.container); } - _this.resourcesToLoad = _this.resourcesToLoad.concat(resourcesToLoad); - return loadResources(_this.container, _this.resourcesToLoad, _this.resources).then(function () { logger.info("Aurelia Started"); var evt = new window.CustomEvent("aurelia-started", { bubbles: true, cancelable: true }); @@ -217,9 +233,12 @@ System.register(["aurelia-logging", "aurelia-dependency-injection", "aurelia-loa * @return {Aurelia} Returns the current Aurelia instance. */ - value: function setRoot(root, applicationHost) { + value: function setRoot() { var _this = this; + var root = arguments[0] === undefined ? "app" : arguments[0]; + var applicationHost = arguments[1] === undefined ? null : arguments[1]; + var compositionEngine, instruction = {}; diff --git a/dist/system/plugins.js b/dist/system/plugins.js index c8cd73ca..cf18a631 100644 --- a/dist/system/plugins.js +++ b/dist/system/plugins.js @@ -6,9 +6,7 @@ System.register(["aurelia-logging", "aurelia-metadata"], function (_export) { aurelia.currentPluginId = info.moduleId; - var baseUrl = info.moduleId.indexOf("./") === 0 ? undefined : ""; - - return loader.loadModule(info.moduleId, baseUrl).then(function (exportedValue) { + return loader.loadModule(info.moduleId).then(function (exportedValue) { if ("install" in exportedValue) { var result = exportedValue.install(aurelia, info.config || {}); diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 91d90fcc..6e1284e1 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -1,3 +1,20 @@ +## 0.9.0 (2015-03-25) + + +#### Bug Fixes + +* **all:** load resources by module id only ([655192b2](http://github.com/aurelia/framework/commit/655192b26f7c8b47fb57ad1522e85af58d971443)) +* **aurelia:** + * update to use latest animator default config api ([5dea25b5](http://github.com/aurelia/framework/commit/5dea25b57512ccf4701daf6520c0156582a5182b)) + * update to use new view engine ([e6d20c42](http://github.com/aurelia/framework/commit/e6d20c42ead1f74652fb1bce5b5ae728b4b6bb77)) + * update to load global resources through new resource pipeline ([bdbca554](http://github.com/aurelia/framework/commit/bdbca554e8d0e7ee839fb1b3b8269f590bc7aa97)) + + +#### Features + +* **aurelia:** add parameter default to setRoot ([f3955d22](http://github.com/aurelia/framework/commit/f3955d228483758ce8b385bba14d99e053468612)) + + ### 0.8.8 (2015-02-28) diff --git a/doc/api.json b/doc/api.json index 5313c57f..91e30260 100644 --- a/doc/api.json +++ b/doc/api.json @@ -1 +1 @@ -{"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":56,"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":82,"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":95,"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":108,"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":122,"description":"Loads plugins, then resources, and then starts the Aurelia instance.","name":"start","return":{"description":"Returns the started Aurelia instance.","type":"Aurelia"}},{"line":163,"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":33,"description":"Manages loading and installing plugins.","is_constructor":1,"params":[{"name":"aurelia","description":"An instance of Aurelia.","type":"Aurelia"}],"methods":[{"line":47,"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":67,"description":"Installs special support for ES5 authoring.","name":"es5","return":{"description":"Returns the current Plugins instance.","type":"Plugins"}},{"line":85,"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 +{"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":59,"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":81,"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":94,"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":107,"description":"Adds globally available view resources to be imported into the Aurelia framework.","name":"globalizeResources","params":[{"name":"resources","description":"The relative module id to the resource. (Relative to the plugin's installer.)","type":"Object|Array"}],"return":{"description":"Returns the current Aurelia instance.","type":"Aurelia"}},{"line":130,"description":"Renames a global resource that was imported.","name":"renameGlobalResource","params":[{"name":"resourcePath","description":"The path to the resource.","type":"String"},{"name":"newName","description":"The new name.","type":"String"}],"return":{"description":"Returns the current Aurelia instance.","type":"Aurelia"}},{"line":143,"description":"Loads plugins, then resources, and then starts the Aurelia instance.","name":"start","return":{"description":"Returns the started Aurelia instance.","type":"Aurelia"}},{"line":179,"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":83,"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 1c75498e..d3191d11 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aurelia-framework", - "version": "0.8.8", + "version": "0.9.0", "description": "The aurelia framework brings together all the required core aurelia libraries into a ready-to-go application-building platform.", "keywords": [ "aurelia", @@ -25,14 +25,14 @@ "lib": "dist/system" }, "dependencies": { - "aurelia-binding": "github:aurelia/binding@^0.3.7", - "aurelia-dependency-injection": "github:aurelia/dependency-injection@^0.4.5", - "aurelia-loader": "github:aurelia/loader@^0.3.5", - "aurelia-logging": "github:aurelia/logging@^0.2.5", - "aurelia-metadata": "github:aurelia/metadata@^0.3.3", - "aurelia-path": "github:aurelia/path@^0.4.5", + "aurelia-binding": "github:aurelia/binding@^0.4.0", + "aurelia-dependency-injection": "github:aurelia/dependency-injection@^0.5.0", + "aurelia-loader": "github:aurelia/loader@^0.4.0", + "aurelia-logging": "github:aurelia/logging@^0.2.6", + "aurelia-metadata": "github:aurelia/metadata@^0.3.4", + "aurelia-path": "github:aurelia/path@^0.4.6", "aurelia-task-queue": "github:aurelia/task-queue@^0.2.5", - "aurelia-templating": "github:aurelia/templating@^0.8.14" + "aurelia-templating": "github:aurelia/templating@^0.9.0" } }, "devDependencies": {