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