From b259ab88588742f25dbc36e30d32a4b6692bf24f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Asiel=20Guevara=20Casta=C3=B1eda?= Date: Wed, 24 Oct 2018 16:04:24 -0400 Subject: [PATCH 01/13] Fixed issue initializing element attributes --- src/generators/attributes.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/generators/attributes.ts b/src/generators/attributes.ts index 54a5511..916f9b5 100644 --- a/src/generators/attributes.ts +++ b/src/generators/attributes.ts @@ -6,7 +6,6 @@ import { BlockAreas, NodeElement } from '../utilities/classes'; import { genShow, genDirective, genValue, genName, genRefs } from './directives'; export function genSetAttrs(target: string, node: NodeElement, scope: string, areas: BlockAreas) { - let res = ''; sortAttrs(node.attributes).forEach(({ name, value }) => { let [attr] = name.split('.'); if (attr === '$show') { @@ -30,14 +29,13 @@ export function genSetAttrs(target: string, node: NodeElement, scope: string, ar } else if (attr[0] === '#') { genRefs(scope, areas, kebabToCamelCases(name.slice(1)), target); } else { - res += `_$sa(${target}, ['${attr}', ${value ? `'${value}'` : `''`}]);`; + areas.hydrate.push(`_$sa(${target}, ['${attr}', ${value ? `'${value}'` : `''`}]);`); } }); - return res; } function sortAttrs(attrs: Attribute[]) { let attrRegExp = /^[$@:#]/; - return attrs.sort((a, b) => attrRegExp.test(a.name) && !attrRegExp.test(b.name) ? -1 : - !attrRegExp.test(a.name) && attrRegExp.test(b.name) ? 1 : 0); + return attrs.sort((a, b) => attrRegExp.test(a.name) && !attrRegExp.test(b.name) ? 1 : + !attrRegExp.test(a.name) && attrRegExp.test(b.name) ? -1 : 0); } \ No newline at end of file From dd8bdf46f9c3aab07d8ec96ae346b95935e2558a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Asiel=20Guevara=20Casta=C3=B1eda?= Date: Wed, 24 Oct 2018 16:06:44 -0400 Subject: [PATCH 02/13] Changed to the a declaration --- src/generators/commons.ts | 5 +---- src/generators/components.ts | 5 +---- src/generators/directives.ts | 7 ++----- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/generators/commons.ts b/src/generators/commons.ts index e865a89..35cdc4c 100644 --- a/src/generators/commons.ts +++ b/src/generators/commons.ts @@ -84,10 +84,7 @@ export function genBlockAreas(node: NodeElement, areas: BlockAreas, scope: strin length = childNodes.length; } } - const attr = genSetAttrs(variable, node, scope, areas); - if (attr) { - areas.hydrate.push(attr); - } + genSetAttrs(variable, node, scope, areas); if (isTpl && areas.create.length === 0) { areas.variables.splice(areas.variables.indexOf(variable), 1); variable = ''; diff --git a/src/generators/components.ts b/src/generators/components.ts index 958c8d3..f70b851 100644 --- a/src/generators/components.ts +++ b/src/generators/components.ts @@ -133,10 +133,7 @@ export function genComponent(node: NodeElement, areas: BlockAreas, scope: string areas.unmount.push(`_$a(${slot}, ${el});`); } }); - const attr = genSetAttrs(slot, n, scope, areas); - if (attr) { - areas.hydrate.push(attr); - } + genSetAttrs(slot, n, scope, areas); areas.unmount.push(`if (${slotDec}) { _$a(${slotDec}, ${slot}); }`); diff --git a/src/generators/directives.ts b/src/generators/directives.ts index c761fbf..9ab98c6 100644 --- a/src/generators/directives.ts +++ b/src/generators/directives.ts @@ -72,11 +72,8 @@ export function genHtml(node: NodeElement, areas: BlockAreas, scope?: string) { } else { content = `${variable}.innerHTML = '${node.innerHTML}';`; } - const attr = genSetAttrs(variable, node, scope, areas); - if (attr) { - areas.hydrate.push(attr); - } - areas.create.push(content); + genSetAttrs(variable, node, scope, areas); + areas.create.push(`${variable}.innerHTML = ${content};`); return variable; } From 70ed67d02a1ad2b48cd5da307ed1dcd26fec4f3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Asiel=20Guevara=20Casta=C3=B1eda?= Date: Wed, 24 Oct 2018 16:08:17 -0400 Subject: [PATCH 03/13] Fixed missing spaces in adjacent interpolation expressions --- src/generators/commons.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/generators/commons.ts b/src/generators/commons.ts index 35cdc4c..d919a2c 100644 --- a/src/generators/commons.ts +++ b/src/generators/commons.ts @@ -20,15 +20,13 @@ export function genBlockAreas(node: NodeElement, areas: BlockAreas, scope: strin variable = getVarName(areas.variables, 'txt'); const setVariable = `set${capitalize(variable)}`; areas.variables.push(setVariable); - const codeFrag = node.textContent; - const intrps = codeFrag.split(/(\{\{\s*(?:(?!\}\})(?:.|\n))*\}\})/).filter(int => !!clearText(int).trim()); - const code = intrps.map(int => { + const code = node.textContent.split(/(\{\{\s*(?:(?!\}\})(?:.|\n))*\}\})/).map(int => { if (int.startsWith('{{') && int.endsWith('}}')) { int = int.replace(/\{\{(\s*((?!\}\})(.|\n))*)\}\}/g, (_, replacer: string) => replacer.trim()); return `(${ctx(filterParser(int), scope, areas.globals)})`; - } + } return `'${clearText(entities.decode(int))}'`; - }).join('+'); + }).join('+').replace(/^' '\+/, '').replace(/\+' '$/, ''); let params = areas.globals && areas.globals.length > 0 ? `, ${areas.globals.join(', ')}` : ''; const setTxt = `${setVariable}(${scope}${params})`; areas.extras.push(`${setVariable} = (${scope}${params}) => ${code};`); From 2fd7c87c09cfc26babaccf370a36e8621e436f0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Asiel=20Guevara=20Casta=C3=B1eda?= Date: Wed, 24 Oct 2018 16:13:12 -0400 Subject: [PATCH 04/13] Optimised generated update code --- src/generators/components.ts | 27 ++++++----------- src/generators/directives.ts | 34 +++++++++------------ src/index.ts | 7 +++-- tools/index.ts | 57 ++++++++++++++++++++++++++---------- 4 files changed, 69 insertions(+), 56 deletions(-) diff --git a/src/generators/components.ts b/src/generators/components.ts index f70b851..8470da8 100644 --- a/src/generators/components.ts +++ b/src/generators/components.ts @@ -80,6 +80,7 @@ export function genComponent(node: NodeElement, areas: BlockAreas, scope: string let init = `const `; let setComponent = `set${capitalize(variable)}`; let setAttrsComponent = `setAttrs${capitalize(variable)}`; + let setComponentCall = `${setComponent}(${isIsAttrExp ? [scope, ...params].join(', ') : ''})`; if (varName === 'component') { globCompName = capitalize(variable); areas.variables.push(setComponent, setAttrsComponent); @@ -88,7 +89,7 @@ export function genComponent(node: NodeElement, areas: BlockAreas, scope: string let comp = ${ctx(isValue, scope, areas.globals.concat(params))}; return _$isType(comp, 'string') ? children[comp] : comp; }` : `() => children['${isValue}']`};`); - init += `${globCompName} = ${setComponent}(${isIsAttrExp ? [scope, ...params].join(', ') : ''});`; + init += `${globCompName} = ${setComponentCall};`; areas.extras.push(`${init} ${anchor} = _$ct(); ${variable} = _$add(${scope}, ${globCompName}, ${setAttrsComponent}());`); @@ -141,23 +142,13 @@ export function genComponent(node: NodeElement, areas: BlockAreas, scope: string }); areas.unmount.push(`${variable}.$mount(${root || '_$frag'}, ${anchor});`); if (varName === 'component') { - let updateVar = `update${capitalize(variable)}`; - areas.update.push(`let ${updateVar} = ${setComponent}(${isIsAttrExp ? [scope, ...params].join(', ') : ''}); - if (${updateVar} === ${globCompName}) { - ${variable} && ${variable}.$update(); - } else { - ${globCompName} = ${updateVar}; - if (${variable}) { - ${variable}.$destroy(); - _$remove(${scope}, ${variable}); - } - if (${globCompName}) { - ${variable} = _$add(${scope}, ${globCompName}, ${setAttrsComponent}()); - ${variable}.$create(); - ${variable}.$mount(${root || `${scope}.$parentEl`}, ${anchor}); - } - } - ${updateVar} = void 0;`); + areas.update.push(`[${variable}, ${globCompName}] = _$pu(${scope}, + ${globCompName}, + ${variable}, + ${setComponentCall}, + ${setAttrsComponent}(), + ${root || `${scope}.$parentEl`}, + ${anchor});`); } else { areas.update.push(`${variable} && ${variable}.$update();`); } diff --git a/src/generators/directives.ts b/src/generators/directives.ts index 9ab98c6..2ac89dc 100644 --- a/src/generators/directives.ts +++ b/src/generators/directives.ts @@ -11,7 +11,8 @@ export function genValue(target: string, node: NodeElement, areas: BlockAreas, s const isMultiSelect = /select/.test(node.tagName) && node.hasAttribute('multiple'); if (/input|select|textarea/.test(node.tagName) && !/checkbox|radio/.test(type)) { const event = /date|file/.test(type) || node.tagName === 'select' ? 'change' : 'input'; - const expression = isMultiSelect ? `_$updateMultiSelect(${target}, ${scope}, '${value}')` : `${value} = ${/number|range/.test(type) ? '+' : ''}$el.value`; + const expression = isMultiSelect ? `_$updateMultiSelect(${target}, ${scope}, '${value}')` : + `${value} = ${/number|range/.test(type) ? '+' : ''}$el.value`; genEvent(target, event, expression, areas, scope); genBind(target, 'value', value, areas, scope, isMultiSelect ? 'multiple' : type, null); } else if (node.tagName === 'input' && /checkbox|radio/.test(type)) { @@ -46,7 +47,7 @@ export function genShow(target: string, node: NodeElement, areas: BlockAreas, sc [scope] = scope.split(', '); let params = areas.globals && areas.globals.length > 0 ? `, ${areas.globals.join(', ')}` : ''; const expression = ctx(node.getAttribute('$show'), scope, areas.globals); - areas.extras.push(`const ${funcName} = function (${scope}${params}, el, display) { + areas.extras.push(`const ${funcName} = (${scope}${params}, el, display) => { el.style.display = ${expression} ? display : 'none'; };`); areas.hydrate.push(`${varDisplay} = ${target}.style.display; @@ -62,15 +63,11 @@ export function genHtml(node: NodeElement, areas: BlockAreas, scope?: string) { let content = ''; if (html) { const setContent = getVarName(areas.variables, `content${capitalize(variable)}`); + content = `${setContent}(${scope})`; areas.extras.push(`${setContent} = (${scope}) => ${ctx(html, scope.split(', ')[0], areas.globals)};`); - areas.update.push(`let update${capitalize(setContent)} = ${setContent}(${scope}); - if (${variable}.innerHTML !== update${capitalize(setContent)}) { - ${variable}.innerHTML = update${capitalize(setContent)}; - } - update${capitalize(setContent)} = void 0;`); - content = `${variable}.innerHTML = ${setContent}(${scope});`; + areas.update.push(`_$hu(${variable}, ${content});`); } else { - content = `${variable}.innerHTML = '${node.innerHTML}';`; + content = `'${node.innerHTML}'`; } genSetAttrs(variable, node, scope, areas); areas.create.push(`${variable}.innerHTML = ${content};`); @@ -78,17 +75,14 @@ export function genHtml(node: NodeElement, areas: BlockAreas, scope?: string) { } export function genRefs(scope: string, areas: BlockAreas, value: string, target: string) { - const [env] = scope.split(', '); - areas.variables.push('_refs'); - areas.extras.push(`_refs = ${env}.$refs;`); - areas.create.push(`!_refs['${value}'] && _$setRef(_refs, '${value}'); - _refs['${value}'] = ${target};`); - areas.destroy.push(`if (_$isType(_refs['${value}'], 'array')) { - const index${capitalize(target)} = _refs['${value}'].indexOf(${target}); - _refs['${value}'].splice(index${capitalize(target)}, 1); - } else { - delete _refs['${value}']; - }`); + [scope] = scope.split(', '); + const init = `_refs = ${scope}.$refs;`; + if (!areas.extras.includes(init)) { + areas.variables.push('_refs'); + areas.extras.push(`_refs = ${scope}.$refs;`); + } + areas.create.push(`_$setRef(_refs, '${value}', ${target});`); + areas.destroy.push(`_$rr(_refs, '${value}', ${target});`); } export function genDirective(target: string, attr: string, value: string, areas: BlockAreas, scope: string) { diff --git a/src/index.ts b/src/index.ts index 4814cbd..8012a9a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,9 +9,10 @@ import { basename, extname, dirname, join } from 'path'; import { genTemplate, CompilerOptions } from './generators'; import { kebabToCamelCases, capitalize, camelToKebabCase } from './utilities/tools'; -const dest = `{ _$CompCtr, _$, _$d, _$a, _$add, _$remove, _$as, _$r, _$ce, _$cse, _$ct, _$bu, _$tu, _$nu, - _$cm, _$sa, _$ga, _$al, _$ul, _$rl, _$bc, _$bs, _$f, _$e, _$is, _$ds, _$toStr, _$bindMultiSelect, _$gv, - _$setRef, _$noop, _$isType, _$isKey, _$bindGroup, _$cu, _$bba, _$emptyElse, _$extends, _$updateMultiSelect }`; +const dest = `{ _$CompCtr, _$, _$d, _$a, _$add, _$remove, _$as, _$r, _$ce, _$cse, _$ct, + _$bu, _$tu, _$nu, _$rr, _$hu, _$pu, _$cm, _$sa, _$ga, _$al, _$ul, _$rl, _$bc, _$bs, _$f, + _$e, _$is, _$ds, _$toStr, _$bindMultiSelect, _$gv, _$setRef, _$noop, _$isType, _$isKey, + _$bindGroup, _$cu, _$bba, _$emptyElse, _$extends, _$updateMultiSelect }`; const esDeps = `import ${dest} from 'trebor/tools';`; const cjsDeps = `const ${dest} = require('trebor/tools');`; const tools = readFileSync(join(__dirname, '../tools/index.js'), 'utf8'); diff --git a/tools/index.ts b/tools/index.ts index 764c11f..848244d 100644 --- a/tools/index.ts +++ b/tools/index.ts @@ -410,13 +410,16 @@ function _$toPlainObj(obj: Component) { }); return _$isObject(obj) ? data : obj; } -export function _$setRef(obj: Object, prop: string) { - const value = []; - _$def(obj, prop, { - get: () => value.length <= 1 ? value[0] : value, - set: val => { val && !~value.indexOf(val) && value.push(val); }, - enumerable: true, configurable: true - }); +export function _$setRef(refs: Object, prop: string, node: HTMLElement) { + if (!_$hasProp(refs, prop)) { + const value = []; + _$def(refs, prop, { + get: () => value.length <= 1 ? value[0] : value, + set: val => { val && !~value.indexOf(val) && value.push(val); }, + enumerable: true, configurable: true + }); + } + refs[prop] = node; } function _$accesor(object: Component, path: string, value?: any) { return path.split('.').reduce((obj, key, i, arr) => { @@ -567,16 +570,16 @@ export function _$cu(block: { type: string } & ComponentTemplate, condition: Fun } return block; } -export function _$bba(el: Element, attrAndValue: [string, any]) { +export function _$bba(el: HTMLElement, attrAndValue: [string, any]) { let [attr, value, hasAttr] = attrAndValue.concat([el.hasAttribute(attrAndValue[0])]); value == null || value === false ? hasAttr && el.removeAttribute(attr) : _$sa(el, [attr, '']); } export function _$bu(el: (HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement) & { _value: any }, binding: [string, any]) { let [attr, value] = binding; - let _value: string | boolean = attr === 'checked' ? !!value : _$toStr(value); - if (/value|checked/.test(attr)) { - if (el[attr] !== _value) el[attr] = _$isValueAttr(attr) ? _value : value; - el[PROP_MAP._] = _$isValueAttr(attr) ? value : el[PROP_MAP.v]; + let _value: string = _$toStr(value); + if (_$isValueAttr(attr)) { + if (el[attr] !== _value) el[attr] = _value; + el[PROP_MAP._] = value; } else if (_$ga(el, attr) !== _value) { _$sa(el, [attr, _value]); } @@ -587,6 +590,30 @@ export function _$tu(text: Text, value: string) { export function _$nu(node: HTMLElement, tag: T) { return tag.toUpperCase() !== node.tagName ? _$as(node, _$ce(tag)) : node; } +export function _$rr(refs: Object, prop: string, node: HTMLElement) { + let nodes = refs[prop]; + _$isArray(nodes) ? refs[prop].splice(nodes.indexOf(node), 1) : (delete refs[prop]); +} +export function _$hu(node: HTMLElement, value: string) { + if (node.innerHTML !== (value = _$toStr(value))) node.innerHTML = value; +} +export function _$pu(parent: Component, Ctor: ComponentConstructor, inst: Component, value: ComponentConstructor, attrs: AttrParams, el: HTMLElement, sibling: HTMLElement) { + if (value === Ctor) { + inst && inst.$update(); + } else { + Ctor = value; + if (inst) { + inst.$destroy(); + _$remove(parent, inst); + } + if (inst) { + inst = _$add(parent, Ctor, attrs); + inst.$create(); + inst.$mount(el, sibling); + } + } + return [inst, Ctor]; +} export function _$f(root: Component, obj: any[], loop: (...args: any[]) => ComponentTemplate) { let items: ObjectLike = {}, loopParent: Element, loopSibling: Element; let globs = _$toArgs(arguments, 3); @@ -637,7 +664,7 @@ export function _$is(id: string, css: string) { isNew = true; style = _$ce('style'); style.id = id; - _$sa(style, ['refs', '1']); + _$sa(style, ['refs', 1]); } if (style.textContent !== css) { style.textContent = css; @@ -646,7 +673,7 @@ export function _$is(id: string, css: string) { _$a(document.head, style); } else { let count = +_$ga(style, 'refs'); - _$sa(style, ['refs', _$toStr(++count)]); + _$sa(style, ['refs', ++count]); } } export function _$ds(id: string) { @@ -656,7 +683,7 @@ export function _$ds(id: string) { if (--count === 0) { _$r(style, document.head); } else { - _$sa(style, ['refs', _$toStr(count)]); + _$sa(style, ['refs', count]); } } } From cd54a6c1a23d7d5455cae7cf234338d91e1c588f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Asiel=20Guevara=20Casta=C3=B1eda?= Date: Wed, 24 Oct 2018 16:15:24 -0400 Subject: [PATCH 05/13] Added ability to get the iteration index when iterate over obejcts --- src/generators/loops.ts | 28 ++++++++++++++++++---------- tools/index.ts | 19 ++++++++++--------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/generators/loops.ts b/src/generators/loops.ts index f3e280e..9bc1b52 100644 --- a/src/generators/loops.ts +++ b/src/generators/loops.ts @@ -10,16 +10,15 @@ export function genForItem(node: NodeElement, areas: BlockAreas, scope: string) const value = node.getAttribute('$for'); node.removeAttribute('$for'); const parent = node.parentElement; - let root = parent.dymTag ? parent.dymTag : parent.varName; + let root = parent.dymTag ? parent.dymTag : parent.varName; const anchor = getVarName(areas.variables, `loopAnchor_${areas.loops}`); areas.unmount.push(`_$a(${root || '_$frag'}, ${anchor});`); const loopBlock = `loopBlock_${areas.loops}`; let [vars, variable] = value.split(' in '); - const [key, val] = vars.split(',').map(v => v.replace(/[()]/g, '').trim()); + const [key, val, index] = vars.split(',').map(v => v.replace(/[()]/g, '').trim()); let [asNumber, ...rest] = variable.split('\|'); let [start, end] = asNumber.split('..'); let globs = `${params.length ? `, ${params.join(', ')}` : ''}`; - let fglobs = `${params.length ? `, ${params.filter(p => p !== '_$index').join(', ')}` : ''}`; if (!isNaN(+start)) { let length = (+end || 0) - (+start); let array = [...Array(length > 0 ? length : -length)].map((_, i) => end ? i + (+start) : i); @@ -27,24 +26,33 @@ export function genForItem(node: NodeElement, areas: BlockAreas, scope: string) } variable = ctx(filterParser(variable), scope, areas.globals.concat(params)); areas.variables.push(loopBlock); - areas.extras.push(`${loopBlock} = _$f(${scope}, ${variable}, itemLoop_${areas.loops}${fglobs}); + areas.extras.push(`${loopBlock} = _$f(${scope}, ${variable}, itemLoop_${areas.loops}${globs}); ${anchor} = _$ct();`); - areas.outer.push(genLoopItem(`${scope}${globs}`, node, key, val, areas)); + areas.outer.push(genLoopItem(`${scope}${globs}`, node, key, val, index, areas)); areas.create.push(`${loopBlock}.$create();`); areas.unmount.push(`${loopBlock}.$mount(${root || '_$frag'}, ${anchor});`); - areas.update.push(`${loopBlock}.$update(${scope}, ${variable}${fglobs});`); + areas.update.push(`${loopBlock}.$update(${scope}, ${variable}${globs});`); areas.destroy.push(`${loopBlock}.$destroy();`); } -function genLoopItem(scope: string, node: NodeElement, variable: string, index: string, areas: BlockAreas) { +function genLoopItem(scope: string, node: NodeElement, variable: string, value: string, index: string, areas: BlockAreas) { const subareas: BlockAreas = new BlockAreas(areas.loops, areas.conditions); const loop = `itemLoop_${areas.loops}`; let params: string[] = []; [scope, ...params] = scope.split(', '); - subareas.globals.push(variable); - index && subareas.globals.push(index); + let parameters: Set = new Set([scope]); + subareas.globals.push(variable); + parameters.add(variable); + if (value) { + parameters.add(value); + subareas.globals.push(value); + } + if (index) { + parameters.add(index); + subareas.globals.push(index); + } subareas.globals.push(...params); - scope = [...new Set([scope, variable, index || '_$index', ...params])].join(', '); + scope = [...parameters, ...params].join(', '); const tag = node.tagName; if (tag === 'template') { node.appendChild(node.content); diff --git a/tools/index.ts b/tools/index.ts index 848244d..0e2b6f5 100644 --- a/tools/index.ts +++ b/tools/index.ts @@ -617,7 +617,7 @@ export function _$pu(parent: Component, Ctor: ComponentConstructor, inst: Compon export function _$f(root: Component, obj: any[], loop: (...args: any[]) => ComponentTemplate) { let items: ObjectLike = {}, loopParent: Element, loopSibling: Element; let globs = _$toArgs(arguments, 3); - _$e(obj, (item, i) => { items[i] = loop.apply(null, [root, item, i].concat(globs)); }); + _$e(obj, (item, i, index) => { items[i] = loop.apply(null, [root, item, i, index].concat(globs)); }); return { $create() { _$e(items, item => { item.$create(); }); @@ -629,17 +629,17 @@ export function _$f(root: Component, obj: any[], loop: (...args: any[]) => Compo }, $update(root: Component, obj: any[]) { let globs = _$toArgs(arguments, 2); - _$e(items, (item, i) => { + _$e(items, (item, i, index) => { if (obj[i]) { - item.$update.apply(item, [root, obj[i], i].concat(globs)); + item.$update.apply(item, [root, obj[i], i, index].concat(globs)); } else { item.$destroy(); delete items[i]; } }); - _$e(obj, (item, i) => { + _$e(obj, (item, i, index) => { if (!items[i]) { - items[i] = loop.apply(null, [root, item, i].concat(globs)); + items[i] = loop.apply(null, [root, item, i, index].concat(globs)); items[i].$create(); items[i].$mount(loopParent, loopSibling); } @@ -650,10 +650,11 @@ export function _$f(root: Component, obj: any[], loop: (...args: any[]) => Compo } }; } -export function _$e(obj: T, cb: (value: IterateValue, key: IterateKey) => void) { - for (const key in obj) { - if (_$hasProp(obj, key)) { - cb(obj[key], (isNaN(+key) ? key : +key)); +export function _$e(obj: T, cb: (value: IterateValue, key: IterateKey, index?: number) => void) { + let i = 0; + for (const key in obj) { + if (_$hasProp(obj, key)) { + cb(obj[key], (isNaN(+key) ? key : +key), i++); } } } From 05996ae2bc77cf32d25fb62fcf6274e2efed9e22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Asiel=20Guevara=20Casta=C3=B1eda?= Date: Wed, 24 Oct 2018 16:20:50 -0400 Subject: [PATCH 06/13] Changed test to work with PhantomJS --- .gitignore | 5 +- package-lock.json | 564 ++++--------- package.json | 11 +- spec/basic usage/initialize.spec.js | 69 -- spec/components/bind.umd.js | 644 -------------- spec/components/condition.umd.js | 677 --------------- spec/components/html.umd.js | 580 ------------- spec/components/init.umd.js | 516 ------------ spec/components/loop.umd.js | 786 ------------------ spec/helpers/setup.js | 19 - spec/special attributes/bind_value.spec.js | 45 - spec/special attributes/condition.spec.js | 35 - spec/special attributes/html.spec.js | 29 - spec/special attributes/loop.spec.js | 55 -- spec/support/jasmine.json | 11 - specs/components/readme.txt | 1 + test/basic usage/init.html | 9 - test/components/bind.html | 29 + .../components/condition.html | 0 .../components/html.html | 0 test/{basic usage => }/components/init.html | 0 test/components/interpolation.html | 13 + test/components/loop.html | 58 ++ test/helpers/setup.ts | 21 - test/special attributes/bind_value.spec.ts | 51 -- test/special attributes/components/bind.html | 18 - test/special attributes/components/loop.html | 28 - test/special attributes/loop.spec.ts | 61 -- test/src/helpers/config.ts | 2 + test/src/helpers/setup.ts | 41 + test/src/run.ts | 98 +++ test/src/spec/bind_value.spec.ts | 107 +++ .../spec}/condition.spec.ts | 22 +- .../spec}/html.spec.ts | 12 +- .../spec}/initialize.spec.ts | 33 +- test/src/spec/interpolation.spec.ts | 23 + test/src/spec/loop.spec.ts | 114 +++ test/{ => src}/tsconfig.json | 8 +- test/src/types.d.ts | 49 ++ 39 files changed, 725 insertions(+), 4119 deletions(-) delete mode 100644 spec/basic usage/initialize.spec.js delete mode 100644 spec/components/bind.umd.js delete mode 100644 spec/components/condition.umd.js delete mode 100644 spec/components/html.umd.js delete mode 100644 spec/components/init.umd.js delete mode 100644 spec/components/loop.umd.js delete mode 100644 spec/helpers/setup.js delete mode 100644 spec/special attributes/bind_value.spec.js delete mode 100644 spec/special attributes/condition.spec.js delete mode 100644 spec/special attributes/html.spec.js delete mode 100644 spec/special attributes/loop.spec.js delete mode 100644 spec/support/jasmine.json create mode 100644 specs/components/readme.txt delete mode 100644 test/basic usage/init.html create mode 100644 test/components/bind.html rename test/{special attributes => }/components/condition.html (100%) rename test/{special attributes => }/components/html.html (100%) rename test/{basic usage => }/components/init.html (100%) create mode 100644 test/components/interpolation.html create mode 100644 test/components/loop.html delete mode 100644 test/helpers/setup.ts delete mode 100644 test/special attributes/bind_value.spec.ts delete mode 100644 test/special attributes/components/bind.html delete mode 100644 test/special attributes/components/loop.html delete mode 100644 test/special attributes/loop.spec.ts create mode 100644 test/src/helpers/config.ts create mode 100644 test/src/helpers/setup.ts create mode 100644 test/src/run.ts create mode 100644 test/src/spec/bind_value.spec.ts rename test/{special attributes => src/spec}/condition.spec.ts (65%) rename test/{special attributes => src/spec}/html.spec.ts (89%) rename test/{basic usage => src/spec}/initialize.spec.ts (75%) create mode 100644 test/src/spec/interpolation.spec.ts create mode 100644 test/src/spec/loop.spec.ts rename test/{ => src}/tsconfig.json (90%) create mode 100644 test/src/types.d.ts diff --git a/.gitignore b/.gitignore index 27c7774..504ae45 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ # Dependency directories node_modules/ - +specs/* +!specs/components +specs/components/* +!specs/components/readme.txt build/ tools/*.js tools/*.map diff --git a/package-lock.json b/package-lock.json index cc5a254..24fe862 100644 --- a/package-lock.json +++ b/package-lock.json @@ -80,26 +80,6 @@ "integrity": "sha512-OJSUxLaxXsjjhob2DBzqzgrkLmukM3+JMpRp0r0E4HTdT1nwDCWhaswjYxazPij6uOdzHCJfNbDjmQ1/rnNbCg==", "dev": true }, - "@types/jsdom": { - "version": "11.0.6", - "resolved": "https://registry.npmjs.org/@types/jsdom/-/jsdom-11.0.6.tgz", - "integrity": "sha512-6sw9iNdXak3Dk4iN1osdZeZcV8cTe2SNIVwbnt8MjFFAI8+nBWDNcDfjUgZZqycF3Twlr7xXlKntnOrruxNRvg==", - "dev": true, - "requires": { - "@types/events": "*", - "@types/node": "*", - "@types/tough-cookie": "*", - "parse5": "^4.0.0" - }, - "dependencies": { - "parse5": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-4.0.0.tgz", - "integrity": "sha512-VrZ7eOd3T1Fk4XWNXMgiGBK/z0MG48BWG2uQNU4I72fkQuKUTZpl+u9k+CxEG0twMVzSmXEEz12z5Fnw1jIQFA==", - "dev": true - } - } - }, "@types/json-schema": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.0.tgz", @@ -124,12 +104,6 @@ "integrity": "sha512-J5D3z703XTDIGQFYXsnU9uRCW9e9mMEFO0Kpe6kykyiboqziru/RlZ0hM2P+PKTG4NHG1SjLrqae/NrV2iJApQ==", "dev": true }, - "@types/tough-cookie": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-2.3.3.tgz", - "integrity": "sha512-MDQLxNFRLasqS4UlkWMSACMKeSm1x4Q3TxzUC7KQUsh6RK1ZrQ0VEyE3yzXcBu+K8ejVj4wuX32eUG02yNp+YQ==", - "dev": true - }, "@types/uglify-js": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/uglify-js/-/uglify-js-3.0.3.tgz", @@ -406,12 +380,6 @@ "long": "^3.2.0" } }, - "abab": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.0.tgz", - "integrity": "sha512-sY5AXXVZv4Y1VACTtR11UJCPHHudgY5i26Qj5TypE6DKlIApbwb5uqhXcJ5UUGbvZNRh7EeIoW+LrJumBsKp7w==", - "dev": true - }, "acorn": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.3.0.tgz", @@ -426,15 +394,6 @@ "acorn": "^5.0.0" } }, - "acorn-globals": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-4.1.0.tgz", - "integrity": "sha512-KjZwU26uG3u6eZcfGbTULzFcsoz6pegNKtHPksZPOUsiKo5bUmiBPa38FuHZ/Eun+XYh/JCCkS9AS3Lu4McQOQ==", - "dev": true, - "requires": { - "acorn": "^5.0.0" - } - }, "acorn-jsx": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-4.1.1.tgz", @@ -505,12 +464,6 @@ "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", "dev": true }, - "array-equal": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/array-equal/-/array-equal-1.0.0.tgz", - "integrity": "sha1-jCpe8kcv2ep0KwTHenUJO6J1fJM=", - "dev": true - }, "array-unique": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", @@ -586,12 +539,6 @@ "integrity": "sha1-GdOGodntxufByF04iu28xW0zYC0=", "dev": true }, - "async-limiter": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", - "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==", - "dev": true - }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -742,12 +689,6 @@ "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=", "dev": true }, - "browser-process-hrtime": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-0.1.2.tgz", - "integrity": "sha1-Ql1opY00R/AqBKqJQYf86K+Le44=", - "dev": true - }, "browserify-aes": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", @@ -1342,21 +1283,6 @@ "integrity": "sha1-lGfQMsOM+u+58teVASUwYvh/ob0=", "dev": true }, - "cssom": { - "version": "0.3.4", - "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.4.tgz", - "integrity": "sha512-+7prCSORpXNeR4/fUP3rL+TzqtiFfhMvTd7uEqMdgPvLPt4+uzFUeufx5RHjGTACCargg/DiEt/moMQmvnfkog==", - "dev": true - }, - "cssstyle": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-1.1.1.tgz", - "integrity": "sha512-364AI1l/M5TYcFH83JnOH/pSqgaNnKmYgKrm0didZMGKWjQB60dymwWy1rKUgL3J1ffdq9xVi2yGLHdSjjSNog==", - "dev": true, - "requires": { - "cssom": "0.3.x" - } - }, "cyclist": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/cyclist/-/cyclist-0.2.2.tgz", @@ -1372,17 +1298,6 @@ "assert-plus": "^1.0.0" } }, - "data-urls": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-1.0.1.tgz", - "integrity": "sha512-0HdcMZzK6ubMUnsMmQmG0AcLQPvbvb47R0+7CCZQCYgcd8OUWG91CG7sM6GoXgjz+WLl4ArFzHtBMy/QqSF4eg==", - "dev": true, - "requires": { - "abab": "^2.0.0", - "whatwg-mimetype": "^2.1.0", - "whatwg-url": "^7.0.0" - } - }, "date-now": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", @@ -1412,12 +1327,6 @@ "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", "dev": true }, - "deep-is": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", - "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", - "dev": true - }, "define-properties": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.2.tgz", @@ -1520,15 +1429,6 @@ "integrity": "sha1-sXrtguirWeUt2cGbF1bg/BhyBMI=", "dev": true }, - "domexception": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/domexception/-/domexception-1.0.1.tgz", - "integrity": "sha512-raigMkn7CJNNo6Ihro1fzG7wr3fHuYVytzquZKX5n0yizGsTcYgzdIUwj1X9pK0VvjeihV+XiclP+DjwbsSKug==", - "dev": true, - "requires": { - "webidl-conversions": "^4.0.2" - } - }, "domhandler": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.1.0.tgz", @@ -1650,68 +1550,18 @@ "is-symbol": "^1.0.1" } }, + "es6-promise": { + "version": "4.2.5", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.5.tgz", + "integrity": "sha512-n6wvpdE43VFtJq+lUDYDBFUwV8TZbuGXLV4D6wKafg13ldznKsyEvatubnmUe31zcvelSzOHF+XbaT+Bl9ObDg==", + "dev": true + }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, - "escodegen": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.11.0.tgz", - "integrity": "sha512-IeMV45ReixHS53K/OmfKAIztN/igDHzTJUhZM3k1jMhIZWjk45SMwAtBsEXiJp3vSPmTcu6CXn7mDvFHRN66fw==", - "dev": true, - "requires": { - "esprima": "^3.1.3", - "estraverse": "^4.2.0", - "esutils": "^2.0.2", - "optionator": "^0.8.1", - "source-map": "~0.6.1" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "optional": true - } - } - }, - "eslint-plugin-html": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/eslint-plugin-html/-/eslint-plugin-html-4.0.5.tgz", - "integrity": "sha512-yULqYldzhYXTwZEaJXM30HhfgJdtTzuVH3LeoANybESHZ5+2ztLD72BsB2wR124/kk/PvQqZofDFSdNIk+kykw==", - "dev": true, - "requires": { - "htmlparser2": "^3.8.2" - }, - "dependencies": { - "domhandler": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.4.2.tgz", - "integrity": "sha512-JiK04h0Ht5u/80fdLMCEmV4zkNh2BcoMFBmZ/91WtYZ8qVXSKjiw7fXMgFPnHcSZgOo3XdinHvmnDUeMf5R4wA==", - "dev": true, - "requires": { - "domelementtype": "1" - } - }, - "htmlparser2": { - "version": "3.9.2", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.9.2.tgz", - "integrity": "sha1-G9+HrMoPP55T+k/M6w9LTLsAszg=", - "dev": true, - "requires": { - "domelementtype": "^1.3.0", - "domhandler": "^2.3.0", - "domutils": "^1.5.1", - "entities": "^1.1.1", - "inherits": "^2.0.1", - "readable-stream": "^2.0.2" - } - } - } - }, "eslint-scope": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.0.tgz", @@ -1737,12 +1587,6 @@ } } }, - "esprima": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-3.1.3.tgz", - "integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=", - "dev": true - }, "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", @@ -1761,12 +1605,6 @@ "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.5.2.tgz", "integrity": "sha512-XpCnW/AE10ws/kDAs37cngSkvgIR8aN3G0MS85m7dUpuK2EREo9VJ00uvw6Dg/hXEpfsE1I1TvJOJr+Z+TL+ig==" }, - "esutils": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", - "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", - "dev": true - }, "events": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", @@ -2002,6 +1840,18 @@ } } }, + "extract-zip": { + "version": "1.6.7", + "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.7.tgz", + "integrity": "sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k=", + "dev": true, + "requires": { + "concat-stream": "1.6.2", + "debug": "2.6.9", + "mkdirp": "0.5.1", + "yauzl": "2.4.1" + } + }, "extsprintf": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", @@ -2020,11 +1870,14 @@ "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", "dev": true }, - "fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", - "dev": true + "fd-slicer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz", + "integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=", + "dev": true, + "requires": { + "pend": "~1.2.0" + } }, "figures": { "version": "2.0.0", @@ -2147,6 +2000,17 @@ "readable-stream": "^2.0.0" } }, + "fs-extra": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-1.0.0.tgz", + "integrity": "sha1-zTzl9+fLYUWIP8rjGR6Yd/hYeVA=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^2.1.0", + "klaw": "^1.0.0" + } + }, "fs-write-stream-atomic": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.10.tgz", @@ -2205,14 +2069,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2227,20 +2089,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -2357,8 +2216,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -2370,7 +2228,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2385,7 +2242,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2393,14 +2249,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -2419,7 +2273,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -2500,8 +2353,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -2513,7 +2365,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -2635,7 +2486,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -2958,6 +2808,16 @@ "minimalistic-assert": "^1.0.1" } }, + "hasha": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/hasha/-/hasha-2.2.0.tgz", + "integrity": "sha1-eNfL/B5tZjA/55g3NlmEUXsvbuE=", + "dev": true, + "requires": { + "is-stream": "^1.0.1", + "pinkie-promise": "^2.0.0" + } + }, "he": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", @@ -2975,15 +2835,6 @@ "minimalistic-crypto-utils": "^1.0.1" } }, - "html-encoding-sniffer": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-1.0.2.tgz", - "integrity": "sha512-71lZziiDnsuabfdYiUeWdCVyKuqwWi23L8YeIgV9jSSZHCtb6wB1BKWooH7L3tn4/FuZJMVWyNaIDr4RGmaSYw==", - "dev": true, - "requires": { - "whatwg-encoding": "^1.0.1" - } - }, "html-entities": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-1.2.1.tgz", @@ -3431,47 +3282,6 @@ "dev": true, "optional": true }, - "jsdom": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-12.0.0.tgz", - "integrity": "sha512-42RgZYXWwyClG0pN6Au7TExAQqRvzbtJhlcIvu58cJj4yr1bIbqZkgxHqn1btxKu80axZXPZLvldeTzg2auKow==", - "dev": true, - "requires": { - "abab": "^2.0.0", - "acorn": "^5.7.1", - "acorn-globals": "^4.1.0", - "array-equal": "^1.0.0", - "cssom": ">= 0.3.2 < 0.4.0", - "cssstyle": "^1.0.0", - "data-urls": "^1.0.1", - "domexception": "^1.0.1", - "escodegen": "^1.11.0", - "html-encoding-sniffer": "^1.0.2", - "nwsapi": "^2.0.8", - "parse5": "5.1.0", - "pn": "^1.1.0", - "request": "^2.88.0", - "request-promise-native": "^1.0.5", - "sax": "^1.2.4", - "symbol-tree": "^3.2.2", - "tough-cookie": "^2.4.3", - "w3c-hr-time": "^1.0.1", - "webidl-conversions": "^4.0.2", - "whatwg-encoding": "^1.0.4", - "whatwg-mimetype": "^2.1.0", - "whatwg-url": "^7.0.0", - "ws": "^6.0.0", - "xml-name-validator": "^3.0.0" - }, - "dependencies": { - "acorn": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.1.tgz", - "integrity": "sha512-d+nbxBUGKg7Arpsvbnlq61mc12ek3EY8EQldM3GPAhWJ1UVxC6TDGbIvUMNU6obBX3i1+ptCIzV4vq0gFPEGVQ==", - "dev": true - } - } - }, "json-parse-better-errors": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", @@ -3501,6 +3311,15 @@ "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=" }, + "jsonfile": { + "version": "2.4.0", + "resolved": "http://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", + "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6" + } + }, "jsprim": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", @@ -3513,10 +3332,10 @@ "verror": "1.10.0" } }, - "keysim": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/keysim/-/keysim-2.1.0.tgz", - "integrity": "sha512-QLrBscwDtm+xL4RXY1PIuaq7UJhZaSx0cp0pzl+vlMnQ+8tHCg4FqFi7vsfkaWeaOMs7iCKWaGXXnMe1Q92oVA==", + "kew": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/kew/-/kew-0.7.0.tgz", + "integrity": "sha1-edk9LTM2PW/dKXCzNdkUGtWR15s=", "dev": true }, "kind-of": { @@ -3527,6 +3346,15 @@ "is-buffer": "^1.1.5" } }, + "klaw": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz", + "integrity": "sha1-QIhDO0azsbolnXh4XY6W9zugJDk=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.9" + } + }, "lcid": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", @@ -3535,16 +3363,6 @@ "invert-kv": "^1.0.0" } }, - "levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", - "dev": true, - "requires": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - } - }, "loader-runner": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-2.3.0.tgz", @@ -3582,12 +3400,6 @@ "integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168=", "dev": true }, - "lodash.sortby": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", - "integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=", - "dev": true - }, "long": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/long/-/long-3.2.0.tgz", @@ -3980,12 +3792,6 @@ "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" }, - "nwsapi": { - "version": "2.0.8", - "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.0.8.tgz", - "integrity": "sha512-7RZ+qbFGiVc6v14Y8DSZjPN1wZPOaMbiiP4tzf5eNuyOITAeOIA3cMhjuKUypVIqBgCSg1KaSyAv8Ocq/0ZJ1A==", - "dev": true - }, "oauth-sign": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", @@ -4133,20 +3939,6 @@ "mimic-fn": "^1.0.0" } }, - "optionator": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", - "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", - "dev": true, - "requires": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.4", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "wordwrap": "~1.0.0" - } - }, "os-browserify": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", @@ -4311,12 +4103,50 @@ "sha.js": "^2.4.8" } }, + "pend": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", + "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=", + "dev": true + }, "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", "dev": true }, + "phantomjs-prebuilt": { + "version": "2.1.16", + "resolved": "https://registry.npmjs.org/phantomjs-prebuilt/-/phantomjs-prebuilt-2.1.16.tgz", + "integrity": "sha1-79ISpKOWbTZHaE6ouniFSb4q7+8=", + "dev": true, + "requires": { + "es6-promise": "^4.0.3", + "extract-zip": "^1.6.5", + "fs-extra": "^1.0.0", + "hasha": "^2.2.0", + "kew": "^0.7.0", + "progress": "^1.1.8", + "request": "^2.81.0", + "request-progress": "^2.0.1", + "which": "^1.2.10" + } + }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", + "dev": true + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "dev": true, + "requires": { + "pinkie": "^2.0.0" + } + }, "pkg-dir": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", @@ -4371,24 +4201,12 @@ } } }, - "pn": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/pn/-/pn-1.1.0.tgz", - "integrity": "sha512-2qHaIQr2VLRFoxe2nASzsV6ef4yOOH+Fi9FBOVH6cqeSgUnoyySPZkxzLuzd+RYOQTRpROA0ztTMqxROKSb/nA==", - "dev": true - }, "posix-character-classes": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", "dev": true }, - "prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", - "dev": true - }, "preserve": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz", @@ -4421,6 +4239,12 @@ "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, + "progress": { + "version": "1.1.8", + "resolved": "http://registry.npmjs.org/progress/-/progress-1.1.8.tgz", + "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", + "dev": true + }, "promise-inflight": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz", @@ -4689,24 +4513,13 @@ } } }, - "request-promise-core": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.1.tgz", - "integrity": "sha1-Pu4AssWqgyOc+wTFcA2jb4HNCLY=", - "dev": true, - "requires": { - "lodash": "^4.13.1" - } - }, - "request-promise-native": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/request-promise-native/-/request-promise-native-1.0.5.tgz", - "integrity": "sha1-UoF3D2jgyXGeUWP9P6tIIhX0/aU=", + "request-progress": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/request-progress/-/request-progress-2.0.1.tgz", + "integrity": "sha1-XTa7V5YcZzqlt4jbyBQf3yO0Tgg=", "dev": true, "requires": { - "request-promise-core": "1.1.1", - "stealthy-require": "^1.1.0", - "tough-cookie": ">=2.3.3" + "throttleit": "^1.0.0" } }, "require-directory": { @@ -4899,12 +4712,6 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true }, - "sax": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", - "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", - "dev": true - }, "schema-utils": { "version": "0.4.7", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-0.4.7.tgz", @@ -5278,12 +5085,6 @@ } } }, - "stealthy-require": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz", - "integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=", - "dev": true - }, "stream-browserify": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz", @@ -5400,18 +5201,18 @@ "resolved": "https://registry.npmjs.org/svg-tag-names/-/svg-tag-names-1.1.1.tgz", "integrity": "sha1-lkGynvcQJe4JTHBD983efZn71Qo=" }, - "symbol-tree": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.2.tgz", - "integrity": "sha1-rifbOPZgp64uHDt9G8KQgZuFGeY=", - "dev": true - }, "tapable": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/tapable/-/tapable-1.0.0.tgz", "integrity": "sha512-dQRhbNQkRnaqauC7WqSJ21EEksgT0fYZX2lqXzGkpo8JNig9zGZTYoMGvyI2nWmXlE2VSVXVDu7wLVGu/mQEsg==", "dev": true }, + "throttleit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/throttleit/-/throttleit-1.0.0.tgz", + "integrity": "sha1-nnhYNtr0Z0MUWlmEtiaNgoUorGw=", + "dev": true + }, "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", @@ -5586,23 +5387,6 @@ "punycode": "^1.4.1" } }, - "tr46": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz", - "integrity": "sha1-qLE/1r/SSJUZZ0zN5VujaTtwbQk=", - "dev": true, - "requires": { - "punycode": "^2.1.0" - }, - "dependencies": { - "punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", - "dev": true - } - } - }, "ts-loader": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-4.4.2.tgz", @@ -5643,15 +5427,6 @@ "dev": true, "optional": true }, - "type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", - "dev": true, - "requires": { - "prelude-ls": "~1.1.2" - } - }, "typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", @@ -5659,9 +5434,9 @@ "dev": true }, "typescript": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.0.1.tgz", - "integrity": "sha512-zQIMOmC+372pC/CCVLqnQ0zSBiY7HHodU7mpQdjiZddek4GMj31I3dUJ7gAs9o65X7mnRma6OokOkc6f9jjfBg==" + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.1.3.tgz", + "integrity": "sha512-+81MUSyX+BaSo+u2RbozuQk/UWx6hfG0a5gHu4ANEM4sU96XbuIyAB+rWBW1u70c6a5QuZfuYICn3s2UjuHUpA==" }, "uglify-es": { "version": "3.3.9", @@ -6033,15 +5808,6 @@ "indexof": "0.0.1" } }, - "w3c-hr-time": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.1.tgz", - "integrity": "sha1-gqwr/2PZUOqeMYmlimViX+3xkEU=", - "dev": true, - "requires": { - "browser-process-hrtime": "^0.1.2" - } - }, "watchpack": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.6.0.tgz", @@ -6053,12 +5819,6 @@ "neo-async": "^2.5.0" } }, - "webidl-conversions": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz", - "integrity": "sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==", - "dev": true - }, "webpack": { "version": "4.16.5", "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.16.5.tgz", @@ -6210,32 +5970,6 @@ } } }, - "whatwg-encoding": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-1.0.4.tgz", - "integrity": "sha512-vM9KWN6MP2mIHZ86ytcyIv7e8Cj3KTfO2nd2c8PFDqcI4bxFmQp83ibq4wadq7rL9l9sZV6o9B0LTt8ygGAAXg==", - "dev": true, - "requires": { - "iconv-lite": "0.4.23" - } - }, - "whatwg-mimetype": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-2.1.0.tgz", - "integrity": "sha512-FKxhYLytBQiUKjkYteN71fAUA3g6KpNXoho1isLiLSB3N1G4F35Q5vUxWfKFhBwi5IWF27VE6WxhrnnC+m0Mew==", - "dev": true - }, - "whatwg-url": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-7.0.0.tgz", - "integrity": "sha512-37GeVSIJ3kn1JgKyjiYNmSLP1yzbpb29jdmwBSgkD9h40/hyrR/OifpVUndji3tmwGgD8qpw7iQu3RSbCrBpsQ==", - "dev": true, - "requires": { - "lodash.sortby": "^4.7.0", - "tr46": "^1.0.1", - "webidl-conversions": "^4.0.2" - } - }, "which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", @@ -6249,12 +5983,6 @@ "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=" }, - "wordwrap": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", - "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", - "dev": true - }, "worker-farm": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/worker-farm/-/worker-farm-1.6.0.tgz", @@ -6298,21 +6026,6 @@ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, - "ws": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-6.0.0.tgz", - "integrity": "sha512-c2UlYcAZp1VS8AORtpq6y4RJIkJ9dQz18W32SpR/qXGfLDZ2jU4y4wKvvZwqbi7U6gxFQTeE+urMbXU/tsDy4w==", - "dev": true, - "requires": { - "async-limiter": "~1.0.0" - } - }, - "xml-name-validator": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz", - "integrity": "sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==", - "dev": true - }, "xregexp": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-4.0.0.tgz", @@ -6360,6 +6073,15 @@ "requires": { "camelcase": "^4.1.0" } + }, + "yauzl": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz", + "integrity": "sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=", + "dev": true, + "requires": { + "fd-slicer": "~1.0.1" + } } } } diff --git a/package.json b/package.json index ac71aad..268371d 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,9 @@ "build:example:calendar": "webpack --config ./examples/calendar/webpack.config.js --watch", "build:example:animation": "webpack --config ./examples/animation/webpack.config.js --watch", "build:example:dynamic": "webpack --config ./examples/dynamic-component/webpack.config.js --watch", - "test": "tsc -p ./test && node ./bin/trebor.js -i ./test -o ./spec/components && jasmine" + "build:test": "node ./specs/helpers/setup.js && phantomjs ./specs/run.js ./specs/test.html", + "build:test:src": "tsc -p ./test/src && node ./bin/trebor.js -i ./test/components -o ./specs/components -f iif", + "test": "npm run build:test:src && npm run build:test" }, "engines": { "node": ">=4" @@ -33,7 +35,7 @@ "rollup-pluginutils": "^2.3.1", "svg-tag-names": "^1.1.1", "tslib": "^1.9.3", - "typescript": "^3.0.1", + "typescript": "^3.1.3", "uglify-es": "^3.3.9", "uglify-js": "^3.4.7", "yargs": "^12.0.1" @@ -46,15 +48,12 @@ "@types/html-entities": "^1.2.16", "@types/html-tag-names": "^1.1.0", "@types/jasmine": "^2.8.8", - "@types/jsdom": "^11.0.6", "@types/node": "^10.7.1", "@types/parse5": "^5.0.0", "@types/uglify-js": "^3.0.3", - "eslint-plugin-html": "^4.0.5", "html-webpack-plugin": "^3.2.0", "jasmine": "^3.2.0", - "jsdom": "^12.0.0", - "keysim": "^2.1.0", + "phantomjs-prebuilt": "^2.1.16", "ts-loader": "^4.4.2", "webpack": "^4.16.5", "webpack-cli": "^3.1.0" diff --git a/spec/basic usage/initialize.spec.js b/spec/basic usage/initialize.spec.js deleted file mode 100644 index 4b6400d..0000000 --- a/spec/basic usage/initialize.spec.js +++ /dev/null @@ -1,69 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -require("../helpers/setup"); -const Component = require('../components/init.umd'); -describe('Component', () => { - it('should be a function constructor', () => { - expect(Component).not.toBeNull(); - expect(typeof Component).toBe('function'); - }); - it('should get an instance when is used with new', () => { - let instance = new Component(); - expect(typeof instance).toBe('object'); - expect(instance.constructor).toEqual(Component); - }); - it('instance should have prototype methods', () => { - let instance = new Component(); - expect('$refs' in instance).toBeTruthy(); - expect('$create' in instance).toBeTruthy(); - expect('$mount' in instance).toBeTruthy(); - expect('$update' in instance).toBeTruthy(); - expect('$unmount' in instance).toBeTruthy(); - expect('$destroy' in instance).toBeTruthy(); - expect('$watch' in instance).toBeTruthy(); - expect('$observe' in instance).toBeTruthy(); - }); - it('instance should have option properties', () => { - let instance = new Component(); - expect('text' in instance).toBeTruthy(); - expect(instance.text).toBe('World'); - }); -}); -describe('Component Instance', () => { - let instance, main; - beforeAll(done => { - instance = new Component(); - main = document.querySelector('main'); - done(); - }); - afterEach(done => { - instance.$unmount(); - done(); - }); - it('should be mounted in an element selector', () => { - instance.$mount('main'); - expect(instance.$parentEl).toEqual(main); - }); - it('should be mounted in an element', () => { - instance.$mount(main); - expect(instance.$parentEl).toEqual(main); - }); - it('should be mounted correctly', () => { - instance.$mount('main'); - let h1 = main.firstChild; - expect(h1.nodeName).toEqual('H1'); - expect(h1.textContent).toBe('Hello, World!!'); - }); - it('should update the view correctly', () => { - instance.$mount('main'); - let h1 = main.firstChild; - instance.$set('text', 'Somebody'); - expect(h1.textContent).toBe('Hello, Somebody!!'); - }); - it('should not update the view correctly if `$set` method is not used', () => { - instance.$mount('main'); - let h1 = main.firstChild; - instance.text = 'World'; - expect(h1.textContent).toBe('Hello, Somebody!!'); - }); -}); diff --git a/spec/components/bind.umd.js b/spec/components/bind.umd.js deleted file mode 100644 index 6e0422c..0000000 --- a/spec/components/bind.umd.js +++ /dev/null @@ -1,644 +0,0 @@ -!function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define('bind', factory) : - (global.Bind = factory()); - }(this, function () { - 'use strict'; -var PROP_MAP = { - p: '__TP__', - v: 'value', - _: '_value', - s: '_subscribers', - e: '_events', - w: '_watchers', - h: 'prototype' -}; -var PROPS = ['$slots', '$refs', '$filters', '$directives', '_events', '_watchers']; -var TPS = window[PROP_MAP.p] || (window[PROP_MAP.p] = []); -var _$assign = Object['assign'] || function(t) { - for (var s = void 0, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (_$hasProp(s, p)) - t[p] = s[p]; - } - return t; -}; -function _$CompCtr(attrs, template, options, parent) { - var self = this; - var _$set = function(prop, value) { - _$def(self, prop, { - value: value, - writable: true - }); - }; - if (!attrs) - attrs = {}; - _$e(PROPS, function(prop) { - _$def(self, prop, { - value: {} - }); - }); - _$set('$parent', parent || null); - _$set('$children', []); - _$set(PROP_MAP.s, {}); - _$set('$options', options); - var opts = self.$options; - if (!opts.attrs) - opts.attrs = {}; - if (!opts.children) - opts.children = {}; - _$e(TPS, function(plugin) { - plugin.fn.call(self, _$CompCtr, plugin.options); - }); - if (opts.filters) - _$assign(self.$filters, opts.filters); - if (opts.directives) _$e(opts.directives, function(drt, k) { - self.$directives[k] = _$drt(drt); - }); - _$e(opts.attrs, function(attrOps, key) { - _$def(self, _$isType(key, 'number') ? attrOps : key, { - get: function() { - if (_$isStr(attrOps)) { - var value = attrs[attrOps]; - return _$isFunction(value) ? value() : value; - } else { - if (!_$hasProp(attrs, key) && attrOps.required) { - return console.error('Attribute \'' + key + '\' is required.'); - } else { - var value = _$isFunction(attrs[key]) ? attrs[key]() : attrs[key]; - if (value === void 0 && _$hasProp(attrOps, 'default')) { - var def = attrOps.default; - value = _$isFunction(def) ? def() : def; - } - var typ = attrOps.type; - if (typ && !_$isType(value, typ) && attrOps.required) { - return console.error('Attribute \'' + key + '\' must be type \'' + typ + '\'.'); - } - value = _$toType(value, value === void 0 ? 'undefined' : typ, self, key); - if (value !== void 0 && _$hasProp(attrOps, 'validator')) { - var validator = attrOps.validator; - if (_$isFunction(validator) && !validator(value)) { - return console.error('Assigment \'' + key + '\'=\'' + JSON.stringify(value) + '\' invalid.'); - } - } - return value; - } - } - }, - - set: function() { - console.error('\'' + key + '\' is read only.'); - }, - - enumerable: true, - configurable: true - }); - }); - var data = opts.model || {}; - var _loop_1 = function(key) { - if (_$hasProp(data, key)) { - var desc = Object.getOwnPropertyDescriptor(data, key); - if (desc.value && _$isArray(desc.value)) { - desc.value = new _$List(desc.value, self, key); - } else { - if (desc.get) { - var getter_1 = desc.get; - desc.get = function() { - var value = getter_1.call(self); - if (_$isArray(value)) - value = new _$List(value, self, key); - return value; - }; - } - if (desc.set) { - var setter_1 = desc.set; - desc.set = function(v) { - if (_$isArray(v)) - v = new _$List(v, self, key); - setter_1.call(self, v); - }; - } - } - _$def(self, key, desc); - } - }; - for (var key in data) { - _loop_1(key); - } - var tpl = template(self); - _$e(tpl, function(value, key) { - _$def(self, key, { - value: function(key) { - var hook = key[1].toUpperCase() + key.slice(2); - var bhook = opts['before' + hook]; - var ahook = opts['after' + hook]; - return function() { - bhook && bhook.call(this); - key.slice(1) === 'update' ? value.call(this, this) : value.apply(this, arguments); - ahook && ahook.call(this); - }; - }(key) - }); - }); - _$def(self, '$data', { - get: function() { - return _$toPlainObj(this); - } - }); -} -function _$isValueAttr(attr) { - return attr === 'value'; -} -function _$subs(dep, listener) { - if (!this[PROP_MAP.s][dep]) { - this[PROP_MAP.s][dep] = []; - } - return this[PROP_MAP.s][dep].push(listener.bind(this)) - 1; -} -function _$def(obj, key, desc) { - Object.defineProperty(obj, key, desc); -} -_$assign(_$CompCtr[PROP_MAP.h], { - $get: function(path) { - return _$accesor(this, path); - }, - - $set: function(path, value) { - _$accesor(this, path, value); - }, - - $on: function(event, handler) { - var _this = this; - if (!this[PROP_MAP.e][event]) { - this[PROP_MAP.e][event] = []; - } - var i = this[PROP_MAP.e][event].push(handler); - return { - $off: function() { - _this[PROP_MAP.e][event].splice(i - 1, 1); - } - }; - }, - - $once: function(event, handler) { - var e = this.$on(event, function(args) { - handler(args); - e.$off(); - }); - }, - - $fire: function(event, data) { - if (this[PROP_MAP.e][event]) { - _$e(this[PROP_MAP.e][event], function(handler) { - handler(data); - }); - } - }, - - $notify: function(key) { - if (this[PROP_MAP.s][key]) { - _$e(this[PROP_MAP.s][key], function(suscriber) { - suscriber(); - }); - } - }, - - $observe: function(deps, listener) { - var _this = this; - var subs = []; - if (_$isArray(deps)) { - _$e(deps, function(dep) { - subs.push({ - sub: dep, - i: _$subs.call(_this, dep, listener) - }); - }); - } else { - subs.push({ - sub: deps, - i: _$subs.call(this, deps, listener) - }); - } - return { - $unobserve: function() { - _$e(subs, function(sub) { - _this[PROP_MAP.s][sub.sub].splice(sub.i, 1); - }); - } - }; - }, - - $watch: function(key, watcher) { - var _this = this; - if (!this[PROP_MAP.w][key]) { - this[PROP_MAP.w][key] = []; - } - var i = this[PROP_MAP.w][key].push(watcher.bind(this)); - return { - $unwatch: function() { - _this[PROP_MAP.w][key].splice(i - 1, 1); - } - }; - } -}); -var array = Array[PROP_MAP.h]; -function _$toArgs(args, start) { - if (start === void 0) { - start = 0; - } - return array.slice.call(args, start); -} -function _$arrayValues(list, value, root, key) { - array.push.apply(list, value.map(function(v, i) { - if (list.length !== 0) - i += list.length; - return !_$isType(v, _$List) && _$isArray(v) ? new _$List(v, root, key + '.' + i) : v; - })); -} -function _$List(value, root, key) { - var self = this; - Array.apply(self, [value.length]); - var desc = { - writable: false, - configurable: false, - enumerable: false - }; - _$def(self, '_key', _$assign({ - value: key - }, desc)); - _$def(self, '_root', _$assign({ - value: root - }, desc)); - _$arrayValues(self, value, root, key); - desc.writable = true; - _$def(self, 'length', _$assign({ - value: self.length - }, desc)); -} -_$extends(_$List, Array); -['pop', 'push', 'reverse', 'shift', 'sort', 'fill', 'unshift', 'splice'].forEach(function(method) { - _$List[PROP_MAP.h][method] = function() { - var self = this; - var old = self.slice(); - var result; - if (method === 'push') { - _$arrayValues(self, _$toArgs(arguments), self._root, self._key); - result = self.length; - } else { - result = array[method].apply(self, arguments); - } - _$dispatch(self._root, self._key, old, self.slice()); - return result; - }; -}); -_$List[PROP_MAP.h].pull = function(index) { - var self = this; - var items = _$toArgs(arguments, 1); - var length = self.length; - if (index > length) { - length = index + 1; - var pull = new Array(index - self.length); - pull.push.apply(pull, items); - for (var i = 0; i < length; i++) { - if (i === index) { - self.push.apply(self, pull); - } - } - } else { - self.splice.apply(self, [index, 1].concat(items)); - } -}; -function _$dispatch(root, key, oldVal, value) { - root.$notify(key); - if (root[PROP_MAP.w][key]) { - _$e(root[PROP_MAP.w][key], function(watcher) { - watcher(oldVal, value); - }); - } - root.$update(); -} -function _$extends(ctor, exts) { - ctor['plugin'] = function(fn, options) { - TPS.push({ - options: options, - fn: fn - }); - }; - ctor[PROP_MAP.h] = Object.create(exts[PROP_MAP.h]); - ctor[PROP_MAP.h].constructor = ctor; -} -function _$isType(value, type) { - return _$type(type) === 'string' ? type.split('|').some(function(t) { - return t.trim() === _$type(value); - }) : value instanceof type; -} -function _$isObject(obj) { - return _$isType(obj, 'object'); -} -function _$isArray(obj) { - return Array.isArray ? Array.isArray(obj) : _$isType(obj, 'array'); -} -function _$isFunction(obj) { - return _$isType(obj, 'function'); -} -function _$isStr(obj) { - return _$isType(obj, 'string'); -} -function _$toType(value, type, root, key) { - switch (type) { - case 'date': - return new Date(value); - case 'string': - return _$toStr(value); - case 'number': - return +value; - case 'boolean': - return _$isStr(value) && !value ? true : !!value; - case 'array': - return _$isType(value, _$List) ? value : new _$List(value, root, key); - default: - return value; - } -} -function _$type(obj) { - return / (\w+)/.exec({}.toString.call(obj))[1].toLowerCase(); -} -function _$hasProp(obj, prop) { - return obj.hasOwnProperty(prop); -} -function _$drt(dd) { - var hasProp = function(prop, instance, options, element) { - return _$isObject(dd) && dd[prop] && dd[prop](instance, options, element); - }; - return { - $init: function(instance, options, element) { - hasProp('$init', instance, options, element); - }, - - $inserted: function(instance, options, element) { - hasProp('$inserted', instance, options, element); - }, - - $update: function(instance, options, element) { - if (_$isFunction(dd)) { - dd(instance, options, element); - } else { - hasProp('$update', instance, options, element); - } - }, - - $destroy: function(instance, options, element) { - hasProp('$destroy', instance, options, element); - } - }; -} -function _$toStr(obj) { - var str = _$type(obj); - return !/null|undefined/.test(str) ? obj.toString() : str; -} -function _$toPlainObj(obj) { - var data = {}; - _$e(_$isObject(obj) ? obj : {}, function(_v, k) { - if (k[0] !== '$' && !_$isFunction(obj[k])) { - if (_$isType(obj[k], _$List)) { - data[k] = obj[k].map(_$toPlainObj); - } else if (_$isObject(obj[k])) { - data[k] = _$toPlainObj(obj[k]); - } else { - data[k] = obj[k]; - } - } - }); - return _$isObject(obj) ? data : obj; -} -function _$accesor(object, path, value) { - return path.split('.').reduce(function(obj, key, i, arr) { - if (_$isType(value, 'undefined')) { - if (obj == null) { - arr.splice(0, arr.length); - return i > 0 && obj === null ? obj : undefined; - } - } else { - if (i === arr.length - 1) { - if (_$isType(obj, _$List) && _$toStr(+key) === key) { - obj.pull(+key, value); - } else { - var oldVal = obj[key]; - obj[key] = !_$isType(value, _$List) && _$isArray(value) ? new _$List(value, object, key) : value; - _$dispatch(object, path, oldVal, obj[key]); - } - } else if (!_$isObject(obj[key])) { - obj[key] = {}; - } - } - return obj ? obj[key] : null; - }, object); -} -function _$bindGroup(input, selection) { - var _value = _$gv(input); - var _$index = selection.indexOf(_value); - input.checked && !~_$index ? selection.push(_value) : selection.splice(_$index, 1); -} -function _$(selector, parent) { - return _$isStr(selector) ? (parent || document).querySelector(selector) : selector; -} -function _$d() { - return document.createDocumentFragment(); -} -function _$a(parent, child, sibling) { - if (_$isType(sibling, 'boolean') && sibling) - parent.parentElement.replaceChild(child, parent); - else if (!sibling) - parent.appendChild(child); - else - parent.insertBefore(child, sibling); -} -function _$ce(tagName) { - return document.createElement(tagName || 'div'); -} -function _$sa(el, attrAndValue) { - var attr = attrAndValue[0], value = attrAndValue[1]; - el.setAttribute(attr, _$toStr(value)); - if (_$isValueAttr(attr) && !_$isStr(value)) - el[PROP_MAP._] = value; -} -function _$ga(el, attr) { - return _$isValueAttr(attr) ? _$gv(el) : el.getAttribute(attr); -} -function _$gv(el) { - return _$hasProp(el, PROP_MAP._) ? el[PROP_MAP._] : el[PROP_MAP.v]; -} -function _$al(el, event, handler) { - el.addEventListener(event, handler, false); -} -function _$rl(el, event, handler) { - el.removeEventListener(event, handler, false); -} -function _$bba(el, attrAndValue) { - var _a = attrAndValue.concat([el.hasAttribute(attrAndValue[0])]), attr = _a[0], value = _a[1], hasAttr = _a[2]; - value == null || value === false ? hasAttr && el.removeAttribute(attr) : _$sa(el, [attr, '']); -} -function _$bu(el, binding) { - var attr = binding[0], value = binding[1]; - var _value = attr === 'checked' ? !!value : _$toStr(value); - if (/value|checked/.test(attr)) { - if (el[attr] !== _value) - el[attr] = _$isValueAttr(attr) ? _value : value; - el[PROP_MAP._] = _$isValueAttr(attr) ? value : el[PROP_MAP.v]; - } else if (_$ga(el, attr) !== _value) { - _$sa(el, [attr, _value]); - } -} -function _$e(obj, cb) { - for (var key in obj) { - if (_$hasProp(obj, key)) { - cb(obj[key], isNaN(+key) ? key : +key); - } - } -} -function _$tplBind(_$state) { - var _$frag, input_1, inputEvent_1, handlerInputEvent_1, bindValueInput_1, input_2, changeEvent_1, handlerChangeEvent_1, bindCheckedInput_2, input_3, changeEvent_2, handlerChangeEvent_2, bindCheckedInput_3, input_4, changeEvent_3, handlerChangeEvent_3, bindCheckedInput_4, input_5, changeEvent_4, handlerChangeEvent_4, bindCheckedInput_5, input_6, changeEvent_5, handlerChangeEvent_5, bindCheckedInput_6; - _$frag = _$d(); - inputEvent_1 = function(_$state, $event, $el) { - _$state.$set('textValue', $el.value); - }; - bindValueInput_1 = function(_$state) { - return ['value', _$state.textValue]; - }; - changeEvent_1 = function(_$state, $event, $el) { - _$bindGroup($el, _$state.checkboxes); - }; - bindCheckedInput_2 = function(_$state) { - return ['checked', !!~_$state.checkboxes.indexOf(_$ga(input_2, 'value'))]; - }; - changeEvent_2 = function(_$state, $event, $el) { - _$bindGroup($el, _$state.checkboxes); - }; - bindCheckedInput_3 = function(_$state) { - return ['checked', !!~_$state.checkboxes.indexOf(_$ga(input_3, 'value'))]; - }; - changeEvent_3 = function(_$state, $event, $el) { - _$state.$set('radios', $el.checked ? _$gv($el) : _$state.radios); - }; - bindCheckedInput_4 = function(_$state) { - return ['checked', _$state.radios === _$ga(input_4, 'value')]; - }; - changeEvent_4 = function(_$state, $event, $el) { - _$state.$set('radios', $el.checked ? _$gv($el) : _$state.radios); - }; - bindCheckedInput_5 = function(_$state) { - return ['checked', _$state.radios === _$ga(input_5, 'value')]; - }; - changeEvent_5 = function(_$state, $event, $el) { - _$state.$set('radios', $el.checked ? _$gv($el) : _$state.radios); - }; - bindCheckedInput_6 = function(_$state) { - return ['checked', _$state.radios === _$ga(input_6, 'value')]; - }; - return { - $create: function() { - input_1 = _$ce('input'); - input_2 = _$ce('input'); - input_3 = _$ce('input'); - input_4 = _$ce('input'); - input_5 = _$ce('input'); - input_6 = _$ce('input'); - _$al(input_1, 'input', handlerInputEvent_1 = function(event) { - inputEvent_1(_$state, event, input_1); - }); - input_1.value = _$toStr(bindValueInput_1(_$state)[1]); - _$sa(input_1, ['id', 'text']); - _$sa(input_1, ['type', 'text']); - _$al(input_2, 'change', handlerChangeEvent_1 = function(event) { - changeEvent_1(_$state, event, input_2); - }); - _$bba(input_2, bindCheckedInput_2(_$state)); - _$sa(input_2, ['id', 'checkbox_1']); - _$sa(input_2, ['type', 'checkbox']); - _$sa(input_2, ['value', 'Yes']); - _$al(input_3, 'change', handlerChangeEvent_2 = function(event) { - changeEvent_2(_$state, event, input_3); - }); - _$bba(input_3, bindCheckedInput_3(_$state)); - _$sa(input_3, ['id', 'checkbox_2']); - _$sa(input_3, ['type', 'checkbox']); - _$sa(input_3, ['value', 'No']); - _$al(input_4, 'change', handlerChangeEvent_3 = function(event) { - changeEvent_3(_$state, event, input_4); - }); - _$bba(input_4, bindCheckedInput_4(_$state)); - _$sa(input_4, ['id', 'radio_1']); - _$sa(input_4, ['type', 'radio']); - _$sa(input_4, ['value', 'radio 1']); - _$al(input_5, 'change', handlerChangeEvent_4 = function(event) { - changeEvent_4(_$state, event, input_5); - }); - _$bba(input_5, bindCheckedInput_5(_$state)); - _$sa(input_5, ['id', 'radio_2']); - _$sa(input_5, ['type', 'radio']); - _$sa(input_5, ['value', 'radio 2']); - _$al(input_6, 'change', handlerChangeEvent_5 = function(event) { - changeEvent_5(_$state, event, input_6); - }); - _$bba(input_6, bindCheckedInput_6(_$state)); - _$sa(input_6, ['id', 'radio_3']); - _$sa(input_6, ['type', 'radio']); - _$sa(input_6, ['value', 'radio 3']); - }, - - $mount: function(parent, sibling) { - this.$unmount(); - _$a(_$(parent), _$frag, _$(sibling)); - this.$siblingEl = _$(sibling); - this.$parentEl = sibling && _$(sibling).parentElement || _$(parent); - }, - - $update: function(_$state) { - _$bu(input_1, bindValueInput_1(_$state)); - _$bba(input_2, bindCheckedInput_2(_$state)); - _$bba(input_3, bindCheckedInput_3(_$state)); - _$bba(input_4, bindCheckedInput_4(_$state)); - _$bba(input_5, bindCheckedInput_5(_$state)); - _$bba(input_6, bindCheckedInput_6(_$state)); - }, - - $unmount: function() { - _$a(_$frag, input_1); - _$a(_$frag, input_2); - _$a(_$frag, input_3); - _$a(_$frag, input_4); - _$a(_$frag, input_5); - _$a(_$frag, input_6); - }, - - $destroy: function() { - this.$unmount(); - this.$parent = null; - this.$parentEl = null; - this.$siblingEl = null; - this.$children.splice(0, this.$children.length); - _$rl(input_1, 'input', handlerInputEvent_1); - _$rl(input_2, 'change', handlerChangeEvent_1); - _$rl(input_3, 'change', handlerChangeEvent_2); - _$rl(input_4, 'change', handlerChangeEvent_3); - _$rl(input_5, 'change', handlerChangeEvent_4); - _$rl(input_6, 'change', handlerChangeEvent_5); - delete _$state.$root; - _$frag = input_1 = inputEvent_1 = handlerInputEvent_1 = bindValueInput_1 = input_2 = changeEvent_1 = handlerChangeEvent_1 = bindCheckedInput_2 = input_3 = changeEvent_2 = handlerChangeEvent_2 = bindCheckedInput_3 = input_4 = changeEvent_3 = handlerChangeEvent_3 = bindCheckedInput_4 = input_5 = changeEvent_4 = handlerChangeEvent_4 = bindCheckedInput_5 = input_6 = changeEvent_5 = handlerChangeEvent_5 = bindCheckedInput_6 = void 0; - } - }; -} -function Bind(_$attrs, _$parent) { - _$CompCtr.call(this, _$attrs, _$tplBind, { - model: { - radios: '', - textValue: '', - checkboxes: [] - } - }, _$parent); - !_$parent && this.$create(); -} -_$extends(Bind, _$CompCtr); -return Bind; - - }); \ No newline at end of file diff --git a/spec/components/condition.umd.js b/spec/components/condition.umd.js deleted file mode 100644 index 2dc8c2f..0000000 --- a/spec/components/condition.umd.js +++ /dev/null @@ -1,677 +0,0 @@ -!function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define('condition', factory) : - (global.Condition = factory()); - }(this, function () { - 'use strict'; -var PROP_MAP = { - p: '__TP__', - v: 'value', - _: '_value', - s: '_subscribers', - e: '_events', - w: '_watchers', - h: 'prototype' -}; -var PROPS = ['$slots', '$refs', '$filters', '$directives', '_events', '_watchers']; -var TPS = window[PROP_MAP.p] || (window[PROP_MAP.p] = []); -var _$assign = Object['assign'] || function(t) { - for (var s = void 0, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (_$hasProp(s, p)) - t[p] = s[p]; - } - return t; -}; -function _$CompCtr(attrs, template, options, parent) { - var self = this; - var _$set = function(prop, value) { - _$def(self, prop, { - value: value, - writable: true - }); - }; - if (!attrs) - attrs = {}; - _$e(PROPS, function(prop) { - _$def(self, prop, { - value: {} - }); - }); - _$set('$parent', parent || null); - _$set('$children', []); - _$set(PROP_MAP.s, {}); - _$set('$options', options); - var opts = self.$options; - if (!opts.attrs) - opts.attrs = {}; - if (!opts.children) - opts.children = {}; - _$e(TPS, function(plugin) { - plugin.fn.call(self, _$CompCtr, plugin.options); - }); - if (opts.filters) - _$assign(self.$filters, opts.filters); - if (opts.directives) _$e(opts.directives, function(drt, k) { - self.$directives[k] = _$drt(drt); - }); - _$e(opts.attrs, function(attrOps, key) { - _$def(self, _$isType(key, 'number') ? attrOps : key, { - get: function() { - if (_$isStr(attrOps)) { - var value = attrs[attrOps]; - return _$isFunction(value) ? value() : value; - } else { - if (!_$hasProp(attrs, key) && attrOps.required) { - return console.error('Attribute \'' + key + '\' is required.'); - } else { - var value = _$isFunction(attrs[key]) ? attrs[key]() : attrs[key]; - if (value === void 0 && _$hasProp(attrOps, 'default')) { - var def = attrOps.default; - value = _$isFunction(def) ? def() : def; - } - var typ = attrOps.type; - if (typ && !_$isType(value, typ) && attrOps.required) { - return console.error('Attribute \'' + key + '\' must be type \'' + typ + '\'.'); - } - value = _$toType(value, value === void 0 ? 'undefined' : typ, self, key); - if (value !== void 0 && _$hasProp(attrOps, 'validator')) { - var validator = attrOps.validator; - if (_$isFunction(validator) && !validator(value)) { - return console.error('Assigment \'' + key + '\'=\'' + JSON.stringify(value) + '\' invalid.'); - } - } - return value; - } - } - }, - - set: function() { - console.error('\'' + key + '\' is read only.'); - }, - - enumerable: true, - configurable: true - }); - }); - var data = opts.model || {}; - var _loop_1 = function(key) { - if (_$hasProp(data, key)) { - var desc = Object.getOwnPropertyDescriptor(data, key); - if (desc.value && _$isArray(desc.value)) { - desc.value = new _$List(desc.value, self, key); - } else { - if (desc.get) { - var getter_1 = desc.get; - desc.get = function() { - var value = getter_1.call(self); - if (_$isArray(value)) - value = new _$List(value, self, key); - return value; - }; - } - if (desc.set) { - var setter_1 = desc.set; - desc.set = function(v) { - if (_$isArray(v)) - v = new _$List(v, self, key); - setter_1.call(self, v); - }; - } - } - _$def(self, key, desc); - } - }; - for (var key in data) { - _loop_1(key); - } - var tpl = template(self); - _$e(tpl, function(value, key) { - _$def(self, key, { - value: function(key) { - var hook = key[1].toUpperCase() + key.slice(2); - var bhook = opts['before' + hook]; - var ahook = opts['after' + hook]; - return function() { - bhook && bhook.call(this); - key.slice(1) === 'update' ? value.call(this, this) : value.apply(this, arguments); - ahook && ahook.call(this); - }; - }(key) - }); - }); - _$def(self, '$data', { - get: function() { - return _$toPlainObj(this); - } - }); -} -function _$subs(dep, listener) { - if (!this[PROP_MAP.s][dep]) { - this[PROP_MAP.s][dep] = []; - } - return this[PROP_MAP.s][dep].push(listener.bind(this)) - 1; -} -function _$def(obj, key, desc) { - Object.defineProperty(obj, key, desc); -} -_$assign(_$CompCtr[PROP_MAP.h], { - $get: function(path) { - return _$accesor(this, path); - }, - - $set: function(path, value) { - _$accesor(this, path, value); - }, - - $on: function(event, handler) { - var _this = this; - if (!this[PROP_MAP.e][event]) { - this[PROP_MAP.e][event] = []; - } - var i = this[PROP_MAP.e][event].push(handler); - return { - $off: function() { - _this[PROP_MAP.e][event].splice(i - 1, 1); - } - }; - }, - - $once: function(event, handler) { - var e = this.$on(event, function(args) { - handler(args); - e.$off(); - }); - }, - - $fire: function(event, data) { - if (this[PROP_MAP.e][event]) { - _$e(this[PROP_MAP.e][event], function(handler) { - handler(data); - }); - } - }, - - $notify: function(key) { - if (this[PROP_MAP.s][key]) { - _$e(this[PROP_MAP.s][key], function(suscriber) { - suscriber(); - }); - } - }, - - $observe: function(deps, listener) { - var _this = this; - var subs = []; - if (_$isArray(deps)) { - _$e(deps, function(dep) { - subs.push({ - sub: dep, - i: _$subs.call(_this, dep, listener) - }); - }); - } else { - subs.push({ - sub: deps, - i: _$subs.call(this, deps, listener) - }); - } - return { - $unobserve: function() { - _$e(subs, function(sub) { - _this[PROP_MAP.s][sub.sub].splice(sub.i, 1); - }); - } - }; - }, - - $watch: function(key, watcher) { - var _this = this; - if (!this[PROP_MAP.w][key]) { - this[PROP_MAP.w][key] = []; - } - var i = this[PROP_MAP.w][key].push(watcher.bind(this)); - return { - $unwatch: function() { - _this[PROP_MAP.w][key].splice(i - 1, 1); - } - }; - } -}); -var array = Array[PROP_MAP.h]; -function _$toArgs(args, start) { - if (start === void 0) { - start = 0; - } - return array.slice.call(args, start); -} -function _$arrayValues(list, value, root, key) { - array.push.apply(list, value.map(function(v, i) { - if (list.length !== 0) - i += list.length; - return !_$isType(v, _$List) && _$isArray(v) ? new _$List(v, root, key + '.' + i) : v; - })); -} -function _$List(value, root, key) { - var self = this; - Array.apply(self, [value.length]); - var desc = { - writable: false, - configurable: false, - enumerable: false - }; - _$def(self, '_key', _$assign({ - value: key - }, desc)); - _$def(self, '_root', _$assign({ - value: root - }, desc)); - _$arrayValues(self, value, root, key); - desc.writable = true; - _$def(self, 'length', _$assign({ - value: self.length - }, desc)); -} -_$extends(_$List, Array); -['pop', 'push', 'reverse', 'shift', 'sort', 'fill', 'unshift', 'splice'].forEach(function(method) { - _$List[PROP_MAP.h][method] = function() { - var self = this; - var old = self.slice(); - var result; - if (method === 'push') { - _$arrayValues(self, _$toArgs(arguments), self._root, self._key); - result = self.length; - } else { - result = array[method].apply(self, arguments); - } - _$dispatch(self._root, self._key, old, self.slice()); - return result; - }; -}); -_$List[PROP_MAP.h].pull = function(index) { - var self = this; - var items = _$toArgs(arguments, 1); - var length = self.length; - if (index > length) { - length = index + 1; - var pull = new Array(index - self.length); - pull.push.apply(pull, items); - for (var i = 0; i < length; i++) { - if (i === index) { - self.push.apply(self, pull); - } - } - } else { - self.splice.apply(self, [index, 1].concat(items)); - } -}; -function _$dispatch(root, key, oldVal, value) { - root.$notify(key); - if (root[PROP_MAP.w][key]) { - _$e(root[PROP_MAP.w][key], function(watcher) { - watcher(oldVal, value); - }); - } - root.$update(); -} -function _$extends(ctor, exts) { - ctor['plugin'] = function(fn, options) { - TPS.push({ - options: options, - fn: fn - }); - }; - ctor[PROP_MAP.h] = Object.create(exts[PROP_MAP.h]); - ctor[PROP_MAP.h].constructor = ctor; -} -function _$isType(value, type) { - return _$type(type) === 'string' ? type.split('|').some(function(t) { - return t.trim() === _$type(value); - }) : value instanceof type; -} -function _$isObject(obj) { - return _$isType(obj, 'object'); -} -function _$isArray(obj) { - return Array.isArray ? Array.isArray(obj) : _$isType(obj, 'array'); -} -function _$isFunction(obj) { - return _$isType(obj, 'function'); -} -function _$isStr(obj) { - return _$isType(obj, 'string'); -} -function _$toType(value, type, root, key) { - switch (type) { - case 'date': - return new Date(value); - case 'string': - return _$toStr(value); - case 'number': - return +value; - case 'boolean': - return _$isStr(value) && !value ? true : !!value; - case 'array': - return _$isType(value, _$List) ? value : new _$List(value, root, key); - default: - return value; - } -} -function _$type(obj) { - return / (\w+)/.exec({}.toString.call(obj))[1].toLowerCase(); -} -function _$hasProp(obj, prop) { - return obj.hasOwnProperty(prop); -} -function _$drt(dd) { - var hasProp = function(prop, instance, options, element) { - return _$isObject(dd) && dd[prop] && dd[prop](instance, options, element); - }; - return { - $init: function(instance, options, element) { - hasProp('$init', instance, options, element); - }, - - $inserted: function(instance, options, element) { - hasProp('$inserted', instance, options, element); - }, - - $update: function(instance, options, element) { - if (_$isFunction(dd)) { - dd(instance, options, element); - } else { - hasProp('$update', instance, options, element); - } - }, - - $destroy: function(instance, options, element) { - hasProp('$destroy', instance, options, element); - } - }; -} -function _$noop() {} -function _$toStr(obj) { - var str = _$type(obj); - return !/null|undefined/.test(str) ? obj.toString() : str; -} -function _$toPlainObj(obj) { - var data = {}; - _$e(_$isObject(obj) ? obj : {}, function(_v, k) { - if (k[0] !== '$' && !_$isFunction(obj[k])) { - if (_$isType(obj[k], _$List)) { - data[k] = obj[k].map(_$toPlainObj); - } else if (_$isObject(obj[k])) { - data[k] = _$toPlainObj(obj[k]); - } else { - data[k] = obj[k]; - } - } - }); - return _$isObject(obj) ? data : obj; -} -function _$accesor(object, path, value) { - return path.split('.').reduce(function(obj, key, i, arr) { - if (_$isType(value, 'undefined')) { - if (obj == null) { - arr.splice(0, arr.length); - return i > 0 && obj === null ? obj : undefined; - } - } else { - if (i === arr.length - 1) { - if (_$isType(obj, _$List) && _$toStr(+key) === key) { - obj.pull(+key, value); - } else { - var oldVal = obj[key]; - obj[key] = !_$isType(value, _$List) && _$isArray(value) ? new _$List(value, object, key) : value; - _$dispatch(object, path, oldVal, obj[key]); - } - } else if (!_$isObject(obj[key])) { - obj[key] = {}; - } - } - return obj ? obj[key] : null; - }, object); -} -function _$emptyElse() { - return { - type: 'empty-else', - $create: _$noop, - $mount: _$noop, - $update: _$noop, - $destroy: _$noop - }; -} -function _$(selector, parent) { - return _$isStr(selector) ? (parent || document).querySelector(selector) : selector; -} -function _$d() { - return document.createDocumentFragment(); -} -function _$a(parent, child, sibling) { - if (_$isType(sibling, 'boolean') && sibling) - parent.parentElement.replaceChild(child, parent); - else if (!sibling) - parent.appendChild(child); - else - parent.insertBefore(child, sibling); -} -function _$ce(tagName) { - return document.createElement(tagName || 'div'); -} -function _$ct(content) { - return document.createTextNode(content || ''); -} -function _$cu(block, condition, inst, parent, anchor) { - if (block && block.type === condition(inst).type) { - block.$update(inst); - } else { - block && block.$destroy(); - block = condition(inst); - block.$create(); - block.$mount(parent, anchor); - } - return block; -} -function _$e(obj, cb) { - for (var key in obj) { - if (_$hasProp(obj, key)) { - cb(obj[key], isNaN(+key) ? key : +key); - } - } -} -function ifCondition_1() { - var _$frag, span_1; - _$frag = _$d(); - return { - type: 'if', - - $create: function() { - span_1 = _$ce('span'); - span_1.innerHTML = '1'; - }, - - $mount: function(parent, sibling) { - this.$unmount(); - _$a(_$(parent), _$frag, _$(sibling)); - }, - - $update: _$noop, - - $unmount: function() { - _$a(_$frag, span_1); - }, - - $destroy: function() { - this.$unmount(); - _$frag = span_1 = void 0; - } - }; -} -function elseIf_1_condition_1() { - var _$frag, span_1; - _$frag = _$d(); - return { - type: 'elseIf_1', - - $create: function() { - span_1 = _$ce('span'); - span_1.innerHTML = '2'; - }, - - $mount: function(parent, sibling) { - this.$unmount(); - _$a(_$(parent), _$frag, _$(sibling)); - }, - - $update: _$noop, - - $unmount: function() { - _$a(_$frag, span_1); - }, - - $destroy: function() { - this.$unmount(); - _$frag = span_1 = void 0; - } - }; -} -function elseCondition_1() { - var _$frag, span_1; - _$frag = _$d(); - return { - type: 'else', - - $create: function() { - span_1 = _$ce('span'); - span_1.innerHTML = 'other'; - }, - - $mount: function(parent, sibling) { - this.$unmount(); - _$a(_$(parent), _$frag, _$(sibling)); - }, - - $update: _$noop, - - $unmount: function() { - _$a(_$frag, span_1); - }, - - $destroy: function() { - this.$unmount(); - _$frag = span_1 = void 0; - } - }; -} -function condition_1(_$state) { - if (_$state.condition === 1) - return ifCondition_1(_$state); - else if (_$state.condition === 2) - return elseIf_1_condition_1(_$state); - else - return elseCondition_1(_$state); -} -function ifCondition_2() { - var _$frag, div_1; - _$frag = _$d(); - return { - type: 'if', - - $create: function() { - div_1 = _$ce(); - div_1.innerHTML = '1'; - }, - - $mount: function(parent, sibling) { - this.$unmount(); - _$a(_$(parent), _$frag, _$(sibling)); - }, - - $update: _$noop, - - $unmount: function() { - _$a(_$frag, div_1); - }, - - $destroy: function() { - this.$unmount(); - _$frag = div_1 = void 0; - } - }; -} -function condition_2(_$state) { - if (_$state.condition_1 === 1) - return ifCondition_2(_$state); - else - return _$emptyElse(); -} -function _$tplCondition(_$state) { - var _$frag, conditionAnchor_1, conditionBlock_1, conditionAnchor_2, conditionBlock_2; - _$frag = _$d(); - conditionAnchor_1 = _$ct(); - conditionAnchor_2 = _$ct(); - return { - $create: function() { - conditionBlock_1 = condition_1(_$state); - conditionBlock_1.$create(); - conditionBlock_2 = condition_2(_$state); - conditionBlock_2.$create(); - }, - - $mount: function(parent, sibling) { - this.$unmount(); - _$a(_$(parent), _$frag, _$(sibling)); - this.$siblingEl = _$(sibling); - this.$parentEl = sibling && _$(sibling).parentElement || _$(parent); - }, - - $update: function(_$state) { - conditionBlock_1 = _$cu( - conditionBlock_1, - condition_1, - _$state, - _$state.$parentEl, - conditionAnchor_1 - ); - conditionBlock_2 = _$cu( - conditionBlock_2, - condition_2, - _$state, - _$state.$parentEl, - conditionAnchor_2 - ); - }, - - $unmount: function() { - _$a(_$frag, conditionAnchor_1); - conditionBlock_1.$mount(_$frag, conditionAnchor_1); - _$a(_$frag, conditionAnchor_2); - conditionBlock_2.$mount(_$frag, conditionAnchor_2); - }, - - $destroy: function() { - this.$unmount(); - this.$parent = null; - this.$parentEl = null; - this.$siblingEl = null; - this.$children.splice(0, this.$children.length); - conditionBlock_1.$destroy(); - conditionBlock_2.$destroy(); - delete _$state.$root; - _$frag = conditionAnchor_1 = conditionBlock_1 = conditionAnchor_2 = conditionBlock_2 = void 0; - } - }; -} -function Condition(_$attrs, _$parent) { - _$CompCtr.call(this, _$attrs, _$tplCondition, { - model: { - condition: 1, - condition_1: 1 - } - }, _$parent); - !_$parent && this.$create(); -} -_$extends(Condition, _$CompCtr); -return Condition; - - }); \ No newline at end of file diff --git a/spec/components/html.umd.js b/spec/components/html.umd.js deleted file mode 100644 index 7a6abe1..0000000 --- a/spec/components/html.umd.js +++ /dev/null @@ -1,580 +0,0 @@ -!function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define('html', factory) : - (global.Html = factory()); - }(this, function () { - 'use strict'; -var PROP_MAP = { - p: '__TP__', - v: 'value', - _: '_value', - s: '_subscribers', - e: '_events', - w: '_watchers', - h: 'prototype' -}; -var PROPS = ['$slots', '$refs', '$filters', '$directives', '_events', '_watchers']; -var TPS = window[PROP_MAP.p] || (window[PROP_MAP.p] = []); -var _$assign = Object['assign'] || function(t) { - for (var s = void 0, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (_$hasProp(s, p)) - t[p] = s[p]; - } - return t; -}; -function _$CompCtr(attrs, template, options, parent) { - var self = this; - var _$set = function(prop, value) { - _$def(self, prop, { - value: value, - writable: true - }); - }; - if (!attrs) - attrs = {}; - _$e(PROPS, function(prop) { - _$def(self, prop, { - value: {} - }); - }); - _$set('$parent', parent || null); - _$set('$children', []); - _$set(PROP_MAP.s, {}); - _$set('$options', options); - var opts = self.$options; - if (!opts.attrs) - opts.attrs = {}; - if (!opts.children) - opts.children = {}; - _$e(TPS, function(plugin) { - plugin.fn.call(self, _$CompCtr, plugin.options); - }); - if (opts.filters) - _$assign(self.$filters, opts.filters); - if (opts.directives) _$e(opts.directives, function(drt, k) { - self.$directives[k] = _$drt(drt); - }); - _$e(opts.attrs, function(attrOps, key) { - _$def(self, _$isType(key, 'number') ? attrOps : key, { - get: function() { - if (_$isStr(attrOps)) { - var value = attrs[attrOps]; - return _$isFunction(value) ? value() : value; - } else { - if (!_$hasProp(attrs, key) && attrOps.required) { - return console.error('Attribute \'' + key + '\' is required.'); - } else { - var value = _$isFunction(attrs[key]) ? attrs[key]() : attrs[key]; - if (value === void 0 && _$hasProp(attrOps, 'default')) { - var def = attrOps.default; - value = _$isFunction(def) ? def() : def; - } - var typ = attrOps.type; - if (typ && !_$isType(value, typ) && attrOps.required) { - return console.error('Attribute \'' + key + '\' must be type \'' + typ + '\'.'); - } - value = _$toType(value, value === void 0 ? 'undefined' : typ, self, key); - if (value !== void 0 && _$hasProp(attrOps, 'validator')) { - var validator = attrOps.validator; - if (_$isFunction(validator) && !validator(value)) { - return console.error('Assigment \'' + key + '\'=\'' + JSON.stringify(value) + '\' invalid.'); - } - } - return value; - } - } - }, - - set: function() { - console.error('\'' + key + '\' is read only.'); - }, - - enumerable: true, - configurable: true - }); - }); - var data = opts.model || {}; - var _loop_1 = function(key) { - if (_$hasProp(data, key)) { - var desc = Object.getOwnPropertyDescriptor(data, key); - if (desc.value && _$isArray(desc.value)) { - desc.value = new _$List(desc.value, self, key); - } else { - if (desc.get) { - var getter_1 = desc.get; - desc.get = function() { - var value = getter_1.call(self); - if (_$isArray(value)) - value = new _$List(value, self, key); - return value; - }; - } - if (desc.set) { - var setter_1 = desc.set; - desc.set = function(v) { - if (_$isArray(v)) - v = new _$List(v, self, key); - setter_1.call(self, v); - }; - } - } - _$def(self, key, desc); - } - }; - for (var key in data) { - _loop_1(key); - } - var tpl = template(self); - _$e(tpl, function(value, key) { - _$def(self, key, { - value: function(key) { - var hook = key[1].toUpperCase() + key.slice(2); - var bhook = opts['before' + hook]; - var ahook = opts['after' + hook]; - return function() { - bhook && bhook.call(this); - key.slice(1) === 'update' ? value.call(this, this) : value.apply(this, arguments); - ahook && ahook.call(this); - }; - }(key) - }); - }); - _$def(self, '$data', { - get: function() { - return _$toPlainObj(this); - } - }); -} -function _$isValueAttr(attr) { - return attr === 'value'; -} -function _$subs(dep, listener) { - if (!this[PROP_MAP.s][dep]) { - this[PROP_MAP.s][dep] = []; - } - return this[PROP_MAP.s][dep].push(listener.bind(this)) - 1; -} -function _$def(obj, key, desc) { - Object.defineProperty(obj, key, desc); -} -_$assign(_$CompCtr[PROP_MAP.h], { - $get: function(path) { - return _$accesor(this, path); - }, - - $set: function(path, value) { - _$accesor(this, path, value); - }, - - $on: function(event, handler) { - var _this = this; - if (!this[PROP_MAP.e][event]) { - this[PROP_MAP.e][event] = []; - } - var i = this[PROP_MAP.e][event].push(handler); - return { - $off: function() { - _this[PROP_MAP.e][event].splice(i - 1, 1); - } - }; - }, - - $once: function(event, handler) { - var e = this.$on(event, function(args) { - handler(args); - e.$off(); - }); - }, - - $fire: function(event, data) { - if (this[PROP_MAP.e][event]) { - _$e(this[PROP_MAP.e][event], function(handler) { - handler(data); - }); - } - }, - - $notify: function(key) { - if (this[PROP_MAP.s][key]) { - _$e(this[PROP_MAP.s][key], function(suscriber) { - suscriber(); - }); - } - }, - - $observe: function(deps, listener) { - var _this = this; - var subs = []; - if (_$isArray(deps)) { - _$e(deps, function(dep) { - subs.push({ - sub: dep, - i: _$subs.call(_this, dep, listener) - }); - }); - } else { - subs.push({ - sub: deps, - i: _$subs.call(this, deps, listener) - }); - } - return { - $unobserve: function() { - _$e(subs, function(sub) { - _this[PROP_MAP.s][sub.sub].splice(sub.i, 1); - }); - } - }; - }, - - $watch: function(key, watcher) { - var _this = this; - if (!this[PROP_MAP.w][key]) { - this[PROP_MAP.w][key] = []; - } - var i = this[PROP_MAP.w][key].push(watcher.bind(this)); - return { - $unwatch: function() { - _this[PROP_MAP.w][key].splice(i - 1, 1); - } - }; - } -}); -var array = Array[PROP_MAP.h]; -function _$toArgs(args, start) { - if (start === void 0) { - start = 0; - } - return array.slice.call(args, start); -} -function _$arrayValues(list, value, root, key) { - array.push.apply(list, value.map(function(v, i) { - if (list.length !== 0) - i += list.length; - return !_$isType(v, _$List) && _$isArray(v) ? new _$List(v, root, key + '.' + i) : v; - })); -} -function _$List(value, root, key) { - var self = this; - Array.apply(self, [value.length]); - var desc = { - writable: false, - configurable: false, - enumerable: false - }; - _$def(self, '_key', _$assign({ - value: key - }, desc)); - _$def(self, '_root', _$assign({ - value: root - }, desc)); - _$arrayValues(self, value, root, key); - desc.writable = true; - _$def(self, 'length', _$assign({ - value: self.length - }, desc)); -} -_$extends(_$List, Array); -['pop', 'push', 'reverse', 'shift', 'sort', 'fill', 'unshift', 'splice'].forEach(function(method) { - _$List[PROP_MAP.h][method] = function() { - var self = this; - var old = self.slice(); - var result; - if (method === 'push') { - _$arrayValues(self, _$toArgs(arguments), self._root, self._key); - result = self.length; - } else { - result = array[method].apply(self, arguments); - } - _$dispatch(self._root, self._key, old, self.slice()); - return result; - }; -}); -_$List[PROP_MAP.h].pull = function(index) { - var self = this; - var items = _$toArgs(arguments, 1); - var length = self.length; - if (index > length) { - length = index + 1; - var pull = new Array(index - self.length); - pull.push.apply(pull, items); - for (var i = 0; i < length; i++) { - if (i === index) { - self.push.apply(self, pull); - } - } - } else { - self.splice.apply(self, [index, 1].concat(items)); - } -}; -function _$dispatch(root, key, oldVal, value) { - root.$notify(key); - if (root[PROP_MAP.w][key]) { - _$e(root[PROP_MAP.w][key], function(watcher) { - watcher(oldVal, value); - }); - } - root.$update(); -} -function _$extends(ctor, exts) { - ctor['plugin'] = function(fn, options) { - TPS.push({ - options: options, - fn: fn - }); - }; - ctor[PROP_MAP.h] = Object.create(exts[PROP_MAP.h]); - ctor[PROP_MAP.h].constructor = ctor; -} -function _$isType(value, type) { - return _$type(type) === 'string' ? type.split('|').some(function(t) { - return t.trim() === _$type(value); - }) : value instanceof type; -} -function _$isObject(obj) { - return _$isType(obj, 'object'); -} -function _$isArray(obj) { - return Array.isArray ? Array.isArray(obj) : _$isType(obj, 'array'); -} -function _$isFunction(obj) { - return _$isType(obj, 'function'); -} -function _$isStr(obj) { - return _$isType(obj, 'string'); -} -function _$toType(value, type, root, key) { - switch (type) { - case 'date': - return new Date(value); - case 'string': - return _$toStr(value); - case 'number': - return +value; - case 'boolean': - return _$isStr(value) && !value ? true : !!value; - case 'array': - return _$isType(value, _$List) ? value : new _$List(value, root, key); - default: - return value; - } -} -function _$type(obj) { - return / (\w+)/.exec({}.toString.call(obj))[1].toLowerCase(); -} -function _$hasProp(obj, prop) { - return obj.hasOwnProperty(prop); -} -function _$drt(dd) { - var hasProp = function(prop, instance, options, element) { - return _$isObject(dd) && dd[prop] && dd[prop](instance, options, element); - }; - return { - $init: function(instance, options, element) { - hasProp('$init', instance, options, element); - }, - - $inserted: function(instance, options, element) { - hasProp('$inserted', instance, options, element); - }, - - $update: function(instance, options, element) { - if (_$isFunction(dd)) { - dd(instance, options, element); - } else { - hasProp('$update', instance, options, element); - } - }, - - $destroy: function(instance, options, element) { - hasProp('$destroy', instance, options, element); - } - }; -} -function _$toStr(obj) { - var str = _$type(obj); - return !/null|undefined/.test(str) ? obj.toString() : str; -} -function _$toPlainObj(obj) { - var data = {}; - _$e(_$isObject(obj) ? obj : {}, function(_v, k) { - if (k[0] !== '$' && !_$isFunction(obj[k])) { - if (_$isType(obj[k], _$List)) { - data[k] = obj[k].map(_$toPlainObj); - } else if (_$isObject(obj[k])) { - data[k] = _$toPlainObj(obj[k]); - } else { - data[k] = obj[k]; - } - } - }); - return _$isObject(obj) ? data : obj; -} -function _$setRef(obj, prop) { - var value = []; - _$def(obj, prop, { - get: function() { - return value.length <= 1 ? value[0] : value; - }, - - set: function(val) { - val && !~value.indexOf(val) && value.push(val); - }, - - enumerable: true, - configurable: true - }); -} -function _$accesor(object, path, value) { - return path.split('.').reduce(function(obj, key, i, arr) { - if (_$isType(value, 'undefined')) { - if (obj == null) { - arr.splice(0, arr.length); - return i > 0 && obj === null ? obj : undefined; - } - } else { - if (i === arr.length - 1) { - if (_$isType(obj, _$List) && _$toStr(+key) === key) { - obj.pull(+key, value); - } else { - var oldVal = obj[key]; - obj[key] = !_$isType(value, _$List) && _$isArray(value) ? new _$List(value, object, key) : value; - _$dispatch(object, path, oldVal, obj[key]); - } - } else if (!_$isObject(obj[key])) { - obj[key] = {}; - } - } - return obj ? obj[key] : null; - }, object); -} -function _$(selector, parent) { - return _$isStr(selector) ? (parent || document).querySelector(selector) : selector; -} -function _$d() { - return document.createDocumentFragment(); -} -function _$a(parent, child, sibling) { - if (_$isType(sibling, 'boolean') && sibling) - parent.parentElement.replaceChild(child, parent); - else if (!sibling) - parent.appendChild(child); - else - parent.insertBefore(child, sibling); -} -function _$ce(tagName) { - return document.createElement(tagName || 'div'); -} -function _$ct(content) { - return document.createTextNode(content || ''); -} -function _$sa(el, attrAndValue) { - var attr = attrAndValue[0], value = attrAndValue[1]; - el.setAttribute(attr, _$toStr(value)); - if (_$isValueAttr(attr) && !_$isStr(value)) - el[PROP_MAP._] = value; -} -function _$tu(text, value) { - if (text.data !== (value = _$toStr(value))) - text.data = value; -} -function _$e(obj, cb) { - for (var key in obj) { - if (_$hasProp(obj, key)) { - cb(obj[key], isNaN(+key) ? key : +key); - } - } -} -function _$tplHtml(_$state) { - var _$frag, div_1, div_2, p_1, txt_1, setTxt_1, div_3, p_2, txt_2, setTxt_2, _refs, div_4, div_5, contentDiv_5_1; - _$frag = _$d(); - setTxt_1 = function(_$state) { - return 'Some paragraph with text ' + _$state.expression; - }; - setTxt_2 = function(_$state) { - return 'Some paragraph with ' + _$state.text + ' and ' + _$state.attribute + ' expressions'; - }; - _refs = _$state.$refs; - contentDiv_5_1 = function(_$state) { - return _$state.html; - }; - return { - $create: function() { - div_1 = _$ce(); - div_1.innerHTML = '

Here\'s a very interesting note displayed in a lovely shadowed box.

Any kind of content here. Such as <p>, <table>. You name it!

'; - div_2 = _$ce(); - p_1 = _$ce('p'); - txt_1 = _$ct(); - txt_1.data = setTxt_1(_$state); - div_3 = _$ce(); - p_2 = _$ce('p'); - txt_2 = _$ct(); - txt_2.data = setTxt_2(_$state); - !_refs['someAttr'] && _$setRef(_refs, 'someAttr'); - _refs['someAttr'] = p_2; - div_4 = _$ce(); - div_4.innerHTML = '

Some paragraph with text intentional {{escaped}}

'; - div_5 = _$ce(); - div_5.innerHTML = contentDiv_5_1(_$state); - _$sa(div_1, ['class', 'shadowbox']); - }, - - $mount: function(parent, sibling) { - this.$unmount(); - _$a(_$(parent), _$frag, _$(sibling)); - this.$siblingEl = _$(sibling); - this.$parentEl = sibling && _$(sibling).parentElement || _$(parent); - }, - - $update: function(_$state) { - _$tu(txt_1, setTxt_1(_$state)); - _$tu(txt_2, setTxt_2(_$state)); - var updateContentDiv_5_1 = contentDiv_5_1(_$state); - if (div_5.innerHTML !== updateContentDiv_5_1) { - div_5.innerHTML = updateContentDiv_5_1; - } - updateContentDiv_5_1 = void 0; - }, - - $unmount: function() { - _$a(_$frag, div_1); - _$a(p_1, txt_1); - _$a(div_2, p_1); - _$a(_$frag, div_2); - _$a(p_2, txt_2); - _$a(div_3, p_2); - _$a(_$frag, div_3); - _$a(_$frag, div_4); - _$a(_$frag, div_5); - }, - - $destroy: function() { - this.$unmount(); - this.$parent = null; - this.$parentEl = null; - this.$siblingEl = null; - this.$children.splice(0, this.$children.length); - if (_$isType(_refs['someAttr'], 'array')) { - var indexP_2 = _refs['someAttr'].indexOf(p_2); - _refs['someAttr'].splice(indexP_2, 1); - } else { - delete _refs['someAttr']; - } - delete _$state.$root; - _$frag = div_1 = div_2 = p_1 = txt_1 = setTxt_1 = div_3 = p_2 = txt_2 = setTxt_2 = _refs = div_4 = div_5 = contentDiv_5_1 = void 0; - } - }; -} -function Html(_$attrs, _$parent) { - _$CompCtr.call(this, _$attrs, _$tplHtml, { - model: { - html: '

Some paragraph with text from {{model}}

' - } - }, _$parent); - !_$parent && this.$create(); -} -_$extends(Html, _$CompCtr); -return Html; - - }); \ No newline at end of file diff --git a/spec/components/init.umd.js b/spec/components/init.umd.js deleted file mode 100644 index ecf8127..0000000 --- a/spec/components/init.umd.js +++ /dev/null @@ -1,516 +0,0 @@ -!function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define('init', factory) : - (global.Init = factory()); - }(this, function () { - 'use strict'; -var PROP_MAP = { - p: '__TP__', - v: 'value', - _: '_value', - s: '_subscribers', - e: '_events', - w: '_watchers', - h: 'prototype' -}; -var PROPS = ['$slots', '$refs', '$filters', '$directives', '_events', '_watchers']; -var TPS = window[PROP_MAP.p] || (window[PROP_MAP.p] = []); -var _$assign = Object['assign'] || function(t) { - for (var s = void 0, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (_$hasProp(s, p)) - t[p] = s[p]; - } - return t; -}; -function _$CompCtr(attrs, template, options, parent) { - var self = this; - var _$set = function(prop, value) { - _$def(self, prop, { - value: value, - writable: true - }); - }; - if (!attrs) - attrs = {}; - _$e(PROPS, function(prop) { - _$def(self, prop, { - value: {} - }); - }); - _$set('$parent', parent || null); - _$set('$children', []); - _$set(PROP_MAP.s, {}); - _$set('$options', options); - var opts = self.$options; - if (!opts.attrs) - opts.attrs = {}; - if (!opts.children) - opts.children = {}; - _$e(TPS, function(plugin) { - plugin.fn.call(self, _$CompCtr, plugin.options); - }); - if (opts.filters) - _$assign(self.$filters, opts.filters); - if (opts.directives) _$e(opts.directives, function(drt, k) { - self.$directives[k] = _$drt(drt); - }); - _$e(opts.attrs, function(attrOps, key) { - _$def(self, _$isType(key, 'number') ? attrOps : key, { - get: function() { - if (_$isStr(attrOps)) { - var value = attrs[attrOps]; - return _$isFunction(value) ? value() : value; - } else { - if (!_$hasProp(attrs, key) && attrOps.required) { - return console.error('Attribute \'' + key + '\' is required.'); - } else { - var value = _$isFunction(attrs[key]) ? attrs[key]() : attrs[key]; - if (value === void 0 && _$hasProp(attrOps, 'default')) { - var def = attrOps.default; - value = _$isFunction(def) ? def() : def; - } - var typ = attrOps.type; - if (typ && !_$isType(value, typ) && attrOps.required) { - return console.error('Attribute \'' + key + '\' must be type \'' + typ + '\'.'); - } - value = _$toType(value, value === void 0 ? 'undefined' : typ, self, key); - if (value !== void 0 && _$hasProp(attrOps, 'validator')) { - var validator = attrOps.validator; - if (_$isFunction(validator) && !validator(value)) { - return console.error('Assigment \'' + key + '\'=\'' + JSON.stringify(value) + '\' invalid.'); - } - } - return value; - } - } - }, - - set: function() { - console.error('\'' + key + '\' is read only.'); - }, - - enumerable: true, - configurable: true - }); - }); - var data = opts.model || {}; - var _loop_1 = function(key) { - if (_$hasProp(data, key)) { - var desc = Object.getOwnPropertyDescriptor(data, key); - if (desc.value && _$isArray(desc.value)) { - desc.value = new _$List(desc.value, self, key); - } else { - if (desc.get) { - var getter_1 = desc.get; - desc.get = function() { - var value = getter_1.call(self); - if (_$isArray(value)) - value = new _$List(value, self, key); - return value; - }; - } - if (desc.set) { - var setter_1 = desc.set; - desc.set = function(v) { - if (_$isArray(v)) - v = new _$List(v, self, key); - setter_1.call(self, v); - }; - } - } - _$def(self, key, desc); - } - }; - for (var key in data) { - _loop_1(key); - } - var tpl = template(self); - _$e(tpl, function(value, key) { - _$def(self, key, { - value: function(key) { - var hook = key[1].toUpperCase() + key.slice(2); - var bhook = opts['before' + hook]; - var ahook = opts['after' + hook]; - return function() { - bhook && bhook.call(this); - key.slice(1) === 'update' ? value.call(this, this) : value.apply(this, arguments); - ahook && ahook.call(this); - }; - }(key) - }); - }); - _$def(self, '$data', { - get: function() { - return _$toPlainObj(this); - } - }); -} -function _$subs(dep, listener) { - if (!this[PROP_MAP.s][dep]) { - this[PROP_MAP.s][dep] = []; - } - return this[PROP_MAP.s][dep].push(listener.bind(this)) - 1; -} -function _$def(obj, key, desc) { - Object.defineProperty(obj, key, desc); -} -_$assign(_$CompCtr[PROP_MAP.h], { - $get: function(path) { - return _$accesor(this, path); - }, - - $set: function(path, value) { - _$accesor(this, path, value); - }, - - $on: function(event, handler) { - var _this = this; - if (!this[PROP_MAP.e][event]) { - this[PROP_MAP.e][event] = []; - } - var i = this[PROP_MAP.e][event].push(handler); - return { - $off: function() { - _this[PROP_MAP.e][event].splice(i - 1, 1); - } - }; - }, - - $once: function(event, handler) { - var e = this.$on(event, function(args) { - handler(args); - e.$off(); - }); - }, - - $fire: function(event, data) { - if (this[PROP_MAP.e][event]) { - _$e(this[PROP_MAP.e][event], function(handler) { - handler(data); - }); - } - }, - - $notify: function(key) { - if (this[PROP_MAP.s][key]) { - _$e(this[PROP_MAP.s][key], function(suscriber) { - suscriber(); - }); - } - }, - - $observe: function(deps, listener) { - var _this = this; - var subs = []; - if (_$isArray(deps)) { - _$e(deps, function(dep) { - subs.push({ - sub: dep, - i: _$subs.call(_this, dep, listener) - }); - }); - } else { - subs.push({ - sub: deps, - i: _$subs.call(this, deps, listener) - }); - } - return { - $unobserve: function() { - _$e(subs, function(sub) { - _this[PROP_MAP.s][sub.sub].splice(sub.i, 1); - }); - } - }; - }, - - $watch: function(key, watcher) { - var _this = this; - if (!this[PROP_MAP.w][key]) { - this[PROP_MAP.w][key] = []; - } - var i = this[PROP_MAP.w][key].push(watcher.bind(this)); - return { - $unwatch: function() { - _this[PROP_MAP.w][key].splice(i - 1, 1); - } - }; - } -}); -var array = Array[PROP_MAP.h]; -function _$toArgs(args, start) { - if (start === void 0) { - start = 0; - } - return array.slice.call(args, start); -} -function _$arrayValues(list, value, root, key) { - array.push.apply(list, value.map(function(v, i) { - if (list.length !== 0) - i += list.length; - return !_$isType(v, _$List) && _$isArray(v) ? new _$List(v, root, key + '.' + i) : v; - })); -} -function _$List(value, root, key) { - var self = this; - Array.apply(self, [value.length]); - var desc = { - writable: false, - configurable: false, - enumerable: false - }; - _$def(self, '_key', _$assign({ - value: key - }, desc)); - _$def(self, '_root', _$assign({ - value: root - }, desc)); - _$arrayValues(self, value, root, key); - desc.writable = true; - _$def(self, 'length', _$assign({ - value: self.length - }, desc)); -} -_$extends(_$List, Array); -['pop', 'push', 'reverse', 'shift', 'sort', 'fill', 'unshift', 'splice'].forEach(function(method) { - _$List[PROP_MAP.h][method] = function() { - var self = this; - var old = self.slice(); - var result; - if (method === 'push') { - _$arrayValues(self, _$toArgs(arguments), self._root, self._key); - result = self.length; - } else { - result = array[method].apply(self, arguments); - } - _$dispatch(self._root, self._key, old, self.slice()); - return result; - }; -}); -_$List[PROP_MAP.h].pull = function(index) { - var self = this; - var items = _$toArgs(arguments, 1); - var length = self.length; - if (index > length) { - length = index + 1; - var pull = new Array(index - self.length); - pull.push.apply(pull, items); - for (var i = 0; i < length; i++) { - if (i === index) { - self.push.apply(self, pull); - } - } - } else { - self.splice.apply(self, [index, 1].concat(items)); - } -}; -function _$dispatch(root, key, oldVal, value) { - root.$notify(key); - if (root[PROP_MAP.w][key]) { - _$e(root[PROP_MAP.w][key], function(watcher) { - watcher(oldVal, value); - }); - } - root.$update(); -} -function _$extends(ctor, exts) { - ctor['plugin'] = function(fn, options) { - TPS.push({ - options: options, - fn: fn - }); - }; - ctor[PROP_MAP.h] = Object.create(exts[PROP_MAP.h]); - ctor[PROP_MAP.h].constructor = ctor; -} -function _$isType(value, type) { - return _$type(type) === 'string' ? type.split('|').some(function(t) { - return t.trim() === _$type(value); - }) : value instanceof type; -} -function _$isObject(obj) { - return _$isType(obj, 'object'); -} -function _$isArray(obj) { - return Array.isArray ? Array.isArray(obj) : _$isType(obj, 'array'); -} -function _$isFunction(obj) { - return _$isType(obj, 'function'); -} -function _$isStr(obj) { - return _$isType(obj, 'string'); -} -function _$toType(value, type, root, key) { - switch (type) { - case 'date': - return new Date(value); - case 'string': - return _$toStr(value); - case 'number': - return +value; - case 'boolean': - return _$isStr(value) && !value ? true : !!value; - case 'array': - return _$isType(value, _$List) ? value : new _$List(value, root, key); - default: - return value; - } -} -function _$type(obj) { - return / (\w+)/.exec({}.toString.call(obj))[1].toLowerCase(); -} -function _$hasProp(obj, prop) { - return obj.hasOwnProperty(prop); -} -function _$drt(dd) { - var hasProp = function(prop, instance, options, element) { - return _$isObject(dd) && dd[prop] && dd[prop](instance, options, element); - }; - return { - $init: function(instance, options, element) { - hasProp('$init', instance, options, element); - }, - - $inserted: function(instance, options, element) { - hasProp('$inserted', instance, options, element); - }, - - $update: function(instance, options, element) { - if (_$isFunction(dd)) { - dd(instance, options, element); - } else { - hasProp('$update', instance, options, element); - } - }, - - $destroy: function(instance, options, element) { - hasProp('$destroy', instance, options, element); - } - }; -} -function _$toStr(obj) { - var str = _$type(obj); - return !/null|undefined/.test(str) ? obj.toString() : str; -} -function _$toPlainObj(obj) { - var data = {}; - _$e(_$isObject(obj) ? obj : {}, function(_v, k) { - if (k[0] !== '$' && !_$isFunction(obj[k])) { - if (_$isType(obj[k], _$List)) { - data[k] = obj[k].map(_$toPlainObj); - } else if (_$isObject(obj[k])) { - data[k] = _$toPlainObj(obj[k]); - } else { - data[k] = obj[k]; - } - } - }); - return _$isObject(obj) ? data : obj; -} -function _$accesor(object, path, value) { - return path.split('.').reduce(function(obj, key, i, arr) { - if (_$isType(value, 'undefined')) { - if (obj == null) { - arr.splice(0, arr.length); - return i > 0 && obj === null ? obj : undefined; - } - } else { - if (i === arr.length - 1) { - if (_$isType(obj, _$List) && _$toStr(+key) === key) { - obj.pull(+key, value); - } else { - var oldVal = obj[key]; - obj[key] = !_$isType(value, _$List) && _$isArray(value) ? new _$List(value, object, key) : value; - _$dispatch(object, path, oldVal, obj[key]); - } - } else if (!_$isObject(obj[key])) { - obj[key] = {}; - } - } - return obj ? obj[key] : null; - }, object); -} -function _$(selector, parent) { - return _$isStr(selector) ? (parent || document).querySelector(selector) : selector; -} -function _$d() { - return document.createDocumentFragment(); -} -function _$a(parent, child, sibling) { - if (_$isType(sibling, 'boolean') && sibling) - parent.parentElement.replaceChild(child, parent); - else if (!sibling) - parent.appendChild(child); - else - parent.insertBefore(child, sibling); -} -function _$ce(tagName) { - return document.createElement(tagName || 'div'); -} -function _$ct(content) { - return document.createTextNode(content || ''); -} -function _$tu(text, value) { - if (text.data !== (value = _$toStr(value))) - text.data = value; -} -function _$e(obj, cb) { - for (var key in obj) { - if (_$hasProp(obj, key)) { - cb(obj[key], isNaN(+key) ? key : +key); - } - } -} -function _$tplInit(_$state) { - var _$frag, h1_1, txt_1, setTxt_1; - _$frag = _$d(); - setTxt_1 = function(_$state) { - return 'Hello, ' + _$state.text + '!!'; - }; - return { - $create: function() { - h1_1 = _$ce('h1'); - txt_1 = _$ct(); - txt_1.data = setTxt_1(_$state); - }, - - $mount: function(parent, sibling) { - this.$unmount(); - _$a(_$(parent), _$frag, _$(sibling)); - this.$siblingEl = _$(sibling); - this.$parentEl = sibling && _$(sibling).parentElement || _$(parent); - }, - - $update: function(_$state) { - _$tu(txt_1, setTxt_1(_$state)); - }, - - $unmount: function() { - _$a(h1_1, txt_1); - _$a(_$frag, h1_1); - }, - - $destroy: function() { - this.$unmount(); - this.$parent = null; - this.$parentEl = null; - this.$siblingEl = null; - this.$children.splice(0, this.$children.length); - delete _$state.$root; - _$frag = h1_1 = txt_1 = setTxt_1 = void 0; - } - }; -} -function Init(_$attrs, _$parent) { - _$CompCtr.call(this, _$attrs, _$tplInit, { - model: { - text: 'World' - } - }, _$parent); - !_$parent && this.$create(); -} -_$extends(Init, _$CompCtr); -return Init; - - }); \ No newline at end of file diff --git a/spec/components/loop.umd.js b/spec/components/loop.umd.js deleted file mode 100644 index 85f8974..0000000 --- a/spec/components/loop.umd.js +++ /dev/null @@ -1,786 +0,0 @@ -!function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define('loop', factory) : - (global.Loop = factory()); - }(this, function () { - 'use strict'; -var PROP_MAP = { - p: '__TP__', - v: 'value', - _: '_value', - s: '_subscribers', - e: '_events', - w: '_watchers', - h: 'prototype' -}; -var PROPS = ['$slots', '$refs', '$filters', '$directives', '_events', '_watchers']; -var TPS = window[PROP_MAP.p] || (window[PROP_MAP.p] = []); -var _$assign = Object['assign'] || function(t) { - for (var s = void 0, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (_$hasProp(s, p)) - t[p] = s[p]; - } - return t; -}; -function _$CompCtr(attrs, template, options, parent) { - var self = this; - var _$set = function(prop, value) { - _$def(self, prop, { - value: value, - writable: true - }); - }; - if (!attrs) - attrs = {}; - _$e(PROPS, function(prop) { - _$def(self, prop, { - value: {} - }); - }); - _$set('$parent', parent || null); - _$set('$children', []); - _$set(PROP_MAP.s, {}); - _$set('$options', options); - var opts = self.$options; - if (!opts.attrs) - opts.attrs = {}; - if (!opts.children) - opts.children = {}; - _$e(TPS, function(plugin) { - plugin.fn.call(self, _$CompCtr, plugin.options); - }); - if (opts.filters) - _$assign(self.$filters, opts.filters); - if (opts.directives) _$e(opts.directives, function(drt, k) { - self.$directives[k] = _$drt(drt); - }); - _$e(opts.attrs, function(attrOps, key) { - _$def(self, _$isType(key, 'number') ? attrOps : key, { - get: function() { - if (_$isStr(attrOps)) { - var value = attrs[attrOps]; - return _$isFunction(value) ? value() : value; - } else { - if (!_$hasProp(attrs, key) && attrOps.required) { - return console.error('Attribute \'' + key + '\' is required.'); - } else { - var value = _$isFunction(attrs[key]) ? attrs[key]() : attrs[key]; - if (value === void 0 && _$hasProp(attrOps, 'default')) { - var def = attrOps.default; - value = _$isFunction(def) ? def() : def; - } - var typ = attrOps.type; - if (typ && !_$isType(value, typ) && attrOps.required) { - return console.error('Attribute \'' + key + '\' must be type \'' + typ + '\'.'); - } - value = _$toType(value, value === void 0 ? 'undefined' : typ, self, key); - if (value !== void 0 && _$hasProp(attrOps, 'validator')) { - var validator = attrOps.validator; - if (_$isFunction(validator) && !validator(value)) { - return console.error('Assigment \'' + key + '\'=\'' + JSON.stringify(value) + '\' invalid.'); - } - } - return value; - } - } - }, - - set: function() { - console.error('\'' + key + '\' is read only.'); - }, - - enumerable: true, - configurable: true - }); - }); - var data = opts.model || {}; - var _loop_1 = function(key) { - if (_$hasProp(data, key)) { - var desc = Object.getOwnPropertyDescriptor(data, key); - if (desc.value && _$isArray(desc.value)) { - desc.value = new _$List(desc.value, self, key); - } else { - if (desc.get) { - var getter_1 = desc.get; - desc.get = function() { - var value = getter_1.call(self); - if (_$isArray(value)) - value = new _$List(value, self, key); - return value; - }; - } - if (desc.set) { - var setter_1 = desc.set; - desc.set = function(v) { - if (_$isArray(v)) - v = new _$List(v, self, key); - setter_1.call(self, v); - }; - } - } - _$def(self, key, desc); - } - }; - for (var key in data) { - _loop_1(key); - } - var tpl = template(self); - _$e(tpl, function(value, key) { - _$def(self, key, { - value: function(key) { - var hook = key[1].toUpperCase() + key.slice(2); - var bhook = opts['before' + hook]; - var ahook = opts['after' + hook]; - return function() { - bhook && bhook.call(this); - key.slice(1) === 'update' ? value.call(this, this) : value.apply(this, arguments); - ahook && ahook.call(this); - }; - }(key) - }); - }); - _$def(self, '$data', { - get: function() { - return _$toPlainObj(this); - } - }); -} -function _$isValueAttr(attr) { - return attr === 'value'; -} -function _$subs(dep, listener) { - if (!this[PROP_MAP.s][dep]) { - this[PROP_MAP.s][dep] = []; - } - return this[PROP_MAP.s][dep].push(listener.bind(this)) - 1; -} -function _$def(obj, key, desc) { - Object.defineProperty(obj, key, desc); -} -_$assign(_$CompCtr[PROP_MAP.h], { - $get: function(path) { - return _$accesor(this, path); - }, - - $set: function(path, value) { - _$accesor(this, path, value); - }, - - $on: function(event, handler) { - var _this = this; - if (!this[PROP_MAP.e][event]) { - this[PROP_MAP.e][event] = []; - } - var i = this[PROP_MAP.e][event].push(handler); - return { - $off: function() { - _this[PROP_MAP.e][event].splice(i - 1, 1); - } - }; - }, - - $once: function(event, handler) { - var e = this.$on(event, function(args) { - handler(args); - e.$off(); - }); - }, - - $fire: function(event, data) { - if (this[PROP_MAP.e][event]) { - _$e(this[PROP_MAP.e][event], function(handler) { - handler(data); - }); - } - }, - - $notify: function(key) { - if (this[PROP_MAP.s][key]) { - _$e(this[PROP_MAP.s][key], function(suscriber) { - suscriber(); - }); - } - }, - - $observe: function(deps, listener) { - var _this = this; - var subs = []; - if (_$isArray(deps)) { - _$e(deps, function(dep) { - subs.push({ - sub: dep, - i: _$subs.call(_this, dep, listener) - }); - }); - } else { - subs.push({ - sub: deps, - i: _$subs.call(this, deps, listener) - }); - } - return { - $unobserve: function() { - _$e(subs, function(sub) { - _this[PROP_MAP.s][sub.sub].splice(sub.i, 1); - }); - } - }; - }, - - $watch: function(key, watcher) { - var _this = this; - if (!this[PROP_MAP.w][key]) { - this[PROP_MAP.w][key] = []; - } - var i = this[PROP_MAP.w][key].push(watcher.bind(this)); - return { - $unwatch: function() { - _this[PROP_MAP.w][key].splice(i - 1, 1); - } - }; - } -}); -var array = Array[PROP_MAP.h]; -function _$toArgs(args, start) { - if (start === void 0) { - start = 0; - } - return array.slice.call(args, start); -} -function _$arrayValues(list, value, root, key) { - array.push.apply(list, value.map(function(v, i) { - if (list.length !== 0) - i += list.length; - return !_$isType(v, _$List) && _$isArray(v) ? new _$List(v, root, key + '.' + i) : v; - })); -} -function _$List(value, root, key) { - var self = this; - Array.apply(self, [value.length]); - var desc = { - writable: false, - configurable: false, - enumerable: false - }; - _$def(self, '_key', _$assign({ - value: key - }, desc)); - _$def(self, '_root', _$assign({ - value: root - }, desc)); - _$arrayValues(self, value, root, key); - desc.writable = true; - _$def(self, 'length', _$assign({ - value: self.length - }, desc)); -} -_$extends(_$List, Array); -['pop', 'push', 'reverse', 'shift', 'sort', 'fill', 'unshift', 'splice'].forEach(function(method) { - _$List[PROP_MAP.h][method] = function() { - var self = this; - var old = self.slice(); - var result; - if (method === 'push') { - _$arrayValues(self, _$toArgs(arguments), self._root, self._key); - result = self.length; - } else { - result = array[method].apply(self, arguments); - } - _$dispatch(self._root, self._key, old, self.slice()); - return result; - }; -}); -_$List[PROP_MAP.h].pull = function(index) { - var self = this; - var items = _$toArgs(arguments, 1); - var length = self.length; - if (index > length) { - length = index + 1; - var pull = new Array(index - self.length); - pull.push.apply(pull, items); - for (var i = 0; i < length; i++) { - if (i === index) { - self.push.apply(self, pull); - } - } - } else { - self.splice.apply(self, [index, 1].concat(items)); - } -}; -function _$dispatch(root, key, oldVal, value) { - root.$notify(key); - if (root[PROP_MAP.w][key]) { - _$e(root[PROP_MAP.w][key], function(watcher) { - watcher(oldVal, value); - }); - } - root.$update(); -} -function _$extends(ctor, exts) { - ctor['plugin'] = function(fn, options) { - TPS.push({ - options: options, - fn: fn - }); - }; - ctor[PROP_MAP.h] = Object.create(exts[PROP_MAP.h]); - ctor[PROP_MAP.h].constructor = ctor; -} -function _$isType(value, type) { - return _$type(type) === 'string' ? type.split('|').some(function(t) { - return t.trim() === _$type(value); - }) : value instanceof type; -} -function _$isObject(obj) { - return _$isType(obj, 'object'); -} -function _$isArray(obj) { - return Array.isArray ? Array.isArray(obj) : _$isType(obj, 'array'); -} -function _$isFunction(obj) { - return _$isType(obj, 'function'); -} -function _$isStr(obj) { - return _$isType(obj, 'string'); -} -function _$toType(value, type, root, key) { - switch (type) { - case 'date': - return new Date(value); - case 'string': - return _$toStr(value); - case 'number': - return +value; - case 'boolean': - return _$isStr(value) && !value ? true : !!value; - case 'array': - return _$isType(value, _$List) ? value : new _$List(value, root, key); - default: - return value; - } -} -function _$type(obj) { - return / (\w+)/.exec({}.toString.call(obj))[1].toLowerCase(); -} -function _$hasProp(obj, prop) { - return obj.hasOwnProperty(prop); -} -function _$drt(dd) { - var hasProp = function(prop, instance, options, element) { - return _$isObject(dd) && dd[prop] && dd[prop](instance, options, element); - }; - return { - $init: function(instance, options, element) { - hasProp('$init', instance, options, element); - }, - - $inserted: function(instance, options, element) { - hasProp('$inserted', instance, options, element); - }, - - $update: function(instance, options, element) { - if (_$isFunction(dd)) { - dd(instance, options, element); - } else { - hasProp('$update', instance, options, element); - } - }, - - $destroy: function(instance, options, element) { - hasProp('$destroy', instance, options, element); - } - }; -} -function _$toStr(obj) { - var str = _$type(obj); - return !/null|undefined/.test(str) ? obj.toString() : str; -} -function _$toPlainObj(obj) { - var data = {}; - _$e(_$isObject(obj) ? obj : {}, function(_v, k) { - if (k[0] !== '$' && !_$isFunction(obj[k])) { - if (_$isType(obj[k], _$List)) { - data[k] = obj[k].map(_$toPlainObj); - } else if (_$isObject(obj[k])) { - data[k] = _$toPlainObj(obj[k]); - } else { - data[k] = obj[k]; - } - } - }); - return _$isObject(obj) ? data : obj; -} -function _$accesor(object, path, value) { - return path.split('.').reduce(function(obj, key, i, arr) { - if (_$isType(value, 'undefined')) { - if (obj == null) { - arr.splice(0, arr.length); - return i > 0 && obj === null ? obj : undefined; - } - } else { - if (i === arr.length - 1) { - if (_$isType(obj, _$List) && _$toStr(+key) === key) { - obj.pull(+key, value); - } else { - var oldVal = obj[key]; - obj[key] = !_$isType(value, _$List) && _$isArray(value) ? new _$List(value, object, key) : value; - _$dispatch(object, path, oldVal, obj[key]); - } - } else if (!_$isObject(obj[key])) { - obj[key] = {}; - } - } - return obj ? obj[key] : null; - }, object); -} -function _$(selector, parent) { - return _$isStr(selector) ? (parent || document).querySelector(selector) : selector; -} -function _$d() { - return document.createDocumentFragment(); -} -function _$a(parent, child, sibling) { - if (_$isType(sibling, 'boolean') && sibling) - parent.parentElement.replaceChild(child, parent); - else if (!sibling) - parent.appendChild(child); - else - parent.insertBefore(child, sibling); -} -function _$ce(tagName) { - return document.createElement(tagName || 'div'); -} -function _$ct(content) { - return document.createTextNode(content || ''); -} -function _$sa(el, attrAndValue) { - var attr = attrAndValue[0], value = attrAndValue[1]; - el.setAttribute(attr, _$toStr(value)); - if (_$isValueAttr(attr) && !_$isStr(value)) - el[PROP_MAP._] = value; -} -function _$tu(text, value) { - if (text.data !== (value = _$toStr(value))) - text.data = value; -} -function _$f(root, obj, loop) { - var items = {}, loopParent, loopSibling; - var globs = _$toArgs(arguments, 3); - _$e(obj, function(item, i) { - items[i] = loop.apply(null, [root, item, i].concat(globs)); - }); - return { - $create: function() { - _$e(items, function(item) { - item.$create(); - }); - }, - - $mount: function(parent, sibling) { - loopParent = _$(parent); - loopSibling = _$(sibling); - _$e(items, function(item) { - item.$mount(loopParent, loopSibling); - }); - }, - - $update: function(root, obj) { - var globs = _$toArgs(arguments, 2); - _$e(items, function(item, i) { - if (obj[i]) { - item.$update.apply(item, [root, obj[i], i].concat(globs)); - } else { - item.$destroy(); - delete items[i]; - } - }); - _$e(obj, function(item, i) { - if (!items[i]) { - items[i] = loop.apply(null, [root, item, i].concat(globs)); - items[i].$create(); - items[i].$mount(loopParent, loopSibling); - } - }); - }, - - $destroy: function() { - _$e(items, function(item) { - item.$destroy(); - }); - } - }; -} -function _$e(obj, cb) { - for (var key in obj) { - if (_$hasProp(obj, key)) { - cb(obj[key], isNaN(+key) ? key : +key); - } - } -} -function itemLoop_1(_$state, item) { - var _$frag, li_1, txt_1, setTxt_1; - _$frag = _$d(); - setTxt_1 = function(_$state, item) { - return item; - }; - return { - $create: function() { - li_1 = _$ce('li'); - txt_1 = _$ct(); - txt_1.data = setTxt_1(_$state, item); - }, - - $mount: function(parent, sibling) { - this.$unmount(); - _$a(_$(parent), _$frag, _$(sibling)); - }, - - $update: function(_$state, item) { - _$tu(txt_1, setTxt_1(_$state, item)); - }, - - $unmount: function() { - _$a(li_1, txt_1); - _$a(_$frag, li_1); - }, - - $destroy: function() { - this.$unmount(); - _$frag = li_1 = txt_1 = setTxt_1 = void 0; - } - }; -} -function itemLoop_2(_$state, item) { - var _$frag, li_1, txt_1, setTxt_1; - _$frag = _$d(); - setTxt_1 = function(_$state, item) { - return item; - }; - return { - $create: function() { - li_1 = _$ce('li'); - txt_1 = _$ct(); - txt_1.data = setTxt_1(_$state, item); - }, - - $mount: function(parent, sibling) { - this.$unmount(); - _$a(_$(parent), _$frag, _$(sibling)); - }, - - $update: function(_$state, item) { - _$tu(txt_1, setTxt_1(_$state, item)); - }, - - $unmount: function() { - _$a(li_1, txt_1); - _$a(_$frag, li_1); - }, - - $destroy: function() { - this.$unmount(); - _$frag = li_1 = txt_1 = setTxt_1 = void 0; - } - }; -} -function itemLoop_3(_$state, item) { - var _$frag, li_1, txt_1, setTxt_1; - _$frag = _$d(); - setTxt_1 = function(_$state, item) { - return item; - }; - return { - $create: function() { - li_1 = _$ce('li'); - txt_1 = _$ct(); - txt_1.data = setTxt_1(_$state, item); - }, - - $mount: function(parent, sibling) { - this.$unmount(); - _$a(_$(parent), _$frag, _$(sibling)); - }, - - $update: function(_$state, item) { - _$tu(txt_1, setTxt_1(_$state, item)); - }, - - $unmount: function() { - _$a(li_1, txt_1); - _$a(_$frag, li_1); - }, - - $destroy: function() { - this.$unmount(); - _$frag = li_1 = txt_1 = setTxt_1 = void 0; - } - }; -} -function itemLoop_4(_$state, item) { - var _$frag, li_1, txt_1, setTxt_1; - _$frag = _$d(); - setTxt_1 = function(_$state, item) { - return item; - }; - return { - $create: function() { - li_1 = _$ce('li'); - txt_1 = _$ct(); - txt_1.data = setTxt_1(_$state, item); - }, - - $mount: function(parent, sibling) { - this.$unmount(); - _$a(_$(parent), _$frag, _$(sibling)); - }, - - $update: function(_$state, item) { - _$tu(txt_1, setTxt_1(_$state, item)); - }, - - $unmount: function() { - _$a(li_1, txt_1); - _$a(_$frag, li_1); - }, - - $destroy: function() { - this.$unmount(); - _$frag = li_1 = txt_1 = setTxt_1 = void 0; - } - }; -} -function itemLoop_5(_$state, item) { - var _$frag, li_1, txt_1, setTxt_1; - _$frag = _$d(); - setTxt_1 = function(_$state, item) { - return item; - }; - return { - $create: function() { - li_1 = _$ce('li'); - txt_1 = _$ct(); - txt_1.data = setTxt_1(_$state, item); - }, - - $mount: function(parent, sibling) { - this.$unmount(); - _$a(_$(parent), _$frag, _$(sibling)); - }, - - $update: function(_$state, item) { - _$tu(txt_1, setTxt_1(_$state, item)); - }, - - $unmount: function() { - _$a(li_1, txt_1); - _$a(_$frag, li_1); - }, - - $destroy: function() { - this.$unmount(); - _$frag = li_1 = txt_1 = setTxt_1 = void 0; - } - }; -} -function _$tplLoop(_$state) { - var _$frag, ul_1, loopAnchor_1_1, loopBlock_1, ul_2, loopAnchor_2_1, loopBlock_2, ul_3, loopAnchor_3_1, loopBlock_3, ul_4, loopAnchor_4_1, loopBlock_4, ul_5, loopAnchor_5_1, loopBlock_5; - _$frag = _$d(); - loopBlock_1 = _$f(_$state, _$state.items, itemLoop_1); - loopAnchor_1_1 = _$ct(); - loopBlock_2 = _$f(_$state, _$state.object, itemLoop_2); - loopAnchor_2_1 = _$ct(); - loopBlock_3 = _$f(_$state, [1, 2, 3, 4, 5], itemLoop_3); - loopAnchor_3_1 = _$ct(); - loopBlock_4 = _$f(_$state, [0, 1, 2, 3, 4], itemLoop_4); - loopAnchor_4_1 = _$ct(); - loopBlock_5 = _$f(_$state, [0, 1, 2, 3, 4], itemLoop_5); - loopAnchor_5_1 = _$ct(); - return { - $create: function() { - ul_1 = _$ce('ul'); - loopBlock_1.$create(); - ul_2 = _$ce('ul'); - loopBlock_2.$create(); - ul_3 = _$ce('ul'); - loopBlock_3.$create(); - ul_4 = _$ce('ul'); - loopBlock_4.$create(); - ul_5 = _$ce('ul'); - loopBlock_5.$create(); - _$sa(ul_1, ['id', 'loop_1']); - _$sa(ul_2, ['id', 'loop_2']); - _$sa(ul_3, ['id', 'loop_3']); - _$sa(ul_4, ['id', 'loop_4']); - _$sa(ul_5, ['id', 'loop_5']); - }, - - $mount: function(parent, sibling) { - this.$unmount(); - _$a(_$(parent), _$frag, _$(sibling)); - this.$siblingEl = _$(sibling); - this.$parentEl = sibling && _$(sibling).parentElement || _$(parent); - }, - - $update: function(_$state) { - loopBlock_1.$update(_$state, _$state.items); - loopBlock_2.$update(_$state, _$state.object); - loopBlock_3.$update(_$state, [1, 2, 3, 4, 5]); - loopBlock_4.$update(_$state, [0, 1, 2, 3, 4]); - loopBlock_5.$update(_$state, [0, 1, 2, 3, 4]); - }, - - $unmount: function() { - _$a(ul_1, loopAnchor_1_1); - loopBlock_1.$mount(ul_1, loopAnchor_1_1); - _$a(_$frag, ul_1); - _$a(ul_2, loopAnchor_2_1); - loopBlock_2.$mount(ul_2, loopAnchor_2_1); - _$a(_$frag, ul_2); - _$a(ul_3, loopAnchor_3_1); - loopBlock_3.$mount(ul_3, loopAnchor_3_1); - _$a(_$frag, ul_3); - _$a(ul_4, loopAnchor_4_1); - loopBlock_4.$mount(ul_4, loopAnchor_4_1); - _$a(_$frag, ul_4); - _$a(ul_5, loopAnchor_5_1); - loopBlock_5.$mount(ul_5, loopAnchor_5_1); - _$a(_$frag, ul_5); - }, - - $destroy: function() { - this.$unmount(); - this.$parent = null; - this.$parentEl = null; - this.$siblingEl = null; - this.$children.splice(0, this.$children.length); - loopBlock_1.$destroy(); - loopBlock_2.$destroy(); - loopBlock_3.$destroy(); - loopBlock_4.$destroy(); - loopBlock_5.$destroy(); - delete _$state.$root; - _$frag = ul_1 = loopAnchor_1_1 = loopBlock_1 = ul_2 = loopAnchor_2_1 = loopBlock_2 = ul_3 = loopAnchor_3_1 = loopBlock_3 = ul_4 = loopAnchor_4_1 = loopBlock_4 = ul_5 = loopAnchor_5_1 = loopBlock_5 = void 0; - } - }; -} -function Loop(_$attrs, _$parent) { - _$CompCtr.call(this, _$attrs, _$tplLoop, { - model: { - items: [1, 2, 3, 4, 5], - - object: { - a: 'a', - b: 'b', - c: 'c', - d: 'd', - e: 'e' - } - } - }, _$parent); - !_$parent && this.$create(); -} -_$extends(Loop, _$CompCtr); -return Loop; - - }); \ No newline at end of file diff --git a/spec/helpers/setup.js b/spec/helpers/setup.js deleted file mode 100644 index 7aa10e6..0000000 --- a/spec/helpers/setup.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsdom_1 = require("jsdom"); -function copyProps(src, target) { - const props = Object.getOwnPropertyNames(src) - .filter(prop => typeof target[prop] === 'undefined') - .reduce((result, prop) => ({ - ...result, - [prop]: Object.getOwnPropertyDescriptor(src, prop), - }), {}); - Object.defineProperties(target, props); -} -global['window'] = new jsdom_1.JSDOM('
').window; -global['document'] = global['window'].document; -global['navigator'] = { - userAgent: 'NodeJS', - language: 'en' -}; -copyProps(window, global); diff --git a/spec/special attributes/bind_value.spec.js b/spec/special attributes/bind_value.spec.js deleted file mode 100644 index 350e95a..0000000 --- a/spec/special attributes/bind_value.spec.js +++ /dev/null @@ -1,45 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -require("../helpers/setup"); -const keysim_1 = require("keysim"); -const Component = require('../components/bind.umd'); -function fireClick(element) { - let event = new window['MouseEvent']('click', { bubbles: true, cancelable: true, view: window }); - element.dispatchEvent(event); -} -describe('Component Bind', () => { - let instance; - beforeAll(done => { - instance = new Component(); - instance.$mount('main'); - done(); - }); - it('`$name` in checkbox should add value to an array', () => { - let input = document.querySelector('#checkbox_1'); - fireClick(input); - expect(instance.checkboxes.length).toBe(1); - expect(instance.checkboxes[0]).toBe('Yes'); - }); - it('`$name` in a checked checkbox should remove value from the array', () => { - let input = document.querySelector('#checkbox_1'); - fireClick(input); - expect(instance.checkboxes.length).toBe(0); - }); - it('`$name` in a radio should change value of the property', () => { - let input = document.querySelector('#radio_1'); - fireClick(input); - expect(instance.radios).toBe('radio 1'); - }); - it('`$value` should change input value from model', () => { - instance.$set('textValue', 'some text'); - let input = document.querySelector('#text'); - expect(input.value).toBe('some text'); - }); - it('`input.value` should change input value in model', () => { - let input = document.querySelector('#text'); - let keyboard = keysim_1.Keyboard.US_ENGLISH; - input.value = input.value + ' to test'; - keyboard.dispatchEventsForInput(input.value, input); - expect(instance.textValue).toBe('some text to test'); - }); -}); diff --git a/spec/special attributes/condition.spec.js b/spec/special attributes/condition.spec.js deleted file mode 100644 index ddffb81..0000000 --- a/spec/special attributes/condition.spec.js +++ /dev/null @@ -1,35 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -require("../helpers/setup"); -const Component = require('../components/condition.umd'); -describe('Component Conditions', () => { - let instance, span, div; - beforeAll(done => { - instance = new Component(); - instance.$mount('main'); - done(); - }); - it('`$if` should be rendered', () => { - span = document.querySelector('span'); - expect(span.textContent).toBe('1'); - }); - it('`$else-if` should be rendered', () => { - instance.$set('condition', 2); - span = document.querySelector('span'); - expect(span.textContent).toBe('2'); - }); - it('`$else` should be rendered', () => { - instance.$set('condition', 3); - span = document.querySelector('span'); - expect(span.textContent).toBe('other'); - }); - it('`$if` only should be rendered', () => { - div = document.querySelector('div'); - expect(div.textContent).toBe('1'); - }); - it('`$if` only should be hidden', () => { - instance.$set('condition_1', 2); - div = document.querySelector('div'); - expect(div).toBeNull(); - }); -}); diff --git a/spec/special attributes/html.spec.js b/spec/special attributes/html.spec.js deleted file mode 100644 index 39d1ebe..0000000 --- a/spec/special attributes/html.spec.js +++ /dev/null @@ -1,29 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -require("../helpers/setup"); -const Component = require('../components/html.umd'); -describe('Component Html', () => { - let instance, divs; - beforeAll(done => { - instance = new Component(); - instance.$mount('main'); - done(); - }); - it('nodes without expression should be normally rendered', () => { - divs = document.querySelectorAll('div'); - let div = divs.item(0); - expect(div.innerHTML).toBe('

Here\'s a very interesting note displayed in a lovely shadowed box.

Any kind of content here. Such as <p>, <table>. You name it!

'); - }); - it('nodes with expression should not escape expressions', () => { - divs = document.querySelectorAll('div'); - let div_1 = divs.item(1), div_2 = divs.item(2); - expect(div_1.innerHTML).toBe('

Some paragraph with text undefined

'); - expect(div_2.innerHTML).toBe('

Some paragraph with undefined and undefined expressions

'); - }); - it('`$html` should escape expressions', () => { - divs = document.querySelectorAll('div'); - let div_1 = divs.item(3), div_2 = divs.item(4); - expect(div_1.innerHTML).toBe('

Some paragraph with text intentional {{escaped}}

'); - expect(div_2.innerHTML).toBe('

Some paragraph with text from {{model}}

'); - }); -}); diff --git a/spec/special attributes/loop.spec.js b/spec/special attributes/loop.spec.js deleted file mode 100644 index 57ec189..0000000 --- a/spec/special attributes/loop.spec.js +++ /dev/null @@ -1,55 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -require("../helpers/setup"); -const Component = require('../components/loop.umd'); -describe('Component Loop', () => { - let instance, items; - beforeAll(done => { - instance = new Component(); - instance.$mount('main'); - done(); - }); - it('should loop over an array variable', () => { - items = document.querySelectorAll('#loop_1 li'); - expect(items.length).toBe(5); - for (let i = 0; i < items.length; i++) { - expect(items.item(i).textContent).toBe(`${i + 1}`); - } - }); - it('should loop over an object', () => { - items = document.querySelectorAll('#loop_2 li'); - expect(items.length).toBe(5); - expect(items.item(0).textContent).toBe('a'); - expect(items.item(4).textContent).toBe('e'); - }); - it('should loop over an array', () => { - items = document.querySelectorAll('#loop_3 li'); - expect(items.length).toBe(5); - for (let i = 0; i < items.length; i++) { - expect(items.item(i).textContent).toBe(`${i + 1}`); - } - }); - it('should loop over a number', () => { - items = document.querySelectorAll('#loop_4 li'); - expect(items.length).toBe(5); - for (let i = 0; i < items.length; i++) { - expect(items.item(i).textContent).toBe(`${i}`); - } - }); - it('should loop over a range of numbers', () => { - items = document.querySelectorAll('#loop_5 li'); - expect(items.length).toBe(5); - for (let i = 0; i < items.length; i++) { - expect(items.item(i).textContent).toBe(`${i}`); - } - }); - it('items should be modified', () => { - instance.items.splice(3, 1); - items = document.querySelectorAll('#loop_1 li'); - expect(items.length).toBe(4); - expect(items.item(0).textContent).toBe('1'); - expect(items.item(1).textContent).toBe('2'); - expect(items.item(2).textContent).toBe('3'); - expect(items.item(3).textContent).toBe('5'); - }); -}); diff --git a/spec/support/jasmine.json b/spec/support/jasmine.json deleted file mode 100644 index 3ea3166..0000000 --- a/spec/support/jasmine.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "spec_dir": "spec", - "spec_files": [ - "**/*[sS]pec.js" - ], - "helpers": [ - "helpers/**/*.js" - ], - "stopSpecOnExpectationFailure": false, - "random": false -} diff --git a/specs/components/readme.txt b/specs/components/readme.txt new file mode 100644 index 0000000..9af0551 --- /dev/null +++ b/specs/components/readme.txt @@ -0,0 +1 @@ +Spec Components folder \ No newline at end of file diff --git a/test/basic usage/init.html b/test/basic usage/init.html deleted file mode 100644 index 9a2513c..0000000 --- a/test/basic usage/init.html +++ /dev/null @@ -1,9 +0,0 @@ -

Hello, {{ text }}!!

- - \ No newline at end of file diff --git a/test/components/bind.html b/test/components/bind.html new file mode 100644 index 0000000..e2d9f87 --- /dev/null +++ b/test/components/bind.html @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/special attributes/components/condition.html b/test/components/condition.html similarity index 100% rename from test/special attributes/components/condition.html rename to test/components/condition.html diff --git a/test/special attributes/components/html.html b/test/components/html.html similarity index 100% rename from test/special attributes/components/html.html rename to test/components/html.html diff --git a/test/basic usage/components/init.html b/test/components/init.html similarity index 100% rename from test/basic usage/components/init.html rename to test/components/init.html diff --git a/test/components/interpolation.html b/test/components/interpolation.html new file mode 100644 index 0000000..eef0191 --- /dev/null +++ b/test/components/interpolation.html @@ -0,0 +1,13 @@ +
Test interpolation with {{ text_1 }}.
+Test interpolation with {{ text_1 }} {{ text_2 }} {{ text_3 }} +

Test {{ text_1 }} with {{ text_3 }} and some expresions with {{ text_2.toUpperCase() }}

+ + \ No newline at end of file diff --git a/test/components/loop.html b/test/components/loop.html new file mode 100644 index 0000000..b327045 --- /dev/null +++ b/test/components/loop.html @@ -0,0 +1,58 @@ +
    +
  • {{ item }}
  • +
+ +
    +
  • {{ item }}
  • +
+ +
    +
  • {{ item }}
  • +
+ +
    +
  • {{ item }}
  • +
+ +
    +
  • {{ item }}
  • +
+ +
    +
  • {{i + 1}} {{ item }}
  • +
+ +
    +
  • + {{ index + 1 }}. {{ key }}: {{ value }} +
  • +
+ +
    +
  • {{ i + 1 }} {{ item }}
  • +
+ +
    +
  • {{ i + 1 }} {{ item }}
  • +
+ +
    +
  • {{ i + 1 }} {{ item }}
  • +
+ +
    +
  • + + {{ `${i + 1}.${item}.${index + 1} - ${key}: ${value}` }} + +
  • +
+ + \ No newline at end of file diff --git a/test/helpers/setup.ts b/test/helpers/setup.ts deleted file mode 100644 index 41e143f..0000000 --- a/test/helpers/setup.ts +++ /dev/null @@ -1,21 +0,0 @@ - -import { JSDOM } from 'jsdom'; - -function copyProps(src, target) { - const props = Object.getOwnPropertyNames(src) - .filter(prop => typeof target[prop] === 'undefined') - .reduce((result, prop) => ({ - ...result, - [prop]: Object.getOwnPropertyDescriptor(src, prop), - }), {}); - Object.defineProperties(target, props); -} - -global['window'] = new JSDOM('
').window; -global['document'] = global['window'].document; -global['navigator'] = { - userAgent: 'NodeJS', - language: 'en' -}; - -copyProps(window, global); \ No newline at end of file diff --git a/test/special attributes/bind_value.spec.ts b/test/special attributes/bind_value.spec.ts deleted file mode 100644 index 59f0986..0000000 --- a/test/special attributes/bind_value.spec.ts +++ /dev/null @@ -1,51 +0,0 @@ -import '../helpers/setup'; -import { Keyboard } from 'keysim'; -const Component = require('../components/bind.umd'); - -function fireClick(element: Element) { - let event = new window['MouseEvent']('click', { bubbles: true, cancelable: true, view: window }); - element.dispatchEvent(event); -} - -describe('Component Bind', () => { - let instance; - - beforeAll(done => { - instance = new Component(); - instance.$mount('main'); - done(); - }); - - it('`$name` in checkbox should add value to an array', () => { - let input: HTMLInputElement = document.querySelector('#checkbox_1'); - fireClick(input); - expect(instance.checkboxes.length).toBe(1); - expect(instance.checkboxes[0]).toBe('Yes'); - }); - - it('`$name` in a checked checkbox should remove value from the array', () => { - let input: HTMLInputElement = document.querySelector('#checkbox_1'); - fireClick(input); - expect(instance.checkboxes.length).toBe(0); - }); - - it('`$name` in a radio should change value of the property', () => { - let input: HTMLInputElement = document.querySelector('#radio_1'); - fireClick(input); - expect(instance.radios).toBe('radio 1'); - }); - - it('`$value` should change input value from model', () => { - instance.$set('textValue', 'some text'); - let input: HTMLInputElement = document.querySelector('#text'); - expect(input.value).toBe('some text'); - }); - - it('`input.value` should change input value in model', () => { - let input: HTMLInputElement = document.querySelector('#text'); - let keyboard = Keyboard.US_ENGLISH; - input.value = input.value + ' to test'; - keyboard.dispatchEventsForInput(input.value, input); - expect(instance.textValue).toBe('some text to test'); - }); -}); \ No newline at end of file diff --git a/test/special attributes/components/bind.html b/test/special attributes/components/bind.html deleted file mode 100644 index 6d63c9c..0000000 --- a/test/special attributes/components/bind.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/test/special attributes/components/loop.html b/test/special attributes/components/loop.html deleted file mode 100644 index 46d3c44..0000000 --- a/test/special attributes/components/loop.html +++ /dev/null @@ -1,28 +0,0 @@ -
    -
  • {{ item }}
  • -
- -
    -
  • {{ item }}
  • -
- -
    -
  • {{ item }}
  • -
- -
    -
  • {{ item }}
  • -
- -
    -
  • {{ item }}
  • -
- - \ No newline at end of file diff --git a/test/special attributes/loop.spec.ts b/test/special attributes/loop.spec.ts deleted file mode 100644 index 7839762..0000000 --- a/test/special attributes/loop.spec.ts +++ /dev/null @@ -1,61 +0,0 @@ -import '../helpers/setup'; -const Component = require('../components/loop.umd'); - -describe('Component Loop', () => { - let instance, items: NodeListOf; - - beforeAll(done => { - instance = new Component(); - instance.$mount('main'); - done(); - }); - - it('should loop over an array variable', () => { - items = document.querySelectorAll('#loop_1 li'); - expect(items.length).toBe(5); - for (let i = 0; i < items.length; i++) { - expect(items.item(i).textContent).toBe(`${i + 1}`); - } - }); - - it('should loop over an object', () => { - items = document.querySelectorAll('#loop_2 li'); - expect(items.length).toBe(5); - expect(items.item(0).textContent).toBe('a'); - expect(items.item(4).textContent).toBe('e'); - }); - - it('should loop over an array', () => { - items = document.querySelectorAll('#loop_3 li'); - expect(items.length).toBe(5); - for (let i = 0; i < items.length; i++) { - expect(items.item(i).textContent).toBe(`${i + 1}`); - } - }); - - it('should loop over a number', () => { - items = document.querySelectorAll('#loop_4 li'); - expect(items.length).toBe(5); - for (let i = 0; i < items.length; i++) { - expect(items.item(i).textContent).toBe(`${i}`); - } - }); - - it('should loop over a range of numbers', () => { - items = document.querySelectorAll('#loop_5 li'); - expect(items.length).toBe(5); - for (let i = 0; i < items.length; i++) { - expect(items.item(i).textContent).toBe(`${i}`); - } - }); - - it('items should be modified', () => { - instance.items.splice(3, 1); - items = document.querySelectorAll('#loop_1 li'); - expect(items.length).toBe(4); - expect(items.item(0).textContent).toBe('1'); - expect(items.item(1).textContent).toBe('2'); - expect(items.item(2).textContent).toBe('3'); - expect(items.item(3).textContent).toBe('5'); - }); -}); \ No newline at end of file diff --git a/test/src/helpers/config.ts b/test/src/helpers/config.ts new file mode 100644 index 0000000..e8af8c7 --- /dev/null +++ b/test/src/helpers/config.ts @@ -0,0 +1,2 @@ +export const specs = 'specs/spec/**/*.spec.js'; +export const components = 'specs/components/**/*.iif.js'; \ No newline at end of file diff --git a/test/src/helpers/setup.ts b/test/src/helpers/setup.ts new file mode 100644 index 0000000..aff13fd --- /dev/null +++ b/test/src/helpers/setup.ts @@ -0,0 +1,41 @@ +import { join } from 'path'; +import glob = require('glob'); +import { writeFileSync } from 'fs'; +import { specs, components } from './config'; + +const jasmineCoreDir = '../node_modules/jasmine-core'; + +glob(specs, (err, test) => { + if (err) console.log(err); + glob(components, (err, utils) => { + if (err) console.log(err); + writeFileSync(join(__dirname, '../test.html'), ` + + + + Jasmine Spec Runner v3.2.1 + + + + + + + + + ${insertScripts(utils)} + + ${insertScripts(test)} + + +
+ +`, 'utf8'); + }); +}); + +function insertScripts(scripts: string[]) { + return scripts.map(u => ``).join('\n '); +} diff --git a/test/src/run.ts b/test/src/run.ts new file mode 100644 index 0000000..2dfe27f --- /dev/null +++ b/test/src/run.ts @@ -0,0 +1,98 @@ +let system = require('system'); + +if (system.args.length !== 2) { + console.log('Usage: test.js URL'); + phantom.exit(1); +} + +let page = require('webpage').create(); + +page.onConsoleMessage = msg => { + console.log(msg); +}; + +page.open(system.args[1], status => { + if (status !== 'success') { + console.log(`Unable to access to '${system.args[1]}'`); + phantom.exit(); + } else { + waitFor(() => page.evaluate(() => window['jsApiReporter'].status() === 'done'), () => { + let exitCode = page.evaluate(() => { + function padString(str: string, chars: string, length: number) { + for (let i = 0; i < length; i++) str += chars; + return str; + } + + function $(sel: string, parent?: HTMLElement) { + return (parent || document.body).querySelector(sel); + } + + console.log(''); + + let version = $('.jasmine-version').innerText; + let duration = $('.jasmine-duration').innerText; + console.log(`Jasmine v${version} - ${duration}`); + + let symbols = $('.jasmine-symbol-summary'); + let symbs = ''; + for (let i = 0; i < symbols.children.length; i++) { + let sym = symbols.children[i]; + symbs += sym.classList.contains('jasmine-passed') ? 'o ' : 'x '; + } + let pad = padString('', '-', symbs.length - 1); + console.log(pad); + console.log(symbs.trim()); + console.log(pad); + + let failures = $('.jasmine-results > .jasmine-failures'); + if (failures.children.length > 0) { + let list = failures.querySelectorAll('.jasmine-spec-detail.jasmine-failed'); + if (list && list.length > 0) { + console.log(''); + console.log(`${list.length} test${list.length > 1 ? 's' : ''} of ${symbols.children.length} FAILED:`); + for (let i = 0; i < list.length; ++i) { + let el = list[i], desc = $('.jasmine-description', el), + msg = $('.jasmine-messages > .jasmine-result-message', el), + stack = $('.jasmine-messages > .jasmine-stack-trace', el); + console.log(''); + let d = ''; + let descs = desc.innerText.split(' > '); + for (let j = 0; j < descs.length; j++) { + d += `${padString('', ' ', j ? j + 3 : 0)}${j === 0 ? `${i + 1}) ` : ''}- ${descs[j]}\n`; + } + console.log(d); + console.log(msg.innerText); + console.log(' on file:', stack.innerText.replace(//g, '').replace('file:///', '').trim()); + (i + 1) === list.length && console.log(''); + } + } + return 1; + } else { + console.log($('.jasmine-bar.jasmine-passed').innerText); + return 0; + } + }); + !exitCode && console.log(''); + console.log(`Tests finished ${exitCode ? 'with errors' : 'successfully'}.`); + exitCode && console.log(''); + phantom.exit(exitCode); + }, 30000); + } +}); + +function waitFor(testFx: string | (() => any), onReady: string | (() => any), timeOutMillis?: number) { + let maxtimeOutMillis = timeOutMillis || 3001, start = new Date().getTime(), condition = false, + interval = setInterval(() => { + if ((new Date().getTime() - start < maxtimeOutMillis) && !condition) { + condition = typeof testFx === 'string' ? eval(testFx) : testFx(); + } else { + if (!condition) { + console.log('Test took too much time to execute'); + phantom.exit(1); + } else { + typeof onReady === 'string' ? eval(onReady) : onReady(); + clearInterval(interval); + } + } + }, 100); +} diff --git a/test/src/spec/bind_value.spec.ts b/test/src/spec/bind_value.spec.ts new file mode 100644 index 0000000..64c09ee --- /dev/null +++ b/test/src/spec/bind_value.spec.ts @@ -0,0 +1,107 @@ +function fireEvent(el: HTMLElement, name: string, type?: string) { // element to click on + // Create the event. + var event = document.createEvent(`${type ? type[0].toUpperCase() + type.slice(1) : ''}Event`); + // Define that the event name is 'build'. + event.initEvent(name, true, true); + // target can be any Element or other EventTarget. + return el.dispatchEvent(event); +} + +describe('Component Bind', () => { + let instance; + + beforeEach(done => { + instance = new Bind(); + instance.$mount('main'); + done(); + }); + + afterEach(done => { + instance && instance.$destroy(); + done(); + }); + + describe('$name directive', () => { + describe('in checked checkbox', () => { + it('should add value to an array', () => { + let input: HTMLInputElement = document.querySelector('#checkbox_1'); + fireEvent(input, 'click', 'mouse'); + expect(instance.checkboxes.length).toBe(1); + expect(instance.checkboxes[0]).toBe('Yes'); + }); + + it('with bond value should add object to an array', () => { + let input: HTMLInputElement = document.querySelector('#checkbox_3'); + fireEvent(input, 'click', 'mouse'); + expect(instance.checkboxes_1.length).toBe(1); + let obj = instance.checkboxes_1[0]; + expect(obj).toBeDefined(); + expect(typeof obj).toBe('object'); + expect(obj).toEqual({ value: 'Yes' }); + }); + }); + + describe('in a unchecked checkbox', () => { + it('should remove value from the array', () => { + let input: HTMLInputElement = document.querySelector('#checkbox_1'); + fireEvent(input, 'click', 'mouse'); + fireEvent(input, 'click', 'mouse'); + expect(instance.checkboxes.length).toBe(0); + }); + + it('with bond value should remove value from the array', () => { + let input: HTMLInputElement = document.querySelector('#checkbox_4'); + fireEvent(input, 'click', 'mouse'); + fireEvent(input, 'click', 'mouse'); + expect(instance.checkboxes_1.length).toBe(0); + }); + }); + + describe('in a checked radio', () => { + it('should assign value to the property', () => { + let input: HTMLInputElement = document.querySelector('#radio_1'); + fireEvent(input, 'click', 'mouse'); + expect(instance.radios).toBe('radio 1'); + }); + + it('with bond value should assign the object value to the property', () => { + let input: HTMLInputElement = document.querySelector('#radio_5'); + fireEvent(input, 'click', 'mouse'); + let obj = instance.radios_1; + expect(obj).toBeDefined(); + expect(typeof obj).toBe('object'); + expect(obj).toEqual({ value: 'radio 5' }); + }); + }); + }); + + describe('$value directive', () => { + it('should change text input value from model', () => { + instance.$set('textValue', 'some text'); + let input: HTMLInputElement = document.querySelector('#text'); + expect(input.value).toBe('some text'); + }); + + it('should change number input value from model', () => { + instance.$set('numValue', 10); + let input: HTMLInputElement = document.querySelector('#number'); + expect(input.value).toBe('10'); + }); + }); + + describe('input.value', () => { + it('should change text input value in model', () => { + let input: HTMLInputElement = document.querySelector('#text'); + input.value = 'text test'; + fireEvent(input, 'input'); + expect(instance.textValue).toBe('text test'); + }); + + it('should change number input value in model', () => { + let input: HTMLInputElement = document.querySelector('#number'); + input.value = '5'; + fireEvent(input, 'input'); + expect(instance.numValue).toBe(5); + }); + }); +}); \ No newline at end of file diff --git a/test/special attributes/condition.spec.ts b/test/src/spec/condition.spec.ts similarity index 65% rename from test/special attributes/condition.spec.ts rename to test/src/spec/condition.spec.ts index 5affc92..a1ec65c 100644 --- a/test/special attributes/condition.spec.ts +++ b/test/src/spec/condition.spec.ts @@ -1,40 +1,42 @@ -import '../helpers/setup'; -const Component = require('../components/condition.umd'); - describe('Component Conditions', () => { let instance, span: HTMLSpanElement, div: HTMLDivElement; - beforeAll(done => { - instance = new Component(); + beforeEach(done => { + instance = new Condition(); instance.$mount('main'); done(); }); + afterEach(done => { + instance && instance.$destroy(); + done(); + }); + it('`$if` should be rendered', () => { - span = document.querySelector('span'); + span = document.querySelector('main span'); expect(span.textContent).toBe('1'); }); it('`$else-if` should be rendered', () => { instance.$set('condition', 2); - span = document.querySelector('span'); + span = document.querySelector('main span'); expect(span.textContent).toBe('2'); }); it('`$else` should be rendered', () => { instance.$set('condition', 3); - span = document.querySelector('span'); + span = document.querySelector('main span'); expect(span.textContent).toBe('other'); }); it('`$if` only should be rendered', () => { - div = document.querySelector('div'); + div = document.querySelector('main div'); expect(div.textContent).toBe('1'); }); it('`$if` only should be hidden', () => { instance.$set('condition_1', 2); - div = document.querySelector('div'); + div = document.querySelector('main div'); expect(div).toBeNull(); }); }); \ No newline at end of file diff --git a/test/special attributes/html.spec.ts b/test/src/spec/html.spec.ts similarity index 89% rename from test/special attributes/html.spec.ts rename to test/src/spec/html.spec.ts index 827fd21..890f6c3 100644 --- a/test/special attributes/html.spec.ts +++ b/test/src/spec/html.spec.ts @@ -1,15 +1,17 @@ -import '../helpers/setup'; -const Component = require('../components/html.umd'); - describe('Component Html', () => { let instance, divs: NodeListOf; - beforeAll(done => { - instance = new Component(); + beforeEach(done => { + instance = new Html(); instance.$mount('main'); done(); }); + afterEach(done => { + instance && instance.$destroy(); + done(); + }); + it('nodes without expression should be normally rendered', () => { divs = document.querySelectorAll('div'); let div = divs.item(0); diff --git a/test/basic usage/initialize.spec.ts b/test/src/spec/initialize.spec.ts similarity index 75% rename from test/basic usage/initialize.spec.ts rename to test/src/spec/initialize.spec.ts index da2368f..092d117 100644 --- a/test/basic usage/initialize.spec.ts +++ b/test/src/spec/initialize.spec.ts @@ -1,21 +1,18 @@ -import '../helpers/setup'; -const Component = require('../components/init.umd'); - describe('Component', () => { it('should be a function constructor', () => { - expect(Component).not.toBeNull(); - expect(typeof Component).toBe('function'); + expect(Init).not.toBeNull(); + expect(typeof Init).toBe('function'); }); it('should get an instance when is used with new', () => { - let instance = new Component(); + let instance = new Init(); expect(typeof instance).toBe('object'); - expect(instance.constructor).toEqual(Component); + expect(instance.constructor).toEqual(Init); }); it('instance should have prototype methods', () => { - let instance = new Component(); + let instance = new Init(); expect('$refs' in instance).toBeTruthy(); expect('$create' in instance).toBeTruthy(); expect('$mount' in instance).toBeTruthy(); @@ -27,7 +24,7 @@ describe('Component', () => { }); it('instance should have option properties', () => { - let instance = new Component(); + let instance = new Init(); expect('text' in instance).toBeTruthy(); expect(instance.text).toBe('World'); }); @@ -35,16 +32,16 @@ describe('Component', () => { describe('Component Instance', () => { let instance, main; - beforeAll(done => { - instance = new Component(); + beforeEach(done => { + instance = new Init(); main = document.querySelector('main'); done(); }); - afterEach(done => { - instance.$unmount(); - done(); - }); + afterEach(done => { + instance && instance.$destroy(); + done(); + }); it('should be mounted in an element selector', () => { instance.$mount('main'); @@ -72,8 +69,8 @@ describe('Component Instance', () => { it('should not update the view correctly if `$set` method is not used', () => { instance.$mount('main'); - let h1 = main.firstChild; - instance.text = 'World'; - expect(h1.textContent).toBe('Hello, Somebody!!'); + let h1 = main.firstChild; + instance.text = 'Somebody'; + expect(h1.textContent).toBe('Hello, World!!'); }); }); diff --git a/test/src/spec/interpolation.spec.ts b/test/src/spec/interpolation.spec.ts new file mode 100644 index 0000000..74c9f2a --- /dev/null +++ b/test/src/spec/interpolation.spec.ts @@ -0,0 +1,23 @@ +describe('Component Text interpolation', () => { + let instance; + + beforeEach(done => { + instance = new Interpolation(); + instance.$mount('main'); + done(); + }); + + afterEach(done => { + instance && instance.$destroy(); + done(); + }); + + it('should render text correctly', () => { + let text_1 = document.querySelector('#text_1'); + let text_2 = document.querySelector('#text_2'); + let text_3 = document.querySelector('#text_3'); + expect(text_1.textContent).toBe('Test interpolation with some text.'); + expect(text_2.textContent).toBe('Test interpolation with some text and some text with quote \' and double quote "'); + expect(text_3.textContent).toBe('Test some text with some text with quote \' and double quote " and some expresions with AND'); + }); +}); \ No newline at end of file diff --git a/test/src/spec/loop.spec.ts b/test/src/spec/loop.spec.ts new file mode 100644 index 0000000..08431f4 --- /dev/null +++ b/test/src/spec/loop.spec.ts @@ -0,0 +1,114 @@ +describe('Component Loop', () => { + let instance, items: NodeListOf; + + beforeEach(done => { + instance = new Loop(); + instance.$mount('main'); + done(); + }); + + afterEach(done => { + instance && instance.$destroy(); + done(); + }); + + it('should loop over an array variable', () => { + items = document.querySelectorAll('#loop_1 li'); + expect(items.length).toBe(5); + for (let i = 0; i < items.length; i++) { + expect(items.item(i).textContent).toBe(`${i + 1}`); + } + }); + + it('should loop over an object', () => { + items = document.querySelectorAll('#loop_2 li'); + expect(items.length).toBe(5); + expect(items.item(0).textContent).toBe('a'); + expect(items.item(4).textContent).toBe('e'); + }); + + it('should loop over an array', () => { + items = document.querySelectorAll('#loop_3 li'); + expect(items.length).toBe(5); + for (let i = 0; i < items.length; i++) { + expect(items.item(i).textContent).toBe(`${i + 1}`); + } + }); + + it('should loop over a number', () => { + items = document.querySelectorAll('#loop_4 li'); + expect(items.length).toBe(5); + for (let i = 0; i < items.length; i++) { + expect(items.item(i).textContent).toBe(`${i}`); + } + }); + + it('should loop over a range of numbers', () => { + items = document.querySelectorAll('#loop_5 li'); + expect(items.length).toBe(5); + for (let i = 0; i < items.length; i++) { + expect(items.item(i).textContent).toBe(`${i}`); + } + }); + + it('should loop over an array variable with the given index', () => { + items = document.querySelectorAll('#loop_6 li'); + expect(items.length).toBe(5); + for (let i = 0; i < items.length; i++) { + expect(items.item(i).textContent).toBe(`${i + 1} ${i + 1}`); + } + }); + + it('should loop over an object with the given index', () => { + items = document.querySelectorAll('#loop_7 li'); + expect(items.length).toBe(5); + expect(items.item(0).textContent).toBe('1. a: a'); + expect(items.item(4).textContent).toBe('5. e: e'); + }); + + it('should loop over an array with the given index', () => { + items = document.querySelectorAll('#loop_8 li'); + expect(items.length).toBe(5); + for (let i = 0; i < items.length; i++) { + expect(items.item(i).textContent).toBe(`${i + 1} ${i + 1}`); + } + }); + + it('should loop over a number with the given index', () => { + items = document.querySelectorAll('#loop_9 li'); + expect(items.length).toBe(5); + for (let i = 0; i < items.length; i++) { + expect(items.item(i).textContent).toBe(`${i + 1} ${i}`); + } + }); + + it('should loop over a range of numbers with the given index', () => { + items = document.querySelectorAll('#loop_10 li'); + expect(items.length).toBe(5); + for (let i = 0; i < items.length; i++) { + expect(items.item(i).textContent).toBe(`${i + 1} ${i}`); + } + }); + + it('nested loops should render with the according scope', () => { + items = document.querySelectorAll('#loop_11 li'); + expect(items.length).toBe(5); + for (let i = 0; i < items.length; i++) { + let { children } = items.item(i); + expect(children.length).toBe(5); + for (let j = 0; j < children.length; j++) { + expect(!!~children[j].textContent.indexOf(`${i + 1}.${i + 1}.${j + 1}`)).toBeTruthy(); + } + } + }); + + it('items should be modified', () => { + instance.items.splice(3, 1); + items = document.querySelectorAll('#loop_1 li'); + expect(items.length).toBe(4); + expect(items.item(0).textContent).toBe('1'); + expect(items.item(1).textContent).toBe('2'); + expect(items.item(2).textContent).toBe('3'); + expect(items.item(3).textContent).toBe('5'); + }); +}); \ No newline at end of file diff --git a/test/tsconfig.json b/test/src/tsconfig.json similarity index 90% rename from test/tsconfig.json rename to test/src/tsconfig.json index ea1514d..cf5eee9 100644 --- a/test/tsconfig.json +++ b/test/src/tsconfig.json @@ -1,16 +1,16 @@ { "compilerOptions": { /* Basic Options */ - "target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ - // "lib": [], /* Specify library files to be included in the compilation. */ + "lib": ["dom", "es5"], /* Specify library files to be included in the compilation. */ // "allowJs": true, /* Allow javascript files to be compiled. */ // "checkJs": true, /* Report errors in .js files. */ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ // "declaration": true, /* Generates corresponding '.d.ts' file. */ "sourceMap": false, /* Generates corresponding '.map' file. */ // "outFile": "./", /* Concatenate and emit output to single file. */ - "outDir": "../spec", /* Redirect output structure to the directory. */ + "outDir": "../../specs", /* Redirect output structure to the directory. */ "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ "removeComments": true, /* Do not emit comments to output. */ // "noEmitOnError": true, /* Do not emit outputs. */ @@ -36,7 +36,7 @@ // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ // "typeRoots": [], /* List of folders to include type definitions from. */ - // "types": [], /* Type declaration files to be included in compilation. */ + "types": ["../../node_modules/@types/jasmine"], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ diff --git a/test/src/types.d.ts b/test/src/types.d.ts new file mode 100644 index 0000000..cacde02 --- /dev/null +++ b/test/src/types.d.ts @@ -0,0 +1,49 @@ +declare var phantom: { + exit(code?: number): void; +} + +interface Component { + $set(key: string, value: any): void; + $destroy(): void; + $mount(parent: HTMLElement, sibling?: HTMLElement | boolean): void; + [key: string]: any; +} + +interface ComponentConstructor { + new(...args: any[]): Component; +} + +declare const Bind: ComponentConstructor; +declare const Html: ComponentConstructor; +declare const Init: ComponentConstructor; +declare const Loop: ComponentConstructor; +declare const Condition: ComponentConstructor; +declare const Interpolation: ComponentConstructor; + +declare module 'system' { + interface System { + args: string[] + } + + var system: System; + + export = system; +} + +declare module 'webpage' { + interface Page { + open(url: string, callback: (status: string) => any): void; + open(url: string, method: string, callback: (status: string) => any): void; + open(url: string, method: string, data: any, callback: (status: string) => any): void; + onConsoleMessage: (msg: string, lineNum?: number, sourceId?: string) => any; + evaluate(fn: Function, ...args: any[]): T; + } + + interface WebPage { + create(): Page + } + + var webPage: WebPage; + + export = webPage; +} From 4b7b20c422942a95ef497d2fc455abe36a9632e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Asiel=20Guevara=20Casta=C3=B1eda?= Date: Wed, 24 Oct 2018 16:21:55 -0400 Subject: [PATCH 07/13] Fixed property name as global --- examples/dynamic-component/dist/js/dynamic.js | 2 +- examples/dynamic-component/src/components/app.html | 2 +- examples/dynamic-component/src/components/blue.html | 4 ++-- examples/dynamic-component/src/components/green.html | 4 ++-- examples/dynamic-component/src/components/red.html | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/dynamic-component/dist/js/dynamic.js b/examples/dynamic-component/dist/js/dynamic.js index ab8bc57..3b0c32a 100644 --- a/examples/dynamic-component/dist/js/dynamic.js +++ b/examples/dynamic-component/dist/js/dynamic.js @@ -94,7 +94,7 @@ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("\n// CONCATENATED MODULE: d:/DEVELOP/Work in Progress/trebor-repos/trebor/tools/index.js\nvar _$assign = Object['assign'] || function (t) {\r\n for (var s = void 0, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s)\r\n if (_$hasProp(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n};\r\nfunction _$CompCtr(attrs, template, options, parent) {\r\n var self = this;\r\n var props = ['$slots', '$refs', '$filters', '$directives', '_events', '_watchers'];\r\n var _$set = function (prop, value) { _$def(self, prop, { value: value, writable: true }); };\r\n if (!attrs)\r\n attrs = {};\r\n _$e(props, function (prop) { _$def(self, prop, { value: {} }); });\r\n _$set('$parent', parent || null);\r\n _$set('$children', []);\r\n _$set('_subscribers', {});\r\n _$set('$options', options);\r\n var opts = self.$options;\r\n if (!opts.attrs)\r\n opts.attrs = {};\r\n if (!opts.children)\r\n opts.children = {};\r\n _$e(_$CompCtr['_plugins'], function (plugin) {\r\n plugin.fn.call(self, _$CompCtr, plugin.options);\r\n });\r\n if (opts.filters)\r\n _$assign(self.$filters, opts.filters);\r\n if (opts.directives)\r\n _$e(opts.directives, function (drt, k) { self.$directives[k] = _$drt(drt); });\r\n _$e(opts.attrs, function (attrOps, key) {\r\n _$def(self, (_$isType(key, 'number') ? attrOps : key), {\r\n get: function () {\r\n if (_$isType(attrOps, 'string')) {\r\n var value = attrs[attrOps];\r\n return _$isType(value, 'function') ? value() : value;\r\n }\r\n else {\r\n if (!_$hasProp(attrs, key) && attrOps.required) {\r\n console.error(\"Attribute '\" + key + \"' must be present because it's required.\");\r\n }\r\n else {\r\n var value = _$isType(attrs[key], 'function') ? attrs[key]() : attrs[key];\r\n if (value === void 0 && _$hasProp(attrOps, 'default')) {\r\n var def = attrOps.default;\r\n value = _$isType(def, 'function') ? def() : def;\r\n }\r\n var typ = attrOps.type;\r\n if (typ && !_$isType(value, typ) && attrOps.required) {\r\n return console.error(\"Attribute '\" + key + \"' must be type '\" + typ + \"'.\");\r\n }\r\n return _$toType(value, value === void 0 ? 'undefined' : typ, self, key);\r\n }\r\n }\r\n },\r\n set: function () {\r\n console.error(\"Can not modify attribute '\" + key + \"' because attributes al read only.\");\r\n },\r\n enumerable: true, configurable: true\r\n });\r\n });\r\n var data = opts.model || {};\r\n var _loop_1 = function (key) {\r\n if (_$hasProp(data, key)) {\r\n var desc = Object.getOwnPropertyDescriptor(data, key);\r\n if (desc.value && _$isArray(desc.value)) {\r\n desc.value = new _$List(desc.value, self, key);\r\n }\r\n else {\r\n if (desc.get) {\r\n var getter_1 = desc.get;\r\n desc.get = function () {\r\n var value = getter_1.call(self);\r\n if (_$isArray(value))\r\n value = new _$List(value, self, key);\r\n return value;\r\n };\r\n }\r\n if (desc.set) {\r\n var setter_1 = desc.set;\r\n desc.set = function (v) {\r\n if (_$isArray(v))\r\n v = new _$List(v, self, key);\r\n setter_1.call(self, v);\r\n };\r\n }\r\n }\r\n _$def(self, key, desc);\r\n }\r\n };\r\n for (var key in data) {\r\n _loop_1(key);\r\n }\r\n var tpl = template(self, opts.children);\r\n _$e(tpl, function (value, key) {\r\n _$def(self, key, {\r\n value: (function (key) {\r\n var hook = key[1].toUpperCase() + key.slice(2);\r\n var bhook = opts[\"before\" + hook];\r\n var ahook = opts[\"after\" + hook];\r\n return function () {\r\n bhook && bhook.call(this);\r\n key.slice(1) === 'update' ? value.call(this, this) : value.apply(this, arguments);\r\n ahook && ahook.call(this);\r\n };\r\n })(key)\r\n });\r\n });\r\n _$def(self, '$data', {\r\n get: function () {\r\n return _$toPlainObj(this);\r\n }\r\n });\r\n}\r\nfunction _$plugin(fn, options) {\r\n _$CompCtr['_plugins'] = _$CompCtr['_plugins'] || [];\r\n _$CompCtr['_plugins'].push({ options: options, fn: fn });\r\n}\r\n_$assign(_$CompCtr.prototype, {\r\n $get: function (path) {\r\n return _$accesor(this, path);\r\n },\r\n $set: function (path, value) {\r\n _$accesor(this, path, value);\r\n },\r\n $on: function (event, handler) {\r\n var _this = this;\r\n if (!this._events[event]) {\r\n this._events[event] = [];\r\n }\r\n var i = this._events[event].push(handler);\r\n return {\r\n $off: function () {\r\n _this._events[event].splice(i - 1, 1);\r\n }\r\n };\r\n },\r\n $once: function (event, handler) {\r\n var e = this.$on(event, function (args) {\r\n handler(args);\r\n e.$off();\r\n });\r\n },\r\n $fire: function (event, data) {\r\n if (this._events[event]) {\r\n _$e(this._events[event], function (handler) { handler(data); });\r\n }\r\n },\r\n $notify: function (key) {\r\n if (this._subscribers[key]) {\r\n _$e(this._subscribers[key], function (suscriber) { suscriber(); });\r\n }\r\n },\r\n $observe: function (deps, listener) {\r\n var _this = this;\r\n var subs = [];\r\n if (_$isArray(deps)) {\r\n _$e(deps, function (dep) {\r\n subs.push({ sub: dep, i: _$subs.call(_this, dep, listener) });\r\n });\r\n }\r\n else {\r\n subs.push({ sub: deps, i: _$subs.call(this, deps, listener) });\r\n }\r\n return {\r\n $unobserve: function () {\r\n _$e(subs, function (sub) {\r\n _this._subscribers[sub.sub].splice(sub.i, 1);\r\n });\r\n }\r\n };\r\n },\r\n $watch: function (key, watcher) {\r\n var _this = this;\r\n if (!this._watchers[key]) {\r\n this._watchers[key] = [];\r\n }\r\n var i = this._watchers[key].push(watcher.bind(this));\r\n return {\r\n $unwatch: function () {\r\n _this._watchers[key].splice(i - 1, 1);\r\n }\r\n };\r\n }\r\n});\r\nvar array = Array.prototype;\r\nfunction _$toArgs(args, start) {\r\n if (start === void 0) { start = 0; }\r\n return array.slice.call(args, start);\r\n}\r\nfunction _$arrayValues(list, value, root, key) {\r\n array.push.apply(list, value.map(function (v, i) {\r\n if (list.length !== 0)\r\n i += list.length;\r\n return !(_$isType(v, _$List)) && _$isArray(v) ? new _$List(v, root, key + \".\" + i) : v;\r\n }));\r\n}\r\nfunction _$List(value, root, key) {\r\n var self = this;\r\n Array.apply(self, [value.length]);\r\n var desc = { writable: false, configurable: false, enumerable: false };\r\n _$def(self, '_key', _$assign({ value: key }, desc));\r\n _$def(self, '_root', _$assign({ value: root }, desc));\r\n _$arrayValues(self, value, root, key);\r\n desc.writable = true;\r\n _$def(self, 'length', _$assign({ value: self.length }, desc));\r\n}\r\n_$List.prototype = Object.create(array);\r\n_$List.prototype.constructor = _$List;\r\n['pop', 'push', 'reverse', 'shift', 'sort', 'fill', 'unshift', 'splice'].forEach(function (method) {\r\n _$List.prototype[method] = function () {\r\n var self = this;\r\n var old = self.slice();\r\n var result;\r\n if (method === 'push') {\r\n _$arrayValues(self, _$toArgs(arguments), self._root, self._key);\r\n result = self.length;\r\n }\r\n else {\r\n result = array[method].apply(self, arguments);\r\n }\r\n _$dispatch(self._root, self._key, old, self.slice());\r\n return result;\r\n };\r\n});\r\n_$List.prototype.pull = function (index) {\r\n var self = this;\r\n var items = _$toArgs(arguments, 1);\r\n var length = self.length;\r\n if (index > length) {\r\n length = index + 1;\r\n var pull = new Array(index - self.length);\r\n pull.push.apply(pull, items);\r\n for (var i = 0; i < length; i++) {\r\n if (i === index) {\r\n self.push.apply(self, pull);\r\n }\r\n }\r\n }\r\n else {\r\n self.splice.apply(self, [index, 1].concat(items));\r\n }\r\n};\r\nfunction _$dispatch(root, key, oldVal, value) {\r\n root.$notify(key);\r\n if (root._watchers[key]) {\r\n _$e(root._watchers[key], function (watcher) { watcher(oldVal, value); });\r\n }\r\n root.$update();\r\n}\r\nfunction _$isType(value, type) {\r\n return _$type(type) === 'string' ? type.split('\\|').some(function (t) { return t.trim() === _$type(value); }) : value instanceof type;\r\n}\r\nfunction _$isObject(obj) {\r\n return _$isType(obj, 'object');\r\n}\r\nfunction _$isArray(obj) {\r\n return Array.isArray ? Array.isArray(obj) : _$isType(obj, 'array');\r\n}\r\nfunction _$toType(value, type, root, key) {\r\n switch (type) {\r\n case 'date':\r\n return new Date(value);\r\n case 'string':\r\n return value.toString();\r\n case 'number':\r\n return +value;\r\n case 'boolean':\r\n return !!value;\r\n case 'array':\r\n return _$isType(value, _$List) ? value : new _$List(value, root, key);\r\n default:\r\n return value;\r\n }\r\n}\r\nfunction _$type(obj) {\r\n return /\\[object (\\w+)\\]/.exec(Object.prototype.toString.call(obj))[1].toLowerCase();\r\n}\r\nfunction _$hasProp(obj, prop) {\r\n return obj.hasOwnProperty(prop);\r\n}\r\nfunction _$drt(directive) {\r\n var hasProp = function (prop, instance, options, element) { return _$isObject(directive) && directive[prop] && directive[prop](instance, options, element); };\r\n return {\r\n $init: function (instance, options, element) {\r\n hasProp('$init', instance, options, element);\r\n },\r\n $inserted: function (instance, options, element) {\r\n hasProp('$inserted', instance, options, element);\r\n },\r\n $update: function (instance, options, element) {\r\n if (_$isType(directive, 'function')) {\r\n directive(instance, options, element);\r\n }\r\n else {\r\n hasProp('$update', instance, options, element);\r\n }\r\n },\r\n $destroy: function (instance, options, element) {\r\n hasProp('$destroy', instance, options, element);\r\n }\r\n };\r\n}\r\nfunction _$noop() { }\r\nfunction _$add(inst, child) {\r\n inst.$children.push(child);\r\n}\r\nfunction _$remove(inst, child) {\r\n var index = inst.$children.indexOf(child);\r\n index >= 0 && inst.$children.splice(index, 1);\r\n}\r\nfunction _$toStr(obj) {\r\n var str = _$type(obj);\r\n return !/null|undefined/.test(str) ? obj.toString() : str;\r\n}\r\nfunction _$toPlainObj(obj) {\r\n var data = {};\r\n _$e(_$isObject(obj) ? obj : {}, function (_v, k) {\r\n if (k[0] !== '$' && !_$isType(obj[k], 'function')) {\r\n if (_$isType(obj[k], _$List)) {\r\n data[k] = obj[k].map(_$toPlainObj);\r\n }\r\n else if (_$isObject(obj[k])) {\r\n data[k] = _$toPlainObj(obj[k]);\r\n }\r\n else {\r\n data[k] = obj[k];\r\n }\r\n }\r\n });\r\n return _$isObject(obj) ? data : obj;\r\n}\r\nfunction _$setRef(obj, prop) {\r\n var value = [];\r\n _$def(obj, prop, {\r\n get: function () {\r\n return value.length <= 1 ? value[0] : value;\r\n },\r\n set: function (val) {\r\n if (val && !~value.indexOf(val)) {\r\n value.push(val);\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n}\r\nfunction _$accesor(object, path, value) {\r\n return path.split('.').reduce(function (obj, key, i, arr) {\r\n if (_$isType(value, 'undefined')) {\r\n if (obj == null) {\r\n arr.splice(0, arr.length);\r\n return i > 0 && obj === null ? obj : undefined;\r\n }\r\n }\r\n else {\r\n if (i === arr.length - 1) {\r\n if (_$isType(obj, _$List) && (+key).toString() === key) {\r\n obj.pull(+key, value);\r\n }\r\n else {\r\n var oldVal = obj[key];\r\n obj[key] = !_$isType(value, _$List) && _$isArray(value) ? new _$List(value, object, key) : value;\r\n _$dispatch(object, path, oldVal, obj[key]);\r\n }\r\n }\r\n else if (!_$isObject(obj[key])) {\r\n obj[key] = {};\r\n }\r\n }\r\n return obj ? obj[key] : null;\r\n }, object);\r\n}\r\nfunction _$emptyElse() {\r\n return { type: 'empty-else', $create: _$noop, $mount: _$noop, $update: _$noop, $destroy: _$noop };\r\n}\r\nfunction _$subs(dep, listener) {\r\n if (!this._subscribers[dep]) {\r\n this._subscribers[dep] = [];\r\n }\r\n return this._subscribers[dep].push(listener.bind(this)) - 1;\r\n}\r\nfunction _$def(obj, key, desc) {\r\n Object.defineProperty(obj, key, desc);\r\n}\r\nfunction _$isKey(event, key) {\r\n return event.key.toLowerCase() === key || !!event[key + \"Key\"];\r\n}\r\nfunction _$bindGroup(input, selection) {\r\n var _$index = selection.indexOf(input.value);\r\n if (input.checked && !~_$index)\r\n selection.push(input.value);\r\n else\r\n selection.splice(_$index, 1);\r\n}\r\nfunction _$(selector, parent) {\r\n return _$isType(selector, 'string') ? (parent || document).querySelector(selector) : selector;\r\n}\r\nfunction _$d() {\r\n return document.createDocumentFragment();\r\n}\r\nfunction _$a(parent, child, sibling) {\r\n if (_$isType(sibling, 'boolean') && sibling)\r\n parent.parentElement.replaceChild(child, parent);\r\n else if (!sibling)\r\n parent.appendChild(child);\r\n else\r\n parent.insertBefore(child, sibling);\r\n}\r\nfunction _$as(source, dest) {\r\n var childNodes = source.childNodes;\r\n var attributes = source.attributes;\r\n for (var i = 0; i < childNodes.length; i++) {\r\n _$a(dest, childNodes[i]);\r\n }\r\n for (var i = 0; i < attributes.length; i++) {\r\n var attr = attributes[i];\r\n dest.setAttributeNS(source.namespaceURI, attr.name, attr.value);\r\n }\r\n source.parentElement.replaceChild(dest, source);\r\n return dest;\r\n}\r\nfunction _$r(el, parent) {\r\n var root = parent || el.parentElement;\r\n if (root)\r\n root.removeChild(el);\r\n}\r\nfunction _$ce(tagName) {\r\n return document.createElement(tagName || 'div');\r\n}\r\nfunction _$cse(tagName) {\r\n return document.createElementNS('http://www.w3.org/2000/svg', tagName || 'svg');\r\n}\r\nfunction _$ct(content) {\r\n return document.createTextNode(content || '');\r\n}\r\nfunction _$cm(content) {\r\n return document.createComment(content || '');\r\n}\r\nfunction _$sa(el, attr, value) {\r\n el.setAttribute(attr, value);\r\n}\r\nfunction _$ga(el, attr) {\r\n return el.getAttribute(attr);\r\n}\r\nfunction _$al(el, event, handler) {\r\n el.addEventListener(event, handler, false);\r\n}\r\nfunction _$ul(el, event, oldHandler, newHandler) {\r\n _$rl(el, event, oldHandler);\r\n _$al(el, event, oldHandler = newHandler);\r\n return oldHandler;\r\n}\r\nfunction _$rl(el, event, handler) {\r\n el.removeEventListener(event, handler, false);\r\n}\r\nfunction _$bc(value) {\r\n var classes = '';\r\n if (_$isType(value, 'string')) {\r\n classes += \" \" + value;\r\n }\r\n else if (_$isArray(value)) {\r\n classes = value.map(_$bc).join(' ');\r\n }\r\n else if (_$isObject(value)) {\r\n for (var key in value)\r\n if (_$hasProp(value, key) && value[key])\r\n classes += \" \" + key;\r\n }\r\n return classes.trim();\r\n}\r\nfunction _$bs(value) {\r\n var el = _$ce();\r\n if (_$isObject(value)) {\r\n var style_1 = el.style;\r\n _$e(value, function (val, prop) {\r\n if (val !== style_1[prop]) {\r\n style_1[prop] = val;\r\n }\r\n });\r\n return style_1.cssText;\r\n }\r\n else if (_$isType(value, 'string')) {\r\n return value;\r\n }\r\n else {\r\n return '';\r\n }\r\n}\r\nfunction _$f(root, obj, loop) {\r\n var items = {}, loopParent, loopSibling;\r\n var globs = _$toArgs(arguments, 3);\r\n _$e(obj, function (item, i) { items[i] = loop.apply(null, [root, item, i].concat(globs)); });\r\n return {\r\n $create: function () {\r\n _$e(items, function (item) { item.$create(); });\r\n },\r\n $mount: function (parent, sibling) {\r\n loopParent = _$(parent);\r\n loopSibling = _$(sibling);\r\n _$e(items, function (item) { item.$mount(loopParent, loopSibling); });\r\n },\r\n $update: function (root, obj) {\r\n var globs = _$toArgs(arguments, 2);\r\n _$e(items, function (item, i) {\r\n if (obj[i]) {\r\n item.$update.apply(item, [root, obj[i], i].concat(globs));\r\n }\r\n else {\r\n item.$destroy();\r\n delete items[i];\r\n }\r\n });\r\n _$e(obj, function (item, i) {\r\n if (!items[i]) {\r\n items[i] = loop.apply(null, [root, item, i].concat(globs));\r\n items[i].$create();\r\n items[i].$mount(loopParent, loopSibling);\r\n }\r\n });\r\n },\r\n $destroy: function () {\r\n _$e(items, function (item) { item.$destroy(); });\r\n }\r\n };\r\n}\r\nfunction _$e(obj, cb) {\r\n for (var key in obj) {\r\n if (_$hasProp(obj, key)) {\r\n cb(obj[key], (isNaN(+key) ? key : +key));\r\n }\r\n }\r\n}\r\nfunction _$is(id, css) {\r\n var isNew = false;\r\n var style = _$(\"#\" + id, document.head);\r\n if (!style) {\r\n isNew = true;\r\n style = _$ce('style');\r\n style.id = id;\r\n _$sa(style, 'refs', '1');\r\n }\r\n if (style.textContent !== css) {\r\n style.textContent = css;\r\n }\r\n if (isNew) {\r\n _$a(document.head, style);\r\n }\r\n else {\r\n var count = +_$ga(style, 'refs');\r\n _$sa(style, 'refs', (++count).toString());\r\n }\r\n}\r\nfunction _$ds(id) {\r\n var style = _$(\"#\" + id, document.head);\r\n if (style) {\r\n var count = +_$ga(style, 'refs');\r\n if (--count === 0) {\r\n _$r(style, document.head);\r\n }\r\n else {\r\n _$sa(style, 'refs', count.toString());\r\n }\r\n }\r\n}\r\n//# sourceMappingURL=index.js.map\n// CONCATENATED MODULE: ./components/red.html\n\nfunction _$tplRed(_$state) {\n var _$frag, h2_1, txt_1, span_1, txt_2, setTxt_2;\n _$frag = _$d();\n setTxt_2 = function (_$state) {\n return 'Red ' + ('name' in _$state ? _$state.name : name);\n };\n return {\n $create: function () {\n h2_1 = _$ce('h2');\n txt_1 = _$ct('Component Red:');\n span_1 = _$ce('span');\n txt_2 = _$ct();\n txt_2.data = setTxt_2(_$state);\n this.$hydrate();\n },\n $hydrate: function () {\n _$sa(span_1, 'style', 'color: red');\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$a(_$(parent), _$frag, _$(sibling));\n this.$siblingEl = _$(sibling);\n this.$parentEl = sibling && _$(sibling).parentElement || _$(parent);\n },\n $update: function (_$state) {\n var updateTxt_2 = setTxt_2(_$state);\n if (txt_2.data !== _$toStr(updateTxt_2)) {\n txt_2.data = updateTxt_2;\n }\n updateTxt_2 = void 0;\n },\n $unmount: function () {\n _$a(h2_1, txt_1);\n _$a(_$frag, h2_1);\n _$a(span_1, txt_2);\n _$a(_$frag, span_1);\n },\n $destroy: function () {\n this.$unmount();\n this.$parent = null;\n this.$parentEl = null;\n this.$siblingEl = null;\n this.$children.splice(0, this.$children.length);\n delete _$state.$root;\n _$frag = h2_1 = txt_1 = span_1 = txt_2 = setTxt_2 = void 0;\n }\n };\n}\nfunction Red(_$attrs, _$parent) {\n _$CompCtr.call(this, _$attrs, _$tplRed, { attrs: ['name'] }, _$parent);\n !_$parent && this.$create();\n}\nRed.plugin = _$plugin;\nRed.prototype = Object.create(_$CompCtr.prototype);\nRed.prototype.constructor = Red;\n/* harmony default export */ var red = (Red);\n// CONCATENATED MODULE: ./components/blue.html\n\nfunction _$tplBlue(_$state) {\n var _$frag, h2_1, txt_1, p_1, txt_2, setTxt_2;\n _$frag = _$d();\n setTxt_2 = function (_$state) {\n return 'Blue ' + ('name' in _$state ? _$state.name : name);\n };\n return {\n $create: function () {\n h2_1 = _$ce('h2');\n txt_1 = _$ct('Component Blue:');\n p_1 = _$ce('p');\n txt_2 = _$ct();\n txt_2.data = setTxt_2(_$state);\n this.$hydrate();\n },\n $hydrate: function () {\n _$sa(p_1, 'style', 'color: blue');\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$a(_$(parent), _$frag, _$(sibling));\n this.$siblingEl = _$(sibling);\n this.$parentEl = sibling && _$(sibling).parentElement || _$(parent);\n },\n $update: function (_$state) {\n var updateTxt_2 = setTxt_2(_$state);\n if (txt_2.data !== _$toStr(updateTxt_2)) {\n txt_2.data = updateTxt_2;\n }\n updateTxt_2 = void 0;\n },\n $unmount: function () {\n _$a(h2_1, txt_1);\n _$a(_$frag, h2_1);\n _$a(p_1, txt_2);\n _$a(_$frag, p_1);\n },\n $destroy: function () {\n this.$unmount();\n this.$parent = null;\n this.$parentEl = null;\n this.$siblingEl = null;\n this.$children.splice(0, this.$children.length);\n delete _$state.$root;\n _$frag = h2_1 = txt_1 = p_1 = txt_2 = setTxt_2 = void 0;\n }\n };\n}\nfunction Blue(_$attrs, _$parent) {\n _$CompCtr.call(this, _$attrs, _$tplBlue, { attrs: ['name'] }, _$parent);\n !_$parent && this.$create();\n}\nBlue.plugin = _$plugin;\nBlue.prototype = Object.create(_$CompCtr.prototype);\nBlue.prototype.constructor = Blue;\n/* harmony default export */ var blue = (Blue);\n// CONCATENATED MODULE: ./components/green.html\n\nfunction _$tplGreen(_$state) {\n var _$frag, h2_1, txt_1, span_1, txt_2, setTxt_2;\n _$frag = _$d();\n setTxt_2 = function (_$state) {\n return 'Green ' + ('name' in _$state ? _$state.name : name);\n };\n return {\n $create: function () {\n h2_1 = _$ce('h2');\n txt_1 = _$ct('Component Green:');\n span_1 = _$ce('span');\n txt_2 = _$ct();\n txt_2.data = setTxt_2(_$state);\n this.$hydrate();\n },\n $hydrate: function () {\n _$sa(span_1, 'style', 'color: green');\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$a(_$(parent), _$frag, _$(sibling));\n this.$siblingEl = _$(sibling);\n this.$parentEl = sibling && _$(sibling).parentElement || _$(parent);\n },\n $update: function (_$state) {\n var updateTxt_2 = setTxt_2(_$state);\n if (txt_2.data !== _$toStr(updateTxt_2)) {\n txt_2.data = updateTxt_2;\n }\n updateTxt_2 = void 0;\n },\n $unmount: function () {\n _$a(h2_1, txt_1);\n _$a(_$frag, h2_1);\n _$a(span_1, txt_2);\n _$a(_$frag, span_1);\n },\n $destroy: function () {\n this.$unmount();\n this.$parent = null;\n this.$parentEl = null;\n this.$siblingEl = null;\n this.$children.splice(0, this.$children.length);\n delete _$state.$root;\n _$frag = h2_1 = txt_1 = span_1 = txt_2 = setTxt_2 = void 0;\n }\n };\n}\nfunction Green(_$attrs, _$parent) {\n _$CompCtr.call(this, _$attrs, _$tplGreen, { attrs: ['name'] }, _$parent);\n !_$parent && this.$create();\n}\nGreen.plugin = _$plugin;\nGreen.prototype = Object.create(_$CompCtr.prototype);\nGreen.prototype.constructor = Green;\n/* harmony default export */ var green = (Green);\n// CONCATENATED MODULE: ./components/app.html\n\n\n\n\nfunction _$tplApp(_$state, children) {\n var _$frag, a_1, txt_1, clickEvent_1, handlerClickEvent_1, a_2, txt_2, clickEvent_2, handlerClickEvent_2, a_3, txt_3, clickEvent_3, handlerClickEvent_3, componentAnchor_1, component_1, setComponent_1, setAttrsComponent_1;\n _$frag = _$d();\n clickEvent_1 = function (_$state) {\n _$state.$set('foo', 'red');\n };\n clickEvent_2 = function (_$state) {\n _$state.$set('foo', 'blue');\n };\n clickEvent_3 = function (_$state) {\n _$state.$set('foo', 'green');\n };\n setAttrsComponent_1 = function () {\n return { name: 'thing' };\n };\n setComponent_1 = function (_$state) {\n var comp = _$state.children[_$state.foo];\n return _$isType(comp, 'string') ? children[comp] : comp;\n };\n var Component_1 = setComponent_1(_$state);\n componentAnchor_1 = _$ct();\n component_1 = new Component_1(setAttrsComponent_1(), _$state);\n component_1 && _$add(_$state, component_1);\n return {\n $create: function () {\n a_1 = _$ce('a');\n txt_1 = _$ct('Red ');\n a_2 = _$ce('a');\n txt_2 = _$ct('Blue ');\n a_3 = _$ce('a');\n txt_3 = _$ct('Gree ');\n component_1.$create();\n this.$hydrate();\n },\n $hydrate: function () {\n _$al(a_1, 'click', handlerClickEvent_1 = function (event) {\n event.preventDefault();\n clickEvent_1(_$state, event, a_1);\n });\n _$sa(a_1, 'href', '#');\n _$al(a_2, 'click', handlerClickEvent_2 = function (event) {\n event.preventDefault();\n clickEvent_2(_$state, event, a_2);\n });\n _$sa(a_2, 'href', '#');\n _$al(a_3, 'click', handlerClickEvent_3 = function (event) {\n event.preventDefault();\n clickEvent_3(_$state, event, a_3);\n });\n _$sa(a_3, 'href', '#');\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$a(_$(parent), _$frag, _$(sibling));\n this.$siblingEl = _$(sibling);\n this.$parentEl = sibling && _$(sibling).parentElement || _$(parent);\n },\n $update: function (_$state) {\n var updateComponent_1 = setComponent_1(_$state);\n if (updateComponent_1 === Component_1) {\n component_1 && component_1.$update();\n } else {\n Component_1 = updateComponent_1;\n if (component_1) {\n component_1.$destroy();\n _$remove(_$state, component_1);\n }\n component_1 = new Component_1(setAttrsComponent_1(), _$state);\n if (component_1) {\n _$add(_$state, component_1);\n component_1.$create();\n component_1.$mount(_$state.$parentEl, componentAnchor_1);\n }\n }\n updateComponent_1 = void 0;\n },\n $unmount: function () {\n _$a(a_1, txt_1);\n _$a(_$frag, a_1);\n _$a(a_2, txt_2);\n _$a(_$frag, a_2);\n _$a(a_3, txt_3);\n _$a(_$frag, a_3);\n _$a(_$frag, componentAnchor_1);\n component_1.$mount(_$frag, componentAnchor_1);\n },\n $destroy: function () {\n this.$unmount();\n this.$parent = null;\n this.$parentEl = null;\n this.$siblingEl = null;\n this.$children.splice(0, this.$children.length);\n _$rl(a_1, 'click', handlerClickEvent_1);\n _$rl(a_2, 'click', handlerClickEvent_2);\n _$rl(a_3, 'click', handlerClickEvent_3);\n component_1 && component_1.$destroy();\n delete _$state.$root;\n _$frag = a_1 = txt_1 = clickEvent_1 = handlerClickEvent_1 = a_2 = txt_2 = clickEvent_2 = handlerClickEvent_2 = a_3 = txt_3 = clickEvent_3 = handlerClickEvent_3 = componentAnchor_1 = component_1 = setComponent_1 = setAttrsComponent_1 = void 0;\n }\n };\n}\nfunction App(_$attrs, _$parent) {\n _$CompCtr.call(this, _$attrs, _$tplApp, {\n model: {\n foo: 'red',\n children: {\n red: red,\n blue: blue,\n green: green\n }\n }\n }, _$parent);\n !_$parent && this.$create();\n}\nApp.plugin = _$plugin;\nApp.prototype = Object.create(_$CompCtr.prototype);\nApp.prototype.constructor = App;\n/* harmony default export */ var app = (App);\n// CONCATENATED MODULE: ./main.ts\n\r\nvar main_app = new app();\r\nmain_app.$mount('main');\r\n\n\n//# sourceURL=webpack:///./main.ts_+_5_modules?"); +eval("\n// CONCATENATED MODULE: h:/trebor-repos/trebor/tools/index.js\nvar PROP_MAP = { p: '__TP__', v: 'value', _: '_value', s: '_subscribers', e: '_events', w: '_watchers', h: 'prototype' };\r\nvar PROPS = ['$slots', '$refs', '$filters', '$directives', '_events', '_watchers'];\r\nvar TPS = window[PROP_MAP.p] || (window[PROP_MAP.p] = []);\r\nvar _$assign = Object['assign'] || function (t) {\r\n for (var s = void 0, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s)\r\n if (_$hasProp(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n};\r\nfunction _$CompCtr(attrs, template, options, parent) {\r\n var self = this;\r\n var _$set = function (prop, value) { _$def(self, prop, { value: value, writable: true }); };\r\n if (!attrs)\r\n attrs = {};\r\n _$e(PROPS, function (prop) { _$def(self, prop, { value: {} }); });\r\n _$set('$parent', parent || null);\r\n _$set('$children', []);\r\n _$set(PROP_MAP.s, {});\r\n _$set('$options', options);\r\n var opts = self.$options;\r\n if (!opts.attrs)\r\n opts.attrs = {};\r\n if (!opts.children)\r\n opts.children = {};\r\n _$e(TPS, function (plugin) { plugin.fn.call(self, _$CompCtr, plugin.options); });\r\n if (opts.filters)\r\n _$assign(self.$filters, opts.filters);\r\n if (opts.directives)\r\n _$e(opts.directives, function (drt, k) { self.$directives[k] = _$drt(drt); });\r\n _$e(opts.attrs, function (attrOps, key) {\r\n _$def(self, (_$isType(key, 'number') ? attrOps : key), {\r\n get: function () {\r\n if (_$isStr(attrOps)) {\r\n var value = attrs[attrOps];\r\n return _$isFunction(value) ? value() : value;\r\n }\r\n else {\r\n if (!_$hasProp(attrs, key) && attrOps.required) {\r\n return console.error(\"Attribute '\" + key + \"' is required.\");\r\n }\r\n else {\r\n var value = _$isFunction(attrs[key]) ? attrs[key]() : attrs[key];\r\n if (value === void 0 && _$hasProp(attrOps, 'default')) {\r\n var def = attrOps.default;\r\n value = _$isFunction(def) ? def() : def;\r\n }\r\n var typ = attrOps.type;\r\n if (typ && !_$isType(value, typ) && attrOps.required) {\r\n return console.error(\"Attribute '\" + key + \"' must be type '\" + typ + \"'.\");\r\n }\r\n value = _$toType(value, value === void 0 ? 'undefined' : typ, self, key);\r\n if (value !== void 0 && _$hasProp(attrOps, 'validator')) {\r\n var validator = attrOps.validator;\r\n if (_$isFunction(validator) && !validator(value)) {\r\n return console.error(\"Assigment '\" + key + \"'='\" + JSON.stringify(value) + \"' invalid.\");\r\n }\r\n }\r\n return value;\r\n }\r\n }\r\n },\r\n set: function () {\r\n console.error(\"'\" + key + \"' is read only.\");\r\n },\r\n enumerable: true, configurable: true\r\n });\r\n });\r\n var data = opts.model || {};\r\n var _loop_1 = function (key) {\r\n if (_$hasProp(data, key)) {\r\n var desc = Object.getOwnPropertyDescriptor(data, key);\r\n if (desc.value && _$isArray(desc.value)) {\r\n desc.value = new _$List(desc.value, self, key);\r\n }\r\n else {\r\n if (desc.get) {\r\n var getter_1 = desc.get;\r\n desc.get = function () {\r\n var value = getter_1.call(self);\r\n if (_$isArray(value))\r\n value = new _$List(value, self, key);\r\n return value;\r\n };\r\n }\r\n if (desc.set) {\r\n var setter_1 = desc.set;\r\n desc.set = function (v) {\r\n if (_$isArray(v))\r\n v = new _$List(v, self, key);\r\n setter_1.call(self, v);\r\n };\r\n }\r\n }\r\n _$def(self, key, desc);\r\n }\r\n };\r\n for (var key in data) {\r\n _loop_1(key);\r\n }\r\n var tpl = template(self);\r\n _$e(tpl, function (value, key) {\r\n _$def(self, key, {\r\n value: (function (key) {\r\n var hook = key[1].toUpperCase() + key.slice(2);\r\n var bhook = opts[\"before\" + hook];\r\n var ahook = opts[\"after\" + hook];\r\n return function () {\r\n bhook && bhook.call(this);\r\n key.slice(1) === 'update' ? value.call(this, this) : value.apply(this, arguments);\r\n ahook && ahook.call(this);\r\n };\r\n })(key)\r\n });\r\n });\r\n _$def(self, '$data', {\r\n get: function () {\r\n return _$toPlainObj(this);\r\n }\r\n });\r\n}\r\nfunction _$isValueAttr(attr) {\r\n return attr === 'value';\r\n}\r\nfunction _$subs(dep, listener) {\r\n if (!this[PROP_MAP.s][dep]) {\r\n this[PROP_MAP.s][dep] = [];\r\n }\r\n return this[PROP_MAP.s][dep].push(listener.bind(this)) - 1;\r\n}\r\nfunction _$def(obj, key, desc) {\r\n Object.defineProperty(obj, key, desc);\r\n}\r\n_$assign(_$CompCtr[PROP_MAP.h], {\r\n $get: function (path) {\r\n return _$accesor(this, path);\r\n },\r\n $set: function (path, value) {\r\n _$accesor(this, path, value);\r\n },\r\n $on: function (event, handler) {\r\n var _this = this;\r\n if (!this[PROP_MAP.e][event]) {\r\n this[PROP_MAP.e][event] = [];\r\n }\r\n var i = this[PROP_MAP.e][event].push(handler);\r\n return {\r\n $off: function () {\r\n _this[PROP_MAP.e][event].splice(i - 1, 1);\r\n }\r\n };\r\n },\r\n $once: function (event, handler) {\r\n var e = this.$on(event, function (args) {\r\n handler(args);\r\n e.$off();\r\n });\r\n },\r\n $fire: function (event, data) {\r\n if (this[PROP_MAP.e][event]) {\r\n _$e(this[PROP_MAP.e][event], function (handler) { handler(data); });\r\n }\r\n },\r\n $notify: function (key) {\r\n if (this[PROP_MAP.s][key]) {\r\n _$e(this[PROP_MAP.s][key], function (suscriber) { suscriber(); });\r\n }\r\n },\r\n $observe: function (deps, listener) {\r\n var _this = this;\r\n var subs = [];\r\n if (_$isArray(deps)) {\r\n _$e(deps, function (dep) {\r\n subs.push({ sub: dep, i: _$subs.call(_this, dep, listener) });\r\n });\r\n }\r\n else {\r\n subs.push({ sub: deps, i: _$subs.call(this, deps, listener) });\r\n }\r\n return {\r\n $unobserve: function () {\r\n _$e(subs, function (sub) {\r\n _this[PROP_MAP.s][sub.sub].splice(sub.i, 1);\r\n });\r\n }\r\n };\r\n },\r\n $watch: function (key, watcher) {\r\n var _this = this;\r\n if (!this[PROP_MAP.w][key]) {\r\n this[PROP_MAP.w][key] = [];\r\n }\r\n var i = this[PROP_MAP.w][key].push(watcher.bind(this));\r\n return {\r\n $unwatch: function () {\r\n _this[PROP_MAP.w][key].splice(i - 1, 1);\r\n }\r\n };\r\n }\r\n});\r\nvar array = Array[PROP_MAP.h];\r\nfunction _$toArgs(args, start) {\r\n if (start === void 0) { start = 0; }\r\n return array.slice.call(args, start);\r\n}\r\nfunction _$arrayValues(list, value, root, key) {\r\n array.push.apply(list, value.map(function (v, i) {\r\n if (list.length !== 0)\r\n i += list.length;\r\n return !(_$isType(v, _$List)) && _$isArray(v) ? new _$List(v, root, key + \".\" + i) : v;\r\n }));\r\n}\r\nfunction _$List(value, root, key) {\r\n var self = this;\r\n Array.apply(self, [value.length]);\r\n var desc = { writable: false, configurable: false, enumerable: false };\r\n _$def(self, '_key', _$assign({ value: key }, desc));\r\n _$def(self, '_root', _$assign({ value: root }, desc));\r\n _$arrayValues(self, value, root, key);\r\n desc.writable = true;\r\n _$def(self, 'length', _$assign({ value: self.length }, desc));\r\n}\r\n_$extends(_$List, Array);\r\n['pop', 'push', 'reverse', 'shift', 'sort', 'fill', 'unshift', 'splice'].forEach(function (method) {\r\n _$List[PROP_MAP.h][method] = function () {\r\n var self = this;\r\n var old = self.slice();\r\n var result;\r\n if (method === 'push') {\r\n _$arrayValues(self, _$toArgs(arguments), self._root, self._key);\r\n result = self.length;\r\n }\r\n else {\r\n result = array[method].apply(self, arguments);\r\n }\r\n _$dispatch(self._root, self._key, old, self.slice());\r\n return result;\r\n };\r\n});\r\n_$List[PROP_MAP.h].pull = function (index) {\r\n var self = this;\r\n var items = _$toArgs(arguments, 1);\r\n var length = self.length;\r\n if (index > length) {\r\n length = index + 1;\r\n var pull = new Array(index - self.length);\r\n pull.push.apply(pull, items);\r\n for (var i = 0; i < length; i++) {\r\n if (i === index) {\r\n self.push.apply(self, pull);\r\n }\r\n }\r\n }\r\n else {\r\n self.splice.apply(self, [index, 1].concat(items));\r\n }\r\n};\r\nfunction _$dispatch(root, key, oldVal, value) {\r\n root.$notify(key);\r\n if (root[PROP_MAP.w][key]) {\r\n _$e(root[PROP_MAP.w][key], function (watcher) { watcher(oldVal, value); });\r\n }\r\n root.$update();\r\n}\r\nfunction _$extends(ctor, exts) {\r\n ctor['plugin'] = function (fn, options) {\r\n TPS.push({ options: options, fn: fn });\r\n };\r\n ctor[PROP_MAP.h] = Object.create(exts[PROP_MAP.h]);\r\n ctor[PROP_MAP.h].constructor = ctor;\r\n}\r\nfunction _$isType(value, type) {\r\n return _$type(type) === 'string' ? type.split('|').some(function (t) { return t.trim() === _$type(value); }) : value instanceof type;\r\n}\r\nfunction _$isObject(obj) {\r\n return _$isType(obj, 'object');\r\n}\r\nfunction _$isArray(obj) {\r\n return Array.isArray ? Array.isArray(obj) : _$isType(obj, 'array');\r\n}\r\nfunction _$isFunction(obj) {\r\n return _$isType(obj, 'function');\r\n}\r\nfunction _$isStr(obj) {\r\n return _$isType(obj, 'string');\r\n}\r\nfunction _$toType(value, type, root, key) {\r\n switch (type) {\r\n case 'date':\r\n return new Date(value);\r\n case 'string':\r\n return _$toStr(value);\r\n case 'number':\r\n return +value;\r\n case 'boolean':\r\n return _$isStr(value) && !value ? true : !!value;\r\n case 'array':\r\n return _$isType(value, _$List) ? value : new _$List(value, root, key);\r\n default:\r\n return value;\r\n }\r\n}\r\nfunction _$type(obj) {\r\n return / (\\w+)/.exec(({}).toString.call(obj))[1].toLowerCase();\r\n}\r\nfunction _$hasProp(obj, prop) {\r\n return obj.hasOwnProperty(prop);\r\n}\r\nfunction _$drt(dd) {\r\n var hasProp = function (prop, instance, options, element) { return _$isObject(dd) && dd[prop] && dd[prop](instance, options, element); };\r\n return {\r\n $init: function (instance, options, element) {\r\n hasProp('$init', instance, options, element);\r\n },\r\n $inserted: function (instance, options, element) {\r\n hasProp('$inserted', instance, options, element);\r\n },\r\n $update: function (instance, options, element) {\r\n if (_$isFunction(dd)) {\r\n dd(instance, options, element);\r\n }\r\n else {\r\n hasProp('$update', instance, options, element);\r\n }\r\n },\r\n $destroy: function (instance, options, element) {\r\n hasProp('$destroy', instance, options, element);\r\n }\r\n };\r\n}\r\nfunction _$noop() { }\r\nfunction _$add(inst, Child, attrs) {\r\n var child = null;\r\n if (Child) {\r\n child = new Child(attrs, inst);\r\n inst.$children.push(child);\r\n }\r\n return child;\r\n}\r\nfunction _$remove(inst, child) {\r\n var index = inst.$children.indexOf(child);\r\n index >= 0 && inst.$children.splice(index, 1);\r\n}\r\nfunction _$toStr(obj) {\r\n var str = _$type(obj);\r\n return !/null|undefined/.test(str) ? obj.toString() : str;\r\n}\r\nfunction _$toPlainObj(obj) {\r\n var data = {};\r\n _$e(_$isObject(obj) ? obj : {}, function (_v, k) {\r\n if (k[0] !== '$' && !_$isFunction(obj[k])) {\r\n if (_$isType(obj[k], _$List)) {\r\n data[k] = obj[k].map(_$toPlainObj);\r\n }\r\n else if (_$isObject(obj[k])) {\r\n data[k] = _$toPlainObj(obj[k]);\r\n }\r\n else {\r\n data[k] = obj[k];\r\n }\r\n }\r\n });\r\n return _$isObject(obj) ? data : obj;\r\n}\r\nfunction _$setRef(refs, prop, node) {\r\n if (!_$hasProp(refs, prop)) {\r\n var value_1 = [];\r\n _$def(refs, prop, {\r\n get: function () { return value_1.length <= 1 ? value_1[0] : value_1; },\r\n set: function (val) { val && !~value_1.indexOf(val) && value_1.push(val); },\r\n enumerable: true, configurable: true\r\n });\r\n }\r\n refs[prop] = node;\r\n}\r\nfunction _$accesor(object, path, value) {\r\n return path.split('.').reduce(function (obj, key, i, arr) {\r\n if (_$isType(value, 'undefined')) {\r\n if (obj == null) {\r\n arr.splice(0, arr.length);\r\n return i > 0 && obj === null ? obj : undefined;\r\n }\r\n }\r\n else {\r\n if (i === arr.length - 1) {\r\n if (_$isType(obj, _$List) && _$toStr(+key) === key) {\r\n obj.pull(+key, value);\r\n }\r\n else {\r\n var oldVal = obj[key];\r\n obj[key] = !_$isType(value, _$List) && _$isArray(value) ? new _$List(value, object, key) : value;\r\n _$dispatch(object, path, oldVal, obj[key]);\r\n }\r\n }\r\n else if (!_$isObject(obj[key])) {\r\n obj[key] = {};\r\n }\r\n }\r\n return obj ? obj[key] : null;\r\n }, object);\r\n}\r\nfunction _$emptyElse() {\r\n return { type: 'empty-else', $create: _$noop, $mount: _$noop, $update: _$noop, $destroy: _$noop };\r\n}\r\nfunction _$isKey(event, key) {\r\n return event.key.toLowerCase() === key || !!event[key + \"Key\"];\r\n}\r\nfunction _$bindGroup(input, selection) {\r\n var _value = _$gv(input);\r\n var _$index = selection.indexOf(_value);\r\n input.checked && !~_$index ? selection.push(_value) : selection.splice(_$index, 1);\r\n}\r\nfunction _$bindMultiSelect(select, selections) {\r\n if (!selections.length)\r\n return;\r\n var options = select.options;\r\n for (var i = 0; i < options.length; i++) {\r\n options[i].selected = !!~selections.indexOf(_$gv(options[i]));\r\n }\r\n}\r\nfunction _$updateMultiSelect(select, obj, prop) {\r\n var items = [];\r\n var selection = obj[prop];\r\n var selectedOptions = select.selectedOptions;\r\n for (var i = 0; i < selectedOptions.length; i++) {\r\n items.push(_$gv(selectedOptions[i]));\r\n }\r\n obj[prop] = new _$List(items, selection['_root'], selection['_key']);\r\n obj.$update();\r\n}\r\nfunction _$(selector, parent) {\r\n return _$isStr(selector) ? (parent || document).querySelector(selector) : selector;\r\n}\r\nfunction _$d() {\r\n return document.createDocumentFragment();\r\n}\r\nfunction _$a(parent, child, sibling) {\r\n if (_$isType(sibling, 'boolean') && sibling)\r\n parent.parentElement.replaceChild(child, parent);\r\n else if (!sibling)\r\n parent.appendChild(child);\r\n else\r\n parent.insertBefore(child, sibling);\r\n}\r\nfunction _$as(source, dest) {\r\n var childNodes = source.childNodes, attributes = source.attributes;\r\n for (var i = 0; i < childNodes.length; i++) {\r\n _$a(dest, childNodes[i]);\r\n }\r\n for (var i = 0; i < attributes.length; i++) {\r\n var attr = attributes[i];\r\n dest.setAttributeNS(source.namespaceURI, attr.name, attr.value);\r\n }\r\n source.parentElement.replaceChild(dest, source);\r\n return dest;\r\n}\r\nfunction _$r(el, parent) {\r\n var root = parent || el.parentElement;\r\n if (root)\r\n root.removeChild(el);\r\n}\r\nfunction _$ce(tagName) {\r\n return document.createElement(tagName || 'div');\r\n}\r\nfunction _$cse(tagName) {\r\n return document.createElementNS('http://www.w3.org/2000/svg', tagName || 'svg');\r\n}\r\nfunction _$ct(content) {\r\n return document.createTextNode(content || '');\r\n}\r\nfunction _$cm(content) {\r\n return document.createComment(content || '');\r\n}\r\nfunction _$sa(el, attrAndValue) {\r\n var attr = attrAndValue[0], value = attrAndValue[1];\r\n el.setAttribute(attr, _$toStr(value));\r\n if (_$isValueAttr(attr) && !_$isStr(value))\r\n el[PROP_MAP._] = value;\r\n}\r\nfunction _$ga(el, attr) {\r\n return _$isValueAttr(attr) ? _$gv(el) : el.getAttribute(attr);\r\n}\r\nfunction _$gv(el) {\r\n return _$hasProp(el, PROP_MAP._) ? el[PROP_MAP._] : el[PROP_MAP.v];\r\n}\r\nfunction _$al(el, event, handler) {\r\n el.addEventListener(event, handler, false);\r\n}\r\nfunction _$ul(el, event, oldHandler, newHandler) {\r\n _$rl(el, event, oldHandler);\r\n _$al(el, event, oldHandler = newHandler);\r\n return oldHandler;\r\n}\r\nfunction _$rl(el, event, handler) {\r\n el.removeEventListener(event, handler, false);\r\n}\r\nfunction _$bc(value) {\r\n var classes = '';\r\n if (_$isStr(value)) {\r\n classes += \" \" + value;\r\n }\r\n else if (_$isArray(value)) {\r\n classes = value.map(_$bc).join(' ');\r\n }\r\n else if (_$isObject(value)) {\r\n for (var key in value)\r\n if (_$hasProp(value, key) && value[key])\r\n classes += \" \" + key;\r\n }\r\n return classes.trim();\r\n}\r\nfunction _$bs(value) {\r\n var el = _$ce();\r\n if (_$isObject(value)) {\r\n var style_1 = el.style;\r\n _$e(value, function (val, prop) {\r\n if (val !== style_1[prop])\r\n style_1[prop] = val;\r\n });\r\n return style_1.cssText;\r\n }\r\n else if (_$isStr(value)) {\r\n return value;\r\n }\r\n else {\r\n return '';\r\n }\r\n}\r\nfunction _$cu(block, condition, inst, parent, anchor) {\r\n if (block && block.type === condition(inst).type) {\r\n block.$update(inst);\r\n }\r\n else {\r\n block && block.$destroy();\r\n block = condition(inst);\r\n block.$create();\r\n block.$mount(parent, anchor);\r\n }\r\n return block;\r\n}\r\nfunction _$bba(el, attrAndValue) {\r\n var _a = attrAndValue.concat([el.hasAttribute(attrAndValue[0])]), attr = _a[0], value = _a[1], hasAttr = _a[2];\r\n value == null || value === false ? hasAttr && el.removeAttribute(attr) : _$sa(el, [attr, '']);\r\n}\r\nfunction _$bu(el, binding) {\r\n var attr = binding[0], value = binding[1];\r\n var _value = attr === 'checked' ? !!value : _$toStr(value);\r\n if (/value|checked/.test(attr)) {\r\n if (el[attr] !== _value)\r\n el[attr] = _$isValueAttr(attr) ? _value : value;\r\n el[PROP_MAP._] = _$isValueAttr(attr) ? value : el[PROP_MAP.v];\r\n }\r\n else if (_$ga(el, attr) !== _value) {\r\n _$sa(el, [attr, _value]);\r\n }\r\n}\r\nfunction _$tu(text, value) {\r\n if (text.data !== (value = _$toStr(value)))\r\n text.data = value;\r\n}\r\nfunction _$nu(node, tag) {\r\n return tag.toUpperCase() !== node.tagName ? _$as(node, _$ce(tag)) : node;\r\n}\r\nfunction _$rr(refs, prop, node) {\r\n var nodes = refs[prop];\r\n _$isArray(nodes) ? refs[prop].splice(nodes.indexOf(node), 1) : (delete refs[prop]);\r\n}\r\nfunction _$hu(node, value) {\r\n if (node.innerHTML !== (value = _$toStr(value)))\r\n node.innerHTML = value;\r\n}\r\nfunction _$pu(parent, Ctor, inst, value, attrs, el, sibling) {\r\n if (value === Ctor) {\r\n inst && inst.$update();\r\n }\r\n else {\r\n Ctor = value;\r\n if (inst) {\r\n inst.$destroy();\r\n _$remove(parent, inst);\r\n }\r\n if (inst) {\r\n inst = _$add(parent, Ctor, attrs);\r\n inst.$create();\r\n inst.$mount(el, sibling);\r\n }\r\n }\r\n return [inst, Ctor];\r\n}\r\nfunction _$f(root, obj, loop) {\r\n var items = {}, loopParent, loopSibling;\r\n var globs = _$toArgs(arguments, 3);\r\n _$e(obj, function (item, i) { items[i] = loop.apply(null, [root, item, i].concat(globs)); });\r\n return {\r\n $create: function () {\r\n _$e(items, function (item) { item.$create(); });\r\n },\r\n $mount: function (parent, sibling) {\r\n loopParent = _$(parent);\r\n loopSibling = _$(sibling);\r\n _$e(items, function (item) { item.$mount(loopParent, loopSibling); });\r\n },\r\n $update: function (root, obj) {\r\n var globs = _$toArgs(arguments, 2);\r\n _$e(items, function (item, i) {\r\n if (obj[i]) {\r\n item.$update.apply(item, [root, obj[i], i].concat(globs));\r\n }\r\n else {\r\n item.$destroy();\r\n delete items[i];\r\n }\r\n });\r\n _$e(obj, function (item, i) {\r\n if (!items[i]) {\r\n items[i] = loop.apply(null, [root, item, i].concat(globs));\r\n items[i].$create();\r\n items[i].$mount(loopParent, loopSibling);\r\n }\r\n });\r\n },\r\n $destroy: function () {\r\n _$e(items, function (item) { item.$destroy(); });\r\n }\r\n };\r\n}\r\nfunction _$e(obj, cb) {\r\n for (var key in obj) {\r\n if (_$hasProp(obj, key)) {\r\n cb(obj[key], (isNaN(+key) ? key : +key));\r\n }\r\n }\r\n}\r\nfunction _$is(id, css) {\r\n var isNew = false;\r\n var style = _$(\"#\" + id, document.head);\r\n if (!style) {\r\n isNew = true;\r\n style = _$ce('style');\r\n style.id = id;\r\n _$sa(style, ['refs', '1']);\r\n }\r\n if (style.textContent !== css) {\r\n style.textContent = css;\r\n }\r\n if (isNew) {\r\n _$a(document.head, style);\r\n }\r\n else {\r\n var count = +_$ga(style, 'refs');\r\n _$sa(style, ['refs', _$toStr(++count)]);\r\n }\r\n}\r\nfunction _$ds(id) {\r\n var style = _$(\"#\" + id, document.head);\r\n if (style) {\r\n var count = +_$ga(style, 'refs');\r\n if (--count === 0) {\r\n _$r(style, document.head);\r\n }\r\n else {\r\n _$sa(style, ['refs', _$toStr(count)]);\r\n }\r\n }\r\n}\r\n//# sourceMappingURL=index.js.map\n// CONCATENATED MODULE: ./components/red.html\n\r\nfunction _$tplRed(_$state) {\r\n var _$frag, h2_1, span_1, txt_1, setTxt_1;\r\n _$frag = _$d();\r\n setTxt_1 = function(_$state) {\r\n return 'Red ' + _$state.text;\r\n };\r\n return {\r\n $create: function() {\r\n h2_1 = _$ce('h2');\r\n h2_1.innerHTML = 'Component Red:';\r\n span_1 = _$ce('span');\r\n txt_1 = _$ct();\r\n txt_1.data = setTxt_1(_$state);\r\n _$sa(span_1, ['style', 'color: red']);\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n this.$siblingEl = _$(sibling);\r\n this.$parentEl = sibling && _$(sibling).parentElement || _$(parent);\r\n },\r\n\r\n $update: function(_$state) {\r\n _$tu(txt_1, setTxt_1(_$state));\r\n },\r\n\r\n $unmount: function() {\r\n _$a(_$frag, h2_1);\r\n _$a(span_1, txt_1);\r\n _$a(_$frag, span_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n this.$parent = null;\r\n this.$parentEl = null;\r\n this.$siblingEl = null;\r\n this.$children.splice(0, this.$children.length);\r\n delete _$state.$root;\r\n _$frag = h2_1 = span_1 = txt_1 = setTxt_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction Red(_$attrs, _$parent) {\r\n _$CompCtr.call(this, _$attrs, _$tplRed, {\r\n attrs: ['text']\r\n }, _$parent);\r\n !_$parent && this.$create();\r\n}\r\n_$extends(Red, _$CompCtr);\r\n/* harmony default export */ var red = (Red);\r\n\n// CONCATENATED MODULE: ./components/blue.html\n\r\nfunction _$tplBlue(_$state) {\r\n var _$frag, h2_1, p_1, txt_1, setTxt_1;\r\n _$frag = _$d();\r\n setTxt_1 = function(_$state) {\r\n return 'Blue ' + _$state.text;\r\n };\r\n return {\r\n $create: function() {\r\n h2_1 = _$ce('h2');\r\n h2_1.innerHTML = 'Component Blue:';\r\n p_1 = _$ce('p');\r\n txt_1 = _$ct();\r\n txt_1.data = setTxt_1(_$state);\r\n _$sa(p_1, ['style', 'color: blue']);\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n this.$siblingEl = _$(sibling);\r\n this.$parentEl = sibling && _$(sibling).parentElement || _$(parent);\r\n },\r\n\r\n $update: function(_$state) {\r\n _$tu(txt_1, setTxt_1(_$state));\r\n },\r\n\r\n $unmount: function() {\r\n _$a(_$frag, h2_1);\r\n _$a(p_1, txt_1);\r\n _$a(_$frag, p_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n this.$parent = null;\r\n this.$parentEl = null;\r\n this.$siblingEl = null;\r\n this.$children.splice(0, this.$children.length);\r\n delete _$state.$root;\r\n _$frag = h2_1 = p_1 = txt_1 = setTxt_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction Blue(_$attrs, _$parent) {\r\n _$CompCtr.call(this, _$attrs, _$tplBlue, {\r\n attrs: ['text']\r\n }, _$parent);\r\n !_$parent && this.$create();\r\n}\r\n_$extends(Blue, _$CompCtr);\r\n/* harmony default export */ var blue = (Blue);\r\n\n// CONCATENATED MODULE: ./components/green.html\n\r\nfunction _$tplGreen(_$state) {\r\n var _$frag, h2_1, span_1, txt_1, setTxt_1;\r\n _$frag = _$d();\r\n setTxt_1 = function(_$state) {\r\n return 'Green ' + _$state.text;\r\n };\r\n return {\r\n $create: function() {\r\n h2_1 = _$ce('h2');\r\n h2_1.innerHTML = 'Component Green:';\r\n span_1 = _$ce('span');\r\n txt_1 = _$ct();\r\n txt_1.data = setTxt_1(_$state);\r\n _$sa(span_1, ['style', 'color: green']);\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n this.$siblingEl = _$(sibling);\r\n this.$parentEl = sibling && _$(sibling).parentElement || _$(parent);\r\n },\r\n\r\n $update: function(_$state) {\r\n _$tu(txt_1, setTxt_1(_$state));\r\n },\r\n\r\n $unmount: function() {\r\n _$a(_$frag, h2_1);\r\n _$a(span_1, txt_1);\r\n _$a(_$frag, span_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n this.$parent = null;\r\n this.$parentEl = null;\r\n this.$siblingEl = null;\r\n this.$children.splice(0, this.$children.length);\r\n delete _$state.$root;\r\n _$frag = h2_1 = span_1 = txt_1 = setTxt_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction Green(_$attrs, _$parent) {\r\n _$CompCtr.call(this, _$attrs, _$tplGreen, {\r\n attrs: ['text']\r\n }, _$parent);\r\n !_$parent && this.$create();\r\n}\r\n_$extends(Green, _$CompCtr);\r\n/* harmony default export */ var green = (Green);\r\n\n// CONCATENATED MODULE: ./components/app.html\n\r\n\r\n\r\n\r\nfunction _$tplApp(_$state) {\r\n var children = _$state.$options.children;\r\n var _$frag, a_1, txt_1, clickEvent_1, handlerClickEvent_1, a_2, txt_2, clickEvent_2, handlerClickEvent_2, a_3, txt_3, clickEvent_3, handlerClickEvent_3, componentAnchor_1, component_1, setComponent_1, setAttrsComponent_1;\r\n _$frag = _$d();\r\n clickEvent_1 = function(_$state) {\r\n _$state.$set('foo', 'red');\r\n };\r\n clickEvent_2 = function(_$state) {\r\n _$state.$set('foo', 'blue');\r\n };\r\n clickEvent_3 = function(_$state) {\r\n _$state.$set('foo', 'green');\r\n };\r\n setAttrsComponent_1 = function() {\r\n return {\r\n text: 'thing'\r\n };\r\n };\r\n setComponent_1 = function(_$state) {\r\n var comp = _$state.children[_$state.foo];\r\n return _$isType(comp, 'string') ? children[comp] : comp;\r\n };\r\n var Component_1 = setComponent_1(_$state);\r\n componentAnchor_1 = _$ct();\r\n component_1 = _$add(_$state, Component_1, setAttrsComponent_1());\r\n return {\r\n $create: function() {\r\n a_1 = _$ce('a');\r\n txt_1 = _$ct('Red ');\r\n a_2 = _$ce('a');\r\n txt_2 = _$ct('Blue ');\r\n a_3 = _$ce('a');\r\n txt_3 = _$ct('Gree ');\r\n component_1.$create();\r\n _$al(a_1, 'click', handlerClickEvent_1 = function(event) {\r\n event.preventDefault();\r\n clickEvent_1(_$state, event, a_1);\r\n });\r\n _$sa(a_1, ['href', '#']);\r\n _$al(a_2, 'click', handlerClickEvent_2 = function(event) {\r\n event.preventDefault();\r\n clickEvent_2(_$state, event, a_2);\r\n });\r\n _$sa(a_2, ['href', '#']);\r\n _$al(a_3, 'click', handlerClickEvent_3 = function(event) {\r\n event.preventDefault();\r\n clickEvent_3(_$state, event, a_3);\r\n });\r\n _$sa(a_3, ['href', '#']);\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n this.$siblingEl = _$(sibling);\r\n this.$parentEl = sibling && _$(sibling).parentElement || _$(parent);\r\n },\r\n\r\n $update: function(_$state) {\r\n var _a;\r\n _a = _$pu(\r\n _$state,\r\n Component_1,\r\n component_1,\r\n setComponent_1(_$state),\r\n setAttrsComponent_1(),\r\n _$state.$parentEl,\r\n componentAnchor_1\r\n ), component_1 = _a[0], Component_1 = _a[1];\r\n },\r\n\r\n $unmount: function() {\r\n _$a(a_1, txt_1);\r\n _$a(_$frag, a_1);\r\n _$a(a_2, txt_2);\r\n _$a(_$frag, a_2);\r\n _$a(a_3, txt_3);\r\n _$a(_$frag, a_3);\r\n _$a(_$frag, componentAnchor_1);\r\n component_1.$mount(_$frag, componentAnchor_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n this.$parent = null;\r\n this.$parentEl = null;\r\n this.$siblingEl = null;\r\n this.$children.splice(0, this.$children.length);\r\n _$rl(a_1, 'click', handlerClickEvent_1);\r\n _$rl(a_2, 'click', handlerClickEvent_2);\r\n _$rl(a_3, 'click', handlerClickEvent_3);\r\n component_1 && component_1.$destroy();\r\n delete _$state.$root;\r\n _$frag = a_1 = txt_1 = clickEvent_1 = handlerClickEvent_1 = a_2 = txt_2 = clickEvent_2 = handlerClickEvent_2 = a_3 = txt_3 = clickEvent_3 = handlerClickEvent_3 = componentAnchor_1 = component_1 = setComponent_1 = setAttrsComponent_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction App(_$attrs, _$parent) {\r\n _$CompCtr.call(this, _$attrs, _$tplApp, {\r\n model: {\r\n foo: 'red',\r\n\r\n children: {\r\n red: red,\r\n blue: blue,\r\n green: green\r\n }\r\n }\r\n }, _$parent);\r\n !_$parent && this.$create();\r\n}\r\n_$extends(App, _$CompCtr);\r\n/* harmony default export */ var app = (App);\r\n\n// CONCATENATED MODULE: ./main.ts\n\r\nvar main_app = new app();\r\nmain_app.$mount('main');\r\n\n\n//# sourceURL=webpack:///./main.ts_+_5_modules?"); /***/ }) diff --git a/examples/dynamic-component/src/components/app.html b/examples/dynamic-component/src/components/app.html index d2934c1..e1bc2de 100644 --- a/examples/dynamic-component/src/components/app.html +++ b/examples/dynamic-component/src/components/app.html @@ -2,7 +2,7 @@ Blue Gree - + \ No newline at end of file diff --git a/examples/dynamic-component/src/components/green.html b/examples/dynamic-component/src/components/green.html index 637cef9..37bf1d9 100644 --- a/examples/dynamic-component/src/components/green.html +++ b/examples/dynamic-component/src/components/green.html @@ -1,8 +1,8 @@

Component Green:

-Green {{ name }} +Green {{ text }} \ No newline at end of file diff --git a/examples/dynamic-component/src/components/red.html b/examples/dynamic-component/src/components/red.html index d05205d..ce13ee0 100644 --- a/examples/dynamic-component/src/components/red.html +++ b/examples/dynamic-component/src/components/red.html @@ -1,8 +1,8 @@

Component Red:

-Red {{ name }} +Red {{ text }} \ No newline at end of file From d2792dff48a92f54fc8045847d2152a61cf601fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Asiel=20Guevara=20Casta=C3=B1eda?= Date: Fri, 26 Oct 2018 10:18:19 -0400 Subject: [PATCH 08/13] Fixed missing attribute generation --- src/generators/attributes.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/generators/attributes.ts b/src/generators/attributes.ts index 916f9b5..b121ca7 100644 --- a/src/generators/attributes.ts +++ b/src/generators/attributes.ts @@ -6,7 +6,10 @@ import { BlockAreas, NodeElement } from '../utilities/classes'; import { genShow, genDirective, genValue, genName, genRefs } from './directives'; export function genSetAttrs(target: string, node: NodeElement, scope: string, areas: BlockAreas) { - sortAttrs(node.attributes).forEach(({ name, value }) => { + const attrs = sortAttrs(node.attributes); + let { length } = attrs; + for (let i = 0; i < length; i++) { + const { name, value } = attrs[i]; let [attr] = name.split('.'); if (attr === '$show') { genShow(target, node, areas, scope); @@ -29,9 +32,13 @@ export function genSetAttrs(target: string, node: NodeElement, scope: string, ar } else if (attr[0] === '#') { genRefs(scope, areas, kebabToCamelCases(name.slice(1)), target); } else { - areas.hydrate.push(`_$sa(${target}, ['${attr}', ${value ? `'${value}'` : `''`}]);`); + areas.hydrate.push(`_$sa(${target}, ['${attr}', ${value ? `'${value}'` : `''`}]);`); } - }); + if (length !== attrs.length) { + i--; + length = attrs.length; + } + } } function sortAttrs(attrs: Attribute[]) { From 1360bd0457ecb7c7266e94c06d6c0101127746e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Asiel=20Guevara=20Casta=C3=B1eda?= Date: Fri, 26 Oct 2018 10:19:36 -0400 Subject: [PATCH 09/13] Removed extra generated code --- src/generators/commons.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/generators/commons.ts b/src/generators/commons.ts index d919a2c..6c38b9c 100644 --- a/src/generators/commons.ts +++ b/src/generators/commons.ts @@ -26,7 +26,7 @@ export function genBlockAreas(node: NodeElement, areas: BlockAreas, scope: strin return `(${ctx(filterParser(int), scope, areas.globals)})`; } return `'${clearText(entities.decode(int))}'`; - }).join('+').replace(/^' '\+/, '').replace(/\+' '$/, ''); + }).join('+').replace(/^'\s*'\+/, '').replace(/\+'\s*'$/, ''); let params = areas.globals && areas.globals.length > 0 ? `, ${areas.globals.join(', ')}` : ''; const setTxt = `${setVariable}(${scope}${params})`; areas.extras.push(`${setVariable} = (${scope}${params}) => ${code};`); From 44548b772a931a6f72f60033a47c6f97432964f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Asiel=20Guevara=20Casta=C3=B1eda?= Date: Fri, 26 Oct 2018 10:21:15 -0400 Subject: [PATCH 10/13] Fixed error with param names --- src/generators/loops.ts | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/generators/loops.ts b/src/generators/loops.ts index 9bc1b52..1e720c0 100644 --- a/src/generators/loops.ts +++ b/src/generators/loops.ts @@ -18,7 +18,8 @@ export function genForItem(node: NodeElement, areas: BlockAreas, scope: string) const [key, val, index] = vars.split(',').map(v => v.replace(/[()]/g, '').trim()); let [asNumber, ...rest] = variable.split('\|'); let [start, end] = asNumber.split('..'); - let globs = `${params.length ? `, ${params.join(', ')}` : ''}`; + let globs = `${params.length ? `, ${params.join(', ')}` : ''}`; + let fglobs = `${params.length ? `, ${params.filter(p => (p !== '_$i' && p !== '_$v')).join(', ')}` : ''}`; if (!isNaN(+start)) { let length = (+end || 0) - (+start); let array = [...Array(length > 0 ? length : -length)].map((_, i) => end ? i + (+start) : i); @@ -26,12 +27,12 @@ export function genForItem(node: NodeElement, areas: BlockAreas, scope: string) } variable = ctx(filterParser(variable), scope, areas.globals.concat(params)); areas.variables.push(loopBlock); - areas.extras.push(`${loopBlock} = _$f(${scope}, ${variable}, itemLoop_${areas.loops}${globs}); + areas.extras.push(`${loopBlock} = _$f(${scope}, ${variable}, itemLoop_${areas.loops}${fglobs}); ${anchor} = _$ct();`); areas.outer.push(genLoopItem(`${scope}${globs}`, node, key, val, index, areas)); areas.create.push(`${loopBlock}.$create();`); areas.unmount.push(`${loopBlock}.$mount(${root || '_$frag'}, ${anchor});`); - areas.update.push(`${loopBlock}.$update(${scope}, ${variable}${globs});`); + areas.update.push(`${loopBlock}.$update(${scope}, ${variable}${fglobs});`); areas.destroy.push(`${loopBlock}.$destroy();`); } @@ -40,19 +41,11 @@ function genLoopItem(scope: string, node: NodeElement, variable: string, value: const loop = `itemLoop_${areas.loops}`; let params: string[] = []; [scope, ...params] = scope.split(', '); - let parameters: Set = new Set([scope]); subareas.globals.push(variable); - parameters.add(variable); - if (value) { - parameters.add(value); - subareas.globals.push(value); - } - if (index) { - parameters.add(index); - subareas.globals.push(index); - } + value && subareas.globals.push(value); + index && subareas.globals.push(index); subareas.globals.push(...params); - scope = [...parameters, ...params].join(', '); + scope = [...new Set([scope, variable, value || '_$v', index || '_$i', ...params])].join(', '); const tag = node.tagName; if (tag === 'template') { node.appendChild(node.content); @@ -60,7 +53,7 @@ function genLoopItem(scope: string, node: NodeElement, variable: string, value: subareas.variables.push('_$frag'); subareas.extras.push('_$frag = _$d();'); node.isBlock = true; - let item = genBlockAreas(node, subareas, scope); + let item = genBlockAreas(node, subareas, scope.replace(', _$v', '').replace(', _$i', '')); delete node.isBlock; areas.loops = subareas.loops; areas.conditions = subareas.conditions; From 92474e49097bbb96c82d25a3b8fbcf8642740d28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Asiel=20Guevara=20Casta=C3=B1eda?= Date: Fri, 26 Oct 2018 10:22:29 -0400 Subject: [PATCH 11/13] Fixed scope issue when conditional are inside loops --- src/generators/conditions.ts | 4 ++-- tools/index.ts | 40 +++++++++++++++++++++--------------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/generators/conditions.ts b/src/generators/conditions.ts index a51c1b7..1c4971e 100644 --- a/src/generators/conditions.ts +++ b/src/generators/conditions.ts @@ -31,8 +31,8 @@ export function genIf(node: NodeElement, areas: BlockAreas, scope: string) { parent.removeChild(node); areas.outer.push(genCondition(scope, condition, condition.index)); areas.create.push(`${block}.$create();`); - areas.unmount.push(`${block}.$mount(${root || '_$frag'}, ${anchor});`); - areas.update.push(`${block} = _$cu(${block}, condition_${condition.index}, ${scope}, ${root || `${scope}.$parentEl`}, ${anchor});`); + areas.unmount.push(`${block}.$mount(${root || '_$frag'}, ${anchor});`); + areas.update.push(`${block} = _$cu(${block}, condition_${condition.index}, ${root}, ${anchor}, ${scope});`); areas.destroy.push(`${block}.$destroy();`); } diff --git a/tools/index.ts b/tools/index.ts index 0e2b6f5..d32e897 100644 --- a/tools/index.ts +++ b/tools/index.ts @@ -46,6 +46,8 @@ interface ComponentTemplate { interface Component extends ComponentTemplate { $parent: Component; + $parentEl: HTMLElement; + $siblingEl: HTMLElement; readonly $refs: ObjectLike; readonly $slots: ObjectLike; readonly $filters: ObjectLike<(...args: any[]) => any>; @@ -323,6 +325,9 @@ export function _$extends(ctor: Function, exts: Function) { export function _$isType(value: any, type: string | Function) { return _$type(type) === 'string' ? (type).split('|').some(t => t.trim() === _$type(value)) : value instanceof type; } +function _$apply(callee: Function, args: any[], globs: any[], thisArg: any = null) { + return callee.apply(thisArg, args.concat(globs)); +} function _$isObject(obj) { return _$isType(obj, 'object'); } @@ -559,20 +564,21 @@ export function _$bs(value: string | ObjectLike) { return ''; } } -export function _$cu(block: { type: string } & ComponentTemplate, condition: Function, inst: Component, parent: Element, anchor: Element) { - if (block && block.type === condition(inst).type) { - block.$update(inst); +export function _$cu(block: { type: string } & ComponentTemplate, condition: Function, parent: Element, anchor: Element, inst: Component) { + let globs = _$toArgs(arguments, 5); + if (block && block.type === _$apply(condition, [inst], globs).type) { + _$apply(block.$update, [inst], globs, block); } else { block && block.$destroy(); - block = condition(inst); + block = _$apply(condition, [inst], globs); block.$create(); - block.$mount(parent, anchor); + block.$mount(parent || inst.$parentEl, anchor); } return block; } export function _$bba(el: HTMLElement, attrAndValue: [string, any]) { - let [attr, value, hasAttr] = attrAndValue.concat([el.hasAttribute(attrAndValue[0])]); - value == null || value === false ? hasAttr && el.removeAttribute(attr) : _$sa(el, [attr, '']); + let [attr, value] = attrAndValue; + el[attr] = value == null || value === false ? (el.removeAttribute(attr), false) : (_$sa(el, [attr, '']), true); } export function _$bu(el: (HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement) & { _value: any }, binding: [string, any]) { let [attr, value] = binding; @@ -617,7 +623,7 @@ export function _$pu(parent: Component, Ctor: ComponentConstructor, inst: Compon export function _$f(root: Component, obj: any[], loop: (...args: any[]) => ComponentTemplate) { let items: ObjectLike = {}, loopParent: Element, loopSibling: Element; let globs = _$toArgs(arguments, 3); - _$e(obj, (item, i, index) => { items[i] = loop.apply(null, [root, item, i, index].concat(globs)); }); + _$e(obj, (item, i, index) => { items[i] = _$apply(loop, [root, item, i, index], globs); }); return { $create() { _$e(items, item => { item.$create(); }); @@ -631,15 +637,15 @@ export function _$f(root: Component, obj: any[], loop: (...args: any[]) => Compo let globs = _$toArgs(arguments, 2); _$e(items, (item, i, index) => { if (obj[i]) { - item.$update.apply(item, [root, obj[i], i, index].concat(globs)); + _$apply(item.$update, [root, obj[i], i, index], globs, item); } else { item.$destroy(); delete items[i]; } }); - _$e(obj, (item, i, index) => { + _$e(obj, (item, i, index) => { if (!items[i]) { - items[i] = loop.apply(null, [root, item, i, index].concat(globs)); + items[i] = _$apply(loop, [root, item, i, index], globs); items[i].$create(); items[i].$mount(loopParent, loopSibling); } @@ -651,10 +657,10 @@ export function _$f(root: Component, obj: any[], loop: (...args: any[]) => Compo }; } export function _$e(obj: T, cb: (value: IterateValue, key: IterateKey, index?: number) => void) { - let i = 0; - for (const key in obj) { - if (_$hasProp(obj, key)) { - cb(obj[key], (isNaN(+key) ? key : +key), i++); + let i = 0; + for (const key in obj) { + if (_$hasProp(obj, key)) { + cb(obj[key], (isNaN(+key) ? key : +key), i++); } } } @@ -674,7 +680,7 @@ export function _$is(id: string, css: string) { _$a(document.head, style); } else { let count = +_$ga(style, 'refs'); - _$sa(style, ['refs', ++count]); + _$sa(style, ['refs', ++count]); } } export function _$ds(id: string) { @@ -684,7 +690,7 @@ export function _$ds(id: string) { if (--count === 0) { _$r(style, document.head); } else { - _$sa(style, ['refs', count]); + _$sa(style, ['refs', count]); } } } From e8c17987651b4bb720e7684910a674be18548abb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Asiel=20Guevara=20Casta=C3=B1eda?= Date: Fri, 26 Oct 2018 10:23:14 -0400 Subject: [PATCH 12/13] Updated examples --- examples/animation/dist/js/animation.js | 12 +- .../animation/src/components/animation.html | 2 +- examples/calendar/dist/js/calendar.js | 2 +- examples/clock/dist/js/clock.js | 2 +- examples/counter/dist/js/counter.js | 2 +- examples/dynamic-component/dist/js/dynamic.js | 2 +- examples/select/index.html | 10 + examples/select/index.iif.js | 584 ++++++++++++++++++ examples/select/index.js | 27 + examples/todomvc/dist/js/todo.js | 2 +- examples/todomvc/src/components/todo.ts | 2 +- 11 files changed, 634 insertions(+), 13 deletions(-) create mode 100644 examples/select/index.html create mode 100644 examples/select/index.iif.js create mode 100644 examples/select/index.js diff --git a/examples/animation/dist/js/animation.js b/examples/animation/dist/js/animation.js index 89eea14..019a25b 100644 --- a/examples/animation/dist/js/animation.js +++ b/examples/animation/dist/js/animation.js @@ -87,15 +87,15 @@ /******/ ({ /***/ "../../../../trebor-transitions/node_modules/hash-sum/hash-sum.js": -/*!*****************************************************************************************************!*\ - !*** d:/DEVELOP/Work in Progress/trebor-repos/trebor-transitions/node_modules/hash-sum/hash-sum.js ***! - \*****************************************************************************************************/ +/*!****************************************************************************!*\ + !*** h:/trebor-repos/trebor-transitions/node_modules/hash-sum/hash-sum.js ***! + \****************************************************************************/ /*! no static exports found */ /*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -eval("\n\nfunction pad (hash, len) {\n while (hash.length < len) {\n hash = '0' + hash;\n }\n return hash;\n}\n\nfunction fold (hash, text) {\n var i;\n var chr;\n var len;\n if (text.length === 0) {\n return hash;\n }\n for (i = 0, len = text.length; i < len; i++) {\n chr = text.charCodeAt(i);\n hash = ((hash << 5) - hash) + chr;\n hash |= 0;\n }\n return hash < 0 ? hash * -2 : hash;\n}\n\nfunction foldObject (hash, o, seen) {\n return Object.keys(o).sort().reduce(foldKey, hash);\n function foldKey (hash, key) {\n return foldValue(hash, o[key], key, seen);\n }\n}\n\nfunction foldValue (input, value, key, seen) {\n var hash = fold(fold(fold(input, key), toString(value)), typeof value);\n if (value === null) {\n return fold(hash, 'null');\n }\n if (value === undefined) {\n return fold(hash, 'undefined');\n }\n if (typeof value === 'object') {\n if (seen.indexOf(value) !== -1) {\n return fold(hash, '[Circular]' + key);\n }\n seen.push(value);\n return foldObject(hash, value, seen);\n }\n return fold(hash, value.toString());\n}\n\nfunction toString (o) {\n return Object.prototype.toString.call(o);\n}\n\nfunction sum (o) {\n return pad(foldValue(0, o, '', []).toString(16), 8);\n}\n\nmodule.exports = sum;\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vZDovREVWRUxPUC9Xb3JrIGluIFByb2dyZXNzL3RyZWJvci1yZXBvcy90cmVib3ItdHJhbnNpdGlvbnMvbm9kZV9tb2R1bGVzL2hhc2gtc3VtL2hhc2gtc3VtLmpzPzI0NzAiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7O0FBRUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBOztBQUVBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EsZ0NBQWdDLFNBQVM7QUFDekM7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBOztBQUVBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7QUFFQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBOztBQUVBO0FBQ0E7QUFDQTs7QUFFQTtBQUNBO0FBQ0E7O0FBRUEiLCJmaWxlIjoiLi4vLi4vLi4vLi4vdHJlYm9yLXRyYW5zaXRpb25zL25vZGVfbW9kdWxlcy9oYXNoLXN1bS9oYXNoLXN1bS5qcy5qcyIsInNvdXJjZXNDb250Z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AgaWYgKHZhbHVlID09PSB1bmRlZmluZWQpIHtcbiAgICByZXR1cm4gZm9sZChoYXNoLCAndW5kZWZpbmVkJyk7XG4gIH1cbiAgaWYgKHR5cGVvZiB2YWx1ZSA9PT0gJ29iamVjdCcpIHtcbiAgICBpZiAoc2Vlbi5pbmRleE9mKHZhbHVlKSAhPT0gLTEpIHtcbiAgICAgIHJldHVybiBmb2xkKGhhc2gsICdbQ2lyY3VsYXJdJyArIGtleSk7XG4gICAgfVxuICAgIHNlZW4ucHVzaCh2YWx1ZSk7XG4gICAgcmV0dXJuIGZvbGRPYmplY3QoaGFzaCwgdmFsdWUsIHNlZW4pO1xuICB9XG4gIHJldHVybiBmb2xkKGhhc2gsIHZhbHVlLnRvU3RyaW5nKCkpO1xufVxuXG5mdW5jdGlvbiB0b1N0cmluZyAobykge1xuICByZXR1cm4gT2JqZWN0LnByb3RvdHlwZS50b1N0cmluZy5jYWxsKG8pO1xufVxuXG5mdW5jdGlvbiBzdW0gKG8pIHtcbiAgcmV0dXJuIHBhZChmb2xkVmFsdWUoMCwgbywgJycsIFtdKS50b1N0cmluZygxNiksIDgpO1xufVxuXG5tb2R1bGUuZXhwb3J0cyA9IHN1bTtcbiJdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///../../../../trebor-transitions/node_modules/hash-sum/hash-sum.js\n"); +eval("\n\nfunction pad (hash, len) {\n while (hash.length < len) {\n hash = '0' + hash;\n }\n return hash;\n}\n\nfunction fold (hash, text) {\n var i;\n var chr;\n var len;\n if (text.length === 0) {\n return hash;\n }\n for (i = 0, len = text.length; i < len; i++) {\n chr = text.charCodeAt(i);\n hash = ((hash << 5) - hash) + chr;\n hash |= 0;\n }\n return hash < 0 ? hash * -2 : hash;\n}\n\nfunction foldObject (hash, o, seen) {\n return Object.keys(o).sort().reduce(foldKey, hash);\n function foldKey (hash, key) {\n return foldValue(hash, o[key], key, seen);\n }\n}\n\nfunction foldValue (input, value, key, seen) {\n var hash = fold(fold(fold(input, key), toString(value)), typeof value);\n if (value === null) {\n return fold(hash, 'null');\n }\n if (value === undefined) {\n return fold(hash, 'undefined');\n }\n if (typeof value === 'object') {\n if (seen.indexOf(value) !== -1) {\n return fold(hash, '[Circular]' + key);\n }\n seen.push(value);\n return foldObject(hash, value, seen);\n }\n return fold(hash, value.toString());\n}\n\nfunction toString (o) {\n return Object.prototype.toString.call(o);\n}\n\nfunction sum (o) {\n return pad(foldValue(0, o, '', []).toString(16), 8);\n}\n\nmodule.exports = sum;\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vaDovdHJlYm9yLXJlcG9zL3RyZWJvci10cmFuc2l0aW9ucy9ub2RlX21vZHVsZXMvaGFzaC1zdW0vaGFzaC1zdW0uanM/M2Y5YyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7QUFFQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7O0FBRUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSxnQ0FBZ0MsU0FBUztBQUN6QztBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7O0FBRUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBOztBQUVBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7O0FBRUE7QUFDQTtBQUNBOztBQUVBO0FBQ0E7QUFDQTs7QUFFQSIsImZpbGUiOiIuLi8uLi8uLi8uLi90cmVib3ItdHJhbnNpdGlvbnMvbm9kZV9tb2R1bGVzL2hhc2gtc3VtL2hhc2gtc3VtLmpzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiJ3VzZSBzdHJpY3QnO1xuXG5mdW5jdGlvbiBwYWQ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KGhhc2gsICd1bmRlZmluZWQnKTtcbiAgfVxuICBpZiAodHlwZW9mIHZhbHVlID09PSAnb2JqZWN0Jykge1xuICAgIGlmIChzZWVuLmluZGV4T2YodmFsdWUpICE9PSAtMSkge1xuICAgICAgcmV0dXJuIGZvbGQoaGFzaCwgJ1tDaXJjdWxhcl0nICsga2V5KTtcbiAgICB9XG4gICAgc2Vlbi5wdXNoKHZhbHVlKTtcbiAgICByZXR1cm4gZm9sZE9iamVjdChoYXNoLCB2YWx1ZSwgc2Vlbik7XG4gIH1cbiAgcmV0dXJuIGZvbGQoaGFzaCwgdmFsdWUudG9TdHJpbmcoKSk7XG59XG5cbmZ1bmN0aW9uIHRvU3RyaW5nIChvKSB7XG4gIHJldHVybiBPYmplY3QucHJvdG90eXBlLnRvU3RyaW5nLmNhbGwobyk7XG59XG5cbmZ1bmN0aW9uIHN1bSAobykge1xuICByZXR1cm4gcGFkKGZvbGRWYWx1ZSgwLCBvLCAnJywgW10pLnRvU3RyaW5nKDE2KSwgOCk7XG59XG5cbm1vZHVsZS5leHBvcnRzID0gc3VtO1xuIl0sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///../../../../trebor-transitions/node_modules/hash-sum/hash-sum.js\n"); /***/ }), @@ -104,11 +104,11 @@ eval("\n\nfunction pad (hash, len) {\n while (hash.length < len) {\n hash = !*** ./main.ts + 5 modules ***! \*****************************/ /*! no exports provided */ -/*! ModuleConcatenation bailout: Cannot concat with d:/DEVELOP/Work in Progress/trebor-repos/trebor-transitions/node_modules/hash-sum/hash-sum.js (<- Module is not an ECMAScript module) */ +/*! ModuleConcatenation bailout: Cannot concat with h:/trebor-repos/trebor-transitions/node_modules/hash-sum/hash-sum.js (<- Module is not an ECMAScript module) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("\n// CONCATENATED MODULE: d:/DEVELOP/Work in Progress/trebor-repos/trebor/tools/index.js\nvar _$assign = Object['assign'] || function (t) {\r\n for (var s = void 0, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s)\r\n if (_$hasProp(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n};\r\nfunction _$CompCtr(attrs, template, options, parent) {\r\n var self = this;\r\n var props = ['$slots', '$refs', '$filters', '$directives', '_events', '_watchers'];\r\n var _$set = function (prop, value) { _$def(self, prop, { value: value, writable: true }); };\r\n if (!attrs)\r\n attrs = {};\r\n _$e(props, function (prop) { _$def(self, prop, { value: {} }); });\r\n _$set('$parent', parent || null);\r\n _$set('$children', []);\r\n _$set('_subscribers', {});\r\n _$set('$options', options);\r\n var opts = self.$options;\r\n if (!opts.attrs)\r\n opts.attrs = {};\r\n if (!opts.children)\r\n opts.children = {};\r\n _$e(_$CompCtr['_plugins'], function (plugin) {\r\n plugin.fn.call(self, _$CompCtr, plugin.options);\r\n });\r\n if (opts.filters)\r\n _$assign(self.$filters, opts.filters);\r\n if (opts.directives)\r\n _$e(opts.directives, function (drt, k) { self.$directives[k] = _$drt(drt); });\r\n _$e(opts.attrs, function (attrOps, key) {\r\n _$def(self, (_$isType(key, 'number') ? attrOps : key), {\r\n get: function () {\r\n if (_$isType(attrOps, 'string')) {\r\n var value = attrs[attrOps];\r\n return _$isType(value, 'function') ? value() : value;\r\n }\r\n else {\r\n if (!_$hasProp(attrs, key) && attrOps.required) {\r\n console.error(\"Attribute '\" + key + \"' must be present because it's required.\");\r\n }\r\n else {\r\n var value = _$isType(attrs[key], 'function') ? attrs[key]() : attrs[key];\r\n if (value === void 0 && _$hasProp(attrOps, 'default')) {\r\n var def = attrOps.default;\r\n value = _$isType(def, 'function') ? def() : def;\r\n }\r\n var typ = attrOps.type;\r\n if (typ && !_$isType(value, typ) && attrOps.required) {\r\n return console.error(\"Attribute '\" + key + \"' must be type '\" + typ + \"'.\");\r\n }\r\n return _$toType(value, value === void 0 ? 'undefined' : typ, self, key);\r\n }\r\n }\r\n },\r\n set: function () {\r\n console.error(\"Can not modify attribute '\" + key + \"' because attributes al read only.\");\r\n },\r\n enumerable: true, configurable: true\r\n });\r\n });\r\n var data = opts.model || {};\r\n var _loop_1 = function (key) {\r\n if (_$hasProp(data, key)) {\r\n var desc = Object.getOwnPropertyDescriptor(data, key);\r\n if (desc.value && _$isArray(desc.value)) {\r\n desc.value = new _$List(desc.value, self, key);\r\n }\r\n else {\r\n if (desc.get) {\r\n var getter_1 = desc.get;\r\n desc.get = function () {\r\n var value = getter_1.call(self);\r\n if (_$isArray(value))\r\n value = new _$List(value, self, key);\r\n return value;\r\n };\r\n }\r\n if (desc.set) {\r\n var setter_1 = desc.set;\r\n desc.set = function (v) {\r\n if (_$isArray(v))\r\n v = new _$List(v, self, key);\r\n setter_1.call(self, v);\r\n };\r\n }\r\n }\r\n _$def(self, key, desc);\r\n }\r\n };\r\n for (var key in data) {\r\n _loop_1(key);\r\n }\r\n var tpl = template(self, opts.children);\r\n _$e(tpl, function (value, key) {\r\n _$def(self, key, {\r\n value: (function (key) {\r\n var hook = key[1].toUpperCase() + key.slice(2);\r\n var bhook = opts[\"before\" + hook];\r\n var ahook = opts[\"after\" + hook];\r\n return function () {\r\n bhook && bhook.call(this);\r\n key.slice(1) === 'update' ? value.call(this, this) : value.apply(this, arguments);\r\n ahook && ahook.call(this);\r\n };\r\n })(key)\r\n });\r\n });\r\n _$def(self, '$data', {\r\n get: function () {\r\n return _$toPlainObj(this);\r\n }\r\n });\r\n}\r\nfunction _$plugin(fn, options) {\r\n _$CompCtr['_plugins'] = _$CompCtr['_plugins'] || [];\r\n _$CompCtr['_plugins'].push({ options: options, fn: fn });\r\n}\r\n_$assign(_$CompCtr.prototype, {\r\n $get: function (path) {\r\n return _$accesor(this, path);\r\n },\r\n $set: function (path, value) {\r\n _$accesor(this, path, value);\r\n },\r\n $on: function (event, handler) {\r\n var _this = this;\r\n if (!this._events[event]) {\r\n this._events[event] = [];\r\n }\r\n var i = this._events[event].push(handler);\r\n return {\r\n $off: function () {\r\n _this._events[event].splice(i - 1, 1);\r\n }\r\n };\r\n },\r\n $once: function (event, handler) {\r\n var e = this.$on(event, function (args) {\r\n handler(args);\r\n e.$off();\r\n });\r\n },\r\n $fire: function (event, data) {\r\n if (this._events[event]) {\r\n _$e(this._events[event], function (handler) { handler(data); });\r\n }\r\n },\r\n $notify: function (key) {\r\n if (this._subscribers[key]) {\r\n _$e(this._subscribers[key], function (suscriber) { suscriber(); });\r\n }\r\n },\r\n $observe: function (deps, listener) {\r\n var _this = this;\r\n var subs = [];\r\n if (_$isArray(deps)) {\r\n _$e(deps, function (dep) {\r\n subs.push({ sub: dep, i: _$subs.call(_this, dep, listener) });\r\n });\r\n }\r\n else {\r\n subs.push({ sub: deps, i: _$subs.call(this, deps, listener) });\r\n }\r\n return {\r\n $unobserve: function () {\r\n _$e(subs, function (sub) {\r\n _this._subscribers[sub.sub].splice(sub.i, 1);\r\n });\r\n }\r\n };\r\n },\r\n $watch: function (key, watcher) {\r\n var _this = this;\r\n if (!this._watchers[key]) {\r\n this._watchers[key] = [];\r\n }\r\n var i = this._watchers[key].push(watcher.bind(this));\r\n return {\r\n $unwatch: function () {\r\n _this._watchers[key].splice(i - 1, 1);\r\n }\r\n };\r\n }\r\n});\r\nvar array = Array.prototype;\r\nfunction _$toArgs(args, start) {\r\n if (start === void 0) { start = 0; }\r\n return array.slice.call(args, start);\r\n}\r\nfunction _$arrayValues(list, value, root, key) {\r\n array.push.apply(list, value.map(function (v, i) {\r\n if (list.length !== 0)\r\n i += list.length;\r\n return !(_$isType(v, _$List)) && _$isArray(v) ? new _$List(v, root, key + \".\" + i) : v;\r\n }));\r\n}\r\nfunction _$List(value, root, key) {\r\n var self = this;\r\n Array.apply(self, [value.length]);\r\n var desc = { writable: false, configurable: false, enumerable: false };\r\n _$def(self, '_key', _$assign({ value: key }, desc));\r\n _$def(self, '_root', _$assign({ value: root }, desc));\r\n _$arrayValues(self, value, root, key);\r\n desc.writable = true;\r\n _$def(self, 'length', _$assign({ value: self.length }, desc));\r\n}\r\n_$List.prototype = Object.create(array);\r\n_$List.prototype.constructor = _$List;\r\n['pop', 'push', 'reverse', 'shift', 'sort', 'fill', 'unshift', 'splice'].forEach(function (method) {\r\n _$List.prototype[method] = function () {\r\n var self = this;\r\n var old = self.slice();\r\n var result;\r\n if (method === 'push') {\r\n _$arrayValues(self, _$toArgs(arguments), self._root, self._key);\r\n result = self.length;\r\n }\r\n else {\r\n result = array[method].apply(self, arguments);\r\n }\r\n _$dispatch(self._root, self._key, old, self.slice());\r\n return result;\r\n };\r\n});\r\n_$List.prototype.pull = function (index) {\r\n var self = this;\r\n var items = _$toArgs(arguments, 1);\r\n var length = self.length;\r\n if (index > length) {\r\n length = index + 1;\r\n var pull = new Array(index - self.length);\r\n pull.push.apply(pull, items);\r\n for (var i = 0; i < length; i++) {\r\n if (i === index) {\r\n self.push.apply(self, pull);\r\n }\r\n }\r\n }\r\n else {\r\n self.splice.apply(self, [index, 1].concat(items));\r\n }\r\n};\r\nfunction _$dispatch(root, key, oldVal, value) {\r\n root.$notify(key);\r\n if (root._watchers[key]) {\r\n _$e(root._watchers[key], function (watcher) { watcher(oldVal, value); });\r\n }\r\n root.$update();\r\n}\r\nfunction _$isType(value, type) {\r\n return _$type(type) === 'string' ? type.split('\\|').some(function (t) { return t.trim() === _$type(value); }) : value instanceof type;\r\n}\r\nfunction _$isObject(obj) {\r\n return _$isType(obj, 'object');\r\n}\r\nfunction _$isArray(obj) {\r\n return Array.isArray ? Array.isArray(obj) : _$isType(obj, 'array');\r\n}\r\nfunction _$toType(value, type, root, key) {\r\n switch (type) {\r\n case 'date':\r\n return new Date(value);\r\n case 'string':\r\n return value.toString();\r\n case 'number':\r\n return +value;\r\n case 'boolean':\r\n return !!value;\r\n case 'array':\r\n return _$isType(value, _$List) ? value : new _$List(value, root, key);\r\n default:\r\n return value;\r\n }\r\n}\r\nfunction _$type(obj) {\r\n return /\\[object (\\w+)\\]/.exec(Object.prototype.toString.call(obj))[1].toLowerCase();\r\n}\r\nfunction _$hasProp(obj, prop) {\r\n return obj.hasOwnProperty(prop);\r\n}\r\nfunction _$drt(directive) {\r\n var hasProp = function (prop, instance, options, element) { return _$isObject(directive) && directive[prop] && directive[prop](instance, options, element); };\r\n return {\r\n $init: function (instance, options, element) {\r\n hasProp('$init', instance, options, element);\r\n },\r\n $inserted: function (instance, options, element) {\r\n hasProp('$inserted', instance, options, element);\r\n },\r\n $update: function (instance, options, element) {\r\n if (_$isType(directive, 'function')) {\r\n directive(instance, options, element);\r\n }\r\n else {\r\n hasProp('$update', instance, options, element);\r\n }\r\n },\r\n $destroy: function (instance, options, element) {\r\n hasProp('$destroy', instance, options, element);\r\n }\r\n };\r\n}\r\nfunction _$noop() { }\r\nfunction _$add(inst, child) {\r\n inst.$children.push(child);\r\n}\r\nfunction _$remove(inst, child) {\r\n var index = inst.$children.indexOf(child);\r\n index >= 0 && inst.$children.splice(index, 1);\r\n}\r\nfunction _$toStr(obj) {\r\n var str = _$type(obj);\r\n return !/null|undefined/.test(str) ? obj.toString() : str;\r\n}\r\nfunction _$toPlainObj(obj) {\r\n var data = {};\r\n _$e(_$isObject(obj) ? obj : {}, function (_v, k) {\r\n if (k[0] !== '$' && !_$isType(obj[k], 'function')) {\r\n if (_$isType(obj[k], _$List)) {\r\n data[k] = obj[k].map(_$toPlainObj);\r\n }\r\n else if (_$isObject(obj[k])) {\r\n data[k] = _$toPlainObj(obj[k]);\r\n }\r\n else {\r\n data[k] = obj[k];\r\n }\r\n }\r\n });\r\n return _$isObject(obj) ? data : obj;\r\n}\r\nfunction _$setRef(obj, prop) {\r\n var value = [];\r\n _$def(obj, prop, {\r\n get: function () {\r\n return value.length <= 1 ? value[0] : value;\r\n },\r\n set: function (val) {\r\n if (val && !~value.indexOf(val)) {\r\n value.push(val);\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n}\r\nfunction _$accesor(object, path, value) {\r\n return path.split('.').reduce(function (obj, key, i, arr) {\r\n if (_$isType(value, 'undefined')) {\r\n if (obj == null) {\r\n arr.splice(0, arr.length);\r\n return i > 0 && obj === null ? obj : undefined;\r\n }\r\n }\r\n else {\r\n if (i === arr.length - 1) {\r\n if (_$isType(obj, _$List) && (+key).toString() === key) {\r\n obj.pull(+key, value);\r\n }\r\n else {\r\n var oldVal = obj[key];\r\n obj[key] = !_$isType(value, _$List) && _$isArray(value) ? new _$List(value, object, key) : value;\r\n _$dispatch(object, path, oldVal, obj[key]);\r\n }\r\n }\r\n else if (!_$isObject(obj[key])) {\r\n obj[key] = {};\r\n }\r\n }\r\n return obj ? obj[key] : null;\r\n }, object);\r\n}\r\nfunction _$emptyElse() {\r\n return { type: 'empty-else', $create: _$noop, $mount: _$noop, $update: _$noop, $destroy: _$noop };\r\n}\r\nfunction _$subs(dep, listener) {\r\n if (!this._subscribers[dep]) {\r\n this._subscribers[dep] = [];\r\n }\r\n return this._subscribers[dep].push(listener.bind(this)) - 1;\r\n}\r\nfunction _$def(obj, key, desc) {\r\n Object.defineProperty(obj, key, desc);\r\n}\r\nfunction _$isKey(event, key) {\r\n return event.key.toLowerCase() === key || !!event[key + \"Key\"];\r\n}\r\nfunction _$bindGroup(input, selection) {\r\n var _$index = selection.indexOf(input.value);\r\n if (input.checked && !~_$index)\r\n selection.push(input.value);\r\n else\r\n selection.splice(_$index, 1);\r\n}\r\nfunction _$(selector, parent) {\r\n return _$isType(selector, 'string') ? (parent || document).querySelector(selector) : selector;\r\n}\r\nfunction _$d() {\r\n return document.createDocumentFragment();\r\n}\r\nfunction _$a(parent, child, sibling) {\r\n if (_$isType(sibling, 'boolean') && sibling)\r\n parent.parentElement.replaceChild(child, parent);\r\n else if (!sibling)\r\n parent.appendChild(child);\r\n else\r\n parent.insertBefore(child, sibling);\r\n}\r\nfunction _$as(source, dest) {\r\n var childNodes = source.childNodes;\r\n var attributes = source.attributes;\r\n for (var i = 0; i < childNodes.length; i++) {\r\n _$a(dest, childNodes[i]);\r\n }\r\n for (var i = 0; i < attributes.length; i++) {\r\n var attr = attributes[i];\r\n dest.setAttributeNS(source.namespaceURI, attr.name, attr.value);\r\n }\r\n source.parentElement.replaceChild(dest, source);\r\n return dest;\r\n}\r\nfunction _$r(el, parent) {\r\n var root = parent || el.parentElement;\r\n if (root)\r\n root.removeChild(el);\r\n}\r\nfunction _$ce(tagName) {\r\n return document.createElement(tagName || 'div');\r\n}\r\nfunction _$cse(tagName) {\r\n return document.createElementNS('http://www.w3.org/2000/svg', tagName || 'svg');\r\n}\r\nfunction _$ct(content) {\r\n return document.createTextNode(content || '');\r\n}\r\nfunction _$cm(content) {\r\n return document.createComment(content || '');\r\n}\r\nfunction _$sa(el, attr, value) {\r\n el.setAttribute(attr, value);\r\n}\r\nfunction _$ga(el, attr) {\r\n return el.getAttribute(attr);\r\n}\r\nfunction _$al(el, event, handler) {\r\n el.addEventListener(event, handler, false);\r\n}\r\nfunction _$ul(el, event, oldHandler, newHandler) {\r\n _$rl(el, event, oldHandler);\r\n _$al(el, event, oldHandler = newHandler);\r\n return oldHandler;\r\n}\r\nfunction _$rl(el, event, handler) {\r\n el.removeEventListener(event, handler, false);\r\n}\r\nfunction _$bc(value) {\r\n var classes = '';\r\n if (_$isType(value, 'string')) {\r\n classes += \" \" + value;\r\n }\r\n else if (_$isArray(value)) {\r\n classes = value.map(_$bc).join(' ');\r\n }\r\n else if (_$isObject(value)) {\r\n for (var key in value)\r\n if (_$hasProp(value, key) && value[key])\r\n classes += \" \" + key;\r\n }\r\n return classes.trim();\r\n}\r\nfunction _$bs(value) {\r\n var el = _$ce();\r\n if (_$isObject(value)) {\r\n var style_1 = el.style;\r\n _$e(value, function (val, prop) {\r\n if (val !== style_1[prop]) {\r\n style_1[prop] = val;\r\n }\r\n });\r\n return style_1.cssText;\r\n }\r\n else if (_$isType(value, 'string')) {\r\n return value;\r\n }\r\n else {\r\n return '';\r\n }\r\n}\r\nfunction _$f(root, obj, loop) {\r\n var items = {}, loopParent, loopSibling;\r\n var globs = _$toArgs(arguments, 3);\r\n _$e(obj, function (item, i) { items[i] = loop.apply(null, [root, item, i].concat(globs)); });\r\n return {\r\n $create: function () {\r\n _$e(items, function (item) { item.$create(); });\r\n },\r\n $mount: function (parent, sibling) {\r\n loopParent = _$(parent);\r\n loopSibling = _$(sibling);\r\n _$e(items, function (item) { item.$mount(loopParent, loopSibling); });\r\n },\r\n $update: function (root, obj) {\r\n var globs = _$toArgs(arguments, 2);\r\n _$e(items, function (item, i) {\r\n if (obj[i]) {\r\n item.$update.apply(item, [root, obj[i], i].concat(globs));\r\n }\r\n else {\r\n item.$destroy();\r\n delete items[i];\r\n }\r\n });\r\n _$e(obj, function (item, i) {\r\n if (!items[i]) {\r\n items[i] = loop.apply(null, [root, item, i].concat(globs));\r\n items[i].$create();\r\n items[i].$mount(loopParent, loopSibling);\r\n }\r\n });\r\n },\r\n $destroy: function () {\r\n _$e(items, function (item) { item.$destroy(); });\r\n }\r\n };\r\n}\r\nfunction _$e(obj, cb) {\r\n for (var key in obj) {\r\n if (_$hasProp(obj, key)) {\r\n cb(obj[key], (isNaN(+key) ? key : +key));\r\n }\r\n }\r\n}\r\nfunction _$is(id, css) {\r\n var isNew = false;\r\n var style = _$(\"#\" + id, document.head);\r\n if (!style) {\r\n isNew = true;\r\n style = _$ce('style');\r\n style.id = id;\r\n _$sa(style, 'refs', '1');\r\n }\r\n if (style.textContent !== css) {\r\n style.textContent = css;\r\n }\r\n if (isNew) {\r\n _$a(document.head, style);\r\n }\r\n else {\r\n var count = +_$ga(style, 'refs');\r\n _$sa(style, 'refs', (++count).toString());\r\n }\r\n}\r\nfunction _$ds(id) {\r\n var style = _$(\"#\" + id, document.head);\r\n if (style) {\r\n var count = +_$ga(style, 'refs');\r\n if (--count === 0) {\r\n _$r(style, document.head);\r\n }\r\n else {\r\n _$sa(style, 'refs', count.toString());\r\n }\r\n }\r\n}\r\n//# sourceMappingURL=index.js.map\n// EXTERNAL MODULE: d:/DEVELOP/Work in Progress/trebor-repos/trebor-transitions/node_modules/hash-sum/hash-sum.js\nvar hash_sum = __webpack_require__(\"../../../../trebor-transitions/node_modules/hash-sum/hash-sum.js\");\nvar hash_sum_default = /*#__PURE__*/__webpack_require__.n(hash_sum);\n\n// CONCATENATED MODULE: d:/DEVELOP/Work in Progress/trebor-repos/trebor-transitions/transition.js\nvar HALF = .5;\r\nvar PI = Math.PI, pow = Math.pow, sin = Math.sin;\r\nvar NEWTON_ITERATIONS = 4;\r\nvar NEWTON_MIN_SLOPE = 0.001;\r\nvar SUBDIVISION_PRECISION = 0.0000001;\r\nvar SUBDIVISION_MAX_ITERATIONS = 10;\r\nvar kSplineTableSize = 11;\r\nvar kSampleStepSize = 1 / (kSplineTableSize - 1);\r\nvar float32ArraySupported = typeof Float32Array === 'function';\r\nfunction C(aA1) { return 3 * aA1; }\r\nfunction now() { return performance.now(); }\r\nfunction B(aA1, aA2) { return C(aA2) - 6 * aA1; }\r\nfunction A(aA1, aA2) { return 1 - C(aA2) + C(aA1); }\r\nfunction calcBezier(aT, aA1, aA2) {\r\n return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT;\r\n}\r\nfunction getSlope(aT, aA1, aA2) {\r\n return C(A(aA1, aA2) * aT * aT + 2 * B(aA1, aA2) * aT + C(aA1));\r\n}\r\nfunction binarySubdivide(aX, aA, aB, mX1, mX2) {\r\n var currentX, currentT, i = 0;\r\n do {\r\n currentT = aA + (aB - aA) / 2;\r\n currentX = calcBezier(currentT, mX1, mX2) - aX;\r\n if (currentX > 0) {\r\n aB = currentT;\r\n }\r\n else {\r\n aA = currentT;\r\n }\r\n } while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS);\r\n return currentT;\r\n}\r\nfunction newtonRaphsonIterate(aX, aGuessT, mX1, mX2) {\r\n for (var i = 0; i < NEWTON_ITERATIONS; ++i) {\r\n var currentSlope = getSlope(aGuessT, mX1, mX2);\r\n if (currentSlope === 0) {\r\n return aGuessT;\r\n }\r\n var currentX = calcBezier(aGuessT, mX1, mX2) - aX;\r\n aGuessT -= currentX / currentSlope;\r\n }\r\n return aGuessT;\r\n}\r\nfunction cubicBezier(mX1, mY1, mX2, mY2) {\r\n if (!(0 <= mX1 && mX1 <= 1 && 0 <= mX2 && mX2 <= 1)) {\r\n throw new Error('bezier x values must be in [0, 1] range');\r\n }\r\n if (mX1 === mY1 && mX2 === mY2) {\r\n return function (x) { return x; };\r\n }\r\n var sampleValues = float32ArraySupported ? new Float32Array(kSplineTableSize) : new Array(kSplineTableSize);\r\n for (var i = 0; i < kSplineTableSize; ++i) {\r\n sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);\r\n }\r\n function getTForX(aX) {\r\n var currentSample = 1;\r\n var intervalStart = 0;\r\n var lastSample = kSplineTableSize - 1;\r\n for (; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) {\r\n intervalStart += kSampleStepSize;\r\n }\r\n --currentSample;\r\n var dist = (aX - sampleValues[currentSample]) / (sampleValues[currentSample + 1] - sampleValues[currentSample]);\r\n var guessForT = intervalStart + dist * kSampleStepSize;\r\n var initialSlope = getSlope(guessForT, mX1, mX2);\r\n if (initialSlope >= NEWTON_MIN_SLOPE) {\r\n return newtonRaphsonIterate(aX, guessForT, mX1, mX2);\r\n }\r\n else if (initialSlope === 0) {\r\n return guessForT;\r\n }\r\n else {\r\n return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, mX1, mX2);\r\n }\r\n }\r\n return function (x) {\r\n if (x === 0)\r\n return 0;\r\n if (x === 1)\r\n return 1;\r\n return calcBezier(getTForX(x), mY1, mY2);\r\n };\r\n}\r\nfunction bounceOut(t) {\r\n var c = .9, a = 4 / 11, b = 8 / 11;\r\n var ca = 4356 / 361, cb = 35442 / 1805, cc = 16061 / 1805, t2 = t * t;\r\n return t < a ? 7.5625 * t2 : t < b ? 9.075 * t2 - 9.9 * t + 3.4 : t < c ? ca * t2 - cb * t + cc : 10.8 * t * t - 20.52 * t + 10.72;\r\n}\r\nfunction bounceInOut(t) {\r\n return t < HALF ? HALF * (1 - bounceOut(1 - t * 2)) : HALF * bounceOut(t * 2 - 1) + HALF;\r\n}\r\nfunction bounceIn(t) {\r\n return 1 - bounceOut(1 - t);\r\n}\r\nfunction elasticInOut(t) {\r\n return t < HALF\r\n ? HALF * sin(13 * PI / 2 * 2 * t) * pow(2, 10 * (2 * t - 1))\r\n : HALF * sin(-13 * PI / 2 * ((2 * t - 1) + 1)) * pow(2, -10 * (2 * t - 1)) + 1;\r\n}\r\nfunction elasticIn(t) {\r\n return sin(13 * t * PI / 2) * pow(2, 10 * (t - 1));\r\n}\r\nfunction elasticOut(t) {\r\n return sin(-13 * (t + 1) * PI / 2) * pow(2, -10 * t) + 1;\r\n}\r\nvar snap = cubicBezier(0, 1, HALF, 1);\r\nvar easeIn = cubicBezier(.42, 0, 1, 1);\r\nvar easeOut = cubicBezier(0, 0, .58, 1);\r\nvar inOut = cubicBezier(.42, 0, .58, 1);\r\nvar linear = cubicBezier(.25, .25, .75, .75);\r\nvar backIn = cubicBezier(.6, -.28, .735, .045);\r\nvar circIn = cubicBezier(.6, .04, .98, .335);\r\nvar cubicIn = cubicBezier(.55, .055, .675, .19);\r\nvar expoIn = cubicBezier(.95, .05, .795, .035);\r\nvar quadIn = cubicBezier(.55, .085, .68, .53);\r\nvar quartIn = cubicBezier(.895, .03, .685, .22);\r\nvar quintIn = cubicBezier(.755, .05, .855, .06);\r\nvar sineIn = cubicBezier(.47, 0, .745, .715);\r\nvar backOut = cubicBezier(.175, .885, .32, 1.275);\r\nvar circOut = cubicBezier(.075, .82, .165, 1);\r\nvar cubicOut = cubicBezier(.215, .61, .355, 1);\r\nvar expoOut = cubicBezier(.19, 1, .22, 1);\r\nvar quadOut = cubicBezier(.25, .46, .45, .94);\r\nvar quartOut = cubicBezier(.165, .84, .44, 1);\r\nvar quintOut = cubicBezier(.23, 1, .32, 1);\r\nvar sineOut = cubicBezier(.39, .575, .565, 1);\r\nvar backInOut = cubicBezier(.68, -.55, .265, 1.55);\r\nvar circInOut = cubicBezier(.785, .135, .15, .86);\r\nvar cubicInOut = cubicBezier(.645, .045, .355, 1);\r\nvar expoInOut = cubicBezier(1, 0, 0, 1);\r\nvar quadInOut = cubicBezier(.455, .03, .515, .955);\r\nvar quartInOut = cubicBezier(.77, 0, .175, 1);\r\nvar quintInOut = cubicBezier(.86, 0, .07, 1);\r\nvar sineInOut = cubicBezier(.445, .05, .55, .95);\r\nfunction transition(_a) {\r\n var _b = _a.ease, ease = _b === void 0 ? easeIn : _b, duration = _a.duration, _c = _a.loop, loop = _c === void 0 ? false : _c, _d = _a.delay, delay = _d === void 0 ? 0 : _d;\r\n var diff = 0;\r\n var start, change, ended;\r\n function init() {\r\n start = now();\r\n !this.running && (this.running = true);\r\n requestAnimationFrame(animate.bind(this));\r\n }\r\n function animate(time) {\r\n if (this.paused || !change)\r\n return;\r\n var fraction = (time - start + diff) / (duration || 800);\r\n var progress = ease(fraction > 1 ? fraction = 1 : fraction);\r\n change(progress);\r\n if (fraction < 1) {\r\n requestAnimationFrame(animate.bind(this));\r\n }\r\n else if (loop) {\r\n diff = 0;\r\n init.call(this);\r\n }\r\n else {\r\n this.running = false;\r\n ended && ended();\r\n }\r\n }\r\n return {\r\n paused: false,\r\n running: false,\r\n on: function (event, handler) {\r\n event === 'ended' && (ended = handler);\r\n event === 'change' && (change = handler);\r\n },\r\n run: function (d, l) {\r\n delay = l || delay || 0;\r\n duration = d || duration || 800;\r\n delay > 0 ? setTimeout(init.bind(this), delay) : init.call(this);\r\n },\r\n pause: function () {\r\n if (!this.running)\r\n return;\r\n this.paused = true;\r\n diff += now() - start;\r\n },\r\n play: function () {\r\n if (!this.running)\r\n return;\r\n this.paused = false;\r\n init.call(this);\r\n }\r\n };\r\n}\r\n\n// CONCATENATED MODULE: d:/DEVELOP/Work in Progress/trebor-repos/trebor-transitions/tools.js\nvar __assign = (undefined && undefined.__assign) || function () {\r\n __assign = Object.assign || function(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n };\r\n return __assign.apply(this, arguments);\r\n};\r\n\r\n\r\nfunction animate(options, run) {\r\n var style = document.querySelector('[animation-style-sheet]');\r\n if (!style) {\r\n style = document.createElement('style');\r\n style.setAttribute('animation-style-sheet', '');\r\n document.head.appendChild(style);\r\n }\r\n var el, styleIndex;\r\n var styleSheet = style.sheet;\r\n var className = \"animation_\" + hash_sum_default()(run);\r\n var _a = __assign({ delay: 0, duration: 400, ease: easeIn }, options), ease = _a.ease, delay = _a.delay, duration = _a.duration;\r\n var inAnimation = transition({ duration: duration, delay: delay, ease: ease });\r\n var outAnimation = transition({ duration: duration, delay: delay, ease: function (x) { return 1 - ease(1 - x); } });\r\n function setChangeCB(node, animation) {\r\n var args = [];\r\n for (var _i = 2; _i < arguments.length; _i++) {\r\n args[_i - 2] = arguments[_i];\r\n }\r\n el = node;\r\n var anime = animation === 'in' ? inAnimation : outAnimation;\r\n var change = run(node);\r\n el.classList.add(className);\r\n anime.on('change', function (progress) {\r\n styleSheet.cssRules.length && styleSheet.deleteRule(styleIndex);\r\n var styleTxt = change(animation === 'in' ? progress : 1 - progress);\r\n styleSheet.insertRule(\".\" + className + \"{\" + styleTxt + \"}\");\r\n styleIndex = styleSheet.cssRules.length - 1;\r\n });\r\n anime.run.apply(anime, args);\r\n }\r\n return {\r\n state: 'in',\r\n started: false,\r\n ended: function (handler) {\r\n var callback = function () {\r\n el.classList.remove(className);\r\n handler && handler();\r\n styleSheet.deleteRule(styleIndex);\r\n };\r\n inAnimation.on('ended', callback);\r\n outAnimation.on('ended', function () {\r\n callback();\r\n });\r\n },\r\n run: function (node) {\r\n var args = [];\r\n for (var _i = 1; _i < arguments.length; _i++) {\r\n args[_i - 1] = arguments[_i];\r\n }\r\n var self = this;\r\n if (self.state === 'in') {\r\n self.in.apply(self, [node].concat(args));\r\n self.state = 'out';\r\n }\r\n else {\r\n self.out.apply(self, [node].concat(args));\r\n self.state = 'in';\r\n }\r\n },\r\n in: function (node) {\r\n var args = [];\r\n for (var _i = 1; _i < arguments.length; _i++) {\r\n args[_i - 1] = arguments[_i];\r\n }\r\n setChangeCB.apply(void 0, [node, 'in'].concat(args));\r\n },\r\n out: function (node) {\r\n var args = [];\r\n for (var _i = 1; _i < arguments.length; _i++) {\r\n args[_i - 1] = arguments[_i];\r\n }\r\n setChangeCB.apply(void 0, [node, 'out'].concat(args));\r\n }\r\n };\r\n}\r\n\n// CONCATENATED MODULE: d:/DEVELOP/Work in Progress/trebor-repos/trebor-transitions/index.js\nvar trebor_transitions_assign = (undefined && undefined.__assign) || function () {\r\n trebor_transitions_assign = Object.assign || function(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n };\r\n return trebor_transitions_assign.apply(this, arguments);\r\n};\r\n\r\n\r\nfunction FadeAnimation(options) {\r\n options = options || { delay: 0, duration: 400 };\r\n return animate(options, function (node) {\r\n var opacity = +(getComputedStyle(node).opacity || 0);\r\n return function (progress) { return \"opacity: \" + progress * opacity + \";\"; };\r\n });\r\n}\r\nfunction FlyAnimation(options) {\r\n options = options || { delay: 0, duration: 400, x: 0, y: 0, ease: cubicOut };\r\n return animate(options, function (node) {\r\n var opacity, transform;\r\n var _a = trebor_transitions_assign({ x: 0, y: 0 }, options), x = _a.x, y = _a.y;\r\n var style = getComputedStyle(node);\r\n opacity = +(style.opacity || 0);\r\n transform = style.transform === 'none' ? '' : (style.transform ? style.transform + \" \" : '');\r\n return function (progress) { return \"opacity: \" + progress * opacity + \"; \" +\r\n (\"transform: \" + transform + \"translate(\" + (1 - progress) * (x || 0) + \"px, \" + (1 - progress) * (y || 0) + \"px);\"); };\r\n });\r\n}\r\nfunction SlideAnimation(options) {\r\n options = options || { delay: 0, duration: 400, ease: cubicOut };\r\n return animate(options, function (node) {\r\n var opacity, height, paddingTop, paddingBottom, marginTop, marginBottom, borderTopWidth, borderBottomWidth;\r\n var style = getComputedStyle(node);\r\n opacity = +(style.opacity || 0);\r\n height = parseFloat(style.height || '0');\r\n marginTop = parseFloat(style.marginTop || '0');\r\n paddingTop = parseFloat(style.paddingTop || '0');\r\n marginBottom = parseFloat(style.marginBottom || '0');\r\n paddingBottom = parseFloat(style.paddingBottom || '0');\r\n borderTopWidth = parseFloat(style.borderTopWidth || '0');\r\n borderBottomWidth = parseFloat(style.borderBottomWidth || '0');\r\n return function (progress) { return \"overflow: hidden;\" +\r\n (\"height: \" + progress * height + \"px;\") +\r\n (\"margin-top: \" + progress * marginTop + \"px;\") +\r\n (\"padding-top: \" + progress * paddingTop + \"px;\") +\r\n (\"margin-bottom: \" + progress * marginBottom + \"px;\") +\r\n (\"padding-bottom: \" + progress * paddingBottom + \"px;\") +\r\n (\"border-top-width: \" + progress * borderTopWidth + \"px;\") +\r\n (\"opacity: \" + Math.min(progress * 20, 1) * opacity + \";\") +\r\n (\"border-bottom-width: \" + progress * borderBottomWidth + \"px;\"); };\r\n });\r\n}\r\n\n// CONCATENATED MODULE: ./components/animation.html\n\n\nfunction ifCondition_1(_$state) {\n var _$frag, div_1, txt_1, _refs;\n _$frag = _$d();\n _refs = _$state.$refs;\n return {\n type: 'if',\n $create: function () {\n div_1 = _$ce();\n txt_1 = _$ct('Hello word!');\n !_refs['box'] && _$setRef(_refs, 'box');\n _refs['box'] = div_1;\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$a(_$(parent), _$frag, _$(sibling));\n },\n $update: _$noop,\n $unmount: function () {\n _$a(div_1, txt_1);\n _$a(_$frag, div_1);\n },\n $destroy: function () {\n this.$unmount();\n if (_$isType(_refs['box'], 'array')) {\n var indexDiv_1 = _refs['box'].indexOf(div_1);\n _refs['box'].splice(indexDiv_1, 1);\n } else {\n delete _refs['box'];\n }\n _$frag = div_1 = txt_1 = _refs = void 0;\n }\n };\n}\nfunction condition_1(_$state) {\n if (_$state.visible)\n return ifCondition_1(_$state);\n else\n return _$emptyElse();\n}\nfunction _$tplAnimation(_$state) {\n var _$frag, input_1, changeEvent_1, handlerChangeEvent_1, label_1, txt_1, setTxt_1, conditionAnchor_1, conditionBlock_1;\n _$frag = _$d();\n changeEvent_1 = function (_$state, $event, $el) {\n _$state.onChange($el.checked);\n };\n setTxt_1 = function () {\n return 'Visible: ';\n };\n '+(_$state.visible)+';\n '';\n conditionAnchor_1 = _$ct();\n return {\n $create: function () {\n input_1 = _$ce('input');\n label_1 = _$ce('label');\n txt_1 = _$ct();\n txt_1.data = setTxt_1(_$state);\n conditionBlock_1 = condition_1(_$state);\n conditionBlock_1.$create();\n this.$hydrate();\n },\n $hydrate: function () {\n _$al(input_1, 'change', handlerChangeEvent_1 = function (event) {\n changeEvent_1(_$state, event, input_1);\n });\n _$sa(input_1, 'id', 'visible');\n _$sa(input_1, 'type', 'checkbox');\n _$sa(label_1, 'for', 'visible');\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$is('scope_53e11e76', 'div {width:125px;padding:45px 0;color:white;text-align:center;background-color:black;}');\n _$a(_$(parent), _$frag, _$(sibling));\n this.$siblingEl = _$(sibling);\n this.$parentEl = sibling && _$(sibling).parentElement || _$(parent);\n },\n $update: function (_$state) {\n var updateTxt_1 = setTxt_1(_$state);\n if (txt_1.data !== _$toStr(updateTxt_1)) {\n txt_1.data = updateTxt_1;\n }\n updateTxt_1 = void 0;\n if (conditionBlock_1 && conditionBlock_1.type === condition_1(_$state).type) {\n conditionBlock_1.$update(_$state);\n } else {\n conditionBlock_1 && conditionBlock_1.$destroy();\n conditionBlock_1 = condition_1(_$state);\n conditionBlock_1.$create();\n conditionBlock_1.$mount(_$state.$parentEl, conditionAnchor_1);\n }\n },\n $unmount: function () {\n _$a(_$frag, input_1);\n _$a(label_1, txt_1);\n _$a(_$frag, label_1);\n _$a(_$frag, conditionAnchor_1);\n conditionBlock_1.$mount(_$frag, conditionAnchor_1);\n },\n $destroy: function () {\n this.$unmount();\n this.$parent = null;\n this.$parentEl = null;\n this.$siblingEl = null;\n this.$children.splice(0, this.$children.length);\n _$ds('scope_53e11e76');\n _$rl(input_1, 'change', handlerChangeEvent_1);\n conditionBlock_1.$destroy();\n delete _$state.$root;\n _$frag = input_1 = changeEvent_1 = handlerChangeEvent_1 = label_1 = txt_1 = setTxt_1 = conditionAnchor_1 = conditionBlock_1 = void 0;\n }\n };\n}\nvar animation = SlideAnimation({\n y: 300,\n duration: 1200\n});\nfunction Animation(_$attrs, _$parent) {\n _$CompCtr.call(this, _$attrs, _$tplAnimation, {\n model: {\n visible: false,\n onChange: function (value) {\n var _this = this;\n var refs = this.$refs;\n animation.ended(function () {\n !value && _this.$update();\n });\n if (value) {\n this.$set('visible', value);\n animation.in(refs.box);\n } else {\n this.visible = value;\n animation.out(refs.box);\n }\n }\n }\n }, _$parent);\n !_$parent && this.$create();\n}\nAnimation.plugin = _$plugin;\nAnimation.prototype = Object.create(_$CompCtr.prototype);\nAnimation.prototype.constructor = Animation;\n/* harmony default export */ var components_animation = (Animation);\n// CONCATENATED MODULE: ./main.ts\n\r\nvar main_animation = new components_animation();\r\nmain_animation.$mount('main');\r\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vZDovREVWRUxPUC9Xb3JrIGluIFByb2dyZXNzL3RyZWJvci1yZXBvcy90cmVib3IvdG9vbHMvaW5kZXguanM/YzBmNiIsIndlYnBhY2s6Ly8vZDovREVWRUxPUC9Xb3JrIGluIFByb2dyZXNzL3RyZWJvci1yZXBvcy90cmVib3ItdHJhbnNpdGlvbnMvdHJhbnNpdGlvbi5qcz8wNDBhIiwid2VicGFjazovLy9kOi9ERVZFTE9QL1dvcmsgaW4gUHJvZ3Jlc3MvdHJlYm9yLXJlcG9zL3RyZWJvci10cmFuc2l0aW9ucy90b29scy5qcz82Yz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B2YXIgdmFsdWUgPSBhdHRyc1thdHRyT3BzXTtcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXyRpc1R5cGUodmFsdWUsICdmdW5jdGlvbicpID8gdmFsdWUoKSA6IHZhbHVlO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFfJGhhc1Byb3AoYXR0cnMsIGtleSkgJiYgYXR0ck9wcy5yZXF1aXJlZCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmVycm9yKFwiQXR0cmlidXRlICdcIiArIGtleSArIFwiJyBtdXN0IGJlIHByZXNlbnQgYmVjYXVzZSBpdCdzIHJlcXVpcmVkLlwiKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB2YWx1ZSA9IF8kaXNUeXBlKGF0dHJzW2tleV0sICdmdW5jdGlvbicpID8gYXR0cnNba2V5XSgpIDogYXR0cnNba2V5XTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlID09PSB2b2lkIDAgJiYgXyRoYXNQcm9wKGF0dHJPcHMsICdkZWZhdWx0JykpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBkZWYgPSBhdHRyT3BzLmRlZmF1bHQ7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IF8kaXNUeXBlKGRlZiwgJ2Z1bmN0aW9uJykgPyBkZWYoKSA6IGRlZjtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgdHlwID0gYXR0ck9wcy50eXBlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwICYmICFfJGlzVHlwZSh2YWx1ZSwgdHlwKSAmJiBhdHRyT3BzLnJlcXVpcmVkKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY29uc29sZS5lcnJvcihcIkF0dHJpYnV0ZSAnXCIgKyBrZXkgKyBcIicgbXVzdCBiZSB0eXBlICdcIiArIHR5cCArIFwiJy5cIik7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF8kdG9UeXBlKHZhbHVlLCB2YWx1ZSA9PT0gdm9pZCAwID8gJ3VuZGVmaW5lZCcgOiB0eXAsIHNlbGYsIGtleSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoXCJDYW4gbm90IG1vZGlmeSBhdHRyaWJ1dGUgJ1wiICsga2V5ICsgXCInIGJlY2F1c2UgYXR0cmlidXRlcyBhbCByZWFkIG9ubHkuXCIpO1xyXG4gICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLCBjb25maWd1cmFibGU6IHRydWVcclxuICAgICAgICB9KTtcclxuICAgIH0pO1xyXG4gICAgdmFyIGRhdGEgPSBvcHRzLm1vZGVsIHx8IHt9O1xyXG4gICAgdmFyIF9sb29wXzEgPSBmdW5jdGlvbiAoa2V5KSB7XHJcbiAgICAgICAgaWYgKF8kaGFzUHJvcChkYXRhLCBrZXkpKSB7XHJcbiAgICAgICAgICAgIHZhciBkZXNjID0gT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcihkYXRhLCBrZXkpO1xyXG4gICAgICAgICAgICBpZiAoZGVzYy52YWx1ZSAmJiBfJGlzQXJyYXkoZGVzYy52YWx1ZSkpIHtcclxuICAgICAgICAgICAgICAgIGRlc2MudmFsdWUgPSBuZXcgXyRMaXN0KGRlc2MudmFsdWUsIHNlbGYsIGtleSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgZWxzZSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoZGVzYy5nZXQpIHtcclxuICAgICAgICAgICAgICAgICAgICB2YXIgZ2V0dGVyXzEgPSBkZXNjLmdldDtcclxuICAgICAgICAgICAgICAgICAgICBkZXNjLmdldCA9IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHZhbHVlID0gZ2V0dGVyXzEuY2FsbChzZWxmKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF8kaXNBcnJheSh2YWx1ZSkpXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IG5ldyBfJExpc3QodmFsdWUsIHNlbGYsIGtleSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTtcclxuICAgICAgICAgICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgaWYgKGRlc2Muc2V0KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdmFyIHNldHRlcl8xID0gZGVzYy5zZXQ7XHJcbiAgICAgICAgICAgICAgICAgICAgZGVzYy5zZXQgPSBmdW5jdGlvbiAodikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoXyRpc0FycmF5KHYpKVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdiA9IG5ldyBfJExpc3Qodiwgc2VsZiwga2V5KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2V0dGVyXzEuY2FsbChzZWxmLCB2KTtcclxuICAgICAgICAgICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIF8kZGVmKHNlbGYsIGtleSwgZGVzYyk7XHJcbiAgICAgICAgfVxyXG4gICAgfTtcclxuICAgIGZvciAodmFyIGtleSBpbiBkYXRhKSB7XHJcbiAgICAgICAgX2xvb3BfMShrZXkpO1xyXG4gICAgfVxyXG4gICAgdmFyIHRwbCA9IHRlbXBsYXRlKHNlbGYsIG9wdHMuY2hpbGRyZW4pO1xyXG4gICAgXyRlKHRwbCwgZnVuY3Rpb24gKHZhbHVlLCBrZXkpIHtcclxuICAgICAgICBfJGRlZihzZWxmLCBrZXksIHtcclxuICAgICAgICAgICAgdmFsdWU6IChmdW5jdGlvbiAoa2V5KSB7XHJcbiAgICAgICAgICAgICAgICB2YXIgaG9vayA9IGtleVsxXS50b1VwcGVyQ2FzZSgpICsga2V5LnNsaWNlKDIpO1xyXG4gICAgICAgICAgICAgICAgdmFyIGJob29rID0gb3B0c1tcImJlZm9yZVwiICsgaG9va107XHJcbiAgICAgICAgICAgICAgICB2YXIgYWhvb2sgPSBvcHRzW1wiYWZ0ZXJcIiArIGhvb2tdO1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgICAgICBiaG9vayAmJiBiaG9vay5jYWxsKHRoaXMpO1xyXG4gICAgICAgICAgICAgICAgICAgIGtleS5zbGljZSgxKSA9PT0gJ3VwZGF0ZScgPyB2YWx1ZS5jYWxsKHRoaXMsIHRoaXMpIDogdmFsdWUuYXBwbHkodGhpcywgYXJndW1lbnRzKTtcclxuICAgICAgICAgICAgICAgICAgICBhaG9vayAmJiBhaG9vay5jYWxsKHRoaXMpO1xyXG4gICAgICAgICAgICAgICAgfTtcclxuICAgICAgICAgICAgfSkoa2V5KVxyXG4gICAgICAgIH0pO1xyXG4gICAgfSk7XHJcbiAgICBfJGRlZihzZWxmLCAnJGRhdGEnLCB7XHJcbiAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIHJldHVybiBfJHRvUGxhaW5PYmoodGhpcyk7XHJcbiAgICAgICAgfVxyXG4gICAgfSk7XHJcbn1cclxuZXhwb3J0IGZ1bmN0aW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0dXJuIHtcclxuICAgICAgICAgICAgJHVub2JzZXJ2ZTogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgXyRlKHN1YnMsIGZ1bmN0aW9uIChzdWIpIHtcclxuICAgICAgICAgICAgICAgICAgICBfdGhpcy5fc3Vic2NyaWJlcnNbc3ViLnN1Yl0uc3BsaWNlKHN1Yi5pLCAxKTtcclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfTtcclxuICAgIH0sXHJcbiAgICAkd2F0Y2g6IGZ1bmN0aW9uIChrZXksIHdhdGNoZXIpIHtcclxuICAgICAgICB2YXIgX3RoaXMgPSB0aGlzO1xyXG4gICAgICAgIGlmICghdGhpcy5fd2F0Y2hlcnNba2V5XSkge1xyXG4gICAgICAgICAgICB0aGlzLl93YXRjaGVyc1trZXldID0gW107XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHZhciBpID0gdGhpcy5fd2F0Y2hlcnNba2V5XS5wdXNoKHdhdGNoZXIuYmluZCh0aGlzKSk7XHJcbiAgICAgICAgcmV0dXJuIHtcclxuICAgICAgICAgICAgJHVud2F0Y2g6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgIF90aGlzLl93YXRjaGVyc1trZXldLnNwbGljZShpIC0gMSwgMSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9O1xyXG4gICAgfVxyXG59KTtcclxudmFyIGFycmF5ID0gQXJyYXkucHJvdG90eXBlO1xyXG5mdW5jdGlvbiBfJHRvQXJncyhhcmdzLCBzdGFydCkge1xyXG4gICAgaWYgKHN0YXJ0ID09PSB2b2lkIDApIHsgc3RhcnQgPSAwOyB9XHJcbiAgICByZXR1cm4gYXJyYXkuc2xpY2UuY2FsbChhcmdzLCBzdGFydCk7XHJcbn1cclxuZnVuY3Rpb24gXyRhcnJheVZhbHVlcyhsaXN0LCB2YWx1ZSwgcm9vdCwga2V5KSB7XHJcbiAgICBhcnJheS5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pba10pO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgZGF0YVtrXSA9IG9ialtrXTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuICAgIH0pO1xyXG4gICAgcmV0dXJuIF8kaXNPYmplY3Qob2JqKSA/IGRhdGEgOiBvYmo7XHJcbn1cclxuZXhwb3J0IGZ1bmN0aW9uIF8kc2V0UmVmKG9iaiwgcHJvcCkge1xyXG4gICAgdmFyIHZhbHVlID0gW107XHJcbiAgICBfJGRlZihvYmosIHByb3AsIHtcclxuICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgcmV0dXJuIHZhbHVlLmxlbmd0aCA8PSAxID8gdmFsdWVbMF0gOiB2YWx1ZTtcclxuICAgICAgICB9LFxyXG4gICAgICAgIHNldDogZnVuY3Rpb24gKHZhbCkge1xyXG4gICAgICAgICAgICBpZiAodmFsICYmICF+dmFsdWUuaW5kZXhPZih2YWwpKSB7XHJcbiAgICAgICAgICAgICAgICB2YWx1ZS5wdXNoKHZhbCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9LFxyXG4gICAgICAgIGVudW1lcmFibGU6IHRydWUsXHJcbiAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlXHJcbiAgICB9KTtcclxufVxyXG5mdW5jdGlvbiBfJGFjY2Vzb3Iob2JqZWN0LCBwYXRoLCB2YWx1ZSkge1xyXG4gICAgcmV0dXJuIHBhdGguc3BsaXQoJy4nKS5yZWR1Y2UoZnVuY3Rpb24gKG9iaiwga2V5LCBpLCBhcnIpIHtcclxuICAgICAgICBpZiAoXyRpc1R5cGUodmFsdWUsICd1bmRlZmluZWQnKSkge1xyXG4gICAgICAgICAgICBpZiAob2JqID09IG51bGwpIHtcclxuICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoMCwgYXJyLmxlbmd0aCk7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gaSA+IDAgJiYgb2JqID09PSBudWxsID8gb2JqIDogdW5kZWZpbmVkO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGVsc2Uge1xyXG4gICAgICAgICAgICBpZiAoaSA9PT0gYXJyLmxlbmd0aCAtIDEpIHtcclxuICAgICAgICAgICAgICAgIGlmIChfJGlzVHlwZShvYmosIF8kTGlzdCkgJiYgKCtrZXkpLnRvU3RyaW5nKCkgPT09IGtleSkge1xyXG4gICAgICAgICAgICAgICAgICAgIG9iai5wdWxsKCtrZXksIHZhbHVlKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgIHZhciBvbGRWYWwgPSBvYmpba2V5XTtcclxuICAgICAgICAgICAgICAgICAgICBvYmpba2V5XSA9ICFfJGlzVHlwZSh2YWx1ZSwgXyRMaXN0KSAmJiBfJGlzQXJyYXkodmFsdWUpID8gbmV3IF8kTGlzdCh2YWx1ZSwgb2JqZWN0LCBrZXkpIDogdmFsdWU7XHJcbiAgICAgICAgICAgICAgICAgICAgXyRkaXNwYXRjaChvYmplY3QsIHBhdGgsIG9sZFZhbCwgb2JqW2tleV0pO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGVsc2UgaWYgKCFfJGlzT2JqZWN0KG9ialtrZXldKSkge1xyXG4gICAgICAgICAgICAgICAgb2JqW2tleV0gPSB7fTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuICAgICAgICByZXR1cm4gb2JqID8gb2JqW2tleV0gOiBudWxsO1xyXG4gICAgfSwgb2JqZWN0KTtcclxufVxyXG5leHBvcnQgZnVuY3Rpb24gXyRlbXB0eUVsc2UoKSB7XHJcbiAgICByZXR1cm4geyB0eXBlOiAnZW1wdHktZWxzZScsICRjcmVhdGU6IF8kbm9vcCwgJG1vdW50OiBfJG5vb3AsICR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cFBhcmVudCA9IF8kKHBhcmVudCk7XHJcbiAgICAgICAgICAgIGxvb3BTaWJsaW5nID0gXyQoc2libGluZyk7XHJcbiAgICAgICAgICAgIF8kZShpdGVtcywgZnVuY3Rpb24gKGl0ZW0pIHsgaXRlbS4kbW91bnQobG9vcFBhcmVudCwgbG9vcFNpYmxpbmcpOyB9KTtcclxuICAgICAgICB9LFxyXG4gICAgICAgICR1cGRhdGU6IGZ1bmN0aW9uIChyb290LCBvYmopIHtcclxuICAgICAgICAgICAgdmFyIGdsb2JzID0gXyR0b0FyZ3MoYXJndW1lbnRzLCAyKTtcclxuICAgICAgICAgICAgXyRlKGl0ZW1zLCBmdW5jdGlvbiAoaXRlbSwgaSkge1xyXG4gICAgICAgICAgICAgICAgaWYgKG9ialtpXSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGl0ZW0uJHVwZGF0ZS5hcHBseShpdGVtLCBbcm9vdCwgb2JqW2ldLCBpXS5jb25jYXQoZ2xvYnMpKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgIGl0ZW0uJGRlc3Ryb3koKTtcclxuICAgICAgICAgICAgICAgICAgICBkZWxldGUgaXRlbXNbaV07XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICBfJGUob2JqLCBmdW5jdGlvbiAoaXRlbSwgaSkge1xyXG4gICAgICAgICAgICAgICAgaWYgKCFpdGVtc1tpXSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGl0ZW1zW2ldID0gbG9vcC5hcHBseShudWxsLCBbcm9vdCwgaXRlbSwgaV0uY29uY2F0KGdsb2JzKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgaXRlbXNbaV0uJGNyZWF0ZSgpO1xyXG4gICAgICAgICAgICAgICAgICAgIGl0ZW1zW2ldLiRtb3VudChsb29wUGFyZW50LCBsb29wU2libGluZyk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgJGRlc3Ryb3k6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgXyRlKGl0ZW1zLCBmdW5jdGlvbiAoaXRlbSkgeyBpdGVtLiRkZXN0cm95KCk7IH0pO1xyXG4gICAgICAgIH1cclxuICAgIH07XHJcbn1cclxuZXhwb3J0IGZ1bmN0aW9uIF8kZShvYmosIGNiKSB7XHJcbiAgICBmb3IgKHZhciBrZXkgaW4gb2JqKSB7XHJcbiAgICAgICAgaWYgKF8kaGFzUHJvcChvYmosIGtleSkpIHtcclxuICAgICAgICAgICAgY2Iob2JqW2tleV0sIChpc05hTigra2V5KSA/IGtleSA6ICtrZXkpKTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcbn1cclxuZXhwb3J0IGZ1bmN0aW9uIF8kaXMoaWQsIGNzcykge1xyXG4gICAgdmFyIGlzTmV3ID0gZmFsc2U7XHJcbiAgICB2YXIgc3R5bGUgPSBfJChcIiNcIiArIGlkLCBkb2N1bWVudC5oZWFkKTtcclxuICAgIGlmICghc3R5bGUpIHtcclxuICAgICAgICBpc05ldyA9IHRydWU7XHJcbiAgICAgICAgc3R5bGUgPSBfJGNlKCdzdHlsZScpO1xyXG4gICAgICAgIHN0eWxlLmlkID0gaWQ7XHJcbiAgICAgICAgXyRzYShzdHlsZSwgJ3JlZnMnLCAnMScpO1xyXG4gICAgfVxyXG4gICAgaWYgKHN0eWxlLnRleHRDb250ZW50ICE9PSBjc3MpIHtcclxuICAgICAgICBzdHlsZS50ZXh0Q29udGVudCA9IGNzcztcclxuICAgIH1cclxuICAgIGlmIChpc05ldykge1xyXG4gICAgICAgIF8kYShkb2N1bWVudC5oZWFkLCBzdHlsZSk7XHJcbiAgICB9XHJcbiAgICBlbHNlIHtcclxuICAgICAgICB2YXIgY291bnQgPSArXyRnYShzdHlsZSwgJ3JlZnMnKTtcclxuICAgICAg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YWxzZSxcclxuICAgICAgICBvbjogZnVuY3Rpb24gKGV2ZW50LCBoYW5kbGVyKSB7XHJcbiAgICAgICAgICAgIGV2ZW50ID09PSAnZW5kZWQnICYmIChlbmRlZCA9IGhhbmRsZXIpO1xyXG4gICAgICAgICAgICBldmVudCA9PT0gJ2NoYW5nZScgJiYgKGNoYW5nZSA9IGhhbmRsZXIpO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgcnVuOiBmdW5jdGlvbiAoZCwgbCkge1xyXG4gICAgICAgICAgICBkZWxheSA9IGwgfHwgZGVsYXkgfHwgMDtcclxuICAgICAgICAgICAgZHVyYXRpb24gPSBkIHx8IGR1cmF0aW9uIHx8IDgwMDtcclxuICAgICAgICAgICAgZGVsYXkgPiAwID8gc2V0VGltZW91dChpbml0LmJpbmQodGhpcyksIGRlbGF5KSA6IGluaXQuY2FsbCh0aGlzKTtcclxuICAgICAgICB9LFxyXG4gICAgICAgIHBhdXNlOiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIGlmICghdGhpcy5ydW5uaW5nKVxyXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICB0aGlzLnBhdXNlZCA9IHRydWU7XHJcbiAgICAgICAgICAgIGRpZmYgKz0gbm93KCkgLSBzdGFydDtcclxuICAgICAgICB9LFxyXG4gICAgICAgIHBsYXk6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgaWYgKCF0aGlzLnJ1bm5pbmcpXHJcbiAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgIHRoaXMucGF1c2VkID0gZmFsc2U7XHJcbiAgICAgICAgICAgIGluaXQuY2FsbCh0aGlzKTtcclxuICAgICAgICB9XHJcbiAgICB9O1xyXG59XHJcbiIsInZhciBfX2Fzc2lnbiA9ICh0aGlzICYmIHRoaXMuX19hc3NpZ24pIHx8IGZ1bmN0aW9uICgpIHtcclxuICAgIF9fYXNzaWduID0gT2JqZWN0LmFzc2l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FyIGFyZ3MgPSBbXTtcclxuICAgICAgICAgICAgZm9yICh2YXIgX2kgPSAxOyBfaSA8IGFyZ3VtZW50cy5sZW5ndGg7IF9pKyspIHtcclxuICAgICAgICAgICAgICAgIGFyZ3NbX2kgLSAxXSA9IGFyZ3VtZW50c1tfaV07XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzO1xyXG4gICAgICAgICAgICBpZiAoc2VsZi5zdGF0ZSA9PT0gJ2luJykge1xyXG4gICAgICAgICAgICAgICAgc2VsZi5pbi5hcHBseShzZWxmLCBbbm9kZV0uY29uY2F0KGFyZ3MpKTtcclxuICAgICAgICAgICAgICAgIHNlbGYuc3RhdGUgPSAnb3V0JztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBlbHNlIHtcclxuICAgICAgICAgICAgICAgIHNlbGYub3V0LmFwcGx5KHNlbGYsIFtub2RlXS5jb25jYXQoYXJncykpO1xyXG4gICAgICAgICAgICAgICAgc2VsZi5zdGF0ZSA9ICdpbic7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9LFxyXG4gICAgICAgIGluOiBmdW5jdGlvbiAobm9kZSkge1xyXG4gICAgICAgICAgICB2YXIgYXJncyA9IFtdO1xyXG4gICAgICAgICAgICBmb3IgKHZhciBfaSA9IDE7IF9pIDwgYXJndW1lbnRzLmxlbmd0aDsgX2krKykge1xyXG4gICAgICAgICAgICAgICAgYXJnc1tfaSAtIDFdID0gYXJndW1lbnRzW19pXTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBzZXRDaGFuZ2VDQi5hcHBseSh2b2lkIDAsIFtub2RlLCAnaW4nXS5jb25jYXQoYXJncykpO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgb3V0OiBmdW5jdGlvbiAobm9kZSkge1xyXG4gICAgICAgICAgICB2YXIgYXJncyA9IFtdO1xyXG4gICAgICAgICAgICBmb3IgKHZhciBfaSA9IDE7IF9pIDwgY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Skge1xuICAgICAgICB2YXIgX3RoaXMgPSB0aGlzO1xuICAgICAgICB2YXIgcmVmcyA9IHRoaXMuJHJlZnM7XG4gICAgICAgIGFuaW1hdGlvbi5lbmRlZChmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgIXZhbHVlICYmIF90aGlzLiR1cGRhdGUoKTtcbiAgICAgICAgfSk7XG4gICAgICAgIGlmICh2YWx1ZSkge1xuICAgICAgICAgIHRoaXMuJHNldCgndmlzaWJsZScsIHZhbHVlKTtcbiAgICAgICAgICBhbmltYXRpb24uaW4ocmVmcy5ib3gpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHRoaXMudmlzaWJsZSA9IHZhbHVlO1xuICAgICAgICAgIGFuaW1hdGlvbi5vdXQocmVmcy5ib3gpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICB9LCBfJHBhcmVudCk7XG4gICFfJHBhcmVudCAmJiB0aGlzLiRjcmVhdGUoKTtcbn1cbkFuaW1hdGlvbi5wbHVnaW4gPSBfJHBsdWdpbjtcbkFuaW1hdGlvbi5wcm90b3R5cGUgPSBPYmplY3QuY3JlYXRlKF8kQ29tcEN0ci5wcm90b3R5cGUpO1xuQW5pbWF0aW9uLnByb3RvdHlwZS5jb25zdHJ1Y3RvciA9IEFuaW1hdGlvbjtcbmV4cG9ydCBkZWZhdWx0IEFuaW1hdGlvbjsiLCJpbXBvcnQgQW5pbWF0aW9uIGZyb20gJy4vY29tcG9uZW50cy9hbmltYXRpb24uaHRtbCc7XHJcblxyXG5jb25zdCBhbmltYXRpb24gPSBuZXcgQW5pbWF0aW9uKCk7XHJcblxyXG5hbmltYXRpb24uJG1vdW50KCdtYWluJyk7XHJcbiJdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///./main.ts\n"); +eval("\n// CONCATENATED MODULE: h:/trebor-repos/trebor/tools/index.js\nvar PROP_MAP = { p: '__TP__', v: 'value', _: '_value', s: '_subscribers', e: '_events', w: '_watchers', h: 'prototype' };\r\nvar PROPS = ['$slots', '$refs', '$filters', '$directives', '_events', '_watchers'];\r\nvar TPS = window[PROP_MAP.p] || (window[PROP_MAP.p] = []);\r\nvar _$assign = Object['assign'] || function (t) {\r\n for (var s = void 0, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s)\r\n if (_$hasProp(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n};\r\nfunction _$CompCtr(attrs, template, options, parent) {\r\n var self = this;\r\n var _$set = function (prop, value) { _$def(self, prop, { value: value, writable: true }); };\r\n if (!attrs)\r\n attrs = {};\r\n _$e(PROPS, function (prop) { _$def(self, prop, { value: {} }); });\r\n _$set('$parent', parent || null);\r\n _$set('$children', []);\r\n _$set(PROP_MAP.s, {});\r\n _$set('$options', options);\r\n var opts = self.$options;\r\n if (!opts.attrs)\r\n opts.attrs = {};\r\n if (!opts.children)\r\n opts.children = {};\r\n _$e(TPS, function (plugin) { plugin.fn.call(self, _$CompCtr, plugin.options); });\r\n if (opts.filters)\r\n _$assign(self.$filters, opts.filters);\r\n if (opts.directives)\r\n _$e(opts.directives, function (drt, k) { self.$directives[k] = _$drt(drt); });\r\n _$e(opts.attrs, function (attrOps, key) {\r\n _$def(self, (_$isType(key, 'number') ? attrOps : key), {\r\n get: function () {\r\n if (_$isStr(attrOps)) {\r\n var value = attrs[attrOps];\r\n return _$isFunction(value) ? value() : value;\r\n }\r\n else {\r\n if (!_$hasProp(attrs, key) && attrOps.required) {\r\n return console.error(\"Attribute '\" + key + \"' is required.\");\r\n }\r\n else {\r\n var value = _$isFunction(attrs[key]) ? attrs[key]() : attrs[key];\r\n if (value === void 0 && _$hasProp(attrOps, 'default')) {\r\n var def = attrOps.default;\r\n value = _$isFunction(def) ? def() : def;\r\n }\r\n var typ = attrOps.type;\r\n if (typ && !_$isType(value, typ) && attrOps.required) {\r\n return console.error(\"Attribute '\" + key + \"' must be type '\" + typ + \"'.\");\r\n }\r\n value = _$toType(value, value === void 0 ? 'undefined' : typ, self, key);\r\n if (value !== void 0 && _$hasProp(attrOps, 'validator')) {\r\n var validator = attrOps.validator;\r\n if (_$isFunction(validator) && !validator(value)) {\r\n return console.error(\"Assigment '\" + key + \"'='\" + JSON.stringify(value) + \"' invalid.\");\r\n }\r\n }\r\n return value;\r\n }\r\n }\r\n },\r\n set: function () {\r\n console.error(\"'\" + key + \"' is read only.\");\r\n },\r\n enumerable: true, configurable: true\r\n });\r\n });\r\n var data = opts.model || {};\r\n var _loop_1 = function (key) {\r\n if (_$hasProp(data, key)) {\r\n var desc = Object.getOwnPropertyDescriptor(data, key);\r\n if (desc.value && _$isArray(desc.value)) {\r\n desc.value = new _$List(desc.value, self, key);\r\n }\r\n else {\r\n if (desc.get) {\r\n var getter_1 = desc.get;\r\n desc.get = function () {\r\n var value = getter_1.call(self);\r\n if (_$isArray(value))\r\n value = new _$List(value, self, key);\r\n return value;\r\n };\r\n }\r\n if (desc.set) {\r\n var setter_1 = desc.set;\r\n desc.set = function (v) {\r\n if (_$isArray(v))\r\n v = new _$List(v, self, key);\r\n setter_1.call(self, v);\r\n };\r\n }\r\n }\r\n _$def(self, key, desc);\r\n }\r\n };\r\n for (var key in data) {\r\n _loop_1(key);\r\n }\r\n var tpl = template(self);\r\n _$e(tpl, function (value, key) {\r\n _$def(self, key, {\r\n value: (function (key) {\r\n var hook = key[1].toUpperCase() + key.slice(2);\r\n var bhook = opts[\"before\" + hook];\r\n var ahook = opts[\"after\" + hook];\r\n return function () {\r\n bhook && bhook.call(this);\r\n key.slice(1) === 'update' ? value.call(this, this) : value.apply(this, arguments);\r\n ahook && ahook.call(this);\r\n };\r\n })(key)\r\n });\r\n });\r\n _$def(self, '$data', {\r\n get: function () {\r\n return _$toPlainObj(this);\r\n }\r\n });\r\n}\r\nfunction _$isValueAttr(attr) {\r\n return attr === 'value';\r\n}\r\nfunction _$subs(dep, listener) {\r\n if (!this[PROP_MAP.s][dep]) {\r\n this[PROP_MAP.s][dep] = [];\r\n }\r\n return this[PROP_MAP.s][dep].push(listener.bind(this)) - 1;\r\n}\r\nfunction _$def(obj, key, desc) {\r\n Object.defineProperty(obj, key, desc);\r\n}\r\n_$assign(_$CompCtr[PROP_MAP.h], {\r\n $get: function (path) {\r\n return _$accesor(this, path);\r\n },\r\n $set: function (path, value) {\r\n _$accesor(this, path, value);\r\n },\r\n $on: function (event, handler) {\r\n var _this = this;\r\n if (!this[PROP_MAP.e][event]) {\r\n this[PROP_MAP.e][event] = [];\r\n }\r\n var i = this[PROP_MAP.e][event].push(handler);\r\n return {\r\n $off: function () {\r\n _this[PROP_MAP.e][event].splice(i - 1, 1);\r\n }\r\n };\r\n },\r\n $once: function (event, handler) {\r\n var e = this.$on(event, function (args) {\r\n handler(args);\r\n e.$off();\r\n });\r\n },\r\n $fire: function (event, data) {\r\n if (this[PROP_MAP.e][event]) {\r\n _$e(this[PROP_MAP.e][event], function (handler) { handler(data); });\r\n }\r\n },\r\n $notify: function (key) {\r\n if (this[PROP_MAP.s][key]) {\r\n _$e(this[PROP_MAP.s][key], function (suscriber) { suscriber(); });\r\n }\r\n },\r\n $observe: function (deps, listener) {\r\n var _this = this;\r\n var subs = [];\r\n if (_$isArray(deps)) {\r\n _$e(deps, function (dep) {\r\n subs.push({ sub: dep, i: _$subs.call(_this, dep, listener) });\r\n });\r\n }\r\n else {\r\n subs.push({ sub: deps, i: _$subs.call(this, deps, listener) });\r\n }\r\n return {\r\n $unobserve: function () {\r\n _$e(subs, function (sub) {\r\n _this[PROP_MAP.s][sub.sub].splice(sub.i, 1);\r\n });\r\n }\r\n };\r\n },\r\n $watch: function (key, watcher) {\r\n var _this = this;\r\n if (!this[PROP_MAP.w][key]) {\r\n this[PROP_MAP.w][key] = [];\r\n }\r\n var i = this[PROP_MAP.w][key].push(watcher.bind(this));\r\n return {\r\n $unwatch: function () {\r\n _this[PROP_MAP.w][key].splice(i - 1, 1);\r\n }\r\n };\r\n }\r\n});\r\nvar array = Array[PROP_MAP.h];\r\nfunction _$toArgs(args, start) {\r\n if (start === void 0) { start = 0; }\r\n return array.slice.call(args, start);\r\n}\r\nfunction _$arrayValues(list, value, root, key) {\r\n array.push.apply(list, value.map(function (v, i) {\r\n if (list.length !== 0)\r\n i += list.length;\r\n return !(_$isType(v, _$List)) && _$isArray(v) ? new _$List(v, root, key + \".\" + i) : v;\r\n }));\r\n}\r\nfunction _$List(value, root, key) {\r\n var self = this;\r\n Array.apply(self, [value.length]);\r\n var desc = { writable: false, configurable: false, enumerable: false };\r\n _$def(self, '_key', _$assign({ value: key }, desc));\r\n _$def(self, '_root', _$assign({ value: root }, desc));\r\n _$arrayValues(self, value, root, key);\r\n desc.writable = true;\r\n _$def(self, 'length', _$assign({ value: self.length }, desc));\r\n}\r\n_$extends(_$List, Array);\r\n['pop', 'push', 'reverse', 'shift', 'sort', 'fill', 'unshift', 'splice'].forEach(function (method) {\r\n _$List[PROP_MAP.h][method] = function () {\r\n var self = this;\r\n var old = self.slice();\r\n var result;\r\n if (method === 'push') {\r\n _$arrayValues(self, _$toArgs(arguments), self._root, self._key);\r\n result = self.length;\r\n }\r\n else {\r\n result = array[method].apply(self, arguments);\r\n }\r\n _$dispatch(self._root, self._key, old, self.slice());\r\n return result;\r\n };\r\n});\r\n_$List[PROP_MAP.h].pull = function (index) {\r\n var self = this;\r\n var items = _$toArgs(arguments, 1);\r\n var length = self.length;\r\n if (index > length) {\r\n length = index + 1;\r\n var pull = new Array(index - self.length);\r\n pull.push.apply(pull, items);\r\n for (var i = 0; i < length; i++) {\r\n if (i === index) {\r\n self.push.apply(self, pull);\r\n }\r\n }\r\n }\r\n else {\r\n self.splice.apply(self, [index, 1].concat(items));\r\n }\r\n};\r\nfunction _$dispatch(root, key, oldVal, value) {\r\n root.$notify(key);\r\n if (root[PROP_MAP.w][key]) {\r\n _$e(root[PROP_MAP.w][key], function (watcher) { watcher(oldVal, value); });\r\n }\r\n root.$update();\r\n}\r\nfunction _$extends(ctor, exts) {\r\n ctor['plugin'] = function (fn, options) {\r\n TPS.push({ options: options, fn: fn });\r\n };\r\n ctor[PROP_MAP.h] = Object.create(exts[PROP_MAP.h]);\r\n ctor[PROP_MAP.h].constructor = ctor;\r\n}\r\nfunction _$isType(value, type) {\r\n return _$type(type) === 'string' ? type.split('|').some(function (t) { return t.trim() === _$type(value); }) : value instanceof type;\r\n}\r\nfunction _$apply(callee, args, globs, thisArg) {\r\n if (thisArg === void 0) { thisArg = null; }\r\n return callee.apply(thisArg, args.concat(globs));\r\n}\r\nfunction _$isObject(obj) {\r\n return _$isType(obj, 'object');\r\n}\r\nfunction _$isArray(obj) {\r\n return Array.isArray ? Array.isArray(obj) : _$isType(obj, 'array');\r\n}\r\nfunction _$isFunction(obj) {\r\n return _$isType(obj, 'function');\r\n}\r\nfunction _$isStr(obj) {\r\n return _$isType(obj, 'string');\r\n}\r\nfunction _$toType(value, type, root, key) {\r\n switch (type) {\r\n case 'date':\r\n return new Date(value);\r\n case 'string':\r\n return _$toStr(value);\r\n case 'number':\r\n return +value;\r\n case 'boolean':\r\n return _$isStr(value) && !value ? true : !!value;\r\n case 'array':\r\n return _$isType(value, _$List) ? value : new _$List(value, root, key);\r\n default:\r\n return value;\r\n }\r\n}\r\nfunction _$type(obj) {\r\n return / (\\w+)/.exec(({}).toString.call(obj))[1].toLowerCase();\r\n}\r\nfunction _$hasProp(obj, prop) {\r\n return obj.hasOwnProperty(prop);\r\n}\r\nfunction _$drt(dd) {\r\n var hasProp = function (prop, instance, options, element) { return _$isObject(dd) && dd[prop] && dd[prop](instance, options, element); };\r\n return {\r\n $init: function (instance, options, element) {\r\n hasProp('$init', instance, options, element);\r\n },\r\n $inserted: function (instance, options, element) {\r\n hasProp('$inserted', instance, options, element);\r\n },\r\n $update: function (instance, options, element) {\r\n if (_$isFunction(dd)) {\r\n dd(instance, options, element);\r\n }\r\n else {\r\n hasProp('$update', instance, options, element);\r\n }\r\n },\r\n $destroy: function (instance, options, element) {\r\n hasProp('$destroy', instance, options, element);\r\n }\r\n };\r\n}\r\nfunction _$noop() { }\r\nfunction _$add(inst, Child, attrs) {\r\n var child = null;\r\n if (Child) {\r\n child = new Child(attrs, inst);\r\n inst.$children.push(child);\r\n }\r\n return child;\r\n}\r\nfunction _$remove(inst, child) {\r\n var index = inst.$children.indexOf(child);\r\n index >= 0 && inst.$children.splice(index, 1);\r\n}\r\nfunction _$toStr(obj) {\r\n var str = _$type(obj);\r\n return !/null|undefined/.test(str) ? obj.toString() : str;\r\n}\r\nfunction _$toPlainObj(obj) {\r\n var data = {};\r\n _$e(_$isObject(obj) ? obj : {}, function (_v, k) {\r\n if (k[0] !== '$' && !_$isFunction(obj[k])) {\r\n if (_$isType(obj[k], _$List)) {\r\n data[k] = obj[k].map(_$toPlainObj);\r\n }\r\n else if (_$isObject(obj[k])) {\r\n data[k] = _$toPlainObj(obj[k]);\r\n }\r\n else {\r\n data[k] = obj[k];\r\n }\r\n }\r\n });\r\n return _$isObject(obj) ? data : obj;\r\n}\r\nfunction _$setRef(refs, prop, node) {\r\n if (!_$hasProp(refs, prop)) {\r\n var value_1 = [];\r\n _$def(refs, prop, {\r\n get: function () { return value_1.length <= 1 ? value_1[0] : value_1; },\r\n set: function (val) { val && !~value_1.indexOf(val) && value_1.push(val); },\r\n enumerable: true, configurable: true\r\n });\r\n }\r\n refs[prop] = node;\r\n}\r\nfunction _$accesor(object, path, value) {\r\n return path.split('.').reduce(function (obj, key, i, arr) {\r\n if (_$isType(value, 'undefined')) {\r\n if (obj == null) {\r\n arr.splice(0, arr.length);\r\n return i > 0 && obj === null ? obj : undefined;\r\n }\r\n }\r\n else {\r\n if (i === arr.length - 1) {\r\n if (_$isType(obj, _$List) && _$toStr(+key) === key) {\r\n obj.pull(+key, value);\r\n }\r\n else {\r\n var oldVal = obj[key];\r\n obj[key] = !_$isType(value, _$List) && _$isArray(value) ? new _$List(value, object, key) : value;\r\n _$dispatch(object, path, oldVal, obj[key]);\r\n }\r\n }\r\n else if (!_$isObject(obj[key])) {\r\n obj[key] = {};\r\n }\r\n }\r\n return obj ? obj[key] : null;\r\n }, object);\r\n}\r\nfunction _$emptyElse() {\r\n return { type: 'empty-else', $create: _$noop, $mount: _$noop, $update: _$noop, $destroy: _$noop };\r\n}\r\nfunction _$isKey(event, key) {\r\n return event.key.toLowerCase() === key || !!event[key + \"Key\"];\r\n}\r\nfunction _$bindGroup(input, selection) {\r\n var _value = _$gv(input);\r\n var _$index = selection.indexOf(_value);\r\n input.checked && !~_$index ? selection.push(_value) : selection.splice(_$index, 1);\r\n}\r\nfunction _$bindMultiSelect(select, selections) {\r\n if (!selections.length)\r\n return;\r\n var options = select.options;\r\n for (var i = 0; i < options.length; i++) {\r\n options[i].selected = !!~selections.indexOf(_$gv(options[i]));\r\n }\r\n}\r\nfunction _$updateMultiSelect(select, obj, prop) {\r\n var items = [];\r\n var selection = obj[prop];\r\n var selectedOptions = select.selectedOptions;\r\n for (var i = 0; i < selectedOptions.length; i++) {\r\n items.push(_$gv(selectedOptions[i]));\r\n }\r\n obj[prop] = new _$List(items, selection['_root'], selection['_key']);\r\n obj.$update();\r\n}\r\nfunction _$(selector, parent) {\r\n return _$isStr(selector) ? (parent || document).querySelector(selector) : selector;\r\n}\r\nfunction _$d() {\r\n return document.createDocumentFragment();\r\n}\r\nfunction _$a(parent, child, sibling) {\r\n if (_$isType(sibling, 'boolean') && sibling)\r\n parent.parentElement.replaceChild(child, parent);\r\n else if (!sibling)\r\n parent.appendChild(child);\r\n else\r\n parent.insertBefore(child, sibling);\r\n}\r\nfunction _$as(source, dest) {\r\n var childNodes = source.childNodes, attributes = source.attributes;\r\n for (var i = 0; i < childNodes.length; i++) {\r\n _$a(dest, childNodes[i]);\r\n }\r\n for (var i = 0; i < attributes.length; i++) {\r\n var attr = attributes[i];\r\n dest.setAttributeNS(source.namespaceURI, attr.name, attr.value);\r\n }\r\n source.parentElement.replaceChild(dest, source);\r\n return dest;\r\n}\r\nfunction _$r(el, parent) {\r\n var root = parent || el.parentElement;\r\n if (root)\r\n root.removeChild(el);\r\n}\r\nfunction _$ce(tagName) {\r\n return document.createElement(tagName || 'div');\r\n}\r\nfunction _$cse(tagName) {\r\n return document.createElementNS('http://www.w3.org/2000/svg', tagName || 'svg');\r\n}\r\nfunction _$ct(content) {\r\n return document.createTextNode(content || '');\r\n}\r\nfunction _$cm(content) {\r\n return document.createComment(content || '');\r\n}\r\nfunction _$sa(el, attrAndValue) {\r\n var attr = attrAndValue[0], value = attrAndValue[1];\r\n el.setAttribute(attr, _$toStr(value));\r\n if (_$isValueAttr(attr) && !_$isStr(value))\r\n el[PROP_MAP._] = value;\r\n}\r\nfunction _$ga(el, attr) {\r\n return _$isValueAttr(attr) ? _$gv(el) : el.getAttribute(attr);\r\n}\r\nfunction _$gv(el) {\r\n return _$hasProp(el, PROP_MAP._) ? el[PROP_MAP._] : el[PROP_MAP.v];\r\n}\r\nfunction _$al(el, event, handler) {\r\n el.addEventListener(event, handler, false);\r\n}\r\nfunction _$ul(el, event, oldHandler, newHandler) {\r\n _$rl(el, event, oldHandler);\r\n _$al(el, event, oldHandler = newHandler);\r\n return oldHandler;\r\n}\r\nfunction _$rl(el, event, handler) {\r\n el.removeEventListener(event, handler, false);\r\n}\r\nfunction _$bc(value) {\r\n var classes = '';\r\n if (_$isStr(value)) {\r\n classes += \" \" + value;\r\n }\r\n else if (_$isArray(value)) {\r\n classes = value.map(_$bc).join(' ');\r\n }\r\n else if (_$isObject(value)) {\r\n for (var key in value)\r\n if (_$hasProp(value, key) && value[key])\r\n classes += \" \" + key;\r\n }\r\n return classes.trim();\r\n}\r\nfunction _$bs(value) {\r\n var el = _$ce();\r\n if (_$isObject(value)) {\r\n var style_1 = el.style;\r\n _$e(value, function (val, prop) {\r\n if (val !== style_1[prop])\r\n style_1[prop] = val;\r\n });\r\n return style_1.cssText;\r\n }\r\n else if (_$isStr(value)) {\r\n return value;\r\n }\r\n else {\r\n return '';\r\n }\r\n}\r\nfunction _$cu(block, condition, parent, anchor, inst) {\r\n var globs = _$toArgs(arguments, 5);\r\n if (block && block.type === _$apply(condition, [inst], globs).type) {\r\n _$apply(block.$update, [inst], globs, block);\r\n }\r\n else {\r\n block && block.$destroy();\r\n block = _$apply(condition, [inst], globs);\r\n block.$create();\r\n block.$mount(parent || inst.$parentEl, anchor);\r\n }\r\n return block;\r\n}\r\nfunction _$bba(el, attrAndValue) {\r\n var attr = attrAndValue[0], value = attrAndValue[1];\r\n el[attr] = value == null || value === false ? (el.removeAttribute(attr), false) : (_$sa(el, [attr, '']), true);\r\n}\r\nfunction _$bu(el, binding) {\r\n var attr = binding[0], value = binding[1];\r\n var _value = _$toStr(value);\r\n if (_$isValueAttr(attr)) {\r\n if (el[attr] !== _value)\r\n el[attr] = _value;\r\n el[PROP_MAP._] = value;\r\n }\r\n else if (_$ga(el, attr) !== _value) {\r\n _$sa(el, [attr, _value]);\r\n }\r\n}\r\nfunction _$tu(text, value) {\r\n if (text.data !== (value = _$toStr(value)))\r\n text.data = value;\r\n}\r\nfunction _$nu(node, tag) {\r\n return tag.toUpperCase() !== node.tagName ? _$as(node, _$ce(tag)) : node;\r\n}\r\nfunction _$rr(refs, prop, node) {\r\n var nodes = refs[prop];\r\n _$isArray(nodes) ? refs[prop].splice(nodes.indexOf(node), 1) : (delete refs[prop]);\r\n}\r\nfunction _$hu(node, value) {\r\n if (node.innerHTML !== (value = _$toStr(value)))\r\n node.innerHTML = value;\r\n}\r\nfunction _$pu(parent, Ctor, inst, value, attrs, el, sibling) {\r\n if (value === Ctor) {\r\n inst && inst.$update();\r\n }\r\n else {\r\n Ctor = value;\r\n if (inst) {\r\n inst.$destroy();\r\n _$remove(parent, inst);\r\n }\r\n if (inst) {\r\n inst = _$add(parent, Ctor, attrs);\r\n inst.$create();\r\n inst.$mount(el, sibling);\r\n }\r\n }\r\n return [inst, Ctor];\r\n}\r\nfunction _$f(root, obj, loop) {\r\n var items = {}, loopParent, loopSibling;\r\n var globs = _$toArgs(arguments, 3);\r\n _$e(obj, function (item, i, index) { items[i] = _$apply(loop, [root, item, i, index], globs); });\r\n return {\r\n $create: function () {\r\n _$e(items, function (item) { item.$create(); });\r\n },\r\n $mount: function (parent, sibling) {\r\n loopParent = _$(parent);\r\n loopSibling = _$(sibling);\r\n _$e(items, function (item) { item.$mount(loopParent, loopSibling); });\r\n },\r\n $update: function (root, obj) {\r\n var globs = _$toArgs(arguments, 2);\r\n _$e(items, function (item, i, index) {\r\n if (obj[i]) {\r\n _$apply(item.$update, [root, obj[i], i, index], globs, item);\r\n }\r\n else {\r\n item.$destroy();\r\n delete items[i];\r\n }\r\n });\r\n _$e(obj, function (item, i, index) {\r\n if (!items[i]) {\r\n items[i] = _$apply(loop, [root, item, i, index], globs);\r\n items[i].$create();\r\n items[i].$mount(loopParent, loopSibling);\r\n }\r\n });\r\n },\r\n $destroy: function () {\r\n _$e(items, function (item) { item.$destroy(); });\r\n }\r\n };\r\n}\r\nfunction _$e(obj, cb) {\r\n var i = 0;\r\n for (var key in obj) {\r\n if (_$hasProp(obj, key)) {\r\n cb(obj[key], (isNaN(+key) ? key : +key), i++);\r\n }\r\n }\r\n}\r\nfunction _$is(id, css) {\r\n var isNew = false;\r\n var style = _$(\"#\" + id, document.head);\r\n if (!style) {\r\n isNew = true;\r\n style = _$ce('style');\r\n style.id = id;\r\n _$sa(style, ['refs', 1]);\r\n }\r\n if (style.textContent !== css) {\r\n style.textContent = css;\r\n }\r\n if (isNew) {\r\n _$a(document.head, style);\r\n }\r\n else {\r\n var count = +_$ga(style, 'refs');\r\n _$sa(style, ['refs', ++count]);\r\n }\r\n}\r\nfunction _$ds(id) {\r\n var style = _$(\"#\" + id, document.head);\r\n if (style) {\r\n var count = +_$ga(style, 'refs');\r\n if (--count === 0) {\r\n _$r(style, document.head);\r\n }\r\n else {\r\n _$sa(style, ['refs', count]);\r\n }\r\n }\r\n}\r\n//# sourceMappingURL=index.js.map\n// EXTERNAL MODULE: h:/trebor-repos/trebor-transitions/node_modules/hash-sum/hash-sum.js\nvar hash_sum = __webpack_require__(\"../../../../trebor-transitions/node_modules/hash-sum/hash-sum.js\");\nvar hash_sum_default = /*#__PURE__*/__webpack_require__.n(hash_sum);\n\n// CONCATENATED MODULE: h:/trebor-repos/trebor-transitions/transition.js\nvar HALF = .5;\r\nvar PI = Math.PI, pow = Math.pow, sin = Math.sin;\r\nvar NEWTON_ITERATIONS = 4;\r\nvar NEWTON_MIN_SLOPE = 0.001;\r\nvar SUBDIVISION_PRECISION = 0.0000001;\r\nvar SUBDIVISION_MAX_ITERATIONS = 10;\r\nvar kSplineTableSize = 11;\r\nvar kSampleStepSize = 1 / (kSplineTableSize - 1);\r\nvar float32ArraySupported = typeof Float32Array === 'function';\r\nfunction C(aA1) { return 3 * aA1; }\r\nfunction now() { return performance.now(); }\r\nfunction B(aA1, aA2) { return C(aA2) - 6 * aA1; }\r\nfunction A(aA1, aA2) { return 1 - C(aA2) + C(aA1); }\r\nfunction calcBezier(aT, aA1, aA2) {\r\n return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT;\r\n}\r\nfunction getSlope(aT, aA1, aA2) {\r\n return C(A(aA1, aA2) * aT * aT + 2 * B(aA1, aA2) * aT + C(aA1));\r\n}\r\nfunction binarySubdivide(aX, aA, aB, mX1, mX2) {\r\n var currentX, currentT, i = 0;\r\n do {\r\n currentT = aA + (aB - aA) / 2;\r\n currentX = calcBezier(currentT, mX1, mX2) - aX;\r\n if (currentX > 0) {\r\n aB = currentT;\r\n }\r\n else {\r\n aA = currentT;\r\n }\r\n } while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS);\r\n return currentT;\r\n}\r\nfunction newtonRaphsonIterate(aX, aGuessT, mX1, mX2) {\r\n for (var i = 0; i < NEWTON_ITERATIONS; ++i) {\r\n var currentSlope = getSlope(aGuessT, mX1, mX2);\r\n if (currentSlope === 0) {\r\n return aGuessT;\r\n }\r\n var currentX = calcBezier(aGuessT, mX1, mX2) - aX;\r\n aGuessT -= currentX / currentSlope;\r\n }\r\n return aGuessT;\r\n}\r\nfunction cubicBezier(mX1, mY1, mX2, mY2) {\r\n if (!(0 <= mX1 && mX1 <= 1 && 0 <= mX2 && mX2 <= 1)) {\r\n throw new Error('bezier x values must be in [0, 1] range');\r\n }\r\n if (mX1 === mY1 && mX2 === mY2) {\r\n return function (x) { return x; };\r\n }\r\n var sampleValues = float32ArraySupported ? new Float32Array(kSplineTableSize) : new Array(kSplineTableSize);\r\n for (var i = 0; i < kSplineTableSize; ++i) {\r\n sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);\r\n }\r\n function getTForX(aX) {\r\n var currentSample = 1;\r\n var intervalStart = 0;\r\n var lastSample = kSplineTableSize - 1;\r\n for (; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) {\r\n intervalStart += kSampleStepSize;\r\n }\r\n --currentSample;\r\n var dist = (aX - sampleValues[currentSample]) / (sampleValues[currentSample + 1] - sampleValues[currentSample]);\r\n var guessForT = intervalStart + dist * kSampleStepSize;\r\n var initialSlope = getSlope(guessForT, mX1, mX2);\r\n if (initialSlope >= NEWTON_MIN_SLOPE) {\r\n return newtonRaphsonIterate(aX, guessForT, mX1, mX2);\r\n }\r\n else if (initialSlope === 0) {\r\n return guessForT;\r\n }\r\n else {\r\n return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, mX1, mX2);\r\n }\r\n }\r\n return function (x) {\r\n if (x === 0)\r\n return 0;\r\n if (x === 1)\r\n return 1;\r\n return calcBezier(getTForX(x), mY1, mY2);\r\n };\r\n}\r\nfunction bounceOut(t) {\r\n var c = .9, a = 4 / 11, b = 8 / 11;\r\n var ca = 4356 / 361, cb = 35442 / 1805, cc = 16061 / 1805, t2 = t * t;\r\n return t < a ? 7.5625 * t2 : t < b ? 9.075 * t2 - 9.9 * t + 3.4 : t < c ? ca * t2 - cb * t + cc : 10.8 * t * t - 20.52 * t + 10.72;\r\n}\r\nfunction bounceInOut(t) {\r\n return t < HALF ? HALF * (1 - bounceOut(1 - t * 2)) : HALF * bounceOut(t * 2 - 1) + HALF;\r\n}\r\nfunction bounceIn(t) {\r\n return 1 - bounceOut(1 - t);\r\n}\r\nfunction elasticInOut(t) {\r\n return t < HALF\r\n ? HALF * sin(13 * PI / 2 * 2 * t) * pow(2, 10 * (2 * t - 1))\r\n : HALF * sin(-13 * PI / 2 * ((2 * t - 1) + 1)) * pow(2, -10 * (2 * t - 1)) + 1;\r\n}\r\nfunction elasticIn(t) {\r\n return sin(13 * t * PI / 2) * pow(2, 10 * (t - 1));\r\n}\r\nfunction elasticOut(t) {\r\n return sin(-13 * (t + 1) * PI / 2) * pow(2, -10 * t) + 1;\r\n}\r\nvar snap = cubicBezier(0, 1, HALF, 1);\r\nvar easeIn = cubicBezier(.42, 0, 1, 1);\r\nvar easeOut = cubicBezier(0, 0, .58, 1);\r\nvar inOut = cubicBezier(.42, 0, .58, 1);\r\nvar linear = cubicBezier(.25, .25, .75, .75);\r\nvar backIn = cubicBezier(.6, -.28, .735, .045);\r\nvar circIn = cubicBezier(.6, .04, .98, .335);\r\nvar cubicIn = cubicBezier(.55, .055, .675, .19);\r\nvar expoIn = cubicBezier(.95, .05, .795, .035);\r\nvar quadIn = cubicBezier(.55, .085, .68, .53);\r\nvar quartIn = cubicBezier(.895, .03, .685, .22);\r\nvar quintIn = cubicBezier(.755, .05, .855, .06);\r\nvar sineIn = cubicBezier(.47, 0, .745, .715);\r\nvar backOut = cubicBezier(.175, .885, .32, 1.275);\r\nvar circOut = cubicBezier(.075, .82, .165, 1);\r\nvar cubicOut = cubicBezier(.215, .61, .355, 1);\r\nvar expoOut = cubicBezier(.19, 1, .22, 1);\r\nvar quadOut = cubicBezier(.25, .46, .45, .94);\r\nvar quartOut = cubicBezier(.165, .84, .44, 1);\r\nvar quintOut = cubicBezier(.23, 1, .32, 1);\r\nvar sineOut = cubicBezier(.39, .575, .565, 1);\r\nvar backInOut = cubicBezier(.68, -.55, .265, 1.55);\r\nvar circInOut = cubicBezier(.785, .135, .15, .86);\r\nvar cubicInOut = cubicBezier(.645, .045, .355, 1);\r\nvar expoInOut = cubicBezier(1, 0, 0, 1);\r\nvar quadInOut = cubicBezier(.455, .03, .515, .955);\r\nvar quartInOut = cubicBezier(.77, 0, .175, 1);\r\nvar quintInOut = cubicBezier(.86, 0, .07, 1);\r\nvar sineInOut = cubicBezier(.445, .05, .55, .95);\r\nfunction transition(_a) {\r\n var _b = _a.ease, ease = _b === void 0 ? easeIn : _b, duration = _a.duration, _c = _a.loop, loop = _c === void 0 ? false : _c, _d = _a.delay, delay = _d === void 0 ? 0 : _d;\r\n var diff = 0;\r\n var start, change, ended;\r\n function init() {\r\n start = now();\r\n !this.running && (this.running = true);\r\n requestAnimationFrame(animate.bind(this));\r\n }\r\n function animate(time) {\r\n if (this.paused || !change)\r\n return;\r\n var fraction = (time - start + diff) / (duration || 800);\r\n var progress = ease(fraction > 1 ? fraction = 1 : fraction);\r\n change(progress);\r\n if (fraction < 1) {\r\n requestAnimationFrame(animate.bind(this));\r\n }\r\n else if (loop) {\r\n diff = 0;\r\n init.call(this);\r\n }\r\n else {\r\n this.running = false;\r\n ended && ended();\r\n }\r\n }\r\n return {\r\n paused: false,\r\n running: false,\r\n on: function (event, handler) {\r\n event === 'ended' && (ended = handler);\r\n event === 'change' && (change = handler);\r\n },\r\n run: function (d, l) {\r\n delay = l || delay || 0;\r\n duration = d || duration || 800;\r\n delay > 0 ? setTimeout(init.bind(this), delay) : init.call(this);\r\n },\r\n pause: function () {\r\n if (!this.running)\r\n return;\r\n this.paused = true;\r\n diff += now() - start;\r\n },\r\n play: function () {\r\n if (!this.running)\r\n return;\r\n this.paused = false;\r\n init.call(this);\r\n }\r\n };\r\n}\r\n\n// CONCATENATED MODULE: h:/trebor-repos/trebor-transitions/tools.js\nvar __assign = (undefined && undefined.__assign) || function () {\r\n __assign = Object.assign || function(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n };\r\n return __assign.apply(this, arguments);\r\n};\r\n\r\n\r\nfunction animate(options, run) {\r\n var style = document.querySelector('[animation-style-sheet]');\r\n if (!style) {\r\n style = document.createElement('style');\r\n style.setAttribute('animation-style-sheet', '');\r\n document.head.appendChild(style);\r\n }\r\n var el, styleIndex;\r\n var styleSheet = style.sheet;\r\n var className = \"animation_\" + hash_sum_default()(run);\r\n var _a = __assign({ delay: 0, duration: 400, ease: easeIn }, options), ease = _a.ease, delay = _a.delay, duration = _a.duration;\r\n var inAnimation = transition({ duration: duration, delay: delay, ease: ease });\r\n var outAnimation = transition({ duration: duration, delay: delay, ease: function (x) { return 1 - ease(1 - x); } });\r\n function setChangeCB(node, animation) {\r\n var args = [];\r\n for (var _i = 2; _i < arguments.length; _i++) {\r\n args[_i - 2] = arguments[_i];\r\n }\r\n el = node;\r\n var anime = animation === 'in' ? inAnimation : outAnimation;\r\n var change = run(node);\r\n el.classList.add(className);\r\n anime.on('change', function (progress) {\r\n styleSheet.cssRules.length && styleSheet.deleteRule(styleIndex);\r\n var styleTxt = change(animation === 'in' ? progress : 1 - progress);\r\n styleSheet.insertRule(\".\" + className + \"{\" + styleTxt + \"}\");\r\n styleIndex = styleSheet.cssRules.length - 1;\r\n });\r\n anime.run.apply(anime, args);\r\n }\r\n return {\r\n state: 'in',\r\n started: false,\r\n ended: function (handler) {\r\n var callback = function () {\r\n el.classList.remove(className);\r\n handler && handler();\r\n styleSheet.deleteRule(styleIndex);\r\n };\r\n inAnimation.on('ended', callback);\r\n outAnimation.on('ended', function () {\r\n callback();\r\n });\r\n },\r\n run: function (node) {\r\n var args = [];\r\n for (var _i = 1; _i < arguments.length; _i++) {\r\n args[_i - 1] = arguments[_i];\r\n }\r\n var self = this;\r\n if (self.state === 'in') {\r\n self.in.apply(self, [node].concat(args));\r\n self.state = 'out';\r\n }\r\n else {\r\n self.out.apply(self, [node].concat(args));\r\n self.state = 'in';\r\n }\r\n },\r\n in: function (node) {\r\n var args = [];\r\n for (var _i = 1; _i < arguments.length; _i++) {\r\n args[_i - 1] = arguments[_i];\r\n }\r\n setChangeCB.apply(void 0, [node, 'in'].concat(args));\r\n },\r\n out: function (node) {\r\n var args = [];\r\n for (var _i = 1; _i < arguments.length; _i++) {\r\n args[_i - 1] = arguments[_i];\r\n }\r\n setChangeCB.apply(void 0, [node, 'out'].concat(args));\r\n }\r\n };\r\n}\r\n\n// CONCATENATED MODULE: h:/trebor-repos/trebor-transitions/index.js\nvar trebor_transitions_assign = (undefined && undefined.__assign) || function () {\r\n trebor_transitions_assign = Object.assign || function(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n };\r\n return trebor_transitions_assign.apply(this, arguments);\r\n};\r\n\r\n\r\nfunction FadeAnimation(options) {\r\n options = options || { delay: 0, duration: 400 };\r\n return animate(options, function (node) {\r\n var opacity = +(getComputedStyle(node).opacity || 0);\r\n return function (progress) { return \"opacity: \" + progress * opacity + \";\"; };\r\n });\r\n}\r\nfunction FlyAnimation(options) {\r\n options = options || { delay: 0, duration: 400, x: 0, y: 0, ease: cubicOut };\r\n return animate(options, function (node) {\r\n var opacity, transform;\r\n var _a = trebor_transitions_assign({ x: 0, y: 0 }, options), x = _a.x, y = _a.y;\r\n var style = getComputedStyle(node);\r\n opacity = +(style.opacity || 0);\r\n transform = style.transform === 'none' ? '' : (style.transform ? style.transform + \" \" : '');\r\n return function (progress) { return \"opacity: \" + progress * opacity + \"; \" +\r\n (\"transform: \" + transform + \"translate(\" + (1 - progress) * (x || 0) + \"px, \" + (1 - progress) * (y || 0) + \"px);\"); };\r\n });\r\n}\r\nfunction SlideAnimation(options) {\r\n options = options || { delay: 0, duration: 400, ease: cubicOut };\r\n return animate(options, function (node) {\r\n var opacity, height, paddingTop, paddingBottom, marginTop, marginBottom, borderTopWidth, borderBottomWidth;\r\n var style = getComputedStyle(node);\r\n opacity = +(style.opacity || 0);\r\n height = parseFloat(style.height || '0');\r\n marginTop = parseFloat(style.marginTop || '0');\r\n paddingTop = parseFloat(style.paddingTop || '0');\r\n marginBottom = parseFloat(style.marginBottom || '0');\r\n paddingBottom = parseFloat(style.paddingBottom || '0');\r\n borderTopWidth = parseFloat(style.borderTopWidth || '0');\r\n borderBottomWidth = parseFloat(style.borderBottomWidth || '0');\r\n return function (progress) { return \"overflow: hidden;\" +\r\n (\"height: \" + progress * height + \"px;\") +\r\n (\"margin-top: \" + progress * marginTop + \"px;\") +\r\n (\"padding-top: \" + progress * paddingTop + \"px;\") +\r\n (\"margin-bottom: \" + progress * marginBottom + \"px;\") +\r\n (\"padding-bottom: \" + progress * paddingBottom + \"px;\") +\r\n (\"border-top-width: \" + progress * borderTopWidth + \"px;\") +\r\n (\"opacity: \" + Math.min(progress * 20, 1) * opacity + \";\") +\r\n (\"border-bottom-width: \" + progress * borderBottomWidth + \"px;\"); };\r\n });\r\n}\r\n\n// CONCATENATED MODULE: ./components/animation.html\n\r\n\r\nfunction ifCondition_1(_$state) {\r\n var _$frag, div_1, txt_1, _refs;\r\n _$frag = _$d();\r\n _refs = _$state.$refs;\r\n return {\r\n type: 'if',\r\n\r\n $create: function() {\r\n div_1 = _$ce();\r\n txt_1 = _$ct('Hello word!');\r\n _$setRef(_refs, 'box', div_1);\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n },\r\n\r\n $update: _$noop,\r\n\r\n $unmount: function() {\r\n _$a(div_1, txt_1);\r\n _$a(_$frag, div_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n _$rr(_refs, 'box', div_1);\r\n _$frag = div_1 = txt_1 = _refs = void 0;\r\n }\r\n };\r\n}\r\nfunction condition_1(_$state) {\r\n if (_$state.visible)\r\n return ifCondition_1(_$state);\r\n else\r\n return _$emptyElse();\r\n}\r\nfunction _$tplAnimation(_$state) {\r\n var _$frag, input_1, changeEvent_1, handlerChangeEvent_1, label_1, txt_1, setTxt_1, conditionAnchor_1, conditionBlock_1;\r\n _$frag = _$d();\r\n changeEvent_1 = function(_$state, $event, $el) {\r\n _$state.onChange($el.checked);\r\n };\r\n setTxt_1 = function() {\r\n return 'Visible: ';\r\n };\r\n '+(_$state.visible)+';\r\n '';\r\n conditionAnchor_1 = _$ct();\r\n return {\r\n $create: function() {\r\n input_1 = _$ce('input');\r\n label_1 = _$ce('label');\r\n txt_1 = _$ct();\r\n txt_1.data = setTxt_1(_$state);\r\n conditionBlock_1 = condition_1(_$state);\r\n conditionBlock_1.$create();\r\n _$sa(input_1, ['id', 'visible']);\r\n _$sa(input_1, ['type', 'checkbox']);\r\n _$al(input_1, 'change', handlerChangeEvent_1 = function(event) {\r\n changeEvent_1(_$state, event, input_1);\r\n });\r\n _$sa(label_1, ['for', 'visible']);\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$is(\r\n 'scope_2d826740',\r\n 'div {width:125px;padding:45px 0;color:white;text-align:center;background-color:black;}'\r\n );\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n this.$siblingEl = _$(sibling);\r\n this.$parentEl = sibling && _$(sibling).parentElement || _$(parent);\r\n },\r\n\r\n $update: function(_$state) {\r\n _$tu(txt_1, setTxt_1(_$state));\r\n conditionBlock_1 = _$cu(conditionBlock_1, condition_1, undefined, conditionAnchor_1, _$state);\r\n },\r\n\r\n $unmount: function() {\r\n _$a(_$frag, input_1);\r\n _$a(label_1, txt_1);\r\n _$a(_$frag, label_1);\r\n _$a(_$frag, conditionAnchor_1);\r\n conditionBlock_1.$mount(_$frag, conditionAnchor_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n this.$parent = null;\r\n this.$parentEl = null;\r\n this.$siblingEl = null;\r\n this.$children.splice(0, this.$children.length);\r\n _$ds('scope_2d826740');\r\n _$rl(input_1, 'change', handlerChangeEvent_1);\r\n conditionBlock_1.$destroy();\r\n delete _$state.$root;\r\n _$frag = input_1 = changeEvent_1 = handlerChangeEvent_1 = label_1 = txt_1 = setTxt_1 = conditionAnchor_1 = conditionBlock_1 = void 0;\r\n }\r\n };\r\n}\r\nvar animation = SlideAnimation({\r\n y: 300,\r\n duration: 1200\r\n});\r\nfunction Animation(_$attrs, _$parent) {\r\n _$CompCtr.call(this, _$attrs, _$tplAnimation, {\r\n model: {\r\n visible: false,\r\n\r\n onChange: function(value) {\r\n var _this = this;\r\n var refs = this.$refs;\r\n animation.ended(function() {\r\n !value && _this.$update();\r\n });\r\n if (value) {\r\n this.$set('visible', value);\r\n animation.in(refs.box);\r\n } else {\r\n this.visible = value;\r\n animation.out(refs.box);\r\n }\r\n }\r\n }\r\n }, _$parent);\r\n !_$parent && this.$create();\r\n}\r\n_$extends(Animation, _$CompCtr);\r\n/* harmony default export */ var components_animation = (Animation);\r\n\n// CONCATENATED MODULE: ./main.ts\n\r\nvar main_animation = new components_animation();\r\nmain_animation.$mount('main');\r\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vaDovdHJlYm9yLXJlcG9zL3RyZWJvci90b29scy9pbmRleC5qcz84MDFhIiwid2VicGFjazovLy9oOi90cmVib3ItcmVwb3MvdHJlYm9yLXRyYW5zaXRpb25zL3RyYW5zaXRpb24uanM/NzkzMiIsIndlYnBhY2s6Ly8vaDovdHJlYm9yLXJlcG9zL3RyZWJvci10cmFuc2l0aW9ucy90b29scy5qcz9hY2UyIiwid2VicGFjazovLy9oOi90cmVib3ItcmVwb3MvdHJlYm9yLXRyYW5zaXRpb25zL2luZGV4LmpzPzllYjMiLCJ3ZWJwYWNrOi8vLy4vY29tcG9uZW50cy9hbmltYXRpb24uaHRtbD9jZDA4Iiwid2VicGFjazovLy8uL21haW4udHM/ODI2OSJdLCJuYW1lcyI6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iKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB2YWx1ZSA9IF8kaXNGdW5jdGlvbihhdHRyc1trZXldKSA/IGF0dHJzW2tleV0oKSA6IGF0dHJzW2tleV07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZSA9PT0gdm9pZCAwICYmIF8kaGFzUHJvcChhdHRyT3BzLCAnZGVmYXVsdCcpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgZGVmID0gYXR0ck9wcy5kZWZhdWx0O1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUgPSBfJGlzRnVuY3Rpb24oZGVmKSA/IGRlZigpIDogZGVmO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0eXAgPSBhdHRyT3BzLnR5cGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXAgJiYgIV8kaXNUeXBlKHZhbHVlLCB0eXApICYmIGF0dHJPcHMucmVxdWlyZWQpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjb25zb2xlLmVycm9yKFwiQXR0cmlidXRlICdcIiArIGtleSArIFwiJyBtdXN0IGJlIHR5cGUgJ1wiICsgdHlwICsgXCInLlwiKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IF8kdG9UeXBlKHZhbHVlLCB2YWx1ZSA9PT0gdm9pZCAwID8gJ3VuZGVmaW5lZCcgOiB0eXAsIHNlbGYsIGtleSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZSAhPT0gdm9pZCAwICYmIF8kaGFzUHJvcChhdHRyT3BzLCAndmFsaWRhdG9yJykpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciB2YWxpZGF0b3IgPSBhdHRyT3BzLnZhbGlkYXRvcjtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfJGlzRnVuY3Rpb24odmFsaWRhdG9yKSAmJiAhdmFsaWRhdG9yKHZhbHVlKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjb25zb2xlLmVycm9yKFwiQXNzaWdtZW50ICdcIiArIGtleSArIFwiJz0nXCIgKyBKU09OLnN0cmluZ2lmeSh2YWx1ZSkgKyBcIicgaW52YWxpZC5cIik7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgc2V0OiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICBjb25zb2xlLmVycm9yKFwiJ1wiICsga2V5ICsgXCInIGlzIHJlYWQgb25seS5cIik7XHJcbiAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsIGNvbmZpZ3VyYWJsZTogdHJ1ZVxyXG4gICAgICAgIH0pO1xyXG4gICAgfSk7XHJcbiAgICB2YXIgZGF0YSA9IG9wdHMubW9kZWwgfHwge307XHJcbiAgICB2YXIgX2xvb3BfMSA9IGZ1bmN0aW9uIChrZXkpIHtcclxuICAgICAgICBpZiAoXyRoYXNQcm9wKGRhdGEsIGtleSkpIHtcclxuICAgICAgICAgICAgdmFyIGRlc2MgPSBPYmplY3QuZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yKGRhdGEsIGtleSk7XHJcbiAgICAgICAgICAgIGlmIChkZXNjLnZhbHVlICYmIF8kaXNBcnJheShkZXNjLnZhbHVlKSkge1xyXG4gICAgICAgICAgICAgICAgZGVzYy52YWx1ZSA9IG5ldyBfJExpc3QoZGVzYy52YWx1ZSwgc2VsZiwga2V5KTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBlbHNlIHtcclxuICAgICAgICAgICAgICAgIGlmIChkZXNjLmdldCkge1xyXG4gICAgICAgICAgICAgICAgICAgIHZhciBnZXR0ZXJfMSA9IGRlc2MuZ2V0O1xyXG4gICAgICAgICAgICAgICAgICAgIGRlc2MuZ2V0ID0gZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgdmFsdWUgPSBnZXR0ZXJfMS5jYWxsKHNlbGYpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoXyRpc0FycmF5KHZhbHVlKSlcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlID0gbmV3IF8kTGlzdCh2YWx1ZSwgc2VsZiwga2V5KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlO1xyXG4gICAgICAgICAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBpZiAoZGVzYy5zZXQpIHtcclxuICAgICAgICAgICAgICAgICAgICB2YXIgc2V0dGVyXzEgPSBkZXNjLnNldDtcclxuICAgICAgICAgICAgICAgICAgICBkZXNjLnNldCA9IGZ1bmN0aW9uICh2KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfJGlzQXJyYXkodikpXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2ID0gbmV3IF8kTGlzdCh2LCBzZWxmLCBrZXkpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzZXR0ZXJfMS5jYWxsKHNlbGYsIHYpO1xyXG4gICAgICAgICAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgXyRkZWYoc2VsZiwga2V5LCBkZXNjKTtcclxuICAgICAgICB9XHJcbiAgICB9O1xyXG4gICAgZm9yICh2YXIga2V5IGluIGRhdGEpIHtcclxuICAgICAgICBfbG9vcF8xKGtleSk7XHJcbiAgICB9XHJcbiAgICB2YXIgdHBsID0gdGVtcGxhdGUoc2VsZik7XHJcbiAgICBfJGUodHBsLCBmdW5jdGlvbiAodmFsdWUsIGtleSkge1xyXG4gICAgICAgIF8kZGVmKHNlbGYsIGtleSwge1xyXG4gICAgICAgICAgICB2YWx1ZTogKGZ1bmN0aW9uIChrZXkpIHtcclxuICAgICAgICAgICAgICAgIHZhciBob29rID0ga2V5WzFdLnRvVXBwZXJDYXNlKCkgKyBrZXkuc2xpY2UoMik7XHJcbiAgICAgICAgICAgICAgICB2YXIgYmhvb2sgPSBvcHRzW1wiYmVmb3JlXCIgKyBob29rXTtcclxuICAgICAgICAgICAgICAgIHZhciBhaG9vayA9IG9wdHNbXCJhZnRlclwiICsgaG9va107XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgICAgIGJob29rICYmIGJob29rLmNhbGwodGhpcyk7XHJcbiAgICAgICAgICAgICAgICAgICAga2V5LnNsaWNlKDEpID09PSAndXBkYXRlJyA/IHZhbHVlLmNhbGwodGhpcywgdGhpcykgOiB2YWx1ZS5hcHBseSh0aGlzLCBhcmd1bWVudHMpO1xyXG4gICAgICAgICAgICAgICAgICAgIGFob29rICYmIGFob29rLmNhbGwodGhpcyk7XHJcbiAgICAgICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICB9KShrZXkpXHJcbiAgICAgICAgfSk7XHJcbiAgICB9KTtcclxuICAgIF8kZGVmKHNlbGYsICckZGF0YScsIHtcclxuICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgcmV0dXJuIF8kdG9QbGFpbk9iaih0aGlzKTtcclxuICAgICAgICB9XHJcbiAgICB9KTtcclxufVx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GlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICBfdGhpc1tQUk9QX01BUC5lXVtldmVudF0uc3BsaWNlKGkgLSAxLCAxKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH07XHJcbiAgICB9LFxyXG4gICAgJG9uY2U6IGZ1bmN0aW9uIChldmVudCwgaGFuZGxlcikge1xyXG4gICAgICAgIHZhciBlID0gdGhpcy4kb24oZXZlbnQsIGZ1bmN0aW9uIChhcmdzKSB7XHJcbiAgICAgICAgICAgIGhhbmRsZXIoYXJncyk7XHJcbiAgICAgICAgICAgIGUuJG9mZigpO1xyXG4gICAgICAgIH0pO1xyXG4gICAgfSxcclxuICAgICRmaXJlOiBmdW5jdGlvbiAoZXZlbnQsIGRhdGEpIHtcclxuICAgICAgICBpZiAodGhpc1tQUk9QX01BUC5lXVtldmVudF0pIHtcclxuICAgICAgICAgICAgXyRlKHRoaXNbUFJPUF9NQVAuZV1bZXZlbnRdLCBmdW5jdGlvbiAoaGFuZGxlcikgeyBoYW5kbGVyKGRhdGEpOyB9KTtcclxuICAgICAgICB9XHJcbiAgICB9LFxyXG4gICAgJG5vdGlmeTogZnVuY3Rpb24gKGtleSkge1xyXG4gICAgICAgIGlmICh0aGlzW1BST1BfTUFQLnNdW2tleV0pIHtcclxuICAgICAgICAgICAgXyRlKHRoaXNbUFJPUF9NQVAuc11ba2V5XSwgZnVuY3Rpb24gKHN1c2NyaWJlcikgeyBzdXNjcmliZXIoKTsgfSk7XHJcbiAgICAgICAgfVxyXG4gICAgfSxcclxuICAgICRvYnNlcnZlOiBmdW5jdGlvbiAoZGVwcywgbGlzdGVuZXIpIHtcclxuICAgICAgICB2YXIgX3RoaXMgPSB0aGlzO1xyXG4gICAgICAgIHZhciBzdWJzID0gW107XHJcbiAgICAgICAgaWYgKF8kaXNBcnJheShkZXBzKSkge1xyXG4gICAgICAgICAgICBfJGUoZGVwcywgZnVuY3Rpb24gKGRlcCkge1xyXG4gICAgICAgICAgICAgICAgc3Vicy5wdXNoKHsgc3ViOiBkZXAsIGk6IF8kc3Vicy5jYWxsKF90aGlzLCBkZXAsIGxpc3RlbmVyKSB9KTtcclxuICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGVsc2Uge1xyXG4gICAgICAgICAgICBzdWJzLnB1c2goeyBzdWI6IGRlcHMsIGk6IF8kc3Vicy5jYWxsKHRoaXMsIGRlcHMsIGxpc3RlbmVyKSB9KTtcclxuICAgICAgICB9XHJcbiAgICAgICAgcmV0dXJuIHtcclxuICAgICAgICAgICAgJHVub2JzZXJ2ZTogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgXyRlKHN1YnMsIGZ1bmN0aW9uIChzdWIpIHtcclxuICAgICAgICAgICAgICAgICAgICBfdGhpc1tQUk9QX01BUC5zXVtzdWIuc3ViXS5zcGxpY2Uoc3ViLmksIDEpO1xyXG4gICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9O1xyXG4gICAgfSxcclxuICAgICR3YXRjaDogZnVuY3Rpb24gKGtleSwgd2F0Y2hlcikge1xyXG4gICAgICAgIHZhciBfdGhpcyA9IHRoaXM7XHJcbiAgICAgICAgaWYgKCF0aGlzW1BST1BfTUFQLnddW2tleV0pIHtcclxuICAgICAgICAgICAgdGhpc1tQUk9QX01BUC53XVtrZXldID0gW107XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHZhciBpID0gdGhpc1tQUk9QX01BUC53XVtrZXldLnB1c2god2F0Y2hlci5iaW5kKHRoaXMpKTtcclxuICAgICAgICByZXR1cm4ge1xyXG4gICAgICAgICAgICAkdW53YXRjaDogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgX3RoaXNbUFJPUF9NQVAud11ba2V5XS5zcGxpY2UoaSAtIDEsIDEpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfTtcclxuICAgIH1cclxufSk7XHJcbnZhciBhcnJheSA9IEFyc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gICAgICAgICAgcmV0dXJuIGkgPiAwICYmIG9iaiA9PT0gbnVsbCA/IG9iaiA6IHVuZGVmaW5lZDtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuICAgICAgICBlbHNlIHtcclxuICAgICAgICAgICAgaWYgKGkgPT09IGFyci5sZW5ndGggLSAxKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoXyRpc1R5cGUob2JqLCBfJExpc3QpICYmIF8kdG9TdHIoK2tleSkgPT09IGtleSkge1xyXG4gICAgICAgICAgICAgICAgICAgIG9iai5wdWxsKCtrZXksIHZhbHVlKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgIHZhciBvbGRWYWwgPSBvYmpba2V5XTtcclxuICAgICAgICAgICAgICAgICAgICBvYmpba2V5XSA9ICFfJGlzVHlwZSh2YWx1ZSwgXyRMaXN0KSAmJiBfJGlzQXJyYXkodmFsdWUpID8gbmV3IF8kTGlzdCh2YWx1ZSwgb2JqZWN0LCBrZXkpIDogdmFsdWU7XHJcbiAgICAgICAgICAgICAgICAgICAgXyRkaXNwYXRjaChvYmplY3QsIHBhdGgsIG9sZFZhbCwgb2JqW2tleV0pO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGVsc2UgaWYgKCFfJGlzT2JqZWN0KG9ialtrZXldKSkge1xyXG4gICAgICAgICAgICAgICAgb2JqW2tleV0gPSB7fTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuICAgICAgICByZXR1cm4gb2JqID8gb2JqW2tleV0gOiBudWxsO1xyXG4gICAgfSwgb2JqZWN0KTtcclxufVxyXG5leHBvcnQgZnVuY3Rpb24gXyRlbXB0eUVsc2UoKSB7XHJcbiAgICByZXR1cm4geyB0eXBlOiAnZW1wdHktZWxzZScsICRjcmVhdGU6IF8kbm9vcCwgJG1vdW50OiBfJG5v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AgICAgICAgZGVsZXRlIGl0ZW1zW2ldO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgXyRlKG9iaiwgZnVuY3Rpb24gKGl0ZW0sIGksIGluZGV4KSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoIWl0ZW1zW2ldKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgaXRlbXNbaV0gPSBfJGFwcGx5KGxvb3AsIFtyb290LCBpdGVtLCBpLCBpbmRleF0sIGdsb2JzKTtcclxuICAgICAgICAgICAgICAgICAgICBpdGVtc1tpXS4kY3JlYXRlKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgaXRlbXNbaV0uJG1vdW50KGxvb3BQYXJlbnQsIGxvb3BTaWJsaW5nKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgfSxcclxuICAgICAgICAkZGVzdHJveTogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICBfJGUoaXRlbXMsIGZ1bmN0aW9uIChpdGVtKSB7IGl0ZW0uJGRlc3Ryb3koKTsgfSk7XHJcbiAgICAgICAgfVxyXG4gICAgfTtcclxufVxyXG5leHBvcnQgZnVuY3Rpb24gXyRlKG9iaiwgY2IpIHtcclxuICAgIHZhciBpID0gMDtcclxuICAgIGZvciAodmFyIGtleSBpbiBvYmopIHtcclxuICAgICAgICBpZiAoXyRoYXNQcm9wKG9iaiwga2V5KSkge1xyXG4gICAgICAgICAgICBjYihvYmpba2V5XSwgKGlzTmFOKCtrZXkpID8ga2V5IDogK2tleSksIGkrKyk7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG59XHJcbmV4cG9ydCBmdW5jdGlvbiBfJGlzKGlkLCBjc3MpIHtcclxuICAgIHZhciBpc05ldyA9IGZhbHNlO1xyXG4gICAgdmFyIHN0eWxlID0gXyQoXCIjXCIgKyBpZCwgZG9jdW1lbnQuaGVhZCk7XHJcbiAgICBp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0aW9uIDwgMSkge1xyXG4gICAgICAgICAgICByZXF1ZXN0QW5pbWF0aW9uRnJhbWUoYW5pbWF0ZS5iaW5kKHRoaXMpKTtcclxuICAgICAgICB9XHJcbiAgICAgICAgZWxzZSBpZiAobG9vcCkge1xyXG4gICAgICAgICAgICBkaWZmID0gMDtcclxuICAgICAgICAgICAgaW5pdC5jYWxsKHRoaXMpO1xyXG4gICAgICAgIH1cclxuICAgICAgICBlbHNlIHtcclxuICAgICAgICAgICAgdGhpcy5ydW5uaW5nID0gZmFsc2U7XHJcbiAgICAgICAgICAgIGVuZGVkICYmIGVuZGVkKCk7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG4gICAgcmV0dXJuIHtcclxuICAgICAgICBwYXVzZWQ6IGZhbHNlLFxyXG4gICAgICAgIHJ1bm5pbmc6IGZhbHNlLFxyXG4gICAgICAgIG9uOiBmdW5jdGlvbiAoZXZlbnQsIGhhbmRsZXIpIHtcclxuICAgICAgICAgICAgZXZlbnQgPT09ICdlbmRlZCcgJiYgKGVuZGVkID0gaGFuZGxlcik7XHJcbiAgICAgICAgICAgIGV2ZW50ID09PSAnY2hhbmdlJyAmJiAoY2hhbmdlID0gaGFuZGxlcik7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBydW46IGZ1bmN0aW9uIChkLCBsKSB7XHJcbiAgICAgICAgICAgIGRlbGF5ID0gbCB8fCBkZWxheSB8fCAwO1xyXG4gICAgICAgICAgICBkdXJhdGlvbiA9IGQgfHwgZHVyYXRpb24gfHwgODAwO1xyXG4gICAgICAgICAgICBkZWxheSA+IDAgPyBzZXRUaW1lb3V0KGluaXQuYmluZCh0aGlzKSwgZGVsYXkpIDogaW5pdC5jYWxsKHRoaXMpO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgcGF1c2U6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgaWYgKCF0aGlzLnJ1bm5pbmcpXHJcbiAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICA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Fzc05hbWUpO1xyXG4gICAgICAgICAgICAgICAgaGFuZGxlciAmJiBoYW5kbGVyKCk7XHJcbiAgICAgICAgICAgICAgICBzdHlsZVNoZWV0LmRlbGV0ZVJ1bGUoc3R5bGVJbmRleCk7XHJcbiAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgIGluQW5pbWF0aW9uLm9uKCdlbmRlZCcsIGNhbGxiYWNrKTtcclxuICAgICAgICAgICAgb3V0QW5pbWF0aW9uLm9uKCdlbmRlZCcsIGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgIGNhbGxiYWNrKCk7XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgcnVuOiBmdW5jdGlvbiAobm9kZSkge1xyXG4gICAgICAgICAgICB2YXIgYXJncyA9IFtdO1xyXG4gICAgICAgICAgICBmb3IgKHZhciBfaSA9IDE7IF9pIDwgYXJndW1lbnRzLmxlbmd0aDsgX2krKykge1xyXG4gICAgICAgICAgICAgICAgYXJnc1tfaSAtIDFdID0gYXJndW1lbnRzW19pXTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXM7XHJcbiAgICAgICAgICAgIGlmIChzZWxmLnN0YXRlID09PSAnaW4nKSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLmluLmFwcGx5KHNlbGYsIFtub2RlXS5jb25jYXQoYXJncykpO1xyXG4gICAgICAgICAgICAgICAgc2VsZi5zdGF0ZSA9ICdvdXQnO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgc2VsZi5vdXQuYXBwbHkoc2VsZiwgW25vZGVdLmNvbmNhdChhcmdzKSk7XHJcbiAgICAgICAgICAgICAgICBzZWxmLnN0YXRlID0gJ2luJztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcbiAgICAgICAgaW46IGZ1bmN0aW9uIChub2RlKSB7XHJcbiAgICAgICAgICAgIHZhciBhcmdzID0gW107XHJcbiAgICAgICAgICAgIGZvciAodmFyIF9pID0gMTsgX2kgPCBhcmd1bWVudHMubGVuZ3RoOyBfaSsrKSB7XHJcbiAgICAgICAgICAgICAgICBhcmdzW19pIC0gMV0gPSBhcmd1bWVudHNbX2ldO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHNldENoYW5nZUNCLmFwcGx5KHZvaWQgMCwgW25vZGUsICdpbiddLmNvbmNhdChhcmdzKSk7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBvdXQ6IGZ1bmN0aW9uIChub2RlKSB7XHJcbiAgICAgICAgICAgIHZhciBhcmdzID0gW107XHJcbiAgICAgICAgICAgIGZvciAodmFyIF9pID0gMTsgX2kgPCBhcmd1bWVudHMubGVuZ3RoOyBfaSsrKSB7XHJcbiAgICAgICAgICAgICAgICBhcmdzW19pIC0gMV0gPSBhcmd1bWVudHNbX2ldO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHNldENoYW5nZUNCLmFwcGx5KHZvaWQgMCwgW25vZGUsICdvdXQnXS5jb25jYXQoYXJncykpO1xyXG4gICAgICAgIH1cclxuICAgIH07XHJcbn1cclxuIiwidmFyIF9fYXNzaWduID0gKHRoaXMgJiYgdGhpcy5fX2Fzc2lnbikgfHwgZnVuY3Rpb24gKCkge1xyXG4gICAgX19hc3NpZ24gPSBPYmplY3QuYXNzaWduIHx8IGZ1bmN0aW9uKHQpIHtcclxuICAgICAgICBmb3IgKHZhciBzLCBpID0gMSwgbiA9IGFyZ3VtZW50cy5sZW5ndGg7IGkgPCBuOyBpKyspIHtcclxuICAgICAgICAgICAgcyA9IGFyZ3VtZW50c1tpXTtcclxuICAgICAgICAgICAgZm9yICh2YXIgcCBpbiBzKSBpZiAoT2JqZWN0LnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eS5jYWxsKHMsIHApKVxyXG4gICAgICAgICAgICAgICAgdFtwXSA9IHNb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7XHJcbiAgICAgICAgdmFyIHJlZnMgPSB0aGlzLiRyZWZzO1xyXG4gICAgICAgIGFuaW1hdGlvbi5lbmRlZChmdW5jdGlvbigpIHtcclxuICAgICAgICAgICF2YWx1ZSAmJiBfdGhpcy4kdXBkYXRlKCk7XHJcbiAgICAgICAgfSk7XHJcbiAgICAgICAgaWYgKHZhbHVlKSB7XHJcbiAgICAgICAgICB0aGlzLiRzZXQoJ3Zpc2libGUnLCB2YWx1ZSk7XHJcbiAgICAgICAgICBhbmltYXRpb24uaW4ocmVmcy5ib3gpO1xyXG4gICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICB0aGlzLnZpc2libGUgPSB2YWx1ZTtcclxuICAgICAgICAgIGFuaW1hdGlvbi5vdXQocmVmcy5ib3gpO1xyXG4gICAgICAgIH1cclxuICAgICAgfVxyXG4gICAgfVxyXG4gIH0sIF8kcGFyZW50KTtcclxuICAhXyRwYXJlbnQgJiYgdGhpcy4kY3JlYXRlKCk7XHJcbn1cclxuXyRleHRlbmRzKEFuaW1hdGlvbiwgXyRDb21wQ3RyKTtcclxuZXhwb3J0IGRlZmF1bHQgQW5pbWF0aW9uO1xyXG4iLCJpbXBvcnQgQW5pbWF0aW9uIGZyb20gJy4vY29tcG9uZW50cy9hbmltYXRpb24uaHRtbCc7XHJcblxyXG5jb25zdCBhbmltYXRpb24gPSBuZXcgQW5pbWF0aW9uKCk7XHJcblxyXG5hbmltYXRpb24uJG1vdW50KCdtYWluJyk7XHJcbiJdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///./main.ts\n"); /***/ }) diff --git a/examples/animation/src/components/animation.html b/examples/animation/src/components/animation.html index 15d79a4..53f4b4d 100644 --- a/examples/animation/src/components/animation.html +++ b/examples/animation/src/components/animation.html @@ -25,7 +25,7 @@ animation.ended(() => { !value && this.$update(); }); if (value) { this.$set('visible', value); - animation.in(refs.box); + animation.in(refs.box); } else { this.visible = value; animation.out(refs.box); diff --git a/examples/calendar/dist/js/calendar.js b/examples/calendar/dist/js/calendar.js index 3cd4014..cd3462f 100644 --- a/examples/calendar/dist/js/calendar.js +++ b/examples/calendar/dist/js/calendar.js @@ -94,7 +94,7 @@ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("\n// CONCATENATED MODULE: d:/DEVELOP/Work in Progress/trebor-repos/trebor/tools/index.js\nvar _$assign = Object['assign'] || function (t) {\r\n for (var s = void 0, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s)\r\n if (_$hasProp(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n};\r\nfunction _$CompCtr(attrs, template, options, parent) {\r\n var self = this;\r\n var props = ['$slots', '$refs', '$filters', '$directives', '_events', '_watchers'];\r\n var _$set = function (prop, value) { _$def(self, prop, { value: value, writable: true }); };\r\n if (!attrs)\r\n attrs = {};\r\n _$e(props, function (prop) { _$def(self, prop, { value: {} }); });\r\n _$set('$parent', parent || null);\r\n _$set('$children', []);\r\n _$set('_subscribers', {});\r\n _$set('$options', options);\r\n var opts = self.$options;\r\n if (!opts.attrs)\r\n opts.attrs = {};\r\n if (!opts.children)\r\n opts.children = {};\r\n _$e(_$CompCtr['_plugins'], function (plugin) {\r\n plugin.fn.call(self, _$CompCtr, plugin.options);\r\n });\r\n if (opts.filters)\r\n _$assign(self.$filters, opts.filters);\r\n if (opts.directives)\r\n _$e(opts.directives, function (drt, k) { self.$directives[k] = _$drt(drt); });\r\n _$e(opts.attrs, function (attrOps, key) {\r\n _$def(self, (_$isType(key, 'number') ? attrOps : key), {\r\n get: function () {\r\n if (_$isType(attrOps, 'string')) {\r\n var value = attrs[attrOps];\r\n return _$isType(value, 'function') ? value() : value;\r\n }\r\n else {\r\n if (!_$hasProp(attrs, key) && attrOps.required) {\r\n console.error(\"Attribute '\" + key + \"' must be present because it's required.\");\r\n }\r\n else {\r\n var value = _$isType(attrs[key], 'function') ? attrs[key]() : attrs[key];\r\n if (value === void 0 && _$hasProp(attrOps, 'default')) {\r\n var def = attrOps.default;\r\n value = _$isType(def, 'function') ? def() : def;\r\n }\r\n var typ = attrOps.type;\r\n if (typ && !_$isType(value, typ) && attrOps.required) {\r\n return console.error(\"Attribute '\" + key + \"' must be type '\" + typ + \"'.\");\r\n }\r\n return _$toType(value, value === void 0 ? 'undefined' : typ, self, key);\r\n }\r\n }\r\n },\r\n set: function () {\r\n console.error(\"Can not modify attribute '\" + key + \"' because attributes al read only.\");\r\n },\r\n enumerable: true, configurable: true\r\n });\r\n });\r\n var data = opts.model || {};\r\n var _loop_1 = function (key) {\r\n if (_$hasProp(data, key)) {\r\n var desc = Object.getOwnPropertyDescriptor(data, key);\r\n if (desc.value && _$isArray(desc.value)) {\r\n desc.value = new _$List(desc.value, self, key);\r\n }\r\n else {\r\n if (desc.get) {\r\n var getter_1 = desc.get;\r\n desc.get = function () {\r\n var value = getter_1.call(self);\r\n if (_$isArray(value))\r\n value = new _$List(value, self, key);\r\n return value;\r\n };\r\n }\r\n if (desc.set) {\r\n var setter_1 = desc.set;\r\n desc.set = function (v) {\r\n if (_$isArray(v))\r\n v = new _$List(v, self, key);\r\n setter_1.call(self, v);\r\n };\r\n }\r\n }\r\n _$def(self, key, desc);\r\n }\r\n };\r\n for (var key in data) {\r\n _loop_1(key);\r\n }\r\n var tpl = template(self, opts.children);\r\n _$e(tpl, function (value, key) {\r\n _$def(self, key, {\r\n value: (function (key) {\r\n var hook = key[1].toUpperCase() + key.slice(2);\r\n var bhook = opts[\"before\" + hook];\r\n var ahook = opts[\"after\" + hook];\r\n return function () {\r\n bhook && bhook.call(this);\r\n key.slice(1) === 'update' ? value.call(this, this) : value.apply(this, arguments);\r\n ahook && ahook.call(this);\r\n };\r\n })(key)\r\n });\r\n });\r\n _$def(self, '$data', {\r\n get: function () {\r\n return _$toPlainObj(this);\r\n }\r\n });\r\n}\r\nfunction _$plugin(fn, options) {\r\n _$CompCtr['_plugins'] = _$CompCtr['_plugins'] || [];\r\n _$CompCtr['_plugins'].push({ options: options, fn: fn });\r\n}\r\n_$assign(_$CompCtr.prototype, {\r\n $get: function (path) {\r\n return _$accesor(this, path);\r\n },\r\n $set: function (path, value) {\r\n _$accesor(this, path, value);\r\n },\r\n $on: function (event, handler) {\r\n var _this = this;\r\n if (!this._events[event]) {\r\n this._events[event] = [];\r\n }\r\n var i = this._events[event].push(handler);\r\n return {\r\n $off: function () {\r\n _this._events[event].splice(i - 1, 1);\r\n }\r\n };\r\n },\r\n $once: function (event, handler) {\r\n var e = this.$on(event, function (args) {\r\n handler(args);\r\n e.$off();\r\n });\r\n },\r\n $fire: function (event, data) {\r\n if (this._events[event]) {\r\n _$e(this._events[event], function (handler) { handler(data); });\r\n }\r\n },\r\n $notify: function (key) {\r\n if (this._subscribers[key]) {\r\n _$e(this._subscribers[key], function (suscriber) { suscriber(); });\r\n }\r\n },\r\n $observe: function (deps, listener) {\r\n var _this = this;\r\n var subs = [];\r\n if (_$isArray(deps)) {\r\n _$e(deps, function (dep) {\r\n subs.push({ sub: dep, i: _$subs.call(_this, dep, listener) });\r\n });\r\n }\r\n else {\r\n subs.push({ sub: deps, i: _$subs.call(this, deps, listener) });\r\n }\r\n return {\r\n $unobserve: function () {\r\n _$e(subs, function (sub) {\r\n _this._subscribers[sub.sub].splice(sub.i, 1);\r\n });\r\n }\r\n };\r\n },\r\n $watch: function (key, watcher) {\r\n var _this = this;\r\n if (!this._watchers[key]) {\r\n this._watchers[key] = [];\r\n }\r\n var i = this._watchers[key].push(watcher.bind(this));\r\n return {\r\n $unwatch: function () {\r\n _this._watchers[key].splice(i - 1, 1);\r\n }\r\n };\r\n }\r\n});\r\nvar array = Array.prototype;\r\nfunction _$toArgs(args, start) {\r\n if (start === void 0) { start = 0; }\r\n return array.slice.call(args, start);\r\n}\r\nfunction _$arrayValues(list, value, root, key) {\r\n array.push.apply(list, value.map(function (v, i) {\r\n if (list.length !== 0)\r\n i += list.length;\r\n return !(_$isType(v, _$List)) && _$isArray(v) ? new _$List(v, root, key + \".\" + i) : v;\r\n }));\r\n}\r\nfunction _$List(value, root, key) {\r\n var self = this;\r\n Array.apply(self, [value.length]);\r\n var desc = { writable: false, configurable: false, enumerable: false };\r\n _$def(self, '_key', _$assign({ value: key }, desc));\r\n _$def(self, '_root', _$assign({ value: root }, desc));\r\n _$arrayValues(self, value, root, key);\r\n desc.writable = true;\r\n _$def(self, 'length', _$assign({ value: self.length }, desc));\r\n}\r\n_$List.prototype = Object.create(array);\r\n_$List.prototype.constructor = _$List;\r\n['pop', 'push', 'reverse', 'shift', 'sort', 'fill', 'unshift', 'splice'].forEach(function (method) {\r\n _$List.prototype[method] = function () {\r\n var self = this;\r\n var old = self.slice();\r\n var result;\r\n if (method === 'push') {\r\n _$arrayValues(self, _$toArgs(arguments), self._root, self._key);\r\n result = self.length;\r\n }\r\n else {\r\n result = array[method].apply(self, arguments);\r\n }\r\n _$dispatch(self._root, self._key, old, self.slice());\r\n return result;\r\n };\r\n});\r\n_$List.prototype.pull = function (index) {\r\n var self = this;\r\n var items = _$toArgs(arguments, 1);\r\n var length = self.length;\r\n if (index > length) {\r\n length = index + 1;\r\n var pull = new Array(index - self.length);\r\n pull.push.apply(pull, items);\r\n for (var i = 0; i < length; i++) {\r\n if (i === index) {\r\n self.push.apply(self, pull);\r\n }\r\n }\r\n }\r\n else {\r\n self.splice.apply(self, [index, 1].concat(items));\r\n }\r\n};\r\nfunction _$dispatch(root, key, oldVal, value) {\r\n root.$notify(key);\r\n if (root._watchers[key]) {\r\n _$e(root._watchers[key], function (watcher) { watcher(oldVal, value); });\r\n }\r\n root.$update();\r\n}\r\nfunction _$isType(value, type) {\r\n return _$type(type) === 'string' ? type.split('\\|').some(function (t) { return t.trim() === _$type(value); }) : value instanceof type;\r\n}\r\nfunction _$isObject(obj) {\r\n return _$isType(obj, 'object');\r\n}\r\nfunction _$isArray(obj) {\r\n return Array.isArray ? Array.isArray(obj) : _$isType(obj, 'array');\r\n}\r\nfunction _$toType(value, type, root, key) {\r\n switch (type) {\r\n case 'date':\r\n return new Date(value);\r\n case 'string':\r\n return value.toString();\r\n case 'number':\r\n return +value;\r\n case 'boolean':\r\n return !!value;\r\n case 'array':\r\n return _$isType(value, _$List) ? value : new _$List(value, root, key);\r\n default:\r\n return value;\r\n }\r\n}\r\nfunction _$type(obj) {\r\n return /\\[object (\\w+)\\]/.exec(Object.prototype.toString.call(obj))[1].toLowerCase();\r\n}\r\nfunction _$hasProp(obj, prop) {\r\n return obj.hasOwnProperty(prop);\r\n}\r\nfunction _$drt(directive) {\r\n var hasProp = function (prop, instance, options, element) { return _$isObject(directive) && directive[prop] && directive[prop](instance, options, element); };\r\n return {\r\n $init: function (instance, options, element) {\r\n hasProp('$init', instance, options, element);\r\n },\r\n $inserted: function (instance, options, element) {\r\n hasProp('$inserted', instance, options, element);\r\n },\r\n $update: function (instance, options, element) {\r\n if (_$isType(directive, 'function')) {\r\n directive(instance, options, element);\r\n }\r\n else {\r\n hasProp('$update', instance, options, element);\r\n }\r\n },\r\n $destroy: function (instance, options, element) {\r\n hasProp('$destroy', instance, options, element);\r\n }\r\n };\r\n}\r\nfunction _$noop() { }\r\nfunction _$add(inst, child) {\r\n inst.$children.push(child);\r\n}\r\nfunction _$remove(inst, child) {\r\n var index = inst.$children.indexOf(child);\r\n index >= 0 && inst.$children.splice(index, 1);\r\n}\r\nfunction _$toStr(obj) {\r\n var str = _$type(obj);\r\n return !/null|undefined/.test(str) ? obj.toString() : str;\r\n}\r\nfunction _$toPlainObj(obj) {\r\n var data = {};\r\n _$e(_$isObject(obj) ? obj : {}, function (_v, k) {\r\n if (k[0] !== '$' && !_$isType(obj[k], 'function')) {\r\n if (_$isType(obj[k], _$List)) {\r\n data[k] = obj[k].map(_$toPlainObj);\r\n }\r\n else if (_$isObject(obj[k])) {\r\n data[k] = _$toPlainObj(obj[k]);\r\n }\r\n else {\r\n data[k] = obj[k];\r\n }\r\n }\r\n });\r\n return _$isObject(obj) ? data : obj;\r\n}\r\nfunction _$setRef(obj, prop) {\r\n var value = [];\r\n _$def(obj, prop, {\r\n get: function () {\r\n return value.length <= 1 ? value[0] : value;\r\n },\r\n set: function (val) {\r\n if (val && !~value.indexOf(val)) {\r\n value.push(val);\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n}\r\nfunction _$accesor(object, path, value) {\r\n return path.split('.').reduce(function (obj, key, i, arr) {\r\n if (_$isType(value, 'undefined')) {\r\n if (obj == null) {\r\n arr.splice(0, arr.length);\r\n return i > 0 && obj === null ? obj : undefined;\r\n }\r\n }\r\n else {\r\n if (i === arr.length - 1) {\r\n if (_$isType(obj, _$List) && (+key).toString() === key) {\r\n obj.pull(+key, value);\r\n }\r\n else {\r\n var oldVal = obj[key];\r\n obj[key] = !_$isType(value, _$List) && _$isArray(value) ? new _$List(value, object, key) : value;\r\n _$dispatch(object, path, oldVal, obj[key]);\r\n }\r\n }\r\n else if (!_$isObject(obj[key])) {\r\n obj[key] = {};\r\n }\r\n }\r\n return obj ? obj[key] : null;\r\n }, object);\r\n}\r\nfunction _$emptyElse() {\r\n return { type: 'empty-else', $create: _$noop, $mount: _$noop, $update: _$noop, $destroy: _$noop };\r\n}\r\nfunction _$subs(dep, listener) {\r\n if (!this._subscribers[dep]) {\r\n this._subscribers[dep] = [];\r\n }\r\n return this._subscribers[dep].push(listener.bind(this)) - 1;\r\n}\r\nfunction _$def(obj, key, desc) {\r\n Object.defineProperty(obj, key, desc);\r\n}\r\nfunction _$isKey(event, key) {\r\n return event.key.toLowerCase() === key || !!event[key + \"Key\"];\r\n}\r\nfunction _$bindGroup(input, selection) {\r\n var _$index = selection.indexOf(input.value);\r\n if (input.checked && !~_$index)\r\n selection.push(input.value);\r\n else\r\n selection.splice(_$index, 1);\r\n}\r\nfunction _$(selector, parent) {\r\n return _$isType(selector, 'string') ? (parent || document).querySelector(selector) : selector;\r\n}\r\nfunction _$d() {\r\n return document.createDocumentFragment();\r\n}\r\nfunction _$a(parent, child, sibling) {\r\n if (_$isType(sibling, 'boolean') && sibling)\r\n parent.parentElement.replaceChild(child, parent);\r\n else if (!sibling)\r\n parent.appendChild(child);\r\n else\r\n parent.insertBefore(child, sibling);\r\n}\r\nfunction _$as(source, dest) {\r\n var childNodes = source.childNodes;\r\n var attributes = source.attributes;\r\n for (var i = 0; i < childNodes.length; i++) {\r\n _$a(dest, childNodes[i]);\r\n }\r\n for (var i = 0; i < attributes.length; i++) {\r\n var attr = attributes[i];\r\n dest.setAttributeNS(source.namespaceURI, attr.name, attr.value);\r\n }\r\n source.parentElement.replaceChild(dest, source);\r\n return dest;\r\n}\r\nfunction _$r(el, parent) {\r\n var root = parent || el.parentElement;\r\n if (root)\r\n root.removeChild(el);\r\n}\r\nfunction _$ce(tagName) {\r\n return document.createElement(tagName || 'div');\r\n}\r\nfunction _$cse(tagName) {\r\n return document.createElementNS('http://www.w3.org/2000/svg', tagName || 'svg');\r\n}\r\nfunction _$ct(content) {\r\n return document.createTextNode(content || '');\r\n}\r\nfunction _$cm(content) {\r\n return document.createComment(content || '');\r\n}\r\nfunction _$sa(el, attr, value) {\r\n el.setAttribute(attr, value);\r\n}\r\nfunction _$ga(el, attr) {\r\n return el.getAttribute(attr);\r\n}\r\nfunction _$al(el, event, handler) {\r\n el.addEventListener(event, handler, false);\r\n}\r\nfunction _$ul(el, event, oldHandler, newHandler) {\r\n _$rl(el, event, oldHandler);\r\n _$al(el, event, oldHandler = newHandler);\r\n return oldHandler;\r\n}\r\nfunction _$rl(el, event, handler) {\r\n el.removeEventListener(event, handler, false);\r\n}\r\nfunction _$bc(value) {\r\n var classes = '';\r\n if (_$isType(value, 'string')) {\r\n classes += \" \" + value;\r\n }\r\n else if (_$isArray(value)) {\r\n classes = value.map(_$bc).join(' ');\r\n }\r\n else if (_$isObject(value)) {\r\n for (var key in value)\r\n if (_$hasProp(value, key) && value[key])\r\n classes += \" \" + key;\r\n }\r\n return classes.trim();\r\n}\r\nfunction _$bs(value) {\r\n var el = _$ce();\r\n if (_$isObject(value)) {\r\n var style_1 = el.style;\r\n _$e(value, function (val, prop) {\r\n if (val !== style_1[prop]) {\r\n style_1[prop] = val;\r\n }\r\n });\r\n return style_1.cssText;\r\n }\r\n else if (_$isType(value, 'string')) {\r\n return value;\r\n }\r\n else {\r\n return '';\r\n }\r\n}\r\nfunction _$f(root, obj, loop) {\r\n var items = {}, loopParent, loopSibling;\r\n var globs = _$toArgs(arguments, 3);\r\n _$e(obj, function (item, i) { items[i] = loop.apply(null, [root, item, i].concat(globs)); });\r\n return {\r\n $create: function () {\r\n _$e(items, function (item) { item.$create(); });\r\n },\r\n $mount: function (parent, sibling) {\r\n loopParent = _$(parent);\r\n loopSibling = _$(sibling);\r\n _$e(items, function (item) { item.$mount(loopParent, loopSibling); });\r\n },\r\n $update: function (root, obj) {\r\n var globs = _$toArgs(arguments, 2);\r\n _$e(items, function (item, i) {\r\n if (obj[i]) {\r\n item.$update.apply(item, [root, obj[i], i].concat(globs));\r\n }\r\n else {\r\n item.$destroy();\r\n delete items[i];\r\n }\r\n });\r\n _$e(obj, function (item, i) {\r\n if (!items[i]) {\r\n items[i] = loop.apply(null, [root, item, i].concat(globs));\r\n items[i].$create();\r\n items[i].$mount(loopParent, loopSibling);\r\n }\r\n });\r\n },\r\n $destroy: function () {\r\n _$e(items, function (item) { item.$destroy(); });\r\n }\r\n };\r\n}\r\nfunction _$e(obj, cb) {\r\n for (var key in obj) {\r\n if (_$hasProp(obj, key)) {\r\n cb(obj[key], (isNaN(+key) ? key : +key));\r\n }\r\n }\r\n}\r\nfunction _$is(id, css) {\r\n var isNew = false;\r\n var style = _$(\"#\" + id, document.head);\r\n if (!style) {\r\n isNew = true;\r\n style = _$ce('style');\r\n style.id = id;\r\n _$sa(style, 'refs', '1');\r\n }\r\n if (style.textContent !== css) {\r\n style.textContent = css;\r\n }\r\n if (isNew) {\r\n _$a(document.head, style);\r\n }\r\n else {\r\n var count = +_$ga(style, 'refs');\r\n _$sa(style, 'refs', (++count).toString());\r\n }\r\n}\r\nfunction _$ds(id) {\r\n var style = _$(\"#\" + id, document.head);\r\n if (style) {\r\n var count = +_$ga(style, 'refs');\r\n if (--count === 0) {\r\n _$r(style, document.head);\r\n }\r\n else {\r\n _$sa(style, 'refs', count.toString());\r\n }\r\n }\r\n}\r\n//# sourceMappingURL=index.js.map\n// CONCATENATED MODULE: ./components/calendar.ts\n/* harmony default export */ var calendar = ({\r\n attrs: {\r\n value: {\r\n type: 'date',\r\n default: function () { return new Date(); }\r\n },\r\n show: {\r\n type: 'boolean',\r\n default: true\r\n },\r\n place: {\r\n type: 'string',\r\n default: 'right'\r\n },\r\n labelTemplate: {\r\n type: 'string',\r\n default: '${month} of ${year}'\r\n },\r\n options: {\r\n type: 'object',\r\n default: function () { return ({\r\n daysOfWeek: ['SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA'],\r\n months: [\r\n 'January', 'February', 'March', 'April', 'May', 'June', 'July',\r\n 'August', 'September', 'October', 'November', 'Dicember',\r\n ]\r\n }); }\r\n }\r\n },\r\n afterMount: function () {\r\n this.$set('date', new Date(this.value.valueOf()));\r\n this.createCalendar(this.date.getMonth(), this.date.getFullYear());\r\n },\r\n model: {\r\n view: '',\r\n month: [],\r\n date: new Date(),\r\n get viewLabel() {\r\n switch (this.view) {\r\n case 'months':\r\n return this.date.getFullYear();\r\n case 'years':\r\n var part = this.date.getFullYear().toString().substring(0, 3);\r\n return part + \"0 - \" + part + \"9\";\r\n default:\r\n return this.labelTemplate\r\n .replace(/\\${day}/g, this.date.getDate() + '')\r\n .replace(/\\${month}/g, this.options.months[this.date.getMonth()])\r\n .replace(/\\${year}/g, this.date.getFullYear() + '');\r\n }\r\n },\r\n get decade() {\r\n return this.yearInDecade(this.date.getFullYear());\r\n },\r\n get months() {\r\n var _this = this;\r\n var d = new Date();\r\n return this.options.months.map(function (month, i) { return ({\r\n value: i, month: month.substring(0, 3),\r\n active: d.getMonth() === i && d.getFullYear() === _this.date.getFullYear()\r\n }); });\r\n },\r\n get visibility() {\r\n if (!this.show) {\r\n this.$set('view', '');\r\n }\r\n return this.show;\r\n },\r\n selectView: function () {\r\n this.$set('view', this.view === '' ? 'months' : 'years');\r\n },\r\n itemState: function (item) {\r\n return { active: item.active, disabled: item.disabled, selected: item.selected };\r\n },\r\n resetDate: function () {\r\n this.$set('date', new Date());\r\n this.$fire('change', new Date());\r\n this.createCalendar(this.date.getMonth(), this.date.getFullYear());\r\n },\r\n resetDaySelection: function () {\r\n this.month.forEach(function (week) {\r\n week.days.forEach(function (day) {\r\n day.selected && (day.selected = false);\r\n });\r\n });\r\n },\r\n selectDay: function (day) {\r\n if (!day.disabled) {\r\n this.resetDaySelection();\r\n var date = new Date(this.date.getFullYear(), this.date.getMonth(), day.day);\r\n this.$fire('change', date);\r\n day.selected = true;\r\n this.$update();\r\n }\r\n },\r\n selectMonth: function (month) {\r\n if (!month.disabled) {\r\n this.date.setMonth(month.value);\r\n this.createCalendar(this.date.getMonth(), this.date.getFullYear());\r\n this.$set('view', '');\r\n }\r\n },\r\n selectYear: function (year) {\r\n if (!year.disabled) {\r\n this.date.setFullYear(year.year);\r\n this.$set('view', 'months');\r\n }\r\n },\r\n weekOfYear: function (day, month, year) {\r\n var target = new Date(year, month, day);\r\n var dayNr = (target.getDay() + 6) % 7;\r\n target.setDate(target.getDate() - dayNr + 3);\r\n var firstThursday = target.valueOf();\r\n target.setMonth(0, 1);\r\n if (target.getDay() !== 4) {\r\n target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7);\r\n }\r\n return 1 + Math.ceil((firstThursday - target.valueOf()) / 604800000);\r\n },\r\n monthOfYear: function (row) {\r\n switch (row) {\r\n case 1:\r\n return this.months.slice(4, 8);\r\n case 2:\r\n return this.months.slice(8);\r\n default:\r\n return this.months.slice(0, 4);\r\n }\r\n },\r\n yearOfDecade: function (row) {\r\n switch (row) {\r\n case 1:\r\n return this.decade.slice(4, 8);\r\n case 2:\r\n return this.decade.slice(8);\r\n default:\r\n return this.decade.slice(0, 4);\r\n }\r\n },\r\n yearInDecade: function (year) {\r\n var now = new Date();\r\n var range = [];\r\n var text = year.toString();\r\n var first = parseInt(text.substring(0, text.length - 1) + 0);\r\n for (var i = 0; i < 12; i++) {\r\n if (i === 0) {\r\n range[i] = { year: first - 1, disabled: true, };\r\n }\r\n else if (i === 11) {\r\n range[i] = { year: first + 10, disabled: true, };\r\n }\r\n else {\r\n var y = first + i - 1;\r\n range[i] = { year: y, active: y === now.getFullYear() };\r\n }\r\n }\r\n return range;\r\n },\r\n daysOfMonth: function (month, year) {\r\n return 32 - new Date(year, month, 32).getDate();\r\n },\r\n createCalendar: function (month, year) {\r\n var date = new Date(year, month, 1).getDay();\r\n var numDays = this.daysOfMonth(month, year);\r\n var lastDay = this.daysOfMonth(month - 1, year);\r\n var start = 1;\r\n var end = 7 - date;\r\n var d = new Date();\r\n var weeks = [];\r\n while (start <= numDays) {\r\n var days = [];\r\n var length_1 = end - start + 1;\r\n for (var i = 0; i < length_1; i++) {\r\n days[i] = {\r\n day: start + i,\r\n active: (start + i) === d.getDate() && d.getMonth() === month && d.getFullYear() === year\r\n };\r\n }\r\n if (days.length < 7 && start === 1) {\r\n for (var i = 0; i < date; i++) {\r\n days.unshift({ day: lastDay - i, disabled: true });\r\n }\r\n }\r\n else if (days.length < 7 && days.length > 0) {\r\n var nend = 7 - days.length;\r\n for (var i = 1; i <= nend; i++) {\r\n days[days.length] = { day: i, disabled: true };\r\n }\r\n }\r\n var week = {\r\n start: start, end: end, days: days,\r\n weekYear: this.weekOfYear(end, month, year)\r\n };\r\n weeks[weeks.length] = week;\r\n start = end + 1;\r\n end = start === 1 && end === 8 ? 1 : end + 7;\r\n if (end > numDays) {\r\n end = numDays;\r\n }\r\n }\r\n if (weeks.length === 4 || date === 0) {\r\n var days = [];\r\n for (var i = 0; i < 7; i++) {\r\n days[6 - i] = { day: lastDay - i, disabled: true };\r\n }\r\n var start_1 = days[0].day;\r\n var end_1 = days[days.length - 1].day;\r\n weeks.unshift({\r\n start: start_1, end: end_1, days: days,\r\n weekYear: this.weekOfYear(end_1, month - 1, year)\r\n });\r\n }\r\n if (weeks.length === 5) {\r\n var days = [];\r\n var start_2 = 1;\r\n var end_2 = 7;\r\n var lastWeek = weeks[weeks.length - 1];\r\n var lastDay_1 = lastWeek.days[lastWeek.days.length - 1];\r\n if (!~[28, 29, 30, 31].indexOf(lastDay_1.day)) {\r\n start_2 = lastDay_1.day + 1;\r\n end_2 = 6 + start_2;\r\n }\r\n for (var i = 0; i < 7; i++) {\r\n days[i] = { day: start_2 + i, disabled: true };\r\n }\r\n weeks.push({\r\n start: start_2, end: end_2, days: days,\r\n weekYear: this.weekOfYear(end_2, month + 1, year)\r\n });\r\n }\r\n this.$set('month', weeks);\r\n },\r\n prev: function () {\r\n if (this.view === 'years') {\r\n this.date = new Date(this.date.getFullYear() - 10, this.date.getMonth(), this.date.getDate());\r\n }\r\n else if (this.view === 'months') {\r\n this.date = new Date(this.date.getFullYear() - 1, this.date.getMonth(), this.date.getDate());\r\n }\r\n else {\r\n this.date = new Date(this.date.getFullYear(), this.date.getMonth() - 1, 1);\r\n this.createCalendar(this.date.getMonth(), this.date.getFullYear());\r\n }\r\n this.$update();\r\n },\r\n next: function () {\r\n if (this.view === 'years') {\r\n this.date = new Date(this.date.getFullYear() + 10, this.date.getMonth(), this.date.getDate());\r\n }\r\n else if (this.view === 'months') {\r\n this.date = new Date(this.date.getFullYear() + 1, this.date.getMonth(), this.date.getDate());\r\n }\r\n else {\r\n this.date = new Date(this.date.getFullYear(), this.date.getMonth() + 1, 1);\r\n this.createCalendar(this.date.getMonth(), this.date.getFullYear());\r\n }\r\n this.$update();\r\n }\r\n }\r\n});\r\n\n// CONCATENATED MODULE: ./components/calendar.html\n\n\nfunction itemLoop_1(_$state, dayOfWeek) {\n var _$frag, th_1, txt_1, setTxt_1;\n _$frag = _$d();\n setTxt_1 = function (_$state, dayOfWeek) {\n return dayOfWeek;\n };\n return {\n $create: function () {\n th_1 = _$ce('th');\n txt_1 = _$ct();\n txt_1.data = setTxt_1(_$state, dayOfWeek);\n this.$hydrate();\n },\n $hydrate: function () {\n _$sa(th_1, 'class', 'scope_126c28ac');\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$a(_$(parent), _$frag, _$(sibling));\n },\n $update: function (_$state, dayOfWeek) {\n var updateTxt_1 = setTxt_1(_$state, dayOfWeek);\n if (txt_1.data !== _$toStr(updateTxt_1)) {\n txt_1.data = updateTxt_1;\n }\n updateTxt_1 = void 0;\n },\n $unmount: function () {\n _$a(th_1, txt_1);\n _$a(_$frag, th_1);\n },\n $destroy: function () {\n this.$unmount();\n _$frag = th_1 = txt_1 = setTxt_1 = void 0;\n }\n };\n}\nfunction ifCondition_1(_$state) {\n var _$frag, thead_1, tr_1, th_1, txt_1, loopAnchor_1_1, loopBlock_1;\n _$frag = _$d();\n loopBlock_1 = _$f(_$state, _$state.options.daysOfWeek, itemLoop_1);\n loopAnchor_1_1 = _$ct();\n return {\n type: 'if',\n $create: function () {\n thead_1 = _$ce('thead');\n tr_1 = _$ce('tr');\n th_1 = _$ce('th');\n txt_1 = _$ct('W#');\n loopBlock_1.$create();\n this.$hydrate();\n },\n $hydrate: function () {\n _$sa(th_1, 'class', 'scope_126c28ac');\n _$sa(tr_1, 'class', 'scope_126c28ac');\n _$sa(thead_1, 'class', 'scope_126c28ac');\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$a(_$(parent), _$frag, _$(sibling));\n },\n $update: function (_$state) {\n loopBlock_1.$update(_$state, _$state.options.daysOfWeek);\n },\n $unmount: function () {\n _$a(th_1, txt_1);\n _$a(tr_1, th_1);\n _$a(tr_1, loopAnchor_1_1);\n loopBlock_1.$mount(tr_1, loopAnchor_1_1);\n _$a(thead_1, tr_1);\n _$a(_$frag, thead_1);\n },\n $destroy: function () {\n this.$unmount();\n loopBlock_1.$destroy();\n _$frag = thead_1 = tr_1 = th_1 = txt_1 = loopAnchor_1_1 = loopBlock_1 = void 0;\n }\n };\n}\nfunction condition_1(_$state) {\n if (_$state.view === '')\n return ifCondition_1(_$state);\n else\n return _$emptyElse();\n}\nfunction ifCondition_3(_$state, year, _$index, row) {\n var _$frag, a_1, txt_1, setTxt_1, bindClassA_1, clickEvent_1, handlerClickEvent_1;\n _$frag = _$d();\n setTxt_1 = function (_$state, year) {\n return year.year;\n };\n bindClassA_1 = function (_$state, year) {\n return ('scope_126c28ac ' + _$bc(_$state.itemState(year))).trim();\n };\n clickEvent_1 = function (_$state, year) {\n _$state.selectYear(year);\n };\n return {\n type: 'if',\n $create: function () {\n a_1 = _$ce('a');\n txt_1 = _$ct();\n txt_1.data = setTxt_1(_$state, year, row, _$index);\n this.$hydrate();\n },\n $hydrate: function () {\n _$sa(a_1, 'class', _$toStr(bindClassA_1(_$state, year, row, _$index)));\n _$al(a_1, 'click', handlerClickEvent_1 = function (event) {\n event.preventDefault();\n clickEvent_1(_$state, year, row, _$index, event, a_1);\n });\n _$sa(a_1, 'href', '#');\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$a(_$(parent), _$frag, _$(sibling));\n },\n $update: function (_$state, year, _$index, row) {\n var updateTxt_1 = setTxt_1(_$state, year, row, _$index);\n if (txt_1.data !== _$toStr(updateTxt_1)) {\n txt_1.data = updateTxt_1;\n }\n updateTxt_1 = void 0;\n var updateClassA_1 = _$toStr(bindClassA_1(_$state, year, row, _$index));\n if (_$ga(a_1, 'class') !== updateClassA_1) {\n _$sa(a_1, 'class', updateClassA_1);\n }\n updateClassA_1 = void 0;\n handlerClickEvent_1 = _$ul(a_1, 'click', handlerClickEvent_1, function (event) {\n event.preventDefault();\n clickEvent_1(_$state, year, row, _$index, event, a_1);\n });\n },\n $unmount: function () {\n _$a(a_1, txt_1);\n _$a(_$frag, a_1);\n },\n $destroy: function () {\n this.$unmount();\n _$rl(a_1, 'click', handlerClickEvent_1);\n _$frag = a_1 = txt_1 = setTxt_1 = bindClassA_1 = clickEvent_1 = handlerClickEvent_1 = void 0;\n }\n };\n}\nfunction elseCondition_3(_$state, year, _$index, row) {\n var _$frag, template_1, txt_1, setTxt_1;\n _$frag = _$d();\n setTxt_1 = function (_$state, year) {\n return year.year;\n };\n return {\n type: 'else',\n $create: function () {\n template_1 = _$d();\n txt_1 = _$ct();\n txt_1.data = setTxt_1(_$state, year, row, _$index);\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$a(_$(parent), _$frag, _$(sibling));\n },\n $update: function (_$state, year, _$index, row) {\n var updateTxt_1 = setTxt_1(_$state, year, row, _$index);\n if (txt_1.data !== _$toStr(updateTxt_1)) {\n txt_1.data = updateTxt_1;\n }\n updateTxt_1 = void 0;\n },\n $unmount: function () {\n _$a(template_1, txt_1);\n _$a(_$frag, template_1);\n },\n $destroy: function () {\n this.$unmount();\n _$frag = template_1 = txt_1 = setTxt_1 = void 0;\n }\n };\n}\nfunction condition_3(_$state, year, _$index, row) {\n if (!year.disabled)\n return ifCondition_3(_$state, year, _$index, row);\n else\n return elseCondition_3(_$state, year, _$index, row);\n}\nfunction itemLoop_3(_$state, year, _$index, row) {\n var _$frag, td_1, conditionAnchor_1, conditionBlock_1, bindClassTd_1;\n _$frag = _$d();\n conditionAnchor_1 = _$ct();\n bindClassTd_1 = function (_$state, year) {\n return ('scope_126c28ac ' + _$bc({ disabled: year.disabled })).trim();\n };\n return {\n $create: function () {\n td_1 = _$ce('td');\n conditionBlock_1 = condition_3(_$state, year, _$index, row);\n conditionBlock_1.$create();\n this.$hydrate();\n },\n $hydrate: function () {\n _$sa(td_1, 'class', _$toStr(bindClassTd_1(_$state, year, row, _$index)));\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$a(_$(parent), _$frag, _$(sibling));\n },\n $update: function (_$state, year, _$index, row) {\n if (conditionBlock_1 && conditionBlock_1.type === condition_3(_$state, year, _$index, row).type) {\n conditionBlock_1.$update(_$state, year, _$index, row);\n } else {\n conditionBlock_1 && conditionBlock_1.$destroy();\n conditionBlock_1 = condition_3(_$state, year, _$index, row);\n conditionBlock_1.$create();\n conditionBlock_1.$mount(td_1, conditionAnchor_1);\n }\n var updateClassTd_1 = _$toStr(bindClassTd_1(_$state, year, row, _$index));\n if (_$ga(td_1, 'class') !== updateClassTd_1) {\n _$sa(td_1, 'class', updateClassTd_1);\n }\n updateClassTd_1 = void 0;\n },\n $unmount: function () {\n _$a(td_1, conditionAnchor_1);\n conditionBlock_1.$mount(td_1, conditionAnchor_1);\n _$a(_$frag, td_1);\n },\n $destroy: function () {\n this.$unmount();\n conditionBlock_1.$destroy();\n _$frag = td_1 = conditionAnchor_1 = conditionBlock_1 = bindClassTd_1 = void 0;\n }\n };\n}\nfunction itemLoop_2(_$state, row) {\n var _$frag, tr_1, loopAnchor_3_1, loopBlock_3;\n _$frag = _$d();\n loopBlock_3 = _$f(_$state, _$state.yearOfDecade(row), itemLoop_3, row);\n loopAnchor_3_1 = _$ct();\n return {\n $create: function () {\n tr_1 = _$ce('tr');\n loopBlock_3.$create();\n this.$hydrate();\n },\n $hydrate: function () {\n _$sa(tr_1, 'class', 'scope_126c28ac');\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$a(_$(parent), _$frag, _$(sibling));\n },\n $update: function (_$state, row) {\n loopBlock_3.$update(_$state, _$state.yearOfDecade(row), row);\n },\n $unmount: function () {\n _$a(tr_1, loopAnchor_3_1);\n loopBlock_3.$mount(tr_1, loopAnchor_3_1);\n _$a(_$frag, tr_1);\n },\n $destroy: function () {\n this.$unmount();\n loopBlock_3.$destroy();\n _$frag = tr_1 = loopAnchor_3_1 = loopBlock_3 = void 0;\n }\n };\n}\nfunction ifCondition_2(_$state) {\n var _$frag, tbody_1, loopAnchor_2_1, loopBlock_2;\n _$frag = _$d();\n loopBlock_2 = _$f(_$state, [\n 0,\n 1,\n 2\n ], itemLoop_2);\n loopAnchor_2_1 = _$ct();\n return {\n type: 'if',\n $create: function () {\n tbody_1 = _$ce('tbody');\n loopBlock_2.$create();\n this.$hydrate();\n },\n $hydrate: function () {\n _$sa(tbody_1, 'class', 'scope_126c28ac');\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$a(_$(parent), _$frag, _$(sibling));\n },\n $update: function (_$state) {\n loopBlock_2.$update(_$state, [\n 0,\n 1,\n 2\n ]);\n },\n $unmount: function () {\n _$a(tbody_1, loopAnchor_2_1);\n loopBlock_2.$mount(tbody_1, loopAnchor_2_1);\n _$a(_$frag, tbody_1);\n },\n $destroy: function () {\n this.$unmount();\n loopBlock_2.$destroy();\n _$frag = tbody_1 = loopAnchor_2_1 = loopBlock_2 = void 0;\n }\n };\n}\nfunction ifCondition_4(_$state, month, _$index, row) {\n var _$frag, a_1, txt_1, setTxt_1, bindClassA_1, clickEvent_1, handlerClickEvent_1;\n _$frag = _$d();\n setTxt_1 = function (_$state, month) {\n return month.month;\n };\n bindClassA_1 = function (_$state, month) {\n return ('scope_126c28ac ' + _$bc(_$state.itemState(month))).trim();\n };\n clickEvent_1 = function (_$state, month) {\n _$state.selectMonth(month);\n };\n return {\n type: 'if',\n $create: function () {\n a_1 = _$ce('a');\n txt_1 = _$ct();\n txt_1.data = setTxt_1(_$state, month, row, _$index);\n this.$hydrate();\n },\n $hydrate: function () {\n _$sa(a_1, 'class', _$toStr(bindClassA_1(_$state, month, row, _$index)));\n _$al(a_1, 'click', handlerClickEvent_1 = function (event) {\n event.preventDefault();\n clickEvent_1(_$state, month, row, _$index, event, a_1);\n });\n _$sa(a_1, 'href', '#');\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$a(_$(parent), _$frag, _$(sibling));\n },\n $update: function (_$state, month, _$index, row) {\n var updateTxt_1 = setTxt_1(_$state, month, row, _$index);\n if (txt_1.data !== _$toStr(updateTxt_1)) {\n txt_1.data = updateTxt_1;\n }\n updateTxt_1 = void 0;\n var updateClassA_1 = _$toStr(bindClassA_1(_$state, month, row, _$index));\n if (_$ga(a_1, 'class') !== updateClassA_1) {\n _$sa(a_1, 'class', updateClassA_1);\n }\n updateClassA_1 = void 0;\n handlerClickEvent_1 = _$ul(a_1, 'click', handlerClickEvent_1, function (event) {\n event.preventDefault();\n clickEvent_1(_$state, month, row, _$index, event, a_1);\n });\n },\n $unmount: function () {\n _$a(a_1, txt_1);\n _$a(_$frag, a_1);\n },\n $destroy: function () {\n this.$unmount();\n _$rl(a_1, 'click', handlerClickEvent_1);\n _$frag = a_1 = txt_1 = setTxt_1 = bindClassA_1 = clickEvent_1 = handlerClickEvent_1 = void 0;\n }\n };\n}\nfunction elseCondition_4(_$state, month, _$index, row) {\n var _$frag, template_1, txt_1, setTxt_1;\n _$frag = _$d();\n setTxt_1 = function (_$state, month) {\n return month.month;\n };\n return {\n type: 'else',\n $create: function () {\n template_1 = _$d();\n txt_1 = _$ct();\n txt_1.data = setTxt_1(_$state, month, row, _$index);\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$a(_$(parent), _$frag, _$(sibling));\n },\n $update: function (_$state, month, _$index, row) {\n var updateTxt_1 = setTxt_1(_$state, month, row, _$index);\n if (txt_1.data !== _$toStr(updateTxt_1)) {\n txt_1.data = updateTxt_1;\n }\n updateTxt_1 = void 0;\n },\n $unmount: function () {\n _$a(template_1, txt_1);\n _$a(_$frag, template_1);\n },\n $destroy: function () {\n this.$unmount();\n _$frag = template_1 = txt_1 = setTxt_1 = void 0;\n }\n };\n}\nfunction condition_4(_$state, month, _$index, row) {\n if (!month.disabled)\n return ifCondition_4(_$state, month, _$index, row);\n else\n return elseCondition_4(_$state, month, _$index, row);\n}\nfunction itemLoop_5(_$state, month, _$index, row) {\n var _$frag, td_1, conditionAnchor_1, conditionBlock_1, bindClassTd_1;\n _$frag = _$d();\n conditionAnchor_1 = _$ct();\n bindClassTd_1 = function (_$state, month) {\n return ('scope_126c28ac ' + _$bc({ disabled: month.disabled })).trim();\n };\n return {\n $create: function () {\n td_1 = _$ce('td');\n conditionBlock_1 = condition_4(_$state, month, _$index, row);\n conditionBlock_1.$create();\n this.$hydrate();\n },\n $hydrate: function () {\n _$sa(td_1, 'class', _$toStr(bindClassTd_1(_$state, month, row, _$index)));\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$a(_$(parent), _$frag, _$(sibling));\n },\n $update: function (_$state, month, _$index, row) {\n if (conditionBlock_1 && conditionBlock_1.type === condition_4(_$state, month, _$index, row).type) {\n conditionBlock_1.$update(_$state, month, _$index, row);\n } else {\n conditionBlock_1 && conditionBlock_1.$destroy();\n conditionBlock_1 = condition_4(_$state, month, _$index, row);\n conditionBlock_1.$create();\n conditionBlock_1.$mount(td_1, conditionAnchor_1);\n }\n var updateClassTd_1 = _$toStr(bindClassTd_1(_$state, month, row, _$index));\n if (_$ga(td_1, 'class') !== updateClassTd_1) {\n _$sa(td_1, 'class', updateClassTd_1);\n }\n updateClassTd_1 = void 0;\n },\n $unmount: function () {\n _$a(td_1, conditionAnchor_1);\n conditionBlock_1.$mount(td_1, conditionAnchor_1);\n _$a(_$frag, td_1);\n },\n $destroy: function () {\n this.$unmount();\n conditionBlock_1.$destroy();\n _$frag = td_1 = conditionAnchor_1 = conditionBlock_1 = bindClassTd_1 = void 0;\n }\n };\n}\nfunction itemLoop_4(_$state, row) {\n var _$frag, tr_1, loopAnchor_5_1, loopBlock_5;\n _$frag = _$d();\n loopBlock_5 = _$f(_$state, _$state.monthOfYear(row), itemLoop_5, row);\n loopAnchor_5_1 = _$ct();\n return {\n $create: function () {\n tr_1 = _$ce('tr');\n loopBlock_5.$create();\n this.$hydrate();\n },\n $hydrate: function () {\n _$sa(tr_1, 'class', 'scope_126c28ac');\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$a(_$(parent), _$frag, _$(sibling));\n },\n $update: function (_$state, row) {\n loopBlock_5.$update(_$state, _$state.monthOfYear(row), row);\n },\n $unmount: function () {\n _$a(tr_1, loopAnchor_5_1);\n loopBlock_5.$mount(tr_1, loopAnchor_5_1);\n _$a(_$frag, tr_1);\n },\n $destroy: function () {\n this.$unmount();\n loopBlock_5.$destroy();\n _$frag = tr_1 = loopAnchor_5_1 = loopBlock_5 = void 0;\n }\n };\n}\nfunction elseIf_1_condition_2(_$state) {\n var _$frag, tbody_1, loopAnchor_4_1, loopBlock_4;\n _$frag = _$d();\n loopBlock_4 = _$f(_$state, [\n 0,\n 1,\n 2\n ], itemLoop_4);\n loopAnchor_4_1 = _$ct();\n return {\n type: 'elseIf_1',\n $create: function () {\n tbody_1 = _$ce('tbody');\n loopBlock_4.$create();\n this.$hydrate();\n },\n $hydrate: function () {\n _$sa(tbody_1, 'class', 'scope_126c28ac');\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$a(_$(parent), _$frag, _$(sibling));\n },\n $update: function (_$state) {\n loopBlock_4.$update(_$state, [\n 0,\n 1,\n 2\n ]);\n },\n $unmount: function () {\n _$a(tbody_1, loopAnchor_4_1);\n loopBlock_4.$mount(tbody_1, loopAnchor_4_1);\n _$a(_$frag, tbody_1);\n },\n $destroy: function () {\n this.$unmount();\n loopBlock_4.$destroy();\n _$frag = tbody_1 = loopAnchor_4_1 = loopBlock_4 = void 0;\n }\n };\n}\nfunction ifCondition_5(_$state, day, _$index, week) {\n var _$frag, a_1, txt_1, setTxt_1, bindClassA_1, clickEvent_1, handlerClickEvent_1;\n _$frag = _$d();\n setTxt_1 = function (_$state, day) {\n return day.day < 10 ? '0' + day.day : day.day;\n };\n bindClassA_1 = function (_$state, day) {\n return ('scope_126c28ac ' + _$bc(_$state.itemState(day))).trim();\n };\n clickEvent_1 = function (_$state, day) {\n _$state.selectDay(day);\n };\n return {\n type: 'if',\n $create: function () {\n a_1 = _$ce('a');\n txt_1 = _$ct();\n txt_1.data = setTxt_1(_$state, day, week, _$index);\n this.$hydrate();\n },\n $hydrate: function () {\n _$sa(a_1, 'class', _$toStr(bindClassA_1(_$state, day, week, _$index)));\n _$al(a_1, 'click', handlerClickEvent_1 = function (event) {\n event.preventDefault();\n clickEvent_1(_$state, day, week, _$index, event, a_1);\n });\n _$sa(a_1, 'href', '#');\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$a(_$(parent), _$frag, _$(sibling));\n },\n $update: function (_$state, day, _$index, week) {\n var updateTxt_1 = setTxt_1(_$state, day, week, _$index);\n if (txt_1.data !== _$toStr(updateTxt_1)) {\n txt_1.data = updateTxt_1;\n }\n updateTxt_1 = void 0;\n var updateClassA_1 = _$toStr(bindClassA_1(_$state, day, week, _$index));\n if (_$ga(a_1, 'class') !== updateClassA_1) {\n _$sa(a_1, 'class', updateClassA_1);\n }\n updateClassA_1 = void 0;\n handlerClickEvent_1 = _$ul(a_1, 'click', handlerClickEvent_1, function (event) {\n event.preventDefault();\n clickEvent_1(_$state, day, week, _$index, event, a_1);\n });\n },\n $unmount: function () {\n _$a(a_1, txt_1);\n _$a(_$frag, a_1);\n },\n $destroy: function () {\n this.$unmount();\n _$rl(a_1, 'click', handlerClickEvent_1);\n _$frag = a_1 = txt_1 = setTxt_1 = bindClassA_1 = clickEvent_1 = handlerClickEvent_1 = void 0;\n }\n };\n}\nfunction elseCondition_5(_$state, day, _$index, week) {\n var _$frag, template_1, txt_1, setTxt_1;\n _$frag = _$d();\n setTxt_1 = function (_$state, day) {\n return day.day < 10 ? '0' + day.day : day.day;\n };\n return {\n type: 'else',\n $create: function () {\n template_1 = _$d();\n txt_1 = _$ct();\n txt_1.data = setTxt_1(_$state, day, week, _$index);\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$a(_$(parent), _$frag, _$(sibling));\n },\n $update: function (_$state, day, _$index, week) {\n var updateTxt_1 = setTxt_1(_$state, day, week, _$index);\n if (txt_1.data !== _$toStr(updateTxt_1)) {\n txt_1.data = updateTxt_1;\n }\n updateTxt_1 = void 0;\n },\n $unmount: function () {\n _$a(template_1, txt_1);\n _$a(_$frag, template_1);\n },\n $destroy: function () {\n this.$unmount();\n _$frag = template_1 = txt_1 = setTxt_1 = void 0;\n }\n };\n}\nfunction condition_5(_$state, day, _$index, week) {\n if (!day.disabled)\n return ifCondition_5(_$state, day, _$index, week);\n else\n return elseCondition_5(_$state, day, _$index, week);\n}\nfunction itemLoop_7(_$state, day, _$index, week) {\n var _$frag, td_1, conditionAnchor_1, conditionBlock_1, bindClassTd_1;\n _$frag = _$d();\n conditionAnchor_1 = _$ct();\n bindClassTd_1 = function (_$state, day) {\n return ('scope_126c28ac ' + _$bc({ disabled: day.disabled })).trim();\n };\n return {\n $create: function () {\n td_1 = _$ce('td');\n conditionBlock_1 = condition_5(_$state, day, _$index, week);\n conditionBlock_1.$create();\n this.$hydrate();\n },\n $hydrate: function () {\n _$sa(td_1, 'class', _$toStr(bindClassTd_1(_$state, day, week, _$index)));\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$a(_$(parent), _$frag, _$(sibling));\n },\n $update: function (_$state, day, _$index, week) {\n if (conditionBlock_1 && conditionBlock_1.type === condition_5(_$state, day, _$index, week).type) {\n conditionBlock_1.$update(_$state, day, _$index, week);\n } else {\n conditionBlock_1 && conditionBlock_1.$destroy();\n conditionBlock_1 = condition_5(_$state, day, _$index, week);\n conditionBlock_1.$create();\n conditionBlock_1.$mount(td_1, conditionAnchor_1);\n }\n var updateClassTd_1 = _$toStr(bindClassTd_1(_$state, day, week, _$index));\n if (_$ga(td_1, 'class') !== updateClassTd_1) {\n _$sa(td_1, 'class', updateClassTd_1);\n }\n updateClassTd_1 = void 0;\n },\n $unmount: function () {\n _$a(td_1, conditionAnchor_1);\n conditionBlock_1.$mount(td_1, conditionAnchor_1);\n _$a(_$frag, td_1);\n },\n $destroy: function () {\n this.$unmount();\n conditionBlock_1.$destroy();\n _$frag = td_1 = conditionAnchor_1 = conditionBlock_1 = bindClassTd_1 = void 0;\n }\n };\n}\nfunction itemLoop_6(_$state, week) {\n var _$frag, tr_1, td_1, txt_1, setTxt_1, loopAnchor_7_1, loopBlock_7;\n _$frag = _$d();\n setTxt_1 = function (_$state, week) {\n return week.weekYear < 10 ? '0' + week.weekYear : week.weekYear;\n };\n loopBlock_7 = _$f(_$state, week.days, itemLoop_7, week);\n loopAnchor_7_1 = _$ct();\n return {\n $create: function () {\n tr_1 = _$ce('tr');\n td_1 = _$ce('td');\n txt_1 = _$ct();\n txt_1.data = setTxt_1(_$state, week);\n loopBlock_7.$create();\n this.$hydrate();\n },\n $hydrate: function () {\n _$sa(td_1, 'class', 'scope_126c28ac week');\n _$sa(tr_1, 'class', 'scope_126c28ac');\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$a(_$(parent), _$frag, _$(sibling));\n },\n $update: function (_$state, week) {\n var updateTxt_1 = setTxt_1(_$state, week);\n if (txt_1.data !== _$toStr(updateTxt_1)) {\n txt_1.data = updateTxt_1;\n }\n updateTxt_1 = void 0;\n loopBlock_7.$update(_$state, week.days, week);\n },\n $unmount: function () {\n _$a(td_1, txt_1);\n _$a(tr_1, td_1);\n _$a(tr_1, loopAnchor_7_1);\n loopBlock_7.$mount(tr_1, loopAnchor_7_1);\n _$a(_$frag, tr_1);\n },\n $destroy: function () {\n this.$unmount();\n loopBlock_7.$destroy();\n _$frag = tr_1 = td_1 = txt_1 = setTxt_1 = loopAnchor_7_1 = loopBlock_7 = void 0;\n }\n };\n}\nfunction elseCondition_2(_$state) {\n var _$frag, tbody_1, loopAnchor_6_1, loopBlock_6;\n _$frag = _$d();\n loopBlock_6 = _$f(_$state, _$state.month, itemLoop_6);\n loopAnchor_6_1 = _$ct();\n return {\n type: 'else',\n $create: function () {\n tbody_1 = _$ce('tbody');\n loopBlock_6.$create();\n this.$hydrate();\n },\n $hydrate: function () {\n _$sa(tbody_1, 'class', 'scope_126c28ac');\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$a(_$(parent), _$frag, _$(sibling));\n },\n $update: function (_$state) {\n loopBlock_6.$update(_$state, _$state.month);\n },\n $unmount: function () {\n _$a(tbody_1, loopAnchor_6_1);\n loopBlock_6.$mount(tbody_1, loopAnchor_6_1);\n _$a(_$frag, tbody_1);\n },\n $destroy: function () {\n this.$unmount();\n loopBlock_6.$destroy();\n _$frag = tbody_1 = loopAnchor_6_1 = loopBlock_6 = void 0;\n }\n };\n}\nfunction condition_2(_$state) {\n if (_$state.view === 'years')\n return ifCondition_2(_$state);\n else if (_$state.view === 'months')\n return elseIf_1_condition_2(_$state);\n else\n return elseCondition_2(_$state);\n}\nfunction _$tplCalendar(_$state) {\n var _$frag, div_1, div_2, a_1, txt_1, clickEvent_1, handlerClickEvent_1, a_2, txt_2, setTxt_2, clickEvent_2, handlerClickEvent_2, a_3, txt_3, clickEvent_3, handlerClickEvent_3, a_4, txt_4, clickEvent_4, handlerClickEvent_4, table_1, conditionAnchor_1, conditionBlock_1, conditionAnchor_2, conditionBlock_2, bindClassTable_1, displayDiv_1, bindClassDiv_1;\n _$frag = _$d();\n clickEvent_1 = function (_$state) {\n _$state.prev();\n };\n setTxt_2 = function (_$state) {\n return _$state.viewLabel;\n };\n clickEvent_2 = function (_$state) {\n _$state.selectView();\n };\n clickEvent_3 = function (_$state) {\n _$state.resetDate();\n };\n clickEvent_4 = function (_$state) {\n _$state.next();\n };\n conditionAnchor_1 = _$ct();\n conditionAnchor_2 = _$ct();\n bindClassTable_1 = function (_$state) {\n return ('scope_126c28ac ' + _$bc([\n 'calendar-view',\n {\n months: _$state.view === 'months',\n years: _$state.view === 'years'\n }\n ])).trim();\n };\n var showDiv_1 = function (_$state, el, display) {\n el.style.display = _$state.visibility ? display : 'none';\n };\n bindClassDiv_1 = function (_$state) {\n return ('scope_126c28ac ' + _$bc([\n 'panel calendar',\n _$state.place\n ])).trim();\n };\n return {\n $create: function () {\n div_1 = _$ce();\n div_2 = _$ce();\n a_1 = _$ce('a');\n txt_1 = _$ct('\\xAB');\n a_2 = _$ce('a');\n txt_2 = _$ct();\n txt_2.data = setTxt_2(_$state);\n a_3 = _$ce('a');\n txt_3 = _$ct(' \\u238C');\n a_4 = _$ce('a');\n txt_4 = _$ct('\\xBB');\n table_1 = _$ce('table');\n conditionBlock_1 = condition_1(_$state);\n conditionBlock_1.$create();\n conditionBlock_2 = condition_2(_$state);\n conditionBlock_2.$create();\n this.$hydrate();\n },\n $hydrate: function () {\n _$al(a_1, 'click', handlerClickEvent_1 = function (event) {\n event.preventDefault();\n clickEvent_1(_$state, event, a_1);\n });\n _$sa(a_1, 'href', '#');\n _$sa(a_1, 'class', 'scope_126c28ac backward');\n _$al(a_2, 'click', handlerClickEvent_2 = function (event) {\n event.preventDefault();\n clickEvent_2(_$state, event, a_2);\n });\n _$sa(a_2, 'href', '#');\n _$sa(a_2, 'class', 'scope_126c28ac month');\n _$al(a_3, 'click', handlerClickEvent_3 = function (event) {\n event.preventDefault();\n clickEvent_3(_$state, event, a_3);\n });\n _$sa(a_3, 'href', '#');\n _$sa(a_3, 'class', 'scope_126c28ac today');\n _$al(a_4, 'click', handlerClickEvent_4 = function (event) {\n event.preventDefault();\n clickEvent_4(_$state, event, a_4);\n });\n _$sa(a_4, 'href', '#');\n _$sa(a_4, 'class', 'scope_126c28ac forward');\n _$sa(div_2, 'class', 'scope_126c28ac panel-heading calendar-actions');\n _$sa(table_1, 'class', _$toStr(bindClassTable_1(_$state)));\n displayDiv_1 = div_1.style.display;\n showDiv_1(_$state, div_1, displayDiv_1);\n _$sa(div_1, 'class', _$toStr(bindClassDiv_1(_$state)));\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$is('scope_126c28ac', 'table.scope_126c28ac{border-spacing:0;border-collapse:collapse;}.scope_126c28ac.panel.calendar{width:266px;}.scope_126c28ac.panel-heading.calendar-actions,tr.scope_126c28ac th.scope_126c28ac,tr.scope_126c28ac td.scope_126c28ac{text-align:center;}.scope_126c28ac.panel-heading.calendar-actions{position:relative;}.scope_126c28ac.panel-heading.calendar-actions .scope_126c28ac.forward{float:right;}.scope_126c28ac.panel-heading.calendar-actions .scope_126c28ac.backward{float:left;}.scope_126c28ac.panel-heading.calendar-actions .scope_126c28ac.today{right:50px;position:absolute;}.scope_126c28ac.calendar-view,tr.scope_126c28ac th.scope_126c28ac,tr.scope_126c28ac td.scope_126c28ac{border:1px solid #000;}tr.scope_126c28ac th.scope_126c28ac{padding:1px 3px;color:#fff;background-color:#000;border-bottom:2px solid #000;}tr.scope_126c28ac th.scope_126c28ac,tr.scope_126c28ac td.scope_126c28ac{cursor:pointer;}tr.scope_126c28ac td.scope_126c28ac{padding:4px 8px;}tr.scope_126c28ac td.scope_126c28ac:first-child,tr.scope_126c28ac td.disabled.scope_126c28ac{cursor:default;}tr.scope_126c28ac td.scope_126c28ac:first-child,tr.scope_126c28ac td.disabled.scope_126c28ac,td.scope_126c28ac a.active.scope_126c28ac,td.scope_126c28ac a.scope_126c28ac:hover{background-color:#a5a5a5;}td.scope_126c28ac a.scope_126c28ac{color:#000;display:table-cell;text-decoration:none;background-color:#fff;}td.scope_126c28ac a.selected.scope_126c28ac{color:#e9e9e9;background-color:#3b3b3b;}');\n _$a(_$(parent), _$frag, _$(sibling));\n this.$siblingEl = _$(sibling);\n this.$parentEl = sibling && _$(sibling).parentElement || _$(parent);\n },\n $update: function (_$state) {\n var updateTxt_2 = setTxt_2(_$state);\n if (txt_2.data !== _$toStr(updateTxt_2)) {\n txt_2.data = updateTxt_2;\n }\n updateTxt_2 = void 0;\n if (conditionBlock_1 && conditionBlock_1.type === condition_1(_$state).type) {\n conditionBlock_1.$update(_$state);\n } else {\n conditionBlock_1 && conditionBlock_1.$destroy();\n conditionBlock_1 = condition_1(_$state);\n conditionBlock_1.$create();\n conditionBlock_1.$mount(table_1, conditionAnchor_1);\n }\n if (conditionBlock_2 && conditionBlock_2.type === condition_2(_$state).type) {\n conditionBlock_2.$update(_$state);\n } else {\n conditionBlock_2 && conditionBlock_2.$destroy();\n conditionBlock_2 = condition_2(_$state);\n conditionBlock_2.$create();\n conditionBlock_2.$mount(table_1, conditionAnchor_2);\n }\n var updateClassTable_1 = _$toStr(bindClassTable_1(_$state));\n if (_$ga(table_1, 'class') !== updateClassTable_1) {\n _$sa(table_1, 'class', updateClassTable_1);\n }\n updateClassTable_1 = void 0;\n showDiv_1(_$state, div_1, displayDiv_1);\n var updateClassDiv_1 = _$toStr(bindClassDiv_1(_$state));\n if (_$ga(div_1, 'class') !== updateClassDiv_1) {\n _$sa(div_1, 'class', updateClassDiv_1);\n }\n updateClassDiv_1 = void 0;\n },\n $unmount: function () {\n _$a(a_1, txt_1);\n _$a(div_2, a_1);\n _$a(a_2, txt_2);\n _$a(div_2, a_2);\n _$a(a_3, txt_3);\n _$a(div_2, a_3);\n _$a(a_4, txt_4);\n _$a(div_2, a_4);\n _$a(div_1, div_2);\n _$a(table_1, conditionAnchor_1);\n conditionBlock_1.$mount(table_1, conditionAnchor_1);\n _$a(table_1, conditionAnchor_2);\n conditionBlock_2.$mount(table_1, conditionAnchor_2);\n _$a(div_1, table_1);\n _$a(_$frag, div_1);\n },\n $destroy: function () {\n this.$unmount();\n this.$parent = null;\n this.$parentEl = null;\n this.$siblingEl = null;\n this.$children.splice(0, this.$children.length);\n _$ds('scope_126c28ac');\n _$rl(a_1, 'click', handlerClickEvent_1);\n _$rl(a_2, 'click', handlerClickEvent_2);\n _$rl(a_3, 'click', handlerClickEvent_3);\n _$rl(a_4, 'click', handlerClickEvent_4);\n conditionBlock_1.$destroy();\n conditionBlock_2.$destroy();\n delete _$state.$root;\n _$frag = div_1 = div_2 = a_1 = txt_1 = clickEvent_1 = handlerClickEvent_1 = a_2 = txt_2 = setTxt_2 = clickEvent_2 = handlerClickEvent_2 = a_3 = txt_3 = clickEvent_3 = handlerClickEvent_3 = a_4 = txt_4 = clickEvent_4 = handlerClickEvent_4 = table_1 = conditionAnchor_1 = conditionBlock_1 = conditionAnchor_2 = conditionBlock_2 = bindClassTable_1 = displayDiv_1 = bindClassDiv_1 = void 0;\n }\n };\n}\nfunction Calendar(_$attrs, _$parent) {\n _$CompCtr.call(this, _$attrs, _$tplCalendar, calendar, _$parent);\n !_$parent && this.$create();\n}\nCalendar.plugin = _$plugin;\nCalendar.prototype = Object.create(_$CompCtr.prototype);\nCalendar.prototype.constructor = Calendar;\n/* harmony default export */ var components_calendar = (Calendar);\n// CONCATENATED MODULE: ./main.ts\n\r\nvar main_calendar = new components_calendar();\r\nmain_calendar.$mount('main');\r\n\n\n//# sourceURL=webpack:///./main.ts_+_3_modules?"); +eval("\n// CONCATENATED MODULE: h:/trebor-repos/trebor/tools/index.js\nvar PROP_MAP = { p: '__TP__', v: 'value', _: '_value', s: '_subscribers', e: '_events', w: '_watchers', h: 'prototype' };\r\nvar PROPS = ['$slots', '$refs', '$filters', '$directives', '_events', '_watchers'];\r\nvar TPS = window[PROP_MAP.p] || (window[PROP_MAP.p] = []);\r\nvar _$assign = Object['assign'] || function (t) {\r\n for (var s = void 0, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s)\r\n if (_$hasProp(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n};\r\nfunction _$CompCtr(attrs, template, options, parent) {\r\n var self = this;\r\n var _$set = function (prop, value) { _$def(self, prop, { value: value, writable: true }); };\r\n if (!attrs)\r\n attrs = {};\r\n _$e(PROPS, function (prop) { _$def(self, prop, { value: {} }); });\r\n _$set('$parent', parent || null);\r\n _$set('$children', []);\r\n _$set(PROP_MAP.s, {});\r\n _$set('$options', options);\r\n var opts = self.$options;\r\n if (!opts.attrs)\r\n opts.attrs = {};\r\n if (!opts.children)\r\n opts.children = {};\r\n _$e(TPS, function (plugin) { plugin.fn.call(self, _$CompCtr, plugin.options); });\r\n if (opts.filters)\r\n _$assign(self.$filters, opts.filters);\r\n if (opts.directives)\r\n _$e(opts.directives, function (drt, k) { self.$directives[k] = _$drt(drt); });\r\n _$e(opts.attrs, function (attrOps, key) {\r\n _$def(self, (_$isType(key, 'number') ? attrOps : key), {\r\n get: function () {\r\n if (_$isStr(attrOps)) {\r\n var value = attrs[attrOps];\r\n return _$isFunction(value) ? value() : value;\r\n }\r\n else {\r\n if (!_$hasProp(attrs, key) && attrOps.required) {\r\n return console.error(\"Attribute '\" + key + \"' is required.\");\r\n }\r\n else {\r\n var value = _$isFunction(attrs[key]) ? attrs[key]() : attrs[key];\r\n if (value === void 0 && _$hasProp(attrOps, 'default')) {\r\n var def = attrOps.default;\r\n value = _$isFunction(def) ? def() : def;\r\n }\r\n var typ = attrOps.type;\r\n if (typ && !_$isType(value, typ) && attrOps.required) {\r\n return console.error(\"Attribute '\" + key + \"' must be type '\" + typ + \"'.\");\r\n }\r\n value = _$toType(value, value === void 0 ? 'undefined' : typ, self, key);\r\n if (value !== void 0 && _$hasProp(attrOps, 'validator')) {\r\n var validator = attrOps.validator;\r\n if (_$isFunction(validator) && !validator(value)) {\r\n return console.error(\"Assigment '\" + key + \"'='\" + JSON.stringify(value) + \"' invalid.\");\r\n }\r\n }\r\n return value;\r\n }\r\n }\r\n },\r\n set: function () {\r\n console.error(\"'\" + key + \"' is read only.\");\r\n },\r\n enumerable: true, configurable: true\r\n });\r\n });\r\n var data = opts.model || {};\r\n var _loop_1 = function (key) {\r\n if (_$hasProp(data, key)) {\r\n var desc = Object.getOwnPropertyDescriptor(data, key);\r\n if (desc.value && _$isArray(desc.value)) {\r\n desc.value = new _$List(desc.value, self, key);\r\n }\r\n else {\r\n if (desc.get) {\r\n var getter_1 = desc.get;\r\n desc.get = function () {\r\n var value = getter_1.call(self);\r\n if (_$isArray(value))\r\n value = new _$List(value, self, key);\r\n return value;\r\n };\r\n }\r\n if (desc.set) {\r\n var setter_1 = desc.set;\r\n desc.set = function (v) {\r\n if (_$isArray(v))\r\n v = new _$List(v, self, key);\r\n setter_1.call(self, v);\r\n };\r\n }\r\n }\r\n _$def(self, key, desc);\r\n }\r\n };\r\n for (var key in data) {\r\n _loop_1(key);\r\n }\r\n var tpl = template(self);\r\n _$e(tpl, function (value, key) {\r\n _$def(self, key, {\r\n value: (function (key) {\r\n var hook = key[1].toUpperCase() + key.slice(2);\r\n var bhook = opts[\"before\" + hook];\r\n var ahook = opts[\"after\" + hook];\r\n return function () {\r\n bhook && bhook.call(this);\r\n key.slice(1) === 'update' ? value.call(this, this) : value.apply(this, arguments);\r\n ahook && ahook.call(this);\r\n };\r\n })(key)\r\n });\r\n });\r\n _$def(self, '$data', {\r\n get: function () {\r\n return _$toPlainObj(this);\r\n }\r\n });\r\n}\r\nfunction _$isValueAttr(attr) {\r\n return attr === 'value';\r\n}\r\nfunction _$subs(dep, listener) {\r\n if (!this[PROP_MAP.s][dep]) {\r\n this[PROP_MAP.s][dep] = [];\r\n }\r\n return this[PROP_MAP.s][dep].push(listener.bind(this)) - 1;\r\n}\r\nfunction _$def(obj, key, desc) {\r\n Object.defineProperty(obj, key, desc);\r\n}\r\n_$assign(_$CompCtr[PROP_MAP.h], {\r\n $get: function (path) {\r\n return _$accesor(this, path);\r\n },\r\n $set: function (path, value) {\r\n _$accesor(this, path, value);\r\n },\r\n $on: function (event, handler) {\r\n var _this = this;\r\n if (!this[PROP_MAP.e][event]) {\r\n this[PROP_MAP.e][event] = [];\r\n }\r\n var i = this[PROP_MAP.e][event].push(handler);\r\n return {\r\n $off: function () {\r\n _this[PROP_MAP.e][event].splice(i - 1, 1);\r\n }\r\n };\r\n },\r\n $once: function (event, handler) {\r\n var e = this.$on(event, function (args) {\r\n handler(args);\r\n e.$off();\r\n });\r\n },\r\n $fire: function (event, data) {\r\n if (this[PROP_MAP.e][event]) {\r\n _$e(this[PROP_MAP.e][event], function (handler) { handler(data); });\r\n }\r\n },\r\n $notify: function (key) {\r\n if (this[PROP_MAP.s][key]) {\r\n _$e(this[PROP_MAP.s][key], function (suscriber) { suscriber(); });\r\n }\r\n },\r\n $observe: function (deps, listener) {\r\n var _this = this;\r\n var subs = [];\r\n if (_$isArray(deps)) {\r\n _$e(deps, function (dep) {\r\n subs.push({ sub: dep, i: _$subs.call(_this, dep, listener) });\r\n });\r\n }\r\n else {\r\n subs.push({ sub: deps, i: _$subs.call(this, deps, listener) });\r\n }\r\n return {\r\n $unobserve: function () {\r\n _$e(subs, function (sub) {\r\n _this[PROP_MAP.s][sub.sub].splice(sub.i, 1);\r\n });\r\n }\r\n };\r\n },\r\n $watch: function (key, watcher) {\r\n var _this = this;\r\n if (!this[PROP_MAP.w][key]) {\r\n this[PROP_MAP.w][key] = [];\r\n }\r\n var i = this[PROP_MAP.w][key].push(watcher.bind(this));\r\n return {\r\n $unwatch: function () {\r\n _this[PROP_MAP.w][key].splice(i - 1, 1);\r\n }\r\n };\r\n }\r\n});\r\nvar array = Array[PROP_MAP.h];\r\nfunction _$toArgs(args, start) {\r\n if (start === void 0) { start = 0; }\r\n return array.slice.call(args, start);\r\n}\r\nfunction _$arrayValues(list, value, root, key) {\r\n array.push.apply(list, value.map(function (v, i) {\r\n if (list.length !== 0)\r\n i += list.length;\r\n return !(_$isType(v, _$List)) && _$isArray(v) ? new _$List(v, root, key + \".\" + i) : v;\r\n }));\r\n}\r\nfunction _$List(value, root, key) {\r\n var self = this;\r\n Array.apply(self, [value.length]);\r\n var desc = { writable: false, configurable: false, enumerable: false };\r\n _$def(self, '_key', _$assign({ value: key }, desc));\r\n _$def(self, '_root', _$assign({ value: root }, desc));\r\n _$arrayValues(self, value, root, key);\r\n desc.writable = true;\r\n _$def(self, 'length', _$assign({ value: self.length }, desc));\r\n}\r\n_$extends(_$List, Array);\r\n['pop', 'push', 'reverse', 'shift', 'sort', 'fill', 'unshift', 'splice'].forEach(function (method) {\r\n _$List[PROP_MAP.h][method] = function () {\r\n var self = this;\r\n var old = self.slice();\r\n var result;\r\n if (method === 'push') {\r\n _$arrayValues(self, _$toArgs(arguments), self._root, self._key);\r\n result = self.length;\r\n }\r\n else {\r\n result = array[method].apply(self, arguments);\r\n }\r\n _$dispatch(self._root, self._key, old, self.slice());\r\n return result;\r\n };\r\n});\r\n_$List[PROP_MAP.h].pull = function (index) {\r\n var self = this;\r\n var items = _$toArgs(arguments, 1);\r\n var length = self.length;\r\n if (index > length) {\r\n length = index + 1;\r\n var pull = new Array(index - self.length);\r\n pull.push.apply(pull, items);\r\n for (var i = 0; i < length; i++) {\r\n if (i === index) {\r\n self.push.apply(self, pull);\r\n }\r\n }\r\n }\r\n else {\r\n self.splice.apply(self, [index, 1].concat(items));\r\n }\r\n};\r\nfunction _$dispatch(root, key, oldVal, value) {\r\n root.$notify(key);\r\n if (root[PROP_MAP.w][key]) {\r\n _$e(root[PROP_MAP.w][key], function (watcher) { watcher(oldVal, value); });\r\n }\r\n root.$update();\r\n}\r\nfunction _$extends(ctor, exts) {\r\n ctor['plugin'] = function (fn, options) {\r\n TPS.push({ options: options, fn: fn });\r\n };\r\n ctor[PROP_MAP.h] = Object.create(exts[PROP_MAP.h]);\r\n ctor[PROP_MAP.h].constructor = ctor;\r\n}\r\nfunction _$isType(value, type) {\r\n return _$type(type) === 'string' ? type.split('|').some(function (t) { return t.trim() === _$type(value); }) : value instanceof type;\r\n}\r\nfunction _$apply(callee, args, globs, thisArg) {\r\n if (thisArg === void 0) { thisArg = null; }\r\n return callee.apply(thisArg, args.concat(globs));\r\n}\r\nfunction _$isObject(obj) {\r\n return _$isType(obj, 'object');\r\n}\r\nfunction _$isArray(obj) {\r\n return Array.isArray ? Array.isArray(obj) : _$isType(obj, 'array');\r\n}\r\nfunction _$isFunction(obj) {\r\n return _$isType(obj, 'function');\r\n}\r\nfunction _$isStr(obj) {\r\n return _$isType(obj, 'string');\r\n}\r\nfunction _$toType(value, type, root, key) {\r\n switch (type) {\r\n case 'date':\r\n return new Date(value);\r\n case 'string':\r\n return _$toStr(value);\r\n case 'number':\r\n return +value;\r\n case 'boolean':\r\n return _$isStr(value) && !value ? true : !!value;\r\n case 'array':\r\n return _$isType(value, _$List) ? value : new _$List(value, root, key);\r\n default:\r\n return value;\r\n }\r\n}\r\nfunction _$type(obj) {\r\n return / (\\w+)/.exec(({}).toString.call(obj))[1].toLowerCase();\r\n}\r\nfunction _$hasProp(obj, prop) {\r\n return obj.hasOwnProperty(prop);\r\n}\r\nfunction _$drt(dd) {\r\n var hasProp = function (prop, instance, options, element) { return _$isObject(dd) && dd[prop] && dd[prop](instance, options, element); };\r\n return {\r\n $init: function (instance, options, element) {\r\n hasProp('$init', instance, options, element);\r\n },\r\n $inserted: function (instance, options, element) {\r\n hasProp('$inserted', instance, options, element);\r\n },\r\n $update: function (instance, options, element) {\r\n if (_$isFunction(dd)) {\r\n dd(instance, options, element);\r\n }\r\n else {\r\n hasProp('$update', instance, options, element);\r\n }\r\n },\r\n $destroy: function (instance, options, element) {\r\n hasProp('$destroy', instance, options, element);\r\n }\r\n };\r\n}\r\nfunction _$noop() { }\r\nfunction _$add(inst, Child, attrs) {\r\n var child = null;\r\n if (Child) {\r\n child = new Child(attrs, inst);\r\n inst.$children.push(child);\r\n }\r\n return child;\r\n}\r\nfunction _$remove(inst, child) {\r\n var index = inst.$children.indexOf(child);\r\n index >= 0 && inst.$children.splice(index, 1);\r\n}\r\nfunction _$toStr(obj) {\r\n var str = _$type(obj);\r\n return !/null|undefined/.test(str) ? obj.toString() : str;\r\n}\r\nfunction _$toPlainObj(obj) {\r\n var data = {};\r\n _$e(_$isObject(obj) ? obj : {}, function (_v, k) {\r\n if (k[0] !== '$' && !_$isFunction(obj[k])) {\r\n if (_$isType(obj[k], _$List)) {\r\n data[k] = obj[k].map(_$toPlainObj);\r\n }\r\n else if (_$isObject(obj[k])) {\r\n data[k] = _$toPlainObj(obj[k]);\r\n }\r\n else {\r\n data[k] = obj[k];\r\n }\r\n }\r\n });\r\n return _$isObject(obj) ? data : obj;\r\n}\r\nfunction _$setRef(refs, prop, node) {\r\n if (!_$hasProp(refs, prop)) {\r\n var value_1 = [];\r\n _$def(refs, prop, {\r\n get: function () { return value_1.length <= 1 ? value_1[0] : value_1; },\r\n set: function (val) { val && !~value_1.indexOf(val) && value_1.push(val); },\r\n enumerable: true, configurable: true\r\n });\r\n }\r\n refs[prop] = node;\r\n}\r\nfunction _$accesor(object, path, value) {\r\n return path.split('.').reduce(function (obj, key, i, arr) {\r\n if (_$isType(value, 'undefined')) {\r\n if (obj == null) {\r\n arr.splice(0, arr.length);\r\n return i > 0 && obj === null ? obj : undefined;\r\n }\r\n }\r\n else {\r\n if (i === arr.length - 1) {\r\n if (_$isType(obj, _$List) && _$toStr(+key) === key) {\r\n obj.pull(+key, value);\r\n }\r\n else {\r\n var oldVal = obj[key];\r\n obj[key] = !_$isType(value, _$List) && _$isArray(value) ? new _$List(value, object, key) : value;\r\n _$dispatch(object, path, oldVal, obj[key]);\r\n }\r\n }\r\n else if (!_$isObject(obj[key])) {\r\n obj[key] = {};\r\n }\r\n }\r\n return obj ? obj[key] : null;\r\n }, object);\r\n}\r\nfunction _$emptyElse() {\r\n return { type: 'empty-else', $create: _$noop, $mount: _$noop, $update: _$noop, $destroy: _$noop };\r\n}\r\nfunction _$isKey(event, key) {\r\n return event.key.toLowerCase() === key || !!event[key + \"Key\"];\r\n}\r\nfunction _$bindGroup(input, selection) {\r\n var _value = _$gv(input);\r\n var _$index = selection.indexOf(_value);\r\n input.checked && !~_$index ? selection.push(_value) : selection.splice(_$index, 1);\r\n}\r\nfunction _$bindMultiSelect(select, selections) {\r\n if (!selections.length)\r\n return;\r\n var options = select.options;\r\n for (var i = 0; i < options.length; i++) {\r\n options[i].selected = !!~selections.indexOf(_$gv(options[i]));\r\n }\r\n}\r\nfunction _$updateMultiSelect(select, obj, prop) {\r\n var items = [];\r\n var selection = obj[prop];\r\n var selectedOptions = select.selectedOptions;\r\n for (var i = 0; i < selectedOptions.length; i++) {\r\n items.push(_$gv(selectedOptions[i]));\r\n }\r\n obj[prop] = new _$List(items, selection['_root'], selection['_key']);\r\n obj.$update();\r\n}\r\nfunction _$(selector, parent) {\r\n return _$isStr(selector) ? (parent || document).querySelector(selector) : selector;\r\n}\r\nfunction _$d() {\r\n return document.createDocumentFragment();\r\n}\r\nfunction _$a(parent, child, sibling) {\r\n if (_$isType(sibling, 'boolean') && sibling)\r\n parent.parentElement.replaceChild(child, parent);\r\n else if (!sibling)\r\n parent.appendChild(child);\r\n else\r\n parent.insertBefore(child, sibling);\r\n}\r\nfunction _$as(source, dest) {\r\n var childNodes = source.childNodes, attributes = source.attributes;\r\n for (var i = 0; i < childNodes.length; i++) {\r\n _$a(dest, childNodes[i]);\r\n }\r\n for (var i = 0; i < attributes.length; i++) {\r\n var attr = attributes[i];\r\n dest.setAttributeNS(source.namespaceURI, attr.name, attr.value);\r\n }\r\n source.parentElement.replaceChild(dest, source);\r\n return dest;\r\n}\r\nfunction _$r(el, parent) {\r\n var root = parent || el.parentElement;\r\n if (root)\r\n root.removeChild(el);\r\n}\r\nfunction _$ce(tagName) {\r\n return document.createElement(tagName || 'div');\r\n}\r\nfunction _$cse(tagName) {\r\n return document.createElementNS('http://www.w3.org/2000/svg', tagName || 'svg');\r\n}\r\nfunction _$ct(content) {\r\n return document.createTextNode(content || '');\r\n}\r\nfunction _$cm(content) {\r\n return document.createComment(content || '');\r\n}\r\nfunction _$sa(el, attrAndValue) {\r\n var attr = attrAndValue[0], value = attrAndValue[1];\r\n el.setAttribute(attr, _$toStr(value));\r\n if (_$isValueAttr(attr) && !_$isStr(value))\r\n el[PROP_MAP._] = value;\r\n}\r\nfunction _$ga(el, attr) {\r\n return _$isValueAttr(attr) ? _$gv(el) : el.getAttribute(attr);\r\n}\r\nfunction _$gv(el) {\r\n return _$hasProp(el, PROP_MAP._) ? el[PROP_MAP._] : el[PROP_MAP.v];\r\n}\r\nfunction _$al(el, event, handler) {\r\n el.addEventListener(event, handler, false);\r\n}\r\nfunction _$ul(el, event, oldHandler, newHandler) {\r\n _$rl(el, event, oldHandler);\r\n _$al(el, event, oldHandler = newHandler);\r\n return oldHandler;\r\n}\r\nfunction _$rl(el, event, handler) {\r\n el.removeEventListener(event, handler, false);\r\n}\r\nfunction _$bc(value) {\r\n var classes = '';\r\n if (_$isStr(value)) {\r\n classes += \" \" + value;\r\n }\r\n else if (_$isArray(value)) {\r\n classes = value.map(_$bc).join(' ');\r\n }\r\n else if (_$isObject(value)) {\r\n for (var key in value)\r\n if (_$hasProp(value, key) && value[key])\r\n classes += \" \" + key;\r\n }\r\n return classes.trim();\r\n}\r\nfunction _$bs(value) {\r\n var el = _$ce();\r\n if (_$isObject(value)) {\r\n var style_1 = el.style;\r\n _$e(value, function (val, prop) {\r\n if (val !== style_1[prop])\r\n style_1[prop] = val;\r\n });\r\n return style_1.cssText;\r\n }\r\n else if (_$isStr(value)) {\r\n return value;\r\n }\r\n else {\r\n return '';\r\n }\r\n}\r\nfunction _$cu(block, condition, parent, anchor, inst) {\r\n var globs = _$toArgs(arguments, 5);\r\n if (block && block.type === _$apply(condition, [inst], globs).type) {\r\n _$apply(block.$update, [inst], globs, block);\r\n }\r\n else {\r\n block && block.$destroy();\r\n block = _$apply(condition, [inst], globs);\r\n block.$create();\r\n block.$mount(parent || inst.$parentEl, anchor);\r\n }\r\n return block;\r\n}\r\nfunction _$bba(el, attrAndValue) {\r\n var attr = attrAndValue[0], value = attrAndValue[1];\r\n el[attr] = value == null || value === false ? (el.removeAttribute(attr), false) : (_$sa(el, [attr, '']), true);\r\n}\r\nfunction _$bu(el, binding) {\r\n var attr = binding[0], value = binding[1];\r\n var _value = _$toStr(value);\r\n if (_$isValueAttr(attr)) {\r\n if (el[attr] !== _value)\r\n el[attr] = _value;\r\n el[PROP_MAP._] = value;\r\n }\r\n else if (_$ga(el, attr) !== _value) {\r\n _$sa(el, [attr, _value]);\r\n }\r\n}\r\nfunction _$tu(text, value) {\r\n if (text.data !== (value = _$toStr(value)))\r\n text.data = value;\r\n}\r\nfunction _$nu(node, tag) {\r\n return tag.toUpperCase() !== node.tagName ? _$as(node, _$ce(tag)) : node;\r\n}\r\nfunction _$rr(refs, prop, node) {\r\n var nodes = refs[prop];\r\n _$isArray(nodes) ? refs[prop].splice(nodes.indexOf(node), 1) : (delete refs[prop]);\r\n}\r\nfunction _$hu(node, value) {\r\n if (node.innerHTML !== (value = _$toStr(value)))\r\n node.innerHTML = value;\r\n}\r\nfunction _$pu(parent, Ctor, inst, value, attrs, el, sibling) {\r\n if (value === Ctor) {\r\n inst && inst.$update();\r\n }\r\n else {\r\n Ctor = value;\r\n if (inst) {\r\n inst.$destroy();\r\n _$remove(parent, inst);\r\n }\r\n if (inst) {\r\n inst = _$add(parent, Ctor, attrs);\r\n inst.$create();\r\n inst.$mount(el, sibling);\r\n }\r\n }\r\n return [inst, Ctor];\r\n}\r\nfunction _$f(root, obj, loop) {\r\n var items = {}, loopParent, loopSibling;\r\n var globs = _$toArgs(arguments, 3);\r\n _$e(obj, function (item, i, index) { items[i] = _$apply(loop, [root, item, i, index], globs); });\r\n return {\r\n $create: function () {\r\n _$e(items, function (item) { item.$create(); });\r\n },\r\n $mount: function (parent, sibling) {\r\n loopParent = _$(parent);\r\n loopSibling = _$(sibling);\r\n _$e(items, function (item) { item.$mount(loopParent, loopSibling); });\r\n },\r\n $update: function (root, obj) {\r\n var globs = _$toArgs(arguments, 2);\r\n _$e(items, function (item, i, index) {\r\n if (obj[i]) {\r\n _$apply(item.$update, [root, obj[i], i, index], globs, item);\r\n }\r\n else {\r\n item.$destroy();\r\n delete items[i];\r\n }\r\n });\r\n _$e(obj, function (item, i, index) {\r\n if (!items[i]) {\r\n items[i] = _$apply(loop, [root, item, i, index], globs);\r\n items[i].$create();\r\n items[i].$mount(loopParent, loopSibling);\r\n }\r\n });\r\n },\r\n $destroy: function () {\r\n _$e(items, function (item) { item.$destroy(); });\r\n }\r\n };\r\n}\r\nfunction _$e(obj, cb) {\r\n var i = 0;\r\n for (var key in obj) {\r\n if (_$hasProp(obj, key)) {\r\n cb(obj[key], (isNaN(+key) ? key : +key), i++);\r\n }\r\n }\r\n}\r\nfunction _$is(id, css) {\r\n var isNew = false;\r\n var style = _$(\"#\" + id, document.head);\r\n if (!style) {\r\n isNew = true;\r\n style = _$ce('style');\r\n style.id = id;\r\n _$sa(style, ['refs', 1]);\r\n }\r\n if (style.textContent !== css) {\r\n style.textContent = css;\r\n }\r\n if (isNew) {\r\n _$a(document.head, style);\r\n }\r\n else {\r\n var count = +_$ga(style, 'refs');\r\n _$sa(style, ['refs', ++count]);\r\n }\r\n}\r\nfunction _$ds(id) {\r\n var style = _$(\"#\" + id, document.head);\r\n if (style) {\r\n var count = +_$ga(style, 'refs');\r\n if (--count === 0) {\r\n _$r(style, document.head);\r\n }\r\n else {\r\n _$sa(style, ['refs', count]);\r\n }\r\n }\r\n}\r\n//# sourceMappingURL=index.js.map\n// CONCATENATED MODULE: ./components/calendar.ts\n/* harmony default export */ var calendar = ({\r\n attrs: {\r\n value: {\r\n type: 'date',\r\n default: function () { return new Date(); }\r\n },\r\n show: {\r\n type: 'boolean',\r\n default: true\r\n },\r\n place: {\r\n type: 'string',\r\n default: 'right'\r\n },\r\n labelTemplate: {\r\n type: 'string',\r\n default: '${month} of ${year}'\r\n },\r\n options: {\r\n type: 'object',\r\n default: function () { return ({\r\n daysOfWeek: ['SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA'],\r\n months: [\r\n 'January', 'February', 'March', 'April', 'May', 'June', 'July',\r\n 'August', 'September', 'October', 'November', 'Dicember',\r\n ]\r\n }); }\r\n }\r\n },\r\n afterMount: function () {\r\n this.$set('date', new Date(this.value.valueOf()));\r\n this.createCalendar(this.date.getMonth(), this.date.getFullYear());\r\n },\r\n model: {\r\n view: '',\r\n month: [],\r\n date: new Date(),\r\n get viewLabel() {\r\n switch (this.view) {\r\n case 'months':\r\n return this.date.getFullYear();\r\n case 'years':\r\n var part = this.date.getFullYear().toString().substring(0, 3);\r\n return part + \"0 - \" + part + \"9\";\r\n default:\r\n return this.labelTemplate\r\n .replace(/\\${day}/g, this.date.getDate() + '')\r\n .replace(/\\${month}/g, this.options.months[this.date.getMonth()])\r\n .replace(/\\${year}/g, this.date.getFullYear() + '');\r\n }\r\n },\r\n get decade() {\r\n return this.yearInDecade(this.date.getFullYear());\r\n },\r\n get months() {\r\n var _this = this;\r\n var d = new Date();\r\n return this.options.months.map(function (month, i) { return ({\r\n value: i, month: month.substring(0, 3),\r\n active: d.getMonth() === i && d.getFullYear() === _this.date.getFullYear()\r\n }); });\r\n },\r\n get visibility() {\r\n if (!this.show) {\r\n this.$set('view', '');\r\n }\r\n return this.show;\r\n },\r\n selectView: function () {\r\n this.$set('view', this.view === '' ? 'months' : 'years');\r\n },\r\n itemState: function (item) {\r\n return { active: item.active, disabled: item.disabled, selected: item.selected };\r\n },\r\n resetDate: function () {\r\n this.$set('date', new Date());\r\n this.$fire('change', new Date());\r\n this.createCalendar(this.date.getMonth(), this.date.getFullYear());\r\n },\r\n resetDaySelection: function () {\r\n this.month.forEach(function (week) {\r\n week.days.forEach(function (day) {\r\n day.selected && (day.selected = false);\r\n });\r\n });\r\n },\r\n selectDay: function (day) {\r\n if (!day.disabled) {\r\n this.resetDaySelection();\r\n var date = new Date(this.date.getFullYear(), this.date.getMonth(), day.day);\r\n this.$fire('change', date);\r\n day.selected = true;\r\n this.$update();\r\n }\r\n },\r\n selectMonth: function (month) {\r\n if (!month.disabled) {\r\n this.date.setMonth(month.value);\r\n this.createCalendar(this.date.getMonth(), this.date.getFullYear());\r\n this.$set('view', '');\r\n }\r\n },\r\n selectYear: function (year) {\r\n if (!year.disabled) {\r\n this.date.setFullYear(year.year);\r\n this.$set('view', 'months');\r\n }\r\n },\r\n weekOfYear: function (day, month, year) {\r\n var target = new Date(year, month, day);\r\n var dayNr = (target.getDay() + 6) % 7;\r\n target.setDate(target.getDate() - dayNr + 3);\r\n var firstThursday = target.valueOf();\r\n target.setMonth(0, 1);\r\n if (target.getDay() !== 4) {\r\n target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7);\r\n }\r\n return 1 + Math.ceil((firstThursday - target.valueOf()) / 604800000);\r\n },\r\n monthOfYear: function (row) {\r\n switch (row) {\r\n case 1:\r\n return this.months.slice(4, 8);\r\n case 2:\r\n return this.months.slice(8);\r\n default:\r\n return this.months.slice(0, 4);\r\n }\r\n },\r\n yearOfDecade: function (row) {\r\n switch (row) {\r\n case 1:\r\n return this.decade.slice(4, 8);\r\n case 2:\r\n return this.decade.slice(8);\r\n default:\r\n return this.decade.slice(0, 4);\r\n }\r\n },\r\n yearInDecade: function (year) {\r\n var now = new Date();\r\n var range = [];\r\n var text = year.toString();\r\n var first = parseInt(text.substring(0, text.length - 1) + 0);\r\n for (var i = 0; i < 12; i++) {\r\n if (i === 0) {\r\n range[i] = { year: first - 1, disabled: true, };\r\n }\r\n else if (i === 11) {\r\n range[i] = { year: first + 10, disabled: true, };\r\n }\r\n else {\r\n var y = first + i - 1;\r\n range[i] = { year: y, active: y === now.getFullYear() };\r\n }\r\n }\r\n return range;\r\n },\r\n daysOfMonth: function (month, year) {\r\n return 32 - new Date(year, month, 32).getDate();\r\n },\r\n createCalendar: function (month, year) {\r\n var date = new Date(year, month, 1).getDay();\r\n var numDays = this.daysOfMonth(month, year);\r\n var lastDay = this.daysOfMonth(month - 1, year);\r\n var start = 1;\r\n var end = 7 - date;\r\n var d = new Date();\r\n var weeks = [];\r\n while (start <= numDays) {\r\n var days = [];\r\n var length_1 = end - start + 1;\r\n for (var i = 0; i < length_1; i++) {\r\n days[i] = {\r\n day: start + i,\r\n active: (start + i) === d.getDate() && d.getMonth() === month && d.getFullYear() === year\r\n };\r\n }\r\n if (days.length < 7 && start === 1) {\r\n for (var i = 0; i < date; i++) {\r\n days.unshift({ day: lastDay - i, disabled: true });\r\n }\r\n }\r\n else if (days.length < 7 && days.length > 0) {\r\n var nend = 7 - days.length;\r\n for (var i = 1; i <= nend; i++) {\r\n days[days.length] = { day: i, disabled: true };\r\n }\r\n }\r\n var week = {\r\n start: start, end: end, days: days,\r\n weekYear: this.weekOfYear(end, month, year)\r\n };\r\n weeks[weeks.length] = week;\r\n start = end + 1;\r\n end = start === 1 && end === 8 ? 1 : end + 7;\r\n if (end > numDays) {\r\n end = numDays;\r\n }\r\n }\r\n if (weeks.length === 4 || date === 0) {\r\n var days = [];\r\n for (var i = 0; i < 7; i++) {\r\n days[6 - i] = { day: lastDay - i, disabled: true };\r\n }\r\n var start_1 = days[0].day;\r\n var end_1 = days[days.length - 1].day;\r\n weeks.unshift({\r\n start: start_1, end: end_1, days: days,\r\n weekYear: this.weekOfYear(end_1, month - 1, year)\r\n });\r\n }\r\n if (weeks.length === 5) {\r\n var days = [];\r\n var start_2 = 1;\r\n var end_2 = 7;\r\n var lastWeek = weeks[weeks.length - 1];\r\n var lastDay_1 = lastWeek.days[lastWeek.days.length - 1];\r\n if (!~[28, 29, 30, 31].indexOf(lastDay_1.day)) {\r\n start_2 = lastDay_1.day + 1;\r\n end_2 = 6 + start_2;\r\n }\r\n for (var i = 0; i < 7; i++) {\r\n days[i] = { day: start_2 + i, disabled: true };\r\n }\r\n weeks.push({\r\n start: start_2, end: end_2, days: days,\r\n weekYear: this.weekOfYear(end_2, month + 1, year)\r\n });\r\n }\r\n this.$set('month', weeks);\r\n },\r\n prev: function () {\r\n if (this.view === 'years') {\r\n this.date = new Date(this.date.getFullYear() - 10, this.date.getMonth(), this.date.getDate());\r\n }\r\n else if (this.view === 'months') {\r\n this.date = new Date(this.date.getFullYear() - 1, this.date.getMonth(), this.date.getDate());\r\n }\r\n else {\r\n this.date = new Date(this.date.getFullYear(), this.date.getMonth() - 1, 1);\r\n this.createCalendar(this.date.getMonth(), this.date.getFullYear());\r\n }\r\n this.$update();\r\n },\r\n next: function () {\r\n if (this.view === 'years') {\r\n this.date = new Date(this.date.getFullYear() + 10, this.date.getMonth(), this.date.getDate());\r\n }\r\n else if (this.view === 'months') {\r\n this.date = new Date(this.date.getFullYear() + 1, this.date.getMonth(), this.date.getDate());\r\n }\r\n else {\r\n this.date = new Date(this.date.getFullYear(), this.date.getMonth() + 1, 1);\r\n this.createCalendar(this.date.getMonth(), this.date.getFullYear());\r\n }\r\n this.$update();\r\n }\r\n }\r\n});\r\n\n// CONCATENATED MODULE: ./components/calendar.html\n\r\n\r\nfunction itemLoop_1(_$state, dayOfWeek) {\r\n var _$frag, th_1, txt_1, setTxt_1;\r\n _$frag = _$d();\r\n setTxt_1 = function(_$state, dayOfWeek) {\r\n return dayOfWeek;\r\n };\r\n return {\r\n $create: function() {\r\n th_1 = _$ce('th');\r\n txt_1 = _$ct();\r\n txt_1.data = setTxt_1(_$state, dayOfWeek);\r\n _$sa(th_1, ['class', 'scope_126c28ac']);\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n },\r\n\r\n $update: function(_$state, dayOfWeek) {\r\n _$tu(txt_1, setTxt_1(_$state, dayOfWeek));\r\n },\r\n\r\n $unmount: function() {\r\n _$a(th_1, txt_1);\r\n _$a(_$frag, th_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n _$frag = th_1 = txt_1 = setTxt_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction ifCondition_1(_$state) {\r\n var _$frag, thead_1, tr_1, th_1, loopAnchor_1_1, loopBlock_1;\r\n _$frag = _$d();\r\n loopBlock_1 = _$f(_$state, _$state.options.daysOfWeek, itemLoop_1);\r\n loopAnchor_1_1 = _$ct();\r\n return {\r\n type: 'if',\r\n\r\n $create: function() {\r\n thead_1 = _$ce('thead');\r\n tr_1 = _$ce('tr');\r\n th_1 = _$ce('th');\r\n th_1.innerHTML = 'W#';\r\n loopBlock_1.$create();\r\n _$sa(th_1, ['class', 'scope_126c28ac']);\r\n _$sa(tr_1, ['class', 'scope_126c28ac']);\r\n _$sa(thead_1, ['class', 'scope_126c28ac']);\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n },\r\n\r\n $update: function(_$state) {\r\n loopBlock_1.$update(_$state, _$state.options.daysOfWeek);\r\n },\r\n\r\n $unmount: function() {\r\n _$a(tr_1, th_1);\r\n _$a(tr_1, loopAnchor_1_1);\r\n loopBlock_1.$mount(tr_1, loopAnchor_1_1);\r\n _$a(thead_1, tr_1);\r\n _$a(_$frag, thead_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n loopBlock_1.$destroy();\r\n _$frag = thead_1 = tr_1 = th_1 = loopAnchor_1_1 = loopBlock_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction condition_1(_$state) {\r\n if (_$state.view === '')\r\n return ifCondition_1(_$state);\r\n else\r\n return _$emptyElse();\r\n}\r\nfunction ifCondition_3(_$state, year, row) {\r\n var _$frag, a_1, txt_1, setTxt_1, bindClassA_1, clickEvent_1, handlerClickEvent_1;\r\n _$frag = _$d();\r\n setTxt_1 = function(_$state, year) {\r\n return year.year;\r\n };\r\n bindClassA_1 = function(_$state, year) {\r\n return ['class', ('scope_126c28ac ' + _$bc(_$state.itemState(year))).trim()];\r\n };\r\n clickEvent_1 = function(_$state, year) {\r\n _$state.selectYear(year);\r\n };\r\n return {\r\n type: 'if',\r\n\r\n $create: function() {\r\n a_1 = _$ce('a');\r\n txt_1 = _$ct();\r\n txt_1.data = setTxt_1(_$state, year, row);\r\n _$sa(a_1, ['href', '#']);\r\n _$sa(a_1, ['class', 'scope_126c28ac']);\r\n _$sa(a_1, bindClassA_1(_$state, year, row));\r\n _$al(a_1, 'click', handlerClickEvent_1 = function(event) {\r\n event.preventDefault();\r\n clickEvent_1(_$state, year, row, event, a_1);\r\n });\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n },\r\n\r\n $update: function(_$state, year, row) {\r\n _$tu(txt_1, setTxt_1(_$state, year, row));\r\n _$bu(a_1, bindClassA_1(_$state, year, row));\r\n handlerClickEvent_1 = _$ul(a_1, 'click', handlerClickEvent_1, function(event) {\r\n event.preventDefault();\r\n clickEvent_1(_$state, year, row, event, a_1);\r\n });\r\n },\r\n\r\n $unmount: function() {\r\n _$a(a_1, txt_1);\r\n _$a(_$frag, a_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n _$rl(a_1, 'click', handlerClickEvent_1);\r\n _$frag = a_1 = txt_1 = setTxt_1 = bindClassA_1 = clickEvent_1 = handlerClickEvent_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction elseCondition_3() {\r\n var _$frag, template_1;\r\n _$frag = _$d();\r\n return {\r\n type: 'else',\r\n\r\n $create: function() {\r\n template_1 = _$d();\r\n template_1 = _$ce('template');\r\n template_1.innerHTML = '';\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n },\r\n\r\n $update: _$noop,\r\n\r\n $unmount: function() {\r\n _$a(_$frag, template_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n _$frag = template_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction condition_3(_$state, year, row) {\r\n if (!year.disabled)\r\n return ifCondition_3(_$state, year, row);\r\n else\r\n return elseCondition_3(_$state, year, row);\r\n}\r\nfunction itemLoop_3(_$state, year, _$v, _$i, row) {\r\n var _$frag, td_1, conditionAnchor_1, conditionBlock_1, bindClassTd_1;\r\n _$frag = _$d();\r\n conditionAnchor_1 = _$ct();\r\n bindClassTd_1 = function(_$state, year) {\r\n return ['class', ('scope_126c28ac ' + _$bc({\r\n disabled: year.disabled\r\n })).trim()];\r\n };\r\n return {\r\n $create: function() {\r\n td_1 = _$ce('td');\r\n conditionBlock_1 = condition_3(_$state, year, row);\r\n conditionBlock_1.$create();\r\n _$sa(td_1, ['class', 'scope_126c28ac']);\r\n _$sa(td_1, bindClassTd_1(_$state, year, row));\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n },\r\n\r\n $update: function(_$state, year, _$v, _$i, row) {\r\n conditionBlock_1 = _$cu(conditionBlock_1, condition_3, td_1, conditionAnchor_1, _$state, year, row);\r\n _$bu(td_1, bindClassTd_1(_$state, year, row));\r\n },\r\n\r\n $unmount: function() {\r\n _$a(td_1, conditionAnchor_1);\r\n conditionBlock_1.$mount(td_1, conditionAnchor_1);\r\n _$a(_$frag, td_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n conditionBlock_1.$destroy();\r\n _$frag = td_1 = conditionAnchor_1 = conditionBlock_1 = bindClassTd_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction itemLoop_2(_$state, row) {\r\n var _$frag, tr_1, loopAnchor_3_1, loopBlock_3;\r\n _$frag = _$d();\r\n loopBlock_3 = _$f(_$state, _$state.yearOfDecade(row), itemLoop_3, row);\r\n loopAnchor_3_1 = _$ct();\r\n return {\r\n $create: function() {\r\n tr_1 = _$ce('tr');\r\n loopBlock_3.$create();\r\n _$sa(tr_1, ['class', 'scope_126c28ac']);\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n },\r\n\r\n $update: function(_$state, row) {\r\n loopBlock_3.$update(_$state, _$state.yearOfDecade(row), row);\r\n },\r\n\r\n $unmount: function() {\r\n _$a(tr_1, loopAnchor_3_1);\r\n loopBlock_3.$mount(tr_1, loopAnchor_3_1);\r\n _$a(_$frag, tr_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n loopBlock_3.$destroy();\r\n _$frag = tr_1 = loopAnchor_3_1 = loopBlock_3 = void 0;\r\n }\r\n };\r\n}\r\nfunction ifCondition_2(_$state) {\r\n var _$frag, tbody_1, loopAnchor_2_1, loopBlock_2;\r\n _$frag = _$d();\r\n loopBlock_2 = _$f(_$state, [0, 1, 2], itemLoop_2);\r\n loopAnchor_2_1 = _$ct();\r\n return {\r\n type: 'if',\r\n\r\n $create: function() {\r\n tbody_1 = _$ce('tbody');\r\n loopBlock_2.$create();\r\n _$sa(tbody_1, ['class', 'scope_126c28ac']);\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n },\r\n\r\n $update: function(_$state) {\r\n loopBlock_2.$update(_$state, [0, 1, 2]);\r\n },\r\n\r\n $unmount: function() {\r\n _$a(tbody_1, loopAnchor_2_1);\r\n loopBlock_2.$mount(tbody_1, loopAnchor_2_1);\r\n _$a(_$frag, tbody_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n loopBlock_2.$destroy();\r\n _$frag = tbody_1 = loopAnchor_2_1 = loopBlock_2 = void 0;\r\n }\r\n };\r\n}\r\nfunction ifCondition_4(_$state, month, row) {\r\n var _$frag, a_1, txt_1, setTxt_1, bindClassA_1, clickEvent_1, handlerClickEvent_1;\r\n _$frag = _$d();\r\n setTxt_1 = function(_$state, month) {\r\n return month.month;\r\n };\r\n bindClassA_1 = function(_$state, month) {\r\n return ['class', ('scope_126c28ac ' + _$bc(_$state.itemState(month))).trim()];\r\n };\r\n clickEvent_1 = function(_$state, month) {\r\n _$state.selectMonth(month);\r\n };\r\n return {\r\n type: 'if',\r\n\r\n $create: function() {\r\n a_1 = _$ce('a');\r\n txt_1 = _$ct();\r\n txt_1.data = setTxt_1(_$state, month, row);\r\n _$sa(a_1, ['href', '#']);\r\n _$sa(a_1, ['class', 'scope_126c28ac']);\r\n _$sa(a_1, bindClassA_1(_$state, month, row));\r\n _$al(a_1, 'click', handlerClickEvent_1 = function(event) {\r\n event.preventDefault();\r\n clickEvent_1(_$state, month, row, event, a_1);\r\n });\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n },\r\n\r\n $update: function(_$state, month, row) {\r\n _$tu(txt_1, setTxt_1(_$state, month, row));\r\n _$bu(a_1, bindClassA_1(_$state, month, row));\r\n handlerClickEvent_1 = _$ul(a_1, 'click', handlerClickEvent_1, function(event) {\r\n event.preventDefault();\r\n clickEvent_1(_$state, month, row, event, a_1);\r\n });\r\n },\r\n\r\n $unmount: function() {\r\n _$a(a_1, txt_1);\r\n _$a(_$frag, a_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n _$rl(a_1, 'click', handlerClickEvent_1);\r\n _$frag = a_1 = txt_1 = setTxt_1 = bindClassA_1 = clickEvent_1 = handlerClickEvent_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction elseCondition_4() {\r\n var _$frag, template_1;\r\n _$frag = _$d();\r\n return {\r\n type: 'else',\r\n\r\n $create: function() {\r\n template_1 = _$d();\r\n template_1 = _$ce('template');\r\n template_1.innerHTML = '';\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n },\r\n\r\n $update: _$noop,\r\n\r\n $unmount: function() {\r\n _$a(_$frag, template_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n _$frag = template_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction condition_4(_$state, month, row) {\r\n if (!month.disabled)\r\n return ifCondition_4(_$state, month, row);\r\n else\r\n return elseCondition_4(_$state, month, row);\r\n}\r\nfunction itemLoop_5(_$state, month, _$v, _$i, row) {\r\n var _$frag, td_1, conditionAnchor_1, conditionBlock_1, bindClassTd_1;\r\n _$frag = _$d();\r\n conditionAnchor_1 = _$ct();\r\n bindClassTd_1 = function(_$state, month) {\r\n return ['class', ('scope_126c28ac ' + _$bc({\r\n disabled: month.disabled\r\n })).trim()];\r\n };\r\n return {\r\n $create: function() {\r\n td_1 = _$ce('td');\r\n conditionBlock_1 = condition_4(_$state, month, row);\r\n conditionBlock_1.$create();\r\n _$sa(td_1, ['class', 'scope_126c28ac']);\r\n _$sa(td_1, bindClassTd_1(_$state, month, row));\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n },\r\n\r\n $update: function(_$state, month, _$v, _$i, row) {\r\n conditionBlock_1 = _$cu(\r\n conditionBlock_1,\r\n condition_4,\r\n td_1,\r\n conditionAnchor_1,\r\n _$state,\r\n month,\r\n row\r\n );\r\n _$bu(td_1, bindClassTd_1(_$state, month, row));\r\n },\r\n\r\n $unmount: function() {\r\n _$a(td_1, conditionAnchor_1);\r\n conditionBlock_1.$mount(td_1, conditionAnchor_1);\r\n _$a(_$frag, td_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n conditionBlock_1.$destroy();\r\n _$frag = td_1 = conditionAnchor_1 = conditionBlock_1 = bindClassTd_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction itemLoop_4(_$state, row) {\r\n var _$frag, tr_1, loopAnchor_5_1, loopBlock_5;\r\n _$frag = _$d();\r\n loopBlock_5 = _$f(_$state, _$state.monthOfYear(row), itemLoop_5, row);\r\n loopAnchor_5_1 = _$ct();\r\n return {\r\n $create: function() {\r\n tr_1 = _$ce('tr');\r\n loopBlock_5.$create();\r\n _$sa(tr_1, ['class', 'scope_126c28ac']);\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n },\r\n\r\n $update: function(_$state, row) {\r\n loopBlock_5.$update(_$state, _$state.monthOfYear(row), row);\r\n },\r\n\r\n $unmount: function() {\r\n _$a(tr_1, loopAnchor_5_1);\r\n loopBlock_5.$mount(tr_1, loopAnchor_5_1);\r\n _$a(_$frag, tr_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n loopBlock_5.$destroy();\r\n _$frag = tr_1 = loopAnchor_5_1 = loopBlock_5 = void 0;\r\n }\r\n };\r\n}\r\nfunction elseIf_1_condition_2(_$state) {\r\n var _$frag, tbody_1, loopAnchor_4_1, loopBlock_4;\r\n _$frag = _$d();\r\n loopBlock_4 = _$f(_$state, [0, 1, 2], itemLoop_4);\r\n loopAnchor_4_1 = _$ct();\r\n return {\r\n type: 'elseIf_1',\r\n\r\n $create: function() {\r\n tbody_1 = _$ce('tbody');\r\n loopBlock_4.$create();\r\n _$sa(tbody_1, ['class', 'scope_126c28ac']);\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n },\r\n\r\n $update: function(_$state) {\r\n loopBlock_4.$update(_$state, [0, 1, 2]);\r\n },\r\n\r\n $unmount: function() {\r\n _$a(tbody_1, loopAnchor_4_1);\r\n loopBlock_4.$mount(tbody_1, loopAnchor_4_1);\r\n _$a(_$frag, tbody_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n loopBlock_4.$destroy();\r\n _$frag = tbody_1 = loopAnchor_4_1 = loopBlock_4 = void 0;\r\n }\r\n };\r\n}\r\nfunction ifCondition_5(_$state, day, week) {\r\n var _$frag, a_1, txt_1, setTxt_1, bindClassA_1, clickEvent_1, handlerClickEvent_1;\r\n _$frag = _$d();\r\n setTxt_1 = function(_$state, day) {\r\n return day.day < 10 ? '0' + day.day : day.day;\r\n };\r\n bindClassA_1 = function(_$state, day) {\r\n return ['class', ('scope_126c28ac ' + _$bc(_$state.itemState(day))).trim()];\r\n };\r\n clickEvent_1 = function(_$state, day) {\r\n _$state.selectDay(day);\r\n };\r\n return {\r\n type: 'if',\r\n\r\n $create: function() {\r\n a_1 = _$ce('a');\r\n txt_1 = _$ct();\r\n txt_1.data = setTxt_1(_$state, day, week);\r\n _$sa(a_1, ['href', '#']);\r\n _$sa(a_1, ['class', 'scope_126c28ac']);\r\n _$sa(a_1, bindClassA_1(_$state, day, week));\r\n _$al(a_1, 'click', handlerClickEvent_1 = function(event) {\r\n event.preventDefault();\r\n clickEvent_1(_$state, day, week, event, a_1);\r\n });\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n },\r\n\r\n $update: function(_$state, day, week) {\r\n _$tu(txt_1, setTxt_1(_$state, day, week));\r\n _$bu(a_1, bindClassA_1(_$state, day, week));\r\n handlerClickEvent_1 = _$ul(a_1, 'click', handlerClickEvent_1, function(event) {\r\n event.preventDefault();\r\n clickEvent_1(_$state, day, week, event, a_1);\r\n });\r\n },\r\n\r\n $unmount: function() {\r\n _$a(a_1, txt_1);\r\n _$a(_$frag, a_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n _$rl(a_1, 'click', handlerClickEvent_1);\r\n _$frag = a_1 = txt_1 = setTxt_1 = bindClassA_1 = clickEvent_1 = handlerClickEvent_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction elseCondition_5() {\r\n var _$frag, template_1;\r\n _$frag = _$d();\r\n return {\r\n type: 'else',\r\n\r\n $create: function() {\r\n template_1 = _$d();\r\n template_1 = _$ce('template');\r\n template_1.innerHTML = '';\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n },\r\n\r\n $update: _$noop,\r\n\r\n $unmount: function() {\r\n _$a(_$frag, template_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n _$frag = template_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction condition_5(_$state, day, week) {\r\n if (!day.disabled)\r\n return ifCondition_5(_$state, day, week);\r\n else\r\n return elseCondition_5(_$state, day, week);\r\n}\r\nfunction itemLoop_7(_$state, day, _$v, _$i, week) {\r\n var _$frag, td_1, conditionAnchor_1, conditionBlock_1, bindClassTd_1;\r\n _$frag = _$d();\r\n conditionAnchor_1 = _$ct();\r\n bindClassTd_1 = function(_$state, day) {\r\n return ['class', ('scope_126c28ac ' + _$bc({\r\n disabled: day.disabled\r\n })).trim()];\r\n };\r\n return {\r\n $create: function() {\r\n td_1 = _$ce('td');\r\n conditionBlock_1 = condition_5(_$state, day, week);\r\n conditionBlock_1.$create();\r\n _$sa(td_1, ['class', 'scope_126c28ac']);\r\n _$sa(td_1, bindClassTd_1(_$state, day, week));\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n },\r\n\r\n $update: function(_$state, day, _$v, _$i, week) {\r\n conditionBlock_1 = _$cu(conditionBlock_1, condition_5, td_1, conditionAnchor_1, _$state, day, week);\r\n _$bu(td_1, bindClassTd_1(_$state, day, week));\r\n },\r\n\r\n $unmount: function() {\r\n _$a(td_1, conditionAnchor_1);\r\n conditionBlock_1.$mount(td_1, conditionAnchor_1);\r\n _$a(_$frag, td_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n conditionBlock_1.$destroy();\r\n _$frag = td_1 = conditionAnchor_1 = conditionBlock_1 = bindClassTd_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction itemLoop_6(_$state, week) {\r\n var _$frag, tr_1, td_1, txt_1, setTxt_1, loopAnchor_7_1, loopBlock_7;\r\n _$frag = _$d();\r\n setTxt_1 = function(_$state, week) {\r\n return week.weekYear < 10 ? '0' + week.weekYear : week.weekYear;\r\n };\r\n loopBlock_7 = _$f(_$state, week.days, itemLoop_7, week);\r\n loopAnchor_7_1 = _$ct();\r\n return {\r\n $create: function() {\r\n tr_1 = _$ce('tr');\r\n td_1 = _$ce('td');\r\n txt_1 = _$ct();\r\n txt_1.data = setTxt_1(_$state, week);\r\n loopBlock_7.$create();\r\n _$sa(td_1, ['class', 'scope_126c28ac week']);\r\n _$sa(tr_1, ['class', 'scope_126c28ac']);\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n },\r\n\r\n $update: function(_$state, week) {\r\n _$tu(txt_1, setTxt_1(_$state, week));\r\n loopBlock_7.$update(_$state, week.days, week);\r\n },\r\n\r\n $unmount: function() {\r\n _$a(td_1, txt_1);\r\n _$a(tr_1, td_1);\r\n _$a(tr_1, loopAnchor_7_1);\r\n loopBlock_7.$mount(tr_1, loopAnchor_7_1);\r\n _$a(_$frag, tr_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n loopBlock_7.$destroy();\r\n _$frag = tr_1 = td_1 = txt_1 = setTxt_1 = loopAnchor_7_1 = loopBlock_7 = void 0;\r\n }\r\n };\r\n}\r\nfunction elseCondition_2(_$state) {\r\n var _$frag, tbody_1, loopAnchor_6_1, loopBlock_6;\r\n _$frag = _$d();\r\n loopBlock_6 = _$f(_$state, _$state.month, itemLoop_6);\r\n loopAnchor_6_1 = _$ct();\r\n return {\r\n type: 'else',\r\n\r\n $create: function() {\r\n tbody_1 = _$ce('tbody');\r\n loopBlock_6.$create();\r\n _$sa(tbody_1, ['class', 'scope_126c28ac']);\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n },\r\n\r\n $update: function(_$state) {\r\n loopBlock_6.$update(_$state, _$state.month);\r\n },\r\n\r\n $unmount: function() {\r\n _$a(tbody_1, loopAnchor_6_1);\r\n loopBlock_6.$mount(tbody_1, loopAnchor_6_1);\r\n _$a(_$frag, tbody_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n loopBlock_6.$destroy();\r\n _$frag = tbody_1 = loopAnchor_6_1 = loopBlock_6 = void 0;\r\n }\r\n };\r\n}\r\nfunction condition_2(_$state) {\r\n if (_$state.view === 'years')\r\n return ifCondition_2(_$state);\r\n else if (_$state.view === 'months')\r\n return elseIf_1_condition_2(_$state);\r\n else\r\n return elseCondition_2(_$state);\r\n}\r\nfunction _$tplCalendar(_$state) {\r\n var _$frag, div_1, div_2, a_1, txt_1, clickEvent_1, handlerClickEvent_1, a_2, txt_2, setTxt_2, clickEvent_2, handlerClickEvent_2, a_3, txt_3, clickEvent_3, handlerClickEvent_3, a_4, txt_4, clickEvent_4, handlerClickEvent_4, table_1, conditionAnchor_1, conditionBlock_1, conditionAnchor_2, conditionBlock_2, bindClassTable_1, displayDiv_1, bindClassDiv_1;\r\n _$frag = _$d();\r\n clickEvent_1 = function(_$state) {\r\n _$state.prev();\r\n };\r\n setTxt_2 = function(_$state) {\r\n return _$state.viewLabel;\r\n };\r\n clickEvent_2 = function(_$state) {\r\n _$state.selectView();\r\n };\r\n clickEvent_3 = function(_$state) {\r\n _$state.resetDate();\r\n };\r\n clickEvent_4 = function(_$state) {\r\n _$state.next();\r\n };\r\n conditionAnchor_1 = _$ct();\r\n conditionAnchor_2 = _$ct();\r\n bindClassTable_1 = function(_$state) {\r\n return ['class', ('scope_126c28ac ' + _$bc(['calendar-view', {\r\n months: _$state.view === 'months',\r\n years: _$state.view === 'years'\r\n }])).trim()];\r\n };\r\n var showDiv_1 = function(_$state, el, display) {\r\n el.style.display = _$state.visibility ? display : 'none';\r\n };\r\n bindClassDiv_1 = function(_$state) {\r\n return [\r\n 'class',\r\n ('scope_126c28ac ' + _$bc(['panel calendar', _$state.place])).trim()\r\n ];\r\n };\r\n return {\r\n $create: function() {\r\n div_1 = _$ce();\r\n div_2 = _$ce();\r\n a_1 = _$ce('a');\r\n txt_1 = _$ct('«');\r\n a_2 = _$ce('a');\r\n txt_2 = _$ct();\r\n txt_2.data = setTxt_2(_$state);\r\n a_3 = _$ce('a');\r\n txt_3 = _$ct(' ⎌');\r\n a_4 = _$ce('a');\r\n txt_4 = _$ct('»');\r\n table_1 = _$ce('table');\r\n conditionBlock_1 = condition_1(_$state);\r\n conditionBlock_1.$create();\r\n conditionBlock_2 = condition_2(_$state);\r\n conditionBlock_2.$create();\r\n _$sa(a_1, ['href', '#']);\r\n _$sa(a_1, ['class', 'scope_126c28ac backward']);\r\n _$al(a_1, 'click', handlerClickEvent_1 = function(event) {\r\n event.preventDefault();\r\n clickEvent_1(_$state, event, a_1);\r\n });\r\n _$sa(a_2, ['href', '#']);\r\n _$sa(a_2, ['class', 'scope_126c28ac month']);\r\n _$al(a_2, 'click', handlerClickEvent_2 = function(event) {\r\n event.preventDefault();\r\n clickEvent_2(_$state, event, a_2);\r\n });\r\n _$sa(a_3, ['href', '#']);\r\n _$sa(a_3, ['class', 'scope_126c28ac today']);\r\n _$al(a_3, 'click', handlerClickEvent_3 = function(event) {\r\n event.preventDefault();\r\n clickEvent_3(_$state, event, a_3);\r\n });\r\n _$sa(a_4, ['href', '#']);\r\n _$sa(a_4, ['class', 'scope_126c28ac forward']);\r\n _$al(a_4, 'click', handlerClickEvent_4 = function(event) {\r\n event.preventDefault();\r\n clickEvent_4(_$state, event, a_4);\r\n });\r\n _$sa(div_2, ['class', 'scope_126c28ac panel-heading calendar-actions']);\r\n _$sa(table_1, ['class', 'scope_126c28ac']);\r\n _$sa(table_1, bindClassTable_1(_$state));\r\n _$sa(div_1, ['class', 'scope_126c28ac']);\r\n displayDiv_1 = div_1.style.display;\r\n showDiv_1(_$state, div_1, displayDiv_1);\r\n _$sa(div_1, bindClassDiv_1(_$state));\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$is(\r\n 'scope_126c28ac',\r\n 'table.scope_126c28ac{border-spacing:0;border-collapse:collapse;}.scope_126c28ac.panel.calendar{width:266px;}.scope_126c28ac.panel-heading.calendar-actions,tr.scope_126c28ac th.scope_126c28ac,tr.scope_126c28ac td.scope_126c28ac{text-align:center;}.scope_126c28ac.panel-heading.calendar-actions{position:relative;}.scope_126c28ac.panel-heading.calendar-actions .scope_126c28ac.forward{float:right;}.scope_126c28ac.panel-heading.calendar-actions .scope_126c28ac.backward{float:left;}.scope_126c28ac.panel-heading.calendar-actions .scope_126c28ac.today{right:50px;position:absolute;}.scope_126c28ac.calendar-view,tr.scope_126c28ac th.scope_126c28ac,tr.scope_126c28ac td.scope_126c28ac{border:1px solid #000;}tr.scope_126c28ac th.scope_126c28ac{padding:1px 3px;color:#fff;background-color:#000;border-bottom:2px solid #000;}tr.scope_126c28ac th.scope_126c28ac,tr.scope_126c28ac td.scope_126c28ac{cursor:pointer;}tr.scope_126c28ac td.scope_126c28ac{padding:4px 8px;}tr.scope_126c28ac td.scope_126c28ac:first-child,tr.scope_126c28ac td.disabled.scope_126c28ac{cursor:default;}tr.scope_126c28ac td.scope_126c28ac:first-child,tr.scope_126c28ac td.disabled.scope_126c28ac,td.scope_126c28ac a.active.scope_126c28ac,td.scope_126c28ac a.scope_126c28ac:hover{background-color:#a5a5a5;}td.scope_126c28ac a.scope_126c28ac{color:#000;display:table-cell;text-decoration:none;background-color:#fff;}td.scope_126c28ac a.selected.scope_126c28ac{color:#e9e9e9;background-color:#3b3b3b;}'\r\n );\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n this.$siblingEl = _$(sibling);\r\n this.$parentEl = sibling && _$(sibling).parentElement || _$(parent);\r\n },\r\n\r\n $update: function(_$state) {\r\n _$tu(txt_2, setTxt_2(_$state));\r\n conditionBlock_1 = _$cu(conditionBlock_1, condition_1, table_1, conditionAnchor_1, _$state);\r\n conditionBlock_2 = _$cu(conditionBlock_2, condition_2, table_1, conditionAnchor_2, _$state);\r\n _$bu(table_1, bindClassTable_1(_$state));\r\n showDiv_1(_$state, div_1, displayDiv_1);\r\n _$bu(div_1, bindClassDiv_1(_$state));\r\n },\r\n\r\n $unmount: function() {\r\n _$a(a_1, txt_1);\r\n _$a(div_2, a_1);\r\n _$a(a_2, txt_2);\r\n _$a(div_2, a_2);\r\n _$a(a_3, txt_3);\r\n _$a(div_2, a_3);\r\n _$a(a_4, txt_4);\r\n _$a(div_2, a_4);\r\n _$a(div_1, div_2);\r\n _$a(table_1, conditionAnchor_1);\r\n conditionBlock_1.$mount(table_1, conditionAnchor_1);\r\n _$a(table_1, conditionAnchor_2);\r\n conditionBlock_2.$mount(table_1, conditionAnchor_2);\r\n _$a(div_1, table_1);\r\n _$a(_$frag, div_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n this.$parent = null;\r\n this.$parentEl = null;\r\n this.$siblingEl = null;\r\n this.$children.splice(0, this.$children.length);\r\n _$ds('scope_126c28ac');\r\n _$rl(a_1, 'click', handlerClickEvent_1);\r\n _$rl(a_2, 'click', handlerClickEvent_2);\r\n _$rl(a_3, 'click', handlerClickEvent_3);\r\n _$rl(a_4, 'click', handlerClickEvent_4);\r\n conditionBlock_1.$destroy();\r\n conditionBlock_2.$destroy();\r\n delete _$state.$root;\r\n _$frag = div_1 = div_2 = a_1 = txt_1 = clickEvent_1 = handlerClickEvent_1 = a_2 = txt_2 = setTxt_2 = clickEvent_2 = handlerClickEvent_2 = a_3 = txt_3 = clickEvent_3 = handlerClickEvent_3 = a_4 = txt_4 = clickEvent_4 = handlerClickEvent_4 = table_1 = conditionAnchor_1 = conditionBlock_1 = conditionAnchor_2 = conditionBlock_2 = bindClassTable_1 = displayDiv_1 = bindClassDiv_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction Calendar(_$attrs, _$parent) {\r\n _$CompCtr.call(this, _$attrs, _$tplCalendar, calendar, _$parent);\r\n !_$parent && this.$create();\r\n}\r\n_$extends(Calendar, _$CompCtr);\r\n/* harmony default export */ var components_calendar = (Calendar);\r\n\n// CONCATENATED MODULE: ./main.ts\n\r\nvar main_calendar = new components_calendar();\r\nmain_calendar.$mount('main');\r\n\n\n//# sourceURL=webpack:///./main.ts_+_3_modules?"); /***/ }) diff --git a/examples/clock/dist/js/clock.js b/examples/clock/dist/js/clock.js index 396515c..cea2b43 100644 --- a/examples/clock/dist/js/clock.js +++ b/examples/clock/dist/js/clock.js @@ -94,7 +94,7 @@ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("\n// CONCATENATED MODULE: d:/DEVELOP/Work in Progress/trebor-repos/trebor/tools/index.js\nvar _$assign = Object['assign'] || function (t) {\r\n for (var s = void 0, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s)\r\n if (_$hasProp(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n};\r\nfunction _$CompCtr(attrs, template, options, parent) {\r\n var self = this;\r\n var props = ['$slots', '$refs', '$filters', '$directives', '_events', '_watchers'];\r\n var _$set = function (prop, value) { _$def(self, prop, { value: value, writable: true }); };\r\n if (!attrs)\r\n attrs = {};\r\n _$e(props, function (prop) { _$def(self, prop, { value: {} }); });\r\n _$set('$parent', parent || null);\r\n _$set('$children', []);\r\n _$set('_subscribers', {});\r\n _$set('$options', options);\r\n var opts = self.$options;\r\n if (!opts.attrs)\r\n opts.attrs = {};\r\n if (!opts.children)\r\n opts.children = {};\r\n _$e(_$CompCtr['_plugins'], function (plugin) {\r\n plugin.fn.call(self, _$CompCtr, plugin.options);\r\n });\r\n if (opts.filters)\r\n _$assign(self.$filters, opts.filters);\r\n if (opts.directives)\r\n _$e(opts.directives, function (drt, k) { self.$directives[k] = _$drt(drt); });\r\n _$e(opts.attrs, function (attrOps, key) {\r\n _$def(self, (_$isType(key, 'number') ? attrOps : key), {\r\n get: function () {\r\n if (_$isType(attrOps, 'string')) {\r\n var value = attrs[attrOps];\r\n return _$isType(value, 'function') ? value() : value;\r\n }\r\n else {\r\n if (!_$hasProp(attrs, key) && attrOps.required) {\r\n console.error(\"Attribute '\" + key + \"' must be present because it's required.\");\r\n }\r\n else {\r\n var value = _$isType(attrs[key], 'function') ? attrs[key]() : attrs[key];\r\n if (value === void 0 && _$hasProp(attrOps, 'default')) {\r\n var def = attrOps.default;\r\n value = _$isType(def, 'function') ? def() : def;\r\n }\r\n var typ = attrOps.type;\r\n if (typ && !_$isType(value, typ) && attrOps.required) {\r\n return console.error(\"Attribute '\" + key + \"' must be type '\" + typ + \"'.\");\r\n }\r\n return _$toType(value, value === void 0 ? 'undefined' : typ, self, key);\r\n }\r\n }\r\n },\r\n set: function () {\r\n console.error(\"Can not modify attribute '\" + key + \"' because attributes al read only.\");\r\n },\r\n enumerable: true, configurable: true\r\n });\r\n });\r\n var data = opts.model || {};\r\n var _loop_1 = function (key) {\r\n if (_$hasProp(data, key)) {\r\n var desc = Object.getOwnPropertyDescriptor(data, key);\r\n if (desc.value && _$isArray(desc.value)) {\r\n desc.value = new _$List(desc.value, self, key);\r\n }\r\n else {\r\n if (desc.get) {\r\n var getter_1 = desc.get;\r\n desc.get = function () {\r\n var value = getter_1.call(self);\r\n if (_$isArray(value))\r\n value = new _$List(value, self, key);\r\n return value;\r\n };\r\n }\r\n if (desc.set) {\r\n var setter_1 = desc.set;\r\n desc.set = function (v) {\r\n if (_$isArray(v))\r\n v = new _$List(v, self, key);\r\n setter_1.call(self, v);\r\n };\r\n }\r\n }\r\n _$def(self, key, desc);\r\n }\r\n };\r\n for (var key in data) {\r\n _loop_1(key);\r\n }\r\n var tpl = template(self, opts.children);\r\n _$e(tpl, function (value, key) {\r\n _$def(self, key, {\r\n value: (function (key) {\r\n var hook = key[1].toUpperCase() + key.slice(2);\r\n var bhook = opts[\"before\" + hook];\r\n var ahook = opts[\"after\" + hook];\r\n return function () {\r\n bhook && bhook.call(this);\r\n key.slice(1) === 'update' ? value.call(this, this) : value.apply(this, arguments);\r\n ahook && ahook.call(this);\r\n };\r\n })(key)\r\n });\r\n });\r\n _$def(self, '$data', {\r\n get: function () {\r\n return _$toPlainObj(this);\r\n }\r\n });\r\n}\r\nfunction _$plugin(fn, options) {\r\n _$CompCtr['_plugins'] = _$CompCtr['_plugins'] || [];\r\n _$CompCtr['_plugins'].push({ options: options, fn: fn });\r\n}\r\n_$assign(_$CompCtr.prototype, {\r\n $get: function (path) {\r\n return _$accesor(this, path);\r\n },\r\n $set: function (path, value) {\r\n _$accesor(this, path, value);\r\n },\r\n $on: function (event, handler) {\r\n var _this = this;\r\n if (!this._events[event]) {\r\n this._events[event] = [];\r\n }\r\n var i = this._events[event].push(handler);\r\n return {\r\n $off: function () {\r\n _this._events[event].splice(i - 1, 1);\r\n }\r\n };\r\n },\r\n $once: function (event, handler) {\r\n var e = this.$on(event, function (args) {\r\n handler(args);\r\n e.$off();\r\n });\r\n },\r\n $fire: function (event, data) {\r\n if (this._events[event]) {\r\n _$e(this._events[event], function (handler) { handler(data); });\r\n }\r\n },\r\n $notify: function (key) {\r\n if (this._subscribers[key]) {\r\n _$e(this._subscribers[key], function (suscriber) { suscriber(); });\r\n }\r\n },\r\n $observe: function (deps, listener) {\r\n var _this = this;\r\n var subs = [];\r\n if (_$isArray(deps)) {\r\n _$e(deps, function (dep) {\r\n subs.push({ sub: dep, i: _$subs.call(_this, dep, listener) });\r\n });\r\n }\r\n else {\r\n subs.push({ sub: deps, i: _$subs.call(this, deps, listener) });\r\n }\r\n return {\r\n $unobserve: function () {\r\n _$e(subs, function (sub) {\r\n _this._subscribers[sub.sub].splice(sub.i, 1);\r\n });\r\n }\r\n };\r\n },\r\n $watch: function (key, watcher) {\r\n var _this = this;\r\n if (!this._watchers[key]) {\r\n this._watchers[key] = [];\r\n }\r\n var i = this._watchers[key].push(watcher.bind(this));\r\n return {\r\n $unwatch: function () {\r\n _this._watchers[key].splice(i - 1, 1);\r\n }\r\n };\r\n }\r\n});\r\nvar array = Array.prototype;\r\nfunction _$toArgs(args, start) {\r\n if (start === void 0) { start = 0; }\r\n return array.slice.call(args, start);\r\n}\r\nfunction _$arrayValues(list, value, root, key) {\r\n array.push.apply(list, value.map(function (v, i) {\r\n if (list.length !== 0)\r\n i += list.length;\r\n return !(_$isType(v, _$List)) && _$isArray(v) ? new _$List(v, root, key + \".\" + i) : v;\r\n }));\r\n}\r\nfunction _$List(value, root, key) {\r\n var self = this;\r\n Array.apply(self, [value.length]);\r\n var desc = { writable: false, configurable: false, enumerable: false };\r\n _$def(self, '_key', _$assign({ value: key }, desc));\r\n _$def(self, '_root', _$assign({ value: root }, desc));\r\n _$arrayValues(self, value, root, key);\r\n desc.writable = true;\r\n _$def(self, 'length', _$assign({ value: self.length }, desc));\r\n}\r\n_$List.prototype = Object.create(array);\r\n_$List.prototype.constructor = _$List;\r\n['pop', 'push', 'reverse', 'shift', 'sort', 'fill', 'unshift', 'splice'].forEach(function (method) {\r\n _$List.prototype[method] = function () {\r\n var self = this;\r\n var old = self.slice();\r\n var result;\r\n if (method === 'push') {\r\n _$arrayValues(self, _$toArgs(arguments), self._root, self._key);\r\n result = self.length;\r\n }\r\n else {\r\n result = array[method].apply(self, arguments);\r\n }\r\n _$dispatch(self._root, self._key, old, self.slice());\r\n return result;\r\n };\r\n});\r\n_$List.prototype.pull = function (index) {\r\n var self = this;\r\n var items = _$toArgs(arguments, 1);\r\n var length = self.length;\r\n if (index > length) {\r\n length = index + 1;\r\n var pull = new Array(index - self.length);\r\n pull.push.apply(pull, items);\r\n for (var i = 0; i < length; i++) {\r\n if (i === index) {\r\n self.push.apply(self, pull);\r\n }\r\n }\r\n }\r\n else {\r\n self.splice.apply(self, [index, 1].concat(items));\r\n }\r\n};\r\nfunction _$dispatch(root, key, oldVal, value) {\r\n root.$notify(key);\r\n if (root._watchers[key]) {\r\n _$e(root._watchers[key], function (watcher) { watcher(oldVal, value); });\r\n }\r\n root.$update();\r\n}\r\nfunction _$isType(value, type) {\r\n return _$type(type) === 'string' ? type.split('\\|').some(function (t) { return t.trim() === _$type(value); }) : value instanceof type;\r\n}\r\nfunction _$isObject(obj) {\r\n return _$isType(obj, 'object');\r\n}\r\nfunction _$isArray(obj) {\r\n return Array.isArray ? Array.isArray(obj) : _$isType(obj, 'array');\r\n}\r\nfunction _$toType(value, type, root, key) {\r\n switch (type) {\r\n case 'date':\r\n return new Date(value);\r\n case 'string':\r\n return value.toString();\r\n case 'number':\r\n return +value;\r\n case 'boolean':\r\n return !!value;\r\n case 'array':\r\n return _$isType(value, _$List) ? value : new _$List(value, root, key);\r\n default:\r\n return value;\r\n }\r\n}\r\nfunction _$type(obj) {\r\n return /\\[object (\\w+)\\]/.exec(Object.prototype.toString.call(obj))[1].toLowerCase();\r\n}\r\nfunction _$hasProp(obj, prop) {\r\n return obj.hasOwnProperty(prop);\r\n}\r\nfunction _$drt(directive) {\r\n var hasProp = function (prop, instance, options, element) { return _$isObject(directive) && directive[prop] && directive[prop](instance, options, element); };\r\n return {\r\n $init: function (instance, options, element) {\r\n hasProp('$init', instance, options, element);\r\n },\r\n $inserted: function (instance, options, element) {\r\n hasProp('$inserted', instance, options, element);\r\n },\r\n $update: function (instance, options, element) {\r\n if (_$isType(directive, 'function')) {\r\n directive(instance, options, element);\r\n }\r\n else {\r\n hasProp('$update', instance, options, element);\r\n }\r\n },\r\n $destroy: function (instance, options, element) {\r\n hasProp('$destroy', instance, options, element);\r\n }\r\n };\r\n}\r\nfunction _$noop() { }\r\nfunction _$add(inst, child) {\r\n inst.$children.push(child);\r\n}\r\nfunction _$remove(inst, child) {\r\n var index = inst.$children.indexOf(child);\r\n index >= 0 && inst.$children.splice(index, 1);\r\n}\r\nfunction _$toStr(obj) {\r\n var str = _$type(obj);\r\n return !/null|undefined/.test(str) ? obj.toString() : str;\r\n}\r\nfunction _$toPlainObj(obj) {\r\n var data = {};\r\n _$e(_$isObject(obj) ? obj : {}, function (_v, k) {\r\n if (k[0] !== '$' && !_$isType(obj[k], 'function')) {\r\n if (_$isType(obj[k], _$List)) {\r\n data[k] = obj[k].map(_$toPlainObj);\r\n }\r\n else if (_$isObject(obj[k])) {\r\n data[k] = _$toPlainObj(obj[k]);\r\n }\r\n else {\r\n data[k] = obj[k];\r\n }\r\n }\r\n });\r\n return _$isObject(obj) ? data : obj;\r\n}\r\nfunction _$setRef(obj, prop) {\r\n var value = [];\r\n _$def(obj, prop, {\r\n get: function () {\r\n return value.length <= 1 ? value[0] : value;\r\n },\r\n set: function (val) {\r\n if (val && !~value.indexOf(val)) {\r\n value.push(val);\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n}\r\nfunction _$accesor(object, path, value) {\r\n return path.split('.').reduce(function (obj, key, i, arr) {\r\n if (_$isType(value, 'undefined')) {\r\n if (obj == null) {\r\n arr.splice(0, arr.length);\r\n return i > 0 && obj === null ? obj : undefined;\r\n }\r\n }\r\n else {\r\n if (i === arr.length - 1) {\r\n if (_$isType(obj, _$List) && (+key).toString() === key) {\r\n obj.pull(+key, value);\r\n }\r\n else {\r\n var oldVal = obj[key];\r\n obj[key] = !_$isType(value, _$List) && _$isArray(value) ? new _$List(value, object, key) : value;\r\n _$dispatch(object, path, oldVal, obj[key]);\r\n }\r\n }\r\n else if (!_$isObject(obj[key])) {\r\n obj[key] = {};\r\n }\r\n }\r\n return obj ? obj[key] : null;\r\n }, object);\r\n}\r\nfunction _$emptyElse() {\r\n return { type: 'empty-else', $create: _$noop, $mount: _$noop, $update: _$noop, $destroy: _$noop };\r\n}\r\nfunction _$subs(dep, listener) {\r\n if (!this._subscribers[dep]) {\r\n this._subscribers[dep] = [];\r\n }\r\n return this._subscribers[dep].push(listener.bind(this)) - 1;\r\n}\r\nfunction _$def(obj, key, desc) {\r\n Object.defineProperty(obj, key, desc);\r\n}\r\nfunction _$isKey(event, key) {\r\n return event.key.toLowerCase() === key || !!event[key + \"Key\"];\r\n}\r\nfunction _$bindGroup(input, selection) {\r\n var _$index = selection.indexOf(input.value);\r\n if (input.checked && !~_$index)\r\n selection.push(input.value);\r\n else\r\n selection.splice(_$index, 1);\r\n}\r\nfunction _$(selector, parent) {\r\n return _$isType(selector, 'string') ? (parent || document).querySelector(selector) : selector;\r\n}\r\nfunction _$d() {\r\n return document.createDocumentFragment();\r\n}\r\nfunction _$a(parent, child, sibling) {\r\n if (_$isType(sibling, 'boolean') && sibling)\r\n parent.parentElement.replaceChild(child, parent);\r\n else if (!sibling)\r\n parent.appendChild(child);\r\n else\r\n parent.insertBefore(child, sibling);\r\n}\r\nfunction _$as(source, dest) {\r\n var childNodes = source.childNodes;\r\n var attributes = source.attributes;\r\n for (var i = 0; i < childNodes.length; i++) {\r\n _$a(dest, childNodes[i]);\r\n }\r\n for (var i = 0; i < attributes.length; i++) {\r\n var attr = attributes[i];\r\n dest.setAttributeNS(source.namespaceURI, attr.name, attr.value);\r\n }\r\n source.parentElement.replaceChild(dest, source);\r\n return dest;\r\n}\r\nfunction _$r(el, parent) {\r\n var root = parent || el.parentElement;\r\n if (root)\r\n root.removeChild(el);\r\n}\r\nfunction _$ce(tagName) {\r\n return document.createElement(tagName || 'div');\r\n}\r\nfunction _$cse(tagName) {\r\n return document.createElementNS('http://www.w3.org/2000/svg', tagName || 'svg');\r\n}\r\nfunction _$ct(content) {\r\n return document.createTextNode(content || '');\r\n}\r\nfunction _$cm(content) {\r\n return document.createComment(content || '');\r\n}\r\nfunction _$sa(el, attr, value) {\r\n el.setAttribute(attr, value);\r\n}\r\nfunction _$ga(el, attr) {\r\n return el.getAttribute(attr);\r\n}\r\nfunction _$al(el, event, handler) {\r\n el.addEventListener(event, handler, false);\r\n}\r\nfunction _$ul(el, event, oldHandler, newHandler) {\r\n _$rl(el, event, oldHandler);\r\n _$al(el, event, oldHandler = newHandler);\r\n return oldHandler;\r\n}\r\nfunction _$rl(el, event, handler) {\r\n el.removeEventListener(event, handler, false);\r\n}\r\nfunction _$bc(value) {\r\n var classes = '';\r\n if (_$isType(value, 'string')) {\r\n classes += \" \" + value;\r\n }\r\n else if (_$isArray(value)) {\r\n classes = value.map(_$bc).join(' ');\r\n }\r\n else if (_$isObject(value)) {\r\n for (var key in value)\r\n if (_$hasProp(value, key) && value[key])\r\n classes += \" \" + key;\r\n }\r\n return classes.trim();\r\n}\r\nfunction _$bs(value) {\r\n var el = _$ce();\r\n if (_$isObject(value)) {\r\n var style_1 = el.style;\r\n _$e(value, function (val, prop) {\r\n if (val !== style_1[prop]) {\r\n style_1[prop] = val;\r\n }\r\n });\r\n return style_1.cssText;\r\n }\r\n else if (_$isType(value, 'string')) {\r\n return value;\r\n }\r\n else {\r\n return '';\r\n }\r\n}\r\nfunction _$f(root, obj, loop) {\r\n var items = {}, loopParent, loopSibling;\r\n var globs = _$toArgs(arguments, 3);\r\n _$e(obj, function (item, i) { items[i] = loop.apply(null, [root, item, i].concat(globs)); });\r\n return {\r\n $create: function () {\r\n _$e(items, function (item) { item.$create(); });\r\n },\r\n $mount: function (parent, sibling) {\r\n loopParent = _$(parent);\r\n loopSibling = _$(sibling);\r\n _$e(items, function (item) { item.$mount(loopParent, loopSibling); });\r\n },\r\n $update: function (root, obj) {\r\n var globs = _$toArgs(arguments, 2);\r\n _$e(items, function (item, i) {\r\n if (obj[i]) {\r\n item.$update.apply(item, [root, obj[i], i].concat(globs));\r\n }\r\n else {\r\n item.$destroy();\r\n delete items[i];\r\n }\r\n });\r\n _$e(obj, function (item, i) {\r\n if (!items[i]) {\r\n items[i] = loop.apply(null, [root, item, i].concat(globs));\r\n items[i].$create();\r\n items[i].$mount(loopParent, loopSibling);\r\n }\r\n });\r\n },\r\n $destroy: function () {\r\n _$e(items, function (item) { item.$destroy(); });\r\n }\r\n };\r\n}\r\nfunction _$e(obj, cb) {\r\n for (var key in obj) {\r\n if (_$hasProp(obj, key)) {\r\n cb(obj[key], (isNaN(+key) ? key : +key));\r\n }\r\n }\r\n}\r\nfunction _$is(id, css) {\r\n var isNew = false;\r\n var style = _$(\"#\" + id, document.head);\r\n if (!style) {\r\n isNew = true;\r\n style = _$ce('style');\r\n style.id = id;\r\n _$sa(style, 'refs', '1');\r\n }\r\n if (style.textContent !== css) {\r\n style.textContent = css;\r\n }\r\n if (isNew) {\r\n _$a(document.head, style);\r\n }\r\n else {\r\n var count = +_$ga(style, 'refs');\r\n _$sa(style, 'refs', (++count).toString());\r\n }\r\n}\r\nfunction _$ds(id) {\r\n var style = _$(\"#\" + id, document.head);\r\n if (style) {\r\n var count = +_$ga(style, 'refs');\r\n if (--count === 0) {\r\n _$r(style, document.head);\r\n }\r\n else {\r\n _$sa(style, 'refs', count.toString());\r\n }\r\n }\r\n}\r\n//# sourceMappingURL=index.js.map\n// CONCATENATED MODULE: ./components/clock.ts\n/* harmony default export */ var clock = ({\r\n afterMount: function () {\r\n var _this = this;\r\n this.interval = setInterval(function () {\r\n _this.$set('time', new Date());\r\n }, 1000);\r\n },\r\n beforeDestroy: function () {\r\n clearInterval(this.interval);\r\n },\r\n model: {\r\n interval: null,\r\n time: new Date(),\r\n get hours() {\r\n return this.time.getHours();\r\n },\r\n get minutes() {\r\n return this.time.getMinutes();\r\n },\r\n get seconds() {\r\n return this.time.getSeconds();\r\n }\r\n }\r\n});\r\n\n// CONCATENATED MODULE: ./components/clock.html\n\n\nfunction itemLoop_2(_$state, offset, _$index, minute) {\n var _$frag, line_1, bindTransformLine_1;\n _$frag = _$d();\n bindTransformLine_1 = function (_$state, offset, minute) {\n return 'rotate(' + 6 * (minute + offset) + ')';\n };\n return {\n $create: function () {\n line_1 = _$cse('line');\n this.$hydrate();\n },\n $hydrate: function () {\n _$sa(line_1, 'transform', _$toStr(bindTransformLine_1(_$state, offset, minute, _$index)));\n _$sa(line_1, 'class', 'scope_735eee30 minor');\n _$sa(line_1, 'y1', '42');\n _$sa(line_1, 'y2', '45');\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$a(_$(parent), _$frag, _$(sibling));\n },\n $update: function (_$state, offset, _$index, minute) {\n var updateTransformLine_1 = _$toStr(bindTransformLine_1(_$state, offset, minute, _$index));\n if (_$ga(line_1, 'transform') !== updateTransformLine_1) {\n _$sa(line_1, 'transform', updateTransformLine_1);\n }\n updateTransformLine_1 = void 0;\n },\n $unmount: function () {\n _$a(_$frag, line_1);\n },\n $destroy: function () {\n this.$unmount();\n _$frag = line_1 = bindTransformLine_1 = void 0;\n }\n };\n}\nfunction itemLoop_1(_$state, minute) {\n var _$frag, template_1, comment_1, line_1, bindTransformLine_1, loopAnchor_2_1, loopBlock_2;\n _$frag = _$d();\n bindTransformLine_1 = function (_$state, minute) {\n return 'rotate(' + 30 * minute + ')';\n };\n loopBlock_2 = _$f(_$state, [\n 1,\n 2,\n 3,\n 4\n ], itemLoop_2, minute);\n loopAnchor_2_1 = _$ct();\n return {\n $create: function () {\n template_1 = _$d();\n comment_1 = _$cm('');\n line_1 = _$cse('line');\n loopBlock_2.$create();\n this.$hydrate();\n },\n $hydrate: function () {\n _$sa(line_1, 'transform', _$toStr(bindTransformLine_1(_$state, minute)));\n _$sa(line_1, 'class', 'scope_735eee30 major');\n _$sa(line_1, 'y1', '35');\n _$sa(line_1, 'y2', '45');\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$a(_$(parent), _$frag, _$(sibling));\n },\n $update: function (_$state, minute) {\n var updateTransformLine_1 = _$toStr(bindTransformLine_1(_$state, minute));\n if (_$ga(line_1, 'transform') !== updateTransformLine_1) {\n _$sa(line_1, 'transform', updateTransformLine_1);\n }\n updateTransformLine_1 = void 0;\n loopBlock_2.$update(_$state, [\n 1,\n 2,\n 3,\n 4\n ], minute);\n },\n $unmount: function () {\n _$a(template_1, comment_1);\n _$a(template_1, line_1);\n _$a(template_1, loopAnchor_2_1);\n loopBlock_2.$mount(template_1, loopAnchor_2_1);\n _$a(_$frag, template_1);\n },\n $destroy: function () {\n this.$unmount();\n loopBlock_2.$destroy();\n _$frag = template_1 = comment_1 = line_1 = bindTransformLine_1 = loopAnchor_2_1 = loopBlock_2 = void 0;\n }\n };\n}\nfunction _$tplClock(_$state) {\n var _$frag, svg_1, circle_1, loopAnchor_1_1, loopBlock_1, comment_1, line_1, bindTransformLine_1, comment_2, line_2, bindTransformLine_2, comment_3, g_1, line_3, line_4, bindTransformG_1;\n _$frag = _$d();\n loopBlock_1 = _$f(_$state, [\n 0,\n 5,\n 10,\n 15,\n 20,\n 25,\n 30,\n 35,\n 40,\n 45,\n 50,\n 55\n ], itemLoop_1);\n loopAnchor_1_1 = _$ct();\n bindTransformLine_1 = function (_$state) {\n return 'rotate(' + (30 * _$state.hours + _$state.minutes / 2) + ')';\n };\n bindTransformLine_2 = function (_$state) {\n return 'rotate(' + (6 * _$state.minutes + _$state.seconds / 10) + ')';\n };\n bindTransformG_1 = function (_$state) {\n return 'rotate(' + 6 * _$state.seconds + ')';\n };\n return {\n $create: function () {\n svg_1 = _$cse();\n circle_1 = _$cse('circle');\n loopBlock_1.$create();\n comment_1 = _$cm('');\n line_1 = _$cse('line');\n comment_2 = _$cm('');\n line_2 = _$cse('line');\n comment_3 = _$cm('');\n g_1 = _$cse('g');\n line_3 = _$cse('line');\n line_4 = _$cse('line');\n this.$hydrate();\n },\n $hydrate: function () {\n _$sa(circle_1, 'class', 'scope_735eee30 clock-face');\n _$sa(circle_1, 'r', '48');\n _$sa(line_1, 'transform', _$toStr(bindTransformLine_1(_$state)));\n _$sa(line_1, 'class', 'scope_735eee30 hour');\n _$sa(line_1, 'y1', '2');\n _$sa(line_1, 'y2', '-20');\n _$sa(line_2, 'transform', _$toStr(bindTransformLine_2(_$state)));\n _$sa(line_2, 'class', 'scope_735eee30 minute');\n _$sa(line_2, 'y1', '4');\n _$sa(line_2, 'y2', '-30');\n _$sa(line_3, 'class', 'scope_735eee30 second');\n _$sa(line_3, 'y1', '10');\n _$sa(line_3, 'y2', '-38');\n _$sa(line_4, 'class', 'scope_735eee30 second-counterweight');\n _$sa(line_4, 'y1', '10');\n _$sa(line_4, 'y2', '2');\n _$sa(g_1, 'transform', _$toStr(bindTransformG_1(_$state)));\n _$sa(g_1, 'class', 'scope_735eee30');\n _$sa(svg_1, 'xmlns', 'http://www.w3.org/2000/svg');\n _$sa(svg_1, 'viewBox', '-50 -50 100 100');\n _$sa(svg_1, 'class', 'scope_735eee30');\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$is('scope_735eee30', 'svg.scope_735eee30{width:30%;height:30%;}.scope_735eee30.clock-face,.scope_735eee30.major,.scope_735eee30.hour{stroke:#333;}.scope_735eee30.clock-face{fill:white;}.scope_735eee30.minor{stroke:#999;stroke-width:0.5;}.scope_735eee30.major{stroke-width:1;}.scope_735eee30.minute{stroke:#666;}.scope_735eee30.second,.scope_735eee30.second-counterweight{stroke:rgb(180,0,0);}.scope_735eee30.second-counterweight{stroke-width:3;}');\n _$a(_$(parent), _$frag, _$(sibling));\n this.$siblingEl = _$(sibling);\n this.$parentEl = sibling && _$(sibling).parentElement || _$(parent);\n },\n $update: function (_$state) {\n loopBlock_1.$update(_$state, [\n 0,\n 5,\n 10,\n 15,\n 20,\n 25,\n 30,\n 35,\n 40,\n 45,\n 50,\n 55\n ]);\n var updateTransformLine_1 = _$toStr(bindTransformLine_1(_$state));\n if (_$ga(line_1, 'transform') !== updateTransformLine_1) {\n _$sa(line_1, 'transform', updateTransformLine_1);\n }\n updateTransformLine_1 = void 0;\n var updateTransformLine_2 = _$toStr(bindTransformLine_2(_$state));\n if (_$ga(line_2, 'transform') !== updateTransformLine_2) {\n _$sa(line_2, 'transform', updateTransformLine_2);\n }\n updateTransformLine_2 = void 0;\n var updateTransformG_1 = _$toStr(bindTransformG_1(_$state));\n if (_$ga(g_1, 'transform') !== updateTransformG_1) {\n _$sa(g_1, 'transform', updateTransformG_1);\n }\n updateTransformG_1 = void 0;\n },\n $unmount: function () {\n _$a(svg_1, circle_1);\n _$a(svg_1, loopAnchor_1_1);\n loopBlock_1.$mount(svg_1, loopAnchor_1_1);\n _$a(svg_1, comment_1);\n _$a(svg_1, line_1);\n _$a(svg_1, comment_2);\n _$a(svg_1, line_2);\n _$a(svg_1, comment_3);\n _$a(g_1, line_3);\n _$a(g_1, line_4);\n _$a(svg_1, g_1);\n _$a(_$frag, svg_1);\n },\n $destroy: function () {\n this.$unmount();\n this.$parent = null;\n this.$parentEl = null;\n this.$siblingEl = null;\n this.$children.splice(0, this.$children.length);\n _$ds('scope_735eee30');\n loopBlock_1.$destroy();\n delete _$state.$root;\n _$frag = svg_1 = circle_1 = loopAnchor_1_1 = loopBlock_1 = comment_1 = line_1 = bindTransformLine_1 = comment_2 = line_2 = bindTransformLine_2 = comment_3 = g_1 = line_3 = line_4 = bindTransformG_1 = void 0;\n }\n };\n}\nfunction Clock(_$attrs, _$parent) {\n _$CompCtr.call(this, _$attrs, _$tplClock, clock, _$parent);\n !_$parent && this.$create();\n}\nClock.plugin = _$plugin;\nClock.prototype = Object.create(_$CompCtr.prototype);\nClock.prototype.constructor = Clock;\n/* harmony default export */ var components_clock = (Clock);\n// CONCATENATED MODULE: ./main.ts\n\r\nvar main_clock = new components_clock();\r\nmain_clock.$mount('main');\r\n\n\n//# sourceURL=webpack:///./main.ts_+_3_modules?"); +eval("\n// CONCATENATED MODULE: h:/trebor-repos/trebor/tools/index.js\nvar PROP_MAP = { p: '__TP__', v: 'value', _: '_value', s: '_subscribers', e: '_events', w: '_watchers', h: 'prototype' };\r\nvar PROPS = ['$slots', '$refs', '$filters', '$directives', '_events', '_watchers'];\r\nvar TPS = window[PROP_MAP.p] || (window[PROP_MAP.p] = []);\r\nvar _$assign = Object['assign'] || function (t) {\r\n for (var s = void 0, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s)\r\n if (_$hasProp(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n};\r\nfunction _$CompCtr(attrs, template, options, parent) {\r\n var self = this;\r\n var _$set = function (prop, value) { _$def(self, prop, { value: value, writable: true }); };\r\n if (!attrs)\r\n attrs = {};\r\n _$e(PROPS, function (prop) { _$def(self, prop, { value: {} }); });\r\n _$set('$parent', parent || null);\r\n _$set('$children', []);\r\n _$set(PROP_MAP.s, {});\r\n _$set('$options', options);\r\n var opts = self.$options;\r\n if (!opts.attrs)\r\n opts.attrs = {};\r\n if (!opts.children)\r\n opts.children = {};\r\n _$e(TPS, function (plugin) { plugin.fn.call(self, _$CompCtr, plugin.options); });\r\n if (opts.filters)\r\n _$assign(self.$filters, opts.filters);\r\n if (opts.directives)\r\n _$e(opts.directives, function (drt, k) { self.$directives[k] = _$drt(drt); });\r\n _$e(opts.attrs, function (attrOps, key) {\r\n _$def(self, (_$isType(key, 'number') ? attrOps : key), {\r\n get: function () {\r\n if (_$isStr(attrOps)) {\r\n var value = attrs[attrOps];\r\n return _$isFunction(value) ? value() : value;\r\n }\r\n else {\r\n if (!_$hasProp(attrs, key) && attrOps.required) {\r\n return console.error(\"Attribute '\" + key + \"' is required.\");\r\n }\r\n else {\r\n var value = _$isFunction(attrs[key]) ? attrs[key]() : attrs[key];\r\n if (value === void 0 && _$hasProp(attrOps, 'default')) {\r\n var def = attrOps.default;\r\n value = _$isFunction(def) ? def() : def;\r\n }\r\n var typ = attrOps.type;\r\n if (typ && !_$isType(value, typ) && attrOps.required) {\r\n return console.error(\"Attribute '\" + key + \"' must be type '\" + typ + \"'.\");\r\n }\r\n value = _$toType(value, value === void 0 ? 'undefined' : typ, self, key);\r\n if (value !== void 0 && _$hasProp(attrOps, 'validator')) {\r\n var validator = attrOps.validator;\r\n if (_$isFunction(validator) && !validator(value)) {\r\n return console.error(\"Assigment '\" + key + \"'='\" + JSON.stringify(value) + \"' invalid.\");\r\n }\r\n }\r\n return value;\r\n }\r\n }\r\n },\r\n set: function () {\r\n console.error(\"'\" + key + \"' is read only.\");\r\n },\r\n enumerable: true, configurable: true\r\n });\r\n });\r\n var data = opts.model || {};\r\n var _loop_1 = function (key) {\r\n if (_$hasProp(data, key)) {\r\n var desc = Object.getOwnPropertyDescriptor(data, key);\r\n if (desc.value && _$isArray(desc.value)) {\r\n desc.value = new _$List(desc.value, self, key);\r\n }\r\n else {\r\n if (desc.get) {\r\n var getter_1 = desc.get;\r\n desc.get = function () {\r\n var value = getter_1.call(self);\r\n if (_$isArray(value))\r\n value = new _$List(value, self, key);\r\n return value;\r\n };\r\n }\r\n if (desc.set) {\r\n var setter_1 = desc.set;\r\n desc.set = function (v) {\r\n if (_$isArray(v))\r\n v = new _$List(v, self, key);\r\n setter_1.call(self, v);\r\n };\r\n }\r\n }\r\n _$def(self, key, desc);\r\n }\r\n };\r\n for (var key in data) {\r\n _loop_1(key);\r\n }\r\n var tpl = template(self);\r\n _$e(tpl, function (value, key) {\r\n _$def(self, key, {\r\n value: (function (key) {\r\n var hook = key[1].toUpperCase() + key.slice(2);\r\n var bhook = opts[\"before\" + hook];\r\n var ahook = opts[\"after\" + hook];\r\n return function () {\r\n bhook && bhook.call(this);\r\n key.slice(1) === 'update' ? value.call(this, this) : value.apply(this, arguments);\r\n ahook && ahook.call(this);\r\n };\r\n })(key)\r\n });\r\n });\r\n _$def(self, '$data', {\r\n get: function () {\r\n return _$toPlainObj(this);\r\n }\r\n });\r\n}\r\nfunction _$isValueAttr(attr) {\r\n return attr === 'value';\r\n}\r\nfunction _$subs(dep, listener) {\r\n if (!this[PROP_MAP.s][dep]) {\r\n this[PROP_MAP.s][dep] = [];\r\n }\r\n return this[PROP_MAP.s][dep].push(listener.bind(this)) - 1;\r\n}\r\nfunction _$def(obj, key, desc) {\r\n Object.defineProperty(obj, key, desc);\r\n}\r\n_$assign(_$CompCtr[PROP_MAP.h], {\r\n $get: function (path) {\r\n return _$accesor(this, path);\r\n },\r\n $set: function (path, value) {\r\n _$accesor(this, path, value);\r\n },\r\n $on: function (event, handler) {\r\n var _this = this;\r\n if (!this[PROP_MAP.e][event]) {\r\n this[PROP_MAP.e][event] = [];\r\n }\r\n var i = this[PROP_MAP.e][event].push(handler);\r\n return {\r\n $off: function () {\r\n _this[PROP_MAP.e][event].splice(i - 1, 1);\r\n }\r\n };\r\n },\r\n $once: function (event, handler) {\r\n var e = this.$on(event, function (args) {\r\n handler(args);\r\n e.$off();\r\n });\r\n },\r\n $fire: function (event, data) {\r\n if (this[PROP_MAP.e][event]) {\r\n _$e(this[PROP_MAP.e][event], function (handler) { handler(data); });\r\n }\r\n },\r\n $notify: function (key) {\r\n if (this[PROP_MAP.s][key]) {\r\n _$e(this[PROP_MAP.s][key], function (suscriber) { suscriber(); });\r\n }\r\n },\r\n $observe: function (deps, listener) {\r\n var _this = this;\r\n var subs = [];\r\n if (_$isArray(deps)) {\r\n _$e(deps, function (dep) {\r\n subs.push({ sub: dep, i: _$subs.call(_this, dep, listener) });\r\n });\r\n }\r\n else {\r\n subs.push({ sub: deps, i: _$subs.call(this, deps, listener) });\r\n }\r\n return {\r\n $unobserve: function () {\r\n _$e(subs, function (sub) {\r\n _this[PROP_MAP.s][sub.sub].splice(sub.i, 1);\r\n });\r\n }\r\n };\r\n },\r\n $watch: function (key, watcher) {\r\n var _this = this;\r\n if (!this[PROP_MAP.w][key]) {\r\n this[PROP_MAP.w][key] = [];\r\n }\r\n var i = this[PROP_MAP.w][key].push(watcher.bind(this));\r\n return {\r\n $unwatch: function () {\r\n _this[PROP_MAP.w][key].splice(i - 1, 1);\r\n }\r\n };\r\n }\r\n});\r\nvar array = Array[PROP_MAP.h];\r\nfunction _$toArgs(args, start) {\r\n if (start === void 0) { start = 0; }\r\n return array.slice.call(args, start);\r\n}\r\nfunction _$arrayValues(list, value, root, key) {\r\n array.push.apply(list, value.map(function (v, i) {\r\n if (list.length !== 0)\r\n i += list.length;\r\n return !(_$isType(v, _$List)) && _$isArray(v) ? new _$List(v, root, key + \".\" + i) : v;\r\n }));\r\n}\r\nfunction _$List(value, root, key) {\r\n var self = this;\r\n Array.apply(self, [value.length]);\r\n var desc = { writable: false, configurable: false, enumerable: false };\r\n _$def(self, '_key', _$assign({ value: key }, desc));\r\n _$def(self, '_root', _$assign({ value: root }, desc));\r\n _$arrayValues(self, value, root, key);\r\n desc.writable = true;\r\n _$def(self, 'length', _$assign({ value: self.length }, desc));\r\n}\r\n_$extends(_$List, Array);\r\n['pop', 'push', 'reverse', 'shift', 'sort', 'fill', 'unshift', 'splice'].forEach(function (method) {\r\n _$List[PROP_MAP.h][method] = function () {\r\n var self = this;\r\n var old = self.slice();\r\n var result;\r\n if (method === 'push') {\r\n _$arrayValues(self, _$toArgs(arguments), self._root, self._key);\r\n result = self.length;\r\n }\r\n else {\r\n result = array[method].apply(self, arguments);\r\n }\r\n _$dispatch(self._root, self._key, old, self.slice());\r\n return result;\r\n };\r\n});\r\n_$List[PROP_MAP.h].pull = function (index) {\r\n var self = this;\r\n var items = _$toArgs(arguments, 1);\r\n var length = self.length;\r\n if (index > length) {\r\n length = index + 1;\r\n var pull = new Array(index - self.length);\r\n pull.push.apply(pull, items);\r\n for (var i = 0; i < length; i++) {\r\n if (i === index) {\r\n self.push.apply(self, pull);\r\n }\r\n }\r\n }\r\n else {\r\n self.splice.apply(self, [index, 1].concat(items));\r\n }\r\n};\r\nfunction _$dispatch(root, key, oldVal, value) {\r\n root.$notify(key);\r\n if (root[PROP_MAP.w][key]) {\r\n _$e(root[PROP_MAP.w][key], function (watcher) { watcher(oldVal, value); });\r\n }\r\n root.$update();\r\n}\r\nfunction _$extends(ctor, exts) {\r\n ctor['plugin'] = function (fn, options) {\r\n TPS.push({ options: options, fn: fn });\r\n };\r\n ctor[PROP_MAP.h] = Object.create(exts[PROP_MAP.h]);\r\n ctor[PROP_MAP.h].constructor = ctor;\r\n}\r\nfunction _$isType(value, type) {\r\n return _$type(type) === 'string' ? type.split('|').some(function (t) { return t.trim() === _$type(value); }) : value instanceof type;\r\n}\r\nfunction _$apply(callee, args, globs, thisArg) {\r\n if (thisArg === void 0) { thisArg = null; }\r\n return callee.apply(thisArg, args.concat(globs));\r\n}\r\nfunction _$isObject(obj) {\r\n return _$isType(obj, 'object');\r\n}\r\nfunction _$isArray(obj) {\r\n return Array.isArray ? Array.isArray(obj) : _$isType(obj, 'array');\r\n}\r\nfunction _$isFunction(obj) {\r\n return _$isType(obj, 'function');\r\n}\r\nfunction _$isStr(obj) {\r\n return _$isType(obj, 'string');\r\n}\r\nfunction _$toType(value, type, root, key) {\r\n switch (type) {\r\n case 'date':\r\n return new Date(value);\r\n case 'string':\r\n return _$toStr(value);\r\n case 'number':\r\n return +value;\r\n case 'boolean':\r\n return _$isStr(value) && !value ? true : !!value;\r\n case 'array':\r\n return _$isType(value, _$List) ? value : new _$List(value, root, key);\r\n default:\r\n return value;\r\n }\r\n}\r\nfunction _$type(obj) {\r\n return / (\\w+)/.exec(({}).toString.call(obj))[1].toLowerCase();\r\n}\r\nfunction _$hasProp(obj, prop) {\r\n return obj.hasOwnProperty(prop);\r\n}\r\nfunction _$drt(dd) {\r\n var hasProp = function (prop, instance, options, element) { return _$isObject(dd) && dd[prop] && dd[prop](instance, options, element); };\r\n return {\r\n $init: function (instance, options, element) {\r\n hasProp('$init', instance, options, element);\r\n },\r\n $inserted: function (instance, options, element) {\r\n hasProp('$inserted', instance, options, element);\r\n },\r\n $update: function (instance, options, element) {\r\n if (_$isFunction(dd)) {\r\n dd(instance, options, element);\r\n }\r\n else {\r\n hasProp('$update', instance, options, element);\r\n }\r\n },\r\n $destroy: function (instance, options, element) {\r\n hasProp('$destroy', instance, options, element);\r\n }\r\n };\r\n}\r\nfunction _$noop() { }\r\nfunction _$add(inst, Child, attrs) {\r\n var child = null;\r\n if (Child) {\r\n child = new Child(attrs, inst);\r\n inst.$children.push(child);\r\n }\r\n return child;\r\n}\r\nfunction _$remove(inst, child) {\r\n var index = inst.$children.indexOf(child);\r\n index >= 0 && inst.$children.splice(index, 1);\r\n}\r\nfunction _$toStr(obj) {\r\n var str = _$type(obj);\r\n return !/null|undefined/.test(str) ? obj.toString() : str;\r\n}\r\nfunction _$toPlainObj(obj) {\r\n var data = {};\r\n _$e(_$isObject(obj) ? obj : {}, function (_v, k) {\r\n if (k[0] !== '$' && !_$isFunction(obj[k])) {\r\n if (_$isType(obj[k], _$List)) {\r\n data[k] = obj[k].map(_$toPlainObj);\r\n }\r\n else if (_$isObject(obj[k])) {\r\n data[k] = _$toPlainObj(obj[k]);\r\n }\r\n else {\r\n data[k] = obj[k];\r\n }\r\n }\r\n });\r\n return _$isObject(obj) ? data : obj;\r\n}\r\nfunction _$setRef(refs, prop, node) {\r\n if (!_$hasProp(refs, prop)) {\r\n var value_1 = [];\r\n _$def(refs, prop, {\r\n get: function () { return value_1.length <= 1 ? value_1[0] : value_1; },\r\n set: function (val) { val && !~value_1.indexOf(val) && value_1.push(val); },\r\n enumerable: true, configurable: true\r\n });\r\n }\r\n refs[prop] = node;\r\n}\r\nfunction _$accesor(object, path, value) {\r\n return path.split('.').reduce(function (obj, key, i, arr) {\r\n if (_$isType(value, 'undefined')) {\r\n if (obj == null) {\r\n arr.splice(0, arr.length);\r\n return i > 0 && obj === null ? obj : undefined;\r\n }\r\n }\r\n else {\r\n if (i === arr.length - 1) {\r\n if (_$isType(obj, _$List) && _$toStr(+key) === key) {\r\n obj.pull(+key, value);\r\n }\r\n else {\r\n var oldVal = obj[key];\r\n obj[key] = !_$isType(value, _$List) && _$isArray(value) ? new _$List(value, object, key) : value;\r\n _$dispatch(object, path, oldVal, obj[key]);\r\n }\r\n }\r\n else if (!_$isObject(obj[key])) {\r\n obj[key] = {};\r\n }\r\n }\r\n return obj ? obj[key] : null;\r\n }, object);\r\n}\r\nfunction _$emptyElse() {\r\n return { type: 'empty-else', $create: _$noop, $mount: _$noop, $update: _$noop, $destroy: _$noop };\r\n}\r\nfunction _$isKey(event, key) {\r\n return event.key.toLowerCase() === key || !!event[key + \"Key\"];\r\n}\r\nfunction _$bindGroup(input, selection) {\r\n var _value = _$gv(input);\r\n var _$index = selection.indexOf(_value);\r\n input.checked && !~_$index ? selection.push(_value) : selection.splice(_$index, 1);\r\n}\r\nfunction _$bindMultiSelect(select, selections) {\r\n if (!selections.length)\r\n return;\r\n var options = select.options;\r\n for (var i = 0; i < options.length; i++) {\r\n options[i].selected = !!~selections.indexOf(_$gv(options[i]));\r\n }\r\n}\r\nfunction _$updateMultiSelect(select, obj, prop) {\r\n var items = [];\r\n var selection = obj[prop];\r\n var selectedOptions = select.selectedOptions;\r\n for (var i = 0; i < selectedOptions.length; i++) {\r\n items.push(_$gv(selectedOptions[i]));\r\n }\r\n obj[prop] = new _$List(items, selection['_root'], selection['_key']);\r\n obj.$update();\r\n}\r\nfunction _$(selector, parent) {\r\n return _$isStr(selector) ? (parent || document).querySelector(selector) : selector;\r\n}\r\nfunction _$d() {\r\n return document.createDocumentFragment();\r\n}\r\nfunction _$a(parent, child, sibling) {\r\n if (_$isType(sibling, 'boolean') && sibling)\r\n parent.parentElement.replaceChild(child, parent);\r\n else if (!sibling)\r\n parent.appendChild(child);\r\n else\r\n parent.insertBefore(child, sibling);\r\n}\r\nfunction _$as(source, dest) {\r\n var childNodes = source.childNodes, attributes = source.attributes;\r\n for (var i = 0; i < childNodes.length; i++) {\r\n _$a(dest, childNodes[i]);\r\n }\r\n for (var i = 0; i < attributes.length; i++) {\r\n var attr = attributes[i];\r\n dest.setAttributeNS(source.namespaceURI, attr.name, attr.value);\r\n }\r\n source.parentElement.replaceChild(dest, source);\r\n return dest;\r\n}\r\nfunction _$r(el, parent) {\r\n var root = parent || el.parentElement;\r\n if (root)\r\n root.removeChild(el);\r\n}\r\nfunction _$ce(tagName) {\r\n return document.createElement(tagName || 'div');\r\n}\r\nfunction _$cse(tagName) {\r\n return document.createElementNS('http://www.w3.org/2000/svg', tagName || 'svg');\r\n}\r\nfunction _$ct(content) {\r\n return document.createTextNode(content || '');\r\n}\r\nfunction _$cm(content) {\r\n return document.createComment(content || '');\r\n}\r\nfunction _$sa(el, attrAndValue) {\r\n var attr = attrAndValue[0], value = attrAndValue[1];\r\n el.setAttribute(attr, _$toStr(value));\r\n if (_$isValueAttr(attr) && !_$isStr(value))\r\n el[PROP_MAP._] = value;\r\n}\r\nfunction _$ga(el, attr) {\r\n return _$isValueAttr(attr) ? _$gv(el) : el.getAttribute(attr);\r\n}\r\nfunction _$gv(el) {\r\n return _$hasProp(el, PROP_MAP._) ? el[PROP_MAP._] : el[PROP_MAP.v];\r\n}\r\nfunction _$al(el, event, handler) {\r\n el.addEventListener(event, handler, false);\r\n}\r\nfunction _$ul(el, event, oldHandler, newHandler) {\r\n _$rl(el, event, oldHandler);\r\n _$al(el, event, oldHandler = newHandler);\r\n return oldHandler;\r\n}\r\nfunction _$rl(el, event, handler) {\r\n el.removeEventListener(event, handler, false);\r\n}\r\nfunction _$bc(value) {\r\n var classes = '';\r\n if (_$isStr(value)) {\r\n classes += \" \" + value;\r\n }\r\n else if (_$isArray(value)) {\r\n classes = value.map(_$bc).join(' ');\r\n }\r\n else if (_$isObject(value)) {\r\n for (var key in value)\r\n if (_$hasProp(value, key) && value[key])\r\n classes += \" \" + key;\r\n }\r\n return classes.trim();\r\n}\r\nfunction _$bs(value) {\r\n var el = _$ce();\r\n if (_$isObject(value)) {\r\n var style_1 = el.style;\r\n _$e(value, function (val, prop) {\r\n if (val !== style_1[prop])\r\n style_1[prop] = val;\r\n });\r\n return style_1.cssText;\r\n }\r\n else if (_$isStr(value)) {\r\n return value;\r\n }\r\n else {\r\n return '';\r\n }\r\n}\r\nfunction _$cu(block, condition, parent, anchor, inst) {\r\n var globs = _$toArgs(arguments, 5);\r\n if (block && block.type === _$apply(condition, [inst], globs).type) {\r\n _$apply(block.$update, [inst], globs, block);\r\n }\r\n else {\r\n block && block.$destroy();\r\n block = _$apply(condition, [inst], globs);\r\n block.$create();\r\n block.$mount(parent || inst.$parentEl, anchor);\r\n }\r\n return block;\r\n}\r\nfunction _$bba(el, attrAndValue) {\r\n var attr = attrAndValue[0], value = attrAndValue[1];\r\n el[attr] = value == null || value === false ? (el.removeAttribute(attr), false) : (_$sa(el, [attr, '']), true);\r\n}\r\nfunction _$bu(el, binding) {\r\n var attr = binding[0], value = binding[1];\r\n var _value = _$toStr(value);\r\n if (_$isValueAttr(attr)) {\r\n if (el[attr] !== _value)\r\n el[attr] = _value;\r\n el[PROP_MAP._] = value;\r\n }\r\n else if (_$ga(el, attr) !== _value) {\r\n _$sa(el, [attr, _value]);\r\n }\r\n}\r\nfunction _$tu(text, value) {\r\n if (text.data !== (value = _$toStr(value)))\r\n text.data = value;\r\n}\r\nfunction _$nu(node, tag) {\r\n return tag.toUpperCase() !== node.tagName ? _$as(node, _$ce(tag)) : node;\r\n}\r\nfunction _$rr(refs, prop, node) {\r\n var nodes = refs[prop];\r\n _$isArray(nodes) ? refs[prop].splice(nodes.indexOf(node), 1) : (delete refs[prop]);\r\n}\r\nfunction _$hu(node, value) {\r\n if (node.innerHTML !== (value = _$toStr(value)))\r\n node.innerHTML = value;\r\n}\r\nfunction _$pu(parent, Ctor, inst, value, attrs, el, sibling) {\r\n if (value === Ctor) {\r\n inst && inst.$update();\r\n }\r\n else {\r\n Ctor = value;\r\n if (inst) {\r\n inst.$destroy();\r\n _$remove(parent, inst);\r\n }\r\n if (inst) {\r\n inst = _$add(parent, Ctor, attrs);\r\n inst.$create();\r\n inst.$mount(el, sibling);\r\n }\r\n }\r\n return [inst, Ctor];\r\n}\r\nfunction _$f(root, obj, loop) {\r\n var items = {}, loopParent, loopSibling;\r\n var globs = _$toArgs(arguments, 3);\r\n _$e(obj, function (item, i, index) { items[i] = _$apply(loop, [root, item, i, index], globs); });\r\n return {\r\n $create: function () {\r\n _$e(items, function (item) { item.$create(); });\r\n },\r\n $mount: function (parent, sibling) {\r\n loopParent = _$(parent);\r\n loopSibling = _$(sibling);\r\n _$e(items, function (item) { item.$mount(loopParent, loopSibling); });\r\n },\r\n $update: function (root, obj) {\r\n var globs = _$toArgs(arguments, 2);\r\n _$e(items, function (item, i, index) {\r\n if (obj[i]) {\r\n _$apply(item.$update, [root, obj[i], i, index], globs, item);\r\n }\r\n else {\r\n item.$destroy();\r\n delete items[i];\r\n }\r\n });\r\n _$e(obj, function (item, i, index) {\r\n if (!items[i]) {\r\n items[i] = _$apply(loop, [root, item, i, index], globs);\r\n items[i].$create();\r\n items[i].$mount(loopParent, loopSibling);\r\n }\r\n });\r\n },\r\n $destroy: function () {\r\n _$e(items, function (item) { item.$destroy(); });\r\n }\r\n };\r\n}\r\nfunction _$e(obj, cb) {\r\n var i = 0;\r\n for (var key in obj) {\r\n if (_$hasProp(obj, key)) {\r\n cb(obj[key], (isNaN(+key) ? key : +key), i++);\r\n }\r\n }\r\n}\r\nfunction _$is(id, css) {\r\n var isNew = false;\r\n var style = _$(\"#\" + id, document.head);\r\n if (!style) {\r\n isNew = true;\r\n style = _$ce('style');\r\n style.id = id;\r\n _$sa(style, ['refs', 1]);\r\n }\r\n if (style.textContent !== css) {\r\n style.textContent = css;\r\n }\r\n if (isNew) {\r\n _$a(document.head, style);\r\n }\r\n else {\r\n var count = +_$ga(style, 'refs');\r\n _$sa(style, ['refs', ++count]);\r\n }\r\n}\r\nfunction _$ds(id) {\r\n var style = _$(\"#\" + id, document.head);\r\n if (style) {\r\n var count = +_$ga(style, 'refs');\r\n if (--count === 0) {\r\n _$r(style, document.head);\r\n }\r\n else {\r\n _$sa(style, ['refs', count]);\r\n }\r\n }\r\n}\r\n//# sourceMappingURL=index.js.map\n// CONCATENATED MODULE: ./components/clock.ts\n/* harmony default export */ var clock = ({\r\n afterMount: function () {\r\n var _this = this;\r\n this.interval = setInterval(function () {\r\n _this.$set('time', new Date());\r\n }, 1000);\r\n },\r\n beforeDestroy: function () {\r\n clearInterval(this.interval);\r\n },\r\n model: {\r\n interval: null,\r\n time: new Date(),\r\n get hours() {\r\n return this.time.getHours();\r\n },\r\n get minutes() {\r\n return this.time.getMinutes();\r\n },\r\n get seconds() {\r\n return this.time.getSeconds();\r\n }\r\n }\r\n});\r\n\n// CONCATENATED MODULE: ./components/clock.html\n\r\n\r\nfunction itemLoop_2(_$state, offset, _$v, _$i, minute) {\r\n var _$frag, line_1, bindTransformLine_1;\r\n _$frag = _$d();\r\n bindTransformLine_1 = function(_$state, offset, minute) {\r\n return ['transform', 'rotate(' + 6 * (minute + offset) + ')'];\r\n };\r\n return {\r\n $create: function() {\r\n line_1 = _$cse('line');\r\n _$sa(line_1, ['class', 'scope_735eee30 minor']);\r\n _$sa(line_1, ['y1', '42']);\r\n _$sa(line_1, ['y2', '45']);\r\n _$sa(line_1, bindTransformLine_1(_$state, offset, minute));\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n },\r\n\r\n $update: function(_$state, offset, _$v, _$i, minute) {\r\n _$bu(line_1, bindTransformLine_1(_$state, offset, minute));\r\n },\r\n\r\n $unmount: function() {\r\n _$a(_$frag, line_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n _$frag = line_1 = bindTransformLine_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction itemLoop_1(_$state, minute) {\r\n var _$frag, template_1, comment_1, line_1, bindTransformLine_1, loopAnchor_2_1, loopBlock_2;\r\n _$frag = _$d();\r\n bindTransformLine_1 = function(_$state, minute) {\r\n return ['transform', 'rotate(' + 30 * minute + ')'];\r\n };\r\n loopBlock_2 = _$f(_$state, [1, 2, 3, 4], itemLoop_2, minute);\r\n loopAnchor_2_1 = _$ct();\r\n return {\r\n $create: function() {\r\n template_1 = _$d();\r\n comment_1 = _$cm('');\r\n line_1 = _$cse('line');\r\n loopBlock_2.$create();\r\n _$sa(line_1, ['class', 'scope_735eee30 major']);\r\n _$sa(line_1, ['y1', '35']);\r\n _$sa(line_1, ['y2', '45']);\r\n _$sa(line_1, bindTransformLine_1(_$state, minute));\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n },\r\n\r\n $update: function(_$state, minute) {\r\n _$bu(line_1, bindTransformLine_1(_$state, minute));\r\n loopBlock_2.$update(_$state, [1, 2, 3, 4], minute);\r\n },\r\n\r\n $unmount: function() {\r\n _$a(template_1, comment_1);\r\n _$a(template_1, line_1);\r\n _$a(template_1, loopAnchor_2_1);\r\n loopBlock_2.$mount(template_1, loopAnchor_2_1);\r\n _$a(_$frag, template_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n loopBlock_2.$destroy();\r\n _$frag = template_1 = comment_1 = line_1 = bindTransformLine_1 = loopAnchor_2_1 = loopBlock_2 = void 0;\r\n }\r\n };\r\n}\r\nfunction _$tplClock(_$state) {\r\n var _$frag, svg_1, circle_1, loopAnchor_1_1, loopBlock_1, comment_1, line_1, bindTransformLine_1, comment_2, line_2, bindTransformLine_2, comment_3, g_1, line_3, line_4, bindTransformG_1;\r\n _$frag = _$d();\r\n loopBlock_1 = _$f(_$state, [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55], itemLoop_1);\r\n loopAnchor_1_1 = _$ct();\r\n bindTransformLine_1 = function(_$state) {\r\n return ['transform', 'rotate(' + (30 * _$state.hours + _$state.minutes / 2) + ')'];\r\n };\r\n bindTransformLine_2 = function(_$state) {\r\n return [\r\n 'transform',\r\n 'rotate(' + (6 * _$state.minutes + _$state.seconds / 10) + ')'\r\n ];\r\n };\r\n bindTransformG_1 = function(_$state) {\r\n return ['transform', 'rotate(' + 6 * _$state.seconds + ')'];\r\n };\r\n return {\r\n $create: function() {\r\n svg_1 = _$cse();\r\n circle_1 = _$cse('circle');\r\n circle_1.innerHTML = '';\r\n loopBlock_1.$create();\r\n comment_1 = _$cm('');\r\n line_1 = _$cse('line');\r\n comment_2 = _$cm('');\r\n line_2 = _$cse('line');\r\n comment_3 = _$cm('');\r\n g_1 = _$cse('g');\r\n line_3 = _$cse('line');\r\n line_3.innerHTML = '';\r\n line_4 = _$cse('line');\r\n line_4.innerHTML = '';\r\n _$sa(circle_1, ['class', 'scope_735eee30 clock-face']);\r\n _$sa(circle_1, ['r', '48']);\r\n _$sa(line_1, ['class', 'scope_735eee30 hour']);\r\n _$sa(line_1, ['y1', '2']);\r\n _$sa(line_1, ['y2', '-20']);\r\n _$sa(line_1, bindTransformLine_1(_$state));\r\n _$sa(line_2, ['class', 'scope_735eee30 minute']);\r\n _$sa(line_2, ['y1', '4']);\r\n _$sa(line_2, ['y2', '-30']);\r\n _$sa(line_2, bindTransformLine_2(_$state));\r\n _$sa(line_3, ['class', 'scope_735eee30 second']);\r\n _$sa(line_3, ['y1', '10']);\r\n _$sa(line_3, ['y2', '-38']);\r\n _$sa(line_4, ['class', 'scope_735eee30 second-counterweight']);\r\n _$sa(line_4, ['y1', '10']);\r\n _$sa(line_4, ['y2', '2']);\r\n _$sa(g_1, ['class', 'scope_735eee30']);\r\n _$sa(g_1, bindTransformG_1(_$state));\r\n _$sa(svg_1, ['xmlns', 'http://www.w3.org/2000/svg']);\r\n _$sa(svg_1, ['viewBox', '-50 -50 100 100']);\r\n _$sa(svg_1, ['class', 'scope_735eee30']);\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$is(\r\n 'scope_735eee30',\r\n 'svg.scope_735eee30{width:30%;height:30%;}.scope_735eee30.clock-face,.scope_735eee30.major,.scope_735eee30.hour{stroke:#333;}.scope_735eee30.clock-face{fill:white;}.scope_735eee30.minor{stroke:#999;stroke-width:0.5;}.scope_735eee30.major{stroke-width:1;}.scope_735eee30.minute{stroke:#666;}.scope_735eee30.second,.scope_735eee30.second-counterweight{stroke:rgb(180,0,0);}.scope_735eee30.second-counterweight{stroke-width:3;}'\r\n );\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n this.$siblingEl = _$(sibling);\r\n this.$parentEl = sibling && _$(sibling).parentElement || _$(parent);\r\n },\r\n\r\n $update: function(_$state) {\r\n loopBlock_1.$update(_$state, [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]);\r\n _$bu(line_1, bindTransformLine_1(_$state));\r\n _$bu(line_2, bindTransformLine_2(_$state));\r\n _$bu(g_1, bindTransformG_1(_$state));\r\n },\r\n\r\n $unmount: function() {\r\n _$a(svg_1, circle_1);\r\n _$a(svg_1, loopAnchor_1_1);\r\n loopBlock_1.$mount(svg_1, loopAnchor_1_1);\r\n _$a(svg_1, comment_1);\r\n _$a(svg_1, line_1);\r\n _$a(svg_1, comment_2);\r\n _$a(svg_1, line_2);\r\n _$a(svg_1, comment_3);\r\n _$a(g_1, line_3);\r\n _$a(g_1, line_4);\r\n _$a(svg_1, g_1);\r\n _$a(_$frag, svg_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n this.$parent = null;\r\n this.$parentEl = null;\r\n this.$siblingEl = null;\r\n this.$children.splice(0, this.$children.length);\r\n _$ds('scope_735eee30');\r\n loopBlock_1.$destroy();\r\n delete _$state.$root;\r\n _$frag = svg_1 = circle_1 = loopAnchor_1_1 = loopBlock_1 = comment_1 = line_1 = bindTransformLine_1 = comment_2 = line_2 = bindTransformLine_2 = comment_3 = g_1 = line_3 = line_4 = bindTransformG_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction Clock(_$attrs, _$parent) {\r\n _$CompCtr.call(this, _$attrs, _$tplClock, clock, _$parent);\r\n !_$parent && this.$create();\r\n}\r\n_$extends(Clock, _$CompCtr);\r\n/* harmony default export */ var components_clock = (Clock);\r\n\n// CONCATENATED MODULE: ./main.ts\n\r\nvar main_clock = new components_clock();\r\nmain_clock.$mount('main');\r\n\n\n//# sourceURL=webpack:///./main.ts_+_3_modules?"); /***/ }) diff --git a/examples/counter/dist/js/counter.js b/examples/counter/dist/js/counter.js index 9f69556..b73f5c3 100644 --- a/examples/counter/dist/js/counter.js +++ b/examples/counter/dist/js/counter.js @@ -94,7 +94,7 @@ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("\n// CONCATENATED MODULE: d:/DEVELOP/Work in Progress/trebor-repos/trebor/tools/index.js\nvar _$assign = Object['assign'] || function (t) {\r\n for (var s = void 0, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s)\r\n if (_$hasProp(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n};\r\nfunction _$CompCtr(attrs, template, options, parent) {\r\n var self = this;\r\n var props = ['$slots', '$refs', '$filters', '$directives', '_events', '_watchers'];\r\n var _$set = function (prop, value) { _$def(self, prop, { value: value, writable: true }); };\r\n if (!attrs)\r\n attrs = {};\r\n _$e(props, function (prop) { _$def(self, prop, { value: {} }); });\r\n _$set('$parent', parent || null);\r\n _$set('$children', []);\r\n _$set('_subscribers', {});\r\n _$set('$options', options);\r\n var opts = self.$options;\r\n if (!opts.attrs)\r\n opts.attrs = {};\r\n if (!opts.children)\r\n opts.children = {};\r\n _$e(_$CompCtr['_plugins'], function (plugin) {\r\n plugin.fn.call(self, _$CompCtr, plugin.options);\r\n });\r\n if (opts.filters)\r\n _$assign(self.$filters, opts.filters);\r\n if (opts.directives)\r\n _$e(opts.directives, function (drt, k) { self.$directives[k] = _$drt(drt); });\r\n _$e(opts.attrs, function (attrOps, key) {\r\n _$def(self, (_$isType(key, 'number') ? attrOps : key), {\r\n get: function () {\r\n if (_$isType(attrOps, 'string')) {\r\n var value = attrs[attrOps];\r\n return _$isType(value, 'function') ? value() : value;\r\n }\r\n else {\r\n if (!_$hasProp(attrs, key) && attrOps.required) {\r\n console.error(\"Attribute '\" + key + \"' must be present because it's required.\");\r\n }\r\n else {\r\n var value = _$isType(attrs[key], 'function') ? attrs[key]() : attrs[key];\r\n if (value === void 0 && _$hasProp(attrOps, 'default')) {\r\n var def = attrOps.default;\r\n value = _$isType(def, 'function') ? def() : def;\r\n }\r\n var typ = attrOps.type;\r\n if (typ && !_$isType(value, typ) && attrOps.required) {\r\n return console.error(\"Attribute '\" + key + \"' must be type '\" + typ + \"'.\");\r\n }\r\n return _$toType(value, value === void 0 ? 'undefined' : typ, self, key);\r\n }\r\n }\r\n },\r\n set: function () {\r\n console.error(\"Can not modify attribute '\" + key + \"' because attributes al read only.\");\r\n },\r\n enumerable: true, configurable: true\r\n });\r\n });\r\n var data = opts.model || {};\r\n var _loop_1 = function (key) {\r\n if (_$hasProp(data, key)) {\r\n var desc = Object.getOwnPropertyDescriptor(data, key);\r\n if (desc.value && _$isArray(desc.value)) {\r\n desc.value = new _$List(desc.value, self, key);\r\n }\r\n else {\r\n if (desc.get) {\r\n var getter_1 = desc.get;\r\n desc.get = function () {\r\n var value = getter_1.call(self);\r\n if (_$isArray(value))\r\n value = new _$List(value, self, key);\r\n return value;\r\n };\r\n }\r\n if (desc.set) {\r\n var setter_1 = desc.set;\r\n desc.set = function (v) {\r\n if (_$isArray(v))\r\n v = new _$List(v, self, key);\r\n setter_1.call(self, v);\r\n };\r\n }\r\n }\r\n _$def(self, key, desc);\r\n }\r\n };\r\n for (var key in data) {\r\n _loop_1(key);\r\n }\r\n var tpl = template(self, opts.children);\r\n _$e(tpl, function (value, key) {\r\n _$def(self, key, {\r\n value: (function (key) {\r\n var hook = key[1].toUpperCase() + key.slice(2);\r\n var bhook = opts[\"before\" + hook];\r\n var ahook = opts[\"after\" + hook];\r\n return function () {\r\n bhook && bhook.call(this);\r\n key.slice(1) === 'update' ? value.call(this, this) : value.apply(this, arguments);\r\n ahook && ahook.call(this);\r\n };\r\n })(key)\r\n });\r\n });\r\n _$def(self, '$data', {\r\n get: function () {\r\n return _$toPlainObj(this);\r\n }\r\n });\r\n}\r\nfunction _$plugin(fn, options) {\r\n _$CompCtr['_plugins'] = _$CompCtr['_plugins'] || [];\r\n _$CompCtr['_plugins'].push({ options: options, fn: fn });\r\n}\r\n_$assign(_$CompCtr.prototype, {\r\n $get: function (path) {\r\n return _$accesor(this, path);\r\n },\r\n $set: function (path, value) {\r\n _$accesor(this, path, value);\r\n },\r\n $on: function (event, handler) {\r\n var _this = this;\r\n if (!this._events[event]) {\r\n this._events[event] = [];\r\n }\r\n var i = this._events[event].push(handler);\r\n return {\r\n $off: function () {\r\n _this._events[event].splice(i - 1, 1);\r\n }\r\n };\r\n },\r\n $once: function (event, handler) {\r\n var e = this.$on(event, function (args) {\r\n handler(args);\r\n e.$off();\r\n });\r\n },\r\n $fire: function (event, data) {\r\n if (this._events[event]) {\r\n _$e(this._events[event], function (handler) { handler(data); });\r\n }\r\n },\r\n $notify: function (key) {\r\n if (this._subscribers[key]) {\r\n _$e(this._subscribers[key], function (suscriber) { suscriber(); });\r\n }\r\n },\r\n $observe: function (deps, listener) {\r\n var _this = this;\r\n var subs = [];\r\n if (_$isArray(deps)) {\r\n _$e(deps, function (dep) {\r\n subs.push({ sub: dep, i: _$subs.call(_this, dep, listener) });\r\n });\r\n }\r\n else {\r\n subs.push({ sub: deps, i: _$subs.call(this, deps, listener) });\r\n }\r\n return {\r\n $unobserve: function () {\r\n _$e(subs, function (sub) {\r\n _this._subscribers[sub.sub].splice(sub.i, 1);\r\n });\r\n }\r\n };\r\n },\r\n $watch: function (key, watcher) {\r\n var _this = this;\r\n if (!this._watchers[key]) {\r\n this._watchers[key] = [];\r\n }\r\n var i = this._watchers[key].push(watcher.bind(this));\r\n return {\r\n $unwatch: function () {\r\n _this._watchers[key].splice(i - 1, 1);\r\n }\r\n };\r\n }\r\n});\r\nvar array = Array.prototype;\r\nfunction _$toArgs(args, start) {\r\n if (start === void 0) { start = 0; }\r\n return array.slice.call(args, start);\r\n}\r\nfunction _$arrayValues(list, value, root, key) {\r\n array.push.apply(list, value.map(function (v, i) {\r\n if (list.length !== 0)\r\n i += list.length;\r\n return !(_$isType(v, _$List)) && _$isArray(v) ? new _$List(v, root, key + \".\" + i) : v;\r\n }));\r\n}\r\nfunction _$List(value, root, key) {\r\n var self = this;\r\n Array.apply(self, [value.length]);\r\n var desc = { writable: false, configurable: false, enumerable: false };\r\n _$def(self, '_key', _$assign({ value: key }, desc));\r\n _$def(self, '_root', _$assign({ value: root }, desc));\r\n _$arrayValues(self, value, root, key);\r\n desc.writable = true;\r\n _$def(self, 'length', _$assign({ value: self.length }, desc));\r\n}\r\n_$List.prototype = Object.create(array);\r\n_$List.prototype.constructor = _$List;\r\n['pop', 'push', 'reverse', 'shift', 'sort', 'fill', 'unshift', 'splice'].forEach(function (method) {\r\n _$List.prototype[method] = function () {\r\n var self = this;\r\n var old = self.slice();\r\n var result;\r\n if (method === 'push') {\r\n _$arrayValues(self, _$toArgs(arguments), self._root, self._key);\r\n result = self.length;\r\n }\r\n else {\r\n result = array[method].apply(self, arguments);\r\n }\r\n _$dispatch(self._root, self._key, old, self.slice());\r\n return result;\r\n };\r\n});\r\n_$List.prototype.pull = function (index) {\r\n var self = this;\r\n var items = _$toArgs(arguments, 1);\r\n var length = self.length;\r\n if (index > length) {\r\n length = index + 1;\r\n var pull = new Array(index - self.length);\r\n pull.push.apply(pull, items);\r\n for (var i = 0; i < length; i++) {\r\n if (i === index) {\r\n self.push.apply(self, pull);\r\n }\r\n }\r\n }\r\n else {\r\n self.splice.apply(self, [index, 1].concat(items));\r\n }\r\n};\r\nfunction _$dispatch(root, key, oldVal, value) {\r\n root.$notify(key);\r\n if (root._watchers[key]) {\r\n _$e(root._watchers[key], function (watcher) { watcher(oldVal, value); });\r\n }\r\n root.$update();\r\n}\r\nfunction _$isType(value, type) {\r\n return _$type(type) === 'string' ? type.split('\\|').some(function (t) { return t.trim() === _$type(value); }) : value instanceof type;\r\n}\r\nfunction _$isObject(obj) {\r\n return _$isType(obj, 'object');\r\n}\r\nfunction _$isArray(obj) {\r\n return Array.isArray ? Array.isArray(obj) : _$isType(obj, 'array');\r\n}\r\nfunction _$toType(value, type, root, key) {\r\n switch (type) {\r\n case 'date':\r\n return new Date(value);\r\n case 'string':\r\n return value.toString();\r\n case 'number':\r\n return +value;\r\n case 'boolean':\r\n return !!value;\r\n case 'array':\r\n return _$isType(value, _$List) ? value : new _$List(value, root, key);\r\n default:\r\n return value;\r\n }\r\n}\r\nfunction _$type(obj) {\r\n return /\\[object (\\w+)\\]/.exec(Object.prototype.toString.call(obj))[1].toLowerCase();\r\n}\r\nfunction _$hasProp(obj, prop) {\r\n return obj.hasOwnProperty(prop);\r\n}\r\nfunction _$drt(directive) {\r\n var hasProp = function (prop, instance, options, element) { return _$isObject(directive) && directive[prop] && directive[prop](instance, options, element); };\r\n return {\r\n $init: function (instance, options, element) {\r\n hasProp('$init', instance, options, element);\r\n },\r\n $inserted: function (instance, options, element) {\r\n hasProp('$inserted', instance, options, element);\r\n },\r\n $update: function (instance, options, element) {\r\n if (_$isType(directive, 'function')) {\r\n directive(instance, options, element);\r\n }\r\n else {\r\n hasProp('$update', instance, options, element);\r\n }\r\n },\r\n $destroy: function (instance, options, element) {\r\n hasProp('$destroy', instance, options, element);\r\n }\r\n };\r\n}\r\nfunction _$noop() { }\r\nfunction _$add(inst, child) {\r\n inst.$children.push(child);\r\n}\r\nfunction _$remove(inst, child) {\r\n var index = inst.$children.indexOf(child);\r\n index >= 0 && inst.$children.splice(index, 1);\r\n}\r\nfunction _$toStr(obj) {\r\n var str = _$type(obj);\r\n return !/null|undefined/.test(str) ? obj.toString() : str;\r\n}\r\nfunction _$toPlainObj(obj) {\r\n var data = {};\r\n _$e(_$isObject(obj) ? obj : {}, function (_v, k) {\r\n if (k[0] !== '$' && !_$isType(obj[k], 'function')) {\r\n if (_$isType(obj[k], _$List)) {\r\n data[k] = obj[k].map(_$toPlainObj);\r\n }\r\n else if (_$isObject(obj[k])) {\r\n data[k] = _$toPlainObj(obj[k]);\r\n }\r\n else {\r\n data[k] = obj[k];\r\n }\r\n }\r\n });\r\n return _$isObject(obj) ? data : obj;\r\n}\r\nfunction _$setRef(obj, prop) {\r\n var value = [];\r\n _$def(obj, prop, {\r\n get: function () {\r\n return value.length <= 1 ? value[0] : value;\r\n },\r\n set: function (val) {\r\n if (val && !~value.indexOf(val)) {\r\n value.push(val);\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n}\r\nfunction _$accesor(object, path, value) {\r\n return path.split('.').reduce(function (obj, key, i, arr) {\r\n if (_$isType(value, 'undefined')) {\r\n if (obj == null) {\r\n arr.splice(0, arr.length);\r\n return i > 0 && obj === null ? obj : undefined;\r\n }\r\n }\r\n else {\r\n if (i === arr.length - 1) {\r\n if (_$isType(obj, _$List) && (+key).toString() === key) {\r\n obj.pull(+key, value);\r\n }\r\n else {\r\n var oldVal = obj[key];\r\n obj[key] = !_$isType(value, _$List) && _$isArray(value) ? new _$List(value, object, key) : value;\r\n _$dispatch(object, path, oldVal, obj[key]);\r\n }\r\n }\r\n else if (!_$isObject(obj[key])) {\r\n obj[key] = {};\r\n }\r\n }\r\n return obj ? obj[key] : null;\r\n }, object);\r\n}\r\nfunction _$emptyElse() {\r\n return { type: 'empty-else', $create: _$noop, $mount: _$noop, $update: _$noop, $destroy: _$noop };\r\n}\r\nfunction _$subs(dep, listener) {\r\n if (!this._subscribers[dep]) {\r\n this._subscribers[dep] = [];\r\n }\r\n return this._subscribers[dep].push(listener.bind(this)) - 1;\r\n}\r\nfunction _$def(obj, key, desc) {\r\n Object.defineProperty(obj, key, desc);\r\n}\r\nfunction _$isKey(event, key) {\r\n return event.key.toLowerCase() === key || !!event[key + \"Key\"];\r\n}\r\nfunction _$bindGroup(input, selection) {\r\n var _$index = selection.indexOf(input.value);\r\n if (input.checked && !~_$index)\r\n selection.push(input.value);\r\n else\r\n selection.splice(_$index, 1);\r\n}\r\nfunction _$(selector, parent) {\r\n return _$isType(selector, 'string') ? (parent || document).querySelector(selector) : selector;\r\n}\r\nfunction _$d() {\r\n return document.createDocumentFragment();\r\n}\r\nfunction _$a(parent, child, sibling) {\r\n if (_$isType(sibling, 'boolean') && sibling)\r\n parent.parentElement.replaceChild(child, parent);\r\n else if (!sibling)\r\n parent.appendChild(child);\r\n else\r\n parent.insertBefore(child, sibling);\r\n}\r\nfunction _$as(source, dest) {\r\n var childNodes = source.childNodes;\r\n var attributes = source.attributes;\r\n for (var i = 0; i < childNodes.length; i++) {\r\n _$a(dest, childNodes[i]);\r\n }\r\n for (var i = 0; i < attributes.length; i++) {\r\n var attr = attributes[i];\r\n dest.setAttributeNS(source.namespaceURI, attr.name, attr.value);\r\n }\r\n source.parentElement.replaceChild(dest, source);\r\n return dest;\r\n}\r\nfunction _$r(el, parent) {\r\n var root = parent || el.parentElement;\r\n if (root)\r\n root.removeChild(el);\r\n}\r\nfunction _$ce(tagName) {\r\n return document.createElement(tagName || 'div');\r\n}\r\nfunction _$cse(tagName) {\r\n return document.createElementNS('http://www.w3.org/2000/svg', tagName || 'svg');\r\n}\r\nfunction _$ct(content) {\r\n return document.createTextNode(content || '');\r\n}\r\nfunction _$cm(content) {\r\n return document.createComment(content || '');\r\n}\r\nfunction _$sa(el, attr, value) {\r\n el.setAttribute(attr, value);\r\n}\r\nfunction _$ga(el, attr) {\r\n return el.getAttribute(attr);\r\n}\r\nfunction _$al(el, event, handler) {\r\n el.addEventListener(event, handler, false);\r\n}\r\nfunction _$ul(el, event, oldHandler, newHandler) {\r\n _$rl(el, event, oldHandler);\r\n _$al(el, event, oldHandler = newHandler);\r\n return oldHandler;\r\n}\r\nfunction _$rl(el, event, handler) {\r\n el.removeEventListener(event, handler, false);\r\n}\r\nfunction _$bc(value) {\r\n var classes = '';\r\n if (_$isType(value, 'string')) {\r\n classes += \" \" + value;\r\n }\r\n else if (_$isArray(value)) {\r\n classes = value.map(_$bc).join(' ');\r\n }\r\n else if (_$isObject(value)) {\r\n for (var key in value)\r\n if (_$hasProp(value, key) && value[key])\r\n classes += \" \" + key;\r\n }\r\n return classes.trim();\r\n}\r\nfunction _$bs(value) {\r\n var el = _$ce();\r\n if (_$isObject(value)) {\r\n var style_1 = el.style;\r\n _$e(value, function (val, prop) {\r\n if (val !== style_1[prop]) {\r\n style_1[prop] = val;\r\n }\r\n });\r\n return style_1.cssText;\r\n }\r\n else if (_$isType(value, 'string')) {\r\n return value;\r\n }\r\n else {\r\n return '';\r\n }\r\n}\r\nfunction _$f(root, obj, loop) {\r\n var items = {}, loopParent, loopSibling;\r\n var globs = _$toArgs(arguments, 3);\r\n _$e(obj, function (item, i) { items[i] = loop.apply(null, [root, item, i].concat(globs)); });\r\n return {\r\n $create: function () {\r\n _$e(items, function (item) { item.$create(); });\r\n },\r\n $mount: function (parent, sibling) {\r\n loopParent = _$(parent);\r\n loopSibling = _$(sibling);\r\n _$e(items, function (item) { item.$mount(loopParent, loopSibling); });\r\n },\r\n $update: function (root, obj) {\r\n var globs = _$toArgs(arguments, 2);\r\n _$e(items, function (item, i) {\r\n if (obj[i]) {\r\n item.$update.apply(item, [root, obj[i], i].concat(globs));\r\n }\r\n else {\r\n item.$destroy();\r\n delete items[i];\r\n }\r\n });\r\n _$e(obj, function (item, i) {\r\n if (!items[i]) {\r\n items[i] = loop.apply(null, [root, item, i].concat(globs));\r\n items[i].$create();\r\n items[i].$mount(loopParent, loopSibling);\r\n }\r\n });\r\n },\r\n $destroy: function () {\r\n _$e(items, function (item) { item.$destroy(); });\r\n }\r\n };\r\n}\r\nfunction _$e(obj, cb) {\r\n for (var key in obj) {\r\n if (_$hasProp(obj, key)) {\r\n cb(obj[key], (isNaN(+key) ? key : +key));\r\n }\r\n }\r\n}\r\nfunction _$is(id, css) {\r\n var isNew = false;\r\n var style = _$(\"#\" + id, document.head);\r\n if (!style) {\r\n isNew = true;\r\n style = _$ce('style');\r\n style.id = id;\r\n _$sa(style, 'refs', '1');\r\n }\r\n if (style.textContent !== css) {\r\n style.textContent = css;\r\n }\r\n if (isNew) {\r\n _$a(document.head, style);\r\n }\r\n else {\r\n var count = +_$ga(style, 'refs');\r\n _$sa(style, 'refs', (++count).toString());\r\n }\r\n}\r\nfunction _$ds(id) {\r\n var style = _$(\"#\" + id, document.head);\r\n if (style) {\r\n var count = +_$ga(style, 'refs');\r\n if (--count === 0) {\r\n _$r(style, document.head);\r\n }\r\n else {\r\n _$sa(style, 'refs', count.toString());\r\n }\r\n }\r\n}\r\n//# sourceMappingURL=index.js.map\n// CONCATENATED MODULE: ./components/counter.html\n\nfunction _$tplCounter(_$state) {\n var _$frag, div_1, h3_1, txt_1, label_1, txt_2, strong_1, txt_3, setTxt_3, bindClassStrong_1, br_1, button_1, txt_4, clickEvent_1, handlerClickEvent_1, button_2, txt_5, clickEvent_2, handlerClickEvent_2;\n _$frag = _$d();\n setTxt_3 = function (_$state) {\n return _$state.count;\n };\n bindClassStrong_1 = function (_$state) {\n return _$bc(_$state.negative).trim();\n };\n clickEvent_1 = function (_$state) {\n _$state.increment();\n };\n clickEvent_2 = function (_$state) {\n _$state.decrement();\n };\n return {\n $create: function () {\n div_1 = _$ce();\n h3_1 = _$ce('h3');\n txt_1 = _$ct('Counter Example');\n label_1 = _$ce('label');\n txt_2 = _$ct('Counter: ');\n strong_1 = _$ce('strong');\n txt_3 = _$ct();\n txt_3.data = setTxt_3(_$state);\n br_1 = _$ce('br');\n button_1 = _$ce('button');\n txt_4 = _$ct('Increment');\n button_2 = _$ce('button');\n txt_5 = _$ct('Decrement');\n this.$hydrate();\n },\n $hydrate: function () {\n _$sa(h3_1, 'class', 'title is-3');\n _$sa(strong_1, 'class', _$toStr(bindClassStrong_1(_$state)));\n _$al(button_1, 'click', handlerClickEvent_1 = function (event) {\n clickEvent_1(_$state, event, button_1);\n });\n _$sa(button_1, 'class', 'button is-primary');\n _$al(button_2, 'click', handlerClickEvent_2 = function (event) {\n clickEvent_2(_$state, event, button_2);\n });\n _$sa(button_2, 'class', 'button is-danger');\n _$sa(div_1, 'class', 'container');\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$is('scope_13212076', '.negative {color:crimson;}');\n _$a(_$(parent), _$frag, _$(sibling));\n this.$siblingEl = _$(sibling);\n this.$parentEl = sibling && _$(sibling).parentElement || _$(parent);\n },\n $update: function (_$state) {\n var updateTxt_3 = setTxt_3(_$state);\n if (txt_3.data !== _$toStr(updateTxt_3)) {\n txt_3.data = updateTxt_3;\n }\n updateTxt_3 = void 0;\n var updateClassStrong_1 = _$toStr(bindClassStrong_1(_$state));\n if (_$ga(strong_1, 'class') !== updateClassStrong_1) {\n _$sa(strong_1, 'class', updateClassStrong_1);\n }\n updateClassStrong_1 = void 0;\n },\n $unmount: function () {\n _$a(h3_1, txt_1);\n _$a(div_1, h3_1);\n _$a(label_1, txt_2);\n _$a(div_1, label_1);\n _$a(strong_1, txt_3);\n _$a(div_1, strong_1);\n _$a(div_1, br_1);\n _$a(button_1, txt_4);\n _$a(div_1, button_1);\n _$a(button_2, txt_5);\n _$a(div_1, button_2);\n _$a(_$frag, div_1);\n },\n $destroy: function () {\n this.$unmount();\n this.$parent = null;\n this.$parentEl = null;\n this.$siblingEl = null;\n this.$children.splice(0, this.$children.length);\n _$ds('scope_13212076');\n _$rl(button_1, 'click', handlerClickEvent_1);\n _$rl(button_2, 'click', handlerClickEvent_2);\n delete _$state.$root;\n _$frag = div_1 = h3_1 = txt_1 = label_1 = txt_2 = strong_1 = txt_3 = setTxt_3 = bindClassStrong_1 = br_1 = button_1 = txt_4 = clickEvent_1 = handlerClickEvent_1 = button_2 = txt_5 = clickEvent_2 = handlerClickEvent_2 = void 0;\n }\n };\n}\nfunction Counter(_$attrs, _$parent) {\n _$CompCtr.call(this, _$attrs, _$tplCounter, {\n model: {\n count: 0,\n increment: function () {\n this.$set('count', this.count + 1);\n },\n decrement: function () {\n this.$set('count', this.count - 1);\n },\n get negative() {\n return { negative: this.count < 0 };\n }\n }\n }, _$parent);\n !_$parent && this.$create();\n}\nCounter.plugin = _$plugin;\nCounter.prototype = Object.create(_$CompCtr.prototype);\nCounter.prototype.constructor = Counter;\n/* harmony default export */ var counter = (Counter);\n// CONCATENATED MODULE: ./main.ts\n\r\nvar main_counter = new counter();\r\nmain_counter.$mount('main');\r\n\n\n//# sourceURL=webpack:///./main.ts_+_2_modules?"); +eval("\n// CONCATENATED MODULE: h:/trebor-repos/trebor/tools/index.js\nvar PROP_MAP = { p: '__TP__', v: 'value', _: '_value', s: '_subscribers', e: '_events', w: '_watchers', h: 'prototype' };\r\nvar PROPS = ['$slots', '$refs', '$filters', '$directives', '_events', '_watchers'];\r\nvar TPS = window[PROP_MAP.p] || (window[PROP_MAP.p] = []);\r\nvar _$assign = Object['assign'] || function (t) {\r\n for (var s = void 0, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s)\r\n if (_$hasProp(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n};\r\nfunction _$CompCtr(attrs, template, options, parent) {\r\n var self = this;\r\n var _$set = function (prop, value) { _$def(self, prop, { value: value, writable: true }); };\r\n if (!attrs)\r\n attrs = {};\r\n _$e(PROPS, function (prop) { _$def(self, prop, { value: {} }); });\r\n _$set('$parent', parent || null);\r\n _$set('$children', []);\r\n _$set(PROP_MAP.s, {});\r\n _$set('$options', options);\r\n var opts = self.$options;\r\n if (!opts.attrs)\r\n opts.attrs = {};\r\n if (!opts.children)\r\n opts.children = {};\r\n _$e(TPS, function (plugin) { plugin.fn.call(self, _$CompCtr, plugin.options); });\r\n if (opts.filters)\r\n _$assign(self.$filters, opts.filters);\r\n if (opts.directives)\r\n _$e(opts.directives, function (drt, k) { self.$directives[k] = _$drt(drt); });\r\n _$e(opts.attrs, function (attrOps, key) {\r\n _$def(self, (_$isType(key, 'number') ? attrOps : key), {\r\n get: function () {\r\n if (_$isStr(attrOps)) {\r\n var value = attrs[attrOps];\r\n return _$isFunction(value) ? value() : value;\r\n }\r\n else {\r\n if (!_$hasProp(attrs, key) && attrOps.required) {\r\n return console.error(\"Attribute '\" + key + \"' is required.\");\r\n }\r\n else {\r\n var value = _$isFunction(attrs[key]) ? attrs[key]() : attrs[key];\r\n if (value === void 0 && _$hasProp(attrOps, 'default')) {\r\n var def = attrOps.default;\r\n value = _$isFunction(def) ? def() : def;\r\n }\r\n var typ = attrOps.type;\r\n if (typ && !_$isType(value, typ) && attrOps.required) {\r\n return console.error(\"Attribute '\" + key + \"' must be type '\" + typ + \"'.\");\r\n }\r\n value = _$toType(value, value === void 0 ? 'undefined' : typ, self, key);\r\n if (value !== void 0 && _$hasProp(attrOps, 'validator')) {\r\n var validator = attrOps.validator;\r\n if (_$isFunction(validator) && !validator(value)) {\r\n return console.error(\"Assigment '\" + key + \"'='\" + JSON.stringify(value) + \"' invalid.\");\r\n }\r\n }\r\n return value;\r\n }\r\n }\r\n },\r\n set: function () {\r\n console.error(\"'\" + key + \"' is read only.\");\r\n },\r\n enumerable: true, configurable: true\r\n });\r\n });\r\n var data = opts.model || {};\r\n var _loop_1 = function (key) {\r\n if (_$hasProp(data, key)) {\r\n var desc = Object.getOwnPropertyDescriptor(data, key);\r\n if (desc.value && _$isArray(desc.value)) {\r\n desc.value = new _$List(desc.value, self, key);\r\n }\r\n else {\r\n if (desc.get) {\r\n var getter_1 = desc.get;\r\n desc.get = function () {\r\n var value = getter_1.call(self);\r\n if (_$isArray(value))\r\n value = new _$List(value, self, key);\r\n return value;\r\n };\r\n }\r\n if (desc.set) {\r\n var setter_1 = desc.set;\r\n desc.set = function (v) {\r\n if (_$isArray(v))\r\n v = new _$List(v, self, key);\r\n setter_1.call(self, v);\r\n };\r\n }\r\n }\r\n _$def(self, key, desc);\r\n }\r\n };\r\n for (var key in data) {\r\n _loop_1(key);\r\n }\r\n var tpl = template(self);\r\n _$e(tpl, function (value, key) {\r\n _$def(self, key, {\r\n value: (function (key) {\r\n var hook = key[1].toUpperCase() + key.slice(2);\r\n var bhook = opts[\"before\" + hook];\r\n var ahook = opts[\"after\" + hook];\r\n return function () {\r\n bhook && bhook.call(this);\r\n key.slice(1) === 'update' ? value.call(this, this) : value.apply(this, arguments);\r\n ahook && ahook.call(this);\r\n };\r\n })(key)\r\n });\r\n });\r\n _$def(self, '$data', {\r\n get: function () {\r\n return _$toPlainObj(this);\r\n }\r\n });\r\n}\r\nfunction _$isValueAttr(attr) {\r\n return attr === 'value';\r\n}\r\nfunction _$subs(dep, listener) {\r\n if (!this[PROP_MAP.s][dep]) {\r\n this[PROP_MAP.s][dep] = [];\r\n }\r\n return this[PROP_MAP.s][dep].push(listener.bind(this)) - 1;\r\n}\r\nfunction _$def(obj, key, desc) {\r\n Object.defineProperty(obj, key, desc);\r\n}\r\n_$assign(_$CompCtr[PROP_MAP.h], {\r\n $get: function (path) {\r\n return _$accesor(this, path);\r\n },\r\n $set: function (path, value) {\r\n _$accesor(this, path, value);\r\n },\r\n $on: function (event, handler) {\r\n var _this = this;\r\n if (!this[PROP_MAP.e][event]) {\r\n this[PROP_MAP.e][event] = [];\r\n }\r\n var i = this[PROP_MAP.e][event].push(handler);\r\n return {\r\n $off: function () {\r\n _this[PROP_MAP.e][event].splice(i - 1, 1);\r\n }\r\n };\r\n },\r\n $once: function (event, handler) {\r\n var e = this.$on(event, function (args) {\r\n handler(args);\r\n e.$off();\r\n });\r\n },\r\n $fire: function (event, data) {\r\n if (this[PROP_MAP.e][event]) {\r\n _$e(this[PROP_MAP.e][event], function (handler) { handler(data); });\r\n }\r\n },\r\n $notify: function (key) {\r\n if (this[PROP_MAP.s][key]) {\r\n _$e(this[PROP_MAP.s][key], function (suscriber) { suscriber(); });\r\n }\r\n },\r\n $observe: function (deps, listener) {\r\n var _this = this;\r\n var subs = [];\r\n if (_$isArray(deps)) {\r\n _$e(deps, function (dep) {\r\n subs.push({ sub: dep, i: _$subs.call(_this, dep, listener) });\r\n });\r\n }\r\n else {\r\n subs.push({ sub: deps, i: _$subs.call(this, deps, listener) });\r\n }\r\n return {\r\n $unobserve: function () {\r\n _$e(subs, function (sub) {\r\n _this[PROP_MAP.s][sub.sub].splice(sub.i, 1);\r\n });\r\n }\r\n };\r\n },\r\n $watch: function (key, watcher) {\r\n var _this = this;\r\n if (!this[PROP_MAP.w][key]) {\r\n this[PROP_MAP.w][key] = [];\r\n }\r\n var i = this[PROP_MAP.w][key].push(watcher.bind(this));\r\n return {\r\n $unwatch: function () {\r\n _this[PROP_MAP.w][key].splice(i - 1, 1);\r\n }\r\n };\r\n }\r\n});\r\nvar array = Array[PROP_MAP.h];\r\nfunction _$toArgs(args, start) {\r\n if (start === void 0) { start = 0; }\r\n return array.slice.call(args, start);\r\n}\r\nfunction _$arrayValues(list, value, root, key) {\r\n array.push.apply(list, value.map(function (v, i) {\r\n if (list.length !== 0)\r\n i += list.length;\r\n return !(_$isType(v, _$List)) && _$isArray(v) ? new _$List(v, root, key + \".\" + i) : v;\r\n }));\r\n}\r\nfunction _$List(value, root, key) {\r\n var self = this;\r\n Array.apply(self, [value.length]);\r\n var desc = { writable: false, configurable: false, enumerable: false };\r\n _$def(self, '_key', _$assign({ value: key }, desc));\r\n _$def(self, '_root', _$assign({ value: root }, desc));\r\n _$arrayValues(self, value, root, key);\r\n desc.writable = true;\r\n _$def(self, 'length', _$assign({ value: self.length }, desc));\r\n}\r\n_$extends(_$List, Array);\r\n['pop', 'push', 'reverse', 'shift', 'sort', 'fill', 'unshift', 'splice'].forEach(function (method) {\r\n _$List[PROP_MAP.h][method] = function () {\r\n var self = this;\r\n var old = self.slice();\r\n var result;\r\n if (method === 'push') {\r\n _$arrayValues(self, _$toArgs(arguments), self._root, self._key);\r\n result = self.length;\r\n }\r\n else {\r\n result = array[method].apply(self, arguments);\r\n }\r\n _$dispatch(self._root, self._key, old, self.slice());\r\n return result;\r\n };\r\n});\r\n_$List[PROP_MAP.h].pull = function (index) {\r\n var self = this;\r\n var items = _$toArgs(arguments, 1);\r\n var length = self.length;\r\n if (index > length) {\r\n length = index + 1;\r\n var pull = new Array(index - self.length);\r\n pull.push.apply(pull, items);\r\n for (var i = 0; i < length; i++) {\r\n if (i === index) {\r\n self.push.apply(self, pull);\r\n }\r\n }\r\n }\r\n else {\r\n self.splice.apply(self, [index, 1].concat(items));\r\n }\r\n};\r\nfunction _$dispatch(root, key, oldVal, value) {\r\n root.$notify(key);\r\n if (root[PROP_MAP.w][key]) {\r\n _$e(root[PROP_MAP.w][key], function (watcher) { watcher(oldVal, value); });\r\n }\r\n root.$update();\r\n}\r\nfunction _$extends(ctor, exts) {\r\n ctor['plugin'] = function (fn, options) {\r\n TPS.push({ options: options, fn: fn });\r\n };\r\n ctor[PROP_MAP.h] = Object.create(exts[PROP_MAP.h]);\r\n ctor[PROP_MAP.h].constructor = ctor;\r\n}\r\nfunction _$isType(value, type) {\r\n return _$type(type) === 'string' ? type.split('|').some(function (t) { return t.trim() === _$type(value); }) : value instanceof type;\r\n}\r\nfunction _$apply(callee, args, globs, thisArg) {\r\n if (thisArg === void 0) { thisArg = null; }\r\n return callee.apply(thisArg, args.concat(globs));\r\n}\r\nfunction _$isObject(obj) {\r\n return _$isType(obj, 'object');\r\n}\r\nfunction _$isArray(obj) {\r\n return Array.isArray ? Array.isArray(obj) : _$isType(obj, 'array');\r\n}\r\nfunction _$isFunction(obj) {\r\n return _$isType(obj, 'function');\r\n}\r\nfunction _$isStr(obj) {\r\n return _$isType(obj, 'string');\r\n}\r\nfunction _$toType(value, type, root, key) {\r\n switch (type) {\r\n case 'date':\r\n return new Date(value);\r\n case 'string':\r\n return _$toStr(value);\r\n case 'number':\r\n return +value;\r\n case 'boolean':\r\n return _$isStr(value) && !value ? true : !!value;\r\n case 'array':\r\n return _$isType(value, _$List) ? value : new _$List(value, root, key);\r\n default:\r\n return value;\r\n }\r\n}\r\nfunction _$type(obj) {\r\n return / (\\w+)/.exec(({}).toString.call(obj))[1].toLowerCase();\r\n}\r\nfunction _$hasProp(obj, prop) {\r\n return obj.hasOwnProperty(prop);\r\n}\r\nfunction _$drt(dd) {\r\n var hasProp = function (prop, instance, options, element) { return _$isObject(dd) && dd[prop] && dd[prop](instance, options, element); };\r\n return {\r\n $init: function (instance, options, element) {\r\n hasProp('$init', instance, options, element);\r\n },\r\n $inserted: function (instance, options, element) {\r\n hasProp('$inserted', instance, options, element);\r\n },\r\n $update: function (instance, options, element) {\r\n if (_$isFunction(dd)) {\r\n dd(instance, options, element);\r\n }\r\n else {\r\n hasProp('$update', instance, options, element);\r\n }\r\n },\r\n $destroy: function (instance, options, element) {\r\n hasProp('$destroy', instance, options, element);\r\n }\r\n };\r\n}\r\nfunction _$noop() { }\r\nfunction _$add(inst, Child, attrs) {\r\n var child = null;\r\n if (Child) {\r\n child = new Child(attrs, inst);\r\n inst.$children.push(child);\r\n }\r\n return child;\r\n}\r\nfunction _$remove(inst, child) {\r\n var index = inst.$children.indexOf(child);\r\n index >= 0 && inst.$children.splice(index, 1);\r\n}\r\nfunction _$toStr(obj) {\r\n var str = _$type(obj);\r\n return !/null|undefined/.test(str) ? obj.toString() : str;\r\n}\r\nfunction _$toPlainObj(obj) {\r\n var data = {};\r\n _$e(_$isObject(obj) ? obj : {}, function (_v, k) {\r\n if (k[0] !== '$' && !_$isFunction(obj[k])) {\r\n if (_$isType(obj[k], _$List)) {\r\n data[k] = obj[k].map(_$toPlainObj);\r\n }\r\n else if (_$isObject(obj[k])) {\r\n data[k] = _$toPlainObj(obj[k]);\r\n }\r\n else {\r\n data[k] = obj[k];\r\n }\r\n }\r\n });\r\n return _$isObject(obj) ? data : obj;\r\n}\r\nfunction _$setRef(refs, prop, node) {\r\n if (!_$hasProp(refs, prop)) {\r\n var value_1 = [];\r\n _$def(refs, prop, {\r\n get: function () { return value_1.length <= 1 ? value_1[0] : value_1; },\r\n set: function (val) { val && !~value_1.indexOf(val) && value_1.push(val); },\r\n enumerable: true, configurable: true\r\n });\r\n }\r\n refs[prop] = node;\r\n}\r\nfunction _$accesor(object, path, value) {\r\n return path.split('.').reduce(function (obj, key, i, arr) {\r\n if (_$isType(value, 'undefined')) {\r\n if (obj == null) {\r\n arr.splice(0, arr.length);\r\n return i > 0 && obj === null ? obj : undefined;\r\n }\r\n }\r\n else {\r\n if (i === arr.length - 1) {\r\n if (_$isType(obj, _$List) && _$toStr(+key) === key) {\r\n obj.pull(+key, value);\r\n }\r\n else {\r\n var oldVal = obj[key];\r\n obj[key] = !_$isType(value, _$List) && _$isArray(value) ? new _$List(value, object, key) : value;\r\n _$dispatch(object, path, oldVal, obj[key]);\r\n }\r\n }\r\n else if (!_$isObject(obj[key])) {\r\n obj[key] = {};\r\n }\r\n }\r\n return obj ? obj[key] : null;\r\n }, object);\r\n}\r\nfunction _$emptyElse() {\r\n return { type: 'empty-else', $create: _$noop, $mount: _$noop, $update: _$noop, $destroy: _$noop };\r\n}\r\nfunction _$isKey(event, key) {\r\n return event.key.toLowerCase() === key || !!event[key + \"Key\"];\r\n}\r\nfunction _$bindGroup(input, selection) {\r\n var _value = _$gv(input);\r\n var _$index = selection.indexOf(_value);\r\n input.checked && !~_$index ? selection.push(_value) : selection.splice(_$index, 1);\r\n}\r\nfunction _$bindMultiSelect(select, selections) {\r\n if (!selections.length)\r\n return;\r\n var options = select.options;\r\n for (var i = 0; i < options.length; i++) {\r\n options[i].selected = !!~selections.indexOf(_$gv(options[i]));\r\n }\r\n}\r\nfunction _$updateMultiSelect(select, obj, prop) {\r\n var items = [];\r\n var selection = obj[prop];\r\n var selectedOptions = select.selectedOptions;\r\n for (var i = 0; i < selectedOptions.length; i++) {\r\n items.push(_$gv(selectedOptions[i]));\r\n }\r\n obj[prop] = new _$List(items, selection['_root'], selection['_key']);\r\n obj.$update();\r\n}\r\nfunction _$(selector, parent) {\r\n return _$isStr(selector) ? (parent || document).querySelector(selector) : selector;\r\n}\r\nfunction _$d() {\r\n return document.createDocumentFragment();\r\n}\r\nfunction _$a(parent, child, sibling) {\r\n if (_$isType(sibling, 'boolean') && sibling)\r\n parent.parentElement.replaceChild(child, parent);\r\n else if (!sibling)\r\n parent.appendChild(child);\r\n else\r\n parent.insertBefore(child, sibling);\r\n}\r\nfunction _$as(source, dest) {\r\n var childNodes = source.childNodes, attributes = source.attributes;\r\n for (var i = 0; i < childNodes.length; i++) {\r\n _$a(dest, childNodes[i]);\r\n }\r\n for (var i = 0; i < attributes.length; i++) {\r\n var attr = attributes[i];\r\n dest.setAttributeNS(source.namespaceURI, attr.name, attr.value);\r\n }\r\n source.parentElement.replaceChild(dest, source);\r\n return dest;\r\n}\r\nfunction _$r(el, parent) {\r\n var root = parent || el.parentElement;\r\n if (root)\r\n root.removeChild(el);\r\n}\r\nfunction _$ce(tagName) {\r\n return document.createElement(tagName || 'div');\r\n}\r\nfunction _$cse(tagName) {\r\n return document.createElementNS('http://www.w3.org/2000/svg', tagName || 'svg');\r\n}\r\nfunction _$ct(content) {\r\n return document.createTextNode(content || '');\r\n}\r\nfunction _$cm(content) {\r\n return document.createComment(content || '');\r\n}\r\nfunction _$sa(el, attrAndValue) {\r\n var attr = attrAndValue[0], value = attrAndValue[1];\r\n el.setAttribute(attr, _$toStr(value));\r\n if (_$isValueAttr(attr) && !_$isStr(value))\r\n el[PROP_MAP._] = value;\r\n}\r\nfunction _$ga(el, attr) {\r\n return _$isValueAttr(attr) ? _$gv(el) : el.getAttribute(attr);\r\n}\r\nfunction _$gv(el) {\r\n return _$hasProp(el, PROP_MAP._) ? el[PROP_MAP._] : el[PROP_MAP.v];\r\n}\r\nfunction _$al(el, event, handler) {\r\n el.addEventListener(event, handler, false);\r\n}\r\nfunction _$ul(el, event, oldHandler, newHandler) {\r\n _$rl(el, event, oldHandler);\r\n _$al(el, event, oldHandler = newHandler);\r\n return oldHandler;\r\n}\r\nfunction _$rl(el, event, handler) {\r\n el.removeEventListener(event, handler, false);\r\n}\r\nfunction _$bc(value) {\r\n var classes = '';\r\n if (_$isStr(value)) {\r\n classes += \" \" + value;\r\n }\r\n else if (_$isArray(value)) {\r\n classes = value.map(_$bc).join(' ');\r\n }\r\n else if (_$isObject(value)) {\r\n for (var key in value)\r\n if (_$hasProp(value, key) && value[key])\r\n classes += \" \" + key;\r\n }\r\n return classes.trim();\r\n}\r\nfunction _$bs(value) {\r\n var el = _$ce();\r\n if (_$isObject(value)) {\r\n var style_1 = el.style;\r\n _$e(value, function (val, prop) {\r\n if (val !== style_1[prop])\r\n style_1[prop] = val;\r\n });\r\n return style_1.cssText;\r\n }\r\n else if (_$isStr(value)) {\r\n return value;\r\n }\r\n else {\r\n return '';\r\n }\r\n}\r\nfunction _$cu(block, condition, parent, anchor, inst) {\r\n var globs = _$toArgs(arguments, 5);\r\n if (block && block.type === _$apply(condition, [inst], globs).type) {\r\n _$apply(block.$update, [inst], globs, block);\r\n }\r\n else {\r\n block && block.$destroy();\r\n block = _$apply(condition, [inst], globs);\r\n block.$create();\r\n block.$mount(parent || inst.$parentEl, anchor);\r\n }\r\n return block;\r\n}\r\nfunction _$bba(el, attrAndValue) {\r\n var attr = attrAndValue[0], value = attrAndValue[1];\r\n el[attr] = value == null || value === false ? (el.removeAttribute(attr), false) : (_$sa(el, [attr, '']), true);\r\n}\r\nfunction _$bu(el, binding) {\r\n var attr = binding[0], value = binding[1];\r\n var _value = _$toStr(value);\r\n if (_$isValueAttr(attr)) {\r\n if (el[attr] !== _value)\r\n el[attr] = _value;\r\n el[PROP_MAP._] = value;\r\n }\r\n else if (_$ga(el, attr) !== _value) {\r\n _$sa(el, [attr, _value]);\r\n }\r\n}\r\nfunction _$tu(text, value) {\r\n if (text.data !== (value = _$toStr(value)))\r\n text.data = value;\r\n}\r\nfunction _$nu(node, tag) {\r\n return tag.toUpperCase() !== node.tagName ? _$as(node, _$ce(tag)) : node;\r\n}\r\nfunction _$rr(refs, prop, node) {\r\n var nodes = refs[prop];\r\n _$isArray(nodes) ? refs[prop].splice(nodes.indexOf(node), 1) : (delete refs[prop]);\r\n}\r\nfunction _$hu(node, value) {\r\n if (node.innerHTML !== (value = _$toStr(value)))\r\n node.innerHTML = value;\r\n}\r\nfunction _$pu(parent, Ctor, inst, value, attrs, el, sibling) {\r\n if (value === Ctor) {\r\n inst && inst.$update();\r\n }\r\n else {\r\n Ctor = value;\r\n if (inst) {\r\n inst.$destroy();\r\n _$remove(parent, inst);\r\n }\r\n if (inst) {\r\n inst = _$add(parent, Ctor, attrs);\r\n inst.$create();\r\n inst.$mount(el, sibling);\r\n }\r\n }\r\n return [inst, Ctor];\r\n}\r\nfunction _$f(root, obj, loop) {\r\n var items = {}, loopParent, loopSibling;\r\n var globs = _$toArgs(arguments, 3);\r\n _$e(obj, function (item, i, index) { items[i] = _$apply(loop, [root, item, i, index], globs); });\r\n return {\r\n $create: function () {\r\n _$e(items, function (item) { item.$create(); });\r\n },\r\n $mount: function (parent, sibling) {\r\n loopParent = _$(parent);\r\n loopSibling = _$(sibling);\r\n _$e(items, function (item) { item.$mount(loopParent, loopSibling); });\r\n },\r\n $update: function (root, obj) {\r\n var globs = _$toArgs(arguments, 2);\r\n _$e(items, function (item, i, index) {\r\n if (obj[i]) {\r\n _$apply(item.$update, [root, obj[i], i, index], globs, item);\r\n }\r\n else {\r\n item.$destroy();\r\n delete items[i];\r\n }\r\n });\r\n _$e(obj, function (item, i, index) {\r\n if (!items[i]) {\r\n items[i] = _$apply(loop, [root, item, i, index], globs);\r\n items[i].$create();\r\n items[i].$mount(loopParent, loopSibling);\r\n }\r\n });\r\n },\r\n $destroy: function () {\r\n _$e(items, function (item) { item.$destroy(); });\r\n }\r\n };\r\n}\r\nfunction _$e(obj, cb) {\r\n var i = 0;\r\n for (var key in obj) {\r\n if (_$hasProp(obj, key)) {\r\n cb(obj[key], (isNaN(+key) ? key : +key), i++);\r\n }\r\n }\r\n}\r\nfunction _$is(id, css) {\r\n var isNew = false;\r\n var style = _$(\"#\" + id, document.head);\r\n if (!style) {\r\n isNew = true;\r\n style = _$ce('style');\r\n style.id = id;\r\n _$sa(style, ['refs', 1]);\r\n }\r\n if (style.textContent !== css) {\r\n style.textContent = css;\r\n }\r\n if (isNew) {\r\n _$a(document.head, style);\r\n }\r\n else {\r\n var count = +_$ga(style, 'refs');\r\n _$sa(style, ['refs', ++count]);\r\n }\r\n}\r\nfunction _$ds(id) {\r\n var style = _$(\"#\" + id, document.head);\r\n if (style) {\r\n var count = +_$ga(style, 'refs');\r\n if (--count === 0) {\r\n _$r(style, document.head);\r\n }\r\n else {\r\n _$sa(style, ['refs', count]);\r\n }\r\n }\r\n}\r\n//# sourceMappingURL=index.js.map\n// CONCATENATED MODULE: ./components/counter.html\n\r\nfunction _$tplCounter(_$state) {\r\n var _$frag, div_1, h3_1, label_1, strong_1, txt_1, setTxt_1, bindClassStrong_1, br_1, button_1, txt_2, clickEvent_1, handlerClickEvent_1, button_2, txt_3, clickEvent_2, handlerClickEvent_2;\r\n _$frag = _$d();\r\n setTxt_1 = function(_$state) {\r\n return _$state.count;\r\n };\r\n bindClassStrong_1 = function(_$state) {\r\n return ['class', _$bc(_$state.negative).trim()];\r\n };\r\n clickEvent_1 = function(_$state) {\r\n _$state.increment();\r\n };\r\n clickEvent_2 = function(_$state) {\r\n _$state.decrement();\r\n };\r\n return {\r\n $create: function() {\r\n div_1 = _$ce();\r\n h3_1 = _$ce('h3');\r\n h3_1.innerHTML = 'Counter Example';\r\n label_1 = _$ce('label');\r\n label_1.innerHTML = 'Counter: ';\r\n strong_1 = _$ce('strong');\r\n txt_1 = _$ct();\r\n txt_1.data = setTxt_1(_$state);\r\n br_1 = _$ce('br');\r\n br_1.innerHTML = '';\r\n button_1 = _$ce('button');\r\n txt_2 = _$ct('Increment');\r\n button_2 = _$ce('button');\r\n txt_3 = _$ct('Decrement');\r\n _$sa(h3_1, ['class', 'title is-3']);\r\n _$sa(strong_1, bindClassStrong_1(_$state));\r\n _$sa(button_1, ['class', 'button is-primary']);\r\n _$al(button_1, 'click', handlerClickEvent_1 = function(event) {\r\n clickEvent_1(_$state, event, button_1);\r\n });\r\n _$sa(button_2, ['class', 'button is-danger']);\r\n _$al(button_2, 'click', handlerClickEvent_2 = function(event) {\r\n clickEvent_2(_$state, event, button_2);\r\n });\r\n _$sa(div_1, ['class', 'container']);\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$is('scope_a64f8780', '.negative {color:crimson;}');\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n this.$siblingEl = _$(sibling);\r\n this.$parentEl = sibling && _$(sibling).parentElement || _$(parent);\r\n },\r\n\r\n $update: function(_$state) {\r\n _$tu(txt_1, setTxt_1(_$state));\r\n _$bu(strong_1, bindClassStrong_1(_$state));\r\n },\r\n\r\n $unmount: function() {\r\n _$a(div_1, h3_1);\r\n _$a(div_1, label_1);\r\n _$a(strong_1, txt_1);\r\n _$a(div_1, strong_1);\r\n _$a(div_1, br_1);\r\n _$a(button_1, txt_2);\r\n _$a(div_1, button_1);\r\n _$a(button_2, txt_3);\r\n _$a(div_1, button_2);\r\n _$a(_$frag, div_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n this.$parent = null;\r\n this.$parentEl = null;\r\n this.$siblingEl = null;\r\n this.$children.splice(0, this.$children.length);\r\n _$ds('scope_a64f8780');\r\n _$rl(button_1, 'click', handlerClickEvent_1);\r\n _$rl(button_2, 'click', handlerClickEvent_2);\r\n delete _$state.$root;\r\n _$frag = div_1 = h3_1 = label_1 = strong_1 = txt_1 = setTxt_1 = bindClassStrong_1 = br_1 = button_1 = txt_2 = clickEvent_1 = handlerClickEvent_1 = button_2 = txt_3 = clickEvent_2 = handlerClickEvent_2 = void 0;\r\n }\r\n };\r\n}\r\nfunction Counter(_$attrs, _$parent) {\r\n _$CompCtr.call(this, _$attrs, _$tplCounter, {\r\n model: {\r\n count: 0,\r\n\r\n increment: function() {\r\n this.$set('count', this.count + 1);\r\n },\r\n\r\n decrement: function() {\r\n this.$set('count', this.count - 1);\r\n },\r\n\r\n get negative() {\r\n return {\r\n negative: this.count < 0\r\n };\r\n }\r\n }\r\n }, _$parent);\r\n !_$parent && this.$create();\r\n}\r\n_$extends(Counter, _$CompCtr);\r\n/* harmony default export */ var counter = (Counter);\r\n\n// CONCATENATED MODULE: ./main.ts\n\r\nvar main_counter = new counter();\r\nmain_counter.$mount('main');\r\n\n\n//# sourceURL=webpack:///./main.ts_+_2_modules?"); /***/ }) diff --git a/examples/dynamic-component/dist/js/dynamic.js b/examples/dynamic-component/dist/js/dynamic.js index 3b0c32a..43dd42c 100644 --- a/examples/dynamic-component/dist/js/dynamic.js +++ b/examples/dynamic-component/dist/js/dynamic.js @@ -94,7 +94,7 @@ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("\n// CONCATENATED MODULE: h:/trebor-repos/trebor/tools/index.js\nvar PROP_MAP = { p: '__TP__', v: 'value', _: '_value', s: '_subscribers', e: '_events', w: '_watchers', h: 'prototype' };\r\nvar PROPS = ['$slots', '$refs', '$filters', '$directives', '_events', '_watchers'];\r\nvar TPS = window[PROP_MAP.p] || (window[PROP_MAP.p] = []);\r\nvar _$assign = Object['assign'] || function (t) {\r\n for (var s = void 0, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s)\r\n if (_$hasProp(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n};\r\nfunction _$CompCtr(attrs, template, options, parent) {\r\n var self = this;\r\n var _$set = function (prop, value) { _$def(self, prop, { value: value, writable: true }); };\r\n if (!attrs)\r\n attrs = {};\r\n _$e(PROPS, function (prop) { _$def(self, prop, { value: {} }); });\r\n _$set('$parent', parent || null);\r\n _$set('$children', []);\r\n _$set(PROP_MAP.s, {});\r\n _$set('$options', options);\r\n var opts = self.$options;\r\n if (!opts.attrs)\r\n opts.attrs = {};\r\n if (!opts.children)\r\n opts.children = {};\r\n _$e(TPS, function (plugin) { plugin.fn.call(self, _$CompCtr, plugin.options); });\r\n if (opts.filters)\r\n _$assign(self.$filters, opts.filters);\r\n if (opts.directives)\r\n _$e(opts.directives, function (drt, k) { self.$directives[k] = _$drt(drt); });\r\n _$e(opts.attrs, function (attrOps, key) {\r\n _$def(self, (_$isType(key, 'number') ? attrOps : key), {\r\n get: function () {\r\n if (_$isStr(attrOps)) {\r\n var value = attrs[attrOps];\r\n return _$isFunction(value) ? value() : value;\r\n }\r\n else {\r\n if (!_$hasProp(attrs, key) && attrOps.required) {\r\n return console.error(\"Attribute '\" + key + \"' is required.\");\r\n }\r\n else {\r\n var value = _$isFunction(attrs[key]) ? attrs[key]() : attrs[key];\r\n if (value === void 0 && _$hasProp(attrOps, 'default')) {\r\n var def = attrOps.default;\r\n value = _$isFunction(def) ? def() : def;\r\n }\r\n var typ = attrOps.type;\r\n if (typ && !_$isType(value, typ) && attrOps.required) {\r\n return console.error(\"Attribute '\" + key + \"' must be type '\" + typ + \"'.\");\r\n }\r\n value = _$toType(value, value === void 0 ? 'undefined' : typ, self, key);\r\n if (value !== void 0 && _$hasProp(attrOps, 'validator')) {\r\n var validator = attrOps.validator;\r\n if (_$isFunction(validator) && !validator(value)) {\r\n return console.error(\"Assigment '\" + key + \"'='\" + JSON.stringify(value) + \"' invalid.\");\r\n }\r\n }\r\n return value;\r\n }\r\n }\r\n },\r\n set: function () {\r\n console.error(\"'\" + key + \"' is read only.\");\r\n },\r\n enumerable: true, configurable: true\r\n });\r\n });\r\n var data = opts.model || {};\r\n var _loop_1 = function (key) {\r\n if (_$hasProp(data, key)) {\r\n var desc = Object.getOwnPropertyDescriptor(data, key);\r\n if (desc.value && _$isArray(desc.value)) {\r\n desc.value = new _$List(desc.value, self, key);\r\n }\r\n else {\r\n if (desc.get) {\r\n var getter_1 = desc.get;\r\n desc.get = function () {\r\n var value = getter_1.call(self);\r\n if (_$isArray(value))\r\n value = new _$List(value, self, key);\r\n return value;\r\n };\r\n }\r\n if (desc.set) {\r\n var setter_1 = desc.set;\r\n desc.set = function (v) {\r\n if (_$isArray(v))\r\n v = new _$List(v, self, key);\r\n setter_1.call(self, v);\r\n };\r\n }\r\n }\r\n _$def(self, key, desc);\r\n }\r\n };\r\n for (var key in data) {\r\n _loop_1(key);\r\n }\r\n var tpl = template(self);\r\n _$e(tpl, function (value, key) {\r\n _$def(self, key, {\r\n value: (function (key) {\r\n var hook = key[1].toUpperCase() + key.slice(2);\r\n var bhook = opts[\"before\" + hook];\r\n var ahook = opts[\"after\" + hook];\r\n return function () {\r\n bhook && bhook.call(this);\r\n key.slice(1) === 'update' ? value.call(this, this) : value.apply(this, arguments);\r\n ahook && ahook.call(this);\r\n };\r\n })(key)\r\n });\r\n });\r\n _$def(self, '$data', {\r\n get: function () {\r\n return _$toPlainObj(this);\r\n }\r\n });\r\n}\r\nfunction _$isValueAttr(attr) {\r\n return attr === 'value';\r\n}\r\nfunction _$subs(dep, listener) {\r\n if (!this[PROP_MAP.s][dep]) {\r\n this[PROP_MAP.s][dep] = [];\r\n }\r\n return this[PROP_MAP.s][dep].push(listener.bind(this)) - 1;\r\n}\r\nfunction _$def(obj, key, desc) {\r\n Object.defineProperty(obj, key, desc);\r\n}\r\n_$assign(_$CompCtr[PROP_MAP.h], {\r\n $get: function (path) {\r\n return _$accesor(this, path);\r\n },\r\n $set: function (path, value) {\r\n _$accesor(this, path, value);\r\n },\r\n $on: function (event, handler) {\r\n var _this = this;\r\n if (!this[PROP_MAP.e][event]) {\r\n this[PROP_MAP.e][event] = [];\r\n }\r\n var i = this[PROP_MAP.e][event].push(handler);\r\n return {\r\n $off: function () {\r\n _this[PROP_MAP.e][event].splice(i - 1, 1);\r\n }\r\n };\r\n },\r\n $once: function (event, handler) {\r\n var e = this.$on(event, function (args) {\r\n handler(args);\r\n e.$off();\r\n });\r\n },\r\n $fire: function (event, data) {\r\n if (this[PROP_MAP.e][event]) {\r\n _$e(this[PROP_MAP.e][event], function (handler) { handler(data); });\r\n }\r\n },\r\n $notify: function (key) {\r\n if (this[PROP_MAP.s][key]) {\r\n _$e(this[PROP_MAP.s][key], function (suscriber) { suscriber(); });\r\n }\r\n },\r\n $observe: function (deps, listener) {\r\n var _this = this;\r\n var subs = [];\r\n if (_$isArray(deps)) {\r\n _$e(deps, function (dep) {\r\n subs.push({ sub: dep, i: _$subs.call(_this, dep, listener) });\r\n });\r\n }\r\n else {\r\n subs.push({ sub: deps, i: _$subs.call(this, deps, listener) });\r\n }\r\n return {\r\n $unobserve: function () {\r\n _$e(subs, function (sub) {\r\n _this[PROP_MAP.s][sub.sub].splice(sub.i, 1);\r\n });\r\n }\r\n };\r\n },\r\n $watch: function (key, watcher) {\r\n var _this = this;\r\n if (!this[PROP_MAP.w][key]) {\r\n this[PROP_MAP.w][key] = [];\r\n }\r\n var i = this[PROP_MAP.w][key].push(watcher.bind(this));\r\n return {\r\n $unwatch: function () {\r\n _this[PROP_MAP.w][key].splice(i - 1, 1);\r\n }\r\n };\r\n }\r\n});\r\nvar array = Array[PROP_MAP.h];\r\nfunction _$toArgs(args, start) {\r\n if (start === void 0) { start = 0; }\r\n return array.slice.call(args, start);\r\n}\r\nfunction _$arrayValues(list, value, root, key) {\r\n array.push.apply(list, value.map(function (v, i) {\r\n if (list.length !== 0)\r\n i += list.length;\r\n return !(_$isType(v, _$List)) && _$isArray(v) ? new _$List(v, root, key + \".\" + i) : v;\r\n }));\r\n}\r\nfunction _$List(value, root, key) {\r\n var self = this;\r\n Array.apply(self, [value.length]);\r\n var desc = { writable: false, configurable: false, enumerable: false };\r\n _$def(self, '_key', _$assign({ value: key }, desc));\r\n _$def(self, '_root', _$assign({ value: root }, desc));\r\n _$arrayValues(self, value, root, key);\r\n desc.writable = true;\r\n _$def(self, 'length', _$assign({ value: self.length }, desc));\r\n}\r\n_$extends(_$List, Array);\r\n['pop', 'push', 'reverse', 'shift', 'sort', 'fill', 'unshift', 'splice'].forEach(function (method) {\r\n _$List[PROP_MAP.h][method] = function () {\r\n var self = this;\r\n var old = self.slice();\r\n var result;\r\n if (method === 'push') {\r\n _$arrayValues(self, _$toArgs(arguments), self._root, self._key);\r\n result = self.length;\r\n }\r\n else {\r\n result = array[method].apply(self, arguments);\r\n }\r\n _$dispatch(self._root, self._key, old, self.slice());\r\n return result;\r\n };\r\n});\r\n_$List[PROP_MAP.h].pull = function (index) {\r\n var self = this;\r\n var items = _$toArgs(arguments, 1);\r\n var length = self.length;\r\n if (index > length) {\r\n length = index + 1;\r\n var pull = new Array(index - self.length);\r\n pull.push.apply(pull, items);\r\n for (var i = 0; i < length; i++) {\r\n if (i === index) {\r\n self.push.apply(self, pull);\r\n }\r\n }\r\n }\r\n else {\r\n self.splice.apply(self, [index, 1].concat(items));\r\n }\r\n};\r\nfunction _$dispatch(root, key, oldVal, value) {\r\n root.$notify(key);\r\n if (root[PROP_MAP.w][key]) {\r\n _$e(root[PROP_MAP.w][key], function (watcher) { watcher(oldVal, value); });\r\n }\r\n root.$update();\r\n}\r\nfunction _$extends(ctor, exts) {\r\n ctor['plugin'] = function (fn, options) {\r\n TPS.push({ options: options, fn: fn });\r\n };\r\n ctor[PROP_MAP.h] = Object.create(exts[PROP_MAP.h]);\r\n ctor[PROP_MAP.h].constructor = ctor;\r\n}\r\nfunction _$isType(value, type) {\r\n return _$type(type) === 'string' ? type.split('|').some(function (t) { return t.trim() === _$type(value); }) : value instanceof type;\r\n}\r\nfunction _$isObject(obj) {\r\n return _$isType(obj, 'object');\r\n}\r\nfunction _$isArray(obj) {\r\n return Array.isArray ? Array.isArray(obj) : _$isType(obj, 'array');\r\n}\r\nfunction _$isFunction(obj) {\r\n return _$isType(obj, 'function');\r\n}\r\nfunction _$isStr(obj) {\r\n return _$isType(obj, 'string');\r\n}\r\nfunction _$toType(value, type, root, key) {\r\n switch (type) {\r\n case 'date':\r\n return new Date(value);\r\n case 'string':\r\n return _$toStr(value);\r\n case 'number':\r\n return +value;\r\n case 'boolean':\r\n return _$isStr(value) && !value ? true : !!value;\r\n case 'array':\r\n return _$isType(value, _$List) ? value : new _$List(value, root, key);\r\n default:\r\n return value;\r\n }\r\n}\r\nfunction _$type(obj) {\r\n return / (\\w+)/.exec(({}).toString.call(obj))[1].toLowerCase();\r\n}\r\nfunction _$hasProp(obj, prop) {\r\n return obj.hasOwnProperty(prop);\r\n}\r\nfunction _$drt(dd) {\r\n var hasProp = function (prop, instance, options, element) { return _$isObject(dd) && dd[prop] && dd[prop](instance, options, element); };\r\n return {\r\n $init: function (instance, options, element) {\r\n hasProp('$init', instance, options, element);\r\n },\r\n $inserted: function (instance, options, element) {\r\n hasProp('$inserted', instance, options, element);\r\n },\r\n $update: function (instance, options, element) {\r\n if (_$isFunction(dd)) {\r\n dd(instance, options, element);\r\n }\r\n else {\r\n hasProp('$update', instance, options, element);\r\n }\r\n },\r\n $destroy: function (instance, options, element) {\r\n hasProp('$destroy', instance, options, element);\r\n }\r\n };\r\n}\r\nfunction _$noop() { }\r\nfunction _$add(inst, Child, attrs) {\r\n var child = null;\r\n if (Child) {\r\n child = new Child(attrs, inst);\r\n inst.$children.push(child);\r\n }\r\n return child;\r\n}\r\nfunction _$remove(inst, child) {\r\n var index = inst.$children.indexOf(child);\r\n index >= 0 && inst.$children.splice(index, 1);\r\n}\r\nfunction _$toStr(obj) {\r\n var str = _$type(obj);\r\n return !/null|undefined/.test(str) ? obj.toString() : str;\r\n}\r\nfunction _$toPlainObj(obj) {\r\n var data = {};\r\n _$e(_$isObject(obj) ? obj : {}, function (_v, k) {\r\n if (k[0] !== '$' && !_$isFunction(obj[k])) {\r\n if (_$isType(obj[k], _$List)) {\r\n data[k] = obj[k].map(_$toPlainObj);\r\n }\r\n else if (_$isObject(obj[k])) {\r\n data[k] = _$toPlainObj(obj[k]);\r\n }\r\n else {\r\n data[k] = obj[k];\r\n }\r\n }\r\n });\r\n return _$isObject(obj) ? data : obj;\r\n}\r\nfunction _$setRef(refs, prop, node) {\r\n if (!_$hasProp(refs, prop)) {\r\n var value_1 = [];\r\n _$def(refs, prop, {\r\n get: function () { return value_1.length <= 1 ? value_1[0] : value_1; },\r\n set: function (val) { val && !~value_1.indexOf(val) && value_1.push(val); },\r\n enumerable: true, configurable: true\r\n });\r\n }\r\n refs[prop] = node;\r\n}\r\nfunction _$accesor(object, path, value) {\r\n return path.split('.').reduce(function (obj, key, i, arr) {\r\n if (_$isType(value, 'undefined')) {\r\n if (obj == null) {\r\n arr.splice(0, arr.length);\r\n return i > 0 && obj === null ? obj : undefined;\r\n }\r\n }\r\n else {\r\n if (i === arr.length - 1) {\r\n if (_$isType(obj, _$List) && _$toStr(+key) === key) {\r\n obj.pull(+key, value);\r\n }\r\n else {\r\n var oldVal = obj[key];\r\n obj[key] = !_$isType(value, _$List) && _$isArray(value) ? new _$List(value, object, key) : value;\r\n _$dispatch(object, path, oldVal, obj[key]);\r\n }\r\n }\r\n else if (!_$isObject(obj[key])) {\r\n obj[key] = {};\r\n }\r\n }\r\n return obj ? obj[key] : null;\r\n }, object);\r\n}\r\nfunction _$emptyElse() {\r\n return { type: 'empty-else', $create: _$noop, $mount: _$noop, $update: _$noop, $destroy: _$noop };\r\n}\r\nfunction _$isKey(event, key) {\r\n return event.key.toLowerCase() === key || !!event[key + \"Key\"];\r\n}\r\nfunction _$bindGroup(input, selection) {\r\n var _value = _$gv(input);\r\n var _$index = selection.indexOf(_value);\r\n input.checked && !~_$index ? selection.push(_value) : selection.splice(_$index, 1);\r\n}\r\nfunction _$bindMultiSelect(select, selections) {\r\n if (!selections.length)\r\n return;\r\n var options = select.options;\r\n for (var i = 0; i < options.length; i++) {\r\n options[i].selected = !!~selections.indexOf(_$gv(options[i]));\r\n }\r\n}\r\nfunction _$updateMultiSelect(select, obj, prop) {\r\n var items = [];\r\n var selection = obj[prop];\r\n var selectedOptions = select.selectedOptions;\r\n for (var i = 0; i < selectedOptions.length; i++) {\r\n items.push(_$gv(selectedOptions[i]));\r\n }\r\n obj[prop] = new _$List(items, selection['_root'], selection['_key']);\r\n obj.$update();\r\n}\r\nfunction _$(selector, parent) {\r\n return _$isStr(selector) ? (parent || document).querySelector(selector) : selector;\r\n}\r\nfunction _$d() {\r\n return document.createDocumentFragment();\r\n}\r\nfunction _$a(parent, child, sibling) {\r\n if (_$isType(sibling, 'boolean') && sibling)\r\n parent.parentElement.replaceChild(child, parent);\r\n else if (!sibling)\r\n parent.appendChild(child);\r\n else\r\n parent.insertBefore(child, sibling);\r\n}\r\nfunction _$as(source, dest) {\r\n var childNodes = source.childNodes, attributes = source.attributes;\r\n for (var i = 0; i < childNodes.length; i++) {\r\n _$a(dest, childNodes[i]);\r\n }\r\n for (var i = 0; i < attributes.length; i++) {\r\n var attr = attributes[i];\r\n dest.setAttributeNS(source.namespaceURI, attr.name, attr.value);\r\n }\r\n source.parentElement.replaceChild(dest, source);\r\n return dest;\r\n}\r\nfunction _$r(el, parent) {\r\n var root = parent || el.parentElement;\r\n if (root)\r\n root.removeChild(el);\r\n}\r\nfunction _$ce(tagName) {\r\n return document.createElement(tagName || 'div');\r\n}\r\nfunction _$cse(tagName) {\r\n return document.createElementNS('http://www.w3.org/2000/svg', tagName || 'svg');\r\n}\r\nfunction _$ct(content) {\r\n return document.createTextNode(content || '');\r\n}\r\nfunction _$cm(content) {\r\n return document.createComment(content || '');\r\n}\r\nfunction _$sa(el, attrAndValue) {\r\n var attr = attrAndValue[0], value = attrAndValue[1];\r\n el.setAttribute(attr, _$toStr(value));\r\n if (_$isValueAttr(attr) && !_$isStr(value))\r\n el[PROP_MAP._] = value;\r\n}\r\nfunction _$ga(el, attr) {\r\n return _$isValueAttr(attr) ? _$gv(el) : el.getAttribute(attr);\r\n}\r\nfunction _$gv(el) {\r\n return _$hasProp(el, PROP_MAP._) ? el[PROP_MAP._] : el[PROP_MAP.v];\r\n}\r\nfunction _$al(el, event, handler) {\r\n el.addEventListener(event, handler, false);\r\n}\r\nfunction _$ul(el, event, oldHandler, newHandler) {\r\n _$rl(el, event, oldHandler);\r\n _$al(el, event, oldHandler = newHandler);\r\n return oldHandler;\r\n}\r\nfunction _$rl(el, event, handler) {\r\n el.removeEventListener(event, handler, false);\r\n}\r\nfunction _$bc(value) {\r\n var classes = '';\r\n if (_$isStr(value)) {\r\n classes += \" \" + value;\r\n }\r\n else if (_$isArray(value)) {\r\n classes = value.map(_$bc).join(' ');\r\n }\r\n else if (_$isObject(value)) {\r\n for (var key in value)\r\n if (_$hasProp(value, key) && value[key])\r\n classes += \" \" + key;\r\n }\r\n return classes.trim();\r\n}\r\nfunction _$bs(value) {\r\n var el = _$ce();\r\n if (_$isObject(value)) {\r\n var style_1 = el.style;\r\n _$e(value, function (val, prop) {\r\n if (val !== style_1[prop])\r\n style_1[prop] = val;\r\n });\r\n return style_1.cssText;\r\n }\r\n else if (_$isStr(value)) {\r\n return value;\r\n }\r\n else {\r\n return '';\r\n }\r\n}\r\nfunction _$cu(block, condition, inst, parent, anchor) {\r\n if (block && block.type === condition(inst).type) {\r\n block.$update(inst);\r\n }\r\n else {\r\n block && block.$destroy();\r\n block = condition(inst);\r\n block.$create();\r\n block.$mount(parent, anchor);\r\n }\r\n return block;\r\n}\r\nfunction _$bba(el, attrAndValue) {\r\n var _a = attrAndValue.concat([el.hasAttribute(attrAndValue[0])]), attr = _a[0], value = _a[1], hasAttr = _a[2];\r\n value == null || value === false ? hasAttr && el.removeAttribute(attr) : _$sa(el, [attr, '']);\r\n}\r\nfunction _$bu(el, binding) {\r\n var attr = binding[0], value = binding[1];\r\n var _value = attr === 'checked' ? !!value : _$toStr(value);\r\n if (/value|checked/.test(attr)) {\r\n if (el[attr] !== _value)\r\n el[attr] = _$isValueAttr(attr) ? _value : value;\r\n el[PROP_MAP._] = _$isValueAttr(attr) ? value : el[PROP_MAP.v];\r\n }\r\n else if (_$ga(el, attr) !== _value) {\r\n _$sa(el, [attr, _value]);\r\n }\r\n}\r\nfunction _$tu(text, value) {\r\n if (text.data !== (value = _$toStr(value)))\r\n text.data = value;\r\n}\r\nfunction _$nu(node, tag) {\r\n return tag.toUpperCase() !== node.tagName ? _$as(node, _$ce(tag)) : node;\r\n}\r\nfunction _$rr(refs, prop, node) {\r\n var nodes = refs[prop];\r\n _$isArray(nodes) ? refs[prop].splice(nodes.indexOf(node), 1) : (delete refs[prop]);\r\n}\r\nfunction _$hu(node, value) {\r\n if (node.innerHTML !== (value = _$toStr(value)))\r\n node.innerHTML = value;\r\n}\r\nfunction _$pu(parent, Ctor, inst, value, attrs, el, sibling) {\r\n if (value === Ctor) {\r\n inst && inst.$update();\r\n }\r\n else {\r\n Ctor = value;\r\n if (inst) {\r\n inst.$destroy();\r\n _$remove(parent, inst);\r\n }\r\n if (inst) {\r\n inst = _$add(parent, Ctor, attrs);\r\n inst.$create();\r\n inst.$mount(el, sibling);\r\n }\r\n }\r\n return [inst, Ctor];\r\n}\r\nfunction _$f(root, obj, loop) {\r\n var items = {}, loopParent, loopSibling;\r\n var globs = _$toArgs(arguments, 3);\r\n _$e(obj, function (item, i) { items[i] = loop.apply(null, [root, item, i].concat(globs)); });\r\n return {\r\n $create: function () {\r\n _$e(items, function (item) { item.$create(); });\r\n },\r\n $mount: function (parent, sibling) {\r\n loopParent = _$(parent);\r\n loopSibling = _$(sibling);\r\n _$e(items, function (item) { item.$mount(loopParent, loopSibling); });\r\n },\r\n $update: function (root, obj) {\r\n var globs = _$toArgs(arguments, 2);\r\n _$e(items, function (item, i) {\r\n if (obj[i]) {\r\n item.$update.apply(item, [root, obj[i], i].concat(globs));\r\n }\r\n else {\r\n item.$destroy();\r\n delete items[i];\r\n }\r\n });\r\n _$e(obj, function (item, i) {\r\n if (!items[i]) {\r\n items[i] = loop.apply(null, [root, item, i].concat(globs));\r\n items[i].$create();\r\n items[i].$mount(loopParent, loopSibling);\r\n }\r\n });\r\n },\r\n $destroy: function () {\r\n _$e(items, function (item) { item.$destroy(); });\r\n }\r\n };\r\n}\r\nfunction _$e(obj, cb) {\r\n for (var key in obj) {\r\n if (_$hasProp(obj, key)) {\r\n cb(obj[key], (isNaN(+key) ? key : +key));\r\n }\r\n }\r\n}\r\nfunction _$is(id, css) {\r\n var isNew = false;\r\n var style = _$(\"#\" + id, document.head);\r\n if (!style) {\r\n isNew = true;\r\n style = _$ce('style');\r\n style.id = id;\r\n _$sa(style, ['refs', '1']);\r\n }\r\n if (style.textContent !== css) {\r\n style.textContent = css;\r\n }\r\n if (isNew) {\r\n _$a(document.head, style);\r\n }\r\n else {\r\n var count = +_$ga(style, 'refs');\r\n _$sa(style, ['refs', _$toStr(++count)]);\r\n }\r\n}\r\nfunction _$ds(id) {\r\n var style = _$(\"#\" + id, document.head);\r\n if (style) {\r\n var count = +_$ga(style, 'refs');\r\n if (--count === 0) {\r\n _$r(style, document.head);\r\n }\r\n else {\r\n _$sa(style, ['refs', _$toStr(count)]);\r\n }\r\n }\r\n}\r\n//# sourceMappingURL=index.js.map\n// CONCATENATED MODULE: ./components/red.html\n\r\nfunction _$tplRed(_$state) {\r\n var _$frag, h2_1, span_1, txt_1, setTxt_1;\r\n _$frag = _$d();\r\n setTxt_1 = function(_$state) {\r\n return 'Red ' + _$state.text;\r\n };\r\n return {\r\n $create: function() {\r\n h2_1 = _$ce('h2');\r\n h2_1.innerHTML = 'Component Red:';\r\n span_1 = _$ce('span');\r\n txt_1 = _$ct();\r\n txt_1.data = setTxt_1(_$state);\r\n _$sa(span_1, ['style', 'color: red']);\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n this.$siblingEl = _$(sibling);\r\n this.$parentEl = sibling && _$(sibling).parentElement || _$(parent);\r\n },\r\n\r\n $update: function(_$state) {\r\n _$tu(txt_1, setTxt_1(_$state));\r\n },\r\n\r\n $unmount: function() {\r\n _$a(_$frag, h2_1);\r\n _$a(span_1, txt_1);\r\n _$a(_$frag, span_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n this.$parent = null;\r\n this.$parentEl = null;\r\n this.$siblingEl = null;\r\n this.$children.splice(0, this.$children.length);\r\n delete _$state.$root;\r\n _$frag = h2_1 = span_1 = txt_1 = setTxt_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction Red(_$attrs, _$parent) {\r\n _$CompCtr.call(this, _$attrs, _$tplRed, {\r\n attrs: ['text']\r\n }, _$parent);\r\n !_$parent && this.$create();\r\n}\r\n_$extends(Red, _$CompCtr);\r\n/* harmony default export */ var red = (Red);\r\n\n// CONCATENATED MODULE: ./components/blue.html\n\r\nfunction _$tplBlue(_$state) {\r\n var _$frag, h2_1, p_1, txt_1, setTxt_1;\r\n _$frag = _$d();\r\n setTxt_1 = function(_$state) {\r\n return 'Blue ' + _$state.text;\r\n };\r\n return {\r\n $create: function() {\r\n h2_1 = _$ce('h2');\r\n h2_1.innerHTML = 'Component Blue:';\r\n p_1 = _$ce('p');\r\n txt_1 = _$ct();\r\n txt_1.data = setTxt_1(_$state);\r\n _$sa(p_1, ['style', 'color: blue']);\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n this.$siblingEl = _$(sibling);\r\n this.$parentEl = sibling && _$(sibling).parentElement || _$(parent);\r\n },\r\n\r\n $update: function(_$state) {\r\n _$tu(txt_1, setTxt_1(_$state));\r\n },\r\n\r\n $unmount: function() {\r\n _$a(_$frag, h2_1);\r\n _$a(p_1, txt_1);\r\n _$a(_$frag, p_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n this.$parent = null;\r\n this.$parentEl = null;\r\n this.$siblingEl = null;\r\n this.$children.splice(0, this.$children.length);\r\n delete _$state.$root;\r\n _$frag = h2_1 = p_1 = txt_1 = setTxt_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction Blue(_$attrs, _$parent) {\r\n _$CompCtr.call(this, _$attrs, _$tplBlue, {\r\n attrs: ['text']\r\n }, _$parent);\r\n !_$parent && this.$create();\r\n}\r\n_$extends(Blue, _$CompCtr);\r\n/* harmony default export */ var blue = (Blue);\r\n\n// CONCATENATED MODULE: ./components/green.html\n\r\nfunction _$tplGreen(_$state) {\r\n var _$frag, h2_1, span_1, txt_1, setTxt_1;\r\n _$frag = _$d();\r\n setTxt_1 = function(_$state) {\r\n return 'Green ' + _$state.text;\r\n };\r\n return {\r\n $create: function() {\r\n h2_1 = _$ce('h2');\r\n h2_1.innerHTML = 'Component Green:';\r\n span_1 = _$ce('span');\r\n txt_1 = _$ct();\r\n txt_1.data = setTxt_1(_$state);\r\n _$sa(span_1, ['style', 'color: green']);\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n this.$siblingEl = _$(sibling);\r\n this.$parentEl = sibling && _$(sibling).parentElement || _$(parent);\r\n },\r\n\r\n $update: function(_$state) {\r\n _$tu(txt_1, setTxt_1(_$state));\r\n },\r\n\r\n $unmount: function() {\r\n _$a(_$frag, h2_1);\r\n _$a(span_1, txt_1);\r\n _$a(_$frag, span_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n this.$parent = null;\r\n this.$parentEl = null;\r\n this.$siblingEl = null;\r\n this.$children.splice(0, this.$children.length);\r\n delete _$state.$root;\r\n _$frag = h2_1 = span_1 = txt_1 = setTxt_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction Green(_$attrs, _$parent) {\r\n _$CompCtr.call(this, _$attrs, _$tplGreen, {\r\n attrs: ['text']\r\n }, _$parent);\r\n !_$parent && this.$create();\r\n}\r\n_$extends(Green, _$CompCtr);\r\n/* harmony default export */ var green = (Green);\r\n\n// CONCATENATED MODULE: ./components/app.html\n\r\n\r\n\r\n\r\nfunction _$tplApp(_$state) {\r\n var children = _$state.$options.children;\r\n var _$frag, a_1, txt_1, clickEvent_1, handlerClickEvent_1, a_2, txt_2, clickEvent_2, handlerClickEvent_2, a_3, txt_3, clickEvent_3, handlerClickEvent_3, componentAnchor_1, component_1, setComponent_1, setAttrsComponent_1;\r\n _$frag = _$d();\r\n clickEvent_1 = function(_$state) {\r\n _$state.$set('foo', 'red');\r\n };\r\n clickEvent_2 = function(_$state) {\r\n _$state.$set('foo', 'blue');\r\n };\r\n clickEvent_3 = function(_$state) {\r\n _$state.$set('foo', 'green');\r\n };\r\n setAttrsComponent_1 = function() {\r\n return {\r\n text: 'thing'\r\n };\r\n };\r\n setComponent_1 = function(_$state) {\r\n var comp = _$state.children[_$state.foo];\r\n return _$isType(comp, 'string') ? children[comp] : comp;\r\n };\r\n var Component_1 = setComponent_1(_$state);\r\n componentAnchor_1 = _$ct();\r\n component_1 = _$add(_$state, Component_1, setAttrsComponent_1());\r\n return {\r\n $create: function() {\r\n a_1 = _$ce('a');\r\n txt_1 = _$ct('Red ');\r\n a_2 = _$ce('a');\r\n txt_2 = _$ct('Blue ');\r\n a_3 = _$ce('a');\r\n txt_3 = _$ct('Gree ');\r\n component_1.$create();\r\n _$al(a_1, 'click', handlerClickEvent_1 = function(event) {\r\n event.preventDefault();\r\n clickEvent_1(_$state, event, a_1);\r\n });\r\n _$sa(a_1, ['href', '#']);\r\n _$al(a_2, 'click', handlerClickEvent_2 = function(event) {\r\n event.preventDefault();\r\n clickEvent_2(_$state, event, a_2);\r\n });\r\n _$sa(a_2, ['href', '#']);\r\n _$al(a_3, 'click', handlerClickEvent_3 = function(event) {\r\n event.preventDefault();\r\n clickEvent_3(_$state, event, a_3);\r\n });\r\n _$sa(a_3, ['href', '#']);\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n this.$siblingEl = _$(sibling);\r\n this.$parentEl = sibling && _$(sibling).parentElement || _$(parent);\r\n },\r\n\r\n $update: function(_$state) {\r\n var _a;\r\n _a = _$pu(\r\n _$state,\r\n Component_1,\r\n component_1,\r\n setComponent_1(_$state),\r\n setAttrsComponent_1(),\r\n _$state.$parentEl,\r\n componentAnchor_1\r\n ), component_1 = _a[0], Component_1 = _a[1];\r\n },\r\n\r\n $unmount: function() {\r\n _$a(a_1, txt_1);\r\n _$a(_$frag, a_1);\r\n _$a(a_2, txt_2);\r\n _$a(_$frag, a_2);\r\n _$a(a_3, txt_3);\r\n _$a(_$frag, a_3);\r\n _$a(_$frag, componentAnchor_1);\r\n component_1.$mount(_$frag, componentAnchor_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n this.$parent = null;\r\n this.$parentEl = null;\r\n this.$siblingEl = null;\r\n this.$children.splice(0, this.$children.length);\r\n _$rl(a_1, 'click', handlerClickEvent_1);\r\n _$rl(a_2, 'click', handlerClickEvent_2);\r\n _$rl(a_3, 'click', handlerClickEvent_3);\r\n component_1 && component_1.$destroy();\r\n delete _$state.$root;\r\n _$frag = a_1 = txt_1 = clickEvent_1 = handlerClickEvent_1 = a_2 = txt_2 = clickEvent_2 = handlerClickEvent_2 = a_3 = txt_3 = clickEvent_3 = handlerClickEvent_3 = componentAnchor_1 = component_1 = setComponent_1 = setAttrsComponent_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction App(_$attrs, _$parent) {\r\n _$CompCtr.call(this, _$attrs, _$tplApp, {\r\n model: {\r\n foo: 'red',\r\n\r\n children: {\r\n red: red,\r\n blue: blue,\r\n green: green\r\n }\r\n }\r\n }, _$parent);\r\n !_$parent && this.$create();\r\n}\r\n_$extends(App, _$CompCtr);\r\n/* harmony default export */ var app = (App);\r\n\n// CONCATENATED MODULE: ./main.ts\n\r\nvar main_app = new app();\r\nmain_app.$mount('main');\r\n\n\n//# sourceURL=webpack:///./main.ts_+_5_modules?"); +eval("\n// CONCATENATED MODULE: h:/trebor-repos/trebor/tools/index.js\nvar PROP_MAP = { p: '__TP__', v: 'value', _: '_value', s: '_subscribers', e: '_events', w: '_watchers', h: 'prototype' };\r\nvar PROPS = ['$slots', '$refs', '$filters', '$directives', '_events', '_watchers'];\r\nvar TPS = window[PROP_MAP.p] || (window[PROP_MAP.p] = []);\r\nvar _$assign = Object['assign'] || function (t) {\r\n for (var s = void 0, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s)\r\n if (_$hasProp(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n};\r\nfunction _$CompCtr(attrs, template, options, parent) {\r\n var self = this;\r\n var _$set = function (prop, value) { _$def(self, prop, { value: value, writable: true }); };\r\n if (!attrs)\r\n attrs = {};\r\n _$e(PROPS, function (prop) { _$def(self, prop, { value: {} }); });\r\n _$set('$parent', parent || null);\r\n _$set('$children', []);\r\n _$set(PROP_MAP.s, {});\r\n _$set('$options', options);\r\n var opts = self.$options;\r\n if (!opts.attrs)\r\n opts.attrs = {};\r\n if (!opts.children)\r\n opts.children = {};\r\n _$e(TPS, function (plugin) { plugin.fn.call(self, _$CompCtr, plugin.options); });\r\n if (opts.filters)\r\n _$assign(self.$filters, opts.filters);\r\n if (opts.directives)\r\n _$e(opts.directives, function (drt, k) { self.$directives[k] = _$drt(drt); });\r\n _$e(opts.attrs, function (attrOps, key) {\r\n _$def(self, (_$isType(key, 'number') ? attrOps : key), {\r\n get: function () {\r\n if (_$isStr(attrOps)) {\r\n var value = attrs[attrOps];\r\n return _$isFunction(value) ? value() : value;\r\n }\r\n else {\r\n if (!_$hasProp(attrs, key) && attrOps.required) {\r\n return console.error(\"Attribute '\" + key + \"' is required.\");\r\n }\r\n else {\r\n var value = _$isFunction(attrs[key]) ? attrs[key]() : attrs[key];\r\n if (value === void 0 && _$hasProp(attrOps, 'default')) {\r\n var def = attrOps.default;\r\n value = _$isFunction(def) ? def() : def;\r\n }\r\n var typ = attrOps.type;\r\n if (typ && !_$isType(value, typ) && attrOps.required) {\r\n return console.error(\"Attribute '\" + key + \"' must be type '\" + typ + \"'.\");\r\n }\r\n value = _$toType(value, value === void 0 ? 'undefined' : typ, self, key);\r\n if (value !== void 0 && _$hasProp(attrOps, 'validator')) {\r\n var validator = attrOps.validator;\r\n if (_$isFunction(validator) && !validator(value)) {\r\n return console.error(\"Assigment '\" + key + \"'='\" + JSON.stringify(value) + \"' invalid.\");\r\n }\r\n }\r\n return value;\r\n }\r\n }\r\n },\r\n set: function () {\r\n console.error(\"'\" + key + \"' is read only.\");\r\n },\r\n enumerable: true, configurable: true\r\n });\r\n });\r\n var data = opts.model || {};\r\n var _loop_1 = function (key) {\r\n if (_$hasProp(data, key)) {\r\n var desc = Object.getOwnPropertyDescriptor(data, key);\r\n if (desc.value && _$isArray(desc.value)) {\r\n desc.value = new _$List(desc.value, self, key);\r\n }\r\n else {\r\n if (desc.get) {\r\n var getter_1 = desc.get;\r\n desc.get = function () {\r\n var value = getter_1.call(self);\r\n if (_$isArray(value))\r\n value = new _$List(value, self, key);\r\n return value;\r\n };\r\n }\r\n if (desc.set) {\r\n var setter_1 = desc.set;\r\n desc.set = function (v) {\r\n if (_$isArray(v))\r\n v = new _$List(v, self, key);\r\n setter_1.call(self, v);\r\n };\r\n }\r\n }\r\n _$def(self, key, desc);\r\n }\r\n };\r\n for (var key in data) {\r\n _loop_1(key);\r\n }\r\n var tpl = template(self);\r\n _$e(tpl, function (value, key) {\r\n _$def(self, key, {\r\n value: (function (key) {\r\n var hook = key[1].toUpperCase() + key.slice(2);\r\n var bhook = opts[\"before\" + hook];\r\n var ahook = opts[\"after\" + hook];\r\n return function () {\r\n bhook && bhook.call(this);\r\n key.slice(1) === 'update' ? value.call(this, this) : value.apply(this, arguments);\r\n ahook && ahook.call(this);\r\n };\r\n })(key)\r\n });\r\n });\r\n _$def(self, '$data', {\r\n get: function () {\r\n return _$toPlainObj(this);\r\n }\r\n });\r\n}\r\nfunction _$isValueAttr(attr) {\r\n return attr === 'value';\r\n}\r\nfunction _$subs(dep, listener) {\r\n if (!this[PROP_MAP.s][dep]) {\r\n this[PROP_MAP.s][dep] = [];\r\n }\r\n return this[PROP_MAP.s][dep].push(listener.bind(this)) - 1;\r\n}\r\nfunction _$def(obj, key, desc) {\r\n Object.defineProperty(obj, key, desc);\r\n}\r\n_$assign(_$CompCtr[PROP_MAP.h], {\r\n $get: function (path) {\r\n return _$accesor(this, path);\r\n },\r\n $set: function (path, value) {\r\n _$accesor(this, path, value);\r\n },\r\n $on: function (event, handler) {\r\n var _this = this;\r\n if (!this[PROP_MAP.e][event]) {\r\n this[PROP_MAP.e][event] = [];\r\n }\r\n var i = this[PROP_MAP.e][event].push(handler);\r\n return {\r\n $off: function () {\r\n _this[PROP_MAP.e][event].splice(i - 1, 1);\r\n }\r\n };\r\n },\r\n $once: function (event, handler) {\r\n var e = this.$on(event, function (args) {\r\n handler(args);\r\n e.$off();\r\n });\r\n },\r\n $fire: function (event, data) {\r\n if (this[PROP_MAP.e][event]) {\r\n _$e(this[PROP_MAP.e][event], function (handler) { handler(data); });\r\n }\r\n },\r\n $notify: function (key) {\r\n if (this[PROP_MAP.s][key]) {\r\n _$e(this[PROP_MAP.s][key], function (suscriber) { suscriber(); });\r\n }\r\n },\r\n $observe: function (deps, listener) {\r\n var _this = this;\r\n var subs = [];\r\n if (_$isArray(deps)) {\r\n _$e(deps, function (dep) {\r\n subs.push({ sub: dep, i: _$subs.call(_this, dep, listener) });\r\n });\r\n }\r\n else {\r\n subs.push({ sub: deps, i: _$subs.call(this, deps, listener) });\r\n }\r\n return {\r\n $unobserve: function () {\r\n _$e(subs, function (sub) {\r\n _this[PROP_MAP.s][sub.sub].splice(sub.i, 1);\r\n });\r\n }\r\n };\r\n },\r\n $watch: function (key, watcher) {\r\n var _this = this;\r\n if (!this[PROP_MAP.w][key]) {\r\n this[PROP_MAP.w][key] = [];\r\n }\r\n var i = this[PROP_MAP.w][key].push(watcher.bind(this));\r\n return {\r\n $unwatch: function () {\r\n _this[PROP_MAP.w][key].splice(i - 1, 1);\r\n }\r\n };\r\n }\r\n});\r\nvar array = Array[PROP_MAP.h];\r\nfunction _$toArgs(args, start) {\r\n if (start === void 0) { start = 0; }\r\n return array.slice.call(args, start);\r\n}\r\nfunction _$arrayValues(list, value, root, key) {\r\n array.push.apply(list, value.map(function (v, i) {\r\n if (list.length !== 0)\r\n i += list.length;\r\n return !(_$isType(v, _$List)) && _$isArray(v) ? new _$List(v, root, key + \".\" + i) : v;\r\n }));\r\n}\r\nfunction _$List(value, root, key) {\r\n var self = this;\r\n Array.apply(self, [value.length]);\r\n var desc = { writable: false, configurable: false, enumerable: false };\r\n _$def(self, '_key', _$assign({ value: key }, desc));\r\n _$def(self, '_root', _$assign({ value: root }, desc));\r\n _$arrayValues(self, value, root, key);\r\n desc.writable = true;\r\n _$def(self, 'length', _$assign({ value: self.length }, desc));\r\n}\r\n_$extends(_$List, Array);\r\n['pop', 'push', 'reverse', 'shift', 'sort', 'fill', 'unshift', 'splice'].forEach(function (method) {\r\n _$List[PROP_MAP.h][method] = function () {\r\n var self = this;\r\n var old = self.slice();\r\n var result;\r\n if (method === 'push') {\r\n _$arrayValues(self, _$toArgs(arguments), self._root, self._key);\r\n result = self.length;\r\n }\r\n else {\r\n result = array[method].apply(self, arguments);\r\n }\r\n _$dispatch(self._root, self._key, old, self.slice());\r\n return result;\r\n };\r\n});\r\n_$List[PROP_MAP.h].pull = function (index) {\r\n var self = this;\r\n var items = _$toArgs(arguments, 1);\r\n var length = self.length;\r\n if (index > length) {\r\n length = index + 1;\r\n var pull = new Array(index - self.length);\r\n pull.push.apply(pull, items);\r\n for (var i = 0; i < length; i++) {\r\n if (i === index) {\r\n self.push.apply(self, pull);\r\n }\r\n }\r\n }\r\n else {\r\n self.splice.apply(self, [index, 1].concat(items));\r\n }\r\n};\r\nfunction _$dispatch(root, key, oldVal, value) {\r\n root.$notify(key);\r\n if (root[PROP_MAP.w][key]) {\r\n _$e(root[PROP_MAP.w][key], function (watcher) { watcher(oldVal, value); });\r\n }\r\n root.$update();\r\n}\r\nfunction _$extends(ctor, exts) {\r\n ctor['plugin'] = function (fn, options) {\r\n TPS.push({ options: options, fn: fn });\r\n };\r\n ctor[PROP_MAP.h] = Object.create(exts[PROP_MAP.h]);\r\n ctor[PROP_MAP.h].constructor = ctor;\r\n}\r\nfunction _$isType(value, type) {\r\n return _$type(type) === 'string' ? type.split('|').some(function (t) { return t.trim() === _$type(value); }) : value instanceof type;\r\n}\r\nfunction _$apply(callee, args, globs, thisArg) {\r\n if (thisArg === void 0) { thisArg = null; }\r\n return callee.apply(thisArg, args.concat(globs));\r\n}\r\nfunction _$isObject(obj) {\r\n return _$isType(obj, 'object');\r\n}\r\nfunction _$isArray(obj) {\r\n return Array.isArray ? Array.isArray(obj) : _$isType(obj, 'array');\r\n}\r\nfunction _$isFunction(obj) {\r\n return _$isType(obj, 'function');\r\n}\r\nfunction _$isStr(obj) {\r\n return _$isType(obj, 'string');\r\n}\r\nfunction _$toType(value, type, root, key) {\r\n switch (type) {\r\n case 'date':\r\n return new Date(value);\r\n case 'string':\r\n return _$toStr(value);\r\n case 'number':\r\n return +value;\r\n case 'boolean':\r\n return _$isStr(value) && !value ? true : !!value;\r\n case 'array':\r\n return _$isType(value, _$List) ? value : new _$List(value, root, key);\r\n default:\r\n return value;\r\n }\r\n}\r\nfunction _$type(obj) {\r\n return / (\\w+)/.exec(({}).toString.call(obj))[1].toLowerCase();\r\n}\r\nfunction _$hasProp(obj, prop) {\r\n return obj.hasOwnProperty(prop);\r\n}\r\nfunction _$drt(dd) {\r\n var hasProp = function (prop, instance, options, element) { return _$isObject(dd) && dd[prop] && dd[prop](instance, options, element); };\r\n return {\r\n $init: function (instance, options, element) {\r\n hasProp('$init', instance, options, element);\r\n },\r\n $inserted: function (instance, options, element) {\r\n hasProp('$inserted', instance, options, element);\r\n },\r\n $update: function (instance, options, element) {\r\n if (_$isFunction(dd)) {\r\n dd(instance, options, element);\r\n }\r\n else {\r\n hasProp('$update', instance, options, element);\r\n }\r\n },\r\n $destroy: function (instance, options, element) {\r\n hasProp('$destroy', instance, options, element);\r\n }\r\n };\r\n}\r\nfunction _$noop() { }\r\nfunction _$add(inst, Child, attrs) {\r\n var child = null;\r\n if (Child) {\r\n child = new Child(attrs, inst);\r\n inst.$children.push(child);\r\n }\r\n return child;\r\n}\r\nfunction _$remove(inst, child) {\r\n var index = inst.$children.indexOf(child);\r\n index >= 0 && inst.$children.splice(index, 1);\r\n}\r\nfunction _$toStr(obj) {\r\n var str = _$type(obj);\r\n return !/null|undefined/.test(str) ? obj.toString() : str;\r\n}\r\nfunction _$toPlainObj(obj) {\r\n var data = {};\r\n _$e(_$isObject(obj) ? obj : {}, function (_v, k) {\r\n if (k[0] !== '$' && !_$isFunction(obj[k])) {\r\n if (_$isType(obj[k], _$List)) {\r\n data[k] = obj[k].map(_$toPlainObj);\r\n }\r\n else if (_$isObject(obj[k])) {\r\n data[k] = _$toPlainObj(obj[k]);\r\n }\r\n else {\r\n data[k] = obj[k];\r\n }\r\n }\r\n });\r\n return _$isObject(obj) ? data : obj;\r\n}\r\nfunction _$setRef(refs, prop, node) {\r\n if (!_$hasProp(refs, prop)) {\r\n var value_1 = [];\r\n _$def(refs, prop, {\r\n get: function () { return value_1.length <= 1 ? value_1[0] : value_1; },\r\n set: function (val) { val && !~value_1.indexOf(val) && value_1.push(val); },\r\n enumerable: true, configurable: true\r\n });\r\n }\r\n refs[prop] = node;\r\n}\r\nfunction _$accesor(object, path, value) {\r\n return path.split('.').reduce(function (obj, key, i, arr) {\r\n if (_$isType(value, 'undefined')) {\r\n if (obj == null) {\r\n arr.splice(0, arr.length);\r\n return i > 0 && obj === null ? obj : undefined;\r\n }\r\n }\r\n else {\r\n if (i === arr.length - 1) {\r\n if (_$isType(obj, _$List) && _$toStr(+key) === key) {\r\n obj.pull(+key, value);\r\n }\r\n else {\r\n var oldVal = obj[key];\r\n obj[key] = !_$isType(value, _$List) && _$isArray(value) ? new _$List(value, object, key) : value;\r\n _$dispatch(object, path, oldVal, obj[key]);\r\n }\r\n }\r\n else if (!_$isObject(obj[key])) {\r\n obj[key] = {};\r\n }\r\n }\r\n return obj ? obj[key] : null;\r\n }, object);\r\n}\r\nfunction _$emptyElse() {\r\n return { type: 'empty-else', $create: _$noop, $mount: _$noop, $update: _$noop, $destroy: _$noop };\r\n}\r\nfunction _$isKey(event, key) {\r\n return event.key.toLowerCase() === key || !!event[key + \"Key\"];\r\n}\r\nfunction _$bindGroup(input, selection) {\r\n var _value = _$gv(input);\r\n var _$index = selection.indexOf(_value);\r\n input.checked && !~_$index ? selection.push(_value) : selection.splice(_$index, 1);\r\n}\r\nfunction _$bindMultiSelect(select, selections) {\r\n if (!selections.length)\r\n return;\r\n var options = select.options;\r\n for (var i = 0; i < options.length; i++) {\r\n options[i].selected = !!~selections.indexOf(_$gv(options[i]));\r\n }\r\n}\r\nfunction _$updateMultiSelect(select, obj, prop) {\r\n var items = [];\r\n var selection = obj[prop];\r\n var selectedOptions = select.selectedOptions;\r\n for (var i = 0; i < selectedOptions.length; i++) {\r\n items.push(_$gv(selectedOptions[i]));\r\n }\r\n obj[prop] = new _$List(items, selection['_root'], selection['_key']);\r\n obj.$update();\r\n}\r\nfunction _$(selector, parent) {\r\n return _$isStr(selector) ? (parent || document).querySelector(selector) : selector;\r\n}\r\nfunction _$d() {\r\n return document.createDocumentFragment();\r\n}\r\nfunction _$a(parent, child, sibling) {\r\n if (_$isType(sibling, 'boolean') && sibling)\r\n parent.parentElement.replaceChild(child, parent);\r\n else if (!sibling)\r\n parent.appendChild(child);\r\n else\r\n parent.insertBefore(child, sibling);\r\n}\r\nfunction _$as(source, dest) {\r\n var childNodes = source.childNodes, attributes = source.attributes;\r\n for (var i = 0; i < childNodes.length; i++) {\r\n _$a(dest, childNodes[i]);\r\n }\r\n for (var i = 0; i < attributes.length; i++) {\r\n var attr = attributes[i];\r\n dest.setAttributeNS(source.namespaceURI, attr.name, attr.value);\r\n }\r\n source.parentElement.replaceChild(dest, source);\r\n return dest;\r\n}\r\nfunction _$r(el, parent) {\r\n var root = parent || el.parentElement;\r\n if (root)\r\n root.removeChild(el);\r\n}\r\nfunction _$ce(tagName) {\r\n return document.createElement(tagName || 'div');\r\n}\r\nfunction _$cse(tagName) {\r\n return document.createElementNS('http://www.w3.org/2000/svg', tagName || 'svg');\r\n}\r\nfunction _$ct(content) {\r\n return document.createTextNode(content || '');\r\n}\r\nfunction _$cm(content) {\r\n return document.createComment(content || '');\r\n}\r\nfunction _$sa(el, attrAndValue) {\r\n var attr = attrAndValue[0], value = attrAndValue[1];\r\n el.setAttribute(attr, _$toStr(value));\r\n if (_$isValueAttr(attr) && !_$isStr(value))\r\n el[PROP_MAP._] = value;\r\n}\r\nfunction _$ga(el, attr) {\r\n return _$isValueAttr(attr) ? _$gv(el) : el.getAttribute(attr);\r\n}\r\nfunction _$gv(el) {\r\n return _$hasProp(el, PROP_MAP._) ? el[PROP_MAP._] : el[PROP_MAP.v];\r\n}\r\nfunction _$al(el, event, handler) {\r\n el.addEventListener(event, handler, false);\r\n}\r\nfunction _$ul(el, event, oldHandler, newHandler) {\r\n _$rl(el, event, oldHandler);\r\n _$al(el, event, oldHandler = newHandler);\r\n return oldHandler;\r\n}\r\nfunction _$rl(el, event, handler) {\r\n el.removeEventListener(event, handler, false);\r\n}\r\nfunction _$bc(value) {\r\n var classes = '';\r\n if (_$isStr(value)) {\r\n classes += \" \" + value;\r\n }\r\n else if (_$isArray(value)) {\r\n classes = value.map(_$bc).join(' ');\r\n }\r\n else if (_$isObject(value)) {\r\n for (var key in value)\r\n if (_$hasProp(value, key) && value[key])\r\n classes += \" \" + key;\r\n }\r\n return classes.trim();\r\n}\r\nfunction _$bs(value) {\r\n var el = _$ce();\r\n if (_$isObject(value)) {\r\n var style_1 = el.style;\r\n _$e(value, function (val, prop) {\r\n if (val !== style_1[prop])\r\n style_1[prop] = val;\r\n });\r\n return style_1.cssText;\r\n }\r\n else if (_$isStr(value)) {\r\n return value;\r\n }\r\n else {\r\n return '';\r\n }\r\n}\r\nfunction _$cu(block, condition, parent, anchor, inst) {\r\n var globs = _$toArgs(arguments, 5);\r\n if (block && block.type === _$apply(condition, [inst], globs).type) {\r\n _$apply(block.$update, [inst], globs, block);\r\n }\r\n else {\r\n block && block.$destroy();\r\n block = _$apply(condition, [inst], globs);\r\n block.$create();\r\n block.$mount(parent || inst.$parentEl, anchor);\r\n }\r\n return block;\r\n}\r\nfunction _$bba(el, attrAndValue) {\r\n var attr = attrAndValue[0], value = attrAndValue[1];\r\n el[attr] = value == null || value === false ? (el.removeAttribute(attr), false) : (_$sa(el, [attr, '']), true);\r\n}\r\nfunction _$bu(el, binding) {\r\n var attr = binding[0], value = binding[1];\r\n var _value = _$toStr(value);\r\n if (_$isValueAttr(attr)) {\r\n if (el[attr] !== _value)\r\n el[attr] = _value;\r\n el[PROP_MAP._] = value;\r\n }\r\n else if (_$ga(el, attr) !== _value) {\r\n _$sa(el, [attr, _value]);\r\n }\r\n}\r\nfunction _$tu(text, value) {\r\n if (text.data !== (value = _$toStr(value)))\r\n text.data = value;\r\n}\r\nfunction _$nu(node, tag) {\r\n return tag.toUpperCase() !== node.tagName ? _$as(node, _$ce(tag)) : node;\r\n}\r\nfunction _$rr(refs, prop, node) {\r\n var nodes = refs[prop];\r\n _$isArray(nodes) ? refs[prop].splice(nodes.indexOf(node), 1) : (delete refs[prop]);\r\n}\r\nfunction _$hu(node, value) {\r\n if (node.innerHTML !== (value = _$toStr(value)))\r\n node.innerHTML = value;\r\n}\r\nfunction _$pu(parent, Ctor, inst, value, attrs, el, sibling) {\r\n if (value === Ctor) {\r\n inst && inst.$update();\r\n }\r\n else {\r\n Ctor = value;\r\n if (inst) {\r\n inst.$destroy();\r\n _$remove(parent, inst);\r\n }\r\n if (inst) {\r\n inst = _$add(parent, Ctor, attrs);\r\n inst.$create();\r\n inst.$mount(el, sibling);\r\n }\r\n }\r\n return [inst, Ctor];\r\n}\r\nfunction _$f(root, obj, loop) {\r\n var items = {}, loopParent, loopSibling;\r\n var globs = _$toArgs(arguments, 3);\r\n _$e(obj, function (item, i, index) { items[i] = _$apply(loop, [root, item, i, index], globs); });\r\n return {\r\n $create: function () {\r\n _$e(items, function (item) { item.$create(); });\r\n },\r\n $mount: function (parent, sibling) {\r\n loopParent = _$(parent);\r\n loopSibling = _$(sibling);\r\n _$e(items, function (item) { item.$mount(loopParent, loopSibling); });\r\n },\r\n $update: function (root, obj) {\r\n var globs = _$toArgs(arguments, 2);\r\n _$e(items, function (item, i, index) {\r\n if (obj[i]) {\r\n _$apply(item.$update, [root, obj[i], i, index], globs, item);\r\n }\r\n else {\r\n item.$destroy();\r\n delete items[i];\r\n }\r\n });\r\n _$e(obj, function (item, i, index) {\r\n if (!items[i]) {\r\n items[i] = _$apply(loop, [root, item, i, index], globs);\r\n items[i].$create();\r\n items[i].$mount(loopParent, loopSibling);\r\n }\r\n });\r\n },\r\n $destroy: function () {\r\n _$e(items, function (item) { item.$destroy(); });\r\n }\r\n };\r\n}\r\nfunction _$e(obj, cb) {\r\n var i = 0;\r\n for (var key in obj) {\r\n if (_$hasProp(obj, key)) {\r\n cb(obj[key], (isNaN(+key) ? key : +key), i++);\r\n }\r\n }\r\n}\r\nfunction _$is(id, css) {\r\n var isNew = false;\r\n var style = _$(\"#\" + id, document.head);\r\n if (!style) {\r\n isNew = true;\r\n style = _$ce('style');\r\n style.id = id;\r\n _$sa(style, ['refs', 1]);\r\n }\r\n if (style.textContent !== css) {\r\n style.textContent = css;\r\n }\r\n if (isNew) {\r\n _$a(document.head, style);\r\n }\r\n else {\r\n var count = +_$ga(style, 'refs');\r\n _$sa(style, ['refs', ++count]);\r\n }\r\n}\r\nfunction _$ds(id) {\r\n var style = _$(\"#\" + id, document.head);\r\n if (style) {\r\n var count = +_$ga(style, 'refs');\r\n if (--count === 0) {\r\n _$r(style, document.head);\r\n }\r\n else {\r\n _$sa(style, ['refs', count]);\r\n }\r\n }\r\n}\r\n//# sourceMappingURL=index.js.map\n// CONCATENATED MODULE: ./components/red.html\n\r\nfunction _$tplRed(_$state) {\r\n var _$frag, h2_1, span_1, txt_1, setTxt_1;\r\n _$frag = _$d();\r\n setTxt_1 = function(_$state) {\r\n return 'Red ' + _$state.text;\r\n };\r\n return {\r\n $create: function() {\r\n h2_1 = _$ce('h2');\r\n h2_1.innerHTML = 'Component Red:';\r\n span_1 = _$ce('span');\r\n txt_1 = _$ct();\r\n txt_1.data = setTxt_1(_$state);\r\n _$sa(span_1, ['style', 'color: red']);\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n this.$siblingEl = _$(sibling);\r\n this.$parentEl = sibling && _$(sibling).parentElement || _$(parent);\r\n },\r\n\r\n $update: function(_$state) {\r\n _$tu(txt_1, setTxt_1(_$state));\r\n },\r\n\r\n $unmount: function() {\r\n _$a(_$frag, h2_1);\r\n _$a(span_1, txt_1);\r\n _$a(_$frag, span_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n this.$parent = null;\r\n this.$parentEl = null;\r\n this.$siblingEl = null;\r\n this.$children.splice(0, this.$children.length);\r\n delete _$state.$root;\r\n _$frag = h2_1 = span_1 = txt_1 = setTxt_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction Red(_$attrs, _$parent) {\r\n _$CompCtr.call(this, _$attrs, _$tplRed, {\r\n attrs: ['text']\r\n }, _$parent);\r\n !_$parent && this.$create();\r\n}\r\n_$extends(Red, _$CompCtr);\r\n/* harmony default export */ var red = (Red);\r\n\n// CONCATENATED MODULE: ./components/blue.html\n\r\nfunction _$tplBlue(_$state) {\r\n var _$frag, h2_1, p_1, txt_1, setTxt_1;\r\n _$frag = _$d();\r\n setTxt_1 = function(_$state) {\r\n return 'Blue ' + _$state.text;\r\n };\r\n return {\r\n $create: function() {\r\n h2_1 = _$ce('h2');\r\n h2_1.innerHTML = 'Component Blue:';\r\n p_1 = _$ce('p');\r\n txt_1 = _$ct();\r\n txt_1.data = setTxt_1(_$state);\r\n _$sa(p_1, ['style', 'color: blue']);\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n this.$siblingEl = _$(sibling);\r\n this.$parentEl = sibling && _$(sibling).parentElement || _$(parent);\r\n },\r\n\r\n $update: function(_$state) {\r\n _$tu(txt_1, setTxt_1(_$state));\r\n },\r\n\r\n $unmount: function() {\r\n _$a(_$frag, h2_1);\r\n _$a(p_1, txt_1);\r\n _$a(_$frag, p_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n this.$parent = null;\r\n this.$parentEl = null;\r\n this.$siblingEl = null;\r\n this.$children.splice(0, this.$children.length);\r\n delete _$state.$root;\r\n _$frag = h2_1 = p_1 = txt_1 = setTxt_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction Blue(_$attrs, _$parent) {\r\n _$CompCtr.call(this, _$attrs, _$tplBlue, {\r\n attrs: ['text']\r\n }, _$parent);\r\n !_$parent && this.$create();\r\n}\r\n_$extends(Blue, _$CompCtr);\r\n/* harmony default export */ var blue = (Blue);\r\n\n// CONCATENATED MODULE: ./components/green.html\n\r\nfunction _$tplGreen(_$state) {\r\n var _$frag, h2_1, span_1, txt_1, setTxt_1;\r\n _$frag = _$d();\r\n setTxt_1 = function(_$state) {\r\n return 'Green ' + _$state.text;\r\n };\r\n return {\r\n $create: function() {\r\n h2_1 = _$ce('h2');\r\n h2_1.innerHTML = 'Component Green:';\r\n span_1 = _$ce('span');\r\n txt_1 = _$ct();\r\n txt_1.data = setTxt_1(_$state);\r\n _$sa(span_1, ['style', 'color: green']);\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n this.$siblingEl = _$(sibling);\r\n this.$parentEl = sibling && _$(sibling).parentElement || _$(parent);\r\n },\r\n\r\n $update: function(_$state) {\r\n _$tu(txt_1, setTxt_1(_$state));\r\n },\r\n\r\n $unmount: function() {\r\n _$a(_$frag, h2_1);\r\n _$a(span_1, txt_1);\r\n _$a(_$frag, span_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n this.$parent = null;\r\n this.$parentEl = null;\r\n this.$siblingEl = null;\r\n this.$children.splice(0, this.$children.length);\r\n delete _$state.$root;\r\n _$frag = h2_1 = span_1 = txt_1 = setTxt_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction Green(_$attrs, _$parent) {\r\n _$CompCtr.call(this, _$attrs, _$tplGreen, {\r\n attrs: ['text']\r\n }, _$parent);\r\n !_$parent && this.$create();\r\n}\r\n_$extends(Green, _$CompCtr);\r\n/* harmony default export */ var green = (Green);\r\n\n// CONCATENATED MODULE: ./components/app.html\n\r\n\r\n\r\n\r\nfunction _$tplApp(_$state) {\r\n var children = _$state.$options.children;\r\n var _$frag, a_1, txt_1, clickEvent_1, handlerClickEvent_1, a_2, txt_2, clickEvent_2, handlerClickEvent_2, a_3, txt_3, clickEvent_3, handlerClickEvent_3, componentAnchor_1, component_1, setComponent_1, setAttrsComponent_1;\r\n _$frag = _$d();\r\n clickEvent_1 = function(_$state) {\r\n _$state.$set('foo', 'red');\r\n };\r\n clickEvent_2 = function(_$state) {\r\n _$state.$set('foo', 'blue');\r\n };\r\n clickEvent_3 = function(_$state) {\r\n _$state.$set('foo', 'green');\r\n };\r\n setAttrsComponent_1 = function() {\r\n return {\r\n text: 'thing'\r\n };\r\n };\r\n setComponent_1 = function(_$state) {\r\n var comp = _$state.children[_$state.foo];\r\n return _$isType(comp, 'string') ? children[comp] : comp;\r\n };\r\n var Component_1 = setComponent_1(_$state);\r\n componentAnchor_1 = _$ct();\r\n component_1 = _$add(_$state, Component_1, setAttrsComponent_1());\r\n return {\r\n $create: function() {\r\n a_1 = _$ce('a');\r\n txt_1 = _$ct('Red ');\r\n a_2 = _$ce('a');\r\n txt_2 = _$ct('Blue ');\r\n a_3 = _$ce('a');\r\n txt_3 = _$ct('Gree ');\r\n component_1.$create();\r\n _$sa(a_1, ['href', '#']);\r\n _$al(a_1, 'click', handlerClickEvent_1 = function(event) {\r\n event.preventDefault();\r\n clickEvent_1(_$state, event, a_1);\r\n });\r\n _$sa(a_2, ['href', '#']);\r\n _$al(a_2, 'click', handlerClickEvent_2 = function(event) {\r\n event.preventDefault();\r\n clickEvent_2(_$state, event, a_2);\r\n });\r\n _$sa(a_3, ['href', '#']);\r\n _$al(a_3, 'click', handlerClickEvent_3 = function(event) {\r\n event.preventDefault();\r\n clickEvent_3(_$state, event, a_3);\r\n });\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n this.$siblingEl = _$(sibling);\r\n this.$parentEl = sibling && _$(sibling).parentElement || _$(parent);\r\n },\r\n\r\n $update: function(_$state) {\r\n var _a;\r\n _a = _$pu(\r\n _$state,\r\n Component_1,\r\n component_1,\r\n setComponent_1(_$state),\r\n setAttrsComponent_1(),\r\n _$state.$parentEl,\r\n componentAnchor_1\r\n ), component_1 = _a[0], Component_1 = _a[1];\r\n },\r\n\r\n $unmount: function() {\r\n _$a(a_1, txt_1);\r\n _$a(_$frag, a_1);\r\n _$a(a_2, txt_2);\r\n _$a(_$frag, a_2);\r\n _$a(a_3, txt_3);\r\n _$a(_$frag, a_3);\r\n _$a(_$frag, componentAnchor_1);\r\n component_1.$mount(_$frag, componentAnchor_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n this.$parent = null;\r\n this.$parentEl = null;\r\n this.$siblingEl = null;\r\n this.$children.splice(0, this.$children.length);\r\n _$rl(a_1, 'click', handlerClickEvent_1);\r\n _$rl(a_2, 'click', handlerClickEvent_2);\r\n _$rl(a_3, 'click', handlerClickEvent_3);\r\n component_1 && component_1.$destroy();\r\n delete _$state.$root;\r\n _$frag = a_1 = txt_1 = clickEvent_1 = handlerClickEvent_1 = a_2 = txt_2 = clickEvent_2 = handlerClickEvent_2 = a_3 = txt_3 = clickEvent_3 = handlerClickEvent_3 = componentAnchor_1 = component_1 = setComponent_1 = setAttrsComponent_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction App(_$attrs, _$parent) {\r\n _$CompCtr.call(this, _$attrs, _$tplApp, {\r\n model: {\r\n foo: 'red',\r\n\r\n children: {\r\n red: red,\r\n blue: blue,\r\n green: green\r\n }\r\n }\r\n }, _$parent);\r\n !_$parent && this.$create();\r\n}\r\n_$extends(App, _$CompCtr);\r\n/* harmony default export */ var app = (App);\r\n\n// CONCATENATED MODULE: ./main.ts\n\r\nvar main_app = new app();\r\nmain_app.$mount('main');\r\n\n\n//# sourceURL=webpack:///./main.ts_+_5_modules?"); /***/ }) diff --git a/examples/select/index.html b/examples/select/index.html new file mode 100644 index 0000000..6c5904a --- /dev/null +++ b/examples/select/index.html @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/examples/select/index.iif.js b/examples/select/index.iif.js new file mode 100644 index 0000000..f308e40 --- /dev/null +++ b/examples/select/index.iif.js @@ -0,0 +1,584 @@ +!function(glob) { + 'use strict'; +var PROP_MAP = { + p: '__TP__', + v: 'value', + _: '_value', + s: '_subscribers', + e: '_events', + w: '_watchers', + h: 'prototype' +}; +var PROPS = ['$slots', '$refs', '$filters', '$directives', '_events', '_watchers']; +var TPS = window[PROP_MAP.p] || (window[PROP_MAP.p] = []); +var _$assign = Object['assign'] || function(t) { + for (var s = void 0, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (_$hasProp(s, p)) + t[p] = s[p]; + } + return t; +}; +function _$CompCtr(attrs, template, options, parent) { + var self = this; + var _$set = function(prop, value) { + _$def(self, prop, { + value: value, + writable: true + }); + }; + if (!attrs) + attrs = {}; + _$e(PROPS, function(prop) { + _$def(self, prop, { + value: {} + }); + }); + _$set('$parent', parent || null); + _$set('$children', []); + _$set(PROP_MAP.s, {}); + _$set('$options', options); + var opts = self.$options; + if (!opts.attrs) + opts.attrs = {}; + if (!opts.children) + opts.children = {}; + _$e(TPS, function(plugin) { + plugin.fn.call(self, _$CompCtr, plugin.options); + }); + if (opts.filters) + _$assign(self.$filters, opts.filters); + if (opts.directives) _$e(opts.directives, function(drt, k) { + self.$directives[k] = _$drt(drt); + }); + _$e(opts.attrs, function(attrOps, key) { + _$def(self, _$isType(key, 'number') ? attrOps : key, { + get: function() { + if (_$isStr(attrOps)) { + var value = attrs[attrOps]; + return _$isFunction(value) ? value() : value; + } else { + if (!_$hasProp(attrs, key) && attrOps.required) { + return console.error('Attribute \'' + key + '\' is required.'); + } else { + var value = _$isFunction(attrs[key]) ? attrs[key]() : attrs[key]; + if (value === void 0 && _$hasProp(attrOps, 'default')) { + var def = attrOps.default; + value = _$isFunction(def) ? def() : def; + } + var typ = attrOps.type; + if (typ && !_$isType(value, typ) && attrOps.required) { + return console.error('Attribute \'' + key + '\' must be type \'' + typ + '\'.'); + } + value = _$toType(value, value === void 0 ? 'undefined' : typ, self, key); + if (value !== void 0 && _$hasProp(attrOps, 'validator')) { + var validator = attrOps.validator; + if (_$isFunction(validator) && !validator(value)) { + return console.error('Assigment \'' + key + '\'=\'' + JSON.stringify(value) + '\' invalid.'); + } + } + return value; + } + } + }, + + set: function() { + console.error('\'' + key + '\' is read only.'); + }, + + enumerable: true, + configurable: true + }); + }); + var data = opts.model || {}; + var _loop_1 = function(key) { + if (_$hasProp(data, key)) { + var desc = Object.getOwnPropertyDescriptor(data, key); + if (desc.value && _$isArray(desc.value)) { + desc.value = new _$List(desc.value, self, key); + } else { + if (desc.get) { + var getter_1 = desc.get; + desc.get = function() { + var value = getter_1.call(self); + if (_$isArray(value)) + value = new _$List(value, self, key); + return value; + }; + } + if (desc.set) { + var setter_1 = desc.set; + desc.set = function(v) { + if (_$isArray(v)) + v = new _$List(v, self, key); + setter_1.call(self, v); + }; + } + } + _$def(self, key, desc); + } + }; + for (var key in data) { + _loop_1(key); + } + var tpl = template(self); + _$e(tpl, function(value, key) { + _$def(self, key, { + value: function(key) { + var hook = key[1].toUpperCase() + key.slice(2); + var bhook = opts['before' + hook]; + var ahook = opts['after' + hook]; + return function() { + bhook && bhook.call(this); + key.slice(1) === 'update' ? value.call(this, this) : value.apply(this, arguments); + ahook && ahook.call(this); + }; + }(key) + }); + }); + _$def(self, '$data', { + get: function() { + return _$toPlainObj(this); + } + }); +} +function _$isValueAttr(attr) { + return attr === 'value'; +} +function _$subs(dep, listener) { + if (!this[PROP_MAP.s][dep]) { + this[PROP_MAP.s][dep] = []; + } + return this[PROP_MAP.s][dep].push(listener.bind(this)) - 1; +} +function _$def(obj, key, desc) { + Object.defineProperty(obj, key, desc); +} +_$assign(_$CompCtr[PROP_MAP.h], { + $get: function(path) { + return _$accesor(this, path); + }, + + $set: function(path, value) { + _$accesor(this, path, value); + }, + + $on: function(event, handler) { + var _this = this; + if (!this[PROP_MAP.e][event]) { + this[PROP_MAP.e][event] = []; + } + var i = this[PROP_MAP.e][event].push(handler); + return { + $off: function() { + _this[PROP_MAP.e][event].splice(i - 1, 1); + } + }; + }, + + $once: function(event, handler) { + var e = this.$on(event, function(args) { + handler(args); + e.$off(); + }); + }, + + $fire: function(event, data) { + if (this[PROP_MAP.e][event]) { + _$e(this[PROP_MAP.e][event], function(handler) { + handler(data); + }); + } + }, + + $notify: function(key) { + if (this[PROP_MAP.s][key]) { + _$e(this[PROP_MAP.s][key], function(suscriber) { + suscriber(); + }); + } + }, + + $observe: function(deps, listener) { + var _this = this; + var subs = []; + if (_$isArray(deps)) { + _$e(deps, function(dep) { + subs.push({ + sub: dep, + i: _$subs.call(_this, dep, listener) + }); + }); + } else { + subs.push({ + sub: deps, + i: _$subs.call(this, deps, listener) + }); + } + return { + $unobserve: function() { + _$e(subs, function(sub) { + _this[PROP_MAP.s][sub.sub].splice(sub.i, 1); + }); + } + }; + }, + + $watch: function(key, watcher) { + var _this = this; + if (!this[PROP_MAP.w][key]) { + this[PROP_MAP.w][key] = []; + } + var i = this[PROP_MAP.w][key].push(watcher.bind(this)); + return { + $unwatch: function() { + _this[PROP_MAP.w][key].splice(i - 1, 1); + } + }; + } +}); +var array = Array[PROP_MAP.h]; +function _$toArgs(args, start) { + if (start === void 0) { + start = 0; + } + return array.slice.call(args, start); +} +function _$arrayValues(list, value, root, key) { + array.push.apply(list, value.map(function(v, i) { + if (list.length !== 0) + i += list.length; + return !_$isType(v, _$List) && _$isArray(v) ? new _$List(v, root, key + '.' + i) : v; + })); +} +function _$List(value, root, key) { + var self = this; + Array.apply(self, [value.length]); + var desc = { + writable: false, + configurable: false, + enumerable: false + }; + _$def(self, '_key', _$assign({ + value: key + }, desc)); + _$def(self, '_root', _$assign({ + value: root + }, desc)); + _$arrayValues(self, value, root, key); + desc.writable = true; + _$def(self, 'length', _$assign({ + value: self.length + }, desc)); +} +_$extends(_$List, Array); +['pop', 'push', 'reverse', 'shift', 'sort', 'fill', 'unshift', 'splice'].forEach(function(method) { + _$List[PROP_MAP.h][method] = function() { + var self = this; + var old = self.slice(); + var result; + if (method === 'push') { + _$arrayValues(self, _$toArgs(arguments), self._root, self._key); + result = self.length; + } else { + result = array[method].apply(self, arguments); + } + _$dispatch(self._root, self._key, old, self.slice()); + return result; + }; +}); +_$List[PROP_MAP.h].pull = function(index) { + var self = this; + var items = _$toArgs(arguments, 1); + var length = self.length; + if (index > length) { + length = index + 1; + var pull = new Array(index - self.length); + pull.push.apply(pull, items); + for (var i = 0; i < length; i++) { + if (i === index) { + self.push.apply(self, pull); + } + } + } else { + self.splice.apply(self, [index, 1].concat(items)); + } +}; +function _$dispatch(root, key, oldVal, value) { + root.$notify(key); + if (root[PROP_MAP.w][key]) { + _$e(root[PROP_MAP.w][key], function(watcher) { + watcher(oldVal, value); + }); + } + root.$update(); +} +function _$extends(ctor, exts) { + ctor['plugin'] = function(fn, options) { + TPS.push({ + options: options, + fn: fn + }); + }; + ctor[PROP_MAP.h] = Object.create(exts[PROP_MAP.h]); + ctor[PROP_MAP.h].constructor = ctor; +} +function _$isType(value, type) { + return _$type(type) === 'string' ? type.split('|').some(function(t) { + return t.trim() === _$type(value); + }) : value instanceof type; +} +function _$isObject(obj) { + return _$isType(obj, 'object'); +} +function _$isArray(obj) { + return Array.isArray ? Array.isArray(obj) : _$isType(obj, 'array'); +} +function _$isFunction(obj) { + return _$isType(obj, 'function'); +} +function _$isStr(obj) { + return _$isType(obj, 'string'); +} +function _$toType(value, type, root, key) { + switch (type) { + case 'date': + return new Date(value); + case 'string': + return _$toStr(value); + case 'number': + return +value; + case 'boolean': + return _$isStr(value) && !value ? true : !!value; + case 'array': + return _$isType(value, _$List) ? value : new _$List(value, root, key); + default: + return value; + } +} +function _$type(obj) { + return / (\w+)/.exec({}.toString.call(obj))[1].toLowerCase(); +} +function _$hasProp(obj, prop) { + return obj.hasOwnProperty(prop); +} +function _$drt(dd) { + var hasProp = function(prop, instance, options, element) { + return _$isObject(dd) && dd[prop] && dd[prop](instance, options, element); + }; + return { + $init: function(instance, options, element) { + hasProp('$init', instance, options, element); + }, + + $inserted: function(instance, options, element) { + hasProp('$inserted', instance, options, element); + }, + + $update: function(instance, options, element) { + if (_$isFunction(dd)) { + dd(instance, options, element); + } else { + hasProp('$update', instance, options, element); + } + }, + + $destroy: function(instance, options, element) { + hasProp('$destroy', instance, options, element); + } + }; +} +function _$toStr(obj) { + var str = _$type(obj); + return !/null|undefined/.test(str) ? obj.toString() : str; +} +function _$toPlainObj(obj) { + var data = {}; + _$e(_$isObject(obj) ? obj : {}, function(_v, k) { + if (k[0] !== '$' && !_$isFunction(obj[k])) { + if (_$isType(obj[k], _$List)) { + data[k] = obj[k].map(_$toPlainObj); + } else if (_$isObject(obj[k])) { + data[k] = _$toPlainObj(obj[k]); + } else { + data[k] = obj[k]; + } + } + }); + return _$isObject(obj) ? data : obj; +} +function _$accesor(object, path, value) { + return path.split('.').reduce(function(obj, key, i, arr) { + if (_$isType(value, 'undefined')) { + if (obj == null) { + arr.splice(0, arr.length); + return i > 0 && obj === null ? obj : undefined; + } + } else { + if (i === arr.length - 1) { + if (_$isType(obj, _$List) && _$toStr(+key) === key) { + obj.pull(+key, value); + } else { + var oldVal = obj[key]; + obj[key] = !_$isType(value, _$List) && _$isArray(value) ? new _$List(value, object, key) : value; + _$dispatch(object, path, oldVal, obj[key]); + } + } else if (!_$isObject(obj[key])) { + obj[key] = {}; + } + } + return obj ? obj[key] : null; + }, object); +} +function _$bindGroup(input, selection) { + var _value = _$gv(input); + var _$index = selection.indexOf(_value); + input.checked && !~_$index ? selection.push(_value) : selection.splice(_$index, 1); +} +function _$(selector, parent) { + return _$isStr(selector) ? (parent || document).querySelector(selector) : selector; +} +function _$d() { + return document.createDocumentFragment(); +} +function _$a(parent, child, sibling) { + if (_$isType(sibling, 'boolean') && sibling) + parent.parentElement.replaceChild(child, parent); + else if (!sibling) + parent.appendChild(child); + else + parent.insertBefore(child, sibling); +} +function _$ce(tagName) { + return document.createElement(tagName || 'div'); +} +function _$sa(el, attrAndValue) { + var attr = attrAndValue[0], value = attrAndValue[1]; + el.setAttribute(attr, _$toStr(value)); + if (_$isValueAttr(attr) && !_$isStr(value)) + el[PROP_MAP._] = value; +} +function _$ga(el, attr) { + return _$isValueAttr(attr) ? _$gv(el) : el.getAttribute(attr); +} +function _$gv(el) { + return _$hasProp(el, PROP_MAP._) ? el[PROP_MAP._] : el[PROP_MAP.v]; +} +function _$al(el, event, handler) { + el.addEventListener(event, handler, false); +} +function _$rl(el, event, handler) { + el.removeEventListener(event, handler, false); +} +function _$bba(el, attrAndValue) { + var _a = attrAndValue.concat([el.hasAttribute(attrAndValue[0])]), attr = _a[0], value = _a[1], hasAttr = _a[2]; + value == null || value === false ? hasAttr && el.removeAttribute(attr) : _$sa(el, [attr, '']); +} +function _$bu(el, binding) { + var attr = binding[0], value = binding[1]; + var _value = _$toStr(value); + if (_$isValueAttr(attr)) { + if (el[attr] !== _value) { + el[attr] = _value; + } + el[PROP_MAP._] = value; + } else if (_$ga(el, attr) !== _value) { + _$sa(el, [attr, _value]); + } +} +function _$e(obj, cb) { + for (var key in obj) { + if (_$hasProp(obj, key)) { + cb(obj[key], isNaN(+key) ? key : +key); + } + } +} +function _$tplIndex(_$state) { + var _$frag, input_1, changeEvent_1, handlerChangeEvent_1, bindCheckedInput_1, bindValueInput_1, input_2, changeEvent_2, handlerChangeEvent_2, bindCheckedInput_2, bindValueInput_2; + _$frag = _$d(); + changeEvent_1 = function(_$state, $event, $el) { + _$bindGroup($el, _$state.checkboxes); + }; + bindCheckedInput_1 = function(_$state) { + return ['checked', !!~_$state.checkboxes.indexOf(_$ga(input_1, 'value'))]; + }; + bindValueInput_1 = function() { + return ['value', { + value: 'No' + }]; + }; + changeEvent_2 = function(_$state, $event, $el) { + _$bindGroup($el, _$state.checkboxes); + }; + bindCheckedInput_2 = function(_$state) { + return ['checked', !!~_$state.checkboxes.indexOf(_$ga(input_2, 'value'))]; + }; + bindValueInput_2 = function() { + return ['value', { + value: 'Yes' + }]; + }; + return { + $create: function() { + input_1 = _$ce('input'); + input_2 = _$ce('input'); + _$al(input_1, 'change', handlerChangeEvent_1 = function(event) { + changeEvent_1(_$state, event, input_1); + }); + _$bba(input_1, bindCheckedInput_1(_$state)); + _$sa(input_1, bindValueInput_1(_$state)); + _$sa(input_1, ['id', 'checkbox_1']); + _$sa(input_1, ['type', 'checkbox']); + _$al(input_2, 'change', handlerChangeEvent_2 = function(event) { + changeEvent_2(_$state, event, input_2); + }); + _$bba(input_2, bindCheckedInput_2(_$state)); + _$sa(input_2, bindValueInput_2(_$state)); + _$sa(input_2, ['id', 'checkbox_2']); + _$sa(input_2, ['type', 'checkbox']); + }, + + $mount: function(parent, sibling) { + this.$unmount(); + _$a(_$(parent), _$frag, _$(sibling)); + this.$siblingEl = _$(sibling); + this.$parentEl = sibling && _$(sibling).parentElement || _$(parent); + }, + + $update: function(_$state) { + _$bba(input_1, bindCheckedInput_1(_$state)); + _$bu(input_1, bindValueInput_1(_$state)); + _$bba(input_2, bindCheckedInput_2(_$state)); + _$bu(input_2, bindValueInput_2(_$state)); + }, + + $unmount: function() { + _$a(_$frag, input_1); + _$a(_$frag, input_2); + }, + + $destroy: function() { + this.$unmount(); + this.$parent = null; + this.$parentEl = null; + this.$siblingEl = null; + this.$children.splice(0, this.$children.length); + _$rl(input_1, 'change', handlerChangeEvent_1); + _$rl(input_2, 'change', handlerChangeEvent_2); + delete _$state.$root; + _$frag = input_1 = changeEvent_1 = handlerChangeEvent_1 = bindCheckedInput_1 = bindValueInput_1 = input_2 = changeEvent_2 = handlerChangeEvent_2 = bindCheckedInput_2 = bindValueInput_2 = void 0; + } + }; +} +function Index(_$attrs, _$parent) { + _$CompCtr.call(this, _$attrs, _$tplIndex, { + model: { + checkboxes: [] + } + }, _$parent); + !_$parent && this.$create(); +} +_$extends(Index, _$CompCtr); +glob.Index = Index; + + }(this); \ No newline at end of file diff --git a/examples/select/index.js b/examples/select/index.js new file mode 100644 index 0000000..6fec045 --- /dev/null +++ b/examples/select/index.js @@ -0,0 +1,27 @@ +phantom.injectJs('index.iif.js'); + +var app = new Index(); +app.$mount('body'); + +var input_1 = document.querySelector('#checkbox_1'); +var input_2 = document.querySelector('#checkbox_2'); + +fireEvent('MouseEvents', input_1, 'click'); +fireEvent('MouseEvents', input_2, 'click'); + +console.log('Model Value:', JSON.stringify(app.checkboxes)); +console.log('Input 1 Value:', input_1.value, typeof input_1.value); +console.log('Input 1 _Value:', input_1._value, typeof input_1._value); +console.log('Input 2 Value:', input_2.value, typeof input_2.value); +console.log('Input 2 _Value:', input_2._value, typeof input_2._value); + +phantom.exit(); + +function fireEvent(type, el, name) { // element to click on + // Create the event. + var event = document.createEvent(type); + // Define that the event name is 'build'. + event.initEvent(name, true, true); + // target can be any Element or other EventTarget. + return el.dispatchEvent(event); +} diff --git a/examples/todomvc/dist/js/todo.js b/examples/todomvc/dist/js/todo.js index 85a6226..0d6d39e 100644 --- a/examples/todomvc/dist/js/todo.js +++ b/examples/todomvc/dist/js/todo.js @@ -94,7 +94,7 @@ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("\n// CONCATENATED MODULE: d:/Robert/Working/trebor-repos/trebor/tools/index.js\nvar _$assign = Object['assign'] || function (t) {\r\n for (var s = void 0, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s)\r\n if (_$hasProp(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n};\r\nfunction _$CompCtr(attrs, template, options, parent) {\r\n var self = this;\r\n var props = ['$slots', '$refs', '$filters', '$directives', '_events', '_watchers'];\r\n var _$set = function (prop, value) { _$def(self, prop, { value: value, writable: true }); };\r\n if (!attrs)\r\n attrs = {};\r\n _$e(props, function (prop) { _$def(self, prop, { value: {} }); });\r\n _$set('$parent', parent || null);\r\n _$set('$children', []);\r\n _$set('_subscribers', {});\r\n _$set('$options', options);\r\n var opts = self.$options;\r\n if (!opts.attrs)\r\n opts.attrs = {};\r\n if (!opts.children)\r\n opts.children = {};\r\n _$e(_$CompCtr['_plugins'], function (plugin) {\r\n plugin.fn.call(self, _$CompCtr, plugin.options);\r\n });\r\n if (opts.filters)\r\n _$assign(self.$filters, opts.filters);\r\n if (opts.directives)\r\n _$e(opts.directives, function (drt, k) { self.$directives[k] = _$drt(drt); });\r\n _$e(opts.attrs, function (attrOps, key) {\r\n _$def(self, (_$isType(key, 'number') ? attrOps : key), {\r\n get: function () {\r\n if (_$isType(attrOps, 'string')) {\r\n var value = attrs[attrOps];\r\n return _$isType(value, 'function') ? value() : value;\r\n }\r\n else {\r\n if (!_$hasProp(attrs, key) && attrOps.required) {\r\n console.error(\"Attribute '\" + key + \"' must be present because it's required.\");\r\n }\r\n else {\r\n var value = _$isType(attrs[key], 'function') ? attrs[key]() : attrs[key];\r\n if (value === void 0 && _$hasProp(attrOps, 'default')) {\r\n var def = attrOps.default;\r\n value = _$isType(def, 'function') ? def() : def;\r\n }\r\n var typ = attrOps.type;\r\n if (typ && !_$isType(value, typ) && attrOps.required) {\r\n return console.error(\"Attribute '\" + key + \"' must be type '\" + typ + \"'.\");\r\n }\r\n return _$toType(value, value === void 0 ? 'undefined' : typ, self, key);\r\n }\r\n }\r\n },\r\n set: function () {\r\n console.error(\"Can not modify attribute '\" + key + \"' because attributes al read only.\");\r\n },\r\n enumerable: true, configurable: true\r\n });\r\n });\r\n var data = opts.model || {};\r\n var _loop_1 = function (key) {\r\n if (_$hasProp(data, key)) {\r\n var desc = Object.getOwnPropertyDescriptor(data, key);\r\n if (desc.value && _$isArray(desc.value)) {\r\n desc.value = new _$List(desc.value, self, key);\r\n }\r\n else {\r\n if (desc.get) {\r\n var getter_1 = desc.get;\r\n desc.get = function () {\r\n var value = getter_1.call(self);\r\n if (_$isArray(value))\r\n value = new _$List(value, self, key);\r\n return value;\r\n };\r\n }\r\n if (desc.set) {\r\n var setter_1 = desc.set;\r\n desc.set = function (v) {\r\n if (_$isArray(v))\r\n v = new _$List(v, self, key);\r\n setter_1.call(self, v);\r\n };\r\n }\r\n }\r\n _$def(self, key, desc);\r\n }\r\n };\r\n for (var key in data) {\r\n _loop_1(key);\r\n }\r\n var tpl = template(self, opts.children);\r\n _$e(tpl, function (value, key) {\r\n _$def(self, key, {\r\n value: (function (key) {\r\n var hook = key[1].toUpperCase() + key.slice(2);\r\n var bhook = opts[\"before\" + hook];\r\n var ahook = opts[\"after\" + hook];\r\n return function () {\r\n bhook && bhook.call(this);\r\n key.slice(1) === 'update' ? value.call(this, this) : value.apply(this, arguments);\r\n ahook && ahook.call(this);\r\n };\r\n })(key)\r\n });\r\n });\r\n _$def(self, '$data', {\r\n get: function () {\r\n return _$toPlainObj(this);\r\n }\r\n });\r\n}\r\nfunction _$plugin(fn, options) {\r\n _$CompCtr['_plugins'] = _$CompCtr['_plugins'] || [];\r\n _$CompCtr['_plugins'].push({ options: options, fn: fn });\r\n}\r\n_$assign(_$CompCtr.prototype, {\r\n $get: function (path) {\r\n return _$accesor(this, path);\r\n },\r\n $set: function (path, value) {\r\n _$accesor(this, path, value);\r\n },\r\n $on: function (event, handler) {\r\n var _this = this;\r\n if (!this._events[event]) {\r\n this._events[event] = [];\r\n }\r\n var i = this._events[event].push(handler);\r\n return {\r\n $off: function () {\r\n _this._events[event].splice(i - 1, 1);\r\n }\r\n };\r\n },\r\n $once: function (event, handler) {\r\n var e = this.$on(event, function (args) {\r\n handler(args);\r\n e.$off();\r\n });\r\n },\r\n $fire: function (event, data) {\r\n if (this._events[event]) {\r\n _$e(this._events[event], function (handler) { handler(data); });\r\n }\r\n },\r\n $notify: function (key) {\r\n if (this._subscribers[key]) {\r\n _$e(this._subscribers[key], function (suscriber) { suscriber(); });\r\n }\r\n },\r\n $observe: function (deps, listener) {\r\n var _this = this;\r\n var subs = [];\r\n if (_$isArray(deps)) {\r\n _$e(deps, function (dep) {\r\n subs.push({ sub: dep, i: _$subs.call(_this, dep, listener) });\r\n });\r\n }\r\n else {\r\n subs.push({ sub: deps, i: _$subs.call(this, deps, listener) });\r\n }\r\n return {\r\n $unobserve: function () {\r\n _$e(subs, function (sub) {\r\n _this._subscribers[sub.sub].splice(sub.i, 1);\r\n });\r\n }\r\n };\r\n },\r\n $watch: function (key, watcher) {\r\n var _this = this;\r\n if (!this._watchers[key]) {\r\n this._watchers[key] = [];\r\n }\r\n var i = this._watchers[key].push(watcher.bind(this));\r\n return {\r\n $unwatch: function () {\r\n _this._watchers[key].splice(i - 1, 1);\r\n }\r\n };\r\n }\r\n});\r\nvar array = Array.prototype;\r\nfunction _$toArgs(args, start) {\r\n if (start === void 0) { start = 0; }\r\n return array.slice.call(args, start);\r\n}\r\nfunction _$arrayValues(list, value, root, key) {\r\n array.push.apply(list, value.map(function (v, i) {\r\n if (list.length !== 0)\r\n i += list.length;\r\n return !(_$isType(v, _$List)) && _$isArray(v) ? new _$List(v, root, key + \".\" + i) : v;\r\n }));\r\n}\r\nfunction _$List(value, root, key) {\r\n var self = this;\r\n Array.apply(self, [value.length]);\r\n var desc = { writable: false, configurable: false, enumerable: false };\r\n _$def(self, '_key', _$assign({ value: key }, desc));\r\n _$def(self, '_root', _$assign({ value: root }, desc));\r\n _$arrayValues(self, value, root, key);\r\n desc.writable = true;\r\n _$def(self, 'length', _$assign({ value: self.length }, desc));\r\n}\r\n_$List.prototype = Object.create(array);\r\n_$List.prototype.constructor = _$List;\r\n['pop', 'push', 'reverse', 'shift', 'sort', 'fill', 'unshift', 'splice'].forEach(function (method) {\r\n _$List.prototype[method] = function () {\r\n var self = this;\r\n var old = self.slice();\r\n var result;\r\n if (method === 'push') {\r\n _$arrayValues(self, _$toArgs(arguments), self._root, self._key);\r\n result = self.length;\r\n }\r\n else {\r\n result = array[method].apply(self, arguments);\r\n }\r\n _$dispatch(self._root, self._key, old, self.slice());\r\n return result;\r\n };\r\n});\r\n_$List.prototype.pull = function (index) {\r\n var self = this;\r\n var items = _$toArgs(arguments, 1);\r\n var length = self.length;\r\n if (index > length) {\r\n length = index + 1;\r\n var pull = new Array(index - self.length);\r\n pull.push.apply(pull, items);\r\n for (var i = 0; i < length; i++) {\r\n if (i === index) {\r\n self.push.apply(self, pull);\r\n }\r\n }\r\n }\r\n else {\r\n self.splice.apply(self, [index, 1].concat(items));\r\n }\r\n};\r\nfunction _$dispatch(root, key, oldVal, value) {\r\n root.$notify(key);\r\n if (root._watchers[key]) {\r\n _$e(root._watchers[key], function (watcher) { watcher(oldVal, value); });\r\n }\r\n root.$update();\r\n}\r\nfunction _$isType(value, type) {\r\n return _$type(type) === 'string' ? type.split('\\|').some(function (t) { return t.trim() === _$type(value); }) : value instanceof type;\r\n}\r\nfunction _$isObject(obj) {\r\n return _$isType(obj, 'object');\r\n}\r\nfunction _$isArray(obj) {\r\n return Array.isArray ? Array.isArray(obj) : _$isType(obj, 'array');\r\n}\r\nfunction _$toType(value, type, root, key) {\r\n switch (type) {\r\n case 'date':\r\n return new Date(value);\r\n case 'string':\r\n return value.toString();\r\n case 'number':\r\n return +value;\r\n case 'boolean':\r\n return !!value;\r\n case 'array':\r\n return _$isType(value, _$List) ? value : new _$List(value, root, key);\r\n default:\r\n return value;\r\n }\r\n}\r\nfunction _$type(obj) {\r\n return /\\[object (\\w+)\\]/.exec(Object.prototype.toString.call(obj))[1].toLowerCase();\r\n}\r\nfunction _$hasProp(obj, prop) {\r\n return obj.hasOwnProperty(prop);\r\n}\r\nfunction _$drt(directive) {\r\n var hasProp = function (prop, instance, options, element) { return _$isObject(directive) && directive[prop] && directive[prop](instance, options, element); };\r\n return {\r\n $init: function (instance, options, element) {\r\n hasProp('$init', instance, options, element);\r\n },\r\n $inserted: function (instance, options, element) {\r\n hasProp('$inserted', instance, options, element);\r\n },\r\n $update: function (instance, options, element) {\r\n if (_$isType(directive, 'function')) {\r\n directive(instance, options, element);\r\n }\r\n else {\r\n hasProp('$update', instance, options, element);\r\n }\r\n },\r\n $destroy: function (instance, options, element) {\r\n hasProp('$destroy', instance, options, element);\r\n }\r\n };\r\n}\r\nfunction _$noop() { }\r\nfunction _$add(inst, child) {\r\n inst.$children.push(child);\r\n}\r\nfunction _$remove(inst, child) {\r\n var index = inst.$children.indexOf(child);\r\n index >= 0 && inst.$children.splice(index, 1);\r\n}\r\nfunction _$toStr(obj) {\r\n var str = _$type(obj);\r\n return !/null|undefined/.test(str) ? obj.toString() : str;\r\n}\r\nfunction _$toPlainObj(obj) {\r\n var data = {};\r\n _$e(_$isObject(obj) ? obj : {}, function (_v, k) {\r\n if (k[0] !== '$' && !_$isType(obj[k], 'function')) {\r\n if (_$isType(obj[k], _$List)) {\r\n data[k] = obj[k].map(_$toPlainObj);\r\n }\r\n else if (_$isObject(obj[k])) {\r\n data[k] = _$toPlainObj(obj[k]);\r\n }\r\n else {\r\n data[k] = obj[k];\r\n }\r\n }\r\n });\r\n return _$isObject(obj) ? data : obj;\r\n}\r\nfunction _$setRef(obj, prop) {\r\n var value = [];\r\n _$def(obj, prop, {\r\n get: function () {\r\n return value.length <= 1 ? value[0] : value;\r\n },\r\n set: function (val) {\r\n if (val && !~value.indexOf(val)) {\r\n value.push(val);\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n}\r\nfunction _$accesor(object, path, value) {\r\n return path.split('.').reduce(function (obj, key, i, arr) {\r\n if (_$isType(value, 'undefined')) {\r\n if (obj == null) {\r\n arr.splice(0, arr.length);\r\n return i > 0 && obj === null ? obj : undefined;\r\n }\r\n }\r\n else {\r\n if (i === arr.length - 1) {\r\n if (_$isType(obj, _$List) && (+key).toString() === key) {\r\n obj.pull(+key, value);\r\n }\r\n else {\r\n var oldVal = obj[key];\r\n obj[key] = !_$isType(value, _$List) && _$isArray(value) ? new _$List(value, object, key) : value;\r\n _$dispatch(object, path, oldVal, obj[key]);\r\n }\r\n }\r\n else if (!_$isObject(obj[key])) {\r\n obj[key] = {};\r\n }\r\n }\r\n return obj ? obj[key] : null;\r\n }, object);\r\n}\r\nfunction _$emptyElse() {\r\n return { type: 'empty-else', $create: _$noop, $mount: _$noop, $update: _$noop, $destroy: _$noop };\r\n}\r\nfunction _$subs(dep, listener) {\r\n if (!this._subscribers[dep]) {\r\n this._subscribers[dep] = [];\r\n }\r\n return this._subscribers[dep].push(listener.bind(this)) - 1;\r\n}\r\nfunction _$def(obj, key, desc) {\r\n Object.defineProperty(obj, key, desc);\r\n}\r\nfunction _$isKey(event, key) {\r\n return event.key.toLowerCase() === key || !!event[key + \"Key\"];\r\n}\r\nfunction _$bindGroup(input, selection) {\r\n var _$index = selection.indexOf(input.value);\r\n if (input.checked && !~_$index)\r\n selection.push(input.value);\r\n else\r\n selection.splice(_$index, 1);\r\n}\r\nfunction _$(selector, parent) {\r\n return _$isType(selector, 'string') ? (parent || document).querySelector(selector) : selector;\r\n}\r\nfunction _$d() {\r\n return document.createDocumentFragment();\r\n}\r\nfunction _$a(parent, child, sibling) {\r\n if (_$isType(sibling, 'boolean') && sibling)\r\n parent.parentElement.replaceChild(child, parent);\r\n else if (!sibling)\r\n parent.appendChild(child);\r\n else\r\n parent.insertBefore(child, sibling);\r\n}\r\nfunction _$as(source, dest) {\r\n var childNodes = source.childNodes;\r\n var attributes = source.attributes;\r\n for (var i = 0; i < childNodes.length; i++) {\r\n _$a(dest, childNodes[i]);\r\n }\r\n for (var i = 0; i < attributes.length; i++) {\r\n var attr = attributes[i];\r\n dest.setAttributeNS(source.namespaceURI, attr.name, attr.value);\r\n }\r\n source.parentElement.replaceChild(dest, source);\r\n return dest;\r\n}\r\nfunction _$r(el, parent) {\r\n var root = parent || el.parentElement;\r\n if (root)\r\n root.removeChild(el);\r\n}\r\nfunction _$ce(tagName) {\r\n return document.createElement(tagName || 'div');\r\n}\r\nfunction _$cse(tagName) {\r\n return document.createElementNS('http://www.w3.org/2000/svg', tagName || 'svg');\r\n}\r\nfunction _$ct(content) {\r\n return document.createTextNode(content || '');\r\n}\r\nfunction _$cm(content) {\r\n return document.createComment(content || '');\r\n}\r\nfunction _$sa(el, attr, value) {\r\n el.setAttribute(attr, value);\r\n}\r\nfunction _$ga(el, attr) {\r\n return el.getAttribute(attr);\r\n}\r\nfunction _$al(el, event, handler) {\r\n el.addEventListener(event, handler, false);\r\n}\r\nfunction _$ul(el, event, oldHandler, newHandler) {\r\n _$rl(el, event, oldHandler);\r\n _$al(el, event, oldHandler = newHandler);\r\n return oldHandler;\r\n}\r\nfunction _$rl(el, event, handler) {\r\n el.removeEventListener(event, handler, false);\r\n}\r\nfunction _$bc(value) {\r\n var classes = '';\r\n if (_$isType(value, 'string')) {\r\n classes += \" \" + value;\r\n }\r\n else if (_$isArray(value)) {\r\n classes = value.map(_$bc).join(' ');\r\n }\r\n else if (_$isObject(value)) {\r\n for (var key in value)\r\n if (_$hasProp(value, key) && value[key])\r\n classes += \" \" + key;\r\n }\r\n return classes.trim();\r\n}\r\nfunction _$bs(value) {\r\n var el = _$ce();\r\n if (_$isObject(value)) {\r\n var style_1 = el.style;\r\n _$e(value, function (val, prop) {\r\n if (val !== style_1[prop]) {\r\n style_1[prop] = val;\r\n }\r\n });\r\n return style_1.cssText;\r\n }\r\n else if (_$isType(value, 'string')) {\r\n return value;\r\n }\r\n else {\r\n return '';\r\n }\r\n}\r\nfunction _$f(root, obj, loop) {\r\n var items = {}, loopParent, loopSibling;\r\n var globs = _$toArgs(arguments, 3);\r\n _$e(obj, function (item, i) { items[i] = loop.apply(null, [root, item, i].concat(globs)); });\r\n return {\r\n $create: function () {\r\n _$e(items, function (item) { item.$create(); });\r\n },\r\n $mount: function (parent, sibling) {\r\n loopParent = _$(parent);\r\n loopSibling = _$(sibling);\r\n _$e(items, function (item) { item.$mount(loopParent, loopSibling); });\r\n },\r\n $update: function (root, obj) {\r\n var globs = _$toArgs(arguments, 2);\r\n _$e(items, function (item, i) {\r\n if (obj[i]) {\r\n item.$update.apply(item, [root, obj[i], i].concat(globs));\r\n }\r\n else {\r\n item.$destroy();\r\n delete items[i];\r\n }\r\n });\r\n _$e(obj, function (item, i) {\r\n if (!items[i]) {\r\n items[i] = loop.apply(null, [root, item, i].concat(globs));\r\n items[i].$create();\r\n items[i].$mount(loopParent, loopSibling);\r\n }\r\n });\r\n },\r\n $destroy: function () {\r\n _$e(items, function (item) { item.$destroy(); });\r\n }\r\n };\r\n}\r\nfunction _$e(obj, cb) {\r\n for (var key in obj) {\r\n if (_$hasProp(obj, key)) {\r\n cb(obj[key], (isNaN(+key) ? key : +key));\r\n }\r\n }\r\n}\r\nfunction _$is(id, css) {\r\n var isNew = false;\r\n var style = _$(\"#\" + id, document.head);\r\n if (!style) {\r\n isNew = true;\r\n style = _$ce('style');\r\n style.id = id;\r\n _$sa(style, 'refs', '1');\r\n }\r\n if (style.textContent !== css) {\r\n style.textContent = css;\r\n }\r\n if (isNew) {\r\n _$a(document.head, style);\r\n }\r\n else {\r\n var count = +_$ga(style, 'refs');\r\n _$sa(style, 'refs', (++count).toString());\r\n }\r\n}\r\nfunction _$ds(id) {\r\n var style = _$(\"#\" + id, document.head);\r\n if (style) {\r\n var count = +_$ga(style, 'refs');\r\n if (--count === 0) {\r\n _$r(style, document.head);\r\n }\r\n else {\r\n _$sa(style, 'refs', count.toString());\r\n }\r\n }\r\n}\r\n//# sourceMappingURL=index.js.map\n// CONCATENATED MODULE: ./components/todo.ts\nvar filters = {\r\n actives: function (todos) {\r\n return todos.filter(function (todo) { return !todo.completed; });\r\n },\r\n filterByView: function (todos, view) {\r\n switch (view) {\r\n case 'active':\r\n return todos.filter(function (todo) { return !todo.completed; });\r\n case 'completed':\r\n return todos.filter(function (todo) { return todo.completed; });\r\n default:\r\n return todos;\r\n }\r\n },\r\n pluralize: function (word, count) {\r\n return \"\" + word + (count > 1 ? 's' : '');\r\n }\r\n};\r\nvar model = {\r\n view: '',\r\n todos: [],\r\n newTodo: '',\r\n oldTitle: '',\r\n _allDone: false,\r\n editedTodo: null,\r\n get remaining() {\r\n return this.$filters.actives(this.todos).length;\r\n },\r\n get allDone() {\r\n return this._allDone || this.remaining === 0;\r\n },\r\n set allDone(value) {\r\n this._allDone = value;\r\n },\r\n mark: function (item, value) {\r\n this.$set(\"todos.\" + item + \".completed\", value);\r\n this.$set('allDone', this.remaining === 0);\r\n },\r\n markAll: function (value) {\r\n this.todos.forEach(function (todo) { todo.completed = value; });\r\n this.$set('allDone', value);\r\n },\r\n addTodo: function () {\r\n var title = this.newTodo && this.newTodo.trim();\r\n if (!title)\r\n return;\r\n this.newTodo = '';\r\n this.todos.push({ title: title, completed: false });\r\n this.$set('allDone', this.remaining === 0);\r\n },\r\n editTodo: function (todo) {\r\n this.editedTodo = todo;\r\n this.oldTitle = todo.title;\r\n this.$update();\r\n },\r\n doneEdit: function (todo, e) {\r\n if (e.key === 'Enter') {\r\n todo.title = todo.title.trim();\r\n if (!todo.title) {\r\n this.removeTodo(todo);\r\n }\r\n this.clearTmps();\r\n }\r\n else if (e.key === 'Escape') {\r\n todo.title = this.oldTitle;\r\n this.clearTmps();\r\n }\r\n },\r\n removeTodo: function (todo) {\r\n var index = this.todos.indexOf(todo);\r\n this.todos.splice(index, 1);\r\n this.$set('allDone', this.remaining === 0);\r\n },\r\n removeCompleted: function () {\r\n this.$set('todos', this.$filters.actives(this.todos));\r\n },\r\n clearTmps: function () {\r\n this.editedTodo = null;\r\n this.oldTitle = '';\r\n this.$update();\r\n }\r\n};\r\nvar directives = {\r\n 'focus-edit': function (_inst, options, el) {\r\n if (options.value) {\r\n el.focus();\r\n }\r\n }\r\n};\r\n/* harmony default export */ var components_todo = ({ model: model, filters: filters, directives: directives });\r\n\n// CONCATENATED MODULE: ./components/todo.html\n\n\nfunction itemLoop_1(_$state, todo, i) {\n var _$frag, li_1, div_1, input_1, bindCheckedInput_1, changeEvent_1, handlerChangeEvent_1, label_1, txt_1, setTxt_1, dblclickEvent_1, handlerDblclickEvent_1, button_1, clickEvent_1, handlerClickEvent_1, input_2, focusEditDirective, inputEvent_1, handlerInputEvent_1, bindValueInput_2, blurEvent_1, handlerBlurEvent_1, keyupEvent_1, handlerKeyupEvent_1, bindClassLi_1;\n _$frag = _$d();\n bindCheckedInput_1 = function (_$state, todo) {\n return todo.completed;\n };\n changeEvent_1 = function (_$state, todo, i, $event, $el) {\n _$state.mark(i, $el.checked);\n };\n setTxt_1 = function (_$state, todo) {\n return todo.title;\n };\n dblclickEvent_1 = function (_$state, todo, i) {\n _$state.editTodo(todo, i);\n };\n clickEvent_1 = function (_$state, todo) {\n _$state.removeTodo(todo);\n };\n focusEditDirective = _$state.$directives['focus-edit'];\n inputEvent_1 = function (_$state, todo, i, $event, $el) {\n todo.title = $el.value;\n };\n bindValueInput_2 = function (_$state, todo) {\n return todo.title;\n };\n blurEvent_1 = function (_$state) {\n _$state.$set('editedTodo', null);\n };\n keyupEvent_1 = function (_$state, todo, i, $event) {\n _$state.doneEdit(todo, $event);\n };\n bindClassLi_1 = function (_$state, todo) {\n return ('scope_4827b611 todo ' + _$bc({\n completed: todo.completed,\n editing: todo === _$state.editedTodo\n })).trim();\n };\n return {\n $create: function () {\n li_1 = _$ce('li');\n div_1 = _$ce();\n input_1 = _$ce('input');\n label_1 = _$ce('label');\n txt_1 = _$ct();\n txt_1.data = setTxt_1(_$state, todo, i);\n button_1 = _$ce('button');\n input_2 = _$ce('input');\n this.$hydrate();\n },\n $hydrate: function () {\n input_1.checked = !!bindCheckedInput_1(_$state, todo, i);\n _$al(input_1, 'change', handlerChangeEvent_1 = function (event) {\n changeEvent_1(_$state, todo, i, event, input_1);\n });\n _$sa(input_1, 'class', 'scope_4827b611 toggle');\n _$sa(input_1, 'type', 'checkbox');\n _$al(label_1, 'dblclick', handlerDblclickEvent_1 = function (event) {\n dblclickEvent_1(_$state, todo, i, event, label_1);\n });\n _$sa(label_1, 'class', 'scope_4827b611');\n _$al(button_1, 'click', handlerClickEvent_1 = function (event) {\n clickEvent_1(_$state, todo, i, event, button_1);\n });\n _$sa(button_1, 'class', 'scope_4827b611 destroy');\n _$sa(div_1, 'class', 'scope_4827b611 view');\n focusEditDirective.$init(_$state, {\n value: todo === _$state.editedTodo,\n expression: 'todo === editedTodo',\n modifiers: {}\n }, input_2);\n _$al(input_2, 'input', handlerInputEvent_1 = function (event) {\n inputEvent_1(_$state, todo, i, event, input_2);\n });\n input_2.value = _$toStr(bindValueInput_2(_$state, todo, i));\n _$al(input_2, 'blur', handlerBlurEvent_1 = function (event) {\n blurEvent_1(_$state, todo, i, event, input_2);\n });\n _$al(input_2, 'keyup', handlerKeyupEvent_1 = function (event) {\n keyupEvent_1(_$state, todo, i, event, input_2);\n });\n _$sa(input_2, 'type', 'text');\n _$sa(input_2, 'class', 'scope_4827b611 edit');\n _$sa(li_1, 'class', _$toStr(bindClassLi_1(_$state, todo, i)));\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$a(_$(parent), _$frag, _$(sibling));\n focusEditDirective.$inserted(_$state, {\n value: todo === _$state.editedTodo,\n expression: 'todo === editedTodo',\n modifiers: {}\n }, input_2);\n },\n $update: function (_$state, todo, i) {\n var updateCheckedInput_1 = !!bindCheckedInput_1(_$state, todo, i);\n if (input_1.checked !== updateCheckedInput_1) {\n input_1.checked = updateCheckedInput_1;\n }\n updateCheckedInput_1 = void 0;\n handlerChangeEvent_1 = _$ul(input_1, 'change', handlerChangeEvent_1, function (event) {\n changeEvent_1(_$state, todo, i, event, input_1);\n });\n var updateTxt_1 = setTxt_1(_$state, todo, i);\n if (txt_1.data !== _$toStr(updateTxt_1)) {\n txt_1.data = updateTxt_1;\n }\n updateTxt_1 = void 0;\n handlerDblclickEvent_1 = _$ul(label_1, 'dblclick', handlerDblclickEvent_1, function (event) {\n dblclickEvent_1(_$state, todo, i, event, label_1);\n });\n handlerClickEvent_1 = _$ul(button_1, 'click', handlerClickEvent_1, function (event) {\n clickEvent_1(_$state, todo, i, event, button_1);\n });\n focusEditDirective.$update(_$state, {\n value: todo === _$state.editedTodo,\n expression: 'todo === editedTodo',\n modifiers: {}\n }, input_2);\n handlerInputEvent_1 = _$ul(input_2, 'input', handlerInputEvent_1, function (event) {\n inputEvent_1(_$state, todo, i, event, input_2);\n });\n var updateValueInput_2 = _$toStr(bindValueInput_2(_$state, todo, i));\n if (input_2.value !== updateValueInput_2) {\n input_2.value = updateValueInput_2;\n }\n updateValueInput_2 = void 0;\n handlerBlurEvent_1 = _$ul(input_2, 'blur', handlerBlurEvent_1, function (event) {\n blurEvent_1(_$state, todo, i, event, input_2);\n });\n handlerKeyupEvent_1 = _$ul(input_2, 'keyup', handlerKeyupEvent_1, function (event) {\n keyupEvent_1(_$state, todo, i, event, input_2);\n });\n var updateClassLi_1 = _$toStr(bindClassLi_1(_$state, todo, i));\n if (_$ga(li_1, 'class') !== updateClassLi_1) {\n _$sa(li_1, 'class', updateClassLi_1);\n }\n updateClassLi_1 = void 0;\n },\n $unmount: function () {\n _$a(div_1, input_1);\n _$a(label_1, txt_1);\n _$a(div_1, label_1);\n _$a(div_1, button_1);\n _$a(li_1, div_1);\n _$a(li_1, input_2);\n _$a(_$frag, li_1);\n },\n $destroy: function () {\n this.$unmount();\n _$rl(input_1, 'change', handlerChangeEvent_1);\n _$rl(label_1, 'dblclick', handlerDblclickEvent_1);\n _$rl(button_1, 'click', handlerClickEvent_1);\n focusEditDirective.$destroy(_$state, {\n value: todo === _$state.editedTodo,\n expression: 'todo === editedTodo',\n modifiers: {}\n }, input_2);\n _$rl(input_2, 'input', handlerInputEvent_1);\n _$rl(input_2, 'blur', handlerBlurEvent_1);\n _$rl(input_2, 'keyup', handlerKeyupEvent_1);\n _$frag = li_1 = div_1 = input_1 = bindCheckedInput_1 = changeEvent_1 = handlerChangeEvent_1 = label_1 = txt_1 = setTxt_1 = dblclickEvent_1 = handlerDblclickEvent_1 = button_1 = clickEvent_1 = handlerClickEvent_1 = input_2 = focusEditDirective = inputEvent_1 = handlerInputEvent_1 = bindValueInput_2 = blurEvent_1 = handlerBlurEvent_1 = keyupEvent_1 = handlerKeyupEvent_1 = bindClassLi_1 = void 0;\n }\n };\n}\nfunction _$tplTodo(_$state) {\n var _$frag, section_1, header_1, h1_1, txt_1, input_1, inputEvent_1, handlerInputEvent_1, bindValueInput_1, keyupEvent_1, handlerKeyupEvent_1, section_2, input_2, bindCheckedInput_2, changeEvent_1, handlerChangeEvent_1, label_1, txt_2, ul_1, loopAnchor_1_1, loopBlock_1, displaySection_2, footer_1, span_1, txt_3, setTxt_3, ul_2, li_1, a_1, txt_4, bindClassA_1, clickEvent_1, handlerClickEvent_1, li_2, a_2, txt_5, bindClassA_2, clickEvent_2, handlerClickEvent_2, li_3, a_3, txt_6, bindClassA_3, clickEvent_3, handlerClickEvent_3, button_1, txt_7, clickEvent_4, handlerClickEvent_4, displayButton_1, displayFooter_1;\n _$frag = _$d();\n inputEvent_1 = function (_$state, $event, $el) {\n _$state.$set('newTodo', $el.value);\n };\n bindValueInput_1 = function (_$state) {\n return _$state.newTodo;\n };\n keyupEvent_1 = function (_$state) {\n _$state.addTodo();\n };\n bindCheckedInput_2 = function (_$state) {\n return _$state.allDone;\n };\n changeEvent_1 = function (_$state, $event, $el) {\n _$state.markAll($el.checked);\n };\n loopBlock_1 = _$f(_$state, _$state.$filters.filterByView(_$state.todos, _$state.view), itemLoop_1);\n loopAnchor_1_1 = _$ct();\n var showSection_2 = function (_$state, el, display) {\n el.style.display = _$state.todos.length ? display : 'none';\n };\n setTxt_3 = function (_$state) {\n return _$state.remaining + _$state.$filters.pluralize(' item', _$state.remaining) + ' left';\n };\n bindClassA_1 = function (_$state) {\n return ('scope_4827b611 ' + _$bc({ selected: _$state.view === '' })).trim();\n };\n clickEvent_1 = function (_$state) {\n _$state.$set('view', '');\n };\n bindClassA_2 = function (_$state) {\n return ('scope_4827b611 ' + _$bc({ selected: _$state.view === 'active' })).trim();\n };\n clickEvent_2 = function (_$state) {\n _$state.$set('view', 'active');\n };\n bindClassA_3 = function (_$state) {\n return ('scope_4827b611 ' + _$bc({ selected: _$state.view === 'completed' })).trim();\n };\n clickEvent_3 = function (_$state) {\n _$state.$set('view', 'completed');\n };\n clickEvent_4 = function (_$state) {\n _$state.removeCompleted();\n };\n var showButton_1 = function (_$state, el, display) {\n el.style.display = _$state.todos.length > _$state.remaining ? display : 'none';\n };\n var showFooter_1 = function (_$state, el, display) {\n el.style.display = _$state.todos.length ? display : 'none';\n };\n return {\n $create: function () {\n section_1 = _$ce('section');\n header_1 = _$ce('header');\n h1_1 = _$ce('h1');\n txt_1 = _$ct('todos');\n input_1 = _$ce('input');\n section_2 = _$ce('section');\n input_2 = _$ce('input');\n label_1 = _$ce('label');\n txt_2 = _$ct('Mark all as complete');\n ul_1 = _$ce('ul');\n loopBlock_1.$create();\n footer_1 = _$ce('footer');\n span_1 = _$ce('span');\n txt_3 = _$ct();\n txt_3.data = setTxt_3(_$state);\n ul_2 = _$ce('ul');\n li_1 = _$ce('li');\n a_1 = _$ce('a');\n txt_4 = _$ct('All');\n li_2 = _$ce('li');\n a_2 = _$ce('a');\n txt_5 = _$ct('Active');\n li_3 = _$ce('li');\n a_3 = _$ce('a');\n txt_6 = _$ct('Completed');\n button_1 = _$ce('button');\n txt_7 = _$ct(' Clear completed ');\n this.$hydrate();\n },\n $hydrate: function () {\n _$sa(h1_1, 'class', 'scope_4827b611');\n _$al(input_1, 'input', handlerInputEvent_1 = function (event) {\n inputEvent_1(_$state, event, input_1);\n });\n input_1.value = _$toStr(bindValueInput_1(_$state));\n _$al(input_1, 'keyup', handlerKeyupEvent_1 = function (event) {\n if (_$isKey(event, 'enter')) {\n keyupEvent_1(_$state, event, input_1);\n }\n });\n _$sa(input_1, 'class', 'scope_4827b611 new-todo');\n _$sa(input_1, 'placeholder', 'What needs to be done?');\n _$sa(input_1, 'autofocus', '');\n _$sa(header_1, 'class', 'scope_4827b611 header');\n input_2.checked = !!bindCheckedInput_2(_$state);\n _$al(input_2, 'change', handlerChangeEvent_1 = function (event) {\n changeEvent_1(_$state, event, input_2);\n });\n _$sa(input_2, 'class', 'scope_4827b611 toggle-all');\n _$sa(input_2, 'type', 'checkbox');\n _$sa(label_1, 'for', 'toggle-all');\n _$sa(label_1, 'class', 'scope_4827b611');\n _$sa(ul_1, 'class', 'scope_4827b611 todo-list');\n displaySection_2 = section_2.style.display;\n showSection_2(_$state, section_2, displaySection_2);\n _$sa(section_2, 'class', 'scope_4827b611 main');\n _$sa(span_1, 'class', 'scope_4827b611 todo-count');\n _$sa(a_1, 'class', _$toStr(bindClassA_1(_$state)));\n _$al(a_1, 'click', handlerClickEvent_1 = function (event) {\n clickEvent_1(_$state, event, a_1);\n });\n _$sa(a_1, 'href', '#/');\n _$sa(li_1, 'class', 'scope_4827b611');\n _$sa(a_2, 'class', _$toStr(bindClassA_2(_$state)));\n _$al(a_2, 'click', handlerClickEvent_2 = function (event) {\n clickEvent_2(_$state, event, a_2);\n });\n _$sa(a_2, 'href', '#/active');\n _$sa(li_2, 'class', 'scope_4827b611');\n _$sa(a_3, 'class', _$toStr(bindClassA_3(_$state)));\n _$al(a_3, 'click', handlerClickEvent_3 = function (event) {\n clickEvent_3(_$state, event, a_3);\n });\n _$sa(a_3, 'href', '#/completed');\n _$sa(li_3, 'class', 'scope_4827b611');\n _$sa(ul_2, 'class', 'scope_4827b611 filters');\n _$al(button_1, 'click', handlerClickEvent_4 = function (event) {\n clickEvent_4(_$state, event, button_1);\n });\n displayButton_1 = button_1.style.display;\n showButton_1(_$state, button_1, displayButton_1);\n _$sa(button_1, 'class', 'scope_4827b611 clear-completed');\n displayFooter_1 = footer_1.style.display;\n showFooter_1(_$state, footer_1, displayFooter_1);\n _$sa(footer_1, 'class', 'scope_4827b611 footer');\n _$sa(section_1, 'class', 'scope_4827b611 todoapp');\n },\n $mount: function (parent, sibling) {\n this.$unmount();\n _$is('scope_4827b611', '.scope_4827b611.view label.scope_4827b611{user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;}');\n _$a(_$(parent), _$frag, _$(sibling));\n this.$siblingEl = _$(sibling);\n this.$parentEl = sibling && _$(sibling).parentElement || _$(parent);\n },\n $update: function (_$state) {\n var updateValueInput_1 = _$toStr(bindValueInput_1(_$state));\n if (input_1.value !== updateValueInput_1) {\n input_1.value = updateValueInput_1;\n }\n updateValueInput_1 = void 0;\n var updateCheckedInput_2 = !!bindCheckedInput_2(_$state);\n if (input_2.checked !== updateCheckedInput_2) {\n input_2.checked = updateCheckedInput_2;\n }\n updateCheckedInput_2 = void 0;\n loopBlock_1.$update(_$state, _$state.$filters.filterByView(_$state.todos, _$state.view));\n showSection_2(_$state, section_2, displaySection_2);\n var updateTxt_3 = setTxt_3(_$state);\n if (txt_3.data !== _$toStr(updateTxt_3)) {\n txt_3.data = updateTxt_3;\n }\n updateTxt_3 = void 0;\n var updateClassA_1 = _$toStr(bindClassA_1(_$state));\n if (_$ga(a_1, 'class') !== updateClassA_1) {\n _$sa(a_1, 'class', updateClassA_1);\n }\n updateClassA_1 = void 0;\n var updateClassA_2 = _$toStr(bindClassA_2(_$state));\n if (_$ga(a_2, 'class') !== updateClassA_2) {\n _$sa(a_2, 'class', updateClassA_2);\n }\n updateClassA_2 = void 0;\n var updateClassA_3 = _$toStr(bindClassA_3(_$state));\n if (_$ga(a_3, 'class') !== updateClassA_3) {\n _$sa(a_3, 'class', updateClassA_3);\n }\n updateClassA_3 = void 0;\n showButton_1(_$state, button_1, displayButton_1);\n showFooter_1(_$state, footer_1, displayFooter_1);\n },\n $unmount: function () {\n _$a(h1_1, txt_1);\n _$a(header_1, h1_1);\n _$a(header_1, input_1);\n _$a(section_1, header_1);\n _$a(section_2, input_2);\n _$a(label_1, txt_2);\n _$a(section_2, label_1);\n _$a(ul_1, loopAnchor_1_1);\n loopBlock_1.$mount(ul_1, loopAnchor_1_1);\n _$a(section_2, ul_1);\n _$a(section_1, section_2);\n _$a(span_1, txt_3);\n _$a(footer_1, span_1);\n _$a(a_1, txt_4);\n _$a(li_1, a_1);\n _$a(ul_2, li_1);\n _$a(a_2, txt_5);\n _$a(li_2, a_2);\n _$a(ul_2, li_2);\n _$a(a_3, txt_6);\n _$a(li_3, a_3);\n _$a(ul_2, li_3);\n _$a(footer_1, ul_2);\n _$a(button_1, txt_7);\n _$a(footer_1, button_1);\n _$a(section_1, footer_1);\n _$a(_$frag, section_1);\n },\n $destroy: function () {\n this.$unmount();\n this.$parent = null;\n this.$parentEl = null;\n this.$siblingEl = null;\n this.$children.splice(0, this.$children.length);\n _$ds('scope_4827b611');\n _$rl(input_1, 'input', handlerInputEvent_1);\n _$rl(input_1, 'keyup', handlerKeyupEvent_1);\n _$rl(input_2, 'change', handlerChangeEvent_1);\n loopBlock_1.$destroy();\n _$rl(a_1, 'click', handlerClickEvent_1);\n _$rl(a_2, 'click', handlerClickEvent_2);\n _$rl(a_3, 'click', handlerClickEvent_3);\n _$rl(button_1, 'click', handlerClickEvent_4);\n delete _$state.$root;\n _$frag = section_1 = header_1 = h1_1 = txt_1 = input_1 = inputEvent_1 = handlerInputEvent_1 = bindValueInput_1 = keyupEvent_1 = handlerKeyupEvent_1 = section_2 = input_2 = bindCheckedInput_2 = changeEvent_1 = handlerChangeEvent_1 = label_1 = txt_2 = ul_1 = loopAnchor_1_1 = loopBlock_1 = displaySection_2 = footer_1 = span_1 = txt_3 = setTxt_3 = ul_2 = li_1 = a_1 = txt_4 = bindClassA_1 = clickEvent_1 = handlerClickEvent_1 = li_2 = a_2 = txt_5 = bindClassA_2 = clickEvent_2 = handlerClickEvent_2 = li_3 = a_3 = txt_6 = bindClassA_3 = clickEvent_3 = handlerClickEvent_3 = button_1 = txt_7 = clickEvent_4 = handlerClickEvent_4 = displayButton_1 = displayFooter_1 = void 0;\n }\n };\n}\nfunction Todo(_$attrs, _$parent) {\n _$CompCtr.call(this, _$attrs, _$tplTodo, components_todo, _$parent);\n !_$parent && this.$create();\n}\nTodo.plugin = _$plugin;\nTodo.prototype = Object.create(_$CompCtr.prototype);\nTodo.prototype.constructor = Todo;\n/* harmony default export */ var components_todo_0 = (Todo);\n// CONCATENATED MODULE: ./main.ts\n\r\nvar main_todo = new components_todo_0();\r\nmain_todo.$mount('main');\r\n\n\n//# sourceURL=webpack:///./main.ts_+_3_modules?"); +eval("\n// CONCATENATED MODULE: h:/trebor-repos/trebor/tools/index.js\nvar PROP_MAP = { p: '__TP__', v: 'value', _: '_value', s: '_subscribers', e: '_events', w: '_watchers', h: 'prototype' };\r\nvar PROPS = ['$slots', '$refs', '$filters', '$directives', '_events', '_watchers'];\r\nvar TPS = window[PROP_MAP.p] || (window[PROP_MAP.p] = []);\r\nvar _$assign = Object['assign'] || function (t) {\r\n for (var s = void 0, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s)\r\n if (_$hasProp(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n};\r\nfunction _$CompCtr(attrs, template, options, parent) {\r\n var self = this;\r\n var _$set = function (prop, value) { _$def(self, prop, { value: value, writable: true }); };\r\n if (!attrs)\r\n attrs = {};\r\n _$e(PROPS, function (prop) { _$def(self, prop, { value: {} }); });\r\n _$set('$parent', parent || null);\r\n _$set('$children', []);\r\n _$set(PROP_MAP.s, {});\r\n _$set('$options', options);\r\n var opts = self.$options;\r\n if (!opts.attrs)\r\n opts.attrs = {};\r\n if (!opts.children)\r\n opts.children = {};\r\n _$e(TPS, function (plugin) { plugin.fn.call(self, _$CompCtr, plugin.options); });\r\n if (opts.filters)\r\n _$assign(self.$filters, opts.filters);\r\n if (opts.directives)\r\n _$e(opts.directives, function (drt, k) { self.$directives[k] = _$drt(drt); });\r\n _$e(opts.attrs, function (attrOps, key) {\r\n _$def(self, (_$isType(key, 'number') ? attrOps : key), {\r\n get: function () {\r\n if (_$isStr(attrOps)) {\r\n var value = attrs[attrOps];\r\n return _$isFunction(value) ? value() : value;\r\n }\r\n else {\r\n if (!_$hasProp(attrs, key) && attrOps.required) {\r\n return console.error(\"Attribute '\" + key + \"' is required.\");\r\n }\r\n else {\r\n var value = _$isFunction(attrs[key]) ? attrs[key]() : attrs[key];\r\n if (value === void 0 && _$hasProp(attrOps, 'default')) {\r\n var def = attrOps.default;\r\n value = _$isFunction(def) ? def() : def;\r\n }\r\n var typ = attrOps.type;\r\n if (typ && !_$isType(value, typ) && attrOps.required) {\r\n return console.error(\"Attribute '\" + key + \"' must be type '\" + typ + \"'.\");\r\n }\r\n value = _$toType(value, value === void 0 ? 'undefined' : typ, self, key);\r\n if (value !== void 0 && _$hasProp(attrOps, 'validator')) {\r\n var validator = attrOps.validator;\r\n if (_$isFunction(validator) && !validator(value)) {\r\n return console.error(\"Assigment '\" + key + \"'='\" + JSON.stringify(value) + \"' invalid.\");\r\n }\r\n }\r\n return value;\r\n }\r\n }\r\n },\r\n set: function () {\r\n console.error(\"'\" + key + \"' is read only.\");\r\n },\r\n enumerable: true, configurable: true\r\n });\r\n });\r\n var data = opts.model || {};\r\n var _loop_1 = function (key) {\r\n if (_$hasProp(data, key)) {\r\n var desc = Object.getOwnPropertyDescriptor(data, key);\r\n if (desc.value && _$isArray(desc.value)) {\r\n desc.value = new _$List(desc.value, self, key);\r\n }\r\n else {\r\n if (desc.get) {\r\n var getter_1 = desc.get;\r\n desc.get = function () {\r\n var value = getter_1.call(self);\r\n if (_$isArray(value))\r\n value = new _$List(value, self, key);\r\n return value;\r\n };\r\n }\r\n if (desc.set) {\r\n var setter_1 = desc.set;\r\n desc.set = function (v) {\r\n if (_$isArray(v))\r\n v = new _$List(v, self, key);\r\n setter_1.call(self, v);\r\n };\r\n }\r\n }\r\n _$def(self, key, desc);\r\n }\r\n };\r\n for (var key in data) {\r\n _loop_1(key);\r\n }\r\n var tpl = template(self);\r\n _$e(tpl, function (value, key) {\r\n _$def(self, key, {\r\n value: (function (key) {\r\n var hook = key[1].toUpperCase() + key.slice(2);\r\n var bhook = opts[\"before\" + hook];\r\n var ahook = opts[\"after\" + hook];\r\n return function () {\r\n bhook && bhook.call(this);\r\n key.slice(1) === 'update' ? value.call(this, this) : value.apply(this, arguments);\r\n ahook && ahook.call(this);\r\n };\r\n })(key)\r\n });\r\n });\r\n _$def(self, '$data', {\r\n get: function () {\r\n return _$toPlainObj(this);\r\n }\r\n });\r\n}\r\nfunction _$isValueAttr(attr) {\r\n return attr === 'value';\r\n}\r\nfunction _$subs(dep, listener) {\r\n if (!this[PROP_MAP.s][dep]) {\r\n this[PROP_MAP.s][dep] = [];\r\n }\r\n return this[PROP_MAP.s][dep].push(listener.bind(this)) - 1;\r\n}\r\nfunction _$def(obj, key, desc) {\r\n Object.defineProperty(obj, key, desc);\r\n}\r\n_$assign(_$CompCtr[PROP_MAP.h], {\r\n $get: function (path) {\r\n return _$accesor(this, path);\r\n },\r\n $set: function (path, value) {\r\n _$accesor(this, path, value);\r\n },\r\n $on: function (event, handler) {\r\n var _this = this;\r\n if (!this[PROP_MAP.e][event]) {\r\n this[PROP_MAP.e][event] = [];\r\n }\r\n var i = this[PROP_MAP.e][event].push(handler);\r\n return {\r\n $off: function () {\r\n _this[PROP_MAP.e][event].splice(i - 1, 1);\r\n }\r\n };\r\n },\r\n $once: function (event, handler) {\r\n var e = this.$on(event, function (args) {\r\n handler(args);\r\n e.$off();\r\n });\r\n },\r\n $fire: function (event, data) {\r\n if (this[PROP_MAP.e][event]) {\r\n _$e(this[PROP_MAP.e][event], function (handler) { handler(data); });\r\n }\r\n },\r\n $notify: function (key) {\r\n if (this[PROP_MAP.s][key]) {\r\n _$e(this[PROP_MAP.s][key], function (suscriber) { suscriber(); });\r\n }\r\n },\r\n $observe: function (deps, listener) {\r\n var _this = this;\r\n var subs = [];\r\n if (_$isArray(deps)) {\r\n _$e(deps, function (dep) {\r\n subs.push({ sub: dep, i: _$subs.call(_this, dep, listener) });\r\n });\r\n }\r\n else {\r\n subs.push({ sub: deps, i: _$subs.call(this, deps, listener) });\r\n }\r\n return {\r\n $unobserve: function () {\r\n _$e(subs, function (sub) {\r\n _this[PROP_MAP.s][sub.sub].splice(sub.i, 1);\r\n });\r\n }\r\n };\r\n },\r\n $watch: function (key, watcher) {\r\n var _this = this;\r\n if (!this[PROP_MAP.w][key]) {\r\n this[PROP_MAP.w][key] = [];\r\n }\r\n var i = this[PROP_MAP.w][key].push(watcher.bind(this));\r\n return {\r\n $unwatch: function () {\r\n _this[PROP_MAP.w][key].splice(i - 1, 1);\r\n }\r\n };\r\n }\r\n});\r\nvar array = Array[PROP_MAP.h];\r\nfunction _$toArgs(args, start) {\r\n if (start === void 0) { start = 0; }\r\n return array.slice.call(args, start);\r\n}\r\nfunction _$arrayValues(list, value, root, key) {\r\n array.push.apply(list, value.map(function (v, i) {\r\n if (list.length !== 0)\r\n i += list.length;\r\n return !(_$isType(v, _$List)) && _$isArray(v) ? new _$List(v, root, key + \".\" + i) : v;\r\n }));\r\n}\r\nfunction _$List(value, root, key) {\r\n var self = this;\r\n Array.apply(self, [value.length]);\r\n var desc = { writable: false, configurable: false, enumerable: false };\r\n _$def(self, '_key', _$assign({ value: key }, desc));\r\n _$def(self, '_root', _$assign({ value: root }, desc));\r\n _$arrayValues(self, value, root, key);\r\n desc.writable = true;\r\n _$def(self, 'length', _$assign({ value: self.length }, desc));\r\n}\r\n_$extends(_$List, Array);\r\n['pop', 'push', 'reverse', 'shift', 'sort', 'fill', 'unshift', 'splice'].forEach(function (method) {\r\n _$List[PROP_MAP.h][method] = function () {\r\n var self = this;\r\n var old = self.slice();\r\n var result;\r\n if (method === 'push') {\r\n _$arrayValues(self, _$toArgs(arguments), self._root, self._key);\r\n result = self.length;\r\n }\r\n else {\r\n result = array[method].apply(self, arguments);\r\n }\r\n _$dispatch(self._root, self._key, old, self.slice());\r\n return result;\r\n };\r\n});\r\n_$List[PROP_MAP.h].pull = function (index) {\r\n var self = this;\r\n var items = _$toArgs(arguments, 1);\r\n var length = self.length;\r\n if (index > length) {\r\n length = index + 1;\r\n var pull = new Array(index - self.length);\r\n pull.push.apply(pull, items);\r\n for (var i = 0; i < length; i++) {\r\n if (i === index) {\r\n self.push.apply(self, pull);\r\n }\r\n }\r\n }\r\n else {\r\n self.splice.apply(self, [index, 1].concat(items));\r\n }\r\n};\r\nfunction _$dispatch(root, key, oldVal, value) {\r\n root.$notify(key);\r\n if (root[PROP_MAP.w][key]) {\r\n _$e(root[PROP_MAP.w][key], function (watcher) { watcher(oldVal, value); });\r\n }\r\n root.$update();\r\n}\r\nfunction _$extends(ctor, exts) {\r\n ctor['plugin'] = function (fn, options) {\r\n TPS.push({ options: options, fn: fn });\r\n };\r\n ctor[PROP_MAP.h] = Object.create(exts[PROP_MAP.h]);\r\n ctor[PROP_MAP.h].constructor = ctor;\r\n}\r\nfunction _$isType(value, type) {\r\n return _$type(type) === 'string' ? type.split('|').some(function (t) { return t.trim() === _$type(value); }) : value instanceof type;\r\n}\r\nfunction _$apply(callee, args, globs, thisArg) {\r\n if (thisArg === void 0) { thisArg = null; }\r\n return callee.apply(thisArg, args.concat(globs));\r\n}\r\nfunction _$isObject(obj) {\r\n return _$isType(obj, 'object');\r\n}\r\nfunction _$isArray(obj) {\r\n return Array.isArray ? Array.isArray(obj) : _$isType(obj, 'array');\r\n}\r\nfunction _$isFunction(obj) {\r\n return _$isType(obj, 'function');\r\n}\r\nfunction _$isStr(obj) {\r\n return _$isType(obj, 'string');\r\n}\r\nfunction _$toType(value, type, root, key) {\r\n switch (type) {\r\n case 'date':\r\n return new Date(value);\r\n case 'string':\r\n return _$toStr(value);\r\n case 'number':\r\n return +value;\r\n case 'boolean':\r\n return _$isStr(value) && !value ? true : !!value;\r\n case 'array':\r\n return _$isType(value, _$List) ? value : new _$List(value, root, key);\r\n default:\r\n return value;\r\n }\r\n}\r\nfunction _$type(obj) {\r\n return / (\\w+)/.exec(({}).toString.call(obj))[1].toLowerCase();\r\n}\r\nfunction _$hasProp(obj, prop) {\r\n return obj.hasOwnProperty(prop);\r\n}\r\nfunction _$drt(dd) {\r\n var hasProp = function (prop, instance, options, element) { return _$isObject(dd) && dd[prop] && dd[prop](instance, options, element); };\r\n return {\r\n $init: function (instance, options, element) {\r\n hasProp('$init', instance, options, element);\r\n },\r\n $inserted: function (instance, options, element) {\r\n hasProp('$inserted', instance, options, element);\r\n },\r\n $update: function (instance, options, element) {\r\n if (_$isFunction(dd)) {\r\n dd(instance, options, element);\r\n }\r\n else {\r\n hasProp('$update', instance, options, element);\r\n }\r\n },\r\n $destroy: function (instance, options, element) {\r\n hasProp('$destroy', instance, options, element);\r\n }\r\n };\r\n}\r\nfunction _$noop() { }\r\nfunction _$add(inst, Child, attrs) {\r\n var child = null;\r\n if (Child) {\r\n child = new Child(attrs, inst);\r\n inst.$children.push(child);\r\n }\r\n return child;\r\n}\r\nfunction _$remove(inst, child) {\r\n var index = inst.$children.indexOf(child);\r\n index >= 0 && inst.$children.splice(index, 1);\r\n}\r\nfunction _$toStr(obj) {\r\n var str = _$type(obj);\r\n return !/null|undefined/.test(str) ? obj.toString() : str;\r\n}\r\nfunction _$toPlainObj(obj) {\r\n var data = {};\r\n _$e(_$isObject(obj) ? obj : {}, function (_v, k) {\r\n if (k[0] !== '$' && !_$isFunction(obj[k])) {\r\n if (_$isType(obj[k], _$List)) {\r\n data[k] = obj[k].map(_$toPlainObj);\r\n }\r\n else if (_$isObject(obj[k])) {\r\n data[k] = _$toPlainObj(obj[k]);\r\n }\r\n else {\r\n data[k] = obj[k];\r\n }\r\n }\r\n });\r\n return _$isObject(obj) ? data : obj;\r\n}\r\nfunction _$setRef(refs, prop, node) {\r\n if (!_$hasProp(refs, prop)) {\r\n var value_1 = [];\r\n _$def(refs, prop, {\r\n get: function () { return value_1.length <= 1 ? value_1[0] : value_1; },\r\n set: function (val) { val && !~value_1.indexOf(val) && value_1.push(val); },\r\n enumerable: true, configurable: true\r\n });\r\n }\r\n refs[prop] = node;\r\n}\r\nfunction _$accesor(object, path, value) {\r\n return path.split('.').reduce(function (obj, key, i, arr) {\r\n if (_$isType(value, 'undefined')) {\r\n if (obj == null) {\r\n arr.splice(0, arr.length);\r\n return i > 0 && obj === null ? obj : undefined;\r\n }\r\n }\r\n else {\r\n if (i === arr.length - 1) {\r\n if (_$isType(obj, _$List) && _$toStr(+key) === key) {\r\n obj.pull(+key, value);\r\n }\r\n else {\r\n var oldVal = obj[key];\r\n obj[key] = !_$isType(value, _$List) && _$isArray(value) ? new _$List(value, object, key) : value;\r\n _$dispatch(object, path, oldVal, obj[key]);\r\n }\r\n }\r\n else if (!_$isObject(obj[key])) {\r\n obj[key] = {};\r\n }\r\n }\r\n return obj ? obj[key] : null;\r\n }, object);\r\n}\r\nfunction _$emptyElse() {\r\n return { type: 'empty-else', $create: _$noop, $mount: _$noop, $update: _$noop, $destroy: _$noop };\r\n}\r\nfunction _$isKey(event, key) {\r\n return event.key.toLowerCase() === key || !!event[key + \"Key\"];\r\n}\r\nfunction _$bindGroup(input, selection) {\r\n var _value = _$gv(input);\r\n var _$index = selection.indexOf(_value);\r\n input.checked && !~_$index ? selection.push(_value) : selection.splice(_$index, 1);\r\n}\r\nfunction _$bindMultiSelect(select, selections) {\r\n if (!selections.length)\r\n return;\r\n var options = select.options;\r\n for (var i = 0; i < options.length; i++) {\r\n options[i].selected = !!~selections.indexOf(_$gv(options[i]));\r\n }\r\n}\r\nfunction _$updateMultiSelect(select, obj, prop) {\r\n var items = [];\r\n var selection = obj[prop];\r\n var selectedOptions = select.selectedOptions;\r\n for (var i = 0; i < selectedOptions.length; i++) {\r\n items.push(_$gv(selectedOptions[i]));\r\n }\r\n obj[prop] = new _$List(items, selection['_root'], selection['_key']);\r\n obj.$update();\r\n}\r\nfunction _$(selector, parent) {\r\n return _$isStr(selector) ? (parent || document).querySelector(selector) : selector;\r\n}\r\nfunction _$d() {\r\n return document.createDocumentFragment();\r\n}\r\nfunction _$a(parent, child, sibling) {\r\n if (_$isType(sibling, 'boolean') && sibling)\r\n parent.parentElement.replaceChild(child, parent);\r\n else if (!sibling)\r\n parent.appendChild(child);\r\n else\r\n parent.insertBefore(child, sibling);\r\n}\r\nfunction _$as(source, dest) {\r\n var childNodes = source.childNodes, attributes = source.attributes;\r\n for (var i = 0; i < childNodes.length; i++) {\r\n _$a(dest, childNodes[i]);\r\n }\r\n for (var i = 0; i < attributes.length; i++) {\r\n var attr = attributes[i];\r\n dest.setAttributeNS(source.namespaceURI, attr.name, attr.value);\r\n }\r\n source.parentElement.replaceChild(dest, source);\r\n return dest;\r\n}\r\nfunction _$r(el, parent) {\r\n var root = parent || el.parentElement;\r\n if (root)\r\n root.removeChild(el);\r\n}\r\nfunction _$ce(tagName) {\r\n return document.createElement(tagName || 'div');\r\n}\r\nfunction _$cse(tagName) {\r\n return document.createElementNS('http://www.w3.org/2000/svg', tagName || 'svg');\r\n}\r\nfunction _$ct(content) {\r\n return document.createTextNode(content || '');\r\n}\r\nfunction _$cm(content) {\r\n return document.createComment(content || '');\r\n}\r\nfunction _$sa(el, attrAndValue) {\r\n var attr = attrAndValue[0], value = attrAndValue[1];\r\n el.setAttribute(attr, _$toStr(value));\r\n if (_$isValueAttr(attr) && !_$isStr(value))\r\n el[PROP_MAP._] = value;\r\n}\r\nfunction _$ga(el, attr) {\r\n return _$isValueAttr(attr) ? _$gv(el) : el.getAttribute(attr);\r\n}\r\nfunction _$gv(el) {\r\n return _$hasProp(el, PROP_MAP._) ? el[PROP_MAP._] : el[PROP_MAP.v];\r\n}\r\nfunction _$al(el, event, handler) {\r\n el.addEventListener(event, handler, false);\r\n}\r\nfunction _$ul(el, event, oldHandler, newHandler) {\r\n _$rl(el, event, oldHandler);\r\n _$al(el, event, oldHandler = newHandler);\r\n return oldHandler;\r\n}\r\nfunction _$rl(el, event, handler) {\r\n el.removeEventListener(event, handler, false);\r\n}\r\nfunction _$bc(value) {\r\n var classes = '';\r\n if (_$isStr(value)) {\r\n classes += \" \" + value;\r\n }\r\n else if (_$isArray(value)) {\r\n classes = value.map(_$bc).join(' ');\r\n }\r\n else if (_$isObject(value)) {\r\n for (var key in value)\r\n if (_$hasProp(value, key) && value[key])\r\n classes += \" \" + key;\r\n }\r\n return classes.trim();\r\n}\r\nfunction _$bs(value) {\r\n var el = _$ce();\r\n if (_$isObject(value)) {\r\n var style_1 = el.style;\r\n _$e(value, function (val, prop) {\r\n if (val !== style_1[prop])\r\n style_1[prop] = val;\r\n });\r\n return style_1.cssText;\r\n }\r\n else if (_$isStr(value)) {\r\n return value;\r\n }\r\n else {\r\n return '';\r\n }\r\n}\r\nfunction _$cu(block, condition, parent, anchor, inst) {\r\n var globs = _$toArgs(arguments, 5);\r\n if (block && block.type === _$apply(condition, [inst], globs).type) {\r\n _$apply(block.$update, [inst], globs, block);\r\n }\r\n else {\r\n block && block.$destroy();\r\n block = _$apply(condition, [inst], globs);\r\n block.$create();\r\n block.$mount(parent || inst.$parentEl, anchor);\r\n }\r\n return block;\r\n}\r\nfunction _$bba(el, attrAndValue) {\r\n var attr = attrAndValue[0], value = attrAndValue[1];\r\n el[attr] = value == null || value === false ? (el.removeAttribute(attr), false) : (_$sa(el, [attr, '']), true);\r\n}\r\nfunction _$bu(el, binding) {\r\n var attr = binding[0], value = binding[1];\r\n var _value = _$toStr(value);\r\n if (_$isValueAttr(attr)) {\r\n if (el[attr] !== _value)\r\n el[attr] = _value;\r\n el[PROP_MAP._] = value;\r\n }\r\n else if (_$ga(el, attr) !== _value) {\r\n _$sa(el, [attr, _value]);\r\n }\r\n}\r\nfunction _$tu(text, value) {\r\n if (text.data !== (value = _$toStr(value)))\r\n text.data = value;\r\n}\r\nfunction _$nu(node, tag) {\r\n return tag.toUpperCase() !== node.tagName ? _$as(node, _$ce(tag)) : node;\r\n}\r\nfunction _$rr(refs, prop, node) {\r\n var nodes = refs[prop];\r\n _$isArray(nodes) ? refs[prop].splice(nodes.indexOf(node), 1) : (delete refs[prop]);\r\n}\r\nfunction _$hu(node, value) {\r\n if (node.innerHTML !== (value = _$toStr(value)))\r\n node.innerHTML = value;\r\n}\r\nfunction _$pu(parent, Ctor, inst, value, attrs, el, sibling) {\r\n if (value === Ctor) {\r\n inst && inst.$update();\r\n }\r\n else {\r\n Ctor = value;\r\n if (inst) {\r\n inst.$destroy();\r\n _$remove(parent, inst);\r\n }\r\n if (inst) {\r\n inst = _$add(parent, Ctor, attrs);\r\n inst.$create();\r\n inst.$mount(el, sibling);\r\n }\r\n }\r\n return [inst, Ctor];\r\n}\r\nfunction _$f(root, obj, loop) {\r\n var items = {}, loopParent, loopSibling;\r\n var globs = _$toArgs(arguments, 3);\r\n _$e(obj, function (item, i, index) { items[i] = _$apply(loop, [root, item, i, index], globs); });\r\n return {\r\n $create: function () {\r\n _$e(items, function (item) { item.$create(); });\r\n },\r\n $mount: function (parent, sibling) {\r\n loopParent = _$(parent);\r\n loopSibling = _$(sibling);\r\n _$e(items, function (item) { item.$mount(loopParent, loopSibling); });\r\n },\r\n $update: function (root, obj) {\r\n var globs = _$toArgs(arguments, 2);\r\n _$e(items, function (item, i, index) {\r\n if (obj[i]) {\r\n _$apply(item.$update, [root, obj[i], i, index], globs, item);\r\n }\r\n else {\r\n item.$destroy();\r\n delete items[i];\r\n }\r\n });\r\n _$e(obj, function (item, i, index) {\r\n if (!items[i]) {\r\n items[i] = _$apply(loop, [root, item, i, index], globs);\r\n items[i].$create();\r\n items[i].$mount(loopParent, loopSibling);\r\n }\r\n });\r\n },\r\n $destroy: function () {\r\n _$e(items, function (item) { item.$destroy(); });\r\n }\r\n };\r\n}\r\nfunction _$e(obj, cb) {\r\n var i = 0;\r\n for (var key in obj) {\r\n if (_$hasProp(obj, key)) {\r\n cb(obj[key], (isNaN(+key) ? key : +key), i++);\r\n }\r\n }\r\n}\r\nfunction _$is(id, css) {\r\n var isNew = false;\r\n var style = _$(\"#\" + id, document.head);\r\n if (!style) {\r\n isNew = true;\r\n style = _$ce('style');\r\n style.id = id;\r\n _$sa(style, ['refs', 1]);\r\n }\r\n if (style.textContent !== css) {\r\n style.textContent = css;\r\n }\r\n if (isNew) {\r\n _$a(document.head, style);\r\n }\r\n else {\r\n var count = +_$ga(style, 'refs');\r\n _$sa(style, ['refs', ++count]);\r\n }\r\n}\r\nfunction _$ds(id) {\r\n var style = _$(\"#\" + id, document.head);\r\n if (style) {\r\n var count = +_$ga(style, 'refs');\r\n if (--count === 0) {\r\n _$r(style, document.head);\r\n }\r\n else {\r\n _$sa(style, ['refs', count]);\r\n }\r\n }\r\n}\r\n//# sourceMappingURL=index.js.map\n// CONCATENATED MODULE: ./components/todo.ts\nvar filters = {\r\n actives: function (todos) {\r\n return todos.filter(function (todo) { return !todo.completed; });\r\n },\r\n filterByView: function (todos, view) {\r\n switch (view) {\r\n case 'active':\r\n return todos.filter(function (todo) { return !todo.completed; });\r\n case 'completed':\r\n return todos.filter(function (todo) { return todo.completed; });\r\n default:\r\n return todos;\r\n }\r\n },\r\n pluralize: function (word, count) {\r\n return \"\" + word + (count !== 1 ? 's' : '');\r\n }\r\n};\r\nvar model = {\r\n view: '',\r\n todos: [],\r\n newTodo: '',\r\n oldTitle: '',\r\n _allDone: false,\r\n editedTodo: null,\r\n get remaining() {\r\n return this.$filters.actives(this.todos).length;\r\n },\r\n get allDone() {\r\n return this._allDone || this.remaining === 0;\r\n },\r\n set allDone(value) {\r\n this._allDone = value;\r\n },\r\n mark: function (item, value) {\r\n this.$set(\"todos.\" + item + \".completed\", value);\r\n this.$set('allDone', this.remaining === 0);\r\n },\r\n markAll: function (value) {\r\n this.todos.forEach(function (todo) { todo.completed = value; });\r\n this.$set('allDone', value);\r\n },\r\n addTodo: function () {\r\n var title = this.newTodo && this.newTodo.trim();\r\n if (!title)\r\n return;\r\n this.newTodo = '';\r\n this.todos.push({ title: title, completed: false });\r\n this.$set('allDone', this.remaining === 0);\r\n },\r\n editTodo: function (todo) {\r\n this.editedTodo = todo;\r\n this.oldTitle = todo.title;\r\n this.$update();\r\n },\r\n doneEdit: function (todo, e) {\r\n if (e.key === 'Enter') {\r\n todo.title = todo.title.trim();\r\n if (!todo.title) {\r\n this.removeTodo(todo);\r\n }\r\n this.clearTmps();\r\n }\r\n else if (e.key === 'Escape') {\r\n todo.title = this.oldTitle;\r\n this.clearTmps();\r\n }\r\n },\r\n removeTodo: function (todo) {\r\n var index = this.todos.indexOf(todo);\r\n this.todos.splice(index, 1);\r\n this.$set('allDone', this.remaining === 0);\r\n },\r\n removeCompleted: function () {\r\n this.$set('todos', this.$filters.actives(this.todos));\r\n },\r\n clearTmps: function () {\r\n this.editedTodo = null;\r\n this.oldTitle = '';\r\n this.$update();\r\n }\r\n};\r\nvar directives = {\r\n 'focus-edit': function (_inst, options, el) {\r\n if (options.value) {\r\n el.focus();\r\n }\r\n }\r\n};\r\n/* harmony default export */ var components_todo = ({ model: model, filters: filters, directives: directives });\r\n\n// CONCATENATED MODULE: ./components/todo.html\n\r\n\r\nfunction itemLoop_1(_$state, todo, i) {\r\n var _$frag, li_1, div_1, input_1, bindCheckedInput_1, changeEvent_1, handlerChangeEvent_1, label_1, txt_1, setTxt_1, dblclickEvent_1, handlerDblclickEvent_1, button_1, clickEvent_1, handlerClickEvent_1, input_2, focusEditDirective, inputEvent_1, handlerInputEvent_1, bindValueInput_2, blurEvent_1, handlerBlurEvent_1, keyupEvent_1, handlerKeyupEvent_1, bindClassLi_1;\r\n _$frag = _$d();\r\n bindCheckedInput_1 = function(_$state, todo) {\r\n return ['checked', todo.completed];\r\n };\r\n changeEvent_1 = function(_$state, todo, i, $event, $el) {\r\n _$state.mark(i, $el.checked);\r\n };\r\n setTxt_1 = function(_$state, todo) {\r\n return todo.title;\r\n };\r\n dblclickEvent_1 = function(_$state, todo, i) {\r\n _$state.editTodo(todo, i);\r\n };\r\n clickEvent_1 = function(_$state, todo) {\r\n _$state.removeTodo(todo);\r\n };\r\n focusEditDirective = _$state.$directives['focus-edit'];\r\n inputEvent_1 = function(_$state, todo, i, $event, $el) {\r\n todo.title = $el.value;\r\n };\r\n bindValueInput_2 = function(_$state, todo) {\r\n return ['value', todo.title];\r\n };\r\n blurEvent_1 = function(_$state) {\r\n _$state.$set('editedTodo', null);\r\n };\r\n keyupEvent_1 = function(_$state, todo, i, $event) {\r\n _$state.doneEdit(todo, $event);\r\n };\r\n bindClassLi_1 = function(_$state, todo) {\r\n return ['class', ('scope_4827b611 todo ' + _$bc({\r\n completed: todo.completed,\r\n editing: todo === _$state.editedTodo\r\n })).trim()];\r\n };\r\n return {\r\n $create: function() {\r\n li_1 = _$ce('li');\r\n div_1 = _$ce();\r\n input_1 = _$ce('input');\r\n label_1 = _$ce('label');\r\n txt_1 = _$ct();\r\n txt_1.data = setTxt_1(_$state, todo, i);\r\n button_1 = _$ce('button');\r\n input_2 = _$ce('input');\r\n _$sa(input_1, ['class', 'scope_4827b611 toggle']);\r\n _$sa(input_1, ['type', 'checkbox']);\r\n _$bba(input_1, bindCheckedInput_1(_$state, todo, i));\r\n _$al(input_1, 'change', handlerChangeEvent_1 = function(event) {\r\n changeEvent_1(_$state, todo, i, event, input_1);\r\n });\r\n _$sa(label_1, ['class', 'scope_4827b611']);\r\n _$al(label_1, 'dblclick', handlerDblclickEvent_1 = function(event) {\r\n dblclickEvent_1(_$state, todo, i, event, label_1);\r\n });\r\n _$sa(button_1, ['class', 'scope_4827b611 destroy']);\r\n _$al(button_1, 'click', handlerClickEvent_1 = function(event) {\r\n clickEvent_1(_$state, todo, i, event, button_1);\r\n });\r\n _$sa(div_1, ['class', 'scope_4827b611 view']);\r\n _$sa(input_2, ['type', 'text']);\r\n _$sa(input_2, ['class', 'scope_4827b611 edit']);\r\n focusEditDirective.$init(_$state, {\r\n value: todo === _$state.editedTodo,\r\n expression: 'todo === editedTodo',\r\n modifiers: {}\r\n }, input_2);\r\n _$al(input_2, 'input', handlerInputEvent_1 = function(event) {\r\n inputEvent_1(_$state, todo, i, event, input_2);\r\n });\r\n input_2.value = _$toStr(bindValueInput_2(_$state, todo, i)[1]);\r\n _$al(input_2, 'blur', handlerBlurEvent_1 = function(event) {\r\n blurEvent_1(_$state, todo, i, event, input_2);\r\n });\r\n _$al(input_2, 'keyup', handlerKeyupEvent_1 = function(event) {\r\n keyupEvent_1(_$state, todo, i, event, input_2);\r\n });\r\n _$sa(li_1, ['class', 'scope_4827b611 todo']);\r\n _$sa(li_1, bindClassLi_1(_$state, todo, i));\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n focusEditDirective.$inserted(_$state, {\r\n value: todo === _$state.editedTodo,\r\n expression: 'todo === editedTodo',\r\n modifiers: {}\r\n }, input_2);\r\n },\r\n\r\n $update: function(_$state, todo, i) {\r\n _$bba(input_1, bindCheckedInput_1(_$state, todo, i));\r\n handlerChangeEvent_1 = _$ul(input_1, 'change', handlerChangeEvent_1, function(event) {\r\n changeEvent_1(_$state, todo, i, event, input_1);\r\n });\r\n _$tu(txt_1, setTxt_1(_$state, todo, i));\r\n handlerDblclickEvent_1 = _$ul(label_1, 'dblclick', handlerDblclickEvent_1, function(event) {\r\n dblclickEvent_1(_$state, todo, i, event, label_1);\r\n });\r\n handlerClickEvent_1 = _$ul(button_1, 'click', handlerClickEvent_1, function(event) {\r\n clickEvent_1(_$state, todo, i, event, button_1);\r\n });\r\n focusEditDirective.$update(_$state, {\r\n value: todo === _$state.editedTodo,\r\n expression: 'todo === editedTodo',\r\n modifiers: {}\r\n }, input_2);\r\n handlerInputEvent_1 = _$ul(input_2, 'input', handlerInputEvent_1, function(event) {\r\n inputEvent_1(_$state, todo, i, event, input_2);\r\n });\r\n _$bu(input_2, bindValueInput_2(_$state, todo, i));\r\n handlerBlurEvent_1 = _$ul(input_2, 'blur', handlerBlurEvent_1, function(event) {\r\n blurEvent_1(_$state, todo, i, event, input_2);\r\n });\r\n handlerKeyupEvent_1 = _$ul(input_2, 'keyup', handlerKeyupEvent_1, function(event) {\r\n keyupEvent_1(_$state, todo, i, event, input_2);\r\n });\r\n _$bu(li_1, bindClassLi_1(_$state, todo, i));\r\n },\r\n\r\n $unmount: function() {\r\n _$a(div_1, input_1);\r\n _$a(label_1, txt_1);\r\n _$a(div_1, label_1);\r\n _$a(div_1, button_1);\r\n _$a(li_1, div_1);\r\n _$a(li_1, input_2);\r\n _$a(_$frag, li_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n _$rl(input_1, 'change', handlerChangeEvent_1);\r\n _$rl(label_1, 'dblclick', handlerDblclickEvent_1);\r\n _$rl(button_1, 'click', handlerClickEvent_1);\r\n focusEditDirective.$destroy(_$state, {\r\n value: todo === _$state.editedTodo,\r\n expression: 'todo === editedTodo',\r\n modifiers: {}\r\n }, input_2);\r\n _$rl(input_2, 'input', handlerInputEvent_1);\r\n _$rl(input_2, 'blur', handlerBlurEvent_1);\r\n _$rl(input_2, 'keyup', handlerKeyupEvent_1);\r\n _$frag = li_1 = div_1 = input_1 = bindCheckedInput_1 = changeEvent_1 = handlerChangeEvent_1 = label_1 = txt_1 = setTxt_1 = dblclickEvent_1 = handlerDblclickEvent_1 = button_1 = clickEvent_1 = handlerClickEvent_1 = input_2 = focusEditDirective = inputEvent_1 = handlerInputEvent_1 = bindValueInput_2 = blurEvent_1 = handlerBlurEvent_1 = keyupEvent_1 = handlerKeyupEvent_1 = bindClassLi_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction _$tplTodo(_$state) {\r\n var _$frag, section_1, header_1, h1_1, input_1, inputEvent_1, handlerInputEvent_1, bindValueInput_1, keyupEvent_1, handlerKeyupEvent_1, section_2, input_2, bindCheckedInput_2, changeEvent_1, handlerChangeEvent_1, label_1, ul_1, loopAnchor_1_1, loopBlock_1, displaySection_2, footer_1, span_1, txt_1, setTxt_1, ul_2, li_1, a_1, txt_2, bindClassA_1, clickEvent_1, handlerClickEvent_1, li_2, a_2, txt_3, bindClassA_2, clickEvent_2, handlerClickEvent_2, li_3, a_3, txt_4, bindClassA_3, clickEvent_3, handlerClickEvent_3, button_1, txt_5, clickEvent_4, handlerClickEvent_4, displayButton_1, displayFooter_1;\r\n _$frag = _$d();\r\n inputEvent_1 = function(_$state, $event, $el) {\r\n _$state.$set('newTodo', $el.value);\r\n };\r\n bindValueInput_1 = function(_$state) {\r\n return ['value', _$state.newTodo];\r\n };\r\n keyupEvent_1 = function(_$state) {\r\n _$state.addTodo();\r\n };\r\n bindCheckedInput_2 = function(_$state) {\r\n return ['checked', _$state.allDone];\r\n };\r\n changeEvent_1 = function(_$state, $event, $el) {\r\n _$state.markAll($el.checked);\r\n };\r\n loopBlock_1 = _$f(\r\n _$state,\r\n _$state.$filters.filterByView(_$state.todos, _$state.view),\r\n itemLoop_1\r\n );\r\n loopAnchor_1_1 = _$ct();\r\n var showSection_2 = function(_$state, el, display) {\r\n el.style.display = _$state.todos.length ? display : 'none';\r\n };\r\n setTxt_1 = function(_$state) {\r\n return _$state.remaining + ' ' + _$state.$filters.pluralize('item', _$state.remaining) + ' left';\r\n };\r\n bindClassA_1 = function(_$state) {\r\n return ['class', ('scope_4827b611 ' + _$bc({\r\n selected: _$state.view === ''\r\n })).trim()];\r\n };\r\n clickEvent_1 = function(_$state) {\r\n _$state.$set('view', '');\r\n };\r\n bindClassA_2 = function(_$state) {\r\n return ['class', ('scope_4827b611 ' + _$bc({\r\n selected: _$state.view === 'active'\r\n })).trim()];\r\n };\r\n clickEvent_2 = function(_$state) {\r\n _$state.$set('view', 'active');\r\n };\r\n bindClassA_3 = function(_$state) {\r\n return ['class', ('scope_4827b611 ' + _$bc({\r\n selected: _$state.view === 'completed'\r\n })).trim()];\r\n };\r\n clickEvent_3 = function(_$state) {\r\n _$state.$set('view', 'completed');\r\n };\r\n clickEvent_4 = function(_$state) {\r\n _$state.removeCompleted();\r\n };\r\n var showButton_1 = function(_$state, el, display) {\r\n el.style.display = _$state.todos.length > _$state.remaining ? display : 'none';\r\n };\r\n var showFooter_1 = function(_$state, el, display) {\r\n el.style.display = _$state.todos.length ? display : 'none';\r\n };\r\n return {\r\n $create: function() {\r\n section_1 = _$ce('section');\r\n header_1 = _$ce('header');\r\n h1_1 = _$ce('h1');\r\n h1_1.innerHTML = 'todos';\r\n input_1 = _$ce('input');\r\n section_2 = _$ce('section');\r\n input_2 = _$ce('input');\r\n label_1 = _$ce('label');\r\n label_1.innerHTML = 'Mark all as complete';\r\n ul_1 = _$ce('ul');\r\n loopBlock_1.$create();\r\n footer_1 = _$ce('footer');\r\n span_1 = _$ce('span');\r\n txt_1 = _$ct();\r\n txt_1.data = setTxt_1(_$state);\r\n ul_2 = _$ce('ul');\r\n li_1 = _$ce('li');\r\n a_1 = _$ce('a');\r\n txt_2 = _$ct('All');\r\n li_2 = _$ce('li');\r\n a_2 = _$ce('a');\r\n txt_3 = _$ct('Active');\r\n li_3 = _$ce('li');\r\n a_3 = _$ce('a');\r\n txt_4 = _$ct('Completed');\r\n button_1 = _$ce('button');\r\n txt_5 = _$ct(' Clear completed ');\r\n _$sa(h1_1, ['class', 'scope_4827b611']);\r\n _$sa(input_1, ['class', 'scope_4827b611 new-todo']);\r\n _$sa(input_1, ['placeholder', 'What needs to be done?']);\r\n _$sa(input_1, ['autofocus', '']);\r\n _$al(input_1, 'input', handlerInputEvent_1 = function(event) {\r\n inputEvent_1(_$state, event, input_1);\r\n });\r\n input_1.value = _$toStr(bindValueInput_1(_$state)[1]);\r\n _$al(input_1, 'keyup', handlerKeyupEvent_1 = function(event) {\r\n if (_$isKey(event, 'enter')) {\r\n keyupEvent_1(_$state, event, input_1);\r\n }\r\n });\r\n _$sa(header_1, ['class', 'scope_4827b611 header']);\r\n _$sa(input_2, ['class', 'scope_4827b611 toggle-all']);\r\n _$sa(input_2, ['type', 'checkbox']);\r\n _$bba(input_2, bindCheckedInput_2(_$state));\r\n _$al(input_2, 'change', handlerChangeEvent_1 = function(event) {\r\n changeEvent_1(_$state, event, input_2);\r\n });\r\n _$sa(label_1, ['for', 'toggle-all']);\r\n _$sa(label_1, ['class', 'scope_4827b611']);\r\n _$sa(ul_1, ['class', 'scope_4827b611 todo-list']);\r\n _$sa(section_2, ['class', 'scope_4827b611 main']);\r\n displaySection_2 = section_2.style.display;\r\n showSection_2(_$state, section_2, displaySection_2);\r\n _$sa(span_1, ['class', 'scope_4827b611 todo-count']);\r\n _$sa(a_1, ['href', '#/']);\r\n _$sa(a_1, ['class', 'scope_4827b611']);\r\n _$sa(a_1, bindClassA_1(_$state));\r\n _$al(a_1, 'click', handlerClickEvent_1 = function(event) {\r\n clickEvent_1(_$state, event, a_1);\r\n });\r\n _$sa(li_1, ['class', 'scope_4827b611']);\r\n _$sa(a_2, ['href', '#/active']);\r\n _$sa(a_2, ['class', 'scope_4827b611']);\r\n _$sa(a_2, bindClassA_2(_$state));\r\n _$al(a_2, 'click', handlerClickEvent_2 = function(event) {\r\n clickEvent_2(_$state, event, a_2);\r\n });\r\n _$sa(li_2, ['class', 'scope_4827b611']);\r\n _$sa(a_3, ['href', '#/completed']);\r\n _$sa(a_3, ['class', 'scope_4827b611']);\r\n _$sa(a_3, bindClassA_3(_$state));\r\n _$al(a_3, 'click', handlerClickEvent_3 = function(event) {\r\n clickEvent_3(_$state, event, a_3);\r\n });\r\n _$sa(li_3, ['class', 'scope_4827b611']);\r\n _$sa(ul_2, ['class', 'scope_4827b611 filters']);\r\n _$sa(button_1, ['class', 'scope_4827b611 clear-completed']);\r\n _$al(button_1, 'click', handlerClickEvent_4 = function(event) {\r\n clickEvent_4(_$state, event, button_1);\r\n });\r\n displayButton_1 = button_1.style.display;\r\n showButton_1(_$state, button_1, displayButton_1);\r\n _$sa(footer_1, ['class', 'scope_4827b611 footer']);\r\n displayFooter_1 = footer_1.style.display;\r\n showFooter_1(_$state, footer_1, displayFooter_1);\r\n _$sa(section_1, ['class', 'scope_4827b611 todoapp']);\r\n },\r\n\r\n $mount: function(parent, sibling) {\r\n this.$unmount();\r\n _$is(\r\n 'scope_4827b611',\r\n '.scope_4827b611.view label.scope_4827b611{user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;}'\r\n );\r\n _$a(_$(parent), _$frag, _$(sibling));\r\n this.$siblingEl = _$(sibling);\r\n this.$parentEl = sibling && _$(sibling).parentElement || _$(parent);\r\n },\r\n\r\n $update: function(_$state) {\r\n _$bu(input_1, bindValueInput_1(_$state));\r\n _$bba(input_2, bindCheckedInput_2(_$state));\r\n loopBlock_1.$update(_$state, _$state.$filters.filterByView(_$state.todos, _$state.view));\r\n showSection_2(_$state, section_2, displaySection_2);\r\n _$tu(txt_1, setTxt_1(_$state));\r\n _$bu(a_1, bindClassA_1(_$state));\r\n _$bu(a_2, bindClassA_2(_$state));\r\n _$bu(a_3, bindClassA_3(_$state));\r\n showButton_1(_$state, button_1, displayButton_1);\r\n showFooter_1(_$state, footer_1, displayFooter_1);\r\n },\r\n\r\n $unmount: function() {\r\n _$a(header_1, h1_1);\r\n _$a(header_1, input_1);\r\n _$a(section_1, header_1);\r\n _$a(section_2, input_2);\r\n _$a(section_2, label_1);\r\n _$a(ul_1, loopAnchor_1_1);\r\n loopBlock_1.$mount(ul_1, loopAnchor_1_1);\r\n _$a(section_2, ul_1);\r\n _$a(section_1, section_2);\r\n _$a(span_1, txt_1);\r\n _$a(footer_1, span_1);\r\n _$a(a_1, txt_2);\r\n _$a(li_1, a_1);\r\n _$a(ul_2, li_1);\r\n _$a(a_2, txt_3);\r\n _$a(li_2, a_2);\r\n _$a(ul_2, li_2);\r\n _$a(a_3, txt_4);\r\n _$a(li_3, a_3);\r\n _$a(ul_2, li_3);\r\n _$a(footer_1, ul_2);\r\n _$a(button_1, txt_5);\r\n _$a(footer_1, button_1);\r\n _$a(section_1, footer_1);\r\n _$a(_$frag, section_1);\r\n },\r\n\r\n $destroy: function() {\r\n this.$unmount();\r\n this.$parent = null;\r\n this.$parentEl = null;\r\n this.$siblingEl = null;\r\n this.$children.splice(0, this.$children.length);\r\n _$ds('scope_4827b611');\r\n _$rl(input_1, 'input', handlerInputEvent_1);\r\n _$rl(input_1, 'keyup', handlerKeyupEvent_1);\r\n _$rl(input_2, 'change', handlerChangeEvent_1);\r\n loopBlock_1.$destroy();\r\n _$rl(a_1, 'click', handlerClickEvent_1);\r\n _$rl(a_2, 'click', handlerClickEvent_2);\r\n _$rl(a_3, 'click', handlerClickEvent_3);\r\n _$rl(button_1, 'click', handlerClickEvent_4);\r\n delete _$state.$root;\r\n _$frag = section_1 = header_1 = h1_1 = input_1 = inputEvent_1 = handlerInputEvent_1 = bindValueInput_1 = keyupEvent_1 = handlerKeyupEvent_1 = section_2 = input_2 = bindCheckedInput_2 = changeEvent_1 = handlerChangeEvent_1 = label_1 = ul_1 = loopAnchor_1_1 = loopBlock_1 = displaySection_2 = footer_1 = span_1 = txt_1 = setTxt_1 = ul_2 = li_1 = a_1 = txt_2 = bindClassA_1 = clickEvent_1 = handlerClickEvent_1 = li_2 = a_2 = txt_3 = bindClassA_2 = clickEvent_2 = handlerClickEvent_2 = li_3 = a_3 = txt_4 = bindClassA_3 = clickEvent_3 = handlerClickEvent_3 = button_1 = txt_5 = clickEvent_4 = handlerClickEvent_4 = displayButton_1 = displayFooter_1 = void 0;\r\n }\r\n };\r\n}\r\nfunction Todo(_$attrs, _$parent) {\r\n _$CompCtr.call(this, _$attrs, _$tplTodo, components_todo, _$parent);\r\n !_$parent && this.$create();\r\n}\r\n_$extends(Todo, _$CompCtr);\r\n/* harmony default export */ var components_todo_0 = (Todo);\r\n\n// CONCATENATED MODULE: ./main.ts\n\r\nvar main_todo = new components_todo_0();\r\nmain_todo.$mount('main');\r\n\n\n//# sourceURL=webpack:///./main.ts_+_3_modules?"); /***/ }) diff --git a/examples/todomvc/src/components/todo.ts b/examples/todomvc/src/components/todo.ts index a48f5f5..0e08b67 100644 --- a/examples/todomvc/src/components/todo.ts +++ b/examples/todomvc/src/components/todo.ts @@ -18,7 +18,7 @@ const filters = { } }, pluralize(word: string, count: number) { - return `${word}${count > 1 ? 's' : ''}`; + return `${word}${count !== 1 ? 's' : ''}`; } }; From e193bb182d00e5da5a9da6c50a2293d1337b816e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Asiel=20Guevara=20Casta=C3=B1eda?= Date: Fri, 26 Oct 2018 10:52:06 -0400 Subject: [PATCH 13/13] Bump to version 0.2.4 --- CHANGELOG.md | 8 ++++++++ package-lock.json | 2 +- package.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f42e94..b85f7b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +0.2.4 +- Added ability to get the iteration index when iterate over obejcts. +- Fixed issue initializing element attributes. +- Fixed missing spaces in adjacent interpolation expressions. +- Fixed missing attribute generation. +- Fixed scope issue when conditional are inside loops. +- Changed test to work with PhantomJS. + 0.2.3 - Added ability to add or remove boolean attributes. - Fixed some bugs on context assignment with Sequence and Assignment expressions. diff --git a/package-lock.json b/package-lock.json index 24fe862..c3f2c48 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "trebor", - "version": "0.2.3", + "version": "0.2.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 268371d..10e0e54 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "trebor", - "version": "0.2.3", + "version": "0.2.4", "description": "A node js module to make standalone web components.", "main": "./build/index.js", "bin": {