Skip to content

Commit

Permalink
chore(all): prepare release 0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Jan 7, 2015
1 parent 53f2549 commit 8ec8630
Show file tree
Hide file tree
Showing 15 changed files with 304 additions and 211 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aurelia-templating",
"version": "0.5.0",
"version": "0.6.0",
"description": "An extensible HTML templating engine supporting databinding, custom elements, attached behaviors and more.",
"keywords": [
"aurelia",
Expand Down
99 changes: 57 additions & 42 deletions dist/amd/composition-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,72 +15,87 @@ define(["exports", "./view-strategy", "./resource-coordinator", "./view-engine",
return [ResourceCoordinator, ViewEngine];
};

CompositionEngine.prototype.bindAndSwap = function (viewSlot, next, current) {
next.bind(next.executionContext);
viewSlot.swap(next.view);

if (current) {
current.unbind();
CompositionEngine.prototype.activate = function (instruction) {
if (instruction.skipActivation || typeof instruction.viewModel.activate !== "function") {
return Promise.resolve();
}

return next;
return instruction.viewModel.activate(instruction.model) || Promise.resolve();
};

CompositionEngine.prototype.activateViewModel = function (viewModel, model) {
if (typeof viewModel.activate === "function") {
return viewModel.activate(model) || Promise.resolve();
} else {
return Promise.resolve();
}
CompositionEngine.prototype.createBehaviorAndSwap = function (instruction) {
return this.createBehavior(instruction).then(function (behavior) {
instruction.viewSlot.swap(behavior.view);

if (instruction.currentBehavior) {
instruction.currentBehavior.unbind();
}

return behavior;
});
};

CompositionEngine.prototype.createBehavior = function (instruction, container, viewModelInfo) {
var _this = this;
return this.activateViewModel(instruction.viewModel, instruction.model).then(function () {
CompositionEngine.prototype.createBehavior = function (instruction) {
var childContainer = instruction.childContainer, viewModelInfo = instruction.viewModelInfo, viewModel = instruction.viewModel;

return this.activate(instruction).then(function () {
var doneLoading;

if ("getViewStrategy" in instruction.viewModel && !instruction.view) {
instruction.view = ViewStrategy.normalize(instruction.viewModel.getViewStrategy());
if ("getViewStrategy" in viewModel && !instruction.view) {
instruction.view = ViewStrategy.normalize(viewModel.getViewStrategy());
}

if (instruction.view && instruction.viewResources) {
instruction.view.makeRelativeTo(instruction.viewResources.viewUrl);
}

if (viewModelInfo) {
doneLoading = viewModelInfo.type.load(container, viewModelInfo.value, instruction.view);
doneLoading = viewModelInfo.type.load(childContainer, viewModelInfo.value, instruction.view);
} else {
doneLoading = new CustomElement().load(container, instruction.viewModel.constructor, instruction.view);
doneLoading = new CustomElement().load(childContainer, viewModel.constructor, instruction.view);
}

return doneLoading.then(function (behaviorType) {
var behavior = behaviorType.create(container, { executionContext: instruction.viewModel, suppressBind: true });
return _this.bindAndSwap(instruction.viewSlot, behavior, instruction.currentBehavior);
return behaviorType.create(childContainer, { executionContext: viewModel });
});
});
};

CompositionEngine.prototype.compose = function (instruction) {
var _this2 = this;
var childContainer;
CompositionEngine.prototype.createViewModel = function (instruction) {
var childContainer = instruction.childContainer || instruction.container.createChild();

instruction.view = ViewStrategy.normalize(instruction.view);
instruction.viewModel = instruction.viewResources ? instruction.viewResources.relativeToView(instruction.viewModel) : instruction.viewModel;

if (typeof instruction.viewModel === "string") {
instruction.viewModel = instruction.viewResources.relativeToView(instruction.viewModel);
return this.resourceCoordinator.loadViewModelInfo(instruction.viewModel).then(function (viewModelInfo) {
childContainer.autoRegister(viewModelInfo.value);
instruction.viewModel = childContainer.viewModel = childContainer.get(viewModelInfo.value);
instruction.viewModelInfo = viewModelInfo;
return instruction;
});
};

return this.resourceCoordinator.loadViewModelInfo(instruction.viewModel).then(function (viewModelInfo) {
childContainer = instruction.container.createChild();
childContainer.autoRegister(viewModelInfo.value);
instruction.viewModel = childContainer.get(viewModelInfo.value);
return _this2.createBehavior(instruction, childContainer, viewModelInfo);
});
} else {
if (instruction.viewModel) {
return this.createBehavior(instruction, instruction.container.createChild());
} else if (instruction.view) {
return instruction.view.loadViewFactory(this.viewEngine).then(function (viewFactory) {
childContainer = instruction.container.createChild();
result = viewFactory.create(childContainer, instruction.executionContext);
instruction.viewSlot.swap(result);
CompositionEngine.prototype.compose = function (instruction) {
var _this = this;
instruction.childContainer = instruction.childContainer || instruction.container.createChild();
instruction.view = ViewStrategy.normalize(instruction.view);

if (instruction.viewModel) {
if (typeof instruction.viewModel === "string") {
return this.createViewModel(instruction).then(function (instruction) {
return _this.createBehaviorAndSwap(instruction);
});
} else {
return this.createBehaviorAndSwap(instruction);
}
} else if (instruction.view) {
return instruction.view.loadViewFactory(this.viewEngine).then(function (viewFactory) {
result = viewFactory.create(childContainer, instruction.executionContext);
instruction.viewSlot.swap(result);
return result;
});
} else if (instruction.viewSlot) {
instruction.viewSlot.removeAll();
return Promise.resolve(null);
}
};

Expand Down
10 changes: 3 additions & 7 deletions dist/amd/custom-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,13 @@ define(["exports", "aurelia-metadata", "./behavior", "./content-selector", "./vi
this.tagName = hyphenate(target.name);
}

if (typeof viewStrategy === "string") {
viewStrategy = new UseView(viewStrategy);
}
viewStrategy = viewStrategy || ViewStrategy.getDefault(target);
options = { targetShadowDOM: this.targetShadowDOM };

if (viewStrategy) {
if (!viewStrategy.moduleId) {
viewStrategy.moduleId = Origin.get(target).moduleId;
}

viewStrategy = viewStrategy || ViewStrategy.getDefault(target);
options = { targetShadowDOM: this.targetShadowDOM };

return viewStrategy.loadViewFactory(container.get(ViewEngine), options).then(function (viewFactory) {
_this.viewFactory = viewFactory;
return _this;
Expand Down
15 changes: 11 additions & 4 deletions dist/amd/view-strategy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
define(["exports", "aurelia-metadata"], function (exports, _aureliaMetadata) {
define(["exports", "aurelia-metadata", "aurelia-path"], function (exports, _aureliaMetadata, _aureliaPath) {
"use strict";

var _inherits = function (child, parent) {
Expand All @@ -18,15 +18,18 @@ define(["exports", "aurelia-metadata"], function (exports, _aureliaMetadata) {

var getAnnotation = _aureliaMetadata.getAnnotation;
var Origin = _aureliaMetadata.Origin;
var relativeToFile = _aureliaPath.relativeToFile;
var ViewStrategy = function ViewStrategy() {};

ViewStrategy.prototype.makeRelativeTo = function (baseUrl) {};

ViewStrategy.prototype.loadViewFactory = function (viewEngine, options) {
throw new Error("A ViewStrategy must implement loadViewFactory(viewEngine, options).");
};

ViewStrategy.normalize = function (value, viewResources) {
ViewStrategy.normalize = function (value) {
if (typeof value === "string") {
value = new UseView(viewResources ? viewResources.relativeToView(value) : value);
value = new UseView(value);
}

if (value && !(value instanceof ViewStrategy)) {
Expand Down Expand Up @@ -69,7 +72,11 @@ define(["exports", "aurelia-metadata"], function (exports, _aureliaMetadata) {
_inherits(UseView, _ViewStrategy);

UseView.prototype.loadViewFactory = function (viewEngine, options) {
return viewEngine.loadViewFactory(this.path, options, this.moduleId);
return viewEngine.loadViewFactory(this.absolutePath || this.path, options, this.moduleId);
};

UseView.prototype.makeRelativeTo = function (file) {
this.absolutePath = relativeToFile(this.path, file);
};

return UseView;
Expand Down
99 changes: 57 additions & 42 deletions dist/commonjs/composition-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,72 +14,87 @@ CompositionEngine.inject = function () {
return [ResourceCoordinator, ViewEngine];
};

CompositionEngine.prototype.bindAndSwap = function (viewSlot, next, current) {
next.bind(next.executionContext);
viewSlot.swap(next.view);

if (current) {
current.unbind();
CompositionEngine.prototype.activate = function (instruction) {
if (instruction.skipActivation || typeof instruction.viewModel.activate !== "function") {
return Promise.resolve();
}

return next;
return instruction.viewModel.activate(instruction.model) || Promise.resolve();
};

CompositionEngine.prototype.activateViewModel = function (viewModel, model) {
if (typeof viewModel.activate === "function") {
return viewModel.activate(model) || Promise.resolve();
} else {
return Promise.resolve();
}
CompositionEngine.prototype.createBehaviorAndSwap = function (instruction) {
return this.createBehavior(instruction).then(function (behavior) {
instruction.viewSlot.swap(behavior.view);

if (instruction.currentBehavior) {
instruction.currentBehavior.unbind();
}

return behavior;
});
};

CompositionEngine.prototype.createBehavior = function (instruction, container, viewModelInfo) {
var _this = this;
return this.activateViewModel(instruction.viewModel, instruction.model).then(function () {
CompositionEngine.prototype.createBehavior = function (instruction) {
var childContainer = instruction.childContainer, viewModelInfo = instruction.viewModelInfo, viewModel = instruction.viewModel;

return this.activate(instruction).then(function () {
var doneLoading;

if ("getViewStrategy" in instruction.viewModel && !instruction.view) {
instruction.view = ViewStrategy.normalize(instruction.viewModel.getViewStrategy());
if ("getViewStrategy" in viewModel && !instruction.view) {
instruction.view = ViewStrategy.normalize(viewModel.getViewStrategy());
}

if (instruction.view && instruction.viewResources) {
instruction.view.makeRelativeTo(instruction.viewResources.viewUrl);
}

if (viewModelInfo) {
doneLoading = viewModelInfo.type.load(container, viewModelInfo.value, instruction.view);
doneLoading = viewModelInfo.type.load(childContainer, viewModelInfo.value, instruction.view);
} else {
doneLoading = new CustomElement().load(container, instruction.viewModel.constructor, instruction.view);
doneLoading = new CustomElement().load(childContainer, viewModel.constructor, instruction.view);
}

return doneLoading.then(function (behaviorType) {
var behavior = behaviorType.create(container, { executionContext: instruction.viewModel, suppressBind: true });
return _this.bindAndSwap(instruction.viewSlot, behavior, instruction.currentBehavior);
return behaviorType.create(childContainer, { executionContext: viewModel });
});
});
};

CompositionEngine.prototype.compose = function (instruction) {
var _this2 = this;
var childContainer;
CompositionEngine.prototype.createViewModel = function (instruction) {
var childContainer = instruction.childContainer || instruction.container.createChild();

instruction.view = ViewStrategy.normalize(instruction.view);
instruction.viewModel = instruction.viewResources ? instruction.viewResources.relativeToView(instruction.viewModel) : instruction.viewModel;

if (typeof instruction.viewModel === "string") {
instruction.viewModel = instruction.viewResources.relativeToView(instruction.viewModel);
return this.resourceCoordinator.loadViewModelInfo(instruction.viewModel).then(function (viewModelInfo) {
childContainer.autoRegister(viewModelInfo.value);
instruction.viewModel = childContainer.viewModel = childContainer.get(viewModelInfo.value);
instruction.viewModelInfo = viewModelInfo;
return instruction;
});
};

return this.resourceCoordinator.loadViewModelInfo(instruction.viewModel).then(function (viewModelInfo) {
childContainer = instruction.container.createChild();
childContainer.autoRegister(viewModelInfo.value);
instruction.viewModel = childContainer.get(viewModelInfo.value);
return _this2.createBehavior(instruction, childContainer, viewModelInfo);
});
} else {
if (instruction.viewModel) {
return this.createBehavior(instruction, instruction.container.createChild());
} else if (instruction.view) {
return instruction.view.loadViewFactory(this.viewEngine).then(function (viewFactory) {
childContainer = instruction.container.createChild();
result = viewFactory.create(childContainer, instruction.executionContext);
instruction.viewSlot.swap(result);
CompositionEngine.prototype.compose = function (instruction) {
var _this = this;
instruction.childContainer = instruction.childContainer || instruction.container.createChild();
instruction.view = ViewStrategy.normalize(instruction.view);

if (instruction.viewModel) {
if (typeof instruction.viewModel === "string") {
return this.createViewModel(instruction).then(function (instruction) {
return _this.createBehaviorAndSwap(instruction);
});
} else {
return this.createBehaviorAndSwap(instruction);
}
} else if (instruction.view) {
return instruction.view.loadViewFactory(this.viewEngine).then(function (viewFactory) {
result = viewFactory.create(childContainer, instruction.executionContext);
instruction.viewSlot.swap(result);
return result;
});
} else if (instruction.viewSlot) {
instruction.viewSlot.removeAll();
return Promise.resolve(null);
}
};

Expand Down
10 changes: 3 additions & 7 deletions dist/commonjs/custom-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,13 @@ var CustomElement = (function () {
this.tagName = hyphenate(target.name);
}

if (typeof viewStrategy === "string") {
viewStrategy = new UseView(viewStrategy);
}
viewStrategy = viewStrategy || ViewStrategy.getDefault(target);
options = { targetShadowDOM: this.targetShadowDOM };

if (viewStrategy) {
if (!viewStrategy.moduleId) {
viewStrategy.moduleId = Origin.get(target).moduleId;
}

viewStrategy = viewStrategy || ViewStrategy.getDefault(target);
options = { targetShadowDOM: this.targetShadowDOM };

return viewStrategy.loadViewFactory(container.get(ViewEngine), options).then(function (viewFactory) {
_this.viewFactory = viewFactory;
return _this;
Expand Down
13 changes: 10 additions & 3 deletions dist/commonjs/view-strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@ var _inherits = function (child, parent) {

var getAnnotation = require("aurelia-metadata").getAnnotation;
var Origin = require("aurelia-metadata").Origin;
var relativeToFile = require("aurelia-path").relativeToFile;
var ViewStrategy = function ViewStrategy() {};

ViewStrategy.prototype.makeRelativeTo = function (baseUrl) {};

ViewStrategy.prototype.loadViewFactory = function (viewEngine, options) {
throw new Error("A ViewStrategy must implement loadViewFactory(viewEngine, options).");
};

ViewStrategy.normalize = function (value, viewResources) {
ViewStrategy.normalize = function (value) {
if (typeof value === "string") {
value = new UseView(viewResources ? viewResources.relativeToView(value) : value);
value = new UseView(value);
}

if (value && !(value instanceof ViewStrategy)) {
Expand Down Expand Up @@ -68,7 +71,11 @@ var UseView = (function () {
_inherits(UseView, _ViewStrategy);

UseView.prototype.loadViewFactory = function (viewEngine, options) {
return viewEngine.loadViewFactory(this.path, options, this.moduleId);
return viewEngine.loadViewFactory(this.absolutePath || this.path, options, this.moduleId);
};

UseView.prototype.makeRelativeTo = function (file) {
this.absolutePath = relativeToFile(this.path, file);
};

return UseView;
Expand Down
Loading

0 comments on commit 8ec8630

Please sign in to comment.