jq79 0.4.1 → 0.4.2
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 +10 -10
- package/dist/jq79.cjs.map +1 -1
- package/dist/jq79.global.js +10 -10
- package/dist/jq79.global.js.map +1 -1
- package/dist/jq79.js +10 -10
- package/dist/jq79.js.map +1 -1
- package/package.json +1 -1
- package/src/jq79.ts +34 -1
package/dist/jq79.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var z=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=J(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}},X=/export\s+default(?![\w$])/y,
|
|
6
|
-
`||r===";"||r==="}"?s=!0:/\s/.test(r)||(s=!1),t++}return-1},
|
|
7
|
-
`||c===";"||c==="}"?r=!0:/\s/.test(c)||(r=!1),t+=c,n++}return o?t:null};var
|
|
8
|
-
`)},
|
|
9
|
-
//# sourceURL=${e}?jq79-script=${t}`:"",
|
|
1
|
+
var z=Object.defineProperty;var qe=Object.getOwnPropertyDescriptor;var He=Object.getOwnPropertyNames;var ze=Object.prototype.hasOwnProperty;var Ge=(e,t,n)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ke=(e,t)=>{for(var n in t)z(e,n,{get:t[n],enumerable:!0})},Ze=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of He(t))!ze.call(e,r)&&r!==n&&z(e,r,{get:()=>t[r],enumerable:!(s=qe(t,r))||s.enumerable});return e};var Je=e=>Ze(z({},"__esModule",{value:!0}),e);var C=(e,t,n)=>Ge(e,typeof t!="symbol"?t+"":t,n);var It={};Ke(It,{$:()=>I,$$:()=>G,$create:()=>K,$reactive:()=>q,Component79:()=>F,enableHotReload:()=>Be,hotUpdate:()=>We,parseComponent:()=>Ft,renderComponent:()=>Rt});module.exports=Je(It);function I(e,t){return typeof e=="string"?document.querySelector(e):e.querySelector(t)}function G(e,t){return Array.from(typeof e=="string"?document.querySelectorAll(e):e.querySelectorAll(t))}var K=(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},Ve=new Set(["a","b","i","em","strong","p","br","ul","ol","li","blockquote","code","pre","span","div","h1","h2","h3","h4","h5","h6","img"]),de={a:new Set(["href","title"]),img:new Set(["src","alt"]),"*":new Set(["class"])},Xe=new Set(["http:","https:","mailto:"]);function Qe(e){try{let t=new URL(e,"https://example.com");return Xe.has(t.protocol)}catch{return!1}}function pe(e,t){for(let n of Array.from(e.childNodes))if(n.nodeType===Node.ELEMENT_NODE){let s=Ye(n);s&&t.appendChild(s)}else n.nodeType===Node.TEXT_NODE&&t.appendChild(n.cloneNode())}function Ye(e){let t=e.tagName.toLowerCase();if(!Ve.has(t))return null;let n=document.createElement(t);for(let s of Array.from(e.attributes)){let r=s.name.toLowerCase(),o=de[t]?.has(r),i=de["*"]?.has(r);!o&&!i||(r==="href"||r==="src")&&!Qe(s.value)||n.setAttribute(r,s.value)}return t==="a"&&n.setAttribute("rel","noopener noreferrer"),pe(e,n),n}function he(e){let t=new DOMParser().parseFromString(e,"text/html"),n=document.createElement("div");return pe(t.body,n),n.innerHTML}var et=(e,t)=>t.split(".").reduce((n,s)=>n?.[s],e),me=e=>{if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},ge=(e,t,n)=>{Object.entries(e).forEach(([s,r])=>{let o=t?`${t}.${s}`:s;r&&typeof r=="object"&&me(r)?ge(r,o,n):n(o,r)})},tt=(e,t)=>e===t||e.startsWith(`${t}.`)||t.startsWith(`${e}.`),te=Symbol("jq79.raw"),Z=e=>{let t=e;for(;t!==null&&typeof t=="object"&&t[te];)t=t[te];return t},ye=Symbol("jq79.store"),U=e=>e!==null&&typeof e=="object"&&e[ye]===!0,W=[],ne=e=>{W.push(new Set);try{return e()}finally{W.pop()}},q=e=>{let t=new Map,n=new Set,s=new Set,r=new WeakMap,o=Object.create(null),i=(a,u,h=!1)=>{t.get(a)?.forEach(S=>S(u,a)),n.forEach(S=>S(a,u)),s.forEach(S=>{(h||Array.from(S.deps).some(T=>tt(T,a)))&&S.run()})},c=a=>a!==null&&typeof a=="object"&&me(a),l=new Map,p=(a,u)=>{let h=l.get(u);h?.store!==a&&(h?.unsubscribe(),l.set(u,{store:a,unsubscribe:a.$onAny((S,T)=>i(`${u}.${S}`,T))}))},f=a=>{l.get(a)?.unsubscribe(),l.delete(a)},E=(a,u)=>{let h=r.get(a);if(h)return h;let S=null,T=new Proxy(a,{has(R,y){return Reflect.has(R,y)||typeof y=="string"&&S?.has(y)===!0},get(R,y,b){if(y===te)return R;if(y===ye)return u==="";if(typeof y!="string")return Reflect.get(R,y,b);if(u===""&&y in o)return o[y];let w=u?`${u}.${y}`:y;W[W.length-1]?.add(w);let N=Reflect.get(R,y,b);if(U(N))return p(N,w),N;let $=Z(N);return c($)?E($,w):$},set(R,y,b,w){if(w!==T&&!Object.prototype.hasOwnProperty.call(R,y))return Reflect.set(R,y,b,w);let N=u?`${u}.${y}`:y,$=U(b)?b:Z(b),P=!Object.prototype.hasOwnProperty.call(R,y);if(!P&&Object.is(R[y],$)&&($===null||typeof $!="object"))return!0;R[y]=$,S?.delete(y),U($)?p($,N):f(N);let L=U($)||!c($)?$:E($,N);return i(N,L,P),!0},deleteProperty(R,y){if(typeof y!="string")return Reflect.deleteProperty(R,y);let b=Object.prototype.hasOwnProperty.call(R,y),w=Reflect.deleteProperty(R,y);if(w&&b){let N=u?`${u}.${y}`:y;(S??(S=new Set)).add(y),f(N),i(N,void 0)}return w}});return r.set(a,T),T},d=E(Z(e),"");Object.entries(Z(e)).forEach(([a,u])=>{U(u)&&p(u,a)});let m=(a,u,{immediate:h=!1}={})=>(t.has(a)||t.set(a,new Set),t.get(a).add(u),h&&u(et(d,a),a),()=>t.get(a)?.delete(u)),g=(a,{immediate:u=!1}={})=>(n.add(a),u&&ge(d,"",(h,S)=>a(h,S)),()=>n.delete(a)),x=a=>{let u=!1,h=!1,S={deps:new Set,run:()=>{if(u){h=!0;return}u=!0;try{let T=0;do{h=!1;let R=new Set;W.push(R);try{a()}finally{W.pop(),S.deps=R}}while(h&&++T<100);h&&console.error("jq79: an effect re-woke itself 100 times in a row (it writes what it reads); giving up on it settling")}finally{u=!1}}};return s.add(S),S.run(),()=>{s.delete(S)}},O=()=>{l.forEach(({unsubscribe:a})=>a()),l.clear()};return o.$on=m,o.$onAny=g,o.$effect=x,o.$dispose=O,d},B=e=>{let t=[],n=[];return{effect:s=>{t.push(e.$effect(s)),n.push(s)},onDispose:s=>{t.push(s)},refresh:()=>{n.forEach(s=>s())},dispose:()=>{t.splice(0).forEach(s=>s()),n.length=0}}};var Ee=/(?:let|var|const)\s+([A-Za-z_$][\w$]*)/y,be=/\$:\s*/y,V=/import(?=\s*\()/y,Se=/\$:\s*([A-Za-z_$][\w$]*)\s*=(?!=)/y,j=(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},A=(e,t)=>{let n=e.indexOf(`
|
|
2
|
+
`,t);return n===-1?e.length:n},v=(e,t)=>{let n=e.indexOf("*/",t+2);return n===-1?e.length:n+2},J=(e,t)=>{let n=t;for(;n<e.length;){if(/\s/.test(e[n])){n++;continue}if(e[n]==="/"&&e[n+1]==="/"){n=A(e,n);continue}if(e[n]==="/"&&e[n+1]==="*"){n=v(e,n);continue}break}return n},nt=new Set(["return","typeof","case","in","instanceof","new","delete","void","do","else","yield","await"]),M=(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 nt.has(e.slice(r,n+1))}return(s==="+"||s==="-")&&e[n-1]===s?!1:!")]}\"'`.".includes(s)},D=(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},st=/^(\?\.|\?\?|&&|\|\||\*\*|[.,+\-*/%&|^<>=?:([])/,rt=(e,t)=>{let n=0,s=t;for(;s<e.length;){let r=e[s];if(r==="'"||r==='"'||r==="`"){s=j(e,s);continue}if(r==="/"&&e[s+1]==="/"){s=A(e,s);continue}if(r==="/"&&e[s+1]==="*"){s=v(e,s);continue}if(r==="/"&&M(e,s)){s=D(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=J(e,s+1);if(o>=e.length||!st.test(e.slice(o,o+2)))return s;s=o;continue}}s++}return e.length},se=e=>{let t=[],n="",s=0,r=0,o=!0;for(;s<e.length;){let i=e[s],c=e[s+1];if(i==="'"||i==='"'||i==="`"){let l=j(e,s);n+=e.slice(s,l),s=l,o=!1;continue}if(i==="/"&&(c==="/"||c==="*")){let l=c==="/"?A(e,s):v(e,s);n+=e.slice(s,l),s=l;continue}if(i==="/"&&M(e,s)){let l=D(e,s);n+=e.slice(s,l),s=l,o=!1;continue}if(i==="i"&&(s===0||!/[\w$.]/.test(e[s-1]))&&(V.lastIndex=s,V.test(e))){n+="$__import",s+=6,o=!1;continue}if(r===0&&o){Ee.lastIndex=s;let l=Ee.exec(e);if(l){t.push(l[1]),n+=l[1],s+=l[0].length,o=!1;continue}be.lastIndex=s;let p=be.exec(e);if(p){Se.lastIndex=s;let f=Se.exec(e);f&&t.push(f[1]);let E=s+p[0].length,d=rt(e,E);n+=`$__effect(() => { ${se(e.slice(E,d)).code} });`,s=d;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}},X=/export\s+default(?![\w$])/y,we=/import\s*(?:([\w$\s,{}*]+?)\s*from\s*)?(["'])([^"'\n]+)\2/y,ot=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},it=(e,t,n)=>{let s=`await $__import(${JSON.stringify(t)})`;if(e===void 0)return s;let r=ot(e),o=[],i=s;if(r.length>1){let c=`$__mod${n}`;o.push(`${c} = ${s}`),i=c}for(let c of r)c.startsWith("{")?o.push(`${c.replace(/\s+as\s+/g,": ")} = ${i}`):c.startsWith("*")?o.push(`${c.replace(/^\*\s*as\s+/,"")} = ${i}`):o.push(`${c} = $__default(${i})`);return`const ${o.join(", ")}`},ct=/^[A-Za-z_$][\w$]*$/,Re=(e,t)=>{let n=0,s=0;for(;s<e.length;){let r=e[s];if(r==="'"||r==='"'||r==="`"){s=j(e,s);continue}if(r==="/"&&e[s+1]==="/"){s=A(e,s);continue}if(r==="/"&&e[s+1]==="*"){s=v(e,s);continue}if(r==="/"&&r!==t&&M(e,s)){s=D(e,s);continue}if("([{".includes(r))n++;else if(")]}".includes(r))n--;else if(n===0&&r===t)return s;s++}return-1},$e=e=>{let t=[],n=0,s=0,r=0;for(;r<=e.length;){let o=e[r];if(o==="'"||o==='"'||o==="`"){r=j(e,r);continue}if(o==="/"&&e[r+1]==="/"){r=A(e,r);continue}if(o==="/"&&e[r+1]==="*"){r=v(e,r);continue}if(o==="/"&&M(e,r)){r=D(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},at=e=>{let t=0;for(;t<e.length;){let n=Re(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},re=e=>{let t=(e??"").trim();if(!t.startsWith("{"))return null;let n=0,s=0;for(;s<t.length;){let o=t[s];if(o==="'"||o==='"'||o==="`"){s=j(t,s);continue}if(o==="/"&&t[s+1]==="/"){s=A(t,s);continue}if(o==="/"&&t[s+1]==="*"){s=v(t,s);continue}if(o==="/"&&M(t,s)){s=D(t,s);continue}if("([{".includes(o))n++;else if(")]}".includes(o)&&--n===0)break;s++}if(s>=t.length)return null;let r=[];for(let o of $e(t.slice(1,s))){if(o.startsWith("..."))continue;let i=at(o),c=i===-1?o:o.slice(0,i),l=i===-1?void 0:o.slice(i+1).trim(),p=Re(c,":"),f=(p===-1?c:c.slice(0,p)).trim();ct.test(f)&&r.push(l===void 0?{name:f}:{name:f,default:l})}return r},lt=e=>{let t=0,n=0,s=!0;for(;t<e.length;){let r=e[t];if(r==="'"||r==='"'||r==="`"){t=j(e,t),s=!1;continue}if(r==="/"&&e[t+1]==="/"){t=A(e,t);continue}if(r==="/"&&e[t+1]==="*"){t=v(e,t);continue}if(r==="/"&&M(e,t)){t=D(e,t),s=!1;continue}if(r==="e"&&n===0&&s&&(t===0||!/[\w$.]/.test(e[t-1]))){X.lastIndex=t;let o=X.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},ft=/^async(?![\w$])/,ut=/^function(?![\w$])\s*\*?\s*[A-Za-z_$][\w$]*|^function(?![\w$])\s*\*?/,dt=e=>{let t=lt(e);if(t===-1)return null;let n=J(e,t),s=e.slice(n);ft.test(s)&&(n=J(e,n+5));let r=ut.exec(e.slice(n));if(r&&(n=J(e,n+r[0].length)),e[n]!=="(")return null;let o=0,i=n;for(;i<e.length;){let c=e[i];if(c==="'"||c==='"'||c==="`"){i=j(e,i);continue}if(c==="/"&&e[i+1]==="/"){i=A(e,i);continue}if(c==="/"&&e[i+1]==="*"){i=v(e,i);continue}if(c==="/"&&M(e,i)){i=D(e,i);continue}if("([{".includes(c))o++;else if(")]}".includes(c)&&--o===0)break;i++}return $e(e.slice(n+1,i))[0]??""},xe=e=>{let t=dt(e);if(t===null)return null;let n=re(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},Te=e=>{let t="",n=0,s=0,r=!0,o=!1,i=0;for(;n<e.length;){let c=e[n],l=e[n+1],p=n===0||!/[\w$.]/.test(e[n-1]);if(c==="'"||c==='"'||c==="`"){let f=j(e,n);t+=e.slice(n,f),n=f,r=!1;continue}if(c==="/"&&(l==="/"||l==="*")){let f=l==="/"?A(e,n):v(e,n);t+=e.slice(n,f),n=f;continue}if(c==="/"&&M(e,n)){let f=D(e,n);t+=e.slice(n,f),n=f,r=!1;continue}if(c==="i"&&p){if(V.lastIndex=n,V.test(e)){t+="$__import",n+=6,r=!1;continue}if(s===0&&r){we.lastIndex=n;let f=we.exec(e);if(f){t+=it(f[1],f[3],i++),n+=f[0].length,r=!1;continue}}}if(c==="e"&&p&&s===0&&r){X.lastIndex=n;let f=X.exec(e);if(f){o=!0,t+="$__exports.default =",n+=f[0].length,r=!1;continue}}"([{".includes(c)?s++:")]}".includes(c)&&(s=Math.max(0,s-1)),c===`
|
|
7
|
+
`||c===";"||c==="}"?r=!0:/\s/.test(c)||(r=!1),t+=c,n++}return o?t:null};var je=e=>Object.fromEntries(Array.from(e.attributes).map(t=>[t.name,t.value])),Me=e=>({tag:e.tagName.toLowerCase(),attrs:je(e),children:Array.from(e.childNodes).flatMap(t=>{if(t.nodeType===Node.TEXT_NODE){let n=t.textContent??"";return n?[n]:[]}return t.nodeType===Node.ELEMENT_NODE?[Me(t)]:[]})}),Ce=new Map,pt=(e,t)=>{let n=`${t.join(",")}|${e}`,s=Ce.get(n);if(s===void 0){try{s=new Function("$scope",...t,`with ($scope) { return (${e}); }`)}catch{s=null}Ce.set(n,s)}return s},_=(e,t,n)=>{let s=pt(e,n?Object.keys(n):[]);if(s)try{return s(t,...n?Object.values(n):[])}catch{return}},ht=(e,t)=>e.replace(/{{\s*([\s\S]+?)\s*}}/g,(n,s)=>_(s,t)??""),De=new Set([":attrs",":class",":if",":elseif",":else",":each",":key",":with",":text",":html"]),mt=/^\s*\(?\s*(\w+)\s*(?:,\s*(\w+))?\s*\)?\s+in\s+([\s\S]+)$/,gt=(e,t,n,s)=>{let[r,...o]=t.slice(1).split("."),i=new Set(o);e.addEventListener(r,c=>{if(i.has("self")&&c.target!==e)return;i.has("prevent")&&c.preventDefault(),i.has("stop")&&c.stopPropagation();let l=_(n,s,{$event:c});typeof l=="function"&&l.call(e,c)},{once:i.has("once"),capture:i.has("capture")})},Ne=e=>e.replace(/-(\w)/g,(t,n)=>n.toUpperCase()),ie=e=>e instanceof DocumentFragment?{first:e.firstChild,last:e.lastChild}:{first:e,last:e},Q=({first:e,last:t})=>{for(let n=e;n;){let s=n===t?null:n.nextSibling;n.parentNode?.removeChild(n),n=s}},yt=({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}},_e=(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},Le=(e,t,n,s,r)=>{let o=document.createComment(e),i=document.createComment(`/${e}`),c=document.createDocumentFragment();c.append(o,i);let l={};Object.entries(t.attrs).forEach(([d,m])=>{if(!(d===le||De.has(d)||d.startsWith("@")))if(d.startsWith(":")){let g=Ne(d.slice(1));l[g]=m||g}else l[Ne(d)]=JSON.stringify(m)});let p=null,f=null,E=null;return s.effect(()=>{let d=_(e,n),m=d instanceof F?d:null;if(m===f||(E?.dispose(),E=null,p?.destroy(),p=null,f=m,!m))return;let g=new F({template:m.template,scripts:m.scripts,styles:m.styles,modules:m.modules,filename:m.filename}),x=ne(()=>Object.fromEntries(Object.entries(l).map(([u,h])=>[u,_(h,n)]))),O=document.createDocumentFragment();(r?g.renderShadow(x):g.render(x)).mount(O),i.parentNode.insertBefore(O,i);let a=B(n);Object.entries(l).forEach(([u,h])=>{a.effect(()=>{g.data[u]=_(h,n)})}),E=a,p=g}),s.onDispose(()=>{E?.dispose(),p?.destroy()}),c},Et=(e,t)=>{let n=()=>{let s=_(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)}})},Y=e=>typeof e=="string"?e.split(/\s+/).filter(Boolean):Array.isArray(e)?e.flatMap(Y):e!==null&&typeof e=="object"?Object.entries(e).flatMap(([t,n])=>n?Y(t):[]):[],ce=(e,t,n,s)=>{let r=e.attrs[":with"],o=r!==void 0?Et(r,t):t,i=_e(o,e.tag);if(i)return Le(i,e,o,n,s);let c=document.createElement(e.tag);if(c instanceof HTMLUnknownElement||e.tag.includes("-")){let d=!1;n.effect(()=>{if(d)return;let m=_e(o,e.tag);if(!m)return;d=!0;let g=Le(m,e,o,n,s),x=ie(g);n.onDispose(()=>Q(x)),c.replaceWith(g)})}Object.entries(e.attrs).forEach(([d,m])=>{d.startsWith("@")?gt(c,d,m,o):De.has(d)||c.setAttribute(d,m)});let l=e.attrs[":attrs"];if(l!==void 0){let d=[];n.effect(()=>{d.forEach(g=>c.removeAttribute(g));let m=_(l,o);d=m&&typeof m=="object"?Object.keys(m):[],d.forEach(g=>{let x=m[g];x!=null&&x!==!1&&c.setAttribute(g,String(x))})})}let p=e.attrs[":class"];if(p!==void 0){let d=new Set(Y(e.attrs.class??"")),m=[];n.effect(()=>{let g=Y(_(p,o));m.forEach(x=>{!g.includes(x)&&!d.has(x)&&c.classList.remove(x)}),c.classList.add(...g),m=g})}let f=e.attrs[":text"],E=e.attrs[":html"];return f!==void 0?n.effect(()=>{c.textContent=String(_(f,o)??"")}):E!==void 0?n.effect(()=>{c.innerHTML=he(String(_(E,o)??""))}):c.appendChild(ae(e.children,o,n,s)),c},bt=(e,t,n,s)=>{let r=document.createComment("if"),o=document.createDocumentFragment();o.appendChild(r);let i=null,c=null,l=null;return n.effect(()=>{let p=e.find(E=>E.expr===void 0||_(E.expr,t))??null;if(p===c||(l?.dispose(),i&&Q(i),i=null,c=p,!p))return;l=B(t);let f=ce(p.node,t,l,s);i=ie(f),r.parentNode.insertBefore(f,r.nextSibling)}),o},H=(e,t,n)=>{Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})},St=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},wt=(e,t,n,s)=>{let r=e.attrs[":each"].match(mt);if(!r)return document.createComment(`invalid :each expression "${e.attrs[":each"]}"`);let[,o,i,c]=r,l=e.attrs[":key"],{[":each"]:p,[":key"]:f,...E}=e.attrs,d={...e,attrs:E},m=document.createComment("each"),g=document.createDocumentFragment();g.appendChild(m),(":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 x=[],O=!1;return n.effect(()=>{let a=_(c,t),u=Array.isArray(a)?a.map((b,w)=>[w,b]):St(a)?Object.entries(a):[],h=new Map;x.forEach(b=>{let w=h.get(b.key);w?w.push(b):h.set(b.key,[b])});let S=new Set,T=[],R=u.map(([b,w],N)=>{let $=Object.create(t);H($,o,w),i&&H($,i,b),H($,"$index",N);let P=l!==void 0?_(l,$):b;S.has(P)&&!O&&(O=!0,console.warn(`jq79: duplicate :key in :each "${e.attrs[":each"]}"; duplicates pair up by position`)),S.add(P);let L=h.get(P)?.shift();if(L&&Object.is(L.item,w))return L.scope.$index!==N&&T.push(L),H(L.scope,"$index",N),i&&H(L.scope,i,b),L;L&&(L.fx.dispose(),Q(L.range));let ue=B(t),Ue=ie(ce(d,$,ue,s));return{key:P,item:w,scope:$,fx:ue,range:Ue}});h.forEach(b=>b.forEach(w=>{w.fx.dispose(),Q(w.range)}));let y=m;R.forEach(b=>{y.nextSibling!==b.range.first&&yt(b.range,y),y=b.range.last}),T.forEach(b=>ne(()=>b.fx.refresh())),x=R}),g},ae=(e,t,n,s=!1)=>{let r=document.createDocumentFragment(),o=0;for(;o<e.length;){let i=e[o];if(typeof i=="string"){let c=document.createTextNode(i);i.includes("{{")&&n.effect(()=>{c.textContent=ht(i,t)}),r.appendChild(c),o++;continue}if(":each"in i.attrs){r.appendChild(wt(i,t,n,s)),o++;continue}if(":if"in i.attrs){let c=[{expr:i.attrs[":if"],node:i}];o++;let l=f=>{let E=o;for(;E<e.length&&typeof e[E]=="string"&&!e[E].trim();)E++;let d=e[E];if(typeof d=="object"&&f in d.attrs)return o=E+1,d};for(let f=l(":elseif");f;f=l(":elseif"))c.push({expr:f.attrs[":elseif"],node:f});let p=l(":else");p&&c.push({node:p}),r.appendChild(bt(c,t,n,s));continue}r.appendChild(ce(i,t,n,s)),o++}return r},Rt=(e,t,n=!1)=>ae(e.template,t,B(t),n),$t=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),xt=/<([A-Za-z][\w-]*)((?:"[^"]*"|'[^']*'|[^>"'])*?)\/>/g,Tt=/(<script[\s\S]*?<\/script\s*>|<style[\s\S]*?<\/style\s*>)/gi,Ct=e=>e.split(Tt).map((t,n)=>n%2===1?t:t.replace(xt,(s,r,o)=>$t.has(r.toLowerCase())?s:`<${r}${o}></${r}>`)).join(""),le="data-jq79",Nt=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)},Pe=(e,t)=>{e.forEach(n=>{typeof n!="string"&&(n.attrs[le]=t,Pe(n.children,t))})},_t=(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}[${le}="${t}"]${i}`}).join(", "),ke=(e,t)=>{Array.from(e).forEach(n=>{n instanceof CSSStyleRule?n.selectorText=_t(n.selectorText,t):n instanceof CSSGroupingRule&&ke(n.cssRules,t)})},Lt=(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),ke(n.cssRules,t),Array.from(n.cssRules).map(s=>s.cssText).join(`
|
|
8
|
+
`)},oe=e=>{let n=new DOMParser().parseFromString(`<template>${Ct(e)}</template>`,"text/html").querySelector("template"),s=[],r=[],o=[];Array.from(n.content.children).forEach(c=>{let l={attrs:je(c),content:c.textContent??""};c.tagName==="SCRIPT"?s.push(l):c.tagName==="STYLE"?r.push(l):o.push(Me(c))}),r.forEach(c=>{"lang"in c.attrs&&console.warn(`jq79: <style lang="${c.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=c=>"scoped"in c.attrs&&!("lang"in c.attrs);if(r.some(i)){let c=Nt(e);Pe(o,c),r.forEach(l=>{i(l)&&(l.scoped=Lt(l.content,c))})}return{template:o,scripts:s,styles:r}},fe=e=>/\.html?([?#]|$)/.test(e)?F.fetch(e):import(e),Fe=(e,t)=>e?`
|
|
9
|
+
//# sourceURL=${e}?jq79-script=${t}`:"",Oe=e=>e.scoped??e.content,ee=new Map,Ot=e=>{let t=ee.get(e);if(!t){let n=document.createElement("style");n.textContent=e,document.head.appendChild(n),t={el:n,count:0},ee.set(e,t)}t.count++},At=e=>{let t=ee.get(e);t&&--t.count<=0&&(t.el.remove(),ee.delete(e))},Ie={$:I,$$:G,$create:K,$reactive:q},vt=(e,t,n,s={},r=fe,o={})=>{let i={...Ie,...s},c=new Proxy(t,{has:(p,f)=>f!=="$__effect"&&f!=="$__import"&&(Reflect.has(p,f)||!(f in globalThis)&&!(f in i))});new Function("$scope","$__effect","$__import",...Object.keys(i),`return (async () => { with ($scope) { ${e} } })()${Fe(o.filename,o.index??0)}`)(c,n,r,...Object.values(i)).catch(p=>console.error("jq79: error in :setup script",p))},Ae=(e,t)=>{t?.forEach(({name:n,default:s})=>{e[n]===void 0&&(e[n]=s===void 0?void 0:_(s,e))})},jt=e=>e&&e.default!==void 0?e.default:e,Mt=(e,t,n,s={},r=fe,o={})=>{let i={...Ie,...s},c={},l=new Function("$__exports","$__default","$__import",...Object.keys(i),`return (async () => { "use strict";
|
|
10
10
|
${e}
|
|
11
|
-
;$__exports.done = true })()${
|
|
11
|
+
;$__exports.done = true })()${Fe(o.filename,o.index??0)}`)(c,jt,r,...Object.values(i)),p=d=>console.error("jq79: error in factory script",d),f=!1,E=()=>{if(f)return;f=!0;let d=c.default;if(typeof d!="function")return;let m=g=>{g&&typeof g=="object"&&Object.assign(t,g)};try{let g=d(t,{$data:t,$props:t,$effect:n,...s});g instanceof Promise?g.then(m).catch(p):m(g)}catch(g){p(g)}};l.then(E,p),c.done&&E()},Dt="__JQ79_HMR_ENABLED__",Pt="__JQ79_HMR__",k=null,kt=e=>{if(!k||!e.filename)return;let t=k.get(e.filename);t||k.set(e.filename,t=new Set),t.add(new WeakRef(e))},ve=e=>{try{return new URL(e,document.baseURI).pathname}catch{return e}},We=(e,t)=>{if(!k)return 0;let n=ve(e),s=oe(t),r=0;for(let[o,i]of k)if(ve(o)===n){for(let c of i){let l=c.deref();if(!l){i.delete(c);continue}l.hotReplace(s)&&r++}i.size||k.delete(o)}return r},Be=()=>{k??(k=new Map),globalThis[Pt]={update:We}},F=class e{constructor(t,n={}){C(this,"template");C(this,"scripts");C(this,"styles");C(this,"modules");C(this,"filename");C(this,"data",null);C(this,"fx",null);C(this,"content",null);C(this,"startMarker",null);C(this,"endMarker",null);C(this,"styleEls",[]);C(this,"ownsSharedStyles",!1);C(this,"useShadow",!1);C(this,"mountRoot",null);C(this,"resolveMounted",null);C(this,"emitListeners",new Map);let s=typeof t=="string"?oe(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),kt(this)}hotReplace(t){let n=typeof t=="string"?oe(t):t,s=this.startMarker,r=!!(s&&this.content),o=r&&s.isConnected,i=o?s.parentNode:null,c=o?this.endMarker.nextSibling:null,l={...this.data},p=this.useShadow;return r&&this.destroy(),this.template=n.template,this.scripts=n.scripts,this.styles=n.styles,!r||(this.renderWith(l,p),!i)?!1:(p&&this.styleEls.forEach(f=>i.insertBefore(f,c)),i.insertBefore(this.content,c),this.mountRoot=i,this.resolveMounted?.(),!0)}static async fetch(t){let n=await fetch(t);if(!n.ok)throw new Error(`failed to fetch component from ${t}: ${n.status}`);return new e(await n.text(),{filename:t})}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=q({...t}),r=B(s);this.data=s,this.fx=r,this.useShadow=n,this.startMarker=document.createComment("jq79"),this.endMarker=document.createComment("/jq79");let o=this.startMarker,i=(a,u)=>{let h=new CustomEvent(a,{detail:u,bubbles:!0,composed:!0}),S=o.dispatchEvent(h);return o===this.startMarker&&this.emitListeners.get(a)?.forEach(T=>T(h,u)),S},c,l=new Promise(a=>{c=a});this.resolveMounted=c;let p=()=>l,f=this.endMarker,E=a=>{let u=[];for(let h=o.nextSibling;h&&h!==f;h=h.nextSibling)h instanceof Element&&(h.matches(a)&&u.push(h),u.push(...Array.from(h.querySelectorAll(a))));return u},d=a=>E(a)[0]??null,m=this.modules,g=a=>m&&a in m?Promise.resolve(m[a]):fe(a),x=a=>`await $mounted();${a}`;this.scripts.forEach((a,u)=>{let h={$emit:i,$mounted:p,$self:d,$$self:E},S={filename:this.filename,index:u},T=Te(a.content);if(T!==null){Ae(s,xe(a.content));let w=":mounted"in a.attrs?x(T):T;Mt(w,s,r.effect,h,g,S);return}let{vars:R,code:y}=se(a.content);Ae(s,re(a.attrs[":setup"])),R.forEach(w=>{w in s||(s[w]=void 0)});let b=":mounted"in a.attrs?x(y):y;vt(b,s,r.effect,h,g,S)});let O=document.createDocumentFragment();return O.append(this.startMarker,ae(this.template,s,r,n),this.endMarker),this.content=O,n?this.styleEls=this.styles.map(a=>{let u=document.createElement("style");return u.textContent=a.content,u}):(this.styles.forEach(a=>Ot(Oe(a))),this.ownsSharedStyles=!0),this}mount(t,n){let s=typeof t=="string"?I(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"?I(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=>At(Oe(t))),this.ownsSharedStyles=!1),this.content=null,this.startMarker=null,this.endMarker=null,this.data=null,this.resolveMounted=null,this}},Ft=e=>new F(e);typeof globalThis<"u"&&globalThis[Dt]&&Be();0&&(module.exports={$,$$,$create,$reactive,Component79,enableHotReload,hotUpdate,parseComponent,renderComponent});
|
|
12
12
|
//# sourceMappingURL=jq79.cjs.map
|