typed-dom
Advanced tools
Comparing version 0.0.221 to 0.0.222
@@ -1,2 +0,2 @@ | ||
/*! typed-dom v0.0.221 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */ | ||
require=function(){return function e(t,n,r){function i(o,c){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!c&&a)return a(o,!0);if(s)return s(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var u=n[o]={exports:{}};t[o][0].call(u.exports,function(e){return i(t[o][1][e]||e)},u,u.exports,e,t,n,r)}return n[o].exports}for(var s="function"==typeof require&&require,o=0;o<r.length;o++)i(r[o]);return i}}()({1:[function(e,t,n){},{}],2:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0})},{}],3:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.isArray=n.ObjectValues=n.ObjectSetPrototypeOf=n.ObjectSeal=n.ObjectPreventExtensions=n.ObjectKeys=n.isSealed=n.isFrozen=n.isExtensible=n.ObjectIs=n.ObjectGetPrototypeOf=n.ObjectGetOwnPropertySymbols=n.ObjectGetOwnPropertyNames=n.ObjectGetOwnPropertyDescriptors=n.ObjectGetOwnPropertyDescriptor=n.ObjectFromEntries=n.ObjectFreeze=n.ObjectEntries=n.ObjectDefineProperty=n.ObjectDefineProperties=n.ObjectCreate=n.ObjectAssign=n.toString=n.isEnumerable=n.isPrototypeOf=n.hasOwnProperty=n.SymbolKeyFor=n.SymbolFor=n.sign=n.round=n.random=n.min=n.max=n.floor=n.ceil=n.abs=n.parseInt=n.parseFloat=n.isSafeInteger=n.isNaN=n.isInteger=n.isFinite=n.NaN=void 0,n.NaN=Number.NaN,n.isFinite=Number.isFinite,n.isInteger=Number.isInteger,n.isNaN=Number.isNaN,n.isSafeInteger=Number.isSafeInteger,n.parseFloat=Number.parseFloat,n.parseInt=Number.parseInt,n.abs=Math.abs,n.ceil=Math.ceil,n.floor=Math.floor,n.max=Math.max,n.min=Math.min,n.random=Math.random,n.round=Math.round,n.sign=Math.sign,n.SymbolFor=Symbol.for,n.SymbolKeyFor=Symbol.keyFor,n.hasOwnProperty=Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty),n.isPrototypeOf=Object.prototype.isPrototypeOf.call.bind(Object.prototype.isPrototypeOf),n.isEnumerable=Object.prototype.propertyIsEnumerable.call.bind(Object.prototype.propertyIsEnumerable),n.toString=Object.prototype.toString.call.bind(Object.prototype.toString),n.ObjectAssign=Object.assign,n.ObjectCreate=Object.create,n.ObjectDefineProperties=Object.defineProperties,n.ObjectDefineProperty=Object.defineProperty,n.ObjectEntries=Object.entries,n.ObjectFreeze=Object.freeze,n.ObjectFromEntries=Object.fromEntries,n.ObjectGetOwnPropertyDescriptor=Object.getOwnPropertyDescriptor,n.ObjectGetOwnPropertyDescriptors=Object.getOwnPropertyDescriptors,n.ObjectGetOwnPropertyNames=Object.getOwnPropertyNames,n.ObjectGetOwnPropertySymbols=Object.getOwnPropertySymbols,n.ObjectGetPrototypeOf=Object.getPrototypeOf,n.ObjectIs=Object.is,n.isExtensible=Object.isExtensible,n.isFrozen=Object.isFrozen,n.isSealed=Object.isSealed,n.ObjectKeys=Object.keys,n.ObjectPreventExtensions=Object.preventExtensions,n.ObjectSeal=Object.seal,n.ObjectSetPrototypeOf=Object.setPrototypeOf,n.ObjectValues=Object.values,n.isArray=Array.isArray},{}],4:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.join=n.splice=n.push=n.pop=n.unshift=n.shift=n.indexOf=void 0;const r=e("./global");function i(e,t){if("length"in e)for(let n=e.length-1;n>=0;--n)t.unshift(e[n]);else t.unshift(...e);return t}function s(e,t){if("length"in t)for(let n=0,r=t.length;n<r;++n)e.push(t[n]);else for(const n of t)e.push(n);return e}function o(e,t,n,...c){if(0===n&&0===c.length)return[];switch(n=n>e.length?e.length:n,t){case 0:switch(n){case 0:return[[],i(c,e)][0];case 1:return 0===e.length?[[],i(c,e)][0]:[[e.shift()],i(c,e)][0];case r.undefined:if(e.length>1||arguments.length>2)break;return 0===e.length?[]:o(e,t,1)}break;case-1:case e.length-1:switch(n){case 1:return 0===e.length?[[],s(e,c)][0]:[[e.pop()],s(e,c)][0];case r.undefined:if(e.length>1||arguments.length>2)break;return 0===e.length?[]:o(e,t,1)}break;case e.length:case r.Infinity:return[[],s(e,c)][0]}return arguments.length>2?e.splice(t,n,...c):e.splice(t)}n.indexOf=function(e,t){return t==t?e.indexOf(t):e.findIndex(e=>e!=e)},n.shift=function(e,t){if(t<0)throw new Error("Unexpected negative number");return t===r.undefined?[e.shift(),e]:[o(e,0,t),e]},n.unshift=i,n.pop=function(e,t){if(t<0)throw new Error("Unexpected negative number");return t===r.undefined?[e,e.pop()]:[e,o(e,e.length-t,t)]},n.push=s,n.splice=o,n.join=function(e,t=""){let n="";for(let r=0;r<e.length;++r)n+=0===r?e[r]:t+e[r];return n}},{"./global":6}],5:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.run=n.once=n.clear=n.mapReturn=n.mapParameters=void 0;const r=e("./global"),i=e("./noop");function s(e){return(...t)=>{e!==i.noop&&(e(...t),e=i.noop,t=[])}}n.mapParameters=function(e,t){return(...n)=>e(...t(...n))},n.mapReturn=function(e,t){return(...n)=>t(e(...n))},n.clear=function(e){return(...t)=>void e(...t)},n.once=s,n.run=function(e){const t=r.Array(e.length);try{for(let n=0;n<e.length;++n)t[n]=e[n]()}catch(e){for(let e=0;t[e];++e)t[e]();throw e}return s(()=>{for(let e=0;t[e];++e)t[e]()})}},{"./global":6,"./noop":8}],6:[function(_dereq_,module,exports){"use strict";const global="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||Function("return this")();eval("global.global = global"),module.exports=global},{}],7:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.memoize=void 0;const r=e("./global");n.memoize=function e(t,n=((...e)=>e[0]),i){if("object"==typeof n)return e(t,r.undefined,n);if(i===r.undefined)return e(t,n,new r.Map);let s=!1;return(...e)=>{const o=n(...e);let c=i.get(o);return c!==r.undefined||s&&i.has(o)?c:(c=t(...e),s||(s=c===r.undefined),i.set(o,c),c)}}},{"./global":6}],8:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.noop=void 0,n.noop=function(){}},{}],9:[function(e,t,n){"use strict";var r;Object.defineProperty(n,"__esModule",{value:!0}),n.isPromiseLike=n.Internal=n.AtomicPromise=void 0;const i=e("./global"),s=e("./alias"),o=e("./array"),c=Symbol.for("spica/promise::internal");class a{constructor(e){this[Symbol.toStringTag]="Promise",this[r]=new l;try{e(e=>this[c].resolve(e),e=>this[c].reject(e))}catch(e){this[c].reject(e)}}static get[Symbol.species](){return a}static all(e){return new a((t,n)=>{const r=s.isArray(e)?e:[...e],o=i.Array(r.length);let a=0;for(let e=0;e<r.length;++e){const i=r[e];if(u(i)){if(d(i)){const{status:t}=i[c];switch(t.state){case 2:o[e]=t.value,++a;continue;case 3:n(t.reason),e=r.length;continue}}i.then(n=>{o[e]=n,++a===r.length&&t(o)},t=>{n(t),e=r.length})}else o[e]=i,++a}a===r.length&&t(o)})}static race(e){return new a((t,n)=>{const r=s.isArray(e)?e:[...e];for(let e=0;e<r.length;++e){const i=r[e];if(!u(i))return t(i);if(d(i)){const{status:e}=i[c];switch(e.state){case 2:return t(e.value);case 3:return n(e.reason)}}}let i=!1;for(let e=0;e<r.length;++e){if(r[e].then(e=>{t(e),i=!0},e=>{n(e),i=!0}),i)return}})}static allSettled(e){return new a(t=>{const n=s.isArray(e)?e:[...e],r=i.Array(n.length);let o=0;for(let e=0;e<n.length;++e){const i=n[e];if(u(i)){if(d(i)){const{status:t}=i[c];switch(t.state){case 2:r[e]={status:"fulfilled",value:t.value},++o;continue;case 3:r[e]={status:"rejected",reason:t.reason},++o;continue}}i.then(i=>{r[e]={status:"fulfilled",value:i},++o===n.length&&t(r)},i=>{r[e]={status:"rejected",reason:i},++o===n.length&&t(r)})}else r[e]={status:"fulfilled",value:i},++o}o===n.length&&t(r)})}static resolve(e){return new a(t=>t(e))}static reject(e){return new a((t,n)=>n(e))}then(e,t){return new a((n,r)=>this[c].then(e,t,n,r))}catch(e){return this.then(i.undefined,e)}finally(e){return this.then(e,e).then(()=>this)}}n.AtomicPromise=a,r=c;class l{constructor(){this.status={state:0},this.reactable=!0,this.fulfillReactions=[],this.rejectReactions=[],this.isHandled=!1}get isPending(){return 0===this.status.state}resolve(e){if(0===this.status.state){if(!u(e))return this.status={state:2,value:e},this.resume();this.status={state:1,promise:e},e.then(e=>{this.status={state:2,value:e},this.resume()},e=>{this.status={state:3,reason:e},this.resume()})}}reject(e){if(0===this.status.state)return this.status={state:3,reason:e},this.resume()}then(e,t,n,r){const{status:i,fulfillReactions:s,rejectReactions:o}=this;switch(i.state){case 2:if(s.length>0)break;try{return n(e?e(i.value):i.value)}catch(e){return r(e)}case 3:if(o.length>0)break;try{return t?n(t(i.reason)):r(i.reason)}catch(e){return r(e)}default:return s.push(t=>{try{n(e?e(t):t)}catch(e){r(e)}}),o.push(e=>{try{t?n(t(e)):r(e)}catch(e){r(e)}}),this.resume()}}resume(){if(!this.reactable)return;const{status:e,fulfillReactions:t,rejectReactions:n}=this;switch(e.state){case 0:case 1:return;case 2:if(this.isHandled&&n.length>0&&o.splice(n,0),0===t.length)return;return this.isHandled=!0,void this.react(t,e.value);case 3:if(this.isHandled&&t.length>0&&o.splice(t,0),0===n.length)return;return this.isHandled=!0,void this.react(n,e.reason)}}react(e,t){if(this.reactable=!1,e.length<5)for(;e.length>0;)e.shift()(t);else{for(let n=0;n<e.length;++n)e[n](t);o.splice(e,0)}this.reactable=!0}}function u(e){return null!==e&&"object"==typeof e&&"then"in e&&"function"==typeof e.then}function d(e){return c in e}n.Internal=l,n.isPromiseLike=u},{"./alias":3,"./array":4,"./global":6}],10:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.unique=n.rnd0Z=n.rnd0z=n.rnd0f=n.rnd64=n.rnd62=n.rnd36=n.rnd32=n.rnd16=void 0;const r=e("./global"),i=[...Array(7)].map((e,t)=>1<<t),s=[...[...Array(36)].map((e,t)=>t.toString(36)),...[...Array(26)].map((e,t)=>(t+10).toString(36).toUpperCase())];function o(e){const t=i.find(t=>t>=e),n=i.indexOf(t);return()=>{for(;;){const t=h(n);if(t<e)return t}}}function c(e){return(t=1)=>{let n="";for(;t--;)n+=s[e()];return n}}n.rnd16=o(16),n.rnd32=o(32),n.rnd36=o(36),n.rnd62=o(62),n.rnd64=o(64),n.rnd0f=c(n.rnd16),n.rnd0z=c(n.rnd36),n.rnd0Z=c(n.rnd62),n.unique=function(e,t,n=new r.Set){let i=5;return()=>{for(;;){for(let r=0;r<i;++r){const r=e(t);if(!n.has(r))return n.add(r),r}i=++t<3?i:3}}};const a=new Uint16Array(512),l=16,u=i.map((e,t)=>+`0b${"1".repeat(t)||0}`);let d=a.length,f=l;function h(e){return d===a.length&&(r.crypto.getRandomValues(a),d=0),f<e?(f=l,++d,h(e)):f>e?(f-=e,a[d]>>f&u[e]):(f=l,a[d++]&u[e])}},{"./global":6}],11:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.SVG=n.HTML=n.Shadow=n.API=void 0;const r=e("spica/global"),i=e("spica/alias"),s=e("./proxy"),o=e("./util/dom");function c(e,t=(e=>e)){return new Proxy(()=>r.undefined,function(e,t){return{apply(e,t,[n,...r]){return this.get(e,n,e)(...r)},get:(n,c)=>n[c]||c in n||"string"!=typeof c?n[c]:n[c]=function(e,n){return function c(a,l,u){if("function"==typeof a)return c(r.undefined,r.undefined,a);if("function"==typeof l)return c(a,r.undefined,l);if(a!==r.undefined&&function(e){if("object"!=typeof e)return!0;for(const t in e)if(i.hasOwnProperty(e,t))return"object"==typeof e[t];return!0}(a))return c(r.undefined,a,u);const d=t(function(t,r,i){const s=t?o.define(t(n,e,r||{},i),r):n(e,r);if(e!==s.tagName.toLowerCase())throw new Error(`TypedDOM: Expected tag name is "${e}" but actually "${s.tagName.toLowerCase()}".`);return s}(u,a,l));return 1===d.nodeType?new s.Elem(d,l):new s.Elem(d.host,l,d)}}(c,e)}}(e,t))}n.API=c,n.Shadow=c(o.html,o.shadow),n.HTML=c(o.html),n.SVG=c(o.svg)},{"./proxy":12,"./util/dom":13,"spica/alias":3,"spica/global":6}],12:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.Elem=n.proxy=void 0;const r=e("spica/global"),i=e("spica/alias"),s=e("./util/identity"),o=e("./util/dom"),c=e("spica/array"),a=new r.WeakMap;function l(e){const t=a.get(e);if(t)return t;throw new Error("TypedDOM: This element has no proxy.")}n.proxy=l;Symbol.for("typed-dom::tag");const u=s.identity();let d=0;function f({element:e}){if(e.parentElement&&a.has(e.parentElement))throw new Error("TypedDOM: Typed DOM children must not be used to another typed DOM.")}n.Elem=class{constructor(e,t,n=e){switch(this.element=e,this.children_=t,this.container=n,this.id_="",this.query_="",this.isPartialUpdate=!1,this.isInit=!0,!0){case t===r.undefined:this.type=0;break;case"string"==typeof t:this.type=1;break;case i.isArray(t):this.type=2;break;case t&&"object"==typeof t:this.type=3;break;default:throw new Error("TypedDOM: Invalid type children.")}switch(f(this),a.set(this.element,this),this.type){case 0:return void(this.isInit=!1);case 1:return o.define(this.container,[]),this.children_=this.container.appendChild(o.text("")),this.children=t,void(this.isInit=!1);case 2:return o.define(this.container,[]),this.children_=[],this.children=t,void(this.isInit=!1);case 3:return o.define(this.container,[]),this.children_=this.observe({...t}),this.children=t,void(this.isInit=!1);default:throw new Error("TypedDOM: Unreachable code.")}}get id(){return this.id_?this.id_:(this.id_=this.element.id,/^[\w-]+$/.test(this.id_)?this.id_:(this.id_=`rnd-${u}-${++d}`,this.element.classList.add(this.id_),this.id_))}get query(){if(this.query_)return this.query_;switch(!0){case this.element!==this.container:return this.query_=":host";case this.id===this.element.id:return this.query_=`#${this.id}`;default:return this.query_=`.${this.id}`}}scope(e){const t=e.element;switch(!1){case"type"in t:case"media"in t:case"STYLE"===t.tagName:return}const n=/(^|[,}])(\s*)\$scope(?![\w-])(?=[^;{}]*{)/g,r=t.innerHTML;if(-1===r.search(n))return;const i=this.query;if(t.innerHTML=r.replace(n,`$1$2${i}`),t.firstElementChild)for(let e=t.children,n=0,r=e.length;n<r;++n)e[0].remove()}observe(e){const t={};for(const n of i.ObjectKeys(e)){if(n in{})continue;let r=e[n];f(r),this.container.appendChild(r.element),t[n]={configurable:!0,enumerable:!0,get:()=>r,set:e=>{const t=r;if(e!==t)if(this.isPartialUpdate)if(r=e,e.element.parentNode===t.element.parentNode){const n=e.element.nextSibling!==t.element?e.element.nextSibling:t.element.nextSibling;this.container.replaceChild(e.element,t.element),this.container.insertBefore(t.element,n)}else this.container.insertBefore(e.element,t.element),this.container.removeChild(t.element);else this.children={...this.children_,[n]:e}}}}return i.ObjectDefineProperties(e,t)}get children(){switch(this.type){case 1:if(this.children_.parentNode!==this.container){this.children_=r.undefined;for(let e=this.container.childNodes,t=0,n=e.length;t<n;++t){const n=e[t];if("wholeText"in n!=0){this.children_=n;break}}}return this.children_.data;default:return this.children_}}set children(e){const t=[],n=[];let s=!1;switch(this.type){case 0:return;case 1:{if(!this.isInit&&e===this.children)return;const t=this.children_,n=t.data,i=e;if(t.data=i,i===n)return;return void this.element.dispatchEvent(new r.Event("mutate",{bubbles:!1,cancelable:!0}))}case 2:{const r=e,i=[];this.children_=i;const o=this.container.children;for(let e=0;e<r.length;++e){const t=r[e],c=o[e];t.element.parentNode!==this.container&&f(t),t.element!==c&&(t.element.parentNode!==this.container&&(this.scope(t),n.push(t)),this.container.insertBefore(t.element,c),s=!0),i.push(t)}for(let e=o.length;r.length<e--;){const e=o[r.length];a.has(e)&&(t.push(l(this.container.removeChild(e))),s=!0)}break}case 3:{const r=e,o=this.children_;for(const e of i.ObjectKeys(o)){const i=o[e],a=r[e];if(this.isInit||a!==i){if(a.element.parentNode!==this.container&&f(a),(this.isInit||a!==i&&a.element.parentNode!==i.element.parentNode)&&(this.scope(a),n.push(a),!this.isInit)){let e=0;(e=t.lastIndexOf(a))>-1&&c.splice(t,e,1),t.push(i),(e=n.lastIndexOf(i))>-1&&c.splice(n,e,1)}this.isPartialUpdate=!0,o[e]=r[e],this.isPartialUpdate=!1,s=!0}}break}}if(t.length){const e=new r.Event("disconnect",{bubbles:!1,cancelable:!0});for(const{element:n}of t)n.dispatchEvent(e)}if(n.length){const e=new r.Event("connect",{bubbles:!1,cancelable:!0});for(const{element:t}of n)t.dispatchEvent(e)}s&&this.element.dispatchEvent(new r.Event("mutate",{bubbles:!1,cancelable:!0}))}}},{"./util/dom":13,"./util/identity":14,"spica/alias":3,"spica/array":4,"spica/global":6}],13:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.isChildren=n.define=n.element=n.text=n.svg=n.html=n.frag=n.shadow=void 0;const r=e("spica/global"),i=e("spica/alias"),s=e("spica/memoize"),o=e("spica/array");var c;function a(e){return r.document.createTextNode(e)}function l(e,t){const n=s.memoize(u,(e,t,n)=>`${t}:${n}`);return(r,i,s)=>{const o=r.includes("-")?u(e,t,r):n(e,t,r).cloneNode(!0);return h(i)?f(o,i):f(d(o,i),s)}}function u(e,t,n){if(!("createElement"in e))throw new Error("TypedDOM: Scoped custom elements are not supported on this browser.");switch(t){case"HTML":return e.createElement(n);case"SVG":return e.createElementNS("http://www.w3.org/2000/svg",n)}}function d(e,t){if(!t)return e;for(let n=0,r=i.ObjectKeys(t);n<r.length;++n){const i=r[n],s=t[i];switch(typeof s){case"string":e.setAttribute(i,s);continue;case"function":if(i.length<3)throw new Error(`TypedDOM: Attribute names for event listeners must have an event name but got "${i}".`);if("on"!==i.slice(0,2))throw new Error(`TypedDOM: Attribute names for event listeners must start with "on" but got "${i}".`);e.addEventListener(i.slice(2),s,{passive:["wheel","mousewheel","touchstart","touchmove","touchend","touchcancel"].includes(i.slice(2))});continue;case"object":e.removeAttribute(i);continue;default:continue}}return e}function f(e,t){switch(typeof t){case"undefined":return e;case"string":return f(e,[t])}if(!("length"in t)){if(e.firstChild)return f(e,o.push([],t));for(const n of t)e.append(n);return e}if(!i.isArray(t)){if(e.firstChild)return f(e,o.push([],t));for(let n=t.length;n--;)e.prepend(t[n]);return e}const n=e.firstChild?e.childNodes:[];let r=n.length;if(0===r)return b(e,t);let s=0;e:for(let i=0;i<t.length;++i){if(s===r)return b(e,t,i);const o=t[i];if("object"==typeof o&&11===o.nodeType){const t=o.childNodes.length;r+=o!==e?t:0,e.insertBefore(o,n[s]||null),s+=t;continue}for(++s;r>t.length;){const e=n[s-1];if(p(e,o))continue e;e.remove(),--r}const c=n[s-1];p(c,o)||(r<t.length-i+s?(r+="string"==typeof o||o.parentNode!==e?1:0,e.insertBefore("string"==typeof o?a(o):o,c)):e.replaceChild("string"==typeof o?a(o):o,c))}for(;s<r;)n[s].remove(),--r;return e}function h(e){return!!(null==e?void 0:e[r.Symbol.iterator])}function p(e,t){return"string"==typeof t?"wholeText"in e&&e.data===t:e===t}function b(e,t,n=0){for(let r=t.length;n<r;++n)e.append(t[n]);return e}!function(e){e.shadows=new WeakMap,e.fragment=r.document.createDocumentFragment()}(c||(c={})),n.shadow=function e(t,i,s){if("string"==typeof t)return e(n.html(t),i,s);if(i&&!h(i))return e(t,r.undefined,i);const o=s===r.undefined?t.shadowRoot||c.shadows.get(t):"open"===s.mode?t.shadowRoot||r.undefined:c.shadows.get(t);return f(s&&"open"!==s.mode?o||c.shadows.set(t,t.attachShadow(s)).get(t):o||t.attachShadow(s||{mode:"open"}),o||i!=r.undefined?i:t.childNodes)},n.frag=function(e){return f(c.fragment.cloneNode(!0),e)},n.html=l(r.document,"HTML"),n.svg=l(r.document,"SVG"),n.text=a,n.element=l,n.define=function(e,t,n){return h(t)?f(e,t):f(d(e,t),n)},n.isChildren=h},{"spica/alias":3,"spica/array":4,"spica/global":6,"spica/memoize":7}],14:[function(e,t,n){"use strict";var r;Object.defineProperty(n,"__esModule",{value:!0}),n.identity=void 0;const i=e("spica/global"),s=e("spica/random"),o=Symbol.for("typed-dom::ids");n.identity=s.unique(s.rnd0Z,2,null!==(r=i.global[o])&&void 0!==r?r:i.global[o]=new i.Set)},{"spica/global":6,"spica/random":10}],15:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.bind=n.delegate=n.wait=n.once=n.listen=n.currentTarget=void 0;const r=e("spica/global"),i=e("spica/promise"),s=e("spica/function"),o=e("spica/noop");function c(e,t,n,r=!1,i={}){return"string"==typeof n?a(e,t,n,r,{..."boolean"==typeof i?{capture:i}:i,once:!0}):l(e,t,n,{..."boolean"==typeof r?{capture:r}:r,once:!0})}function a(e,t,n,i,s={}){let a=o.noop;return l(e,n,e=>{var o,l;a();const u=e.target.shadowRoot?null===(o=e.composedPath()[0])||void 0===o?void 0:o.closest(t):null===(l=e.target)||void 0===l?void 0:l.closest(t);return u?a=c(u,n,i,s):r.undefined,e.returnValue},{...s,capture:!0})}function l(e,t,i,o=!1){return e.addEventListener(t,c,o),s.once(()=>void e.removeEventListener(t,c,o));function c(e){return n.currentTarget in e&&!e[n.currentTarget]?r.undefined:e[n.currentTarget]=e.currentTarget,i(e)}}n.currentTarget=Symbol.for("typed-dom::currentTarget"),n.listen=function(e,t,n,r=!1,i={}){return"string"==typeof n?a(e,t,n,r,i):l(e,t,n,r)},n.once=c,n.wait=function(e,t,n=!1,r={}){return new i.AtomicPromise(i=>"string"==typeof n?c(e,t,n,i,r):c(e,t,i,n))},n.delegate=a,n.bind=l},{"spica/function":5,"spica/global":6,"spica/noop":8,"spica/promise":9}],16:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.apply=void 0;const r=e("./dom");n.apply=function(e,t,n){const i=e.querySelectorAll(t);for(let e=0,t=i.length;e<t;++e)r.define(i[e],n);return i}},{"./dom":13}],"typed-dom":[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.identity=n.apply=n.currentTarget=n.wait=n.once=n.bind=n.delegate=n.listen=n.define=n.element=n.text=n.svg=n.html=n.frag=n.shadow=n.proxy=n.API=n.SVG=n.HTML=n.Shadow=void 0,e("spica/global");var r=e("./src/builder");Object.defineProperty(n,"Shadow",{enumerable:!0,get:function(){return r.Shadow}}),Object.defineProperty(n,"HTML",{enumerable:!0,get:function(){return r.HTML}}),Object.defineProperty(n,"SVG",{enumerable:!0,get:function(){return r.SVG}}),Object.defineProperty(n,"API",{enumerable:!0,get:function(){return r.API}});var i=e("./src/proxy");Object.defineProperty(n,"proxy",{enumerable:!0,get:function(){return i.proxy}});var s=e("./src/util/dom");Object.defineProperty(n,"shadow",{enumerable:!0,get:function(){return s.shadow}}),Object.defineProperty(n,"frag",{enumerable:!0,get:function(){return s.frag}}),Object.defineProperty(n,"html",{enumerable:!0,get:function(){return s.html}}),Object.defineProperty(n,"svg",{enumerable:!0,get:function(){return s.svg}}),Object.defineProperty(n,"text",{enumerable:!0,get:function(){return s.text}}),Object.defineProperty(n,"element",{enumerable:!0,get:function(){return s.element}}),Object.defineProperty(n,"define",{enumerable:!0,get:function(){return s.define}});var o=e("./src/util/listener");Object.defineProperty(n,"listen",{enumerable:!0,get:function(){return o.listen}}),Object.defineProperty(n,"delegate",{enumerable:!0,get:function(){return o.delegate}}),Object.defineProperty(n,"bind",{enumerable:!0,get:function(){return o.bind}}),Object.defineProperty(n,"once",{enumerable:!0,get:function(){return o.once}}),Object.defineProperty(n,"wait",{enumerable:!0,get:function(){return o.wait}}),Object.defineProperty(n,"currentTarget",{enumerable:!0,get:function(){return o.currentTarget}});var c=e("./src/util/query");Object.defineProperty(n,"apply",{enumerable:!0,get:function(){return c.apply}});var a=e("./src/util/identity");Object.defineProperty(n,"identity",{enumerable:!0,get:function(){return a.identity}})},{"./src/builder":11,"./src/proxy":12,"./src/util/dom":13,"./src/util/identity":14,"./src/util/listener":15,"./src/util/query":16,"spica/global":6}]},{},[1,"typed-dom",2]),function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof module&&module.exports&&(module.exports=t())}("undefined"!=typeof self&&self,function(){return require("typed-dom")}); | ||
/*! typed-dom v0.0.222 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */ | ||
require=function(){return function e(t,n,r){function i(o,c){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!c&&a)return a(o,!0);if(s)return s(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var u=n[o]={exports:{}};t[o][0].call(u.exports,function(e){return i(t[o][1][e]||e)},u,u.exports,e,t,n,r)}return n[o].exports}for(var s="function"==typeof require&&require,o=0;o<r.length;o++)i(r[o]);return i}}()({1:[function(e,t,n){},{}],2:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0})},{}],3:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.isArray=n.ObjectValues=n.ObjectSetPrototypeOf=n.ObjectSeal=n.ObjectPreventExtensions=n.ObjectKeys=n.isSealed=n.isFrozen=n.isExtensible=n.ObjectIs=n.ObjectGetPrototypeOf=n.ObjectGetOwnPropertySymbols=n.ObjectGetOwnPropertyNames=n.ObjectGetOwnPropertyDescriptors=n.ObjectGetOwnPropertyDescriptor=n.ObjectFromEntries=n.ObjectFreeze=n.ObjectEntries=n.ObjectDefineProperty=n.ObjectDefineProperties=n.ObjectCreate=n.ObjectAssign=n.toString=n.isEnumerable=n.isPrototypeOf=n.hasOwnProperty=n.SymbolKeyFor=n.SymbolFor=n.sign=n.round=n.random=n.min=n.max=n.floor=n.ceil=n.abs=n.parseInt=n.parseFloat=n.isSafeInteger=n.isNaN=n.isInteger=n.isFinite=n.NaN=void 0,n.NaN=Number.NaN,n.isFinite=Number.isFinite,n.isInteger=Number.isInteger,n.isNaN=Number.isNaN,n.isSafeInteger=Number.isSafeInteger,n.parseFloat=Number.parseFloat,n.parseInt=Number.parseInt,n.abs=Math.abs,n.ceil=Math.ceil,n.floor=Math.floor,n.max=Math.max,n.min=Math.min,n.random=Math.random,n.round=Math.round,n.sign=Math.sign,n.SymbolFor=Symbol.for,n.SymbolKeyFor=Symbol.keyFor,n.hasOwnProperty=Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty),n.isPrototypeOf=Object.prototype.isPrototypeOf.call.bind(Object.prototype.isPrototypeOf),n.isEnumerable=Object.prototype.propertyIsEnumerable.call.bind(Object.prototype.propertyIsEnumerable),n.toString=Object.prototype.toString.call.bind(Object.prototype.toString),n.ObjectAssign=Object.assign,n.ObjectCreate=Object.create,n.ObjectDefineProperties=Object.defineProperties,n.ObjectDefineProperty=Object.defineProperty,n.ObjectEntries=Object.entries,n.ObjectFreeze=Object.freeze,n.ObjectFromEntries=Object.fromEntries,n.ObjectGetOwnPropertyDescriptor=Object.getOwnPropertyDescriptor,n.ObjectGetOwnPropertyDescriptors=Object.getOwnPropertyDescriptors,n.ObjectGetOwnPropertyNames=Object.getOwnPropertyNames,n.ObjectGetOwnPropertySymbols=Object.getOwnPropertySymbols,n.ObjectGetPrototypeOf=Object.getPrototypeOf,n.ObjectIs=Object.is,n.isExtensible=Object.isExtensible,n.isFrozen=Object.isFrozen,n.isSealed=Object.isSealed,n.ObjectKeys=Object.keys,n.ObjectPreventExtensions=Object.preventExtensions,n.ObjectSeal=Object.seal,n.ObjectSetPrototypeOf=Object.setPrototypeOf,n.ObjectValues=Object.values,n.isArray=Array.isArray},{}],4:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.join=n.splice=n.pop=n.push=n.shift=n.unshift=n.indexOf=void 0;const r=e("./global");function i(e,t){if("length"in e)for(let n=e.length-1;n>=0;--n)t.unshift(e[n]);else t.unshift(...e);return t}function s(e,t){if("length"in t)for(let n=0,r=t.length;n<r;++n)e.push(t[n]);else for(const n of t)e.push(n);return e}function o(e,t,n,...c){if(0===n&&0===c.length)return[];switch(n=n>e.length?e.length:n,t){case 0:switch(n){case 0:return[[],i(c,e)][0];case 1:return 0===e.length?[[],i(c,e)][0]:[[e.shift()],i(c,e)][0];case r.undefined:if(e.length>1||arguments.length>2)break;return 0===e.length?[]:o(e,t,1)}break;case-1:case e.length-1:switch(n){case 1:return 0===e.length?[[],s(e,c)][0]:[[e.pop()],s(e,c)][0];case r.undefined:if(e.length>1||arguments.length>2)break;return 0===e.length?[]:o(e,t,1)}break;case e.length:case r.Infinity:return[[],s(e,c)][0]}return arguments.length>2?e.splice(t,n,...c):e.splice(t)}n.indexOf=function(e,t){return t==t?e.indexOf(t):e.findIndex(e=>e!=e)},n.unshift=i,n.shift=function(e,t){if(t<0)throw new Error("Unexpected negative number");return t===r.undefined?[e.shift(),e]:[o(e,0,t),e]},n.push=s,n.pop=function(e,t){if(t<0)throw new Error("Unexpected negative number");return t===r.undefined?[e,e.pop()]:[e,o(e,e.length-t,t)]},n.splice=o,n.join=function(e,t=""){let n="";for(let r=0;r<e.length;++r)n+=0===r?e[r]:t+e[r];return n}},{"./global":6}],5:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.run=n.once=n.clear=n.mapReturn=n.mapParameters=void 0;const r=e("./global"),i=e("./noop");function s(e){return(...t)=>{e!==i.noop&&(e(...t),e=i.noop,t=[])}}n.mapParameters=function(e,t){return(...n)=>e(...t(...n))},n.mapReturn=function(e,t){return(...n)=>t(e(...n))},n.clear=function(e){return(...t)=>void e(...t)},n.once=s,n.run=function(e){const t=r.Array(e.length);try{for(let n=0;n<e.length;++n)t[n]=e[n]()}catch(e){for(let e=0;t[e];++e)t[e]();throw e}return s(()=>{for(let e=0;t[e];++e)t[e]()})}},{"./global":6,"./noop":8}],6:[function(_dereq_,module,exports){"use strict";const global="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||Function("return this")();eval("global.global = global"),module.exports=global},{}],7:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.memoize=void 0;const r=e("./global");n.memoize=function e(t,n=((...e)=>e[0]),i){if("object"==typeof n)return e(t,r.undefined,n);if(i===r.undefined)return e(t,n,new r.Map);let s=!1;return(...e)=>{const o=n(...e);let c=i.get(o);return c!==r.undefined||s&&i.has(o)?c:(c=t(...e),s||(s=c===r.undefined),i.set(o,c),c)}}},{"./global":6}],8:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.noop=void 0,n.noop=function(){}},{}],9:[function(e,t,n){"use strict";var r;Object.defineProperty(n,"__esModule",{value:!0}),n.isPromiseLike=n.Internal=n.AtomicPromise=void 0;const i=e("./global"),s=e("./alias"),o=e("./array"),c=Symbol.for("spica/promise::internal");class a{constructor(e){this[Symbol.toStringTag]="Promise",this[r]=new l;try{e(e=>this[c].resolve(e),e=>this[c].reject(e))}catch(e){this[c].reject(e)}}static get[Symbol.species](){return a}static all(e){return new a((t,n)=>{const r=s.isArray(e)?e:[...e],o=i.Array(r.length);let a=0;for(let e=0;e<r.length;++e){const i=r[e];if(u(i)){if(d(i)){const{status:t}=i[c];switch(t.state){case 2:o[e]=t.value,++a;continue;case 3:n(t.reason),e=r.length;continue}}i.then(n=>{o[e]=n,++a===r.length&&t(o)},t=>{n(t),e=r.length})}else o[e]=i,++a}a===r.length&&t(o)})}static race(e){return new a((t,n)=>{const r=s.isArray(e)?e:[...e];for(let e=0;e<r.length;++e){const i=r[e];if(!u(i))return t(i);if(d(i)){const{status:e}=i[c];switch(e.state){case 2:return t(e.value);case 3:return n(e.reason)}}}let i=!1;for(let e=0;e<r.length;++e){if(r[e].then(e=>{t(e),i=!0},e=>{n(e),i=!0}),i)return}})}static allSettled(e){return new a(t=>{const n=s.isArray(e)?e:[...e],r=i.Array(n.length);let o=0;for(let e=0;e<n.length;++e){const i=n[e];if(u(i)){if(d(i)){const{status:t}=i[c];switch(t.state){case 2:r[e]={status:"fulfilled",value:t.value},++o;continue;case 3:r[e]={status:"rejected",reason:t.reason},++o;continue}}i.then(i=>{r[e]={status:"fulfilled",value:i},++o===n.length&&t(r)},i=>{r[e]={status:"rejected",reason:i},++o===n.length&&t(r)})}else r[e]={status:"fulfilled",value:i},++o}o===n.length&&t(r)})}static resolve(e){return new a(t=>t(e))}static reject(e){return new a((t,n)=>n(e))}then(e,t){return new a((n,r)=>this[c].then(e,t,n,r))}catch(e){return this.then(i.undefined,e)}finally(e){return this.then(e,e).then(()=>this)}}n.AtomicPromise=a,r=c;class l{constructor(){this.status={state:0},this.reactable=!0,this.fulfillReactions=[],this.rejectReactions=[],this.isHandled=!1}get isPending(){return 0===this.status.state}resolve(e){if(0===this.status.state){if(!u(e))return this.status={state:2,value:e},this.resume();this.status={state:1,promise:e},e.then(e=>{this.status={state:2,value:e},this.resume()},e=>{this.status={state:3,reason:e},this.resume()})}}reject(e){if(0===this.status.state)return this.status={state:3,reason:e},this.resume()}then(e,t,n,r){const{status:i,fulfillReactions:s,rejectReactions:o}=this;switch(i.state){case 2:if(s.length>0)break;try{return n(e?e(i.value):i.value)}catch(e){return r(e)}case 3:if(o.length>0)break;try{return t?n(t(i.reason)):r(i.reason)}catch(e){return r(e)}default:return s.push(t=>{try{n(e?e(t):t)}catch(e){r(e)}}),o.push(e=>{try{t?n(t(e)):r(e)}catch(e){r(e)}}),this.resume()}}resume(){if(!this.reactable)return;const{status:e,fulfillReactions:t,rejectReactions:n}=this;switch(e.state){case 0:case 1:return;case 2:if(this.isHandled&&n.length>0&&o.splice(n,0),0===t.length)return;return this.isHandled=!0,void this.react(t,e.value);case 3:if(this.isHandled&&t.length>0&&o.splice(t,0),0===n.length)return;return this.isHandled=!0,void this.react(n,e.reason)}}react(e,t){if(this.reactable=!1,e.length<5)for(;e.length>0;)e.shift()(t);else{for(let n=0;n<e.length;++n)e[n](t);o.splice(e,0)}this.reactable=!0}}function u(e){return null!==e&&"object"==typeof e&&"then"in e&&"function"==typeof e.then}function d(e){return c in e}n.Internal=l,n.isPromiseLike=u},{"./alias":3,"./array":4,"./global":6}],10:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.unique=n.rnd0Z=n.rnd0z=n.rnd0f=n.rnd64=n.rnd62=n.rnd36=n.rnd32=n.rnd16=void 0;const r=e("./global"),i=[...Array(7)].map((e,t)=>1<<t),s=[...[...Array(36)].map((e,t)=>t.toString(36)),...[...Array(26)].map((e,t)=>(t+10).toString(36).toUpperCase())];function o(e){const t=i.find(t=>t>=e),n=i.indexOf(t);return()=>{for(;;){const t=h(n);if(t<e)return t}}}function c(e){return(t=1)=>{let n="";for(;t--;)n+=s[e()];return n}}n.rnd16=o(16),n.rnd32=o(32),n.rnd36=o(36),n.rnd62=o(62),n.rnd64=o(64),n.rnd0f=c(n.rnd16),n.rnd0z=c(n.rnd36),n.rnd0Z=c(n.rnd62),n.unique=function(e,t,n=new r.Set){let i=5;return()=>{for(;;){for(let r=0;r<i;++r){const r=e(t);if(!n.has(r))return n.add(r),r}i=++t<3?i:3}}};const a=new Uint16Array(512),l=16,u=i.map((e,t)=>+`0b${"1".repeat(t)||0}`);let d=a.length,f=l;function h(e){return d===a.length&&(r.crypto.getRandomValues(a),d=0),f<e?(f=l,++d,h(e)):f>e?(f-=e,a[d]>>f&u[e]):(f=l,a[d++]&u[e])}},{"./global":6}],11:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.SVG=n.HTML=n.Shadow=n.API=void 0;const r=e("spica/global"),i=e("spica/alias"),s=e("./proxy"),o=e("./util/dom");function c(e,t=(e=>e)){return new Proxy(()=>r.undefined,function(e,t){return{apply(e,t,[n,...r]){return this.get(e,n,e)(...r)},get:(n,c)=>n[c]||c in n||"string"!=typeof c?n[c]:n[c]=function(e,n){return function c(a,l,u){if("function"==typeof a)return c(r.undefined,r.undefined,a);if("function"==typeof l)return c(a,r.undefined,l);if(a!==r.undefined&&function(e){if("object"!=typeof e)return!0;for(const t in e)if(i.hasOwnProperty(e,t))return"object"==typeof e[t];return!0}(a))return c(r.undefined,a,u);const d=t(function(t,r,i){const s=t?o.define(t(n,e,r||{},i),r):n(e,r);if(e!==s.tagName.toLowerCase())throw new Error(`TypedDOM: Expected tag name is "${e}" but actually "${s.tagName.toLowerCase()}".`);return s}(u,a,l));return 1===d.nodeType?new s.Elem(d,l):new s.Elem(d.host,l,d)}}(c,e)}}(e,t))}n.API=c,n.Shadow=c(o.html,o.shadow),n.HTML=c(o.html),n.SVG=c(o.svg)},{"./proxy":12,"./util/dom":13,"spica/alias":3,"spica/global":6}],12:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.Elem=n.proxy=void 0;const r=e("spica/global"),i=e("spica/alias"),s=e("./util/identity"),o=e("./util/dom"),c=e("spica/array"),a=new r.WeakMap;function l(e){const t=a.get(e);if(t)return t;throw new Error("TypedDOM: This element has no proxy.")}n.proxy=l;Symbol.for("typed-dom::tag");const u=s.identity();let d=0;function f({element:e}){if(e.parentElement&&a.has(e.parentElement))throw new Error("TypedDOM: Typed DOM children must not be used to another typed DOM.")}n.Elem=class{constructor(e,t,n=e){switch(this.element=e,this.children_=t,this.container=n,this.id_="",this.query_="",this.isPartialUpdate=!1,this.isInit=!0,!0){case t===r.undefined:this.type=0;break;case"string"==typeof t:this.type=1;break;case i.isArray(t):this.type=2;break;case t&&"object"==typeof t:this.type=3;break;default:throw new Error("TypedDOM: Invalid type children.")}switch(f(this),a.set(this.element,this),this.type){case 0:return void(this.isInit=!1);case 1:return o.define(this.container,[]),this.children_=this.container.appendChild(o.text("")),this.children=t,void(this.isInit=!1);case 2:return o.define(this.container,[]),this.children_=[],this.children=t,void(this.isInit=!1);case 3:return o.define(this.container,[]),this.children_=this.observe({...t}),this.children=t,void(this.isInit=!1);default:throw new Error("TypedDOM: Unreachable code.")}}get id(){return this.id_?this.id_:(this.id_=this.element.id,/^[\w-]+$/.test(this.id_)?this.id_:(this.id_=`rnd-${u}-${++d}`,this.element.classList.add(this.id_),this.id_))}get query(){if(this.query_)return this.query_;switch(!0){case this.element!==this.container:return this.query_=":host";case this.id===this.element.id:return this.query_=`#${this.id}`;default:return this.query_=`.${this.id}`}}scope(e){const t=e.element;switch(!1){case"type"in t:case"media"in t:case"STYLE"===t.tagName:return}const n=/(^|[,}])(\s*)\$scope(?![\w-])(?=[^;{}]*{)/g,r=t.innerHTML;if(-1===r.search(n))return;const i=this.query;if(t.innerHTML=r.replace(n,`$1$2${i}`),t.firstElementChild)for(let e=t.children,n=0,r=e.length;n<r;++n)e[0].remove()}observe(e){const t={};for(const n of i.ObjectKeys(e)){if(n in{})continue;let r=e[n];f(r),this.container.appendChild(r.element),t[n]={configurable:!0,enumerable:!0,get:()=>r,set:e=>{const t=r;if(e!==t)if(this.isPartialUpdate)if(r=e,e.element.parentNode===t.element.parentNode){const n=e.element.nextSibling!==t.element?e.element.nextSibling:t.element.nextSibling;this.container.replaceChild(e.element,t.element),this.container.insertBefore(t.element,n)}else this.container.insertBefore(e.element,t.element),this.container.removeChild(t.element);else this.children={...this.children_,[n]:e}}}}return i.ObjectDefineProperties(e,t)}get children(){switch(this.type){case 1:if(this.children_.parentNode!==this.container){this.children_=r.undefined;for(let e=this.container.childNodes,t=0,n=e.length;t<n;++t){const n=e[t];if("wholeText"in n!=0){this.children_=n;break}}}return this.children_.data;default:return this.children_}}set children(e){const t=[],n=[];let s=!1;switch(this.type){case 0:return;case 1:{if(!this.isInit&&e===this.children)return;const t=this.children_,n=t.data,i=e;if(t.data=i,i===n)return;return void this.element.dispatchEvent(new r.Event("mutate",{bubbles:!1,cancelable:!0}))}case 2:{const r=e,i=[];this.children_=i;const o=this.container.children;for(let e=0;e<r.length;++e){const t=r[e],c=o[e];t.element.parentNode!==this.container&&f(t),t.element!==c&&(t.element.parentNode!==this.container&&(this.scope(t),n.push(t)),this.container.insertBefore(t.element,c),s=!0),i.push(t)}for(let e=o.length;r.length<e--;){const e=o[r.length];a.has(e)&&(t.push(l(this.container.removeChild(e))),s=!0)}break}case 3:{const r=e,o=this.children_;for(const e of i.ObjectKeys(o)){const i=o[e],a=r[e];if(this.isInit||a!==i){if(a.element.parentNode!==this.container&&f(a),(this.isInit||a!==i&&a.element.parentNode!==i.element.parentNode)&&(this.scope(a),n.push(a),!this.isInit)){let e=0;(e=t.lastIndexOf(a))>-1&&c.splice(t,e,1),t.push(i),(e=n.lastIndexOf(i))>-1&&c.splice(n,e,1)}this.isPartialUpdate=!0,o[e]=r[e],this.isPartialUpdate=!1,s=!0}}break}}if(t.length){const e=new r.Event("disconnect",{bubbles:!1,cancelable:!0});for(const{element:n}of t)n.dispatchEvent(e)}if(n.length){const e=new r.Event("connect",{bubbles:!1,cancelable:!0});for(const{element:t}of n)t.dispatchEvent(e)}s&&this.element.dispatchEvent(new r.Event("mutate",{bubbles:!1,cancelable:!0}))}}},{"./util/dom":13,"./util/identity":14,"spica/alias":3,"spica/array":4,"spica/global":6}],13:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.defrag=n.isChildren=n.define=n.element=n.text=n.svg=n.html=n.frag=n.shadow=void 0;const r=e("spica/global"),i=e("spica/alias"),s=e("spica/memoize"),o=e("spica/array");var c;function a(e){return r.document.createTextNode(e)}function l(e,t){const n=s.memoize(u,(e,t,n)=>`${t}:${n}`);return(r,i,s)=>{const o=r.includes("-")?u(e,t,r):n(e,t,r).cloneNode(!0);return h(i)?f(o,i):f(d(o,i),s)}}function u(e,t,n){if(!("createElement"in e))throw new Error("TypedDOM: Scoped custom elements are not supported on this browser.");switch(t){case"HTML":return e.createElement(n);case"SVG":return e.createElementNS("http://www.w3.org/2000/svg",n)}}function d(e,t){if(!t)return e;for(let n=0,r=i.ObjectKeys(t);n<r.length;++n){const i=r[n],s=t[i];switch(typeof s){case"string":e.setAttribute(i,s);continue;case"function":if(i.length<3)throw new Error(`TypedDOM: Attribute names for event listeners must have an event name but got "${i}".`);if("on"!==i.slice(0,2))throw new Error(`TypedDOM: Attribute names for event listeners must start with "on" but got "${i}".`);e.addEventListener(i.slice(2),s,{passive:["wheel","mousewheel","touchstart","touchmove","touchend","touchcancel"].includes(i.slice(2))});continue;case"object":e.removeAttribute(i);continue;default:continue}}return e}function f(e,t){switch(typeof t){case"undefined":return e;case"string":return f(e,[t])}if(!("length"in t)){if(e.firstChild)return f(e,o.push([],t));for(const n of t)e.append(n);return e}if(!i.isArray(t)){if(e.firstChild)return f(e,o.push([],t));for(let n=t.length;n--;)e.prepend(t[n]);return e}const n=e.firstChild?e.childNodes:[];let r=n.length;if(0===r)return b(e,t);let s=0;e:for(let i=0;i<t.length;++i){if(s===r)return b(e,t,i);const o=t[i];if("object"==typeof o&&11===o.nodeType){const t=o.childNodes.length;r+=o!==e?t:0,e.insertBefore(o,n[s]||null),s+=t;continue}for(++s;r>t.length;){const e=n[s-1];if(p(e,o))continue e;e.remove(),--r}const c=n[s-1];p(c,o)||(r<t.length-i+s?(r+="string"==typeof o||o.parentNode!==e?1:0,e.insertBefore("string"==typeof o?a(o):o,c)):e.replaceChild("string"==typeof o?a(o):o,c))}for(;s<r;)n[s].remove(),--r;return e}function h(e){return!!(null==e?void 0:e[r.Symbol.iterator])}function p(e,t){return"string"==typeof t?"wholeText"in e&&e.data===t:e===t}function b(e,t,n=0){for(let r=t.length;n<r;++n)e.append(t[n]);return e}!function(e){e.shadows=new WeakMap,e.fragment=r.document.createDocumentFragment()}(c||(c={})),n.shadow=function e(t,i,s){if("string"==typeof t)return e(n.html(t),i,s);if(i&&!h(i))return e(t,r.undefined,i);const o=s===r.undefined?t.shadowRoot||c.shadows.get(t):"open"===s.mode?t.shadowRoot||r.undefined:c.shadows.get(t);return f(s&&"open"!==s.mode?o||c.shadows.set(t,t.attachShadow(s)).get(t):o||t.attachShadow(s||{mode:"open"}),o||i!=r.undefined?i:t.childNodes)},n.frag=function(e){return f(c.fragment.cloneNode(!0),e)},n.html=l(r.document,"HTML"),n.svg=l(r.document,"SVG"),n.text=a,n.element=l,n.define=function(e,t,n){return h(t)?f(e,t):f(d(e,t),n)},n.isChildren=h,n.defrag=function(e){const t=[];for(let n=0;n<e.length;++n){const r=e[n];""!==r&&(t.length>0&&"string"==typeof r&&"string"==typeof e[n-1]?t[t.length-1]+=r:t.push(r))}return t}},{"spica/alias":3,"spica/array":4,"spica/global":6,"spica/memoize":7}],14:[function(e,t,n){"use strict";var r;Object.defineProperty(n,"__esModule",{value:!0}),n.identity=void 0;const i=e("spica/global"),s=e("spica/random"),o=Symbol.for("typed-dom::ids");n.identity=s.unique(s.rnd0Z,2,null!==(r=i.global[o])&&void 0!==r?r:i.global[o]=new i.Set)},{"spica/global":6,"spica/random":10}],15:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.bind=n.delegate=n.wait=n.once=n.listen=n.currentTarget=void 0;const r=e("spica/global"),i=e("spica/promise"),s=e("spica/function"),o=e("spica/noop");function c(e,t,n,r=!1,i={}){return"string"==typeof n?a(e,t,n,r,{..."boolean"==typeof i?{capture:i}:i,once:!0}):l(e,t,n,{..."boolean"==typeof r?{capture:r}:r,once:!0})}function a(e,t,n,i,s={}){let a=o.noop;return l(e,n,e=>{var o,l;a();const u=e.target.shadowRoot?null===(o=e.composedPath()[0])||void 0===o?void 0:o.closest(t):null===(l=e.target)||void 0===l?void 0:l.closest(t);return u?a=c(u,n,i,s):r.undefined,e.returnValue},{...s,capture:!0})}function l(e,t,i,o=!1){return e.addEventListener(t,c,o),s.once(()=>void e.removeEventListener(t,c,o));function c(e){return n.currentTarget in e&&!e[n.currentTarget]?r.undefined:e[n.currentTarget]=e.currentTarget,i(e)}}n.currentTarget=Symbol.for("typed-dom::currentTarget"),n.listen=function(e,t,n,r=!1,i={}){return"string"==typeof n?a(e,t,n,r,i):l(e,t,n,r)},n.once=c,n.wait=function(e,t,n=!1,r={}){return new i.AtomicPromise(i=>"string"==typeof n?c(e,t,n,i,r):c(e,t,i,n))},n.delegate=a,n.bind=l},{"spica/function":5,"spica/global":6,"spica/noop":8,"spica/promise":9}],16:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.apply=void 0;const r=e("./dom");n.apply=function(e,t,n){const i=e.querySelectorAll(t);for(let e=0,t=i.length;e<t;++e)r.define(i[e],n);return i}},{"./dom":13}],"typed-dom":[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.identity=n.apply=n.currentTarget=n.wait=n.once=n.bind=n.delegate=n.listen=n.defrag=n.define=n.element=n.text=n.svg=n.html=n.frag=n.shadow=n.proxy=n.API=n.SVG=n.HTML=n.Shadow=void 0,e("spica/global");var r=e("./src/builder");Object.defineProperty(n,"Shadow",{enumerable:!0,get:function(){return r.Shadow}}),Object.defineProperty(n,"HTML",{enumerable:!0,get:function(){return r.HTML}}),Object.defineProperty(n,"SVG",{enumerable:!0,get:function(){return r.SVG}}),Object.defineProperty(n,"API",{enumerable:!0,get:function(){return r.API}});var i=e("./src/proxy");Object.defineProperty(n,"proxy",{enumerable:!0,get:function(){return i.proxy}});var s=e("./src/util/dom");Object.defineProperty(n,"shadow",{enumerable:!0,get:function(){return s.shadow}}),Object.defineProperty(n,"frag",{enumerable:!0,get:function(){return s.frag}}),Object.defineProperty(n,"html",{enumerable:!0,get:function(){return s.html}}),Object.defineProperty(n,"svg",{enumerable:!0,get:function(){return s.svg}}),Object.defineProperty(n,"text",{enumerable:!0,get:function(){return s.text}}),Object.defineProperty(n,"element",{enumerable:!0,get:function(){return s.element}}),Object.defineProperty(n,"define",{enumerable:!0,get:function(){return s.define}}),Object.defineProperty(n,"defrag",{enumerable:!0,get:function(){return s.defrag}});var o=e("./src/util/listener");Object.defineProperty(n,"listen",{enumerable:!0,get:function(){return o.listen}}),Object.defineProperty(n,"delegate",{enumerable:!0,get:function(){return o.delegate}}),Object.defineProperty(n,"bind",{enumerable:!0,get:function(){return o.bind}}),Object.defineProperty(n,"once",{enumerable:!0,get:function(){return o.once}}),Object.defineProperty(n,"wait",{enumerable:!0,get:function(){return o.wait}}),Object.defineProperty(n,"currentTarget",{enumerable:!0,get:function(){return o.currentTarget}});var c=e("./src/util/query");Object.defineProperty(n,"apply",{enumerable:!0,get:function(){return c.apply}});var a=e("./src/util/identity");Object.defineProperty(n,"identity",{enumerable:!0,get:function(){return a.identity}})},{"./src/builder":11,"./src/proxy":12,"./src/util/dom":13,"./src/util/identity":14,"./src/util/listener":15,"./src/util/query":16,"spica/global":6}]},{},[1,"typed-dom",2]),function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof module&&module.exports&&(module.exports=t())}("undefined"!=typeof self&&self,function(){return require("typed-dom")}); |
@@ -5,3 +5,3 @@ import 'spica/global'; | ||
export { El, proxy } from './src/proxy'; | ||
export { NS, shadow, frag, html, svg, text, element, define } from './src/util/dom'; | ||
export { NS, shadow, frag, html, svg, text, element, define, defrag } from './src/util/dom'; | ||
export { listen, delegate, bind, once, wait, currentTarget } from './src/util/listener'; | ||
@@ -8,0 +8,0 @@ export { apply } from './src/util/query'; |
{ | ||
"name": "typed-dom", | ||
"version": "0.0.221", | ||
"version": "0.0.222", | ||
"description": "A DOM component builder creating type-level DOM structures.", | ||
@@ -50,3 +50,3 @@ "private": false, | ||
"gulp-unassert": "^2.0.0", | ||
"karma": "^6.0.3", | ||
"karma": "^6.0.4", | ||
"karma-chrome-launcher": "^3.1.0", | ||
@@ -62,5 +62,5 @@ "karma-coverage-istanbul-instrumenter": "^1.0.3", | ||
"power-assert": "^1.6.1", | ||
"spica": "0.0.424", | ||
"spica": "0.0.426", | ||
"tsify": "^5.0.2", | ||
"typescript": "4.2.0-dev.20210201", | ||
"typescript": "4.2.0-dev.20210202", | ||
"vinyl-buffer": "^1.0.1", | ||
@@ -67,0 +67,0 @@ "vinyl-source-stream": "^2.0.0" |
@@ -142,2 +142,3 @@ # typed-dom | ||
- define | ||
- defrag | ||
- listen | ||
@@ -144,0 +145,0 @@ - once |
@@ -1,2 +0,2 @@ | ||
import { shadow, frag, html, svg, text, define } from './dom'; | ||
import { shadow, frag, html, svg, text, define, defrag } from './dom'; | ||
import { HTML, SVG } from '../builder'; | ||
@@ -83,2 +83,23 @@ import { Sequence } from 'spica/sequence'; | ||
describe('defrag', () => { | ||
it('', () => { | ||
assert.deepStrictEqual( | ||
defrag([]), | ||
[]); | ||
assert.deepStrictEqual( | ||
defrag(['']), | ||
[]); | ||
assert.deepStrictEqual( | ||
defrag(['', 'a']), | ||
['a']); | ||
assert.deepStrictEqual( | ||
defrag(['a', '']), | ||
['a']); | ||
assert.deepStrictEqual( | ||
defrag(['a', 'b']), | ||
['ab']); | ||
}); | ||
}); | ||
}); |
@@ -202,1 +202,15 @@ import { undefined, Symbol, document } from 'spica/global'; | ||
} | ||
export function defrag<T extends Element | string>(nodes: ArrayLike<T>): T[]; | ||
export function defrag(nodes: ArrayLike<Element | string>): (Element | string)[] { | ||
assert(push([], nodes).every(n => typeof n === 'string' || n instanceof Element)); | ||
const acc: (Element | string)[] = []; | ||
for (let i = 0; i < nodes.length; ++i) { | ||
const node = nodes[i]; | ||
if (node === '') continue; | ||
acc.length > 0 && typeof node === 'string' && typeof nodes[i - 1] === 'string' | ||
? acc[acc.length - 1] += node | ||
: acc.push(node); | ||
} | ||
return acc; | ||
} |
@@ -1,2 +0,2 @@ | ||
import { Shadow, HTML, SVG, API, proxy, NS, shadow, frag, html, svg, text, element, define, listen, once, wait, bind, delegate, currentTarget, apply, identity } from '../../index'; | ||
import { Shadow, HTML, SVG, API, proxy, NS, shadow, frag, html, svg, text, element, define, defrag, listen, once, wait, bind, delegate, currentTarget, apply, identity } from '../../index'; | ||
@@ -62,2 +62,6 @@ describe('Interface: Package', function () { | ||
it('defrag', function () { | ||
assert(typeof defrag === 'function'); | ||
}); | ||
it('listen', function () { | ||
@@ -64,0 +68,0 @@ assert(typeof listen === 'function'); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
639788
14796
356