Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aurumjs

Package Overview
Dependencies
Maintainers
1
Versions
244
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aurumjs - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

dist/aurumjs.d.ts

13

dist/nodes/aurum_element.d.ts

@@ -13,2 +13,3 @@ import { DataSource } from '../stream/data_source';

repeatModel?: ArrayDataSource<any> | any[];
onDblclick?: DataDrain<MouseEvent>;
onClick?: DataDrain<MouseEvent>;

@@ -22,2 +23,4 @@ onKeydown?: DataDrain<KeyboardEvent>;

onMousewheel?: DataDrain<WheelEvent>;
onBlur?: DataDrain<FocusEvent>;
onFocus?: DataDrain<FocusEvent>;
onAttach?: (node: AurumElement) => void;

@@ -41,2 +44,4 @@ template?: Template<any>;

onMouseleave: DataSource<KeyboardEvent>;
onFocus: DataSource<FocusEvent>;
onBlur: DataSource<FocusEvent>;
constructor(props: AurumElementProps, domNodeName: string);

@@ -56,4 +61,12 @@ private initialize;

protected addDomNodeAt(node: HTMLElement, index: number): void;
remove(): void;
hasParent(): boolean;
isConnected(): boolean;
removeChild(child: AurumElement): void;
removeChildAt(index: number): void;
clearChildren(): void;
addChild(child: AurumElement): HTMLElement;
addChildAt(child: AurumElement, index: number): void;
addChildren(nodes: AurumElement[]): void;
dispose(): void;
}

@@ -60,0 +73,0 @@ export interface TemplateProps<T> extends AurumElementProps {

53

dist/nodes/aurum_element.js
import { DataSource } from '../stream/data_source';
import { CancellationToken } from '../utilities/cancellation_token';
import { ArrayDataSource } from '../stream/array_data_source';
import { ownerSymbol } from '../utilities/owner_symbol';
export class AurumElement {

@@ -17,3 +18,3 @@ constructor(props, domNodeName) {

this.node.owner = this;
this.createEventHandlers(['click', 'keydown', 'keyhit', 'keyup', 'mousedown, mouseup', 'mouseenter', 'mouseleave', 'mousewheel'], props);
this.createEventHandlers(['blur', 'focus', 'click', 'dblclick', 'keydown', 'keyhit', 'keyup', 'mousedown, mouseup', 'mouseenter', 'mouseleave', 'mousewheel'], props);
this.bindProps(['id', 'draggable', 'tabindex', 'style'], props);

@@ -106,3 +107,3 @@ if (props.class) {

if (!this.cachedChildren.includes(this.node.children[i].owner)) {
this.node.children[i].remove();
this.node.children[i][ownerSymbol].remove();
i--;

@@ -121,3 +122,3 @@ continue;

while (this.node.childElementCount > this.cachedChildren.length) {
this.node.removeChild(this.node.lastChild);
this.node[ownerSymbol].removeChild(this.node.lastChild[ownerSymbol]);
}

@@ -199,2 +200,3 @@ this.rerenderPending = false;

const node = document.createElement(this.domNodeName);
node[ownerSymbol] = this;
return node;

@@ -221,2 +223,5 @@ }

setInnerText(value) {
if (this.node.firstChild) {
throw new Error('Cannot combine text and child nodes into a single element');
}
this.node.innerText = value;

@@ -249,4 +254,41 @@ }

}
remove() {
if (this.hasParent()) {
this.node.parentElement.removeChild(this.node);
this.dispose();
}
}
hasParent() {
return !!this.node.parentElement;
}
isConnected() {
return this.node.isConnected;
}
removeChild(child) {
child.dispose();
this.node.removeChild(child.node);
}
removeChildAt(index) {
const childNode = this.node.childNodes[index];
if (childNode) {
const child = childNode[ownerSymbol];
child.dispose();
this.node.removeChild(child.node);
}
}
clearChildren() {
while (this.node.firstChild) {
const owner = this.node.firstChild[ownerSymbol];
owner.dispose();
this.node.removeChild(this.node.firstChild);
}
}
addChild(child) {
if (child.node instanceof Template) {
return;
}
return this.node.appendChild(child.node);
}
addChildAt(child, index) {
if (child instanceof Template) {
if (child.node instanceof Template) {
return;

@@ -285,2 +327,5 @@ }

}
dispose() {
this.cancellationToken.cancel();
}
}

@@ -287,0 +332,0 @@ export class Template extends AurumElement {

3

dist/nodes/input.d.ts

@@ -10,2 +10,3 @@ import { AurumElement, AurumElementProps } from './aurum_element';

inputValueSource?: DataSource<string>;
initialValue?: string;
}

@@ -16,6 +17,4 @@ export declare class Input extends AurumElement {

onInput: DataSource<InputEvent>;
onFocus: DataSource<FocusEvent>;
onBlur: DataSource<FocusEvent>;
constructor(props: InputProps);
}
//# sourceMappingURL=input.d.ts.map
import { AurumElement } from './aurum_element';
export class Input extends AurumElement {
constructor(props) {
var _a, _b, _c;
super(props, 'input');
if (props.inputValueSource) {
this.node.value = (_b = (_a = props.initialValue, (_a !== null && _a !== void 0 ? _a : props.inputValueSource.value)), (_b !== null && _b !== void 0 ? _b : ''));
props.inputValueSource.listen((value) => (this.node.value = value), this.cancellationToken);
}
else {
this.node.value = (_c = props.initialValue, (_c !== null && _c !== void 0 ? _c : ''));
}
this.bindProps(['placeholder'], props);
this.createEventHandlers(['input', 'change', 'focus', 'blur'], props);
this.createEventHandlers(['input', 'change'], props);
}
}
//# sourceMappingURL=input.js.map

@@ -22,3 +22,4 @@ import { Template } from '../nodes/aurum_element';

const children = [].concat(...innerNodes).filter((e) => e);
const refs = {};
const templateMap = {};
let defaultTemplate;
let hasRef = false;

@@ -29,13 +30,16 @@ for (const c of children) {

}
if (c instanceof Template && !c.ref) {
refs['template'] = c;
hasRef = true;
if (c instanceof Template && (!c.ref || c.ref === 'default')) {
defaultTemplate = c;
}
if (c.ref) {
refs[c.ref] = c;
templateMap[c.ref] = c;
hasRef = true;
}
}
args = (args !== null && args !== void 0 ? args : {});
if (defaultTemplate) {
args.template = defaultTemplate;
}
if (hasRef) {
Object.assign(args, refs);
args.templateMap = templateMap;
}

@@ -42,0 +46,0 @@ let instance;

{
"name": "aurumjs",
"version": "0.0.4",
"version": "0.0.5",
"description": "Fast and concise declarative DOM rendering library for javascript",
"main": "dist/aurum.js",
"typings": "dist/aurum.d.ts",
"main": "dist/aurumjs.js",
"typings": "dist/aurumjs.d.ts",
"scripts": {
"build": "tsc",
"watch": "tsc -w",
"deploy": "npm run build && microbundle --entry dist/aurum.js --output prebuilt --name aurumjs"
"deploy": "npm run build && microbundle --entry dist/aurumjs.js --output prebuilt --name aurumjs"
},

@@ -12,0 +12,0 @@ "repository": {

@@ -1,2 +0,2 @@

var t=function(t){var e=this;this.subscribeChannel=[],this.subscribeOnceChannel=[],this.throttleCount=0,this.onAfterFire=[],t&&(t.observable&&this.makeObservable(),t.cancellationToken&&t.cancellationToken.addCancelable(function(){return e.cancelAll()}),t.throttled&&(this.throttle=t.throttled))},e={subscriptions:{configurable:!0},oneTimeSubscriptions:{configurable:!0}};e.subscriptions.get=function(){return this.subscribeChannel.length},e.oneTimeSubscriptions.get=function(){return this.subscribeOnceChannel.length},t.prototype.linkEvent=function(t){this.linkedEvents||(this.linkedEvents=[]),this.linkedEvents.push(t)},t.prototype.unlinkEvent=function(t){if(!this.linkedEvents||!this.linkedEvents.includes(t))throw new Error("Cannot unlink event that is not linked");this.linkedEvents.splice(this.linkedEvents.indexOf(t),1)},t.prototype.makeObservable=function(){this.onSubscribe||(this.onSubscribe=new t,this.onSubscribeOnce=new t,this.onCancelAll=new t,this.onCancel=new t)},t.prototype.swapSubscriptions=function(t){var e=this.subscribeChannel,n=this.subscribeOnceChannel;this.subscribeChannel=t.subscribeChannel,this.subscribeOnceChannel=t.subscribeOnceChannel,t.subscribeChannel=e,t.subscribeOnceChannel=n},t.prototype.subscribe=function(t,e){return this.onSubscribe&&this.onSubscribe.fire(),this.createSubscription(t,this.subscribeChannel,e).facade},t.prototype.hasSubscriptions=function(){return this.subscriptions>0||this.oneTimeSubscriptions>0},t.prototype.subscribeOnce=function(t){var e=this;return this.onSubscribeOnce&&this.onSubscribeOnce.fire(),new Promise(function(n){e.createSubscription(function(t){return n(t)},e.subscribeOnceChannel,t)})},t.prototype.cancelAll=function(){void 0!==this.onCancelAll&&this.onCancelAll.fire()},t.prototype.fire=function(t,e,n,i,o){if(!this.throttle||this.throttleCount++%this.throttle==0){this.isFiring=!0;for(var r=this.subscribeChannel.length,a=0;a<r;a++)this.subscribeChannel[a].callback(t);if(r=this.subscribeOnceChannel.length,this.subscribeOnceChannel.length>0){for(var s=0;s<r;s++)this.subscribeOnceChannel[s].callback(t);this.subscribeOnceChannel.length=0}if(this.linkedEvents)for(var c=0,h=this.linkedEvents;c<h.length;c+=1)h[c].fire(t,e,n,i,o);this.isFiring=!1,this.onAfterFire.length>0&&(this.onAfterFire.forEach(function(t){return t()}),this.onAfterFire.length=0)}},t.prototype.createSubscription=function(t,e,n){var i=this,o={callback:t},r={cancel:function(){i.cancel(o,e)}};return void 0!==n&&n.addCancelable(function(){return i.cancel(o,e)}),e.push(o),{subscription:o,facade:r}},t.prototype.cancel=function(t,e){var n=this,i=e.indexOf(t);i>=0&&(this.isFiring?this.onAfterFire.push(function(){return n.cancel(t,e)}):e.splice(i,1))},Object.defineProperties(t.prototype,e);var n=function(t){this.value=t,this.listeners=[]};n.prototype.update=function(t){this.value=t;for(var e=0,n=this.listeners;e<n.length;e+=1)(0,n[e])(t)},n.prototype.listen=function(t,e){var n,i=this;this.listeners.push(t);var o=function(){var e=i.listeners.indexOf(t);-1!==e&&i.listeners.splice(e,1)};return null===(n=e)||void 0===n||n.addCancelable(function(){o()}),o},n.prototype.filter=function(t,e){var i=new n;return this.listen(function(e){t(e)&&i.update(e)},e),i},n.prototype.pipe=function(t,e){this.listen(function(e){return t.update(e)},e)},n.prototype.map=function(t,e){var i=new n(t(this.value));return this.listen(function(e){i.update(t(e))},e),i},n.prototype.unique=function(t){var e=new n;return this.listen(function(t){t!==e.value&&e.update(t)},t),e},n.prototype.reduce=function(t,e){var i=new n;return this.listen(function(e){return i.update(t(i.value,e))},e),i},n.prototype.combine=function(t,e,i){var o=this,r=new n;return this.listen(function(){return r.update(e(o.value,t.value))},i),t.listen(function(){return r.update(e(o.value,t.value))},i),r},n.prototype.pick=function(t,e){var i=new n;return this.listen(function(e){i.update(e[t])},e),i},n.prototype.cancelAll=function(){this.listeners.length=0};var i=function(e){this.data=e?e.slice():[],this.onChange=new t},o={length:{configurable:!0}};o.length.get=function(){return this.data.length},i.prototype.getData=function(){return this.data.slice()},i.prototype.get=function(t){return this.data[t]},i.prototype.set=function(t,e){var n=this.data[t];n!==e&&(this.data[t]=e,this.onChange.fire({operation:"replace",target:n,count:1,index:t,items:[e],newState:this.data}))},i.prototype.push=function(){for(var t,e=[],n=arguments.length;n--;)e[n]=arguments[n];(t=this.data).push.apply(t,e),this.onChange.fire({operation:"append",count:e.length,index:this.data.length-e.length,items:e,newState:this.data})},i.prototype.unshift=function(){for(var t,e=[],n=arguments.length;n--;)e[n]=arguments[n];(t=this.data).unshift.apply(t,e),this.onChange.fire({operation:"prepend",count:e.length,items:e,index:0,newState:this.data})},i.prototype.pop=function(){var t=this.data.pop();return this.onChange.fire({operation:"removeRight",count:1,index:this.data.length,items:[t],newState:this.data}),t},i.prototype.merge=function(t){for(var e=0;e<t.length;e++)this.data[e]!==t[e]&&(this.length>e?this.set(e,t[e]):this.push(t[e]));this.length>t.length&&this.removeRight(this.length-t.length)},i.prototype.removeRight=function(t){var e=this.data.splice(this.length-t,t);this.onChange.fire({operation:"removeRight",count:t,index:this.length,items:e,newState:this.data})},i.prototype.removeLeft=function(t){var e=this.data.splice(0,t);this.onChange.fire({operation:"removeLeft",count:t,index:0,items:e,newState:this.data})},i.prototype.remove=function(t){var e=this.data.indexOf(t);-1!==e&&(this.data.splice(e,1),this.onChange.fire({operation:"remove",count:1,index:e,items:[t],newState:this.data}))},i.prototype.clear=function(){var t=this.data;this.data=[],this.onChange.fire({operation:"remove",count:t.length,index:0,items:t,newState:this.data})},i.prototype.shift=function(){var t=this.data.shift();return this.onChange.fire({operation:"removeLeft",items:[t],count:1,index:0,newState:this.data}),t},i.prototype.toArray=function(){return this.data.slice()},i.prototype.filter=function(t,e){return new r(this,t,e)},i.prototype.forEach=function(t,e){return this.data.forEach(t,e)},i.prototype.toDataSource=function(){var t=new n(this.data);return this.onChange.subscribe(function(e){t.update(e.newState)}),t},Object.defineProperties(i.prototype,o);var r=function(t){function e(e,n,i){var o=this,r=e.data.filter(n);t.call(this,r),this.parent=e,this.viewFilter=n,e.onChange.subscribe(function(t){var e,n,i;switch(t.operation){case"remove":case"removeLeft":case"removeRight":for(var r=0,a=t.items;r<a.length;r+=1)o.remove(a[r]);break;case"prepend":i=t.items.filter(o.viewFilter),(e=o).unshift.apply(e,i);break;case"append":i=t.items.filter(o.viewFilter),(n=o).push.apply(n,i);break;case"replace":var s=o.data.indexOf(t.target);if(-1!==s){o.viewFilter(t.items[0])?o.set(s,t.items[0]):o.remove(t.target);break}}},i)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.updateFilter=function(t){this.viewFilter!==t&&(this.viewFilter=t,this.refresh())},e.prototype.refresh=function(){var t;this.clear();var e=this.parent.data.filter(this.viewFilter);(t=this).push.apply(t,e)},e}(i),a=function(t){this.data=t};a.prototype.deleteNext=function(){if(this.next){var t=this.next.next;this.next.next=void 0,this.next.previous=void 0,this.next=t,this.next.previous=this}},a.prototype.deletePrevious=function(){this.previous&&(this.previous=this.previous.previous,this.previous.next=void 0,this.previous.previous=void 0)};var s=function(t){var e=this;void 0===t&&(t=[]),this.length=0,t.forEach(function(t){return e.append(t)})};s.prototype.find=function(t){for(var e=this.rootNode;e&&!t(e);)e=e.next;return e},s.prototype.append=function(t){return this.rootNode||this.lastNode?(this.lastNode.next=new a(t),this.lastNode.next.previous=this.lastNode,this.lastNode=this.lastNode.next):this.rootNode=this.lastNode=new a(t),this.length++,t},s.prototype.forEach=function(t){this.find(function(e){return t(e.data),!1})},s.prototype.prepend=function(t){return this.rootNode||this.lastNode?(this.rootNode.previous=new a(t),this.rootNode.previous.next=this.rootNode,this.rootNode=this.rootNode.previous):this.rootNode=this.lastNode=new a(t),this.length++,t},s.prototype.remove=function(t){if(t===this.rootNode.data)this.rootNode=this.rootNode.next,this.length--;else{var e=this.find(function(e){return e.next&&e.next.data===t});e&&(e.next===this.lastNode&&(this.lastNode=e),e.deleteNext(),this.length--)}};var c=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];this.cancelables=new s(t),this._isCancelled=!1},h={isCanceled:{configurable:!0}};h.isCanceled.get=function(){return this._isCancelled},c.prototype.addCancelable=function(t){return this.throwIfCancelled("attempting to add cancellable to token that is already cancelled"),this.cancelables.append(t),this.cancelables.length>200&&console.log("potential memory leak: cancellation token has over 200 clean up calls"),this},c.prototype.removeCancelable=function(t){return this.throwIfCancelled("attempting to remove cancellable from token that is already cancelled"),this.cancelables.remove(t),this},c.prototype.addDisposable=function(t){return this.addCancelable(function(){return t.dispose()}),this},c.prototype.callIfNotCancelled=function(t){this.isCanceled||t()},c.prototype.setTimeout=function(t,e){void 0===e&&(e=0);var n=setTimeout(t,e);this.addCancelable(function(){return clearTimeout(n)})},c.prototype.setInterval=function(t,e){var n=setInterval(t,e);this.addCancelable(function(){return clearInterval(n)})},c.prototype.requestAnimationFrame=function(t){var e=requestAnimationFrame(t);this.addCancelable(function(){return cancelAnimationFrame(e)})},c.prototype.animationLoop=function(t){var e=requestAnimationFrame(function n(i){t(i),e=requestAnimationFrame(n)});this.addCancelable(function(){return cancelAnimationFrame(e)})},c.prototype.throwIfCancelled=function(t){if(this.isCanceled)throw new Error(t||"cancellation token is cancelled")},c.prototype.chain=function(t,e){return void 0===e&&(e=!1),e&&t.chain(this,!1),this.addCancelable(function(){return t.cancel()}),this},c.prototype.registerDomEvent=function(t,e,n){return t.addEventListener(e,n),this.addCancelable(function(){return t.removeEventListener(e,n)}),this},c.prototype.cancel=function(){this.isCanceled||(this._isCancelled=!0,this.cancelables.forEach(function(t){return t()}),this.cancelables=void 0)},Object.defineProperties(c.prototype,h);var l=function(t,e){this.domNodeName=e,this.template=t.template,this.cancellationToken=new c,this.node=this.create(t),this.initialize(t),t.onAttach&&t.onAttach(this)};l.prototype.initialize=function(t){this.node.owner=this,this.createEventHandlers(["click","keydown","keyhit","keyup","mousedown, mouseup","mouseenter","mouseleave","mousewheel"],t),this.bindProps(["id","draggable","tabindex","style"],t),t.class&&this.handleClass(t.class),t.repeatModel&&(this.cachedChildren=[],this.handleRepeat(t.repeatModel))},l.prototype.bindProps=function(t,e){for(var n=0,i=t;n<i.length;n+=1){var o=i[n];e[o]&&this.assignStringSourceToAttribute(e[o],o)}},l.prototype.createEventHandlers=function(t,e){for(var i=this,o=function(){var t=a[r],o="on"+t[0].toUpperCase()+t.slice(1),s=void 0;Object.defineProperty(i,o,{get:function(){return s||(s=new n),s},set:function(){throw new Error(o+" is read only")}}),e[o]&&(e[o]instanceof n?i[o].listen(e[o].update.bind(e.onClick),i.cancellationToken):"function"==typeof e[o]&&i[o].listen(e[o],i.cancellationToken)),i.cancellationToken.registerDomEvent(i.node,t,function(t){return i[o].update(t)})},r=0,a=t;r<a.length;r+=1)o()},l.prototype.handleRepeat=function(t){var e,n=this;this.repeatData=t instanceof i?t:new i(t),this.repeatData.length&&((e=this.cachedChildren).push.apply(e,this.repeatData.toArray().map(function(t){return n.template.generate(t)})),this.renderRepeat()),this.repeatData.onChange.subscribe(function(t){var e,i;switch(t.operation){case"append":(e=n.cachedChildren).push.apply(e,t.items.map(function(t){return n.template.generate(t)}));break;case"removeLeft":n.cachedChildren.splice(0,t.count);break;case"removeRight":n.cachedChildren.splice(n.node.childElementCount-t.count,t.count);break;case"remove":n.cachedChildren.splice(t.index,t.count);break;default:n.cachedChildren.length=0,(i=n.cachedChildren).push.apply(i,n.repeatData.toArray().map(function(t){return n.template.generate(t)}))}n.renderRepeat()})},l.prototype.renderRepeat=function(){var t=this;this.rerenderPending||(setTimeout(function(){for(var e=0;e<t.cachedChildren.length;e++){if(t.node.childElementCount<=e){t.addChildren(t.cachedChildren.slice(e,t.cachedChildren.length));break}if(t.node.children[e].owner!==t.cachedChildren[e]){if(!t.cachedChildren.includes(t.node.children[e].owner)){t.node.children[e].remove(),e--;continue}var n=t.getChildIndex(t.cachedChildren[e].node);-1!==n?t.swapChildren(e,n):t.addChildAt(t.cachedChildren[e],e)}}for(;t.node.childElementCount>t.cachedChildren.length;)t.node.removeChild(t.node.lastChild);t.rerenderPending=!1}),this.rerenderPending=!0)},l.prototype.assignStringSourceToAttribute=function(t,e){var n=this;"string"==typeof t?this.node[e]=t:(t.value&&(this.node[e]=t.value),t.unique(this.cancellationToken).listen(function(t){return n.node.id=t},this.cancellationToken))},l.prototype.handleClass=function(t){var e=this;if("string"==typeof t)this.node.className=t;else if(t instanceof n)t.value&&(Array.isArray(t.value)?(this.node.className=t.value.join(" "),t.unique(this.cancellationToken).listen(function(){e.node.className=t.value.join(" ")},this.cancellationToken)):(this.node.className=t.value,t.unique(this.cancellationToken).listen(function(){e.node.className=t.value},this.cancellationToken))),t.unique(this.cancellationToken).listen(function(t){return e.node.className=t},this.cancellationToken);else{var i=t.reduce(function(t,e){return"string"==typeof e?t+" "+e:e.value?t+" "+e.value:t},"");this.node.className=i;for(var o=0,r=t;o<r.length;o+=1){var a=r[o];a instanceof n&&a.unique(this.cancellationToken).listen(function(n){var i=t.reduce(function(t,e){return"string"==typeof e?t+" "+e:e.value?t+" "+e.value:t},"");e.node.className=i},this.cancellationToken)}}},l.prototype.create=function(t){return document.createElement(this.domNodeName)},l.prototype.getChildIndex=function(t){for(var e=0,n=0,i=t.children;n<i.length;n+=1){if(i[n]===t)return e;e++}return-1},l.prototype.hasChild=function(t){for(var e=0,n=t.children;e<n.length;e+=1)if(n[e]===t)return!0;return!1},l.prototype.setInnerText=function(t){this.node.innerText=t},l.prototype.swapChildren=function(t,e){if(t!==e){var n=this.node.children[t],i=this.node.children[e];n.remove(),i.remove(),t<e?(this.addDomNodeAt(i,t),this.addDomNodeAt(n,e)):(this.addDomNodeAt(n,e),this.addDomNodeAt(i,t))}},l.prototype.addDomNodeAt=function(t,e){e>=this.node.childElementCount?this.node.appendChild(t):this.node.insertBefore(t,this.node.children[e])},l.prototype.addChildAt=function(t,e){if(!(t instanceof u))return this.addDomNodeAt(t.node,e)},l.prototype.addChildren=function(t){var e=this;if(0!==t.length){for(var i=[],o=0,r=t;o<r.length;o+=1){var a=r[o];a instanceof u||("string"==typeof a?i.push(a):a instanceof n?(i.push(a),this.setInnerText(a.value),a.listen(function(t){var o=i.reduce(function(t,e){var i;return t+(e instanceof n?(i=e.value,null!=i?i:"").toString():e)},"");e.setInnerText(o)},this.cancellationToken)):this.node.appendChild(a.node))}if(i.length){var s=i.reduce(function(t,e){var i;return t+(e instanceof n?(i=e.value,null!=i?i:"").toString():e)},"");this.setInnerText(s)}}};var u=function(t){function e(e){t.call(this,e,"template"),this.ref=e.ref,this.generate=e.generator}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(l),p=Symbol("owner"),d=function(){};d.attach=function(t,e){if(e[p])throw new Error("This node is already managed by aurum and cannot be used");e.appendChild(t.node),e[p]=t},d.detach=function(t){t[p]&&(t[p].dispose(),t[p]=void 0)},d.factory=function(t,e){for(var n,i=[],o=arguments.length-2;o-- >0;)i[o]=arguments[o+2];if("string"!=typeof t){for(var r,a=(n=[]).concat.apply(n,i).filter(function(t){return t}),s={},c=!1,h=0,l=a;h<l.length;h+=1){var p=l[h];"string"!=typeof p&&(p instanceof u&&!p.ref&&(s.template=p,c=!0),p.ref&&(s[p.ref]=p,c=!0))}return c&&Object.assign(e,s),(r=t.prototype?new t(e||{}):t(e||{})).addChildren(a),r}};var f=function(t){function e(e){t.call(this,e,"button")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(l),v=function(t){function e(e){t.call(this,e,"div")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(l),b=function(t){function e(e){var n=this;t.call(this,e,"input"),e.inputValueSource&&e.inputValueSource.listen(function(t){return n.node.value=t},this.cancellationToken),this.bindProps(["placeholder"],e),this.createEventHandlers(["input","change","focus","blur"],e)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(l),y=function(t){function e(e){t.call(this,e,"li")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(l),g=function(t){function e(e){t.call(this,e,"span")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(l),m=function(t){function e(e){t.call(this,e,"style")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(l),C=function(t){function e(e){t.call(this,e,"ul")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(l),w=function(t){function e(e){t.call(this,e,"p")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(l),x=function(t){function e(e){t.call(this,e,"img"),this.bindProps(["src"],e)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(l),k=function(t){function e(e){t.call(this,e,"link"),this.bindProps(["href","rel"],e)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(l),_=function(t){function e(e){t.call(this,e,"canvas"),this.bindProps(["width","height"],e)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(l);exports.ArrayDataSource=i,exports.FilteredArrayView=r,exports.DataSource=n,exports.EventEmitter=t,exports.CancellationToken=c,exports.Aurum=d,exports.AurumElement=l,exports.Template=u,exports.Button=f,exports.Div=v,exports.Input=b,exports.Li=y,exports.Span=g,exports.Style=m,exports.Ul=C,exports.P=w,exports.Img=x,exports.Link=k,exports.Canvas=_;
var t=function(t){var e=this;this.subscribeChannel=[],this.subscribeOnceChannel=[],this.throttleCount=0,this.onAfterFire=[],t&&(t.observable&&this.makeObservable(),t.cancellationToken&&t.cancellationToken.addCancelable(function(){return e.cancelAll()}),t.throttled&&(this.throttle=t.throttled))},e={subscriptions:{configurable:!0},oneTimeSubscriptions:{configurable:!0}};e.subscriptions.get=function(){return this.subscribeChannel.length},e.oneTimeSubscriptions.get=function(){return this.subscribeOnceChannel.length},t.prototype.linkEvent=function(t){this.linkedEvents||(this.linkedEvents=[]),this.linkedEvents.push(t)},t.prototype.unlinkEvent=function(t){if(!this.linkedEvents||!this.linkedEvents.includes(t))throw new Error("Cannot unlink event that is not linked");this.linkedEvents.splice(this.linkedEvents.indexOf(t),1)},t.prototype.makeObservable=function(){this.onSubscribe||(this.onSubscribe=new t,this.onSubscribeOnce=new t,this.onCancelAll=new t,this.onCancel=new t)},t.prototype.swapSubscriptions=function(t){var e=this.subscribeChannel,n=this.subscribeOnceChannel;this.subscribeChannel=t.subscribeChannel,this.subscribeOnceChannel=t.subscribeOnceChannel,t.subscribeChannel=e,t.subscribeOnceChannel=n},t.prototype.subscribe=function(t,e){return this.onSubscribe&&this.onSubscribe.fire(),this.createSubscription(t,this.subscribeChannel,e).facade},t.prototype.hasSubscriptions=function(){return this.subscriptions>0||this.oneTimeSubscriptions>0},t.prototype.subscribeOnce=function(t){var e=this;return this.onSubscribeOnce&&this.onSubscribeOnce.fire(),new Promise(function(n){e.createSubscription(function(t){return n(t)},e.subscribeOnceChannel,t)})},t.prototype.cancelAll=function(){void 0!==this.onCancelAll&&this.onCancelAll.fire()},t.prototype.fire=function(t,e,n,i,o){if(!this.throttle||this.throttleCount++%this.throttle==0){this.isFiring=!0;for(var r=this.subscribeChannel.length,a=0;a<r;a++)this.subscribeChannel[a].callback(t);if(r=this.subscribeOnceChannel.length,this.subscribeOnceChannel.length>0){for(var s=0;s<r;s++)this.subscribeOnceChannel[s].callback(t);this.subscribeOnceChannel.length=0}if(this.linkedEvents)for(var c=0,l=this.linkedEvents;c<l.length;c+=1)l[c].fire(t,e,n,i,o);this.isFiring=!1,this.onAfterFire.length>0&&(this.onAfterFire.forEach(function(t){return t()}),this.onAfterFire.length=0)}},t.prototype.createSubscription=function(t,e,n){var i=this,o={callback:t},r={cancel:function(){i.cancel(o,e)}};return void 0!==n&&n.addCancelable(function(){return i.cancel(o,e)}),e.push(o),{subscription:o,facade:r}},t.prototype.cancel=function(t,e){var n=this,i=e.indexOf(t);i>=0&&(this.isFiring?this.onAfterFire.push(function(){return n.cancel(t,e)}):e.splice(i,1))},Object.defineProperties(t.prototype,e);var n=function(t){this.value=t,this.listeners=[]};n.prototype.update=function(t){this.value=t;for(var e=0,n=this.listeners;e<n.length;e+=1)(0,n[e])(t)},n.prototype.listen=function(t,e){var n,i=this;this.listeners.push(t);var o=function(){var e=i.listeners.indexOf(t);-1!==e&&i.listeners.splice(e,1)};return null===(n=e)||void 0===n||n.addCancelable(function(){o()}),o},n.prototype.filter=function(t,e){var i=new n;return this.listen(function(e){t(e)&&i.update(e)},e),i},n.prototype.pipe=function(t,e){this.listen(function(e){return t.update(e)},e)},n.prototype.map=function(t,e){var i=new n(t(this.value));return this.listen(function(e){i.update(t(e))},e),i},n.prototype.unique=function(t){var e=new n;return this.listen(function(t){t!==e.value&&e.update(t)},t),e},n.prototype.reduce=function(t,e){var i=new n;return this.listen(function(e){return i.update(t(i.value,e))},e),i},n.prototype.combine=function(t,e,i){var o=this,r=new n;return this.listen(function(){return r.update(e(o.value,t.value))},i),t.listen(function(){return r.update(e(o.value,t.value))},i),r},n.prototype.pick=function(t,e){var i=new n;return this.listen(function(e){i.update(e[t])},e),i},n.prototype.cancelAll=function(){this.listeners.length=0};var i=function(e){this.data=e?e.slice():[],this.onChange=new t},o={length:{configurable:!0}};o.length.get=function(){return this.data.length},i.prototype.getData=function(){return this.data.slice()},i.prototype.get=function(t){return this.data[t]},i.prototype.set=function(t,e){var n=this.data[t];n!==e&&(this.data[t]=e,this.onChange.fire({operation:"replace",target:n,count:1,index:t,items:[e],newState:this.data}))},i.prototype.push=function(){for(var t,e=[],n=arguments.length;n--;)e[n]=arguments[n];(t=this.data).push.apply(t,e),this.onChange.fire({operation:"append",count:e.length,index:this.data.length-e.length,items:e,newState:this.data})},i.prototype.unshift=function(){for(var t,e=[],n=arguments.length;n--;)e[n]=arguments[n];(t=this.data).unshift.apply(t,e),this.onChange.fire({operation:"prepend",count:e.length,items:e,index:0,newState:this.data})},i.prototype.pop=function(){var t=this.data.pop();return this.onChange.fire({operation:"removeRight",count:1,index:this.data.length,items:[t],newState:this.data}),t},i.prototype.merge=function(t){for(var e=0;e<t.length;e++)this.data[e]!==t[e]&&(this.length>e?this.set(e,t[e]):this.push(t[e]));this.length>t.length&&this.removeRight(this.length-t.length)},i.prototype.removeRight=function(t){var e=this.data.splice(this.length-t,t);this.onChange.fire({operation:"removeRight",count:t,index:this.length,items:e,newState:this.data})},i.prototype.removeLeft=function(t){var e=this.data.splice(0,t);this.onChange.fire({operation:"removeLeft",count:t,index:0,items:e,newState:this.data})},i.prototype.remove=function(t){var e=this.data.indexOf(t);-1!==e&&(this.data.splice(e,1),this.onChange.fire({operation:"remove",count:1,index:e,items:[t],newState:this.data}))},i.prototype.clear=function(){var t=this.data;this.data=[],this.onChange.fire({operation:"remove",count:t.length,index:0,items:t,newState:this.data})},i.prototype.shift=function(){var t=this.data.shift();return this.onChange.fire({operation:"removeLeft",items:[t],count:1,index:0,newState:this.data}),t},i.prototype.toArray=function(){return this.data.slice()},i.prototype.filter=function(t,e){return new r(this,t,e)},i.prototype.forEach=function(t,e){return this.data.forEach(t,e)},i.prototype.toDataSource=function(){var t=new n(this.data);return this.onChange.subscribe(function(e){t.update(e.newState)}),t},Object.defineProperties(i.prototype,o);var r=function(t){function e(e,n,i){var o=this,r=e.data.filter(n);t.call(this,r),this.parent=e,this.viewFilter=n,e.onChange.subscribe(function(t){var e,n,i;switch(t.operation){case"remove":case"removeLeft":case"removeRight":for(var r=0,a=t.items;r<a.length;r+=1)o.remove(a[r]);break;case"prepend":i=t.items.filter(o.viewFilter),(e=o).unshift.apply(e,i);break;case"append":i=t.items.filter(o.viewFilter),(n=o).push.apply(n,i);break;case"replace":var s=o.data.indexOf(t.target);if(-1!==s){o.viewFilter(t.items[0])?o.set(s,t.items[0]):o.remove(t.target);break}}},i)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.updateFilter=function(t){this.viewFilter!==t&&(this.viewFilter=t,this.refresh())},e.prototype.refresh=function(){var t;this.clear();var e=this.parent.data.filter(this.viewFilter);(t=this).push.apply(t,e)},e}(i),a=function(t){this.data=t};a.prototype.deleteNext=function(){if(this.next){var t=this.next.next;this.next.next=void 0,this.next.previous=void 0,this.next=t,this.next.previous=this}},a.prototype.deletePrevious=function(){this.previous&&(this.previous=this.previous.previous,this.previous.next=void 0,this.previous.previous=void 0)};var s=function(t){var e=this;void 0===t&&(t=[]),this.length=0,t.forEach(function(t){return e.append(t)})};s.prototype.find=function(t){for(var e=this.rootNode;e&&!t(e);)e=e.next;return e},s.prototype.append=function(t){return this.rootNode||this.lastNode?(this.lastNode.next=new a(t),this.lastNode.next.previous=this.lastNode,this.lastNode=this.lastNode.next):this.rootNode=this.lastNode=new a(t),this.length++,t},s.prototype.forEach=function(t){this.find(function(e){return t(e.data),!1})},s.prototype.prepend=function(t){return this.rootNode||this.lastNode?(this.rootNode.previous=new a(t),this.rootNode.previous.next=this.rootNode,this.rootNode=this.rootNode.previous):this.rootNode=this.lastNode=new a(t),this.length++,t},s.prototype.remove=function(t){if(t===this.rootNode.data)this.rootNode=this.rootNode.next,this.length--;else{var e=this.find(function(e){return e.next&&e.next.data===t});e&&(e.next===this.lastNode&&(this.lastNode=e),e.deleteNext(),this.length--)}};var c=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];this.cancelables=new s(t),this._isCancelled=!1},l={isCanceled:{configurable:!0}};l.isCanceled.get=function(){return this._isCancelled},c.prototype.addCancelable=function(t){return this.throwIfCancelled("attempting to add cancellable to token that is already cancelled"),this.cancelables.append(t),this.cancelables.length>200&&console.log("potential memory leak: cancellation token has over 200 clean up calls"),this},c.prototype.removeCancelable=function(t){return this.throwIfCancelled("attempting to remove cancellable from token that is already cancelled"),this.cancelables.remove(t),this},c.prototype.addDisposable=function(t){return this.addCancelable(function(){return t.dispose()}),this},c.prototype.callIfNotCancelled=function(t){this.isCanceled||t()},c.prototype.setTimeout=function(t,e){void 0===e&&(e=0);var n=setTimeout(t,e);this.addCancelable(function(){return clearTimeout(n)})},c.prototype.setInterval=function(t,e){var n=setInterval(t,e);this.addCancelable(function(){return clearInterval(n)})},c.prototype.requestAnimationFrame=function(t){var e=requestAnimationFrame(t);this.addCancelable(function(){return cancelAnimationFrame(e)})},c.prototype.animationLoop=function(t){var e=requestAnimationFrame(function n(i){t(i),e=requestAnimationFrame(n)});this.addCancelable(function(){return cancelAnimationFrame(e)})},c.prototype.throwIfCancelled=function(t){if(this.isCanceled)throw new Error(t||"cancellation token is cancelled")},c.prototype.chain=function(t,e){return void 0===e&&(e=!1),e&&t.chain(this,!1),this.addCancelable(function(){return t.cancel()}),this},c.prototype.registerDomEvent=function(t,e,n){return t.addEventListener(e,n),this.addCancelable(function(){return t.removeEventListener(e,n)}),this},c.prototype.cancel=function(){this.isCanceled||(this._isCancelled=!0,this.cancelables.forEach(function(t){return t()}),this.cancelables=void 0)},Object.defineProperties(c.prototype,l);var h=Symbol("owner"),u=function(t,e){this.domNodeName=e,this.template=t.template,this.cancellationToken=new c,this.node=this.create(t),this.initialize(t),t.onAttach&&t.onAttach(this)};u.prototype.initialize=function(t){this.node.owner=this,this.createEventHandlers(["blur","focus","click","dblclick","keydown","keyhit","keyup","mousedown, mouseup","mouseenter","mouseleave","mousewheel"],t),this.bindProps(["id","draggable","tabindex","style"],t),t.class&&this.handleClass(t.class),t.repeatModel&&(this.cachedChildren=[],this.handleRepeat(t.repeatModel))},u.prototype.bindProps=function(t,e){for(var n=0,i=t;n<i.length;n+=1){var o=i[n];e[o]&&this.assignStringSourceToAttribute(e[o],o)}},u.prototype.createEventHandlers=function(t,e){for(var i=this,o=function(){var t=a[r],o="on"+t[0].toUpperCase()+t.slice(1),s=void 0;Object.defineProperty(i,o,{get:function(){return s||(s=new n),s},set:function(){throw new Error(o+" is read only")}}),e[o]&&(e[o]instanceof n?i[o].listen(e[o].update.bind(e.onClick),i.cancellationToken):"function"==typeof e[o]&&i[o].listen(e[o],i.cancellationToken)),i.cancellationToken.registerDomEvent(i.node,t,function(t){return i[o].update(t)})},r=0,a=t;r<a.length;r+=1)o()},u.prototype.handleRepeat=function(t){var e,n=this;this.repeatData=t instanceof i?t:new i(t),this.repeatData.length&&((e=this.cachedChildren).push.apply(e,this.repeatData.toArray().map(function(t){return n.template.generate(t)})),this.renderRepeat()),this.repeatData.onChange.subscribe(function(t){var e,i;switch(t.operation){case"append":(e=n.cachedChildren).push.apply(e,t.items.map(function(t){return n.template.generate(t)}));break;case"removeLeft":n.cachedChildren.splice(0,t.count);break;case"removeRight":n.cachedChildren.splice(n.node.childElementCount-t.count,t.count);break;case"remove":n.cachedChildren.splice(t.index,t.count);break;default:n.cachedChildren.length=0,(i=n.cachedChildren).push.apply(i,n.repeatData.toArray().map(function(t){return n.template.generate(t)}))}n.renderRepeat()})},u.prototype.renderRepeat=function(){var t=this;this.rerenderPending||(setTimeout(function(){for(var e=0;e<t.cachedChildren.length;e++){if(t.node.childElementCount<=e){t.addChildren(t.cachedChildren.slice(e,t.cachedChildren.length));break}if(t.node.children[e].owner!==t.cachedChildren[e]){if(!t.cachedChildren.includes(t.node.children[e].owner)){t.node.children[e][h].remove(),e--;continue}var n=t.getChildIndex(t.cachedChildren[e].node);-1!==n?t.swapChildren(e,n):t.addChildAt(t.cachedChildren[e],e)}}for(;t.node.childElementCount>t.cachedChildren.length;)t.node[h].removeChild(t.node.lastChild[h]);t.rerenderPending=!1}),this.rerenderPending=!0)},u.prototype.assignStringSourceToAttribute=function(t,e){var n=this;"string"==typeof t?this.node[e]=t:(t.value&&(this.node[e]=t.value),t.unique(this.cancellationToken).listen(function(t){return n.node.id=t},this.cancellationToken))},u.prototype.handleClass=function(t){var e=this;if("string"==typeof t)this.node.className=t;else if(t instanceof n)t.value&&(Array.isArray(t.value)?(this.node.className=t.value.join(" "),t.unique(this.cancellationToken).listen(function(){e.node.className=t.value.join(" ")},this.cancellationToken)):(this.node.className=t.value,t.unique(this.cancellationToken).listen(function(){e.node.className=t.value},this.cancellationToken))),t.unique(this.cancellationToken).listen(function(t){return e.node.className=t},this.cancellationToken);else{var i=t.reduce(function(t,e){return"string"==typeof e?t+" "+e:e.value?t+" "+e.value:t},"");this.node.className=i;for(var o=0,r=t;o<r.length;o+=1){var a=r[o];a instanceof n&&a.unique(this.cancellationToken).listen(function(n){var i=t.reduce(function(t,e){return"string"==typeof e?t+" "+e:e.value?t+" "+e.value:t},"");e.node.className=i},this.cancellationToken)}}},u.prototype.create=function(t){var e=document.createElement(this.domNodeName);return e[h]=this,e},u.prototype.getChildIndex=function(t){for(var e=0,n=0,i=t.children;n<i.length;n+=1){if(i[n]===t)return e;e++}return-1},u.prototype.hasChild=function(t){for(var e=0,n=t.children;e<n.length;e+=1)if(n[e]===t)return!0;return!1},u.prototype.setInnerText=function(t){if(this.node.firstChild)throw new Error("Cannot combine text and child nodes into a single element");this.node.innerText=t},u.prototype.swapChildren=function(t,e){if(t!==e){var n=this.node.children[t],i=this.node.children[e];n.remove(),i.remove(),t<e?(this.addDomNodeAt(i,t),this.addDomNodeAt(n,e)):(this.addDomNodeAt(n,e),this.addDomNodeAt(i,t))}},u.prototype.addDomNodeAt=function(t,e){e>=this.node.childElementCount?this.node.appendChild(t):this.node.insertBefore(t,this.node.children[e])},u.prototype.remove=function(){this.hasParent()&&(this.node.parentElement.removeChild(this.node),this.dispose())},u.prototype.hasParent=function(){return!!this.node.parentElement},u.prototype.isConnected=function(){return this.node.isConnected},u.prototype.removeChild=function(t){t.dispose(),this.node.removeChild(t.node)},u.prototype.removeChildAt=function(t){var e=this.node.childNodes[t];if(e){var n=e[h];n.dispose(),this.node.removeChild(n.node)}},u.prototype.clearChildren=function(){for(;this.node.firstChild;)this.node.firstChild[h].dispose(),this.node.removeChild(this.node.firstChild)},u.prototype.addChild=function(t){if(!(t.node instanceof p))return this.node.appendChild(t.node)},u.prototype.addChildAt=function(t,e){if(!(t.node instanceof p))return this.addDomNodeAt(t.node,e)},u.prototype.addChildren=function(t){var e=this;if(0!==t.length){for(var i=[],o=0,r=t;o<r.length;o+=1){var a=r[o];a instanceof p||("string"==typeof a?i.push(a):a instanceof n?(i.push(a),this.setInnerText(a.value),a.listen(function(t){var o=i.reduce(function(t,e){var i;return t+(e instanceof n?(i=e.value,null!=i?i:"").toString():e)},"");e.setInnerText(o)},this.cancellationToken)):this.node.appendChild(a.node))}if(i.length){var s=i.reduce(function(t,e){var i;return t+(e instanceof n?(i=e.value,null!=i?i:"").toString():e)},"");this.setInnerText(s)}}},u.prototype.dispose=function(){this.cancellationToken.cancel()};var p=function(t){function e(e){t.call(this,e,"template"),this.ref=e.ref,this.generate=e.generator}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(u),d=function(){};d.attach=function(t,e){if(e[h])throw new Error("This node is already managed by aurum and cannot be used");e.appendChild(t.node),e[h]=t},d.detach=function(t){t[h]&&(t[h].dispose(),t[h]=void 0)},d.factory=function(t,e){for(var n,i=[],o=arguments.length-2;o-- >0;)i[o]=arguments[o+2];if("string"!=typeof t){for(var r,a,s=(n=[]).concat.apply(n,i).filter(function(t){return t}),c={},l=!1,h=0,u=s;h<u.length;h+=1){var d=u[h];"string"!=typeof d&&(d instanceof p&&(!d.ref||"default"===d.ref)&&(r=d),d.ref&&(c[d.ref]=d,l=!0))}return e=null!=e?e:{},r&&(e.template=r),l&&(e.templateMap=c),(a=t.prototype?new t(e||{}):t(e||{})).addChildren(s),a}};var f=function(t){function e(e){t.call(this,e,"button")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(u),v=function(t){function e(e){t.call(this,e,"div")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(u),b=function(t){function e(e){var n,i,o,r=this;t.call(this,e,"input"),e.inputValueSource?(this.node.value=null!=(i=null!=(n=e.initialValue)?n:e.inputValueSource.value)?i:"",e.inputValueSource.listen(function(t){return r.node.value=t},this.cancellationToken)):this.node.value=null!=(o=e.initialValue)?o:"",this.bindProps(["placeholder"],e),this.createEventHandlers(["input","change"],e)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(u),y=function(t){function e(e){t.call(this,e,"li")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(u),m=function(t){function e(e){t.call(this,e,"span")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(u),g=function(t){function e(e){t.call(this,e,"style")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(u),C=function(t){function e(e){t.call(this,e,"ul")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(u),w=function(t){function e(e){t.call(this,e,"p")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(u),x=function(t){function e(e){t.call(this,e,"img"),this.bindProps(["src"],e)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(u),k=function(t){function e(e){t.call(this,e,"link"),this.bindProps(["href","rel"],e)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(u),_=function(t){function e(e){t.call(this,e,"canvas"),this.bindProps(["width","height"],e)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(u),N=function(t){function e(e){var n=this;t.call(this,e,"switch"),this.firstRender=!0,this.templateMap=e.templateMap,this.render(e.state.value),e.state.listen(function(t){n.render(t)},this.cancellationToken)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.render=function(t){var e;if(t!==this.lastValue||this.firstRender)if(this.lastValue=t,this.firstRender=!1,this.clearChildren(),null!=t){var n=null!=(e=this.templateMap[t.toString()])?e:this.template;if(n){var i=n.generate();this.addChild(i)}}else if(this.template){var o=this.template.generate();this.addChild(o)}},e}(u);exports.ArrayDataSource=i,exports.FilteredArrayView=r,exports.DataSource=n,exports.EventEmitter=t,exports.CancellationToken=c,exports.Aurum=d,exports.AurumElement=u,exports.Template=p,exports.Button=f,exports.Div=v,exports.Input=b,exports.Li=y,exports.Span=m,exports.Style=g,exports.Ul=C,exports.P=w,exports.Img=x,exports.Link=k,exports.Canvas=_,exports.Switch=N;
//# sourceMappingURL=aurumjs.js.map

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.aurumjs={})}(this,function(t){var e=function(t){var e=this;this.subscribeChannel=[],this.subscribeOnceChannel=[],this.throttleCount=0,this.onAfterFire=[],t&&(t.observable&&this.makeObservable(),t.cancellationToken&&t.cancellationToken.addCancelable(function(){return e.cancelAll()}),t.throttled&&(this.throttle=t.throttled))},n={subscriptions:{configurable:!0},oneTimeSubscriptions:{configurable:!0}};n.subscriptions.get=function(){return this.subscribeChannel.length},n.oneTimeSubscriptions.get=function(){return this.subscribeOnceChannel.length},e.prototype.linkEvent=function(t){this.linkedEvents||(this.linkedEvents=[]),this.linkedEvents.push(t)},e.prototype.unlinkEvent=function(t){if(!this.linkedEvents||!this.linkedEvents.includes(t))throw new Error("Cannot unlink event that is not linked");this.linkedEvents.splice(this.linkedEvents.indexOf(t),1)},e.prototype.makeObservable=function(){this.onSubscribe||(this.onSubscribe=new e,this.onSubscribeOnce=new e,this.onCancelAll=new e,this.onCancel=new e)},e.prototype.swapSubscriptions=function(t){var e=this.subscribeChannel,n=this.subscribeOnceChannel;this.subscribeChannel=t.subscribeChannel,this.subscribeOnceChannel=t.subscribeOnceChannel,t.subscribeChannel=e,t.subscribeOnceChannel=n},e.prototype.subscribe=function(t,e){return this.onSubscribe&&this.onSubscribe.fire(),this.createSubscription(t,this.subscribeChannel,e).facade},e.prototype.hasSubscriptions=function(){return this.subscriptions>0||this.oneTimeSubscriptions>0},e.prototype.subscribeOnce=function(t){var e=this;return this.onSubscribeOnce&&this.onSubscribeOnce.fire(),new Promise(function(n){e.createSubscription(function(t){return n(t)},e.subscribeOnceChannel,t)})},e.prototype.cancelAll=function(){void 0!==this.onCancelAll&&this.onCancelAll.fire()},e.prototype.fire=function(t,e,n,i,o){if(!this.throttle||this.throttleCount++%this.throttle==0){this.isFiring=!0;for(var r=this.subscribeChannel.length,a=0;a<r;a++)this.subscribeChannel[a].callback(t);if(r=this.subscribeOnceChannel.length,this.subscribeOnceChannel.length>0){for(var s=0;s<r;s++)this.subscribeOnceChannel[s].callback(t);this.subscribeOnceChannel.length=0}if(this.linkedEvents)for(var c=0,h=this.linkedEvents;c<h.length;c+=1)h[c].fire(t,e,n,i,o);this.isFiring=!1,this.onAfterFire.length>0&&(this.onAfterFire.forEach(function(t){return t()}),this.onAfterFire.length=0)}},e.prototype.createSubscription=function(t,e,n){var i=this,o={callback:t},r={cancel:function(){i.cancel(o,e)}};return void 0!==n&&n.addCancelable(function(){return i.cancel(o,e)}),e.push(o),{subscription:o,facade:r}},e.prototype.cancel=function(t,e){var n=this,i=e.indexOf(t);i>=0&&(this.isFiring?this.onAfterFire.push(function(){return n.cancel(t,e)}):e.splice(i,1))},Object.defineProperties(e.prototype,n);var i=function(t){this.value=t,this.listeners=[]};i.prototype.update=function(t){this.value=t;for(var e=0,n=this.listeners;e<n.length;e+=1)(0,n[e])(t)},i.prototype.listen=function(t,e){var n,i=this;this.listeners.push(t);var o=function(){var e=i.listeners.indexOf(t);-1!==e&&i.listeners.splice(e,1)};return null===(n=e)||void 0===n||n.addCancelable(function(){o()}),o},i.prototype.filter=function(t,e){var n=new i;return this.listen(function(e){t(e)&&n.update(e)},e),n},i.prototype.pipe=function(t,e){this.listen(function(e){return t.update(e)},e)},i.prototype.map=function(t,e){var n=new i(t(this.value));return this.listen(function(e){n.update(t(e))},e),n},i.prototype.unique=function(t){var e=new i;return this.listen(function(t){t!==e.value&&e.update(t)},t),e},i.prototype.reduce=function(t,e){var n=new i;return this.listen(function(e){return n.update(t(n.value,e))},e),n},i.prototype.combine=function(t,e,n){var o=this,r=new i;return this.listen(function(){return r.update(e(o.value,t.value))},n),t.listen(function(){return r.update(e(o.value,t.value))},n),r},i.prototype.pick=function(t,e){var n=new i;return this.listen(function(e){n.update(e[t])},e),n},i.prototype.cancelAll=function(){this.listeners.length=0};var o=function(t){this.data=t?t.slice():[],this.onChange=new e},r={length:{configurable:!0}};r.length.get=function(){return this.data.length},o.prototype.getData=function(){return this.data.slice()},o.prototype.get=function(t){return this.data[t]},o.prototype.set=function(t,e){var n=this.data[t];n!==e&&(this.data[t]=e,this.onChange.fire({operation:"replace",target:n,count:1,index:t,items:[e],newState:this.data}))},o.prototype.push=function(){for(var t,e=[],n=arguments.length;n--;)e[n]=arguments[n];(t=this.data).push.apply(t,e),this.onChange.fire({operation:"append",count:e.length,index:this.data.length-e.length,items:e,newState:this.data})},o.prototype.unshift=function(){for(var t,e=[],n=arguments.length;n--;)e[n]=arguments[n];(t=this.data).unshift.apply(t,e),this.onChange.fire({operation:"prepend",count:e.length,items:e,index:0,newState:this.data})},o.prototype.pop=function(){var t=this.data.pop();return this.onChange.fire({operation:"removeRight",count:1,index:this.data.length,items:[t],newState:this.data}),t},o.prototype.merge=function(t){for(var e=0;e<t.length;e++)this.data[e]!==t[e]&&(this.length>e?this.set(e,t[e]):this.push(t[e]));this.length>t.length&&this.removeRight(this.length-t.length)},o.prototype.removeRight=function(t){var e=this.data.splice(this.length-t,t);this.onChange.fire({operation:"removeRight",count:t,index:this.length,items:e,newState:this.data})},o.prototype.removeLeft=function(t){var e=this.data.splice(0,t);this.onChange.fire({operation:"removeLeft",count:t,index:0,items:e,newState:this.data})},o.prototype.remove=function(t){var e=this.data.indexOf(t);-1!==e&&(this.data.splice(e,1),this.onChange.fire({operation:"remove",count:1,index:e,items:[t],newState:this.data}))},o.prototype.clear=function(){var t=this.data;this.data=[],this.onChange.fire({operation:"remove",count:t.length,index:0,items:t,newState:this.data})},o.prototype.shift=function(){var t=this.data.shift();return this.onChange.fire({operation:"removeLeft",items:[t],count:1,index:0,newState:this.data}),t},o.prototype.toArray=function(){return this.data.slice()},o.prototype.filter=function(t,e){return new a(this,t,e)},o.prototype.forEach=function(t,e){return this.data.forEach(t,e)},o.prototype.toDataSource=function(){var t=new i(this.data);return this.onChange.subscribe(function(e){t.update(e.newState)}),t},Object.defineProperties(o.prototype,r);var a=function(t){function e(e,n,i){var o=this,r=e.data.filter(n);t.call(this,r),this.parent=e,this.viewFilter=n,e.onChange.subscribe(function(t){var e,n,i;switch(t.operation){case"remove":case"removeLeft":case"removeRight":for(var r=0,a=t.items;r<a.length;r+=1)o.remove(a[r]);break;case"prepend":i=t.items.filter(o.viewFilter),(e=o).unshift.apply(e,i);break;case"append":i=t.items.filter(o.viewFilter),(n=o).push.apply(n,i);break;case"replace":var s=o.data.indexOf(t.target);if(-1!==s){o.viewFilter(t.items[0])?o.set(s,t.items[0]):o.remove(t.target);break}}},i)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.updateFilter=function(t){this.viewFilter!==t&&(this.viewFilter=t,this.refresh())},e.prototype.refresh=function(){var t;this.clear();var e=this.parent.data.filter(this.viewFilter);(t=this).push.apply(t,e)},e}(o),s=function(t){this.data=t};s.prototype.deleteNext=function(){if(this.next){var t=this.next.next;this.next.next=void 0,this.next.previous=void 0,this.next=t,this.next.previous=this}},s.prototype.deletePrevious=function(){this.previous&&(this.previous=this.previous.previous,this.previous.next=void 0,this.previous.previous=void 0)};var c=function(t){var e=this;void 0===t&&(t=[]),this.length=0,t.forEach(function(t){return e.append(t)})};c.prototype.find=function(t){for(var e=this.rootNode;e&&!t(e);)e=e.next;return e},c.prototype.append=function(t){return this.rootNode||this.lastNode?(this.lastNode.next=new s(t),this.lastNode.next.previous=this.lastNode,this.lastNode=this.lastNode.next):this.rootNode=this.lastNode=new s(t),this.length++,t},c.prototype.forEach=function(t){this.find(function(e){return t(e.data),!1})},c.prototype.prepend=function(t){return this.rootNode||this.lastNode?(this.rootNode.previous=new s(t),this.rootNode.previous.next=this.rootNode,this.rootNode=this.rootNode.previous):this.rootNode=this.lastNode=new s(t),this.length++,t},c.prototype.remove=function(t){if(t===this.rootNode.data)this.rootNode=this.rootNode.next,this.length--;else{var e=this.find(function(e){return e.next&&e.next.data===t});e&&(e.next===this.lastNode&&(this.lastNode=e),e.deleteNext(),this.length--)}};var h=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];this.cancelables=new c(t),this._isCancelled=!1},l={isCanceled:{configurable:!0}};l.isCanceled.get=function(){return this._isCancelled},h.prototype.addCancelable=function(t){return this.throwIfCancelled("attempting to add cancellable to token that is already cancelled"),this.cancelables.append(t),this.cancelables.length>200&&console.log("potential memory leak: cancellation token has over 200 clean up calls"),this},h.prototype.removeCancelable=function(t){return this.throwIfCancelled("attempting to remove cancellable from token that is already cancelled"),this.cancelables.remove(t),this},h.prototype.addDisposable=function(t){return this.addCancelable(function(){return t.dispose()}),this},h.prototype.callIfNotCancelled=function(t){this.isCanceled||t()},h.prototype.setTimeout=function(t,e){void 0===e&&(e=0);var n=setTimeout(t,e);this.addCancelable(function(){return clearTimeout(n)})},h.prototype.setInterval=function(t,e){var n=setInterval(t,e);this.addCancelable(function(){return clearInterval(n)})},h.prototype.requestAnimationFrame=function(t){var e=requestAnimationFrame(t);this.addCancelable(function(){return cancelAnimationFrame(e)})},h.prototype.animationLoop=function(t){var e=requestAnimationFrame(function n(i){t(i),e=requestAnimationFrame(n)});this.addCancelable(function(){return cancelAnimationFrame(e)})},h.prototype.throwIfCancelled=function(t){if(this.isCanceled)throw new Error(t||"cancellation token is cancelled")},h.prototype.chain=function(t,e){return void 0===e&&(e=!1),e&&t.chain(this,!1),this.addCancelable(function(){return t.cancel()}),this},h.prototype.registerDomEvent=function(t,e,n){return t.addEventListener(e,n),this.addCancelable(function(){return t.removeEventListener(e,n)}),this},h.prototype.cancel=function(){this.isCanceled||(this._isCancelled=!0,this.cancelables.forEach(function(t){return t()}),this.cancelables=void 0)},Object.defineProperties(h.prototype,l);var u=function(t,e){this.domNodeName=e,this.template=t.template,this.cancellationToken=new h,this.node=this.create(t),this.initialize(t),t.onAttach&&t.onAttach(this)};u.prototype.initialize=function(t){this.node.owner=this,this.createEventHandlers(["click","keydown","keyhit","keyup","mousedown, mouseup","mouseenter","mouseleave","mousewheel"],t),this.bindProps(["id","draggable","tabindex","style"],t),t.class&&this.handleClass(t.class),t.repeatModel&&(this.cachedChildren=[],this.handleRepeat(t.repeatModel))},u.prototype.bindProps=function(t,e){for(var n=0,i=t;n<i.length;n+=1){var o=i[n];e[o]&&this.assignStringSourceToAttribute(e[o],o)}},u.prototype.createEventHandlers=function(t,e){for(var n=this,o=function(){var t=a[r],o="on"+t[0].toUpperCase()+t.slice(1),s=void 0;Object.defineProperty(n,o,{get:function(){return s||(s=new i),s},set:function(){throw new Error(o+" is read only")}}),e[o]&&(e[o]instanceof i?n[o].listen(e[o].update.bind(e.onClick),n.cancellationToken):"function"==typeof e[o]&&n[o].listen(e[o],n.cancellationToken)),n.cancellationToken.registerDomEvent(n.node,t,function(t){return n[o].update(t)})},r=0,a=t;r<a.length;r+=1)o()},u.prototype.handleRepeat=function(t){var e,n=this;this.repeatData=t instanceof o?t:new o(t),this.repeatData.length&&((e=this.cachedChildren).push.apply(e,this.repeatData.toArray().map(function(t){return n.template.generate(t)})),this.renderRepeat()),this.repeatData.onChange.subscribe(function(t){var e,i;switch(t.operation){case"append":(e=n.cachedChildren).push.apply(e,t.items.map(function(t){return n.template.generate(t)}));break;case"removeLeft":n.cachedChildren.splice(0,t.count);break;case"removeRight":n.cachedChildren.splice(n.node.childElementCount-t.count,t.count);break;case"remove":n.cachedChildren.splice(t.index,t.count);break;default:n.cachedChildren.length=0,(i=n.cachedChildren).push.apply(i,n.repeatData.toArray().map(function(t){return n.template.generate(t)}))}n.renderRepeat()})},u.prototype.renderRepeat=function(){var t=this;this.rerenderPending||(setTimeout(function(){for(var e=0;e<t.cachedChildren.length;e++){if(t.node.childElementCount<=e){t.addChildren(t.cachedChildren.slice(e,t.cachedChildren.length));break}if(t.node.children[e].owner!==t.cachedChildren[e]){if(!t.cachedChildren.includes(t.node.children[e].owner)){t.node.children[e].remove(),e--;continue}var n=t.getChildIndex(t.cachedChildren[e].node);-1!==n?t.swapChildren(e,n):t.addChildAt(t.cachedChildren[e],e)}}for(;t.node.childElementCount>t.cachedChildren.length;)t.node.removeChild(t.node.lastChild);t.rerenderPending=!1}),this.rerenderPending=!0)},u.prototype.assignStringSourceToAttribute=function(t,e){var n=this;"string"==typeof t?this.node[e]=t:(t.value&&(this.node[e]=t.value),t.unique(this.cancellationToken).listen(function(t){return n.node.id=t},this.cancellationToken))},u.prototype.handleClass=function(t){var e=this;if("string"==typeof t)this.node.className=t;else if(t instanceof i)t.value&&(Array.isArray(t.value)?(this.node.className=t.value.join(" "),t.unique(this.cancellationToken).listen(function(){e.node.className=t.value.join(" ")},this.cancellationToken)):(this.node.className=t.value,t.unique(this.cancellationToken).listen(function(){e.node.className=t.value},this.cancellationToken))),t.unique(this.cancellationToken).listen(function(t){return e.node.className=t},this.cancellationToken);else{var n=t.reduce(function(t,e){return"string"==typeof e?t+" "+e:e.value?t+" "+e.value:t},"");this.node.className=n;for(var o=0,r=t;o<r.length;o+=1){var a=r[o];a instanceof i&&a.unique(this.cancellationToken).listen(function(n){var i=t.reduce(function(t,e){return"string"==typeof e?t+" "+e:e.value?t+" "+e.value:t},"");e.node.className=i},this.cancellationToken)}}},u.prototype.create=function(t){return document.createElement(this.domNodeName)},u.prototype.getChildIndex=function(t){for(var e=0,n=0,i=t.children;n<i.length;n+=1){if(i[n]===t)return e;e++}return-1},u.prototype.hasChild=function(t){for(var e=0,n=t.children;e<n.length;e+=1)if(n[e]===t)return!0;return!1},u.prototype.setInnerText=function(t){this.node.innerText=t},u.prototype.swapChildren=function(t,e){if(t!==e){var n=this.node.children[t],i=this.node.children[e];n.remove(),i.remove(),t<e?(this.addDomNodeAt(i,t),this.addDomNodeAt(n,e)):(this.addDomNodeAt(n,e),this.addDomNodeAt(i,t))}},u.prototype.addDomNodeAt=function(t,e){e>=this.node.childElementCount?this.node.appendChild(t):this.node.insertBefore(t,this.node.children[e])},u.prototype.addChildAt=function(t,e){if(!(t instanceof p))return this.addDomNodeAt(t.node,e)},u.prototype.addChildren=function(t){var e=this;if(0!==t.length){for(var n=[],o=0,r=t;o<r.length;o+=1){var a=r[o];a instanceof p||("string"==typeof a?n.push(a):a instanceof i?(n.push(a),this.setInnerText(a.value),a.listen(function(t){var o=n.reduce(function(t,e){var n;return t+(e instanceof i?(n=e.value,null!=n?n:"").toString():e)},"");e.setInnerText(o)},this.cancellationToken)):this.node.appendChild(a.node))}if(n.length){var s=n.reduce(function(t,e){var n;return t+(e instanceof i?(n=e.value,null!=n?n:"").toString():e)},"");this.setInnerText(s)}}};var p=function(t){function e(e){t.call(this,e,"template"),this.ref=e.ref,this.generate=e.generator}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(u),d=Symbol("owner"),f=function(){};f.attach=function(t,e){if(e[d])throw new Error("This node is already managed by aurum and cannot be used");e.appendChild(t.node),e[d]=t},f.detach=function(t){t[d]&&(t[d].dispose(),t[d]=void 0)},f.factory=function(t,e){for(var n,i=[],o=arguments.length-2;o-- >0;)i[o]=arguments[o+2];if("string"!=typeof t){for(var r,a=(n=[]).concat.apply(n,i).filter(function(t){return t}),s={},c=!1,h=0,l=a;h<l.length;h+=1){var u=l[h];"string"!=typeof u&&(u instanceof p&&!u.ref&&(s.template=u,c=!0),u.ref&&(s[u.ref]=u,c=!0))}return c&&Object.assign(e,s),(r=t.prototype?new t(e||{}):t(e||{})).addChildren(a),r}};var v=function(t){function e(e){t.call(this,e,"button")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(u),b=function(t){function e(e){t.call(this,e,"div")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(u),y=function(t){function e(e){var n=this;t.call(this,e,"input"),e.inputValueSource&&e.inputValueSource.listen(function(t){return n.node.value=t},this.cancellationToken),this.bindProps(["placeholder"],e),this.createEventHandlers(["input","change","focus","blur"],e)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(u),m=function(t){function e(e){t.call(this,e,"li")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(u),g=function(t){function e(e){t.call(this,e,"span")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(u),C=function(t){function e(e){t.call(this,e,"style")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(u),w=function(t){function e(e){t.call(this,e,"ul")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(u),k=function(t){function e(e){t.call(this,e,"p")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(u),_=function(t){function e(e){t.call(this,e,"img"),this.bindProps(["src"],e)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(u),x=function(t){function e(e){t.call(this,e,"link"),this.bindProps(["href","rel"],e)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(u),N=function(t){function e(e){t.call(this,e,"canvas"),this.bindProps(["width","height"],e)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(u);t.ArrayDataSource=o,t.FilteredArrayView=a,t.DataSource=i,t.EventEmitter=e,t.CancellationToken=h,t.Aurum=f,t.AurumElement=u,t.Template=p,t.Button=v,t.Div=b,t.Input=y,t.Li=m,t.Span=g,t.Style=C,t.Ul=w,t.P=k,t.Img=_,t.Link=x,t.Canvas=N});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.aurumjs={})}(this,function(t){var e=function(t){var e=this;this.subscribeChannel=[],this.subscribeOnceChannel=[],this.throttleCount=0,this.onAfterFire=[],t&&(t.observable&&this.makeObservable(),t.cancellationToken&&t.cancellationToken.addCancelable(function(){return e.cancelAll()}),t.throttled&&(this.throttle=t.throttled))},n={subscriptions:{configurable:!0},oneTimeSubscriptions:{configurable:!0}};n.subscriptions.get=function(){return this.subscribeChannel.length},n.oneTimeSubscriptions.get=function(){return this.subscribeOnceChannel.length},e.prototype.linkEvent=function(t){this.linkedEvents||(this.linkedEvents=[]),this.linkedEvents.push(t)},e.prototype.unlinkEvent=function(t){if(!this.linkedEvents||!this.linkedEvents.includes(t))throw new Error("Cannot unlink event that is not linked");this.linkedEvents.splice(this.linkedEvents.indexOf(t),1)},e.prototype.makeObservable=function(){this.onSubscribe||(this.onSubscribe=new e,this.onSubscribeOnce=new e,this.onCancelAll=new e,this.onCancel=new e)},e.prototype.swapSubscriptions=function(t){var e=this.subscribeChannel,n=this.subscribeOnceChannel;this.subscribeChannel=t.subscribeChannel,this.subscribeOnceChannel=t.subscribeOnceChannel,t.subscribeChannel=e,t.subscribeOnceChannel=n},e.prototype.subscribe=function(t,e){return this.onSubscribe&&this.onSubscribe.fire(),this.createSubscription(t,this.subscribeChannel,e).facade},e.prototype.hasSubscriptions=function(){return this.subscriptions>0||this.oneTimeSubscriptions>0},e.prototype.subscribeOnce=function(t){var e=this;return this.onSubscribeOnce&&this.onSubscribeOnce.fire(),new Promise(function(n){e.createSubscription(function(t){return n(t)},e.subscribeOnceChannel,t)})},e.prototype.cancelAll=function(){void 0!==this.onCancelAll&&this.onCancelAll.fire()},e.prototype.fire=function(t,e,n,i,o){if(!this.throttle||this.throttleCount++%this.throttle==0){this.isFiring=!0;for(var r=this.subscribeChannel.length,a=0;a<r;a++)this.subscribeChannel[a].callback(t);if(r=this.subscribeOnceChannel.length,this.subscribeOnceChannel.length>0){for(var s=0;s<r;s++)this.subscribeOnceChannel[s].callback(t);this.subscribeOnceChannel.length=0}if(this.linkedEvents)for(var c=0,l=this.linkedEvents;c<l.length;c+=1)l[c].fire(t,e,n,i,o);this.isFiring=!1,this.onAfterFire.length>0&&(this.onAfterFire.forEach(function(t){return t()}),this.onAfterFire.length=0)}},e.prototype.createSubscription=function(t,e,n){var i=this,o={callback:t},r={cancel:function(){i.cancel(o,e)}};return void 0!==n&&n.addCancelable(function(){return i.cancel(o,e)}),e.push(o),{subscription:o,facade:r}},e.prototype.cancel=function(t,e){var n=this,i=e.indexOf(t);i>=0&&(this.isFiring?this.onAfterFire.push(function(){return n.cancel(t,e)}):e.splice(i,1))},Object.defineProperties(e.prototype,n);var i=function(t){this.value=t,this.listeners=[]};i.prototype.update=function(t){this.value=t;for(var e=0,n=this.listeners;e<n.length;e+=1)(0,n[e])(t)},i.prototype.listen=function(t,e){var n,i=this;this.listeners.push(t);var o=function(){var e=i.listeners.indexOf(t);-1!==e&&i.listeners.splice(e,1)};return null===(n=e)||void 0===n||n.addCancelable(function(){o()}),o},i.prototype.filter=function(t,e){var n=new i;return this.listen(function(e){t(e)&&n.update(e)},e),n},i.prototype.pipe=function(t,e){this.listen(function(e){return t.update(e)},e)},i.prototype.map=function(t,e){var n=new i(t(this.value));return this.listen(function(e){n.update(t(e))},e),n},i.prototype.unique=function(t){var e=new i;return this.listen(function(t){t!==e.value&&e.update(t)},t),e},i.prototype.reduce=function(t,e){var n=new i;return this.listen(function(e){return n.update(t(n.value,e))},e),n},i.prototype.combine=function(t,e,n){var o=this,r=new i;return this.listen(function(){return r.update(e(o.value,t.value))},n),t.listen(function(){return r.update(e(o.value,t.value))},n),r},i.prototype.pick=function(t,e){var n=new i;return this.listen(function(e){n.update(e[t])},e),n},i.prototype.cancelAll=function(){this.listeners.length=0};var o=function(t){this.data=t?t.slice():[],this.onChange=new e},r={length:{configurable:!0}};r.length.get=function(){return this.data.length},o.prototype.getData=function(){return this.data.slice()},o.prototype.get=function(t){return this.data[t]},o.prototype.set=function(t,e){var n=this.data[t];n!==e&&(this.data[t]=e,this.onChange.fire({operation:"replace",target:n,count:1,index:t,items:[e],newState:this.data}))},o.prototype.push=function(){for(var t,e=[],n=arguments.length;n--;)e[n]=arguments[n];(t=this.data).push.apply(t,e),this.onChange.fire({operation:"append",count:e.length,index:this.data.length-e.length,items:e,newState:this.data})},o.prototype.unshift=function(){for(var t,e=[],n=arguments.length;n--;)e[n]=arguments[n];(t=this.data).unshift.apply(t,e),this.onChange.fire({operation:"prepend",count:e.length,items:e,index:0,newState:this.data})},o.prototype.pop=function(){var t=this.data.pop();return this.onChange.fire({operation:"removeRight",count:1,index:this.data.length,items:[t],newState:this.data}),t},o.prototype.merge=function(t){for(var e=0;e<t.length;e++)this.data[e]!==t[e]&&(this.length>e?this.set(e,t[e]):this.push(t[e]));this.length>t.length&&this.removeRight(this.length-t.length)},o.prototype.removeRight=function(t){var e=this.data.splice(this.length-t,t);this.onChange.fire({operation:"removeRight",count:t,index:this.length,items:e,newState:this.data})},o.prototype.removeLeft=function(t){var e=this.data.splice(0,t);this.onChange.fire({operation:"removeLeft",count:t,index:0,items:e,newState:this.data})},o.prototype.remove=function(t){var e=this.data.indexOf(t);-1!==e&&(this.data.splice(e,1),this.onChange.fire({operation:"remove",count:1,index:e,items:[t],newState:this.data}))},o.prototype.clear=function(){var t=this.data;this.data=[],this.onChange.fire({operation:"remove",count:t.length,index:0,items:t,newState:this.data})},o.prototype.shift=function(){var t=this.data.shift();return this.onChange.fire({operation:"removeLeft",items:[t],count:1,index:0,newState:this.data}),t},o.prototype.toArray=function(){return this.data.slice()},o.prototype.filter=function(t,e){return new a(this,t,e)},o.prototype.forEach=function(t,e){return this.data.forEach(t,e)},o.prototype.toDataSource=function(){var t=new i(this.data);return this.onChange.subscribe(function(e){t.update(e.newState)}),t},Object.defineProperties(o.prototype,r);var a=function(t){function e(e,n,i){var o=this,r=e.data.filter(n);t.call(this,r),this.parent=e,this.viewFilter=n,e.onChange.subscribe(function(t){var e,n,i;switch(t.operation){case"remove":case"removeLeft":case"removeRight":for(var r=0,a=t.items;r<a.length;r+=1)o.remove(a[r]);break;case"prepend":i=t.items.filter(o.viewFilter),(e=o).unshift.apply(e,i);break;case"append":i=t.items.filter(o.viewFilter),(n=o).push.apply(n,i);break;case"replace":var s=o.data.indexOf(t.target);if(-1!==s){o.viewFilter(t.items[0])?o.set(s,t.items[0]):o.remove(t.target);break}}},i)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.updateFilter=function(t){this.viewFilter!==t&&(this.viewFilter=t,this.refresh())},e.prototype.refresh=function(){var t;this.clear();var e=this.parent.data.filter(this.viewFilter);(t=this).push.apply(t,e)},e}(o),s=function(t){this.data=t};s.prototype.deleteNext=function(){if(this.next){var t=this.next.next;this.next.next=void 0,this.next.previous=void 0,this.next=t,this.next.previous=this}},s.prototype.deletePrevious=function(){this.previous&&(this.previous=this.previous.previous,this.previous.next=void 0,this.previous.previous=void 0)};var c=function(t){var e=this;void 0===t&&(t=[]),this.length=0,t.forEach(function(t){return e.append(t)})};c.prototype.find=function(t){for(var e=this.rootNode;e&&!t(e);)e=e.next;return e},c.prototype.append=function(t){return this.rootNode||this.lastNode?(this.lastNode.next=new s(t),this.lastNode.next.previous=this.lastNode,this.lastNode=this.lastNode.next):this.rootNode=this.lastNode=new s(t),this.length++,t},c.prototype.forEach=function(t){this.find(function(e){return t(e.data),!1})},c.prototype.prepend=function(t){return this.rootNode||this.lastNode?(this.rootNode.previous=new s(t),this.rootNode.previous.next=this.rootNode,this.rootNode=this.rootNode.previous):this.rootNode=this.lastNode=new s(t),this.length++,t},c.prototype.remove=function(t){if(t===this.rootNode.data)this.rootNode=this.rootNode.next,this.length--;else{var e=this.find(function(e){return e.next&&e.next.data===t});e&&(e.next===this.lastNode&&(this.lastNode=e),e.deleteNext(),this.length--)}};var l=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];this.cancelables=new c(t),this._isCancelled=!1},h={isCanceled:{configurable:!0}};h.isCanceled.get=function(){return this._isCancelled},l.prototype.addCancelable=function(t){return this.throwIfCancelled("attempting to add cancellable to token that is already cancelled"),this.cancelables.append(t),this.cancelables.length>200&&console.log("potential memory leak: cancellation token has over 200 clean up calls"),this},l.prototype.removeCancelable=function(t){return this.throwIfCancelled("attempting to remove cancellable from token that is already cancelled"),this.cancelables.remove(t),this},l.prototype.addDisposable=function(t){return this.addCancelable(function(){return t.dispose()}),this},l.prototype.callIfNotCancelled=function(t){this.isCanceled||t()},l.prototype.setTimeout=function(t,e){void 0===e&&(e=0);var n=setTimeout(t,e);this.addCancelable(function(){return clearTimeout(n)})},l.prototype.setInterval=function(t,e){var n=setInterval(t,e);this.addCancelable(function(){return clearInterval(n)})},l.prototype.requestAnimationFrame=function(t){var e=requestAnimationFrame(t);this.addCancelable(function(){return cancelAnimationFrame(e)})},l.prototype.animationLoop=function(t){var e=requestAnimationFrame(function n(i){t(i),e=requestAnimationFrame(n)});this.addCancelable(function(){return cancelAnimationFrame(e)})},l.prototype.throwIfCancelled=function(t){if(this.isCanceled)throw new Error(t||"cancellation token is cancelled")},l.prototype.chain=function(t,e){return void 0===e&&(e=!1),e&&t.chain(this,!1),this.addCancelable(function(){return t.cancel()}),this},l.prototype.registerDomEvent=function(t,e,n){return t.addEventListener(e,n),this.addCancelable(function(){return t.removeEventListener(e,n)}),this},l.prototype.cancel=function(){this.isCanceled||(this._isCancelled=!0,this.cancelables.forEach(function(t){return t()}),this.cancelables=void 0)},Object.defineProperties(l.prototype,h);var u=Symbol("owner"),p=function(t,e){this.domNodeName=e,this.template=t.template,this.cancellationToken=new l,this.node=this.create(t),this.initialize(t),t.onAttach&&t.onAttach(this)};p.prototype.initialize=function(t){this.node.owner=this,this.createEventHandlers(["blur","focus","click","dblclick","keydown","keyhit","keyup","mousedown, mouseup","mouseenter","mouseleave","mousewheel"],t),this.bindProps(["id","draggable","tabindex","style"],t),t.class&&this.handleClass(t.class),t.repeatModel&&(this.cachedChildren=[],this.handleRepeat(t.repeatModel))},p.prototype.bindProps=function(t,e){for(var n=0,i=t;n<i.length;n+=1){var o=i[n];e[o]&&this.assignStringSourceToAttribute(e[o],o)}},p.prototype.createEventHandlers=function(t,e){for(var n=this,o=function(){var t=a[r],o="on"+t[0].toUpperCase()+t.slice(1),s=void 0;Object.defineProperty(n,o,{get:function(){return s||(s=new i),s},set:function(){throw new Error(o+" is read only")}}),e[o]&&(e[o]instanceof i?n[o].listen(e[o].update.bind(e.onClick),n.cancellationToken):"function"==typeof e[o]&&n[o].listen(e[o],n.cancellationToken)),n.cancellationToken.registerDomEvent(n.node,t,function(t){return n[o].update(t)})},r=0,a=t;r<a.length;r+=1)o()},p.prototype.handleRepeat=function(t){var e,n=this;this.repeatData=t instanceof o?t:new o(t),this.repeatData.length&&((e=this.cachedChildren).push.apply(e,this.repeatData.toArray().map(function(t){return n.template.generate(t)})),this.renderRepeat()),this.repeatData.onChange.subscribe(function(t){var e,i;switch(t.operation){case"append":(e=n.cachedChildren).push.apply(e,t.items.map(function(t){return n.template.generate(t)}));break;case"removeLeft":n.cachedChildren.splice(0,t.count);break;case"removeRight":n.cachedChildren.splice(n.node.childElementCount-t.count,t.count);break;case"remove":n.cachedChildren.splice(t.index,t.count);break;default:n.cachedChildren.length=0,(i=n.cachedChildren).push.apply(i,n.repeatData.toArray().map(function(t){return n.template.generate(t)}))}n.renderRepeat()})},p.prototype.renderRepeat=function(){var t=this;this.rerenderPending||(setTimeout(function(){for(var e=0;e<t.cachedChildren.length;e++){if(t.node.childElementCount<=e){t.addChildren(t.cachedChildren.slice(e,t.cachedChildren.length));break}if(t.node.children[e].owner!==t.cachedChildren[e]){if(!t.cachedChildren.includes(t.node.children[e].owner)){t.node.children[e][u].remove(),e--;continue}var n=t.getChildIndex(t.cachedChildren[e].node);-1!==n?t.swapChildren(e,n):t.addChildAt(t.cachedChildren[e],e)}}for(;t.node.childElementCount>t.cachedChildren.length;)t.node[u].removeChild(t.node.lastChild[u]);t.rerenderPending=!1}),this.rerenderPending=!0)},p.prototype.assignStringSourceToAttribute=function(t,e){var n=this;"string"==typeof t?this.node[e]=t:(t.value&&(this.node[e]=t.value),t.unique(this.cancellationToken).listen(function(t){return n.node.id=t},this.cancellationToken))},p.prototype.handleClass=function(t){var e=this;if("string"==typeof t)this.node.className=t;else if(t instanceof i)t.value&&(Array.isArray(t.value)?(this.node.className=t.value.join(" "),t.unique(this.cancellationToken).listen(function(){e.node.className=t.value.join(" ")},this.cancellationToken)):(this.node.className=t.value,t.unique(this.cancellationToken).listen(function(){e.node.className=t.value},this.cancellationToken))),t.unique(this.cancellationToken).listen(function(t){return e.node.className=t},this.cancellationToken);else{var n=t.reduce(function(t,e){return"string"==typeof e?t+" "+e:e.value?t+" "+e.value:t},"");this.node.className=n;for(var o=0,r=t;o<r.length;o+=1){var a=r[o];a instanceof i&&a.unique(this.cancellationToken).listen(function(n){var i=t.reduce(function(t,e){return"string"==typeof e?t+" "+e:e.value?t+" "+e.value:t},"");e.node.className=i},this.cancellationToken)}}},p.prototype.create=function(t){var e=document.createElement(this.domNodeName);return e[u]=this,e},p.prototype.getChildIndex=function(t){for(var e=0,n=0,i=t.children;n<i.length;n+=1){if(i[n]===t)return e;e++}return-1},p.prototype.hasChild=function(t){for(var e=0,n=t.children;e<n.length;e+=1)if(n[e]===t)return!0;return!1},p.prototype.setInnerText=function(t){if(this.node.firstChild)throw new Error("Cannot combine text and child nodes into a single element");this.node.innerText=t},p.prototype.swapChildren=function(t,e){if(t!==e){var n=this.node.children[t],i=this.node.children[e];n.remove(),i.remove(),t<e?(this.addDomNodeAt(i,t),this.addDomNodeAt(n,e)):(this.addDomNodeAt(n,e),this.addDomNodeAt(i,t))}},p.prototype.addDomNodeAt=function(t,e){e>=this.node.childElementCount?this.node.appendChild(t):this.node.insertBefore(t,this.node.children[e])},p.prototype.remove=function(){this.hasParent()&&(this.node.parentElement.removeChild(this.node),this.dispose())},p.prototype.hasParent=function(){return!!this.node.parentElement},p.prototype.isConnected=function(){return this.node.isConnected},p.prototype.removeChild=function(t){t.dispose(),this.node.removeChild(t.node)},p.prototype.removeChildAt=function(t){var e=this.node.childNodes[t];if(e){var n=e[u];n.dispose(),this.node.removeChild(n.node)}},p.prototype.clearChildren=function(){for(;this.node.firstChild;)this.node.firstChild[u].dispose(),this.node.removeChild(this.node.firstChild)},p.prototype.addChild=function(t){if(!(t.node instanceof d))return this.node.appendChild(t.node)},p.prototype.addChildAt=function(t,e){if(!(t.node instanceof d))return this.addDomNodeAt(t.node,e)},p.prototype.addChildren=function(t){var e=this;if(0!==t.length){for(var n=[],o=0,r=t;o<r.length;o+=1){var a=r[o];a instanceof d||("string"==typeof a?n.push(a):a instanceof i?(n.push(a),this.setInnerText(a.value),a.listen(function(t){var o=n.reduce(function(t,e){var n;return t+(e instanceof i?(n=e.value,null!=n?n:"").toString():e)},"");e.setInnerText(o)},this.cancellationToken)):this.node.appendChild(a.node))}if(n.length){var s=n.reduce(function(t,e){var n;return t+(e instanceof i?(n=e.value,null!=n?n:"").toString():e)},"");this.setInnerText(s)}}},p.prototype.dispose=function(){this.cancellationToken.cancel()};var d=function(t){function e(e){t.call(this,e,"template"),this.ref=e.ref,this.generate=e.generator}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(p),f=function(){};f.attach=function(t,e){if(e[u])throw new Error("This node is already managed by aurum and cannot be used");e.appendChild(t.node),e[u]=t},f.detach=function(t){t[u]&&(t[u].dispose(),t[u]=void 0)},f.factory=function(t,e){for(var n,i=[],o=arguments.length-2;o-- >0;)i[o]=arguments[o+2];if("string"!=typeof t){for(var r,a,s=(n=[]).concat.apply(n,i).filter(function(t){return t}),c={},l=!1,h=0,u=s;h<u.length;h+=1){var p=u[h];"string"!=typeof p&&(p instanceof d&&(!p.ref||"default"===p.ref)&&(r=p),p.ref&&(c[p.ref]=p,l=!0))}return e=null!=e?e:{},r&&(e.template=r),l&&(e.templateMap=c),(a=t.prototype?new t(e||{}):t(e||{})).addChildren(s),a}};var v=function(t){function e(e){t.call(this,e,"button")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(p),b=function(t){function e(e){t.call(this,e,"div")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(p),y=function(t){function e(e){var n,i,o,r=this;t.call(this,e,"input"),e.inputValueSource?(this.node.value=null!=(i=null!=(n=e.initialValue)?n:e.inputValueSource.value)?i:"",e.inputValueSource.listen(function(t){return r.node.value=t},this.cancellationToken)):this.node.value=null!=(o=e.initialValue)?o:"",this.bindProps(["placeholder"],e),this.createEventHandlers(["input","change"],e)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(p),m=function(t){function e(e){t.call(this,e,"li")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(p),g=function(t){function e(e){t.call(this,e,"span")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(p),C=function(t){function e(e){t.call(this,e,"style")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(p),w=function(t){function e(e){t.call(this,e,"ul")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(p),k=function(t){function e(e){t.call(this,e,"p")}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(p),_=function(t){function e(e){t.call(this,e,"img"),this.bindProps(["src"],e)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(p),x=function(t){function e(e){t.call(this,e,"link"),this.bindProps(["href","rel"],e)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(p),N=function(t){function e(e){t.call(this,e,"canvas"),this.bindProps(["width","height"],e)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(p),S=function(t){function e(e){var n=this;t.call(this,e,"switch"),this.firstRender=!0,this.templateMap=e.templateMap,this.render(e.state.value),e.state.listen(function(t){n.render(t)},this.cancellationToken)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.render=function(t){var e;if(t!==this.lastValue||this.firstRender)if(this.lastValue=t,this.firstRender=!1,this.clearChildren(),null!=t){var n=null!=(e=this.templateMap[t.toString()])?e:this.template;if(n){var i=n.generate();this.addChild(i)}}else if(this.template){var o=this.template.generate();this.addChild(o)}},e}(p);t.ArrayDataSource=o,t.FilteredArrayView=a,t.DataSource=i,t.EventEmitter=e,t.CancellationToken=l,t.Aurum=f,t.AurumElement=p,t.Template=d,t.Button=v,t.Div=b,t.Input=y,t.Li=m,t.Span=g,t.Style=C,t.Ul=w,t.P=k,t.Img=_,t.Link=x,t.Canvas=N,t.Switch=S});
//# sourceMappingURL=aurumjs.umd.js.map

@@ -64,2 +64,4 @@ <p align="center">

Simple TODO app in aurum: https://codepen.io/cyberphoenix90/pen/LYYMwVr
Better examples, proper documentation and benchmarks will be added in the near future.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc