jq79 0.3.25 → 0.3.27
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 +9 -9
- package/dist/jq79.cjs.map +1 -1
- package/dist/jq79.d.ts +1 -1
- package/dist/jq79.global.js +9 -9
- package/dist/jq79.global.js.map +1 -1
- package/dist/jq79.js +9 -9
- package/dist/jq79.js.map +1 -1
- package/package.json +1 -1
- package/src/jq79.ts +26 -18
package/dist/jq79.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var j=Object.defineProperty;var
|
|
2
|
-
`,
|
|
3
|
-
`){let o=
|
|
4
|
-
`||
|
|
5
|
-
`||
|
|
6
|
-
`)},
|
|
7
|
-
//# sourceURL=${
|
|
8
|
-
${
|
|
9
|
-
;$__exports.done = true })()${
|
|
1
|
+
var j=Object.defineProperty;var $e=Object.getOwnPropertyDescriptor;var Re=Object.getOwnPropertyNames;var we=Object.prototype.hasOwnProperty;var xe=(e,t,n)=>t in e?j(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Te=(e,t)=>{for(var n in t)j(e,n,{get:t[n],enumerable:!0})},Ce=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Re(t))!we.call(e,r)&&r!==n&&j(e,r,{get:()=>t[r],enumerable:!(s=$e(t,r))||s.enumerable});return e};var Le=e=>Ce(j({},"__esModule",{value:!0}),e);var $=(e,t,n)=>xe(e,typeof t!="symbol"?t+"":t,n);var it={};Te(it,{$:()=>N,$$:()=>M,$create:()=>D,$reactive:()=>O,Component79:()=>L,parseComponent:()=>ot,renderComponent:()=>ze});module.exports=Le(it);function N(e,t){return typeof e=="string"?document.querySelector(e):e.querySelector(t)}function M(e,t){return Array.from(typeof e=="string"?document.querySelectorAll(e):e.querySelectorAll(t))}var D=(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"]),X={a:new Set(["href","title"]),img:new Set(["src","alt"]),"*":new Set(["class"])},Ne=new Set(["http:","https:","mailto:"]);function _e(e){try{let t=new URL(e,"https://example.com");return Ne.has(t.protocol)}catch{return!1}}function J(e,t){for(let n of Array.from(e.childNodes))if(n.nodeType===Node.ELEMENT_NODE){let s=Ae(n);s&&t.appendChild(s)}else n.nodeType===Node.TEXT_NODE&&t.appendChild(n.cloneNode())}function Ae(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=X[t]?.has(r),c=X["*"]?.has(r);!o&&!c||(r==="href"||r==="src")&&!_e(s.value)||n.setAttribute(r,s.value)}return t==="a"&&n.setAttribute("rel","noopener noreferrer"),J(e,n),n}function Y(e){let t=new DOMParser().parseFromString(e,"text/html"),n=document.createElement("div");return J(t.body,n),n.innerHTML}var Oe=(e,t)=>t.split(".").reduce((n,s)=>n?.[s],e),Q=e=>{if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},ee=(e,t,n)=>{Object.entries(e).forEach(([s,r])=>{let o=t?`${t}.${s}`:s;r&&typeof r=="object"&&Q(r)?ee(r,o,n):n(o,r)})},je=(e,t)=>e===t||e.startsWith(`${t}.`)||t.startsWith(`${e}.`),q=Symbol("jq79.raw"),I=e=>{let t=e;for(;t!==null&&typeof t=="object"&&t[q];)t=t[q];return t},te=Symbol("jq79.store"),W=e=>e!==null&&typeof e=="object"&&e[te]===!0,_=[],ne=e=>{_.push(new Set);try{return e()}finally{_.pop()}},O=e=>{let t=new Map,n=new Set,s=new Set,r=new WeakMap,o=Object.create(null),c=(f,u,S=!1)=>{t.get(f)?.forEach(b=>b(u,f)),n.forEach(b=>b(f,u)),s.forEach(b=>{(S||Array.from(b.deps).some(m=>je(m,f)))&&b.run()})},i=f=>f!==null&&typeof f=="object"&&Q(f),a=(f,u)=>{let S=r.get(f);if(S)return S;let b=new Proxy(f,{get(m,h,E){if(h===q)return m;if(h===te)return u==="";if(typeof h!="string")return Reflect.get(m,h,E);if(u===""&&h in o)return o[h];let w=u?`${u}.${h}`:h;_[_.length-1]?.add(w);let y=Reflect.get(m,h,E);if(W(y))return y;let R=I(y);return i(R)?a(R,w):R},set(m,h,E,w){if(w!==b&&!Object.prototype.hasOwnProperty.call(m,h))return Reflect.set(m,h,E,w);let y=u?`${u}.${h}`:h,R=W(E)?E:I(E),C=!Object.prototype.hasOwnProperty.call(m,h);m[h]=R;let v=W(R)||!i(R)?R:a(R,y);return c(y,v,C),!0}});return r.set(f,b),b},g=a(I(e),""),l=(f,u,{immediate:S=!1}={})=>(t.has(f)||t.set(f,new Set),t.get(f).add(u),S&&u(Oe(g,f),f),()=>t.get(f)?.delete(u)),p=(f,{immediate:u=!1}={})=>(n.add(f),u&&ee(g,"",(S,b)=>f(S,b)),()=>n.delete(f)),d=f=>{let u={deps:new Set,run:()=>{let S=new Set;_.push(S);try{f()}finally{_.pop(),u.deps=S}}};return s.add(u),u.run(),()=>{s.delete(u)}};return o.$on=l,o.$onAny=p,o.$effect=d,g},A=e=>{let t=[];return{effect:n=>{t.push(e.$effect(n))},onDispose:n=>{t.push(n)},dispose:()=>{t.splice(0).forEach(n=>n())}}};var se=/(?:let|var|const)\s+([A-Za-z_$][\w$]*)/y,re=/\$:\s*/y,k=/import(?=\s*\()/y,oe=/\$:\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},P=(e,t)=>{let n=e.indexOf(`
|
|
2
|
+
`,t);return n===-1?e.length:n},F=(e,t)=>{let n=e.indexOf("*/",t+2);return n===-1?e.length:n+2},Me=(e,t)=>{let n=t;for(;n<e.length;){if(/\s/.test(e[n])){n++;continue}if(e[n]==="/"&&e[n+1]==="/"){n=P(e,n);continue}if(e[n]==="/"&&e[n+1]==="*"){n=F(e,n);continue}break}return n},De=/^(\?\.|\?\?|&&|\|\||\*\*|[.,+\-*/%&|^<>=?:([])/,ke=(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=P(e,s);continue}if(r==="/"&&e[s+1]==="*"){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===`
|
|
3
|
+
`){let o=Me(e,s+1);if(o>=e.length||!De.test(e.slice(o,o+2)))return s;s=o;continue}}s++}return e.length},ae=e=>{let t=[],n="",s=0,r=0,o=!0;for(;s<e.length;){let c=e[s],i=e[s+1];if(c==="'"||c==='"'||c==="`"){let a=U(e,s);n+=e.slice(s,a),s=a,o=!1;continue}if(c==="/"&&(i==="/"||i==="*")){let a=i==="/"?P(e,s):F(e,s);n+=e.slice(s,a),s=a;continue}if(c==="i"&&(s===0||!/[\w$.]/.test(e[s-1]))&&(k.lastIndex=s,k.test(e))){n+="$__import",s+=6,o=!1;continue}if(r===0&&o){se.lastIndex=s;let a=se.exec(e);if(a){t.push(a[1]),n+=a[1],s+=a[0].length,o=!1;continue}re.lastIndex=s;let g=re.exec(e);if(g){oe.lastIndex=s;let l=oe.exec(e);l&&t.push(l[1]);let p=s+g[0].length,d=ke(e,p);n+=`$__effect(() => { ${e.slice(p,d)} });`,s=d;continue}}"([{".includes(c)?r++:")]}".includes(c)&&(r=Math.max(0,r-1)),c===`
|
|
4
|
+
`||c===";"||c==="}"?o=!0:/\s/.test(c)||(o=!1),n+=c,s++}return{vars:t,code:n}},ie=/export\s+default(?![\w$])/y,ce=/import\s*(?:([\w$\s,{}*]+?)\s*from\s*)?(["'])([^"'\n]+)\2/y,Pe=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 c=e.slice(s,r).trim();c&&t.push(c),s=r+1}}return t},Fe=(e,t,n)=>{let s=`await $__import(${JSON.stringify(t)})`;if(e===void 0)return s;let r=Pe(e),o=[],c=s;if(r.length>1){let i=`$__mod${n}`;o.push(`${i} = ${s}`),c=i}for(let i of r)i.startsWith("{")?o.push(`${i.replace(/\s+as\s+/g,": ")} = ${c}`):i.startsWith("*")?o.push(`${i.replace(/^\*\s*as\s+/,"")} = ${c}`):o.push(`${i} = $__default(${c})`);return`const ${o.join(", ")}`},le=e=>{let t="",n=0,s=0,r=!0,o=!1,c=0;for(;n<e.length;){let i=e[n],a=e[n+1],g=n===0||!/[\w$.]/.test(e[n-1]);if(i==="'"||i==='"'||i==="`"){let l=U(e,n);t+=e.slice(n,l),n=l,r=!1;continue}if(i==="/"&&(a==="/"||a==="*")){let l=a==="/"?P(e,n):F(e,n);t+=e.slice(n,l),n=l;continue}if(i==="i"&&g){if(k.lastIndex=n,k.test(e)){t+="$__import",n+=6,r=!1;continue}if(s===0&&r){ce.lastIndex=n;let l=ce.exec(e);if(l){t+=Fe(l[1],l[3],c++),n+=l[0].length,r=!1;continue}}}if(i==="e"&&g&&s===0&&r){ie.lastIndex=n;let l=ie.exec(e);if(l){o=!0,t+="$__exports.default =",n+=l[0].length,r=!1;continue}}"([{".includes(i)?s++:")]}".includes(i)&&(s=Math.max(0,s-1)),i===`
|
|
5
|
+
`||i===";"||i==="}"?r=!0:/\s/.test(i)||(r=!1),t+=i,n++}return o?t:null};var me=e=>Object.fromEntries(Array.from(e.attributes).map(t=>[t.name,t.value])),he=e=>({tag:e.tagName.toLowerCase(),attrs:me(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?[he(t)]:[]})}),T=(e,t,n)=>{try{return new Function("$scope",...Object.keys(n??{}),`with ($scope) { return (${e}); }`)(t,...Object.values(n??{}))}catch{return}},Be=(e,t)=>e.replace(/{{\s*([\s\S]+?)\s*}}/g,(n,s)=>T(s,t)??""),ge=new Set([":attrs",":if",":elseif",":else",":each",":key",":with",":text",":html"]),Ie=/^\s*(\w+)\s+in\s+([\s\S]+)$/,We=(e,t,n,s)=>{let[r,...o]=t.slice(1).split("."),c=new Set(o);e.addEventListener(r,i=>{if(c.has("self")&&i.target!==e)return;c.has("prevent")&&i.preventDefault(),c.has("stop")&&i.stopPropagation();let a=T(n,s,{$event:i});typeof a=="function"&&a.call(e,i)},{once:c.has("once"),capture:c.has("capture")})},fe=e=>e.replace(/-(\w)/g,(t,n)=>n.toUpperCase()),ue=(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},de=(e,t,n,s,r)=>{let o=document.createComment(e),c=document.createDocumentFragment();c.appendChild(o);let i={};Object.entries(t.attrs).forEach(([p,d])=>{if(!(p===K||ge.has(p)||p.startsWith("@")))if(p.startsWith(":")){let f=fe(p.slice(1));i[f]=d||f}else i[fe(p)]=JSON.stringify(d)});let a=null,g=null,l=null;return s.effect(()=>{let p=T(e,n),d=p instanceof L?p:null;if(d===g||(l?.dispose(),l=null,a?.destroy(),a=null,g=d,!d))return;let f=new L({template:d.template,scripts:d.scripts,styles:d.styles,modules:d.modules,filename:d.filename}),u=ne(()=>Object.fromEntries(Object.entries(i).map(([m,h])=>[m,T(h,n)]))),S=document.createDocumentFragment();(r?f.renderShadow(u):f.render(u)).mount(S),o.parentNode.insertBefore(S,o.nextSibling);let b=A(n);Object.entries(i).forEach(([m,h])=>{b.effect(()=>{f.data[m]=T(h,n)})}),l=b,a=f}),s.onDispose(()=>{l?.dispose(),a?.destroy()}),c},qe=(e,t)=>{let n=()=>{let s=T(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 c=n();return c!==null&&Reflect.has(c,r)?(c[r]=o,!0):Reflect.set(s,r,o)}})},z=(e,t,n,s)=>{let r=e.attrs[":with"],o=r!==void 0?qe(r,t):t,c=ue(o,e.tag);if(c)return de(c,e,o,n,s);let i=document.createElement(e.tag);if(i instanceof HTMLUnknownElement||e.tag.includes("-")){let p=!1;n.effect(()=>{if(p)return;let d=ue(o,e.tag);d&&(p=!0,i.replaceWith(de(d,e,o,n,s)))})}Object.entries(e.attrs).forEach(([p,d])=>{p.startsWith("@")?We(i,p,d,o):ge.has(p)||i.setAttribute(p,d)});let a=e.attrs[":attrs"];if(a!==void 0){let p=[];n.effect(()=>{p.forEach(f=>i.removeAttribute(f));let d=T(a,o);p=d&&typeof d=="object"?Object.keys(d):[],p.forEach(f=>{let u=d[f];u!=null&&u!==!1&&i.setAttribute(f,String(u))})})}let g=e.attrs[":text"],l=e.attrs[":html"];return g!==void 0?n.effect(()=>{i.textContent=String(T(g,o)??"")}):l!==void 0?n.effect(()=>{i.innerHTML=Y(String(T(l,o)??""))}):i.appendChild(G(e.children,o,n,s)),i},Ue=(e,t,n,s)=>{let r=document.createComment("if"),o=document.createDocumentFragment();o.appendChild(r);let c=null,i=null,a=null;return n.effect(()=>{let g=e.find(l=>l.expr===void 0||T(l.expr,t))??null;g!==i&&(a?.dispose(),c&&c.parentNode?.removeChild(c),c=null,i=g,g&&(a=A(t),c=z(g.node,t,a,s),r.parentNode.insertBefore(c,r.nextSibling)))}),o},H=(e,t,n)=>{Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})},He=(e,t,n,s)=>{let r=e.attrs[":each"].match(Ie);if(!r)return document.createComment(`invalid :each expression "${e.attrs[":each"]}"`);let[,o,c]=r,i=e.attrs[":key"],{[":each"]:a,[":key"]:g,...l}=e.attrs,p={...e,attrs:l},d=document.createComment("each"),f=document.createDocumentFragment();f.appendChild(d);let u=[];return n.effect(()=>{let S=T(c,t),b=Array.isArray(S)?S:[],m=new Map(u.map(y=>[y.key,y])),h=b.map((y,R)=>{let C=Object.create(t);H(C,o,y),H(C,"$index",R);let v=i!==void 0?T(i,C):R,x=m.get(v);if(x&&Object.is(x.item,y))return H(x.scope,"$index",R),x;x?.fx.dispose(),x?.node.parentNode?.removeChild(x.node);let Z=A(t);return{key:v,item:y,scope:C,fx:Z,node:z(p,C,Z,s)}}),E=new Set(h.map(y=>y.key));u.forEach(y=>{E.has(y.key)||(y.fx.dispose(),y.node.parentNode?.removeChild(y.node))});let w=d;h.forEach(y=>{w.nextSibling!==y.node&&d.parentNode.insertBefore(y.node,w.nextSibling),w=y.node}),u=h}),f},G=(e,t,n,s=!1)=>{let r=document.createDocumentFragment(),o=0;for(;o<e.length;){let c=e[o];if(typeof c=="string"){let i=document.createTextNode(c);c.includes("{{")&&n.effect(()=>{i.textContent=Be(c,t)}),r.appendChild(i),o++;continue}if(":each"in c.attrs){r.appendChild(He(c,t,n,s)),o++;continue}if(":if"in c.attrs){let i=[{expr:c.attrs[":if"],node:c}];o++;let a=l=>{let p=o;for(;p<e.length&&typeof e[p]=="string"&&!e[p].trim();)p++;let d=e[p];if(typeof d=="object"&&l in d.attrs)return o=p+1,d};for(let l=a(":elseif");l;l=a(":elseif"))i.push({expr:l.attrs[":elseif"],node:l});let g=a(":else");g&&i.push({node:g}),r.appendChild(Ue(i,t,n,s));continue}r.appendChild(z(c,t,n,s)),o++}return r},ze=(e,t,n=!1)=>G(e.template,t,A(t),n),Ge=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Ke=/<([A-Za-z][\w-]*)((?:"[^"]*"|'[^']*'|[^>"'])*?)\/>/g,Ve=/(<script[\s\S]*?<\/script\s*>|<style[\s\S]*?<\/style\s*>)/gi,Ze=e=>e.split(Ve).map((t,n)=>n%2===1?t:t.replace(Ke,(s,r,o)=>Ge.has(r.toLowerCase())?s:`<${r}${o}></${r}>`)).join(""),K="data-jq79",Xe=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)},ye=(e,t)=>{e.forEach(n=>{typeof n!="string"&&(n.attrs[K]=t,ye(n.children,t))})},Je=(e,t)=>e.split(",").map(n=>{let s=n.trim(),r=s.indexOf("::"),o=r===-1?s:s.slice(0,r),c=r===-1?"":s.slice(r);return`${o}[${K}="${t}"]${c}`}).join(", "),Ee=(e,t)=>{Array.from(e).forEach(n=>{n instanceof CSSStyleRule?n.selectorText=Je(n.selectorText,t):n instanceof CSSGroupingRule&&Ee(n.cssRules,t)})},Ye=(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),Ee(n.cssRules,t),Array.from(n.cssRules).map(s=>s.cssText).join(`
|
|
6
|
+
`)},Qe=e=>{let n=new DOMParser().parseFromString(`<template>${Ze(e)}</template>`,"text/html").querySelector("template"),s=[],r=[],o=[];Array.from(n.content.children).forEach(i=>{let a={attrs:me(i),content:i.textContent??""};i.tagName==="SCRIPT"?s.push(a):i.tagName==="STYLE"?r.push(a):o.push(he(i))}),r.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 c=i=>"scoped"in i.attrs&&!("lang"in i.attrs);if(r.some(c)){let i=Xe(e);ye(o,i),r.forEach(a=>{c(a)&&(a.scoped=Ye(a.content,i))})}return{template:o,scripts:s,styles:r}},V=e=>/\.html?([?#]|$)/.test(e)?L.fetch(e):import(e),Se=(e,t)=>e?`
|
|
7
|
+
//# sourceURL=${e}?jq79-script=${t}`:"",pe=e=>e.scoped??e.content,B=new Map,et=e=>{let t=B.get(e);if(!t){let n=document.createElement("style");n.textContent=e,document.head.appendChild(n),t={el:n,count:0},B.set(e,t)}t.count++},tt=e=>{let t=B.get(e);t&&--t.count<=0&&(t.el.remove(),B.delete(e))},be={$:N,$$:M,$create:D,$reactive:O},nt=(e,t,n,s={},r=V,o={})=>{let c={...be,...s},i=new Proxy(t,{has:(g,l)=>l!=="$__effect"&&l!=="$__import"&&(Reflect.has(g,l)||!(l in globalThis)&&!(l in c))});new Function("$scope","$__effect","$__import",...Object.keys(c),`return (async () => { with ($scope) { ${e} } })()${Se(o.filename,o.index??0)}`)(i,n,r,...Object.values(c)).catch(g=>console.error("jq79: error in :setup script",g))},st=e=>e&&e.default!==void 0?e.default:e,rt=(e,t,n,s={},r=V,o={})=>{let c={...be,...s},i={},a=new Function("$__exports","$__default","$__import",...Object.keys(c),`return (async () => { "use strict";
|
|
8
|
+
${e}
|
|
9
|
+
;$__exports.done = true })()${Se(o.filename,o.index??0)}`)(i,st,r,...Object.values(c)),g=d=>console.error("jq79: error in factory script",d),l=!1,p=()=>{if(l)return;l=!0;let d=i.default;if(typeof d!="function")return;let f=u=>{u&&typeof u=="object"&&Object.assign(t,u)};try{let u=d({$data:t,$effect:n,...s});u instanceof Promise?u.then(f).catch(g):f(u)}catch(u){g(u)}};a.then(p,g),i.done&&p()},L=class e{constructor(t,n={}){$(this,"template");$(this,"scripts");$(this,"styles");$(this,"modules");$(this,"filename");$(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"?Qe(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)}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=O({...t}),r=A(s);this.data=s,this.fx=r,this.useShadow=n,this.startMarker=document.createComment("jq79"),this.endMarker=document.createComment("/jq79");let o=this.startMarker,c=(m,h)=>{let E=new CustomEvent(m,{detail:h,bubbles:!0,composed:!0}),w=o.dispatchEvent(E);return o===this.startMarker&&this.emitListeners.get(m)?.forEach(y=>y(E,h)),w},i,a=new Promise(m=>{i=m});this.resolveMounted=i;let g=()=>a,l=this.endMarker,p=m=>{let h=[];for(let E=o.nextSibling;E&&E!==l;E=E.nextSibling)E instanceof Element&&(E.matches(m)&&h.push(E),h.push(...Array.from(E.querySelectorAll(m))));return h},d=m=>p(m)[0]??null,f=this.modules,u=m=>f&&m in f?Promise.resolve(f[m]):V(m),S=m=>`await $mounted();${m}`;this.scripts.forEach((m,h)=>{let E={$emit:c,$mounted:g,$self:d,$$self:p},w={filename:this.filename,index:h},y=le(m.content);if(y!==null){let x=":mounted"in m.attrs?S(y):y;rt(x,s,r.effect,E,u,w);return}let{vars:R,code:C}=ae(m.content);R.forEach(x=>{x in s||(s[x]=void 0)});let v=":mounted"in m.attrs?S(C):C;nt(v,s,r.effect,E,u,w)});let b=document.createDocumentFragment();return b.append(this.startMarker,G(this.template,s,r,n),this.endMarker),this.content=b,n?this.styleEls=this.styles.map(m=>{let h=document.createElement("style");return h.textContent=m.content,h}):(this.styles.forEach(m=>et(pe(m))),this.ownsSharedStyles=!0),this}mount(t,n){let s=typeof t=="string"?N(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"?N(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.styleEls.forEach(t=>t.parentNode?.removeChild(t)),this.styleEls=[],this.ownsSharedStyles&&(this.styles.forEach(t=>tt(pe(t))),this.ownsSharedStyles=!1),this.content=null,this.startMarker=null,this.endMarker=null,this.data=null,this.resolveMounted=null,this}},ot=e=>new L(e);0&&(module.exports={$,$$,$create,$reactive,Component79,parseComponent,renderComponent});
|
|
10
10
|
//# sourceMappingURL=jq79.cjs.map
|