jq79 0.5.3 → 0.5.5
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/jq79.cjs +12 -12
- package/dist/jq79.cjs.map +1 -1
- package/dist/jq79.global.js +12 -12
- package/dist/jq79.global.js.map +1 -1
- package/dist/jq79.js +12 -12
- package/dist/jq79.js.map +1 -1
- package/package.json +1 -1
- package/src/jq79.ts +86 -26
package/dist/jq79.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
var te=Object.defineProperty;var
|
|
2
|
-
`,t);return n===-1?e.length:n},
|
|
3
|
-
`)return n;if(r==="[")s=!0;else if(r==="]")s=!1;else if(r==="/"&&!s){for(n++;n<e.length&&/[a-z]/i.test(e[n]);)n++;return n}n++}return e.length},
|
|
4
|
-
`){let o=ie(e,s+1);if(!(o<e.length&&(
|
|
5
|
-
`||i===";"||i==="}"?o=!0:/\s/.test(i)||(o=!1),n+=i,s++}return{vars:t,code:n}},le=/export\s+default(?![\w$])/y,Je=/import\s*(?:([\w$\s,{}*]+?)\s*from\s*)?(["'])([^"'\n]+)\2/y,
|
|
6
|
-
`||r===";"||r==="}"?s=!0:/\s/.test(r)||(s=!1),t++}return-1},
|
|
7
|
-
`||a===";"||a==="}"?r=!0:/\s/.test(a)||(r=!1),t+=a,n++}return o?t:null};var
|
|
8
|
-
); }`)}catch{s=null}Ye.set(n,s)}return s},
|
|
9
|
-
= $value`,w=new Set;Object.entries(u).forEach(([f,l])=>{let p=
|
|
10
|
-
`)},
|
|
11
|
-
//# sourceURL=${e}?jq79-script=${t}`:"",ot=e=>e.scoped??e.content,ge=new Map,
|
|
1
|
+
var te=Object.defineProperty;var jt=Object.getOwnPropertyDescriptor;var Nt=Object.getOwnPropertyNames;var Ot=Object.prototype.hasOwnProperty;var vt=(e,t,n)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Lt=(e,t)=>{for(var n in t)te(e,n,{get:t[n],enumerable:!0})},Pt=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Nt(t))!Ot.call(e,r)&&r!==n&&te(e,r,{get:()=>t[r],enumerable:!(s=jt(t,r))||s.enumerable});return e};var Mt=e=>Pt(te({},"__esModule",{value:!0}),e);var _=(e,t,n)=>vt(e,typeof t!="symbol"?t+"":t,n);var os={};Lt(os,{$:()=>Z,$$:()=>ne,$create:()=>se,$reactive:()=>Q,C79:()=>q,Component79:()=>q,PendingComponent79:()=>me,enableHotReload:()=>_t,hotUpdate:()=>Ct,parseComponent:()=>rs,renderComponent:()=>An});module.exports=Mt(os);function Z(e,t){return typeof e=="string"?document.querySelector(e):e.querySelector(t)}function ne(e,t){return Array.from(typeof e=="string"?document.querySelectorAll(e):e.querySelectorAll(t))}var se=(e,t={})=>{let n=document.createElement(e);for(let[s,r]of Object.entries(t))if(s==="className")n.className=Array.isArray(r)?r.join(" "):r;else if(s==="textContent")n.textContent=r;else if(s==="children")for(let o of r)n.appendChild(o);else n.setAttribute(s,r);return n},Dt=new Set(["a","b","i","em","strong","p","br","ul","ol","li","blockquote","code","pre","span","div","h1","h2","h3","h4","h5","h6","img"]),ke={a:new Set(["href","title"]),img:new Set(["src","alt"]),"*":new Set(["class"])},kt=new Set(["http:","https:","mailto:"]);function qt(e){try{let t=new URL(e,"https://example.com");return kt.has(t.protocol)}catch{return!1}}var Wt={"https:":"443","http:":"80"};function Ut(e){let t=e.trim().toLowerCase().match(/^([a-z\d*][a-z\d.*-]*?)(?::(\d{1,5}|\*))?$/);if(!t)return null;let[,n,s]=t,r=n.split(".");return r.some(i=>i!=="*"&&!/^[a-z\d-]+$/.test(i))?null:{host:new RegExp(`^${r.map(i=>i==="*"?"[^.]+":i).join("\\.")}$`),port:!s||s==="*"?null:s}}var We=e=>{let t=(Array.isArray(e)?e:e.split(",")).map(Ut).filter(n=>n!==null);return n=>{let s=n.hostname.toLowerCase(),r=n.port||Wt[n.protocol]||"";return t.some(o=>o.host.test(s)&&(o.port===null||o.port===r))}};function It(e,t,n,s){try{return!!e(new URL(t,document.baseURI),n,s)}catch{return!1}}var qe=512;function Ue(e,t,n,s){if(n>qe)throw new RangeError(`jq79: sanitizeHTML input nests deeper than ${qe} elements`);for(let r of Array.from(e.childNodes))if(r.nodeType===Node.ELEMENT_NODE){let o=Ft(r,n,s);o&&t.appendChild(o)}else r.nodeType===Node.TEXT_NODE&&t.appendChild(r.cloneNode())}function Ft(e,t,n){let s=e.tagName.toLowerCase();if(!Dt.has(s))return null;let r=document.createElement(s);for(let o of Array.from(e.attributes)){let i=o.name.toLowerCase(),a=ke[s]?.has(i),c=ke["*"]?.has(i);!a&&!c||(i==="href"||i==="src")&&(!qt(o.value)||n&&!It(n,o.value,s,i))||r.setAttribute(i,o.value)}return s==="a"&&r.setAttribute("rel","noopener noreferrer"),Ue(e,r,t+1,n),r}function Ie(e,t){let n=document.createElement("template");n.innerHTML=e;let s=document.createElement("div");return Ue(n.content,s,0,t?.allowUrl),s.innerHTML}var Bt=(e,t)=>t.split(".").reduce((n,s)=>n?.[s],e),Be=e=>{if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},He=(e,t,n)=>{Object.entries(e).forEach(([s,r])=>{let o=t?`${t}.${s}`:s;r&&typeof r=="object"&&Be(r)?He(r,o,n):n(o,r)})},Ht=(e,t)=>e===t||e.startsWith(`${t}.`)||t.startsWith(`${e}.`),be=Symbol("jq79.raw"),re=e=>{let t=e;for(;t!==null&&typeof t=="object"&&t[be];)t=t[be];return t},ze=Symbol("jq79.store"),J=e=>e!==null&&typeof e=="object"&&e[ze]===!0,K=[],X=e=>{K.push(new Set);try{return e()}finally{K.pop()}},Fe="$__attach",oe=Symbol("jq79.alsoWakenBy"),Q=e=>{let t=new Map,n=new Set,s=new Set,r=new WeakMap,o=Object.create(null),i=(h,b,$=!1)=>{t.get(h)?.forEach(E=>E(b,h)),n.forEach(E=>E(h,b)),s.forEach(E=>{($||Array.from(E.deps).some(N=>Ht(N,h)))&&E.run()})},a=h=>h!==null&&typeof h=="object"&&Be(h),c=new Map,d=(h,b)=>{let $=c.get(b);$?.store!==h&&($?.unsubscribe(),c.set(b,{store:h,unsubscribe:h.$onAny((E,N)=>i(`${b}.${E}`,N))}))},u=h=>{c.get(h)?.unsubscribe(),c.delete(h)},m=(h,b)=>{let $=r.get(h);if($)return $;let E=null,N=new Proxy(h,{has(f,l){return Reflect.has(f,l)||typeof l=="string"&&E?.has(l)===!0},get(f,l,p){if(l===be)return f;if(l===ze)return b==="";if(typeof l!="string")return Reflect.get(f,l,p);if(b===""&&l in o)return o[l];let g=b?`${b}.${l}`:l;K[K.length-1]?.add(g);let x=Reflect.get(f,l,p);if(J(x))return d(x,g),x;let R=re(x);return a(R)?m(R,g):R},set(f,l,p,g){if(g!==N&&!Object.prototype.hasOwnProperty.call(f,l))return Reflect.set(f,l,p,g);let x=b?`${b}.${l}`:l,R=J(p)?p:re(p),P=!Object.prototype.hasOwnProperty.call(f,l);if(!P&&Object.is(f[l],R)&&(R===null||typeof R!="object"))return!0;f[l]=R,E?.delete(l),J(R)?d(R,x):u(x);let v=J(R)||!a(R)?R:m(R,x);return i(x,v,P),!0},deleteProperty(f,l){if(typeof l!="string")return Reflect.deleteProperty(f,l);let p=Object.prototype.hasOwnProperty.call(f,l),g=Reflect.deleteProperty(f,l);if(g&&p){let x=b?`${b}.${l}`:l;(E??(E=new Set)).add(l),u(x),i(x,void 0)}return g}});return r.set(h,N),N},S=m(re(e),"");Object.entries(re(e)).forEach(([h,b])=>{J(b)&&d(b,h)});let C=(h,b,{immediate:$=!1}={})=>(t.has(h)||t.set(h,new Set),t.get(h).add(b),$&&b(Bt(S,h),h),()=>t.get(h)?.delete(b)),O=(h,{immediate:b=!1}={})=>(n.add(h),b&&He(S,"",($,E)=>h($,E)),()=>n.delete(h)),j=(h,b)=>{let $=!1,E=!1,N={deps:new Set,run:()=>{if($){E=!0;return}$=!0;try{let f=0;do{E=!1;let l=new Set;K.push(l);try{h()}finally{K.pop(),N.deps=l}}while(E&&++f<100);E&&console.error("jq79: an effect re-woke itself 100 times in a row (it writes what it reads); giving up on it settling")}finally{$=!1}}};return s.add(N),b?.length?y(N,b):(N.run(),()=>{s.delete(N)})},y=(h,b)=>{let $=b.map(E=>E?.[Fe]?.(h)).filter(Boolean);return h.run(),()=>{s.delete(h),$.forEach(E=>E())}},w=h=>(s.add(h),()=>{s.delete(h)}),T=()=>{c.forEach(({unsubscribe:h})=>h()),c.clear()};return o.$on=C,o.$onAny=O,o.$effect=j,o.$dispose=T,o[Fe]=w,S},H=e=>{let t=[],n=[],s=e[oe];return{effect:r=>{t.push(e.$effect(r,s)),n.push(r)},onDispose:r=>{t.push(r)},refresh:()=>{n.forEach(r=>r())},dispose:()=>{t.splice(0).forEach(r=>r()),n.length=0}}};var Ge=/(?:let|var|const)(?:\s+(?=[A-Za-z_$])|\s*(?=[{[]))/y,Ze=/\$:\s*/y,ae=/import(?=\s*\()/y,Ke=/\$:\s*([A-Za-z_$][\w$]*)\s*=(?!=)/y,U=(e,t)=>{let n=e[t],s=t+1;for(;s<e.length;){if(e[s]==="\\"){s+=2;continue}if(e[s]===n)return s+1;s++}return e.length},D=(e,t)=>{let n=e.indexOf(`
|
|
2
|
+
`,t);return n===-1?e.length:n},k=(e,t)=>{let n=e.indexOf("*/",t+2);return n===-1?e.length:n+2},ie=(e,t)=>{let n=t;for(;n<e.length;){if(/\s/.test(e[n])){n++;continue}if(e[n]==="/"&&e[n+1]==="/"){n=D(e,n);continue}if(e[n]==="/"&&e[n+1]==="*"){n=k(e,n);continue}break}return n},zt=new Set(["return","typeof","case","in","instanceof","new","delete","void","do","else","yield","await"]),I=(e,t)=>{let n=t-1;for(;n>=0;){let r=e[n];if(/\s/.test(r)){n--;continue}if(r==="/"&&e[n-1]==="*"){let o=e.lastIndexOf("/*",n-2);if(o===-1)return!0;n=o-1;continue}break}if(n<0)return!0;let s=e[n];if(/[\w$]/.test(s)){let r=n;for(;r>0&&/[\w$]/.test(e[r-1]);)r--;return zt.has(e.slice(r,n+1))}return(s==="+"||s==="-")&&e[n-1]===s?!1:!")]}\"'`.".includes(s)},F=(e,t)=>{let n=t+1,s=!1;for(;n<e.length;){let r=e[n];if(r==="\\"){n+=2;continue}if(r===`
|
|
3
|
+
`)return n;if(r==="[")s=!0;else if(r==="]")s=!1;else if(r==="/"&&!s){for(n++;n<e.length&&/[a-z]/i.test(e[n]);)n++;return n}n++}return e.length},Gt=/^(\?\.|\?\?|&&|\|\||\*\*|[.,+\-*/%&|^<>=?:([])/,Zt=(e,t)=>{let n=t-1;for(;n>=0;){let s=e[n];if(/\s/.test(s)){n--;continue}if(s==="/"&&e[n-1]==="*"){let r=e.lastIndexOf("/*",n-2);if(r===-1)return"";n=r-1;continue}return s}return""},Ve=(e,t)=>{let n=0,s=t;for(;s<e.length;){let r=e[s];if(r==="'"||r==='"'||r==="`"){s=U(e,s);continue}if(r==="/"&&e[s+1]==="/"){s=D(e,s);continue}if(r==="/"&&e[s+1]==="*"){s=k(e,s);continue}if(r==="/"&&I(e,s)){s=F(e,s);continue}if("([{".includes(r))n++;else if(")]}".includes(r))n--;else{if(n<=0&&r===";")return s;if(n<=0&&r===`
|
|
4
|
+
`){let o=ie(e,s+1);if(!(o<e.length&&(Gt.test(e.slice(o,o+2))||[",","="].includes(Zt(e,s)))))return s;s=o;continue}}s++}return e.length},Kt=e=>{let t=[],n=0,s=0,r=0,o=a=>{t.push({raw:e.slice(s,a),codeEnd:Math.max(0,r-s)}),s=a+1,r=s},i=0;for(;i<e.length;){let a=e[i];if(a==="'"||a==='"'||a==="`"){i=U(e,i),r=i;continue}if(a==="/"&&e[i+1]==="/"){i=D(e,i);continue}if(a==="/"&&e[i+1]==="*"){i=k(e,i);continue}if(a==="/"&&I(e,i)){i=F(e,i),r=i;continue}if("([{".includes(a))n++;else if(")]}".includes(a))n--;else if(a===","&&n<=0){o(i),i++;continue}/\s/.test(a)||(r=i+1),i++}return o(e.length),t},Ee=e=>{let t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return ce.test(t)?[t]:[];let n=[];for(let s of we(t.slice(1,Xe(t)))){s.startsWith("...")&&(s=s.slice(3).trim());let r=Re(s);if(r!==-1&&(s=s.slice(0,r).trim()),t.startsWith("{")){let o=Se(s,":");if(o!==-1){n.push(...Ee(s.slice(o+1)));continue}}n.push(...Ee(s))}return n},Vt=e=>{let t=[],n=Kt(e).map(({raw:o,codeEnd:i})=>{let a=o.match(/^\s*/)[0];if(i<=a.length)return{text:o,empty:!0};let c=o.slice(a.length,i),d=o.slice(i),u=Re(c),m=(u===-1?c:c.slice(0,u)).trim(),S=c[0]==="{"||c[0]==="[";S?t.push(...Ee(m)):ce.test(m)&&t.push(m);let C=ue(c).code;return{text:`${a}${S?`(${C})`:C}${d}`,empty:!1}}),s=[];for(;n.length&&n[n.length-1].empty;)s.unshift(n.pop().text);let r=n.map(o=>o.text).join(",")+s.join("");return r.trimStart().startsWith("(")&&(r=`;${r}`),{vars:t,code:r}},ue=e=>{let t=[],n="",s=0,r=0,o=!0;for(;s<e.length;){let i=e[s],a=e[s+1];if(i==="'"||i==='"'||i==="`"){let c=U(e,s);n+=e.slice(s,c),s=c,o=!1;continue}if(i==="/"&&(a==="/"||a==="*")){let c=a==="/"?D(e,s):k(e,s);n+=e.slice(s,c),s=c;continue}if(i==="/"&&I(e,s)){let c=F(e,s);n+=e.slice(s,c),s=c,o=!1;continue}if(i==="i"&&(s===0||!/[\w$.]/.test(e[s-1]))&&(ae.lastIndex=s,ae.test(e))){n+="$__import",s+=6,o=!1;continue}if(r===0&&o){Ge.lastIndex=s;let c=Ge.exec(e);if(c){let u=s+c[0].length,m=Ve(e,u),{vars:S,code:C}=Vt(e.slice(u,m));t.push(...S),n+=C,s=m,o=!1;continue}Ze.lastIndex=s;let d=Ze.exec(e);if(d){Ke.lastIndex=s;let u=Ke.exec(e);u&&t.push(u[1]);let m=s+d[0].length,S=Ve(e,m);n+=`$__effect(() => { ${ue(e.slice(m,S)).code} });`,s=S;continue}}"([{".includes(i)?r++:")]}".includes(i)&&(r=Math.max(0,r-1)),i===`
|
|
5
|
+
`||i===";"||i==="}"?o=!0:/\s/.test(i)||(o=!1),n+=i,s++}return{vars:t,code:n}},le=/export\s+default(?![\w$])/y,Je=/import\s*(?:([\w$\s,{}*]+?)\s*from\s*)?(["'])([^"'\n]+)\2/y,Jt=e=>{let t=[],n=0,s=0;for(let r=0;r<=e.length;r++){let o=e[r];if(o==="{")n++;else if(o==="}")n--;else if(r===e.length||o===","&&n===0){let i=e.slice(s,r).trim();i&&t.push(i),s=r+1}}return t},Xt=(e,t,n)=>{let s=`await $__import(${JSON.stringify(t)})`;if(e===void 0)return s;let r=Jt(e),o=[],i=s;if(r.length>1){let a=`$__mod${n}`;o.push(`${a} = ${s}`),i=a}for(let a of r)a.startsWith("{")?o.push(`${a.replace(/\s+as\s+/g,": ")} = ${i}`):a.startsWith("*")?o.push(`${a.replace(/^\*\s*as\s+/,"")} = ${i}`):o.push(`${a} = $__default(${i})`);return`const ${o.join(", ")}`},ce=/^[A-Za-z_$][\w$]*$/,Xe=e=>{let t=0,n=0;for(;n<e.length;){let s=e[n];if(s==="'"||s==='"'||s==="`"){n=U(e,n);continue}if(s==="/"&&e[n+1]==="/"){n=D(e,n);continue}if(s==="/"&&e[n+1]==="*"){n=k(e,n);continue}if(s==="/"&&I(e,n)){n=F(e,n);continue}if("([{".includes(s))t++;else if(")]}".includes(s)&&--t===0)return n;n++}return e.length},Se=(e,t)=>{let n=0,s=0;for(;s<e.length;){let r=e[s];if(r==="'"||r==='"'||r==="`"){s=U(e,s);continue}if(r==="/"&&e[s+1]==="/"){s=D(e,s);continue}if(r==="/"&&e[s+1]==="*"){s=k(e,s);continue}if(r==="/"&&r!==t&&I(e,s)){s=F(e,s);continue}if("([{".includes(r))n++;else if(")]}".includes(r))n--;else if(n===0&&r===t)return s;s++}return-1},we=e=>{let t=[],n=0,s=0,r=0;for(;r<=e.length;){let o=e[r];if(o==="'"||o==='"'||o==="`"){r=U(e,r);continue}if(o==="/"&&e[r+1]==="/"){r=D(e,r);continue}if(o==="/"&&e[r+1]==="*"){r=k(e,r);continue}if(o==="/"&&I(e,r)){r=F(e,r);continue}if(o!==void 0&&"([{".includes(o))n++;else if(o!==void 0&&")]}".includes(o))n--;else if(r===e.length||o===","&&n===0){let i=e.slice(s,r).trim();i&&t.push(i),s=r+1}r++}return t},Re=e=>{let t=0;for(;t<e.length;){let n=Se(e.slice(t),"=");if(n===-1)return-1;let s=t+n;if(e[s+1]!=="="&&e[s+1]!==">"&&e[s-1]!=="="&&e[s-1]!=="!")return s;t=s+1}return-1},fe=e=>{let t=(e??"").trim();if(!t.startsWith("{"))return null;let n=Xe(t);if(n>=t.length)return null;let s=[];for(let r of we(t.slice(1,n))){if(r.startsWith("..."))continue;let o=Re(r),i=o===-1?r:r.slice(0,o),a=o===-1?void 0:r.slice(o+1).trim(),c=Se(i,":"),d=(c===-1?i:i.slice(0,c)).trim();if(!ce.test(d))continue;let u={name:d};a!==void 0&&(u.default=a);let m=c===-1?"":i.slice(c+1).trim();ce.test(m)&&(u.as=m),s.push(u)}return s},Qt=e=>{let t=0,n=0,s=!0;for(;t<e.length;){let r=e[t];if(r==="'"||r==='"'||r==="`"){t=U(e,t),s=!1;continue}if(r==="/"&&e[t+1]==="/"){t=D(e,t);continue}if(r==="/"&&e[t+1]==="*"){t=k(e,t);continue}if(r==="/"&&I(e,t)){t=F(e,t),s=!1;continue}if(r==="e"&&n===0&&s&&(t===0||!/[\w$.]/.test(e[t-1]))){le.lastIndex=t;let o=le.exec(e);if(o)return t+o[0].length}"([{".includes(r)?n++:")]}".includes(r)&&(n=Math.max(0,n-1)),r===`
|
|
6
|
+
`||r===";"||r==="}"?s=!0:/\s/.test(r)||(s=!1),t++}return-1},Yt=/^async(?![\w$])/,en=/^function(?![\w$])\s*\*?\s*[A-Za-z_$][\w$]*|^function(?![\w$])\s*\*?/,tn=e=>{let t=Qt(e);if(t===-1)return null;let n=ie(e,t),s=e.slice(n);Yt.test(s)&&(n=ie(e,n+5));let r=en.exec(e.slice(n));if(r&&(n=ie(e,n+r[0].length)),e[n]!=="(")return null;let o=0,i=n;for(;i<e.length;){let a=e[i];if(a==="'"||a==='"'||a==="`"){i=U(e,i);continue}if(a==="/"&&e[i+1]==="/"){i=D(e,i);continue}if(a==="/"&&e[i+1]==="*"){i=k(e,i);continue}if(a==="/"&&I(e,i)){i=F(e,i);continue}if("([{".includes(a))o++;else if(")]}".includes(a)&&--o===0)break;i++}return we(e.slice(n+1,i))[0]??""},de=e=>{let t=tn(e);if(t===null)return null;let n=fe(t),s=n?.find(r=>r.name.startsWith("$"))?.name;if(s)throw new Error(`jq79: the factory signature is (props, ctx), so \`${s}\` can't be destructured from the first parameter. Write \`export default (props, { ${s} }) => \u2026\`, or \`_\` in place of props if the component takes none.`);return n},Qe=e=>{let t="",n=0,s=0,r=!0,o=!1,i=0;for(;n<e.length;){let a=e[n],c=e[n+1],d=n===0||!/[\w$.]/.test(e[n-1]);if(a==="'"||a==='"'||a==="`"){let u=U(e,n);t+=e.slice(n,u),n=u,r=!1;continue}if(a==="/"&&(c==="/"||c==="*")){let u=c==="/"?D(e,n):k(e,n);t+=e.slice(n,u),n=u;continue}if(a==="/"&&I(e,n)){let u=F(e,n);t+=e.slice(n,u),n=u,r=!1;continue}if(a==="i"&&d){if(ae.lastIndex=n,ae.test(e)){t+="$__import",n+=6,r=!1;continue}if(s===0&&r){Je.lastIndex=n;let u=Je.exec(e);if(u){t+=Xt(u[1],u[3],i++),n+=u[0].length,r=!1;continue}}}if(a==="e"&&d&&s===0&&r){le.lastIndex=n;let u=le.exec(e);if(u){o=!0,t+="$__exports.default =",n+=u[0].length,r=!1;continue}}"([{".includes(a)?s++:")]}".includes(a)&&(s=Math.max(0,s-1)),a===`
|
|
7
|
+
`||a===";"||a==="}"?r=!0:/\s/.test(a)||(r=!1),t+=a,n++}return o?t:null};var nn="0.5.5",ft=e=>Object.fromEntries(Array.from(e.attributes).map(t=>[t.name,t.value])),dt=e=>({tag:e.tagName.toLowerCase(),attrs:ft(e),children:Array.from((e instanceof HTMLTemplateElement?e.content:e).childNodes).flatMap(t=>{if(t.nodeType===Node.TEXT_NODE){let n=t.textContent??"";return n?[n]:[]}return t.nodeType===Node.ELEMENT_NODE?[dt(t)]:[]})}),Ye=new Map,pt=(e,t)=>{let n=`${t.join(",")}|${e}`,s=Ye.get(n);if(s===void 0){try{s=new Function("$scope",...t,`with ($scope) { return (${e}
|
|
8
|
+
); }`)}catch{s=null}Ye.set(n,s)}return s},sn=/^(?:([\w$]+) is not defined|Can't find variable: ([\w$]+))/,rn=100,z=new Map,Ae=new Set,pe=0,Te=!1,on=()=>{Te=!1,!(pe>0)&&(z.forEach(({name:e,expr:t,scope:n},s)=>{e in n||(Ae.add(s),console.warn(`jq79: ${e} is not defined - evaluating "${t}". Template expressions resolve against the component store: a top-level let/var/const in a :setup script, a declared prop, or a global. Note a "function name() {}" declaration is not on the store - write "const name = () => {}".`))}),z.clear())},ht=()=>{Te||pe>0||!z.size||(Te=!0,queueMicrotask(on))},gt=e=>{pe++;let t=()=>{pe--,ht()};e.then(t,t)},mt=(e,t,n)=>{if(!(n instanceof ReferenceError))return;let s=sn.exec(n.message),r=s?.[1]??s?.[2];if(!r)return;let o=`${r}|${e}`;Ae.has(o)||z.has(o)||z.size>=rn||(z.set(o,{name:r,expr:e,scope:t}),ht())},yt=(e,t,n)=>{let s=pt(e,n?Object.keys(n):[]);if(s)return s(t,...n?Object.values(n):[])},A=(e,t,n)=>{try{return yt(e,t,n)}catch(s){mt(e,t,s);return}},bt=(e,t,n)=>{try{return yt(e,t,n)}catch(s){if(!(s instanceof ReferenceError))throw s;mt(e,t,s);return}},an=(e,t)=>e.replace(/{{\s*([\s\S]+?)\s*}}/g,(n,s)=>A(s,t)??""),ln=new Set([":attrs",":class",":value",":checked",":selected",":if",":elseif",":else",":each",":key",":with",":text",":html",":html.allowed",":props"]),je=e=>ln.has(e)||e.startsWith(":class.")||e.startsWith(":props.")||e===":slot"||e.startsWith(":slot."),cn=/^\s*\(?\s*(\w+)\s*(?:,\s*(\w+))?\s*\)?\s+in\s+([\s\S]+)$/,un=(e,t,n,s)=>{let[r,...o]=t.slice(1).split("."),i=new Set(o);e.addEventListener(r,a=>{if(i.has("self")&&a.target!==e)return;i.has("prevent")&&a.preventDefault(),i.has("stop")&&a.stopPropagation();let c=bt(n,s,{$event:a});typeof c=="function"&&c.call(e,a)},{once:i.has("once"),capture:i.has("capture")})},fn=(e,t,n,s)=>{let[r,...o]=t.slice(1).split("."),i=new Set(o),a=c=>{i.has("prevent")&&c.preventDefault(),i.has("stop")&&c.stopPropagation(),i.has("once")&&e.off(r,a),X(()=>{let d=bt(n,s,{$event:c});typeof d=="function"&&d(c)})};e.on(r,a)},B=e=>e.replace(/-(\w)/g,(t,n)=>n.toUpperCase()),xe=e=>e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`),Ne=e=>e instanceof DocumentFragment?{first:e.firstChild,last:e.lastChild}:{first:e,last:e},he=({first:e,last:t})=>{for(let n=e;n;){let s=n===t?null:n.nextSibling;n.parentNode?.removeChild(n),n=s}},dn=({first:e,last:t},n)=>{let s=n.nextSibling;for(let r=e;r;){let o=r===t?null:r.nextSibling;n.parentNode.insertBefore(r,s),r=o}},et=(e,t)=>{let n=t.replace(/-/g,"").toLowerCase();for(let s=e;s&&s!==Object.prototype;s=Object.getPrototypeOf(s))for(let r of Object.keys(s))if(/^[A-Z]/.test(r)&&r.replace(/-/g,"").toLowerCase()===n)return r;return null},tt=200,$e=0,Et=Symbol("jq79.slots"),pn=e=>e==="slot"||e.startsWith("slot."),St=e=>e?B(e):"default",Oe=e=>Object.keys(e.attrs).find(t=>t===":slot"||t.startsWith(":slot.")),hn=e=>e==="default"?":slot":`:slot.${e}`,gn=e=>typeof e!="string"||e.trim()!=="",mn=e=>{let t={},n=[];e.children.forEach(r=>{let o=typeof r=="object"&&r.tag==="template"?Oe(r):void 0;if(typeof r=="string"||o===void 0){n.push(r);return}let i=St(o.slice(6));if(i in t){console.warn(`jq79: two <template ${hn(i)}> in <${e.tag}>; the second was ignored`);return}t[i]={nodes:r.children,binder:r.attrs[o]||void 0}});let s=n.some(gn);return s&&"default"in t?console.warn(`jq79: <${e.tag}> has both a <template :slot> and content outside it - the <template> is the default slot's content, and the rest was ignored`):s&&(t.default={nodes:n,binder:e.attrs[":slot"]||void 0}),t},yn=(e,t,n)=>{fe(t)?.forEach(({name:s,as:r,default:o})=>{let i=r??s;Object.defineProperty(e,i,{enumerable:!0,configurable:!0,get:()=>{let a=n[s]?.();return a===void 0&&o!==void 0?A(o,e):a},set:()=>console.warn(`jq79: "${i}" is a slot prop - it comes from the component, so assigning to it does nothing`)})})},bn=e=>{let t=Oe(e);return console.warn(`jq79: <template ${t}> fills a slot only as a direct child of a component tag; here it rendered nothing`),document.createComment(`misplaced ${t}`)},En=(e,t)=>{let n=Object.entries(mn(e));if(!n.length)return null;let s={};return n.forEach(([r,o])=>{s[r]=Sn(o,t)}),s},Sn=(e,t)=>(n,s,r,o)=>{let i=Object.create(t);yn(i,e.binder,n);let a=i[oe]??[];Object.defineProperty(i,oe,{value:[...a,s]});let c=H(i);return r.onDispose(()=>c.dispose()),V(e.nodes,i,c,o)},wn=(e,t,n,s)=>{let r=St(e.tag.slice(5)),o=document.createDocumentFragment(),i=document.createComment(e.tag),a=document.createComment(`/${e.tag}`);o.append(i,a);let c=t[Et]?.[r];if(!c)return o.insertBefore(V(e.children,t,n,s),a),o;let d={};return Object.entries(e.attrs).forEach(([u,m])=>{if(!(u===ye||je(u)||u.startsWith("@")))if(u.startsWith(":")){let S=m||u.slice(1);d[B(u.slice(1))]=()=>A(S,t)}else d[B(u)]=()=>m}),o.insertBefore(c(d,t,n,s),a),o},nt=(e,t,n,s,r)=>{let o=document.createComment(e),i=document.createComment(`/${e}`),a=document.createDocumentFragment();a.append(o,i);let c=En(t,n),d={},u={},m=[],S=[],C=!1;Object.entries(t.attrs).forEach(([f,l])=>{if(f!==ye){if(f===":props"||f.startsWith(":props.")){C=!0,S.push({expr:l});return}if(!je(f))if(f.startsWith("@"))m.push([f,l]);else if(f===":model"||f.startsWith(":model.")){let p=f===":model"?"default":B(f.slice(7));u[p]=l||(f===":model"?"model":p)}else if(f.startsWith(":")){let p=B(f.slice(1));d[p]=l||p,S.push({name:p,expr:l||p})}else{let p=B(f),g=JSON.stringify(l);d[p]=g,S.push({name:p,expr:g})}}});let O=f=>f==="default"?":model":`:model.${f}`,j=f=>f==="default"?"model":f,y=f=>`${f}
|
|
9
|
+
= $value`,w=new Set;Object.entries(u).forEach(([f,l])=>{let p=j(f);d[p]!==void 0&&console.warn(`jq79: <${t.tag}> binds prop "${p}" through both :${p} and ${O(f)} - ${O(f)} wins`),d[p]=l,pt(y(l),["$value"])===null&&(w.add(f),console.warn(`jq79: ${O(f)}="${l}" is not assignable - updates from <${t.tag}> will be dropped`))});let T=()=>{let f={};return S.forEach(({name:l,expr:p})=>{if(l!==void 0)f[l]=A(p,n);else{let g=A(p,n);g!==null&&typeof g=="object"&&Object.assign(f,g)}}),Object.entries(u).forEach(([l,p])=>{f[j(l)]=A(p,n)}),f},h=null,b=null,$=null,E=new Set,N=f=>{if(f==null){if(!n[xt]?.has(e)||E.has("unfilled"))return;E.add("unfilled"),console.error(`jq79: <${t.tag}> is declared as a prop and the parent passed nothing - nothing renders here. Pass it (:${e}="\u2026"), or drop it from the signature to use the one declared in this file.`);return}E.has("type")||(E.add("type"),console.error(`jq79: <${t.tag}> is ${typeof f}, not a component - nothing renders here`))};return s.effect(()=>{let f=A(e,n),l=f instanceof q?f:null;if(l||N(f),l===b||($?.dispose(),$=null,h?.destroy(),h=null,b=l,!l))return;let p=new q({template:l.template,scripts:l.scripts,styles:l.styles,modules:l.modules,filename:l.filename,siblings:l.siblings,name:l.name});if(c&&(p.slots=c),Object.keys(u).length){let v=new Set;p.modelWriteback=(L,W)=>{let M=L==null?"default":B(String(L)),De=u[M];return De===void 0?(v.has(M)||(v.add(M),console.warn(`jq79: <${t.tag}> has no ${O(M)} - bound: ${Object.keys(u).map(O).join(", ")}`)),!1):w.has(M)?!1:(X(()=>A(y(De),n,{$value:W})),!0)}}m.forEach(([v,L])=>fn(p,v,L,n));let g=Jn(p.scripts);Xn(t,e,Object.keys(d),g);let x=lt(X(T),g),R=document.createDocumentFragment();if($e>=tt){console.error(`jq79: <${t.tag}> is ${tt} levels deep inside itself; giving up here. A component that renders itself stops when its data stops - is there a cycle in it?`);return}$e++;try{(r?p.renderShadow(x):p.render(x)).mount(R)}finally{$e--}i.parentNode.insertBefore(R,i);let P=H(n);if(C){let v=[];P.effect(()=>{let L=lt(T(),g),W=Object.keys(L);v.forEach(M=>{M in L||(p.data[M]=void 0)}),W.forEach(M=>{p.data[M]=L[M]}),v=W})}else Object.entries(d).forEach(([v,L])=>{g!==null&&!g.has(v)||P.effect(()=>{p.data[v]=A(L,n)})});$=P,h=p}),s.onDispose(()=>{$?.dispose(),h?.destroy()}),a},Rn=(e,t)=>{let n=()=>{let s=A(e,t);return s!==null&&typeof s=="object"?s:null};return new Proxy(t,{has(s,r){let o=n();return o!==null&&Reflect.has(o,r)||Reflect.has(s,r)},get(s,r){let o=n();return o!==null&&Reflect.has(o,r)?o[r]:Reflect.get(s,r)},set(s,r,o){let i=n();return i!==null&&Reflect.has(i,r)?(i[r]=o,!0):Reflect.set(s,r,o)}})},ee=e=>typeof e=="string"?e.split(/\s+/).filter(Boolean):Array.isArray(e)?e.flatMap(ee):e!==null&&typeof e=="object"?Object.entries(e).flatMap(([t,n])=>n?ee(t):[]):[],$n=e=>typeof e=="function"?(t,n,s)=>{try{return!!e(t,n,s)}catch{return!1}}:typeof e=="string"||Array.isArray(e)?We(e):()=>!1,Tn=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"]),st=(e,t,n)=>{let s=Tn.has(t);(s?!n:n==null)?e.removeAttribute(t):e.setAttribute(t,s?"":String(n))},ve=(e,t,n,s)=>{let r=e.attrs[":with"],o=r!==void 0?Rn(r,t):t;if(pn(e.tag))return wn(e,o,n,s);if(e.tag==="template"&&Oe(e)!==void 0)return bn(e);let i=et(o,e.tag);if(i)return nt(i,e,o,n,s);let a=document.createElement(e.tag),c=a instanceof HTMLUnknownElement||e.tag.includes("-");if(c){let y=!1;n.effect(()=>{if(y)return;let w=et(o,e.tag);if(!w)return;y=!0;let T=nt(w,e,o,n,s),h=Ne(T);n.onDispose(()=>he(h)),a.replaceWith(T)})}Object.entries(e.attrs).forEach(([y,w])=>{if(y.startsWith("@"))un(a,y,w,o);else if(y===":model"||y.startsWith(":model."))c||console.warn(`jq79: ${y} on <${e.tag}> does nothing - :model binds component tags only (for now)`);else if(!je(y))if(y.startsWith(":"))if(c)a.setAttribute(y,w);else{let T=y.slice(1),h=w||B(T);n.effect(()=>st(a,T,A(h,o)))}else a.setAttribute(y,w)});let d=e.attrs[":attrs"];if(d!==void 0){let y=[];n.effect(()=>{y.forEach(T=>a.removeAttribute(T));let w=A(d,o);y=w&&typeof w=="object"?Object.keys(w):[],y.forEach(T=>st(a,T,w[T]))})}let u=e.attrs[":class"],m=Object.entries(e.attrs).filter(([y])=>y.startsWith(":class.")).map(([y,w])=>[y.slice(7),w]);if(u!==void 0||m.length){let y=new Set(ee(e.attrs.class??"")),w=[];n.effect(()=>{let T=u!==void 0?ee(A(u,o)):[];m.forEach(([h,b])=>{A(b,o)&&T.push(...ee(h))}),w.forEach(h=>{!T.includes(h)&&!y.has(h)&&a.classList.remove(h)}),a.classList.add(...T),w=T})}let S=e.attrs[":text"],C=e.attrs[":html"],O=e.attrs[":html.allowed"];O!==void 0&&C===void 0&&console.warn("jq79: :html.allowed without :html on the same element does nothing"),S!==void 0?n.effect(()=>{a.textContent=String(A(S,o)??"")}):C!==void 0?n.effect(()=>{let y=O!==void 0?{allowUrl:$n(A(O,o))}:void 0;a.innerHTML=Ie(String(A(C,o)??""),y)}):a instanceof HTMLTemplateElement?a.content.appendChild(V(e.children,o,n,s)):a.appendChild(V(e.children,o,n,s));let j=e.attrs[":value"];return j!==void 0&&n.effect(()=>{let y=String(A(j,o)??"");a.value!==y&&(a.value=y)}),[":checked",":selected"].forEach(y=>{let w=e.attrs[y];if(w===void 0)return;let T=y.slice(1);n.effect(()=>{a[T]=!!A(w,o)})}),a},xn=(e,t,n,s)=>{let r=document.createComment("if"),o=document.createDocumentFragment();o.appendChild(r);let i=null,a=null,c=null;return n.effect(()=>{let d=e.find(m=>m.expr===void 0||A(m.expr,t))??null;if(d===a||(c?.dispose(),i&&he(i),i=null,a=d,!d))return;c=H(t);let u=ve(d.node,t,c,s);i=Ne(u),r.parentNode.insertBefore(u,r.nextSibling)}),o},Y=(e,t,n)=>{Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})},Cn=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},_n=(e,t,n,s)=>{let r=e.attrs[":each"].match(cn);if(!r)return document.createComment(`invalid :each expression "${e.attrs[":each"]}"`);let[,o,i,a]=r,c=e.attrs[":key"],{[":each"]:d,[":key"]:u,...m}=e.attrs,S={...e,attrs:m},C=document.createComment("each"),O=document.createDocumentFragment();O.appendChild(C),(":if"in e.attrs||":elseif"in e.attrs||":else"in e.attrs)&&console.warn("jq79: :if/:elseif/:else on a :each element is ignored; filter the list expression instead");let j=[],y=!1;return n.effect(()=>{let w=A(a,t),T=Array.isArray(w)?w.map((f,l)=>[l,f]):Cn(w)?Object.entries(w):[],h=new Map;j.forEach(f=>{let l=h.get(f.key);l?l.push(f):h.set(f.key,[f])});let b=new Set,$=[],E=T.map(([f,l],p)=>{let g=Object.create(t);Y(g,o,l),i&&Y(g,i,f),Y(g,"$index",p);let x=c!==void 0?A(c,g):f;b.has(x)&&!y&&(y=!0,console.warn(`jq79: duplicate :key in :each "${e.attrs[":each"]}"; duplicates pair up by position`)),b.add(x);let R=h.get(x)?.shift();if(R&&Object.is(R.item,l))return R.scope.$index!==p&&$.push(R),Y(R.scope,"$index",p),i&&Y(R.scope,i,f),R;R&&(R.fx.dispose(),he(R.range));let P=H(t),v=Ne(ve(S,g,P,s));return{key:x,item:l,scope:g,fx:P,range:v}});h.forEach(f=>f.forEach(l=>{l.fx.dispose(),he(l.range)}));let N=C;E.forEach(f=>{N.nextSibling!==f.range.first&&dn(f.range,N),N=f.range.last}),$.forEach(f=>X(()=>f.fx.refresh())),j=E}),O},V=(e,t,n,s=!1)=>{let r=document.createDocumentFragment(),o=0;for(;o<e.length;){let i=e[o];if(typeof i=="string"){let a=document.createTextNode(i);i.includes("{{")&&n.effect(()=>{a.textContent=an(i,t)}),r.appendChild(a),o++;continue}if(":each"in i.attrs){r.appendChild(_n(i,t,n,s)),o++;continue}if(":if"in i.attrs){let a=[{expr:i.attrs[":if"],node:i}];o++;let c=u=>{let m=o;for(;m<e.length&&typeof e[m]=="string"&&!e[m].trim();)m++;let S=e[m];if(typeof S=="object"&&u in S.attrs)return o=m+1,S};for(let u=c(":elseif");u;u=c(":elseif"))a.push({expr:u.attrs[":elseif"],node:u});let d=c(":else");d&&a.push({node:d}),r.appendChild(xn(a,t,n,s));continue}r.appendChild(ve(i,t,n,s)),o++}return r},An=(e,t,n=!1)=>V(e.template,t,H(t),n),jn=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Nn=/<([A-Za-z][\w.-]*)((?:"[^"]*"|'[^']*'|[^>"'])*?)\/>/g,Le=/(<script[\s\S]*?<\/script\s*>|<style[\s\S]*?<\/style\s*>)/gi,On=e=>e.split(Le).map((t,n)=>n%2===1?t:t.replace(Nn,(s,r,o)=>jn.has(r.toLowerCase())?s:`<${r}${o}></${r}>`)).join(""),wt=/<([A-Za-z][\w.-]*)((?:"[^"]*"|'[^']*'|[^>"'])*)>/g,vn=/"[^"]*"|'[^']*'|(^|\s)\.\.\.([A-Za-z_$][\w$.]*)/g,Ln=e=>e.split(Le).map((t,n)=>n%2===1?t:t.replace(wt,(s,r,o)=>{let i=0,a=o.replace(vn,(c,d,u)=>u===void 0?c:`${d}:props.${i++}="${u}"`);return`<${r}${a}>`})).join(""),Pn=/"[^"]*"|'[^']*'|(^|\s)(:[\w.$-]+)/g,Mn=/<\/slot\.([\w.$-]+)(\s*)>/gi,Dn=/^slot\./i,kn=e=>Dn.test(e)?`slot.${xe(e.slice(5))}`:e,qn=e=>e.split(Le).map((t,n)=>n%2===1?t:t.replace(wt,(s,r,o)=>{let i=o.replace(Pn,(a,c,d)=>d===void 0?a:`${c}${xe(d)}`);return`<${kn(r)}${i}>`}).replace(Mn,(s,r,o)=>`</slot.${xe(r)}${o}>`)).join(""),ye="data-jq79",Wn=e=>{let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return(t>>>0).toString(36)},Rt=(e,t)=>{e.forEach(n=>{typeof n!="string"&&(n.attrs[ye]=t,Rt(n.children,t))})},Un=(e,t)=>e.split(",").map(n=>{let s=n.trim(),r=s.indexOf("::"),o=r===-1?s:s.slice(0,r),i=r===-1?"":s.slice(r);return`${o}[${ye}="${t}"]${i}`}).join(", "),$t=(e,t)=>{Array.from(e).forEach(n=>{n instanceof CSSStyleRule?n.selectorText=Un(n.selectorText,t):n instanceof CSSGroupingRule&&$t(n.cssRules,t)})},In=(e,t)=>{/:deep\(|::v-deep|>>>/.test(e)&&console.warn("jq79: :deep()/::v-deep/>>> are not supported in <style scoped>; the rule will be dropped by the browser");let n=new CSSStyleSheet;return n.replaceSync(e),$t(n.cssRules,t),Array.from(n.cssRules).map(s=>s.cssText).join(`
|
|
10
|
+
`)},Fn=/^[A-Z][A-Za-z0-9]*$/,Ce=e=>{let t=On(Ln(qn(e))),s=new DOMParser().parseFromString(`<template>${t}</template>`,"text/html").querySelector("template"),r=[],o=[];Array.from(s.content.children).forEach(c=>{c.tagName==="TEMPLATE"?o.push(c):r.push(c)});let i=rt(r,e),a={};return o.forEach(c=>{let d=c.getAttribute("name");if(d===null){console.warn("jq79: a top-level <template> without a name declares nothing and was ignored");return}if(!Fn.test(d)){console.warn(`jq79: <template name="${d}"> was ignored - a component name has to be PascalCase, or no tag could ever reference it (only capitalized names resolve as components)`);return}if(d in a){console.warn(`jq79: two <template name="${d}"> in one file; the second was ignored`);return}a[d]=new q({...rt(Array.from(c.content.children),c.innerHTML),siblings:a,name:d})}),Object.keys(a).length&&(i.siblings=a),i},rt=(e,t)=>{let n=[],s=[],r=[];e.forEach(i=>{let a={attrs:ft(i),content:i.textContent??""};i.tagName==="SCRIPT"?n.push(a):i.tagName==="STYLE"?s.push(a):r.push(dt(i))}),s.forEach(i=>{"lang"in i.attrs&&console.warn(`jq79: <style lang="${i.attrs.lang}"> needs the jq79/vite plugin to compile it. This component didn't go through the bundler, so its styles were left uncompiled and the browser will ignore them.`)});let o=i=>"scoped"in i.attrs&&!("lang"in i.attrs);if(s.some(o)){let i=Wn(t);Rt(r,i),s.forEach(a=>{o(a)&&(a.scoped=In(a.content,i))})}return{template:r,scripts:n,styles:s}},Pe=e=>/\.html?([?#]|$)/.test(e)?_e(e):import(e),Bn=/^(?:\.\.?\/|\/|[a-z][a-z0-9+.-]*:)/i,Hn=(e,t)=>{if(!Bn.test(e))return e;try{return new URL(e,new URL(t??"",document.baseURI)).href}catch{return e}},Tt=(e,t)=>e?`
|
|
11
|
+
//# sourceURL=${e}?jq79-script=${t}`:"",ot=e=>e.scoped??e.content,ge=new Map,zn=e=>{let t=ge.get(e);if(!t){let n=document.createElement("style");n.textContent=e,document.head.appendChild(n),t={el:n,count:0},ge.set(e,t)}t.count++},Gn=e=>{let t=ge.get(e);t&&--t.count<=0&&(t.el.remove(),ge.delete(e))},Zn=(e,t,n,s={},r=Pe,o={})=>{let i={...At,...s},a=new Proxy(t,{has:(d,u)=>u!=="$__effect"&&u!=="$__import"&&(Reflect.has(d,u)||!(u in globalThis)&&!(u in i))}),c=new Function("$scope","$__effect","$__import",...Object.keys(i),`return (async () => { with ($scope) { ${e} } })()${Tt(o.filename,o.index??0)}`)(a,n,r,...Object.values(i));c.catch(d=>console.error("jq79: error in :setup script",d)),gt(c)},it=(e,t)=>{t?.forEach(({name:n,default:s})=>{e[n]===void 0&&(e[n]=s===void 0?void 0:A(s,e))})},Me=e=>{let t=e.attrs[":setup"];if(t===void 0)return null;if(t.trim()==="")return[];let n=fe(t);return n||Kn(e,t),n},at=new WeakSet,Kn=(e,t)=>{t.trim()==="_"||at.has(e)||(at.add(e),console.warn(`jq79: :setup="${t}" is not a props pattern, so this component declares no signature and takes whatever a parent passes - write the props it takes ("{ a, b }"), a bare :setup for none, or "_" to stay open on purpose`))},Vn=e=>{let t=new Set;return e.forEach(n=>{(de(n.content)??Me(n))?.forEach(({name:r})=>t.add(r))}),t},Jn=e=>{let t=null;return e.forEach(n=>{let s=de(n.content)??Me(n);if(!s)return;let r=t??(t=new Set);s.forEach(({name:o})=>r.add(o))}),t},lt=(e,t)=>{if(t===null)return e;let n={};return Object.keys(e).forEach(s=>{t.has(s)&&(n[s]=e[s])}),n},ct=new WeakMap,Xn=(e,t,n,s)=>{if(s===null)return;let r=ct.get(e)??new Set;ct.set(e,r),n.forEach(o=>{s.has(o)||r.has(o)||(r.add(o),console.warn(`jq79: :${o} is not declared by <${t}> - add it to the :setup signature, or drop it`))})},Qn=(e,t)=>{if(!e)return null;let n=Object.create(null),s=!1;return Object.entries(e).forEach(([r,o])=>{t.has(r)||(n[r]=o,s=!0)}),s?n:null},xt=Symbol("jq79.unfilledProps"),Yn=e=>e&&e.default!==void 0?e.default:e,es=(e,t,n,s={},r=Pe,o={})=>{let i={...At,...s},a={},c=new Function("$__exports","$__default","$__import",...Object.keys(i),`return (async () => { "use strict";
|
|
12
12
|
${e}
|
|
13
|
-
;$__exports.done = true })()${
|
|
13
|
+
;$__exports.done = true })()${Tt(o.filename,o.index??0)}`)(a,Yn,r,...Object.values(i)),d=C=>console.error("jq79: error in factory script",C),u=!1,m,S=()=>{if(u)return m;u=!0;let C=a.default;if(typeof C!="function")return;let O=j=>{j&&typeof j=="object"&&Object.assign(t,j)};try{let j=C(t,{$data:t,$props:t,$effect:n,...s});j instanceof Promise?m=j.then(O).catch(d):O(j)}catch(j){d(j)}return m};gt(c.then(S,d)),a.done&&S()},ts="__JQ79_HMR_ENABLED__",ns="__JQ79_HMR__",G=null,ss=e=>{if(!G||!e.filename)return;let t=G.get(e.filename);t||G.set(e.filename,t=new Set),t.add(new WeakRef(e))},ut=e=>{try{return new URL(e,document.baseURI).pathname}catch{return e}},Ct=(e,t)=>{if(!G)return 0;let n=ut(e),s=Ce(t),r=!1,o=a=>a.name===void 0?s:s.siblings?.[a.name]??null,i=0;for(let[a,c]of G)if(ut(a)===n){for(let d of c){let u=d.deref();if(!u){c.delete(d);continue}let m=o(u);if(!m){r=!0;continue}u.hotReplace(m)&&i++}c.size||G.delete(a)}return r?0:i},_t=()=>{G??(G=new Map),globalThis[ns]={update:Ct}},_e=async e=>{let t=await fetch(e);if(!t.ok)throw new Error(`failed to fetch component from ${e}: ${t.status}`);return new q(await t.text(),{filename:e})},q=class{constructor(t,n={}){_(this,"template");_(this,"scripts");_(this,"styles");_(this,"modules");_(this,"filename");_(this,"siblings");_(this,"name");_(this,"slots");_(this,"modelWriteback");_(this,"data",null);_(this,"fx",null);_(this,"content",null);_(this,"startMarker",null);_(this,"endMarker",null);_(this,"styleEls",[]);_(this,"ownsSharedStyles",!1);_(this,"useShadow",!1);_(this,"mountRoot",null);_(this,"resolveMounted",null);_(this,"emitListeners",new Map);let s=typeof t=="string"?Ce(t):t;this.template=s.template,this.scripts=s.scripts,this.styles=s.styles,this.modules=n.modules??(typeof t=="string"?void 0:t.modules),this.filename=n.filename??(typeof t=="string"?void 0:t.filename),this.siblings=s.siblings,this.name=s.name,this.adoptSiblings(),ss(this)}adoptSiblings(){this.siblings&&Object.entries(this.siblings).forEach(([t,n])=>{n.filename??(n.filename=this.filename),n.modules??(n.modules=this.modules),this.name||(this[t]=n)})}hotReplace(t){let n=typeof t=="string"?Ce(t):t;Ae.clear(),z.clear();let s=this.startMarker,r=!!(s&&this.content),o=r&&s.isConnected,i=o?s.parentNode:null,a=o?this.endMarker.nextSibling:null,c={...this.data},d=this.useShadow;return r&&this.destroy(),this.template=n.template,this.scripts=n.scripts,this.styles=n.styles,this.siblings=n.siblings,this.adoptSiblings(),!r||(this.renderWith(c,d),!i)?!1:(d&&this.styleEls.forEach(u=>i.insertBefore(u,a)),i.insertBefore(this.content,a),this.mountRoot=i,this.resolveMounted?.(),!0)}static fetch(t){if(Array.isArray(t))throw new TypeError("Component79.fetch takes one URL; use fetchAll for an array");return new me(_e(t))}static fetchAll(t){return Promise.all(t.map(_e))}on(t,n){return this.emitListeners.has(t)||this.emitListeners.set(t,new Set),this.emitListeners.get(t).add(n),this}off(t,n){return this.emitListeners.get(t)?.delete(n),this}render(t={}){return this.renderWith(t,!1)}renderShadow(t={}){return this.renderWith(t,!0)}renderWith(t,n){this.destroy();let s=Vn(this.scripts),r=Qn(this.siblings,s),o=r?Object.assign(Object.create(r),t):{...t},i=new Set([...s].filter(l=>!(l in t)));i.size&&Object.defineProperty(o,xt,{value:i}),this.slots&&Object.defineProperty(o,Et,{value:this.slots});let a=Q(o),c=H(a);this.data=a,this.fx=c,this.useShadow=n,this.startMarker=document.createComment("jq79"),this.endMarker=document.createComment("/jq79");let d=this.startMarker,u=!1,m=(l,p)=>{l==="model:update"&&!u&&(u=!0,console.warn("jq79: $emit('model:update', \u2026) no longer feeds :model - call $updateModel(value) or $updateModel(name, value) instead"));let g=new CustomEvent(l,{detail:p,bubbles:!0,composed:!0,cancelable:!0});return d===this.startMarker&&this.emitListeners.get(l)?.forEach(x=>x(g,p)),g.cancelBubble||d.dispatchEvent(g),!g.defaultPrevented},S,C=new Promise(l=>{S=l});this.resolveMounted=S;let O=()=>C,j=this.endMarker,y=l=>{let p=[];for(let g=d.nextSibling;g&&g!==j;g=g.nextSibling)g instanceof Element&&(g.matches(l)&&p.push(g),p.push(...Array.from(g.querySelectorAll(l))));return p},w=l=>y(l)[0]??null,T=this.modules,h=l=>T&&l in T?Promise.resolve(T[l]):Pe(Hn(l,this.filename)),$=Object.assign(Object.create(null),{$emit:m,$updateModel:(...l)=>{let[p,g]=l.length>1?l:[void 0,l[0]];return d!==this.startMarker?!1:this.modelWriteback?.(p,g)??!1},$slots:Object.fromEntries(Object.keys(this.slots??{}).map(l=>[l,!0]))}),E=l=>`await $mounted();${l}`;this.scripts.forEach((l,p)=>{let g={$mounted:O,$self:w,$$self:y,...$,...r},x={filename:this.filename,index:p},R=Qe(l.content);if(R!==null){it(a,de(l.content));let W=":mounted"in l.attrs?E(R):R;es(W,a,c.effect,g,h,x);return}let{vars:P,code:v}=ue(l.content);it(a,Me(l)),P.forEach(W=>{W in a||(a[W]=void 0)});let L=":mounted"in l.attrs?E(v):v;Zn(L,a,c.effect,g,h,x)});let N=document.createDocumentFragment(),f=new Proxy(a,{has:(l,p)=>typeof p=="string"&&p in $||Reflect.has(l,p),get:(l,p,g)=>typeof p=="string"&&p in $&&!Reflect.has(l,p)?$[p]:Reflect.get(l,p,g)});return N.append(this.startMarker,V(this.template,f,c,n),this.endMarker),this.content=N,n?this.styleEls=this.styles.map(l=>{let p=document.createElement("style");return p.textContent=l.content,p}):(this.styles.forEach(l=>zn(ot(l))),this.ownsSharedStyles=!0),this}mount(t,n){let s=typeof t=="string"?Z(t):t;if(!s)throw new Error(`mount target not found: ${t}`);return(!this.content||n!==void 0)&&this.renderWith(n??{},this.useShadow),this.attach(s)}mountShadow(t,n){let s=typeof t=="string"?Z(t):t;if(!s)throw new Error(`mount target not found: ${t}`);return(!this.content||n!==void 0||!this.useShadow)&&this.renderWith(n??{},!0),this.attach(s)}attach(t){this.mountRoot&&this.detach();let n=this.useShadow&&t instanceof Element?t.shadowRoot??t.attachShadow({mode:"open"}):t;return this.useShadow&&this.styleEls.forEach(s=>n.appendChild(s)),n.appendChild(this.content),this.mountRoot=n,this.resolveMounted?.(),this}detach(){if(!this.mountRoot||!this.content||!this.startMarker||!this.endMarker)return this;let t=this.startMarker;for(;t;){let n=t.nextSibling;if(this.content.appendChild(t),t===this.endMarker)break;t=n}return this.mountRoot=null,this}destroy(){return this.detach(),this.fx?.dispose(),this.fx=null,this.data?.$dispose(),this.styleEls.forEach(t=>t.parentNode?.removeChild(t)),this.styleEls=[],this.ownsSharedStyles&&(this.styles.forEach(t=>Gn(ot(t))),this.ownsSharedStyles=!1),this.content=null,this.startMarker=null,this.endMarker=null,this.data=null,this.resolveMounted=null,this}};_(q,"version",nn);var me=class{constructor(t){_(this,"chain");this.chain=t}queue(t){return this.chain=this.chain.then(n=>(t(n),n)),this}then(t,n){return this.chain.then(t,n)}catch(t){return this.chain.catch(t)}finally(t){return this.chain.finally(t)}mount(t,n){return this.queue(s=>s.mount(t,n))}mountShadow(t,n){return this.queue(s=>s.mountShadow(t,n))}render(t={}){return this.queue(n=>n.render(t))}renderShadow(t={}){return this.queue(n=>n.renderShadow(t))}on(t,n){return this.queue(s=>s.on(t,n))}off(t,n){return this.queue(s=>s.off(t,n))}detach(){return this.queue(t=>t.detach())}destroy(){return this.queue(t=>t.destroy())}};var rs=e=>new q(e),At={$:Z,$$:ne,$create:se,$reactive:Q,Component79:q};typeof globalThis<"u"&&globalThis[ts]&&_t();0&&(module.exports={$,$$,$create,$reactive,C79,Component79,PendingComponent79,enableHotReload,hotUpdate,parseComponent,renderComponent});
|
|
14
14
|
//# sourceMappingURL=jq79.cjs.map
|