@webqit/oohtml 5.0.6 → 5.0.8
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/bindings-api.js +1765 -1
- package/dist/bindings-api.js.map +3 -3
- package/dist/context-api.js +1644 -1
- package/dist/context-api.js.map +3 -3
- package/dist/data-binding.js +1674 -23
- package/dist/data-binding.js.map +4 -4
- package/dist/html-imports.js +2215 -1
- package/dist/html-imports.js.map +3 -3
- package/dist/main.js +13305 -46
- package/dist/main.js.map +3 -3
- package/dist/main.lite.js +5896 -38
- package/dist/main.lite.js.map +3 -3
- package/dist/namespaced-html.js +2019 -1
- package/dist/namespaced-html.js.map +3 -3
- package/dist/scoped-css.js +1858 -5
- package/dist/scoped-css.js.map +3 -3
- package/dist/scoped-js.js +1557 -1
- package/dist/scoped-js.js.map +4 -4
- package/package.json +6 -5
- package/src/bindings-api/index.js +80 -75
- package/src/context-api/DOMContext.js +2 -1
- package/src/data-binding/index.js +14 -6
- package/src/html-imports/_HTMLImportElement.js +4 -2
- package/src/namespaced-html/index.js +3 -2
- package/src/scoped-css/index.js +2 -1
- package/src/scoped-js/index.js +71 -68
- package/test/bindings-api.test.js +3 -1
- package/test/imports.test.js +8 -0
- package/test/modules.test.js +6 -4
package/dist/html-imports.js
CHANGED
|
@@ -1,2 +1,2216 @@
|
|
|
1
|
-
var lt=Object.defineProperty;var ft=(n,e,r)=>e in n?lt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[e]=r;var ye=(n,e,r)=>(ft(n,typeof e!="symbol"?e+"":e,r),r),He=(n,e,r)=>{if(!e.has(n))throw TypeError("Cannot "+r)};var T=(n,e,r)=>(He(n,e,"read from private field"),r?r.call(n):e.get(n)),oe=(n,e,r)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,r)},ee=(n,e,r,t)=>(He(n,e,"write to private field"),t?t.call(n,r):e.set(n,r),r);function v(n){return!Array.isArray(n)&&typeof n=="object"&&n}function y(n){return Array.isArray(n)}function te(n){return typeof n=="function"}function se(n){return n===null||n===""}function U(n){return arguments.length&&(n===void 0||typeof n>"u")}function S(n){return Array.isArray(n)||typeof n=="object"&&n||te(n)}function Ae(n){return se(n)||U(n)||n===!1||n===0||S(n)&&!Object.keys(n).length}function b(n){return te(n)||n&&{}.toString.call(n)==="[object function]"}function le(n){return n instanceof Number||typeof n=="number"}function q(n){return le(n)||n!==!0&&n!==!1&&n!==null&&n!==""&&!isNaN(n*1)}function re(n){return n instanceof String||typeof n=="string"&&n!==null}function Ee(n){return!re(n)&&!U(n.length)}function we(n,...e){return e.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n}function Te(t,e){e=e||Object.prototype,e=e&&!y(e)?[e]:e;for(var r=[],t=t;t&&(!e||e.indexOf(t)<0)&&t.name!=="default";)r.push(t),t=t?Object.getPrototypeOf(t):null;return r}function Ce(n,e){var r=[];return Te(n,e).forEach(t=>{we(r,...Object.getOwnPropertyNames(t))}),r}function k(n,e,r=!1,t=!1,o=!1){var s=0,i=n.shift();if((q(i)||i===!0||i===!1)&&(s=i,i=n.shift()),!n.length)throw new Error("_merge() requires two or more array/objects.");return n.forEach((l,u)=>{!S(l)&&!b(l)||(r?Ce(l):Object.keys(l)).forEach(f=>{if(!!e(f,i,l,u)){var a=i[f],m=l[f];if((y(a)&&y(m)||v(a)&&v(m))&&(s===!0||s>0))i[f]=y(a)&&y(m)?[]:{},k([q(s)?s-1:s,i[f],a,m],e,r,t,o);else if(y(i)&&y(l))t?i[f]=m:i.push(m);else try{o?Object.defineProperty(i,f,Object.getOwnPropertyDescriptor(l,f)):i[f]=l[f]}catch{}}})}),i}function fe(...n){return k(n,(e,r,t)=>!0,!1,!1,!1)}function P(n,...e){if(!n||!["object","function"].includes(typeof n))throw new Error("Argument #1 must be of type object");let r=n[Symbol.for("wq")];if(r||(r=new _e,Object.defineProperty(n,Symbol.for("wq"),{value:r,enumerable:!1,configurable:!1,writable:!1})),!e.length)return r;let t,o;for(;t=e.shift();)(o=r)&&!(r=r.get(t))&&(r=new _e,o.set(t,r));return r}var _e=class extends Map{};function M(n,e=!0){return y(n)?n:!e&&v(n)?[n]:n!==!1&&n!==0&&Ae(n)?[]:Ee(n)?Array.prototype.slice.call(n):v(n)?Object.values(n):[n]}function ae(n,e,r={},t={}){e=M(e).slice();for(var o=n;!U(o)&&!se(o)&&e.length;){var s=e.shift();if(!(r.get?r.get(o,s):S(o)?s in o:o[s])){t.exists=!1;return}o=r.get?r.get(o,s):o[s]}return t.exists=!0,o}function Me(n,e,r,t={},o={}){let s=(a,m,c)=>o.set?o.set(a,m,c):(q(e[l])&&y(a)?a.push(c):a[m]=c,!0);e=M(e);for(var i=n,l=0;l<e.length;l++)if(l<e.length-1){if(!i||!S(i)&&!b(i))return!1;var u=ae(i,e[l],o);if(!S(u)){if(o.buildTree===!1)return!1;u=b(o.buildTree)?o.buildTree(l):q(e[l+1])?[]:{};var f=s(i,e[l],u);if(!f)return!1}i=u}else return s(i,e[l],r)}var ce=class{constructor(e,r=!1){Object.defineProperty(this,"window",{value:e}),Object.defineProperty(this,"readCallbacks",{value:new Set}),Object.defineProperty(this,"writeCallbacks",{value:new Set}),Object.defineProperty(this,"_synthesis",{value:0,writable:!0}),!r&&this.window.requestAnimationFrame?this._loop():this._synthesis++}get synthesis(){return this._synthesis}async synthesizeWhile(e){this._synthesis++,this._fulfill();let r=await e();return this._synthesis--,r}_fulfill(){for(let e of this.readCallbacks)e(),this.readCallbacks.delete(e);for(let e of this.writeCallbacks)e(),this.writeCallbacks.delete(e)}_loop(){this.window.requestAnimationFrame(()=>{this._fulfill(),this._loop()})}onread(e,r=!1){if(r)return new Promise(t=>{this.synthesis?t(e()):this.readCallbacks.add(()=>{t(e())})});this.synthesis?Promise.resolve().then(e):this.readCallbacks.add(e)}onwrite(e,r=!1){if(r)return new Promise(t=>{this.synthesis?t(e()):this.writeCallbacks.add(()=>{t(e())})});this.synthesis?Promise.resolve().then(e):this.writeCallbacks.add(e)}cycle(e,r,t){this.onread(()=>{let o=e(t),s=i=>{i!==void 0&&this.onwrite(()=>{let l=r(i,t),u=f=>{f!==void 0&&this.cycle(e,r,f)};l instanceof Promise?l.then(u):u(l)})};o instanceof Promise?o.then(s):s(o)})}};function Ue(n){return(n=n.trim())&&n.startsWith("(")&&n.endsWith(")")}function xe(n,e,r,t=!0){r=(Array.isArray(r)?r:[r]).map(i=>(i+"").replace("(",t?"(.//":"(./")).join("|");let o=[],s;try{let i=n.document.evaluate(r,e,null,n.XPathResult.ANY_TYPE);for(;s=i.iterateNext();)o.push(s)}catch{}return o}function Ve(n,e,r){r=(Array.isArray(r)?r:[r]).map(t=>(t+"").replace("(","(self::")).join("|");try{return n.document.evaluate(`${r}`,e,null,n.XPathResult.BOOLEAN_TYPE).booleanValue}catch{}}function ue(n,e,r,t=!1,o=null){let s=o?.get(e)?.get(r);if(typeof s<"u")return s;let i=f=>(o?.has(e)||o?.set(e,new WeakMap),o?.get(e)?.set(r,f),f),l=e.getRootNode(),u=r.getRootNode();return l===u?i(e.contains(r)):t&&u instanceof n.ShadowRoot?i(ue(n,e,u.host,t,o)):i(!1)}function Be(n,e="|"){return[...n].reduce(([r,t,o,s],i)=>!r&&t===0&&(Array.isArray(e)?e:[e]).includes(i)?[r,t,[""].concat(o)]:(!r&&["(","[","{"].includes(i)&&!o[0].endsWith("\\")&&t++,!r&&[")","]","}"].includes(i)&&!o[0].endsWith("\\")&&t--,['"',"'","`"].includes(i)&&!o[0].endsWith("\\")&&(r=r===i?null:r||i),o[0]+=i,[r,t,o]),[null,0,[""]])[2].reverse()}var L=class{constructor(e){this.content=e,this.type=typeof e=="string"?"selector":"instance",this.kind=this.type==="instance"?null:Ue(e)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=Be(e.trim().slice(1,-1),"@").length>1)}toString(){return this.content}};var Z=class{constructor(e,r,t){this.context=e,this.namespace=r,this.window=e.defaultView||e.ownerDocument?.defaultView||t,this.document=this.window.document,this.webqit=this.window.webqit,Object.defineProperty(this,"#",{value:{}})}resolveArgs(e){if(b(e[0])?e=[[],...e]:v(e[0])&&!(e[0]instanceof L)&&e.length===1?e=[[],void 0,e[0]]:v(e[1])&&e.length===2?e=[M(e[0],!1),void 0,e[1]]:e[0]=M(e[0],!1),e[0].filter(r=>typeof r!="string"&&!(r instanceof L)&&!(r instanceof this.window.Node)).length)throw new Error("Argument #2 must be either a string or a Node object, or a list of those.");return e[0]=e[0].map(r=>r instanceof L?r:new L(r)),e}registry(...e){return P(this.window,"realdom",this.namespace,...e)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(e,r,t){let{window:o}=this,s=new Set,i=new WeakMap;for(let[l,u]of this.registry(e)){let f=[].concat(r).filter(m=>ue(o,l.context,m.target,l.params.subtree==="cross-roots",i));if(!f.length)continue;let a=[l,Array.isArray(r)?f:f[0]];u?s.add(a):t.call(o,...a)}for(let l of s)t.call(o,...l);s.clear()}disconnectables(e,...r){let t={disconnect(){r.forEach(o=>o&&b(o.disconnect)&&o.disconnect()||b(o)&&o()||v(o)&&(o.disconnected=!0))}};return e&&e.addEventListener("abort",()=>t.disconnect()),t}};var z=class extends Z{type="attr";constructor(e,...r){super(e,"attr",...r)}get(e,r=void 0,t={}){let o=typeof e=="string"||e instanceof L;[e=[],r=void 0,t={}]=this.resolveArgs(arguments);let{context:s}=this,i=Qe(s,e);if(!r)return i;let l=t.lifecycleSignals&&this.createSignalGenerator();if(o)for(let u of i){let f=l?l.generate():{};r(u,f,s)}else{let u=l?.generate()||{};r(i,u,s)}if(t.live){l&&(t={...t,signalGenerator:l});let u=this.observe(o?e[0]:e,r,{newValue:!0,...t});return this.disconnectables(t.signal,u)}}observe(e,r,t={}){let o=typeof e=="string"||e instanceof L;if([e=[],r,t={}]=this.resolveArgs(arguments),["sync","intercept"].includes(t.timing))return this.observeSync(o?e[0]:e,r,t);if(t.timing&&t.timing!=="async")throw new Error(`Timing option "${t.timing}" invalid.`);let{context:s,window:i,webqit:l}=this;t.eventDetails&&!l.realdom.attrInterceptionHooks?.intercepting&&ze.call(i,"intercept",()=>{});let u=new i.MutationObserver(c=>{c=Xe(c).map(d=>Je.call(i,d)),Ge.call(i,m,c,s)}),f={attributes:!0,attributeOldValue:t.oldValue,subtree:t.subtree&&!0};e.length&&(f.attributeFilter=e.map(c=>c+"")),u.observe(s,f);let a=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),m={context:s,spec:e,callback:r,params:t,atomics:new Map,originalFilterIsString:o,signalGenerator:a,disconnectable:u};return this.disconnectables(t.signal,u,a)}observeSync(e,r,t={}){let o=typeof e=="string"||e instanceof L;[e,r,t={}]=this.resolveArgs(arguments);let{context:s,window:i}=this;if(t.timing&&!["sync","intercept"].includes(t.timing))throw new Error(`Timing option "${t.timing}" invalid.`);let l=t.timing==="intercept"?"intercept":"sync";this.registry(l).size||ze.call(i,l,c=>{this.forEachMatchingContext(l,c,Ge)});let u={disconnect(){m.delete(a)}},f=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),a={context:s,spec:e,callback:r,params:t,atomics:new Map,originalFilterIsString:o,signalGenerator:f,disconnectable:u},m=this.registry(l);return m.set(a,!!a.params.deferred),this.disconnectables(t.signal,u,f)}};function Xe(n){return n.reduce((e,r,t)=>e[t-1]?.attributeName===r.attributeName||P(r.target,"realdom","internalAttrInteractions").get(r.attributeName)?e:e.concat(r),[])}function Ge(n,e){let{context:r,spec:t,callback:o,params:s,atomics:i,originalFilterIsString:l,signalGenerator:u}=n;if(s.subtree||(e=e.filter(c=>c.target===r)),!e.length)return;let f=t.map(c=>c+"");if(s.atomic&&!i.size?e=Qe(r,t,e):s.timing!=="async"&&t.length&&(e=e.filter(c=>f.includes(c.name))),!e.length)return;s.newValue===null&&s.oldValue===null&&s.eventDetails||(e=e.map(c=>{let d;return s.eventDetails||({event:d,...c}=c),!s.oldValue&&"oldValue"in c&&({oldValue:d,...c}=c),!s.newValue&&"value"in c?{value:d,...c}=c:s.newValue&&typeof c.value>"u"&&(c={...c,value:ve(c.target,c.name,()=>c.target.getAttribute(c.name))}),c})),s.atomic&&(e.forEach(c=>i.set(c.name,c)),e=Array.from(i.entries()).map(([,c])=>c));let a=l?e[0]:e,m=u?u.generate():{};o(a,m,r)}function ve(n,e,r){let t=P(n,"realdom","internalAttrInteractions").get(e);P(n,"realdom","internalAttrInteractions").set(e,!0);let o=r();return P(n,"realdom","internalAttrInteractions").set(e,t),o}function Qe(n,e,r=[]){let t={event:null,type:"attribute"};return e.length?e.map(s=>(s=s+"",r.find(i=>i.name===s)||{target:n,name:s,value:ve(n,s,()=>n.getAttribute(s)),...t})):Array.from(n.attributes).map(s=>r.find(i=>i.name===s.nodeName)||{target:n,name:s.nodeName,value:ve(n,s.nodeName,()=>s.nodeValue),...t})}function Je({target:n,attributeName:e,value:r,oldValue:t}){let i=(this.webqit.realdom.attrInterceptionRecords?.get(n)||{})[e]?.[0]||"mutation";return{target:n,name:e,value:r,oldValue:t,type:"observation",event:i}}function ze(n,e){let r=this,{webqit:t,document:o,Element:s}=r;t.realdom.attrInterceptionHooks||Object.defineProperty(t.realdom,"attrInterceptionHooks",{value:new Map}),t.realdom.attrInterceptionHooks.has(n)||t.realdom.attrInterceptionHooks.set(n,new Set),t.realdom.attrInterceptionHooks.get(n).add(e);let i=()=>t.realdom.attrInterceptionHooks.get(n).delete(e);if(t.realdom.attrInterceptionHooks?.intercepting)return i;console.warn("Attr mutation APIs are now being intercepted."),t.realdom.attrInterceptionHooks.intercepting=!0,Object.defineProperty(t.realdom,"attrInterceptionRecords",{value:new Map});let l=(a,m)=>{t.realdom.attrInterceptionRecords.has(a.target)||t.realdom.attrInterceptionRecords.set(a.target,{});let c=t.realdom.attrInterceptionRecords.get(a.target);if(c[a.name]=c[a.name]||[],c[a.name].unshift(a.event),P(a.target,"realdom","internalAttrInteractions").get(a.name))return m();t.realdom.attrInterceptionHooks.get("intercept")?.forEach(p=>p([a]));let d=m();return t.realdom.attrInterceptionHooks.get("sync")?.forEach(p=>p([a])),d};new r.MutationObserver(a=>{a=a.filter(m=>!(r.webqit.realdom.attrInterceptionRecords?.get(m.target)||{})[m.attributeName]?.shift()),a=Xe(a).map(m=>Je.call(r,m)),a.length&&(t.realdom.attrInterceptionHooks.get("intercept")?.forEach(m=>m(a)),t.realdom.attrInterceptionHooks.get("sync")?.forEach(m=>m(a)))}).observe(o,{attributes:!0,subtree:!0,attributeOldValue:!0});let f=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(a=>{f[a]=s.prototype[a],s.prototype[a]=function(...m){let c,d=ve(this,m[0],()=>this.getAttribute(m[0]));["setAttribute","toggleAttribute"].includes(a)&&(c=m[1]),a==="toggleAttribute"&&c===void 0&&(c=d===null);let p={target:this,name:m[0],value:c,oldValue:d,type:"interception",event:[this,a]};return l(p,()=>f[a].call(this,...m))}}),i}var me=class extends Z{constructor(e,...r){super(e,"tree",...r)}attr(e,r=void 0,t={}){let{context:o,window:s}=this;return new z(o,s).get(...arguments)}query(e,r=void 0,t={}){[e,r=void 0,t={}]=this.resolveArgs(arguments);let{context:o}=this,s=new Map,i=f=>(s.has(f)||s.set(f,{target:f,entrants:[],exits:[],type:"query",event:null}),s.get(f));if(!t.generation||t.generation==="entrants"){if(!e.length)[...o.children].forEach(f=>i(o).entrants.push(f));else if(e.every(f=>f.type==="selector")){let[f,a]=e.reduce(([c,d],p)=>p.kind==="xpath"?[c,d.concat(p)]:[c.concat(p),d],[[],[]]),m=[];t.subtree?(f.length&&m.push(...o.querySelectorAll(f.join(","))),a.length&&m.push(...xe(this.window,o,a))):(f.length&&m.push(...[...o.children].filter(c=>c.matches(f))),a.length&&m.push(...xe(this.window,o,a,!1))),m.forEach(c=>i(c.parentNode||o).entrants.push(c))}}if(!r)return s;let l={disconnected:!1},u=r&&t.lifecycleSignals&&this.createSignalGenerator();for(let[,f]of s){if(l.disconnected)break;let a=u?.generate()||{};r(f,a,o)}if(t.live){u&&(t={...t,signalGenerator:u});let f=this.observe(e,r,t);return this.disconnectables(t.signal,l,f)}return this.disconnectables(t.signal,l,u)}children(e,r=void 0,t={}){return[e,r=void 0,t={}]=this.resolveArgs(arguments),this.query(e,r,{...t,subtree:!1})}subtree(e,r=void 0,t={}){return[e,r=void 0,t={}]=this.resolveArgs(arguments),this.query(e,r,{...t,subtree:!0})}observe(e,r,t={}){if([e,r,t={}]=this.resolveArgs(arguments),["sync","intercept"].includes(t.timing))return this.observeSync(e,r,t);if(t.timing&&t.timing!=="async")throw new Error(`Timing option "${t.timing}" invalid.`);let{context:o,window:s,webqit:i,document:l}=this;t.eventDetails&&(i.realdom.domInterceptionRecordsAlwaysOn=!0),(l.readyState==="loading"||i.realdom.domInterceptionRecordsAlwaysOn)&&!i.realdom.domInterceptionHooks?.intercepting&&Ke.call(s,"sync",()=>{});let u=new s.MutationObserver(m=>m.forEach(c=>{Pe.call(s,a,Ze.call(s,c),o)}));u.observe(o,{childList:!0,subtree:t.subtree&&!0});let f=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),a={context:o,spec:e,callback:r,params:t,signalGenerator:f,disconnectable:u};if(t.staticSensitivity){let m=Ye.call(s,a);return this.disconnectables(t.signal,u,f,m)}return this.disconnectables(t.signal,u,f)}observeSync(e,r,t={}){[e,r,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 i=t.timing==="intercept"?"intercept":"sync";this.registry(i).size||Ke.call(s,i,c=>{this.forEachMatchingContext(i,c,Pe)});let l=new s.MutationObserver(c=>c.forEach(d=>{Array.isArray((d=Ze.call(s,d)).event)||Pe.call(s,a,d,o)}));l.observe(o,{childList:!0,subtree:t.subtree&&!0});let u={disconnect(){m.delete(a),l.disconnect()}},f=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),a={context:o,spec:e,callback:r,params:t,signalGenerator:f,disconnectable:u},m=this.registry(i);if(m.set(a,!!a.params.deferred),t.staticSensitivity){let c=Ye.call(s,a);return this.disconnectables(t.signal,u,f,c)}return this.disconnectables(t.signal,u,f)}track(e,r,t={}){return t={subtree:!0,...t},this.observe(e,o=>{o.entrants.length&&r(!0,Array.isArray(e)?o.entrants:o.entrants[0]),o.exits.length&&r(!1,Array.isArray(e)?o.exits:o.exits[0])},t)}};function Ye(n){let e=this,{context:r,spec:t,callback:o,params:s,signalGenerator:i}=n,l=t.filter(d=>d.kind==="css"),u=d=>d.match(/\.([\w-]+)/g)?.length?["class"]:[],f=d=>d.match(/#([\w-]+)/g)?.length?["id"]:[],a=d=>[...d.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(p=>p[1]).concat(u(d)).concat(f(d));if(!(n.$attrs=Array.from(new Set(l.filter(d=>(d+"").includes("[")).reduce((d,p)=>d.concat(a(p+"")),[])))).length)return;let m=new Set,c=new Set;return m.push=d=>(c.delete(d),m.add(d)),c.push=d=>(m.delete(d),c.add(d)),n.$deliveryCache={entrants:m,exits:c},new z(r,e).observe(n.$attrs,d=>{let p=new Map,_=w=>(p.has(w)||p.set(w,{target:w,entrants:[],exits:[],type:"static",event:null}),p.get(w)),E=new WeakMap,h=w=>(E.has(w)||E.set(w,l.some(A=>w.matches(A+""))),E.get(w));for(let w of d)["entrants","exits"].forEach(A=>{s.generation&&A!==s.generation||n.$deliveryCache[A].has(w.target)||(A==="entrants"?!h(w.target):h(w.target))||(n.$deliveryCache[A].push(w.target),_(w.target)[A].push(w.target),_(w.target).event=w.event)});for(let[,w]of p){let A=i?.generate()||{};o(w,A,r)}},{subtree:s.subtree,timing:s.timing,eventDetails:s.eventDetails})}function Pe(n,e){let{context:r,spec:t,callback:o,params:s,signalGenerator:i,$deliveryCache:l}=n,u={...e,entrants:[],exits:[]};if(s.eventDetails||delete u.event,["entrants","exits"].forEach(a=>{if(!(s.generation&&a!==s.generation)&&(t.length?u[a]=At.call(this,t,s.subtree==="cross-roots",e[a],e.event!=="parse"):u[a]=[...e[a]],!!l))for(let m of u[a])l[a].push(m)}),!u.entrants.length&&!u.exits.length)return;let f=i?.generate()||{};o(u,f,r)}function At(n,e,r,t){r=Array.isArray(r)?r:[...r];let o=(s,i)=>{if(i.type==="selector"){let l=i.isXpathAttr?[]:s.filter(u=>i.kind==="xpath"?Ve(this,u,i+""):u.matches&&u.matches(i+""));if((t||i.isXpathAttr)&&(l=s.reduce((u,f)=>i.kind==="xpath"?[...u,...xe(this,f,i,t)]:f.querySelectorAll?[...u,...f.querySelectorAll(i+"")]:u,l)),l.length)return l}else if(s.includes(i.content)||t&&s.some(l=>ue(this,l,i.content,e)))return[i.content]};return r.$$searchCache||(r.$$searchCache=new Map),n.reduce((s,i)=>{let l;return r.$$searchCache.has(i.content)?l=r.$$searchCache.get(i.content):(l=o(r,i)||[],i.type==="instance"&&r.$$searchCache.set(i.content,l)),s.concat(l)},[])}function Ze({target:n,addedNodes:e,removedNodes:r}){let t=this,o;return o=M(e).reduce((s,i)=>s||t.webqit.realdom.domInterceptionRecords?.get(i),null),o=M(r).reduce((s,i)=>s||t.webqit.realdom.domInterceptionRecords?.get(i),o),o=o||t.document.readyState==="loading"&&"parse"||"mutation",{target:n,entrants:e,exits:r,type:"observation",event:o}}function Ke(n,e){let r=this,{webqit:t,document:o,Node:s,CharacterData:i,Element:l,HTMLElement:u,HTMLTemplateElement:f,DocumentFragment:a}=r;t.realdom.domInterceptionHooks||Object.defineProperty(t.realdom,"domInterceptionHooks",{value:new Map}),t.realdom.domInterceptionNoRecurse||Object.defineProperty(t.realdom,"domInterceptionNoRecurse",{value:new Map}),t.realdom.domInterceptionHooks.has(n)||t.realdom.domInterceptionHooks.set(n,new Set),t.realdom.domInterceptionHooks.get(n).add(e);let m=()=>t.realdom.domInterceptionHooks.get(n).delete(e);if(t.realdom.domInterceptionHooks?.intercepting)return m;console.warn("DOM mutation APIs are now being intercepted."),t.realdom.domInterceptionHooks.intercepting=!0,Object.defineProperty(t.realdom,"domInterceptionRecords",{value:new Map});let c=(h,w,A)=>{t.realdom.domInterceptionNoRecurse.set(h,w);let g=A();return t.realdom.domInterceptionNoRecurse.delete(h),g},d=(h,w)=>{h.entrants.concat(h.exits).forEach(g=>{clearTimeout(t.realdom.domInterceptionRecords.get(g)?.timeout),t.realdom.domInterceptionRecords.set(g,h.event);let R=setTimeout(()=>{t.realdom.domInterceptionRecords.delete(g)},0);Object.defineProperty(h.event,"timeout",{value:R,configurable:!0})}),t.realdom.domInterceptionHooks.get("intercept")?.forEach(g=>g(h));let A=w();return t.realdom.domInterceptionHooks.get("sync")?.forEach(g=>g(h)),A},p={ShadowRoot:["innerHTML","setHTMLUnsafe"],DocumentFragment:["replaceChildren","append","prepend"],Document:["replaceChildren","append","prepend"],HTMLElement:["outerText","innerText"],Element:["append","prepend","before","after","insertAdjacentElement","insertAdjacentHTML","remove","replaceChildren","replaceWith","setHTMLUnsafe","innerHTML","outerHTML"],CharacterData:["before","after","remove","replaceWith"],Node:["insertBefore","replaceChild","removeChild","appendChild","textContent","nodeValue"]},_={ShadowRoot:Object.create(null),DocumentFragment:Object.create(null),Document:Object.create(null),HTMLElement:Object.create(null),Element:Object.create(null),CharacterData:Object.create(null),Node:Object.create(null)};return new Set(Object.values(p).reduce((h,w)=>h.concat(w),[])).forEach(h=>{Object.keys(p).forEach(g=>{if(!p[g].includes(h))return;let R=Object.getOwnPropertyDescriptor(r[g].prototype,h);!R||(Object.defineProperty(r[g].prototype,h,"value"in R?{...R,value:w}:{...R,set:A}),_[g][h]=R)});function w(...g){let R=Object.keys(_).find(N=>this instanceof r[N]&&h in _[N]),K=_[R],$=()=>K[h].value.call(this,...g);if(t.realdom.domInterceptionNoRecurse.get(this)===h)return $();let H=[],C=[],D=this;["insertBefore"].includes(h)?C=[g[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(h)?(C=[g[1]],["beforebegin","afterend"].includes(g[0])&&(D=this.parentNode)):["setHTMLUnsafe","replaceChildren"].includes(h)?(H=[...this.childNodes],C=h==="replaceChildren"?[...g]:[g[0]]):["replaceWith","remove"].includes(h)?(H=[this],C=h==="replaceWith"?[...g]:[],D=this.parentNode):["replaceChild"].includes(h)?(H=[g[1]],C=[g[0]]):["removeChild"].includes(h)?H=[...g]:(C=[...g],["before","after"].includes(h)&&(D=this.parentNode));let ge=h;if(["insertAdjacentHTML","setHTMLUnsafe"].includes(h)){let N=this.nodeName;if(h==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(g[0])){if(!this.parentNode)return K[h].value.call(this,...g);N=this.parentNode.nodeName}let G=o.createElement(N.includes("-")?"div":N);K.setHTMLUnsafe.value.call(G,C[0],h==="setHTMLUnsafe"?g[1]:{}),C=[...G.childNodes],h==="insertAdjacentHTML"?(ge="insertAdjacentElement",g[1]=new a,c(g[1],"append",()=>g[1].append(...G.childNodes))):(ge="replaceChildren",g=[...G.childNodes])}return D?d({target:D,entrants:C,exits:H,type:"interception",event:[this,h]},()=>K[ge].value.call(this,...g)):$()}function A(g){let R=Object.keys(_).find(J=>this instanceof r[J]&&h in _[J]),K=_[R],$=()=>K[h].set.call(this,g);if(this instanceof HTMLScriptElement||t.realdom.domInterceptionNoRecurse.get(this)===h)return $();let H=[],C=[],D=this;if(["outerHTML","outerText"].includes(h)?(H=[this],D=this.parentNode):this instanceof f?(D=this.content,H=[...this.content.childNodes]):H=[...this.childNodes],["outerHTML","innerHTML"].includes(h)){let J=this.nodeName;if(h==="outerHTML"){if(!this.parentNode)return $();J=this.parentNode.nodeName}let N=o.createElement(J.includes("-")?"div":J);if(c(N,h,()=>N[h]=g),C=this instanceof f?[...N.content.childNodes]:[...N.childNodes],this instanceof f&&this.hasAttribute("src")||this instanceof ShadowRoot){let G=Y=>Y.reduce((W,F)=>F instanceof HTMLScriptElement?W.concat(F):F instanceof f?W.concat(G([F.content])):(W=W.concat(G([...F.querySelectorAll?.("template")||[]].map(st=>st.content))),W.concat(...F.querySelectorAll?.("script")||[])),[]);for(let Y of G(C)){if(this instanceof ShadowRoot){Y.setAttribute("data-handling","manual");continue}let W=o.createElement("script");[...Y.attributes].forEach(F=>W.setAttribute(F.name,F.value)),W.textContent=Y.textContent,c(Y,"replaceWith",()=>Y.replaceWith(W))}}h==="outerHTML"?(g=new a,c(g,"append",()=>g.append(...C)),$=()=>c(this,"replaceWith",()=>l.prototype.replaceWith.call(this,g))):this instanceof f?$=()=>c(this.content,"replaceChildren",()=>this.content.replaceChildren(...C)):$=()=>c(this,"replaceChildren",()=>l.prototype.replaceChildren.call(this,...C))}return d({target:D,entrants:C,exits:H,type:"interception",event:[this,h]},$)}}),m}function et(){Et.call(this),Tt.call(this),Ct.call(this)}function Et(){let n=this;n.CSS||(n.CSS={}),n.CSS.escape||(n.CSS.escape=e=>e.replace(/([\:@\~\$\&])/g,"\\$1"))}function Tt(){let n=this;"isConnected"in n.Node.prototype||Object.defineProperty(n.Node.prototype,"isConnected",{get:function(){return!this.ownerDocument||!(this.ownerDocument.compareDocumentPosition(this)&this.DOCUMENT_POSITION_DISCONNECTED)}})}function Ct(){let n=this;n.Element.prototype.matches||(n.Element.prototype.matches=n.Element.prototype.matchesSelector||n.Element.prototype.mozMatchesSelector||n.Element.prototype.msMatchesSelector||n.Element.prototype.oMatchesSelector||n.Element.prototype.webkitMatchesSelector||function(e){for(var r=(this.document||this.ownerDocument).querySelectorAll(e),t=r.length;--t>=0&&r.item(t)!==this;);return t>-1})}function tt(){let n=this;if(n.webqit||(n.webqit={}),n.webqit.realdom)return n.webqit.realdom;n.webqit.realdom={},et.call(n),n.webqit.realdom.meta=(...r)=>St.call(n,...r),n.webqit.realdom.ready=(...r)=>Le.call(n,...r),n.webqit.realdom.realtime=(r,t="dom")=>{if(t==="dom")return new me(r,n);if(t==="attr")return new z(r,n)};let e=new ce(n);return n.webqit.realdom.schedule=(r,...t)=>e[`on${r}`](...t),n.webqit.realdom.synthesizeWhile=(...r)=>e.synthesizeWhile(...r),n.webqit.realdom}function Le(...n){let e="interactive",r;re(n[0])?(e=n[0],b(n[1])&&(r=n[1])):b(n[0])&&(r=n[0]);let t={interactive:["interactive","complete"],complete:["complete"]};if(!t[e])throw new Error(`Invalid ready-state timing: ${e}.`);let o=this;if(!r)return o.webqit.realdom.readyStatePromises||(o.webqit.realdom.readyStatePromises={interactive:new Promise(s=>Le.call(this,"interactive",s)),complete:new Promise(s=>Le.call(this,"complete",s))}),o.webqit.realdom.readyStatePromises[e];if(t[e].includes(o.document.readyState))return r(o);o.webqit.realdom.readyStateCallbacks||(o.webqit.realdom.readyStateCallbacks={interactive:[],complete:[]},o.document.addEventListener("readystatechange",()=>{let s=o.document.readyState;for(let i of o.webqit.realdom.readyStateCallbacks[s].splice(0))i(o)},!1)),o.webqit.realdom.readyStateCallbacks[e].push(r)}function St(n){let e=this,r={},t;return(t=e.document.querySelector(`meta[name="${n}"]`))&&(r=(t.content||"").split(";").filter(o=>o).reduce((o,s)=>{let i=s.split("=").map(l=>l.trim());return Me(o,i[0].split("."),i[1]==="true"?!0:i[1]==="false"?!1:q(i[1])?parseInt(i[1]):i[1]),o},{})),{get name(){return n},get content(){return t.content},json(){return JSON.parse(JSON.stringify(r))}}}function Oe(n,e){return typeof n!="string"?n:n.replace(/\w\S*/g,function(r){return r.charAt(0).toUpperCase()+(typeof e!==void 0&&e?r.substr(1).toLowerCase():r.substr(1))})}var x=(n,...e)=>P(n,"oohtml",...e),O={};function nt(n,e,r){let t=this,o=tt.call(t);O.window=t,t.webqitConfig||(t.webqitConfig=o.meta("webqit").json()),t.webqit||(t.webqit={}),t.webqit.oohtml||(t.webqit.oohtml={}),t.webqit.oohtml.configs||(t.webqit.oohtml.configs={});let s=n.toUpperCase().replace("-","_");if(!t.webqit.oohtml.configs[s]){t.webqit.oohtml.configs[s]={};let i=t.webqit.oohtml.configs[s];fe(2,i,r,e,o.meta(n).json()),t.webqitConfig.prefix&&Object.keys(i).forEach(l=>{Object.keys(i[l]).forEach(u=>{l==="api"&&typeof i[l][u]=="string"?i[l][u]=`${t.webqitConfig.prefix}${Oe(i[l][u])}`:["attr","elements"].includes(l)&&i[l][u]?.startsWith("data-")===!1&&(i[l][u]=`${t.webqitConfig.prefix}-${i[l][u]}`)})})}return{config:t.webqit.oohtml.configs[s],realdom:o,window:t}}var j=class{static instance(e){return x(e).get("defsmanager::instance")||new this(e)}constructor(e,r=null,t=0){let{window:o}=O,{webqit:{realdom:s,oohtml:{configs:i}}}=o;x(e).get("defsmanager::instance")?.dispose(),x(e).set("defsmanager::instance",this),this.window=o,this.host=e,this.config=i.HTML_IMPORTS,this.parent=r,this.level=t,this.defs=V(this.host),this.defId=(this.host.getAttribute(this.config.attr.def)||"").trim(),this.validateDefId(this.defId),this.realtimeA=s.realtime(this.host.content).children(l=>{this.expose(l.exits,!1),this.expose(l.entrants,!0)},{live:!0,timing:"sync"}),this.realtimeB=s.realtime(this.host).attr(["src","loading"],(...l)=>this.evaluateLoading(...l),{live:!0,atomic:!0,timing:"sync",lifecycleSignals:!0}),this.realtimeC=this.evalInheritance()}validateDefId(e){if(["@","/","*","#"].some(r=>e.includes(r)))throw new Error(`The export ID "${e}" contains an invalid character.`)}expose(e,r){let{window:t}=O,{webqit:{Observer:o}}=t,s,i=this.defs["#"]||[];e.forEach(l=>{if(!l||l.nodeType!==1)return;let u=l.matches(this.config.templateSelector),f=(l.getAttribute(u?this.config.attr.def:this.config.attr.fragmentdef)||"").trim();r?(u&&f?new j(l,this.host,this.level+1):(i.push(l),s=!0,typeof requestIdleCallback=="function"&&requestIdleCallback(()=>{this.config.idleCompilers?.forEach(a=>a.call(this.window,l))})),f&&(this.validateDefId(f),o.set(this.defs,(!u&&"#"||"")+f,l))):(u&&f?j.instance(l).dispose():(i=i.filter(a=>a!==l),s=!0),f&&o.deleteProperty(this.defs,(!u&&"#"||"")+f))}),s&&o.set(this.defs,"#",i)}evaluateLoading([e,r],{signal:t}){let{window:{webqit:{Observer:o}}}=O,s=(e.value||"").trim();if(!s)return;let i,l=a=>{if(!a)return i;i=a.then(()=>f.remove())},u=(r.value||"").trim(),f=o.intercept(this.defs,"get",async(a,m,c)=>(u==="lazy"&&l(this.load(s,!0)),await l(),c()),{signal:t});u!=="lazy"&&l(this.load(s))}#e=new Set;#t;load(e){let{window:r}=O;if(this.#e.has(e)||(this.#e.add(e),this.#e.size===1&&this.host.content.children.length))return Promise.resolve();this.#t?.controller.abort();let t=new AbortController,o=(i,l)=>this.host.dispatchEvent(new r.CustomEvent(i,{detail:l})),s=r.fetch(e,{signal:t.signal,element:this.host}).then(i=>i.ok?i.text():Promise.reject(i.statusText)).then(i=>(this.host.innerHTML=i.trim(),o("load"),this.host)).catch(i=>(console.error(`Error fetching the bundle at "${e}": ${i.message}`),this.#t=null,o("loaderror"),this.host));return this.#t={request:s,controller:t},s}evalInheritance(){if(!this.parent)return[];let{window:{webqit:{Observer:e}}}=O,r=(this.host.getAttribute(this.config.attr.extends)||"").trim(),t=(this.host.getAttribute(this.config.attr.inherits)||"").trim().split(" ").map(l=>l.trim()).filter(l=>l),o=l=>{l.forEach(u=>{e.get(this.defs,u.key)===u.oldValue&&(["get","set","def"].includes(u.type)?e[u.type.replace("get","set")](this.defs,u.key,u.value):u.type==="delete"&&e.deleteProperty(this.defs,u.key))})},s=[],i=V(this.parent);return r&&s.push(e.reduce(i,[r,this.config.api.defs,1/0],e.get,o,{live:!0})),t.length&&s.push(e.get(i,t.includes("*")?1/0:t,o,{live:!0})),s}dispose(){this.realtimeA.disconnect(),this.realtimeB.disconnect(),this.realtimeC.forEach(e=>e instanceof Promise?e.then(r=>r.abort()):e.abort()),Object.entries(this.defs).forEach(([e,r])=>{e.startsWith("#")||j.instance(r).dispose()})}};function it(){let{window:n}=O,{webqit:e}=n;if(e.DOMContextRequestEvent)return e.DOMContextRequestEvent;class r extends n.Event{constructor(...o){let s=o.pop();if(typeof s!="function")throw new Error("Callback must be provided.");let i=o.pop();if(!i?.kind)throw new Error('"options.kind" must be specified.');let l=["contextrequest","contextclaim"],u=o.pop()||l[0];if(!l.includes(u))throw new Error(`Invalid event type. Must be one of: ${l.join(",")}`);let{kind:f,detail:a,targetContext:m,live:c,signal:d,diff:p,..._}=i;super(u,{..._,bubbles:_.bubbles!==!1}),Object.defineProperty(this,"callback",{get:()=>s}),Object.defineProperty(this,"kind",{get:()=>f}),Object.defineProperty(this,"targetContext",{get:()=>m}),Object.defineProperty(this,"detail",{get:()=>a}),Object.defineProperty(this,"live",{get:()=>c}),Object.defineProperty(this,"signal",{get:()=>d}),Object.defineProperty(this,"diff",{get:()=>p}),Object.defineProperty(this,"options",{get:()=>_}),Object.defineProperty(this,"meta",{value:{}})}get target(){return super.target||this.meta.target}get answered(){return this.meta.answered||!1}respondWith(o){if(this.meta.answered=!0,this.diff){if("_prevValue"in this&&this._prevValue===o)return;Object.defineProperty(this,"_prevValue",{value:o,configurable:!0})}return this.callback(o)}}return e.DOMContextRequestEvent=r,r}var de=class extends AbortController{constructor(e){super(),e(r=>{let{window:{webqit:{Observer:t}}}=O;t.defineProperty(this,"value",{value:r,configurable:!0,enumerable:!0})},this)}};var he=class extends Error{};var pe=class{static instance(e){return x(e).get("contexts::instance")||new this(e)}constructor(e){x(e).get("contexts::instance")?.dispose(),x(e).set("contexts::instance",this);let r={host:e,contexts:new Set};Object.defineProperty(this,"#",{get:()=>r})}[Symbol.iterator](){return this["#"].contexts[Symbol.iterator]()}get length(){return this["#"].contexts.size}find(...e){return[...this["#"].contexts].find(r=>typeof e[0]=="function"?e[0](r):r.constructor.kind===e[0]&&(!e[1]||r.detail===e[1]))}attach(e){if(!(e instanceof X))throw new TypeError("Context is not a valid DOMContext instance.");if(this.find(e.constructor.kind,e.detail))throw new he(`Context of same kind "${e.constructor.kind}"${e.detail?` and detail "${e.detail}"`:""} already exists.`);this["#"].contexts.add(e),e.initialize(this["#"].host)}detach(e){e.dispose(this["#"].host),this["#"].contexts.delete(e)}request(...e){return new de((r,t)=>{typeof e[e.length-1]!="function"&&(e[e.length-1]?e.push(r):e[e.length-1]=r);let o;(o=e.find(i=>typeof i=="object"&&i))&&o.live&&(o.signal&&o.signal.addEventListener("abort",()=>t.abort()),e[e.indexOf(o)]={...o,signal:t.signal});let s=new(it())(...e);this["#"].host.dispatchEvent(s)})}};var Re=class{static createRequest(){return{kind:this.kind}}constructor(e=null){Object.defineProperty(this,"detail",{get:()=>e}),Object.defineProperty(this,"subscriptions",{value:new Set})}get configs(){let{window:{webqit:{oohtml:{configs:e}}}}=O;return e}get name(){return[O.window.Document,O.window.ShadowRoot].some(e=>this.host instanceof e)?1/0:this.host.getAttribute(this.configs.CONTEXT_API.attr.contextname)}subscribed(e){}handle(e){}unsubscribed(e){}matchEvent(e){return e.kind===this.constructor.kind&&(!e.targetContext||e.targetContext===this.name)}handleEvent(e){if(!(this.disposed||typeof e.respondWith!="function")){if(e.type==="contextclaim"){if(!(e.detail instanceof Re)||e.target===this.host)return;let r=new Set;if(this.subscriptions.forEach(t=>{!e.target.contains(t.target)||!e.detail.matchEvent(t)||(this.subscriptions.delete(t),this.unsubscribed(t),r.add(t))}),r.size)return e.respondWith(r)}if(e.type==="contextrequest")return this.matchEvent(e)?(e.live&&(this.subscriptions.add(e),this.subscribed(e),e.signal?.addEventListener("abort",()=>{this.subscriptions.delete(e),this.unsubscribed(e)})),e.stopPropagation(),this.handle(e)):void 0}}initialize(e){this.host=e,this.disposed=!1,e.addEventListener("contextrequest",this),e.addEventListener("contextclaim",this);let{value:r}=pe.instance(e).request("contextclaim",{kind:this.constructor.kind,detail:this});return r?.forEach(t=>{this.subscriptions.add(t),this.subscribed(t),this.handle(t)}),this}dispose(e){return this.disposed=!0,e.removeEventListener("contextrequest",this),e.removeEventListener("contextclaim",this),this.subscriptions.forEach(r=>{this.subscriptions.delete(r),this.unsubscribed(r);let{target:t}=r;r.meta.answered=!1,t.dispatchEvent(r)}),this}},X=Re;ye(X,"kind");var Q,I,ne,ie,B=class extends X{constructor(){super(...arguments);oe(this,Q,{});oe(this,I,void 0);oe(this,ne,void 0);oe(this,ie,void 0)}static createRequest(r=null){let t=super.createRequest();if(r?.startsWith("/"))t.detail=r,t.targetContext=1/0;else if(r?.startsWith("@")){let[o,...s]=r.slice(1).split(/(?<=\w)(?=\/|#)/).map(i=>i.trim());t.targetContext=o,t.detail=s.join("")}else t.detail=r;return t}get localModules(){return V(this.host)}get inheritedModules(){return T(this,Q)}handle(r){let{window:{webqit:{Observer:t}}}=O;r.meta.controller?.abort();let o=(r.detail||"").split(/\/|(?<=\w)(?=#)/g).map(i=>i.trim()).filter(i=>i);if(!o.length)return r.respondWith();o=o.join(`/${this.configs.HTML_IMPORTS.api.defs}/`)?.split("/").map(i=>i==="*"?1/0:i)||[];let s={live:r.live,sig_nal:r.signal,descripted:!0};r.meta.controller=t.reduce(T(this,I),o,t.get,i=>{if(Array.isArray(i)){if(!i.length){r.respondWith();return}for(let l of i)r.respondWith(l)}else r.respondWith(i.value)},s)}unsubscribed(r){r.meta.controller?.abort()}initialize(r){this.host=r;let{window:{webqit:{Observer:t}}}=O,o=()=>{for(let i of new Set([...Object.keys(this.localModules),...Object.keys(this.inheritedModules),...Object.keys(T(this,I))]))if(!t.has(this.localModules,i)&&!t.has(this.inheritedModules,i))t.deleteProperty(T(this,I),i);else if(i==="#"&&t.has(this.localModules,i)&&t.has(this.inheritedModules,i))t.set(T(this,I),i,[...t.get(this.localModules,i),...t.get(this.inheritedModules,i)]);else{let l=t.get(this.localModules,i)||t.get(this.inheritedModules,i);t.get(T(this,I),i)!==l&&t.set(T(this,I),i,l)}};ee(this,I,{...this.localModules}),T(this,ne)?.abort(),ee(this,ne,t.observe(this.localModules,()=>o("local"),{timing:"sync"}));let s=this.configs.HTML_IMPORTS;if(this.host.matches&&s.attr.importscontext){let i=this.host.ownerDocument.defaultView.webqit.realdom,l;T(this,ie)?.disconnect(),ee(this,ie,i.realtime(this.host).attr(s.attr.importscontext,(u,{signal:f})=>{let a=(u.value||"").trim();l=a,ee(this,Q,{});let m={...this.constructor.createRequest(a?`${a}/*`:"*"),live:!0,signal:f,diff:!0};this.host.parentNode[this.configs.CONTEXT_API.api.contexts].request(m,c=>{c?c.type==="delete"?(delete T(this,Q)[c.key],Reflect.has(this.localModules,c.key)||t.deleteProperty(T(this,I),c.key)):(T(this,Q)[c.key]=c.value,!Reflect.has(this.localModules,c.key)&&Reflect.get(T(this,I),c.key)!==c.value&&t.set(T(this,I),c.key,c.value)):(ee(this,Q,{}),o("inherited"))}),o("inherited")},{live:!0,timing:"sync",oldValue:!0,lifecycleSignals:!0}))}return super.initialize(r)}dispose(r){return T(this,ne)?.abort(),T(this,ie)?.disconnect(),super.dispose(r)}};Q=new WeakMap,I=new WeakMap,ne=new WeakMap,ie=new WeakMap,ye(B,"kind","html-imports");function ot(){let{window:n}=O,{webqit:e}=n,{realdom:r,oohtml:{configs:t}}=e;if(e.HTMLImportElement)return e.HTMLImportElement;let o=t.HTML_IMPORTS.elements.import.includes("-")?n.HTMLElement:class{};class s extends o{static instance(l){return t.HTML_IMPORTS.elements.import.includes("-")&&l instanceof this?l:x(l).get("import::instance")||new this(l)}constructor(...l){super();let u=l[0]||this;x(u).set("import::instance",this),Object.defineProperty(this,"el",{get:()=>u,configurable:!1});let f={};Object.defineProperty(this,"#",{get:()=>f,configurable:!1}),f.slottedElements=new Set,f.setAnchorNode=a=>(f.anchorNode=a,a),f.live=a=>{if(f.liveImportsRealtime)throw new Error("Import element already in live mode.");let m=this.el.isConnected?this.el.parentNode:f.anchorNode.parentNode;f.liveImportsRealtime=r.realtime(this.el).attr(t.HTML_IMPORTS.attr.ref,(c,{signal:d})=>{f.moduleRef=c.value;let p=f.moduleRef.includes("#")?f.moduleRef:`${f.moduleRef}#`,_={...B.createRequest(p),live:d&&!0,signal:d,diff:!p.endsWith("#")};m[t.CONTEXT_API.api.contexts].request(_,E=>{a((E instanceof n.HTMLTemplateElement?[...E.content.children]:Array.isArray(E)?E:E&&[E])||[])})},{live:!0,timing:"sync",lifecycleSignals:!0}),f.autoDestroyRealtime=r.realtime(n.document).track(m,()=>{f.die()},{subtree:"cross-roots",timing:"sync",generation:"exits"})},f.die=()=>{f.autoDestroyRealtime?.disconnect(),f.liveImportsRealtime?.disconnect(),f.liveImportsRealtime=null},f.hydrate=(a,m)=>{a.replaceWith(f.setAnchorNode(this.createAnchorNode())),f.live(c=>{if(f.originalsRemapped)return this.fill(c);let d=c.map((p,_)=>({el:p,fragmentDef:p.getAttribute(t.HTML_IMPORTS.attr.fragmentdef)||"",tagName:p.tagName,i:_}));m.forEach((p,_)=>{let E=p.tagName,h=p.getAttribute(t.HTML_IMPORTS.attr.fragmentdef)||"",w=(_++,d.find(A=>A.tagName===E&&A.fragmentDef===h&&A.i===_));w&&x(p).set("original@imports",w.el),x(p).set("slot@imports",this.el),f.slottedElements.add(p)}),f.originalsRemapped=!0})},f.autoRestore=(a=null)=>{f.autoRestoreRealtime?.disconnect(),a&&a();let m=()=>{this.el.isConnected||(this.el.setAttribute("data-nodecount",0),f.internalMutation=!0,f.anchorNode.replaceWith(this.el),f.internalMutation=!1,f.setAnchorNode(null))};if(!f.slottedElements.size)return m();let c=r.realtime(f.anchorNode.parentNode).observe([...f.slottedElements],d=>{if(d.exits.forEach(p=>{x(p).delete("slot@imports"),f.slottedElements.delete(p)}),!f.slottedElements.size){if(c.disconnect(),!d.target.isConnected)return;m()}},{subtree:"cross-roots",timing:"sync",generation:"exits"});f.autoRestoreRealtime=c},f.connectedCallback=()=>{f.internalMutation||f.live(a=>this.fill(a))},f.disconnectedCallback=()=>{f.internalMutation||f.die()}}createAnchorNode(){if(n.webqit.env!=="server")return n.document.createTextNode("");let l=n.document.createElement("div");l.textContent=this.el.outerHTML;let u=n.document.createComment(l.innerHTML);return x(u).set("isAnchorNode",!0),u}fill(l,u){!this.el.isConnected&&(!this["#"].anchorNode||!this["#"].anchorNode.isConnected)||(Array.isArray(l)&&(l=new Set(l)),this.el.setAttribute("data-nodecount",l.size),this["#"].autoRestore(()=>{if(this["#"].slottedElements.forEach(f=>{let a=x(f).get("original@imports");l.has(a)?l.delete(a):(this["#"].slottedElements.delete(f),f.remove())}),l.size&&this.el.isConnected){let f=this["#"].setAnchorNode(this.createAnchorNode());this["#"].internalMutation=!0,this.el.replaceWith(f),this["#"].internalMutation=!1}l.forEach(f=>{let a=f.cloneNode(!0);a.hasAttribute(t.HTML_IMPORTS.attr.fragmentdef)||a.toggleAttribute(t.HTML_IMPORTS.attr.fragmentdef,!0),x(a).set("original@imports",f),x(a).set("slot@imports",this.el),this["#"].slottedElements.add(a),this["#"].anchorNode.before(a)})}))}empty(){this["#"].slottedElements.forEach(l=>l.remove())}get anchorNode(){return this["#"].anchorNode}get moduleRef(){return this["#"].moduleRef}get slottedElements(){return this["#"].slottedElements}}return t.HTML_IMPORTS.elements.import.includes("-")&&customElements.define(t.HTML_IMPORTS.elements.import,s),e.HTMLImportElement=s,s}function Ne(n={}){let{config:e,window:r}=nt.call(this,"html-imports",n,{elements:{import:"import"},attr:{def:"def",extends:"extends",inherits:"inherits",ref:"ref",importscontext:"importscontext"},api:{def:"def",defs:"defs",import:"import"}});e.attr.fragmentdef||(e.attr.fragmentdef=e.attr.def),e.templateSelector=`template[${r.CSS.escape(e.attr.def)}]`,e.importsContextSelector=`[${r.CSS.escape(e.attr.importscontext)}]`,e.slottedElementsSelector=`[${r.CSS.escape(e.attr.fragmentdef)}]:not(template)`;let t=(o,s)=>{let i=`starts-with(., "${o}")`,l=`substring(., string-length(.) - string-length("${s}") + 1) = "${s}"`;return`${i} and ${l}`};e.anchorNodeSelector=`comment()[${t(`<${e.elements.import}`,`</${e.elements.import}>`)}]`,r.webqit.HTMLImportsContext=B,r.webqit.HTMLImportElement=ot(),qt.call(r,e),Pt.call(r,e)}function V(n,e=!0){if(!x(n).has("defs")&&e){let r=Object.create(null);x(n).set("defs",r)}return x(n).get("defs")}function qt(n){let e=this,{webqit:{oohtml:{configs:r}}}=e;if(n.api.def in e.HTMLTemplateElement.prototype)throw new Error(`The "HTMLTemplateElement" prototype already has a "${n.api.def}" API!`);if(n.api.defs in e.HTMLTemplateElement.prototype)throw new Error(`The "HTMLTemplateElement" prototype already has a "${n.api.defs}" API!`);Object.defineProperty(e.HTMLTemplateElement.prototype,n.api.def,{get:function(){return this.getAttribute(n.attr.def)}}),Object.defineProperty(e.HTMLTemplateElement.prototype,n.api.defs,{get:function(){return V(this)}}),Object.defineProperty(e.HTMLTemplateElement.prototype,"scoped",{configurable:!0,get(){return this.hasAttribute("scoped")},set(o){this.toggleAttribute("scoped",o)}}),[e.Document.prototype,e.Element.prototype,e.ShadowRoot.prototype].forEach(o=>{let s=o===e.Document.prototype?"Document":o===e.ShadowRoot.prototype?"ShadowRoot":"Element";if(n.api.import in o)throw new Error(`The ${s} prototype already has a "${n.api.import}" API!`);if(n.api.defs in o)throw new Error(`The ${s} prototype already has a "${n.api.defs}" API!`);Object.defineProperty(o,n.api.defs,{get:function(){return V(this)}}),Object.defineProperty(o,n.api.import,{value:function(i,l=!1,u=null){return t(this,...arguments)}})});function t(o,s,i=!1,l=null){let u={};typeof i=="function"?(l=i,i=!1):typeof i=="object"&&i?u={...i,...u}:u={live:i};let f={...B.createRequest(s),...u};return o[r.CONTEXT_API.api.contexts].request(f,l)}}function Pt(n){let e=this,{webqit:{Observer:r,realdom:t,oohtml:{configs:o},HTMLImportElement:s,HTMLImportsContext:i}}=e,l=a=>{let m=a[o.CONTEXT_API.api.contexts];m.find(i.kind)||m.attach(new i)},u=a=>{let m=a[o.CONTEXT_API.api.contexts],c=m.find(i.kind);c&&(!a.isConnected||!a.matches?.(n.importsContextSelector)&&!Object.keys(c.localModules).length)&&m.detach(c)};t.realtime(e.document).query([n.templateSelector,n.importsContextSelector],a=>{a.entrants.forEach(m=>{if(m.matches(n.templateSelector)){let c=j.instance(m);c.ownerContext=m.scoped?m.parentNode:m.getRootNode();let d=V(c.ownerContext);c.defId&&r.set(d,c.defId,m),l(c.ownerContext)}else l(m)}),a.exits.forEach(m=>{if(m.matches(n.templateSelector)){let c=j.instance(m),d=V(c.ownerContext);c.defId&&c.ownerContext.isConnected&&r.deleteProperty(d,c.defId),u(c.ownerContext)}else u(m)})},{id:"imports:template/importscontext",live:!0,subtree:"cross-roots",timing:"sync",staticSensitivity:!0,eventDetails:!0}),t.realtime(e.document).query(n.elements.import,a=>{a.entrants.forEach(m=>f(m,!0,a)),a.exits.forEach(m=>f(m,!1,a))},{id:"imports:import",live:!0,subtree:"cross-roots",timing:"sync",deferred:!0});function f(a,m){let c=s.instance(a);m?c["#"].connectedCallback():c["#"].disconnectedCallback()}e.webqit.env!=="server"&&t.realtime(e.document).query(`(${n.anchorNodeSelector})`,a=>{a.entrants.forEach(m=>{if(x(m).get("isAnchorNode"))return;let c=e.document.createElement("div");c.innerHTML=m.nodeValue,c.innerHTML=c.firstChild.textContent;let d=c.firstChild,p=parseInt(d.getAttribute("data-nodecount")),_=new Set,E=m;for(;(E=E.previousElementSibling)&&E.matches(n.slottedElementsSelector)&&p--;)_.add(E);s.instance(d)["#"].hydrate(m,_)})},{id:"imports:hydration",live:!0,subtree:"cross-roots",timing:"sync"})}Ne.call(window);
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
var __accessCheck = (obj, member, msg) => {
|
|
8
|
+
if (!member.has(obj))
|
|
9
|
+
throw TypeError("Cannot " + msg);
|
|
10
|
+
};
|
|
11
|
+
var __privateGet = (obj, member, getter) => {
|
|
12
|
+
__accessCheck(obj, member, "read from private field");
|
|
13
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
14
|
+
};
|
|
15
|
+
var __privateAdd = (obj, member, value) => {
|
|
16
|
+
if (member.has(obj))
|
|
17
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
18
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
19
|
+
};
|
|
20
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
21
|
+
__accessCheck(obj, member, "write to private field");
|
|
22
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
23
|
+
return value;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// node_modules/@webqit/util/js/isObject.js
|
|
27
|
+
function isObject_default(val) {
|
|
28
|
+
return !Array.isArray(val) && typeof val === "object" && val;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// node_modules/@webqit/util/js/isArray.js
|
|
32
|
+
function isArray_default(val) {
|
|
33
|
+
return Array.isArray(val);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// node_modules/@webqit/util/js/isTypeFunction.js
|
|
37
|
+
function isTypeFunction_default(val) {
|
|
38
|
+
return typeof val === "function";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// node_modules/@webqit/util/js/isNull.js
|
|
42
|
+
function isNull_default(val) {
|
|
43
|
+
return val === null || val === "";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// node_modules/@webqit/util/js/isUndefined.js
|
|
47
|
+
function isUndefined_default(val) {
|
|
48
|
+
return arguments.length && (val === void 0 || typeof val === "undefined");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// node_modules/@webqit/util/js/isTypeObject.js
|
|
52
|
+
function isTypeObject_default(val) {
|
|
53
|
+
return Array.isArray(val) || typeof val === "object" && val || isTypeFunction_default(val);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// node_modules/@webqit/util/js/isEmpty.js
|
|
57
|
+
function isEmpty_default(val) {
|
|
58
|
+
return isNull_default(val) || isUndefined_default(val) || val === false || val === 0 || isTypeObject_default(val) && !Object.keys(val).length;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// node_modules/@webqit/util/js/isFunction.js
|
|
62
|
+
function isFunction_default(val) {
|
|
63
|
+
return isTypeFunction_default(val) || val && {}.toString.call(val) === "[object function]";
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// node_modules/@webqit/util/js/isNumber.js
|
|
67
|
+
function isNumber_default(val) {
|
|
68
|
+
return val instanceof Number || typeof val === "number";
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// node_modules/@webqit/util/js/isNumeric.js
|
|
72
|
+
function isNumeric_default(val) {
|
|
73
|
+
return isNumber_default(val) || val !== true && val !== false && val !== null && val !== "" && !isNaN(val * 1);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// node_modules/@webqit/util/js/isString.js
|
|
77
|
+
function isString_default(val) {
|
|
78
|
+
return val instanceof String || typeof val === "string" && val !== null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// node_modules/@webqit/util/js/isTypeArray.js
|
|
82
|
+
function isTypeArray_default(val) {
|
|
83
|
+
return !isString_default(val) && !isUndefined_default(val.length);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// node_modules/@webqit/util/arr/pushUnique.js
|
|
87
|
+
function pushUnique_default(arr, ...items) {
|
|
88
|
+
items.forEach((itm) => {
|
|
89
|
+
if (arr.indexOf(itm) < 0) {
|
|
90
|
+
arr.push(itm);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
return arr;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// node_modules/@webqit/util/obj/getPrototypeChain.js
|
|
97
|
+
function getPrototypeChain_default(obj, until) {
|
|
98
|
+
until = until || Object.prototype;
|
|
99
|
+
until = until && !isArray_default(until) ? [until] : until;
|
|
100
|
+
var prototypalChain = [];
|
|
101
|
+
var obj = obj;
|
|
102
|
+
while (obj && (!until || until.indexOf(obj) < 0) && obj.name !== "default") {
|
|
103
|
+
prototypalChain.push(obj);
|
|
104
|
+
obj = obj ? Object.getPrototypeOf(obj) : null;
|
|
105
|
+
}
|
|
106
|
+
return prototypalChain;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// node_modules/@webqit/util/obj/getAllPropertyNames.js
|
|
110
|
+
function getAllPropertyNames_default(obj, until) {
|
|
111
|
+
var keysAll = [];
|
|
112
|
+
getPrototypeChain_default(obj, until).forEach((obj2) => {
|
|
113
|
+
pushUnique_default(keysAll, ...Object.getOwnPropertyNames(obj2));
|
|
114
|
+
});
|
|
115
|
+
return keysAll;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// node_modules/@webqit/util/obj/mergeCallback.js
|
|
119
|
+
function mergeCallback(objs, callback, deepProps = false, isReplace = false, withSymbols = false) {
|
|
120
|
+
var depth = 0;
|
|
121
|
+
var obj1 = objs.shift();
|
|
122
|
+
if (isNumeric_default(obj1) || obj1 === true || obj1 === false) {
|
|
123
|
+
depth = obj1;
|
|
124
|
+
obj1 = objs.shift();
|
|
125
|
+
}
|
|
126
|
+
if (!objs.length) {
|
|
127
|
+
throw new Error("_merge() requires two or more array/objects.");
|
|
128
|
+
}
|
|
129
|
+
objs.forEach((obj2, i) => {
|
|
130
|
+
if (!isTypeObject_default(obj2) && !isFunction_default(obj2)) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
(deepProps ? getAllPropertyNames_default(obj2) : Object.keys(obj2)).forEach((key) => {
|
|
134
|
+
if (!callback(key, obj1, obj2, i)) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
var valAtObj1 = obj1[key];
|
|
138
|
+
var valAtObj2 = obj2[key];
|
|
139
|
+
if ((isArray_default(valAtObj1) && isArray_default(valAtObj2) || isObject_default(valAtObj1) && isObject_default(valAtObj2)) && (depth === true || depth > 0)) {
|
|
140
|
+
obj1[key] = isArray_default(valAtObj1) && isArray_default(valAtObj2) ? [] : {};
|
|
141
|
+
mergeCallback([isNumeric_default(depth) ? depth - 1 : depth, obj1[key], valAtObj1, valAtObj2], callback, deepProps, isReplace, withSymbols);
|
|
142
|
+
} else {
|
|
143
|
+
if (isArray_default(obj1) && isArray_default(obj2)) {
|
|
144
|
+
if (isReplace) {
|
|
145
|
+
obj1[key] = valAtObj2;
|
|
146
|
+
} else {
|
|
147
|
+
obj1.push(valAtObj2);
|
|
148
|
+
}
|
|
149
|
+
} else {
|
|
150
|
+
try {
|
|
151
|
+
if (withSymbols) {
|
|
152
|
+
Object.defineProperty(obj1, key, Object.getOwnPropertyDescriptor(obj2, key));
|
|
153
|
+
} else {
|
|
154
|
+
obj1[key] = obj2[key];
|
|
155
|
+
}
|
|
156
|
+
} catch (e) {
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
return obj1;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// node_modules/@webqit/util/obj/merge.js
|
|
166
|
+
function merge_default(...objs) {
|
|
167
|
+
return mergeCallback(objs, (k, obj1, obj2) => {
|
|
168
|
+
return true;
|
|
169
|
+
}, false, false, false);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// node_modules/@webqit/util/js/wq.js
|
|
173
|
+
function wq(obj, ...namespaces) {
|
|
174
|
+
if (!obj || !["object", "function"].includes(typeof obj)) {
|
|
175
|
+
throw new Error(`Argument #1 must be of type object`);
|
|
176
|
+
}
|
|
177
|
+
let wq2 = obj[Symbol.for("wq")];
|
|
178
|
+
if (!wq2) {
|
|
179
|
+
wq2 = new WQInternals();
|
|
180
|
+
Object.defineProperty(obj, Symbol.for("wq"), {
|
|
181
|
+
value: wq2,
|
|
182
|
+
enumerable: false,
|
|
183
|
+
configurable: false,
|
|
184
|
+
writable: false
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
if (!namespaces.length) {
|
|
188
|
+
return wq2;
|
|
189
|
+
}
|
|
190
|
+
let _ns, _wq2;
|
|
191
|
+
while (_ns = namespaces.shift()) {
|
|
192
|
+
if ((_wq2 = wq2) && !(wq2 = wq2.get(_ns))) {
|
|
193
|
+
wq2 = new WQInternals();
|
|
194
|
+
_wq2.set(_ns, wq2);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return wq2;
|
|
198
|
+
}
|
|
199
|
+
var WQInternals = class extends Map {
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
// node_modules/@webqit/util/arr/from.js
|
|
203
|
+
function from_default(val, castObject = true) {
|
|
204
|
+
if (isArray_default(val)) {
|
|
205
|
+
return val;
|
|
206
|
+
}
|
|
207
|
+
;
|
|
208
|
+
if (!castObject && isObject_default(val)) {
|
|
209
|
+
return [val];
|
|
210
|
+
}
|
|
211
|
+
;
|
|
212
|
+
if (val !== false && val !== 0 && isEmpty_default(val)) {
|
|
213
|
+
return [];
|
|
214
|
+
}
|
|
215
|
+
;
|
|
216
|
+
if (isTypeArray_default(val)) {
|
|
217
|
+
return Array.prototype.slice.call(val);
|
|
218
|
+
}
|
|
219
|
+
;
|
|
220
|
+
if (isObject_default(val)) {
|
|
221
|
+
return Object.values(val);
|
|
222
|
+
}
|
|
223
|
+
;
|
|
224
|
+
return [val];
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// node_modules/@webqit/util/obj/get.js
|
|
228
|
+
function get_default(ctxt, path, trap = {}, reciever = {}) {
|
|
229
|
+
path = from_default(path).slice();
|
|
230
|
+
var _ctxt = ctxt;
|
|
231
|
+
while (!isUndefined_default(_ctxt) && !isNull_default(_ctxt) && path.length) {
|
|
232
|
+
var _key = path.shift();
|
|
233
|
+
if (!(trap.get ? trap.get(_ctxt, _key) : isTypeObject_default(_ctxt) ? _key in _ctxt : _ctxt[_key])) {
|
|
234
|
+
reciever.exists = false;
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
_ctxt = trap.get ? trap.get(_ctxt, _key) : _ctxt[_key];
|
|
238
|
+
}
|
|
239
|
+
reciever.exists = true;
|
|
240
|
+
return _ctxt;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// node_modules/@webqit/util/obj/set.js
|
|
244
|
+
function set_default(obj, path, val, buildTree = {}, trap = {}) {
|
|
245
|
+
const _set = (target2, key, val2) => {
|
|
246
|
+
if (trap.set) {
|
|
247
|
+
return trap.set(target2, key, val2);
|
|
248
|
+
} else {
|
|
249
|
+
if (isNumeric_default(path[i]) && isArray_default(target2)) {
|
|
250
|
+
target2.push(val2);
|
|
251
|
+
} else {
|
|
252
|
+
target2[key] = val2;
|
|
253
|
+
}
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
path = from_default(path);
|
|
258
|
+
var target = obj;
|
|
259
|
+
for (var i = 0; i < path.length; i++) {
|
|
260
|
+
if (i < path.length - 1) {
|
|
261
|
+
if (!target || !isTypeObject_default(target) && !isFunction_default(target)) {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
var branch = get_default(target, path[i], trap);
|
|
265
|
+
if (!isTypeObject_default(branch)) {
|
|
266
|
+
if (trap.buildTree === false) {
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
branch = isFunction_default(trap.buildTree) ? trap.buildTree(i) : isNumeric_default(path[i + 1]) ? [] : {};
|
|
270
|
+
var branchSuccess = _set(target, path[i], branch);
|
|
271
|
+
if (!branchSuccess) {
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
target = branch;
|
|
276
|
+
} else {
|
|
277
|
+
return _set(target, path[i], val);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// node_modules/@webqit/realdom/src/Scheduler.js
|
|
283
|
+
var Scheduler = class {
|
|
284
|
+
constructor(window2, synthesis = false) {
|
|
285
|
+
Object.defineProperty(this, "window", { value: window2 });
|
|
286
|
+
Object.defineProperty(this, "readCallbacks", { value: /* @__PURE__ */ new Set() });
|
|
287
|
+
Object.defineProperty(this, "writeCallbacks", { value: /* @__PURE__ */ new Set() });
|
|
288
|
+
Object.defineProperty(this, "_synthesis", { value: 0, writable: true });
|
|
289
|
+
if (!synthesis && this.window.requestAnimationFrame) {
|
|
290
|
+
this._loop();
|
|
291
|
+
} else {
|
|
292
|
+
this._synthesis++;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
get synthesis() {
|
|
296
|
+
return this._synthesis;
|
|
297
|
+
}
|
|
298
|
+
async synthesizeWhile(callback) {
|
|
299
|
+
this._synthesis++;
|
|
300
|
+
this._fulfill();
|
|
301
|
+
const returnValue = await callback();
|
|
302
|
+
this._synthesis--;
|
|
303
|
+
return returnValue;
|
|
304
|
+
}
|
|
305
|
+
_fulfill() {
|
|
306
|
+
for (const callback of this.readCallbacks) {
|
|
307
|
+
callback();
|
|
308
|
+
this.readCallbacks.delete(callback);
|
|
309
|
+
}
|
|
310
|
+
for (const callback of this.writeCallbacks) {
|
|
311
|
+
callback();
|
|
312
|
+
this.writeCallbacks.delete(callback);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
_loop() {
|
|
316
|
+
this.window.requestAnimationFrame(() => {
|
|
317
|
+
this._fulfill();
|
|
318
|
+
this._loop();
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
onread(callback, withPromise = false) {
|
|
322
|
+
if (withPromise) {
|
|
323
|
+
return new Promise((resolve) => {
|
|
324
|
+
if (this.synthesis) {
|
|
325
|
+
resolve(callback());
|
|
326
|
+
} else {
|
|
327
|
+
this.readCallbacks.add(() => {
|
|
328
|
+
resolve(callback());
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
if (this.synthesis) {
|
|
334
|
+
Promise.resolve().then(callback);
|
|
335
|
+
} else {
|
|
336
|
+
this.readCallbacks.add(callback);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
onwrite(callback, withPromise = false) {
|
|
340
|
+
if (withPromise) {
|
|
341
|
+
return new Promise((resolve) => {
|
|
342
|
+
if (this.synthesis) {
|
|
343
|
+
resolve(callback());
|
|
344
|
+
} else {
|
|
345
|
+
this.writeCallbacks.add(() => {
|
|
346
|
+
resolve(callback());
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
if (this.synthesis) {
|
|
352
|
+
Promise.resolve().then(callback);
|
|
353
|
+
} else {
|
|
354
|
+
this.writeCallbacks.add(callback);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
cycle(onread, onwrite, prevTransaction) {
|
|
358
|
+
this.onread(() => {
|
|
359
|
+
const readReturn = onread(prevTransaction);
|
|
360
|
+
const callWrite = (readReturn2) => {
|
|
361
|
+
if (readReturn2 === void 0)
|
|
362
|
+
return;
|
|
363
|
+
this.onwrite(() => {
|
|
364
|
+
const writeReturn = onwrite(readReturn2, prevTransaction);
|
|
365
|
+
const repeatTransaction = (writeReturn2) => {
|
|
366
|
+
if (writeReturn2 === void 0)
|
|
367
|
+
return;
|
|
368
|
+
this.cycle(onread, onwrite, writeReturn2);
|
|
369
|
+
};
|
|
370
|
+
if (writeReturn instanceof Promise) {
|
|
371
|
+
writeReturn.then(repeatTransaction);
|
|
372
|
+
} else {
|
|
373
|
+
repeatTransaction(writeReturn);
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
};
|
|
377
|
+
if (readReturn instanceof Promise) {
|
|
378
|
+
readReturn.then(callWrite);
|
|
379
|
+
} else {
|
|
380
|
+
callWrite(readReturn);
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
// node_modules/@webqit/realdom/src/realtime/Util.js
|
|
387
|
+
function isXpath(expr) {
|
|
388
|
+
return (expr = expr.trim()) && expr.startsWith("(") && expr.endsWith(")");
|
|
389
|
+
}
|
|
390
|
+
function xpathQuery(window2, context, expr, subtree = true) {
|
|
391
|
+
expr = (Array.isArray(expr) ? expr : [expr]).map((x) => (x + "").replace("(", subtree ? "(.//" : "(./")).join("|");
|
|
392
|
+
let nodes = [], node;
|
|
393
|
+
try {
|
|
394
|
+
const result = window2.document.evaluate(expr, context, null, window2.XPathResult.ANY_TYPE);
|
|
395
|
+
while (node = result.iterateNext())
|
|
396
|
+
nodes.push(node);
|
|
397
|
+
} catch (e) {
|
|
398
|
+
}
|
|
399
|
+
return nodes;
|
|
400
|
+
}
|
|
401
|
+
function xpathMatch(window2, node, expr) {
|
|
402
|
+
expr = (Array.isArray(expr) ? expr : [expr]).map((x) => (x + "").replace("(", "(self::")).join("|");
|
|
403
|
+
try {
|
|
404
|
+
return window2.document.evaluate(`${expr}`, node, null, window2.XPathResult.BOOLEAN_TYPE).booleanValue;
|
|
405
|
+
} catch (e) {
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
function containsNode(window2, a, b, crossRoots = false, testCache = null) {
|
|
409
|
+
const prevTest = testCache?.get(a)?.get(b);
|
|
410
|
+
if (typeof prevTest !== "undefined")
|
|
411
|
+
return prevTest;
|
|
412
|
+
const response = (val) => {
|
|
413
|
+
if (!testCache?.has(a))
|
|
414
|
+
testCache?.set(a, /* @__PURE__ */ new WeakMap());
|
|
415
|
+
testCache?.get(a)?.set(b, val);
|
|
416
|
+
return val;
|
|
417
|
+
};
|
|
418
|
+
const rootNodeA = a.getRootNode();
|
|
419
|
+
const rootNodeB = b.getRootNode();
|
|
420
|
+
if (rootNodeA === rootNodeB)
|
|
421
|
+
return response(a.contains(b));
|
|
422
|
+
if (crossRoots && isShadowRoot(rootNodeB))
|
|
423
|
+
return response(containsNode(window2, a, rootNodeB.host, crossRoots, testCache));
|
|
424
|
+
return response(false);
|
|
425
|
+
}
|
|
426
|
+
function splitOuter(str, delim = "|") {
|
|
427
|
+
return [...str].reduce(([quote, depth, splits, skip], x) => {
|
|
428
|
+
if (!quote && depth === 0 && (Array.isArray(delim) ? delim : [delim]).includes(x)) {
|
|
429
|
+
return [quote, depth, [""].concat(splits)];
|
|
430
|
+
}
|
|
431
|
+
if (!quote && ["(", "[", "{"].includes(x) && !splits[0].endsWith("\\"))
|
|
432
|
+
depth++;
|
|
433
|
+
if (!quote && [")", "]", "}"].includes(x) && !splits[0].endsWith("\\"))
|
|
434
|
+
depth--;
|
|
435
|
+
if (['"', "'", "`"].includes(x) && !splits[0].endsWith("\\")) {
|
|
436
|
+
quote = quote === x ? null : quote || x;
|
|
437
|
+
}
|
|
438
|
+
splits[0] += x;
|
|
439
|
+
return [quote, depth, splits];
|
|
440
|
+
}, [null, 0, [""]])[2].reverse();
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// node_modules/@webqit/realdom/src/realtime/DOMSpec.js
|
|
444
|
+
var DOMSpec = class {
|
|
445
|
+
constructor(content) {
|
|
446
|
+
this.content = content;
|
|
447
|
+
this.type = typeof content === "string" ? "selector" : "instance";
|
|
448
|
+
this.kind = this.type === "instance" ? null : isXpath(content) ? "xpath" : "css";
|
|
449
|
+
if (this.kind === "xpath") {
|
|
450
|
+
this.isXpathAttr = splitOuter(content.trim().slice(1, -1), "@").length > 1;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
toString() {
|
|
454
|
+
return this.content;
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
// node_modules/@webqit/realdom/src/realtime/Realtime.js
|
|
459
|
+
var Realtime = class {
|
|
460
|
+
constructor(context, namespace, window2) {
|
|
461
|
+
this.context = context;
|
|
462
|
+
this.namespace = namespace;
|
|
463
|
+
this.window = context.defaultView || context.ownerDocument?.defaultView || window2;
|
|
464
|
+
this.document = this.window.document;
|
|
465
|
+
this.webqit = this.window.webqit;
|
|
466
|
+
Object.defineProperty(this, "#", { value: {} });
|
|
467
|
+
}
|
|
468
|
+
resolveArgs(args) {
|
|
469
|
+
if (isFunction_default(args[0])) {
|
|
470
|
+
args = [[], ...args];
|
|
471
|
+
} else if (isObject_default(args[0]) && !(args[0] instanceof DOMSpec) && args.length === 1) {
|
|
472
|
+
args = [[], void 0, args[0]];
|
|
473
|
+
} else if (isObject_default(args[1]) && args.length === 2) {
|
|
474
|
+
args = [from_default(args[0], false), void 0, args[1]];
|
|
475
|
+
} else {
|
|
476
|
+
args[0] = from_default(args[0], false);
|
|
477
|
+
}
|
|
478
|
+
if (args[0].filter((x) => typeof x !== "string" && !(x instanceof DOMSpec) && !isNode(x)).length) {
|
|
479
|
+
throw new Error(`Argument #2 must be either a string or a Node object, or a list of those.`);
|
|
480
|
+
}
|
|
481
|
+
args[0] = args[0].map((s) => s instanceof DOMSpec ? s : new DOMSpec(s));
|
|
482
|
+
return args;
|
|
483
|
+
}
|
|
484
|
+
registry(...args) {
|
|
485
|
+
return wq(this.window, "realdom", this.namespace, ...args);
|
|
486
|
+
}
|
|
487
|
+
createSignalGenerator() {
|
|
488
|
+
return {
|
|
489
|
+
generate() {
|
|
490
|
+
this.lastController?.abort();
|
|
491
|
+
this.lastController = new AbortController();
|
|
492
|
+
const flags = { signal: this.lastController.signal };
|
|
493
|
+
return flags;
|
|
494
|
+
},
|
|
495
|
+
disconnect() {
|
|
496
|
+
this.lastController?.abort();
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
forEachMatchingContext(interceptionTiming, record_s, callback) {
|
|
501
|
+
const { window: window2 } = this, deferreds = /* @__PURE__ */ new Set(), testCache = /* @__PURE__ */ new WeakMap();
|
|
502
|
+
for (const [registration, deferred] of this.registry(interceptionTiming)) {
|
|
503
|
+
let $records = [].concat(record_s).filter((record) => containsNode(window2, registration.context, record.target, registration.params.subtree === "cross-roots", testCache));
|
|
504
|
+
if (!$records.length)
|
|
505
|
+
continue;
|
|
506
|
+
const args = [registration, Array.isArray(record_s) ? $records : $records[0]];
|
|
507
|
+
if (deferred)
|
|
508
|
+
deferreds.add(args);
|
|
509
|
+
else
|
|
510
|
+
callback.call(window2, ...args);
|
|
511
|
+
}
|
|
512
|
+
for (const args of deferreds)
|
|
513
|
+
callback.call(window2, ...args);
|
|
514
|
+
deferreds.clear();
|
|
515
|
+
}
|
|
516
|
+
disconnectables(signal, ...objects) {
|
|
517
|
+
const disconnectable = { disconnect() {
|
|
518
|
+
objects.forEach((d) => d && isFunction_default(d.disconnect) && d.disconnect() || isFunction_default(d) && d() || isObject_default(d) && (d.disconnected = true));
|
|
519
|
+
} };
|
|
520
|
+
if (signal)
|
|
521
|
+
signal.addEventListener("abort", () => disconnectable.disconnect());
|
|
522
|
+
return disconnectable;
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
|
|
526
|
+
// node_modules/@webqit/realdom/src/realtime/AttrRealtime.js
|
|
527
|
+
var AttrRealtime = class extends Realtime {
|
|
528
|
+
type = "attr";
|
|
529
|
+
constructor(context, ...args) {
|
|
530
|
+
super(context, "attr", ...args);
|
|
531
|
+
}
|
|
532
|
+
get(spec, callback = void 0, params = {}) {
|
|
533
|
+
const originalFilterIsString = typeof spec === "string" || spec instanceof DOMSpec;
|
|
534
|
+
[spec = [], callback = void 0, params = {}] = this.resolveArgs(arguments);
|
|
535
|
+
const { context } = this;
|
|
536
|
+
const records = attrIntersection(context, spec);
|
|
537
|
+
if (!callback)
|
|
538
|
+
return records;
|
|
539
|
+
const signalGenerator = params.lifecycleSignals && this.createSignalGenerator();
|
|
540
|
+
if (!originalFilterIsString) {
|
|
541
|
+
const flags = signalGenerator?.generate() || {};
|
|
542
|
+
callback(records, flags, context);
|
|
543
|
+
} else {
|
|
544
|
+
for (const record of records) {
|
|
545
|
+
const flags = signalGenerator ? signalGenerator.generate() : {};
|
|
546
|
+
callback(record, flags, context);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
if (params.live) {
|
|
550
|
+
if (signalGenerator) {
|
|
551
|
+
params = { ...params, signalGenerator };
|
|
552
|
+
}
|
|
553
|
+
const disconnectable_live = this.observe(originalFilterIsString ? spec[0] : spec, callback, { newValue: true, ...params });
|
|
554
|
+
return this.disconnectables(params.signal, disconnectable_live);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
observe(spec, callback, params = {}) {
|
|
558
|
+
const originalFilterIsString = typeof spec === "string" || spec instanceof DOMSpec;
|
|
559
|
+
[spec = [], callback, params = {}] = this.resolveArgs(arguments);
|
|
560
|
+
if (["sync", "intercept"].includes(params.timing))
|
|
561
|
+
return this.observeSync(originalFilterIsString ? spec[0] : spec, callback, params);
|
|
562
|
+
if (params.timing && params.timing !== "async")
|
|
563
|
+
throw new Error(`Timing option "${params.timing}" invalid.`);
|
|
564
|
+
const { context, window: window2, webqit } = this;
|
|
565
|
+
if (params.eventDetails && !webqit.realdom.attrInterceptionHooks?.intercepting) {
|
|
566
|
+
attrInterception.call(window2, "intercept", () => {
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
const disconnectable = new window2.MutationObserver((records) => {
|
|
570
|
+
records = dedupAndIgnoreInternals(records).map((rcd) => withAttrEventDetails.call(window2, rcd));
|
|
571
|
+
dispatch.call(window2, registration, records, context);
|
|
572
|
+
});
|
|
573
|
+
const $params = { attributes: true, attributeOldValue: params.oldValue, subtree: params.subtree && true };
|
|
574
|
+
if (spec.length) {
|
|
575
|
+
$params.attributeFilter = spec.map((a) => a + "");
|
|
576
|
+
}
|
|
577
|
+
disconnectable.observe(context, $params);
|
|
578
|
+
const signalGenerator = params.signalGenerator || params.lifecycleSignals && this.createSignalGenerator();
|
|
579
|
+
const registration = { context, spec, callback, params, atomics: /* @__PURE__ */ new Map(), originalFilterIsString, signalGenerator, disconnectable };
|
|
580
|
+
return this.disconnectables(params.signal, disconnectable, signalGenerator);
|
|
581
|
+
}
|
|
582
|
+
observeSync(spec, callback, params = {}) {
|
|
583
|
+
const originalFilterIsString = typeof spec === "string" || spec instanceof DOMSpec;
|
|
584
|
+
[spec, callback, params = {}] = this.resolveArgs(arguments);
|
|
585
|
+
const { context, window: window2 } = this;
|
|
586
|
+
if (params.timing && !["sync", "intercept"].includes(params.timing))
|
|
587
|
+
throw new Error(`Timing option "${params.timing}" invalid.`);
|
|
588
|
+
const interceptionTiming = params.timing === "intercept" ? "intercept" : "sync";
|
|
589
|
+
if (!this.registry(interceptionTiming).size) {
|
|
590
|
+
attrInterception.call(window2, interceptionTiming, (records) => {
|
|
591
|
+
this.forEachMatchingContext(interceptionTiming, records, dispatch);
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
const disconnectable = { disconnect() {
|
|
595
|
+
registry.delete(registration);
|
|
596
|
+
} };
|
|
597
|
+
const signalGenerator = params.signalGenerator || params.lifecycleSignals && this.createSignalGenerator();
|
|
598
|
+
const registration = { context, spec, callback, params, atomics: /* @__PURE__ */ new Map(), originalFilterIsString, signalGenerator, disconnectable };
|
|
599
|
+
const registry = this.registry(interceptionTiming);
|
|
600
|
+
registry.set(registration, !!registration.params.deferred);
|
|
601
|
+
return this.disconnectables(params.signal, disconnectable, signalGenerator);
|
|
602
|
+
}
|
|
603
|
+
};
|
|
604
|
+
function dedupAndIgnoreInternals(records) {
|
|
605
|
+
return records.reduce((rcds, rcd, i) => {
|
|
606
|
+
if (rcds[i - 1]?.attributeName === rcd.attributeName)
|
|
607
|
+
return rcds;
|
|
608
|
+
if (wq(rcd.target, "realdom", "internalAttrInteractions").get(rcd.attributeName))
|
|
609
|
+
return rcds;
|
|
610
|
+
return rcds.concat(rcd);
|
|
611
|
+
}, []);
|
|
612
|
+
}
|
|
613
|
+
function dispatch(registration, records) {
|
|
614
|
+
const { context, spec, callback, params, atomics, originalFilterIsString, signalGenerator } = registration;
|
|
615
|
+
if (!params.subtree) {
|
|
616
|
+
records = records.filter((r) => {
|
|
617
|
+
return r.target === context;
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
if (!records.length)
|
|
621
|
+
return;
|
|
622
|
+
const $spec = spec.map((a) => a + "");
|
|
623
|
+
if (params.atomic && !atomics.size) {
|
|
624
|
+
records = attrIntersection(context, spec, records);
|
|
625
|
+
} else if (params.timing !== "async" && spec.length) {
|
|
626
|
+
records = records.filter((r) => $spec.includes(r.name));
|
|
627
|
+
}
|
|
628
|
+
if (!records.length)
|
|
629
|
+
return;
|
|
630
|
+
if (!(params.newValue === null && params.oldValue === null && params.eventDetails)) {
|
|
631
|
+
records = records.map((rcd) => {
|
|
632
|
+
let exclusion;
|
|
633
|
+
if (!params.eventDetails) {
|
|
634
|
+
({ event: exclusion, ...rcd } = rcd);
|
|
635
|
+
}
|
|
636
|
+
if (!params.oldValue && "oldValue" in rcd) {
|
|
637
|
+
({ oldValue: exclusion, ...rcd } = rcd);
|
|
638
|
+
}
|
|
639
|
+
if (!params.newValue && "value" in rcd) {
|
|
640
|
+
({ value: exclusion, ...rcd } = rcd);
|
|
641
|
+
} else if (params.newValue && typeof rcd.value === "undefined") {
|
|
642
|
+
rcd = { ...rcd, value: internalAttrInteraction(rcd.target, rcd.name, () => rcd.target.getAttribute(rcd.name)) };
|
|
643
|
+
}
|
|
644
|
+
return rcd;
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
if (params.atomic) {
|
|
648
|
+
records.forEach((record) => atomics.set(record.name, record));
|
|
649
|
+
records = Array.from(atomics.entries()).map(([, value]) => value);
|
|
650
|
+
}
|
|
651
|
+
const record_s = originalFilterIsString ? records[0] : records;
|
|
652
|
+
const flags = signalGenerator ? signalGenerator.generate() : {};
|
|
653
|
+
callback(record_s, flags, context);
|
|
654
|
+
}
|
|
655
|
+
function internalAttrInteraction(node, attrName, callback) {
|
|
656
|
+
const savedAttrLocking = wq(node, "realdom", "internalAttrInteractions").get(attrName);
|
|
657
|
+
wq(node, "realdom", "internalAttrInteractions").set(attrName, true);
|
|
658
|
+
const value = callback();
|
|
659
|
+
wq(node, "realdom", "internalAttrInteractions").set(attrName, savedAttrLocking);
|
|
660
|
+
return value;
|
|
661
|
+
}
|
|
662
|
+
function attrIntersection(context, spec, records = []) {
|
|
663
|
+
const _type = { event: null, type: "attribute" };
|
|
664
|
+
if (spec.length) {
|
|
665
|
+
return spec.map((attrName) => {
|
|
666
|
+
attrName = attrName + "";
|
|
667
|
+
return records.find((r) => r.name === attrName) || { target: context, name: attrName, value: internalAttrInteraction(context, attrName, () => context.getAttribute(attrName)), ..._type };
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
const attrs = Array.from(context.attributes);
|
|
671
|
+
return attrs.map((attr) => {
|
|
672
|
+
return records.find((r) => r.name === attr.nodeName) || { target: context, name: attr.nodeName, value: internalAttrInteraction(context, attr.nodeName, () => attr.nodeValue), ..._type };
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
function withAttrEventDetails({ target, attributeName, value, oldValue }) {
|
|
676
|
+
const window2 = this, registry = window2.webqit.realdom.attrInterceptionRecords?.get(target) || {};
|
|
677
|
+
const event = registry[attributeName]?.[0] || "mutation";
|
|
678
|
+
const record = { target, name: attributeName, value, oldValue, type: "observation", event };
|
|
679
|
+
return record;
|
|
680
|
+
}
|
|
681
|
+
function attrInterception(timing, callback) {
|
|
682
|
+
const window2 = this;
|
|
683
|
+
const { webqit, document, Element } = window2;
|
|
684
|
+
if (!webqit.realdom.attrInterceptionHooks) {
|
|
685
|
+
Object.defineProperty(webqit.realdom, "attrInterceptionHooks", { value: /* @__PURE__ */ new Map() });
|
|
686
|
+
}
|
|
687
|
+
if (!webqit.realdom.attrInterceptionHooks.has(timing)) {
|
|
688
|
+
webqit.realdom.attrInterceptionHooks.set(timing, /* @__PURE__ */ new Set());
|
|
689
|
+
}
|
|
690
|
+
webqit.realdom.attrInterceptionHooks.get(timing).add(callback);
|
|
691
|
+
const rm = () => webqit.realdom.attrInterceptionHooks.get(timing).delete(callback);
|
|
692
|
+
if (webqit.realdom.attrInterceptionHooks?.intercepting)
|
|
693
|
+
return rm;
|
|
694
|
+
console.warn(`Attr mutation APIs are now being intercepted.`);
|
|
695
|
+
webqit.realdom.attrInterceptionHooks.intercepting = true;
|
|
696
|
+
Object.defineProperty(webqit.realdom, "attrInterceptionRecords", { value: /* @__PURE__ */ new Map() });
|
|
697
|
+
const attrIntercept = (record, defaultAction) => {
|
|
698
|
+
if (!webqit.realdom.attrInterceptionRecords.has(record.target)) {
|
|
699
|
+
webqit.realdom.attrInterceptionRecords.set(record.target, {});
|
|
700
|
+
}
|
|
701
|
+
const registry = webqit.realdom.attrInterceptionRecords.get(record.target);
|
|
702
|
+
registry[record.name] = registry[record.name] || [];
|
|
703
|
+
registry[record.name].unshift(record.event);
|
|
704
|
+
if (wq(record.target, "realdom", "internalAttrInteractions").get(record.name))
|
|
705
|
+
return defaultAction();
|
|
706
|
+
webqit.realdom.attrInterceptionHooks.get("intercept")?.forEach((callback2) => callback2([record]));
|
|
707
|
+
const returnValue = defaultAction();
|
|
708
|
+
webqit.realdom.attrInterceptionHooks.get("sync")?.forEach((callback2) => callback2([record]));
|
|
709
|
+
return returnValue;
|
|
710
|
+
};
|
|
711
|
+
const mo = new window2.MutationObserver((records) => {
|
|
712
|
+
records = records.filter((rcd) => {
|
|
713
|
+
const registry = window2.webqit.realdom.attrInterceptionRecords?.get(rcd.target) || {};
|
|
714
|
+
return !registry[rcd.attributeName]?.shift();
|
|
715
|
+
});
|
|
716
|
+
records = dedupAndIgnoreInternals(records).map((rcd) => withAttrEventDetails.call(window2, rcd));
|
|
717
|
+
if (!records.length)
|
|
718
|
+
return;
|
|
719
|
+
webqit.realdom.attrInterceptionHooks.get("intercept")?.forEach((callback2) => callback2(records));
|
|
720
|
+
webqit.realdom.attrInterceptionHooks.get("sync")?.forEach((callback2) => callback2(records));
|
|
721
|
+
});
|
|
722
|
+
mo.observe(document, { attributes: true, subtree: true, attributeOldValue: true });
|
|
723
|
+
const originalApis = /* @__PURE__ */ Object.create(null);
|
|
724
|
+
["setAttribute", "removeAttribute", "toggleAttribute"].forEach((apiName) => {
|
|
725
|
+
originalApis[apiName] = Element.prototype[apiName];
|
|
726
|
+
Element.prototype[apiName] = function(...args) {
|
|
727
|
+
let value, oldValue = internalAttrInteraction(this, args[0], () => this.getAttribute(args[0]));
|
|
728
|
+
if (["setAttribute", "toggleAttribute"].includes(apiName)) {
|
|
729
|
+
value = args[1];
|
|
730
|
+
}
|
|
731
|
+
if (apiName === "toggleAttribute" && value === void 0) {
|
|
732
|
+
value = oldValue === null ? true : false;
|
|
733
|
+
}
|
|
734
|
+
const record = { target: this, name: args[0], value, oldValue, type: "interception", event: [this, apiName] };
|
|
735
|
+
const exec = () => originalApis[apiName].call(this, ...args);
|
|
736
|
+
return attrIntercept(record, exec);
|
|
737
|
+
};
|
|
738
|
+
});
|
|
739
|
+
return rm;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
// node_modules/@webqit/realdom/src/realtime/DOMRealtime.js
|
|
743
|
+
var DOMRealtime = class extends Realtime {
|
|
744
|
+
constructor(context, ...args) {
|
|
745
|
+
super(context, "tree", ...args);
|
|
746
|
+
}
|
|
747
|
+
attr(filter, callback = void 0, params = {}) {
|
|
748
|
+
const { context, window: window2 } = this;
|
|
749
|
+
return new AttrRealtime(context, window2).get(...arguments);
|
|
750
|
+
}
|
|
751
|
+
query(spec, callback = void 0, params = {}) {
|
|
752
|
+
[spec, callback = void 0, params = {}] = this.resolveArgs(arguments);
|
|
753
|
+
const { context } = this;
|
|
754
|
+
const records = /* @__PURE__ */ new Map(), getRecord = (target) => {
|
|
755
|
+
if (!records.has(target)) {
|
|
756
|
+
records.set(target, { target, entrants: [], exits: [], type: "query", event: null });
|
|
757
|
+
}
|
|
758
|
+
return records.get(target);
|
|
759
|
+
};
|
|
760
|
+
if (!params.generation || params.generation === "entrants") {
|
|
761
|
+
if (!spec.length) {
|
|
762
|
+
[...context.children].forEach((node) => getRecord(context).entrants.push(node));
|
|
763
|
+
} else if (spec.every((s) => s.type === "selector")) {
|
|
764
|
+
const [cssSelectors, xpathQueries] = spec.reduce(([css, xpath], s) => {
|
|
765
|
+
return s.kind === "xpath" ? [css, xpath.concat(s)] : [css.concat(s), xpath];
|
|
766
|
+
}, [[], []]);
|
|
767
|
+
const matches = [];
|
|
768
|
+
if (params.subtree) {
|
|
769
|
+
if (cssSelectors.length) {
|
|
770
|
+
matches.push(...context.querySelectorAll(cssSelectors.join(",")));
|
|
771
|
+
}
|
|
772
|
+
if (xpathQueries.length) {
|
|
773
|
+
matches.push(...xpathQuery(this.window, context, xpathQueries));
|
|
774
|
+
}
|
|
775
|
+
} else {
|
|
776
|
+
if (cssSelectors.length) {
|
|
777
|
+
matches.push(...[...context.children].filter((node) => node.matches(cssSelectors)));
|
|
778
|
+
}
|
|
779
|
+
if (xpathQueries.length) {
|
|
780
|
+
matches.push(...xpathQuery(this.window, context, xpathQueries, false));
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
matches.forEach((node) => getRecord(node.parentNode || context).entrants.push(node));
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
if (!callback)
|
|
787
|
+
return records;
|
|
788
|
+
const disconnectable = { disconnected: false };
|
|
789
|
+
const signalGenerator = callback && params.lifecycleSignals && this.createSignalGenerator();
|
|
790
|
+
for (const [, record] of records) {
|
|
791
|
+
if (disconnectable.disconnected)
|
|
792
|
+
break;
|
|
793
|
+
const flags = signalGenerator?.generate() || {};
|
|
794
|
+
callback(record, flags, context);
|
|
795
|
+
}
|
|
796
|
+
if (params.live) {
|
|
797
|
+
if (signalGenerator) {
|
|
798
|
+
params = { ...params, signalGenerator };
|
|
799
|
+
}
|
|
800
|
+
const disconnectable_live = this.observe(spec, callback, params);
|
|
801
|
+
return this.disconnectables(params.signal, disconnectable, disconnectable_live);
|
|
802
|
+
}
|
|
803
|
+
return this.disconnectables(params.signal, disconnectable, signalGenerator);
|
|
804
|
+
}
|
|
805
|
+
children(spec, callback = void 0, params = {}) {
|
|
806
|
+
[spec, callback = void 0, params = {}] = this.resolveArgs(arguments);
|
|
807
|
+
return this.query(spec, callback, { ...params, subtree: false });
|
|
808
|
+
}
|
|
809
|
+
subtree(spec, callback = void 0, params = {}) {
|
|
810
|
+
[spec, callback = void 0, params = {}] = this.resolveArgs(arguments);
|
|
811
|
+
return this.query(spec, callback, { ...params, subtree: true });
|
|
812
|
+
}
|
|
813
|
+
observe(spec, callback, params = {}) {
|
|
814
|
+
[spec, callback, params = {}] = this.resolveArgs(arguments);
|
|
815
|
+
if (["sync", "intercept"].includes(params.timing))
|
|
816
|
+
return this.observeSync(spec, callback, params);
|
|
817
|
+
if (params.timing && params.timing !== "async")
|
|
818
|
+
throw new Error(`Timing option "${params.timing}" invalid.`);
|
|
819
|
+
const { context, window: window2, webqit, document } = this;
|
|
820
|
+
if (params.eventDetails) {
|
|
821
|
+
webqit.realdom.domInterceptionRecordsAlwaysOn = true;
|
|
822
|
+
}
|
|
823
|
+
if ((document.readyState === "loading" || webqit.realdom.domInterceptionRecordsAlwaysOn) && !webqit.realdom.domInterceptionHooks?.intercepting) {
|
|
824
|
+
domInterception.call(window2, "sync", () => {
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
const disconnectable = new window2.MutationObserver((records) => records.forEach((record) => {
|
|
828
|
+
dispatch2.call(window2, registration, withEventDetails.call(window2, record), context);
|
|
829
|
+
}));
|
|
830
|
+
disconnectable.observe(context, { childList: true, subtree: params.subtree && true });
|
|
831
|
+
const signalGenerator = params.signalGenerator || params.lifecycleSignals && this.createSignalGenerator();
|
|
832
|
+
const registration = { context, spec, callback, params, signalGenerator, disconnectable };
|
|
833
|
+
if (params.staticSensitivity) {
|
|
834
|
+
const disconnectable_attr = staticSensitivity.call(window2, registration);
|
|
835
|
+
return this.disconnectables(params.signal, disconnectable, signalGenerator, disconnectable_attr);
|
|
836
|
+
}
|
|
837
|
+
return this.disconnectables(params.signal, disconnectable, signalGenerator);
|
|
838
|
+
}
|
|
839
|
+
observeSync(spec, callback, params = {}) {
|
|
840
|
+
[spec, callback, params = {}] = this.resolveArgs(arguments);
|
|
841
|
+
const { context, window: window2 } = this;
|
|
842
|
+
if (params.timing && !["sync", "intercept"].includes(params.timing))
|
|
843
|
+
throw new Error(`Timing option "${params.timing}" invalid.`);
|
|
844
|
+
const interceptionTiming = params.timing === "intercept" ? "intercept" : "sync";
|
|
845
|
+
if (!this.registry(interceptionTiming).size) {
|
|
846
|
+
domInterception.call(window2, interceptionTiming, (record) => {
|
|
847
|
+
this.forEachMatchingContext(interceptionTiming, record, dispatch2);
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
const mo = new window2.MutationObserver((records) => records.forEach((record) => {
|
|
851
|
+
if (Array.isArray((record = withEventDetails.call(window2, record)).event))
|
|
852
|
+
return;
|
|
853
|
+
dispatch2.call(window2, registration, record, context);
|
|
854
|
+
}));
|
|
855
|
+
mo.observe(context, { childList: true, subtree: params.subtree && true });
|
|
856
|
+
const disconnectable = {
|
|
857
|
+
disconnect() {
|
|
858
|
+
registry.delete(registration);
|
|
859
|
+
mo.disconnect();
|
|
860
|
+
}
|
|
861
|
+
};
|
|
862
|
+
const signalGenerator = params.signalGenerator || params.lifecycleSignals && this.createSignalGenerator();
|
|
863
|
+
const registration = { context, spec, callback, params, signalGenerator, disconnectable };
|
|
864
|
+
const registry = this.registry(interceptionTiming);
|
|
865
|
+
registry.set(registration, !!registration.params.deferred);
|
|
866
|
+
if (params.staticSensitivity) {
|
|
867
|
+
const disconnectable_attr = staticSensitivity.call(window2, registration);
|
|
868
|
+
return this.disconnectables(params.signal, disconnectable, signalGenerator, disconnectable_attr);
|
|
869
|
+
}
|
|
870
|
+
return this.disconnectables(params.signal, disconnectable, signalGenerator);
|
|
871
|
+
}
|
|
872
|
+
track(elements, callback, params = {}) {
|
|
873
|
+
params = { subtree: true, ...params };
|
|
874
|
+
return this.observe(elements, (record) => {
|
|
875
|
+
if (record.entrants.length)
|
|
876
|
+
callback(true, Array.isArray(elements) ? record.entrants : record.entrants[0]);
|
|
877
|
+
if (record.exits.length)
|
|
878
|
+
callback(false, Array.isArray(elements) ? record.exits : record.exits[0]);
|
|
879
|
+
}, params);
|
|
880
|
+
}
|
|
881
|
+
};
|
|
882
|
+
function staticSensitivity(registration) {
|
|
883
|
+
const window2 = this;
|
|
884
|
+
const { context, spec, callback, params, signalGenerator } = registration;
|
|
885
|
+
const cssSelectors = spec.filter((s) => s.kind === "css");
|
|
886
|
+
const parseDot = (selector) => selector.match(/\.([\w-]+)/g)?.length ? ["class"] : [];
|
|
887
|
+
const parseHash = (selector) => selector.match(/#([\w-]+)/g)?.length ? ["id"] : [];
|
|
888
|
+
const parse = (selector) => [...selector.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map((x) => x[1]).concat(parseDot(selector)).concat(parseHash(selector));
|
|
889
|
+
if (!(registration.$attrs = Array.from(new Set(cssSelectors.filter((s) => (s + "").includes("[")).reduce((attrs, selector) => attrs.concat(parse(selector + "")), [])))).length)
|
|
890
|
+
return;
|
|
891
|
+
const entrants = /* @__PURE__ */ new Set(), exits = /* @__PURE__ */ new Set();
|
|
892
|
+
entrants.push = (val) => (exits.delete(val), entrants.add(val));
|
|
893
|
+
exits.push = (val) => (entrants.delete(val), exits.add(val));
|
|
894
|
+
registration.$deliveryCache = { entrants, exits };
|
|
895
|
+
return new AttrRealtime(context, window2).observe(registration.$attrs, (_records) => {
|
|
896
|
+
const records = /* @__PURE__ */ new Map(), getRecord = (target) => {
|
|
897
|
+
if (!records.has(target)) {
|
|
898
|
+
records.set(target, { target, entrants: [], exits: [], type: "static", event: null });
|
|
899
|
+
}
|
|
900
|
+
return records.get(target);
|
|
901
|
+
};
|
|
902
|
+
const matchesCache = /* @__PURE__ */ new WeakMap();
|
|
903
|
+
const matches = (node) => {
|
|
904
|
+
if (!matchesCache.has(node)) {
|
|
905
|
+
matchesCache.set(node, cssSelectors.some((s) => node.matches(s + "")));
|
|
906
|
+
}
|
|
907
|
+
return matchesCache.get(node);
|
|
908
|
+
};
|
|
909
|
+
for (const _record of _records) {
|
|
910
|
+
["entrants", "exits"].forEach((generation) => {
|
|
911
|
+
if (params.generation && generation !== params.generation)
|
|
912
|
+
return;
|
|
913
|
+
if (registration.$deliveryCache[generation].has(_record.target) || (generation === "entrants" ? !matches(_record.target) : matches(_record.target)))
|
|
914
|
+
return;
|
|
915
|
+
registration.$deliveryCache[generation].push(_record.target);
|
|
916
|
+
getRecord(_record.target)[generation].push(_record.target);
|
|
917
|
+
getRecord(_record.target).event = _record.event;
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
for (const [, record] of records) {
|
|
921
|
+
const flags = signalGenerator?.generate() || {};
|
|
922
|
+
callback(record, flags, context);
|
|
923
|
+
}
|
|
924
|
+
}, { subtree: params.subtree, timing: params.timing, eventDetails: params.eventDetails });
|
|
925
|
+
}
|
|
926
|
+
function dispatch2(registration, _record) {
|
|
927
|
+
const { context, spec, callback, params, signalGenerator, $deliveryCache } = registration;
|
|
928
|
+
const record = { ..._record, entrants: [], exits: [] };
|
|
929
|
+
if (!params.eventDetails) {
|
|
930
|
+
delete record.event;
|
|
931
|
+
}
|
|
932
|
+
["entrants", "exits"].forEach((generation) => {
|
|
933
|
+
if (params.generation && generation !== params.generation)
|
|
934
|
+
return;
|
|
935
|
+
if (spec.length) {
|
|
936
|
+
record[generation] = nodesIntersection.call(this, spec, params.subtree === "cross-roots", _record[generation], _record.event !== "parse");
|
|
937
|
+
} else {
|
|
938
|
+
record[generation] = [..._record[generation]];
|
|
939
|
+
}
|
|
940
|
+
if (!$deliveryCache)
|
|
941
|
+
return;
|
|
942
|
+
for (const node of record[generation]) {
|
|
943
|
+
$deliveryCache[generation].push(node);
|
|
944
|
+
}
|
|
945
|
+
});
|
|
946
|
+
if (!record.entrants.length && !record.exits.length)
|
|
947
|
+
return;
|
|
948
|
+
const flags = signalGenerator?.generate() || {};
|
|
949
|
+
callback(record, flags, context);
|
|
950
|
+
}
|
|
951
|
+
function nodesIntersection(spec, crossRoots, sources, deepIntersect) {
|
|
952
|
+
sources = Array.isArray(sources) ? sources : [...sources];
|
|
953
|
+
const match = (sources2, s) => {
|
|
954
|
+
if (s.type === "selector") {
|
|
955
|
+
let matches = s.isXpathAttr ? [] : sources2.filter((source) => s.kind === "xpath" ? xpathMatch(this, source, s + "") : source.matches && source.matches(s + ""));
|
|
956
|
+
if (deepIntersect || s.isXpathAttr) {
|
|
957
|
+
matches = sources2.reduce((collection, source) => {
|
|
958
|
+
if (s.kind === "xpath") {
|
|
959
|
+
return [...collection, ...xpathQuery(this, source, s, deepIntersect)];
|
|
960
|
+
}
|
|
961
|
+
return source.querySelectorAll ? [...collection, ...source.querySelectorAll(s + "")] : collection;
|
|
962
|
+
}, matches);
|
|
963
|
+
}
|
|
964
|
+
if (matches.length)
|
|
965
|
+
return matches;
|
|
966
|
+
} else {
|
|
967
|
+
if (sources2.includes(s.content) || deepIntersect && sources2.some((source) => containsNode(this, source, s.content, crossRoots))) {
|
|
968
|
+
return [s.content];
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
};
|
|
972
|
+
if (!sources.$$searchCache) {
|
|
973
|
+
sources.$$searchCache = /* @__PURE__ */ new Map();
|
|
974
|
+
}
|
|
975
|
+
return spec.reduce((matches, s) => {
|
|
976
|
+
let _matches;
|
|
977
|
+
if (sources.$$searchCache.has(s.content)) {
|
|
978
|
+
_matches = sources.$$searchCache.get(s.content);
|
|
979
|
+
} else {
|
|
980
|
+
_matches = match(sources, s) || [];
|
|
981
|
+
if (s.type === "instance") {
|
|
982
|
+
sources.$$searchCache.set(s.content, _matches);
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
return matches.concat(_matches);
|
|
986
|
+
}, []);
|
|
987
|
+
}
|
|
988
|
+
function withEventDetails({ target, addedNodes, removedNodes }) {
|
|
989
|
+
let window2 = this, event;
|
|
990
|
+
event = from_default(addedNodes).reduce((prev, node) => prev || window2.webqit.realdom.domInterceptionRecords?.get(node), null);
|
|
991
|
+
event = from_default(removedNodes).reduce((prev, node) => prev || window2.webqit.realdom.domInterceptionRecords?.get(node), event);
|
|
992
|
+
event = event || window2.document.readyState === "loading" && "parse" || "mutation";
|
|
993
|
+
return { target, entrants: addedNodes, exits: removedNodes, type: "observation", event };
|
|
994
|
+
}
|
|
995
|
+
function domInterception(timing, callback) {
|
|
996
|
+
const window2 = this;
|
|
997
|
+
const { webqit, document, Node, CharacterData, Element, HTMLElement, HTMLTemplateElement, DocumentFragment } = window2;
|
|
998
|
+
if (!webqit.realdom.domInterceptionHooks) {
|
|
999
|
+
Object.defineProperty(webqit.realdom, "domInterceptionHooks", { value: /* @__PURE__ */ new Map() });
|
|
1000
|
+
}
|
|
1001
|
+
if (!webqit.realdom.domInterceptionNoRecurse) {
|
|
1002
|
+
Object.defineProperty(webqit.realdom, "domInterceptionNoRecurse", { value: /* @__PURE__ */ new Map() });
|
|
1003
|
+
}
|
|
1004
|
+
if (!webqit.realdom.domInterceptionHooks.has(timing)) {
|
|
1005
|
+
webqit.realdom.domInterceptionHooks.set(timing, /* @__PURE__ */ new Set());
|
|
1006
|
+
}
|
|
1007
|
+
webqit.realdom.domInterceptionHooks.get(timing).add(callback);
|
|
1008
|
+
const rm = () => webqit.realdom.domInterceptionHooks.get(timing).delete(callback);
|
|
1009
|
+
if (webqit.realdom.domInterceptionHooks?.intercepting)
|
|
1010
|
+
return rm;
|
|
1011
|
+
console.warn(`DOM mutation APIs are now being intercepted.`);
|
|
1012
|
+
webqit.realdom.domInterceptionHooks.intercepting = true;
|
|
1013
|
+
Object.defineProperty(webqit.realdom, "domInterceptionRecords", { value: /* @__PURE__ */ new Map() });
|
|
1014
|
+
const noRecurse = (node, method, callback2) => {
|
|
1015
|
+
webqit.realdom.domInterceptionNoRecurse.set(node, method);
|
|
1016
|
+
const returnValue = callback2();
|
|
1017
|
+
webqit.realdom.domInterceptionNoRecurse.delete(node);
|
|
1018
|
+
return returnValue;
|
|
1019
|
+
};
|
|
1020
|
+
const intercept = (record, defaultAction) => {
|
|
1021
|
+
record.entrants.concat(record.exits).forEach((node) => {
|
|
1022
|
+
clearTimeout(webqit.realdom.domInterceptionRecords.get(node)?.timeout);
|
|
1023
|
+
webqit.realdom.domInterceptionRecords.set(node, record.event);
|
|
1024
|
+
const timeout = setTimeout(() => {
|
|
1025
|
+
webqit.realdom.domInterceptionRecords.delete(node);
|
|
1026
|
+
}, 0);
|
|
1027
|
+
Object.defineProperty(record.event, "timeout", { value: timeout, configurable: true });
|
|
1028
|
+
});
|
|
1029
|
+
webqit.realdom.domInterceptionHooks.get("intercept")?.forEach((callback2) => callback2(record));
|
|
1030
|
+
const returnValue = defaultAction();
|
|
1031
|
+
webqit.realdom.domInterceptionHooks.get("sync")?.forEach((callback2) => callback2(record));
|
|
1032
|
+
return returnValue;
|
|
1033
|
+
};
|
|
1034
|
+
const _apiNames = {
|
|
1035
|
+
ShadowRoot: ["innerHTML", "setHTMLUnsafe"],
|
|
1036
|
+
DocumentFragment: ["replaceChildren", "append", "prepend"],
|
|
1037
|
+
Document: ["replaceChildren", "append", "prepend"],
|
|
1038
|
+
HTMLElement: ["outerText", "innerText"],
|
|
1039
|
+
Element: ["append", "prepend", "before", "after", "insertAdjacentElement", "insertAdjacentHTML", "remove", "replaceChildren", "replaceWith", "setHTMLUnsafe", "innerHTML", "outerHTML"],
|
|
1040
|
+
CharacterData: ["before", "after", "remove", "replaceWith"],
|
|
1041
|
+
Node: ["insertBefore", "replaceChild", "removeChild", "appendChild", "textContent", "nodeValue"]
|
|
1042
|
+
};
|
|
1043
|
+
const _apiOriginals = {
|
|
1044
|
+
ShadowRoot: /* @__PURE__ */ Object.create(null),
|
|
1045
|
+
DocumentFragment: /* @__PURE__ */ Object.create(null),
|
|
1046
|
+
Document: /* @__PURE__ */ Object.create(null),
|
|
1047
|
+
HTMLElement: /* @__PURE__ */ Object.create(null),
|
|
1048
|
+
Element: /* @__PURE__ */ Object.create(null),
|
|
1049
|
+
CharacterData: /* @__PURE__ */ Object.create(null),
|
|
1050
|
+
Node: /* @__PURE__ */ Object.create(null)
|
|
1051
|
+
};
|
|
1052
|
+
const _apiNamesUnique = new Set(Object.values(_apiNames).reduce((all, apis) => all.concat(apis), []));
|
|
1053
|
+
_apiNamesUnique.forEach((apiName) => {
|
|
1054
|
+
Object.keys(_apiNames).forEach((DOMClassName) => {
|
|
1055
|
+
if (!_apiNames[DOMClassName].includes(apiName))
|
|
1056
|
+
return;
|
|
1057
|
+
const _apiOriginal = Object.getOwnPropertyDescriptor(window2[DOMClassName].prototype, apiName);
|
|
1058
|
+
if (!_apiOriginal)
|
|
1059
|
+
return;
|
|
1060
|
+
Object.defineProperty(window2[DOMClassName].prototype, apiName, "value" in _apiOriginal ? { ..._apiOriginal, value: method } : { ..._apiOriginal, set: setter });
|
|
1061
|
+
_apiOriginals[DOMClassName][apiName] = _apiOriginal;
|
|
1062
|
+
});
|
|
1063
|
+
function method(...args) {
|
|
1064
|
+
const DOMClassName = Object.keys(_apiOriginals).find((name) => isNodeInterface(this, name) && apiName in _apiOriginals[name]);
|
|
1065
|
+
const $apiOriginals = _apiOriginals[DOMClassName];
|
|
1066
|
+
let exec = () => $apiOriginals[apiName].value.call(this, ...args);
|
|
1067
|
+
if (webqit.realdom.domInterceptionNoRecurse.get(this) === apiName)
|
|
1068
|
+
return exec();
|
|
1069
|
+
let exits = [], entrants = [], target = this;
|
|
1070
|
+
if (["insertBefore"].includes(apiName)) {
|
|
1071
|
+
entrants = [args[0]];
|
|
1072
|
+
} else if (["insertAdjacentElement", "insertAdjacentHTML"].includes(apiName)) {
|
|
1073
|
+
entrants = [args[1]];
|
|
1074
|
+
if (["beforebegin", "afterend"].includes(args[0])) {
|
|
1075
|
+
target = this.parentNode;
|
|
1076
|
+
}
|
|
1077
|
+
} else if (["setHTMLUnsafe", "replaceChildren"].includes(apiName)) {
|
|
1078
|
+
exits = [...this.childNodes];
|
|
1079
|
+
entrants = apiName === "replaceChildren" ? [...args] : [args[0]];
|
|
1080
|
+
} else if (["replaceWith", "remove"].includes(apiName)) {
|
|
1081
|
+
exits = [this];
|
|
1082
|
+
entrants = apiName === "replaceWith" ? [...args] : [];
|
|
1083
|
+
target = this.parentNode;
|
|
1084
|
+
} else if (["replaceChild"].includes(apiName)) {
|
|
1085
|
+
exits = [args[1]];
|
|
1086
|
+
entrants = [args[0]];
|
|
1087
|
+
} else if (["removeChild"].includes(apiName)) {
|
|
1088
|
+
exits = [...args];
|
|
1089
|
+
} else {
|
|
1090
|
+
entrants = [...args];
|
|
1091
|
+
if (["before", "after"].includes(apiName)) {
|
|
1092
|
+
target = this.parentNode;
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
let apiNameFinal = apiName;
|
|
1096
|
+
if (["insertAdjacentHTML", "setHTMLUnsafe"].includes(apiName)) {
|
|
1097
|
+
let tempNodeName = this.nodeName;
|
|
1098
|
+
if (apiName === "insertAdjacentHTML" && ["beforebegin", "afterend"].includes(args[0])) {
|
|
1099
|
+
if (!this.parentNode)
|
|
1100
|
+
return $apiOriginals[apiName].value.call(this, ...args);
|
|
1101
|
+
tempNodeName = this.parentNode.nodeName;
|
|
1102
|
+
}
|
|
1103
|
+
const temp = document.createElement(tempNodeName.includes("-") ? "div" : tempNodeName);
|
|
1104
|
+
$apiOriginals.setHTMLUnsafe.value.call(temp, entrants[0], apiName === "setHTMLUnsafe" ? args[1] : {});
|
|
1105
|
+
entrants = [...temp.childNodes];
|
|
1106
|
+
if (apiName === "insertAdjacentHTML") {
|
|
1107
|
+
apiNameFinal = "insertAdjacentElement";
|
|
1108
|
+
args[1] = new DocumentFragment();
|
|
1109
|
+
noRecurse(args[1], "append", () => args[1].append(...temp.childNodes));
|
|
1110
|
+
} else {
|
|
1111
|
+
apiNameFinal = "replaceChildren";
|
|
1112
|
+
args = [...temp.childNodes];
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
if (!target)
|
|
1116
|
+
return exec();
|
|
1117
|
+
const record = { target, entrants, exits, type: "interception", event: [this, apiName] };
|
|
1118
|
+
return intercept(record, () => {
|
|
1119
|
+
return $apiOriginals[apiNameFinal].value.call(this, ...args);
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
function setter(value) {
|
|
1123
|
+
const DOMClassName = Object.keys(_apiOriginals).find((name) => isNodeInterface(this, name) && apiName in _apiOriginals[name]);
|
|
1124
|
+
const $apiOriginals = _apiOriginals[DOMClassName];
|
|
1125
|
+
let exec = () => $apiOriginals[apiName].set.call(this, value);
|
|
1126
|
+
if (isNodeInterface(this, "HTMLScriptElement") || webqit.realdom.domInterceptionNoRecurse.get(this) === apiName)
|
|
1127
|
+
return exec();
|
|
1128
|
+
let exits = [], entrants = [], target = this;
|
|
1129
|
+
if (["outerHTML", "outerText"].includes(apiName)) {
|
|
1130
|
+
exits = [this];
|
|
1131
|
+
target = this.parentNode;
|
|
1132
|
+
} else {
|
|
1133
|
+
if (isNodeInterface(this, "HTMLTemplateElement")) {
|
|
1134
|
+
target = this.content;
|
|
1135
|
+
exits = [...this.content.childNodes];
|
|
1136
|
+
} else {
|
|
1137
|
+
exits = [...this.childNodes];
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
if (["outerHTML", "innerHTML"].includes(apiName)) {
|
|
1141
|
+
let tempNodeName = this.nodeName;
|
|
1142
|
+
if (apiName === "outerHTML") {
|
|
1143
|
+
if (!this.parentNode)
|
|
1144
|
+
return exec();
|
|
1145
|
+
tempNodeName = this.parentNode.nodeName;
|
|
1146
|
+
}
|
|
1147
|
+
const temp = document.createElement(tempNodeName.includes("-") ? "div" : tempNodeName);
|
|
1148
|
+
noRecurse(temp, apiName, () => temp[apiName] = value);
|
|
1149
|
+
entrants = isNodeInterface(this, "HTMLTemplateElement") ? [...temp.content.childNodes] : [...temp.childNodes];
|
|
1150
|
+
if (isNodeInterface(this, "HTMLTemplateElement") && this.hasAttribute("src") || isShadowRoot(this)) {
|
|
1151
|
+
const getScripts = (nodes) => nodes.reduce((scripts, el) => {
|
|
1152
|
+
if (isNodeInterface(el, "HTMLScriptElement"))
|
|
1153
|
+
return scripts.concat(el);
|
|
1154
|
+
if (isNodeInterface(el, "HTMLTemplateElement"))
|
|
1155
|
+
return scripts.concat(getScripts([el.content]));
|
|
1156
|
+
scripts = scripts.concat(getScripts([...el.querySelectorAll?.("template") || []].map((t) => t.content)));
|
|
1157
|
+
return scripts.concat(...el.querySelectorAll?.("script") || []);
|
|
1158
|
+
}, []);
|
|
1159
|
+
for (const script of getScripts(entrants)) {
|
|
1160
|
+
if (isShadowRoot(this)) {
|
|
1161
|
+
script.setAttribute("data-handling", "manual");
|
|
1162
|
+
continue;
|
|
1163
|
+
}
|
|
1164
|
+
const $script = document.createElement("script");
|
|
1165
|
+
[...script.attributes].forEach((attr) => $script.setAttribute(attr.name, attr.value));
|
|
1166
|
+
$script.textContent = script.textContent;
|
|
1167
|
+
noRecurse(script, "replaceWith", () => script.replaceWith($script));
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
if (apiName === "outerHTML") {
|
|
1171
|
+
value = new DocumentFragment();
|
|
1172
|
+
noRecurse(value, "append", () => value.append(...entrants));
|
|
1173
|
+
exec = () => noRecurse(this, "replaceWith", () => Element.prototype.replaceWith.call(this, value));
|
|
1174
|
+
} else {
|
|
1175
|
+
if (isNodeInterface(this, "HTMLTemplateElement")) {
|
|
1176
|
+
exec = () => noRecurse(this.content, "replaceChildren", () => this.content.replaceChildren(...entrants));
|
|
1177
|
+
} else {
|
|
1178
|
+
exec = () => noRecurse(this, "replaceChildren", () => Element.prototype.replaceChildren.call(this, ...entrants));
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
const record = { target, entrants, exits, type: "interception", event: [this, apiName] };
|
|
1183
|
+
return intercept(record, exec);
|
|
1184
|
+
}
|
|
1185
|
+
});
|
|
1186
|
+
return rm;
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
// node_modules/@webqit/realdom/src/polyfills.js
|
|
1190
|
+
function polyfills_default() {
|
|
1191
|
+
CSS_escape.call(this);
|
|
1192
|
+
Node_isConnected.call(this);
|
|
1193
|
+
Element_matches.call(this);
|
|
1194
|
+
}
|
|
1195
|
+
function CSS_escape() {
|
|
1196
|
+
const window2 = this;
|
|
1197
|
+
if (!window2.CSS) {
|
|
1198
|
+
window2.CSS = {};
|
|
1199
|
+
}
|
|
1200
|
+
if (!window2.CSS.escape) {
|
|
1201
|
+
window2.CSS.escape = (str) => str.replace(/([\:@\~\$\&])/g, "\\$1");
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
function Node_isConnected() {
|
|
1205
|
+
const window2 = this;
|
|
1206
|
+
if (!("isConnected" in window2.Node.prototype)) {
|
|
1207
|
+
Object.defineProperty(window2.Node.prototype, "isConnected", { get: function() {
|
|
1208
|
+
return !this.ownerDocument || !(this.ownerDocument.compareDocumentPosition(this) & this.DOCUMENT_POSITION_DISCONNECTED);
|
|
1209
|
+
} });
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
function Element_matches() {
|
|
1213
|
+
const window2 = this;
|
|
1214
|
+
if (!window2.Element.prototype.matches) {
|
|
1215
|
+
window2.Element.prototype.matches = window2.Element.prototype.matchesSelector || window2.Element.prototype.mozMatchesSelector || window2.Element.prototype.msMatchesSelector || window2.Element.prototype.oMatchesSelector || window2.Element.prototype.webkitMatchesSelector || function(s) {
|
|
1216
|
+
var matches = (this.document || this.ownerDocument).querySelectorAll(s), i = matches.length;
|
|
1217
|
+
while (--i >= 0 && matches.item(i) !== this) {
|
|
1218
|
+
}
|
|
1219
|
+
return i > -1;
|
|
1220
|
+
};
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
// node_modules/@webqit/realdom/src/index.js
|
|
1225
|
+
function src_default() {
|
|
1226
|
+
const window2 = this;
|
|
1227
|
+
if (!window2.webqit)
|
|
1228
|
+
window2.webqit = {};
|
|
1229
|
+
if (window2.webqit.realdom)
|
|
1230
|
+
return window2.webqit.realdom;
|
|
1231
|
+
window2.webqit.realdom = {};
|
|
1232
|
+
polyfills_default.call(window2);
|
|
1233
|
+
window2.webqit.realdom.meta = (...args) => meta.call(window2, ...args);
|
|
1234
|
+
window2.webqit.realdom.ready = (...args) => ready.call(window2, ...args);
|
|
1235
|
+
window2.webqit.realdom.realtime = (context, namespace = "dom") => {
|
|
1236
|
+
if (namespace === "dom")
|
|
1237
|
+
return new DOMRealtime(context, window2);
|
|
1238
|
+
if (namespace === "attr")
|
|
1239
|
+
return new AttrRealtime(context, window2);
|
|
1240
|
+
};
|
|
1241
|
+
const scheduler = new Scheduler(window2);
|
|
1242
|
+
window2.webqit.realdom.schedule = (type, ...args) => {
|
|
1243
|
+
return scheduler[`on${type}`](...args);
|
|
1244
|
+
};
|
|
1245
|
+
window2.webqit.realdom.synthesizeWhile = (...args) => {
|
|
1246
|
+
return scheduler.synthesizeWhile(...args);
|
|
1247
|
+
};
|
|
1248
|
+
return window2.webqit.realdom;
|
|
1249
|
+
}
|
|
1250
|
+
function ready(...args) {
|
|
1251
|
+
let timing = "interactive", callback;
|
|
1252
|
+
if (isString_default(args[0])) {
|
|
1253
|
+
timing = args[0];
|
|
1254
|
+
if (isFunction_default(args[1])) {
|
|
1255
|
+
callback = args[1];
|
|
1256
|
+
}
|
|
1257
|
+
} else if (isFunction_default(args[0])) {
|
|
1258
|
+
callback = args[0];
|
|
1259
|
+
}
|
|
1260
|
+
const timings = { interactive: ["interactive", "complete"], complete: ["complete"] };
|
|
1261
|
+
if (!timings[timing])
|
|
1262
|
+
throw new Error(`Invalid ready-state timing: ${timing}.`);
|
|
1263
|
+
const window2 = this;
|
|
1264
|
+
if (!callback) {
|
|
1265
|
+
if (!window2.webqit.realdom.readyStatePromises) {
|
|
1266
|
+
window2.webqit.realdom.readyStatePromises = {
|
|
1267
|
+
interactive: new Promise((res) => ready.call(this, "interactive", res)),
|
|
1268
|
+
complete: new Promise((res) => ready.call(this, "complete", res))
|
|
1269
|
+
};
|
|
1270
|
+
}
|
|
1271
|
+
return window2.webqit.realdom.readyStatePromises[timing];
|
|
1272
|
+
}
|
|
1273
|
+
if (timings[timing].includes(window2.document.readyState))
|
|
1274
|
+
return callback(window2);
|
|
1275
|
+
if (!window2.webqit.realdom.readyStateCallbacks) {
|
|
1276
|
+
window2.webqit.realdom.readyStateCallbacks = { interactive: [], complete: [] };
|
|
1277
|
+
window2.document.addEventListener("readystatechange", () => {
|
|
1278
|
+
const state = window2.document.readyState;
|
|
1279
|
+
for (const callback2 of window2.webqit.realdom.readyStateCallbacks[state].splice(0)) {
|
|
1280
|
+
callback2(window2);
|
|
1281
|
+
}
|
|
1282
|
+
}, false);
|
|
1283
|
+
}
|
|
1284
|
+
window2.webqit.realdom.readyStateCallbacks[timing].push(callback);
|
|
1285
|
+
}
|
|
1286
|
+
function meta(name) {
|
|
1287
|
+
const window2 = this;
|
|
1288
|
+
let _content = {}, _el;
|
|
1289
|
+
if (_el = window2.document.querySelector(`meta[name="${name}"]`)) {
|
|
1290
|
+
_content = (_el.content || "").split(";").filter((v) => v).reduce((_metaVars, directive) => {
|
|
1291
|
+
const directiveSplit = directive.split("=").map((d) => d.trim());
|
|
1292
|
+
set_default(
|
|
1293
|
+
_metaVars,
|
|
1294
|
+
directiveSplit[0].split("."),
|
|
1295
|
+
directiveSplit[1] === "true" ? true : directiveSplit[1] === "false" ? false : isNumeric_default(directiveSplit[1]) ? parseInt(directiveSplit[1]) : directiveSplit[1]
|
|
1296
|
+
);
|
|
1297
|
+
return _metaVars;
|
|
1298
|
+
}, {});
|
|
1299
|
+
}
|
|
1300
|
+
return {
|
|
1301
|
+
get name() {
|
|
1302
|
+
return name;
|
|
1303
|
+
},
|
|
1304
|
+
get content() {
|
|
1305
|
+
return _el.content;
|
|
1306
|
+
},
|
|
1307
|
+
json() {
|
|
1308
|
+
return JSON.parse(JSON.stringify(_content));
|
|
1309
|
+
}
|
|
1310
|
+
};
|
|
1311
|
+
}
|
|
1312
|
+
function isNode(value) {
|
|
1313
|
+
return value !== null && typeof value === "object" && typeof value.nodeType === "number" && typeof value.nodeName === "string";
|
|
1314
|
+
}
|
|
1315
|
+
function isElement(value) {
|
|
1316
|
+
return value?.nodeType === 1;
|
|
1317
|
+
}
|
|
1318
|
+
function isShadowRoot(value) {
|
|
1319
|
+
return value?.nodeType === 11 && Object.prototype.toString.call(value) === "[object ShadowRoot]";
|
|
1320
|
+
}
|
|
1321
|
+
function isDocument(value) {
|
|
1322
|
+
return value?.nodeType === 9 && Object.prototype.toString.call(value) === "[object Document]";
|
|
1323
|
+
}
|
|
1324
|
+
function isCharacterData(value) {
|
|
1325
|
+
const toStringValue = Object.prototype.toString.call(value);
|
|
1326
|
+
return toStringValue === "[object Text]" || toStringValue === "[object Comment]" || toStringValue === "[object CDATASection]" || toStringValue === "[object ProcessingInstruction]";
|
|
1327
|
+
}
|
|
1328
|
+
function isNodeInterface(value, interfaceName) {
|
|
1329
|
+
if (!isNode(value))
|
|
1330
|
+
return false;
|
|
1331
|
+
if (interfaceName === "ShadowRoot") {
|
|
1332
|
+
return isShadowRoot(value);
|
|
1333
|
+
HTMLUnknownElement;
|
|
1334
|
+
}
|
|
1335
|
+
const toStringValue = Object.prototype.toString.call(value);
|
|
1336
|
+
if (toStringValue === `[object ${interfaceName}]`)
|
|
1337
|
+
return true;
|
|
1338
|
+
if (interfaceName === "DocumentFragment" && isShadowRoot(value))
|
|
1339
|
+
return true;
|
|
1340
|
+
if (interfaceName === "CharacterData" && isCharacterData(value))
|
|
1341
|
+
return true;
|
|
1342
|
+
return (interfaceName === "Node" || interfaceName === "Element" || interfaceName === "HTMLElement") && isElement(value) || interfaceName === "Node" && isNode(value);
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
// node_modules/@webqit/util/str/toTitle.js
|
|
1346
|
+
function toTitle_default(str, strict) {
|
|
1347
|
+
if (typeof str !== "string") {
|
|
1348
|
+
return str;
|
|
1349
|
+
}
|
|
1350
|
+
return str.replace(/\w\S*/g, function(txt) {
|
|
1351
|
+
return txt.charAt(0).toUpperCase() + (typeof strict !== void 0 && strict ? txt.substr(1).toLowerCase() : txt.substr(1));
|
|
1352
|
+
});
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
// src/util.js
|
|
1356
|
+
var _wq = (target, ...args) => wq(target, "oohtml", ...args);
|
|
1357
|
+
var env = {};
|
|
1358
|
+
function _init(name, $config, $defaults) {
|
|
1359
|
+
const window2 = this, realdom = src_default.call(window2);
|
|
1360
|
+
env.window = window2;
|
|
1361
|
+
if (!window2.webqitConfig) {
|
|
1362
|
+
window2.webqitConfig = realdom.meta("webqit").json();
|
|
1363
|
+
}
|
|
1364
|
+
window2.webqit || (window2.webqit = {});
|
|
1365
|
+
window2.webqit.oohtml || (window2.webqit.oohtml = {});
|
|
1366
|
+
window2.webqit.oohtml.configs || (window2.webqit.oohtml.configs = {});
|
|
1367
|
+
const configKey = name.toUpperCase().replace("-", "_");
|
|
1368
|
+
if (!window2.webqit.oohtml.configs[configKey]) {
|
|
1369
|
+
window2.webqit.oohtml.configs[configKey] = {};
|
|
1370
|
+
const config = window2.webqit.oohtml.configs[configKey];
|
|
1371
|
+
merge_default(2, config, $defaults, $config, realdom.meta(name).json());
|
|
1372
|
+
if (window2.webqitConfig.prefix) {
|
|
1373
|
+
Object.keys(config).forEach((main) => {
|
|
1374
|
+
Object.keys(config[main]).forEach((key) => {
|
|
1375
|
+
if (main === "api" && typeof config[main][key] === "string") {
|
|
1376
|
+
config[main][key] = `${window2.webqitConfig.prefix}${toTitle_default(config[main][key])}`;
|
|
1377
|
+
} else if (["attr", "elements"].includes(main) && config[main][key]?.startsWith("data-") === false) {
|
|
1378
|
+
config[main][key] = `${window2.webqitConfig.prefix}-${config[main][key]}`;
|
|
1379
|
+
}
|
|
1380
|
+
});
|
|
1381
|
+
});
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
return { config: window2.webqit.oohtml.configs[configKey], realdom, window: window2 };
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
// src/html-imports/HTMLModule.js
|
|
1388
|
+
var HTMLModule = class {
|
|
1389
|
+
static instance(host) {
|
|
1390
|
+
return _wq(host).get("defsmanager::instance") || new this(host);
|
|
1391
|
+
}
|
|
1392
|
+
constructor(host, parent = null, level = 0) {
|
|
1393
|
+
const { window: window2 } = env, { webqit: { realdom, oohtml: { configs } } } = window2;
|
|
1394
|
+
_wq(host).get(`defsmanager::instance`)?.dispose();
|
|
1395
|
+
_wq(host).set(`defsmanager::instance`, this);
|
|
1396
|
+
this.window = window2;
|
|
1397
|
+
this.host = host;
|
|
1398
|
+
this.config = configs.HTML_IMPORTS;
|
|
1399
|
+
this.parent = parent;
|
|
1400
|
+
this.level = level;
|
|
1401
|
+
this.defs = getDefs(this.host);
|
|
1402
|
+
this.defId = (this.host.getAttribute(this.config.attr.def) || "").trim();
|
|
1403
|
+
this.validateDefId(this.defId);
|
|
1404
|
+
this.realtimeA = realdom.realtime(this.host.content).children((record) => {
|
|
1405
|
+
this.expose(record.exits, false);
|
|
1406
|
+
this.expose(record.entrants, true);
|
|
1407
|
+
}, { live: true, timing: "sync" });
|
|
1408
|
+
this.realtimeB = realdom.realtime(this.host).attr(["src", "loading"], (...args) => this.evaluateLoading(...args), {
|
|
1409
|
+
live: true,
|
|
1410
|
+
atomic: true,
|
|
1411
|
+
timing: "sync",
|
|
1412
|
+
lifecycleSignals: true
|
|
1413
|
+
});
|
|
1414
|
+
this.realtimeC = this.evalInheritance();
|
|
1415
|
+
}
|
|
1416
|
+
validateDefId(defId) {
|
|
1417
|
+
if (["@", "/", "*", "#"].some((token) => defId.includes(token))) {
|
|
1418
|
+
throw new Error(`The export ID "${defId}" contains an invalid character.`);
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
expose(entries, isConnected) {
|
|
1422
|
+
const { window: window2 } = env, { webqit: { Observer } } = window2;
|
|
1423
|
+
let dirty, allFragments = this.defs["#"] || [];
|
|
1424
|
+
entries.forEach((entry) => {
|
|
1425
|
+
if (!entry || entry.nodeType !== 1)
|
|
1426
|
+
return;
|
|
1427
|
+
const isTemplate = entry.matches(this.config.templateSelector);
|
|
1428
|
+
const defId = (entry.getAttribute(isTemplate ? this.config.attr.def : this.config.attr.fragmentdef) || "").trim();
|
|
1429
|
+
if (isConnected) {
|
|
1430
|
+
if (isTemplate && defId) {
|
|
1431
|
+
new HTMLModule(entry, this.host, this.level + 1);
|
|
1432
|
+
} else {
|
|
1433
|
+
allFragments.push(entry);
|
|
1434
|
+
dirty = true;
|
|
1435
|
+
if (typeof requestIdleCallback === "function") {
|
|
1436
|
+
requestIdleCallback(() => {
|
|
1437
|
+
this.config.idleCompilers?.forEach((callback) => callback.call(this.window, entry));
|
|
1438
|
+
});
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
if (defId) {
|
|
1442
|
+
this.validateDefId(defId);
|
|
1443
|
+
Observer.set(this.defs, (!isTemplate && "#" || "") + defId, entry);
|
|
1444
|
+
}
|
|
1445
|
+
} else {
|
|
1446
|
+
if (isTemplate && defId) {
|
|
1447
|
+
HTMLModule.instance(entry).dispose();
|
|
1448
|
+
} else {
|
|
1449
|
+
allFragments = allFragments.filter((x) => x !== entry);
|
|
1450
|
+
dirty = true;
|
|
1451
|
+
}
|
|
1452
|
+
if (defId)
|
|
1453
|
+
Observer.deleteProperty(this.defs, (!isTemplate && "#" || "") + defId);
|
|
1454
|
+
}
|
|
1455
|
+
});
|
|
1456
|
+
if (dirty)
|
|
1457
|
+
Observer.set(this.defs, "#", allFragments);
|
|
1458
|
+
}
|
|
1459
|
+
evaluateLoading([record1, record2], { signal }) {
|
|
1460
|
+
const { window: { webqit: { Observer } } } = env;
|
|
1461
|
+
const src = (record1.value || "").trim();
|
|
1462
|
+
if (!src)
|
|
1463
|
+
return;
|
|
1464
|
+
let $loadingPromise, loadingPromise = (promise) => {
|
|
1465
|
+
if (!promise)
|
|
1466
|
+
return $loadingPromise;
|
|
1467
|
+
$loadingPromise = promise.then(() => interception.remove());
|
|
1468
|
+
};
|
|
1469
|
+
const loading = (record2.value || "").trim();
|
|
1470
|
+
const interception = Observer.intercept(this.defs, "get", async (descriptor, recieved, next) => {
|
|
1471
|
+
if (loading === "lazy") {
|
|
1472
|
+
loadingPromise(this.load(src, true));
|
|
1473
|
+
}
|
|
1474
|
+
await loadingPromise();
|
|
1475
|
+
return next();
|
|
1476
|
+
}, { signal });
|
|
1477
|
+
if (loading !== "lazy") {
|
|
1478
|
+
loadingPromise(this.load(src));
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
#fetchedURLs = /* @__PURE__ */ new Set();
|
|
1482
|
+
#fetchInFlight;
|
|
1483
|
+
load(src) {
|
|
1484
|
+
const { window: window2 } = env;
|
|
1485
|
+
if (this.#fetchedURLs.has(src)) {
|
|
1486
|
+
return Promise.resolve();
|
|
1487
|
+
}
|
|
1488
|
+
this.#fetchedURLs.add(src);
|
|
1489
|
+
if (this.#fetchedURLs.size === 1 && this.host.content.children.length) {
|
|
1490
|
+
return Promise.resolve();
|
|
1491
|
+
}
|
|
1492
|
+
this.#fetchInFlight?.controller.abort();
|
|
1493
|
+
const controller = new AbortController();
|
|
1494
|
+
const fire = (type, detail) => this.host.dispatchEvent(new window2.CustomEvent(type, { detail }));
|
|
1495
|
+
const request = window2.fetch(src, { signal: controller.signal, element: this.host }).then((response) => {
|
|
1496
|
+
return response.ok ? response.text() : Promise.reject(response.statusText);
|
|
1497
|
+
}).then((content) => {
|
|
1498
|
+
this.host.innerHTML = content.trim();
|
|
1499
|
+
fire("load");
|
|
1500
|
+
return this.host;
|
|
1501
|
+
}).catch((e) => {
|
|
1502
|
+
console.error(`Error fetching the bundle at "${src}": ${e.message}`);
|
|
1503
|
+
this.#fetchInFlight = null;
|
|
1504
|
+
fire("loaderror");
|
|
1505
|
+
return this.host;
|
|
1506
|
+
});
|
|
1507
|
+
this.#fetchInFlight = { request, controller };
|
|
1508
|
+
return request;
|
|
1509
|
+
}
|
|
1510
|
+
evalInheritance() {
|
|
1511
|
+
if (!this.parent)
|
|
1512
|
+
return [];
|
|
1513
|
+
const { window: { webqit: { Observer } } } = env;
|
|
1514
|
+
let extendedId = (this.host.getAttribute(this.config.attr.extends) || "").trim();
|
|
1515
|
+
let inheritedIds = (this.host.getAttribute(this.config.attr.inherits) || "").trim().split(" ").map((id) => id.trim()).filter((x) => x);
|
|
1516
|
+
const handleInherited = (records) => {
|
|
1517
|
+
records.forEach((record) => {
|
|
1518
|
+
if (Observer.get(this.defs, record.key) !== record.oldValue)
|
|
1519
|
+
return;
|
|
1520
|
+
if (["get", "set", "def"].includes(record.type)) {
|
|
1521
|
+
Observer[record.type.replace("get", "set")](this.defs, record.key, record.value);
|
|
1522
|
+
} else if (record.type === "delete") {
|
|
1523
|
+
Observer.deleteProperty(this.defs, record.key);
|
|
1524
|
+
}
|
|
1525
|
+
});
|
|
1526
|
+
};
|
|
1527
|
+
const realtimes = [];
|
|
1528
|
+
const parentDefsObj = getDefs(this.parent);
|
|
1529
|
+
if (extendedId) {
|
|
1530
|
+
realtimes.push(Observer.reduce(parentDefsObj, [extendedId, this.config.api.defs, Infinity], Observer.get, handleInherited, { live: true }));
|
|
1531
|
+
}
|
|
1532
|
+
if (inheritedIds.length) {
|
|
1533
|
+
realtimes.push(Observer.get(parentDefsObj, inheritedIds.includes("*") ? Infinity : inheritedIds, handleInherited, { live: true }));
|
|
1534
|
+
}
|
|
1535
|
+
return realtimes;
|
|
1536
|
+
}
|
|
1537
|
+
dispose() {
|
|
1538
|
+
this.realtimeA.disconnect();
|
|
1539
|
+
this.realtimeB.disconnect();
|
|
1540
|
+
this.realtimeC.forEach((r) => r instanceof Promise ? r.then((r2) => r2.abort()) : r.abort());
|
|
1541
|
+
Object.entries(this.defs).forEach(([key, entry]) => {
|
|
1542
|
+
if (key.startsWith("#"))
|
|
1543
|
+
return;
|
|
1544
|
+
HTMLModule.instance(entry).dispose();
|
|
1545
|
+
});
|
|
1546
|
+
}
|
|
1547
|
+
};
|
|
1548
|
+
|
|
1549
|
+
// src/context-api/_DOMContextRequestEvent.js
|
|
1550
|
+
function DOMContextRequestEvent_default() {
|
|
1551
|
+
const { window: window2 } = env, { webqit } = window2;
|
|
1552
|
+
if (webqit.DOMContextRequestEvent)
|
|
1553
|
+
return webqit.DOMContextRequestEvent;
|
|
1554
|
+
class DOMContextRequestEvent extends window2.Event {
|
|
1555
|
+
constructor(...args) {
|
|
1556
|
+
const callback = args.pop();
|
|
1557
|
+
if (typeof callback !== "function")
|
|
1558
|
+
throw new Error(`Callback must be provided.`);
|
|
1559
|
+
const options = args.pop();
|
|
1560
|
+
if (!options?.kind)
|
|
1561
|
+
throw new Error(`"options.kind" must be specified.`);
|
|
1562
|
+
const eventNames = ["contextrequest", "contextclaim"];
|
|
1563
|
+
const type = args.pop() || eventNames[0];
|
|
1564
|
+
if (!eventNames.includes(type))
|
|
1565
|
+
throw new Error(`Invalid event type. Must be one of: ${eventNames.join(",")}`);
|
|
1566
|
+
const { kind, detail, targetContext, live, signal, diff, ...otherOpts } = options;
|
|
1567
|
+
super(type, { ...otherOpts, bubbles: otherOpts.bubbles !== false });
|
|
1568
|
+
Object.defineProperty(this, "callback", { get: () => callback });
|
|
1569
|
+
Object.defineProperty(this, "kind", { get: () => kind });
|
|
1570
|
+
Object.defineProperty(this, "targetContext", { get: () => targetContext });
|
|
1571
|
+
Object.defineProperty(this, "detail", { get: () => detail });
|
|
1572
|
+
Object.defineProperty(this, "live", { get: () => live });
|
|
1573
|
+
Object.defineProperty(this, "signal", { get: () => signal });
|
|
1574
|
+
Object.defineProperty(this, "diff", { get: () => diff });
|
|
1575
|
+
Object.defineProperty(this, "options", { get: () => otherOpts });
|
|
1576
|
+
Object.defineProperty(this, "meta", { value: {} });
|
|
1577
|
+
}
|
|
1578
|
+
get target() {
|
|
1579
|
+
return super.target || this.meta.target;
|
|
1580
|
+
}
|
|
1581
|
+
get answered() {
|
|
1582
|
+
return this.meta.answered || false;
|
|
1583
|
+
}
|
|
1584
|
+
respondWith(response) {
|
|
1585
|
+
this.meta.answered = true;
|
|
1586
|
+
if (this.diff) {
|
|
1587
|
+
if ("_prevValue" in this && this._prevValue === response)
|
|
1588
|
+
return;
|
|
1589
|
+
Object.defineProperty(this, "_prevValue", { value: response, configurable: true });
|
|
1590
|
+
}
|
|
1591
|
+
return this.callback(response);
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
webqit.DOMContextRequestEvent = DOMContextRequestEvent;
|
|
1595
|
+
return DOMContextRequestEvent;
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
// src/context-api/DOMContextResponse.js
|
|
1599
|
+
var DOMContextResponse = class extends AbortController {
|
|
1600
|
+
constructor(callback) {
|
|
1601
|
+
super();
|
|
1602
|
+
callback((response) => {
|
|
1603
|
+
const { window: { webqit: { Observer } } } = env;
|
|
1604
|
+
Observer.defineProperty(this, "value", { value: response, configurable: true, enumerable: true });
|
|
1605
|
+
}, this);
|
|
1606
|
+
}
|
|
1607
|
+
};
|
|
1608
|
+
|
|
1609
|
+
// src/context-api/DuplicateContextError.js
|
|
1610
|
+
var DuplicateContextError = class extends Error {
|
|
1611
|
+
};
|
|
1612
|
+
|
|
1613
|
+
// src/context-api/DOMContexts.js
|
|
1614
|
+
var DOMContexts = class {
|
|
1615
|
+
static instance(host) {
|
|
1616
|
+
return _wq(host).get("contexts::instance") || new this(host);
|
|
1617
|
+
;
|
|
1618
|
+
}
|
|
1619
|
+
constructor(host) {
|
|
1620
|
+
_wq(host).get(`contexts::instance`)?.dispose();
|
|
1621
|
+
_wq(host).set(`contexts::instance`, this);
|
|
1622
|
+
const priv = { host, contexts: /* @__PURE__ */ new Set() };
|
|
1623
|
+
Object.defineProperty(this, "#", { get: () => priv });
|
|
1624
|
+
}
|
|
1625
|
+
[Symbol.iterator]() {
|
|
1626
|
+
return this["#"].contexts[Symbol.iterator]();
|
|
1627
|
+
}
|
|
1628
|
+
get length() {
|
|
1629
|
+
return this["#"].contexts.size;
|
|
1630
|
+
}
|
|
1631
|
+
find(...args) {
|
|
1632
|
+
return [...this["#"].contexts].find((ctx) => {
|
|
1633
|
+
if (typeof args[0] === "function")
|
|
1634
|
+
return args[0](ctx);
|
|
1635
|
+
return ctx.constructor.kind === args[0] && (!args[1] || ctx.detail === args[1]);
|
|
1636
|
+
});
|
|
1637
|
+
}
|
|
1638
|
+
attach(ctx) {
|
|
1639
|
+
if (!(ctx instanceof DOMContext))
|
|
1640
|
+
throw new TypeError(`Context is not a valid DOMContext instance.`);
|
|
1641
|
+
if (this.find(ctx.constructor.kind, ctx.detail)) {
|
|
1642
|
+
throw new DuplicateContextError(`Context of same kind "${ctx.constructor.kind}"${ctx.detail ? ` and detail "${ctx.detail}"` : ""} already exists.`);
|
|
1643
|
+
}
|
|
1644
|
+
this["#"].contexts.add(ctx);
|
|
1645
|
+
ctx.initialize(this["#"].host);
|
|
1646
|
+
}
|
|
1647
|
+
detach(ctx) {
|
|
1648
|
+
ctx.dispose(this["#"].host);
|
|
1649
|
+
this["#"].contexts.delete(ctx);
|
|
1650
|
+
}
|
|
1651
|
+
request(...args) {
|
|
1652
|
+
return new DOMContextResponse((emitter, responseInstance) => {
|
|
1653
|
+
if (typeof args[args.length - 1] !== "function") {
|
|
1654
|
+
if (!args[args.length - 1]) {
|
|
1655
|
+
args[args.length - 1] = emitter;
|
|
1656
|
+
} else {
|
|
1657
|
+
args.push(emitter);
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
let options;
|
|
1661
|
+
if ((options = args.find((arg) => typeof arg === "object" && arg)) && options.live) {
|
|
1662
|
+
if (options.signal)
|
|
1663
|
+
options.signal.addEventListener("abort", () => responseInstance.abort());
|
|
1664
|
+
args[args.indexOf(options)] = { ...options, signal: responseInstance.signal };
|
|
1665
|
+
}
|
|
1666
|
+
const event = new (DOMContextRequestEvent_default())(...args);
|
|
1667
|
+
this["#"].host.dispatchEvent(event);
|
|
1668
|
+
});
|
|
1669
|
+
}
|
|
1670
|
+
};
|
|
1671
|
+
|
|
1672
|
+
// src/context-api/DOMContext.js
|
|
1673
|
+
var _DOMContext = class {
|
|
1674
|
+
static createRequest() {
|
|
1675
|
+
return { kind: this.kind };
|
|
1676
|
+
}
|
|
1677
|
+
constructor(detail = null) {
|
|
1678
|
+
Object.defineProperty(this, "detail", { get: () => detail });
|
|
1679
|
+
Object.defineProperty(this, "subscriptions", { value: /* @__PURE__ */ new Set() });
|
|
1680
|
+
}
|
|
1681
|
+
get configs() {
|
|
1682
|
+
const { window: { webqit: { oohtml: { configs } } } } = env;
|
|
1683
|
+
return configs;
|
|
1684
|
+
}
|
|
1685
|
+
get name() {
|
|
1686
|
+
return isDocument(this.host) || isShadowRoot(this.host) ? Infinity : this.host.getAttribute(this.configs.CONTEXT_API.attr.contextname);
|
|
1687
|
+
}
|
|
1688
|
+
subscribed(event) {
|
|
1689
|
+
}
|
|
1690
|
+
handle(event) {
|
|
1691
|
+
}
|
|
1692
|
+
unsubscribed(event) {
|
|
1693
|
+
}
|
|
1694
|
+
matchEvent(event) {
|
|
1695
|
+
return event.kind === this.constructor.kind && (!event.targetContext || event.targetContext === this.name);
|
|
1696
|
+
}
|
|
1697
|
+
handleEvent(event) {
|
|
1698
|
+
if (this.disposed || typeof event.respondWith !== "function")
|
|
1699
|
+
return;
|
|
1700
|
+
if (event.type === "contextclaim") {
|
|
1701
|
+
if (!(event.detail instanceof _DOMContext) || event.target === this.host)
|
|
1702
|
+
return;
|
|
1703
|
+
const claims = /* @__PURE__ */ new Set();
|
|
1704
|
+
this.subscriptions.forEach((subscriptionEvent) => {
|
|
1705
|
+
if (!event.target.contains(subscriptionEvent.target) || !event.detail.matchEvent(subscriptionEvent))
|
|
1706
|
+
return;
|
|
1707
|
+
this.subscriptions.delete(subscriptionEvent);
|
|
1708
|
+
this.unsubscribed(subscriptionEvent);
|
|
1709
|
+
claims.add(subscriptionEvent);
|
|
1710
|
+
});
|
|
1711
|
+
if (claims.size) {
|
|
1712
|
+
return event.respondWith(claims);
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
if (event.type === "contextrequest") {
|
|
1716
|
+
if (!this.matchEvent(event))
|
|
1717
|
+
return;
|
|
1718
|
+
if (event.live) {
|
|
1719
|
+
this.subscriptions.add(event);
|
|
1720
|
+
this.subscribed(event);
|
|
1721
|
+
event.signal?.addEventListener("abort", () => {
|
|
1722
|
+
this.subscriptions.delete(event);
|
|
1723
|
+
this.unsubscribed(event);
|
|
1724
|
+
});
|
|
1725
|
+
}
|
|
1726
|
+
event.stopPropagation();
|
|
1727
|
+
return this.handle(event);
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
initialize(host) {
|
|
1731
|
+
this.host = host;
|
|
1732
|
+
this.disposed = false;
|
|
1733
|
+
host.addEventListener("contextrequest", this);
|
|
1734
|
+
host.addEventListener("contextclaim", this);
|
|
1735
|
+
const { value: claims } = DOMContexts.instance(host).request("contextclaim", { kind: this.constructor.kind, detail: this });
|
|
1736
|
+
claims?.forEach((subscriptionEvent) => {
|
|
1737
|
+
this.subscriptions.add(subscriptionEvent);
|
|
1738
|
+
this.subscribed(subscriptionEvent);
|
|
1739
|
+
this.handle(subscriptionEvent);
|
|
1740
|
+
});
|
|
1741
|
+
return this;
|
|
1742
|
+
}
|
|
1743
|
+
dispose(host) {
|
|
1744
|
+
this.disposed = true;
|
|
1745
|
+
host.removeEventListener("contextrequest", this);
|
|
1746
|
+
host.removeEventListener("contextclaim", this);
|
|
1747
|
+
this.subscriptions.forEach((subscriptionEvent) => {
|
|
1748
|
+
this.subscriptions.delete(subscriptionEvent);
|
|
1749
|
+
this.unsubscribed(subscriptionEvent);
|
|
1750
|
+
const { target } = subscriptionEvent;
|
|
1751
|
+
subscriptionEvent.meta.answered = false;
|
|
1752
|
+
target.dispatchEvent(subscriptionEvent);
|
|
1753
|
+
});
|
|
1754
|
+
return this;
|
|
1755
|
+
}
|
|
1756
|
+
};
|
|
1757
|
+
var DOMContext = _DOMContext;
|
|
1758
|
+
__publicField(DOMContext, "kind");
|
|
1759
|
+
|
|
1760
|
+
// src/html-imports/HTMLImportsContext.js
|
|
1761
|
+
var _inheritedModules, _modules, _controller1, _controller2;
|
|
1762
|
+
var HTMLImportsContext = class extends DOMContext {
|
|
1763
|
+
constructor() {
|
|
1764
|
+
super(...arguments);
|
|
1765
|
+
__privateAdd(this, _inheritedModules, {});
|
|
1766
|
+
__privateAdd(this, _modules, void 0);
|
|
1767
|
+
__privateAdd(this, _controller1, void 0);
|
|
1768
|
+
__privateAdd(this, _controller2, void 0);
|
|
1769
|
+
}
|
|
1770
|
+
static createRequest(detail = null) {
|
|
1771
|
+
const request = super.createRequest();
|
|
1772
|
+
if (detail?.startsWith("/")) {
|
|
1773
|
+
request.detail = detail;
|
|
1774
|
+
request.targetContext = Infinity;
|
|
1775
|
+
} else if (detail?.startsWith("@")) {
|
|
1776
|
+
const [targetContext, ..._detail] = detail.slice(1).split(/(?<=\w)(?=\/|#)/).map((s) => s.trim());
|
|
1777
|
+
request.targetContext = targetContext;
|
|
1778
|
+
request.detail = _detail.join("");
|
|
1779
|
+
} else {
|
|
1780
|
+
request.detail = detail;
|
|
1781
|
+
}
|
|
1782
|
+
return request;
|
|
1783
|
+
}
|
|
1784
|
+
get localModules() {
|
|
1785
|
+
return getDefs(this.host);
|
|
1786
|
+
}
|
|
1787
|
+
get inheritedModules() {
|
|
1788
|
+
return __privateGet(this, _inheritedModules);
|
|
1789
|
+
}
|
|
1790
|
+
handle(event) {
|
|
1791
|
+
const { window: { webqit: { Observer } } } = env;
|
|
1792
|
+
event.meta.controller?.abort();
|
|
1793
|
+
let path = (event.detail || "").split(/\/|(?<=\w)(?=#)/g).map((x) => x.trim()).filter((x) => x);
|
|
1794
|
+
if (!path.length)
|
|
1795
|
+
return event.respondWith();
|
|
1796
|
+
path = path.join(`/${this.configs.HTML_IMPORTS.api.defs}/`)?.split("/").map((x) => x === "*" ? Infinity : x) || [];
|
|
1797
|
+
const options = { live: event.live, sig_nal: event.signal, descripted: true };
|
|
1798
|
+
event.meta.controller = Observer.reduce(__privateGet(this, _modules), path, Observer.get, (m) => {
|
|
1799
|
+
if (Array.isArray(m)) {
|
|
1800
|
+
if (!m.length) {
|
|
1801
|
+
event.respondWith();
|
|
1802
|
+
return;
|
|
1803
|
+
}
|
|
1804
|
+
for (const n of m) {
|
|
1805
|
+
event.respondWith(n);
|
|
1806
|
+
}
|
|
1807
|
+
} else {
|
|
1808
|
+
event.respondWith(m.value);
|
|
1809
|
+
}
|
|
1810
|
+
}, options);
|
|
1811
|
+
}
|
|
1812
|
+
unsubscribed(event) {
|
|
1813
|
+
event.meta.controller?.abort();
|
|
1814
|
+
}
|
|
1815
|
+
initialize(host) {
|
|
1816
|
+
this.host = host;
|
|
1817
|
+
const { window: { webqit: { Observer } } } = env;
|
|
1818
|
+
const resolve = () => {
|
|
1819
|
+
for (const key of /* @__PURE__ */ new Set([...Object.keys(this.localModules), ...Object.keys(this.inheritedModules), ...Object.keys(__privateGet(this, _modules))])) {
|
|
1820
|
+
if (!Observer.has(this.localModules, key) && !Observer.has(this.inheritedModules, key)) {
|
|
1821
|
+
Observer.deleteProperty(__privateGet(this, _modules), key);
|
|
1822
|
+
} else if (key === "#" && Observer.has(this.localModules, key) && Observer.has(this.inheritedModules, key)) {
|
|
1823
|
+
Observer.set(__privateGet(this, _modules), key, [...Observer.get(this.localModules, key), ...Observer.get(this.inheritedModules, key)]);
|
|
1824
|
+
} else {
|
|
1825
|
+
const _module = Observer.get(this.localModules, key) || Observer.get(this.inheritedModules, key);
|
|
1826
|
+
if (Observer.get(__privateGet(this, _modules), key) !== _module) {
|
|
1827
|
+
Observer.set(__privateGet(this, _modules), key, _module);
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1831
|
+
};
|
|
1832
|
+
__privateSet(this, _modules, { ...this.localModules });
|
|
1833
|
+
__privateGet(this, _controller1)?.abort();
|
|
1834
|
+
__privateSet(this, _controller1, Observer.observe(this.localModules, () => resolve("local"), { timing: "sync" }));
|
|
1835
|
+
const $config = this.configs.HTML_IMPORTS;
|
|
1836
|
+
if (this.host.matches && $config.attr.importscontext) {
|
|
1837
|
+
const realdom = this.host.ownerDocument.defaultView.webqit.realdom;
|
|
1838
|
+
let prevRef;
|
|
1839
|
+
__privateGet(this, _controller2)?.disconnect();
|
|
1840
|
+
__privateSet(this, _controller2, realdom.realtime(this.host).attr($config.attr.importscontext, (record, { signal }) => {
|
|
1841
|
+
const moduleRef = (record.value || "").trim();
|
|
1842
|
+
prevRef = moduleRef;
|
|
1843
|
+
__privateSet(this, _inheritedModules, {});
|
|
1844
|
+
const request = { ...this.constructor.createRequest(moduleRef ? `${moduleRef}/*` : "*"), live: true, signal, diff: true };
|
|
1845
|
+
this.host.parentNode[this.configs.CONTEXT_API.api.contexts].request(request, (m) => {
|
|
1846
|
+
if (!m) {
|
|
1847
|
+
__privateSet(this, _inheritedModules, {});
|
|
1848
|
+
resolve("inherited");
|
|
1849
|
+
} else if (m.type === "delete") {
|
|
1850
|
+
delete __privateGet(this, _inheritedModules)[m.key];
|
|
1851
|
+
if (!Reflect.has(this.localModules, m.key)) {
|
|
1852
|
+
Observer.deleteProperty(__privateGet(this, _modules), m.key);
|
|
1853
|
+
}
|
|
1854
|
+
} else {
|
|
1855
|
+
__privateGet(this, _inheritedModules)[m.key] = m.value;
|
|
1856
|
+
if (!Reflect.has(this.localModules, m.key) && Reflect.get(__privateGet(this, _modules), m.key) !== m.value) {
|
|
1857
|
+
Observer.set(__privateGet(this, _modules), m.key, m.value);
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
});
|
|
1861
|
+
resolve("inherited");
|
|
1862
|
+
}, { live: true, timing: "sync", oldValue: true, lifecycleSignals: true }));
|
|
1863
|
+
}
|
|
1864
|
+
return super.initialize(host);
|
|
1865
|
+
}
|
|
1866
|
+
dispose(host) {
|
|
1867
|
+
__privateGet(this, _controller1)?.abort();
|
|
1868
|
+
__privateGet(this, _controller2)?.disconnect();
|
|
1869
|
+
return super.dispose(host);
|
|
1870
|
+
}
|
|
1871
|
+
};
|
|
1872
|
+
_inheritedModules = new WeakMap();
|
|
1873
|
+
_modules = new WeakMap();
|
|
1874
|
+
_controller1 = new WeakMap();
|
|
1875
|
+
_controller2 = new WeakMap();
|
|
1876
|
+
__publicField(HTMLImportsContext, "kind", "html-imports");
|
|
1877
|
+
|
|
1878
|
+
// src/html-imports/_HTMLImportElement.js
|
|
1879
|
+
function HTMLImportElement_default() {
|
|
1880
|
+
const { window: window2 } = env, { webqit } = window2, { realdom, oohtml: { configs } } = webqit;
|
|
1881
|
+
if (webqit.HTMLImportElement)
|
|
1882
|
+
return webqit.HTMLImportElement;
|
|
1883
|
+
const BaseElement = configs.HTML_IMPORTS.elements.import.includes("-") ? window2.HTMLElement : class {
|
|
1884
|
+
};
|
|
1885
|
+
class HTMLImportElement extends BaseElement {
|
|
1886
|
+
static instance(node) {
|
|
1887
|
+
if (configs.HTML_IMPORTS.elements.import.includes("-") && node.nodeName === this.nodeName)
|
|
1888
|
+
return node;
|
|
1889
|
+
return _wq(node).get("import::instance") || new this(node);
|
|
1890
|
+
}
|
|
1891
|
+
constructor(...args) {
|
|
1892
|
+
super();
|
|
1893
|
+
const el = args[0] || this;
|
|
1894
|
+
_wq(el).set("import::instance", this);
|
|
1895
|
+
Object.defineProperty(this, "el", { get: () => el, configurable: false });
|
|
1896
|
+
const priv = {};
|
|
1897
|
+
Object.defineProperty(this, "#", { get: () => priv, configurable: false });
|
|
1898
|
+
priv.slottedElements = /* @__PURE__ */ new Set();
|
|
1899
|
+
priv.setAnchorNode = (anchorNode) => {
|
|
1900
|
+
priv.anchorNode = anchorNode;
|
|
1901
|
+
return anchorNode;
|
|
1902
|
+
};
|
|
1903
|
+
priv.live = (callback) => {
|
|
1904
|
+
if (priv.liveImportsRealtime)
|
|
1905
|
+
throw new Error(`Import element already in live mode.`);
|
|
1906
|
+
const parentNode = this.el.isConnected ? this.el.parentNode : priv.anchorNode.parentNode;
|
|
1907
|
+
priv.liveImportsRealtime = realdom.realtime(this.el).attr(configs.HTML_IMPORTS.attr.ref, (record, { signal }) => {
|
|
1908
|
+
priv.moduleRef = record.value;
|
|
1909
|
+
const moduleRef = priv.moduleRef.includes("#") ? priv.moduleRef : `${priv.moduleRef}#`;
|
|
1910
|
+
const request = { ...HTMLImportsContext.createRequest(moduleRef), live: signal && true, signal, diff: !moduleRef.endsWith("#") };
|
|
1911
|
+
parentNode[configs.CONTEXT_API.api.contexts].request(request, (response) => {
|
|
1912
|
+
callback((isNodeInterface(response, "HTMLTemplateElement") ? [...response.content.children] : Array.isArray(response) ? response : response && [response]) || []);
|
|
1913
|
+
});
|
|
1914
|
+
}, { live: true, timing: "sync", lifecycleSignals: true });
|
|
1915
|
+
priv.autoDestroyRealtime = realdom.realtime(window2.document).track(parentNode, () => {
|
|
1916
|
+
priv.die();
|
|
1917
|
+
}, { subtree: "cross-roots", timing: "sync", generation: "exits" });
|
|
1918
|
+
};
|
|
1919
|
+
priv.die = () => {
|
|
1920
|
+
priv.autoDestroyRealtime?.disconnect();
|
|
1921
|
+
priv.liveImportsRealtime?.disconnect();
|
|
1922
|
+
priv.liveImportsRealtime = null;
|
|
1923
|
+
};
|
|
1924
|
+
priv.hydrate = (anchorNode, slottedElements) => {
|
|
1925
|
+
anchorNode.replaceWith(priv.setAnchorNode(this.createAnchorNode()));
|
|
1926
|
+
priv.live((fragments) => {
|
|
1927
|
+
if (priv.originalsRemapped)
|
|
1928
|
+
return this.fill(fragments);
|
|
1929
|
+
const identifiersMap = fragments.map((fragment, i) => ({ el: fragment, fragmentDef: fragment.getAttribute(configs.HTML_IMPORTS.attr.fragmentdef) || "", tagName: fragment.tagName, i }));
|
|
1930
|
+
slottedElements.forEach((slottedElement, i) => {
|
|
1931
|
+
const tagName = slottedElement.tagName, fragmentDef = slottedElement.getAttribute(configs.HTML_IMPORTS.attr.fragmentdef) || "";
|
|
1932
|
+
const originalsMatch = (i++, identifiersMap.find((fragmentIdentifiers) => fragmentIdentifiers.tagName === tagName && fragmentIdentifiers.fragmentDef === fragmentDef && fragmentIdentifiers.i === i));
|
|
1933
|
+
if (originalsMatch)
|
|
1934
|
+
_wq(slottedElement).set("original@imports", originalsMatch.el);
|
|
1935
|
+
_wq(slottedElement).set("slot@imports", this.el);
|
|
1936
|
+
priv.slottedElements.add(slottedElement);
|
|
1937
|
+
});
|
|
1938
|
+
priv.originalsRemapped = true;
|
|
1939
|
+
priv.autoRestore();
|
|
1940
|
+
});
|
|
1941
|
+
};
|
|
1942
|
+
priv.autoRestore = (callback = null) => {
|
|
1943
|
+
priv.autoRestoreRealtime?.disconnect();
|
|
1944
|
+
if (callback)
|
|
1945
|
+
callback();
|
|
1946
|
+
const restore = () => {
|
|
1947
|
+
if (this.el.isConnected)
|
|
1948
|
+
return;
|
|
1949
|
+
this.el.setAttribute("data-nodecount", 0);
|
|
1950
|
+
priv.internalMutation = true;
|
|
1951
|
+
priv.anchorNode.replaceWith(this.el);
|
|
1952
|
+
priv.internalMutation = false;
|
|
1953
|
+
priv.setAnchorNode(null);
|
|
1954
|
+
};
|
|
1955
|
+
if (!priv.slottedElements.size)
|
|
1956
|
+
return restore();
|
|
1957
|
+
const autoRestoreRealtime = realdom.realtime(priv.anchorNode.parentNode).observe([...priv.slottedElements], (record) => {
|
|
1958
|
+
record.exits.forEach((outgoingNode) => {
|
|
1959
|
+
_wq(outgoingNode).delete("slot@imports");
|
|
1960
|
+
priv.slottedElements.delete(outgoingNode);
|
|
1961
|
+
});
|
|
1962
|
+
if (!priv.slottedElements.size) {
|
|
1963
|
+
autoRestoreRealtime.disconnect();
|
|
1964
|
+
if (!record.target.isConnected)
|
|
1965
|
+
return;
|
|
1966
|
+
restore();
|
|
1967
|
+
}
|
|
1968
|
+
}, { subtree: "cross-roots", timing: "sync", generation: "exits" });
|
|
1969
|
+
priv.autoRestoreRealtime = autoRestoreRealtime;
|
|
1970
|
+
};
|
|
1971
|
+
priv.connectedCallback = () => {
|
|
1972
|
+
if (priv.internalMutation)
|
|
1973
|
+
return;
|
|
1974
|
+
priv.live((fragments) => this.fill(fragments));
|
|
1975
|
+
};
|
|
1976
|
+
priv.disconnectedCallback = () => {
|
|
1977
|
+
if (priv.internalMutation)
|
|
1978
|
+
return;
|
|
1979
|
+
priv.die();
|
|
1980
|
+
};
|
|
1981
|
+
}
|
|
1982
|
+
createAnchorNode() {
|
|
1983
|
+
if (window2.webqit.env !== "server") {
|
|
1984
|
+
return window2.document.createTextNode("");
|
|
1985
|
+
}
|
|
1986
|
+
const escapeElement = window2.document.createElement("div");
|
|
1987
|
+
escapeElement.textContent = this.el.outerHTML;
|
|
1988
|
+
const anchorNode = window2.document.createComment(escapeElement.innerHTML);
|
|
1989
|
+
_wq(anchorNode).set("isAnchorNode", true);
|
|
1990
|
+
return anchorNode;
|
|
1991
|
+
}
|
|
1992
|
+
fill(slottableElements, r) {
|
|
1993
|
+
if (!this.el.isConnected && (!this["#"].anchorNode || !this["#"].anchorNode.isConnected)) {
|
|
1994
|
+
return;
|
|
1995
|
+
}
|
|
1996
|
+
if (Array.isArray(slottableElements)) {
|
|
1997
|
+
slottableElements = new Set(slottableElements);
|
|
1998
|
+
}
|
|
1999
|
+
this.el.setAttribute("data-nodecount", slottableElements.size);
|
|
2000
|
+
this["#"].autoRestore(() => {
|
|
2001
|
+
this["#"].slottedElements.forEach((slottedElement) => {
|
|
2002
|
+
const slottedElementOriginal = _wq(slottedElement).get("original@imports");
|
|
2003
|
+
if (slottableElements.has(slottedElementOriginal)) {
|
|
2004
|
+
slottableElements.delete(slottedElementOriginal);
|
|
2005
|
+
} else {
|
|
2006
|
+
this["#"].slottedElements.delete(slottedElement);
|
|
2007
|
+
slottedElement.remove();
|
|
2008
|
+
}
|
|
2009
|
+
});
|
|
2010
|
+
if (slottableElements.size && this.el.isConnected) {
|
|
2011
|
+
const newAnchorNode = this["#"].setAnchorNode(this.createAnchorNode());
|
|
2012
|
+
this["#"].internalMutation = true;
|
|
2013
|
+
this.el.replaceWith(newAnchorNode);
|
|
2014
|
+
this["#"].internalMutation = false;
|
|
2015
|
+
}
|
|
2016
|
+
slottableElements.forEach((slottableElement) => {
|
|
2017
|
+
const slottableElementClone = slottableElement.cloneNode(true);
|
|
2018
|
+
if (!slottableElementClone.hasAttribute(configs.HTML_IMPORTS.attr.fragmentdef)) {
|
|
2019
|
+
slottableElementClone.toggleAttribute(configs.HTML_IMPORTS.attr.fragmentdef, true);
|
|
2020
|
+
}
|
|
2021
|
+
_wq(slottableElementClone).set("original@imports", slottableElement);
|
|
2022
|
+
_wq(slottableElementClone).set("slot@imports", this.el);
|
|
2023
|
+
this["#"].slottedElements.add(slottableElementClone);
|
|
2024
|
+
this["#"].anchorNode.before(slottableElementClone);
|
|
2025
|
+
});
|
|
2026
|
+
});
|
|
2027
|
+
}
|
|
2028
|
+
empty() {
|
|
2029
|
+
this["#"].slottedElements.forEach((slottedElement) => slottedElement.remove());
|
|
2030
|
+
}
|
|
2031
|
+
get anchorNode() {
|
|
2032
|
+
return this["#"].anchorNode;
|
|
2033
|
+
}
|
|
2034
|
+
get moduleRef() {
|
|
2035
|
+
return this["#"].moduleRef;
|
|
2036
|
+
}
|
|
2037
|
+
get slottedElements() {
|
|
2038
|
+
return this["#"].slottedElements;
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
if (configs.HTML_IMPORTS.elements.import.includes("-")) {
|
|
2042
|
+
customElements.define(configs.HTML_IMPORTS.elements.import, HTMLImportElement);
|
|
2043
|
+
}
|
|
2044
|
+
webqit.HTMLImportElement = HTMLImportElement;
|
|
2045
|
+
return HTMLImportElement;
|
|
2046
|
+
}
|
|
2047
|
+
|
|
2048
|
+
// src/html-imports/index.js
|
|
2049
|
+
function init($config = {}) {
|
|
2050
|
+
const { config, window: window2 } = _init.call(this, "html-imports", $config, {
|
|
2051
|
+
elements: { import: "import" },
|
|
2052
|
+
attr: { def: "def", extends: "extends", inherits: "inherits", ref: "ref", importscontext: "importscontext" },
|
|
2053
|
+
api: { def: "def", defs: "defs", import: "import" }
|
|
2054
|
+
});
|
|
2055
|
+
if (!config.attr.fragmentdef) {
|
|
2056
|
+
config.attr.fragmentdef = config.attr.def;
|
|
2057
|
+
}
|
|
2058
|
+
config.templateSelector = `template[${window2.CSS.escape(config.attr.def)}]`;
|
|
2059
|
+
config.importsContextSelector = `[${window2.CSS.escape(config.attr.importscontext)}]`;
|
|
2060
|
+
config.slottedElementsSelector = `[${window2.CSS.escape(config.attr.fragmentdef)}]:not(template)`;
|
|
2061
|
+
const anchorNodeMatch = (start, end) => {
|
|
2062
|
+
const starting = `starts-with(., "${start}")`;
|
|
2063
|
+
const ending = `substring(., string-length(.) - string-length("${end}") + 1) = "${end}"`;
|
|
2064
|
+
return `${starting} and ${ending}`;
|
|
2065
|
+
};
|
|
2066
|
+
config.anchorNodeSelector = `comment()[${anchorNodeMatch(`<${config.elements.import}`, `</${config.elements.import}>`)}]`;
|
|
2067
|
+
window2.webqit.HTMLImportsContext = HTMLImportsContext;
|
|
2068
|
+
window2.webqit.HTMLImportElement = HTMLImportElement_default();
|
|
2069
|
+
exposeAPIs.call(window2, config);
|
|
2070
|
+
realtime.call(window2, config);
|
|
2071
|
+
}
|
|
2072
|
+
function getDefs(node, autoCreate = true) {
|
|
2073
|
+
if (!_wq(node).has("defs") && autoCreate) {
|
|
2074
|
+
const defs = /* @__PURE__ */ Object.create(null);
|
|
2075
|
+
_wq(node).set("defs", defs);
|
|
2076
|
+
}
|
|
2077
|
+
return _wq(node).get("defs");
|
|
2078
|
+
}
|
|
2079
|
+
function exposeAPIs(config) {
|
|
2080
|
+
const window2 = this, { webqit: { oohtml: { configs } } } = window2;
|
|
2081
|
+
if (config.api.def in window2.HTMLTemplateElement.prototype) {
|
|
2082
|
+
throw new Error(`The "HTMLTemplateElement" prototype already has a "${config.api.def}" API!`);
|
|
2083
|
+
}
|
|
2084
|
+
if (config.api.defs in window2.HTMLTemplateElement.prototype) {
|
|
2085
|
+
throw new Error(`The "HTMLTemplateElement" prototype already has a "${config.api.defs}" API!`);
|
|
2086
|
+
}
|
|
2087
|
+
Object.defineProperty(window2.HTMLTemplateElement.prototype, config.api.def, {
|
|
2088
|
+
get: function() {
|
|
2089
|
+
return this.getAttribute(config.attr.def);
|
|
2090
|
+
}
|
|
2091
|
+
});
|
|
2092
|
+
Object.defineProperty(window2.HTMLTemplateElement.prototype, config.api.defs, {
|
|
2093
|
+
get: function() {
|
|
2094
|
+
return getDefs(this);
|
|
2095
|
+
}
|
|
2096
|
+
});
|
|
2097
|
+
Object.defineProperty(window2.HTMLTemplateElement.prototype, "scoped", {
|
|
2098
|
+
configurable: true,
|
|
2099
|
+
get() {
|
|
2100
|
+
return this.hasAttribute("scoped");
|
|
2101
|
+
},
|
|
2102
|
+
set(value) {
|
|
2103
|
+
this.toggleAttribute("scoped", value);
|
|
2104
|
+
}
|
|
2105
|
+
});
|
|
2106
|
+
[window2.Document.prototype, window2.Element.prototype, window2.ShadowRoot.prototype].forEach((prototype) => {
|
|
2107
|
+
const type = prototype === window2.Document.prototype ? "Document" : prototype === window2.ShadowRoot.prototype ? "ShadowRoot" : "Element";
|
|
2108
|
+
if (config.api.import in prototype) {
|
|
2109
|
+
throw new Error(`The ${type} prototype already has a "${config.api.import}" API!`);
|
|
2110
|
+
}
|
|
2111
|
+
if (config.api.defs in prototype) {
|
|
2112
|
+
throw new Error(`The ${type} prototype already has a "${config.api.defs}" API!`);
|
|
2113
|
+
}
|
|
2114
|
+
Object.defineProperty(prototype, config.api.defs, {
|
|
2115
|
+
get: function() {
|
|
2116
|
+
return getDefs(this);
|
|
2117
|
+
}
|
|
2118
|
+
});
|
|
2119
|
+
Object.defineProperty(prototype, config.api.import, {
|
|
2120
|
+
value: function(ref, live = false, callback = null) {
|
|
2121
|
+
return importRequest(this, ...arguments);
|
|
2122
|
+
}
|
|
2123
|
+
});
|
|
2124
|
+
});
|
|
2125
|
+
function importRequest(context, ref, live = false, callback = null) {
|
|
2126
|
+
let options = {};
|
|
2127
|
+
if (typeof live === "function") {
|
|
2128
|
+
callback = live;
|
|
2129
|
+
live = false;
|
|
2130
|
+
} else if (typeof live === "object" && live) {
|
|
2131
|
+
options = { ...live, ...options };
|
|
2132
|
+
} else {
|
|
2133
|
+
options = { live };
|
|
2134
|
+
}
|
|
2135
|
+
const request = { ...HTMLImportsContext.createRequest(ref), ...options };
|
|
2136
|
+
return context[configs.CONTEXT_API.api.contexts].request(request, callback);
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
function realtime(config) {
|
|
2140
|
+
const window2 = this, { webqit: { Observer, realdom, oohtml: { configs }, HTMLImportElement, HTMLImportsContext: HTMLImportsContext2 } } = window2;
|
|
2141
|
+
const attachImportsContext = (host) => {
|
|
2142
|
+
const contextsApi = host[configs.CONTEXT_API.api.contexts];
|
|
2143
|
+
if (!contextsApi.find(HTMLImportsContext2.kind)) {
|
|
2144
|
+
contextsApi.attach(new HTMLImportsContext2());
|
|
2145
|
+
}
|
|
2146
|
+
};
|
|
2147
|
+
const detachImportsContext = (host) => {
|
|
2148
|
+
const contextsApi = host[configs.CONTEXT_API.api.contexts];
|
|
2149
|
+
const ctx = contextsApi.find(HTMLImportsContext2.kind);
|
|
2150
|
+
if (ctx && (!host.isConnected || !host.matches?.(config.importsContextSelector) && !Object.keys(ctx.localModules).length)) {
|
|
2151
|
+
contextsApi.detach(ctx);
|
|
2152
|
+
}
|
|
2153
|
+
};
|
|
2154
|
+
realdom.realtime(window2.document).query([config.templateSelector, config.importsContextSelector], (record) => {
|
|
2155
|
+
record.entrants.forEach((entry) => {
|
|
2156
|
+
if (entry.matches(config.templateSelector)) {
|
|
2157
|
+
const htmlModule = HTMLModule.instance(entry);
|
|
2158
|
+
htmlModule.ownerContext = entry.scoped ? entry.parentNode : entry.getRootNode();
|
|
2159
|
+
const ownerContextModulesObj = getDefs(htmlModule.ownerContext);
|
|
2160
|
+
if (htmlModule.defId) {
|
|
2161
|
+
Observer.set(ownerContextModulesObj, htmlModule.defId, entry);
|
|
2162
|
+
}
|
|
2163
|
+
attachImportsContext(htmlModule.ownerContext);
|
|
2164
|
+
} else {
|
|
2165
|
+
attachImportsContext(entry);
|
|
2166
|
+
}
|
|
2167
|
+
});
|
|
2168
|
+
record.exits.forEach((entry) => {
|
|
2169
|
+
if (entry.matches(config.templateSelector)) {
|
|
2170
|
+
const htmlModule = HTMLModule.instance(entry);
|
|
2171
|
+
const ownerContextModulesObj = getDefs(htmlModule.ownerContext);
|
|
2172
|
+
if (htmlModule.defId && htmlModule.ownerContext.isConnected) {
|
|
2173
|
+
Observer.deleteProperty(ownerContextModulesObj, htmlModule.defId);
|
|
2174
|
+
}
|
|
2175
|
+
detachImportsContext(htmlModule.ownerContext);
|
|
2176
|
+
} else {
|
|
2177
|
+
detachImportsContext(entry);
|
|
2178
|
+
}
|
|
2179
|
+
});
|
|
2180
|
+
}, { id: "imports:template/importscontext", live: true, subtree: "cross-roots", timing: "sync", staticSensitivity: true, eventDetails: true });
|
|
2181
|
+
realdom.realtime(window2.document).query(config.elements.import, (record) => {
|
|
2182
|
+
record.entrants.forEach((node) => handleRealtime(node, true, record));
|
|
2183
|
+
record.exits.forEach((node) => handleRealtime(node, false, record));
|
|
2184
|
+
}, { id: "imports:import", live: true, subtree: "cross-roots", timing: "sync", deferred: true });
|
|
2185
|
+
function handleRealtime(entry, connectedState) {
|
|
2186
|
+
const elInstance = HTMLImportElement.instance(entry);
|
|
2187
|
+
if (connectedState) {
|
|
2188
|
+
elInstance["#"].connectedCallback();
|
|
2189
|
+
} else {
|
|
2190
|
+
elInstance["#"].disconnectedCallback();
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2193
|
+
if (window2.webqit.env === "server")
|
|
2194
|
+
return;
|
|
2195
|
+
realdom.realtime(window2.document).query(`(${config.anchorNodeSelector})`, (record) => {
|
|
2196
|
+
record.entrants.forEach((anchorNode) => {
|
|
2197
|
+
if (_wq(anchorNode).get("isAnchorNode"))
|
|
2198
|
+
return;
|
|
2199
|
+
const reviver = window2.document.createElement("div");
|
|
2200
|
+
reviver.innerHTML = anchorNode.nodeValue;
|
|
2201
|
+
reviver.innerHTML = reviver.firstChild.textContent;
|
|
2202
|
+
const importEl = reviver.firstChild;
|
|
2203
|
+
let nodecount = parseInt(importEl.getAttribute("data-nodecount"));
|
|
2204
|
+
const slottedElements = /* @__PURE__ */ new Set();
|
|
2205
|
+
let slottedElement = anchorNode;
|
|
2206
|
+
while ((slottedElement = slottedElement.previousElementSibling) && slottedElement.matches(config.slottedElementsSelector) && nodecount--) {
|
|
2207
|
+
slottedElements.add(slottedElement);
|
|
2208
|
+
}
|
|
2209
|
+
HTMLImportElement.instance(importEl)["#"].hydrate(anchorNode, slottedElements);
|
|
2210
|
+
});
|
|
2211
|
+
}, { id: "imports:hydration", live: true, subtree: "cross-roots", timing: "sync" });
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
// src/html-imports/targets.browser.js
|
|
2215
|
+
init.call(window);
|
|
2
2216
|
//# sourceMappingURL=html-imports.js.map
|