UNPKG

78.6 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5var aureliaDependencyInjection = require('aurelia-dependency-injection');
6var aureliaPal = require('aurelia-pal');
7var aureliaTaskQueue = require('aurelia-task-queue');
8var aureliaTemplating = require('aurelia-templating');
9var aureliaBinding = require('aurelia-binding');
10var aureliaLoader = require('aurelia-loader');
11var aureliaPath = require('aurelia-path');
12var aureliaMetadata = require('aurelia-metadata');
13var aureliaLogging = require('aurelia-logging');
14
15/*! *****************************************************************************
16Copyright (c) Microsoft Corporation.
17
18Permission to use, copy, modify, and/or distribute this software for any
19purpose with or without fee is hereby granted.
20
21THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
22REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
23AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
24INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
25LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
26OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
27PERFORMANCE OF THIS SOFTWARE.
28***************************************************************************** */
29/* global Reflect, Promise */
30
31var extendStatics = function(d, b) {
32 extendStatics = Object.setPrototypeOf ||
33 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
35 return extendStatics(d, b);
36};
37
38function __extends(d, b) {
39 if (typeof b !== "function" && b !== null)
40 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
41 extendStatics(d, b);
42 function __() { this.constructor = d; }
43 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
44}
45
46function __decorate(decorators, target, key, desc) {
47 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
48 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
49 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
50 return c > 3 && r && Object.defineProperty(target, key, r), r;
51}
52
53var ActivationStrategy;
54(function (ActivationStrategy) {
55 ActivationStrategy["InvokeLifecycle"] = "invoke-lifecycle";
56 ActivationStrategy["Replace"] = "replace";
57})(ActivationStrategy || (ActivationStrategy = {}));
58var Compose = (function () {
59 function Compose(element, container, compositionEngine, viewSlot, viewResources, taskQueue) {
60 this.activationStrategy = ActivationStrategy.InvokeLifecycle;
61 this.element = element;
62 this.container = container;
63 this.compositionEngine = compositionEngine;
64 this.viewSlot = viewSlot;
65 this.viewResources = viewResources;
66 this.taskQueue = taskQueue;
67 this.currentController = null;
68 this.currentViewModel = null;
69 this.changes = Object.create(null);
70 }
71 Compose.inject = function () {
72 return [aureliaPal.DOM.Element, aureliaDependencyInjection.Container, aureliaTemplating.CompositionEngine, aureliaTemplating.ViewSlot, aureliaTemplating.ViewResources, aureliaTaskQueue.TaskQueue];
73 };
74 Compose.prototype.created = function (owningView) {
75 this.owningView = owningView;
76 };
77 Compose.prototype.bind = function (bindingContext, overrideContext) {
78 this.bindingContext = bindingContext;
79 this.overrideContext = overrideContext;
80 var changes = this.changes;
81 changes.view = this.view;
82 changes.viewModel = this.viewModel;
83 changes.model = this.model;
84 if (!this.pendingTask) {
85 processChanges(this);
86 }
87 };
88 Compose.prototype.unbind = function () {
89 this.changes = Object.create(null);
90 this.bindingContext = null;
91 this.overrideContext = null;
92 var returnToCache = true;
93 var skipAnimation = true;
94 this.viewSlot.removeAll(returnToCache, skipAnimation);
95 };
96 Compose.prototype.modelChanged = function (newValue, oldValue) {
97 this.changes.model = newValue;
98 requestUpdate(this);
99 };
100 Compose.prototype.viewChanged = function (newValue, oldValue) {
101 this.changes.view = newValue;
102 requestUpdate(this);
103 };
104 Compose.prototype.viewModelChanged = function (newValue, oldValue) {
105 this.changes.viewModel = newValue;
106 requestUpdate(this);
107 };
108 __decorate([
109 aureliaTemplating.bindable
110 ], Compose.prototype, "model", void 0);
111 __decorate([
112 aureliaTemplating.bindable
113 ], Compose.prototype, "view", void 0);
114 __decorate([
115 aureliaTemplating.bindable
116 ], Compose.prototype, "viewModel", void 0);
117 __decorate([
118 aureliaTemplating.bindable
119 ], Compose.prototype, "activationStrategy", void 0);
120 __decorate([
121 aureliaTemplating.bindable
122 ], Compose.prototype, "swapOrder", void 0);
123 Compose = __decorate([
124 aureliaTemplating.noView,
125 aureliaTemplating.customElement('compose')
126 ], Compose);
127 return Compose;
128}());
129function isEmpty(obj) {
130 for (var _ in obj) {
131 return false;
132 }
133 return true;
134}
135function tryActivateViewModel(vm, model) {
136 if (vm && typeof vm.activate === 'function') {
137 return Promise.resolve(vm.activate(model));
138 }
139}
140function createInstruction(composer, instruction) {
141 return Object.assign(instruction, {
142 bindingContext: composer.bindingContext,
143 overrideContext: composer.overrideContext,
144 owningView: composer.owningView,
145 container: composer.container,
146 viewSlot: composer.viewSlot,
147 viewResources: composer.viewResources,
148 currentController: composer.currentController,
149 host: composer.element,
150 swapOrder: composer.swapOrder
151 });
152}
153function processChanges(composer) {
154 var changes = composer.changes;
155 composer.changes = Object.create(null);
156 if (needsReInitialization(composer, changes)) {
157 var instruction = {
158 view: composer.view,
159 viewModel: composer.currentViewModel || composer.viewModel,
160 model: composer.model
161 };
162 instruction = Object.assign(instruction, changes);
163 instruction = createInstruction(composer, instruction);
164 composer.pendingTask = composer.compositionEngine.compose(instruction).then(function (controller) {
165 composer.currentController = controller;
166 composer.currentViewModel = controller ? controller.viewModel : null;
167 });
168 }
169 else {
170 composer.pendingTask = tryActivateViewModel(composer.currentViewModel, changes.model);
171 if (!composer.pendingTask) {
172 return;
173 }
174 }
175 composer.pendingTask = composer.pendingTask
176 .then(function () {
177 completeCompositionTask(composer);
178 }, function (reason) {
179 completeCompositionTask(composer);
180 throw reason;
181 });
182}
183function completeCompositionTask(composer) {
184 composer.pendingTask = null;
185 if (!isEmpty(composer.changes)) {
186 processChanges(composer);
187 }
188}
189function requestUpdate(composer) {
190 if (composer.pendingTask || composer.updateRequested) {
191 return;
192 }
193 composer.updateRequested = true;
194 composer.taskQueue.queueMicroTask(function () {
195 composer.updateRequested = false;
196 processChanges(composer);
197 });
198}
199function needsReInitialization(composer, changes) {
200 var activationStrategy = composer.activationStrategy;
201 var vm = composer.currentViewModel;
202 if (vm && typeof vm.determineActivationStrategy === 'function') {
203 activationStrategy = vm.determineActivationStrategy();
204 }
205 return 'view' in changes
206 || 'viewModel' in changes
207 || activationStrategy === ActivationStrategy.Replace;
208}
209
210var IfCore = (function () {
211 function IfCore(viewFactory, viewSlot) {
212 this.viewFactory = viewFactory;
213 this.viewSlot = viewSlot;
214 this.view = null;
215 this.bindingContext = null;
216 this.overrideContext = null;
217 this.showing = false;
218 this.cache = true;
219 }
220 IfCore.prototype.bind = function (bindingContext, overrideContext) {
221 this.bindingContext = bindingContext;
222 this.overrideContext = overrideContext;
223 };
224 IfCore.prototype.unbind = function () {
225 if (this.view === null) {
226 return;
227 }
228 this.view.unbind();
229 if (!this.viewFactory.isCaching) {
230 return;
231 }
232 if (this.showing) {
233 this.showing = false;
234 this.viewSlot.remove(this.view, true, true);
235 }
236 else {
237 this.view.returnToCache();
238 }
239 this.view = null;
240 };
241 IfCore.prototype._show = function () {
242 if (this.showing) {
243 if (!this.view.isBound) {
244 this.view.bind(this.bindingContext, this.overrideContext);
245 }
246 return;
247 }
248 if (this.view === null) {
249 this.view = this.viewFactory.create();
250 }
251 if (!this.view.isBound) {
252 this.view.bind(this.bindingContext, this.overrideContext);
253 }
254 this.showing = true;
255 return this.viewSlot.add(this.view);
256 };
257 IfCore.prototype._hide = function () {
258 var _this = this;
259 if (!this.showing) {
260 return;
261 }
262 this.showing = false;
263 var removed = this.viewSlot.remove(this.view);
264 if (removed instanceof Promise) {
265 return removed.then(function () {
266 _this._unbindView();
267 });
268 }
269 this._unbindView();
270 };
271 IfCore.prototype._unbindView = function () {
272 var cache = this.cache === 'false' ? false : !!this.cache;
273 this.view.unbind();
274 if (!cache) {
275 this.view = null;
276 }
277 };
278 return IfCore;
279}());
280
281var If = (function (_super) {
282 __extends(If, _super);
283 function If() {
284 var _this = _super !== null && _super.apply(this, arguments) || this;
285 _this.cache = true;
286 return _this;
287 }
288 If.prototype.bind = function (bindingContext, overrideContext) {
289 _super.prototype.bind.call(this, bindingContext, overrideContext);
290 if (this.condition) {
291 this._show();
292 }
293 else {
294 this._hide();
295 }
296 };
297 If.prototype.conditionChanged = function (newValue) {
298 this._update(newValue);
299 };
300 If.prototype._update = function (show) {
301 var _this = this;
302 if (this.animating) {
303 return;
304 }
305 var promise;
306 if (this.elseVm) {
307 promise = show ? this._swap(this.elseVm, this) : this._swap(this, this.elseVm);
308 }
309 else {
310 promise = show ? this._show() : this._hide();
311 }
312 if (promise) {
313 this.animating = true;
314 promise.then(function () {
315 _this.animating = false;
316 if (_this.condition !== _this.showing) {
317 _this._update(_this.condition);
318 }
319 });
320 }
321 };
322 If.prototype._swap = function (remove, add) {
323 switch (this.swapOrder) {
324 case 'before':
325 return Promise.resolve(add._show()).then(function () { return remove._hide(); });
326 case 'with':
327 return Promise.all([remove._hide(), add._show()]);
328 default:
329 var promise = remove._hide();
330 return promise ? promise.then(function () { return add._show(); }) : add._show();
331 }
332 };
333 __decorate([
334 aureliaTemplating.bindable({ primaryProperty: true })
335 ], If.prototype, "condition", void 0);
336 __decorate([
337 aureliaTemplating.bindable
338 ], If.prototype, "swapOrder", void 0);
339 __decorate([
340 aureliaTemplating.bindable
341 ], If.prototype, "cache", void 0);
342 If = __decorate([
343 aureliaTemplating.customAttribute('if'),
344 aureliaTemplating.templateController,
345 aureliaDependencyInjection.inject(aureliaTemplating.BoundViewFactory, aureliaTemplating.ViewSlot)
346 ], If);
347 return If;
348}(IfCore));
349
350var Else = (function (_super) {
351 __extends(Else, _super);
352 function Else(viewFactory, viewSlot) {
353 var _this = _super.call(this, viewFactory, viewSlot) || this;
354 _this._registerInIf();
355 return _this;
356 }
357 Else.prototype.bind = function (bindingContext, overrideContext) {
358 _super.prototype.bind.call(this, bindingContext, overrideContext);
359 if (this.ifVm.condition) {
360 this._hide();
361 }
362 else {
363 this._show();
364 }
365 };
366 Else.prototype._registerInIf = function () {
367 var previous = this.viewSlot.anchor.previousSibling;
368 while (previous && !previous.au) {
369 previous = previous.previousSibling;
370 }
371 if (!previous || !previous.au.if) {
372 throw new Error("Can't find matching If for Else custom attribute.");
373 }
374 this.ifVm = previous.au.if.viewModel;
375 this.ifVm.elseVm = this;
376 };
377 Else = __decorate([
378 aureliaTemplating.customAttribute('else'),
379 aureliaTemplating.templateController,
380 aureliaDependencyInjection.inject(aureliaTemplating.BoundViewFactory, aureliaTemplating.ViewSlot)
381 ], Else);
382 return Else;
383}(IfCore));
384
385var With = (function () {
386 function With(viewFactory, viewSlot) {
387 this.viewFactory = viewFactory;
388 this.viewSlot = viewSlot;
389 this.parentOverrideContext = null;
390 this.view = null;
391 }
392 With.prototype.bind = function (bindingContext, overrideContext) {
393 this.parentOverrideContext = overrideContext;
394 this.valueChanged(this.value);
395 };
396 With.prototype.valueChanged = function (newValue) {
397 var overrideContext = aureliaBinding.createOverrideContext(newValue, this.parentOverrideContext);
398 var view = this.view;
399 if (!view) {
400 view = this.view = this.viewFactory.create();
401 view.bind(newValue, overrideContext);
402 this.viewSlot.add(view);
403 }
404 else {
405 view.bind(newValue, overrideContext);
406 }
407 };
408 With.prototype.unbind = function () {
409 var view = this.view;
410 this.parentOverrideContext = null;
411 if (view) {
412 view.unbind();
413 }
414 };
415 With = __decorate([
416 aureliaTemplating.customAttribute('with'),
417 aureliaTemplating.templateController,
418 aureliaDependencyInjection.inject(aureliaTemplating.BoundViewFactory, aureliaTemplating.ViewSlot)
419 ], With);
420 return With;
421}());
422
423var oneTime = aureliaBinding.bindingMode.oneTime;
424function updateOverrideContexts(views, startIndex) {
425 var length = views.length;
426 if (startIndex > 0) {
427 startIndex = startIndex - 1;
428 }
429 for (; startIndex < length; ++startIndex) {
430 updateOverrideContext(views[startIndex].overrideContext, startIndex, length);
431 }
432}
433function createFullOverrideContext(repeat, data, index, length, key) {
434 var bindingContext = {};
435 var overrideContext = aureliaBinding.createOverrideContext(bindingContext, repeat.scope.overrideContext);
436 if (typeof key !== 'undefined') {
437 bindingContext[repeat.key] = key;
438 bindingContext[repeat.value] = data;
439 }
440 else {
441 bindingContext[repeat.local] = data;
442 }
443 updateOverrideContext(overrideContext, index, length);
444 return overrideContext;
445}
446function updateOverrideContext(overrideContext, index, length) {
447 var first = (index === 0);
448 var last = (index === length - 1);
449 var even = index % 2 === 0;
450 overrideContext.$index = index;
451 overrideContext.$first = first;
452 overrideContext.$last = last;
453 overrideContext.$middle = !(first || last);
454 overrideContext.$odd = !even;
455 overrideContext.$even = even;
456}
457function getItemsSourceExpression(instruction, attrName) {
458 return instruction.behaviorInstructions
459 .filter(function (bi) { return bi.originalAttrName === attrName; })[0]
460 .attributes
461 .items
462 .sourceExpression;
463}
464function unwrapExpression(expression) {
465 var unwrapped = false;
466 while (expression instanceof aureliaBinding.BindingBehavior) {
467 expression = expression.expression;
468 }
469 while (expression instanceof aureliaBinding.ValueConverter) {
470 expression = expression.expression;
471 unwrapped = true;
472 }
473 return unwrapped ? expression : null;
474}
475function isOneTime(expression) {
476 while (expression instanceof aureliaBinding.BindingBehavior) {
477 if (expression.name === 'oneTime') {
478 return true;
479 }
480 expression = expression.expression;
481 }
482 return false;
483}
484function updateOneTimeBinding(binding) {
485 if (binding.call && binding.mode === oneTime) {
486 binding.call(aureliaBinding.sourceContext);
487 }
488 else if (binding.updateOneTimeBindings) {
489 binding.updateOneTimeBindings();
490 }
491}
492function indexOf(array, item, matcher, startIndex) {
493 if (!matcher) {
494 return array.indexOf(item);
495 }
496 var length = array.length;
497 for (var index = startIndex || 0; index < length; index++) {
498 if (matcher(array[index], item)) {
499 return index;
500 }
501 }
502 return -1;
503}
504
505var ArrayRepeatStrategy = (function () {
506 function ArrayRepeatStrategy() {
507 }
508 ArrayRepeatStrategy.prototype.getCollectionObserver = function (observerLocator, items) {
509 return observerLocator.getArrayObserver(items);
510 };
511 ArrayRepeatStrategy.prototype.instanceChanged = function (repeat, items) {
512 var _this = this;
513 var $repeat = repeat;
514 var itemsLength = items.length;
515 if (!items || itemsLength === 0) {
516 $repeat.removeAllViews(true, !$repeat.viewsRequireLifecycle);
517 return;
518 }
519 var children = $repeat.views();
520 var viewsLength = children.length;
521 if (viewsLength === 0) {
522 this._standardProcessInstanceChanged($repeat, items);
523 return;
524 }
525 if ($repeat.viewsRequireLifecycle) {
526 var childrenSnapshot = children.slice(0);
527 var itemNameInBindingContext = $repeat.local;
528 var matcher_1 = $repeat.matcher();
529 var itemsPreviouslyInViews_1 = [];
530 var viewsToRemove = [];
531 for (var index = 0; index < viewsLength; index++) {
532 var view = childrenSnapshot[index];
533 var oldItem = view.bindingContext[itemNameInBindingContext];
534 if (indexOf(items, oldItem, matcher_1) === -1) {
535 viewsToRemove.push(view);
536 }
537 else {
538 itemsPreviouslyInViews_1.push(oldItem);
539 }
540 }
541 var updateViews = void 0;
542 var removePromise = void 0;
543 if (itemsPreviouslyInViews_1.length > 0) {
544 removePromise = $repeat.removeViews(viewsToRemove, true, !$repeat.viewsRequireLifecycle);
545 updateViews = function () {
546 for (var index = 0; index < itemsLength; index++) {
547 var item = items[index];
548 var indexOfView = indexOf(itemsPreviouslyInViews_1, item, matcher_1, index);
549 var view = void 0;
550 if (indexOfView === -1) {
551 var overrideContext = createFullOverrideContext($repeat, items[index], index, itemsLength);
552 $repeat.insertView(index, overrideContext.bindingContext, overrideContext);
553 itemsPreviouslyInViews_1.splice(index, 0, undefined);
554 }
555 else if (indexOfView === index) {
556 view = children[indexOfView];
557 itemsPreviouslyInViews_1[indexOfView] = undefined;
558 }
559 else {
560 view = children[indexOfView];
561 $repeat.moveView(indexOfView, index);
562 itemsPreviouslyInViews_1.splice(indexOfView, 1);
563 itemsPreviouslyInViews_1.splice(index, 0, undefined);
564 }
565 if (view) {
566 updateOverrideContext(view.overrideContext, index, itemsLength);
567 }
568 }
569 _this._inPlaceProcessItems($repeat, items);
570 };
571 }
572 else {
573 removePromise = $repeat.removeAllViews(true, !$repeat.viewsRequireLifecycle);
574 updateViews = function () { return _this._standardProcessInstanceChanged($repeat, items); };
575 }
576 if (removePromise instanceof Promise) {
577 removePromise.then(updateViews);
578 }
579 else {
580 updateViews();
581 }
582 }
583 else {
584 this._inPlaceProcessItems($repeat, items);
585 }
586 };
587 ArrayRepeatStrategy.prototype._standardProcessInstanceChanged = function (repeat, items) {
588 for (var i = 0, ii = items.length; i < ii; i++) {
589 var overrideContext = createFullOverrideContext(repeat, items[i], i, ii);
590 repeat.addView(overrideContext.bindingContext, overrideContext);
591 }
592 };
593 ArrayRepeatStrategy.prototype._inPlaceProcessItems = function (repeat, items) {
594 var itemsLength = items.length;
595 var viewsLength = repeat.viewCount();
596 while (viewsLength > itemsLength) {
597 viewsLength--;
598 repeat.removeView(viewsLength, true, !repeat.viewsRequireLifecycle);
599 }
600 var local = repeat.local;
601 for (var i = 0; i < viewsLength; i++) {
602 var view = repeat.view(i);
603 var last = i === itemsLength - 1;
604 var middle = i !== 0 && !last;
605 var bindingContext = view.bindingContext;
606 var overrideContext = view.overrideContext;
607 if (bindingContext[local] === items[i]
608 && overrideContext.$middle === middle
609 && overrideContext.$last === last) {
610 continue;
611 }
612 bindingContext[local] = items[i];
613 overrideContext.$middle = middle;
614 overrideContext.$last = last;
615 repeat.updateBindings(view);
616 }
617 for (var i = viewsLength; i < itemsLength; i++) {
618 var overrideContext = createFullOverrideContext(repeat, items[i], i, itemsLength);
619 repeat.addView(overrideContext.bindingContext, overrideContext);
620 }
621 };
622 ArrayRepeatStrategy.prototype.instanceMutated = function (repeat, array, splices) {
623 var _this = this;
624 if (repeat.__queuedSplices) {
625 for (var i = 0, ii = splices.length; i < ii; ++i) {
626 var _a = splices[i], index = _a.index, removed = _a.removed, addedCount = _a.addedCount;
627 aureliaBinding.mergeSplice(repeat.__queuedSplices, index, removed, addedCount);
628 }
629 repeat.__array = array.slice(0);
630 return;
631 }
632 var maybePromise = this._runSplices(repeat, array.slice(0), splices);
633 if (maybePromise instanceof Promise) {
634 var queuedSplices_1 = repeat.__queuedSplices = [];
635 var runQueuedSplices_1 = function () {
636 if (!queuedSplices_1.length) {
637 repeat.__queuedSplices = undefined;
638 repeat.__array = undefined;
639 return;
640 }
641 var nextPromise = _this._runSplices(repeat, repeat.__array, queuedSplices_1) || Promise.resolve();
642 queuedSplices_1 = repeat.__queuedSplices = [];
643 nextPromise.then(runQueuedSplices_1);
644 };
645 maybePromise.then(runQueuedSplices_1);
646 }
647 };
648 ArrayRepeatStrategy.prototype._runSplices = function (repeat, array, splices) {
649 var _this = this;
650 var removeDelta = 0;
651 var rmPromises = [];
652 for (var i = 0, ii = splices.length; i < ii; ++i) {
653 var splice = splices[i];
654 var removed = splice.removed;
655 for (var j = 0, jj = removed.length; j < jj; ++j) {
656 var viewOrPromise = repeat.removeView(splice.index + removeDelta + rmPromises.length, true);
657 if (viewOrPromise instanceof Promise) {
658 rmPromises.push(viewOrPromise);
659 }
660 }
661 removeDelta -= splice.addedCount;
662 }
663 if (rmPromises.length > 0) {
664 return Promise.all(rmPromises).then(function () {
665 var spliceIndexLow = _this._handleAddedSplices(repeat, array, splices);
666 updateOverrideContexts(repeat.views(), spliceIndexLow);
667 });
668 }
669 var spliceIndexLow = this._handleAddedSplices(repeat, array, splices);
670 updateOverrideContexts(repeat.views(), spliceIndexLow);
671 return undefined;
672 };
673 ArrayRepeatStrategy.prototype._handleAddedSplices = function (repeat, array, splices) {
674 var spliceIndex;
675 var spliceIndexLow;
676 var arrayLength = array.length;
677 for (var i = 0, ii = splices.length; i < ii; ++i) {
678 var splice = splices[i];
679 var addIndex = spliceIndex = splice.index;
680 var end = splice.index + splice.addedCount;
681 if (typeof spliceIndexLow === 'undefined' || spliceIndexLow === null || spliceIndexLow > splice.index) {
682 spliceIndexLow = spliceIndex;
683 }
684 for (; addIndex < end; ++addIndex) {
685 var overrideContext = createFullOverrideContext(repeat, array[addIndex], addIndex, arrayLength);
686 repeat.insertView(addIndex, overrideContext.bindingContext, overrideContext);
687 }
688 }
689 return spliceIndexLow;
690 };
691 return ArrayRepeatStrategy;
692}());
693
694var MapRepeatStrategy = (function () {
695 function MapRepeatStrategy() {
696 }
697 MapRepeatStrategy.prototype.getCollectionObserver = function (observerLocator, items) {
698 return observerLocator.getMapObserver(items);
699 };
700 MapRepeatStrategy.prototype.instanceChanged = function (repeat, items) {
701 var _this = this;
702 var removePromise = repeat.removeAllViews(true, !repeat.viewsRequireLifecycle);
703 if (removePromise instanceof Promise) {
704 removePromise.then(function () { return _this._standardProcessItems(repeat, items); });
705 return;
706 }
707 this._standardProcessItems(repeat, items);
708 };
709 MapRepeatStrategy.prototype._standardProcessItems = function (repeat, items) {
710 var index = 0;
711 var overrideContext;
712 items.forEach(function (value, key) {
713 overrideContext = createFullOverrideContext(repeat, value, index, items.size, key);
714 repeat.addView(overrideContext.bindingContext, overrideContext);
715 ++index;
716 });
717 };
718 MapRepeatStrategy.prototype.instanceMutated = function (repeat, map, records) {
719 var key;
720 var i;
721 var ii;
722 var overrideContext;
723 var removeIndex;
724 var addIndex;
725 var record;
726 var rmPromises = [];
727 var viewOrPromise;
728 for (i = 0, ii = records.length; i < ii; ++i) {
729 record = records[i];
730 key = record.key;
731 switch (record.type) {
732 case 'update':
733 removeIndex = this._getViewIndexByKey(repeat, key);
734 viewOrPromise = repeat.removeView(removeIndex, true, !repeat.viewsRequireLifecycle);
735 if (viewOrPromise instanceof Promise) {
736 rmPromises.push(viewOrPromise);
737 }
738 overrideContext = createFullOverrideContext(repeat, map.get(key), removeIndex, map.size, key);
739 repeat.insertView(removeIndex, overrideContext.bindingContext, overrideContext);
740 break;
741 case 'add':
742 addIndex = repeat.viewCount() <= map.size - 1 ? repeat.viewCount() : map.size - 1;
743 overrideContext = createFullOverrideContext(repeat, map.get(key), addIndex, map.size, key);
744 repeat.insertView(map.size - 1, overrideContext.bindingContext, overrideContext);
745 break;
746 case 'delete':
747 if (record.oldValue === undefined) {
748 return;
749 }
750 removeIndex = this._getViewIndexByKey(repeat, key);
751 viewOrPromise = repeat.removeView(removeIndex, true, !repeat.viewsRequireLifecycle);
752 if (viewOrPromise instanceof Promise) {
753 rmPromises.push(viewOrPromise);
754 }
755 break;
756 case 'clear':
757 repeat.removeAllViews(true, !repeat.viewsRequireLifecycle);
758 break;
759 default:
760 continue;
761 }
762 }
763 if (rmPromises.length > 0) {
764 Promise.all(rmPromises).then(function () {
765 updateOverrideContexts(repeat.views(), 0);
766 });
767 }
768 else {
769 updateOverrideContexts(repeat.views(), 0);
770 }
771 };
772 MapRepeatStrategy.prototype._getViewIndexByKey = function (repeat, key) {
773 var i;
774 var ii;
775 var child;
776 for (i = 0, ii = repeat.viewCount(); i < ii; ++i) {
777 child = repeat.view(i);
778 if (child.bindingContext[repeat.key] === key) {
779 return i;
780 }
781 }
782 return undefined;
783 };
784 return MapRepeatStrategy;
785}());
786
787var NullRepeatStrategy = (function () {
788 function NullRepeatStrategy() {
789 }
790 NullRepeatStrategy.prototype.instanceChanged = function (repeat, items) {
791 repeat.removeAllViews(true);
792 };
793 NullRepeatStrategy.prototype.getCollectionObserver = function (observerLocator, items) {
794 };
795 return NullRepeatStrategy;
796}());
797
798var NumberRepeatStrategy = (function () {
799 function NumberRepeatStrategy() {
800 }
801 NumberRepeatStrategy.prototype.getCollectionObserver = function () {
802 return null;
803 };
804 NumberRepeatStrategy.prototype.instanceChanged = function (repeat, value) {
805 var _this = this;
806 var removePromise = repeat.removeAllViews(true, !repeat.viewsRequireLifecycle);
807 if (removePromise instanceof Promise) {
808 removePromise.then(function () { return _this._standardProcessItems(repeat, value); });
809 return;
810 }
811 this._standardProcessItems(repeat, value);
812 };
813 NumberRepeatStrategy.prototype._standardProcessItems = function (repeat, value) {
814 var childrenLength = repeat.viewCount();
815 var i;
816 var ii;
817 var overrideContext;
818 var viewsToRemove;
819 value = Math.floor(value);
820 viewsToRemove = childrenLength - value;
821 if (viewsToRemove > 0) {
822 if (viewsToRemove > childrenLength) {
823 viewsToRemove = childrenLength;
824 }
825 for (i = 0, ii = viewsToRemove; i < ii; ++i) {
826 repeat.removeView(childrenLength - (i + 1), true, !repeat.viewsRequireLifecycle);
827 }
828 return;
829 }
830 for (i = childrenLength, ii = value; i < ii; ++i) {
831 overrideContext = createFullOverrideContext(repeat, i, i, ii);
832 repeat.addView(overrideContext.bindingContext, overrideContext);
833 }
834 updateOverrideContexts(repeat.views(), 0);
835 };
836 return NumberRepeatStrategy;
837}());
838
839var SetRepeatStrategy = (function () {
840 function SetRepeatStrategy() {
841 }
842 SetRepeatStrategy.prototype.getCollectionObserver = function (observerLocator, items) {
843 return observerLocator.getSetObserver(items);
844 };
845 SetRepeatStrategy.prototype.instanceChanged = function (repeat, items) {
846 var _this = this;
847 var removePromise = repeat.removeAllViews(true, !repeat.viewsRequireLifecycle);
848 if (removePromise instanceof Promise) {
849 removePromise.then(function () { return _this._standardProcessItems(repeat, items); });
850 return;
851 }
852 this._standardProcessItems(repeat, items);
853 };
854 SetRepeatStrategy.prototype._standardProcessItems = function (repeat, items) {
855 var index = 0;
856 var overrideContext;
857 items.forEach(function (value) {
858 overrideContext = createFullOverrideContext(repeat, value, index, items.size);
859 repeat.addView(overrideContext.bindingContext, overrideContext);
860 ++index;
861 });
862 };
863 SetRepeatStrategy.prototype.instanceMutated = function (repeat, set, records) {
864 var value;
865 var i;
866 var ii;
867 var overrideContext;
868 var removeIndex;
869 var record;
870 var rmPromises = [];
871 var viewOrPromise;
872 for (i = 0, ii = records.length; i < ii; ++i) {
873 record = records[i];
874 value = record.value;
875 switch (record.type) {
876 case 'add':
877 var size = Math.max(set.size - 1, 0);
878 overrideContext = createFullOverrideContext(repeat, value, size, set.size);
879 repeat.insertView(size, overrideContext.bindingContext, overrideContext);
880 break;
881 case 'delete':
882 removeIndex = this._getViewIndexByValue(repeat, value);
883 viewOrPromise = repeat.removeView(removeIndex, true, !repeat.viewsRequireLifecycle);
884 if (viewOrPromise instanceof Promise) {
885 rmPromises.push(viewOrPromise);
886 }
887 break;
888 case 'clear':
889 repeat.removeAllViews(true, !repeat.viewsRequireLifecycle);
890 break;
891 default:
892 continue;
893 }
894 }
895 if (rmPromises.length > 0) {
896 Promise.all(rmPromises).then(function () {
897 updateOverrideContexts(repeat.views(), 0);
898 });
899 }
900 else {
901 updateOverrideContexts(repeat.views(), 0);
902 }
903 };
904 SetRepeatStrategy.prototype._getViewIndexByValue = function (repeat, value) {
905 var i;
906 var ii;
907 var child;
908 for (i = 0, ii = repeat.viewCount(); i < ii; ++i) {
909 child = repeat.view(i);
910 if (child.bindingContext[repeat.local] === value) {
911 return i;
912 }
913 }
914 return undefined;
915 };
916 return SetRepeatStrategy;
917}());
918
919var RepeatStrategyLocator = (function () {
920 function RepeatStrategyLocator() {
921 this.matchers = [];
922 this.strategies = [];
923 this.addStrategy(function (items) { return items === null || items === undefined; }, new NullRepeatStrategy());
924 this.addStrategy(function (items) { return items instanceof Array; }, new ArrayRepeatStrategy());
925 this.addStrategy(function (items) { return items instanceof Map; }, new MapRepeatStrategy());
926 this.addStrategy(function (items) { return items instanceof Set; }, new SetRepeatStrategy());
927 this.addStrategy(function (items) { return typeof items === 'number'; }, new NumberRepeatStrategy());
928 }
929 RepeatStrategyLocator.prototype.addStrategy = function (matcher, strategy) {
930 this.matchers.push(matcher);
931 this.strategies.push(strategy);
932 };
933 RepeatStrategyLocator.prototype.getStrategy = function (items) {
934 var matchers = this.matchers;
935 for (var i = 0, ii = matchers.length; i < ii; ++i) {
936 if (matchers[i](items)) {
937 return this.strategies[i];
938 }
939 }
940 return null;
941 };
942 return RepeatStrategyLocator;
943}());
944
945var lifecycleOptionalBehaviors = ['focus', 'if', 'else', 'repeat', 'show', 'hide', 'with'];
946function behaviorRequiresLifecycle(instruction) {
947 var t = instruction.type;
948 var name = t.elementName !== null ? t.elementName : t.attributeName;
949 return lifecycleOptionalBehaviors.indexOf(name) === -1 && (t.handlesAttached || t.handlesBind || t.handlesCreated || t.handlesDetached || t.handlesUnbind)
950 || t.viewFactory && viewsRequireLifecycle(t.viewFactory)
951 || instruction.viewFactory && viewsRequireLifecycle(instruction.viewFactory);
952}
953function targetRequiresLifecycle(instruction) {
954 var behaviors = instruction.behaviorInstructions;
955 if (behaviors) {
956 var i = behaviors.length;
957 while (i--) {
958 if (behaviorRequiresLifecycle(behaviors[i])) {
959 return true;
960 }
961 }
962 }
963 return instruction.viewFactory && viewsRequireLifecycle(instruction.viewFactory);
964}
965function viewsRequireLifecycle(viewFactory) {
966 if ('_viewsRequireLifecycle' in viewFactory) {
967 return viewFactory._viewsRequireLifecycle;
968 }
969 viewFactory._viewsRequireLifecycle = false;
970 if (viewFactory.viewFactory) {
971 viewFactory._viewsRequireLifecycle = viewsRequireLifecycle(viewFactory.viewFactory);
972 return viewFactory._viewsRequireLifecycle;
973 }
974 if (viewFactory.template.querySelector('.au-animate')) {
975 viewFactory._viewsRequireLifecycle = true;
976 return true;
977 }
978 for (var id in viewFactory.instructions) {
979 if (targetRequiresLifecycle(viewFactory.instructions[id])) {
980 viewFactory._viewsRequireLifecycle = true;
981 return true;
982 }
983 }
984 viewFactory._viewsRequireLifecycle = false;
985 return false;
986}
987
988var AbstractRepeater = (function () {
989 function AbstractRepeater(options) {
990 Object.assign(this, {
991 local: 'items',
992 viewsRequireLifecycle: true
993 }, options);
994 }
995 AbstractRepeater.prototype.viewCount = function () {
996 throw new Error('subclass must implement `viewCount`');
997 };
998 AbstractRepeater.prototype.views = function () {
999 throw new Error('subclass must implement `views`');
1000 };
1001 AbstractRepeater.prototype.view = function (index) {
1002 throw new Error('subclass must implement `view`');
1003 };
1004 AbstractRepeater.prototype.matcher = function () {
1005 throw new Error('subclass must implement `matcher`');
1006 };
1007 AbstractRepeater.prototype.addView = function (bindingContext, overrideContext) {
1008 throw new Error('subclass must implement `addView`');
1009 };
1010 AbstractRepeater.prototype.insertView = function (index, bindingContext, overrideContext) {
1011 throw new Error('subclass must implement `insertView`');
1012 };
1013 AbstractRepeater.prototype.moveView = function (sourceIndex, targetIndex) {
1014 throw new Error('subclass must implement `moveView`');
1015 };
1016 AbstractRepeater.prototype.removeAllViews = function (returnToCache, skipAnimation) {
1017 throw new Error('subclass must implement `removeAllViews`');
1018 };
1019 AbstractRepeater.prototype.removeViews = function (viewsToRemove, returnToCache, skipAnimation) {
1020 throw new Error('subclass must implement `removeView`');
1021 };
1022 AbstractRepeater.prototype.removeView = function (index, returnToCache, skipAnimation) {
1023 throw new Error('subclass must implement `removeView`');
1024 };
1025 AbstractRepeater.prototype.updateBindings = function (view) {
1026 throw new Error('subclass must implement `updateBindings`');
1027 };
1028 return AbstractRepeater;
1029}());
1030
1031var matcherExtractionMarker = '__marker_extracted__';
1032var Repeat = (function (_super) {
1033 __extends(Repeat, _super);
1034 function Repeat(viewFactory, instruction, viewSlot, viewResources, observerLocator, strategyLocator) {
1035 var _this = _super.call(this, {
1036 local: 'item',
1037 viewsRequireLifecycle: viewsRequireLifecycle(viewFactory)
1038 }) || this;
1039 _this.viewFactory = viewFactory;
1040 _this.instruction = instruction;
1041 _this.viewSlot = viewSlot;
1042 _this.lookupFunctions = viewResources.lookupFunctions;
1043 _this.observerLocator = observerLocator;
1044 _this.key = 'key';
1045 _this.value = 'value';
1046 _this.strategyLocator = strategyLocator;
1047 _this.ignoreMutation = false;
1048 _this.sourceExpression = getItemsSourceExpression(_this.instruction, 'repeat.for');
1049 _this.isOneTime = isOneTime(_this.sourceExpression);
1050 _this.viewsRequireLifecycle = viewsRequireLifecycle(viewFactory);
1051 return _this;
1052 }
1053 Repeat_1 = Repeat;
1054 Repeat.prototype.call = function (context, changes) {
1055 this[context](this.items, changes);
1056 };
1057 Repeat.prototype.bind = function (bindingContext, overrideContext) {
1058 this.scope = { bindingContext: bindingContext, overrideContext: overrideContext };
1059 var instruction = this.instruction;
1060 if (!(matcherExtractionMarker in instruction)) {
1061 instruction[matcherExtractionMarker] = this._captureAndRemoveMatcherBinding();
1062 }
1063 this.matcherBinding = instruction[matcherExtractionMarker];
1064 this.itemsChanged();
1065 };
1066 Repeat.prototype.unbind = function () {
1067 this.scope = null;
1068 this.items = null;
1069 this.matcherBinding = null;
1070 this.viewSlot.removeAll(true, true);
1071 this._unsubscribeCollection();
1072 };
1073 Repeat.prototype._unsubscribeCollection = function () {
1074 if (this.collectionObserver) {
1075 this.collectionObserver.unsubscribe(this.callContext, this);
1076 this.collectionObserver = null;
1077 this.callContext = null;
1078 }
1079 };
1080 Repeat.prototype.itemsChanged = function () {
1081 var _this = this;
1082 this._unsubscribeCollection();
1083 if (!this.scope) {
1084 return;
1085 }
1086 var items = this.items;
1087 this.strategy = this.strategyLocator.getStrategy(items);
1088 if (!this.strategy) {
1089 throw new Error("Value for '".concat(this.sourceExpression, "' is non-repeatable"));
1090 }
1091 if (!this.isOneTime && !this._observeInnerCollection()) {
1092 this._observeCollection();
1093 }
1094 this.ignoreMutation = true;
1095 this.strategy.instanceChanged(this, items);
1096 this.observerLocator.taskQueue.queueMicroTask(function () {
1097 _this.ignoreMutation = false;
1098 });
1099 };
1100 Repeat.prototype._getInnerCollection = function () {
1101 var expression = unwrapExpression(this.sourceExpression);
1102 if (!expression) {
1103 return null;
1104 }
1105 return expression.evaluate(this.scope, null);
1106 };
1107 Repeat.prototype.handleCollectionMutated = function (collection, changes) {
1108 if (!this.collectionObserver) {
1109 return;
1110 }
1111 if (this.ignoreMutation) {
1112 return;
1113 }
1114 this.strategy.instanceMutated(this, collection, changes);
1115 };
1116 Repeat.prototype.handleInnerCollectionMutated = function (collection, changes) {
1117 var _this = this;
1118 if (!this.collectionObserver) {
1119 return;
1120 }
1121 if (this.ignoreMutation) {
1122 return;
1123 }
1124 this.ignoreMutation = true;
1125 var newItems = this.sourceExpression.evaluate(this.scope, this.lookupFunctions);
1126 this.observerLocator.taskQueue.queueMicroTask(function () { return _this.ignoreMutation = false; });
1127 if (newItems === this.items) {
1128 this.itemsChanged();
1129 }
1130 else {
1131 this.items = newItems;
1132 }
1133 };
1134 Repeat.prototype._observeInnerCollection = function () {
1135 var items = this._getInnerCollection();
1136 var strategy = this.strategyLocator.getStrategy(items);
1137 if (!strategy) {
1138 return false;
1139 }
1140 this.collectionObserver = strategy.getCollectionObserver(this.observerLocator, items);
1141 if (!this.collectionObserver) {
1142 return false;
1143 }
1144 this.callContext = 'handleInnerCollectionMutated';
1145 this.collectionObserver.subscribe(this.callContext, this);
1146 return true;
1147 };
1148 Repeat.prototype._observeCollection = function () {
1149 var items = this.items;
1150 this.collectionObserver = this.strategy.getCollectionObserver(this.observerLocator, items);
1151 if (this.collectionObserver) {
1152 this.callContext = 'handleCollectionMutated';
1153 this.collectionObserver.subscribe(this.callContext, this);
1154 }
1155 };
1156 Repeat.prototype._captureAndRemoveMatcherBinding = function () {
1157 var viewFactory = this.viewFactory.viewFactory;
1158 if (viewFactory) {
1159 var template = viewFactory.template;
1160 var instructions = viewFactory.instructions;
1161 if (Repeat_1.useInnerMatcher) {
1162 return extractMatcherBindingExpression(instructions);
1163 }
1164 if (getChildrenCount(template) > 1) {
1165 return undefined;
1166 }
1167 var repeatedElement = getFirstElementChild(template);
1168 if (!repeatedElement.hasAttribute('au-target-id')) {
1169 return undefined;
1170 }
1171 var repeatedElementTargetId = repeatedElement.getAttribute('au-target-id');
1172 return extractMatcherBindingExpression(instructions, repeatedElementTargetId);
1173 }
1174 return undefined;
1175 };
1176 Repeat.prototype.viewCount = function () { return this.viewSlot.children.length; };
1177 Repeat.prototype.views = function () { return this.viewSlot.children; };
1178 Repeat.prototype.view = function (index) { return this.viewSlot.children[index]; };
1179 Repeat.prototype.matcher = function () {
1180 var matcherBinding = this.matcherBinding;
1181 return matcherBinding
1182 ? matcherBinding.sourceExpression.evaluate(this.scope, matcherBinding.lookupFunctions)
1183 : null;
1184 };
1185 Repeat.prototype.addView = function (bindingContext, overrideContext) {
1186 var view = this.viewFactory.create();
1187 view.bind(bindingContext, overrideContext);
1188 this.viewSlot.add(view);
1189 };
1190 Repeat.prototype.insertView = function (index, bindingContext, overrideContext) {
1191 var view = this.viewFactory.create();
1192 view.bind(bindingContext, overrideContext);
1193 this.viewSlot.insert(index, view);
1194 };
1195 Repeat.prototype.moveView = function (sourceIndex, targetIndex) {
1196 this.viewSlot.move(sourceIndex, targetIndex);
1197 };
1198 Repeat.prototype.removeAllViews = function (returnToCache, skipAnimation) {
1199 return this.viewSlot.removeAll(returnToCache, skipAnimation);
1200 };
1201 Repeat.prototype.removeViews = function (viewsToRemove, returnToCache, skipAnimation) {
1202 return this.viewSlot.removeMany(viewsToRemove, returnToCache, skipAnimation);
1203 };
1204 Repeat.prototype.removeView = function (index, returnToCache, skipAnimation) {
1205 return this.viewSlot.removeAt(index, returnToCache, skipAnimation);
1206 };
1207 Repeat.prototype.updateBindings = function (view) {
1208 var $view = view;
1209 var j = $view.bindings.length;
1210 while (j--) {
1211 updateOneTimeBinding($view.bindings[j]);
1212 }
1213 j = $view.controllers.length;
1214 while (j--) {
1215 var k = $view.controllers[j].boundProperties.length;
1216 while (k--) {
1217 var binding = $view.controllers[j].boundProperties[k].binding;
1218 updateOneTimeBinding(binding);
1219 }
1220 }
1221 };
1222 var Repeat_1;
1223 Repeat.useInnerMatcher = true;
1224 __decorate([
1225 aureliaTemplating.bindable
1226 ], Repeat.prototype, "items", void 0);
1227 __decorate([
1228 aureliaTemplating.bindable
1229 ], Repeat.prototype, "local", void 0);
1230 __decorate([
1231 aureliaTemplating.bindable
1232 ], Repeat.prototype, "key", void 0);
1233 __decorate([
1234 aureliaTemplating.bindable
1235 ], Repeat.prototype, "value", void 0);
1236 Repeat = Repeat_1 = __decorate([
1237 aureliaTemplating.customAttribute('repeat'),
1238 aureliaTemplating.templateController,
1239 aureliaDependencyInjection.inject(aureliaTemplating.BoundViewFactory, aureliaTemplating.TargetInstruction, aureliaTemplating.ViewSlot, aureliaTemplating.ViewResources, aureliaBinding.ObserverLocator, RepeatStrategyLocator)
1240 ], Repeat);
1241 return Repeat;
1242}(AbstractRepeater));
1243var extractMatcherBindingExpression = function (instructions, targetedElementId) {
1244 var instructionIds = Object.keys(instructions);
1245 for (var i = 0; i < instructionIds.length; i++) {
1246 var instructionId = instructionIds[i];
1247 if (targetedElementId !== undefined && instructionId !== targetedElementId) {
1248 continue;
1249 }
1250 var expressions = instructions[instructionId].expressions;
1251 if (expressions) {
1252 for (var ii = 0; ii < expressions.length; ii++) {
1253 if (expressions[ii].targetProperty === 'matcher') {
1254 var matcherBindingExpression = expressions[ii];
1255 expressions.splice(ii, 1);
1256 return matcherBindingExpression;
1257 }
1258 }
1259 }
1260 }
1261};
1262var getChildrenCount = function (el) {
1263 var childNodes = el.childNodes;
1264 var count = 0;
1265 for (var i = 0, ii = childNodes.length; ii > i; ++i) {
1266 if (childNodes[i].nodeType === 1) {
1267 ++count;
1268 }
1269 }
1270 return count;
1271};
1272var getFirstElementChild = function (el) {
1273 var firstChild = el.firstChild;
1274 while (firstChild !== null) {
1275 if (firstChild.nodeType === 1) {
1276 return firstChild;
1277 }
1278 firstChild = firstChild.nextSibling;
1279 }
1280 return null;
1281};
1282
1283var aureliaHideClassName = 'aurelia-hide';
1284var aureliaHideClass = ".".concat(aureliaHideClassName, " { display:none !important; }");
1285function injectAureliaHideStyleAtHead() {
1286 aureliaPal.DOM.injectStyles(aureliaHideClass);
1287}
1288function injectAureliaHideStyleAtBoundary(domBoundary) {
1289 if (aureliaPal.FEATURE.shadowDOM && domBoundary && !domBoundary.hasAureliaHideStyle) {
1290 domBoundary.hasAureliaHideStyle = true;
1291 aureliaPal.DOM.injectStyles(aureliaHideClass, domBoundary);
1292 }
1293}
1294
1295var Show = (function () {
1296 function Show(element, animator, domBoundary) {
1297 this.element = element;
1298 this.animator = animator;
1299 this.domBoundary = domBoundary;
1300 }
1301 Show.inject = function () {
1302 return [aureliaPal.DOM.Element, aureliaTemplating.Animator, aureliaDependencyInjection.Optional.of(aureliaPal.DOM.boundary, true)];
1303 };
1304 Show.prototype.created = function () {
1305 injectAureliaHideStyleAtBoundary(this.domBoundary);
1306 };
1307 Show.prototype.valueChanged = function (newValue) {
1308 var element = this.element;
1309 var animator = this.animator;
1310 if (newValue) {
1311 animator.removeClass(element, aureliaHideClassName);
1312 }
1313 else {
1314 animator.addClass(element, aureliaHideClassName);
1315 }
1316 };
1317 Show.prototype.bind = function (bindingContext) {
1318 this.valueChanged(this.value);
1319 };
1320 Show = __decorate([
1321 aureliaTemplating.customAttribute('show')
1322 ], Show);
1323 return Show;
1324}());
1325
1326var Hide = (function () {
1327 function Hide(element, animator, domBoundary) {
1328 this.element = element;
1329 this.animator = animator;
1330 this.domBoundary = domBoundary;
1331 }
1332 Hide.inject = function () {
1333 return [aureliaPal.DOM.Element, aureliaTemplating.Animator, aureliaDependencyInjection.Optional.of(aureliaPal.DOM.boundary, true)];
1334 };
1335 Hide.prototype.created = function () {
1336 injectAureliaHideStyleAtBoundary(this.domBoundary);
1337 };
1338 Hide.prototype.valueChanged = function (newValue) {
1339 if (newValue) {
1340 this.animator.addClass(this.element, aureliaHideClassName);
1341 }
1342 else {
1343 this.animator.removeClass(this.element, aureliaHideClassName);
1344 }
1345 };
1346 Hide.prototype.bind = function (bindingContext) {
1347 this.valueChanged(this.value);
1348 };
1349 Hide.prototype.value = function (value) {
1350 throw new Error('Method not implemented.');
1351 };
1352 Hide = __decorate([
1353 aureliaTemplating.customAttribute('hide')
1354 ], Hide);
1355 return Hide;
1356}());
1357
1358var HTMLSanitizer = (function () {
1359 function HTMLSanitizer() {
1360 }
1361 HTMLSanitizer.prototype.sanitize = function (input) {
1362 throw new Error("To protect the application against a wide variety of sophisticated XSS attacks.\nPlease see https://aurelia.io/docs/binding/basics#element-content for instructions on how to use a secure solution like DOMPurify or sanitize-html.");
1363 };
1364 return HTMLSanitizer;
1365}());
1366
1367var SanitizeHTMLValueConverter = (function () {
1368 function SanitizeHTMLValueConverter(sanitizer) {
1369 this.sanitizer = sanitizer;
1370 }
1371 SanitizeHTMLValueConverter.prototype.toView = function (untrustedMarkup) {
1372 if (untrustedMarkup === null || untrustedMarkup === undefined) {
1373 return null;
1374 }
1375 return this.sanitizer.sanitize(untrustedMarkup);
1376 };
1377 SanitizeHTMLValueConverter = __decorate([
1378 aureliaBinding.valueConverter('sanitizeHTML'),
1379 aureliaDependencyInjection.inject(HTMLSanitizer)
1380 ], SanitizeHTMLValueConverter);
1381 return SanitizeHTMLValueConverter;
1382}());
1383
1384var Replaceable = (function () {
1385 function Replaceable(viewFactory, viewSlot) {
1386 this.viewFactory = viewFactory;
1387 this.viewSlot = viewSlot;
1388 this.view = null;
1389 }
1390 Replaceable.prototype.bind = function (bindingContext, overrideContext) {
1391 if (this.view === null) {
1392 this.view = this.viewFactory.create();
1393 this.viewSlot.add(this.view);
1394 }
1395 this.view.bind(bindingContext, overrideContext);
1396 };
1397 Replaceable.prototype.unbind = function () {
1398 this.view.unbind();
1399 };
1400 Replaceable = __decorate([
1401 aureliaTemplating.customAttribute('replaceable'),
1402 aureliaTemplating.templateController,
1403 aureliaDependencyInjection.inject(aureliaTemplating.BoundViewFactory, aureliaTemplating.ViewSlot)
1404 ], Replaceable);
1405 return Replaceable;
1406}());
1407
1408var Focus = (function () {
1409 function Focus(element, taskQueue) {
1410 this.element = element;
1411 this.taskQueue = taskQueue;
1412 this.isAttached = false;
1413 this.needsApply = false;
1414 }
1415 Focus.inject = function () {
1416 return [aureliaPal.DOM.Element, aureliaTaskQueue.TaskQueue];
1417 };
1418 Focus.prototype.valueChanged = function () {
1419 if (this.isAttached) {
1420 this._apply();
1421 }
1422 else {
1423 this.needsApply = true;
1424 }
1425 };
1426 Focus.prototype._apply = function () {
1427 var _this = this;
1428 if (this.value) {
1429 this.taskQueue.queueMicroTask(function () {
1430 if (_this.value) {
1431 _this.element.focus();
1432 }
1433 });
1434 }
1435 else {
1436 this.element.blur();
1437 }
1438 };
1439 Focus.prototype.attached = function () {
1440 this.isAttached = true;
1441 if (this.needsApply) {
1442 this.needsApply = false;
1443 this._apply();
1444 }
1445 this.element.addEventListener('focus', this);
1446 this.element.addEventListener('blur', this);
1447 };
1448 Focus.prototype.detached = function () {
1449 this.isAttached = false;
1450 this.element.removeEventListener('focus', this);
1451 this.element.removeEventListener('blur', this);
1452 };
1453 Focus.prototype.handleEvent = function (e) {
1454 if (e.type === 'focus') {
1455 this.value = true;
1456 }
1457 else if (aureliaPal.DOM.activeElement !== this.element) {
1458 this.value = false;
1459 }
1460 };
1461 Focus = __decorate([
1462 aureliaTemplating.customAttribute('focus', aureliaBinding.bindingMode.twoWay)
1463 ], Focus);
1464 return Focus;
1465}());
1466
1467var cssUrlMatcher = /url\((?!['"]data)([^)]+)\)/gi;
1468function fixupCSSUrls(address, css) {
1469 if (typeof css !== 'string') {
1470 throw new Error("Failed loading required CSS file: ".concat(address));
1471 }
1472 return css.replace(cssUrlMatcher, function (match, p1) {
1473 var quote = p1.charAt(0);
1474 if (quote === '\'' || quote === '"') {
1475 p1 = p1.substr(1, p1.length - 2);
1476 }
1477 return 'url(\'' + aureliaPath.relativeToFile(p1, address) + '\')';
1478 });
1479}
1480var CSSResource = (function () {
1481 function CSSResource(address) {
1482 this.address = address;
1483 this._scoped = null;
1484 this._global = false;
1485 this._alreadyGloballyInjected = false;
1486 }
1487 CSSResource.prototype.initialize = function (container, Target) {
1488 this._scoped = new Target(this);
1489 };
1490 CSSResource.prototype.register = function (registry, name) {
1491 if (name === 'scoped') {
1492 registry.registerViewEngineHooks(this._scoped);
1493 }
1494 else {
1495 this._global = true;
1496 }
1497 };
1498 CSSResource.prototype.load = function (container) {
1499 var _this = this;
1500 return container.get(aureliaLoader.Loader)
1501 .loadText(this.address)
1502 .catch(function () { return null; })
1503 .then(function (text) {
1504 text = fixupCSSUrls(_this.address, text);
1505 _this._scoped.css = text;
1506 if (_this._global) {
1507 _this._alreadyGloballyInjected = true;
1508 aureliaPal.DOM.injectStyles(text);
1509 }
1510 return _this;
1511 });
1512 };
1513 return CSSResource;
1514}());
1515var CSSViewEngineHooks = (function () {
1516 function CSSViewEngineHooks(owner) {
1517 this.owner = owner;
1518 this.css = null;
1519 }
1520 CSSViewEngineHooks.prototype.beforeCompile = function (content, resources, instruction) {
1521 if (instruction.targetShadowDOM) {
1522 aureliaPal.DOM.injectStyles(this.css, content, true);
1523 }
1524 else if (aureliaPal.FEATURE.scopedCSS) {
1525 var styleNode = aureliaPal.DOM.injectStyles(this.css, content, true);
1526 styleNode.setAttribute('scoped', 'scoped');
1527 }
1528 else if (this._global && !this.owner._alreadyGloballyInjected) {
1529 aureliaPal.DOM.injectStyles(this.css);
1530 this.owner._alreadyGloballyInjected = true;
1531 }
1532 };
1533 return CSSViewEngineHooks;
1534}());
1535function _createCSSResource(address) {
1536 var ViewCSS = (function (_super) {
1537 __extends(ViewCSS, _super);
1538 function ViewCSS() {
1539 return _super !== null && _super.apply(this, arguments) || this;
1540 }
1541 ViewCSS = __decorate([
1542 aureliaTemplating.resource(new CSSResource(address))
1543 ], ViewCSS);
1544 return ViewCSS;
1545 }(CSSViewEngineHooks));
1546 return ViewCSS;
1547}
1548
1549var AttrBindingBehavior = (function () {
1550 function AttrBindingBehavior() {
1551 }
1552 AttrBindingBehavior.prototype.bind = function (binding, source) {
1553 binding.targetObserver = new aureliaBinding.DataAttributeObserver(binding.target, binding.targetProperty);
1554 };
1555 AttrBindingBehavior.prototype.unbind = function (binding, source) {
1556 };
1557 AttrBindingBehavior = __decorate([
1558 aureliaBinding.bindingBehavior('attr')
1559 ], AttrBindingBehavior);
1560 return AttrBindingBehavior;
1561}());
1562
1563var modeBindingBehavior = {
1564 bind: function (binding, source, lookupFunctions) {
1565 binding.originalMode = binding.mode;
1566 binding.mode = this.mode;
1567 },
1568 unbind: function (binding, source) {
1569 binding.mode = binding.originalMode;
1570 binding.originalMode = null;
1571 }
1572};
1573var OneTimeBindingBehavior = (function () {
1574 function OneTimeBindingBehavior() {
1575 this.mode = aureliaBinding.bindingMode.oneTime;
1576 }
1577 OneTimeBindingBehavior = __decorate([
1578 aureliaMetadata.mixin(modeBindingBehavior),
1579 aureliaBinding.bindingBehavior('oneTime')
1580 ], OneTimeBindingBehavior);
1581 return OneTimeBindingBehavior;
1582}());
1583var OneWayBindingBehavior = (function () {
1584 function OneWayBindingBehavior() {
1585 this.mode = aureliaBinding.bindingMode.toView;
1586 }
1587 OneWayBindingBehavior = __decorate([
1588 aureliaMetadata.mixin(modeBindingBehavior),
1589 aureliaBinding.bindingBehavior('oneWay')
1590 ], OneWayBindingBehavior);
1591 return OneWayBindingBehavior;
1592}());
1593var ToViewBindingBehavior = (function () {
1594 function ToViewBindingBehavior() {
1595 this.mode = aureliaBinding.bindingMode.toView;
1596 }
1597 ToViewBindingBehavior = __decorate([
1598 aureliaMetadata.mixin(modeBindingBehavior),
1599 aureliaBinding.bindingBehavior('toView')
1600 ], ToViewBindingBehavior);
1601 return ToViewBindingBehavior;
1602}());
1603var FromViewBindingBehavior = (function () {
1604 function FromViewBindingBehavior() {
1605 this.mode = aureliaBinding.bindingMode.fromView;
1606 }
1607 FromViewBindingBehavior = __decorate([
1608 aureliaMetadata.mixin(modeBindingBehavior),
1609 aureliaBinding.bindingBehavior('fromView')
1610 ], FromViewBindingBehavior);
1611 return FromViewBindingBehavior;
1612}());
1613var TwoWayBindingBehavior = (function () {
1614 function TwoWayBindingBehavior() {
1615 this.mode = aureliaBinding.bindingMode.twoWay;
1616 }
1617 TwoWayBindingBehavior = __decorate([
1618 aureliaMetadata.mixin(modeBindingBehavior),
1619 aureliaBinding.bindingBehavior('twoWay')
1620 ], TwoWayBindingBehavior);
1621 return TwoWayBindingBehavior;
1622}());
1623
1624function throttle(newValue) {
1625 var _this = this;
1626 var state = this.throttleState;
1627 var elapsed = +new Date() - state.last;
1628 if (elapsed >= state.delay) {
1629 clearTimeout(state.timeoutId);
1630 state.timeoutId = null;
1631 state.last = +new Date();
1632 this.throttledMethod(newValue);
1633 return;
1634 }
1635 state.newValue = newValue;
1636 if (state.timeoutId === null) {
1637 state.timeoutId = setTimeout(function () {
1638 state.timeoutId = null;
1639 state.last = +new Date();
1640 _this.throttledMethod(state.newValue);
1641 }, state.delay - elapsed);
1642 }
1643}
1644var ThrottleBindingBehavior = (function () {
1645 function ThrottleBindingBehavior() {
1646 }
1647 ThrottleBindingBehavior.prototype.bind = function (binding, source, delay) {
1648 if (delay === void 0) { delay = 200; }
1649 var methodToThrottle = 'updateTarget';
1650 if (binding.callSource) {
1651 methodToThrottle = 'callSource';
1652 }
1653 else if (binding.updateSource && binding.mode === aureliaBinding.bindingMode.twoWay) {
1654 methodToThrottle = 'updateSource';
1655 }
1656 binding.throttledMethod = binding[methodToThrottle];
1657 binding.throttledMethod.originalName = methodToThrottle;
1658 binding[methodToThrottle] = throttle;
1659 binding.throttleState = {
1660 delay: delay,
1661 last: 0,
1662 timeoutId: null
1663 };
1664 };
1665 ThrottleBindingBehavior.prototype.unbind = function (binding, source) {
1666 var methodToRestore = binding.throttledMethod.originalName;
1667 binding[methodToRestore] = binding.throttledMethod;
1668 binding.throttledMethod = null;
1669 clearTimeout(binding.throttleState.timeoutId);
1670 binding.throttleState = null;
1671 };
1672 ThrottleBindingBehavior = __decorate([
1673 aureliaBinding.bindingBehavior('throttle')
1674 ], ThrottleBindingBehavior);
1675 return ThrottleBindingBehavior;
1676}());
1677
1678var unset = {};
1679function debounceCallSource(event) {
1680 var _this = this;
1681 var state = this.debounceState;
1682 clearTimeout(state.timeoutId);
1683 state.timeoutId = setTimeout(function () { return _this.debouncedMethod(event); }, state.delay);
1684}
1685function debounceCall(context, newValue, oldValue) {
1686 var _this = this;
1687 var state = this.debounceState;
1688 clearTimeout(state.timeoutId);
1689 if (context !== state.callContextToDebounce) {
1690 state.oldValue = unset;
1691 this.debouncedMethod(context, newValue, oldValue);
1692 return;
1693 }
1694 if (state.oldValue === unset) {
1695 state.oldValue = oldValue;
1696 }
1697 state.timeoutId = setTimeout(function () {
1698 var _oldValue = state.oldValue;
1699 state.oldValue = unset;
1700 _this.debouncedMethod(context, newValue, _oldValue);
1701 }, state.delay);
1702}
1703var DebounceBindingBehavior = (function () {
1704 function DebounceBindingBehavior() {
1705 }
1706 DebounceBindingBehavior.prototype.bind = function (binding, source, delay) {
1707 if (delay === void 0) { delay = 200; }
1708 var isCallSource = binding.callSource !== undefined;
1709 var methodToDebounce = isCallSource ? 'callSource' : 'call';
1710 var debouncer = isCallSource ? debounceCallSource : debounceCall;
1711 var mode = binding.mode;
1712 var callContextToDebounce = mode === aureliaBinding.bindingMode.twoWay || mode === aureliaBinding.bindingMode.fromView ? aureliaBinding.targetContext : aureliaBinding.sourceContext;
1713 binding.debouncedMethod = binding[methodToDebounce];
1714 binding.debouncedMethod.originalName = methodToDebounce;
1715 binding[methodToDebounce] = debouncer;
1716 binding.debounceState = {
1717 callContextToDebounce: callContextToDebounce,
1718 delay: delay,
1719 timeoutId: 0,
1720 oldValue: unset
1721 };
1722 };
1723 DebounceBindingBehavior.prototype.unbind = function (binding, source) {
1724 var methodToRestore = binding.debouncedMethod.originalName;
1725 binding[methodToRestore] = binding.debouncedMethod;
1726 binding.debouncedMethod = null;
1727 clearTimeout(binding.debounceState.timeoutId);
1728 binding.debounceState = null;
1729 };
1730 DebounceBindingBehavior = __decorate([
1731 aureliaBinding.bindingBehavior('debounce')
1732 ], DebounceBindingBehavior);
1733 return DebounceBindingBehavior;
1734}());
1735
1736function findOriginalEventTarget(event) {
1737 return (event.path && event.path[0]) || (event.deepPath && event.deepPath[0]) || event.target;
1738}
1739function handleSelfEvent(event) {
1740 var target = findOriginalEventTarget(event);
1741 if (this.target !== target) {
1742 return;
1743 }
1744 this.selfEventCallSource(event);
1745}
1746var SelfBindingBehavior = (function () {
1747 function SelfBindingBehavior() {
1748 }
1749 SelfBindingBehavior.prototype.bind = function (binding, source) {
1750 if (!binding.callSource || !binding.targetEvent) {
1751 throw new Error('Self binding behavior only supports event.');
1752 }
1753 binding.selfEventCallSource = binding.callSource;
1754 binding.callSource = handleSelfEvent;
1755 };
1756 SelfBindingBehavior.prototype.unbind = function (binding, source) {
1757 binding.callSource = binding.selfEventCallSource;
1758 binding.selfEventCallSource = null;
1759 };
1760 SelfBindingBehavior = __decorate([
1761 aureliaBinding.bindingBehavior('self')
1762 ], SelfBindingBehavior);
1763 return SelfBindingBehavior;
1764}());
1765
1766var BindingSignaler = (function () {
1767 function BindingSignaler() {
1768 this.signals = {};
1769 }
1770 BindingSignaler.prototype.signal = function (name) {
1771 var bindings = this.signals[name];
1772 if (!bindings) {
1773 return;
1774 }
1775 var i = bindings.length;
1776 while (i--) {
1777 bindings[i].call(aureliaBinding.sourceContext);
1778 }
1779 };
1780 return BindingSignaler;
1781}());
1782
1783var SignalBindingBehavior = (function () {
1784 function SignalBindingBehavior(bindingSignaler) {
1785 this.signals = bindingSignaler.signals;
1786 }
1787 SignalBindingBehavior.inject = function () { return [BindingSignaler]; };
1788 SignalBindingBehavior.prototype.bind = function (binding, source) {
1789 var names = [];
1790 for (var _i = 2; _i < arguments.length; _i++) {
1791 names[_i - 2] = arguments[_i];
1792 }
1793 if (!binding.updateTarget) {
1794 throw new Error('Only property bindings and string interpolation bindings can be signaled. Trigger, delegate and call bindings cannot be signaled.');
1795 }
1796 var signals = this.signals;
1797 if (names.length === 1) {
1798 var name_1 = names[0];
1799 var bindings = signals[name_1] || (signals[name_1] = []);
1800 bindings.push(binding);
1801 binding.signalName = name_1;
1802 }
1803 else if (names.length > 1) {
1804 var i = names.length;
1805 while (i--) {
1806 var name_2 = names[i];
1807 var bindings = signals[name_2] || (signals[name_2] = []);
1808 bindings.push(binding);
1809 }
1810 binding.signalName = names;
1811 }
1812 else {
1813 throw new Error('Signal name is required.');
1814 }
1815 };
1816 SignalBindingBehavior.prototype.unbind = function (binding, source) {
1817 var signals = this.signals;
1818 var name = binding.signalName;
1819 binding.signalName = null;
1820 if (Array.isArray(name)) {
1821 var names = name;
1822 var i = names.length;
1823 while (i--) {
1824 var n = names[i];
1825 var bindings = signals[n];
1826 bindings.splice(bindings.indexOf(binding), 1);
1827 }
1828 }
1829 else {
1830 var bindings = signals[name];
1831 bindings.splice(bindings.indexOf(binding), 1);
1832 }
1833 };
1834 SignalBindingBehavior = __decorate([
1835 aureliaBinding.bindingBehavior('signal')
1836 ], SignalBindingBehavior);
1837 return SignalBindingBehavior;
1838}());
1839
1840var eventNamesRequired = 'The updateTrigger binding behavior requires at least one event name argument: eg <input value.bind="firstName & updateTrigger:\'blur\'">';
1841var notApplicableMessage = 'The updateTrigger binding behavior can only be applied to two-way/ from-view bindings on input/select elements.';
1842var UpdateTriggerBindingBehavior = (function () {
1843 function UpdateTriggerBindingBehavior() {
1844 }
1845 UpdateTriggerBindingBehavior.prototype.bind = function (binding, source) {
1846 var events = [];
1847 for (var _i = 2; _i < arguments.length; _i++) {
1848 events[_i - 2] = arguments[_i];
1849 }
1850 if (events.length === 0) {
1851 throw new Error(eventNamesRequired);
1852 }
1853 if (binding.mode !== aureliaBinding.bindingMode.twoWay && binding.mode !== aureliaBinding.bindingMode.fromView) {
1854 throw new Error(notApplicableMessage);
1855 }
1856 var targetObserver = binding.observerLocator.getObserver(binding.target, binding.targetProperty);
1857 if (!targetObserver.handler) {
1858 throw new Error(notApplicableMessage);
1859 }
1860 binding.targetObserver = targetObserver;
1861 targetObserver.originalHandler = binding.targetObserver.handler;
1862 var handler = new aureliaBinding.EventSubscriber(events);
1863 targetObserver.handler = handler;
1864 };
1865 UpdateTriggerBindingBehavior.prototype.unbind = function (binding, source) {
1866 var targetObserver = binding.targetObserver;
1867 targetObserver.handler.dispose();
1868 targetObserver.handler = targetObserver.originalHandler;
1869 targetObserver.originalHandler = null;
1870 };
1871 UpdateTriggerBindingBehavior = __decorate([
1872 aureliaBinding.bindingBehavior('updateTrigger')
1873 ], UpdateTriggerBindingBehavior);
1874 return UpdateTriggerBindingBehavior;
1875}());
1876
1877function _createDynamicElement(_a) {
1878 var name = _a.name, viewUrl = _a.viewUrl, bindableNames = _a.bindableNames, useShadowDOMmode = _a.useShadowDOMmode;
1879 var DynamicElement = (function () {
1880 function DynamicElement() {
1881 }
1882 DynamicElement.prototype.bind = function (bindingContext) {
1883 this.$parent = bindingContext;
1884 };
1885 DynamicElement = __decorate([
1886 aureliaTemplating.customElement(name),
1887 aureliaTemplating.useView(viewUrl)
1888 ], DynamicElement);
1889 return DynamicElement;
1890 }());
1891 for (var i = 0, ii = bindableNames.length; i < ii; ++i) {
1892 aureliaTemplating.bindable(bindableNames[i])(DynamicElement);
1893 }
1894 switch (useShadowDOMmode) {
1895 case 'open':
1896 aureliaTemplating.useShadowDOM({ mode: 'open' })(DynamicElement);
1897 break;
1898 case 'closed':
1899 aureliaTemplating.useShadowDOM({ mode: 'closed' })(DynamicElement);
1900 break;
1901 case '':
1902 aureliaTemplating.useShadowDOM(DynamicElement);
1903 break;
1904 case null:
1905 break;
1906 default:
1907 aureliaLogging.getLogger('aurelia-html-only-element')
1908 .warn("Expected 'use-shadow-dom' value to be \"close\", \"open\" or \"\", received ".concat(useShadowDOMmode));
1909 break;
1910 }
1911 return DynamicElement;
1912}
1913
1914function getElementName(address) {
1915 return /([^\/^\?]+)\.html/i.exec(address)[1].toLowerCase();
1916}
1917function configure$1(config) {
1918 var viewEngine = config.container.get(aureliaTemplating.ViewEngine);
1919 var loader = config.aurelia.loader;
1920 viewEngine.addResourcePlugin('.html', {
1921 'fetch': function (viewUrl) {
1922 return loader.loadTemplate(viewUrl).then(function (registryEntry) {
1923 var _a;
1924 var bindableNames = registryEntry.template.getAttribute('bindable');
1925 var useShadowDOMmode = registryEntry.template.getAttribute('use-shadow-dom');
1926 var name = getElementName(viewUrl);
1927 if (bindableNames) {
1928 bindableNames = bindableNames.split(',').map(function (x) { return x.trim(); });
1929 registryEntry.template.removeAttribute('bindable');
1930 }
1931 else {
1932 bindableNames = [];
1933 }
1934 return _a = {}, _a[name] = _createDynamicElement({ name: name, viewUrl: viewUrl, bindableNames: bindableNames, useShadowDOMmode: useShadowDOMmode }), _a;
1935 });
1936 }
1937 });
1938}
1939
1940function configure(config) {
1941 injectAureliaHideStyleAtHead();
1942 config.globalResources(Compose, If, Else, With, Repeat, Show, Hide, Replaceable, Focus, SanitizeHTMLValueConverter, OneTimeBindingBehavior, OneWayBindingBehavior, ToViewBindingBehavior, FromViewBindingBehavior, TwoWayBindingBehavior, ThrottleBindingBehavior, DebounceBindingBehavior, SelfBindingBehavior, SignalBindingBehavior, UpdateTriggerBindingBehavior, AttrBindingBehavior);
1943 configure$1(config);
1944 var viewEngine = config.container.get(aureliaTemplating.ViewEngine);
1945 var styleResourcePlugin = {
1946 fetch: function (address) {
1947 var _a;
1948 return _a = {}, _a[address] = _createCSSResource(address), _a;
1949 }
1950 };
1951 ['.css', '.less', '.sass', '.scss', '.styl'].forEach(function (ext) { return viewEngine.addResourcePlugin(ext, styleResourcePlugin); });
1952}
1953
1954exports.AbstractRepeater = AbstractRepeater;
1955exports.ArrayRepeatStrategy = ArrayRepeatStrategy;
1956exports.AttrBindingBehavior = AttrBindingBehavior;
1957exports.BindingSignaler = BindingSignaler;
1958exports.Compose = Compose;
1959exports.DebounceBindingBehavior = DebounceBindingBehavior;
1960exports.Else = Else;
1961exports.Focus = Focus;
1962exports.FromViewBindingBehavior = FromViewBindingBehavior;
1963exports.HTMLSanitizer = HTMLSanitizer;
1964exports.Hide = Hide;
1965exports.If = If;
1966exports.MapRepeatStrategy = MapRepeatStrategy;
1967exports.NullRepeatStrategy = NullRepeatStrategy;
1968exports.NumberRepeatStrategy = NumberRepeatStrategy;
1969exports.OneTimeBindingBehavior = OneTimeBindingBehavior;
1970exports.OneWayBindingBehavior = OneWayBindingBehavior;
1971exports.Repeat = Repeat;
1972exports.RepeatStrategyLocator = RepeatStrategyLocator;
1973exports.Replaceable = Replaceable;
1974exports.SanitizeHTMLValueConverter = SanitizeHTMLValueConverter;
1975exports.SelfBindingBehavior = SelfBindingBehavior;
1976exports.SetRepeatStrategy = SetRepeatStrategy;
1977exports.Show = Show;
1978exports.SignalBindingBehavior = SignalBindingBehavior;
1979exports.ThrottleBindingBehavior = ThrottleBindingBehavior;
1980exports.ToViewBindingBehavior = ToViewBindingBehavior;
1981exports.TwoWayBindingBehavior = TwoWayBindingBehavior;
1982exports.UpdateTriggerBindingBehavior = UpdateTriggerBindingBehavior;
1983exports.With = With;
1984exports.configure = configure;
1985exports.createFullOverrideContext = createFullOverrideContext;
1986exports.getItemsSourceExpression = getItemsSourceExpression;
1987exports.isOneTime = isOneTime;
1988exports.unwrapExpression = unwrapExpression;
1989exports.updateOneTimeBinding = updateOneTimeBinding;
1990exports.updateOverrideContext = updateOverrideContext;
1991exports.viewsRequireLifecycle = viewsRequireLifecycle;
1992//# sourceMappingURL=aurelia-templating-resources.js.map