@webqit/oohtml 2.1.1 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/context-api.js +1 -1
- package/dist/context-api.js.map +3 -3
- package/dist/html-imports.js +1 -1
- package/dist/html-imports.js.map +2 -2
- package/dist/html-modules.js +1 -1
- package/dist/html-modules.js.map +2 -2
- package/dist/main.js +7 -7
- package/dist/main.js.map +2 -2
- package/dist/scoped-js.js +7 -7
- package/dist/scoped-js.js.map +2 -2
- package/package.json +1 -1
- package/src/context-api/index.js +4 -0
- package/src/html-imports/index.js +7 -5
- package/src/html-modules/index.js +9 -7
- package/src/scoped-js/index.js +16 -9
- package/src/scoped-js/targets.browser.js +3 -2
package/dist/context-api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(()=>{function x(r){return!Array.isArray(r)&&typeof r=="object"&&r}function H(r,...e){globalThis.WebQitInternalsRegistry||(globalThis.WebQitInternalsRegistry=new Map);var n=globalThis.WebQitInternalsRegistry.get(r);if(!n){if(n=new Map,e[0]===!1)return n;globalThis.WebQitInternalsRegistry.set(r,n)}for(var t,i;t=e.shift();)if((i=n)&&!(n=n.get(t))){if(n=new Map,e[0]===!1)return n;i.set(t,n)}return n}function g(r){return Array.isArray(r)}function L(r){return typeof r=="function"}function D(r){return r===null||r===""}function T(r){return arguments.length&&(r===void 0||typeof r>"u")}function v(r){return Array.isArray(r)||typeof r=="object"&&r||L(r)}function z(r){return D(r)||T(r)||r===!1||r===0||v(r)&&!Object.keys(r).length}function w(r){return L(r)||r&&{}.toString.call(r)==="[object function]"}function N(r){return r instanceof Number||typeof r=="number"}function E(r){return N(r)||r!==!0&&r!==!1&&r!==null&&r!==""&&!isNaN(r*1)}function j(r){return r instanceof String||typeof r=="string"&&r!==null}function J(r){return!j(r)&&!T(r.length)}function W(r,...e){return e.forEach(n=>{r.indexOf(n)<0&&r.push(n)}),r}function Q(t,e){e=e||Object.prototype,e=e&&!g(e)?[e]:e;for(var n=[],t=t;t&&(!e||e.indexOf(t)<0)&&t.name!=="default";)n.push(t),t=t?Object.getPrototypeOf(t):null;return n}function X(r,e){var n=[];return Q(r,e).forEach(t=>{W(n,...Object.getOwnPropertyNames(t))}),n}function C(r,e,n=!1,t=!1,i=!1){var o=0,s=r.shift();if((E(s)||s===!0||s===!1)&&(o=s,s=r.shift()),!r.length)throw new Error("_merge() requires two or more array/objects.");return r.forEach((l,a)=>{!v(l)&&!w(l)||(n?X(l):Object.keys(l)).forEach(c=>{if(!!e(c,s,l,a)){var f=s[c],u=l[c];if((g(f)&&g(u)||x(f)&&x(u))&&(o===!0||o>0))s[c]=g(f)&&g(u)?[]:{},C([E(o)?o-1:o,s[c],f,u],e,n,t,i);else if(g(s)&&g(l))t?s[c]=u:s.push(u);else try{i?Object.defineProperty(s,c,Object.getOwnPropertyDescriptor(l,c)):s[c]=l[c]}catch{}}})}),s}function $(...r){return C(r,(e,n,t)=>!0,!1,!1,!1)}function O(r,e=!0){return g(r)?r:!e&&x(r)?[r]:r!==!1&&r!==0&&z(r)?[]:J(r)?Array.prototype.slice.call(r):x(r)?Object.values(r):[r]}function q(r,e,n={},t={}){e=O(e).slice();for(var i=r;!T(i)&&!D(i)&&e.length;){var o=e.shift();if(!(n.get?n.get(i,o):v(i)?o in i:i[o])){t.exists=!1;return}i=n.get?n.get(i,o):i[o]}return t.exists=!0,i}function Z(r,e,n,t={},i={}){let o=(f,u,d)=>i.set?i.set(f,u,d):(E(e[l])&&g(f)?f.push(d):f[u]=d,!0);e=O(e);for(var s=r,l=0;l<e.length;l++)if(l<e.length-1){if(!s||!v(s)&&!w(s))return!1;var a=q(s,e[l],i);if(!v(a)){if(i.buildTree===!1)return!1;a=w(i.buildTree)?i.buildTree(l):E(e[l+1])?[]:{};var c=o(s,e[l],a);if(!c)return!1}s=a}else return o(s,e[l],n)}var oe=r=>class{constructor(n=!0){Object.defineProperty(this,"window",{value:r}),Object.defineProperty(this,"readCallbacks",{value:new Set}),Object.defineProperty(this,"writeCallbacks",{value:new Set}),this.async=n,this.window.requestAnimationFrame?this._run():this.async=!1}_run(){this.window.requestAnimationFrame(()=>{this.readCallbacks.forEach(n=>{n()||this.readCallbacks.delete(n)}),this.writeCallbacks.forEach(n=>{n()||this.writeCallbacks.delete(n)}),this._run()})}onread(n,t=!1){if(t)return new Promise((i,o)=>{this.async===!1?n(i,o):this.readCallbacks.add(()=>{n(i,o)})});this.async===!1?n():this.readCallbacks.add(n)}onwrite(n,t=!1){if(t)return new Promise((i,o)=>{this.async===!1?n(i,o):this.writeCallbacks.add(()=>{n(i,o)})});this.async===!1?n():this.writeCallbacks.add(n)}cycle(n,t,i){this.onread(()=>{let o=n(i),s=l=>{l!==void 0&&this.onwrite(()=>{let a=t(l,i),c=f=>{f!==void 0&&this.cycle(n,t,f)};a instanceof Promise?a.then(c):c(a)})};o instanceof Promise?o.then(s):s(o)})}};var P=class{constructor(e,n,t){this.context=e,this.namespace=n,this.window=e.defaultView||e.ownerDocument?.defaultView||t,this.document=this.window.document,this.wq=this.window.wq,Object.defineProperty(this,"#",{value:{}})}resolveArgs(e){return w(e[0])?e=[[],...e]:x(e[0])&&e.length===1?e=[[],void 0,e[0]]:x(e[1])&&e.length===2?e=[O(e[0],!1),void 0,e[1]]:e[0]=O(e[0],!1),e}registry(...e){return H(this.window,"dom.realtime",this.namespace,...e)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(e,n,t){let{window:i}=this,o=Array.isArray(n)?n:[n],s=new Set;for(let[l,a]of this.registry(e))for(let[c,f]of a){let u=o.filter(d=>c.contains(d.target)?l==="subtree"||d.target===c:!1);if(!!u.length){Array.isArray(n)||(u=u[0]);for(let d of f)s.add([d,u,c])}}for(let[l,a,c]of s)t.call(this,l,a,c)}disconnectables(e,...n){let t={disconnect(){n.forEach(i=>i&&w(i.disconnect)&&i.disconnect()||w(i)&&i()||x(i)&&(i.disconnected=!0))}};return e&&e.addEventListener("abort",()=>t.disconnect()),t}};var S=class extends P{constructor(e,...n){super(e,"attr",...n)}get(e,n=void 0,t={}){let i=typeof e=="string";[e=[],n=void 0,t={}]=this.resolveArgs(arguments);let{context:o}=this,s=me(o,e),l=i?s[0]:s;if(!n)return l;let a=n&&t.lifecycleSignals&&this.createSignalGenerator(),c=a?.generate()||{};if(n(l,c,o),t.live){a&&(t={...t,signalGenerator:a});let f=this.observe(i?e[0]:e,n,{newValue:!0,...t});return this.disconnectables(t.signal,f)}}observe(e,n,t={}){let i=typeof e=="string";if([e=[],n,t={}]=this.resolveArgs(arguments),["sync","intercept"].includes(t.timing))return this.observeSync(i?e[0]:e,n,t);if(t.timing&&t.timing!=="async")throw new Error(`Timing option "${t.timing}" invalid.`);let{context:o,window:s,wq:l}=this;t.eventDetails&&!l.attrInterceptionHooks?.intercepting&&ce.call(s,"intercept",()=>{});let a=new s.MutationObserver(d=>{d=le(d).map(_=>ae.call(s,_)),ue.call(s,u,d,o)}),c={attributes:!0,attributeOldValue:t.oldValue,subtree:t.subtree};e.length&&(c.attributeFilter=e),a.observe(o,c);let f=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),u={context:o,filter:e,callback:n,params:t,atomics:new Map,originalFilterIsString:i,signalGenerator:f,disconnectable:a};return this.disconnectables(t.signal,a,f)}observeSync(e,n,t={}){let i=typeof e=="string";[e,n,t={}]=this.resolveArgs(arguments);let{context:o,window:s}=this;if(t.timing&&!["sync","intercept"].includes(t.timing))throw new Error(`Timing option "${t.timing}" invalid.`);let l=t.timing==="intercept"?"intercept":"sync",a=t.subtree?"subtree":"children";this.registry(l).size||ce.call(s,l,m=>{this.forEachMatchingContext(l,m,ue)});let c={disconnect(){_.delete(u),_.size||d.delete(o)}},f=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),u={context:o,filter:e,callback:n,params:t,atomics:new Map,originalFilterIsString:i,signalGenerator:f,disconnectable:c},d=this.registry(l,a);d.has(o)||d.set(o,new Set);let _=d.get(o);return _.add(u),this.disconnectables(t.signal,c,f)}};function le(r){return r.reduce((e,n,t)=>e[t-1]?.attributeName===n.attributeName?e:e.concat(n),[])}function ue(r,e){let{context:n,filter:t,callback:i,params:o,atomics:s,originalFilterIsString:l,signalGenerator:a}=r;o.atomic&&!s.size&&(e=me(n,t,e)),o.newValue===null&&o.oldValue===null||(e=e.map(u=>{let d;return!o.oldValue&&"oldValue"in u&&({oldValue:d,...u}=u),!o.newValue&&"value"in u?{value:d,...u}=u:o.newValue&&typeof u.value>"u"&&(u={...u,value:u.target.getAttribute(u.name)}),u})),o.atomic&&(e.forEach(u=>s.set(u.name,u)),e=Array.from(s.entries()).map(([,u])=>u));let c=l?e[0]:e,f=a?.generate()||{};i(c,f,n)}function me(r,e,n=[]){let t={event:null,type:"attribute"};return e.length?e.map(o=>n.find(s=>s.name===o)||{target:r,name:o,value:r.getAttribute(o),...t}):Array.from(r.attributes).map(o=>n.find(s=>s.name===o.nodeName)||{target:r,name:o.nodeName,value:o.nodeValue,...t})}function ae({target:r,attributeName:e,value:n,oldValue:t}){let s=(this.wq.attrInterceptionRecords?.get(r)||{})[e]||"mutation";return{target:r,name:e,value:n,oldValue:t,type:"observation",event:s}}function ce(r,e){let n=this,{wq:t,document:i,Element:o}=n;t.attrInterceptionHooks||(t.attrInterceptionHooks=new Map),t.attrInterceptionHooks.has(r)||t.attrInterceptionHooks.set(r,new Set),t.attrInterceptionHooks.get(r).add(e);let s=()=>t.attrInterceptionHooks.get(r).delete(e);if(t.attrInterceptionHooks?.intercepting)return s;console.warn("Attr mutation APIs are now being intercepted."),t.attrInterceptionHooks.intercepting=!0,t.attrInterceptionRecords=new Map;let l=(f,u)=>{t.attrInterceptionRecords.has(f.target)||t.attrInterceptionRecords.set(f.target,{});let d=t.attrInterceptionRecords.get(f.target);clearTimeout(d[f.name]?.timeout),d[f.name]=f.event;let _=setTimeout(()=>{delete d[f.name]},0);Object.defineProperty(f.event,"timeout",{value:_,configurable:!0}),t.attrInterceptionHooks.get("intercept")?.forEach(h=>h([f]));let m=u();return t.attrInterceptionHooks.get("sync")?.forEach(h=>h([f])),m};new n.MutationObserver(f=>{f=le(f).map(u=>ae.call(n,u)).filter((u,d)=>!Array.isArray(u.event)),f.length&&(t.attrInterceptionHooks.get("intercept")?.forEach(u=>u(f)),t.attrInterceptionHooks.get("sync")?.forEach(u=>u(f)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let c=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(f=>{c[f]=o.prototype[f],o.prototype[f]=function(...u){let d,_=this.getAttribute(u[0]);["setAttribute","toggleAttribute"].includes(f)&&(d=u[1]),f==="toggleAttribute"&&d===void 0&&(d=_===null);let m={target:this,name:u[0],value:d,oldValue:_,type:"interception",event:[this,f]};return l(m,()=>c[f].call(this,...u))}}),s}var F=class extends P{constructor(e,...n){super(e,"tree",...n)}attr(e,n=void 0,t={}){let{context:i,window:o}=this;return new S(i,o).get(...arguments)}query(e,n=void 0,t={}){[e,n=void 0,t={}]=this.resolveArgs(arguments);let{context:i}=this,o=new Map,s=c=>(o.has(c)||o.set(c,{target:c,entrants:[],exits:[],type:"query",event:null}),o.get(c));if((!t.generation||t.generation==="entrants")&&(e.length?e.every(c=>typeof c=="string")&&(e=e.join(","))&&(t.subtree?i.querySelectorAll(e):[...i.children].filter(f=>f.matches(e))).forEach(f=>s(f.parentNode||i).entrants.push(f)):[...i.children].forEach(c=>s(i).entrants.push(c))),!n)return o;let l={disconnected:!1},a=n&&t.lifecycleSignals&&this.createSignalGenerator();for(let[,c]of o){if(l.disconnected)break;let f=a?.generate()||{};n(c,f,i)}if(t.live){a&&(t={...t,signalGenerator:a});let c=this.observe(e,n,t);return this.disconnectables(t.signal,l,c)}return this.disconnectables(t.signal,l,a)}children(e,n=void 0,t={}){return[e,n=void 0,t={}]=this.resolveArgs(arguments),this.query(e,n,{...t,subtree:!1})}subtree(e,n=void 0,t={}){return[e,n=void 0,t={}]=this.resolveArgs(arguments),this.query(e,n,{...t,subtree:!0})}observe(e,n,t={}){if([e,n,t={}]=this.resolveArgs(arguments),["sync","intercept"].includes(t.timing))return this.observeSync(e,n,t);if(t.timing&&t.timing!=="async")throw new Error(`Timing option "${t.timing}" invalid.`);let{context:i,window:o,wq:s,document:l}=this;t.eventDetails&&(s.domInterceptionRecordsAlwaysOn=!0),(l.readyState==="loading"||s.domInterceptionRecordsAlwaysOn)&&!s.domInterceptionHooks?.intercepting&&he.call(o,"sync",()=>{});let a=new o.MutationObserver(u=>u.forEach(d=>{de.call(o,f,ge.call(o,d),i)}));a.observe(i,{childList:!0,subtree:t.subtree});let c=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),f={context:i,selectors:e,callback:n,params:t,signalGenerator:c,disconnectable:a};if(t.staticSensitivity){let u=pe.call(o,f);return this.disconnectables(t.signal,a,c,u)}return this.disconnectables(t.signal,a,c)}observeSync(e,n,t={}){[e,n,t={}]=this.resolveArgs(arguments);let{context:i,window:o}=this;if(t.timing&&!["sync","intercept"].includes(t.timing))throw new Error(`Timing option "${t.timing}" invalid.`);let s=t.timing==="intercept"?"intercept":"sync",l=t.subtree?"subtree":"children";this.registry(s).size||he.call(o,s,_=>{this.forEachMatchingContext(s,_,de)});let a={disconnect(){d.delete(f),d.size||u.delete(i)}},c=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),f={context:i,selectors:e,callback:n,params:t,signalGenerator:c,disconnectable:a},u=this.registry(s,l);u.has(i)||u.set(i,new Set);let d=u.get(i);if(d.add(f),t.staticSensitivity){let _=pe.call(o,f);return this.disconnectables(t.signal,a,c,_)}return this.disconnectables(t.signal,a,c)}};function pe(r){let e=this,{context:n,selectors:t,callback:i,params:o,signalGenerator:s}=r,l=f=>[...f.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(u=>u[1]);if(!(r.$attrs=t.filter(f=>typeof f=="string"&&f.includes("[")).reduce((f,u)=>f.concat(l(u)),[])).length)return;let a=new Set,c=new Set;return a.push=f=>(c.delete(f),a.add(f)),c.push=f=>(a.delete(f),c.add(f)),r.$deliveryCache={entrants:a,exits:c},new S(n,e).observe(r.$attrs,f=>{let u=new Map,d=h=>(u.has(h)||u.set(h,{target:h,entrants:[],exits:[],type:"static",event:null}),u.get(h)),_=new WeakMap,m=h=>(_.has(h)||_.set(h,t.some(p=>h.matches(p))),_.get(h));for(let h of f)["entrants","exits"].forEach(p=>{o.generation&&p!==o.generation||r.$deliveryCache[p].has(h.target)||(p==="entrants"?!m(h.target):m(h.target))||(r.$deliveryCache[p].push(h.target),d(h.target)[p].push(h.target),d(h.target).event=h.event)});for(let[,h]of u){let p=s?.generate()||{};i(h,p,n)}},{subtree:o.subtree,timing:o.timing,eventDetails:o.eventDetails})}function de(r,e){let{context:n,selectors:t,callback:i,params:o,signalGenerator:s,$deliveryCache:l}=r,a={...e,entrants:[],exits:[]};if(["entrants","exits"].forEach(f=>{if(!(o.generation&&f!==o.generation)&&(t.length?a[f]=Le(t,e[f],e.event!=="parse"):a[f]=[...e[f]],!!l))for(let u of a[f])l[f].push(u)}),!a.entrants.length&&!a.exits.length)return;let c=s?.generate()||{};i(a,c,n)}function Le(r,e,n){e=Array.isArray(e)?e:[...e];let t=(i,o)=>{if(i=i.filter(s=>s.matches),typeof o=="string"){let s=i.filter(l=>l.matches(o));if(n&&(s=i.reduce((l,a)=>[...l,...a.querySelectorAll(o)],s)),s.length)return s}else if(i.includes(o)||n&&i.some(s=>s.contains(o)))return[o]};return e.$$searchCache||(e.$$searchCache=new Map),r.reduce((i,o)=>{let s;return e.$$searchCache.has(o)?s=e.$$searchCache.get(o):(s=t(e,o)||[],x(o)&&e.$$searchCache.set(o,s)),i.concat(s)},[])}function ge({target:r,addedNodes:e,removedNodes:n}){let t=this,i;return i=O(e).reduce((o,s)=>o||t.wq.domInterceptionRecords?.get(s),null),i=O(n).reduce((o,s)=>o||t.wq.domInterceptionRecords?.get(s),i),i=i||t.document.readyState==="loading"&&"parse"||"mutation",{target:r,entrants:e,exits:n,type:"observation",event:i}}function he(r,e){let n=this,{wq:t,document:i,Node:o,Element:s,HTMLElement:l,HTMLTemplateElement:a,DocumentFragment:c}=n;t.domInterceptionHooks||(t.domInterceptionHooks=new Map),t.domInterceptionHooks.has(r)||t.domInterceptionHooks.set(r,new Set),t.domInterceptionHooks.get(r).add(e);let f=()=>t.domInterceptionHooks.get(r).delete(e);if(t.domInterceptionHooks?.intercepting)return f;console.warn("DOM mutation APIs are now being intercepted."),t.domInterceptionHooks.intercepting=!0,t.domInterceptionRecords=new Map;let u=()=>!0,d=(m,h)=>{u()?m.entrants.concat(m.exits).forEach(y=>{clearTimeout(t.domInterceptionRecords.get(y)?.timeout),t.domInterceptionRecords.set(y,m.event);let b=setTimeout(()=>{t.domInterceptionRecords.delete(y)},0);Object.defineProperty(m.event,"timeout",{value:b,configurable:!0})}):t.domInterceptionRecords.clear(),t.domInterceptionHooks.get("intercept")?.forEach(y=>y(m));let p=h();return t.domInterceptionHooks.get("sync")?.forEach(y=>y(m)),p};if(u()){let m=new n.MutationObserver(h=>h.forEach(p=>{Array.isArray((p=ge.call(n,p)).event)||(t.domInterceptionHooks.get("intercept")?.forEach(y=>y(p)),t.domInterceptionHooks.get("sync")?.forEach(y=>y(p)))}));m.observe(i,{childList:!0,subtree:!0}),i.addEventListener("readystatechange",()=>!u()&&m.disconnect())}let _=Object.create(null);return["insertBefore","insertAdjacentElement","insertAdjacentHTML","setHTML","replaceChildren","replaceWith","remove","replaceChild","removeChild","before","after","append","prepend","appendChild"].forEach(m=>{let h=["insertBefore","replaceChild","removeChild","appendChild"].includes(m)?o:s;_[m]=h.prototype[m],_[m]&&(h.prototype[m]=function(...p){let y=()=>_[m].call(this,...p);if(!(this instanceof s||this instanceof c))return y();let b=[],A=[],M=this;["insertBefore"].includes(m)?A=[p[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(m)?(A=[p[1]],["beforebegin","afterend"].includes(p[0])&&(M=this.parentNode)):["setHTML","replaceChildren"].includes(m)?(b=[...this.childNodes],A=m==="replaceChildren"?[...p]:[p[0]]):["replaceWith","remove"].includes(m)?(b=[this],A=m==="replaceWith"?[...p]:[],M=this.parentNode):["replaceChild"].includes(m)?(b=[p[1]],A=[p[0]]):["removeChild"].includes(m)?b=[...p]:(A=[...p],["before","after"].includes(m)&&(M=this.parentNode));let k=m;if(["insertAdjacentHTML","setHTML"].includes(m)){let I=this.nodeName;if(m==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(p[0])){if(!this.parentNode)return _[m].call(this,...p);I=this.parentNode.nodeName}let G=i.createElement(I);_.setHTML.call(G,A[0],m==="setHTML"?p[1]:{}),A=[...G.childNodes],m==="insertAdjacentHTML"?(k="insertAdjacentElement",p[1]=new c,p[1].______isTemp=!0,p[1].append(...G.childNodes)):(k="replaceChildren",p=[...G.childNodes])}return d({target:M,entrants:A,exits:b,type:"interception",event:[this,m]},()=>_[k].call(this,...p))})}),["outerHTML","outerText","innerHTML","innerText","textContent","nodeValue"].forEach(m=>{let h=["textContent","nodeValue"].includes(m)?o:["outerText","innerText"].includes(m)?l:s;_[m]=Object.getOwnPropertyDescriptor(h.prototype,m),Object.defineProperty(h.prototype,m,{..._[m],set:function(p){let y=()=>_[m].set.call(this,p);if(!(this instanceof s))return y();let b=[],A=[],M=this;if(["outerHTML","outerText"].includes(m)?(b=[this],M=this.parentNode):b=[...this.childNodes],["outerHTML","innerHTML"].includes(m)){let V=this.nodeName;if(m==="outerHTML"){if(!this.parentNode)return y();V=this.parentNode.nodeName}let I=i.createElement(V==="TEMPLATE"?"div":V);_[m].set.call(I,p),A=this instanceof a?[]:[...I.childNodes],m==="outerHTML"?(p=new c,p.______isTemp=!0,p.append(...I.childNodes),y=()=>_.replaceWith.call(this,p)):this instanceof a?y=()=>this.content.replaceChildren(...I.childNodes):y=()=>_.replaceChildren.call(this,...I.childNodes)}return d({target:M,entrants:A,exits:b,type:"interception",event:[this,m]},y)}})}),["append","prepend","replaceChildren"].forEach(m=>{[i,c.prototype].forEach(h=>{let p=h[m];h[m]=function(...y){if(this.______isTemp)return p.call(this,...y);let b=m==="replaceChildren"?[...this.childNodes]:[];return d({target:this,entrants:y,exits:b,type:"interception",event:[this,m]},()=>p.call(this,...y))}})}),f}function _e(){Fe.call(this),Re.call(this),De.call(this)}function Fe(){let r=this;r.CSS||(r.CSS={}),r.CSS.escape||(r.CSS.escape=e=>e.replace(/([\:@\~\$\&])/g,"\\$1"))}function Re(){let r=this;"isConnected"in r.Node.prototype||Object.defineProperty(r.Node.prototype,"isConnected",{get:function(){return!this.ownerDocument||!(this.ownerDocument.compareDocumentPosition(this)&this.DOCUMENT_POSITION_DISCONNECTED)}})}function De(){let r=this;r.Element.prototype.matches||(r.Element.prototype.matches=r.Element.prototype.matchesSelector||r.Element.prototype.mozMatchesSelector||r.Element.prototype.msMatchesSelector||r.Element.prototype.oMatchesSelector||r.Element.prototype.webkitMatchesSelector||function(e){for(var n=(this.document||this.ownerDocument).querySelectorAll(e),t=n.length;--t>=0&&n.item(t)!==this;);return t>-1})}function ye(){let r=this;if(r.wq||(r.wq={}),r.wq.dom)return r.wq.dom;r.wq.dom={},_e.call(r);let e=oe(r);return r.wq.dom.Reflow=new e,r.wq.dom.DOMRealtime=F,r.wq.dom.AttrRealtime=S,r.wq.dom.realtime=(n,t="tree")=>{if(t==="tree")return new F(n,r);if(t==="attr")return new S(n,r)},r.wq.dom.ready=Ne.bind(r),r.wq.dom.meta=$e.bind(r),r.wq.dom}function Ne(r){let e=this;e.document.readyState==="complete"?r(e):(e.document.domReadyCallbacks||(e.document.domReadyCallbacks=[],e.document.addEventListener("DOMContentLoaded",()=>{e.document.domReadyCallbacks.splice(0).forEach(n=>n(e))},!1)),e.document.domReadyCallbacks.push(r))}function $e(r,e=!1){let n=this,t={content:{}};return!(t.el=n.document.querySelector(`meta[name="${r}"]`))&&e&&(t.el=n.document.createElement("meta"),t.el.setAttribute("name",r),n.document.head.append(t.el)),t.el&&(t.content=(t.el.getAttribute("content")||"").split(";").filter(i=>i).reduce((i,o)=>{let s=o.split("=").map(l=>l.trim());return Z(i,s[0].split("."),s[1]==="true"?!0:s[1]==="false"?!1:E(s[1])?parseInt(s[1]):s[1]),i},{})),t.get=function(i){return JSON.parse(JSON.stringify(q(this.content,i.split("."))))},t.copy=function(){return JSON.parse(JSON.stringify(this.content))},t.copyWithDefaults=function(...i){return i.length?$(!0,{},...i.reverse().concat(this.content)):this.copy()},t}function xe(){let r=this;return class extends r.Event{constructor(n,t,{type:i="contextrequest",...o}={}){super(i,o),Object.defineProperty(this,"request",{get:()=>n}),Object.defineProperty(this,"callback",{get:()=>t})}respondWith(n,...t){if(this.request.diff){if("previousValue"in this&&this.previousValue===n)return;this.previousValue=n}return this.callback(n,...t)}}}var U=(r,...e)=>H(r,"oohtml",...e);var R=class{static instance(e){return U(e).get("contextsmanager::instance")||new this(e)}constructor(e){U(e).get("contextsmanager::instance")?.dispose(),U(e).set("contextsmanager::instance",this);let n={host:e,contexts:new Set};Object.defineProperty(this,"#",{get:()=>n});let t=xe.call(e.ownerDocument?.defaultView||e.defaultView);Object.defineProperty(this,"ContextRequestEvent",{get:()=>t}),this[Symbol.iterator]=function*(){yield n.contexts[Symbol.iterator]().next().value}}get length(){this["#"].contexts.size}find(e){return[...this["#"].contexts].find(e)}attach(e){this["#"].contexts.add(e),e.initialize(this["#"].host)}detach(e){e.dispose(this["#"].host),this["#"].contexts.delete(e)}ask(e,n,t={}){return this["#"].host.dispatchEvent(new this.ContextRequestEvent(e,n,{bubbles:!0,...t}))}dispose(){}};function ee(r={}){let e=this,t=ye.call(e).meta("oohtml").copyWithDefaults(r,{api:{context:"context"}});ke.call(this,t)}function ke(r){let e=this;if(r.api.context in e.document)throw new Error(`document already has a "${r.api.context}" property!`);if(r.api.context in e.HTMLElement.prototype)throw new Error(`The "HTMLElement" class already has a "${r.api.context}" property!`);Object.defineProperty(e.document,r.api.context,{get:function(){return R.instance(e.document)}}),Object.defineProperty(e.HTMLElement.prototype,r.api.context,{get:function(){return R.instance(this)}})}ee.call(window);})();
|
|
1
|
+
(()=>{function x(r){return!Array.isArray(r)&&typeof r=="object"&&r}function L(r,...t){globalThis.WebQitInternalsRegistry||(globalThis.WebQitInternalsRegistry=new Map);var n=globalThis.WebQitInternalsRegistry.get(r);if(!n){if(n=new Map,t[0]===!1)return n;globalThis.WebQitInternalsRegistry.set(r,n)}for(var e,i;e=t.shift();)if((i=n)&&!(n=n.get(e))){if(n=new Map,t[0]===!1)return n;i.set(e,n)}return n}function g(r){return Array.isArray(r)}function R(r){return typeof r=="function"}function D(r){return r===null||r===""}function S(r){return arguments.length&&(r===void 0||typeof r>"u")}function O(r){return Array.isArray(r)||typeof r=="object"&&r||R(r)}function J(r){return D(r)||S(r)||r===!1||r===0||O(r)&&!Object.keys(r).length}function w(r){return R(r)||r&&{}.toString.call(r)==="[object function]"}function N(r){return r instanceof Number||typeof r=="number"}function E(r){return N(r)||r!==!0&&r!==!1&&r!==null&&r!==""&&!isNaN(r*1)}function W(r){return r instanceof String||typeof r=="string"&&r!==null}function Q(r){return!W(r)&&!S(r.length)}function B(r,...t){return t.forEach(n=>{r.indexOf(n)<0&&r.push(n)}),r}function X(e,t){t=t||Object.prototype,t=t&&!g(t)?[t]:t;for(var n=[],e=e;e&&(!t||t.indexOf(e)<0)&&e.name!=="default";)n.push(e),e=e?Object.getPrototypeOf(e):null;return n}function Y(r,t){var n=[];return X(r,t).forEach(e=>{B(n,...Object.getOwnPropertyNames(e))}),n}function T(r,t,n=!1,e=!1,i=!1){var o=0,s=r.shift();if((E(s)||s===!0||s===!1)&&(o=s,s=r.shift()),!r.length)throw new Error("_merge() requires two or more array/objects.");return r.forEach((l,m)=>{!O(l)&&!w(l)||(n?Y(l):Object.keys(l)).forEach(u=>{if(!!t(u,s,l,m)){var f=s[u],c=l[u];if((g(f)&&g(c)||x(f)&&x(c))&&(o===!0||o>0))s[u]=g(f)&&g(c)?[]:{},T([E(o)?o-1:o,s[u],f,c],t,n,e,i);else if(g(s)&&g(l))e?s[u]=c:s.push(c);else try{i?Object.defineProperty(s,u,Object.getOwnPropertyDescriptor(l,u)):s[u]=l[u]}catch{}}})}),s}function k(...r){return T(r,(t,n,e)=>!0,!1,!1,!1)}function b(r,t=!0){return g(r)?r:!t&&x(r)?[r]:r!==!1&&r!==0&&J(r)?[]:Q(r)?Array.prototype.slice.call(r):x(r)?Object.values(r):[r]}function P(r,t,n={},e={}){t=b(t).slice();for(var i=r;!S(i)&&!D(i)&&t.length;){var o=t.shift();if(!(n.get?n.get(i,o):O(i)?o in i:i[o])){e.exists=!1;return}i=n.get?n.get(i,o):i[o]}return e.exists=!0,i}function K(r,t,n,e={},i={}){let o=(f,c,d)=>i.set?i.set(f,c,d):(E(t[l])&&g(f)?f.push(d):f[c]=d,!0);t=b(t);for(var s=r,l=0;l<t.length;l++)if(l<t.length-1){if(!s||!O(s)&&!w(s))return!1;var m=P(s,t[l],i);if(!O(m)){if(i.buildTree===!1)return!1;m=w(i.buildTree)?i.buildTree(l):E(t[l+1])?[]:{};var u=o(s,t[l],m);if(!u)return!1}s=m}else return o(s,t[l],n)}var ft=r=>class{constructor(n=!0){Object.defineProperty(this,"window",{value:r}),Object.defineProperty(this,"readCallbacks",{value:new Set}),Object.defineProperty(this,"writeCallbacks",{value:new Set}),this.async=n,this.window.requestAnimationFrame?this._run():this.async=!1}_run(){this.window.requestAnimationFrame(()=>{this.readCallbacks.forEach(n=>{n()||this.readCallbacks.delete(n)}),this.writeCallbacks.forEach(n=>{n()||this.writeCallbacks.delete(n)}),this._run()})}onread(n,e=!1){if(e)return new Promise((i,o)=>{this.async===!1?n(i,o):this.readCallbacks.add(()=>{n(i,o)})});this.async===!1?n():this.readCallbacks.add(n)}onwrite(n,e=!1){if(e)return new Promise((i,o)=>{this.async===!1?n(i,o):this.writeCallbacks.add(()=>{n(i,o)})});this.async===!1?n():this.writeCallbacks.add(n)}cycle(n,e,i){this.onread(()=>{let o=n(i),s=l=>{l!==void 0&&this.onwrite(()=>{let m=e(l,i),u=f=>{f!==void 0&&this.cycle(n,e,f)};m instanceof Promise?m.then(u):u(m)})};o instanceof Promise?o.then(s):s(o)})}};var H=class{constructor(t,n,e){this.context=t,this.namespace=n,this.window=t.defaultView||t.ownerDocument?.defaultView||e,this.document=this.window.document,this.wq=this.window.wq,Object.defineProperty(this,"#",{value:{}})}resolveArgs(t){return w(t[0])?t=[[],...t]:x(t[0])&&t.length===1?t=[[],void 0,t[0]]:x(t[1])&&t.length===2?t=[b(t[0],!1),void 0,t[1]]:t[0]=b(t[0],!1),t}registry(...t){return L(this.window,"dom.realtime",this.namespace,...t)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(t,n,e){let{window:i}=this,o=Array.isArray(n)?n:[n],s=new Set;for(let[l,m]of this.registry(t))for(let[u,f]of m){let c=o.filter(d=>u.contains(d.target)?l==="subtree"||d.target===u:!1);if(!!c.length){Array.isArray(n)||(c=c[0]);for(let d of f)s.add([d,c,u])}}for(let[l,m,u]of s)e.call(this,l,m,u)}disconnectables(t,...n){let e={disconnect(){n.forEach(i=>i&&w(i.disconnect)&&i.disconnect()||w(i)&&i()||x(i)&&(i.disconnected=!0))}};return t&&t.addEventListener("abort",()=>e.disconnect()),e}};var q=class extends H{constructor(t,...n){super(t,"attr",...n)}get(t,n=void 0,e={}){let i=typeof t=="string";[t=[],n=void 0,e={}]=this.resolveArgs(arguments);let{context:o}=this,s=pt(o,t),l=i?s[0]:s;if(!n)return l;let m=n&&e.lifecycleSignals&&this.createSignalGenerator(),u=m?.generate()||{};if(n(l,u,o),e.live){m&&(e={...e,signalGenerator:m});let f=this.observe(i?t[0]:t,n,{newValue:!0,...e});return this.disconnectables(e.signal,f)}}observe(t,n,e={}){let i=typeof t=="string";if([t=[],n,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(i?t[0]:t,n,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:o,window:s,wq:l}=this;e.eventDetails&&!l.attrInterceptionHooks?.intercepting&&at.call(s,"intercept",()=>{});let m=new s.MutationObserver(d=>{d=mt(d).map(y=>dt.call(s,y)),lt.call(s,c,d,o)}),u={attributes:!0,attributeOldValue:e.oldValue,subtree:e.subtree};t.length&&(u.attributeFilter=t),m.observe(o,u);let f=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),c={context:o,filter:t,callback:n,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:f,disconnectable:m};return this.disconnectables(e.signal,m,f)}observeSync(t,n,e={}){let i=typeof t=="string";[t,n,e={}]=this.resolveArgs(arguments);let{context:o,window:s}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let l=e.timing==="intercept"?"intercept":"sync",m=e.subtree?"subtree":"children";this.registry(l).size||at.call(s,l,a=>{this.forEachMatchingContext(l,a,lt)});let u={disconnect(){y.delete(c),y.size||d.delete(o)}},f=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),c={context:o,filter:t,callback:n,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:f,disconnectable:u},d=this.registry(l,m);d.has(o)||d.set(o,new Set);let y=d.get(o);return y.add(c),this.disconnectables(e.signal,u,f)}};function mt(r){return r.reduce((t,n,e)=>t[e-1]?.attributeName===n.attributeName?t:t.concat(n),[])}function lt(r,t){let{context:n,filter:e,callback:i,params:o,atomics:s,originalFilterIsString:l,signalGenerator:m}=r;o.atomic&&!s.size&&(t=pt(n,e,t)),o.newValue===null&&o.oldValue===null||(t=t.map(c=>{let d;return!o.oldValue&&"oldValue"in c&&({oldValue:d,...c}=c),!o.newValue&&"value"in c?{value:d,...c}=c:o.newValue&&typeof c.value>"u"&&(c={...c,value:c.target.getAttribute(c.name)}),c})),o.atomic&&(t.forEach(c=>s.set(c.name,c)),t=Array.from(s.entries()).map(([,c])=>c));let u=l?t[0]:t,f=m?.generate()||{};i(u,f,n)}function pt(r,t,n=[]){let e={event:null,type:"attribute"};return t.length?t.map(o=>n.find(s=>s.name===o)||{target:r,name:o,value:r.getAttribute(o),...e}):Array.from(r.attributes).map(o=>n.find(s=>s.name===o.nodeName)||{target:r,name:o.nodeName,value:o.nodeValue,...e})}function dt({target:r,attributeName:t,value:n,oldValue:e}){let s=(this.wq.attrInterceptionRecords?.get(r)||{})[t]||"mutation";return{target:r,name:t,value:n,oldValue:e,type:"observation",event:s}}function at(r,t){let n=this,{wq:e,document:i,Element:o}=n;e.attrInterceptionHooks||(e.attrInterceptionHooks=new Map),e.attrInterceptionHooks.has(r)||e.attrInterceptionHooks.set(r,new Set),e.attrInterceptionHooks.get(r).add(t);let s=()=>e.attrInterceptionHooks.get(r).delete(t);if(e.attrInterceptionHooks?.intercepting)return s;console.warn("Attr mutation APIs are now being intercepted."),e.attrInterceptionHooks.intercepting=!0,e.attrInterceptionRecords=new Map;let l=(f,c)=>{e.attrInterceptionRecords.has(f.target)||e.attrInterceptionRecords.set(f.target,{});let d=e.attrInterceptionRecords.get(f.target);clearTimeout(d[f.name]?.timeout),d[f.name]=f.event;let y=setTimeout(()=>{delete d[f.name]},0);Object.defineProperty(f.event,"timeout",{value:y,configurable:!0}),e.attrInterceptionHooks.get("intercept")?.forEach(h=>h([f]));let a=c();return e.attrInterceptionHooks.get("sync")?.forEach(h=>h([f])),a};new n.MutationObserver(f=>{f=mt(f).map(c=>dt.call(n,c)).filter((c,d)=>!Array.isArray(c.event)),f.length&&(e.attrInterceptionHooks.get("intercept")?.forEach(c=>c(f)),e.attrInterceptionHooks.get("sync")?.forEach(c=>c(f)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let u=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(f=>{u[f]=o.prototype[f],o.prototype[f]=function(...c){let d,y=this.getAttribute(c[0]);["setAttribute","toggleAttribute"].includes(f)&&(d=c[1]),f==="toggleAttribute"&&d===void 0&&(d=y===null);let a={target:this,name:c[0],value:d,oldValue:y,type:"interception",event:[this,f]};return l(a,()=>u[f].call(this,...c))}}),s}var F=class extends H{constructor(t,...n){super(t,"tree",...n)}attr(t,n=void 0,e={}){let{context:i,window:o}=this;return new q(i,o).get(...arguments)}query(t,n=void 0,e={}){[t,n=void 0,e={}]=this.resolveArgs(arguments);let{context:i}=this,o=new Map,s=u=>(o.has(u)||o.set(u,{target:u,entrants:[],exits:[],type:"query",event:null}),o.get(u));if((!e.generation||e.generation==="entrants")&&(t.length?t.every(u=>typeof u=="string")&&(t=t.join(","))&&(e.subtree?i.querySelectorAll(t):[...i.children].filter(f=>f.matches(t))).forEach(f=>s(f.parentNode||i).entrants.push(f)):[...i.children].forEach(u=>s(i).entrants.push(u))),!n)return o;let l={disconnected:!1},m=n&&e.lifecycleSignals&&this.createSignalGenerator();for(let[,u]of o){if(l.disconnected)break;let f=m?.generate()||{};n(u,f,i)}if(e.live){m&&(e={...e,signalGenerator:m});let u=this.observe(t,n,e);return this.disconnectables(e.signal,l,u)}return this.disconnectables(e.signal,l,m)}children(t,n=void 0,e={}){return[t,n=void 0,e={}]=this.resolveArgs(arguments),this.query(t,n,{...e,subtree:!1})}subtree(t,n=void 0,e={}){return[t,n=void 0,e={}]=this.resolveArgs(arguments),this.query(t,n,{...e,subtree:!0})}observe(t,n,e={}){if([t,n,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(t,n,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:i,window:o,wq:s,document:l}=this;e.eventDetails&&(s.domInterceptionRecordsAlwaysOn=!0),(l.readyState==="loading"||s.domInterceptionRecordsAlwaysOn)&&!s.domInterceptionHooks?.intercepting&&yt.call(o,"sync",()=>{});let m=new o.MutationObserver(c=>c.forEach(d=>{gt.call(o,f,_t.call(o,d),i)}));m.observe(i,{childList:!0,subtree:e.subtree});let u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),f={context:i,selectors:t,callback:n,params:e,signalGenerator:u,disconnectable:m};if(e.staticSensitivity){let c=ht.call(o,f);return this.disconnectables(e.signal,m,u,c)}return this.disconnectables(e.signal,m,u)}observeSync(t,n,e={}){[t,n,e={}]=this.resolveArgs(arguments);let{context:i,window:o}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let s=e.timing==="intercept"?"intercept":"sync",l=e.subtree?"subtree":"children";this.registry(s).size||yt.call(o,s,y=>{this.forEachMatchingContext(s,y,gt)});let m={disconnect(){d.delete(f),d.size||c.delete(i)}},u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),f={context:i,selectors:t,callback:n,params:e,signalGenerator:u,disconnectable:m},c=this.registry(s,l);c.has(i)||c.set(i,new Set);let d=c.get(i);if(d.add(f),e.staticSensitivity){let y=ht.call(o,f);return this.disconnectables(e.signal,m,u,y)}return this.disconnectables(e.signal,m,u)}};function ht(r){let t=this,{context:n,selectors:e,callback:i,params:o,signalGenerator:s}=r,l=f=>[...f.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(c=>c[1]);if(!(r.$attrs=e.filter(f=>typeof f=="string"&&f.includes("[")).reduce((f,c)=>f.concat(l(c)),[])).length)return;let m=new Set,u=new Set;return m.push=f=>(u.delete(f),m.add(f)),u.push=f=>(m.delete(f),u.add(f)),r.$deliveryCache={entrants:m,exits:u},new q(n,t).observe(r.$attrs,f=>{let c=new Map,d=h=>(c.has(h)||c.set(h,{target:h,entrants:[],exits:[],type:"static",event:null}),c.get(h)),y=new WeakMap,a=h=>(y.has(h)||y.set(h,e.some(p=>h.matches(p))),y.get(h));for(let h of f)["entrants","exits"].forEach(p=>{o.generation&&p!==o.generation||r.$deliveryCache[p].has(h.target)||(p==="entrants"?!a(h.target):a(h.target))||(r.$deliveryCache[p].push(h.target),d(h.target)[p].push(h.target),d(h.target).event=h.event)});for(let[,h]of c){let p=s?.generate()||{};i(h,p,n)}},{subtree:o.subtree,timing:o.timing,eventDetails:o.eventDetails})}function gt(r,t){let{context:n,selectors:e,callback:i,params:o,signalGenerator:s,$deliveryCache:l}=r,m={...t,entrants:[],exits:[]};if(["entrants","exits"].forEach(f=>{if(!(o.generation&&f!==o.generation)&&(e.length?m[f]=Ft(e,t[f],t.event!=="parse"):m[f]=[...t[f]],!!l))for(let c of m[f])l[f].push(c)}),!m.entrants.length&&!m.exits.length)return;let u=s?.generate()||{};i(m,u,n)}function Ft(r,t,n){t=Array.isArray(t)?t:[...t];let e=(i,o)=>{if(i=i.filter(s=>s.matches),typeof o=="string"){let s=i.filter(l=>l.matches(o));if(n&&(s=i.reduce((l,m)=>[...l,...m.querySelectorAll(o)],s)),s.length)return s}else if(i.includes(o)||n&&i.some(s=>s.contains(o)))return[o]};return t.$$searchCache||(t.$$searchCache=new Map),r.reduce((i,o)=>{let s;return t.$$searchCache.has(o)?s=t.$$searchCache.get(o):(s=e(t,o)||[],x(o)&&t.$$searchCache.set(o,s)),i.concat(s)},[])}function _t({target:r,addedNodes:t,removedNodes:n}){let e=this,i;return i=b(t).reduce((o,s)=>o||e.wq.domInterceptionRecords?.get(s),null),i=b(n).reduce((o,s)=>o||e.wq.domInterceptionRecords?.get(s),i),i=i||e.document.readyState==="loading"&&"parse"||"mutation",{target:r,entrants:t,exits:n,type:"observation",event:i}}function yt(r,t){let n=this,{wq:e,document:i,Node:o,Element:s,HTMLElement:l,HTMLTemplateElement:m,DocumentFragment:u}=n;e.domInterceptionHooks||(e.domInterceptionHooks=new Map),e.domInterceptionHooks.has(r)||e.domInterceptionHooks.set(r,new Set),e.domInterceptionHooks.get(r).add(t);let f=()=>e.domInterceptionHooks.get(r).delete(t);if(e.domInterceptionHooks?.intercepting)return f;console.warn("DOM mutation APIs are now being intercepted."),e.domInterceptionHooks.intercepting=!0,e.domInterceptionRecords=new Map;let c=()=>!0,d=(a,h)=>{c()?a.entrants.concat(a.exits).forEach(_=>{clearTimeout(e.domInterceptionRecords.get(_)?.timeout),e.domInterceptionRecords.set(_,a.event);let v=setTimeout(()=>{e.domInterceptionRecords.delete(_)},0);Object.defineProperty(a.event,"timeout",{value:v,configurable:!0})}):e.domInterceptionRecords.clear(),e.domInterceptionHooks.get("intercept")?.forEach(_=>_(a));let p=h();return e.domInterceptionHooks.get("sync")?.forEach(_=>_(a)),p};if(c()){let a=new n.MutationObserver(h=>h.forEach(p=>{Array.isArray((p=_t.call(n,p)).event)||(e.domInterceptionHooks.get("intercept")?.forEach(_=>_(p)),e.domInterceptionHooks.get("sync")?.forEach(_=>_(p)))}));a.observe(i,{childList:!0,subtree:!0}),i.addEventListener("readystatechange",()=>!c()&&a.disconnect())}let y=Object.create(null);return["insertBefore","insertAdjacentElement","insertAdjacentHTML","setHTML","replaceChildren","replaceWith","remove","replaceChild","removeChild","before","after","append","prepend","appendChild"].forEach(a=>{let h=["insertBefore","replaceChild","removeChild","appendChild"].includes(a)?o:s;y[a]=h.prototype[a],y[a]&&(h.prototype[a]=function(...p){let _=()=>y[a].call(this,...p);if(!(this instanceof s||this instanceof u))return _();let v=[],A=[],I=this;["insertBefore"].includes(a)?A=[p[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(a)?(A=[p[1]],["beforebegin","afterend"].includes(p[0])&&(I=this.parentNode)):["setHTML","replaceChildren"].includes(a)?(v=[...this.childNodes],A=a==="replaceChildren"?[...p]:[p[0]]):["replaceWith","remove"].includes(a)?(v=[this],A=a==="replaceWith"?[...p]:[],I=this.parentNode):["replaceChild"].includes(a)?(v=[p[1]],A=[p[0]]):["removeChild"].includes(a)?v=[...p]:(A=[...p],["before","after"].includes(a)&&(I=this.parentNode));let V=a;if(["insertAdjacentHTML","setHTML"].includes(a)){let M=this.nodeName;if(a==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(p[0])){if(!this.parentNode)return y[a].call(this,...p);M=this.parentNode.nodeName}let G=i.createElement(M);y.setHTML.call(G,A[0],a==="setHTML"?p[1]:{}),A=[...G.childNodes],a==="insertAdjacentHTML"?(V="insertAdjacentElement",p[1]=new u,p[1].______isTemp=!0,p[1].append(...G.childNodes)):(V="replaceChildren",p=[...G.childNodes])}return d({target:I,entrants:A,exits:v,type:"interception",event:[this,a]},()=>y[V].call(this,...p))})}),["outerHTML","outerText","innerHTML","innerText","textContent","nodeValue"].forEach(a=>{let h=["textContent","nodeValue"].includes(a)?o:["outerText","innerText"].includes(a)?l:s;y[a]=Object.getOwnPropertyDescriptor(h.prototype,a),Object.defineProperty(h.prototype,a,{...y[a],set:function(p){let _=()=>y[a].set.call(this,p);if(!(this instanceof s))return _();let v=[],A=[],I=this;if(["outerHTML","outerText"].includes(a)?(v=[this],I=this.parentNode):v=[...this.childNodes],["outerHTML","innerHTML"].includes(a)){let j=this.nodeName;if(a==="outerHTML"){if(!this.parentNode)return _();j=this.parentNode.nodeName}let M=i.createElement(j==="TEMPLATE"?"div":j);y[a].set.call(M,p),A=this instanceof m?[]:[...M.childNodes],a==="outerHTML"?(p=new u,p.______isTemp=!0,p.append(...M.childNodes),_=()=>y.replaceWith.call(this,p)):this instanceof m?_=()=>this.content.replaceChildren(...M.childNodes):_=()=>y.replaceChildren.call(this,...M.childNodes)}return d({target:I,entrants:A,exits:v,type:"interception",event:[this,a]},_)}})}),["append","prepend","replaceChildren"].forEach(a=>{[i,u.prototype].forEach(h=>{let p=h[a];h[a]=function(..._){if(this.______isTemp)return p.call(this,..._);let v=a==="replaceChildren"?[...this.childNodes]:[];return d({target:this,entrants:_,exits:v,type:"interception",event:[this,a]},()=>p.call(this,..._))}})}),f}function xt(){Dt.call(this),Nt.call(this),kt.call(this)}function Dt(){let r=this;r.CSS||(r.CSS={}),r.CSS.escape||(r.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function Nt(){let r=this;"isConnected"in r.Node.prototype||Object.defineProperty(r.Node.prototype,"isConnected",{get:function(){return!this.ownerDocument||!(this.ownerDocument.compareDocumentPosition(this)&this.DOCUMENT_POSITION_DISCONNECTED)}})}function kt(){let r=this;r.Element.prototype.matches||(r.Element.prototype.matches=r.Element.prototype.matchesSelector||r.Element.prototype.mozMatchesSelector||r.Element.prototype.msMatchesSelector||r.Element.prototype.oMatchesSelector||r.Element.prototype.webkitMatchesSelector||function(t){for(var n=(this.document||this.ownerDocument).querySelectorAll(t),e=n.length;--e>=0&&n.item(e)!==this;);return e>-1})}function wt(){let r=this;if(r.wq||(r.wq={}),r.wq.dom)return r.wq.dom;r.wq.dom={},xt.call(r);let t=ft(r);return r.wq.dom.Reflow=new t,r.wq.dom.DOMRealtime=F,r.wq.dom.AttrRealtime=q,r.wq.dom.realtime=(n,e="tree")=>{if(e==="tree")return new F(n,r);if(e==="attr")return new q(n,r)},r.wq.dom.ready=$t.bind(r),r.wq.dom.meta=Vt.bind(r),r.wq.dom}function $t(r){let t=this;t.document.readyState==="complete"?r(t):(t.document.domReadyCallbacks||(t.document.domReadyCallbacks=[],t.document.addEventListener("DOMContentLoaded",()=>{t.document.domReadyCallbacks.splice(0).forEach(n=>n(t))},!1)),t.document.domReadyCallbacks.push(r))}function Vt(r,t=!1){let n=this,e={content:{}};return!(e.el=n.document.querySelector(`meta[name="${r}"]`))&&t&&(e.el=n.document.createElement("meta"),e.el.setAttribute("name",r),n.document.head.append(e.el)),e.el&&(e.content=(e.el.getAttribute("content")||"").split(";").filter(i=>i).reduce((i,o)=>{let s=o.split("=").map(l=>l.trim());return K(i,s[0].split("."),s[1]==="true"?!0:s[1]==="false"?!1:E(s[1])?parseInt(s[1]):s[1]),i},{})),e.get=function(i){return JSON.parse(JSON.stringify(P(this.content,i.split("."))))},e.copy=function(){return JSON.parse(JSON.stringify(this.content))},e.copyWithDefaults=function(...i){return i.length?k(!0,{},...i.reverse().concat(this.content)):this.copy()},e}function Ot(){let r=this;return class extends r.Event{constructor(n,e,{type:i="contextrequest",...o}={}){super(i,o),Object.defineProperty(this,"request",{get:()=>n}),Object.defineProperty(this,"callback",{get:()=>e})}respondWith(n,...e){if(this.request.diff){if("previousValue"in this&&this.previousValue===n)return;this.previousValue=n}return this.callback(n,...e)}}}var z=(r,...t)=>L(r,"oohtml",...t),et=(r,t,n=1,e=!1)=>{if(n&&typeof r=="object"&&r&&typeof t=="object"&&t&&(!e||Object.keys(r).length===Object.keys(t).length)){for(let i in r)if(!et(r[i],t[i],n-1,e))return!1;return!0}return Array.isArray(r)&&Array.isArray(t)&&r.length===t.length?(t=t.slice(0).sort())&&r.slice(0).sort().every((i,o)=>i===t[o]):r===t};var C=class{static instance(t){return z(t).get("contextsmanager::instance")||new this(t)}constructor(t){z(t).get("contextsmanager::instance")?.dispose(),z(t).set("contextsmanager::instance",this);let n={host:t,contexts:new Set};Object.defineProperty(this,"#",{get:()=>n});let e=Ot.call(t.ownerDocument?.defaultView||t.defaultView);Object.defineProperty(this,"ContextRequestEvent",{get:()=>e}),this[Symbol.iterator]=function*(){yield n.contexts[Symbol.iterator]().next().value}}get length(){this["#"].contexts.size}find(t){return[...this["#"].contexts].find(t)}attach(t){this["#"].contexts.add(t),t.initialize(this["#"].host)}detach(t){t.dispose(this["#"].host),this["#"].contexts.delete(t)}ask(t,n,e={}){return this["#"].host.dispatchEvent(new this.ContextRequestEvent(t,n,{bubbles:!0,...e}))}dispose(){}};var $=class{static get params(){return{}}static attachTo(t,n,e=!1){let i,o=C.instance(t);return!e&&(i=o.find(s=>this.matchRequest(s.id,n,!0)))?i:o.attach(new this(n))}static detachFrom(t,n,e=!1){let i,o=C.instance(t);for(i of o["#"].contexts)if(!(!this.matchRequest(i.id,n,!0)||typeof e=="function"&&!e(i))&&(o.detach(i),typeof e!="function"&&!e))return i}static createId(t,n={}){let e={type:"HTMLModules",...n};return e.name||(t.getAttribute&&!(e.name=(t.getAttribute(this.params.context.attr.contextname)||"").trim())?delete e.name:t.ownerDocument||(e.name="root")),e}static createRequest(t={}){return{...t}}static matchRequest(t,n,e=!1){return e?et(t,n,1,!0):n.type===t.type&&!n.name||n.name===t.name}constructor(t){Object.defineProperty(this,"id",{get:()=>t}),Object.defineProperty(this,"subscriptions",{value:new Set})}get length(){this.subscriptions.size}handle(t){}subscribe(t){this.subscriptions.add(t),t.request.signal&&t.request.signal.addEventListener("abort",()=>{this.unsubscribe(t)})}unsubscribe(t){this.subscriptions.delete(t),t.request.controller?.abort()}handleEvent(t){if(!(this.disposed||t.target===this.host&&t.request?.superContextOnly||!t.request||typeof t.callback!="function"||!this.constructor.matchRequest(this.id,t.request)))if(t.stopPropagation(),t.type==="contextclaim"){let n=new Set;this.subscriptions.forEach(e=>{!t.target.contains(e.request.superContextOnly?e.target.parentNode:e.target)||!this.constructor.matchRequest(t.request,e.request)||(this.subscriptions.delete(e),n.add(e))}),t.respondWith(n)}else t.type==="contextrequest"&&(t.request.live&&this.subscribe(t),this.handle(t))}initialize(t){return this.host=t,this.disposed=!1,t.addEventListener("contextrequest",this),t.addEventListener("contextclaim",this),C.instance(t).ask({...this.id,superContextOnly:!0},n=>n.forEach(e=>{this.subscribe(e),this.handle(e)}),{type:"contextclaim"}),this}dispose(t){return this.disposed=!0,t.removeEventListener("contextrequest",this),t.removeEventListener("contextclaim",this),this.subscriptions.forEach(n=>{this.unsubscribe(n);let{target:e,request:i,callback:o,params:s}=n;C.instance(e).ask(i,o,s)}),this}};function rt(r={}){let t=this,n=wt.call(t);t.wq||(t.wq={}),t.wq.HTMLContextManager=C,t.wq.HTMLContext=$;let e=n.meta("oohtml").copyWithDefaults(r,{api:{context:"context"}});jt.call(this,e)}function jt(r){let t=this;if(r.api.context in t.document)throw new Error(`document already has a "${r.api.context}" property!`);if(r.api.context in t.HTMLElement.prototype)throw new Error(`The "HTMLElement" class already has a "${r.api.context}" property!`);Object.defineProperty(t.document,r.api.context,{get:function(){return C.instance(t.document)}}),Object.defineProperty(t.HTMLElement.prototype,r.api.context,{get:function(){return C.instance(this)}})}rt.call(window);})();
|
|
2
2
|
//# sourceMappingURL=context-api.js.map
|