jq79 0.4.12 → 0.4.13
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/README.md +1 -1
- package/dev/vite.ts +47 -0
- package/dist/jq79.cjs +13 -13
- package/dist/jq79.cjs.map +1 -1
- package/dist/jq79.d.ts +6 -0
- 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/vite.cjs +39 -0
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.js +39 -0
- package/dist/vite.js.map +1 -1
- package/package.json +1 -1
- package/src/jq79.ts +250 -13
package/README.md
CHANGED
|
@@ -108,7 +108,7 @@ When the fetch resolves, the assignments to `firstName`/`lastName` re-run the `$
|
|
|
108
108
|
## Documentation
|
|
109
109
|
|
|
110
110
|
- [Tutorial](https://jgermade.github.io/jq79/tutorial/) — learn it by doing, in the browser.
|
|
111
|
-
- [Components](docs/components.md) — lifecycle (`mount`, `mountShadow`, `detach`, `destroy`), instance events (`on`/`off`), `<style scoped>`, loading remote components with `Component79.fetch`.
|
|
111
|
+
- [Components](docs/components.md) — lifecycle (`mount`, `mountShadow`, `detach`, `destroy`), instance events (`on`/`off`), `<style scoped>`, several components in one file with `<template name>`, loading remote components with `Component79.fetch`.
|
|
112
112
|
- [Template syntax](docs/template-syntax.md) — `{{ }}` interpolation, `:attrs`, `:text`/`:html`, `:if`/`:elseif`/`:else`, `:each`/`:key`, `:with`, `@event` listeners and modifiers, nested components.
|
|
113
113
|
- [Setup scripts](docs/setup-scripts.md) — `<script :setup>` reactive scripts, `$:` declarations, `$emit`, `await $mounted()`, `$self`/`$$self`, and `export default` factory scripts (plain-JS alternative).
|
|
114
114
|
- [Reactive data](docs/reactive-data.md) — the standalone `$reactive` store: `$on`, `$onAny`, `$effect`.
|
package/dev/vite.ts
CHANGED
|
@@ -105,6 +105,44 @@ const hoistableImports = (source: string, include: RegExp): string[] => {
|
|
|
105
105
|
return [...specifiers]
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
// any start or end tag, quote-aware so a ">" inside an attribute value doesn't
|
|
109
|
+
// end it early
|
|
110
|
+
const TAG_RE = /<(\/?)([A-Za-z][\w-]*)((?:"[^"]*"|'[^']*'|[^>"'])*)>/g
|
|
111
|
+
const NAME_ATTR_RE = /\bname\s*=\s*(?:"([^"]*)"|'([^']*)')/i
|
|
112
|
+
const COMPONENT_NAME_RE = /^[A-Z][A-Za-z0-9]*$/
|
|
113
|
+
const VOID_ELEMENTS = new Set([
|
|
114
|
+
"area", "base", "br", "col", "embed", "hr", "img", "input",
|
|
115
|
+
"link", "meta", "param", "source", "track", "wbr",
|
|
116
|
+
])
|
|
117
|
+
|
|
118
|
+
// the components a file declares: its *top-level* <template name="…"> blocks,
|
|
119
|
+
// which the emitted module re-exports by name. Depth is tracked because only
|
|
120
|
+
// the top level declares - a <template> nested in the markup is a plain inert
|
|
121
|
+
// element the runtime leaves alone, and exporting it would name something that
|
|
122
|
+
// never exists. Script and style bodies are cut out first, so a "<" in JS or a
|
|
123
|
+
// selector can't be read as a tag
|
|
124
|
+
const declaredComponents = (source: string): string[] => {
|
|
125
|
+
const markup = source.replace(SCRIPT_BLOCK_RE, "").replace(STYLE_BLOCK_RE, "")
|
|
126
|
+
const names: string[] = []
|
|
127
|
+
let depth = 0
|
|
128
|
+
|
|
129
|
+
for (const [, closing, tag, attrs] of markup.matchAll(TAG_RE)) {
|
|
130
|
+
if (closing) {
|
|
131
|
+
depth = Math.max(0, depth - 1)
|
|
132
|
+
continue
|
|
133
|
+
}
|
|
134
|
+
const selfClosing = /\/\s*$/.test(attrs) || VOID_ELEMENTS.has(tag.toLowerCase())
|
|
135
|
+
if (depth === 0 && !selfClosing && tag.toLowerCase() === "template") {
|
|
136
|
+
const declared = attrs.match(NAME_ATTR_RE)
|
|
137
|
+
const name = declared?.[1] ?? declared?.[2]
|
|
138
|
+
// the runtime warns about the ones this skips (nameless, not PascalCase)
|
|
139
|
+
if (name && COMPONENT_NAME_RE.test(name)) names.push(name)
|
|
140
|
+
}
|
|
141
|
+
if (!selfClosing) depth++
|
|
142
|
+
}
|
|
143
|
+
return names
|
|
144
|
+
}
|
|
145
|
+
|
|
108
146
|
// a <style> block with its attribute string, so `lang` can be read and the
|
|
109
147
|
// content replaced. Attribute values are matched as quoted chunks so a ">"
|
|
110
148
|
// inside one doesn't end the tag early
|
|
@@ -156,6 +194,14 @@ const compileStyleBlocks = async (
|
|
|
156
194
|
// Component79, matching what runtime fetch resolves to); everything else as
|
|
157
195
|
// a namespace (matching native import()).
|
|
158
196
|
//
|
|
197
|
+
// A file's <template name="…"> components are re-exported by name, so the
|
|
198
|
+
// module shape is the one the file already has: default plus named. They read
|
|
199
|
+
// off the instance, which is where the runtime hangs them - so in dev they are
|
|
200
|
+
// bound to the *first* evaluation's definitions and a module that imports one
|
|
201
|
+
// by name keeps the pre-edit child until the page reloads. The file's own
|
|
202
|
+
// component patches in place, and its rendered children come from the reparse,
|
|
203
|
+
// so this only shows in a component imported by name from another file.
|
|
204
|
+
//
|
|
159
205
|
// In dev, `hot.data` carries the exported instance across updates: importers
|
|
160
206
|
// hold a reference to the *first* module evaluation's instance, so later
|
|
161
207
|
// evaluations patch that same instance in place instead of exporting a new one
|
|
@@ -204,6 +250,7 @@ if (import.meta.hot) {
|
|
|
204
250
|
}
|
|
205
251
|
|
|
206
252
|
export default component
|
|
253
|
+
${declaredComponents(source).map(name => `export const ${name} = component.${name}`).join("\n")}
|
|
207
254
|
`
|
|
208
255
|
}
|
|
209
256
|
|
package/dist/jq79.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
var X=Object.defineProperty;var
|
|
2
|
-
`,n);return
|
|
3
|
-
`)return
|
|
4
|
-
`){let
|
|
5
|
-
`||
|
|
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(
|
|
10
|
-
`)},
|
|
11
|
-
//# sourceURL=${
|
|
12
|
-
${
|
|
13
|
-
;$__exports.done = true })()${
|
|
1
|
+
var X=Object.defineProperty;var rt=Object.getOwnPropertyDescriptor;var it=Object.getOwnPropertyNames;var lt=Object.prototype.hasOwnProperty;var at=(e,n,t)=>n in e?X(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var ct=(e,n)=>{for(var t in n)X(e,t,{get:n[t],enumerable:!0})},ft=(e,n,t,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of it(n))!lt.call(e,o)&&o!==t&&X(e,o,{get:()=>n[o],enumerable:!(s=rt(n,o))||s.enumerable});return e};var ut=e=>ft(X({},"__esModule",{value:!0}),e);var N=(e,n,t)=>at(e,typeof n!="symbol"?n+"":n,t);var dn={};ct(dn,{$:()=>k,$$:()=>J,$create:()=>V,$reactive:()=>Z,C79:()=>D,Component79:()=>D,enableHotReload:()=>st,hotUpdate:()=>nt,parseComponent:()=>un,renderComponent:()=>Ht});module.exports=ut(dn);function k(e,n){return typeof e=="string"?document.querySelector(e):e.querySelector(n)}function J(e,n){return Array.from(typeof e=="string"?document.querySelectorAll(e):e.querySelectorAll(n))}var V=(e,n={})=>{let t=document.createElement(e);for(let[s,o]of Object.entries(n))if(s==="className")t.className=Array.isArray(o)?o.join(" "):o;else if(s==="textContent")t.textContent=o;else if(s==="children")for(let i of o)t.appendChild(i);else t.setAttribute(s,o);return t},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"]),Re={a:new Set(["href","title"]),img:new Set(["src","alt"]),"*":new Set(["class"])},pt=new Set(["http:","https:","mailto:"]);function ht(e){try{let n=new URL(e,"https://example.com");return pt.has(n.protocol)}catch{return!1}}var gt={"https:":"443","http:":"80"};function mt(e){let n=e.trim().toLowerCase().match(/^([a-z\d*][a-z\d.*-]*?)(?::(\d{1,5}|\*))?$/);if(!n)return null;let[,t,s]=n,o=t.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 Te=e=>{let n=(Array.isArray(e)?e:e.split(",")).map(mt).filter(t=>t!==null);return t=>{let s=t.hostname.toLowerCase(),o=t.port||gt[t.protocol]||"";return n.some(i=>i.host.test(s)&&(i.port===null||i.port===o))}};function yt(e,n,t,s){try{return!!e(new URL(n,document.baseURI),t,s)}catch{return!1}}var xe=512;function Ce(e,n,t,s){if(t>xe)throw new RangeError(`jq79: sanitizeHTML input nests deeper than ${xe} elements`);for(let o of Array.from(e.childNodes))if(o.nodeType===Node.ELEMENT_NODE){let i=Et(o,t,s);i&&n.appendChild(i)}else o.nodeType===Node.TEXT_NODE&&n.appendChild(o.cloneNode())}function Et(e,n,t){let s=e.tagName.toLowerCase();if(!dt.has(s))return null;let o=document.createElement(s);for(let i of Array.from(e.attributes)){let r=i.name.toLowerCase(),l=Re[s]?.has(r),c=Re["*"]?.has(r);!l&&!c||(r==="href"||r==="src")&&(!ht(i.value)||t&&!yt(t,i.value,s,r))||o.setAttribute(r,i.value)}return s==="a"&&o.setAttribute("rel","noopener noreferrer"),Ce(e,o,n+1,t),o}function Ae(e,n){let t=document.createElement("template");t.innerHTML=e;let s=document.createElement("div");return Ce(t.content,s,0,n?.allowUrl),s.innerHTML}var bt=(e,n)=>n.split(".").reduce((t,s)=>t?.[s],e),je=e=>{if(Array.isArray(e))return!0;let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null},_e=(e,n,t)=>{Object.entries(e).forEach(([s,o])=>{let i=n?`${n}.${s}`:s;o&&typeof o=="object"&&je(o)?_e(o,i,t):t(i,o)})},wt=(e,n)=>e===n||e.startsWith(`${n}.`)||n.startsWith(`${e}.`),ae=Symbol("jq79.raw"),Q=e=>{let n=e;for(;n!==null&&typeof n=="object"&&n[ae];)n=n[ae];return n},Ne=Symbol("jq79.store"),B=e=>e!==null&&typeof e=="object"&&e[Ne]===!0,q=[],z=e=>{q.push(new Set);try{return e()}finally{q.pop()}},Z=e=>{let n=new Map,t=new Set,s=new Set,o=new WeakMap,i=Object.create(null),r=(h,g,w=!1)=>{n.get(h)?.forEach(S=>S(g,h)),t.forEach(S=>S(h,g)),s.forEach(S=>{(w||Array.from(S.deps).some(v=>wt(v,h)))&&S.run()})},l=h=>h!==null&&typeof h=="object"&&je(h),c=new Map,d=(h,g)=>{let w=c.get(g);w?.store!==h&&(w?.unsubscribe(),c.set(g,{store:h,unsubscribe:h.$onAny((S,v)=>r(`${g}.${S}`,v))}))},p=h=>{c.get(h)?.unsubscribe(),c.delete(h)},m=(h,g)=>{let w=o.get(h);if(w)return w;let S=null,v=new Proxy(h,{has(a,f){return Reflect.has(a,f)||typeof f=="string"&&S?.has(f)===!0},get(a,f,u){if(f===ae)return a;if(f===Ne)return g==="";if(typeof f!="string")return Reflect.get(a,f,u);if(g===""&&f in i)return i[f];let E=g?`${g}.${f}`:f;q[q.length-1]?.add(E);let C=Reflect.get(a,f,u);if(B(C))return d(C,E),C;let R=Q(C);return l(R)?m(R,E):R},set(a,f,u,E){if(E!==v&&!Object.prototype.hasOwnProperty.call(a,f))return Reflect.set(a,f,u,E);let C=g?`${g}.${f}`:f,R=B(u)?u:Q(u),_=!Object.prototype.hasOwnProperty.call(a,f);if(!_&&Object.is(a[f],R)&&(R===null||typeof R!="object"))return!0;a[f]=R,S?.delete(f),B(R)?d(R,C):p(C);let x=B(R)||!l(R)?R:m(R,C);return r(C,x,_),!0},deleteProperty(a,f){if(typeof f!="string")return Reflect.deleteProperty(a,f);let u=Object.prototype.hasOwnProperty.call(a,f),E=Reflect.deleteProperty(a,f);if(E&&u){let C=g?`${g}.${f}`:f;(S??(S=new Set)).add(f),p(C),r(C,void 0)}return E}});return o.set(h,v),v},b=m(Q(e),"");Object.entries(Q(e)).forEach(([h,g])=>{B(g)&&d(g,h)});let T=(h,g,{immediate:w=!1}={})=>(n.has(h)||n.set(h,new Set),n.get(h).add(g),w&&g(bt(b,h),h),()=>n.get(h)?.delete(g)),A=(h,{immediate:g=!1}={})=>(t.add(h),g&&_e(b,"",(w,S)=>h(w,S)),()=>t.delete(h)),y=h=>{let g=!1,w=!1,S={deps:new Set,run:()=>{if(g){w=!0;return}g=!0;try{let v=0;do{w=!1;let a=new Set;q.push(a);try{h()}finally{q.pop(),S.deps=a}}while(w&&++v<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{g=!1}}};return s.add(S),S.run(),()=>{s.delete(S)}},$=()=>{c.forEach(({unsubscribe:h})=>h()),c.clear()};return i.$on=T,i.$onAny=A,i.$effect=y,i.$dispose=$,b},H=e=>{let n=[],t=[];return{effect:s=>{n.push(e.$effect(s)),t.push(s)},onDispose:s=>{n.push(s)},refresh:()=>{t.forEach(s=>s())},dispose:()=>{n.splice(0).forEach(s=>s()),t.length=0}}};var Oe=/(?:let|var|const)(?:\s+(?=[A-Za-z_$])|\s*(?=[{[]))/y,ve=/\$:\s*/y,ee=/import(?=\s*\()/y,Le=/\$:\s*([A-Za-z_$][\w$]*)\s*=(?!=)/y,U=(e,n)=>{let t=e[n],s=n+1;for(;s<e.length;){if(e[s]==="\\"){s+=2;continue}if(e[s]===t)return s+1;s++}return e.length},P=(e,n)=>{let t=e.indexOf(`
|
|
2
|
+
`,n);return t===-1?e.length:t},M=(e,n)=>{let t=e.indexOf("*/",n+2);return t===-1?e.length:t+2},Y=(e,n)=>{let t=n;for(;t<e.length;){if(/\s/.test(e[t])){t++;continue}if(e[t]==="/"&&e[t+1]==="/"){t=P(e,t);continue}if(e[t]==="/"&&e[t+1]==="*"){t=M(e,t);continue}break}return t},St=new Set(["return","typeof","case","in","instanceof","new","delete","void","do","else","yield","await"]),F=(e,n)=>{let t=n-1;for(;t>=0;){let o=e[t];if(/\s/.test(o)){t--;continue}if(o==="/"&&e[t-1]==="*"){let i=e.lastIndexOf("/*",t-2);if(i===-1)return!0;t=i-1;continue}break}if(t<0)return!0;let s=e[t];if(/[\w$]/.test(s)){let o=t;for(;o>0&&/[\w$]/.test(e[o-1]);)o--;return St.has(e.slice(o,t+1))}return(s==="+"||s==="-")&&e[t-1]===s?!1:!")]}\"'`.".includes(s)},I=(e,n)=>{let t=n+1,s=!1;for(;t<e.length;){let o=e[t];if(o==="\\"){t+=2;continue}if(o===`
|
|
3
|
+
`)return t;if(o==="[")s=!0;else if(o==="]")s=!1;else if(o==="/"&&!s){for(t++;t<e.length&&/[a-z]/i.test(e[t]);)t++;return t}t++}return e.length},$t=/^(\?\.|\?\?|&&|\|\||\*\*|[.,+\-*/%&|^<>=?:([])/,Rt=(e,n)=>{let t=n-1;for(;t>=0;){let s=e[t];if(/\s/.test(s)){t--;continue}if(s==="/"&&e[t-1]==="*"){let o=e.lastIndexOf("/*",t-2);if(o===-1)return"";t=o-1;continue}return s}return""},Pe=(e,n)=>{let t=0,s=n;for(;s<e.length;){let o=e[s];if(o==="'"||o==='"'||o==="`"){s=U(e,s);continue}if(o==="/"&&e[s+1]==="/"){s=P(e,s);continue}if(o==="/"&&e[s+1]==="*"){s=M(e,s);continue}if(o==="/"&&F(e,s)){s=I(e,s);continue}if("([{".includes(o))t++;else if(")]}".includes(o))t--;else{if(t<=0&&o===";")return s;if(t<=0&&o===`
|
|
4
|
+
`){let i=Y(e,s+1);if(!(i<e.length&&($t.test(e.slice(i,i+2))||[",","="].includes(Rt(e,s)))))return s;s=i;continue}}s++}return e.length},xt=e=>{let n=[],t=0,s=0,o=0,i=l=>{n.push({raw:e.slice(s,l),codeEnd:Math.max(0,o-s)}),s=l+1,o=s},r=0;for(;r<e.length;){let l=e[r];if(l==="'"||l==='"'||l==="`"){r=U(e,r),o=r;continue}if(l==="/"&&e[r+1]==="/"){r=P(e,r);continue}if(l==="/"&&e[r+1]==="*"){r=M(e,r);continue}if(l==="/"&&F(e,r)){r=I(e,r),o=r;continue}if("([{".includes(l))t++;else if(")]}".includes(l))t--;else if(l===","&&t<=0){i(r),r++;continue}/\s/.test(l)||(o=r+1),r++}return i(e.length),n},ce=e=>{let n=e.trim();if(!n.startsWith("{")&&!n.startsWith("["))return fe.test(n)?[n]:[];let t=[];for(let s of de(n.slice(1,De(n)))){s.startsWith("...")&&(s=s.slice(3).trim());let o=pe(s);if(o!==-1&&(s=s.slice(0,o).trim()),n.startsWith("{")){let i=ue(s,":");if(i!==-1){t.push(...ce(s.slice(i+1)));continue}}t.push(...ce(s))}return t},Tt=e=>{let n=[],t=xt(e).map(({raw:i,codeEnd:r})=>{let l=i.match(/^\s*/)[0];if(r<=l.length)return{text:i,empty:!0};let c=i.slice(l.length,r),d=i.slice(r),p=pe(c),m=(p===-1?c:c.slice(0,p)).trim(),b=c[0]==="{"||c[0]==="[";b?n.push(...ce(m)):fe.test(m)&&n.push(m);let T=ne(c).code;return{text:`${l}${b?`(${T})`:T}${d}`,empty:!1}}),s=[];for(;t.length&&t[t.length-1].empty;)s.unshift(t.pop().text);let o=t.map(i=>i.text).join(",")+s.join("");return o.trimStart().startsWith("(")&&(o=`;${o}`),{vars:n,code:o}},ne=e=>{let n=[],t="",s=0,o=0,i=!0;for(;s<e.length;){let r=e[s],l=e[s+1];if(r==="'"||r==='"'||r==="`"){let c=U(e,s);t+=e.slice(s,c),s=c,i=!1;continue}if(r==="/"&&(l==="/"||l==="*")){let c=l==="/"?P(e,s):M(e,s);t+=e.slice(s,c),s=c;continue}if(r==="/"&&F(e,s)){let c=I(e,s);t+=e.slice(s,c),s=c,i=!1;continue}if(r==="i"&&(s===0||!/[\w$.]/.test(e[s-1]))&&(ee.lastIndex=s,ee.test(e))){t+="$__import",s+=6,i=!1;continue}if(o===0&&i){Oe.lastIndex=s;let c=Oe.exec(e);if(c){let p=s+c[0].length,m=Pe(e,p),{vars:b,code:T}=Tt(e.slice(p,m));n.push(...b),t+=T,s=m,i=!1;continue}ve.lastIndex=s;let d=ve.exec(e);if(d){Le.lastIndex=s;let p=Le.exec(e);p&&n.push(p[1]);let m=s+d[0].length,b=Pe(e,m);t+=`$__effect(() => { ${ne(e.slice(m,b)).code} });`,s=b;continue}}"([{".includes(r)?o++:")]}".includes(r)&&(o=Math.max(0,o-1)),r===`
|
|
5
|
+
`||r===";"||r==="}"?i=!0:/\s/.test(r)||(i=!1),t+=r,s++}return{vars:n,code:t}},te=/export\s+default(?![\w$])/y,Me=/import\s*(?:([\w$\s,{}*]+?)\s*from\s*)?(["'])([^"'\n]+)\2/y,Ct=e=>{let n=[],t=0,s=0;for(let o=0;o<=e.length;o++){let i=e[o];if(i==="{")t++;else if(i==="}")t--;else if(o===e.length||i===","&&t===0){let r=e.slice(s,o).trim();r&&n.push(r),s=o+1}}return n},At=(e,n,t)=>{let s=`await $__import(${JSON.stringify(n)})`;if(e===void 0)return s;let o=Ct(e),i=[],r=s;if(o.length>1){let l=`$__mod${t}`;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(", ")}`},fe=/^[A-Za-z_$][\w$]*$/,De=e=>{let n=0,t=0;for(;t<e.length;){let s=e[t];if(s==="'"||s==='"'||s==="`"){t=U(e,t);continue}if(s==="/"&&e[t+1]==="/"){t=P(e,t);continue}if(s==="/"&&e[t+1]==="*"){t=M(e,t);continue}if(s==="/"&&F(e,t)){t=I(e,t);continue}if("([{".includes(s))n++;else if(")]}".includes(s)&&--n===0)return t;t++}return e.length},ue=(e,n)=>{let t=0,s=0;for(;s<e.length;){let o=e[s];if(o==="'"||o==='"'||o==="`"){s=U(e,s);continue}if(o==="/"&&e[s+1]==="/"){s=P(e,s);continue}if(o==="/"&&e[s+1]==="*"){s=M(e,s);continue}if(o==="/"&&o!==n&&F(e,s)){s=I(e,s);continue}if("([{".includes(o))t++;else if(")]}".includes(o))t--;else if(t===0&&o===n)return s;s++}return-1},de=e=>{let n=[],t=0,s=0,o=0;for(;o<=e.length;){let i=e[o];if(i==="'"||i==='"'||i==="`"){o=U(e,o);continue}if(i==="/"&&e[o+1]==="/"){o=P(e,o);continue}if(i==="/"&&e[o+1]==="*"){o=M(e,o);continue}if(i==="/"&&F(e,o)){o=I(e,o);continue}if(i!==void 0&&"([{".includes(i))t++;else if(i!==void 0&&")]}".includes(i))t--;else if(o===e.length||i===","&&t===0){let r=e.slice(s,o).trim();r&&n.push(r),s=o+1}o++}return n},pe=e=>{let n=0;for(;n<e.length;){let t=ue(e.slice(n),"=");if(t===-1)return-1;let s=n+t;if(e[s+1]!=="="&&e[s+1]!==">"&&e[s-1]!=="="&&e[s-1]!=="!")return s;n=s+1}return-1},se=e=>{let n=(e??"").trim();if(!n.startsWith("{"))return null;let t=De(n);if(t>=n.length)return null;let s=[];for(let o of de(n.slice(1,t))){if(o.startsWith("..."))continue;let i=pe(o),r=i===-1?o:o.slice(0,i),l=i===-1?void 0:o.slice(i+1).trim(),c=ue(r,":"),d=(c===-1?r:r.slice(0,c)).trim();fe.test(d)&&s.push(l===void 0?{name:d}:{name:d,default:l})}return s},jt=e=>{let n=0,t=0,s=!0;for(;n<e.length;){let o=e[n];if(o==="'"||o==='"'||o==="`"){n=U(e,n),s=!1;continue}if(o==="/"&&e[n+1]==="/"){n=P(e,n);continue}if(o==="/"&&e[n+1]==="*"){n=M(e,n);continue}if(o==="/"&&F(e,n)){n=I(e,n),s=!1;continue}if(o==="e"&&t===0&&s&&(n===0||!/[\w$.]/.test(e[n-1]))){te.lastIndex=n;let i=te.exec(e);if(i)return n+i[0].length}"([{".includes(o)?t++:")]}".includes(o)&&(t=Math.max(0,t-1)),o===`
|
|
6
|
+
`||o===";"||o==="}"?s=!0:/\s/.test(o)||(s=!1),n++}return-1},_t=/^async(?![\w$])/,Nt=/^function(?![\w$])\s*\*?\s*[A-Za-z_$][\w$]*|^function(?![\w$])\s*\*?/,Ot=e=>{let n=jt(e);if(n===-1)return null;let t=Y(e,n),s=e.slice(t);_t.test(s)&&(t=Y(e,t+5));let o=Nt.exec(e.slice(t));if(o&&(t=Y(e,t+o[0].length)),e[t]!=="(")return null;let i=0,r=t;for(;r<e.length;){let l=e[r];if(l==="'"||l==='"'||l==="`"){r=U(e,r);continue}if(l==="/"&&e[r+1]==="/"){r=P(e,r);continue}if(l==="/"&&e[r+1]==="*"){r=M(e,r);continue}if(l==="/"&&F(e,r)){r=I(e,r);continue}if("([{".includes(l))i++;else if(")]}".includes(l)&&--i===0)break;r++}return de(e.slice(t+1,r))[0]??""},he=e=>{let n=Ot(e);if(n===null)return null;let t=se(n),s=t?.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 t},Ue=e=>{let n="",t=0,s=0,o=!0,i=!1,r=0;for(;t<e.length;){let l=e[t],c=e[t+1],d=t===0||!/[\w$.]/.test(e[t-1]);if(l==="'"||l==='"'||l==="`"){let p=U(e,t);n+=e.slice(t,p),t=p,o=!1;continue}if(l==="/"&&(c==="/"||c==="*")){let p=c==="/"?P(e,t):M(e,t);n+=e.slice(t,p),t=p;continue}if(l==="/"&&F(e,t)){let p=I(e,t);n+=e.slice(t,p),t=p,o=!1;continue}if(l==="i"&&d){if(ee.lastIndex=t,ee.test(e)){n+="$__import",t+=6,o=!1;continue}if(s===0&&o){Me.lastIndex=t;let p=Me.exec(e);if(p){n+=At(p[1],p[3],r++),t+=p[0].length,o=!1;continue}}}if(l==="e"&&d&&s===0&&o){te.lastIndex=t;let p=te.exec(e);if(p){i=!0,n+="$__exports.default =",t+=p[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,t++}return i?n:null};var Ge=e=>Object.fromEntries(Array.from(e.attributes).map(n=>[n.name,n.value])),Ke=e=>({tag:e.tagName.toLowerCase(),attrs:Ge(e),children:Array.from(e.childNodes).flatMap(n=>{if(n.nodeType===Node.TEXT_NODE){let t=n.textContent??"";return t?[t]:[]}return n.nodeType===Node.ELEMENT_NODE?[Ke(n)]:[]})}),Fe=new Map,Xe=(e,n)=>{let t=`${n.join(",")}|${e}`,s=Fe.get(t);if(s===void 0){try{s=new Function("$scope",...n,`with ($scope) { return (${e}
|
|
8
|
+
); }`)}catch{s=null}Fe.set(t,s)}return s},j=(e,n,t)=>{let s=Xe(e,t?Object.keys(t):[]);if(s)try{return s(n,...t?Object.values(t):[])}catch{return}},vt=(e,n)=>e.replace(/{{\s*([\s\S]+?)\s*}}/g,(t,s)=>j(s,n)??""),Lt=new Set([":attrs",":class",":value",":checked",":selected",":if",":elseif",":else",":each",":key",":with",":text",":html",":html.allowed",":props"]),Je=e=>Lt.has(e)||e.startsWith(":class.")||e.startsWith(":props."),Pt=/^\s*\(?\s*(\w+)\s*(?:,\s*(\w+))?\s*\)?\s+in\s+([\s\S]+)$/,Mt=(e,n,t,s)=>{let[o,...i]=n.slice(1).split("."),r=new Set(i);e.addEventListener(o,l=>{if(r.has("self")&&l.target!==e)return;r.has("prevent")&&l.preventDefault(),r.has("stop")&&l.stopPropagation();let c=j(t,s,{$event:l});typeof c=="function"&&c.call(e,l)},{once:r.has("once"),capture:r.has("capture")})},Dt=(e,n,t,s)=>{let[o,...i]=n.slice(1).split("."),r=new Set(i),l=c=>{r.has("prevent")&&c.preventDefault(),r.has("stop")&&c.stopPropagation(),r.has("once")&&e.off(o,l),z(()=>{let d=j(t,s,{$event:c});typeof d=="function"&&d(c)})};e.on(o,l)},oe=e=>e.replace(/-(\w)/g,(n,t)=>t.toUpperCase()),ye=e=>e instanceof DocumentFragment?{first:e.firstChild,last:e.lastChild}:{first:e,last:e},re=({first:e,last:n})=>{for(let t=e;t;){let s=t===n?null:t.nextSibling;t.parentNode?.removeChild(t),t=s}},Ut=({first:e,last:n},t)=>{let s=t.nextSibling;for(let o=e;o;){let i=o===n?null:o.nextSibling;t.parentNode.insertBefore(o,s),o=i}},Ie=(e,n)=>{let t=n.replace(/-/g,"").toLowerCase();for(let s=e;s&&s!==Object.prototype;s=Object.getPrototypeOf(s))for(let o of Object.keys(s))if(/^[A-Z]/.test(o)&&o.replace(/-/g,"").toLowerCase()===t)return o;return null},We=200,ge=0,ke=(e,n,t,s,o)=>{let i=document.createComment(e),r=document.createComment(`/${e}`),l=document.createDocumentFragment();l.append(i,r);let c={},d={},p=[],m=[],b=!1;Object.entries(n.attrs).forEach(([a,f])=>{if(a!==we){if(a===":props"||a.startsWith(":props.")){b=!0,m.push({expr:f});return}if(!Je(a))if(a.startsWith("@"))p.push([a,f]);else if(a===":model"||a.startsWith(":model.")){let u=a===":model"?"default":oe(a.slice(7));d[u]=f||(a===":model"?"model":u)}else if(a.startsWith(":")){let u=oe(a.slice(1));c[u]=f||u,m.push({name:u,expr:f||u})}else{let u=oe(a),E=JSON.stringify(f);c[u]=E,m.push({name:u,expr:E})}}});let T=a=>a==="default"?":model":`:model.${a}`,A=a=>a==="default"?"model":a,y=a=>`${a}
|
|
9
|
+
= $value`;Object.entries(d).forEach(([a,f])=>{let u=A(a);c[u]!==void 0&&console.warn(`jq79: <${n.tag}> binds prop "${u}" through both :${u} and ${T(a)} - ${T(a)} wins`),c[u]=f,Xe(y(f),["$value"])===null&&console.warn(`jq79: ${T(a)}="${f}" is not assignable - updates from <${n.tag}> will be dropped`)});let $=()=>{let a={};return m.forEach(({name:f,expr:u})=>{if(f!==void 0)a[f]=j(u,t);else{let E=j(u,t);E!==null&&typeof E=="object"&&Object.assign(a,E)}}),Object.entries(d).forEach(([f,u])=>{a[A(f)]=j(u,t)}),a},h=null,g=null,w=null,S=new Set,v=a=>{if(a==null){if(!t[tt]?.has(e)||S.has("unfilled"))return;S.add("unfilled"),console.error(`jq79: <${n.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}S.has("type")||(S.add("type"),console.error(`jq79: <${n.tag}> is ${typeof a}, not a component - nothing renders here`))};return s.effect(()=>{let a=j(e,t),f=a instanceof D?a:null;if(f||v(a),f===g||(w?.dispose(),w=null,h?.destroy(),h=null,g=f,!f))return;let u=new D({template:f.template,scripts:f.scripts,styles:f.styles,modules:f.modules,filename:f.filename,siblings:f.siblings,name:f.name});if(Object.keys(d).length){let _=new Set,x=(L,O)=>{_.has(L)||(_.add(L),console.warn(O))};u.on("model:update",(L,O)=>{if(O===null||typeof O!="object"){x("payload",`jq79: model:update expects a { name?, value } payload, got ${O===null?"null":typeof O}`);return}let le=O.name==null?"default":oe(String(O.name)),$e=d[le];if($e===void 0){x(le,`jq79: <${n.tag}> has no ${T(le)} - bound: ${Object.keys(d).map(T).join(", ")}`);return}z(()=>j(y($e),t,{$value:O.value}))})}p.forEach(([_,x])=>Dt(u,_,x,t));let E=z($),C=document.createDocumentFragment();if(ge>=We){console.error(`jq79: <${n.tag}> is ${We} levels deep inside itself; giving up here. A component that renders itself stops when its data stops - is there a cycle in it?`);return}ge++;try{(o?u.renderShadow(E):u.render(E)).mount(C)}finally{ge--}r.parentNode.insertBefore(C,r);let R=H(t);if(b){let _=[];R.effect(()=>{let x=$(),L=Object.keys(x);_.forEach(O=>{O in x||(u.data[O]=void 0)}),L.forEach(O=>{u.data[O]=x[O]}),_=L})}else Object.entries(c).forEach(([_,x])=>{R.effect(()=>{u.data[_]=j(x,t)})});w=R,h=u}),s.onDispose(()=>{w?.dispose(),h?.destroy()}),l},Ft=(e,n)=>{let t=()=>{let s=j(e,n);return s!==null&&typeof s=="object"?s:null};return new Proxy(n,{has(s,o){let i=t();return i!==null&&Reflect.has(i,o)||Reflect.has(s,o)},get(s,o){let i=t();return i!==null&&Reflect.has(i,o)?i[o]:Reflect.get(s,o)},set(s,o,i){let r=t();return r!==null&&Reflect.has(r,o)?(r[o]=i,!0):Reflect.set(s,o,i)}})},K=e=>typeof e=="string"?e.split(/\s+/).filter(Boolean):Array.isArray(e)?e.flatMap(K):e!==null&&typeof e=="object"?Object.entries(e).flatMap(([n,t])=>t?K(n):[]):[],It=e=>typeof e=="function"?(n,t,s)=>{try{return!!e(n,t,s)}catch{return!1}}:typeof e=="string"||Array.isArray(e)?Te(e):()=>!1,Ee=(e,n,t,s)=>{let o=e.attrs[":with"],i=o!==void 0?Ft(o,n):n,r=Ie(i,e.tag);if(r)return ke(r,e,i,t,s);let l=document.createElement(e.tag);if(l instanceof HTMLUnknownElement||e.tag.includes("-")){let y=!1;t.effect(()=>{if(y)return;let $=Ie(i,e.tag);if(!$)return;y=!0;let h=ke($,e,i,t,s),g=ye(h);t.onDispose(()=>re(g)),l.replaceWith(h)})}Object.entries(e.attrs).forEach(([y,$])=>{y.startsWith("@")?Mt(l,y,$,i):y===":model"||y.startsWith(":model.")?l instanceof HTMLUnknownElement||e.tag.includes("-")||console.warn(`jq79: ${y} on <${e.tag}> does nothing - :model binds component tags only (for now)`):Je(y)||l.setAttribute(y,$)});let c=e.attrs[":attrs"];if(c!==void 0){let y=[];t.effect(()=>{y.forEach(h=>l.removeAttribute(h));let $=j(c,i);y=$&&typeof $=="object"?Object.keys($):[],y.forEach(h=>{let g=$[h];g!=null&&g!==!1&&l.setAttribute(h,String(g))})})}let d=e.attrs[":class"],p=Object.entries(e.attrs).filter(([y])=>y.startsWith(":class.")).map(([y,$])=>[y.slice(7),$]);if(d!==void 0||p.length){let y=new Set(K(e.attrs.class??"")),$=[];t.effect(()=>{let h=d!==void 0?K(j(d,i)):[];p.forEach(([g,w])=>{j(w,i)&&h.push(...K(g))}),$.forEach(g=>{!h.includes(g)&&!y.has(g)&&l.classList.remove(g)}),l.classList.add(...h),$=h})}let m=e.attrs[":text"],b=e.attrs[":html"],T=e.attrs[":html.allowed"];T!==void 0&&b===void 0&&console.warn("jq79: :html.allowed without :html on the same element does nothing"),m!==void 0?t.effect(()=>{l.textContent=String(j(m,i)??"")}):b!==void 0?t.effect(()=>{let y=T!==void 0?{allowUrl:It(j(T,i))}:void 0;l.innerHTML=Ae(String(j(b,i)??""),y)}):l.appendChild(be(e.children,i,t,s));let A=e.attrs[":value"];return A!==void 0&&t.effect(()=>{let y=String(j(A,i)??"");l.value!==y&&(l.value=y)}),[":checked",":selected"].forEach(y=>{let $=e.attrs[y];if($===void 0)return;let h=y.slice(1);t.effect(()=>{l[h]=!!j($,i)})}),l},Wt=(e,n,t,s)=>{let o=document.createComment("if"),i=document.createDocumentFragment();i.appendChild(o);let r=null,l=null,c=null;return t.effect(()=>{let d=e.find(m=>m.expr===void 0||j(m.expr,n))??null;if(d===l||(c?.dispose(),r&&re(r),r=null,l=d,!d))return;c=H(n);let p=Ee(d.node,n,c,s);r=ye(p),o.parentNode.insertBefore(p,o.nextSibling)}),i},G=(e,n,t)=>{Object.defineProperty(e,n,{value:t,writable:!0,enumerable:!0,configurable:!0})},kt=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return!1;let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null},qt=(e,n,t,s)=>{let o=e.attrs[":each"].match(Pt);if(!o)return document.createComment(`invalid :each expression "${e.attrs[":each"]}"`);let[,i,r,l]=o,c=e.attrs[":key"],{[":each"]:d,[":key"]:p,...m}=e.attrs,b={...e,attrs:m},T=document.createComment("each"),A=document.createDocumentFragment();A.appendChild(T),(":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 y=[],$=!1;return t.effect(()=>{let h=j(l,n),g=Array.isArray(h)?h.map((u,E)=>[E,u]):kt(h)?Object.entries(h):[],w=new Map;y.forEach(u=>{let E=w.get(u.key);E?E.push(u):w.set(u.key,[u])});let S=new Set,v=[],a=g.map(([u,E],C)=>{let R=Object.create(n);G(R,i,E),r&&G(R,r,u),G(R,"$index",C);let _=c!==void 0?j(c,R):u;S.has(_)&&!$&&($=!0,console.warn(`jq79: duplicate :key in :each "${e.attrs[":each"]}"; duplicates pair up by position`)),S.add(_);let x=w.get(_)?.shift();if(x&&Object.is(x.item,E))return x.scope.$index!==C&&v.push(x),G(x.scope,"$index",C),r&&G(x.scope,r,u),x;x&&(x.fx.dispose(),re(x.range));let L=H(n),O=ye(Ee(b,R,L,s));return{key:_,item:E,scope:R,fx:L,range:O}});w.forEach(u=>u.forEach(E=>{E.fx.dispose(),re(E.range)}));let f=T;a.forEach(u=>{f.nextSibling!==u.range.first&&Ut(u.range,f),f=u.range.last}),v.forEach(u=>z(()=>u.fx.refresh())),y=a}),A},be=(e,n,t,s=!1)=>{let o=document.createDocumentFragment(),i=0;for(;i<e.length;){let r=e[i];if(typeof r=="string"){let l=document.createTextNode(r);r.includes("{{")&&t.effect(()=>{l.textContent=vt(r,n)}),o.appendChild(l),i++;continue}if(":each"in r.attrs){o.appendChild(qt(r,n,t,s)),i++;continue}if(":if"in r.attrs){let l=[{expr:r.attrs[":if"],node:r}];i++;let c=p=>{let m=i;for(;m<e.length&&typeof e[m]=="string"&&!e[m].trim();)m++;let b=e[m];if(typeof b=="object"&&p in b.attrs)return i=m+1,b};for(let p=c(":elseif");p;p=c(":elseif"))l.push({expr:p.attrs[":elseif"],node:p});let d=c(":else");d&&l.push({node:d}),o.appendChild(Wt(l,n,t,s));continue}o.appendChild(Ee(r,n,t,s)),i++}return o},Ht=(e,n,t=!1)=>be(e.template,n,H(n),t),Bt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),zt=/<([A-Za-z][\w-]*)((?:"[^"]*"|'[^']*'|[^>"'])*?)\/>/g,Ve=/(<script[\s\S]*?<\/script\s*>|<style[\s\S]*?<\/style\s*>)/gi,Zt=e=>e.split(Ve).map((n,t)=>t%2===1?n:n.replace(zt,(s,o,i)=>Bt.has(o.toLowerCase())?s:`<${o}${i}></${o}>`)).join(""),Gt=/<([A-Za-z][\w-]*)((?:"[^"]*"|'[^']*'|[^>"'])*)>/g,Kt=/"[^"]*"|'[^']*'|(^|\s)\.\.\.([A-Za-z_$][\w$.]*)/g,Xt=e=>e.split(Ve).map((n,t)=>t%2===1?n:n.replace(Gt,(s,o,i)=>{let r=0,l=i.replace(Kt,(c,d,p)=>p===void 0?c:`${d}:props.${r++}="${p}"`);return`<${o}${l}>`})).join(""),we="data-jq79",Jt=e=>{let n=2166136261;for(let t=0;t<e.length;t++)n=Math.imul(n^e.charCodeAt(t),16777619);return(n>>>0).toString(36)},Qe=(e,n)=>{e.forEach(t=>{typeof t!="string"&&(t.attrs[we]=n,Qe(t.children,n))})},Vt=(e,n)=>e.split(",").map(t=>{let s=t.trim(),o=s.indexOf("::"),i=o===-1?s:s.slice(0,o),r=o===-1?"":s.slice(o);return`${i}[${we}="${n}"]${r}`}).join(", "),Ye=(e,n)=>{Array.from(e).forEach(t=>{t instanceof CSSStyleRule?t.selectorText=Vt(t.selectorText,n):t instanceof CSSGroupingRule&&Ye(t.cssRules,n)})},Qt=(e,n)=>{/: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 t=new CSSStyleSheet;return t.replaceSync(e),Ye(t.cssRules,n),Array.from(t.cssRules).map(s=>s.cssText).join(`
|
|
10
|
+
`)},Yt=/^[A-Z][A-Za-z0-9]*$/,me=e=>{let n=Zt(Xt(e)),s=new DOMParser().parseFromString(`<template>${n}</template>`,"text/html").querySelector("template"),o=[],i=[];Array.from(s.content.children).forEach(c=>{c.tagName==="TEMPLATE"?i.push(c):o.push(c)});let r=qe(o,e),l={};return i.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(!Yt.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 l){console.warn(`jq79: two <template name="${d}"> in one file; the second was ignored`);return}l[d]=new D({...qe(Array.from(c.content.children),c.innerHTML),siblings:l,name:d})}),Object.keys(l).length&&(r.siblings=l),r},qe=(e,n)=>{let t=[],s=[],o=[];e.forEach(r=>{let l={attrs:Ge(r),content:r.textContent??""};r.tagName==="SCRIPT"?t.push(l):r.tagName==="STYLE"?s.push(l):o.push(Ke(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=Jt(n);Qe(o,r),s.forEach(l=>{i(l)&&(l.scoped=Qt(l.content,r))})}return{template:o,scripts:t,styles:s}},Se=e=>/\.html?([?#]|$)/.test(e)?D.fetch(e):import(e),et=(e,n)=>e?`
|
|
11
|
+
//# sourceURL=${e}?jq79-script=${n}`:"",He=e=>e.scoped??e.content,ie=new Map,en=e=>{let n=ie.get(e);if(!n){let t=document.createElement("style");t.textContent=e,document.head.appendChild(t),n={el:t,count:0},ie.set(e,n)}n.count++},tn=e=>{let n=ie.get(e);n&&--n.count<=0&&(n.el.remove(),ie.delete(e))},nn=(e,n,t,s={},o=Se,i={})=>{let r={...ot,...s},l=new Proxy(n,{has:(d,p)=>p!=="$__effect"&&p!=="$__import"&&(Reflect.has(d,p)||!(p in globalThis)&&!(p in r))});new Function("$scope","$__effect","$__import",...Object.keys(r),`return (async () => { with ($scope) { ${e} } })()${et(i.filename,i.index??0)}`)(l,t,o,...Object.values(r)).catch(d=>console.error("jq79: error in :setup script",d))},Be=(e,n)=>{n?.forEach(({name:t,default:s})=>{e[t]===void 0&&(e[t]=s===void 0?void 0:j(s,e))})},sn=e=>{let n=new Set;return e.forEach(t=>{(he(t.content)??se(t.attrs[":setup"]))?.forEach(({name:o})=>n.add(o))}),n},on=(e,n)=>{if(!e)return null;let t=Object.create(null),s=!1;return Object.entries(e).forEach(([o,i])=>{n.has(o)||(t[o]=i,s=!0)}),s?t:null},tt=Symbol("jq79.unfilledProps"),rn=e=>e&&e.default!==void 0?e.default:e,ln=(e,n,t,s={},o=Se,i={})=>{let r={...ot,...s},l={},c=new Function("$__exports","$__default","$__import",...Object.keys(r),`return (async () => { "use strict";
|
|
12
|
+
${e}
|
|
13
|
+
;$__exports.done = true })()${et(i.filename,i.index??0)}`)(l,rn,o,...Object.values(r)),d=b=>console.error("jq79: error in factory script",b),p=!1,m=()=>{if(p)return;p=!0;let b=l.default;if(typeof b!="function")return;let T=A=>{A&&typeof A=="object"&&Object.assign(n,A)};try{let A=b(n,{$data:n,$props:n,$effect:t,...s});A instanceof Promise?A.then(T).catch(d):T(A)}catch(A){d(A)}};c.then(m,d),l.done&&m()},an="__JQ79_HMR_ENABLED__",cn="__JQ79_HMR__",W=null,fn=e=>{if(!W||!e.filename)return;let n=W.get(e.filename);n||W.set(e.filename,n=new Set),n.add(new WeakRef(e))},ze=e=>{try{return new URL(e,document.baseURI).pathname}catch{return e}},nt=(e,n)=>{if(!W)return 0;let t=ze(e),s=me(n),o=!1,i=l=>l.name===void 0?s:s.siblings?.[l.name]??null,r=0;for(let[l,c]of W)if(ze(l)===t){for(let d of c){let p=d.deref();if(!p){c.delete(d);continue}let m=i(p);if(!m){o=!0;continue}p.hotReplace(m)&&r++}c.size||W.delete(l)}return o?0:r},st=()=>{W??(W=new Map),globalThis[cn]={update:nt}},Ze=async e=>{let n=await fetch(e);if(!n.ok)throw new Error(`failed to fetch component from ${e}: ${n.status}`);return new D(await n.text(),{filename:e})},D=class{constructor(n,t={}){N(this,"template");N(this,"scripts");N(this,"styles");N(this,"modules");N(this,"filename");N(this,"siblings");N(this,"name");N(this,"data",null);N(this,"fx",null);N(this,"content",null);N(this,"startMarker",null);N(this,"endMarker",null);N(this,"styleEls",[]);N(this,"ownsSharedStyles",!1);N(this,"useShadow",!1);N(this,"mountRoot",null);N(this,"resolveMounted",null);N(this,"emitListeners",new Map);let s=typeof n=="string"?me(n):n;this.template=s.template,this.scripts=s.scripts,this.styles=s.styles,this.modules=t.modules??(typeof n=="string"?void 0:n.modules),this.filename=t.filename??(typeof n=="string"?void 0:n.filename),this.siblings=s.siblings,this.name=s.name,this.adoptSiblings(),fn(this)}adoptSiblings(){this.siblings&&Object.entries(this.siblings).forEach(([n,t])=>{t.filename??(t.filename=this.filename),t.modules??(t.modules=this.modules),this.name||(this[n]=t)})}hotReplace(n){let t=typeof n=="string"?me(n):n,s=this.startMarker,o=!!(s&&this.content),i=o&&s.isConnected,r=i?s.parentNode:null,l=i?this.endMarker.nextSibling:null,c={...this.data},d=this.useShadow;return o&&this.destroy(),this.template=t.template,this.scripts=t.scripts,this.styles=t.styles,this.siblings=t.siblings,this.adoptSiblings(),!o||(this.renderWith(c,d),!r)?!1:(d&&this.styleEls.forEach(p=>r.insertBefore(p,l)),r.insertBefore(this.content,l),this.mountRoot=r,this.resolveMounted?.(),!0)}static fetch(n){return Array.isArray(n)?Promise.all(n.map(Ze)):Ze(n)}on(n,t){return this.emitListeners.has(n)||this.emitListeners.set(n,new Set),this.emitListeners.get(n).add(t),this}off(n,t){return this.emitListeners.get(n)?.delete(t),this}render(n={}){return this.renderWith(n,!1)}renderShadow(n={}){return this.renderWith(n,!0)}renderWith(n,t){this.destroy();let s=sn(this.scripts),o=on(this.siblings,s),i=o?Object.assign(Object.create(o),n):{...n},r=new Set([...s].filter(a=>!(a in n)));r.size&&Object.defineProperty(i,tt,{value:r});let l=Z(i),c=H(l);this.data=l,this.fx=c,this.useShadow=t,this.startMarker=document.createComment("jq79"),this.endMarker=document.createComment("/jq79");let d=this.startMarker,p=(a,f)=>{let u=new CustomEvent(a,{detail:f,bubbles:!0,composed:!0,cancelable:!0});return d===this.startMarker&&this.emitListeners.get(a)?.forEach(E=>E(u,f)),u.cancelBubble||d.dispatchEvent(u),!u.defaultPrevented},m,b=new Promise(a=>{m=a});this.resolveMounted=m;let T=()=>b,A=this.endMarker,y=a=>{let f=[];for(let u=d.nextSibling;u&&u!==A;u=u.nextSibling)u instanceof Element&&(u.matches(a)&&f.push(u),f.push(...Array.from(u.querySelectorAll(a))));return f},$=a=>y(a)[0]??null,h=this.modules,g=a=>h&&a in h?Promise.resolve(h[a]):Se(a),w=a=>`await $mounted();${a}`;this.scripts.forEach((a,f)=>{let u={$emit:p,$mounted:T,$self:$,$$self:y,...o},E={filename:this.filename,index:f},C=Ue(a.content);if(C!==null){Be(l,he(a.content));let L=":mounted"in a.attrs?w(C):C;ln(L,l,c.effect,u,g,E);return}let{vars:R,code:_}=ne(a.content);Be(l,se(a.attrs[":setup"])),R.forEach(L=>{L in l||(l[L]=void 0)});let x=":mounted"in a.attrs?w(_):_;nn(x,l,c.effect,u,g,E)});let S=document.createDocumentFragment(),v=new Proxy(l,{has:(a,f)=>f==="$emit"||Reflect.has(a,f),get:(a,f,u)=>f==="$emit"&&!Reflect.has(a,f)?p:Reflect.get(a,f,u)});return S.append(this.startMarker,be(this.template,v,c,t),this.endMarker),this.content=S,t?this.styleEls=this.styles.map(a=>{let f=document.createElement("style");return f.textContent=a.content,f}):(this.styles.forEach(a=>en(He(a))),this.ownsSharedStyles=!0),this}mount(n,t){let s=typeof n=="string"?k(n):n;if(!s)throw new Error(`mount target not found: ${n}`);return(!this.content||t!==void 0)&&this.renderWith(t??{},this.useShadow),this.attach(s)}mountShadow(n,t){let s=typeof n=="string"?k(n):n;if(!s)throw new Error(`mount target not found: ${n}`);return(!this.content||t!==void 0||!this.useShadow)&&this.renderWith(t??{},!0),this.attach(s)}attach(n){this.mountRoot&&this.detach();let t=this.useShadow&&n instanceof Element?n.shadowRoot??n.attachShadow({mode:"open"}):n;return this.useShadow&&this.styleEls.forEach(s=>t.appendChild(s)),t.appendChild(this.content),this.mountRoot=t,this.resolveMounted?.(),this}detach(){if(!this.mountRoot||!this.content||!this.startMarker||!this.endMarker)return this;let n=this.startMarker;for(;n;){let t=n.nextSibling;if(this.content.appendChild(n),n===this.endMarker)break;n=t}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=>tn(He(n))),this.ownsSharedStyles=!1),this.content=null,this.startMarker=null,this.endMarker=null,this.data=null,this.resolveMounted=null,this}};var un=e=>new D(e),ot={$:k,$$:J,$create:V,$reactive:Z,Component79:D};typeof globalThis<"u"&&globalThis[an]&&st();0&&(module.exports={$,$$,$create,$reactive,C79,Component79,enableHotReload,hotUpdate,parseComponent,renderComponent});
|
|
14
14
|
//# sourceMappingURL=jq79.cjs.map
|