@webqit/oohtml 5.0.5 → 5.0.7
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 +1719 -1
- package/dist/bindings-api.js.map +1 -1
- package/dist/context-api.js +1602 -1
- package/dist/context-api.js.map +1 -1
- package/dist/data-binding.js +1634 -22
- package/dist/data-binding.js.map +2 -2
- package/dist/html-imports.js +2172 -1
- package/dist/html-imports.js.map +1 -1
- package/dist/main.js +12649 -45
- package/dist/main.js.map +2 -2
- package/dist/main.lite.js +5829 -37
- package/dist/main.lite.js.map +2 -2
- package/dist/namespaced-html.js +1977 -1
- package/dist/namespaced-html.js.map +1 -1
- package/dist/scoped-css.js +1816 -5
- package/dist/scoped-css.js.map +1 -1
- package/dist/scoped-js.js +1516 -1
- package/dist/scoped-js.js.map +1 -1
- package/package.json +5 -4
- package/src/data-binding/index.js +13 -5
- package/test/bindings-api.test.js +2 -2
package/dist/bindings-api.js
CHANGED
|
@@ -1,2 +1,1720 @@
|
|
|
1
|
-
var Kt=Object.defineProperty;var te=(n,t,r)=>t in n?Kt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r;var lt=(n,t,r)=>(te(n,typeof t!="symbol"?t+"":t,r),r);function w(n){return!Array.isArray(n)&&typeof n=="object"&&n}function g(n){return Array.isArray(n)}function X(n){return typeof n=="function"}function J(n){return n===null||n===""}function D(n){return arguments.length&&(n===void 0||typeof n>"u")}function A(n){return Array.isArray(n)||typeof n=="object"&&n||X(n)}function gt(n){return J(n)||D(n)||n===!1||n===0||A(n)&&!Object.keys(n).length}function b(n){return X(n)||n&&{}.toString.call(n)==="[object function]"}function Y(n){return n instanceof Number||typeof n=="number"}function S(n){return Y(n)||n!==!0&&n!==!1&&n!==null&&n!==""&&!isNaN(n*1)}function Q(n){return n instanceof String||typeof n=="string"&&n!==null}function yt(n){return!Q(n)&&!D(n.length)}function ct(n,...t){return t.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n}function bt(e,t){t=t||Object.prototype,t=t&&!g(t)?[t]:t;for(var r=[],e=e;e&&(!t||t.indexOf(e)<0)&&e.name!=="default";)r.push(e),e=e?Object.getPrototypeOf(e):null;return r}function _t(n,t){var r=[];return bt(n,t).forEach(e=>{ct(r,...Object.getOwnPropertyNames(e))}),r}function j(n,t,r=!1,e=!1,i=!1){var o=0,s=n.shift();if((S(s)||s===!0||s===!1)&&(o=s,s=n.shift()),!n.length)throw new Error("_merge() requires two or more array/objects.");return n.forEach((f,c)=>{!A(f)&&!b(f)||(r?_t(f):Object.keys(f)).forEach(l=>{if(!!t(l,s,f,c)){var a=s[l],m=f[l];if((g(a)&&g(m)||w(a)&&w(m))&&(o===!0||o>0))s[l]=g(a)&&g(m)?[]:{},j([S(o)?o-1:o,s[l],a,m],t,r,e,i);else if(g(s)&&g(f))e?s[l]=m:s.push(m);else try{i?Object.defineProperty(s,l,Object.getOwnPropertyDescriptor(f,l)):s[l]=f[l]}catch{}}})}),s}function Z(...n){return j(n,(t,r,e)=>!0,!1,!1,!1)}function C(n,...t){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 at,Object.defineProperty(n,Symbol.for("wq"),{value:r,enumerable:!1,configurable:!1,writable:!1})),!t.length)return r;let e,i;for(;e=t.shift();)(i=r)&&!(r=r.get(e))&&(r=new at,i.set(e,r));return r}var at=class extends Map{};function E(n,t=!0){return g(n)?n:!t&&w(n)?[n]:n!==!1&&n!==0&>(n)?[]:yt(n)?Array.prototype.slice.call(n):w(n)?Object.values(n):[n]}function K(n,t,r={},e={}){t=E(t).slice();for(var i=n;!D(i)&&!J(i)&&t.length;){var o=t.shift();if(!(r.get?r.get(i,o):A(i)?o in i:i[o])){e.exists=!1;return}i=r.get?r.get(i,o):i[o]}return e.exists=!0,i}function xt(n,t,r,e={},i={}){let o=(a,m,u)=>i.set?i.set(a,m,u):(S(t[f])&&g(a)?a.push(u):a[m]=u,!0);t=E(t);for(var s=n,f=0;f<t.length;f++)if(f<t.length-1){if(!s||!A(s)&&!b(s))return!1;var c=K(s,t[f],i);if(!A(c)){if(i.buildTree===!1)return!1;c=b(i.buildTree)?i.buildTree(f):S(t[f+1])?[]:{};var l=o(s,t[f],c);if(!l)return!1}s=c}else return o(s,t[f],r)}var tt=class{constructor(t,r=!1){Object.defineProperty(this,"window",{value:t}),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(t){this._synthesis++,this._fulfill();let r=await t();return this._synthesis--,r}_fulfill(){for(let t of this.readCallbacks)t(),this.readCallbacks.delete(t);for(let t of this.writeCallbacks)t(),this.writeCallbacks.delete(t)}_loop(){this.window.requestAnimationFrame(()=>{this._fulfill(),this._loop()})}onread(t,r=!1){if(r)return new Promise(e=>{this.synthesis?e(t()):this.readCallbacks.add(()=>{e(t())})});this.synthesis?Promise.resolve().then(t):this.readCallbacks.add(t)}onwrite(t,r=!1){if(r)return new Promise(e=>{this.synthesis?e(t()):this.writeCallbacks.add(()=>{e(t())})});this.synthesis?Promise.resolve().then(t):this.writeCallbacks.add(t)}cycle(t,r,e){this.onread(()=>{let i=t(e),o=s=>{s!==void 0&&this.onwrite(()=>{let f=r(s,e),c=l=>{l!==void 0&&this.cycle(t,r,l)};f instanceof Promise?f.then(c):c(f)})};i instanceof Promise?i.then(o):o(i)})}};function Nt(n){return(n=n.trim())&&n.startsWith("(")&&n.endsWith(")")}function mt(n,t,r,e=!0){r=(Array.isArray(r)?r:[r]).map(s=>(s+"").replace("(",e?"(.//":"(./")).join("|");let i=[],o;try{let s=n.document.evaluate(r,t,null,n.XPathResult.ANY_TYPE);for(;o=s.iterateNext();)i.push(o)}catch{}return i}function Ht(n,t,r){r=(Array.isArray(r)?r:[r]).map(e=>(e+"").replace("(","(self::")).join("|");try{return n.document.evaluate(`${r}`,t,null,n.XPathResult.BOOLEAN_TYPE).booleanValue}catch{}}function et(n,t,r,e=!1,i=null){let o=i?.get(t)?.get(r);if(typeof o<"u")return o;let s=l=>(i?.has(t)||i?.set(t,new WeakMap),i?.get(t)?.set(r,l),l),f=t.getRootNode(),c=r.getRootNode();return f===c?s(t.contains(r)):e&&c instanceof n.ShadowRoot?s(et(n,t,c.host,e,i)):s(!1)}function $t(n,t="|"){return[...n].reduce(([r,e,i,o],s)=>!r&&e===0&&(Array.isArray(t)?t:[t]).includes(s)?[r,e,[""].concat(i)]:(!r&&["(","[","{"].includes(s)&&!i[0].endsWith("\\")&&e++,!r&&[")","]","}"].includes(s)&&!i[0].endsWith("\\")&&e--,['"',"'","`"].includes(s)&&!i[0].endsWith("\\")&&(r=r===s?null:r||s),i[0]+=s,[r,e,i]),[null,0,[""]])[2].reverse()}var q=class{constructor(t){this.content=t,this.type=typeof t=="string"?"selector":"instance",this.kind=this.type==="instance"?null:Nt(t)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=$t(t.trim().slice(1,-1),"@").length>1)}toString(){return this.content}};var G=class{constructor(t,r,e){this.context=t,this.namespace=r,this.window=t.defaultView||t.ownerDocument?.defaultView||e,this.document=this.window.document,this.webqit=this.window.webqit,Object.defineProperty(this,"#",{value:{}})}resolveArgs(t){if(b(t[0])?t=[[],...t]:w(t[0])&&!(t[0]instanceof q)&&t.length===1?t=[[],void 0,t[0]]:w(t[1])&&t.length===2?t=[E(t[0],!1),void 0,t[1]]:t[0]=E(t[0],!1),t[0].filter(r=>typeof r!="string"&&!(r instanceof q)&&!(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 t[0]=t[0].map(r=>r instanceof q?r:new q(r)),t}registry(...t){return C(this.window,"realdom",this.namespace,...t)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(t,r,e){let{window:i}=this,o=new Set,s=new WeakMap;for(let[f,c]of this.registry(t)){let l=[].concat(r).filter(m=>et(i,f.context,m.target,f.params.subtree==="cross-roots",s));if(!l.length)continue;let a=[f,Array.isArray(r)?l:l[0]];c?o.add(a):e.call(i,...a)}for(let f of o)e.call(i,...f);o.clear()}disconnectables(t,...r){let e={disconnect(){r.forEach(i=>i&&b(i.disconnect)&&i.disconnect()||b(i)&&i()||w(i)&&(i.disconnected=!0))}};return t&&t.addEventListener("abort",()=>e.disconnect()),e}};var F=class extends G{type="attr";constructor(t,...r){super(t,"attr",...r)}get(t,r=void 0,e={}){let i=typeof t=="string"||t instanceof q;[t=[],r=void 0,e={}]=this.resolveArgs(arguments);let{context:o}=this,s=Wt(o,t);if(!r)return s;let f=e.lifecycleSignals&&this.createSignalGenerator();if(i)for(let c of s){let l=f?f.generate():{};r(c,l,o)}else{let c=f?.generate()||{};r(s,c,o)}if(e.live){f&&(e={...e,signalGenerator:f});let c=this.observe(i?t[0]:t,r,{newValue:!0,...e});return this.disconnectables(e.signal,c)}}observe(t,r,e={}){let i=typeof t=="string"||t instanceof q;if([t=[],r,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(i?t[0]:t,r,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:o,window:s,webqit:f}=this;e.eventDetails&&!f.realdom.attrInterceptionHooks?.intercepting&&Rt.call(s,"intercept",()=>{});let c=new s.MutationObserver(u=>{u=Ft(u).map(p=>Ut.call(s,p)),Dt.call(s,m,u,o)}),l={attributes:!0,attributeOldValue:e.oldValue,subtree:e.subtree&&!0};t.length&&(l.attributeFilter=t.map(u=>u+"")),c.observe(o,l);let a=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),m={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:a,disconnectable:c};return this.disconnectables(e.signal,c,a)}observeSync(t,r,e={}){let i=typeof t=="string"||t instanceof q;[t,r,e={}]=this.resolveArgs(arguments);let{context:o,window:s}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let f=e.timing==="intercept"?"intercept":"sync";this.registry(f).size||Rt.call(s,f,u=>{this.forEachMatchingContext(f,u,Dt)});let c={disconnect(){m.delete(a)}},l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),a={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:l,disconnectable:c},m=this.registry(f);return m.set(a,!!a.params.deferred),this.disconnectables(e.signal,c,l)}};function Ft(n){return n.reduce((t,r,e)=>t[e-1]?.attributeName===r.attributeName||C(r.target,"realdom","internalAttrInteractions").get(r.attributeName)?t:t.concat(r),[])}function Dt(n,t){let{context:r,spec:e,callback:i,params:o,atomics:s,originalFilterIsString:f,signalGenerator:c}=n;if(o.subtree||(t=t.filter(u=>u.target===r)),!t.length)return;let l=e.map(u=>u+"");if(o.atomic&&!s.size?t=Wt(r,e,t):o.timing!=="async"&&e.length&&(t=t.filter(u=>l.includes(u.name))),!t.length)return;o.newValue===null&&o.oldValue===null&&o.eventDetails||(t=t.map(u=>{let p;return o.eventDetails||({event:p,...u}=u),!o.oldValue&&"oldValue"in u&&({oldValue:p,...u}=u),!o.newValue&&"value"in u?{value:p,...u}=u:o.newValue&&typeof u.value>"u"&&(u={...u,value:dt(u.target,u.name,()=>u.target.getAttribute(u.name))}),u})),o.atomic&&(t.forEach(u=>s.set(u.name,u)),t=Array.from(s.entries()).map(([,u])=>u));let a=f?t[0]:t,m=c?c.generate():{};i(a,m,r)}function dt(n,t,r){let e=C(n,"realdom","internalAttrInteractions").get(t);C(n,"realdom","internalAttrInteractions").set(t,!0);let i=r();return C(n,"realdom","internalAttrInteractions").set(t,e),i}function Wt(n,t,r=[]){let e={event:null,type:"attribute"};return t.length?t.map(o=>(o=o+"",r.find(s=>s.name===o)||{target:n,name:o,value:dt(n,o,()=>n.getAttribute(o)),...e})):Array.from(n.attributes).map(o=>r.find(s=>s.name===o.nodeName)||{target:n,name:o.nodeName,value:dt(n,o.nodeName,()=>o.nodeValue),...e})}function Ut({target:n,attributeName:t,value:r,oldValue:e}){let s=(this.webqit.realdom.attrInterceptionRecords?.get(n)||{})[t]?.[0]||"mutation";return{target:n,name:t,value:r,oldValue:e,type:"observation",event:s}}function Rt(n,t){let r=this,{webqit:e,document:i,Element:o}=r;e.realdom.attrInterceptionHooks||Object.defineProperty(e.realdom,"attrInterceptionHooks",{value:new Map}),e.realdom.attrInterceptionHooks.has(n)||e.realdom.attrInterceptionHooks.set(n,new Set),e.realdom.attrInterceptionHooks.get(n).add(t);let s=()=>e.realdom.attrInterceptionHooks.get(n).delete(t);if(e.realdom.attrInterceptionHooks?.intercepting)return s;console.warn("Attr mutation APIs are now being intercepted."),e.realdom.attrInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"attrInterceptionRecords",{value:new Map});let f=(a,m)=>{e.realdom.attrInterceptionRecords.has(a.target)||e.realdom.attrInterceptionRecords.set(a.target,{});let u=e.realdom.attrInterceptionRecords.get(a.target);if(u[a.name]=u[a.name]||[],u[a.name].unshift(a.event),C(a.target,"realdom","internalAttrInteractions").get(a.name))return m();e.realdom.attrInterceptionHooks.get("intercept")?.forEach(_=>_([a]));let p=m();return e.realdom.attrInterceptionHooks.get("sync")?.forEach(_=>_([a])),p};new r.MutationObserver(a=>{a=a.filter(m=>!(r.webqit.realdom.attrInterceptionRecords?.get(m.target)||{})[m.attributeName]?.shift()),a=Ft(a).map(m=>Ut.call(r,m)),a.length&&(e.realdom.attrInterceptionHooks.get("intercept")?.forEach(m=>m(a)),e.realdom.attrInterceptionHooks.get("sync")?.forEach(m=>m(a)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let l=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(a=>{l[a]=o.prototype[a],o.prototype[a]=function(...m){let u,p=dt(this,m[0],()=>this.getAttribute(m[0]));["setAttribute","toggleAttribute"].includes(a)&&(u=m[1]),a==="toggleAttribute"&&u===void 0&&(u=p===null);let _={target:this,name:m[0],value:u,oldValue:p,type:"interception",event:[this,a]};return f(_,()=>l[a].call(this,...m))}}),s}var rt=class extends G{constructor(t,...r){super(t,"tree",...r)}attr(t,r=void 0,e={}){let{context:i,window:o}=this;return new F(i,o).get(...arguments)}query(t,r=void 0,e={}){[t,r=void 0,e={}]=this.resolveArgs(arguments);let{context:i}=this,o=new Map,s=l=>(o.has(l)||o.set(l,{target:l,entrants:[],exits:[],type:"query",event:null}),o.get(l));if(!e.generation||e.generation==="entrants"){if(!t.length)[...i.children].forEach(l=>s(i).entrants.push(l));else if(t.every(l=>l.type==="selector")){let[l,a]=t.reduce(([u,p],_)=>_.kind==="xpath"?[u,p.concat(_)]:[u.concat(_),p],[[],[]]),m=[];e.subtree?(l.length&&m.push(...i.querySelectorAll(l.join(","))),a.length&&m.push(...mt(this.window,i,a))):(l.length&&m.push(...[...i.children].filter(u=>u.matches(l))),a.length&&m.push(...mt(this.window,i,a,!1))),m.forEach(u=>s(u.parentNode||i).entrants.push(u))}}if(!r)return o;let f={disconnected:!1},c=r&&e.lifecycleSignals&&this.createSignalGenerator();for(let[,l]of o){if(f.disconnected)break;let a=c?.generate()||{};r(l,a,i)}if(e.live){c&&(e={...e,signalGenerator:c});let l=this.observe(t,r,e);return this.disconnectables(e.signal,f,l)}return this.disconnectables(e.signal,f,c)}children(t,r=void 0,e={}){return[t,r=void 0,e={}]=this.resolveArgs(arguments),this.query(t,r,{...e,subtree:!1})}subtree(t,r=void 0,e={}){return[t,r=void 0,e={}]=this.resolveArgs(arguments),this.query(t,r,{...e,subtree:!0})}observe(t,r,e={}){if([t,r,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(t,r,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:i,window:o,webqit:s,document:f}=this;e.eventDetails&&(s.realdom.domInterceptionRecordsAlwaysOn=!0),(f.readyState==="loading"||s.realdom.domInterceptionRecordsAlwaysOn)&&!s.realdom.domInterceptionHooks?.intercepting&&Gt.call(o,"sync",()=>{});let c=new o.MutationObserver(m=>m.forEach(u=>{At.call(o,a,Bt.call(o,u),i)}));c.observe(i,{childList:!0,subtree:e.subtree&&!0});let l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),a={context:i,spec:t,callback:r,params:e,signalGenerator:l,disconnectable:c};if(e.staticSensitivity){let m=Vt.call(o,a);return this.disconnectables(e.signal,c,l,m)}return this.disconnectables(e.signal,c,l)}observeSync(t,r,e={}){[t,r,e={}]=this.resolveArgs(arguments);let{context:i,window:o}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let s=e.timing==="intercept"?"intercept":"sync";this.registry(s).size||Gt.call(o,s,u=>{this.forEachMatchingContext(s,u,At)});let f=new o.MutationObserver(u=>u.forEach(p=>{Array.isArray((p=Bt.call(o,p)).event)||At.call(o,a,p,i)}));f.observe(i,{childList:!0,subtree:e.subtree&&!0});let c={disconnect(){m.delete(a),f.disconnect()}},l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),a={context:i,spec:t,callback:r,params:e,signalGenerator:l,disconnectable:c},m=this.registry(s);if(m.set(a,!!a.params.deferred),e.staticSensitivity){let u=Vt.call(o,a);return this.disconnectables(e.signal,c,l,u)}return this.disconnectables(e.signal,c,l)}track(t,r,e={}){return e={subtree:!0,...e},this.observe(t,i=>{i.entrants.length&&r(!0,Array.isArray(t)?i.entrants:i.entrants[0]),i.exits.length&&r(!1,Array.isArray(t)?i.exits:i.exits[0])},e)}};function Vt(n){let t=this,{context:r,spec:e,callback:i,params:o,signalGenerator:s}=n,f=e.filter(p=>p.kind==="css"),c=p=>p.match(/\.([\w-]+)/g)?.length?["class"]:[],l=p=>p.match(/#([\w-]+)/g)?.length?["id"]:[],a=p=>[...p.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(_=>_[1]).concat(c(p)).concat(l(p));if(!(n.$attrs=Array.from(new Set(f.filter(p=>(p+"").includes("[")).reduce((p,_)=>p.concat(a(_+"")),[])))).length)return;let m=new Set,u=new Set;return m.push=p=>(u.delete(p),m.add(p)),u.push=p=>(m.delete(p),u.add(p)),n.$deliveryCache={entrants:m,exits:u},new F(r,t).observe(n.$attrs,p=>{let _=new Map,O=y=>(_.has(y)||_.set(y,{target:y,entrants:[],exits:[],type:"static",event:null}),_.get(y)),st=new WeakMap,d=y=>(st.has(y)||st.set(y,f.some(v=>y.matches(v+""))),st.get(y));for(let y of p)["entrants","exits"].forEach(v=>{o.generation&&v!==o.generation||n.$deliveryCache[v].has(y.target)||(v==="entrants"?!d(y.target):d(y.target))||(n.$deliveryCache[v].push(y.target),O(y.target)[v].push(y.target),O(y.target).event=y.event)});for(let[,y]of _){let v=s?.generate()||{};i(y,v,r)}},{subtree:o.subtree,timing:o.timing,eventDetails:o.eventDetails})}function At(n,t){let{context:r,spec:e,callback:i,params:o,signalGenerator:s,$deliveryCache:f}=n,c={...t,entrants:[],exits:[]};if(o.eventDetails||delete c.event,["entrants","exits"].forEach(a=>{if(!(o.generation&&a!==o.generation)&&(e.length?c[a]=ge.call(this,e,o.subtree==="cross-roots",t[a],t.event!=="parse"):c[a]=[...t[a]],!!f))for(let m of c[a])f[a].push(m)}),!c.entrants.length&&!c.exits.length)return;let l=s?.generate()||{};i(c,l,r)}function ge(n,t,r,e){r=Array.isArray(r)?r:[...r];let i=(o,s)=>{if(s.type==="selector"){let f=s.isXpathAttr?[]:o.filter(c=>s.kind==="xpath"?Ht(this,c,s+""):c.matches&&c.matches(s+""));if((e||s.isXpathAttr)&&(f=o.reduce((c,l)=>s.kind==="xpath"?[...c,...mt(this,l,s,e)]:l.querySelectorAll?[...c,...l.querySelectorAll(s+"")]:c,f)),f.length)return f}else if(o.includes(s.content)||e&&o.some(f=>et(this,f,s.content,t)))return[s.content]};return r.$$searchCache||(r.$$searchCache=new Map),n.reduce((o,s)=>{let f;return r.$$searchCache.has(s.content)?f=r.$$searchCache.get(s.content):(f=i(r,s)||[],s.type==="instance"&&r.$$searchCache.set(s.content,f)),o.concat(f)},[])}function Bt({target:n,addedNodes:t,removedNodes:r}){let e=this,i;return i=E(t).reduce((o,s)=>o||e.webqit.realdom.domInterceptionRecords?.get(s),null),i=E(r).reduce((o,s)=>o||e.webqit.realdom.domInterceptionRecords?.get(s),i),i=i||e.document.readyState==="loading"&&"parse"||"mutation",{target:n,entrants:t,exits:r,type:"observation",event:i}}function Gt(n,t){let r=this,{webqit:e,document:i,Node:o,CharacterData:s,Element:f,HTMLElement:c,HTMLTemplateElement:l,DocumentFragment:a}=r;e.realdom.domInterceptionHooks||Object.defineProperty(e.realdom,"domInterceptionHooks",{value:new Map}),e.realdom.domInterceptionNoRecurse||Object.defineProperty(e.realdom,"domInterceptionNoRecurse",{value:new Map}),e.realdom.domInterceptionHooks.has(n)||e.realdom.domInterceptionHooks.set(n,new Set),e.realdom.domInterceptionHooks.get(n).add(t);let m=()=>e.realdom.domInterceptionHooks.get(n).delete(t);if(e.realdom.domInterceptionHooks?.intercepting)return m;console.warn("DOM mutation APIs are now being intercepted."),e.realdom.domInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"domInterceptionRecords",{value:new Map});let u=(d,y,v)=>{e.realdom.domInterceptionNoRecurse.set(d,y);let h=v();return e.realdom.domInterceptionNoRecurse.delete(d),h},p=(d,y)=>{d.entrants.concat(d.exits).forEach(h=>{clearTimeout(e.realdom.domInterceptionRecords.get(h)?.timeout),e.realdom.domInterceptionRecords.set(h,d.event);let I=setTimeout(()=>{e.realdom.domInterceptionRecords.delete(h)},0);Object.defineProperty(d.event,"timeout",{value:I,configurable:!0})}),e.realdom.domInterceptionHooks.get("intercept")?.forEach(h=>h(d));let v=y();return e.realdom.domInterceptionHooks.get("sync")?.forEach(h=>h(d)),v},_={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"]},O={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(_).reduce((d,y)=>d.concat(y),[])).forEach(d=>{Object.keys(_).forEach(h=>{if(!_[h].includes(d))return;let I=Object.getOwnPropertyDescriptor(r[h].prototype,d);!I||(Object.defineProperty(r[h].prototype,d,"value"in I?{...I,value:y}:{...I,set:v}),O[h][d]=I)});function y(...h){let I=Object.keys(O).find(P=>this instanceof r[P]&&d in O[P]),z=O[I],L=()=>z[d].value.call(this,...h);if(e.realdom.domInterceptionNoRecurse.get(this)===d)return L();let k=[],x=[],N=this;["insertBefore"].includes(d)?x=[h[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(d)?(x=[h[1]],["beforebegin","afterend"].includes(h[0])&&(N=this.parentNode)):["setHTMLUnsafe","replaceChildren"].includes(d)?(k=[...this.childNodes],x=d==="replaceChildren"?[...h]:[h[0]]):["replaceWith","remove"].includes(d)?(k=[this],x=d==="replaceWith"?[...h]:[],N=this.parentNode):["replaceChild"].includes(d)?(k=[h[1]],x=[h[0]]):["removeChild"].includes(d)?k=[...h]:(x=[...h],["before","after"].includes(d)&&(N=this.parentNode));let ft=d;if(["insertAdjacentHTML","setHTMLUnsafe"].includes(d)){let P=this.nodeName;if(d==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(h[0])){if(!this.parentNode)return z[d].value.call(this,...h);P=this.parentNode.nodeName}let R=i.createElement(P.includes("-")?"div":P);z.setHTMLUnsafe.value.call(R,x[0],d==="setHTMLUnsafe"?h[1]:{}),x=[...R.childNodes],d==="insertAdjacentHTML"?(ft="insertAdjacentElement",h[1]=new a,u(h[1],"append",()=>h[1].append(...R.childNodes))):(ft="replaceChildren",h=[...R.childNodes])}return N?p({target:N,entrants:x,exits:k,type:"interception",event:[this,d]},()=>z[ft].value.call(this,...h)):L()}function v(h){let I=Object.keys(O).find(V=>this instanceof r[V]&&d in O[V]),z=O[I],L=()=>z[d].set.call(this,h);if(this instanceof HTMLScriptElement||e.realdom.domInterceptionNoRecurse.get(this)===d)return L();let k=[],x=[],N=this;if(["outerHTML","outerText"].includes(d)?(k=[this],N=this.parentNode):this instanceof l?(N=this.content,k=[...this.content.childNodes]):k=[...this.childNodes],["outerHTML","innerHTML"].includes(d)){let V=this.nodeName;if(d==="outerHTML"){if(!this.parentNode)return L();V=this.parentNode.nodeName}let P=i.createElement(V.includes("-")?"div":V);if(u(P,d,()=>P[d]=h),x=this instanceof l?[...P.content.childNodes]:[...P.childNodes],this instanceof l&&this.hasAttribute("src")||this instanceof ShadowRoot){let R=B=>B.reduce((H,$)=>$ instanceof HTMLScriptElement?H.concat($):$ instanceof l?H.concat(R([$.content])):(H=H.concat(R([...$.querySelectorAll?.("template")||[]].map(Zt=>Zt.content))),H.concat(...$.querySelectorAll?.("script")||[])),[]);for(let B of R(x)){if(this instanceof ShadowRoot){B.setAttribute("data-handling","manual");continue}let H=i.createElement("script");[...B.attributes].forEach($=>H.setAttribute($.name,$.value)),H.textContent=B.textContent,u(B,"replaceWith",()=>B.replaceWith(H))}}d==="outerHTML"?(h=new a,u(h,"append",()=>h.append(...x)),L=()=>u(this,"replaceWith",()=>f.prototype.replaceWith.call(this,h))):this instanceof l?L=()=>u(this.content,"replaceChildren",()=>this.content.replaceChildren(...x)):L=()=>u(this,"replaceChildren",()=>f.prototype.replaceChildren.call(this,...x))}return p({target:N,entrants:x,exits:k,type:"interception",event:[this,d]},L)}}),m}function zt(){ye.call(this),be.call(this),_e.call(this)}function ye(){let n=this;n.CSS||(n.CSS={}),n.CSS.escape||(n.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function be(){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 _e(){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(t){for(var r=(this.document||this.ownerDocument).querySelectorAll(t),e=r.length;--e>=0&&r.item(e)!==this;);return e>-1})}function Xt(){let n=this;if(n.webqit||(n.webqit={}),n.webqit.realdom)return n.webqit.realdom;n.webqit.realdom={},zt.call(n),n.webqit.realdom.meta=(...r)=>we.call(n,...r),n.webqit.realdom.ready=(...r)=>Et.call(n,...r),n.webqit.realdom.realtime=(r,e="dom")=>{if(e==="dom")return new rt(r,n);if(e==="attr")return new F(r,n)};let t=new tt(n);return n.webqit.realdom.schedule=(r,...e)=>t[`on${r}`](...e),n.webqit.realdom.synthesizeWhile=(...r)=>t.synthesizeWhile(...r),n.webqit.realdom}function Et(...n){let t="interactive",r;Q(n[0])?(t=n[0],b(n[1])&&(r=n[1])):b(n[0])&&(r=n[0]);let e={interactive:["interactive","complete"],complete:["complete"]};if(!e[t])throw new Error(`Invalid ready-state timing: ${t}.`);let i=this;if(!r)return i.webqit.realdom.readyStatePromises||(i.webqit.realdom.readyStatePromises={interactive:new Promise(o=>Et.call(this,"interactive",o)),complete:new Promise(o=>Et.call(this,"complete",o))}),i.webqit.realdom.readyStatePromises[t];if(e[t].includes(i.document.readyState))return r(i);i.webqit.realdom.readyStateCallbacks||(i.webqit.realdom.readyStateCallbacks={interactive:[],complete:[]},i.document.addEventListener("readystatechange",()=>{let o=i.document.readyState;for(let s of i.webqit.realdom.readyStateCallbacks[o].splice(0))s(i)},!1)),i.webqit.realdom.readyStateCallbacks[t].push(r)}function we(n){let t=this,r={},e;return(e=t.document.querySelector(`meta[name="${n}"]`))&&(r=(e.content||"").split(";").filter(i=>i).reduce((i,o)=>{let s=o.split("=").map(f=>f.trim());return xt(i,s[0].split("."),s[1]==="true"?!0:s[1]==="false"?!1:S(s[1])?parseInt(s[1]):s[1]),i},{})),{get name(){return n},get content(){return e.content},json(){return JSON.parse(JSON.stringify(r))}}}function pt(n,t){return typeof n!="string"?n:n.replace(/\w\S*/g,function(r){return r.charAt(0).toUpperCase()+(typeof t!==void 0&&t?r.substr(1).toLowerCase():r.substr(1))})}var W=(n,...t)=>C(n,"oohtml",...t),M={};function Jt(n,t,r){let e=this,i=Xt.call(e);M.window=e,e.webqitConfig||(e.webqitConfig=i.meta("webqit").json()),e.webqit||(e.webqit={}),e.webqit.oohtml||(e.webqit.oohtml={}),e.webqit.oohtml.configs||(e.webqit.oohtml.configs={});let o=n.toUpperCase().replace("-","_");if(!e.webqit.oohtml.configs[o]){e.webqit.oohtml.configs[o]={};let s=e.webqit.oohtml.configs[o];Z(2,s,r,t,i.meta(n).json()),e.webqitConfig.prefix&&Object.keys(s).forEach(f=>{Object.keys(s[f]).forEach(c=>{f==="api"&&typeof s[f][c]=="string"?s[f][c]=`${e.webqitConfig.prefix}${pt(s[f][c])}`:["attr","elements"].includes(f)&&s[f][c]?.startsWith("data-")===!1&&(s[f][c]=`${e.webqitConfig.prefix}-${s[f][c]}`)})})}return{config:e.webqit.oohtml.configs[o],realdom:i,window:e}}function St(n,t){return[...n].reduce(([r,e,i],o)=>!r&&e===0&&(Array.isArray(t)?t:[t]).includes(o)?[r,e,[""].concat(i)]:(!r&&["(","[","{"].includes(o)&&!i[0].endsWith("\\")&&e++,!r&&[")","]","}"].includes(o)&&!i[0].endsWith("\\")&&e--,['"',"'","`"].includes(o)&&!i[0].endsWith("\\")&&(r=r===o?null:r||o),i[0]+=o,[r,e,i]),[null,0,[""]])[2].reverse()}function Yt(){let{window:n}=M,{webqit:t}=n;if(t.DOMContextRequestEvent)return t.DOMContextRequestEvent;class r extends n.Event{constructor(...i){let o=i.pop();if(typeof o!="function")throw new Error("Callback must be provided.");let s=i.pop();if(!s?.kind)throw new Error('"options.kind" must be specified.');let f=["contextrequest","contextclaim"],c=i.pop()||f[0];if(!f.includes(c))throw new Error(`Invalid event type. Must be one of: ${f.join(",")}`);let{kind:l,detail:a,targetContext:m,live:u,signal:p,diff:_,...O}=s;super(c,{...O,bubbles:O.bubbles!==!1}),Object.defineProperty(this,"callback",{get:()=>o}),Object.defineProperty(this,"kind",{get:()=>l}),Object.defineProperty(this,"targetContext",{get:()=>m}),Object.defineProperty(this,"detail",{get:()=>a}),Object.defineProperty(this,"live",{get:()=>u}),Object.defineProperty(this,"signal",{get:()=>p}),Object.defineProperty(this,"diff",{get:()=>_}),Object.defineProperty(this,"options",{get:()=>O}),Object.defineProperty(this,"meta",{value:{}})}get target(){return super.target||this.meta.target}get answered(){return this.meta.answered||!1}respondWith(i){if(this.meta.answered=!0,this.diff){if("_prevValue"in this&&this._prevValue===i)return;Object.defineProperty(this,"_prevValue",{value:i,configurable:!0})}return this.callback(i)}}return t.DOMContextRequestEvent=r,r}var nt=class extends AbortController{constructor(t){super(),t(r=>{let{window:{webqit:{Observer:e}}}=M;e.defineProperty(this,"value",{value:r,configurable:!0,enumerable:!0})},this)}};var it=class extends Error{};var ot=class{static instance(t){return W(t).get("contexts::instance")||new this(t)}constructor(t){W(t).get("contexts::instance")?.dispose(),W(t).set("contexts::instance",this);let r={host:t,contexts:new Set};Object.defineProperty(this,"#",{get:()=>r})}[Symbol.iterator](){return this["#"].contexts[Symbol.iterator]()}get length(){return this["#"].contexts.size}find(...t){return[...this["#"].contexts].find(r=>typeof t[0]=="function"?t[0](r):r.constructor.kind===t[0]&&(!t[1]||r.detail===t[1]))}attach(t){if(!(t instanceof U))throw new TypeError("Context is not a valid DOMContext instance.");if(this.find(t.constructor.kind,t.detail))throw new it(`Context of same kind "${t.constructor.kind}"${t.detail?` and detail "${t.detail}"`:""} already exists.`);this["#"].contexts.add(t),t.initialize(this["#"].host)}detach(t){t.dispose(this["#"].host),this["#"].contexts.delete(t)}request(...t){return new nt((r,e)=>{typeof t[t.length-1]!="function"&&(t[t.length-1]?t.push(r):t[t.length-1]=r);let i;(i=t.find(s=>typeof s=="object"&&s))&&i.live&&(i.signal&&i.signal.addEventListener("abort",()=>e.abort()),t[t.indexOf(i)]={...i,signal:e.signal});let o=new(Yt())(...t);this["#"].host.dispatchEvent(o)})}};var Ct=class{static createRequest(){return{kind:this.kind}}constructor(t=null){Object.defineProperty(this,"detail",{get:()=>t}),Object.defineProperty(this,"subscriptions",{value:new Set})}get configs(){let{window:{webqit:{oohtml:{configs:t}}}}=M;return t}get name(){return[M.window.Document,M.window.ShadowRoot].some(t=>this.host instanceof t)?1/0:this.host.getAttribute(this.configs.CONTEXT_API.attr.contextname)}subscribed(t){}handle(t){}unsubscribed(t){}matchEvent(t){return t.kind===this.constructor.kind&&(!t.targetContext||t.targetContext===this.name)}handleEvent(t){if(!(this.disposed||typeof t.respondWith!="function")){if(t.type==="contextclaim"){if(!(t.detail instanceof Ct)||t.target===this.host)return;let r=new Set;if(this.subscriptions.forEach(e=>{!t.target.contains(e.target)||!t.detail.matchEvent(e)||(this.subscriptions.delete(e),this.unsubscribed(e),r.add(e))}),r.size)return t.respondWith(r)}if(t.type==="contextrequest")return this.matchEvent(t)?(t.live&&(this.subscriptions.add(t),this.subscribed(t),t.signal?.addEventListener("abort",()=>{this.subscriptions.delete(t),this.unsubscribed(t)})),t.stopPropagation(),this.handle(t)):void 0}}initialize(t){this.host=t,this.disposed=!1,t.addEventListener("contextrequest",this),t.addEventListener("contextclaim",this);let{value:r}=ot.instance(t).request("contextclaim",{kind:this.constructor.kind,detail:this});return r?.forEach(e=>{this.subscriptions.add(e),this.subscribed(e),this.handle(e)}),this}dispose(t){return this.disposed=!0,t.removeEventListener("contextrequest",this),t.removeEventListener("contextclaim",this),this.subscriptions.forEach(r=>{this.subscriptions.delete(r),this.unsubscribed(r);let{target:e}=r;r.meta.answered=!1,e.dispatchEvent(r)}),this}},U=Ct;lt(U,"kind");var T=class extends U{static createRequest(t=null){let r=super.createRequest();if(t?.startsWith("@")){let[e,...i]=i.slice(1).split(".").map(o=>o.trim());r.targetContext=e,r.detail=i.join(".")}else r.detail=t;return r}get bindingsObj(){return this.host[this.configs.BINDINGS_API.api.bindings]}matchEvent(t){return super.matchEvent(t)&&(!t.detail||!this.detail||(Array.isArray(t.detail)?t.detail[0]===this.detail:t.detail===this.detail))}handle(t){if(t.meta.controller?.abort(),!(t.detail+"").trim())return t.respondWith(this.bindingsObj);let{window:{webqit:{Observer:r}}}=M;t.meta.controller=r.reduce(this.bindingsObj,Array.isArray(t.detail)?t.detail:[t.detail],r.get,e=>{this.disposed||t.respondWith(e.value)},{live:t.live,signal:t.signal,descripted:!0})}unsubscribed(t){t.meta.controller?.abort()}};lt(T,"kind","bindings");function qt(n={}){let{config:t,window:r}=Jt.call(this,"bindings-api",n,{attr:{bindingsreflection:"bindings"},api:{bind:"bind",bindings:"bindings"}});r.webqit.DOMBindingsContext=T,ve.call(r,t),Ee.call(r,t)}function Tt(n,t){let r=this,{webqit:{Observer:e,oohtml:{configs:{CONTEXT_API:i}}}}=r;if(!W(t).has("bindings")){let o=Object.create(null);W(t).set("bindings",o),e.observe(o,s=>{if(t instanceof r.Element){let f=ht(t.getAttribute(n.attr.bindingsreflection)||""),c=new Map(f);for(let l of s)l.detail?.publish!==!1&&(l.type==="delete"?f.delete(l.key):f.set(l.key,void 0));f.size&&f.size!==c.size?t.setAttribute(n.attr.bindingsreflection,`{ ${[...f.entries()].map(([l,a])=>a===void 0?l:`${l}: ${a}`).join(", ")} }`):f.size||t.toggleAttribute(n.attr.bindingsreflection,!1)}else{let f=t[i.api.contexts];for(let c of s)if(c.type==="delete"){let l=f.find(T.kind,c.key);l&&f.detach(l)}else f.find(T.kind,c.key)||f.attach(new T(c.key))}})}return W(t).get("bindings")}function ve(n){let t=this,{webqit:{Observer:r}}=t;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(e=>{let i=e===t.Document.prototype?"Document":e===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(n.api.bind in e)throw new Error(`The ${i} prototype already has a "${n.api.bind}" API!`);if(n.api.bindings in e)throw new Error(`The ${i} prototype already has a "${n.api.bindings}" API!`);Object.defineProperty(e,n.api.bind,{value:function(o,s={}){return Ae.call(t,n,this,o,s)}}),Object.defineProperty(e,n.api.bindings,{get:function(){return r.proxy(Tt.call(t,n,this))}})})}function Ae(n,t,r,{merge:e,diff:i,publish:o,namespace:s}={}){let f=this,{webqit:{Observer:c}}=f,l=Tt.call(this,n,t),a={diff:i,namespace:s,detail:{publish:o}},m=e?[]:Object.keys(l).filter(u=>!(u in r));return c.batch(l,()=>(m.length&&c.deleteProperties(l,m,a),c.set(l,r,a)),a)}function Ee(n){let t=this,{webqit:{realdom:r,Observer:e,oohtml:{configs:i}}}=t,o=(f,c)=>{let l=f[i.CONTEXT_API.api.contexts];l.find(T.kind,c)||l.attach(new T(c))},s=(f,c)=>{let l,a=f[i.CONTEXT_API.api.contexts];for(;l=a.find(T.kind,c);)a.detach(l)};r.realtime(t.document).query(`[${t.CSS.escape(n.attr.bindingsreflection)}]`,f=>{f.exits.forEach(c=>s(c)),f.entrants.forEach(c=>{let l=ht(c.getAttribute(n.attr.bindingsreflection)||""),a=[...l.entries()].filter(([m,u])=>u!==void 0);a.length&&c[n.api.bind](Object.fromEntries(a),{merge:!0,publish:!1});for(let[m]of l)o(c,m)})},{id:"bindings:dom",live:!0,subtree:"cross-roots",timing:"sync",eventDetails:!0}),r.realtime(t.document,"attr").observe(n.attr.bindingsreflection,f=>{let c=Tt.call(t,n,f.target),l=ht(f.value||""),a=ht(f.oldValue||"");for(let m of new Set([...l.keys(),...a.keys()]))a.has(m)?l.has(m)?l.get(m)!==a.get(m)&&e.set(c,m,l.get(m),{detail:{publish:!1}}):(a.get(m)!==void 0&&e.deleteProperty(c,m,{detail:{publish:!1}}),s(f.target,m)):(l.get(m)!==void 0&&e.set(c,m,l.get(m),{detail:{publish:!1}}),o(f.target,m))},{id:"bindings:attr",subtree:"cross-roots",timing:"sync",newValue:!0,oldValue:!0})}var ht=n=>(n=n.trim(),new Map(St(n.slice(1,-1),",").filter(t=>t.trim()).map(t=>St(t,":").map(r=>r.trim()))));qt.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
|
+
|
|
8
|
+
// node_modules/@webqit/util/js/isObject.js
|
|
9
|
+
function isObject_default(val) {
|
|
10
|
+
return !Array.isArray(val) && typeof val === "object" && val;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// node_modules/@webqit/util/js/isArray.js
|
|
14
|
+
function isArray_default(val) {
|
|
15
|
+
return Array.isArray(val);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// node_modules/@webqit/util/js/isTypeFunction.js
|
|
19
|
+
function isTypeFunction_default(val) {
|
|
20
|
+
return typeof val === "function";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// node_modules/@webqit/util/js/isNull.js
|
|
24
|
+
function isNull_default(val) {
|
|
25
|
+
return val === null || val === "";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// node_modules/@webqit/util/js/isUndefined.js
|
|
29
|
+
function isUndefined_default(val) {
|
|
30
|
+
return arguments.length && (val === void 0 || typeof val === "undefined");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// node_modules/@webqit/util/js/isTypeObject.js
|
|
34
|
+
function isTypeObject_default(val) {
|
|
35
|
+
return Array.isArray(val) || typeof val === "object" && val || isTypeFunction_default(val);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// node_modules/@webqit/util/js/isEmpty.js
|
|
39
|
+
function isEmpty_default(val) {
|
|
40
|
+
return isNull_default(val) || isUndefined_default(val) || val === false || val === 0 || isTypeObject_default(val) && !Object.keys(val).length;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// node_modules/@webqit/util/js/isFunction.js
|
|
44
|
+
function isFunction_default(val) {
|
|
45
|
+
return isTypeFunction_default(val) || val && {}.toString.call(val) === "[object function]";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// node_modules/@webqit/util/js/isNumber.js
|
|
49
|
+
function isNumber_default(val) {
|
|
50
|
+
return val instanceof Number || typeof val === "number";
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// node_modules/@webqit/util/js/isNumeric.js
|
|
54
|
+
function isNumeric_default(val) {
|
|
55
|
+
return isNumber_default(val) || val !== true && val !== false && val !== null && val !== "" && !isNaN(val * 1);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// node_modules/@webqit/util/js/isString.js
|
|
59
|
+
function isString_default(val) {
|
|
60
|
+
return val instanceof String || typeof val === "string" && val !== null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// node_modules/@webqit/util/js/isTypeArray.js
|
|
64
|
+
function isTypeArray_default(val) {
|
|
65
|
+
return !isString_default(val) && !isUndefined_default(val.length);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// node_modules/@webqit/util/arr/pushUnique.js
|
|
69
|
+
function pushUnique_default(arr, ...items) {
|
|
70
|
+
items.forEach((itm) => {
|
|
71
|
+
if (arr.indexOf(itm) < 0) {
|
|
72
|
+
arr.push(itm);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
return arr;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// node_modules/@webqit/util/obj/getPrototypeChain.js
|
|
79
|
+
function getPrototypeChain_default(obj, until) {
|
|
80
|
+
until = until || Object.prototype;
|
|
81
|
+
until = until && !isArray_default(until) ? [until] : until;
|
|
82
|
+
var prototypalChain = [];
|
|
83
|
+
var obj = obj;
|
|
84
|
+
while (obj && (!until || until.indexOf(obj) < 0) && obj.name !== "default") {
|
|
85
|
+
prototypalChain.push(obj);
|
|
86
|
+
obj = obj ? Object.getPrototypeOf(obj) : null;
|
|
87
|
+
}
|
|
88
|
+
return prototypalChain;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// node_modules/@webqit/util/obj/getAllPropertyNames.js
|
|
92
|
+
function getAllPropertyNames_default(obj, until) {
|
|
93
|
+
var keysAll = [];
|
|
94
|
+
getPrototypeChain_default(obj, until).forEach((obj2) => {
|
|
95
|
+
pushUnique_default(keysAll, ...Object.getOwnPropertyNames(obj2));
|
|
96
|
+
});
|
|
97
|
+
return keysAll;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// node_modules/@webqit/util/obj/mergeCallback.js
|
|
101
|
+
function mergeCallback(objs, callback, deepProps = false, isReplace = false, withSymbols = false) {
|
|
102
|
+
var depth = 0;
|
|
103
|
+
var obj1 = objs.shift();
|
|
104
|
+
if (isNumeric_default(obj1) || obj1 === true || obj1 === false) {
|
|
105
|
+
depth = obj1;
|
|
106
|
+
obj1 = objs.shift();
|
|
107
|
+
}
|
|
108
|
+
if (!objs.length) {
|
|
109
|
+
throw new Error("_merge() requires two or more array/objects.");
|
|
110
|
+
}
|
|
111
|
+
objs.forEach((obj2, i) => {
|
|
112
|
+
if (!isTypeObject_default(obj2) && !isFunction_default(obj2)) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
(deepProps ? getAllPropertyNames_default(obj2) : Object.keys(obj2)).forEach((key) => {
|
|
116
|
+
if (!callback(key, obj1, obj2, i)) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
var valAtObj1 = obj1[key];
|
|
120
|
+
var valAtObj2 = obj2[key];
|
|
121
|
+
if ((isArray_default(valAtObj1) && isArray_default(valAtObj2) || isObject_default(valAtObj1) && isObject_default(valAtObj2)) && (depth === true || depth > 0)) {
|
|
122
|
+
obj1[key] = isArray_default(valAtObj1) && isArray_default(valAtObj2) ? [] : {};
|
|
123
|
+
mergeCallback([isNumeric_default(depth) ? depth - 1 : depth, obj1[key], valAtObj1, valAtObj2], callback, deepProps, isReplace, withSymbols);
|
|
124
|
+
} else {
|
|
125
|
+
if (isArray_default(obj1) && isArray_default(obj2)) {
|
|
126
|
+
if (isReplace) {
|
|
127
|
+
obj1[key] = valAtObj2;
|
|
128
|
+
} else {
|
|
129
|
+
obj1.push(valAtObj2);
|
|
130
|
+
}
|
|
131
|
+
} else {
|
|
132
|
+
try {
|
|
133
|
+
if (withSymbols) {
|
|
134
|
+
Object.defineProperty(obj1, key, Object.getOwnPropertyDescriptor(obj2, key));
|
|
135
|
+
} else {
|
|
136
|
+
obj1[key] = obj2[key];
|
|
137
|
+
}
|
|
138
|
+
} catch (e) {
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
return obj1;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// node_modules/@webqit/util/obj/merge.js
|
|
148
|
+
function merge_default(...objs) {
|
|
149
|
+
return mergeCallback(objs, (k, obj1, obj2) => {
|
|
150
|
+
return true;
|
|
151
|
+
}, false, false, false);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// node_modules/@webqit/util/js/wq.js
|
|
155
|
+
function wq(obj, ...namespaces) {
|
|
156
|
+
if (!obj || !["object", "function"].includes(typeof obj)) {
|
|
157
|
+
throw new Error(`Argument #1 must be of type object`);
|
|
158
|
+
}
|
|
159
|
+
let wq2 = obj[Symbol.for("wq")];
|
|
160
|
+
if (!wq2) {
|
|
161
|
+
wq2 = new WQInternals();
|
|
162
|
+
Object.defineProperty(obj, Symbol.for("wq"), {
|
|
163
|
+
value: wq2,
|
|
164
|
+
enumerable: false,
|
|
165
|
+
configurable: false,
|
|
166
|
+
writable: false
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
if (!namespaces.length) {
|
|
170
|
+
return wq2;
|
|
171
|
+
}
|
|
172
|
+
let _ns, _wq2;
|
|
173
|
+
while (_ns = namespaces.shift()) {
|
|
174
|
+
if ((_wq2 = wq2) && !(wq2 = wq2.get(_ns))) {
|
|
175
|
+
wq2 = new WQInternals();
|
|
176
|
+
_wq2.set(_ns, wq2);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return wq2;
|
|
180
|
+
}
|
|
181
|
+
var WQInternals = class extends Map {
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
// node_modules/@webqit/util/arr/from.js
|
|
185
|
+
function from_default(val, castObject = true) {
|
|
186
|
+
if (isArray_default(val)) {
|
|
187
|
+
return val;
|
|
188
|
+
}
|
|
189
|
+
;
|
|
190
|
+
if (!castObject && isObject_default(val)) {
|
|
191
|
+
return [val];
|
|
192
|
+
}
|
|
193
|
+
;
|
|
194
|
+
if (val !== false && val !== 0 && isEmpty_default(val)) {
|
|
195
|
+
return [];
|
|
196
|
+
}
|
|
197
|
+
;
|
|
198
|
+
if (isTypeArray_default(val)) {
|
|
199
|
+
return Array.prototype.slice.call(val);
|
|
200
|
+
}
|
|
201
|
+
;
|
|
202
|
+
if (isObject_default(val)) {
|
|
203
|
+
return Object.values(val);
|
|
204
|
+
}
|
|
205
|
+
;
|
|
206
|
+
return [val];
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// node_modules/@webqit/util/obj/get.js
|
|
210
|
+
function get_default(ctxt, path, trap = {}, reciever = {}) {
|
|
211
|
+
path = from_default(path).slice();
|
|
212
|
+
var _ctxt = ctxt;
|
|
213
|
+
while (!isUndefined_default(_ctxt) && !isNull_default(_ctxt) && path.length) {
|
|
214
|
+
var _key = path.shift();
|
|
215
|
+
if (!(trap.get ? trap.get(_ctxt, _key) : isTypeObject_default(_ctxt) ? _key in _ctxt : _ctxt[_key])) {
|
|
216
|
+
reciever.exists = false;
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
_ctxt = trap.get ? trap.get(_ctxt, _key) : _ctxt[_key];
|
|
220
|
+
}
|
|
221
|
+
reciever.exists = true;
|
|
222
|
+
return _ctxt;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// node_modules/@webqit/util/obj/set.js
|
|
226
|
+
function set_default(obj, path, val, buildTree = {}, trap = {}) {
|
|
227
|
+
const _set = (target2, key, val2) => {
|
|
228
|
+
if (trap.set) {
|
|
229
|
+
return trap.set(target2, key, val2);
|
|
230
|
+
} else {
|
|
231
|
+
if (isNumeric_default(path[i]) && isArray_default(target2)) {
|
|
232
|
+
target2.push(val2);
|
|
233
|
+
} else {
|
|
234
|
+
target2[key] = val2;
|
|
235
|
+
}
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
path = from_default(path);
|
|
240
|
+
var target = obj;
|
|
241
|
+
for (var i = 0; i < path.length; i++) {
|
|
242
|
+
if (i < path.length - 1) {
|
|
243
|
+
if (!target || !isTypeObject_default(target) && !isFunction_default(target)) {
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
var branch = get_default(target, path[i], trap);
|
|
247
|
+
if (!isTypeObject_default(branch)) {
|
|
248
|
+
if (trap.buildTree === false) {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
branch = isFunction_default(trap.buildTree) ? trap.buildTree(i) : isNumeric_default(path[i + 1]) ? [] : {};
|
|
252
|
+
var branchSuccess = _set(target, path[i], branch);
|
|
253
|
+
if (!branchSuccess) {
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
target = branch;
|
|
258
|
+
} else {
|
|
259
|
+
return _set(target, path[i], val);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// node_modules/@webqit/realdom/src/Scheduler.js
|
|
265
|
+
var Scheduler = class {
|
|
266
|
+
constructor(window2, synthesis = false) {
|
|
267
|
+
Object.defineProperty(this, "window", { value: window2 });
|
|
268
|
+
Object.defineProperty(this, "readCallbacks", { value: /* @__PURE__ */ new Set() });
|
|
269
|
+
Object.defineProperty(this, "writeCallbacks", { value: /* @__PURE__ */ new Set() });
|
|
270
|
+
Object.defineProperty(this, "_synthesis", { value: 0, writable: true });
|
|
271
|
+
if (!synthesis && this.window.requestAnimationFrame) {
|
|
272
|
+
this._loop();
|
|
273
|
+
} else {
|
|
274
|
+
this._synthesis++;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
get synthesis() {
|
|
278
|
+
return this._synthesis;
|
|
279
|
+
}
|
|
280
|
+
async synthesizeWhile(callback) {
|
|
281
|
+
this._synthesis++;
|
|
282
|
+
this._fulfill();
|
|
283
|
+
const returnValue = await callback();
|
|
284
|
+
this._synthesis--;
|
|
285
|
+
return returnValue;
|
|
286
|
+
}
|
|
287
|
+
_fulfill() {
|
|
288
|
+
for (const callback of this.readCallbacks) {
|
|
289
|
+
callback();
|
|
290
|
+
this.readCallbacks.delete(callback);
|
|
291
|
+
}
|
|
292
|
+
for (const callback of this.writeCallbacks) {
|
|
293
|
+
callback();
|
|
294
|
+
this.writeCallbacks.delete(callback);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
_loop() {
|
|
298
|
+
this.window.requestAnimationFrame(() => {
|
|
299
|
+
this._fulfill();
|
|
300
|
+
this._loop();
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
onread(callback, withPromise = false) {
|
|
304
|
+
if (withPromise) {
|
|
305
|
+
return new Promise((resolve) => {
|
|
306
|
+
if (this.synthesis) {
|
|
307
|
+
resolve(callback());
|
|
308
|
+
} else {
|
|
309
|
+
this.readCallbacks.add(() => {
|
|
310
|
+
resolve(callback());
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
if (this.synthesis) {
|
|
316
|
+
Promise.resolve().then(callback);
|
|
317
|
+
} else {
|
|
318
|
+
this.readCallbacks.add(callback);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
onwrite(callback, withPromise = false) {
|
|
322
|
+
if (withPromise) {
|
|
323
|
+
return new Promise((resolve) => {
|
|
324
|
+
if (this.synthesis) {
|
|
325
|
+
resolve(callback());
|
|
326
|
+
} else {
|
|
327
|
+
this.writeCallbacks.add(() => {
|
|
328
|
+
resolve(callback());
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
if (this.synthesis) {
|
|
334
|
+
Promise.resolve().then(callback);
|
|
335
|
+
} else {
|
|
336
|
+
this.writeCallbacks.add(callback);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
cycle(onread, onwrite, prevTransaction) {
|
|
340
|
+
this.onread(() => {
|
|
341
|
+
const readReturn = onread(prevTransaction);
|
|
342
|
+
const callWrite = (readReturn2) => {
|
|
343
|
+
if (readReturn2 === void 0)
|
|
344
|
+
return;
|
|
345
|
+
this.onwrite(() => {
|
|
346
|
+
const writeReturn = onwrite(readReturn2, prevTransaction);
|
|
347
|
+
const repeatTransaction = (writeReturn2) => {
|
|
348
|
+
if (writeReturn2 === void 0)
|
|
349
|
+
return;
|
|
350
|
+
this.cycle(onread, onwrite, writeReturn2);
|
|
351
|
+
};
|
|
352
|
+
if (writeReturn instanceof Promise) {
|
|
353
|
+
writeReturn.then(repeatTransaction);
|
|
354
|
+
} else {
|
|
355
|
+
repeatTransaction(writeReturn);
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
};
|
|
359
|
+
if (readReturn instanceof Promise) {
|
|
360
|
+
readReturn.then(callWrite);
|
|
361
|
+
} else {
|
|
362
|
+
callWrite(readReturn);
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
// node_modules/@webqit/realdom/src/realtime/Util.js
|
|
369
|
+
function isXpath(expr) {
|
|
370
|
+
return (expr = expr.trim()) && expr.startsWith("(") && expr.endsWith(")");
|
|
371
|
+
}
|
|
372
|
+
function xpathQuery(window2, context, expr, subtree = true) {
|
|
373
|
+
expr = (Array.isArray(expr) ? expr : [expr]).map((x) => (x + "").replace("(", subtree ? "(.//" : "(./")).join("|");
|
|
374
|
+
let nodes = [], node;
|
|
375
|
+
try {
|
|
376
|
+
const result = window2.document.evaluate(expr, context, null, window2.XPathResult.ANY_TYPE);
|
|
377
|
+
while (node = result.iterateNext())
|
|
378
|
+
nodes.push(node);
|
|
379
|
+
} catch (e) {
|
|
380
|
+
}
|
|
381
|
+
return nodes;
|
|
382
|
+
}
|
|
383
|
+
function xpathMatch(window2, node, expr) {
|
|
384
|
+
expr = (Array.isArray(expr) ? expr : [expr]).map((x) => (x + "").replace("(", "(self::")).join("|");
|
|
385
|
+
try {
|
|
386
|
+
return window2.document.evaluate(`${expr}`, node, null, window2.XPathResult.BOOLEAN_TYPE).booleanValue;
|
|
387
|
+
} catch (e) {
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
function containsNode(window2, a, b, crossRoots = false, testCache = null) {
|
|
391
|
+
const prevTest = testCache?.get(a)?.get(b);
|
|
392
|
+
if (typeof prevTest !== "undefined")
|
|
393
|
+
return prevTest;
|
|
394
|
+
const response = (val) => {
|
|
395
|
+
if (!testCache?.has(a))
|
|
396
|
+
testCache?.set(a, /* @__PURE__ */ new WeakMap());
|
|
397
|
+
testCache?.get(a)?.set(b, val);
|
|
398
|
+
return val;
|
|
399
|
+
};
|
|
400
|
+
const rootNodeA = a.getRootNode();
|
|
401
|
+
const rootNodeB = b.getRootNode();
|
|
402
|
+
if (rootNodeA === rootNodeB)
|
|
403
|
+
return response(a.contains(b));
|
|
404
|
+
if (crossRoots && rootNodeB instanceof window2.ShadowRoot)
|
|
405
|
+
return response(containsNode(window2, a, rootNodeB.host, crossRoots, testCache));
|
|
406
|
+
return response(false);
|
|
407
|
+
}
|
|
408
|
+
function splitOuter(str, delim = "|") {
|
|
409
|
+
return [...str].reduce(([quote, depth, splits, skip], x) => {
|
|
410
|
+
if (!quote && depth === 0 && (Array.isArray(delim) ? delim : [delim]).includes(x)) {
|
|
411
|
+
return [quote, depth, [""].concat(splits)];
|
|
412
|
+
}
|
|
413
|
+
if (!quote && ["(", "[", "{"].includes(x) && !splits[0].endsWith("\\"))
|
|
414
|
+
depth++;
|
|
415
|
+
if (!quote && [")", "]", "}"].includes(x) && !splits[0].endsWith("\\"))
|
|
416
|
+
depth--;
|
|
417
|
+
if (['"', "'", "`"].includes(x) && !splits[0].endsWith("\\")) {
|
|
418
|
+
quote = quote === x ? null : quote || x;
|
|
419
|
+
}
|
|
420
|
+
splits[0] += x;
|
|
421
|
+
return [quote, depth, splits];
|
|
422
|
+
}, [null, 0, [""]])[2].reverse();
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// node_modules/@webqit/realdom/src/realtime/DOMSpec.js
|
|
426
|
+
var DOMSpec = class {
|
|
427
|
+
constructor(content) {
|
|
428
|
+
this.content = content;
|
|
429
|
+
this.type = typeof content === "string" ? "selector" : "instance";
|
|
430
|
+
this.kind = this.type === "instance" ? null : isXpath(content) ? "xpath" : "css";
|
|
431
|
+
if (this.kind === "xpath") {
|
|
432
|
+
this.isXpathAttr = splitOuter(content.trim().slice(1, -1), "@").length > 1;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
toString() {
|
|
436
|
+
return this.content;
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
// node_modules/@webqit/realdom/src/realtime/Realtime.js
|
|
441
|
+
var Realtime = class {
|
|
442
|
+
constructor(context, namespace, window2) {
|
|
443
|
+
this.context = context;
|
|
444
|
+
this.namespace = namespace;
|
|
445
|
+
this.window = context.defaultView || context.ownerDocument?.defaultView || window2;
|
|
446
|
+
this.document = this.window.document;
|
|
447
|
+
this.webqit = this.window.webqit;
|
|
448
|
+
Object.defineProperty(this, "#", { value: {} });
|
|
449
|
+
}
|
|
450
|
+
resolveArgs(args) {
|
|
451
|
+
if (isFunction_default(args[0])) {
|
|
452
|
+
args = [[], ...args];
|
|
453
|
+
} else if (isObject_default(args[0]) && !(args[0] instanceof DOMSpec) && args.length === 1) {
|
|
454
|
+
args = [[], void 0, args[0]];
|
|
455
|
+
} else if (isObject_default(args[1]) && args.length === 2) {
|
|
456
|
+
args = [from_default(args[0], false), void 0, args[1]];
|
|
457
|
+
} else {
|
|
458
|
+
args[0] = from_default(args[0], false);
|
|
459
|
+
}
|
|
460
|
+
if (args[0].filter((x) => typeof x !== "string" && !(x instanceof DOMSpec) && !(x instanceof this.window.Node)).length) {
|
|
461
|
+
throw new Error(`Argument #2 must be either a string or a Node object, or a list of those.`);
|
|
462
|
+
}
|
|
463
|
+
args[0] = args[0].map((s) => s instanceof DOMSpec ? s : new DOMSpec(s));
|
|
464
|
+
return args;
|
|
465
|
+
}
|
|
466
|
+
registry(...args) {
|
|
467
|
+
return wq(this.window, "realdom", this.namespace, ...args);
|
|
468
|
+
}
|
|
469
|
+
createSignalGenerator() {
|
|
470
|
+
return {
|
|
471
|
+
generate() {
|
|
472
|
+
this.lastController?.abort();
|
|
473
|
+
this.lastController = new AbortController();
|
|
474
|
+
const flags = { signal: this.lastController.signal };
|
|
475
|
+
return flags;
|
|
476
|
+
},
|
|
477
|
+
disconnect() {
|
|
478
|
+
this.lastController?.abort();
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
forEachMatchingContext(interceptionTiming, record_s, callback) {
|
|
483
|
+
const { window: window2 } = this, deferreds = /* @__PURE__ */ new Set(), testCache = /* @__PURE__ */ new WeakMap();
|
|
484
|
+
for (const [registration, deferred] of this.registry(interceptionTiming)) {
|
|
485
|
+
let $records = [].concat(record_s).filter((record) => containsNode(window2, registration.context, record.target, registration.params.subtree === "cross-roots", testCache));
|
|
486
|
+
if (!$records.length)
|
|
487
|
+
continue;
|
|
488
|
+
const args = [registration, Array.isArray(record_s) ? $records : $records[0]];
|
|
489
|
+
if (deferred)
|
|
490
|
+
deferreds.add(args);
|
|
491
|
+
else
|
|
492
|
+
callback.call(window2, ...args);
|
|
493
|
+
}
|
|
494
|
+
for (const args of deferreds)
|
|
495
|
+
callback.call(window2, ...args);
|
|
496
|
+
deferreds.clear();
|
|
497
|
+
}
|
|
498
|
+
disconnectables(signal, ...objects) {
|
|
499
|
+
const disconnectable = { disconnect() {
|
|
500
|
+
objects.forEach((d) => d && isFunction_default(d.disconnect) && d.disconnect() || isFunction_default(d) && d() || isObject_default(d) && (d.disconnected = true));
|
|
501
|
+
} };
|
|
502
|
+
if (signal)
|
|
503
|
+
signal.addEventListener("abort", () => disconnectable.disconnect());
|
|
504
|
+
return disconnectable;
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
// node_modules/@webqit/realdom/src/realtime/AttrRealtime.js
|
|
509
|
+
var AttrRealtime = class extends Realtime {
|
|
510
|
+
type = "attr";
|
|
511
|
+
constructor(context, ...args) {
|
|
512
|
+
super(context, "attr", ...args);
|
|
513
|
+
}
|
|
514
|
+
get(spec, callback = void 0, params = {}) {
|
|
515
|
+
const originalFilterIsString = typeof spec === "string" || spec instanceof DOMSpec;
|
|
516
|
+
[spec = [], callback = void 0, params = {}] = this.resolveArgs(arguments);
|
|
517
|
+
const { context } = this;
|
|
518
|
+
const records = attrIntersection(context, spec);
|
|
519
|
+
if (!callback)
|
|
520
|
+
return records;
|
|
521
|
+
const signalGenerator = params.lifecycleSignals && this.createSignalGenerator();
|
|
522
|
+
if (!originalFilterIsString) {
|
|
523
|
+
const flags = signalGenerator?.generate() || {};
|
|
524
|
+
callback(records, flags, context);
|
|
525
|
+
} else {
|
|
526
|
+
for (const record of records) {
|
|
527
|
+
const flags = signalGenerator ? signalGenerator.generate() : {};
|
|
528
|
+
callback(record, flags, context);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
if (params.live) {
|
|
532
|
+
if (signalGenerator) {
|
|
533
|
+
params = { ...params, signalGenerator };
|
|
534
|
+
}
|
|
535
|
+
const disconnectable_live = this.observe(originalFilterIsString ? spec[0] : spec, callback, { newValue: true, ...params });
|
|
536
|
+
return this.disconnectables(params.signal, disconnectable_live);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
observe(spec, callback, params = {}) {
|
|
540
|
+
const originalFilterIsString = typeof spec === "string" || spec instanceof DOMSpec;
|
|
541
|
+
[spec = [], callback, params = {}] = this.resolveArgs(arguments);
|
|
542
|
+
if (["sync", "intercept"].includes(params.timing))
|
|
543
|
+
return this.observeSync(originalFilterIsString ? spec[0] : spec, callback, params);
|
|
544
|
+
if (params.timing && params.timing !== "async")
|
|
545
|
+
throw new Error(`Timing option "${params.timing}" invalid.`);
|
|
546
|
+
const { context, window: window2, webqit } = this;
|
|
547
|
+
if (params.eventDetails && !webqit.realdom.attrInterceptionHooks?.intercepting) {
|
|
548
|
+
attrInterception.call(window2, "intercept", () => {
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
const disconnectable = new window2.MutationObserver((records) => {
|
|
552
|
+
records = dedupAndIgnoreInternals(records).map((rcd) => withAttrEventDetails.call(window2, rcd));
|
|
553
|
+
dispatch.call(window2, registration, records, context);
|
|
554
|
+
});
|
|
555
|
+
const $params = { attributes: true, attributeOldValue: params.oldValue, subtree: params.subtree && true };
|
|
556
|
+
if (spec.length) {
|
|
557
|
+
$params.attributeFilter = spec.map((a) => a + "");
|
|
558
|
+
}
|
|
559
|
+
disconnectable.observe(context, $params);
|
|
560
|
+
const signalGenerator = params.signalGenerator || params.lifecycleSignals && this.createSignalGenerator();
|
|
561
|
+
const registration = { context, spec, callback, params, atomics: /* @__PURE__ */ new Map(), originalFilterIsString, signalGenerator, disconnectable };
|
|
562
|
+
return this.disconnectables(params.signal, disconnectable, signalGenerator);
|
|
563
|
+
}
|
|
564
|
+
observeSync(spec, callback, params = {}) {
|
|
565
|
+
const originalFilterIsString = typeof spec === "string" || spec instanceof DOMSpec;
|
|
566
|
+
[spec, callback, params = {}] = this.resolveArgs(arguments);
|
|
567
|
+
const { context, window: window2 } = this;
|
|
568
|
+
if (params.timing && !["sync", "intercept"].includes(params.timing))
|
|
569
|
+
throw new Error(`Timing option "${params.timing}" invalid.`);
|
|
570
|
+
const interceptionTiming = params.timing === "intercept" ? "intercept" : "sync";
|
|
571
|
+
if (!this.registry(interceptionTiming).size) {
|
|
572
|
+
attrInterception.call(window2, interceptionTiming, (records) => {
|
|
573
|
+
this.forEachMatchingContext(interceptionTiming, records, dispatch);
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
const disconnectable = { disconnect() {
|
|
577
|
+
registry.delete(registration);
|
|
578
|
+
} };
|
|
579
|
+
const signalGenerator = params.signalGenerator || params.lifecycleSignals && this.createSignalGenerator();
|
|
580
|
+
const registration = { context, spec, callback, params, atomics: /* @__PURE__ */ new Map(), originalFilterIsString, signalGenerator, disconnectable };
|
|
581
|
+
const registry = this.registry(interceptionTiming);
|
|
582
|
+
registry.set(registration, !!registration.params.deferred);
|
|
583
|
+
return this.disconnectables(params.signal, disconnectable, signalGenerator);
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
function dedupAndIgnoreInternals(records) {
|
|
587
|
+
return records.reduce((rcds, rcd, i) => {
|
|
588
|
+
if (rcds[i - 1]?.attributeName === rcd.attributeName)
|
|
589
|
+
return rcds;
|
|
590
|
+
if (wq(rcd.target, "realdom", "internalAttrInteractions").get(rcd.attributeName))
|
|
591
|
+
return rcds;
|
|
592
|
+
return rcds.concat(rcd);
|
|
593
|
+
}, []);
|
|
594
|
+
}
|
|
595
|
+
function dispatch(registration, records) {
|
|
596
|
+
const { context, spec, callback, params, atomics, originalFilterIsString, signalGenerator } = registration;
|
|
597
|
+
if (!params.subtree) {
|
|
598
|
+
records = records.filter((r) => {
|
|
599
|
+
return r.target === context;
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
if (!records.length)
|
|
603
|
+
return;
|
|
604
|
+
const $spec = spec.map((a) => a + "");
|
|
605
|
+
if (params.atomic && !atomics.size) {
|
|
606
|
+
records = attrIntersection(context, spec, records);
|
|
607
|
+
} else if (params.timing !== "async" && spec.length) {
|
|
608
|
+
records = records.filter((r) => $spec.includes(r.name));
|
|
609
|
+
}
|
|
610
|
+
if (!records.length)
|
|
611
|
+
return;
|
|
612
|
+
if (!(params.newValue === null && params.oldValue === null && params.eventDetails)) {
|
|
613
|
+
records = records.map((rcd) => {
|
|
614
|
+
let exclusion;
|
|
615
|
+
if (!params.eventDetails) {
|
|
616
|
+
({ event: exclusion, ...rcd } = rcd);
|
|
617
|
+
}
|
|
618
|
+
if (!params.oldValue && "oldValue" in rcd) {
|
|
619
|
+
({ oldValue: exclusion, ...rcd } = rcd);
|
|
620
|
+
}
|
|
621
|
+
if (!params.newValue && "value" in rcd) {
|
|
622
|
+
({ value: exclusion, ...rcd } = rcd);
|
|
623
|
+
} else if (params.newValue && typeof rcd.value === "undefined") {
|
|
624
|
+
rcd = { ...rcd, value: internalAttrInteraction(rcd.target, rcd.name, () => rcd.target.getAttribute(rcd.name)) };
|
|
625
|
+
}
|
|
626
|
+
return rcd;
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
if (params.atomic) {
|
|
630
|
+
records.forEach((record) => atomics.set(record.name, record));
|
|
631
|
+
records = Array.from(atomics.entries()).map(([, value]) => value);
|
|
632
|
+
}
|
|
633
|
+
const record_s = originalFilterIsString ? records[0] : records;
|
|
634
|
+
const flags = signalGenerator ? signalGenerator.generate() : {};
|
|
635
|
+
callback(record_s, flags, context);
|
|
636
|
+
}
|
|
637
|
+
function internalAttrInteraction(node, attrName, callback) {
|
|
638
|
+
const savedAttrLocking = wq(node, "realdom", "internalAttrInteractions").get(attrName);
|
|
639
|
+
wq(node, "realdom", "internalAttrInteractions").set(attrName, true);
|
|
640
|
+
const value = callback();
|
|
641
|
+
wq(node, "realdom", "internalAttrInteractions").set(attrName, savedAttrLocking);
|
|
642
|
+
return value;
|
|
643
|
+
}
|
|
644
|
+
function attrIntersection(context, spec, records = []) {
|
|
645
|
+
const _type = { event: null, type: "attribute" };
|
|
646
|
+
if (spec.length) {
|
|
647
|
+
return spec.map((attrName) => {
|
|
648
|
+
attrName = attrName + "";
|
|
649
|
+
return records.find((r) => r.name === attrName) || { target: context, name: attrName, value: internalAttrInteraction(context, attrName, () => context.getAttribute(attrName)), ..._type };
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
const attrs = Array.from(context.attributes);
|
|
653
|
+
return attrs.map((attr) => {
|
|
654
|
+
return records.find((r) => r.name === attr.nodeName) || { target: context, name: attr.nodeName, value: internalAttrInteraction(context, attr.nodeName, () => attr.nodeValue), ..._type };
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
function withAttrEventDetails({ target, attributeName, value, oldValue }) {
|
|
658
|
+
const window2 = this, registry = window2.webqit.realdom.attrInterceptionRecords?.get(target) || {};
|
|
659
|
+
const event = registry[attributeName]?.[0] || "mutation";
|
|
660
|
+
const record = { target, name: attributeName, value, oldValue, type: "observation", event };
|
|
661
|
+
return record;
|
|
662
|
+
}
|
|
663
|
+
function attrInterception(timing, callback) {
|
|
664
|
+
const window2 = this;
|
|
665
|
+
const { webqit, document, Element } = window2;
|
|
666
|
+
if (!webqit.realdom.attrInterceptionHooks) {
|
|
667
|
+
Object.defineProperty(webqit.realdom, "attrInterceptionHooks", { value: /* @__PURE__ */ new Map() });
|
|
668
|
+
}
|
|
669
|
+
if (!webqit.realdom.attrInterceptionHooks.has(timing)) {
|
|
670
|
+
webqit.realdom.attrInterceptionHooks.set(timing, /* @__PURE__ */ new Set());
|
|
671
|
+
}
|
|
672
|
+
webqit.realdom.attrInterceptionHooks.get(timing).add(callback);
|
|
673
|
+
const rm = () => webqit.realdom.attrInterceptionHooks.get(timing).delete(callback);
|
|
674
|
+
if (webqit.realdom.attrInterceptionHooks?.intercepting)
|
|
675
|
+
return rm;
|
|
676
|
+
console.warn(`Attr mutation APIs are now being intercepted.`);
|
|
677
|
+
webqit.realdom.attrInterceptionHooks.intercepting = true;
|
|
678
|
+
Object.defineProperty(webqit.realdom, "attrInterceptionRecords", { value: /* @__PURE__ */ new Map() });
|
|
679
|
+
const attrIntercept = (record, defaultAction) => {
|
|
680
|
+
if (!webqit.realdom.attrInterceptionRecords.has(record.target)) {
|
|
681
|
+
webqit.realdom.attrInterceptionRecords.set(record.target, {});
|
|
682
|
+
}
|
|
683
|
+
const registry = webqit.realdom.attrInterceptionRecords.get(record.target);
|
|
684
|
+
registry[record.name] = registry[record.name] || [];
|
|
685
|
+
registry[record.name].unshift(record.event);
|
|
686
|
+
if (wq(record.target, "realdom", "internalAttrInteractions").get(record.name))
|
|
687
|
+
return defaultAction();
|
|
688
|
+
webqit.realdom.attrInterceptionHooks.get("intercept")?.forEach((callback2) => callback2([record]));
|
|
689
|
+
const returnValue = defaultAction();
|
|
690
|
+
webqit.realdom.attrInterceptionHooks.get("sync")?.forEach((callback2) => callback2([record]));
|
|
691
|
+
return returnValue;
|
|
692
|
+
};
|
|
693
|
+
const mo = new window2.MutationObserver((records) => {
|
|
694
|
+
records = records.filter((rcd) => {
|
|
695
|
+
const registry = window2.webqit.realdom.attrInterceptionRecords?.get(rcd.target) || {};
|
|
696
|
+
return !registry[rcd.attributeName]?.shift();
|
|
697
|
+
});
|
|
698
|
+
records = dedupAndIgnoreInternals(records).map((rcd) => withAttrEventDetails.call(window2, rcd));
|
|
699
|
+
if (!records.length)
|
|
700
|
+
return;
|
|
701
|
+
webqit.realdom.attrInterceptionHooks.get("intercept")?.forEach((callback2) => callback2(records));
|
|
702
|
+
webqit.realdom.attrInterceptionHooks.get("sync")?.forEach((callback2) => callback2(records));
|
|
703
|
+
});
|
|
704
|
+
mo.observe(document, { attributes: true, subtree: true, attributeOldValue: true });
|
|
705
|
+
const originalApis = /* @__PURE__ */ Object.create(null);
|
|
706
|
+
["setAttribute", "removeAttribute", "toggleAttribute"].forEach((apiName) => {
|
|
707
|
+
originalApis[apiName] = Element.prototype[apiName];
|
|
708
|
+
Element.prototype[apiName] = function(...args) {
|
|
709
|
+
let value, oldValue = internalAttrInteraction(this, args[0], () => this.getAttribute(args[0]));
|
|
710
|
+
if (["setAttribute", "toggleAttribute"].includes(apiName)) {
|
|
711
|
+
value = args[1];
|
|
712
|
+
}
|
|
713
|
+
if (apiName === "toggleAttribute" && value === void 0) {
|
|
714
|
+
value = oldValue === null ? true : false;
|
|
715
|
+
}
|
|
716
|
+
const record = { target: this, name: args[0], value, oldValue, type: "interception", event: [this, apiName] };
|
|
717
|
+
const exec = () => originalApis[apiName].call(this, ...args);
|
|
718
|
+
return attrIntercept(record, exec);
|
|
719
|
+
};
|
|
720
|
+
});
|
|
721
|
+
return rm;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
// node_modules/@webqit/realdom/src/realtime/DOMRealtime.js
|
|
725
|
+
var DOMRealtime = class extends Realtime {
|
|
726
|
+
constructor(context, ...args) {
|
|
727
|
+
super(context, "tree", ...args);
|
|
728
|
+
}
|
|
729
|
+
attr(filter, callback = void 0, params = {}) {
|
|
730
|
+
const { context, window: window2 } = this;
|
|
731
|
+
return new AttrRealtime(context, window2).get(...arguments);
|
|
732
|
+
}
|
|
733
|
+
query(spec, callback = void 0, params = {}) {
|
|
734
|
+
[spec, callback = void 0, params = {}] = this.resolveArgs(arguments);
|
|
735
|
+
const { context } = this;
|
|
736
|
+
const records = /* @__PURE__ */ new Map(), getRecord = (target) => {
|
|
737
|
+
if (!records.has(target)) {
|
|
738
|
+
records.set(target, { target, entrants: [], exits: [], type: "query", event: null });
|
|
739
|
+
}
|
|
740
|
+
return records.get(target);
|
|
741
|
+
};
|
|
742
|
+
if (!params.generation || params.generation === "entrants") {
|
|
743
|
+
if (!spec.length) {
|
|
744
|
+
[...context.children].forEach((node) => getRecord(context).entrants.push(node));
|
|
745
|
+
} else if (spec.every((s) => s.type === "selector")) {
|
|
746
|
+
const [cssSelectors, xpathQueries] = spec.reduce(([css, xpath], s) => {
|
|
747
|
+
return s.kind === "xpath" ? [css, xpath.concat(s)] : [css.concat(s), xpath];
|
|
748
|
+
}, [[], []]);
|
|
749
|
+
const matches = [];
|
|
750
|
+
if (params.subtree) {
|
|
751
|
+
if (cssSelectors.length) {
|
|
752
|
+
matches.push(...context.querySelectorAll(cssSelectors.join(",")));
|
|
753
|
+
}
|
|
754
|
+
if (xpathQueries.length) {
|
|
755
|
+
matches.push(...xpathQuery(this.window, context, xpathQueries));
|
|
756
|
+
}
|
|
757
|
+
} else {
|
|
758
|
+
if (cssSelectors.length) {
|
|
759
|
+
matches.push(...[...context.children].filter((node) => node.matches(cssSelectors)));
|
|
760
|
+
}
|
|
761
|
+
if (xpathQueries.length) {
|
|
762
|
+
matches.push(...xpathQuery(this.window, context, xpathQueries, false));
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
matches.forEach((node) => getRecord(node.parentNode || context).entrants.push(node));
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
if (!callback)
|
|
769
|
+
return records;
|
|
770
|
+
const disconnectable = { disconnected: false };
|
|
771
|
+
const signalGenerator = callback && params.lifecycleSignals && this.createSignalGenerator();
|
|
772
|
+
for (const [, record] of records) {
|
|
773
|
+
if (disconnectable.disconnected)
|
|
774
|
+
break;
|
|
775
|
+
const flags = signalGenerator?.generate() || {};
|
|
776
|
+
callback(record, flags, context);
|
|
777
|
+
}
|
|
778
|
+
if (params.live) {
|
|
779
|
+
if (signalGenerator) {
|
|
780
|
+
params = { ...params, signalGenerator };
|
|
781
|
+
}
|
|
782
|
+
const disconnectable_live = this.observe(spec, callback, params);
|
|
783
|
+
return this.disconnectables(params.signal, disconnectable, disconnectable_live);
|
|
784
|
+
}
|
|
785
|
+
return this.disconnectables(params.signal, disconnectable, signalGenerator);
|
|
786
|
+
}
|
|
787
|
+
children(spec, callback = void 0, params = {}) {
|
|
788
|
+
[spec, callback = void 0, params = {}] = this.resolveArgs(arguments);
|
|
789
|
+
return this.query(spec, callback, { ...params, subtree: false });
|
|
790
|
+
}
|
|
791
|
+
subtree(spec, callback = void 0, params = {}) {
|
|
792
|
+
[spec, callback = void 0, params = {}] = this.resolveArgs(arguments);
|
|
793
|
+
return this.query(spec, callback, { ...params, subtree: true });
|
|
794
|
+
}
|
|
795
|
+
observe(spec, callback, params = {}) {
|
|
796
|
+
[spec, callback, params = {}] = this.resolveArgs(arguments);
|
|
797
|
+
if (["sync", "intercept"].includes(params.timing))
|
|
798
|
+
return this.observeSync(spec, callback, params);
|
|
799
|
+
if (params.timing && params.timing !== "async")
|
|
800
|
+
throw new Error(`Timing option "${params.timing}" invalid.`);
|
|
801
|
+
const { context, window: window2, webqit, document } = this;
|
|
802
|
+
if (params.eventDetails) {
|
|
803
|
+
webqit.realdom.domInterceptionRecordsAlwaysOn = true;
|
|
804
|
+
}
|
|
805
|
+
if ((document.readyState === "loading" || webqit.realdom.domInterceptionRecordsAlwaysOn) && !webqit.realdom.domInterceptionHooks?.intercepting) {
|
|
806
|
+
domInterception.call(window2, "sync", () => {
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
const disconnectable = new window2.MutationObserver((records) => records.forEach((record) => {
|
|
810
|
+
dispatch2.call(window2, registration, withEventDetails.call(window2, record), context);
|
|
811
|
+
}));
|
|
812
|
+
disconnectable.observe(context, { childList: true, subtree: params.subtree && true });
|
|
813
|
+
const signalGenerator = params.signalGenerator || params.lifecycleSignals && this.createSignalGenerator();
|
|
814
|
+
const registration = { context, spec, callback, params, signalGenerator, disconnectable };
|
|
815
|
+
if (params.staticSensitivity) {
|
|
816
|
+
const disconnectable_attr = staticSensitivity.call(window2, registration);
|
|
817
|
+
return this.disconnectables(params.signal, disconnectable, signalGenerator, disconnectable_attr);
|
|
818
|
+
}
|
|
819
|
+
return this.disconnectables(params.signal, disconnectable, signalGenerator);
|
|
820
|
+
}
|
|
821
|
+
observeSync(spec, callback, params = {}) {
|
|
822
|
+
[spec, callback, params = {}] = this.resolveArgs(arguments);
|
|
823
|
+
const { context, window: window2 } = this;
|
|
824
|
+
if (params.timing && !["sync", "intercept"].includes(params.timing))
|
|
825
|
+
throw new Error(`Timing option "${params.timing}" invalid.`);
|
|
826
|
+
const interceptionTiming = params.timing === "intercept" ? "intercept" : "sync";
|
|
827
|
+
if (!this.registry(interceptionTiming).size) {
|
|
828
|
+
domInterception.call(window2, interceptionTiming, (record) => {
|
|
829
|
+
this.forEachMatchingContext(interceptionTiming, record, dispatch2);
|
|
830
|
+
});
|
|
831
|
+
}
|
|
832
|
+
const mo = new window2.MutationObserver((records) => records.forEach((record) => {
|
|
833
|
+
if (Array.isArray((record = withEventDetails.call(window2, record)).event))
|
|
834
|
+
return;
|
|
835
|
+
dispatch2.call(window2, registration, record, context);
|
|
836
|
+
}));
|
|
837
|
+
mo.observe(context, { childList: true, subtree: params.subtree && true });
|
|
838
|
+
const disconnectable = { disconnect() {
|
|
839
|
+
registry.delete(registration);
|
|
840
|
+
mo.disconnect();
|
|
841
|
+
} };
|
|
842
|
+
const signalGenerator = params.signalGenerator || params.lifecycleSignals && this.createSignalGenerator();
|
|
843
|
+
const registration = { context, spec, callback, params, signalGenerator, disconnectable };
|
|
844
|
+
const registry = this.registry(interceptionTiming);
|
|
845
|
+
registry.set(registration, !!registration.params.deferred);
|
|
846
|
+
if (params.staticSensitivity) {
|
|
847
|
+
const disconnectable_attr = staticSensitivity.call(window2, registration);
|
|
848
|
+
return this.disconnectables(params.signal, disconnectable, signalGenerator, disconnectable_attr);
|
|
849
|
+
}
|
|
850
|
+
return this.disconnectables(params.signal, disconnectable, signalGenerator);
|
|
851
|
+
}
|
|
852
|
+
track(elements, callback, params = {}) {
|
|
853
|
+
params = { subtree: true, ...params };
|
|
854
|
+
return this.observe(elements, (record) => {
|
|
855
|
+
if (record.entrants.length)
|
|
856
|
+
callback(true, Array.isArray(elements) ? record.entrants : record.entrants[0]);
|
|
857
|
+
if (record.exits.length)
|
|
858
|
+
callback(false, Array.isArray(elements) ? record.exits : record.exits[0]);
|
|
859
|
+
}, params);
|
|
860
|
+
}
|
|
861
|
+
};
|
|
862
|
+
function staticSensitivity(registration) {
|
|
863
|
+
const window2 = this;
|
|
864
|
+
const { context, spec, callback, params, signalGenerator } = registration;
|
|
865
|
+
const cssSelectors = spec.filter((s) => s.kind === "css");
|
|
866
|
+
const parseDot = (selector) => selector.match(/\.([\w-]+)/g)?.length ? ["class"] : [];
|
|
867
|
+
const parseHash = (selector) => selector.match(/#([\w-]+)/g)?.length ? ["id"] : [];
|
|
868
|
+
const parse = (selector) => [...selector.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map((x) => x[1]).concat(parseDot(selector)).concat(parseHash(selector));
|
|
869
|
+
if (!(registration.$attrs = Array.from(new Set(cssSelectors.filter((s) => (s + "").includes("[")).reduce((attrs, selector) => attrs.concat(parse(selector + "")), [])))).length)
|
|
870
|
+
return;
|
|
871
|
+
const entrants = /* @__PURE__ */ new Set(), exits = /* @__PURE__ */ new Set();
|
|
872
|
+
entrants.push = (val) => (exits.delete(val), entrants.add(val));
|
|
873
|
+
exits.push = (val) => (entrants.delete(val), exits.add(val));
|
|
874
|
+
registration.$deliveryCache = { entrants, exits };
|
|
875
|
+
return new AttrRealtime(context, window2).observe(registration.$attrs, (_records) => {
|
|
876
|
+
const records = /* @__PURE__ */ new Map(), getRecord = (target) => {
|
|
877
|
+
if (!records.has(target)) {
|
|
878
|
+
records.set(target, { target, entrants: [], exits: [], type: "static", event: null });
|
|
879
|
+
}
|
|
880
|
+
return records.get(target);
|
|
881
|
+
};
|
|
882
|
+
const matchesCache = /* @__PURE__ */ new WeakMap();
|
|
883
|
+
const matches = (node) => {
|
|
884
|
+
if (!matchesCache.has(node)) {
|
|
885
|
+
matchesCache.set(node, cssSelectors.some((s) => node.matches(s + "")));
|
|
886
|
+
}
|
|
887
|
+
return matchesCache.get(node);
|
|
888
|
+
};
|
|
889
|
+
for (const _record of _records) {
|
|
890
|
+
["entrants", "exits"].forEach((generation) => {
|
|
891
|
+
if (params.generation && generation !== params.generation)
|
|
892
|
+
return;
|
|
893
|
+
if (registration.$deliveryCache[generation].has(_record.target) || (generation === "entrants" ? !matches(_record.target) : matches(_record.target)))
|
|
894
|
+
return;
|
|
895
|
+
registration.$deliveryCache[generation].push(_record.target);
|
|
896
|
+
getRecord(_record.target)[generation].push(_record.target);
|
|
897
|
+
getRecord(_record.target).event = _record.event;
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
for (const [, record] of records) {
|
|
901
|
+
const flags = signalGenerator?.generate() || {};
|
|
902
|
+
callback(record, flags, context);
|
|
903
|
+
}
|
|
904
|
+
}, { subtree: params.subtree, timing: params.timing, eventDetails: params.eventDetails });
|
|
905
|
+
}
|
|
906
|
+
function dispatch2(registration, _record) {
|
|
907
|
+
const { context, spec, callback, params, signalGenerator, $deliveryCache } = registration;
|
|
908
|
+
const record = { ..._record, entrants: [], exits: [] };
|
|
909
|
+
if (!params.eventDetails) {
|
|
910
|
+
delete record.event;
|
|
911
|
+
}
|
|
912
|
+
["entrants", "exits"].forEach((generation) => {
|
|
913
|
+
if (params.generation && generation !== params.generation)
|
|
914
|
+
return;
|
|
915
|
+
if (spec.length) {
|
|
916
|
+
record[generation] = nodesIntersection.call(this, spec, params.subtree === "cross-roots", _record[generation], _record.event !== "parse");
|
|
917
|
+
} else {
|
|
918
|
+
record[generation] = [..._record[generation]];
|
|
919
|
+
}
|
|
920
|
+
if (!$deliveryCache)
|
|
921
|
+
return;
|
|
922
|
+
for (const node of record[generation]) {
|
|
923
|
+
$deliveryCache[generation].push(node);
|
|
924
|
+
}
|
|
925
|
+
});
|
|
926
|
+
if (!record.entrants.length && !record.exits.length)
|
|
927
|
+
return;
|
|
928
|
+
const flags = signalGenerator?.generate() || {};
|
|
929
|
+
callback(record, flags, context);
|
|
930
|
+
}
|
|
931
|
+
function nodesIntersection(spec, crossRoots, sources, deepIntersect) {
|
|
932
|
+
sources = Array.isArray(sources) ? sources : [...sources];
|
|
933
|
+
const match = (sources2, s) => {
|
|
934
|
+
if (s.type === "selector") {
|
|
935
|
+
let matches = s.isXpathAttr ? [] : sources2.filter((source) => s.kind === "xpath" ? xpathMatch(this, source, s + "") : source.matches && source.matches(s + ""));
|
|
936
|
+
if (deepIntersect || s.isXpathAttr) {
|
|
937
|
+
matches = sources2.reduce((collection, source) => {
|
|
938
|
+
if (s.kind === "xpath") {
|
|
939
|
+
return [...collection, ...xpathQuery(this, source, s, deepIntersect)];
|
|
940
|
+
}
|
|
941
|
+
return source.querySelectorAll ? [...collection, ...source.querySelectorAll(s + "")] : collection;
|
|
942
|
+
}, matches);
|
|
943
|
+
}
|
|
944
|
+
if (matches.length)
|
|
945
|
+
return matches;
|
|
946
|
+
} else {
|
|
947
|
+
if (sources2.includes(s.content) || deepIntersect && sources2.some((source) => containsNode(this, source, s.content, crossRoots))) {
|
|
948
|
+
return [s.content];
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
if (!sources.$$searchCache) {
|
|
953
|
+
sources.$$searchCache = /* @__PURE__ */ new Map();
|
|
954
|
+
}
|
|
955
|
+
return spec.reduce((matches, s) => {
|
|
956
|
+
let _matches;
|
|
957
|
+
if (sources.$$searchCache.has(s.content)) {
|
|
958
|
+
_matches = sources.$$searchCache.get(s.content);
|
|
959
|
+
} else {
|
|
960
|
+
_matches = match(sources, s) || [];
|
|
961
|
+
if (s.type === "instance") {
|
|
962
|
+
sources.$$searchCache.set(s.content, _matches);
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
return matches.concat(_matches);
|
|
966
|
+
}, []);
|
|
967
|
+
}
|
|
968
|
+
function withEventDetails({ target, addedNodes, removedNodes }) {
|
|
969
|
+
let window2 = this, event;
|
|
970
|
+
event = from_default(addedNodes).reduce((prev, node) => prev || window2.webqit.realdom.domInterceptionRecords?.get(node), null);
|
|
971
|
+
event = from_default(removedNodes).reduce((prev, node) => prev || window2.webqit.realdom.domInterceptionRecords?.get(node), event);
|
|
972
|
+
event = event || window2.document.readyState === "loading" && "parse" || "mutation";
|
|
973
|
+
return { target, entrants: addedNodes, exits: removedNodes, type: "observation", event };
|
|
974
|
+
}
|
|
975
|
+
function domInterception(timing, callback) {
|
|
976
|
+
const window2 = this;
|
|
977
|
+
const { webqit, document, Node, CharacterData, Element, HTMLElement, HTMLTemplateElement, DocumentFragment } = window2;
|
|
978
|
+
if (!webqit.realdom.domInterceptionHooks) {
|
|
979
|
+
Object.defineProperty(webqit.realdom, "domInterceptionHooks", { value: /* @__PURE__ */ new Map() });
|
|
980
|
+
}
|
|
981
|
+
if (!webqit.realdom.domInterceptionNoRecurse) {
|
|
982
|
+
Object.defineProperty(webqit.realdom, "domInterceptionNoRecurse", { value: /* @__PURE__ */ new Map() });
|
|
983
|
+
}
|
|
984
|
+
if (!webqit.realdom.domInterceptionHooks.has(timing)) {
|
|
985
|
+
webqit.realdom.domInterceptionHooks.set(timing, /* @__PURE__ */ new Set());
|
|
986
|
+
}
|
|
987
|
+
webqit.realdom.domInterceptionHooks.get(timing).add(callback);
|
|
988
|
+
const rm = () => webqit.realdom.domInterceptionHooks.get(timing).delete(callback);
|
|
989
|
+
if (webqit.realdom.domInterceptionHooks?.intercepting)
|
|
990
|
+
return rm;
|
|
991
|
+
console.warn(`DOM mutation APIs are now being intercepted.`);
|
|
992
|
+
webqit.realdom.domInterceptionHooks.intercepting = true;
|
|
993
|
+
Object.defineProperty(webqit.realdom, "domInterceptionRecords", { value: /* @__PURE__ */ new Map() });
|
|
994
|
+
const noRecurse = (node, method, callback2) => {
|
|
995
|
+
webqit.realdom.domInterceptionNoRecurse.set(node, method);
|
|
996
|
+
const returnValue = callback2();
|
|
997
|
+
webqit.realdom.domInterceptionNoRecurse.delete(node);
|
|
998
|
+
return returnValue;
|
|
999
|
+
};
|
|
1000
|
+
const intercept = (record, defaultAction) => {
|
|
1001
|
+
record.entrants.concat(record.exits).forEach((node) => {
|
|
1002
|
+
clearTimeout(webqit.realdom.domInterceptionRecords.get(node)?.timeout);
|
|
1003
|
+
webqit.realdom.domInterceptionRecords.set(node, record.event);
|
|
1004
|
+
const timeout = setTimeout(() => {
|
|
1005
|
+
webqit.realdom.domInterceptionRecords.delete(node);
|
|
1006
|
+
}, 0);
|
|
1007
|
+
Object.defineProperty(record.event, "timeout", { value: timeout, configurable: true });
|
|
1008
|
+
});
|
|
1009
|
+
webqit.realdom.domInterceptionHooks.get("intercept")?.forEach((callback2) => callback2(record));
|
|
1010
|
+
const returnValue = defaultAction();
|
|
1011
|
+
webqit.realdom.domInterceptionHooks.get("sync")?.forEach((callback2) => callback2(record));
|
|
1012
|
+
return returnValue;
|
|
1013
|
+
};
|
|
1014
|
+
const _apiNames = {
|
|
1015
|
+
ShadowRoot: ["innerHTML", "setHTMLUnsafe"],
|
|
1016
|
+
DocumentFragment: ["replaceChildren", "append", "prepend"],
|
|
1017
|
+
Document: ["replaceChildren", "append", "prepend"],
|
|
1018
|
+
HTMLElement: ["outerText", "innerText"],
|
|
1019
|
+
Element: ["append", "prepend", "before", "after", "insertAdjacentElement", "insertAdjacentHTML", "remove", "replaceChildren", "replaceWith", "setHTMLUnsafe", "innerHTML", "outerHTML"],
|
|
1020
|
+
CharacterData: ["before", "after", "remove", "replaceWith"],
|
|
1021
|
+
Node: ["insertBefore", "replaceChild", "removeChild", "appendChild", "textContent", "nodeValue"]
|
|
1022
|
+
};
|
|
1023
|
+
const _apiOriginals = {
|
|
1024
|
+
ShadowRoot: /* @__PURE__ */ Object.create(null),
|
|
1025
|
+
DocumentFragment: /* @__PURE__ */ Object.create(null),
|
|
1026
|
+
Document: /* @__PURE__ */ Object.create(null),
|
|
1027
|
+
HTMLElement: /* @__PURE__ */ Object.create(null),
|
|
1028
|
+
Element: /* @__PURE__ */ Object.create(null),
|
|
1029
|
+
CharacterData: /* @__PURE__ */ Object.create(null),
|
|
1030
|
+
Node: /* @__PURE__ */ Object.create(null)
|
|
1031
|
+
};
|
|
1032
|
+
const _apiNamesUnique = new Set(Object.values(_apiNames).reduce((all, apis) => all.concat(apis), []));
|
|
1033
|
+
_apiNamesUnique.forEach((apiName) => {
|
|
1034
|
+
Object.keys(_apiNames).forEach((DOMClassName) => {
|
|
1035
|
+
if (!_apiNames[DOMClassName].includes(apiName))
|
|
1036
|
+
return;
|
|
1037
|
+
const _apiOriginal = Object.getOwnPropertyDescriptor(window2[DOMClassName].prototype, apiName);
|
|
1038
|
+
if (!_apiOriginal)
|
|
1039
|
+
return;
|
|
1040
|
+
Object.defineProperty(window2[DOMClassName].prototype, apiName, "value" in _apiOriginal ? { ..._apiOriginal, value: method } : { ..._apiOriginal, set: setter });
|
|
1041
|
+
_apiOriginals[DOMClassName][apiName] = _apiOriginal;
|
|
1042
|
+
});
|
|
1043
|
+
function method(...args) {
|
|
1044
|
+
const DOMClassName = Object.keys(_apiOriginals).find((name) => this instanceof window2[name] && apiName in _apiOriginals[name]);
|
|
1045
|
+
const $apiOriginals = _apiOriginals[DOMClassName];
|
|
1046
|
+
let exec = () => $apiOriginals[apiName].value.call(this, ...args);
|
|
1047
|
+
if (webqit.realdom.domInterceptionNoRecurse.get(this) === apiName)
|
|
1048
|
+
return exec();
|
|
1049
|
+
let exits = [], entrants = [], target = this;
|
|
1050
|
+
if (["insertBefore"].includes(apiName)) {
|
|
1051
|
+
entrants = [args[0]];
|
|
1052
|
+
} else if (["insertAdjacentElement", "insertAdjacentHTML"].includes(apiName)) {
|
|
1053
|
+
entrants = [args[1]];
|
|
1054
|
+
if (["beforebegin", "afterend"].includes(args[0])) {
|
|
1055
|
+
target = this.parentNode;
|
|
1056
|
+
}
|
|
1057
|
+
} else if (["setHTMLUnsafe", "replaceChildren"].includes(apiName)) {
|
|
1058
|
+
exits = [...this.childNodes];
|
|
1059
|
+
entrants = apiName === "replaceChildren" ? [...args] : [args[0]];
|
|
1060
|
+
} else if (["replaceWith", "remove"].includes(apiName)) {
|
|
1061
|
+
exits = [this];
|
|
1062
|
+
entrants = apiName === "replaceWith" ? [...args] : [];
|
|
1063
|
+
target = this.parentNode;
|
|
1064
|
+
} else if (["replaceChild"].includes(apiName)) {
|
|
1065
|
+
exits = [args[1]];
|
|
1066
|
+
entrants = [args[0]];
|
|
1067
|
+
} else if (["removeChild"].includes(apiName)) {
|
|
1068
|
+
exits = [...args];
|
|
1069
|
+
} else {
|
|
1070
|
+
entrants = [...args];
|
|
1071
|
+
if (["before", "after"].includes(apiName)) {
|
|
1072
|
+
target = this.parentNode;
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
let apiNameFinal = apiName;
|
|
1076
|
+
if (["insertAdjacentHTML", "setHTMLUnsafe"].includes(apiName)) {
|
|
1077
|
+
let tempNodeName = this.nodeName;
|
|
1078
|
+
if (apiName === "insertAdjacentHTML" && ["beforebegin", "afterend"].includes(args[0])) {
|
|
1079
|
+
if (!this.parentNode)
|
|
1080
|
+
return $apiOriginals[apiName].value.call(this, ...args);
|
|
1081
|
+
tempNodeName = this.parentNode.nodeName;
|
|
1082
|
+
}
|
|
1083
|
+
const temp = document.createElement(tempNodeName.includes("-") ? "div" : tempNodeName);
|
|
1084
|
+
$apiOriginals.setHTMLUnsafe.value.call(temp, entrants[0], apiName === "setHTMLUnsafe" ? args[1] : {});
|
|
1085
|
+
entrants = [...temp.childNodes];
|
|
1086
|
+
if (apiName === "insertAdjacentHTML") {
|
|
1087
|
+
apiNameFinal = "insertAdjacentElement";
|
|
1088
|
+
args[1] = new DocumentFragment();
|
|
1089
|
+
noRecurse(args[1], "append", () => args[1].append(...temp.childNodes));
|
|
1090
|
+
} else {
|
|
1091
|
+
apiNameFinal = "replaceChildren";
|
|
1092
|
+
args = [...temp.childNodes];
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
if (!target)
|
|
1096
|
+
return exec();
|
|
1097
|
+
const record = { target, entrants, exits, type: "interception", event: [this, apiName] };
|
|
1098
|
+
return intercept(record, () => {
|
|
1099
|
+
return $apiOriginals[apiNameFinal].value.call(this, ...args);
|
|
1100
|
+
});
|
|
1101
|
+
}
|
|
1102
|
+
function setter(value) {
|
|
1103
|
+
const DOMClassName = Object.keys(_apiOriginals).find((name) => this instanceof window2[name] && apiName in _apiOriginals[name]);
|
|
1104
|
+
const $apiOriginals = _apiOriginals[DOMClassName];
|
|
1105
|
+
let exec = () => $apiOriginals[apiName].set.call(this, value);
|
|
1106
|
+
if (this instanceof HTMLScriptElement || webqit.realdom.domInterceptionNoRecurse.get(this) === apiName)
|
|
1107
|
+
return exec();
|
|
1108
|
+
let exits = [], entrants = [], target = this;
|
|
1109
|
+
if (["outerHTML", "outerText"].includes(apiName)) {
|
|
1110
|
+
exits = [this];
|
|
1111
|
+
target = this.parentNode;
|
|
1112
|
+
} else {
|
|
1113
|
+
if (this instanceof HTMLTemplateElement) {
|
|
1114
|
+
target = this.content;
|
|
1115
|
+
exits = [...this.content.childNodes];
|
|
1116
|
+
} else {
|
|
1117
|
+
exits = [...this.childNodes];
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
if (["outerHTML", "innerHTML"].includes(apiName)) {
|
|
1121
|
+
let tempNodeName = this.nodeName;
|
|
1122
|
+
if (apiName === "outerHTML") {
|
|
1123
|
+
if (!this.parentNode)
|
|
1124
|
+
return exec();
|
|
1125
|
+
tempNodeName = this.parentNode.nodeName;
|
|
1126
|
+
}
|
|
1127
|
+
const temp = document.createElement(tempNodeName.includes("-") ? "div" : tempNodeName);
|
|
1128
|
+
noRecurse(temp, apiName, () => temp[apiName] = value);
|
|
1129
|
+
entrants = this instanceof HTMLTemplateElement ? [...temp.content.childNodes] : [...temp.childNodes];
|
|
1130
|
+
if (this instanceof HTMLTemplateElement && this.hasAttribute("src") || this instanceof ShadowRoot) {
|
|
1131
|
+
const getScripts = (nodes) => nodes.reduce((scripts, el) => {
|
|
1132
|
+
if (el instanceof HTMLScriptElement)
|
|
1133
|
+
return scripts.concat(el);
|
|
1134
|
+
if (el instanceof HTMLTemplateElement)
|
|
1135
|
+
return scripts.concat(getScripts([el.content]));
|
|
1136
|
+
scripts = scripts.concat(getScripts([...el.querySelectorAll?.("template") || []].map((t) => t.content)));
|
|
1137
|
+
return scripts.concat(...el.querySelectorAll?.("script") || []);
|
|
1138
|
+
}, []);
|
|
1139
|
+
for (const script of getScripts(entrants)) {
|
|
1140
|
+
if (this instanceof ShadowRoot) {
|
|
1141
|
+
script.setAttribute("data-handling", "manual");
|
|
1142
|
+
continue;
|
|
1143
|
+
}
|
|
1144
|
+
const $script = document.createElement("script");
|
|
1145
|
+
[...script.attributes].forEach((attr) => $script.setAttribute(attr.name, attr.value));
|
|
1146
|
+
$script.textContent = script.textContent;
|
|
1147
|
+
noRecurse(script, "replaceWith", () => script.replaceWith($script));
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
if (apiName === "outerHTML") {
|
|
1151
|
+
value = new DocumentFragment();
|
|
1152
|
+
noRecurse(value, "append", () => value.append(...entrants));
|
|
1153
|
+
exec = () => noRecurse(this, "replaceWith", () => Element.prototype.replaceWith.call(this, value));
|
|
1154
|
+
} else {
|
|
1155
|
+
if (this instanceof HTMLTemplateElement) {
|
|
1156
|
+
exec = () => noRecurse(this.content, "replaceChildren", () => this.content.replaceChildren(...entrants));
|
|
1157
|
+
} else {
|
|
1158
|
+
exec = () => noRecurse(this, "replaceChildren", () => Element.prototype.replaceChildren.call(this, ...entrants));
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
const record = { target, entrants, exits, type: "interception", event: [this, apiName] };
|
|
1163
|
+
return intercept(record, exec);
|
|
1164
|
+
}
|
|
1165
|
+
});
|
|
1166
|
+
return rm;
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
// node_modules/@webqit/realdom/src/polyfills.js
|
|
1170
|
+
function polyfills_default() {
|
|
1171
|
+
CSS_escape.call(this);
|
|
1172
|
+
Node_isConnected.call(this);
|
|
1173
|
+
Element_matches.call(this);
|
|
1174
|
+
}
|
|
1175
|
+
function CSS_escape() {
|
|
1176
|
+
const window2 = this;
|
|
1177
|
+
if (!window2.CSS) {
|
|
1178
|
+
window2.CSS = {};
|
|
1179
|
+
}
|
|
1180
|
+
if (!window2.CSS.escape) {
|
|
1181
|
+
window2.CSS.escape = (str) => str.replace(/([\:@\~\$\&])/g, "\\$1");
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
function Node_isConnected() {
|
|
1185
|
+
const window2 = this;
|
|
1186
|
+
if (!("isConnected" in window2.Node.prototype)) {
|
|
1187
|
+
Object.defineProperty(window2.Node.prototype, "isConnected", { get: function() {
|
|
1188
|
+
return !this.ownerDocument || !(this.ownerDocument.compareDocumentPosition(this) & this.DOCUMENT_POSITION_DISCONNECTED);
|
|
1189
|
+
} });
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
function Element_matches() {
|
|
1193
|
+
const window2 = this;
|
|
1194
|
+
if (!window2.Element.prototype.matches) {
|
|
1195
|
+
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) {
|
|
1196
|
+
var matches = (this.document || this.ownerDocument).querySelectorAll(s), i = matches.length;
|
|
1197
|
+
while (--i >= 0 && matches.item(i) !== this) {
|
|
1198
|
+
}
|
|
1199
|
+
return i > -1;
|
|
1200
|
+
};
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
// node_modules/@webqit/realdom/src/index.js
|
|
1205
|
+
function src_default() {
|
|
1206
|
+
const window2 = this;
|
|
1207
|
+
if (!window2.webqit)
|
|
1208
|
+
window2.webqit = {};
|
|
1209
|
+
if (window2.webqit.realdom)
|
|
1210
|
+
return window2.webqit.realdom;
|
|
1211
|
+
window2.webqit.realdom = {};
|
|
1212
|
+
polyfills_default.call(window2);
|
|
1213
|
+
window2.webqit.realdom.meta = (...args) => meta.call(window2, ...args);
|
|
1214
|
+
window2.webqit.realdom.ready = (...args) => ready.call(window2, ...args);
|
|
1215
|
+
window2.webqit.realdom.realtime = (context, namespace = "dom") => {
|
|
1216
|
+
if (namespace === "dom")
|
|
1217
|
+
return new DOMRealtime(context, window2);
|
|
1218
|
+
if (namespace === "attr")
|
|
1219
|
+
return new AttrRealtime(context, window2);
|
|
1220
|
+
};
|
|
1221
|
+
const scheduler = new Scheduler(window2);
|
|
1222
|
+
window2.webqit.realdom.schedule = (type, ...args) => {
|
|
1223
|
+
return scheduler[`on${type}`](...args);
|
|
1224
|
+
};
|
|
1225
|
+
window2.webqit.realdom.synthesizeWhile = (...args) => {
|
|
1226
|
+
return scheduler.synthesizeWhile(...args);
|
|
1227
|
+
};
|
|
1228
|
+
return window2.webqit.realdom;
|
|
1229
|
+
}
|
|
1230
|
+
function ready(...args) {
|
|
1231
|
+
let timing = "interactive", callback;
|
|
1232
|
+
if (isString_default(args[0])) {
|
|
1233
|
+
timing = args[0];
|
|
1234
|
+
if (isFunction_default(args[1])) {
|
|
1235
|
+
callback = args[1];
|
|
1236
|
+
}
|
|
1237
|
+
} else if (isFunction_default(args[0])) {
|
|
1238
|
+
callback = args[0];
|
|
1239
|
+
}
|
|
1240
|
+
const timings = { interactive: ["interactive", "complete"], complete: ["complete"] };
|
|
1241
|
+
if (!timings[timing])
|
|
1242
|
+
throw new Error(`Invalid ready-state timing: ${timing}.`);
|
|
1243
|
+
const window2 = this;
|
|
1244
|
+
if (!callback) {
|
|
1245
|
+
if (!window2.webqit.realdom.readyStatePromises) {
|
|
1246
|
+
window2.webqit.realdom.readyStatePromises = {
|
|
1247
|
+
interactive: new Promise((res) => ready.call(this, "interactive", res)),
|
|
1248
|
+
complete: new Promise((res) => ready.call(this, "complete", res))
|
|
1249
|
+
};
|
|
1250
|
+
}
|
|
1251
|
+
return window2.webqit.realdom.readyStatePromises[timing];
|
|
1252
|
+
}
|
|
1253
|
+
if (timings[timing].includes(window2.document.readyState))
|
|
1254
|
+
return callback(window2);
|
|
1255
|
+
if (!window2.webqit.realdom.readyStateCallbacks) {
|
|
1256
|
+
window2.webqit.realdom.readyStateCallbacks = { interactive: [], complete: [] };
|
|
1257
|
+
window2.document.addEventListener("readystatechange", () => {
|
|
1258
|
+
const state = window2.document.readyState;
|
|
1259
|
+
for (const callback2 of window2.webqit.realdom.readyStateCallbacks[state].splice(0)) {
|
|
1260
|
+
callback2(window2);
|
|
1261
|
+
}
|
|
1262
|
+
}, false);
|
|
1263
|
+
}
|
|
1264
|
+
window2.webqit.realdom.readyStateCallbacks[timing].push(callback);
|
|
1265
|
+
}
|
|
1266
|
+
function meta(name) {
|
|
1267
|
+
const window2 = this;
|
|
1268
|
+
let _content = {}, _el;
|
|
1269
|
+
if (_el = window2.document.querySelector(`meta[name="${name}"]`)) {
|
|
1270
|
+
_content = (_el.content || "").split(";").filter((v) => v).reduce((_metaVars, directive) => {
|
|
1271
|
+
const directiveSplit = directive.split("=").map((d) => d.trim());
|
|
1272
|
+
set_default(_metaVars, directiveSplit[0].split("."), directiveSplit[1] === "true" ? true : directiveSplit[1] === "false" ? false : isNumeric_default(directiveSplit[1]) ? parseInt(directiveSplit[1]) : directiveSplit[1]);
|
|
1273
|
+
return _metaVars;
|
|
1274
|
+
}, {});
|
|
1275
|
+
}
|
|
1276
|
+
return { get name() {
|
|
1277
|
+
return name;
|
|
1278
|
+
}, get content() {
|
|
1279
|
+
return _el.content;
|
|
1280
|
+
}, json() {
|
|
1281
|
+
return JSON.parse(JSON.stringify(_content));
|
|
1282
|
+
} };
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
// node_modules/@webqit/util/str/toTitle.js
|
|
1286
|
+
function toTitle_default(str, strict) {
|
|
1287
|
+
if (typeof str !== "string") {
|
|
1288
|
+
return str;
|
|
1289
|
+
}
|
|
1290
|
+
return str.replace(/\w\S*/g, function(txt) {
|
|
1291
|
+
return txt.charAt(0).toUpperCase() + (typeof strict !== void 0 && strict ? txt.substr(1).toLowerCase() : txt.substr(1));
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
// src/util.js
|
|
1296
|
+
var _wq = (target, ...args) => wq(target, "oohtml", ...args);
|
|
1297
|
+
var env = {};
|
|
1298
|
+
function _init(name, $config, $defaults) {
|
|
1299
|
+
const window2 = this, realdom = src_default.call(window2);
|
|
1300
|
+
env.window = window2;
|
|
1301
|
+
if (!window2.webqitConfig) {
|
|
1302
|
+
window2.webqitConfig = realdom.meta("webqit").json();
|
|
1303
|
+
}
|
|
1304
|
+
window2.webqit || (window2.webqit = {});
|
|
1305
|
+
window2.webqit.oohtml || (window2.webqit.oohtml = {});
|
|
1306
|
+
window2.webqit.oohtml.configs || (window2.webqit.oohtml.configs = {});
|
|
1307
|
+
const configKey = name.toUpperCase().replace("-", "_");
|
|
1308
|
+
if (!window2.webqit.oohtml.configs[configKey]) {
|
|
1309
|
+
window2.webqit.oohtml.configs[configKey] = {};
|
|
1310
|
+
const config = window2.webqit.oohtml.configs[configKey];
|
|
1311
|
+
merge_default(2, config, $defaults, $config, realdom.meta(name).json());
|
|
1312
|
+
if (window2.webqitConfig.prefix) {
|
|
1313
|
+
Object.keys(config).forEach((main) => {
|
|
1314
|
+
Object.keys(config[main]).forEach((key) => {
|
|
1315
|
+
if (main === "api" && typeof config[main][key] === "string") {
|
|
1316
|
+
config[main][key] = `${window2.webqitConfig.prefix}${toTitle_default(config[main][key])}`;
|
|
1317
|
+
} else if (["attr", "elements"].includes(main) && config[main][key]?.startsWith("data-") === false) {
|
|
1318
|
+
config[main][key] = `${window2.webqitConfig.prefix}-${config[main][key]}`;
|
|
1319
|
+
}
|
|
1320
|
+
});
|
|
1321
|
+
});
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
return { config: window2.webqit.oohtml.configs[configKey], realdom, window: window2 };
|
|
1325
|
+
}
|
|
1326
|
+
function _splitOuter(str, delim) {
|
|
1327
|
+
return [...str].reduce(([quote, depth, splits], x) => {
|
|
1328
|
+
if (!quote && depth === 0 && (Array.isArray(delim) ? delim : [delim]).includes(x)) {
|
|
1329
|
+
return [quote, depth, [""].concat(splits)];
|
|
1330
|
+
}
|
|
1331
|
+
if (!quote && ["(", "[", "{"].includes(x) && !splits[0].endsWith("\\"))
|
|
1332
|
+
depth++;
|
|
1333
|
+
if (!quote && [")", "]", "}"].includes(x) && !splits[0].endsWith("\\"))
|
|
1334
|
+
depth--;
|
|
1335
|
+
if (['"', "'", "`"].includes(x) && !splits[0].endsWith("\\")) {
|
|
1336
|
+
quote = quote === x ? null : quote || x;
|
|
1337
|
+
}
|
|
1338
|
+
splits[0] += x;
|
|
1339
|
+
return [quote, depth, splits];
|
|
1340
|
+
}, [null, 0, [""]])[2].reverse();
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
// src/context-api/_DOMContextRequestEvent.js
|
|
1344
|
+
function DOMContextRequestEvent_default() {
|
|
1345
|
+
const { window: window2 } = env, { webqit } = window2;
|
|
1346
|
+
if (webqit.DOMContextRequestEvent)
|
|
1347
|
+
return webqit.DOMContextRequestEvent;
|
|
1348
|
+
class DOMContextRequestEvent extends window2.Event {
|
|
1349
|
+
constructor(...args) {
|
|
1350
|
+
const callback = args.pop();
|
|
1351
|
+
if (typeof callback !== "function")
|
|
1352
|
+
throw new Error(`Callback must be provided.`);
|
|
1353
|
+
const options = args.pop();
|
|
1354
|
+
if (!options?.kind)
|
|
1355
|
+
throw new Error(`"options.kind" must be specified.`);
|
|
1356
|
+
const eventNames = ["contextrequest", "contextclaim"];
|
|
1357
|
+
const type = args.pop() || eventNames[0];
|
|
1358
|
+
if (!eventNames.includes(type))
|
|
1359
|
+
throw new Error(`Invalid event type. Must be one of: ${eventNames.join(",")}`);
|
|
1360
|
+
const { kind, detail, targetContext, live, signal, diff, ...otherOpts } = options;
|
|
1361
|
+
super(type, { ...otherOpts, bubbles: otherOpts.bubbles !== false });
|
|
1362
|
+
Object.defineProperty(this, "callback", { get: () => callback });
|
|
1363
|
+
Object.defineProperty(this, "kind", { get: () => kind });
|
|
1364
|
+
Object.defineProperty(this, "targetContext", { get: () => targetContext });
|
|
1365
|
+
Object.defineProperty(this, "detail", { get: () => detail });
|
|
1366
|
+
Object.defineProperty(this, "live", { get: () => live });
|
|
1367
|
+
Object.defineProperty(this, "signal", { get: () => signal });
|
|
1368
|
+
Object.defineProperty(this, "diff", { get: () => diff });
|
|
1369
|
+
Object.defineProperty(this, "options", { get: () => otherOpts });
|
|
1370
|
+
Object.defineProperty(this, "meta", { value: {} });
|
|
1371
|
+
}
|
|
1372
|
+
get target() {
|
|
1373
|
+
return super.target || this.meta.target;
|
|
1374
|
+
}
|
|
1375
|
+
get answered() {
|
|
1376
|
+
return this.meta.answered || false;
|
|
1377
|
+
}
|
|
1378
|
+
respondWith(response) {
|
|
1379
|
+
this.meta.answered = true;
|
|
1380
|
+
if (this.diff) {
|
|
1381
|
+
if ("_prevValue" in this && this._prevValue === response)
|
|
1382
|
+
return;
|
|
1383
|
+
Object.defineProperty(this, "_prevValue", { value: response, configurable: true });
|
|
1384
|
+
}
|
|
1385
|
+
return this.callback(response);
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
webqit.DOMContextRequestEvent = DOMContextRequestEvent;
|
|
1389
|
+
return DOMContextRequestEvent;
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
// src/context-api/DOMContextResponse.js
|
|
1393
|
+
var DOMContextResponse = class extends AbortController {
|
|
1394
|
+
constructor(callback) {
|
|
1395
|
+
super();
|
|
1396
|
+
callback((response) => {
|
|
1397
|
+
const { window: { webqit: { Observer } } } = env;
|
|
1398
|
+
Observer.defineProperty(this, "value", { value: response, configurable: true, enumerable: true });
|
|
1399
|
+
}, this);
|
|
1400
|
+
}
|
|
1401
|
+
};
|
|
1402
|
+
|
|
1403
|
+
// src/context-api/DuplicateContextError.js
|
|
1404
|
+
var DuplicateContextError = class extends Error {
|
|
1405
|
+
};
|
|
1406
|
+
|
|
1407
|
+
// src/context-api/DOMContexts.js
|
|
1408
|
+
var DOMContexts = class {
|
|
1409
|
+
static instance(host) {
|
|
1410
|
+
return _wq(host).get("contexts::instance") || new this(host);
|
|
1411
|
+
;
|
|
1412
|
+
}
|
|
1413
|
+
constructor(host) {
|
|
1414
|
+
_wq(host).get(`contexts::instance`)?.dispose();
|
|
1415
|
+
_wq(host).set(`contexts::instance`, this);
|
|
1416
|
+
const priv = { host, contexts: /* @__PURE__ */ new Set() };
|
|
1417
|
+
Object.defineProperty(this, "#", { get: () => priv });
|
|
1418
|
+
}
|
|
1419
|
+
[Symbol.iterator]() {
|
|
1420
|
+
return this["#"].contexts[Symbol.iterator]();
|
|
1421
|
+
}
|
|
1422
|
+
get length() {
|
|
1423
|
+
return this["#"].contexts.size;
|
|
1424
|
+
}
|
|
1425
|
+
find(...args) {
|
|
1426
|
+
return [...this["#"].contexts].find((ctx) => {
|
|
1427
|
+
if (typeof args[0] === "function")
|
|
1428
|
+
return args[0](ctx);
|
|
1429
|
+
return ctx.constructor.kind === args[0] && (!args[1] || ctx.detail === args[1]);
|
|
1430
|
+
});
|
|
1431
|
+
}
|
|
1432
|
+
attach(ctx) {
|
|
1433
|
+
if (!(ctx instanceof DOMContext))
|
|
1434
|
+
throw new TypeError(`Context is not a valid DOMContext instance.`);
|
|
1435
|
+
if (this.find(ctx.constructor.kind, ctx.detail)) {
|
|
1436
|
+
throw new DuplicateContextError(`Context of same kind "${ctx.constructor.kind}"${ctx.detail ? ` and detail "${ctx.detail}"` : ""} already exists.`);
|
|
1437
|
+
}
|
|
1438
|
+
this["#"].contexts.add(ctx);
|
|
1439
|
+
ctx.initialize(this["#"].host);
|
|
1440
|
+
}
|
|
1441
|
+
detach(ctx) {
|
|
1442
|
+
ctx.dispose(this["#"].host);
|
|
1443
|
+
this["#"].contexts.delete(ctx);
|
|
1444
|
+
}
|
|
1445
|
+
request(...args) {
|
|
1446
|
+
return new DOMContextResponse((emitter, responseInstance) => {
|
|
1447
|
+
if (typeof args[args.length - 1] !== "function") {
|
|
1448
|
+
if (!args[args.length - 1]) {
|
|
1449
|
+
args[args.length - 1] = emitter;
|
|
1450
|
+
} else {
|
|
1451
|
+
args.push(emitter);
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
let options;
|
|
1455
|
+
if ((options = args.find((arg) => typeof arg === "object" && arg)) && options.live) {
|
|
1456
|
+
if (options.signal)
|
|
1457
|
+
options.signal.addEventListener("abort", () => responseInstance.abort());
|
|
1458
|
+
args[args.indexOf(options)] = { ...options, signal: responseInstance.signal };
|
|
1459
|
+
}
|
|
1460
|
+
const event = new (DOMContextRequestEvent_default())(...args);
|
|
1461
|
+
this["#"].host.dispatchEvent(event);
|
|
1462
|
+
});
|
|
1463
|
+
}
|
|
1464
|
+
};
|
|
1465
|
+
|
|
1466
|
+
// src/context-api/DOMContext.js
|
|
1467
|
+
var _DOMContext = class {
|
|
1468
|
+
static createRequest() {
|
|
1469
|
+
return { kind: this.kind };
|
|
1470
|
+
}
|
|
1471
|
+
constructor(detail = null) {
|
|
1472
|
+
Object.defineProperty(this, "detail", { get: () => detail });
|
|
1473
|
+
Object.defineProperty(this, "subscriptions", { value: /* @__PURE__ */ new Set() });
|
|
1474
|
+
}
|
|
1475
|
+
get configs() {
|
|
1476
|
+
const { window: { webqit: { oohtml: { configs } } } } = env;
|
|
1477
|
+
return configs;
|
|
1478
|
+
}
|
|
1479
|
+
get name() {
|
|
1480
|
+
return [env.window.Document, env.window.ShadowRoot].some((x) => this.host instanceof x) ? Infinity : this.host.getAttribute(this.configs.CONTEXT_API.attr.contextname);
|
|
1481
|
+
}
|
|
1482
|
+
subscribed(event) {
|
|
1483
|
+
}
|
|
1484
|
+
handle(event) {
|
|
1485
|
+
}
|
|
1486
|
+
unsubscribed(event) {
|
|
1487
|
+
}
|
|
1488
|
+
matchEvent(event) {
|
|
1489
|
+
return event.kind === this.constructor.kind && (!event.targetContext || event.targetContext === this.name);
|
|
1490
|
+
}
|
|
1491
|
+
handleEvent(event) {
|
|
1492
|
+
if (this.disposed || typeof event.respondWith !== "function")
|
|
1493
|
+
return;
|
|
1494
|
+
if (event.type === "contextclaim") {
|
|
1495
|
+
if (!(event.detail instanceof _DOMContext) || event.target === this.host)
|
|
1496
|
+
return;
|
|
1497
|
+
const claims = /* @__PURE__ */ new Set();
|
|
1498
|
+
this.subscriptions.forEach((subscriptionEvent) => {
|
|
1499
|
+
if (!event.target.contains(subscriptionEvent.target) || !event.detail.matchEvent(subscriptionEvent))
|
|
1500
|
+
return;
|
|
1501
|
+
this.subscriptions.delete(subscriptionEvent);
|
|
1502
|
+
this.unsubscribed(subscriptionEvent);
|
|
1503
|
+
claims.add(subscriptionEvent);
|
|
1504
|
+
});
|
|
1505
|
+
if (claims.size) {
|
|
1506
|
+
return event.respondWith(claims);
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
if (event.type === "contextrequest") {
|
|
1510
|
+
if (!this.matchEvent(event))
|
|
1511
|
+
return;
|
|
1512
|
+
if (event.live) {
|
|
1513
|
+
this.subscriptions.add(event);
|
|
1514
|
+
this.subscribed(event);
|
|
1515
|
+
event.signal?.addEventListener("abort", () => {
|
|
1516
|
+
this.subscriptions.delete(event);
|
|
1517
|
+
this.unsubscribed(event);
|
|
1518
|
+
});
|
|
1519
|
+
}
|
|
1520
|
+
event.stopPropagation();
|
|
1521
|
+
return this.handle(event);
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
initialize(host) {
|
|
1525
|
+
this.host = host;
|
|
1526
|
+
this.disposed = false;
|
|
1527
|
+
host.addEventListener("contextrequest", this);
|
|
1528
|
+
host.addEventListener("contextclaim", this);
|
|
1529
|
+
const { value: claims } = DOMContexts.instance(host).request("contextclaim", { kind: this.constructor.kind, detail: this });
|
|
1530
|
+
claims?.forEach((subscriptionEvent) => {
|
|
1531
|
+
this.subscriptions.add(subscriptionEvent);
|
|
1532
|
+
this.subscribed(subscriptionEvent);
|
|
1533
|
+
this.handle(subscriptionEvent);
|
|
1534
|
+
});
|
|
1535
|
+
return this;
|
|
1536
|
+
}
|
|
1537
|
+
dispose(host) {
|
|
1538
|
+
this.disposed = true;
|
|
1539
|
+
host.removeEventListener("contextrequest", this);
|
|
1540
|
+
host.removeEventListener("contextclaim", this);
|
|
1541
|
+
this.subscriptions.forEach((subscriptionEvent) => {
|
|
1542
|
+
this.subscriptions.delete(subscriptionEvent);
|
|
1543
|
+
this.unsubscribed(subscriptionEvent);
|
|
1544
|
+
const { target } = subscriptionEvent;
|
|
1545
|
+
subscriptionEvent.meta.answered = false;
|
|
1546
|
+
target.dispatchEvent(subscriptionEvent);
|
|
1547
|
+
});
|
|
1548
|
+
return this;
|
|
1549
|
+
}
|
|
1550
|
+
};
|
|
1551
|
+
var DOMContext = _DOMContext;
|
|
1552
|
+
__publicField(DOMContext, "kind");
|
|
1553
|
+
|
|
1554
|
+
// src/bindings-api/DOMBindingsContext.js
|
|
1555
|
+
var DOMBindingsContext = class extends DOMContext {
|
|
1556
|
+
static createRequest(detail = null) {
|
|
1557
|
+
const request = super.createRequest();
|
|
1558
|
+
if (detail?.startsWith("@")) {
|
|
1559
|
+
const [targetContext, ...detail2] = detail2.slice(1).split(".").map((s) => s.trim());
|
|
1560
|
+
request.targetContext = targetContext;
|
|
1561
|
+
request.detail = detail2.join(".");
|
|
1562
|
+
} else {
|
|
1563
|
+
request.detail = detail;
|
|
1564
|
+
}
|
|
1565
|
+
return request;
|
|
1566
|
+
}
|
|
1567
|
+
get bindingsObj() {
|
|
1568
|
+
return this.host[this.configs.BINDINGS_API.api.bindings];
|
|
1569
|
+
}
|
|
1570
|
+
matchEvent(event) {
|
|
1571
|
+
return super.matchEvent(event) && (!event.detail || !this.detail || (Array.isArray(event.detail) ? event.detail[0] === this.detail : event.detail === this.detail));
|
|
1572
|
+
}
|
|
1573
|
+
handle(event) {
|
|
1574
|
+
event.meta.controller?.abort();
|
|
1575
|
+
if (!(event.detail + "").trim())
|
|
1576
|
+
return event.respondWith(this.bindingsObj);
|
|
1577
|
+
const { window: { webqit: { Observer } } } = env;
|
|
1578
|
+
event.meta.controller = Observer.reduce(this.bindingsObj, Array.isArray(event.detail) ? event.detail : [event.detail], Observer.get, (descriptor) => {
|
|
1579
|
+
if (this.disposed)
|
|
1580
|
+
return;
|
|
1581
|
+
event.respondWith(descriptor.value);
|
|
1582
|
+
}, { live: event.live, signal: event.signal, descripted: true });
|
|
1583
|
+
}
|
|
1584
|
+
unsubscribed(event) {
|
|
1585
|
+
event.meta.controller?.abort();
|
|
1586
|
+
}
|
|
1587
|
+
};
|
|
1588
|
+
__publicField(DOMBindingsContext, "kind", "bindings");
|
|
1589
|
+
|
|
1590
|
+
// src/bindings-api/index.js
|
|
1591
|
+
function init($config = {}) {
|
|
1592
|
+
const { config, window: window2 } = _init.call(this, "bindings-api", $config, {
|
|
1593
|
+
attr: { bindingsreflection: "bindings" },
|
|
1594
|
+
api: { bind: "bind", bindings: "bindings" }
|
|
1595
|
+
});
|
|
1596
|
+
window2.webqit.DOMBindingsContext = DOMBindingsContext;
|
|
1597
|
+
exposeAPIs.call(window2, config);
|
|
1598
|
+
realtime.call(window2, config);
|
|
1599
|
+
}
|
|
1600
|
+
function getBindings(config, node) {
|
|
1601
|
+
const window2 = this, { webqit: { Observer, oohtml: { configs: { CONTEXT_API: ctxConfig } } } } = window2;
|
|
1602
|
+
if (!_wq(node).has("bindings")) {
|
|
1603
|
+
const bindingsObj = /* @__PURE__ */ Object.create(null);
|
|
1604
|
+
_wq(node).set("bindings", bindingsObj);
|
|
1605
|
+
Observer.observe(bindingsObj, (mutations) => {
|
|
1606
|
+
if (node instanceof window2.Element) {
|
|
1607
|
+
const bindingsParse = parseBindingsAttr(node.getAttribute(config.attr.bindingsreflection) || "");
|
|
1608
|
+
const bindingsParseBefore = new Map(bindingsParse);
|
|
1609
|
+
for (const m of mutations) {
|
|
1610
|
+
if (m.detail?.publish !== false) {
|
|
1611
|
+
if (m.type === "delete")
|
|
1612
|
+
bindingsParse.delete(m.key);
|
|
1613
|
+
else
|
|
1614
|
+
bindingsParse.set(m.key, void 0);
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
if (bindingsParse.size && bindingsParse.size !== bindingsParseBefore.size) {
|
|
1618
|
+
node.setAttribute(config.attr.bindingsreflection, `{ ${[...bindingsParse.entries()].map(([key, value]) => value === void 0 ? key : `${key}: ${value}`).join(", ")} }`);
|
|
1619
|
+
} else if (!bindingsParse.size)
|
|
1620
|
+
node.toggleAttribute(config.attr.bindingsreflection, false);
|
|
1621
|
+
} else {
|
|
1622
|
+
const contextsApi = node[ctxConfig.api.contexts];
|
|
1623
|
+
for (const m of mutations) {
|
|
1624
|
+
if (m.type === "delete") {
|
|
1625
|
+
const ctx = contextsApi.find(DOMBindingsContext.kind, m.key);
|
|
1626
|
+
if (ctx)
|
|
1627
|
+
contextsApi.detach(ctx);
|
|
1628
|
+
} else if (!contextsApi.find(DOMBindingsContext.kind, m.key)) {
|
|
1629
|
+
contextsApi.attach(new DOMBindingsContext(m.key));
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
});
|
|
1634
|
+
}
|
|
1635
|
+
return _wq(node).get("bindings");
|
|
1636
|
+
}
|
|
1637
|
+
function exposeAPIs(config) {
|
|
1638
|
+
const window2 = this, { webqit: { Observer } } = window2;
|
|
1639
|
+
[window2.Document.prototype, window2.Element.prototype, window2.ShadowRoot.prototype].forEach((prototype) => {
|
|
1640
|
+
const type = prototype === window2.Document.prototype ? "Document" : prototype === window2.ShadowRoot.prototype ? "ShadowRoot" : "Element";
|
|
1641
|
+
if (config.api.bind in prototype) {
|
|
1642
|
+
throw new Error(`The ${type} prototype already has a "${config.api.bind}" API!`);
|
|
1643
|
+
}
|
|
1644
|
+
if (config.api.bindings in prototype) {
|
|
1645
|
+
throw new Error(`The ${type} prototype already has a "${config.api.bindings}" API!`);
|
|
1646
|
+
}
|
|
1647
|
+
Object.defineProperty(prototype, config.api.bind, { value: function(bindings, options = {}) {
|
|
1648
|
+
return applyBindings.call(window2, config, this, bindings, options);
|
|
1649
|
+
} });
|
|
1650
|
+
Object.defineProperty(prototype, config.api.bindings, { get: function() {
|
|
1651
|
+
return Observer.proxy(getBindings.call(window2, config, this));
|
|
1652
|
+
} });
|
|
1653
|
+
});
|
|
1654
|
+
}
|
|
1655
|
+
function applyBindings(config, target, bindings, { merge, diff, publish, namespace } = {}) {
|
|
1656
|
+
const window2 = this, { webqit: { Observer } } = window2;
|
|
1657
|
+
const bindingsObj = getBindings.call(this, config, target);
|
|
1658
|
+
const $params = { diff, namespace, detail: { publish } };
|
|
1659
|
+
const exitingKeys = merge ? [] : Object.keys(bindingsObj).filter((key) => !(key in bindings));
|
|
1660
|
+
return Observer.batch(bindingsObj, () => {
|
|
1661
|
+
if (exitingKeys.length) {
|
|
1662
|
+
Observer.deleteProperties(bindingsObj, exitingKeys, $params);
|
|
1663
|
+
}
|
|
1664
|
+
return Observer.set(bindingsObj, bindings, $params);
|
|
1665
|
+
}, $params);
|
|
1666
|
+
}
|
|
1667
|
+
function realtime(config) {
|
|
1668
|
+
const window2 = this, { webqit: { realdom, Observer, oohtml: { configs } } } = window2;
|
|
1669
|
+
const attachBindingsContext = (host, key) => {
|
|
1670
|
+
const contextsApi = host[configs.CONTEXT_API.api.contexts];
|
|
1671
|
+
if (!contextsApi.find(DOMBindingsContext.kind, key)) {
|
|
1672
|
+
contextsApi.attach(new DOMBindingsContext(key));
|
|
1673
|
+
}
|
|
1674
|
+
};
|
|
1675
|
+
const detachBindingsContext = (host, key) => {
|
|
1676
|
+
let ctx, contextsApi = host[configs.CONTEXT_API.api.contexts];
|
|
1677
|
+
while (ctx = contextsApi.find(DOMBindingsContext.kind, key))
|
|
1678
|
+
contextsApi.detach(ctx);
|
|
1679
|
+
};
|
|
1680
|
+
realdom.realtime(window2.document).query(`[${window2.CSS.escape(config.attr.bindingsreflection)}]`, (record) => {
|
|
1681
|
+
record.exits.forEach((entry) => detachBindingsContext(entry));
|
|
1682
|
+
record.entrants.forEach((entry) => {
|
|
1683
|
+
const bindingsParse = parseBindingsAttr(entry.getAttribute(config.attr.bindingsreflection) || "");
|
|
1684
|
+
const newData = [...bindingsParse.entries()].filter(([k, v]) => v !== void 0);
|
|
1685
|
+
if (newData.length)
|
|
1686
|
+
entry[config.api.bind](Object.fromEntries(newData), { merge: true, publish: false });
|
|
1687
|
+
for (const [key] of bindingsParse) {
|
|
1688
|
+
attachBindingsContext(entry, key);
|
|
1689
|
+
}
|
|
1690
|
+
});
|
|
1691
|
+
}, { id: "bindings:dom", live: true, subtree: "cross-roots", timing: "sync", eventDetails: true });
|
|
1692
|
+
realdom.realtime(window2.document, "attr").observe(config.attr.bindingsreflection, (record) => {
|
|
1693
|
+
const bindingsObj = getBindings.call(window2, config, record.target);
|
|
1694
|
+
const bindingsParse = parseBindingsAttr(record.value || "");
|
|
1695
|
+
const oldBindings = parseBindingsAttr(record.oldValue || "");
|
|
1696
|
+
for (const key of /* @__PURE__ */ new Set([...bindingsParse.keys(), ...oldBindings.keys()])) {
|
|
1697
|
+
if (!oldBindings.has(key)) {
|
|
1698
|
+
if (bindingsParse.get(key) !== void 0)
|
|
1699
|
+
Observer.set(bindingsObj, key, bindingsParse.get(key), { detail: { publish: false } });
|
|
1700
|
+
attachBindingsContext(record.target, key);
|
|
1701
|
+
} else if (!bindingsParse.has(key)) {
|
|
1702
|
+
if (oldBindings.get(key) !== void 0)
|
|
1703
|
+
Observer.deleteProperty(bindingsObj, key, { detail: { publish: false } });
|
|
1704
|
+
detachBindingsContext(record.target, key);
|
|
1705
|
+
} else if (bindingsParse.get(key) !== oldBindings.get(key)) {
|
|
1706
|
+
Observer.set(bindingsObj, key, bindingsParse.get(key), { detail: { publish: false } });
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
}, { id: "bindings:attr", subtree: "cross-roots", timing: "sync", newValue: true, oldValue: true });
|
|
1710
|
+
}
|
|
1711
|
+
var parseBindingsAttr = (str) => {
|
|
1712
|
+
str = str.trim();
|
|
1713
|
+
return new Map(_splitOuter(str.slice(1, -1), ",").filter((s) => s.trim()).map((_str) => {
|
|
1714
|
+
return _splitOuter(_str, ":").map((s) => s.trim());
|
|
1715
|
+
}));
|
|
1716
|
+
};
|
|
1717
|
+
|
|
1718
|
+
// src/bindings-api/targets.browser.js
|
|
1719
|
+
init.call(window);
|
|
2
1720
|
//# sourceMappingURL=bindings-api.js.map
|