From e13b3aa45562965e03dc43dcafa53a5fb8aa5f1a Mon Sep 17 00:00:00 2001 From: webreflection Date: Wed, 21 Jun 2023 15:31:35 +0200 Subject: [PATCH] better test/input.js --- es.js | 2 +- esm/channel.js | 2 +- global.js | 4 ++-- package.json | 2 +- structured.js | 2 +- test/input.js | 23 ++++++++++++----------- uhtml.js | 6 +++--- 7 files changed, 21 insertions(+), 20 deletions(-) diff --git a/es.js b/es.js index 593d5f9..93163b2 100644 --- a/es.js +++ b/es.js @@ -1,2 +1,2 @@ -var e="4c9d14a5-5462-4074-b208-d8633aa2f6e9",t=e=>({value:new Promise((t=>{let n=new Worker("data:application/javascript,"+encodeURIComponent("onmessage=({data:b})=>(Atomics.wait(b,0),postMessage(0))"));n.onmessage=t,n.postMessage(e)}))}) +var e="417f77a3-3f54-4e3f-95fa-50ee1cb1635d",t=e=>({value:new Promise((t=>{let n=new Worker("data:application/javascript,"+encodeURIComponent("onmessage=({data:b})=>(Atomics.wait(b,0),postMessage(0))"));n.onmessage=t,n.postMessage(e)}))}) /*! (c) Andrea Giammarchi - ISC */;const{Int32Array:n,Map:a,SharedArrayBuffer:s,Uint16Array:r}=globalThis,{BYTES_PER_ELEMENT:o}=n,{BYTES_PER_ELEMENT:i}=r,{isArray:c}=Array,{notify:f,wait:l,waitAsync:w}=Atomics,{fromCharCode:d}=String,g=(e,n)=>e?(w||t)(n,0):(l(n,0),{value:{then:e=>e()}}),p=new WeakSet,h=new WeakMap;let u=0;const E=(t,{parse:l,stringify:w}=JSON)=>{if(!h.has(t)){const E=(n,...a)=>t.postMessage({[e]:a},{transfer:n});h.set(t,new Proxy(new a,{get:(e,a)=>"then"===a?null:(...e)=>{const c=u++;let f=new n(new s(o)),w=[];p.has(e.at(-1)||w)&&p.delete(w=e.pop()),E(w,c,f,a,e);const h=t instanceof Worker;return g(h,f).value.then((()=>{const e=f[0];if(!e)return;const t=i*e;return f=new n(new s(t+t%o)),E([],c,f),g(h,f).value.then((()=>l(d(...new r(f.buffer).slice(0,e)))))}))},set(n,s,o){if(!n.size){const s=new a;t.addEventListener("message",(async t=>{const a=t.data?.[e];if(c(a)){t.stopImmediatePropagation();const[e,o,...i]=a;if(i.length){const[t,a]=i;if(!n.has(t))throw new Error(`Unsupported action: ${t}`);{const r=w(await n.get(t)(...a));r&&(s.set(e,r),o[0]=r.length)}}else{const t=s.get(e);s.delete(e);for(let e=new r(o.buffer),n=0;n(p.add(e),e);export{E as default}; diff --git a/esm/channel.js b/esm/channel.js index 942af9a..dce4446 100644 --- a/esm/channel.js +++ b/esm/channel.js @@ -1 +1 @@ -export default '4c9d14a5-5462-4074-b208-d8633aa2f6e9'; +export default '417f77a3-3f54-4e3f-95fa-50ee1cb1635d'; diff --git a/global.js b/global.js index e8b6ce2..24072bf 100644 --- a/global.js +++ b/global.js @@ -1,2 +1,2 @@ -var e="4c9d14a5-5462-4074-b208-d8633aa2f6e9",t=e=>({value:new Promise((t=>{let n=new Worker("data:application/javascript,"+encodeURIComponent("onmessage=({data:b})=>(Atomics.wait(b,0),postMessage(0))"));n.onmessage=t,n.postMessage(e)}))}) -/*! (c) Andrea Giammarchi - ISC */;const{Int32Array:n,Map:r,SharedArrayBuffer:s,Uint16Array:a}=globalThis,{BYTES_PER_ELEMENT:o}=n,{BYTES_PER_ELEMENT:i}=a,{isArray:c}=Array,{notify:l,wait:p,waitAsync:f}=Atomics,{fromCharCode:u}=String,g=(e,n)=>e?(f||t)(n,0):(p(n,0),{value:{then:e=>e()}}),y=new WeakSet,w=new WeakMap;let d=0;const h=(t,{parse:p,stringify:f}=JSON)=>{if(!w.has(t)){const h=(n,...r)=>t.postMessage({[e]:r},{transfer:n});w.set(t,new Proxy(new r,{get:(e,r)=>"then"===r?null:(...e)=>{const c=d++;let l=new n(new s(o)),f=[];y.has(e.at(-1)||f)&&y.delete(f=e.pop()),h(f,c,l,r,e);const w=t instanceof Worker;return g(w,l).value.then((()=>{const e=l[0];if(!e)return;const t=i*e;return l=new n(new s(t+t%o)),h([],c,l),g(w,l).value.then((()=>p(u(...new a(l.buffer).slice(0,e)))))}))},set(n,s,o){if(!n.size){const s=new r;t.addEventListener("message",(async t=>{const r=t.data?.[e];if(c(r)){t.stopImmediatePropagation();const[e,o,...i]=r;if(i.length){const[t,r]=i;if(!n.has(t))throw new Error(`Unsupported action: ${t}`);{const a=f(await n.get(t)(...r));a&&(s.set(e,a),o[0]=a.length)}}else{const t=s.get(e);s.delete(e);for(let e=new a(o.buffer),n=0;n(y.add(e),e);const m="object",v="function",b="number",E="string",M="undefined",P="symbol",{defineProperty:k,getOwnPropertyDescriptor:S,getPrototypeOf:T,isExtensible:x,ownKeys:A,preventExtensions:W,set:R,setPrototypeOf:O}=Reflect,L=(e,t)=>{const{get:n,set:r,value:s}=e;return n&&(e.get=t(n)),r&&(e.set=t(r)),s&&(e.value=t(s)),e},C=(e,t)=>[e,t],U=e=>t=>{const n=typeof t;switch(n){case m:if(null==t)return C("null",t);case v:return e(n,t);case"boolean":case b:case E:case M:case"bigint":return C(n,t);case P:if(_.has(t))return C(n,_.get(t))}throw new Error(`Unable to handle this ${n} type`)},_=new Map(A(Symbol).filter((e=>typeof Symbol[e]===P)).map((e=>[Symbol[e],e]))),z=e=>{for(const[t,n]of _)if(n===e)return t},B="apply",I="construct",N="defineProperty",j="deleteProperty",D="get",F="getOwnPropertyDescriptor",K="getPrototypeOf",Y="has",$="isExtensible",G="ownKeys",J="preventExtensions",q="set",H="setPrototypeOf",Q="delete";let V=0;const X=new Map,Z=new Map,ee=new WeakMap,{addEventListener:te}=EventTarget.prototype;k(EventTarget.prototype,"addEventListener",{value(e,t,...n){return n.at(0)?.invoke&&(ee.has(this)||ee.set(this,new Map),ee.get(this).set(e,[].concat(n[0].invoke)),delete n[0].invoke),te.call(this,e,t,...n)}});const ne=U(((e,t)=>{if(!X.has(t)){let e;for(;Z.has(e=V++););X.set(t,e),Z.set(e,t)}return C(e,X.get(t))}));var re=(e,t,n)=>{const{[n]:r}=e,s=new FinalizationRegistry((e=>{r(Q,C(E,e))})),a=([e,t])=>{switch(e){case m:return null==t?globalThis:typeof t===b?Z.get(t):t;case v:if(typeof t===E){if(!Z.has(t)){const e=function(...e){return e.at(0)instanceof Event&&(e=>{const{currentTarget:t,target:n,type:r}=e;for(const s of ee.get(t||n)?.get(r)||[])e[s]()})(...e),r(B,C(v,t),ne(this),e.map(ne))},n=new WeakRef(e);Z.set(t,n),s.register(e,t,n)}return Z.get(t).deref()}return Z.get(t);case P:return z(t)}return t},o={[B]:(e,t,n)=>ne(e.apply(t,n)),[I]:(e,t)=>ne(new e(...t)),[N]:(e,t,n)=>ne(k(e,t,n)),[j]:(e,t)=>ne(delete e[t]),[K]:e=>ne(T(e)),[D]:(e,t)=>ne(e[t]),[F]:(e,t)=>{const n=S(e,t);return n?C(m,L(n,ne)):C(M,n)},[Y]:(e,t)=>ne(t in e),[$]:e=>ne(x(e)),[G]:e=>C(m,A(e).map(ne)),[J]:e=>ne(W(e)),[q]:(e,t,n)=>ne(R(e,t,n)),[H]:(e,t)=>ne(O(e,t)),[Q](e){X.delete(Z.get(e)),Z.delete(e)}};return e[t]=(e,t,...n)=>{switch(e){case B:n[0]=a(n[0]),n[1]=n[1].map(a);break;case I:n[0]=n[0].map(a);break;case N:{const[e,t]=n;n[0]=a(e);const{get:r,set:s,value:o}=t;r&&(t.get=a(r)),s&&(t.set=a(s)),o&&(t.value=a(o));break}default:n=n.map(a)}return o[e](a(t),...n)},e};const se=e=>typeof e===v?e():e,ae=U(((e,t)=>{if(oe in t)return se(t[oe]);if(e===v){if(!le.has(t)){let e;for(;le.has(e=String(ie++)););ce.set(t,e),le.set(e,t)}return C(e,ce.get(t))}return C(e,t)})),oe=Symbol();let ie=0;const ce=new Map,le=new Map;var pe=(e,t,n)=>{const{[t]:r}=e,s=new Map,a=new FinalizationRegistry((e=>{s.delete(e),r(Q,ae(e))})),o=e=>{const[t,n]=e;if(!s.has(n)){const r=t===v?fe.bind(e):e,o=new Proxy(r,l),i=new WeakRef(o);s.set(n,i),a.register(o,n,i)}return s.get(n).deref()},i=e=>{const[t,n]=e;switch(t){case m:return typeof n===b?o(e):n;case v:return typeof n===E?le.get(n):o(e);case P:return z(n)}return n},c=(e,t,...n)=>i(r(e,se(t),...n)),l={[B]:(e,t,n)=>c(B,e,ae(t),n.map(ae)),[I]:(e,t)=>c(I,e,t.map(ae)),[N]:(e,t,n)=>{const{get:r,set:s,value:a}=n;return typeof r===v&&(n.get=ae(r)),typeof s===v&&(n.set=ae(s)),typeof a===v&&(n.value=ae(a)),c(N,e,ae(t),n)},[j]:(e,t)=>c(j,e,ae(t)),[K]:e=>c(K,e),[D]:(e,t)=>t===oe?e:c(D,e,ae(t)),[F]:(e,t)=>{const n=c(F,e,ae(t));return n&&L(n,i)},[Y]:(e,t)=>t===oe||c(Y,e,ae(t)),[$]:e=>c($,e),[G]:e=>c(G,e).map(i),[J]:e=>c(J,e),[q]:(e,t,n)=>c(q,e,ae(t),ae(n)),[H]:(e,t)=>c(H,e,ae(t))};return e[n]=(e,t,n,r)=>{switch(e){case B:return i(t).apply(i(n),r.map(i));case Q:{const e=i(t);ce.delete(le.get(e)),le.delete(e)}}},{proxy:e,global:new Proxy([m,null],l),isGlobal:e=>typeof e===m&&!!e&&oe in e}};function fe(){return this}const ue=e+"M",ge=e+"T",ye=new WeakMap,we=(e,...t)=>{const n=h(e,...t);if(!ye.has(n)){const t=e instanceof Worker?re:pe;ye.set(n,t(n,ue,ge))}return ye.get(n)};we.transfer=h.transfer;export{we as default}; +var e="417f77a3-3f54-4e3f-95fa-50ee1cb1635d",t=e=>({value:new Promise((t=>{let n=new Worker("data:application/javascript,"+encodeURIComponent("onmessage=({data:b})=>(Atomics.wait(b,0),postMessage(0))"));n.onmessage=t,n.postMessage(e)}))}) +/*! (c) Andrea Giammarchi - ISC */;const{Int32Array:n,Map:r,SharedArrayBuffer:s,Uint16Array:a}=globalThis,{BYTES_PER_ELEMENT:o}=n,{BYTES_PER_ELEMENT:i}=a,{isArray:c}=Array,{notify:l,wait:f,waitAsync:p}=Atomics,{fromCharCode:u}=String,g=(e,n)=>e?(p||t)(n,0):(f(n,0),{value:{then:e=>e()}}),y=new WeakSet,w=new WeakMap;let h=0;const d=(t,{parse:f,stringify:p}=JSON)=>{if(!w.has(t)){const d=(n,...r)=>t.postMessage({[e]:r},{transfer:n});w.set(t,new Proxy(new r,{get:(e,r)=>"then"===r?null:(...e)=>{const c=h++;let l=new n(new s(o)),p=[];y.has(e.at(-1)||p)&&y.delete(p=e.pop()),d(p,c,l,r,e);const w=t instanceof Worker;return g(w,l).value.then((()=>{const e=l[0];if(!e)return;const t=i*e;return l=new n(new s(t+t%o)),d([],c,l),g(w,l).value.then((()=>f(u(...new a(l.buffer).slice(0,e)))))}))},set(n,s,o){if(!n.size){const s=new r;t.addEventListener("message",(async t=>{const r=t.data?.[e];if(c(r)){t.stopImmediatePropagation();const[e,o,...i]=r;if(i.length){const[t,r]=i;if(!n.has(t))throw new Error(`Unsupported action: ${t}`);{const a=p(await n.get(t)(...r));a&&(s.set(e,a),o[0]=a.length)}}else{const t=s.get(e);s.delete(e);for(let e=new a(o.buffer),n=0;n(y.add(e),e);const m="object",v="function",b="number",E="string",M="undefined",P="symbol",{defineProperty:k,getOwnPropertyDescriptor:S,getPrototypeOf:T,isExtensible:x,ownKeys:A,preventExtensions:W,set:R,setPrototypeOf:O}=Reflect,L=(e,t)=>{const{get:n,set:r,value:s}=e;return n&&(e.get=t(n)),r&&(e.set=t(r)),s&&(e.value=t(s)),e},C=(e,t)=>[e,t],U=e=>t=>{const n=typeof t;switch(n){case m:if(null==t)return C("null",t);case v:return e(n,t);case"boolean":case b:case E:case M:case"bigint":return C(n,t);case P:if(_.has(t))return C(n,_.get(t))}throw new Error(`Unable to handle this ${n} type`)},_=new Map(A(Symbol).filter((e=>typeof Symbol[e]===P)).map((e=>[Symbol[e],e]))),z=e=>{for(const[t,n]of _)if(n===e)return t},B="apply",I="construct",N="defineProperty",j="deleteProperty",D="get",F="getOwnPropertyDescriptor",K="getPrototypeOf",Y="has",$="isExtensible",G="ownKeys",J="preventExtensions",q="set",H="setPrototypeOf",Q="delete";let V=0;const X=new Map,Z=new Map,ee=new WeakMap,{addEventListener:te}=EventTarget.prototype;k(EventTarget.prototype,"addEventListener",{value(e,t,...n){return n.at(0)?.invoke&&(ee.has(this)||ee.set(this,new Map),ee.get(this).set(e,[].concat(n[0].invoke)),delete n[0].invoke),te.call(this,e,t,...n)}});const ne=U(((e,t)=>{if(!X.has(t)){let e;for(;Z.has(e=V++););X.set(t,e),Z.set(e,t)}return C(e,X.get(t))}));var re=(e,t,n)=>{const{[n]:r}=e,s=new FinalizationRegistry((e=>{r(Q,C(E,e))})),a=([e,t])=>{switch(e){case m:return null==t?globalThis:typeof t===b?Z.get(t):t;case v:if(typeof t===E){if(!Z.has(t)){const e=function(...e){return e.at(0)instanceof Event&&(e=>{const{currentTarget:t,target:n,type:r}=e;for(const s of ee.get(t||n)?.get(r)||[])e[s]()})(...e),r(B,C(v,t),ne(this),e.map(ne))},n=new WeakRef(e);Z.set(t,n),s.register(e,t,n)}return Z.get(t).deref()}return Z.get(t);case P:return z(t)}return t},o={[B]:(e,t,n)=>ne(e.apply(t,n)),[I]:(e,t)=>ne(new e(...t)),[N]:(e,t,n)=>ne(k(e,t,n)),[j]:(e,t)=>ne(delete e[t]),[K]:e=>ne(T(e)),[D]:(e,t)=>ne(e[t]),[F]:(e,t)=>{const n=S(e,t);return n?C(m,L(n,ne)):C(M,n)},[Y]:(e,t)=>ne(t in e),[$]:e=>ne(x(e)),[G]:e=>C(m,A(e).map(ne)),[J]:e=>ne(W(e)),[q]:(e,t,n)=>ne(R(e,t,n)),[H]:(e,t)=>ne(O(e,t)),[Q](e){X.delete(Z.get(e)),Z.delete(e)}};return e[t]=(e,t,...n)=>{switch(e){case B:n[0]=a(n[0]),n[1]=n[1].map(a);break;case I:n[0]=n[0].map(a);break;case N:{const[e,t]=n;n[0]=a(e);const{get:r,set:s,value:o}=t;r&&(t.get=a(r)),s&&(t.set=a(s)),o&&(t.value=a(o));break}default:n=n.map(a)}return o[e](a(t),...n)},e};const se=e=>typeof e===v?e():e,ae=U(((e,t)=>{if(oe in t)return se(t[oe]);if(e===v){if(!le.has(t)){let e;for(;le.has(e=String(ie++)););ce.set(t,e),le.set(e,t)}return C(e,ce.get(t))}return C(e,t)})),oe=Symbol();let ie=0;const ce=new Map,le=new Map;var fe=(e,t,n)=>{const{[t]:r}=e,s=new Map,a=new FinalizationRegistry((e=>{s.delete(e),r(Q,ae(e))})),o=e=>{const[t,n]=e;if(!s.has(n)){const r=t===v?pe.bind(e):e,o=new Proxy(r,l),i=new WeakRef(o);s.set(n,i),a.register(o,n,i)}return s.get(n).deref()},i=e=>{const[t,n]=e;switch(t){case m:return typeof n===b?o(e):n;case v:return typeof n===E?le.get(n):o(e);case P:return z(n)}return n},c=(e,t,...n)=>i(r(e,se(t),...n)),l={[B]:(e,t,n)=>c(B,e,ae(t),n.map(ae)),[I]:(e,t)=>c(I,e,t.map(ae)),[N]:(e,t,n)=>{const{get:r,set:s,value:a}=n;return typeof r===v&&(n.get=ae(r)),typeof s===v&&(n.set=ae(s)),typeof a===v&&(n.value=ae(a)),c(N,e,ae(t),n)},[j]:(e,t)=>c(j,e,ae(t)),[K]:e=>c(K,e),[D]:(e,t)=>t===oe?e:c(D,e,ae(t)),[F]:(e,t)=>{const n=c(F,e,ae(t));return n&&L(n,i)},[Y]:(e,t)=>t===oe||c(Y,e,ae(t)),[$]:e=>c($,e),[G]:e=>c(G,e).map(i),[J]:e=>c(J,e),[q]:(e,t,n)=>c(q,e,ae(t),ae(n)),[H]:(e,t)=>c(H,e,ae(t))};return e[n]=(e,t,n,r)=>{switch(e){case B:return i(t).apply(i(n),r.map(i));case Q:{const e=i(t);ce.delete(le.get(e)),le.delete(e)}}},{proxy:e,global:new Proxy([m,null],l),isGlobal:e=>typeof e===m&&!!e&&oe in e}};function pe(){return this}const ue=e+"M",ge=e+"T",ye=new WeakMap,we=(e,...t)=>{const n=d(e,...t);if(!ye.has(n)){const t=e instanceof Worker?re:fe;ye.set(n,t(n,ue,ge))}return ye.get(n)};we.transfer=d.transfer;export{we as default}; diff --git a/package.json b/package.json index d991b3b..d194d21 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "rollup:uhtml": "rollup --config rollup/uhtml.config.js", "test": "c8 node test/index.js", "server": "npx static-handler --cors --coop --coep --corp .", - "size": "cat es.js | brotli | wc -c; cat structured.js | brotli | wc -c; cat global.js | brotli | wc -c", + "size": "cat es.js | brotli | wc -c; cat structured.js | brotli | wc -c; cat global.js | brotli | wc -c; cat uhtml.js | brotli | wc -c", "coverage": "mkdir -p ./coverage; c8 report --reporter=text-lcov > ./coverage/lcov.info" }, "keywords": [ diff --git a/structured.js b/structured.js index ea173f4..da8451c 100644 --- a/structured.js +++ b/structured.js @@ -1,2 +1,2 @@ -const e="object"==typeof self?self:globalThis,t=t=>((t,n)=>{const r=(e,n)=>(t.set(n,e),e),s=a=>{if(t.has(a))return t.get(a);const[o,c]=n[a];switch(o){case 0:case-1:return r(c,a);case 1:{const e=r([],a);for(const t of c)e.push(s(t));return e}case 2:{const e=r({},a);for(const[t,n]of c)e[s(t)]=s(n);return e}case 3:return r(new Date(c),a);case 4:{const{source:e,flags:t}=c;return r(new RegExp(e,t),a)}case 5:{const e=r(new Map,a);for(const[t,n]of c)e.set(s(t),s(n));return e}case 6:{const e=r(new Set,a);for(const t of c)e.add(s(t));return e}case 7:{const{name:t,message:n}=c;return r(new e[t](n),a)}case 8:return r(BigInt(c),a);case"BigInt":return r(Object(BigInt(c)),a)}return r(new e[o](c),a)};return s})(new Map,t)(0),n="",{toString:r}={},{keys:s}=Object,a=e=>{const t=typeof e;if("object"!==t||!e)return[0,t];const s=r.call(e).slice(8,-1);switch(s){case"Array":return[1,n];case"Object":return[2,n];case"Date":return[3,n];case"RegExp":return[4,n];case"Map":return[5,n];case"Set":return[6,n]}return s.includes("Array")?[1,s]:s.includes("Error")?[7,s]:[2,s]},o=([e,t])=>0===e&&("function"===t||"symbol"===t),c=(e,{json:t,lossy:n}={})=>{const r=[];return((e,t,n,r)=>{const c=(e,t)=>{const s=r.push(e)-1;return n.set(t,s),s},u=r=>{if(n.has(r))return n.get(r);let[i,f]=a(r);switch(i){case 0:{let t=r;switch(f){case"bigint":i=8,t=r.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+f);t=null;break;case"undefined":return c([-1],r)}return c([i,t],r)}case 1:{if(f)return c([f,[...r]],r);const e=[],t=c([i,e],r);for(const t of r)e.push(u(t));return t}case 2:{if(f)switch(f){case"BigInt":return c([f,r.toString()],r);case"Boolean":case"Number":case"String":return c([f,r.valueOf()],r)}if(t&&"toJSON"in r)return u(r.toJSON());const n=[],l=c([i,n],r);for(const t of s(r))!e&&o(a(r[t]))||n.push([u(t),u(r[t])]);return l}case 3:return c([i,r.toISOString()],r);case 4:{const{source:e,flags:t}=r;return c([i,{source:e,flags:t}],r)}case 5:{const t=[],n=c([i,t],r);for(const[n,s]of r)(e||!o(a(n))&&!o(a(s)))&&t.push([u(n),u(s)]);return n}case 6:{const t=[],n=c([i,t],r);for(const n of r)!e&&o(a(n))||t.push(u(n));return n}}const{message:l}=r;return c([i,{name:f,message:l}],r)};return u})(!(t||n),!!t,new Map,r)(e),r},{parse:u,stringify:i}=JSON,f={json:!0,lossy:!0};var l=Object.freeze({__proto__:null,parse:e=>t(u(e)),stringify:e=>i(c(e,f))}),g="4c9d14a5-5462-4074-b208-d8633aa2f6e9",p=e=>({value:new Promise((t=>{let n=new Worker("data:application/javascript,"+encodeURIComponent("onmessage=({data:b})=>(Atomics.wait(b,0),postMessage(0))"));n.onmessage=t,n.postMessage(e)}))}) +const e="object"==typeof self?self:globalThis,t=t=>((t,n)=>{const r=(e,n)=>(t.set(n,e),e),s=a=>{if(t.has(a))return t.get(a);const[o,c]=n[a];switch(o){case 0:case-1:return r(c,a);case 1:{const e=r([],a);for(const t of c)e.push(s(t));return e}case 2:{const e=r({},a);for(const[t,n]of c)e[s(t)]=s(n);return e}case 3:return r(new Date(c),a);case 4:{const{source:e,flags:t}=c;return r(new RegExp(e,t),a)}case 5:{const e=r(new Map,a);for(const[t,n]of c)e.set(s(t),s(n));return e}case 6:{const e=r(new Set,a);for(const t of c)e.add(s(t));return e}case 7:{const{name:t,message:n}=c;return r(new e[t](n),a)}case 8:return r(BigInt(c),a);case"BigInt":return r(Object(BigInt(c)),a)}return r(new e[o](c),a)};return s})(new Map,t)(0),n="",{toString:r}={},{keys:s}=Object,a=e=>{const t=typeof e;if("object"!==t||!e)return[0,t];const s=r.call(e).slice(8,-1);switch(s){case"Array":return[1,n];case"Object":return[2,n];case"Date":return[3,n];case"RegExp":return[4,n];case"Map":return[5,n];case"Set":return[6,n]}return s.includes("Array")?[1,s]:s.includes("Error")?[7,s]:[2,s]},o=([e,t])=>0===e&&("function"===t||"symbol"===t),c=(e,{json:t,lossy:n}={})=>{const r=[];return((e,t,n,r)=>{const c=(e,t)=>{const s=r.push(e)-1;return n.set(t,s),s},u=r=>{if(n.has(r))return n.get(r);let[i,f]=a(r);switch(i){case 0:{let t=r;switch(f){case"bigint":i=8,t=r.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+f);t=null;break;case"undefined":return c([-1],r)}return c([i,t],r)}case 1:{if(f)return c([f,[...r]],r);const e=[],t=c([i,e],r);for(const t of r)e.push(u(t));return t}case 2:{if(f)switch(f){case"BigInt":return c([f,r.toString()],r);case"Boolean":case"Number":case"String":return c([f,r.valueOf()],r)}if(t&&"toJSON"in r)return u(r.toJSON());const n=[],l=c([i,n],r);for(const t of s(r))!e&&o(a(r[t]))||n.push([u(t),u(r[t])]);return l}case 3:return c([i,r.toISOString()],r);case 4:{const{source:e,flags:t}=r;return c([i,{source:e,flags:t}],r)}case 5:{const t=[],n=c([i,t],r);for(const[n,s]of r)(e||!o(a(n))&&!o(a(s)))&&t.push([u(n),u(s)]);return n}case 6:{const t=[],n=c([i,t],r);for(const n of r)!e&&o(a(n))||t.push(u(n));return n}}const{message:l}=r;return c([i,{name:f,message:l}],r)};return u})(!(t||n),!!t,new Map,r)(e),r},{parse:u,stringify:i}=JSON,f={json:!0,lossy:!0};var l=Object.freeze({__proto__:null,parse:e=>t(u(e)),stringify:e=>i(c(e,f))}),g="417f77a3-3f54-4e3f-95fa-50ee1cb1635d",p=e=>({value:new Promise((t=>{let n=new Worker("data:application/javascript,"+encodeURIComponent("onmessage=({data:b})=>(Atomics.wait(b,0),postMessage(0))"));n.onmessage=t,n.postMessage(e)}))}) /*! (c) Andrea Giammarchi - ISC */;const{Int32Array:w,Map:h,SharedArrayBuffer:d,Uint16Array:y}=globalThis,{BYTES_PER_ELEMENT:b}=w,{BYTES_PER_ELEMENT:m}=y,{isArray:S}=Array,{notify:E,wait:A,waitAsync:M}=Atomics,{fromCharCode:O}=String,j=(e,t)=>e?(M||p)(t,0):(A(t,0),{value:{then:e=>e()}}),v=new WeakSet,B=new WeakMap;let I=0;const _=(e,{parse:t,stringify:n}=JSON)=>{if(!B.has(e)){const r=(t,...n)=>e.postMessage({[g]:n},{transfer:t});B.set(e,new Proxy(new h,{get:(n,s)=>"then"===s?null:(...n)=>{const a=I++;let o=new w(new d(b)),c=[];v.has(n.at(-1)||c)&&v.delete(c=n.pop()),r(c,a,o,s,n);const u=e instanceof Worker;return j(u,o).value.then((()=>{const e=o[0];if(!e)return;const n=m*e;return o=new w(new d(n+n%b)),r([],a,o),j(u,o).value.then((()=>t(O(...new y(o.buffer).slice(0,e)))))}))},set(t,r,s){if(!t.size){const r=new h;e.addEventListener("message",(async e=>{const s=e.data?.[g];if(S(s)){e.stopImmediatePropagation();const[a,o,...c]=s;if(c.length){const[e,s]=c;if(!t.has(e))throw new Error(`Unsupported action: ${e}`);{const c=n(await t.get(e)(...s));c&&(r.set(a,c),o[0]=c.length)}}else{const e=r.get(a);r.delete(a);for(let t=new y(o.buffer),n=0;n_(e,l);k.transfer=_.transfer=(...e)=>(v.add(e),e);export{k as default}; diff --git a/test/input.js b/test/input.js index 2a83a4e..8bb6f72 100644 --- a/test/input.js +++ b/test/input.js @@ -1,23 +1,24 @@ -import coincident from '../global.js'; -import uhtml from './uhtml.mjs'; +import coincident from '../uhtml.js'; -const {global} = coincident(self); -const {render, html} = uhtml(global); +const {global, uhtml} = coincident(self); +const {render, html} = uhtml; const {document} = global; -input(''); +input('', handler); -function input(value) { +function input(value, handler) { render(document.body, html`
- +
${value}
`); } + +function handler(event) { + const {value} = event.target; + console.log(value); + input(value, handler); +} diff --git a/uhtml.js b/uhtml.js index 12e6619..c387202 100644 --- a/uhtml.js +++ b/uhtml.js @@ -1,3 +1,3 @@ -var e="4c9d14a5-5462-4074-b208-d8633aa2f6e9",t=e=>({value:new Promise((t=>{let n=new Worker("data:application/javascript,"+encodeURIComponent("onmessage=({data:b})=>(Atomics.wait(b,0),postMessage(0))"));n.onmessage=t,n.postMessage(e)}))}) -/*! (c) Andrea Giammarchi - ISC */;const{Int32Array:n,Map:r,SharedArrayBuffer:s,Uint16Array:a}=globalThis,{BYTES_PER_ELEMENT:o}=n,{BYTES_PER_ELEMENT:l}=a,{isArray:i}=Array,{notify:c,wait:u,waitAsync:p}=Atomics,{fromCharCode:f}=String,d=(e,n)=>e?(p||t)(n,0):(u(n,0),{value:{then:e=>e()}}),g=new WeakSet,h=new WeakMap;let y=0;const w=(t,{parse:u,stringify:p}=JSON)=>{if(!h.has(t)){const w=(n,...r)=>t.postMessage({[e]:r},{transfer:n});h.set(t,new Proxy(new r,{get:(e,r)=>"then"===r?null:(...e)=>{const i=y++;let c=new n(new s(o)),p=[];g.has(e.at(-1)||p)&&g.delete(p=e.pop()),w(p,i,c,r,e);const h=t instanceof Worker;return d(h,c).value.then((()=>{const e=c[0];if(!e)return;const t=l*e;return c=new n(new s(t+t%o)),w([],i,c),d(h,c).value.then((()=>u(f(...new a(c.buffer).slice(0,e)))))}))},set(n,s,o){if(!n.size){const s=new r;t.addEventListener("message",(async t=>{const r=t.data?.[e];if(i(r)){t.stopImmediatePropagation();const[e,o,...l]=r;if(l.length){const[t,r]=l;if(!n.has(t))throw new Error(`Unsupported action: ${t}`);{const a=p(await n.get(t)(...r));a&&(s.set(e,a),o[0]=a.length)}}else{const t=s.get(e);s.delete(e);for(let e=new a(o.buffer),n=0;n(g.add(e),e);const m="object",b="function",v="number",E="string",k="undefined",x="symbol",{defineProperty:M,getOwnPropertyDescriptor:N,getPrototypeOf:A,isExtensible:C,ownKeys:S,preventExtensions:T,set:O,setPrototypeOf:P}=Reflect,$=(e,t)=>{const{get:n,set:r,value:s}=e;return n&&(e.get=t(n)),r&&(e.set=t(r)),s&&(e.value=t(s)),e},L=(e,t)=>[e,t],W=e=>t=>{const n=typeof t;switch(n){case m:if(null==t)return L("null",t);case b:return e(n,t);case"boolean":case v:case E:case k:case"bigint":return L(n,t);case x:if(R.has(t))return L(n,R.get(t))}throw new Error(`Unable to handle this ${n} type`)},R=new Map(S(Symbol).filter((e=>typeof Symbol[e]===x)).map((e=>[Symbol[e],e]))),B=e=>{for(const[t,n]of R)if(n===e)return t},_="apply",j="construct",z="defineProperty",D="deleteProperty",U="get",F="getOwnPropertyDescriptor",H="getPrototypeOf",I="has",K="isExtensible",Y="ownKeys",G="preventExtensions",J="set",q="setPrototypeOf",Q="delete";let V=0;const X=new Map,Z=new Map,ee=new WeakMap,{addEventListener:te}=EventTarget.prototype;M(EventTarget.prototype,"addEventListener",{value(e,t,...n){return n.at(0)?.invoke&&(ee.has(this)||ee.set(this,new Map),ee.get(this).set(e,[].concat(n[0].invoke)),delete n[0].invoke),te.call(this,e,t,...n)}});const ne=W(((e,t)=>{if(!X.has(t)){let e;for(;Z.has(e=V++););X.set(t,e),Z.set(e,t)}return L(e,X.get(t))}));var re=(e,t,n)=>{const{[n]:r}=e,s=new FinalizationRegistry((e=>{r(Q,L(E,e))})),a=([e,t])=>{switch(e){case m:return null==t?globalThis:typeof t===v?Z.get(t):t;case b:if(typeof t===E){if(!Z.has(t)){const e=function(...e){return e.at(0)instanceof Event&&(e=>{const{currentTarget:t,target:n,type:r}=e;for(const s of ee.get(t||n)?.get(r)||[])e[s]()})(...e),r(_,L(b,t),ne(this),e.map(ne))},n=new WeakRef(e);Z.set(t,n),s.register(e,t,n)}return Z.get(t).deref()}return Z.get(t);case x:return B(t)}return t},o={[_]:(e,t,n)=>ne(e.apply(t,n)),[j]:(e,t)=>ne(new e(...t)),[z]:(e,t,n)=>ne(M(e,t,n)),[D]:(e,t)=>ne(delete e[t]),[H]:e=>ne(A(e)),[U]:(e,t)=>ne(e[t]),[F]:(e,t)=>{const n=N(e,t);return n?L(m,$(n,ne)):L(k,n)},[I]:(e,t)=>ne(t in e),[K]:e=>ne(C(e)),[Y]:e=>L(m,S(e).map(ne)),[G]:e=>ne(T(e)),[J]:(e,t,n)=>ne(O(e,t,n)),[q]:(e,t)=>ne(P(e,t)),[Q](e){X.delete(Z.get(e)),Z.delete(e)}};return e[t]=(e,t,...n)=>{switch(e){case _:n[0]=a(n[0]),n[1]=n[1].map(a);break;case j:n[0]=n[0].map(a);break;case z:{const[e,t]=n;n[0]=a(e);const{get:r,set:s,value:o}=t;r&&(t.get=a(r)),s&&(t.set=a(s)),o&&(t.value=a(o));break}default:n=n.map(a)}return o[e](a(t),...n)},e};const se=e=>typeof e===b?e():e,ae=W(((e,t)=>{if(oe in t)return se(t[oe]);if(e===b){if(!ce.has(t)){let e;for(;ce.has(e=String(le++)););ie.set(t,e),ce.set(e,t)}return L(e,ie.get(t))}return L(e,t)})),oe=Symbol();let le=0;const ie=new Map,ce=new Map;var ue=(e,t,n)=>{const{[t]:r}=e,s=new Map,a=new FinalizationRegistry((e=>{s.delete(e),r(Q,ae(e))})),o=e=>{const[t,n]=e;if(!s.has(n)){const r=t===b?pe.bind(e):e,o=new Proxy(r,c),l=new WeakRef(o);s.set(n,l),a.register(o,n,l)}return s.get(n).deref()},l=e=>{const[t,n]=e;switch(t){case m:return typeof n===v?o(e):n;case b:return typeof n===E?ce.get(n):o(e);case x:return B(n)}return n},i=(e,t,...n)=>l(r(e,se(t),...n)),c={[_]:(e,t,n)=>i(_,e,ae(t),n.map(ae)),[j]:(e,t)=>i(j,e,t.map(ae)),[z]:(e,t,n)=>{const{get:r,set:s,value:a}=n;return typeof r===b&&(n.get=ae(r)),typeof s===b&&(n.set=ae(s)),typeof a===b&&(n.value=ae(a)),i(z,e,ae(t),n)},[D]:(e,t)=>i(D,e,ae(t)),[H]:e=>i(H,e),[U]:(e,t)=>t===oe?e:i(U,e,ae(t)),[F]:(e,t)=>{const n=i(F,e,ae(t));return n&&$(n,l)},[I]:(e,t)=>t===oe||i(I,e,ae(t)),[K]:e=>i(K,e),[Y]:e=>i(Y,e).map(l),[G]:e=>i(G,e),[J]:(e,t,n)=>i(J,e,ae(t),ae(n)),[q]:(e,t)=>i(q,e,ae(t))};return e[n]=(e,t,n,r)=>{switch(e){case _:return l(t).apply(l(n),r.map(l));case Q:{const e=l(t);ie.delete(ce.get(e)),ce.delete(e)}}},{proxy:e,global:new Proxy([m,null],c),isGlobal:e=>typeof e===m&&!!e&&oe in e}};function pe(){return this}const fe=e+"M",de=e+"T",ge=new WeakMap,he=(e,...t)=>{const n=w(e,...t);if(!ge.has(n)){const t=e instanceof Worker?re:ue;ge.set(n,t(n,fe,de))}return ge.get(n)};he.transfer=w.transfer;class ye extends WeakMap{set(e,t){return super.set(e,t),t}} -/*! (c) Andrea Giammarchi - ISC */const we=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,me=/<([a-z]+[a-z0-9:._-]*)([^>]*?)(\/?)>/g,be=/([^\s\\>"'=]+)\s*=\s*(['"]?)\x01/g,ve=/[\x01\x02]/g;var Ee=({document:e})=>{const{isArray:t,prototype:n}=Array,{indexOf:r}=n,{createDocumentFragment:s,createElement:a,createElementNS:o,createTextNode:l,createTreeWalker:i,importNode:c}=new Proxy({},{get:(t,n)=>e[n].bind(e)});let u;const p=(e,t)=>t?(e=>{u||(u=o("http://www.w3.org/2000/svg","svg")),u.innerHTML=e;const t=s();return t.append(...u.childNodes),t})(e):(e=>{const t=a("template");return t.innerHTML=e,t.content})(e),f=(t,n)=>111===t.nodeType?1/n<0?n?(({firstChild:t,lastChild:n})=>{const r=e.createRange();return r.setStartAfter(t),r.setEndAfter(n),r.deleteContents(),t})(t):t.lastChild:n?t.valueOf():t.firstChild:t,d=e=>null==e?e:e.valueOf(),g=(e,n)=>{let r,s,a=n.slice(2);return!(n in e)&&(s=n.toLowerCase())in e&&(a=s.slice(2)),n=>{const s=t(n)?n:[n,!1];r!==s[0]&&(r&&e.removeEventListener(a,r,s[1]),(r=s[0])&&e.addEventListener(a,r,s[1]))}},h=({childNodes:e},t)=>e[t],y=(e,t,n)=>((e,t,n,r,s)=>{const a=n.length;let o=t.length,l=a,i=0,c=0,u=null;for(;is-c){const a=r(t[i],0);for(;c{switch(n[0]){case"?":return((e,t,n)=>r=>{const s=!!d(r);n!==s&&((n=s)?e.setAttribute(t,""):e.removeAttribute(t))})(t,n.slice(1),!1);case".":return((e,t)=>"dataset"===t?(({dataset:e})=>t=>{for(const n in t){const r=t[n];null==r?delete e[n]:e[n]=r}})(e):n=>{e[t]=n})(t,n.slice(1));case"@":return g(t,"on"+n.slice(1));case"o":if("n"===n[1])return g(t,n)}switch(n){case"ref":return(e=>{let t;return n=>{t!==n&&(t=n,"function"==typeof n?n(e):n.current=e)}})(t);case"aria":return(e=>t=>{for(const n in t){const r="role"===n?n:`aria-${n}`,s=t[n];null==s?e.removeAttribute(r):e.setAttribute(r,s)}})(t)}return((t,n)=>{let r,s=!0;const a=e.createAttributeNS(null,n);return e=>{const n=d(e);r!==n&&(null==(r=n)?s||(t.removeAttributeNode(a),s=!0):(a.value=n,s&&(t.setAttributeNodeNS(a),s=!1)))}})(t,n)};function m(e){const{type:n,path:r}=e,s=r.reduceRight(h,this);return"node"===n?(e=>{let n,r,s=[];const a=o=>{switch(typeof o){case"string":case"number":case"boolean":n!==o&&(n=o,r||(r=l("")),r.data=o,s=y(e,s,[r]));break;case"object":case"undefined":if(null==o){n!=o&&(n=o,s=y(e,s,[]));break}if(t(o)){n=o,0===o.length?s=y(e,s,[]):"object"==typeof o[0]?s=y(e,s,o):a(String(o));break}if(n!==o)if("ELEMENT_NODE"in o)n=o,s=y(e,s,11===o.nodeType?[...o.childNodes]:[o]);else{const e=o.valueOf();e!==o&&a(e)}break;case"function":a(o(e))}};return a})(s):"attr"===n?w(s,e.name):(e=>{let t;return n=>{const r=d(n);t!=r&&(t=r,e.textContent=null==r?"":r)}})(s)}const b=e=>{const t=[];let{parentNode:n}=e;for(;n;)t.push(r.call(n.childNodes,e)),e=n,({parentNode:n}=e);return t},v="isµ",E=new ye,k=/^(?:textarea|script|style|title|plaintext|xmp)$/,x=(e,t)=>{const n="svg"===e,r=((e,t,n)=>{let r=0;return e.join("").trim().replace(me,((e,t,r,s)=>{let a=t+r.replace(be,"=$2$1").trimEnd();return s.length&&(a+=n||we.test(t)?" /":">"})).replace(ve,(e=>""===e?"\x3c!--"+t+r+++"--\x3e":t+r++))})(t,v,n),s=p(r,n),a=i(s,129),o=[],l=t.length-1;let c=0,u=`${v}${c}`;for(;c{const{content:n,nodes:r}=E.get(t)||E.set(t,x(e,t)),s=c(n,!0);return{content:s,updates:r.map(m,s)}},N=(e,{type:t,template:n,values:r})=>{const s=A(e,r);let{entry:a}=e;a&&a.template===n&&a.type===t||(e.entry=a=((e,t)=>{const{content:n,updates:r}=M(e,t);return{type:e,template:t,content:n,updates:r,wire:null}})(t,n));const{content:o,updates:l,wire:i}=a;for(let e=0;e{const{firstChild:t,lastChild:n}=e;if(t===n)return n||e;const{childNodes:r}=e,s=[...r];return{ELEMENT_NODE:1,nodeType:111,firstChild:t,lastChild:n,valueOf:()=>(r.length!==s.length&&e.append(...s),e)}})(o))},A=({stack:e},n)=>{const{length:r}=n;for(let s=0;s{const t=new ye;return Object.assign(((t,...n)=>new C(e,t,n)),{for(n,r){const s=t.get(n)||t.set(n,new MapSet);return s.get(r)||s.set(r,(t=>(n,...r)=>N(t,{type:e,template:n,values:r}))({stack:[],entry:null,wire:null}))},node:(t,...n)=>N({stack:[],entry:null,wire:null},new C(e,t,n)).valueOf()})},T=new ye,O=S("html"),P=S("svg");return{Hole:C,render:(e,t)=>{const n="function"==typeof t?t():t,r=T.get(e)||T.set(e,{stack:[],entry:null,wire:null}),s=n instanceof C?N(r,n):n;return s!==r.wire&&(r.wire=s,e.replaceChildren(s.valueOf())),e},html:O,svg:P}};const ke=(e,...t)=>{const n=he(e,...t);return e instanceof Worker||(n.uhtml=Ee(n.global)),n};ke.transfer=he.transfer;export{ke as default}; +var e="417f77a3-3f54-4e3f-95fa-50ee1cb1635d",t=e=>({value:new Promise((t=>{let n=new Worker("data:application/javascript,"+encodeURIComponent("onmessage=({data:b})=>(Atomics.wait(b,0),postMessage(0))"));n.onmessage=t,n.postMessage(e)}))}) +/*! (c) Andrea Giammarchi - ISC */;const{Int32Array:n,Map:r,SharedArrayBuffer:s,Uint16Array:a}=globalThis,{BYTES_PER_ELEMENT:o}=n,{BYTES_PER_ELEMENT:l}=a,{isArray:i}=Array,{notify:c,wait:u,waitAsync:f}=Atomics,{fromCharCode:p}=String,d=(e,n)=>e?(f||t)(n,0):(u(n,0),{value:{then:e=>e()}}),g=new WeakSet,h=new WeakMap;let y=0;const w=(t,{parse:u,stringify:f}=JSON)=>{if(!h.has(t)){const w=(n,...r)=>t.postMessage({[e]:r},{transfer:n});h.set(t,new Proxy(new r,{get:(e,r)=>"then"===r?null:(...e)=>{const i=y++;let c=new n(new s(o)),f=[];g.has(e.at(-1)||f)&&g.delete(f=e.pop()),w(f,i,c,r,e);const h=t instanceof Worker;return d(h,c).value.then((()=>{const e=c[0];if(!e)return;const t=l*e;return c=new n(new s(t+t%o)),w([],i,c),d(h,c).value.then((()=>u(p(...new a(c.buffer).slice(0,e)))))}))},set(n,s,o){if(!n.size){const s=new r;t.addEventListener("message",(async t=>{const r=t.data?.[e];if(i(r)){t.stopImmediatePropagation();const[e,o,...l]=r;if(l.length){const[t,r]=l;if(!n.has(t))throw new Error(`Unsupported action: ${t}`);{const a=f(await n.get(t)(...r));a&&(s.set(e,a),o[0]=a.length)}}else{const t=s.get(e);s.delete(e);for(let e=new a(o.buffer),n=0;n(g.add(e),e);const m="object",b="function",v="number",E="string",k="undefined",x="symbol",{defineProperty:M,getOwnPropertyDescriptor:N,getPrototypeOf:A,isExtensible:C,ownKeys:S,preventExtensions:T,set:O,setPrototypeOf:P}=Reflect,$=(e,t)=>{const{get:n,set:r,value:s}=e;return n&&(e.get=t(n)),r&&(e.set=t(r)),s&&(e.value=t(s)),e},L=(e,t)=>[e,t],W=e=>t=>{const n=typeof t;switch(n){case m:if(null==t)return L("null",t);case b:return e(n,t);case"boolean":case v:case E:case k:case"bigint":return L(n,t);case x:if(R.has(t))return L(n,R.get(t))}throw new Error(`Unable to handle this ${n} type`)},R=new Map(S(Symbol).filter((e=>typeof Symbol[e]===x)).map((e=>[Symbol[e],e]))),B=e=>{for(const[t,n]of R)if(n===e)return t},_="apply",j="construct",z="defineProperty",D="deleteProperty",U="get",F="getOwnPropertyDescriptor",H="getPrototypeOf",I="has",K="isExtensible",Y="ownKeys",G="preventExtensions",J="set",q="setPrototypeOf",Q="delete";let V=0;const X=new Map,Z=new Map,ee=new WeakMap,{addEventListener:te}=EventTarget.prototype;M(EventTarget.prototype,"addEventListener",{value(e,t,...n){return n.at(0)?.invoke&&(ee.has(this)||ee.set(this,new Map),ee.get(this).set(e,[].concat(n[0].invoke)),delete n[0].invoke),te.call(this,e,t,...n)}});const ne=W(((e,t)=>{if(!X.has(t)){let e;for(;Z.has(e=V++););X.set(t,e),Z.set(e,t)}return L(e,X.get(t))}));var re=(e,t,n)=>{const{[n]:r}=e,s=new FinalizationRegistry((e=>{r(Q,L(E,e))})),a=([e,t])=>{switch(e){case m:return null==t?globalThis:typeof t===v?Z.get(t):t;case b:if(typeof t===E){if(!Z.has(t)){const e=function(...e){return e.at(0)instanceof Event&&(e=>{const{currentTarget:t,target:n,type:r}=e;for(const s of ee.get(t||n)?.get(r)||[])e[s]()})(...e),r(_,L(b,t),ne(this),e.map(ne))},n=new WeakRef(e);Z.set(t,n),s.register(e,t,n)}return Z.get(t).deref()}return Z.get(t);case x:return B(t)}return t},o={[_]:(e,t,n)=>ne(e.apply(t,n)),[j]:(e,t)=>ne(new e(...t)),[z]:(e,t,n)=>ne(M(e,t,n)),[D]:(e,t)=>ne(delete e[t]),[H]:e=>ne(A(e)),[U]:(e,t)=>ne(e[t]),[F]:(e,t)=>{const n=N(e,t);return n?L(m,$(n,ne)):L(k,n)},[I]:(e,t)=>ne(t in e),[K]:e=>ne(C(e)),[Y]:e=>L(m,S(e).map(ne)),[G]:e=>ne(T(e)),[J]:(e,t,n)=>ne(O(e,t,n)),[q]:(e,t)=>ne(P(e,t)),[Q](e){X.delete(Z.get(e)),Z.delete(e)}};return e[t]=(e,t,...n)=>{switch(e){case _:n[0]=a(n[0]),n[1]=n[1].map(a);break;case j:n[0]=n[0].map(a);break;case z:{const[e,t]=n;n[0]=a(e);const{get:r,set:s,value:o}=t;r&&(t.get=a(r)),s&&(t.set=a(s)),o&&(t.value=a(o));break}default:n=n.map(a)}return o[e](a(t),...n)},e};const se=e=>typeof e===b?e():e,ae=W(((e,t)=>{if(oe in t)return se(t[oe]);if(e===b){if(!ce.has(t)){let e;for(;ce.has(e=String(le++)););ie.set(t,e),ce.set(e,t)}return L(e,ie.get(t))}return L(e,t)})),oe=Symbol();let le=0;const ie=new Map,ce=new Map;var ue=(e,t,n)=>{const{[t]:r}=e,s=new Map,a=new FinalizationRegistry((e=>{s.delete(e),r(Q,ae(e))})),o=e=>{const[t,n]=e;if(!s.has(n)){const r=t===b?fe.bind(e):e,o=new Proxy(r,c),l=new WeakRef(o);s.set(n,l),a.register(o,n,l)}return s.get(n).deref()},l=e=>{const[t,n]=e;switch(t){case m:return typeof n===v?o(e):n;case b:return typeof n===E?ce.get(n):o(e);case x:return B(n)}return n},i=(e,t,...n)=>l(r(e,se(t),...n)),c={[_]:(e,t,n)=>i(_,e,ae(t),n.map(ae)),[j]:(e,t)=>i(j,e,t.map(ae)),[z]:(e,t,n)=>{const{get:r,set:s,value:a}=n;return typeof r===b&&(n.get=ae(r)),typeof s===b&&(n.set=ae(s)),typeof a===b&&(n.value=ae(a)),i(z,e,ae(t),n)},[D]:(e,t)=>i(D,e,ae(t)),[H]:e=>i(H,e),[U]:(e,t)=>t===oe?e:i(U,e,ae(t)),[F]:(e,t)=>{const n=i(F,e,ae(t));return n&&$(n,l)},[I]:(e,t)=>t===oe||i(I,e,ae(t)),[K]:e=>i(K,e),[Y]:e=>i(Y,e).map(l),[G]:e=>i(G,e),[J]:(e,t,n)=>i(J,e,ae(t),ae(n)),[q]:(e,t)=>i(q,e,ae(t))};return e[n]=(e,t,n,r)=>{switch(e){case _:return l(t).apply(l(n),r.map(l));case Q:{const e=l(t);ie.delete(ce.get(e)),ce.delete(e)}}},{proxy:e,global:new Proxy([m,null],c),isGlobal:e=>typeof e===m&&!!e&&oe in e}};function fe(){return this}const pe=e+"M",de=e+"T",ge=new WeakMap,he=(e,...t)=>{const n=w(e,...t);if(!ge.has(n)){const t=e instanceof Worker?re:ue;ge.set(n,t(n,pe,de))}return ge.get(n)};he.transfer=w.transfer;class ye extends WeakMap{set(e,t){return super.set(e,t),t}} +/*! (c) Andrea Giammarchi - ISC */const we=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,me=/<([a-z]+[a-z0-9:._-]*)([^>]*?)(\/?)>/g,be=/([^\s\\>"'=]+)\s*=\s*(['"]?)\x01/g,ve=/[\x01\x02]/g;var Ee=({document:e})=>{const{isArray:t,prototype:n}=Array,{indexOf:r}=n,{createDocumentFragment:s,createElement:a,createElementNS:o,createTextNode:l,createTreeWalker:i,importNode:c}=new Proxy({},{get:(t,n)=>e[n].bind(e)});let u;const f=(e,t)=>t?(e=>{u||(u=o("http://www.w3.org/2000/svg","svg")),u.innerHTML=e;const t=s();return t.append(...u.childNodes),t})(e):(e=>{const t=a("template");return t.innerHTML=e,t.content})(e),p=(t,n)=>111===t.nodeType?1/n<0?n?(({firstChild:t,lastChild:n})=>{const r=e.createRange();return r.setStartAfter(t),r.setEndAfter(n),r.deleteContents(),t})(t):t.lastChild:n?t.valueOf():t.firstChild:t,d=e=>null==e?e:e.valueOf(),g=(e,n)=>{let r,s,a=n.slice(2);return!(n in e)&&(s=n.toLowerCase())in e&&(a=s.slice(2)),n=>{const s=t(n)?n:[n,!1];r!==s[0]&&(r&&e.removeEventListener(a,r,s[1]),(r=s[0])&&e.addEventListener(a,r,s[1]))}},h=({childNodes:e},t)=>e[t],y=(e,t,n)=>((e,t,n,r,s)=>{const a=n.length;let o=t.length,l=a,i=0,c=0,u=null;for(;is-c){const a=r(t[i],0);for(;c{switch(n[0]){case"?":return((e,t,n)=>r=>{const s=!!d(r);n!==s&&((n=s)?e.setAttribute(t,""):e.removeAttribute(t))})(t,n.slice(1),!1);case".":return((e,t)=>"dataset"===t?(({dataset:e})=>t=>{for(const n in t){const r=t[n];null==r?delete e[n]:e[n]=r}})(e):n=>{e[t]=n})(t,n.slice(1));case"@":return g(t,"on"+n.slice(1));case"o":if("n"===n[1])return g(t,n)}switch(n){case"ref":return(e=>{let t;return n=>{t!==n&&(t=n,"function"==typeof n?n(e):n.current=e)}})(t);case"aria":return(e=>t=>{for(const n in t){const r="role"===n?n:`aria-${n}`,s=t[n];null==s?e.removeAttribute(r):e.setAttribute(r,s)}})(t)}return((t,n)=>{let r,s=!0;const a=e.createAttributeNS(null,n);return e=>{const n=d(e);r!==n&&(null==(r=n)?s||(t.removeAttributeNode(a),s=!0):(a.value=n,s&&(t.setAttributeNodeNS(a),s=!1)))}})(t,n)};function m(e){const{type:n,path:r}=e,s=r.reduceRight(h,this);return"node"===n?(e=>{let n,r,s=[];const a=o=>{switch(typeof o){case"string":case"number":case"boolean":n!==o&&(n=o,r||(r=l("")),r.data=o,s=y(e,s,[r]));break;case"object":case"undefined":if(null==o){n!=o&&(n=o,s=y(e,s,[]));break}if(t(o)){n=o,0===o.length?s=y(e,s,[]):"object"==typeof o[0]?s=y(e,s,o):a(String(o));break}if(n!==o)if("ELEMENT_NODE"in o)n=o,s=y(e,s,11===o.nodeType?[...o.childNodes]:[o]);else{const e=o.valueOf();e!==o&&a(e)}break;case"function":a(o(e))}};return a})(s):"attr"===n?w(s,e.name):(e=>{let t;return n=>{const r=d(n);t!=r&&(t=r,e.textContent=null==r?"":r)}})(s)}const b=e=>{const t=[];let{parentNode:n}=e;for(;n;)t.push(r.call(n.childNodes,e)),e=n,({parentNode:n}=e);return t},v="isµ",E=new ye,k=/^(?:textarea|script|style|title|plaintext|xmp)$/,x=(e,t)=>{const n="svg"===e,r=((e,t,n)=>{let r=0;return e.join("").trim().replace(me,((e,t,r,s)=>{let a=t+r.replace(be,"=$2$1").trimEnd();return s.length&&(a+=n||we.test(t)?" /":">"})).replace(ve,(e=>""===e?"\x3c!--"+t+r+++"--\x3e":t+r++))})(t,v,n),s=f(r,n),a=i(s,129),o=[],l=t.length-1;let c=0,u=`${v}${c}`;for(;c{const{content:n,nodes:r}=E.get(t)||E.set(t,x(e,t)),s=c(n,!0);return{content:s,updates:r.map(m,s)}},N=(e,{type:t,template:n,values:r})=>{const s=A(e,r);let{entry:a}=e;a&&a.template===n&&a.type===t||(e.entry=a=((e,t)=>{const{content:n,updates:r}=M(e,t);return{type:e,template:t,content:n,updates:r,wire:null}})(t,n));const{content:o,updates:l,wire:i}=a;for(let e=0;e{const{firstChild:t,lastChild:n}=e;if(t===n)return n||e;const{childNodes:r}=e,s=[...r];return{ELEMENT_NODE:1,nodeType:111,firstChild:t,lastChild:n,valueOf:()=>(r.length!==s.length&&e.append(...s),e)}})(o))},A=({stack:e},n)=>{const{length:r}=n;for(let s=0;s{const t=new ye;return Object.assign(((t,...n)=>new C(e,t,n)),{for(n,r){const s=t.get(n)||t.set(n,new MapSet);return s.get(r)||s.set(r,(t=>(n,...r)=>N(t,{type:e,template:n,values:r}))({stack:[],entry:null,wire:null}))},node:(t,...n)=>N({stack:[],entry:null,wire:null},new C(e,t,n)).valueOf()})},T=new ye,O=S("html"),P=S("svg");return{Hole:C,render:(e,t)=>{const n="function"==typeof t?t():t,r=T.get(e)||T.set(e,{stack:[],entry:null,wire:null}),s=n instanceof C?N(r,n):n;return s!==r.wire&&(r.wire=s,e.replaceChildren(s.valueOf())),e},html:O,svg:P}};const ke=(e,...t)=>{const n=he(e,...t);return e instanceof Worker||(n.uhtml=Ee(n.global)),n};ke.transfer=he.transfer;export{ke as default};