Skip to content

Commit 5de9585

Browse files
chore(all): prepare release 1.3.0-rc.1
1 parent a44e714 commit 5de9585

File tree

11 files changed

+713
-338
lines changed

11 files changed

+713
-338
lines changed

bower.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aurelia-framework",
3-
"version": "1.2.0",
3+
"version": "1.3.0-rc.1",
44
"description": "The aurelia framework brings together all the required core aurelia libraries into a ready-to-go application-building platform.",
55
"keywords": [
66
"aurelia",
@@ -19,14 +19,14 @@
1919
"url": "http://github.com/aurelia/framework"
2020
},
2121
"dependencies": {
22-
"aurelia-binding": "^1.0.0",
22+
"aurelia-binding": "^1.0.0 || ^2.0.0",
2323
"aurelia-dependency-injection": "^1.0.0",
2424
"aurelia-loader": "^1.0.0",
2525
"aurelia-logging": "^1.0.0",
2626
"aurelia-metadata": "^1.0.0",
2727
"aurelia-pal": "^1.0.0",
2828
"aurelia-path": "^1.0.0",
2929
"aurelia-task-queue": "^1.0.0",
30-
"aurelia-templating": "^1.0.0"
30+
"aurelia-templating": "^1.8.0-rc.1"
3131
}
3232
}

dist/amd/aurelia-framework.js

Lines changed: 117 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-m
9797
}
9898
}
9999

100+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
101+
return typeof obj;
102+
} : function (obj) {
103+
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
104+
};
105+
100106

101107

102108
function preventActionlessFormSubmit() {
@@ -258,36 +264,53 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-m
258264
return next();
259265
}
260266

261-
function loadPlugin(config, loader, info) {
267+
function loadPlugin(fwConfig, loader, info) {
262268
logger.debug('Loading plugin ' + info.moduleId + '.');
263-
config.resourcesRelativeTo = info.resourcesRelativeTo;
269+
if (typeof info.moduleId === 'string') {
270+
fwConfig.resourcesRelativeTo = info.resourcesRelativeTo;
264271

265-
var id = info.moduleId;
272+
var id = info.moduleId;
266273

267-
if (info.resourcesRelativeTo.length > 1) {
268-
return loader.normalize(info.moduleId, info.resourcesRelativeTo[1]).then(function (normalizedId) {
269-
return _loadPlugin(normalizedId);
270-
});
271-
}
274+
if (info.resourcesRelativeTo.length > 1) {
275+
return loader.normalize(info.moduleId, info.resourcesRelativeTo[1]).then(function (normalizedId) {
276+
return _loadPlugin(normalizedId);
277+
});
278+
}
272279

273-
return _loadPlugin(id);
280+
return _loadPlugin(id);
281+
} else if (typeof info.configure === 'function') {
282+
if (fwConfig.configuredPlugins.indexOf(info.configure) !== -1) {
283+
return Promise.resolve();
284+
}
285+
fwConfig.configuredPlugins.push(info.configure);
286+
287+
return Promise.resolve(info.configure.call(null, fwConfig, info.config || {}));
288+
}
289+
throw new Error(invalidConfigMsg(info.moduleId || info.configure, 'plugin'));
274290

275291
function _loadPlugin(moduleId) {
276292
return loader.loadModule(moduleId).then(function (m) {
277293
if ('configure' in m) {
278-
return Promise.resolve(m.configure(config, info.config || {})).then(function () {
279-
config.resourcesRelativeTo = null;
294+
if (fwConfig.configuredPlugins.indexOf(m.configure) !== -1) {
295+
return Promise.resolve();
296+
}
297+
return Promise.resolve(m.configure(fwConfig, info.config || {})).then(function () {
298+
fwConfig.configuredPlugins.push(m.configure);
299+
fwConfig.resourcesRelativeTo = null;
280300
logger.debug('Configured plugin ' + info.moduleId + '.');
281301
});
282302
}
283303

284-
config.resourcesRelativeTo = null;
304+
fwConfig.resourcesRelativeTo = null;
285305
logger.debug('Loaded plugin ' + info.moduleId + '.');
286306
});
287307
}
288308
}
289309

290310
function loadResources(aurelia, resourcesToLoad, appResources) {
311+
if (Object.keys(resourcesToLoad).length === 0) {
312+
return Promise.resolve();
313+
}
291314
var viewEngine = aurelia.container.get(_aureliaTemplating.ViewEngine);
292315

293316
return Promise.all(Object.keys(resourcesToLoad).map(function (n) {
@@ -344,12 +367,24 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-m
344367
}
345368
}
346369

370+
function loadBehaviors(config) {
371+
return Promise.all(config.behaviorsToLoad.map(function (m) {
372+
return m.load(config.container, m.target);
373+
})).then(function () {
374+
config.behaviorsToLoad = null;
375+
});
376+
}
377+
347378
function assertProcessed(plugins) {
348379
if (plugins.processed) {
349380
throw new Error('This config instance has already been applied. To load more plugins or global resources, create a new FrameworkConfiguration instance.');
350381
}
351382
}
352383

384+
function invalidConfigMsg(cfg, type) {
385+
return 'Invalid ' + type + ' [' + cfg + '], ' + type + ' must be specified as functions or relative module IDs.';
386+
}
387+
353388
var FrameworkConfiguration = function () {
354389
function FrameworkConfiguration(aurelia) {
355390
var _this4 = this;
@@ -358,10 +393,15 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-m
358393

359394
this.aurelia = aurelia;
360395
this.container = aurelia.container;
396+
361397
this.info = [];
362398
this.processed = false;
363399
this.preTasks = [];
364400
this.postTasks = [];
401+
402+
this.behaviorsToLoad = [];
403+
404+
this.configuredPlugins = [];
365405
this.resourcesToLoad = {};
366406
this.preTask(function () {
367407
return aurelia.loader.normalize('aurelia-bootstrapper').then(function (name) {
@@ -403,13 +443,26 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-m
403443
FrameworkConfiguration.prototype.feature = function feature(plugin) {
404444
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
405445

406-
var hasIndex = /\/index$/i.test(plugin);
407-
var moduleId = hasIndex || getExt(plugin) ? plugin : plugin + '/index';
408-
var root = hasIndex ? plugin.substr(0, plugin.length - 6) : plugin;
409-
return this.plugin({ moduleId: moduleId, resourcesRelativeTo: [root, ''], config: config });
446+
switch (typeof plugin === 'undefined' ? 'undefined' : _typeof(plugin)) {
447+
case 'string':
448+
var hasIndex = /\/index$/i.test(plugin);
449+
var _moduleId = hasIndex || getExt(plugin) ? plugin : plugin + '/index';
450+
var root = hasIndex ? plugin.substr(0, plugin.length - 6) : plugin;
451+
this.info.push({ moduleId: _moduleId, resourcesRelativeTo: [root, ''], config: config });
452+
break;
453+
454+
case 'function':
455+
this.info.push({ configure: plugin, config: config || {} });
456+
break;
457+
default:
458+
throw new Error(invalidConfigMsg(plugin, 'feature'));
459+
}
460+
return this;
410461
};
411462

412463
FrameworkConfiguration.prototype.globalResources = function globalResources(resources) {
464+
var _this5 = this;
465+
413466
assertProcessed(this);
414467

415468
var toAdd = Array.isArray(resources) ? resources : arguments;
@@ -418,19 +471,31 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-m
418471

419472
for (var i = 0, ii = toAdd.length; i < ii; ++i) {
420473
resource = toAdd[i];
421-
if (typeof resource !== 'string') {
422-
throw new Error('Invalid resource path [' + resource + ']. Resources must be specified as relative module IDs.');
474+
switch (typeof resource === 'undefined' ? 'undefined' : _typeof(resource)) {
475+
case 'string':
476+
var parent = resourcesRelativeTo[0];
477+
var grandParent = resourcesRelativeTo[1];
478+
var name = resource;
479+
480+
if ((resource.startsWith('./') || resource.startsWith('../')) && parent !== '') {
481+
name = (0, _aureliaPath.join)(parent, resource);
482+
}
483+
484+
this.resourcesToLoad[name] = { moduleId: name, relativeTo: grandParent };
485+
break;
486+
case 'function':
487+
var meta = this.aurelia.resources.autoRegister(this.container, resource);
488+
if (meta instanceof _aureliaTemplating.HtmlBehaviorResource && meta.elementName !== null) {
489+
if (this.behaviorsToLoad.push(meta) === 1) {
490+
this.postTask(function () {
491+
return loadBehaviors(_this5);
492+
});
493+
}
494+
}
495+
break;
496+
default:
497+
throw new Error(invalidConfigMsg(resource, 'resource'));
423498
}
424-
425-
var parent = resourcesRelativeTo[0];
426-
var grandParent = resourcesRelativeTo[1];
427-
var name = resource;
428-
429-
if ((resource.startsWith('./') || resource.startsWith('../')) && parent !== '') {
430-
name = (0, _aureliaPath.join)(parent, resource);
431-
}
432-
433-
this.resourcesToLoad[name] = { moduleId: name, relativeTo: grandParent };
434499
}
435500

436501
return this;
@@ -442,25 +507,32 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-m
442507
return this;
443508
};
444509

445-
FrameworkConfiguration.prototype.plugin = function plugin(_plugin, config) {
510+
FrameworkConfiguration.prototype.plugin = function plugin(_plugin, pluginConfig) {
446511
assertProcessed(this);
447512

448-
if (typeof _plugin === 'string') {
449-
return this.plugin({ moduleId: _plugin, resourcesRelativeTo: [_plugin, ''], config: config || {} });
513+
var info = void 0;
514+
switch (typeof _plugin === 'undefined' ? 'undefined' : _typeof(_plugin)) {
515+
case 'string':
516+
info = { moduleId: _plugin, resourcesRelativeTo: [_plugin, ''], config: pluginConfig || {} };
517+
break;
518+
case 'function':
519+
info = { configure: _plugin, config: pluginConfig || {} };
520+
break;
521+
default:
522+
throw new Error(invalidConfigMsg(_plugin, 'plugin'));
450523
}
451-
452-
this.info.push(_plugin);
524+
this.info.push(info);
453525
return this;
454526
};
455527

456528
FrameworkConfiguration.prototype._addNormalizedPlugin = function _addNormalizedPlugin(name, config) {
457-
var _this5 = this;
529+
var _this6 = this;
458530

459531
var plugin = { moduleId: name, resourcesRelativeTo: [name, ''], config: config || {} };
460532
this.plugin(plugin);
461533

462534
this.preTask(function () {
463-
var relativeTo = [name, _this5.bootstrapperName];
535+
var relativeTo = [name, _this6.bootstrapperName];
464536
plugin.moduleId = name;
465537
plugin.resourcesRelativeTo = relativeTo;
466538
return Promise.resolve();
@@ -498,7 +570,7 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-m
498570
};
499571

500572
FrameworkConfiguration.prototype.developmentLogging = function developmentLogging(level) {
501-
var _this6 = this;
573+
var _this7 = this;
502574

503575
var logLevel = level ? TheLogManager.logLevel[level] : undefined;
504576

@@ -507,8 +579,8 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-m
507579
}
508580

509581
this.preTask(function () {
510-
return _this6.aurelia.loader.normalize('aurelia-logging-console', _this6.bootstrapperName).then(function (name) {
511-
return _this6.aurelia.loader.loadModule(name).then(function (m) {
582+
return _this7.aurelia.loader.normalize('aurelia-logging-console', _this7.bootstrapperName).then(function (name) {
583+
return _this7.aurelia.loader.loadModule(name).then(function (m) {
512584
TheLogManager.addAppender(new m.ConsoleAppender());
513585
TheLogManager.setLevel(logLevel);
514586
});
@@ -519,29 +591,30 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-m
519591
};
520592

521593
FrameworkConfiguration.prototype.apply = function apply() {
522-
var _this7 = this;
594+
var _this8 = this;
523595

524596
if (this.processed) {
525597
return Promise.resolve();
526598
}
527599

528600
return runTasks(this, this.preTasks).then(function () {
529-
var loader = _this7.aurelia.loader;
530-
var info = _this7.info;
601+
var loader = _this8.aurelia.loader;
602+
var info = _this8.info;
531603
var current = void 0;
532604

533605
var next = function next() {
534606
current = info.shift();
535607
if (current) {
536-
return loadPlugin(_this7, loader, current).then(next);
608+
return loadPlugin(_this8, loader, current).then(next);
537609
}
538610

539-
_this7.processed = true;
611+
_this8.processed = true;
612+
_this8.configuredPlugins = null;
540613
return Promise.resolve();
541614
};
542615

543616
return next().then(function () {
544-
return runTasks(_this7, _this7.postTasks);
617+
return runTasks(_this8, _this8.postTasks);
545618
});
546619
});
547620
};

dist/aurelia-framework.d.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111
ViewResources,
1212
TemplatingEngine,
1313
CompositionTransaction,
14-
ViewEngine
14+
ViewEngine,
15+
HtmlBehaviorResource
1516
} from 'aurelia-templating';
1617
import {
1718
DOM,
@@ -21,6 +22,12 @@ import {
2122
relativeToFile,
2223
join
2324
} from 'aurelia-path';
25+
export declare interface FrameworkPluginInfo {
26+
moduleId?: string;
27+
resourcesRelativeTo?: string[];
28+
configure?: (config: FrameworkConfiguration, pluginConfig?: any) => any;
29+
config?: any;
30+
}
2431

2532
/**
2633
* The framework core that provides the main Aurelia object.
@@ -81,7 +88,7 @@ export declare class Aurelia {
8188
* @param applicationHost The DOM object that Aurelia will attach to.
8289
* @return Returns a Promise of the current Aurelia instance.
8390
*/
84-
setRoot(root?: string, applicationHost?: string | Element): Promise<Aurelia>;
91+
setRoot(root?: string | Function, applicationHost?: string | Element): Promise<Aurelia>;
8592
}
8693

8794
/**
@@ -149,14 +156,14 @@ export declare class FrameworkConfiguration {
149156
* @param config The configuration for the specified plugin.
150157
* @return Returns the current FrameworkConfiguration instance.
151158
*/
152-
feature(plugin: string, config?: any): FrameworkConfiguration;
159+
feature(plugin: string | ((config: FrameworkConfiguration, pluginConfig?: any) => any), config?: any): FrameworkConfiguration;
153160

154161
/**
155162
* Adds globally available view resources to be imported into the Aurelia framework.
156163
* @param resources The relative module id to the resource. (Relative to the plugin's installer.)
157164
* @return Returns the current FrameworkConfiguration instance.
158165
*/
159-
globalResources(resources: string | string[]): FrameworkConfiguration;
166+
globalResources(resources: string | Function | Array<string | Function>): FrameworkConfiguration;
160167

161168
/**
162169
* Renames a global resource that was imported.
@@ -169,10 +176,10 @@ export declare class FrameworkConfiguration {
169176
/**
170177
* Configures an external, 3rd party plugin before Aurelia starts.
171178
* @param plugin The ID of the 3rd party plugin to configure.
172-
* @param config The configuration for the specified plugin.
179+
* @param pluginConfig The configuration for the specified plugin.
173180
* @return Returns the current FrameworkConfiguration instance.
174181
*/
175-
plugin(plugin: string, config?: any): FrameworkConfiguration;
182+
plugin(plugin: string | ((frameworkConfig: FrameworkConfiguration) => any) | FrameworkPluginInfo, pluginConfig?: any): FrameworkConfiguration;
176183

177184
// Default configuration helpers
178185
// Note: Please do NOT add PLATFORM.moduleName() around those module names.
@@ -243,8 +250,9 @@ export * from 'aurelia-templating';
243250
export * from 'aurelia-loader';
244251
export * from 'aurelia-task-queue';
245252
export * from 'aurelia-path';
253+
export * from 'aurelia-pal';
254+
246255
/**
247256
* The log manager.
248257
*/
249258
export const LogManager: typeof TheLogManager;
250-
export * from 'aurelia-pal';

0 commit comments

Comments
 (0)