Skip to content

Commit

Permalink
chore(all): prepare release 1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Oct 2, 2017
1 parent cd3dce8 commit 004ccb1
Show file tree
Hide file tree
Showing 48 changed files with 2,457 additions and 1,544 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-resources",
"version": "1.4.0",
"version": "1.5.0",
"description": "A standard set of behaviors, converters and other resources for use with the Aurelia templating library.",
"keywords": [
"aurelia",
Expand Down
146 changes: 71 additions & 75 deletions dist/amd/array-repeat-strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,71 +36,69 @@ define(['exports', './repeat-utilities', 'aurelia-binding'], function (exports,
}

if (repeat.viewsRequireLifecycle) {
(function () {
var childrenSnapshot = children.slice(0);
var itemNameInBindingContext = repeat.local;
var matcher = repeat.matcher();

var itemsPreviouslyInViews = [];
var viewsToRemove = [];

for (var index = 0; index < viewsLength; index++) {
var view = childrenSnapshot[index];
var oldItem = view.bindingContext[itemNameInBindingContext];

if ((0, _repeatUtilities.indexOf)(items, oldItem, matcher) === -1) {
viewsToRemove.push(view);
} else {
itemsPreviouslyInViews.push(oldItem);
}
}
var childrenSnapshot = children.slice(0);
var itemNameInBindingContext = repeat.local;
var matcher = repeat.matcher();

var updateViews = void 0;
var removePromise = void 0;

if (itemsPreviouslyInViews.length > 0) {
removePromise = repeat.removeViews(viewsToRemove, true, !repeat.viewsRequireLifecycle);
updateViews = function updateViews() {
for (var _index = 0; _index < itemsLength; _index++) {
var item = items[_index];
var indexOfView = (0, _repeatUtilities.indexOf)(itemsPreviouslyInViews, item, matcher, _index);
var _view = void 0;

if (indexOfView === -1) {
var overrideContext = (0, _repeatUtilities.createFullOverrideContext)(repeat, items[_index], _index, itemsLength);
repeat.insertView(_index, overrideContext.bindingContext, overrideContext);

itemsPreviouslyInViews.splice(_index, 0, undefined);
} else if (indexOfView === _index) {
_view = children[indexOfView];
itemsPreviouslyInViews[indexOfView] = undefined;
} else {
_view = children[indexOfView];
repeat.moveView(indexOfView, _index);
itemsPreviouslyInViews.splice(indexOfView, 1);
itemsPreviouslyInViews.splice(_index, 0, undefined);
}

if (_view) {
(0, _repeatUtilities.updateOverrideContext)(_view.overrideContext, _index, itemsLength);
}
}
var itemsPreviouslyInViews = [];
var viewsToRemove = [];

_this._inPlaceProcessItems(repeat, items);
};
} else {
removePromise = repeat.removeAllViews(true, !repeat.viewsRequireLifecycle);
updateViews = function updateViews() {
return _this._standardProcessInstanceChanged(repeat, items);
};
}
for (var index = 0; index < viewsLength; index++) {
var view = childrenSnapshot[index];
var oldItem = view.bindingContext[itemNameInBindingContext];

if (removePromise instanceof Promise) {
removePromise.then(updateViews);
if ((0, _repeatUtilities.indexOf)(items, oldItem, matcher) === -1) {
viewsToRemove.push(view);
} else {
updateViews();
itemsPreviouslyInViews.push(oldItem);
}
})();
}

var updateViews = void 0;
var removePromise = void 0;

if (itemsPreviouslyInViews.length > 0) {
removePromise = repeat.removeViews(viewsToRemove, true, !repeat.viewsRequireLifecycle);
updateViews = function updateViews() {
for (var _index = 0; _index < itemsLength; _index++) {
var item = items[_index];
var indexOfView = (0, _repeatUtilities.indexOf)(itemsPreviouslyInViews, item, matcher, _index);
var _view = void 0;

if (indexOfView === -1) {
var overrideContext = (0, _repeatUtilities.createFullOverrideContext)(repeat, items[_index], _index, itemsLength);
repeat.insertView(_index, overrideContext.bindingContext, overrideContext);

itemsPreviouslyInViews.splice(_index, 0, undefined);
} else if (indexOfView === _index) {
_view = children[indexOfView];
itemsPreviouslyInViews[indexOfView] = undefined;
} else {
_view = children[indexOfView];
repeat.moveView(indexOfView, _index);
itemsPreviouslyInViews.splice(indexOfView, 1);
itemsPreviouslyInViews.splice(_index, 0, undefined);
}

if (_view) {
(0, _repeatUtilities.updateOverrideContext)(_view.overrideContext, _index, itemsLength);
}
}

_this._inPlaceProcessItems(repeat, items);
};
} else {
removePromise = repeat.removeAllViews(true, !repeat.viewsRequireLifecycle);
updateViews = function updateViews() {
return _this._standardProcessInstanceChanged(repeat, items);
};
}

if (removePromise instanceof Promise) {
removePromise.then(updateViews);
} else {
updateViews();
}
} else {
this._inPlaceProcessItems(repeat, items);
}
Expand Down Expand Up @@ -164,23 +162,21 @@ define(['exports', './repeat-utilities', 'aurelia-binding'], function (exports,

var maybePromise = this._runSplices(repeat, array.slice(0), splices);
if (maybePromise instanceof Promise) {
(function () {
var queuedSplices = repeat.__queuedSplices = [];

var runQueuedSplices = function runQueuedSplices() {
if (!queuedSplices.length) {
repeat.__queuedSplices = undefined;
repeat.__array = undefined;
return;
}
var queuedSplices = repeat.__queuedSplices = [];

var nextPromise = _this2._runSplices(repeat, repeat.__array, queuedSplices) || Promise.resolve();
queuedSplices = repeat.__queuedSplices = [];
nextPromise.then(runQueuedSplices);
};
var runQueuedSplices = function runQueuedSplices() {
if (!queuedSplices.length) {
repeat.__queuedSplices = undefined;
repeat.__array = undefined;
return;
}

var nextPromise = _this2._runSplices(repeat, repeat.__array, queuedSplices) || Promise.resolve();
queuedSplices = repeat.__queuedSplices = [];
nextPromise.then(runQueuedSplices);
};

maybePromise.then(runQueuedSplices);
})();
maybePromise.then(runQueuedSplices);
}
};

Expand Down
161 changes: 96 additions & 65 deletions dist/amd/compose.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
define(['exports', 'aurelia-dependency-injection', 'aurelia-task-queue', 'aurelia-templating', 'aurelia-pal'], function (exports, _aureliaDependencyInjection, _aureliaTaskQueue, _aureliaTemplating, _aureliaPal) {
define(['exports', 'aurelia-dependency-injection', 'aurelia-logging', 'aurelia-task-queue', 'aurelia-templating', 'aurelia-pal'], function (exports, _aureliaDependencyInjection, _aureliaLogging, _aureliaTaskQueue, _aureliaTemplating, _aureliaPal) {
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Compose = undefined;

var LogManager = _interopRequireWildcard(_aureliaLogging);

function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
} else {
var newObj = {};

if (obj != null) {
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
}
}

newObj.default = obj;
return newObj;
}
}

function _initDefineProp(target, property, descriptor, context) {
if (!descriptor) return;
Object.defineProperty(target, property, {
Expand Down Expand Up @@ -53,6 +72,8 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-task-queue', 'aureli

var _dec, _dec2, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4;

var logger = LogManager.getLogger('templating-resources');

var Compose = exports.Compose = (_dec = (0, _aureliaTemplating.customElement)('compose'), _dec2 = (0, _aureliaDependencyInjection.inject)(_aureliaPal.DOM.Element, _aureliaDependencyInjection.Container, _aureliaTemplating.CompositionEngine, _aureliaTemplating.ViewSlot, _aureliaTemplating.ViewResources, _aureliaTaskQueue.TaskQueue), _dec(_class = (0, _aureliaTemplating.noView)(_class = _dec2(_class = (_class2 = function () {
function Compose(element, container, compositionEngine, viewSlot, viewResources, taskQueue) {

Expand All @@ -73,6 +94,7 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-task-queue', 'aureli
this.taskQueue = taskQueue;
this.currentController = null;
this.currentViewModel = null;
this.changes = Object.create(null);
}

Compose.prototype.created = function created(owningView) {
Expand All @@ -82,14 +104,15 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-task-queue', 'aureli
Compose.prototype.bind = function bind(bindingContext, overrideContext) {
this.bindingContext = bindingContext;
this.overrideContext = overrideContext;
processInstruction(this, createInstruction(this, {
view: this.view,
viewModel: this.viewModel,
model: this.model
}));
this.changes.view = this.view;
this.changes.viewModel = this.viewModel;
this.changes.model = this.model;
processChanges(this);
};

Compose.prototype.unbind = function unbind(bindingContext, overrideContext) {
Compose.prototype.unbind = function unbind() {
this.changes = Object.create(null);
this.pendingTask = null;
this.bindingContext = null;
this.overrideContext = null;
var returnToCache = true;
Expand All @@ -98,65 +121,18 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-task-queue', 'aureli
};

Compose.prototype.modelChanged = function modelChanged(newValue, oldValue) {
var _this = this;

if (this.currentInstruction) {
this.currentInstruction.model = newValue;
return;
}

this.taskQueue.queueMicroTask(function () {
if (_this.currentInstruction) {
_this.currentInstruction.model = newValue;
return;
}

var vm = _this.currentViewModel;

if (vm && typeof vm.activate === 'function') {
vm.activate(newValue);
}
});
this.changes.model = newValue;
requestUpdate(this);
};

Compose.prototype.viewChanged = function viewChanged(newValue, oldValue) {
var _this2 = this;

var instruction = createInstruction(this, {
view: newValue,
viewModel: this.currentViewModel || this.viewModel,
model: this.model
});

if (this.currentInstruction) {
this.currentInstruction = instruction;
return;
}

this.currentInstruction = instruction;
this.taskQueue.queueMicroTask(function () {
return processInstruction(_this2, _this2.currentInstruction);
});
this.changes.view = newValue;
requestUpdate(this);
};

Compose.prototype.viewModelChanged = function viewModelChanged(newValue, oldValue) {
var _this3 = this;

var instruction = createInstruction(this, {
viewModel: newValue,
view: this.view,
model: this.model
});

if (this.currentInstruction) {
this.currentInstruction = instruction;
return;
}

this.currentInstruction = instruction;
this.taskQueue.queueMicroTask(function () {
return processInstruction(_this3, _this3.currentInstruction);
});
this.changes.viewModel = newValue;
requestUpdate(this);
};

return Compose;
Expand All @@ -175,6 +151,19 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-task-queue', 'aureli
})), _class2)) || _class) || _class) || _class);


function isEmpty(obj) {
for (var key in obj) {
return false;
}
return true;
}

function tryActivateViewModel(vm, model) {
if (vm && typeof vm.activate === 'function') {
return Promise.resolve(vm.activate(model));
}
}

function createInstruction(composer, instruction) {
return Object.assign(instruction, {
bindingContext: composer.bindingContext,
Expand All @@ -189,11 +178,53 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-task-queue', 'aureli
});
}

function processInstruction(composer, instruction) {
composer.currentInstruction = null;
composer.compositionEngine.compose(instruction).then(function (controller) {
composer.currentController = controller;
composer.currentViewModel = controller ? controller.viewModel : null;
function processChanges(composer) {
var changes = composer.changes;
composer.changes = Object.create(null);

if (!('view' in changes) && !('viewModel' in changes) && 'model' in changes) {
composer.pendingTask = tryActivateViewModel(composer.currentViewModel, changes.model);
if (!composer.pendingTask) {
return;
}
} else {
var instruction = {
view: composer.view,
viewModel: composer.currentViewModel || composer.viewModel,
model: composer.model
};

instruction = Object.assign(instruction, changes);

instruction = createInstruction(composer, instruction);
composer.pendingTask = composer.compositionEngine.compose(instruction).then(function (controller) {
composer.currentController = controller;
composer.currentViewModel = controller ? controller.viewModel : null;
});
}

composer.pendingTask = composer.pendingTask.catch(function (e) {
logger.error(e);
}).then(function () {
if (!composer.pendingTask) {
return;
}

composer.pendingTask = null;
if (!isEmpty(composer.changes)) {
processChanges(composer);
}
});
}

function requestUpdate(composer) {
if (composer.pendingTask || composer.updateRequested) {
return;
}
composer.updateRequested = true;
composer.taskQueue.queueMicroTask(function () {
composer.updateRequested = false;
processChanges(composer);
});
}
});
Loading

0 comments on commit 004ccb1

Please sign in to comment.