@stacksjs/stx-vscode 0.2.629 → 0.2.631
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.
|
@@ -15,28 +15,28 @@ type __StxRequired<O> = { [K in keyof O]-?: O[K] extends { required: true } ? K
|
|
|
15
15
|
type __StxDefaulted<O> = { [K in keyof O]-?: O[K] extends { default: unknown } ? K : never }[keyof O];
|
|
16
16
|
type __StxOptions<O> = { [K in Exclude<__StxRequired<O>, __StxDefaulted<O>>]: __StxOption<O[K]> } & { [K in Exclude<keyof O, Exclude<__StxRequired<O>, __StxDefaulted<O>>>]?: __StxOption<O[K]> };
|
|
17
17
|
type __StxDefaults<P, K> = Omit<P, Extract<keyof P, K>> & Partial<Pick<P, Extract<keyof P, K>>>;
|
|
18
|
-
`;function Re(e,s){let t=[],n={defineProps:["defineProps"],defineEmits:["defineEmits"],withDefaults:["withDefaults"]},i=L(e),o=e.replace(/\bimport\s+(?:type\s+)?(\{[^}]*\}|\*\s+as\s+[\w$]+|[\w$]+)\s+from\s*(['"])([^'"]+)\2\s*;?/g,(g,S,
|
|
18
|
+
`;function Re(e,s){let t=[],n={defineProps:["defineProps"],defineEmits:["defineEmits"],withDefaults:["withDefaults"]},i=L(e),o=e.replace(/\bimport\s+(?:type\s+)?(\{[^}]*\}|\*\s+as\s+[\w$]+|[\w$]+)\s+from\s*(['"])([^'"]+)\2\s*;?/g,(g,S,w,b,v)=>{if(i.slice(v,v+6)!=="import")return g;if(b.endsWith(".stx"))return"";let k=`${s}Import${t.length}`;if(t.push(`import * as ${k} from ${JSON.stringify(b)};`),S.startsWith("*"))return`import ${S.replace(/^\*\s+as\s+/,"")} = ${k};`;if(!S.startsWith("{"))return`import ${S} = ${k}.default;`;return S.slice(1,-1).split(",").map((y)=>{let[_,C=_]=y.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(!_)return"";if(/^(?:stx|@stacksjs\/stx)(?:\/|$)/.test(b)&&_ in n)n[_].push(C);return`import ${C} = ${k}.${_};`}).join(`
|
|
19
19
|
`)}),r=ce(e,n.defineProps),a=ce(e,n.defineEmits),c=ce(e,n.withDefaults);if(!r&&!a)return{declarations:"",props:null,events:null};let u=[],p=null,m=null;if(r){u.push(`const __options = (${r.args[0]||"{}"}) as const;`),u.push(`const __defaults = (${c?.args[1]||"{}"});`);let g=r.type||"__StxOptions<typeof __options>";u.push(`export type __StxProps = __StxDefaults<${g}, keyof typeof __defaults | __StxDefaulted<typeof __options>>;`),p=`${s}.__StxProps`}if(a)u.push(`const __events = (${a.args[0]||"[]"}) as const;`),u.push(`export type __StxEvents = ${a.type||"Record<(typeof __events)[number], any[]>"};`),m=`${s}.__StxEvents`;return{declarations:`${t.join(`
|
|
20
20
|
`)}
|
|
21
21
|
namespace ${s} {
|
|
22
22
|
${o}
|
|
23
23
|
${u.join(`
|
|
24
24
|
`)}
|
|
25
|
-
}`,props:p,events:m}}var Z=G(require("node:fs"),1),A=G(require("node:path"),1);function Pe(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}var De=new Map;function Ie(e,s=!0){let t=De.get(e);if(s&&t)return t;let n=new Map,i=[A.default.join(e,"src"),A.default.join(e,"dist"),e];function o(r,a){if(a>6)return;let c;try{c=Z.default.readdirSync(r,{withFileTypes:!0})}catch{return}for(let u of c){let p=A.default.join(r,u.name);if(u.isDirectory()){if(u.name==="node_modules"||u.name.startsWith("."))continue;o(p,a+1)}else if(u.isFile()&&u.name.endsWith(".stx")){let m=u.name.slice(0,-4);if(!n.has(m))n.set(m,p);let g=m.toLowerCase();if(!n.has(g))n.set(g,p);let S=Pe(m);if(!n.has(S))n.set(S,p)}}}for(let r of i)if(o(r,0),n.size>0)break;if(s)De.set(e,n);return n}function Le(e,s){if(e.startsWith(".")||e.startsWith("/"))return null;let t=s;while(!0){let n=A.default.join(t,"node_modules",e);try{if(Z.default.statSync(n).isDirectory())return n}catch{}let i=A.default.dirname(t);if(i===t)return null;t=i}}function Oe(e,s,t={}){return[A.default.resolve(A.default.dirname(s),`${e}.stx`),A.default.resolve(A.default.dirname(s),e),A.default.resolve(t.componentsDir||"components",`${e}.stx`),A.default.resolve(t.componentsDir||"components",e),e.endsWith(".stx")?e:`${e}.stx`]}function Me(e){let s=e.endsWith(".stx")?e.slice(0,-4):e,t=s.split("-").map((i)=>i.charAt(0).toUpperCase()+i.slice(1)).join(""),n=Pe(s);return[s,t,n]}function Lt(e,s){let[t,n,i]=Me(e);for(let o of[t,t.toLowerCase(),n,i]){let r=s?.__importedComponents?.get(o);if(r!==void 0)return r}}function*Ot(e,s,t={},n){let i=Me(e);if(i[0].startsWith("./")||i[0].startsWith("../")){yield A.default.resolve(A.default.dirname(s),`${i[0]}.stx`);return}let o=[...new Set(i.map((c)=>`${c}.stx`))],r=t.projectRoot||process.cwd(),a=[...n?.__originalFilePath?[A.default.join(A.default.dirname(n.__originalFilePath),"components")]:[],...t.componentsDir?[t.componentsDir]:[],A.default.join(A.default.dirname(s),"components"),A.default.resolve(r,"src/components"),A.default.resolve(r,"components"),A.default.resolve("/home/runner/work/stx/stx/packages/stx/src","components")];for(let c of new Set(a)){for(let u of o)yield A.default.join(c,u);try{for(let u of Z.default.readdirSync(c,{withFileTypes:!0}))if(u.isDirectory())for(let p of o)yield A.default.join(c,u.name,p)}catch{}}}function Ne(e,s,t={},n){let i=Lt(e,n);if(i!==void 0)return i;for(let o of Ot(e,s,t,n))try{if(Z.default.statSync(o,{throwIfNoEntry:!1})?.isFile())return o}catch{}return null}var je=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","component","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);function Be(e){if(e.includes("-")||e==="component")return!1;if(/^[A-Z]/.test(e))return!/[a-z]/.test(e)&&[...je].some((s)=>s.toLowerCase()===e.toLowerCase());return je.has(e)||/[A-Z]/.test(e)}function*Mt(e){let s=/<([A-Za-z][\w.-]*)(?=[\s/>])/g,t;while(t=s.exec(e)){let n=s.lastIndex,i=[];while(n<e.length){while(/\s/.test(e[n]||""))n++;if(e[n]===">"||e.slice(n,n+2)==="/>"){n+=e[n]===">"?1:2;break}let o=/^[^\s=/>]+/.exec(e.slice(n))?.[0];if(!o){n++;continue}let r=n;n+=o.length;while(/\s/.test(e[n]||""))n++;if(e[n]!=="="){i.push({name:o,value:!0,offset:r,braced:!1});continue}n++;while(/\s/.test(e[n]||""))n++;let a=e[n],c=a==="{",u=a==='"'||a==="'";if(u||c)n++;let p=n;if(c){let m=L(e.slice(n)),g=1,S=0;for(;S<m.length;S++){if(m[S]==="{")g++;if(m[S]==="}"&&--g===0)break}n+=S}else if(u)while(n<e.length&&e[n]!==a)n++;else while(n<e.length&&!/[\s/>]/.test(e[n]))n++;if(i.push({name:o,value:e.slice(p,n),offset:p,braced:c}),u||c)n++}s.lastIndex=n,yield{name:t[1],offset:t.index,attributes:i}}}function Fe(e,s,t){let n=[],i=[Ae,"type __StxAssignedValue<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? T extends () => infer V ? V : T : T;","type __StxProp<P, K> = K extends keyof P ? P[K] : unknown;",'type __StxEvent<E, K> = K extends keyof E ? E[K] extends readonly unknown[] ? Exclude<E[K]["length"], 0 | 1> extends never ? E[K][0] : E[K] : E[K] : any;'],o=new Map,r=new Map,a=new Map,c=t.scriptCode(e,t.filePath),u=L(c);for(let
|
|
26
|
-
`).length,column:
|
|
27
|
-
`)}},S=(
|
|
25
|
+
}`,props:p,events:m}}var Z=G(require("node:fs"),1),A=G(require("node:path"),1);function Pe(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}var De=new Map;function Ie(e,s=!0){let t=De.get(e);if(s&&t)return t;let n=new Map,i=[A.default.join(e,"src"),A.default.join(e,"dist"),e];function o(r,a){if(a>6)return;let c;try{c=Z.default.readdirSync(r,{withFileTypes:!0})}catch{return}for(let u of c){let p=A.default.join(r,u.name);if(u.isDirectory()){if(u.name==="node_modules"||u.name.startsWith("."))continue;o(p,a+1)}else if(u.isFile()&&u.name.endsWith(".stx")){let m=u.name.slice(0,-4);if(!n.has(m))n.set(m,p);let g=m.toLowerCase();if(!n.has(g))n.set(g,p);let S=Pe(m);if(!n.has(S))n.set(S,p)}}}for(let r of i)if(o(r,0),n.size>0)break;if(s)De.set(e,n);return n}function Le(e,s){if(e.startsWith(".")||e.startsWith("/"))return null;let t=s;while(!0){let n=A.default.join(t,"node_modules",e);try{if(Z.default.statSync(n).isDirectory())return n}catch{}let i=A.default.dirname(t);if(i===t)return null;t=i}}function Oe(e,s,t={}){return[A.default.resolve(A.default.dirname(s),`${e}.stx`),A.default.resolve(A.default.dirname(s),e),A.default.resolve(t.componentsDir||"components",`${e}.stx`),A.default.resolve(t.componentsDir||"components",e),e.endsWith(".stx")?e:`${e}.stx`]}function Me(e){let s=e.endsWith(".stx")?e.slice(0,-4):e,t=s.split("-").map((i)=>i.charAt(0).toUpperCase()+i.slice(1)).join(""),n=Pe(s);return[s,t,n]}function Lt(e,s){let[t,n,i]=Me(e);for(let o of[t,t.toLowerCase(),n,i]){let r=s?.__importedComponents?.get(o);if(r!==void 0)return r}}function*Ot(e,s,t={},n){let i=Me(e);if(i[0].startsWith("./")||i[0].startsWith("../")){yield A.default.resolve(A.default.dirname(s),`${i[0]}.stx`);return}let o=[...new Set(i.map((c)=>`${c}.stx`))],r=t.projectRoot||process.cwd(),a=[...n?.__originalFilePath?[A.default.join(A.default.dirname(n.__originalFilePath),"components")]:[],...t.componentsDir?[t.componentsDir]:[],A.default.join(A.default.dirname(s),"components"),A.default.resolve(r,"src/components"),A.default.resolve(r,"components"),A.default.resolve("/home/runner/work/stx/stx/packages/stx/src","components")];for(let c of new Set(a)){for(let u of o)yield A.default.join(c,u);try{for(let u of Z.default.readdirSync(c,{withFileTypes:!0}))if(u.isDirectory())for(let p of o)yield A.default.join(c,u.name,p)}catch{}}}function Ne(e,s,t={},n){let i=Lt(e,n);if(i!==void 0)return i;for(let o of Ot(e,s,t,n))try{if(Z.default.statSync(o,{throwIfNoEntry:!1})?.isFile())return o}catch{}return null}var je=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","component","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);function Be(e){if(e.includes("-")||e==="component")return!1;if(/^[A-Z]/.test(e))return!/[a-z]/.test(e)&&[...je].some((s)=>s.toLowerCase()===e.toLowerCase());return je.has(e)||/[A-Z]/.test(e)}function*Mt(e){let s=/<([A-Za-z][\w.-]*)(?=[\s/>])/g,t;while(t=s.exec(e)){let n=s.lastIndex,i=[];while(n<e.length){while(/\s/.test(e[n]||""))n++;if(e[n]===">"||e.slice(n,n+2)==="/>"){n+=e[n]===">"?1:2;break}let o=/^[^\s=/>]+/.exec(e.slice(n))?.[0];if(!o){n++;continue}let r=n;n+=o.length;while(/\s/.test(e[n]||""))n++;if(e[n]!=="="){i.push({name:o,value:!0,offset:r,braced:!1});continue}n++;while(/\s/.test(e[n]||""))n++;let a=e[n],c=a==="{",u=a==='"'||a==="'";if(u||c)n++;let p=n;if(c){let m=L(e.slice(n)),g=1,S=0;for(;S<m.length;S++){if(m[S]==="{")g++;if(m[S]==="}"&&--g===0)break}n+=S}else if(u)while(n<e.length&&e[n]!==a)n++;else while(n<e.length&&!/[\s/>]/.test(e[n]))n++;if(i.push({name:o,value:e.slice(p,n),offset:p,braced:c}),u||c)n++}s.lastIndex=n,yield{name:t[1],offset:t.index,attributes:i}}}function Fe(e,s,t){let n=[],i=[Ae,"type __StxAssignedValue<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? T extends () => infer V ? V : T : T;","type __StxProp<P, K> = K extends keyof P ? P[K] : unknown;",'type __StxEvent<E, K> = K extends keyof E ? E[K] extends readonly unknown[] ? Exclude<E[K]["length"], 0 | 1> extends never ? E[K][0] : E[K] : E[K] : any;'],o=new Map,r=new Map,a=new Map,c=t.scriptCode(e,t.filePath),u=L(c);for(let w of c.matchAll(/\bimport\s+(\{[^}]+\}|[\w$]+)\s+from\s*['"]([^'"]+)['"]/g)){if(u.slice(w.index,w.index+6)!=="import")continue;let b=w[2],v=z.default.isAbsolute(b)||b.startsWith(".")?z.default.resolve(z.default.dirname(t.filePath),b):Le(b,z.default.dirname(t.filePath));if(!v)continue;let k=v.endsWith(".stx")?v:J.default.existsSync(`${v}.stx`)?`${v}.stx`:void 0,y=k?null:Ie(v,!1),_=w[1].startsWith("{")?w[1].slice(1,-1).split(","):[w[1]];for(let C of _){let[O,T=O]=C.trim().split(/\s+as\s+/),N=k||y?.get(O)||y?.get(O.toLowerCase());if(N)a.set(T,N),a.set(T.toLowerCase(),N),a.set(T.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),N)}}for(let w of s.matchAll(/@import\s*\(([^)]+)\)/g))for(let b of w[1].matchAll(/['"]([^'"]+)['"]/g)){let v=Oe(b[1],t.filePath,t).find((k)=>J.default.statSync(k,{throwIfNoEntry:!1})?.isFile());if(v)a.set(z.default.basename(b[1]).replace(/\.stx$/,""),v)}let p={__importedComponents:a},m=new Map,g=(w,b,v)=>{let k=e.slice(0,w);return{code:b,offset:w,attribute:v,anchor:!0,kind:"directive",line:k.split(`
|
|
26
|
+
`).length,column:w-k.lastIndexOf(`
|
|
27
|
+
`)}},S=(w,b,v)=>n.push({expression:w,statement:{text:b+w.code+v,prefixLength:b.length}});for(let w of Mt(s)){if(Be(w.name)||w.name==="component")continue;let b=Ne(w.name,t.filePath,t,p);if(!b)continue;let v=m.get(b);if(!v){let y;try{y=t.readComponent?t.readComponent(b):J.default.readFileSync(b,"utf8")}catch{continue}if(y===void 0)continue;r.set(b,y),v=Re(t.scriptCode(y,b),`__StxComponent${m.size}`),m.set(b,v),i.push(v.declarations)}let k=[];for(let y of w.attributes){let{name:_,offset:C}=y,O=y.value===!0?"true":y.value;if(_.startsWith("@")||_.startsWith("v-on:")){if(v.events&&y.value!==!0)o.set(C,`__StxEvent<${v.events}, ${JSON.stringify(_.replace(/^@|^v-on:/,"").split(".")[0])}>`);continue}let T=/^v-model(?::([\w-]+))?(?:\.[\w-]+)*$/.exec(_);if(_.startsWith("v-")&&!_.startsWith("v-bind:")&&!T)continue;if(/^(?:x-|:)(?:if|for|show|key|else)(?:$|[.:-])/.test(_))continue;let N=(T?T[1]||"modelValue":_.replace(/^:|^v-bind:/,"")).replace(/-([a-z])/g,(M,j)=>j.toUpperCase());if(k.push(N),!v.props)continue;let P=_.startsWith(":")||_.startsWith("v-bind:")||!!T||y.braced?O:y.value!==!0?JSON.stringify(O):"true";S(g(C,P,_),";void ((",`) satisfies __StxProp<${v.props}, ${JSON.stringify(N)}>);`)}if(v.props){let y=[...new Set(k)].map((C)=>`${JSON.stringify(C)}: undefined as any`).join(", "),_=g(w.offset,`<${w.name}>`);n.push({expression:_,statement:{text:`;void ({ ${y} } satisfies ${v.props} & Record<string, unknown>);`,prefixLength:0}})}}return{declarations:m.size?i.join(`
|
|
28
28
|
`):"",checks:n,events:o,dependencies:r}}function Ve(e){if(!e.includes("#")&&!e.includes("v-slot:"))return[];let s=[],t=[],n=/<!--[\s\S]*?-->|<script\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/script\s*>|<style\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/style\s*>|<\/?[a-z][\w:-]*\b(?:"[^"]*"|'[^']*'|[^'">])*>/gi;for(let i of e.matchAll(n)){let o=i[0];if(/^<\/template\s*>$/i.test(o)){let r=t.pop();if(r)r.end=i.index}else if(/^<template\b/i.test(o)&&!/\/\s*>$/.test(o)){let a=[...o.slice(9).matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g)].find((p)=>/^(?:#[\w-]+|v-slot:[\w-]+)$/i.test(p[1])),c=(a?.[2]??a?.[3])?.trim(),u=c?{start:i.index+o.length,end:e.length,binding:c}:void 0;if(t.push(u),u)s.push(u)}}return s}var We=/<script(\s[^>]*)?>([\s\S]*?)<\/script>/gi;function Nt(e){let s=(t)=>t.replace(/[^\n]/g," ");return e.replace(/<!--[\s\S]*?-->/g,s).replace(/\{\{--[\s\S]*?--\}\}/g,s)}function te(e){let s=[],t=Nt(e);We.lastIndex=0;let n;while((n=We.exec(t))!==null){let i=(n[1]||"").trim(),o=(n[0].match(/^<script(?:\s[^>]*)?>/i)?.[0]??"<script>").length,r=(n[0].match(/<\/script\s*>$/i)?.[0]??"</script>").length,a=n.index+o,c=n.index+n[0].length-r,u=e.slice(a,c);if(/\bsrc\s*=/.test(i))continue;let p=i.match(/\btype\s*=\s*["']([^"']+)["']/i);if(p&&!/^(?:module|text\/(?:javascript|typescript))$/i.test(p[1]))continue;let m=/\bserver\b/.test(i)?"server":/\bclient\b/.test(i)?"client":"plain",g=U(e,a);s.push({kind:m,code:u,startLine:g,startColumn:q(e,a),offset:a,attrs:i})}return s}function U(e,s){let t=1;for(let n=0;n<s&&n<e.length;n++)if(e.charCodeAt(n)===10)t++;return t}function q(e,s){let t=e.lastIndexOf(`
|
|
29
29
|
`,s-1)+1;return s-t+1}function ne(e){let s=e.split(""),t=(i,o)=>{for(let r=i;r<o&&r<s.length;r++)if(s[r]!==`
|
|
30
30
|
`)s[r]=" "},n=[/<script(?:\s[^>]*)?>[\s\S]*?<\/script>/gi,/<style(?:\s[^>]*)?>[\s\S]*?<\/style>/gi,/<!--[\s\S]*?-->/g,/\{\{--[\s\S]*?--\}\}/g,/@verbatim\b[\s\S]*?@endverbatim\b/g];for(let i of n){i.lastIndex=0;let o;while((o=i.exec(e))!==null)t(o.index,o.index+o[0].length)}return s.join("")}function jt(e){let s=0,t="";for(let n=0;n<e.length;n++){let i=e[n];if(t){if(i==="\\"){n++;continue}if(i===t)t="";continue}if(i==='"'||i==="'"||i==="`"){t=i;continue}if(i==="("||i==="["||i==="{"){s++;continue}if(i===")"||i==="]"||i==="}"){s--;continue}if(i==="|"&&s===0){if(e[n+1]==="|"){n++;continue}if(e[n-1]==="|")continue;return e.slice(0,n)}}return e}var Ue=new Set([":for","x-for","v-for"]),se=/(?:^|\s)((?::|x-|v-|@)[\w.:-]+)\s*=\s*(["'])([\s\S]*?)\2/g,le="__stx_interpolated",Ge="__StxElement",qe="__StxTemplateValue",Bt=`type ${qe}<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? (T extends () => infer V ? T & V : T) : T`;function Ke(e){return e.replace(/\{\{[\s\S]*?\}\}/g,le).replace(/\{!![\s\S]*?!!\}/g,le)}function Ft(e){return e.replace(/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/g,(s)=>{let t=s.split(`
|
|
31
31
|
`).length-1,n=s.length-t;return`0${" ".repeat(Math.max(0,n-1))}${`
|
|
32
|
-
`.repeat(t)}`})}var Vt=["foreach","endforeach","forelse","endforelse","for","endfor","while","endwhile","empty","if","elseif","else","endif","unless","endunless","isset","endisset","switch","case","default","endswitch","auth","endauth","guest","endguest","env","endenv","once","endonce","break","continue"],Wt=new RegExp(String.raw`^[ \t]*@(?:${Vt.join("|")})\b[ \t]*(\([^\n)]*\))?[ \t]*$`,"gm");function Gt(e){return e.replace(Wt,(s)=>s.replace(/[^\n]/g," "))}var He=new Set(["x-cloak","x-ref","x-transition","x-teleport","v-slot","x-hydrate",":key","x-tooltip","x-tooltip-position"]);function Kt(e){let s=ne(e),t=[],n=/(@?)\{\{([\s\S]*?)\}\}|(@?)\{!!([\s\S]*?)!!\}/g,i;while((i=n.exec(s))!==null){if(i[1]||i[3])continue;let a=i[2]??i[4]??"",c=i[2]!==void 0?2:3,u=jt(a);if(!u.trim())continue;let p=i.index+c+(u.length-u.trimStart().length);t.push({code:u.trim(),line:U(s,p),column:q(s,p),offset:p,kind:"interpolation"})}let o=/@(if|elseif|else\s+if|unless)\b\s*\(/g;while((i=o.exec(s))!==null){let r=i.index+i[0].length-1,a=0,c=r;for(;c<s.length;c++){let g=s[c];if(g==="(")a++;else if(g===")"){if(a--,a===0)break}}if(a!==0)continue;let u=s.slice(r+1,c),p=u.trim();if(o.lastIndex=c+1,!p)continue;let m=r+1+(u.length-u.trimStart().length);t.push({code:p,line:U(s,m),column:q(s,m),offset:i.index,kind:"condition"})}se.lastIndex=0;while((i=se.exec(s))!==null){let r=i[1],a=i[3]??"",c=r.replace(/\..*$/,"").replace(/^([^:].*?):.*$/,"$1");if(He.has(c)||He.has(r))continue;if(!a.trim())continue;let u=i.index+i[0].indexOf(i[2],i[0].indexOf(r)+r.length)+1;if(Ue.has(c)){let m=a.match(/\s+(?:in|of)\s+/);if(!m||m.index===void 0)continue;let g=a.slice(m.index+m[0].length),S=m.index+m[0].length+(g.length-g.trimStart().length);t.push({code:Ke(g.trim()),line:U(s,u+S),column:q(s,u+S),offset:u+S,kind:"directive",attribute:c});continue}let p=a.length-a.trimStart().length;t.push({code:Ke(a.trim()),line:U(s,u+p),column:q(s,u+p),offset:u+p,kind:"directive",attribute:c})}return t.sort((r,a)=>r.line-a.line||r.column-a.column),t}var Ht=2000;function zt(e,s){let t=0,n=Math.min(e.length,s+Ht);for(let i=s;i<n;i++){let o=e[i];if(o==="(")t++;else if(o===")"){if(t--,t===0)return e.slice(s+1,i)}}return null}function Xt(e){let s=new Map,t=(a,c)=>{let u=a.split(/[,[\]{}()\s]+/).filter(Boolean);for(let p of u){let m=p.replace(/^\.\.\./,"").trim();if(!/^\$?[A-Z_$][\w$]*$/i.test(m))continue;let g=u.length===1?c:void 0,S=s.get(m);if(!S)s.set(m,{name:m,iterable:g});else if(S.iterable!==g)S.iterable=void 0}},n=/^\$?[A-Z_$][\w$]*$/i,i=(a)=>{let c=a.trim();return n.test(c)?c:void 0};for(let a of e.matchAll(/@for(?:each|else)\s*\(/g)){let c=zt(e,a.index+a[0].length-1);if(c===null)continue;let u=Ce(c);if(!u)continue;t(u.itemVar.replace(/=>/g," "),i(u.arrayExpr))}for(let a of e.matchAll(/@for\s*\(\s*(?:(?:let|const|var)\s+)?([\w$]+|\[[^\]]*\]|\{[^}]*\})\s+(of|in)\s+([^)]*)/g))t(a[1],a[2]==="of"?i(a[3]):void 0);for(let a of e.matchAll(/@for\s*\(\s*(?:let|const|var)\s+([\w$]+)\s*[=;]/g))t(a[1]);let o=ne(e);se.lastIndex=0;let r;while((r=se.exec(o))!==null){let a=r[1].replace(/\..*$/,"");if(!Ue.has(a))continue;let c=r[3].match(/\s+(?:in|of)\s+/);if(!c||c.index===void 0)continue;t(r[3].slice(0,c.index),i(r[3].slice(c.index+c[0].length)))}for(let a of e.matchAll(/@(?:php|js|ts)\b([\s\S]*?)@end(?:php|js|ts)\b/g))for(let c of a[1].matchAll(/\b(?:const|let|var|function|class)\s+([\w$]+)/g))t(c[1]);return[...s.values()].sort((a,c)=>a.name.localeCompare(c.name))}function ee(e){let s=new Set;for(let t of e.matchAll(/^\s*(?:export\s+)?(?:const|let|var)\s+([\w$]+)/gm))s.add(t[1]);for(let t of e.matchAll(/^\s*(?:export\s+)?(?:async\s+)?function\s*\*?\s*([\w$]+)/gm))s.add(t[1]);for(let t of e.matchAll(/^\s*(?:export\s+)?class\s+([\w$]+)/gm))s.add(t[1]);for(let t of e.matchAll(/^\s*(?:export\s+)?(?:const|let|var)\s*[[{]([^\]}]*)[\]}]/gm))for(let n of t[1].split(",")){let i=n.split(":").pop().split("=")[0].replace(/^\.\.\./,"").trim();if(/^[A-Z_$][\w$]*$/i.test(i))s.add(i)}return[...s].sort()}var ze=["params","query","cookies","host","ip","setResponseStatus","setResponseHeader","notFound","request","url","definePageMeta","defineClientPayload","defineStore","props","$props"];var Xe=["$env","$user","$slot","$slots","$attrs","$props","$page","$route","$loop","loop","$errors","$csrf","props","slot"];function Ye(e){let s=new Set,t=new Set;for(let n of e){let i=n.kind==="server"?s:t;for(let o of ee(n.code))i.add(o)}return[...s].filter((n)=>t.has(n)).sort()}var Zt=/^\s*[A-Z_$][\w$]*\s*=[^=]/i;function Ut(e){let s=new Map,t=/!|===|!==|==|!=|&&|\|\||<|>|\btypeof\b|\binstanceof\b|\bin\b/;for(let n of e){let i=L(n),{depths:o,balanced:r}=Q(i);if(!r)continue;let a=/^([ \t]*(?:export[ \t]+)?const[ \t]+)([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=[ \t]*([^\n]+)$/gm;for(let c of i.matchAll(a)){let u=c.index??0;if(o[u+c[1].length]!==0)continue;let p=c[2],m=u+c[0].length-c[3].length,g=n.slice(m,u+c[0].length).trim().replace(/;$/,"").trim(),S=c[3],
|
|
32
|
+
`.repeat(t)}`})}var Vt=["foreach","endforeach","forelse","endforelse","for","endfor","while","endwhile","empty","if","elseif","else","endif","unless","endunless","isset","endisset","switch","case","default","endswitch","auth","endauth","guest","endguest","env","endenv","once","endonce","break","continue"],Wt=new RegExp(String.raw`^[ \t]*@(?:${Vt.join("|")})\b[ \t]*(\([^\n)]*\))?[ \t]*$`,"gm");function Gt(e){return e.replace(Wt,(s)=>s.replace(/[^\n]/g," "))}var He=new Set(["x-cloak","x-ref","x-transition","x-teleport","v-slot","x-hydrate",":key","x-tooltip","x-tooltip-position"]);function Kt(e){let s=ne(e),t=[],n=/(@?)\{\{([\s\S]*?)\}\}|(@?)\{!!([\s\S]*?)!!\}/g,i;while((i=n.exec(s))!==null){if(i[1]||i[3])continue;let a=i[2]??i[4]??"",c=i[2]!==void 0?2:3,u=jt(a);if(!u.trim())continue;let p=i.index+c+(u.length-u.trimStart().length);t.push({code:u.trim(),line:U(s,p),column:q(s,p),offset:p,kind:"interpolation"})}let o=/@(if|elseif|else\s+if|unless)\b\s*\(/g;while((i=o.exec(s))!==null){let r=i.index+i[0].length-1,a=0,c=r;for(;c<s.length;c++){let g=s[c];if(g==="(")a++;else if(g===")"){if(a--,a===0)break}}if(a!==0)continue;let u=s.slice(r+1,c),p=u.trim();if(o.lastIndex=c+1,!p)continue;let m=r+1+(u.length-u.trimStart().length);t.push({code:p,line:U(s,m),column:q(s,m),offset:i.index,kind:"condition"})}se.lastIndex=0;while((i=se.exec(s))!==null){let r=i[1],a=i[3]??"",c=r.replace(/\..*$/,"").replace(/^([^:].*?):.*$/,"$1");if(He.has(c)||He.has(r))continue;if(!a.trim())continue;let u=i.index+i[0].indexOf(i[2],i[0].indexOf(r)+r.length)+1;if(Ue.has(c)){let m=a.match(/\s+(?:in|of)\s+/);if(!m||m.index===void 0)continue;let g=a.slice(m.index+m[0].length),S=m.index+m[0].length+(g.length-g.trimStart().length);t.push({code:Ke(g.trim()),line:U(s,u+S),column:q(s,u+S),offset:u+S,kind:"directive",attribute:c});continue}let p=a.length-a.trimStart().length;t.push({code:Ke(a.trim()),line:U(s,u+p),column:q(s,u+p),offset:u+p,kind:"directive",attribute:c})}return t.sort((r,a)=>r.line-a.line||r.column-a.column),t}var Ht=2000;function zt(e,s){let t=0,n=Math.min(e.length,s+Ht);for(let i=s;i<n;i++){let o=e[i];if(o==="(")t++;else if(o===")"){if(t--,t===0)return e.slice(s+1,i)}}return null}function Xt(e){let s=new Map,t=(a,c)=>{let u=a.split(/[,[\]{}()\s]+/).filter(Boolean);for(let p of u){let m=p.replace(/^\.\.\./,"").trim();if(!/^\$?[A-Z_$][\w$]*$/i.test(m))continue;let g=u.length===1?c:void 0,S=s.get(m);if(!S)s.set(m,{name:m,iterable:g});else if(S.iterable!==g)S.iterable=void 0}},n=/^\$?[A-Z_$][\w$]*$/i,i=(a)=>{let c=a.trim();return n.test(c)?c:void 0};for(let a of e.matchAll(/@for(?:each|else)\s*\(/g)){let c=zt(e,a.index+a[0].length-1);if(c===null)continue;let u=Ce(c);if(!u)continue;t(u.itemVar.replace(/=>/g," "),i(u.arrayExpr))}for(let a of e.matchAll(/@for\s*\(\s*(?:(?:let|const|var)\s+)?([\w$]+|\[[^\]]*\]|\{[^}]*\})\s+(of|in)\s+([^)]*)/g))t(a[1],a[2]==="of"?i(a[3]):void 0);for(let a of e.matchAll(/@for\s*\(\s*(?:let|const|var)\s+([\w$]+)\s*[=;]/g))t(a[1]);let o=ne(e);se.lastIndex=0;let r;while((r=se.exec(o))!==null){let a=r[1].replace(/\..*$/,"");if(!Ue.has(a))continue;let c=r[3].match(/\s+(?:in|of)\s+/);if(!c||c.index===void 0)continue;t(r[3].slice(0,c.index),i(r[3].slice(c.index+c[0].length)))}for(let a of e.matchAll(/@(?:php|js|ts)\b([\s\S]*?)@end(?:php|js|ts)\b/g))for(let c of a[1].matchAll(/\b(?:const|let|var|function|class)\s+([\w$]+)/g))t(c[1]);return[...s.values()].sort((a,c)=>a.name.localeCompare(c.name))}function ee(e){let s=new Set;for(let t of e.matchAll(/^\s*(?:export\s+)?(?:const|let|var)\s+([\w$]+)/gm))s.add(t[1]);for(let t of e.matchAll(/^\s*(?:export\s+)?(?:async\s+)?function\s*\*?\s*([\w$]+)/gm))s.add(t[1]);for(let t of e.matchAll(/^\s*(?:export\s+)?class\s+([\w$]+)/gm))s.add(t[1]);for(let t of e.matchAll(/^\s*(?:export\s+)?(?:const|let|var)\s*[[{]([^\]}]*)[\]}]/gm))for(let n of t[1].split(",")){let i=n.split(":").pop().split("=")[0].replace(/^\.\.\./,"").trim();if(/^[A-Z_$][\w$]*$/i.test(i))s.add(i)}return[...s].sort()}var ze=["params","query","cookies","host","ip","setResponseStatus","setResponseHeader","notFound","request","url","definePageMeta","defineClientPayload","defineStore","props","$props"];var Xe=["$env","$user","$slot","$slots","$attrs","$props","$page","$route","$loop","loop","$errors","$csrf","props","slot"];function Ye(e){let s=new Set,t=new Set;for(let n of e){let i=n.kind==="server"?s:t;for(let o of ee(n.code))i.add(o)}return[...s].filter((n)=>t.has(n)).sort()}var Zt=/^\s*[A-Z_$][\w$]*\s*=[^=]/i;function Ut(e){let s=new Map,t=/!|===|!==|==|!=|&&|\|\||<|>|\btypeof\b|\binstanceof\b|\bin\b/;for(let n of e){let i=L(n),{depths:o,balanced:r}=Q(i);if(!r)continue;let a=/^([ \t]*(?:export[ \t]+)?const[ \t]+)([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=[ \t]*([^\n]+)$/gm;for(let c of i.matchAll(a)){let u=c.index??0;if(o[u+c[1].length]!==0)continue;let p=c[2],m=u+c[0].length-c[3].length,g=n.slice(m,u+c[0].length).trim().replace(/;$/,"").trim(),S=c[3],w=t.test(S)&&!/\bawait\b|=>|\bfunction\b|[{}]/.test(S)&&!/[,+\-*/%&|?:=]$/.test(g)&&Q(S).balanced;s.set(p,s.has(p)||!w?null:g)}}return new Map([...s].filter((n)=>n[1]!==null))}function Qe(e,s,t=0,n=new Set){if(s.size===0||t>=5)return e;let i=L(e),o="",r=0;for(let a of i.matchAll(/[A-Za-z_$][\w$]*/g)){let c=a.index??0,u=a[0],p=s.get(u);if(!p||n.has(u))continue;let m=i.slice(0,c).trimEnd(),g=i.slice(c+u.length).trimStart();if(m.endsWith(".")||/^:(?!:)/.test(g)&&/[{,]$/.test(m))continue;if(c>0&&/[\w$]/.test(i[c-1]))continue;o+=`${e.slice(r,c)}(${Qe(p,s,t+1,new Set([...n,u]))})`,r=c+u.length}return o+e.slice(r)}function qt(e,s){let t=/@(if|unless|elseif|else|endif|endunless)\b\s*(\()?/g,n=[],i;while((i=t.exec(e))!==null){if(i.index>s)break;let o=i[1];if(i.index===s){if(o==="elseif"){let a=n[n.length-1];if(a?.current)a.seen.push(a.current);if(a)a.current=null}break}if(o==="endif"||o==="endunless"){n.pop();continue}let r="";if(i[2]==="("){let a=0,c=i.index+i[0].length-1,u=c+1;for(;c<e.length;c++){let p=e[c];if(p==="(")a++;else if(p===")"){if(a--,a===0)break}}r=e.slice(u,c).trim(),t.lastIndex=c+1}if(o==="if")n.push({seen:[],current:r});else if(o==="unless")n.push({seen:[],current:`!(${r})`});else if(o==="elseif"||o==="else"){let a=n[n.length-1];if(!a)continue;if(a.current)a.seen.push(a.current);a.current=o==="elseif"?r:null}}return n.flatMap((o)=>[...o.seen.map((r)=>`!(${r})`),...o.current?[o.current]:[]]).filter(Boolean)}function Yt(e){let s=e.code.trim();if(!s)return null;if(e.attribute?.startsWith("@")){if(Zt.test(s))return null;let n=";(($event: any): void => { ";return{text:`${n}${s} });`,prefixLength:n.length}}let t=";void ((";return{text:`${t}${s}));`,prefixLength:t.length}}var Qt=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.{1,2}\/[^'"\n]*)\2/g;function Ze(e,s){if(!s)return e;return e.replace(Qt,(t,n,i,o)=>{let r=ue.default.resolve(s,o).replace(/\\/g,"/");return`${n}${i}${r}${i}`})}function Jt(e){return" ".repeat(Math.max(0,(e.startColumn??1)-1))}function en(e){let s=new Set,t=L(e);for(let n of t.matchAll(/\bimport\s+(?:type\s+)?([\w$*{}\s,]+?)\s+from\b/g)){let i=n[1],o=/\{([^}]*)\}/.exec(i);for(let u of o?.[1].split(",")??[]){let p=u.trim().replace(/^type\s+/,"").split(/\s+as\s+/).pop()?.trim();if(p&&/^[A-Z_$][\w$]*$/i.test(p))s.add(p)}let r=i.replace(/\{[^}]*\}/,""),a=/\*\s*as\s+([A-Z_$][\w$]*)/i.exec(r);if(a)s.add(a[1]);let c=/^\s*([A-Z_$][\w$]*)/i.exec(r);if(c&&c[1]!=="type")s.add(c[1])}return[...s].sort()}function Je(e,s={}){let t=te(e),n=e.split(`
|
|
33
33
|
`),i=Array.from({length:n.length},()=>""),o=new Map,r=s.filePath&&s.templateExpressions!==!1?Fe(e,ne(e),{filePath:s.filePath,componentsDir:s.componentsDir,projectRoot:s.projectRoot,readComponent:s.readComponent,scriptCode:(m,g)=>te(m).map((S)=>Ze(S.code,ue.default.dirname(g))).join(`
|
|
34
34
|
`)}):void 0,a=new Set,c=[];for(let m of t){let g=Gt(Ft(m.code)),S=Ze(g,s.originDir??"").split(`
|
|
35
|
-
`);S.forEach((
|
|
36
|
-
`).entries())if(i.push(
|
|
37
|
-
`))u(g);let m=Kt(e).map((g)=>{let S=r?.events.get(g.offset??-1);if(S){g.anchor=!0;let
|
|
35
|
+
`);S.forEach((w,b)=>{let v=m.startLine-1+b;if(v<i.length)i[v]=b===0?Jt(m)+w:w,a.add(v)}),c.push(m.startLine-1+S.length-1)}for(let m of c){let g=i[m]?.trim()===""?m:m+1;if(g<i.length&&i[g].trim()===""&&(g===m||!a.has(g)))i[g]=";"}let u=(m,g)=>{for(let[S,w]of m.split(`
|
|
36
|
+
`).entries())if(i.push(w),g)o.set(i.length,S===0?g:{...g,line:g.line+S,column:1,prefixLength:0})};if(s.globals!==!1){u("");let m=new Set([...t.flatMap((b)=>ee(b.code)),...t.flatMap((b)=>en(b.code))]),g=(b)=>{if(!m.has(b))u(`declare var ${b}: any`)};if(s.runtimeGlobals!==!1){if(!m.has("window"))u("declare var window: any");for(let b of H)g(b)}let S=[...new Set([...ze,...ae,...Xe])].filter((b)=>s.runtimeGlobals!==!1||!H.includes(b));if(s.contextScope==="global"){u("declare global {");for(let b of S)u(` var ${b}: any`);u("}")}else{for(let b of ze)g(b);for(let b of ae)g(b);for(let b of Xe)g(b)}u(`declare var ${le}: any`);let w=new Set(t.flatMap((b)=>ee(b.code)));u(`type ${Ge}<T> = T extends readonly (infer E)[] ? E : T extends Iterable<infer E2> ? E2 : any`);for(let b of Xt(e)){if(w.has(b.name))continue;let v=b.iterable&&w.has(b.iterable)?`${Ge}<typeof ${b.iterable}>`:"any";u(`declare var ${b.name}: ${v}`)}}if(s.templateExpressions!==!1){if(r?.declarations)for(let g of r.declarations.split(`
|
|
37
|
+
`))u(g);let m=Kt(e).map((g)=>{let S=r?.events.get(g.offset??-1);if(S){g.anchor=!0;let w=g.code.trim(),b=/^([\w$]+)\s*=\s*([^=][\s\S]*)$/.exec(w),v=b?`void ((${b[2]}) satisfies __StxAssignedValue<typeof ${b[1]}>)`:/^[\w$]+(?:\.[\w$]+)*$/.test(w)?`${w} satisfies (($event: ${S}) => unknown)`:w,k=`;(($event: ${S}): void => { `;return{expression:g,statement:{text:`${k}${v} });`,prefixLength:k.length}}}return{expression:g,statement:Yt(g)}}).filter((g)=>g.statement!==null);if(m.push(...r?.checks||[]),m.length>0){let g=ne(e),S=Ve(g),w=Ut(t.map((y)=>y.code)),v=[...new Set(t.flatMap((y)=>ee(y.code)))].filter((y)=>/^[A-Z_$][\w$]*$/i.test(y)),k=0;if(v.length>0){u(Bt);for(let y of v)u(`function __StxRead_${y}() { return ${y} }`),u(`type __StxT_${y} = ${qe}<ReturnType<typeof __StxRead_${y}>>`);u(`;((${v.map((y)=>`${y}: __StxT_${y}`).join(", ")}) => {`),k=1}for(let{expression:y,statement:_}of m){let C=" ".repeat(k),O=y.offset===void 0?[]:S.filter((j)=>y.offset>=j.start&&y.offset<j.end),T=O.map((j)=>`;((${j.binding.replace(/[\r\n]/g," ")}: any) => { `).join(""),N=" });".repeat(O.length),F=y.offset===void 0?[]:qt(g,y.offset),P=F.length>0?`${F.map((j)=>`if (${Qe(j,w)}) `).join("")}{ `:"",M=F.length>0?" }":"";u(C+T+P+_.text+M+N,{line:y.line,column:y.column,expression:y,prefixLength:_.prefixLength+C.length+T.length+P.length,guardPrefixLength:C.length+T.length+P.length})}if(k>0)u("});")}}let p=!1;if(s.reference&&i[0]!==void 0&&i[0].trim()==="")i[0]=`/// <reference path=${JSON.stringify(s.reference.replace(/\\/g,"/"))} />`,p=!0;return u("export {}"),{text:i.join(`
|
|
38
38
|
`),lineMap:o,sourceLineCount:n.length,componentDependencies:r?.dependencies,referenced:p}}function fe(e){let s=[0];for(let t=0;t<e.length;t++)if(e.charCodeAt(t)===10)s.push(t+1);return s}function ie(e,s){let t=0,n=e.length-1;while(t<n){let i=Math.ceil((t+n)/2);if(e[i]<=s)t=i;else n=i-1}return{line:t+1,column:s-e[t]+1}}function re(e,s,t){let n=Math.min(Math.max(s,1),e.length)-1,i=n+1<e.length?e[n+1]-1:Number.MAX_SAFE_INTEGER;return Math.min(e[n]+Math.max(t,1)-1,i)}function et(e,s){if(!e.expression)return!1;return e.inGuard===!0||s===2774}function tt(e,s,t){let n=e.lineMap.get(s);if(!n)return s<=e.sourceLineCount?{line:s,column:t}:null;let i=n.expression?.anchor?0:Math.max(0,t-1-(n.prefixLength??0));return{line:n.line,column:n.column+i,expression:n.expression,inGuard:t<=(n.guardPrefixLength??0)}}var nt=["module","exports","require","props","$props","$bool","$num","defineProps","withDefaults","defineClientPayload","useServerData","useRuntimeConfig","useServerRuntimeConfig","state","derived","effect","batch","onMount","onDestroy","definePageMeta","useRoute","useRouter","useHead","useSeoMeta","setResponseStatus","setResponseHeader","notFound","ref","reactive","computed","watch","onMounted","onUnmounted","nextTick","defineEmits","defineExpose","defineSlots","provide","inject","useColorMode","useDark","useMediaQuery","useScrollLock","usePreferredDark","usePreferredLight","usePreferredReducedMotion","usePreferredContrast","window","document","console","confirm","alert","fetch","params"];var tn=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),it=nt.filter((e)=>!tn.has(e)).sort(),rt=[...H].sort(),nn=[...new Set([...it,...rt])].sort(),sn=new Set(it),rn=new Set(rt),on=new Set(nn),st=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function an(e,s){if(s==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ot(e,s){let t=[];for(let n of s){if(n.offset===void 0)continue;let i=n.kind==="server"?sn:rn;st.lastIndex=0;for(let o of n.code.matchAll(st)){let r=o.index+o[0].indexOf("{")+1;for(let a of o[1].matchAll(/[^,]+/g)){let c=a[0];if(/^\s*type\s/.test(c))continue;let u=/^\s*([A-Za-z_$][\w$]*)/.exec(c);if(!u)continue;let p=u[1];if(!on.has(p)||i.has(p))continue;let m=n.offset+r+a.index+u[0].length-p.length,g=e.slice(0,m),S=g.split(`
|
|
39
39
|
`).length;t.push({line:S,column:m-(g.lastIndexOf(`
|
|
40
40
|
`)+1)+1,offset:m,length:p.length,name:p,kind:n.kind,message:an(p,n.kind)})}}}return t}var W=G(require("node:path"),1),cn="@stacksjs/stx-typescript-plugin";function ln(e,s){let t=W.default.resolve(e);for(;;){let n=W.default.join(t,"tsconfig.json");if(s(n))return n;let i=W.default.dirname(t);if(i===t)return;t=i}}function at(e,s,t){let n=ln(e,t);if(!n)return;let i=new Set,o=(r)=>{if(i.has(r))return;i.add(r);let a=s(r);if(!a)return;let c=a.compilerOptions?.plugins;if(Array.isArray(c)){let p=c.find((g)=>g?.name===cn),m=Array.isArray(p?.libs)?p.libs.filter((g)=>typeof g==="string"):[];return p?{configPath:r,libs:m.map((g)=>W.default.resolve(W.default.dirname(r),g))}:null}let u=typeof a.extends==="string"?[a.extends]:Array.isArray(a.extends)?a.extends:[];for(let p of[...u].reverse()){if(typeof p!=="string"||!p.startsWith("."))continue;let m=W.default.resolve(W.default.dirname(r),p.endsWith(".json")?p:`${p}.json`),g=o(m);if(g!==void 0)return g}return};return o(n)??void 0}var ct=Symbol.for("@stacksjs/stx-typescript-plugin"),un=new Set([2300,2451,2403]);function Y(e){return e.endsWith(".stx")}function lt(e){return Y(e)||e.endsWith(".md")}function fn(e){if(!e)return;return B.existsSync(I.default.join(e,"stx-module.d.ts"))&&B.existsSync(I.default.join(e,"stx.d.ts"))?I.default.join(e,"stx-module.d.ts"):void 0}function dn(e,s=B.existsSync){let t=e;for(;;){let n=I.default.join(t,"node_modules","@stacksjs","stx","stx-module.d.ts");if(s(n))return n;let i=I.default.dirname(t);if(i===t)return;t=i}}function pn(e,s=I.default.join(ft.tmpdir(),"stx-typescript-plugin")){let t=e.map((i)=>`/// <reference path=${JSON.stringify(i.replace(/\\/g,"/"))} />`).join(`
|
|
41
41
|
`)+`
|
|
42
|
-
`,n=I.default.join(s,`${ut.createHash("sha1").update(t).digest("hex").slice(0,16)}.d.ts`);if(!B.existsSync(n))B.mkdirSync(s,{recursive:!0}),B.writeFileSync(n,t);return n}function gn(e,s,t,n){let i=(a)=>Je(s,{templateExpressions:Y(e),originDir:I.default.dirname(e),filePath:e,readComponent:n.readComponent,componentsDir:n.componentsDir,projectRoot:n.projectRoot,reference:a,runtimeGlobals:!a,contextScope:"global"}),o=i(n.declarations);if(n.declarations&&!o.referenced)o=i(void 0);let r=te(s);return{version:t,source:s,virtual:o,blocks:r,sourceStarts:fe(s),virtualStarts:fe(o.text),collisions:new Set(Ye(r))}}function mn(e,s){let t=e.findConfigFile(s,e.sys.fileExists);if(!t)return;let n=e.readConfigFile(t,e.sys.readFile);if(n.error)return;let i=e.parseJsonConfigFileContent(n.config,e.sys,I.default.dirname(t),void 0,t),o={};if(i.options.types)o.types=i.options.types;let r=i.options.paths;if(r){let a=i.options.baseUrl??i.options.pathsBasePath??I.default.dirname(t);o.paths={};for(let[c,u]of Object.entries(r))o.paths[c]=u.map((p)=>I.default.isAbsolute(p)?p:I.default.resolve(a,p))}return o}function hn(e,s={}){let t=e.typescript,n={},i=new Set,o=new WeakSet;return{create(r){let a=(l)=>{r.project.projectService.logger.info(`[stx-plugin] ${l}`)};if(r.languageService[ct])return o.add(r.project),a("already applied to this project by another registration of the plugin; leaving it as it is"),r.languageService;a("TypeScript stx plugin initialized");let{languageService:c,languageServiceHost:u}=r,p=(l)=>{let d=c[l];return typeof d==="function"?d.bind(c):()=>{return}},m=u.getScriptSnapshot?.bind(u),g=u.getScriptVersion?.bind(u),S=fn(s.declarationsDir);if(!S)a("the bundled stx declarations were not found; apps without their own fall back to `any`");let
|
|
42
|
+
`,n=I.default.join(s,`${ut.createHash("sha1").update(t).digest("hex").slice(0,16)}.d.ts`);if(!B.existsSync(n))B.mkdirSync(s,{recursive:!0}),B.writeFileSync(n,t);return n}function gn(e,s,t,n){let i=(a)=>Je(s,{templateExpressions:Y(e),originDir:I.default.dirname(e),filePath:e,readComponent:n.readComponent,componentsDir:n.componentsDir,projectRoot:n.projectRoot,reference:a,runtimeGlobals:!a,contextScope:"global"}),o=i(n.declarations);if(n.declarations&&!o.referenced)o=i(void 0);let r=te(s);return{version:t,source:s,virtual:o,blocks:r,sourceStarts:fe(s),virtualStarts:fe(o.text),collisions:new Set(Ye(r))}}function mn(e,s){let t=e.findConfigFile(s,e.sys.fileExists);if(!t)return;let n=e.readConfigFile(t,e.sys.readFile);if(n.error)return;let i=e.parseJsonConfigFileContent(n.config,e.sys,I.default.dirname(t),void 0,t),o={};if(i.options.types)o.types=i.options.types;let r=i.options.paths;if(r){let a=i.options.baseUrl??i.options.pathsBasePath??I.default.dirname(t);o.paths={};for(let[c,u]of Object.entries(r))o.paths[c]=u.map((p)=>I.default.isAbsolute(p)?p:I.default.resolve(a,p))}return o}function hn(e,s={}){let t=e.typescript,n={},i=new Set,o=new WeakSet;return{create(r){let a=(l)=>{r.project.projectService.logger.info(`[stx-plugin] ${l}`)};if(r.languageService[ct])return o.add(r.project),a("already applied to this project by another registration of the plugin; leaving it as it is"),r.languageService;a("TypeScript stx plugin initialized");let{languageService:c,languageServiceHost:u}=r,p=(l)=>{let d=c[l];return typeof d==="function"?d.bind(c):()=>{return}},m=u.getScriptSnapshot?.bind(u),g=u.getScriptVersion?.bind(u),S=fn(s.declarationsDir);if(!S)a("the bundled stx declarations were not found; apps without their own fall back to `any`");let w=(l)=>t.sys?.fileExists(l)??B.existsSync(l),b=(l)=>{let d=t.readConfigFile?.(l,(f)=>t.sys.readFile(f));return d&&!d.error?d.config:void 0},v=new Map,k=(l)=>{let d=I.default.dirname(l);if(!v.has(d)){let f=dn(d,w)??S,x=[];try{x=(at(d,b,w)?.libs??[]).filter(w)}catch(h){a(`could not read the stx entry of the project's tsconfig: ${String(h)}`)}v.set(d,f&&x.length>0?pn([f,...x]):f)}return v.get(d)},y=new Map,_=(l)=>{let d=m?.(l);return d?d.getText(0,d.getLength()):t.sys?.readFile(l)},C=()=>n.enabled!==!1;i.add(()=>{y.clear(),r.project.refreshDiagnostics?.()});let O=(l)=>{if(!lt(l)||!m)return;let d=`${g?.(l)||"0"}:${u.getProjectVersion?.()||""}`,f=y.get(l);if(f&&f.version===d&&[...f.virtual.componentDependencies||[]].every(([h,E])=>_(h)===E))return f;let x=m(l);if(!x)return;try{let h=r.project.getCurrentDirectory?.(),E=h?I.default.resolve(h,typeof r.config?.componentsDir==="string"?r.config.componentsDir:"components"):void 0,R=gn(l,x.getText(0,x.getLength()),d,{declarations:k(l),readComponent:_,componentsDir:E,projectRoot:h});return y.set(l,R),R}catch(h){a(`failed to build virtual document for ${l}: ${String(h)}`);return}},T=(l)=>Y(l)?O(l):void 0,N=(l,d)=>{let f=ie(l.virtualStarts,d);return tt(l.virtual,f.line,f.column)},F=(l,d)=>{let f=N(l,d);if(!f)return;return re(l.sourceStarts,f.line,f.column)},P=(l,d)=>{let f=ie(l.sourceStarts,d);return re(l.virtualStarts,f.line,f.column)},M=(l,d)=>{let f=F(l,d.start);if(f===void 0)return;let x=F(l,d.start+d.length);return{start:f,length:x!==void 0&&x>=f?x-f:d.length}},j=(l,d)=>l.blocks.some((f)=>f.offset!==void 0&&d>=f.offset&&d<=f.offset+f.code.length),de=(l)=>{let d=T(l.fileName);if(!d)return l;let f=M(d,l.textSpan);if(!f)return;let x=l.contextSpan?M(d,l.contextSpan):void 0;return{...l,textSpan:f,contextSpan:x}},pe=(l)=>l?.map(de).filter((d)=>d!==void 0),ge=(l)=>l?.filter((d)=>{let f=T(d.fileName);if(!f)return!0;let{line:x}=ie(f.virtualStarts,d.textSpan.start);return x<=f.virtual.sourceLineCount&&!f.virtual.lineMap.has(x)});if(m)u.getScriptSnapshot=(l)=>{let d=O(l);if(d)return t.ScriptSnapshot.fromString(d.virtual.text);return m(l)};let me=u.getCompilationSettings?.bind(u),pt=t.server?.ProjectKind!==void 0&&r.project.projectKind===t.server.ProjectKind.Inferred;if(me&&pt){let l=null,d;u.getCompilationSettings=()=>{let f=me();if(l===null)try{l=mn(t,r.project.getCurrentDirectory())}catch(x){a(`could not read the project's tsconfig: ${String(x)}`),l=void 0}if(!l)return f;if(d?.from!==f)d={from:f,options:{...f,...l.paths&&!f.paths?{paths:l.paths}:{},...l.types&&!f.types?{types:l.types}:{}}};return d.options}}let oe=(l,d)=>{let f=O(l);if(!f)return d;if(Y(l)&&!C())return[];let x=[];for(let h of d){let E=typeof h.messageText==="string"?h.messageText:h.messageText.messageText;if(un.has(h.code)){let V=E.match(/'([^']+)'/)?.[1];if(V&&f.collisions.has(V))continue}if(h.start===void 0){x.push(h);continue}let R=N(f,h.start);if(!R||et(R,h.code))continue;let D=re(f.sourceStarts,R.line,R.column),X=F(f,h.start+(h.length??0));x.push({...h,start:D,length:X!==void 0&&X>D?X-D:h.length??0})}return x},gt=p("getSemanticDiagnostics");c.getSemanticDiagnostics=(l)=>{let d=oe(l,gt(l)),f=T(l);if(!f||!C())return d;let x=c.getProgram?.()?.getSourceFile(l);for(let h of ot(f.source,f.blocks))d.push({file:x,start:h.offset,length:h.length,messageText:h.message,category:t.DiagnosticCategory?.Error??1,code:0,source:"stx"});return d};let mt=p("getSyntacticDiagnostics");c.getSyntacticDiagnostics=(l)=>oe(l,mt(l));let ht=p("getSuggestionDiagnostics");c.getSuggestionDiagnostics=(l)=>oe(l,ht(l));let he=p("getQuickInfoAtPosition");c.getQuickInfoAtPosition=(l,d,...f)=>{let x=T(l);if(!x)return he(l,d,...f);if(!C())return;let h=he(l,P(x,d),...f);if(!h)return h;let E=M(x,h.textSpan);return E?{...h,textSpan:E}:void 0};let xe=p("getCompletionsAtPosition");c.getCompletionsAtPosition=(l,d,f,...x)=>{let h=T(l);if(!h)return xe(l,d,f,...x);if(!C()||!j(h,d))return;let E=xe(l,P(h,d),{...f,includeCompletionsForModuleExports:!1},...x);if(!E)return E;let R=(D)=>D&&M(h,D);return{...E,optionalReplacementSpan:R(E.optionalReplacementSpan),entries:E.entries.filter((D)=>!D.name.startsWith("__stx")&&!D.name.startsWith("__Stx")).map((D)=>D.replacementSpan?{...D,replacementSpan:R(D.replacementSpan)}:D)}};let be=p("getCompletionEntryDetails");c.getCompletionEntryDetails=(l,d,...f)=>{let x=T(l);if(!x)return be(l,d,...f);let h=be(l,P(x,d),...f);return h?{...h,codeActions:void 0}:h};let Se=p("getSignatureHelpItems");c.getSignatureHelpItems=(l,d,...f)=>{let x=T(l);if(!x)return Se(l,d,...f);if(!C()||!j(x,d))return;let h=Se(l,P(x,d),...f),E=h&&M(x,h.applicableSpan);return h&&E?{...h,applicableSpan:E}:void 0};let ye=p("getDefinitionAndBoundSpan");c.getDefinitionAndBoundSpan=(l,d)=>{let f=T(l);if(!f)return we(ye(l,d));if(!C())return;let x=ye(l,P(f,d)),h=x&&M(f,x.textSpan);return x&&h?{...we(x),textSpan:h}:void 0};let we=(l)=>l&&{...l,definitions:ge(l.definitions)};for(let l of["getDefinitionAtPosition","getTypeDefinitionAtPosition","getImplementationAtPosition"]){let d=p(l);c[l]=(f,x,...h)=>{let E=T(f);if(E&&!C())return;return ge(d(f,E?P(E,x):x,...h))}}for(let l of["getReferencesAtPosition"]){let d=p(l);c[l]=(f,x,...h)=>{let E=T(f);if(E&&!C())return;return pe(d(f,E?P(E,x):x,...h))}}let xt=p("findReferences");c.findReferences=(l,d)=>{let f=T(l);if(f&&!C())return;return xt(l,f?P(f,d):d)?.map((x)=>{let h=de(x.definition);return h?{definition:h,references:pe(x.references)}:void 0}).filter((x)=>x!==void 0)};let bt=p("getDocumentHighlights");c.getDocumentHighlights=(l,d,f)=>{let x=T(l);if(x&&(!C()||!j(x,d)))return;return bt(l,x?P(x,d):d,f)?.map((h)=>{let E=T(h.fileName);if(!E)return h;return{...h,highlightSpans:h.highlightSpans.map((R)=>{let D=M(E,R.textSpan);return D?{...R,textSpan:D,contextSpan:R.contextSpan&&M(E,R.contextSpan)}:void 0}).filter((R)=>R!==void 0)}})};let St=p("getNavigationTree");c.getNavigationTree=(l)=>{let d=St(l),f=T(l);if(!f)return d;let x=(E)=>{let R=E.spans.map((V)=>M(f,V)).filter((V)=>V!==void 0);if(R.length===0)return;let D=E.nameSpan&&M(f,E.nameSpan),X=E.childItems?.map(x).filter((V)=>V!==void 0);return{...E,spans:R,nameSpan:D,childItems:X}},h={...d,spans:[{start:0,length:f.source.length}]};return C()?{...h,childItems:d.childItems?.map(x).filter((E)=>E!==void 0)}:{...h,childItems:[]}};let yt={getEncodedSemanticClassifications:()=>{return},getEncodedSyntacticClassifications:()=>{return},getSemanticClassifications:()=>[],getSyntacticClassifications:()=>[],getFormattingEditsForDocument:()=>[],getFormattingEditsForRange:()=>[],getFormattingEditsAfterKeystroke:()=>[],getNavigationBarItems:()=>[],getOutliningSpans:()=>[],getBraceMatchingAtPosition:()=>[],getTodoComments:()=>[],getDocCommentTemplateAtPosition:()=>{return},getJsxClosingTagAtPosition:()=>{return},getLinkedEditingRangeAtPosition:()=>{return},getSpanOfEnclosingComment:()=>{return},getCodeFixesAtPosition:()=>[],getApplicableRefactors:()=>[],getEditsForRefactor:()=>{return},getRenameInfo:()=>({canRename:!1,localizedErrorMessage:"Rename is not supported in .stx files."}),findRenameLocations:()=>{return},provideInlayHints:()=>[],prepareCallHierarchy:()=>{return},provideCallHierarchyIncomingCalls:()=>[],provideCallHierarchyOutgoingCalls:()=>[],getFileReferences:()=>[]};for(let[l,d]of Object.entries(yt)){let f=c[l];if(typeof f!=="function")continue;let x=f.bind(c);c[l]=(h,...E)=>typeof h==="string"&&Y(h)?d():x(h,...E)}return c[ct]=!0,a("Language service proxy created"),c},getExternalFiles(r){if(o.has(r))return[];return r.getFileNames().filter(lt)},onConfigurationChanged(r){n={...n,...r};for(let a of i)a()}}}var dt=hn;module.exports=dt;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/stx-vscode",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.631",
|
|
5
5
|
"description": "stx language support for VS Code extensions to embed: the hovers, completions, diagnostics, grammar, snippets, language configuration and TypeScript server plugin behind the stx extension.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|