typed-dom
Advanced tools
Comparing version 0.0.203 to 0.0.204
@@ -1,2 +0,2 @@ | ||
/*! typed-dom v0.0.203 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */ | ||
/*! typed-dom v0.0.204 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */ | ||
require = function () { | ||
@@ -198,3 +198,3 @@ function r(e, n, t) { | ||
'./alias': 3, | ||
'./global': 5 | ||
'./global': 6 | ||
} | ||
@@ -205,2 +205,56 @@ ], | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
exports.run = exports.once = exports.clear = exports.mapReturn = exports.mapParameters = void 0; | ||
const global_1 = _dereq_('./global'); | ||
const noop_1 = _dereq_('./noop'); | ||
function mapParameters(f, g) { | ||
return (...as) => f(...g(...as)); | ||
} | ||
exports.mapParameters = mapParameters; | ||
function mapReturn(f, g) { | ||
return (...as) => g(f(...as)); | ||
} | ||
exports.mapReturn = mapReturn; | ||
function clear(f) { | ||
return (...as) => void f(...as); | ||
} | ||
exports.clear = clear; | ||
function once(f) { | ||
return (...as) => { | ||
if (f === noop_1.noop) | ||
return; | ||
f(...as); | ||
f = noop_1.noop; | ||
as = []; | ||
}; | ||
} | ||
exports.once = once; | ||
function run(fs) { | ||
const gs = global_1.Array(fs.length); | ||
try { | ||
for (let i = 0; i < fs.length; ++i) { | ||
gs[i] = fs[i](); | ||
} | ||
} catch (reason) { | ||
for (let i = 0; gs[i]; ++i) { | ||
gs[i](); | ||
} | ||
throw reason; | ||
} | ||
return once(() => { | ||
for (let i = 0; gs[i]; ++i) { | ||
gs[i](); | ||
} | ||
}); | ||
} | ||
exports.run = run; | ||
}, | ||
{ | ||
'./global': 6, | ||
'./noop': 8 | ||
} | ||
], | ||
6: [ | ||
function (_dereq_, module, exports) { | ||
'use strict'; | ||
const global = void 0 || typeof globalThis !== 'undefined' && globalThis || typeof self !== 'undefined' && self || Function('return this')(); | ||
@@ -212,3 +266,3 @@ eval('global.global = global'); | ||
], | ||
6: [ | ||
7: [ | ||
function (_dereq_, module, exports) { | ||
@@ -238,5 +292,5 @@ 'use strict'; | ||
}, | ||
{ './global': 5 } | ||
{ './global': 6 } | ||
], | ||
7: [ | ||
8: [ | ||
function (_dereq_, module, exports) { | ||
@@ -252,3 +306,3 @@ 'use strict'; | ||
], | ||
8: [ | ||
9: [ | ||
function (_dereq_, module, exports) { | ||
@@ -557,6 +611,6 @@ 'use strict'; | ||
'./array': 4, | ||
'./global': 5 | ||
'./global': 6 | ||
} | ||
], | ||
9: [ | ||
10: [ | ||
function (_dereq_, module, exports) { | ||
@@ -597,4 +651,4 @@ 'use strict'; | ||
const rnd = buffer[index]; | ||
buffer[index] = rnd % denom; | ||
return rnd / denom | 0; | ||
const mod = buffer[index] = rnd % denom; | ||
return (rnd - mod) / denom; | ||
} else { | ||
@@ -607,5 +661,5 @@ denom = scale; | ||
}, | ||
{ './global': 5 } | ||
{ './global': 6 } | ||
], | ||
10: [ | ||
11: [ | ||
function (_dereq_, module, exports) { | ||
@@ -670,9 +724,9 @@ 'use strict'; | ||
{ | ||
'./proxy': 12, | ||
'./util/dom': 13, | ||
'./proxy': 13, | ||
'./util/dom': 14, | ||
'spica/alias': 3, | ||
'spica/global': 5 | ||
'spica/global': 6 | ||
} | ||
], | ||
11: [ | ||
12: [ | ||
function (_dereq_, module, exports) { | ||
@@ -690,5 +744,5 @@ 'use strict'; | ||
}, | ||
{ 'spica/uuid': 9 } | ||
{ 'spica/uuid': 10 } | ||
], | ||
12: [ | ||
13: [ | ||
function (_dereq_, module, exports) { | ||
@@ -983,10 +1037,10 @@ 'use strict'; | ||
{ | ||
'./identity': 11, | ||
'./util/dom': 13, | ||
'./identity': 12, | ||
'./util/dom': 14, | ||
'spica/alias': 3, | ||
'spica/array': 4, | ||
'spica/global': 5 | ||
'spica/global': 6 | ||
} | ||
], | ||
13: [ | ||
14: [ | ||
function (_dereq_, module, exports) { | ||
@@ -1064,3 +1118,5 @@ 'use strict'; | ||
'touchstart', | ||
'touchmove' | ||
'touchmove', | ||
'touchend', | ||
'touchcancel' | ||
].includes(name.slice(2)) | ||
@@ -1088,5 +1144,5 @@ }); | ||
return defineChildren(node, [...children]); | ||
const ns = []; | ||
for (let i = 0, len = children.length; i < len; ++i) { | ||
ns.push(children[i]); | ||
const ns = global_1.Array(children.length); | ||
for (let i = 0; i < ns.length; ++i) { | ||
ns[i] = children[i]; | ||
} | ||
@@ -1149,7 +1205,7 @@ return defineChildren(node, ns); | ||
'spica/alias': 3, | ||
'spica/global': 5, | ||
'spica/memoize': 6 | ||
'spica/global': 6, | ||
'spica/memoize': 7 | ||
} | ||
], | ||
14: [ | ||
15: [ | ||
function (_dereq_, module, exports) { | ||
@@ -1161,2 +1217,3 @@ 'use strict'; | ||
const promise_1 = _dereq_('spica/promise'); | ||
const function_1 = _dereq_('spica/function'); | ||
const noop_1 = _dereq_('spica/noop'); | ||
@@ -1197,4 +1254,3 @@ exports.currentTarget = Symbol.for('currentTarget'); | ||
target.addEventListener(type, handler, option); | ||
let unbind = () => void target.removeEventListener(type, handler, option); | ||
return () => void (unbind = unbind() || noop_1.noop); | ||
return function_1.once(() => void target.removeEventListener(type, handler, option)); | ||
function handler(ev) { | ||
@@ -1207,8 +1263,9 @@ return exports.currentTarget in ev && !ev[exports.currentTarget] ? global_1.undefined : ev[exports.currentTarget] = ev.currentTarget, listener(ev); | ||
{ | ||
'spica/global': 5, | ||
'spica/noop': 7, | ||
'spica/promise': 8 | ||
'spica/function': 5, | ||
'spica/global': 6, | ||
'spica/noop': 8, | ||
'spica/promise': 9 | ||
} | ||
], | ||
15: [ | ||
16: [ | ||
function (_dereq_, module, exports) { | ||
@@ -1228,3 +1285,3 @@ 'use strict'; | ||
}, | ||
{ './dom': 13 } | ||
{ './dom': 14 } | ||
], | ||
@@ -1235,3 +1292,3 @@ 'typed-dom': [ | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
exports.apply = exports.currentTarget = exports.bind = exports.delegate = exports.wait = exports.once = exports.listen = exports.define = exports.element = exports.text = exports.svg = exports.html = exports.frag = exports.shadow = exports.proxy = exports.API = exports.SVG = exports.HTML = exports.Shadow = void 0; | ||
exports.apply = exports.currentTarget = exports.wait = exports.once = exports.bind = exports.delegate = exports.listen = exports.define = exports.element = exports.text = exports.svg = exports.html = exports.frag = exports.shadow = exports.proxy = exports.API = exports.SVG = exports.HTML = exports.Shadow = void 0; | ||
_dereq_('spica/global'); | ||
@@ -1320,24 +1377,24 @@ var builder_1 = _dereq_('./src/builder'); | ||
}); | ||
Object.defineProperty(exports, 'once', { | ||
Object.defineProperty(exports, 'delegate', { | ||
enumerable: true, | ||
get: function () { | ||
return listener_1.once; | ||
return listener_1.delegate; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'wait', { | ||
Object.defineProperty(exports, 'bind', { | ||
enumerable: true, | ||
get: function () { | ||
return listener_1.wait; | ||
return listener_1.bind; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'delegate', { | ||
Object.defineProperty(exports, 'once', { | ||
enumerable: true, | ||
get: function () { | ||
return listener_1.delegate; | ||
return listener_1.once; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'bind', { | ||
Object.defineProperty(exports, 'wait', { | ||
enumerable: true, | ||
get: function () { | ||
return listener_1.bind; | ||
return listener_1.wait; | ||
} | ||
@@ -1360,8 +1417,8 @@ }); | ||
{ | ||
'./src/builder': 10, | ||
'./src/proxy': 12, | ||
'./src/util/dom': 13, | ||
'./src/util/listener': 14, | ||
'./src/util/query': 15, | ||
'spica/global': 5 | ||
'./src/builder': 11, | ||
'./src/proxy': 13, | ||
'./src/util/dom': 14, | ||
'./src/util/listener': 15, | ||
'./src/util/query': 16, | ||
'spica/global': 6 | ||
} | ||
@@ -1368,0 +1425,0 @@ ] |
@@ -1,2 +0,2 @@ | ||
/*! typed-dom v0.0.203 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.ObjectFreeze=n.ObjectEntries=n.ObjectDefineProperty=n.ObjectDefineProperties=n.ObjectCreate=n.ObjectAssign=n.toString=n.isEnumerable=n.isPrototypeOf=n.hasOwnProperty=n.SymbolKeyFor=n.SymbolFor=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.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.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"),i=e("./alias");function s(e,t){if(i.isArray(e))for(let n=e.length-1;n>=0;--n)t.unshift(e[n]);else t.unshift(...e);return t}function o(e,t){if(i.isArray(t))for(let n=0;n<t.length;++n)e.push(t[n]);else e.push(...t);return e}function c(e,t,n,...i){if(0===n&&0===i.length)return[];switch(n=n>e.length?e.length:n,t){case 0:switch(n){case 0:return[[],s(i,e)][0];case 1:return 0===e.length?[[],s(i,e)][0]:[[e.shift()],s(i,e)][0];case r.undefined:if(e.length>1||arguments.length>2)break;return 0===e.length?[]:c(e,t,1)}break;case-1:case e.length-1:case r.Infinity:switch(n){case 0:return[[],o(e,i)][0];case 1:return 0===e.length?[[],o(e,i)][0]:[[e.pop()],o(e,i)][0];case r.undefined:if(e.length>1||arguments.length>2)break;return 0===e.length?[]:c(e,t,1)}}return arguments.length>2?e.splice(t,n,...i):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]:[c(e,0,t),e]},n.unshift=s,n.pop=function(e,t){if(t<0)throw new Error("Unexpected negative number");return t===r.undefined?[e,e.pop()]:[e,c(e,e.length-t,t)]},n.push=o,n.splice=c,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}},{"./alias":3,"./global":5}],5:[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},{}],6:[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":5}],7:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.noop=void 0,n.noop=function(){}},{}],8:[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(f(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(f(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(f(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 f(e){return c in e}n.Internal=l,n.isPromiseLike=u},{"./alias":3,"./array":4,"./global":5}],9:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.uuid=void 0;const r=e("./global"),i="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";function s(e){if("x"===e||"y"===e){const t=function(){a===o.length&&(r.crypto.getRandomValues(o),a=0);if(l>16){l/=16;const e=o[a];return o[a]=e%l,e/l|0}return l=c,o[a++]%16}();return u["x"===e?t:3&t|8]}return e}n.uuid=function(){let e="";for(let t=0;t<i.length;++t)e+=s(i[t]);return e};const o=new Uint16Array(256),c=65536;let a=o.length,l=c;const u=[...Array(16)].map((e,t)=>t.toString(16))},{"./global":5}],10:[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 a(l,u,f){if("function"==typeof l)return a(r.undefined,r.undefined,l);if("function"==typeof u)return a(l,r.undefined,u);if(l!==r.undefined&&function(e){return"object"!=typeof e||i.ObjectValues(e).slice(-1).every(e=>"object"==typeof e)}(l))return a(r.undefined,l,f);const d=t(function(t,r,s){const a=t(n,e,r||{},s);if(e!==a.tagName.toLowerCase())throw new Error(`TypedDOM: Expected tag name is "${e}" but actually "${a.tagName.toLowerCase()}".`);if(t!==c){if(r)for(const e of i.ObjectKeys(r)){const t=r[e];"function"==typeof t&&a.removeEventListener(e,t)}o.define(a,r)}return a}(f||c,l,u));return 1===d.nodeType?new s.Elem(d,u):new s.Elem(d.host,u,d)};function c(e,t,n){return e(t,n)}}(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":5}],11:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.id=void 0;const r=e("spica/uuid").uuid().split("-").pop();let i=0;n.id=function(){return`id-${r}-${++i}`}},{"spica/uuid":9}],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("./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");function u({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(u(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.trim(),this.id_?this.id_:(this.id_=s.id(),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.trim():return this.query_=`#${this.id}`;default:return this.query_=`.${this.id}`}}observe(e){const t={};for(const n of i.ObjectKeys(e)){if(n in{})continue;let r=e[n];u(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)}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(/^[:#.][\w-]+$/.test(i)&&(t.innerHTML=r.replace(n,(e,t,n)=>`${t}${n}${i}`),t.firstElementChild))for(let e=t.children,n=0,r=e.length;n<r;++n)e[0].remove()}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("change",{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&&u(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&&u(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("change",{bubbles:!1,cancelable:!0}))}}},{"./identity":11,"./util/dom":13,"spica/alias":3,"spica/array":4,"spica/global":5}],13:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),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");var o;function c(e){return r.document.createTextNode(e)}function a(e,t){const n=s.memoize(l,(e,t,n)=>`${t}:${n}`);return(r,i,s)=>{const o=r.includes("-")?l(e,t,r):n(e,t,r).cloneNode(!0);return d(i)?f(o,i):f(u(o,i),s)}}function l(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 u(e,t){if(!t)return e;for(const n of i.ObjectKeys(t)){const r=t[n];switch(typeof r){case"string":e.setAttribute(n,r);continue;case"function":if(n.length<3)throw new Error(`TypedDOM: Attribute names for event listeners must have an event name but got "${n}".`);if("on"!==n.slice(0,2))throw new Error(`TypedDOM: Attribute names for event listeners must start with "on" but got "${n}".`);e.addEventListener(n.slice(2),r,{passive:["wheel","mousewheel","touchstart","touchmove"].includes(n.slice(2))});continue;case"object":e.removeAttribute(n);continue;default:continue}}return e}function f(e,t){switch(typeof t){case"undefined":return e;case"string":return f(e,[t])}if(!i.isArray(t)){if(!("length"in t))return f(e,[...t]);const n=[];for(let e=0,r=t.length;e<r;++e)n.push(t[e]);return f(e,n)}const n=e.firstChild?e.childNodes:[];let r=n.length;if(0===r)return e.append(...t),e;let s=0;e:for(let i=0;i<t.length;++i){if(s===r)return e.append(...t.slice(i)),e;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(h(e,o))continue e;e.remove(),--r}const a=n[s-1];h(a,o)||(r<t.length-i+s?(r+="string"==typeof o||o.parentNode!==e?1:0,e.insertBefore("string"==typeof o?c(o):o,a)):e.replaceChild("string"==typeof o?c(o):o,a))}for(;s<r;)n[s].remove(),--r;return e}function d(e){return!!(null==e?void 0:e[r.Symbol.iterator])}function h(e,t){return"string"==typeof t?"wholeText"in e&&e.data===t:e===t}!function(e){e.shadows=new WeakMap,e.fragment=r.document.createDocumentFragment()}(o||(o={})),n.shadow=function e(t,i,s){if("string"==typeof t)return e(n.html(t),i,s);if(i&&!d(i))return e(t,r.undefined,i);const c=s===r.undefined?t.shadowRoot||o.shadows.get(t):"open"===s.mode?t.shadowRoot||r.undefined:o.shadows.get(t);return f(s&&"open"!==s.mode?c||o.shadows.set(t,t.attachShadow(s)).get(t):c||t.attachShadow(s||{mode:"open"}),c||i!=r.undefined?i:t.childNodes)},n.frag=function(e){return f(o.fragment.cloneNode(!0),e)},n.html=a(r.document,"HTML"),n.svg=a(r.document,"SVG"),n.text=c,n.element=a,n.define=function(e,t,n){return d(t)?f(e,t):f(u(e,t),n)}},{"spica/alias":3,"spica/global":5,"spica/memoize":6}],14:[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/noop");function o(e,t,n,r=!1,i={}){return"string"==typeof n?c(e,t,n,r,{..."boolean"==typeof i?{capture:i}:i,once:!0}):a(e,t,n,{..."boolean"==typeof r?{capture:r}:r,once:!0})}function c(e,t,n,i,c={}){let l=s.noop;return a(e,n,e=>{var s,a;l();const u=e.target.shadowRoot?null===(s=e.composedPath()[0])||void 0===s?void 0:s.closest(t):null===(a=e.target)||void 0===a?void 0:a.closest(t);return u?l=o(u,n,i,c):r.undefined,e.returnValue},{...c,capture:!0})}function a(e,t,i,o=!1){e.addEventListener(t,a,o);let c=()=>void e.removeEventListener(t,a,o);return()=>void(c=c()||s.noop);function a(e){return n.currentTarget in e&&!e[n.currentTarget]?r.undefined:e[n.currentTarget]=e.currentTarget,i(e)}}n.currentTarget=Symbol.for("currentTarget"),n.listen=function(e,t,n,r=!1,i={}){return"string"==typeof n?c(e,t,n,r,i):a(e,t,n,r)},n.once=o,n.wait=function(e,t,n=!1,r={}){return new i.AtomicPromise(i=>"string"==typeof n?o(e,t,n,i,r):o(e,t,i,n))},n.delegate=c,n.bind=a},{"spica/global":5,"spica/noop":7,"spica/promise":8}],15:[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.apply=n.currentTarget=n.bind=n.delegate=n.wait=n.once=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,"once",{enumerable:!0,get:function(){return o.once}}),Object.defineProperty(n,"wait",{enumerable:!0,get:function(){return o.wait}}),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,"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}})},{"./src/builder":10,"./src/proxy":12,"./src/util/dom":13,"./src/util/listener":14,"./src/util/query":15,"spica/global":5}]},{},[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.204 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.ObjectFreeze=n.ObjectEntries=n.ObjectDefineProperty=n.ObjectDefineProperties=n.ObjectCreate=n.ObjectAssign=n.toString=n.isEnumerable=n.isPrototypeOf=n.hasOwnProperty=n.SymbolKeyFor=n.SymbolFor=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.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.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"),i=e("./alias");function s(e,t){if(i.isArray(e))for(let n=e.length-1;n>=0;--n)t.unshift(e[n]);else t.unshift(...e);return t}function o(e,t){if(i.isArray(t))for(let n=0;n<t.length;++n)e.push(t[n]);else e.push(...t);return e}function c(e,t,n,...i){if(0===n&&0===i.length)return[];switch(n=n>e.length?e.length:n,t){case 0:switch(n){case 0:return[[],s(i,e)][0];case 1:return 0===e.length?[[],s(i,e)][0]:[[e.shift()],s(i,e)][0];case r.undefined:if(e.length>1||arguments.length>2)break;return 0===e.length?[]:c(e,t,1)}break;case-1:case e.length-1:case r.Infinity:switch(n){case 0:return[[],o(e,i)][0];case 1:return 0===e.length?[[],o(e,i)][0]:[[e.pop()],o(e,i)][0];case r.undefined:if(e.length>1||arguments.length>2)break;return 0===e.length?[]:c(e,t,1)}}return arguments.length>2?e.splice(t,n,...i):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]:[c(e,0,t),e]},n.unshift=s,n.pop=function(e,t){if(t<0)throw new Error("Unexpected negative number");return t===r.undefined?[e,e.pop()]:[e,c(e,e.length-t,t)]},n.push=o,n.splice=c,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}},{"./alias":3,"./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(f(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(f(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(f(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 f(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.uuid=void 0;const r=e("./global"),i="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";function s(e){if("x"===e||"y"===e){const t=function(){a===o.length&&(r.crypto.getRandomValues(o),a=0);if(l>16){l/=16;const e=o[a],t=o[a]=e%l;return(e-t)/l}return l=c,o[a++]%16}();return u["x"===e?t:3&t|8]}return e}n.uuid=function(){let e="";for(let t=0;t<i.length;++t)e+=s(i[t]);return e};const o=new Uint16Array(256),c=65536;let a=o.length,l=c;const u=[...Array(16)].map((e,t)=>t.toString(16))},{"./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 a(l,u,f){if("function"==typeof l)return a(r.undefined,r.undefined,l);if("function"==typeof u)return a(l,r.undefined,u);if(l!==r.undefined&&function(e){return"object"!=typeof e||i.ObjectValues(e).slice(-1).every(e=>"object"==typeof e)}(l))return a(r.undefined,l,f);const d=t(function(t,r,s){const a=t(n,e,r||{},s);if(e!==a.tagName.toLowerCase())throw new Error(`TypedDOM: Expected tag name is "${e}" but actually "${a.tagName.toLowerCase()}".`);if(t!==c){if(r)for(const e of i.ObjectKeys(r)){const t=r[e];"function"==typeof t&&a.removeEventListener(e,t)}o.define(a,r)}return a}(f||c,l,u));return 1===d.nodeType?new s.Elem(d,u):new s.Elem(d.host,u,d)};function c(e,t,n){return e(t,n)}}(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":13,"./util/dom":14,"spica/alias":3,"spica/global":6}],12:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.id=void 0;const r=e("spica/uuid").uuid().split("-").pop();let i=0;n.id=function(){return`id-${r}-${++i}`}},{"spica/uuid":10}],13:[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("./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");function u({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(u(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.trim(),this.id_?this.id_:(this.id_=s.id(),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.trim():return this.query_=`#${this.id}`;default:return this.query_=`.${this.id}`}}observe(e){const t={};for(const n of i.ObjectKeys(e)){if(n in{})continue;let r=e[n];u(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)}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(/^[:#.][\w-]+$/.test(i)&&(t.innerHTML=r.replace(n,(e,t,n)=>`${t}${n}${i}`),t.firstElementChild))for(let e=t.children,n=0,r=e.length;n<r;++n)e[0].remove()}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("change",{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&&u(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&&u(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("change",{bubbles:!1,cancelable:!0}))}}},{"./identity":12,"./util/dom":14,"spica/alias":3,"spica/array":4,"spica/global":6}],14:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),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");var o;function c(e){return r.document.createTextNode(e)}function a(e,t){const n=s.memoize(l,(e,t,n)=>`${t}:${n}`);return(r,i,s)=>{const o=r.includes("-")?l(e,t,r):n(e,t,r).cloneNode(!0);return d(i)?f(o,i):f(u(o,i),s)}}function l(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 u(e,t){if(!t)return e;for(const n of i.ObjectKeys(t)){const r=t[n];switch(typeof r){case"string":e.setAttribute(n,r);continue;case"function":if(n.length<3)throw new Error(`TypedDOM: Attribute names for event listeners must have an event name but got "${n}".`);if("on"!==n.slice(0,2))throw new Error(`TypedDOM: Attribute names for event listeners must start with "on" but got "${n}".`);e.addEventListener(n.slice(2),r,{passive:["wheel","mousewheel","touchstart","touchmove","touchend","touchcancel"].includes(n.slice(2))});continue;case"object":e.removeAttribute(n);continue;default:continue}}return e}function f(e,t){switch(typeof t){case"undefined":return e;case"string":return f(e,[t])}if(!i.isArray(t)){if(!("length"in t))return f(e,[...t]);const n=r.Array(t.length);for(let e=0;e<n.length;++e)n[e]=t[e];return f(e,n)}const n=e.firstChild?e.childNodes:[];let s=n.length;if(0===s)return e.append(...t),e;let o=0;e:for(let r=0;r<t.length;++r){if(o===s)return e.append(...t.slice(r)),e;const i=t[r];if("object"==typeof i&&11===i.nodeType){const t=i.childNodes.length;s+=i!==e?t:0,e.insertBefore(i,n[o]||null),o+=t;continue}for(++o;s>t.length;){const e=n[o-1];if(h(e,i))continue e;e.remove(),--s}const a=n[o-1];h(a,i)||(s<t.length-r+o?(s+="string"==typeof i||i.parentNode!==e?1:0,e.insertBefore("string"==typeof i?c(i):i,a)):e.replaceChild("string"==typeof i?c(i):i,a))}for(;o<s;)n[o].remove(),--s;return e}function d(e){return!!(null==e?void 0:e[r.Symbol.iterator])}function h(e,t){return"string"==typeof t?"wholeText"in e&&e.data===t:e===t}!function(e){e.shadows=new WeakMap,e.fragment=r.document.createDocumentFragment()}(o||(o={})),n.shadow=function e(t,i,s){if("string"==typeof t)return e(n.html(t),i,s);if(i&&!d(i))return e(t,r.undefined,i);const c=s===r.undefined?t.shadowRoot||o.shadows.get(t):"open"===s.mode?t.shadowRoot||r.undefined:o.shadows.get(t);return f(s&&"open"!==s.mode?c||o.shadows.set(t,t.attachShadow(s)).get(t):c||t.attachShadow(s||{mode:"open"}),c||i!=r.undefined?i:t.childNodes)},n.frag=function(e){return f(o.fragment.cloneNode(!0),e)},n.html=a(r.document,"HTML"),n.svg=a(r.document,"SVG"),n.text=c,n.element=a,n.define=function(e,t,n){return d(t)?f(e,t):f(u(e,t),n)}},{"spica/alias":3,"spica/global":6,"spica/memoize":7}],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("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":14}],"typed-dom":[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),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}})},{"./src/builder":11,"./src/proxy":13,"./src/util/dom":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")}); |
@@ -6,3 +6,3 @@ import 'spica/global'; | ||
export { NS, shadow, frag, html, svg, text, element, define } from './src/util/dom'; | ||
export { listen, once, wait, delegate, bind, currentTarget } from './src/util/listener'; | ||
export { listen, delegate, bind, once, wait, currentTarget } from './src/util/listener'; | ||
export { apply } from './src/util/query'; | ||
@@ -9,0 +9,0 @@ |
{ | ||
"name": "typed-dom", | ||
"version": "0.0.203", | ||
"version": "0.0.204", | ||
"description": "A DOM component builder creating type-level DOM structures.", | ||
@@ -60,5 +60,5 @@ "private": false, | ||
"power-assert": "^1.6.1", | ||
"spica": "0.0.404", | ||
"spica": "0.0.405", | ||
"tsify": "^5.0.2", | ||
"typescript": "4.2.0-dev.20201222", | ||
"typescript": "4.2.0-dev.20201223", | ||
"vinyl-buffer": "^1.0.1", | ||
@@ -65,0 +65,0 @@ "vinyl-source-stream": "^2.0.0" |
@@ -1,2 +0,2 @@ | ||
import { undefined, Symbol, document } from 'spica/global'; | ||
import { undefined, Array, Symbol, document } from 'spica/global'; | ||
import { isArray, ObjectKeys } from 'spica/alias'; | ||
@@ -104,2 +104,4 @@ import { memoize } from 'spica/memoize'; | ||
'touchmove', | ||
'touchend', | ||
'touchcancel', | ||
].includes(name.slice(2)), | ||
@@ -126,5 +128,5 @@ }); | ||
if (!('length' in children)) return defineChildren(node, [...children]); | ||
const ns: (string | Node)[] = []; | ||
for (let i = 0, len = children.length; i < len; ++i) { | ||
ns.push(children[i]); | ||
const ns = Array<string | Node>(children.length); | ||
for (let i = 0; i < ns.length; ++i) { | ||
ns[i] = children[i]; | ||
} | ||
@@ -131,0 +133,0 @@ return defineChildren(node, ns); |
import { undefined } from 'spica/global'; | ||
import { AtomicPromise } from 'spica/promise'; | ||
import { once as one } from 'spica/function'; | ||
import { noop } from 'spica/noop'; | ||
@@ -82,4 +83,3 @@ | ||
target.addEventListener(type, handler, option); | ||
let unbind = () => void target.removeEventListener(type, handler, option); | ||
return () => void (unbind = unbind() || noop); | ||
return one(() => void target.removeEventListener(type, handler, option)); | ||
@@ -86,0 +86,0 @@ function handler(ev: Event): unknown { |
Sorry, the diff of this file is too big to display
620333
14363