diff --git a/bower.json b/bower.json index 0332f9b5..ec0f3db7 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "aurelia-framework", - "version": "0.8.6", + "version": "0.8.7", "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 4cc8e377..345aae6c 100644 --- a/dist/amd/aurelia.js +++ b/dist/amd/aurelia.js @@ -3,6 +3,8 @@ define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-l var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var LogManager = _aureliaLogging; var Container = _aureliaDependencyInjection.Container; var Loader = _aureliaLoader.Loader; @@ -11,14 +13,14 @@ define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-l 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; if (!window.CustomEvent || typeof window.CustomEvent !== "function") { - var CustomEvent = function (event, params) { + var CustomEvent = function CustomEvent(event, params) { var params = params || { bubbles: false, cancelable: false, @@ -34,6 +36,17 @@ define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-l window.CustomEvent = CustomEvent; } + function preventActionlessFormSubmit() { + document.body.addEventListener("submit", function (evt) { + var target = evt.target; + var action = target.action; + + if (target.tagName.toLowerCase() === "form" && !action) { + evt.preventDefault(); + } + }); + } + function loadResources(container, resourcesToLoad, appResources) { var resourceCoordinator = container.get(ResourceCoordinator), current; @@ -54,8 +67,20 @@ define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-l 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. + */ + var Aurelia = exports.Aurelia = (function () { function Aurelia(loader, container, resources) { + _classCallCheck(this, Aurelia); + this.loader = loader || Loader.createDefaultLoader(); this.container = container || new Container(); this.resources = resources || new ResourceRegistry(); @@ -73,6 +98,16 @@ define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-l _prototypeProperties(Aurelia, null, { withInstance: { + + /** + * 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. + */ + value: function withInstance(type, instance) { this.container.registerInstance(type, instance); return this; @@ -81,6 +116,16 @@ define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-l configurable: true }, withSingleton: { + + /** + * 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. + */ + value: function withSingleton(type, implementation) { this.container.registerSingleton(type, implementation); return this; @@ -89,6 +134,15 @@ define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-l configurable: true }, withResources: { + + /** + * 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. + */ + value: function withResources(resources) { var toAdd = Array.isArray(resources) ? resources : slice.call(arguments); toAdd.resourceManifestUrl = this.currentPluginId; @@ -99,8 +153,17 @@ define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-l configurable: true }, start: { + + /** + * Loads plugins, then resources, and then starts the Aurelia instance. + * + * @method start + * @return {Aurelia} Returns the started Aurelia instance. + */ + value: function start() { var _this = this; + if (this.started) { return Promise.resolve(this); } @@ -108,12 +171,20 @@ define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-l this.started = true; logger.info("Aurelia Starting"); + preventActionlessFormSubmit(); + var resourcesToLoad = this.resourcesToLoad; this.resourcesToLoad = []; return this.use._process().then(function () { if (!_this.container.hasHandler(BindingLanguage)) { - logger.error("You must configure Aurelia with a BindingLanguage implementation."); + var message = "You must configure Aurelia with a BindingLanguage implementation."; + logger.error(message); + throw new Error(message); + } + + if (!_this.container.hasHandler(Animator)) { + _this.withInstance(Animator, new Animator()); } _this.resourcesToLoad = _this.resourcesToLoad.concat(resourcesToLoad); @@ -130,8 +201,19 @@ define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-l configurable: true }, setRoot: { + + /** + * 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. + */ + value: function setRoot(root, applicationHost) { var _this = this; + var compositionEngine, instruction = {}; @@ -167,5 +249,8 @@ define(["exports", "aurelia-logging", "aurelia-dependency-injection", "aurelia-l return Aurelia; })(); - exports.__esModule = true; + + Object.defineProperty(exports, "__esModule", { + value: true + }); }); \ No newline at end of file diff --git a/dist/amd/index.js b/dist/amd/index.js index e186f718..2a4709af 100644 --- a/dist/amd/index.js +++ b/dist/amd/index.js @@ -3,9 +3,16 @@ define(["exports", "./aurelia", "aurelia-dependency-injection", "aurelia-binding var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; }; - var _defaults = function (obj, defaults) { for (var key in defaults) { if (obj[key] === undefined) { obj[key] = defaults[key]; } } return obj; }; + var _defaults = function (obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }; + + /** + * The aurelia framework brings together all the required core aurelia libraries into a ready-to-go application-building platform. + * + * @module framework + */ exports.Aurelia = _aurelia.Aurelia; + _defaults(exports, _interopRequireWildcard(_aureliaDependencyInjection)); _defaults(exports, _interopRequireWildcard(_aureliaBinding)); @@ -20,5 +27,7 @@ define(["exports", "./aurelia", "aurelia-dependency-injection", "aurelia-binding var TheLogManager = _aureliaLogging; var LogManager = exports.LogManager = TheLogManager; - exports.__esModule = true; + Object.defineProperty(exports, "__esModule", { + value: true + }); }); \ No newline at end of file diff --git a/dist/amd/plugins.js b/dist/amd/plugins.js index 39bcefb1..37fcd4cc 100644 --- a/dist/amd/plugins.js +++ b/dist/amd/plugins.js @@ -3,10 +3,11 @@ define(["exports", "aurelia-logging", "aurelia-metadata"], function (exports, _a var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var LogManager = _aureliaLogging; var Metadata = _aureliaMetadata.Metadata; - var logger = LogManager.getLogger("aurelia"); function loadPlugin(aurelia, loader, info) { @@ -14,7 +15,7 @@ define(["exports", "aurelia-logging", "aurelia-metadata"], function (exports, _a aurelia.currentPluginId = info.moduleId; - var baseUrl = info.moduleId.startsWith("./") ? undefined : ""; + var baseUrl = info.moduleId.indexOf("./") === 0 ? undefined : ""; return loader.loadModule(info.moduleId, baseUrl).then(function (exportedValue) { if ("install" in exportedValue) { @@ -36,8 +37,18 @@ define(["exports", "aurelia-logging", "aurelia-metadata"], function (exports, _a }); } + /** + * Manages loading and installing plugins. + * + * @class Plugins + * @constructor + * @param {Aurelia} aurelia An instance of Aurelia. + */ + var Plugins = exports.Plugins = (function () { function Plugins(aurelia) { + _classCallCheck(this, Plugins); + this.aurelia = aurelia; this.info = []; this.processed = false; @@ -45,7 +56,27 @@ define(["exports", "aurelia-logging", "aurelia-metadata"], function (exports, _a _prototypeProperties(Plugins, null, { plugin: { - value: function plugin(moduleId, 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. + */ + + value: (function (_plugin) { + var _pluginWrapper = function plugin(_x, _x2) { + return _plugin.apply(this, arguments); + }; + + _pluginWrapper.toString = function () { + return _plugin.toString(); + }; + + return _pluginWrapper; + })(function (moduleId, config) { var plugin = { moduleId: moduleId, config: config || {} }; if (this.processed) { @@ -55,11 +86,19 @@ define(["exports", "aurelia-logging", "aurelia-metadata"], function (exports, _a } return this; - }, + }), writable: true, configurable: true }, es5: { + + /** + * Installs special support for ES5 authoring. + * + * @method es5 + * @return {Plugins} Returns the current Plugins instance. + */ + value: function es5() { Function.prototype.computed = function (computedProperties) { for (var key in computedProperties) { @@ -75,6 +114,14 @@ define(["exports", "aurelia-logging", "aurelia-metadata"], function (exports, _a configurable: true }, atscript: { + + /** + * Installs special support for AtScript authoring. + * + * @method atscript + * @return {Plugins} Returns the current Plugins instance. + */ + value: function atscript() { this.aurelia.container.supportAtScript(); Metadata.configure.locator(function (fn) { @@ -88,6 +135,7 @@ define(["exports", "aurelia-logging", "aurelia-metadata"], function (exports, _a _process: { value: function _process() { var _this = this; + var aurelia = this.aurelia, loader = aurelia.loader, info = this.info, @@ -115,5 +163,8 @@ define(["exports", "aurelia-logging", "aurelia-metadata"], function (exports, _a return Plugins; })(); - exports.__esModule = true; + + Object.defineProperty(exports, "__esModule", { + value: true + }); }); \ No newline at end of file diff --git a/dist/commonjs/aurelia.js b/dist/commonjs/aurelia.js index 3bf74c0f..9d67834a 100644 --- a/dist/commonjs/aurelia.js +++ b/dist/commonjs/aurelia.js @@ -4,10 +4,14 @@ var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? ob var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; +var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var LogManager = _interopRequireWildcard(require("aurelia-logging")); var Container = require("aurelia-dependency-injection").Container; + var Loader = require("aurelia-loader").Loader; + var _aureliaTemplating = require("aurelia-templating"); var BindingLanguage = _aureliaTemplating.BindingLanguage; @@ -15,14 +19,15 @@ var ResourceCoordinator = _aureliaTemplating.ResourceCoordinator; var ViewSlot = _aureliaTemplating.ViewSlot; var ResourceRegistry = _aureliaTemplating.ResourceRegistry; var CompositionEngine = _aureliaTemplating.CompositionEngine; -var Plugins = require("./plugins").Plugins; +var Animator = _aureliaTemplating.Animator; +var Plugins = require("./plugins").Plugins; var logger = LogManager.getLogger("aurelia"), slice = Array.prototype.slice; if (!window.CustomEvent || typeof window.CustomEvent !== "function") { - var CustomEvent = function (event, params) { + var CustomEvent = function CustomEvent(event, params) { var params = params || { bubbles: false, cancelable: false, @@ -38,6 +43,17 @@ if (!window.CustomEvent || typeof window.CustomEvent !== "function") { window.CustomEvent = CustomEvent; } +function preventActionlessFormSubmit() { + document.body.addEventListener("submit", function (evt) { + var target = evt.target; + var action = target.action; + + if (target.tagName.toLowerCase() === "form" && !action) { + evt.preventDefault(); + } + }); +} + function loadResources(container, resourcesToLoad, appResources) { var resourceCoordinator = container.get(ResourceCoordinator), current; @@ -58,8 +74,20 @@ 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. + */ + var Aurelia = exports.Aurelia = (function () { function Aurelia(loader, container, resources) { + _classCallCheck(this, Aurelia); + this.loader = loader || Loader.createDefaultLoader(); this.container = container || new Container(); this.resources = resources || new ResourceRegistry(); @@ -77,6 +105,16 @@ var Aurelia = exports.Aurelia = (function () { _prototypeProperties(Aurelia, null, { withInstance: { + + /** + * 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. + */ + value: function withInstance(type, instance) { this.container.registerInstance(type, instance); return this; @@ -85,6 +123,16 @@ var Aurelia = exports.Aurelia = (function () { configurable: true }, withSingleton: { + + /** + * 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. + */ + value: function withSingleton(type, implementation) { this.container.registerSingleton(type, implementation); return this; @@ -93,6 +141,15 @@ var Aurelia = exports.Aurelia = (function () { configurable: true }, withResources: { + + /** + * 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. + */ + value: function withResources(resources) { var toAdd = Array.isArray(resources) ? resources : slice.call(arguments); toAdd.resourceManifestUrl = this.currentPluginId; @@ -103,8 +160,17 @@ var Aurelia = exports.Aurelia = (function () { configurable: true }, start: { + + /** + * Loads plugins, then resources, and then starts the Aurelia instance. + * + * @method start + * @return {Aurelia} Returns the started Aurelia instance. + */ + value: function start() { var _this = this; + if (this.started) { return Promise.resolve(this); } @@ -112,12 +178,20 @@ var Aurelia = exports.Aurelia = (function () { this.started = true; logger.info("Aurelia Starting"); + preventActionlessFormSubmit(); + var resourcesToLoad = this.resourcesToLoad; this.resourcesToLoad = []; return this.use._process().then(function () { if (!_this.container.hasHandler(BindingLanguage)) { - logger.error("You must configure Aurelia with a BindingLanguage implementation."); + var message = "You must configure Aurelia with a BindingLanguage implementation."; + logger.error(message); + throw new Error(message); + } + + if (!_this.container.hasHandler(Animator)) { + _this.withInstance(Animator, new Animator()); } _this.resourcesToLoad = _this.resourcesToLoad.concat(resourcesToLoad); @@ -134,8 +208,19 @@ var Aurelia = exports.Aurelia = (function () { configurable: true }, setRoot: { + + /** + * 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. + */ + value: function setRoot(root, applicationHost) { var _this = this; + var compositionEngine, instruction = {}; @@ -171,4 +256,7 @@ var Aurelia = exports.Aurelia = (function () { return Aurelia; })(); -exports.__esModule = true; \ No newline at end of file + +Object.defineProperty(exports, "__esModule", { + value: true +}); \ No newline at end of file diff --git a/dist/commonjs/index.js b/dist/commonjs/index.js index 87c0b82c..65289afe 100644 --- a/dist/commonjs/index.js +++ b/dist/commonjs/index.js @@ -2,9 +2,16 @@ var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; }; -var _defaults = function (obj, defaults) { for (var key in defaults) { if (obj[key] === undefined) { obj[key] = defaults[key]; } } return obj; }; +var _defaults = function (obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }; + +/** + * The aurelia framework brings together all the required core aurelia libraries into a ready-to-go application-building platform. + * + * @module framework + */ exports.Aurelia = require("./aurelia").Aurelia; + _defaults(exports, _interopRequireWildcard(require("aurelia-dependency-injection"))); _defaults(exports, _interopRequireWildcard(require("aurelia-binding"))); @@ -20,4 +27,6 @@ _defaults(exports, _interopRequireWildcard(require("aurelia-task-queue"))); var TheLogManager = _interopRequireWildcard(require("aurelia-logging")); var LogManager = exports.LogManager = TheLogManager; -exports.__esModule = true; \ No newline at end of file +Object.defineProperty(exports, "__esModule", { + value: true +}); \ No newline at end of file diff --git a/dist/commonjs/plugins.js b/dist/commonjs/plugins.js index dca74ddc..331fee43 100644 --- a/dist/commonjs/plugins.js +++ b/dist/commonjs/plugins.js @@ -4,11 +4,12 @@ var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? ob var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; +var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + var LogManager = _interopRequireWildcard(require("aurelia-logging")); var Metadata = require("aurelia-metadata").Metadata; - var logger = LogManager.getLogger("aurelia"); function loadPlugin(aurelia, loader, info) { @@ -16,7 +17,7 @@ function loadPlugin(aurelia, loader, info) { aurelia.currentPluginId = info.moduleId; - var baseUrl = info.moduleId.startsWith("./") ? undefined : ""; + var baseUrl = info.moduleId.indexOf("./") === 0 ? undefined : ""; return loader.loadModule(info.moduleId, baseUrl).then(function (exportedValue) { if ("install" in exportedValue) { @@ -38,8 +39,18 @@ function loadPlugin(aurelia, loader, info) { }); } +/** + * Manages loading and installing plugins. + * + * @class Plugins + * @constructor + * @param {Aurelia} aurelia An instance of Aurelia. + */ + var Plugins = exports.Plugins = (function () { function Plugins(aurelia) { + _classCallCheck(this, Plugins); + this.aurelia = aurelia; this.info = []; this.processed = false; @@ -47,7 +58,27 @@ var Plugins = exports.Plugins = (function () { _prototypeProperties(Plugins, null, { plugin: { - value: function plugin(moduleId, 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. + */ + + value: (function (_plugin) { + var _pluginWrapper = function plugin(_x, _x2) { + return _plugin.apply(this, arguments); + }; + + _pluginWrapper.toString = function () { + return _plugin.toString(); + }; + + return _pluginWrapper; + })(function (moduleId, config) { var plugin = { moduleId: moduleId, config: config || {} }; if (this.processed) { @@ -57,11 +88,19 @@ var Plugins = exports.Plugins = (function () { } return this; - }, + }), writable: true, configurable: true }, es5: { + + /** + * Installs special support for ES5 authoring. + * + * @method es5 + * @return {Plugins} Returns the current Plugins instance. + */ + value: function es5() { Function.prototype.computed = function (computedProperties) { for (var key in computedProperties) { @@ -77,6 +116,14 @@ var Plugins = exports.Plugins = (function () { configurable: true }, atscript: { + + /** + * Installs special support for AtScript authoring. + * + * @method atscript + * @return {Plugins} Returns the current Plugins instance. + */ + value: function atscript() { this.aurelia.container.supportAtScript(); Metadata.configure.locator(function (fn) { @@ -90,6 +137,7 @@ var Plugins = exports.Plugins = (function () { _process: { value: function _process() { var _this = this; + var aurelia = this.aurelia, loader = aurelia.loader, info = this.info, @@ -117,4 +165,7 @@ var Plugins = exports.Plugins = (function () { return Plugins; })(); -exports.__esModule = true; \ No newline at end of file + +Object.defineProperty(exports, "__esModule", { + value: true +}); \ No newline at end of file diff --git a/dist/es6/aurelia.js b/dist/es6/aurelia.js index 7989bb97..e036b119 100644 --- a/dist/es6/aurelia.js +++ b/dist/es6/aurelia.js @@ -1,7 +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, Animator} from 'aurelia-templating'; import {Plugins} from './plugins'; var logger = LogManager.getLogger('aurelia'), @@ -24,8 +24,19 @@ if (!window.CustomEvent || typeof window.CustomEvent !== 'function') { window.CustomEvent = CustomEvent; } +function preventActionlessFormSubmit() { + document.body.addEventListener('submit', evt => { + const target = evt.target; + const action = target.action; + + if (target.tagName.toLowerCase() === 'form' && !action){ + evt.preventDefault(); + } + }); +} + function loadResources(container, resourcesToLoad, appResources){ - var resourceCoordinator = container.get(ResourceCoordinator), + var resourceCoordinator = container.get(ResourceCoordinator), current; function next(){ @@ -122,12 +133,20 @@ export class Aurelia { this.started = true; logger.info('Aurelia Starting'); + preventActionlessFormSubmit(); + var resourcesToLoad = this.resourcesToLoad; this.resourcesToLoad = []; return this.use._process().then(() => { if(!this.container.hasHandler(BindingLanguage)){ - logger.error('You must configure Aurelia with a BindingLanguage implementation.'); + var message = 'You must configure Aurelia with a BindingLanguage implementation.'; + logger.error(message); + throw new Error(message); + } + + if(!this.container.hasHandler(Animator)){ + this.withInstance(Animator, new Animator()); } this.resourcesToLoad = this.resourcesToLoad.concat(resourcesToLoad); @@ -175,4 +194,4 @@ export class Aurelia { return this; }); } -} \ No newline at end of file +} diff --git a/dist/es6/plugins.js b/dist/es6/plugins.js index 987728f6..9539d177 100644 --- a/dist/es6/plugins.js +++ b/dist/es6/plugins.js @@ -8,7 +8,7 @@ function loadPlugin(aurelia, loader, info){ aurelia.currentPluginId = info.moduleId; - var baseUrl = info.moduleId.startsWith('./') ? undefined : ""; + var baseUrl = info.moduleId.indexOf('./') === 0 ? undefined : ""; return loader.loadModule(info.moduleId, baseUrl).then(exportedValue => { if('install' in exportedValue){ @@ -77,7 +77,7 @@ export class Plugins { Object.defineProperty(this.prototype, key, { get: computedProperties[key], enumerable: true }); } } - } + }; return this; } diff --git a/dist/system/aurelia.js b/dist/system/aurelia.js index dd2fc6af..2a515c5c 100644 --- a/dist/system/aurelia.js +++ b/dist/system/aurelia.js @@ -1,8 +1,16 @@ System.register(["aurelia-logging", "aurelia-dependency-injection", "aurelia-loader", "aurelia-templating", "./plugins"], function (_export) { - "use strict"; + var LogManager, Container, Loader, BindingLanguage, ResourceCoordinator, ViewSlot, ResourceRegistry, CompositionEngine, Animator, Plugins, _prototypeProperties, _classCallCheck, logger, slice, CustomEvent, Aurelia; - var LogManager, Container, Loader, BindingLanguage, ResourceCoordinator, ViewSlot, ResourceRegistry, CompositionEngine, Plugins, _prototypeProperties, logger, slice, CustomEvent, Aurelia; + function preventActionlessFormSubmit() { + document.body.addEventListener("submit", function (evt) { + var target = evt.target; + var action = target.action; + if (target.tagName.toLowerCase() === "form" && !action) { + evt.preventDefault(); + } + }); + } function loadResources(container, resourcesToLoad, appResources) { var resourceCoordinator = container.get(ResourceCoordinator), @@ -37,18 +45,22 @@ System.register(["aurelia-logging", "aurelia-dependency-injection", "aurelia-loa ViewSlot = _aureliaTemplating.ViewSlot; ResourceRegistry = _aureliaTemplating.ResourceRegistry; CompositionEngine = _aureliaTemplating.CompositionEngine; + Animator = _aureliaTemplating.Animator; }, function (_plugins) { Plugins = _plugins.Plugins; }], execute: function () { + "use strict"; + _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + logger = LogManager.getLogger("aurelia"); slice = Array.prototype.slice; - if (!window.CustomEvent || typeof window.CustomEvent !== "function") { - CustomEvent = function (event, params) { + CustomEvent = function CustomEvent(event, params) { var params = params || { bubbles: false, cancelable: false, @@ -62,8 +74,19 @@ System.register(["aurelia-logging", "aurelia-dependency-injection", "aurelia-loa CustomEvent.prototype = window.Event.prototype; window.CustomEvent = CustomEvent; - }Aurelia = _export("Aurelia", (function () { + } /** + * 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. + */ + Aurelia = _export("Aurelia", (function () { function Aurelia(loader, container, resources) { + _classCallCheck(this, Aurelia); + this.loader = loader || Loader.createDefaultLoader(); this.container = container || new Container(); this.resources = resources || new ResourceRegistry(); @@ -81,6 +104,16 @@ System.register(["aurelia-logging", "aurelia-dependency-injection", "aurelia-loa _prototypeProperties(Aurelia, null, { withInstance: { + + /** + * 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. + */ + value: function withInstance(type, instance) { this.container.registerInstance(type, instance); return this; @@ -89,6 +122,16 @@ System.register(["aurelia-logging", "aurelia-dependency-injection", "aurelia-loa configurable: true }, withSingleton: { + + /** + * 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. + */ + value: function withSingleton(type, implementation) { this.container.registerSingleton(type, implementation); return this; @@ -97,6 +140,15 @@ System.register(["aurelia-logging", "aurelia-dependency-injection", "aurelia-loa configurable: true }, withResources: { + + /** + * 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. + */ + value: function withResources(resources) { var toAdd = Array.isArray(resources) ? resources : slice.call(arguments); toAdd.resourceManifestUrl = this.currentPluginId; @@ -107,8 +159,17 @@ System.register(["aurelia-logging", "aurelia-dependency-injection", "aurelia-loa configurable: true }, start: { + + /** + * Loads plugins, then resources, and then starts the Aurelia instance. + * + * @method start + * @return {Aurelia} Returns the started Aurelia instance. + */ + value: function start() { var _this = this; + if (this.started) { return Promise.resolve(this); } @@ -116,12 +177,20 @@ System.register(["aurelia-logging", "aurelia-dependency-injection", "aurelia-loa this.started = true; logger.info("Aurelia Starting"); + preventActionlessFormSubmit(); + var resourcesToLoad = this.resourcesToLoad; this.resourcesToLoad = []; return this.use._process().then(function () { if (!_this.container.hasHandler(BindingLanguage)) { - logger.error("You must configure Aurelia with a BindingLanguage implementation."); + var message = "You must configure Aurelia with a BindingLanguage implementation."; + logger.error(message); + throw new Error(message); + } + + if (!_this.container.hasHandler(Animator)) { + _this.withInstance(Animator, new Animator()); } _this.resourcesToLoad = _this.resourcesToLoad.concat(resourcesToLoad); @@ -138,8 +207,19 @@ System.register(["aurelia-logging", "aurelia-dependency-injection", "aurelia-loa configurable: true }, setRoot: { + + /** + * 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. + */ + value: function setRoot(root, applicationHost) { var _this = this; + var compositionEngine, instruction = {}; diff --git a/dist/system/index.js b/dist/system/index.js index 3db8c799..605dc96b 100644 --- a/dist/system/index.js +++ b/dist/system/index.js @@ -1,9 +1,13 @@ System.register(["./aurelia", "aurelia-dependency-injection", "aurelia-binding", "aurelia-metadata", "aurelia-templating", "aurelia-loader", "aurelia-task-queue", "aurelia-logging"], function (_export) { - "use strict"; - var TheLogManager, LogManager; return { setters: [function (_aurelia) { + /** + * The aurelia framework brings together all the required core aurelia libraries into a ready-to-go application-building platform. + * + * @module framework + */ + _export("Aurelia", _aurelia.Aurelia); }, function (_aureliaDependencyInjection) { for (var _key in _aureliaDependencyInjection) { @@ -33,6 +37,8 @@ System.register(["./aurelia", "aurelia-dependency-injection", "aurelia-binding", TheLogManager = _aureliaLogging; }], execute: function () { + "use strict"; + LogManager = _export("LogManager", TheLogManager); } }; diff --git a/dist/system/plugins.js b/dist/system/plugins.js index 4bfe5e0e..c8cd73ca 100644 --- a/dist/system/plugins.js +++ b/dist/system/plugins.js @@ -1,15 +1,12 @@ System.register(["aurelia-logging", "aurelia-metadata"], function (_export) { - "use strict"; - - var LogManager, Metadata, _prototypeProperties, logger, Plugins; - + var LogManager, Metadata, _prototypeProperties, _classCallCheck, logger, Plugins; function loadPlugin(aurelia, loader, info) { logger.debug("Loading plugin " + info.moduleId + "."); aurelia.currentPluginId = info.moduleId; - var baseUrl = info.moduleId.startsWith("./") ? undefined : ""; + var baseUrl = info.moduleId.indexOf("./") === 0 ? undefined : ""; return loader.loadModule(info.moduleId, baseUrl).then(function (exportedValue) { if ("install" in exportedValue) { @@ -38,11 +35,24 @@ System.register(["aurelia-logging", "aurelia-metadata"], function (_export) { Metadata = _aureliaMetadata.Metadata; }], execute: function () { + "use strict"; + _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + logger = LogManager.getLogger("aurelia"); + /** + * Manages loading and installing plugins. + * + * @class Plugins + * @constructor + * @param {Aurelia} aurelia An instance of Aurelia. + */ Plugins = _export("Plugins", (function () { function Plugins(aurelia) { + _classCallCheck(this, Plugins); + this.aurelia = aurelia; this.info = []; this.processed = false; @@ -50,7 +60,27 @@ System.register(["aurelia-logging", "aurelia-metadata"], function (_export) { _prototypeProperties(Plugins, null, { plugin: { - value: function plugin(moduleId, 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. + */ + + value: (function (_plugin) { + var _pluginWrapper = function plugin(_x, _x2) { + return _plugin.apply(this, arguments); + }; + + _pluginWrapper.toString = function () { + return _plugin.toString(); + }; + + return _pluginWrapper; + })(function (moduleId, config) { var plugin = { moduleId: moduleId, config: config || {} }; if (this.processed) { @@ -60,11 +90,19 @@ System.register(["aurelia-logging", "aurelia-metadata"], function (_export) { } return this; - }, + }), writable: true, configurable: true }, es5: { + + /** + * Installs special support for ES5 authoring. + * + * @method es5 + * @return {Plugins} Returns the current Plugins instance. + */ + value: function es5() { Function.prototype.computed = function (computedProperties) { for (var key in computedProperties) { @@ -80,6 +118,14 @@ System.register(["aurelia-logging", "aurelia-metadata"], function (_export) { configurable: true }, atscript: { + + /** + * Installs special support for AtScript authoring. + * + * @method atscript + * @return {Plugins} Returns the current Plugins instance. + */ + value: function atscript() { this.aurelia.container.supportAtScript(); Metadata.configure.locator(function (fn) { @@ -93,6 +139,7 @@ System.register(["aurelia-logging", "aurelia-metadata"], function (_export) { _process: { value: function _process() { var _this = this; + var aurelia = this.aurelia, loader = aurelia.loader, info = this.info, diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 6a54b66a..c0dd9c34 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -1,3 +1,20 @@ +### 0.8.7 (2015-02-28) + + +#### Bug Fixes + +* **aurelia:** global resources left out ([4bb098a3](http://github.com/aurelia/framework/commit/4bb098a36ea226dedc5343f3c629d889f9028580)) +* **build:** add missing bower bump ([111797ae](http://github.com/aurelia/framework/commit/111797ae2f669b3eb9a86538c23f5e537fc259c5)) +* **package:** update dependencies ([79feec43](http://github.com/aurelia/framework/commit/79feec432b8f3afd7a2ca90fc4eec2445e34940f)) + + +#### Features + +* **aurelia:** ensure animator implementation ([e3ab3ab0](http://github.com/aurelia/framework/commit/e3ab3ab08aac022d0c7b58ddef7b8632f2e5f980)) +* **build:** add command line argument for semver bump. resolve #28 ([39652c80](http://github.com/aurelia/framework/commit/39652c8026dd26e459ed5e84a0924e1f58724d53)) +* **framework:** prevent forms without [action] from submiting ([a5805257](http://github.com/aurelia/framework/commit/a58052571281cce001089bc065858e47ee595874)) + + ### 0.8.6 (2015-02-03) diff --git a/doc/api.json b/doc/api.json index 3675a052..5313c57f 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":45,"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":71,"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":84,"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":97,"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":111,"description":"Loads plugins, then resources, and then starts the Aurelia instance.","name":"start","return":{"description":"Returns the started Aurelia instance.","type":"Aurelia"}},{"line":144,"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":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 diff --git a/package.json b/package.json index bbd9555a..6a1dad8f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aurelia-framework", - "version": "0.8.6", + "version": "0.8.7", "description": "The aurelia framework brings together all the required core aurelia libraries into a ready-to-go application-building platform.", "keywords": [ "aurelia",