@stacksjs/stx-vscode 0.2.794 → 0.2.798
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.
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)n++;continue}if(
|
|
3
|
-
`)return-1;if(
|
|
4
|
-
`)s+=" ",t++;continue}if(
|
|
1
|
+
var vt=Object.create;var{getPrototypeOf:_t,defineProperty:Ee,getOwnPropertyNames:Tt}=Object;var ve=Object.prototype.hasOwnProperty;function Ct(e){return this[e]}var kt,At,z=(e,s,t)=>{var n=e!=null&&typeof e==="object";if(n){var r=s?kt??=new WeakMap:At??=new WeakMap,i=r.get(e);if(i)return i}t=e!=null?vt(_t(e)):{};let o=s||!e||!e.__esModule||!ve.call(e,"default")?Ee(t,"default",{value:e,enumerable:!0}):t;if(e&&typeof e==="object"||typeof e==="function"){for(let a of Tt(e))if(!ve.call(o,a))Ee(o,a,{get:Ct.bind(e,a),enumerable:!0})}if(n)r.set(e,o);return o};var pt=require("node:crypto"),V=require("node:fs"),gt=require("node:os"),j=z(require("node:path"));var fe=["browserQuery","BrowserQueryBuilder","BrowserQueryError","browserAuth","configureBrowser","getBrowserConfig","createBrowserDb","createBrowserModel","isBrowser","debounce","throttle","retry","sleep","wait","delay","waitUntil","waitWhile","lazy","clamp","rand","readableSize","useActiveElement","useIntervalFn","useObjectUrl"];var me=z(require("node:path"),1);function Rt(e,s){let t=e[s],n=s+1;while(n<e.length){if(e[n]==="\\"){n+=2;continue}if(e[n]===t)return n+1;n++}return e.length}function Dt(e,s){let t=s+1;while(t<e.length){if(e[t]==="\\"){t+=2;continue}if(e[t]==="`")return t+1;if(e[t]==="$"&&e[t+1]==="{"){if(t=_e(e,t+2),t<e.length)t++;continue}t++}return e.length}function _e(e,s){let t=1,n=s,r="{",i="";while(n<e.length){let o=e[n];if(o==="\\"){n+=2;continue}if(o==='"'||o==="'"){n=Rt(e,n),r=X,i="";continue}if(o==="`"){n=Dt(e,n),r=X,i="";continue}if(o==="/"&&e[n+1]==="/"){while(n<e.length&&e[n]!==`
|
|
2
|
+
`)n++;continue}if(o==="/"&&e[n+1]==="*"){n+=2;while(n<e.length&&e.slice(n,n+2)!=="*/")n++;n+=2;continue}if(o==="/"&&Te(r,i)){let a=Ce(e,n);if(a!==-1){n=a,r=X,i="";continue}}if(o==="{")t++;else if(o==="}"){if(t--,t===0)return n}if(/[\w$]/.test(o))i=/[\w$]/.test(r)?i+o:o,r=o;else if(!/\s/.test(o))r=o,i="";n++}return e.length}var Pt=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]);function Te(e,s){if(s)return Pt.has(s);return!(e===")"||e==="]"||e===X)}var X="\x00";function Ce(e,s){let t=s+1,n=!1;while(t<e.length){let r=e[t];if(r===`
|
|
3
|
+
`)return-1;if(r==="\\"){t+=2;continue}if(r==="[")n=!0;else if(r==="]")n=!1;else if(r==="/"&&!n){t++;while(t<e.length&&/[a-z]/i.test(e[t]))t++;return t}t++}return-1}function O(e){let s="",t=0,n="",r="";while(t<e.length){let i=e.slice(t,t+2);if(i==="//"){while(t<e.length&&e[t]!==`
|
|
4
|
+
`)s+=" ",t++;continue}if(i==="/*"){while(t<e.length&&e.slice(t,t+2)!=="*/")s+=e[t]===`
|
|
5
5
|
`?`
|
|
6
|
-
`:" ",t++;s+=" ",t+=2;continue}let
|
|
6
|
+
`:" ",t++;s+=" ",t+=2;continue}let o=e[t];if(o==='"'||o==="'"){let a=o;s+=" ",t++;while(t<e.length&&e[t]!==a){if(e[t]==="\\"){s+=" ",t+=2;continue}s+=e[t]===`
|
|
7
7
|
`?`
|
|
8
|
-
`:" ",t++}s+=" ",t++,n=
|
|
8
|
+
`:" ",t++}s+=" ",t++,n=X,r="";continue}if(o==="/"&&Te(n,r)){let a=Ce(e,t);if(a!==-1){s+=`/${" ".repeat(a-t-2)}/`,t=a,n=X,r="";continue}}if(o==="`"){s+=" ",t++;while(t<e.length&&e[t]!=="`"){if(e[t]==="\\"){s+=" ",t+=2;continue}if(e[t]==="$"&&e[t+1]==="{"){let a=t+2,c=_e(e,a);if(s+=" ",s+=O(e.slice(a,c)),c<e.length)s+=" ";t=c+1;continue}s+=e[t]===`
|
|
9
9
|
`?`
|
|
10
|
-
`:" ",t++}s+=" ",t++,n=
|
|
10
|
+
`:" ",t++}s+=" ",t++,n=X,r="";continue}if(s+=o,t++,/[\w$]/.test(o))r=/[\w$]/.test(n)?r+o:o,n=o;else if(!/\s/.test(o))n=o,r=""}return s}function ne(e){let s=new Uint16Array(e.length),t=0,n=!0;for(let r=0;r<e.length;r++){let i=e[r];if(i===")"||i==="]"||i==="}")if(t===0)n=!1;else t--;if(s[r]=t,i==="("||i==="["||i==="{")t++}return{depths:s,balanced:n&&t===0}}function ke(e){let s=e.indexOf(" as ");if(s!==-1){let i=e.slice(0,s).trim(),o=e.slice(s+4).trim();return i&&o?{arrayExpr:i,itemVar:o}:null}let t=/^\s*(.+?)\s+in\s+([\s\S]+)$/.exec(e);if(!t)return null;let n=t[1].trim().replace(/^\(([\s\S]*)\)$/,"$1").trim(),r=t[2].trim();return n&&r?{arrayExpr:r,itemVar:n}:null}var Z=["batch","cachedQuery","clearServerData","computed","configureFetch","defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","defineStore","derived","effect","flushKeptState","forgetKeptState","goBack","goForward","inject","invalidateRoute","isDerived","isSignal","keptState","memo","navigate","nextTick","onBeforeMount","onBeforeUnmount","onDestroy","onMount","onMounted","onUnmounted","peek","provide","reactive","ref","refDebounced","refresh","registerStoresClient","setKeptScope","setRouteParams","sharedRequest","state","untrack","useAsync","useBroadcastStream","useClickOutside","useColorMode","useCookie","useCounter","useDark","useDebounce","useDebounceFn","useDebouncedValue","useDocumentVisibility","useEventListener","useFetch","useFocus","useHead","useId","useInterval","useLocalStorage","useMediaQuery","useModel","useMutation","useNativeDesktop","useOptimistic","usePreferredContrast","usePreferredDark","usePreferredLight","usePreferredReducedMotion","useQuery","useReactiveProp","useRef","useRoute","useRouteParam","useRouteParams","useScrollLock","useSearchParams","useSeoMeta","useSessionStorage","useSlots","useStore","useThrottle","useThrottleFn","useTimeout","useTimeoutFn","useToggle","useWebSocket","watch","watchEffect","watchMultiple","withDefaults"];var It=["defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","withDefaults"];var Dn=Z.filter((e)=>!It.includes(e));var Lt=["x-text","x-html","x-model","x-show","x-if","x-for","x-cloak","x-ref","x-data","x-bind","x-class","x-style","x-tooltip","x-tooltip-position"],Mt=["x-init","x-transition","x-effect","x-on"],Pn=[...Lt,...Mt];var se=z(require("node:fs"),1),U=z(require("node:path"),1);function Ae(e,s,t,n){let r=0;for(let i=s;i<e.length;i++)if(e[i]===t)r++;else if(e[i]===n&&!(n===">"&&e[i-1]==="=")){if(--r===0)return i}return-1}function Ot(e){let s=O(e),t=0,n=0,r=[];for(let i=0;i<s.length;i++)if("([{".includes(s[i]))t++;else if(")]}".includes(s[i]))t--;else if(s[i]===","&&t===0)r.push(e.slice(n,i).trim()),n=i+1;return r.push(e.slice(n).trim()),r}function de(e,s){let t=O(e),n=new RegExp(`\\b(?:${s.map((r)=>r.replace(/[$]/g,"\\$&")).join("|")})\\s*(?=[<(])`,"g");for(let r of t.matchAll(n)){let i=r.index+r[0].length,o="";if(t[i]==="<"){let c=Ae(t,i,"<",">");if(c<0)continue;o=e.slice(i+1,c),i=c+1;while(/\s/.test(t[i]||"")&&i<t.length)i++}if(t[i]!=="(")continue;let a=Ae(t,i,"(",")");if(a>=0)return{type:o,args:Ot(e.slice(i+1,a))}}return null}var Re=`
|
|
11
11
|
type __StxCtor<T> = T extends StringConstructor ? string : T extends NumberConstructor ? number : T extends BooleanConstructor ? boolean : T extends ArrayConstructor ? unknown[] : T extends ObjectConstructor ? object : T extends readonly unknown[] ? __StxCtor<T[number]> : T extends abstract new (...args: any[]) => infer V ? V : unknown;
|
|
12
12
|
type __StxWiden<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T;
|
|
13
13
|
type __StxOption<T> = T extends { type: infer C } ? __StxCtor<C> : T extends { default: infer D } ? D extends (...args: any[]) => infer V ? V : __StxWiden<D> : __StxCtor<T>;
|
|
@@ -15,28 +15,39 @@ 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
|
|
19
|
-
`)}),
|
|
18
|
+
`;function De(e,s){let t=[],n={defineProps:["defineProps"],defineEmits:["defineEmits"],withDefaults:["withDefaults"]},r=O(e),i=e.replace(/\bimport\s+(?:type\s+)?(\{[^}]*\}|\*\s+as\s+[\w$]+|[\w$]+)\s+from\s*(['"])([^'"]+)\2\s*;?/g,(b,C,y,m,S)=>{if(r.slice(S,S+6)!=="import")return b;if(m.endsWith(".stx"))return"";let E=`${s}Import${t.length}`;if(t.push(`import * as ${E} from ${JSON.stringify(m)};`),C.startsWith("*"))return`import ${C.replace(/^\*\s+as\s+/,"")} = ${E};`;if(!C.startsWith("{"))return`import ${C} = ${E}.default;`;return C.slice(1,-1).split(",").map((g)=>{let[v,k=v]=g.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(!v)return"";if(/^(?:stx|@stacksjs\/stx)(?:\/|$)/.test(m)&&v in n)n[v].push(k);return`import ${k} = ${E}.${v};`}).join(`
|
|
19
|
+
`)}),o=de(e,n.defineProps),a=de(e,n.defineEmits),c=de(e,n.withDefaults);if(!o&&!a)return{declarations:"",props:null,events:null};let u=[],p=null,w=null;if(o){u.push(`const __options = (${o.args[0]||"{}"}) as const;`),u.push(`const __defaults = (${c?.args[1]||"{}"});`);let b=o.type||"__StxOptions<typeof __options>";u.push(`export type __StxProps = __StxDefaults<${b}, 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[]>"};`),w=`${s}.__StxEvents`;return{declarations:`${t.join(`
|
|
20
20
|
`)}
|
|
21
21
|
namespace ${s} {
|
|
22
|
-
${
|
|
22
|
+
${i}
|
|
23
23
|
${u.join(`
|
|
24
24
|
`)}
|
|
25
|
-
}`,props:p,events:
|
|
26
|
-
`).length,column:
|
|
27
|
-
`)}},
|
|
28
|
-
`):"",checks:n,events:
|
|
29
|
-
`,s-1)+1;return s-t+1}function
|
|
30
|
-
`)s[
|
|
31
|
-
`)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
`)}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
`).length;t.push({line:
|
|
40
|
-
`)
|
|
25
|
+
}`,props:p,events:w}}var Q=z(require("node:fs"),1),D=z(require("node:path"),1);function Ie(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}var Pe=new Map;function Le(e,s=!0){let t=Pe.get(e);if(s&&t)return t;let n=new Map,r=[D.default.join(e,"src"),D.default.join(e,"dist"),e];function i(o,a){if(a>6)return;let c;try{c=Q.default.readdirSync(o,{withFileTypes:!0})}catch{return}for(let u of c){let p=D.default.join(o,u.name);if(u.isDirectory()){if(u.name==="node_modules"||u.name.startsWith("."))continue;i(p,a+1)}else if(u.isFile()&&u.name.endsWith(".stx")){let w=u.name.slice(0,-4);if(!n.has(w))n.set(w,p);let b=w.toLowerCase();if(!n.has(b))n.set(b,p);let C=Ie(w);if(!n.has(C))n.set(C,p)}}}for(let o of r)if(i(o,0),n.size>0)break;if(s)Pe.set(e,n);return n}function Me(e,s){if(e.startsWith(".")||e.startsWith("/"))return null;let t=s;while(!0){let n=D.default.join(t,"node_modules",e);try{if(Q.default.statSync(n).isDirectory())return n}catch{}let r=D.default.dirname(t);if(r===t)return null;t=r}}function Oe(e,s,t={}){return[D.default.resolve(D.default.dirname(s),`${e}.stx`),D.default.resolve(D.default.dirname(s),e),D.default.resolve(t.componentsDir||"components",`${e}.stx`),D.default.resolve(t.componentsDir||"components",e),e.endsWith(".stx")?e:`${e}.stx`]}function je(e){let s=e.endsWith(".stx")?e.slice(0,-4):e,t=s.split("-").map((r)=>r.charAt(0).toUpperCase()+r.slice(1)).join(""),n=Ie(s);return[s,t,n]}function jt(e,s){let[t,n,r]=je(e);for(let i of[t,t.toLowerCase(),n,r]){let o=s?.__importedComponents?.get(i);if(o!==void 0)return o}}function*Nt(e,s,t={},n){let r=je(e);if(r[0].startsWith("./")||r[0].startsWith("../")){yield D.default.resolve(D.default.dirname(s),`${r[0]}.stx`);return}let i=[...new Set(r.map((c)=>`${c}.stx`))],o=t.projectRoot||process.cwd(),a=[...n?.__originalFilePath?[D.default.join(D.default.dirname(n.__originalFilePath),"components")]:[],...t.componentsDir?[t.componentsDir]:[],D.default.join(D.default.dirname(s),"components"),D.default.resolve(o,"src/components"),D.default.resolve(o,"components"),D.default.resolve("/home/runner/work/stx/stx/packages/stx/src","components")];for(let c of new Set(a)){for(let u of i)yield D.default.join(c,u);try{for(let u of Q.default.readdirSync(c,{withFileTypes:!0}))if(u.isDirectory())for(let p of i)yield D.default.join(c,u.name,p)}catch{}}}function Ne(e,s,t={},n){let r=jt(e,n);if(r!==void 0)return r;for(let i of Nt(e,s,t,n))try{if(Q.default.statSync(i,{throwIfNoEntry:!1})?.isFile())return i}catch{}return null}var Be=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 Fe(e){if(e.includes("-")||e==="component")return!1;if(/^[A-Z]/.test(e))return!/[a-z]/.test(e)&&[...Be].some((s)=>s.toLowerCase()===e.toLowerCase());return Be.has(e)||/[A-Z]/.test(e)}function*Bt(e){let s=/<([A-Za-z][\w.-]*)(?=[\s/>])/g,t;while(t=s.exec(e)){let n=s.lastIndex,r=[];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 i=/^[^\s=/>]+/.exec(e.slice(n))?.[0];if(!i){n++;continue}let o=n;n+=i.length;while(/\s/.test(e[n]||""))n++;if(e[n]!=="="){r.push({name:i,value:!0,offset:o,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 w=O(e.slice(n)),b=1,C=0;for(;C<w.length;C++){if(w[C]==="{")b++;if(w[C]==="}"&&--b===0)break}n+=C}else if(u)while(n<e.length&&e[n]!==a)n++;else while(n<e.length&&!/[\s/>]/.test(e[n]))n++;if(r.push({name:i,value:e.slice(p,n),offset:p,braced:c}),u||c)n++}s.lastIndex=n,yield{name:t[1],offset:t.index,attributes:r}}}function We(e,s,t){let n=[],r=[Re,"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 __StxStaticProp<P, K> = __StxProp<P, K> extends infer T ? boolean extends T ? T | "true" | "false" : T : never;','type __StxEvent<E, K> = K extends keyof E ? E[K] extends readonly unknown[] ? number extends E[K]["length"] ? E[K][0] : Exclude<E[K]["length"], 0 | 1> extends never ? E[K][0] : E[K] : E[K] : any;'],i=new Map,o=new Map,a=new Map,c=t.scriptCode(e,t.filePath),u=O(c);for(let y of c.matchAll(/\bimport\s+(\{[^}]+\}|[\w$]+)\s+from\s*['"]([^'"]+)['"]/g)){if(u.slice(y.index,y.index+6)!=="import")continue;let m=y[2],S=U.default.isAbsolute(m)||m.startsWith(".")?U.default.resolve(U.default.dirname(t.filePath),m):Me(m,U.default.dirname(t.filePath));if(!S)continue;let E=S.endsWith(".stx")?S:se.default.existsSync(`${S}.stx`)?`${S}.stx`:void 0,g=E?null:Le(S,!1),v=y[1].startsWith("{")?y[1].slice(1,-1).split(","):[y[1]];for(let k of v){let[_,A=_]=k.trim().split(/\s+as\s+/),I=E||g?.get(_)||g?.get(_.toLowerCase());if(I)a.set(A,I),a.set(A.toLowerCase(),I),a.set(A.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),I)}}for(let y of s.matchAll(/@import\s*\(([^)]+)\)/g))for(let m of y[1].matchAll(/['"]([^'"]+)['"]/g)){let S=Oe(m[1],t.filePath,t).find((E)=>se.default.statSync(E,{throwIfNoEntry:!1})?.isFile());if(S)a.set(U.default.basename(m[1]).replace(/\.stx$/,""),S)}let p={__importedComponents:a},w=new Map,b=(y,m,S)=>{let E=e.slice(0,y);return{code:m,offset:y,attribute:S,anchor:!0,kind:"directive",line:E.split(`
|
|
26
|
+
`).length,column:y-E.lastIndexOf(`
|
|
27
|
+
`)}},C=(y,m,S)=>n.push({expression:y,statement:{text:m+y.code+S,prefixLength:m.length}});for(let y of Bt(s)){if(Fe(y.name)||y.name==="component")continue;let m=Ne(y.name,t.filePath,t,p);if(!m)continue;let S=w.get(m);if(!S){let g;try{g=t.readComponent?t.readComponent(m):se.default.readFileSync(m,"utf8")}catch{continue}if(g===void 0)continue;o.set(m,g),S=De(t.scriptCode(g,m),`__StxComponent${w.size}`),w.set(m,S),r.push(S.declarations)}let E=[];for(let g of y.attributes){let{name:v,offset:k}=g,_=g.value===!0?"true":g.value;if(v.startsWith("@")||v.startsWith("v-on:")){if(S.events&&g.value!==!0)i.set(k,`__StxEvent<${S.events}, ${JSON.stringify(v.replace(/^@|^v-on:/,"").split(".")[0])}>`);continue}let A=/^v-model(?::([\w-]+))?(?:\.[\w-]+)*$/.exec(v);if(v.startsWith("v-")&&!v.startsWith("v-bind:")&&!A)continue;if(/^(?:x-|:)(?:if|for|show|key|else)(?:$|[.:-])/.test(v))continue;let I=(A?A[1]||"modelValue":v.replace(/^:|^v-bind:/,"")).replace(/-([a-z])/g,(F,W)=>W.toUpperCase());if(E.push(I),!S.props)continue;let N=v.startsWith(":")||v.startsWith("v-bind:")||!!A||g.braced,R=N?_:g.value!==!0?JSON.stringify(_):"true",P=!N&&g.value!==!0&&(_==="true"||_==="false");C(b(k,R,v),";void ((",`) satisfies ${P?"__StxStaticProp":"__StxProp"}<${S.props}, ${JSON.stringify(I)}>);`)}if(S.props){let g=[...new Set(E)].map((k)=>`${JSON.stringify(k)}: undefined as any`).join(", "),v=b(y.offset,`<${y.name}>`);n.push({expression:v,statement:{text:`;void ({ ${g} } satisfies ${S.props} & Record<string, unknown>);`,prefixLength:0}})}}return{declarations:w.size?r.join(`
|
|
28
|
+
`):"",checks:n,events:i,dependencies:o}}function Ve(e){if(!e.includes("#")&&!e.includes("v-slot:")&&!e.includes("data-stx-slot-binding"))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 r of e.matchAll(n)){let i=r[0];if(/^<\/template\s*>$/i.test(i)){let o=t.pop();if(o)o.end=r.index}else if(/^<template\b/i.test(i)&&!/\/\s*>$/.test(i)){let a=[...i.slice(9).matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g)].find((p)=>/^(?:#[\w-]+|v-slot:[\w-]+|data-stx-slot-binding)$/i.test(p[1])),c=(a?.[2]??a?.[3])?.trim();if(c&&a?.[1]==="data-stx-slot-binding")try{c=decodeURIComponent(c)}catch{c=void 0}let u=c?{start:r.index+i.length,end:e.length,binding:c}:void 0;if(t.push(u),u)s.push(u)}}return s}var Ge=/<script(\s[^>]*)?>([\s\S]*?)<\/script>/gi;function Ft(e){let s=(t)=>t.replace(/[^\n]/g," ");return e.replace(/<!--[\s\S]*?-->/g,s).replace(/\{\{--[\s\S]*?--\}\}/g,s)}function ie(e){let s=[],t=Ft(e);Ge.lastIndex=0;let n;while((n=Ge.exec(t))!==null){let r=(n[1]||"").trim(),i=(n[0].match(/^<script(?:\s[^>]*)?>/i)?.[0]??"<script>").length,o=(n[0].match(/<\/script\s*>$/i)?.[0]??"</script>").length,a=n.index+i,c=n.index+n[0].length-o,u=e.slice(a,c);if(/\bsrc\s*=/.test(r))continue;let p=r.match(/\btype\s*=\s*["']([^"']+)["']/i);if(p&&!/^(?:module|text\/(?:javascript|typescript))$/i.test(p[1]))continue;let w=/\bserver\b/.test(r)?"server":/\bclient\b/.test(r)?"client":"plain",b=J(e,a);s.push({kind:w,code:u,startLine:b,startColumn:ee(e,a),offset:a,attrs:r})}return s}function J(e,s){let t=1;for(let n=0;n<s&&n<e.length;n++)if(e.charCodeAt(n)===10)t++;return t}function ee(e,s){let t=e.lastIndexOf(`
|
|
29
|
+
`,s-1)+1;return s-t+1}function oe(e){let s=e.split(""),t=(r,i)=>{for(let o=r;o<i&&o<s.length;o++)if(s[o]!==`
|
|
30
|
+
`)s[o]=" "},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 r of n){r.lastIndex=0;let i;while((i=r.exec(e))!==null)t(i.index,i.index+i[0].length)}return s.join("")}function Ue(e){let s=0,t="";for(let n=0;n<e.length;n++){let r=e[n];if(t){if(r==="\\"){n++;continue}if(r===t)t="";continue}if(r==='"'||r==="'"||r==="`"){t=r;continue}if(r==="("||r==="["||r==="{"){s++;continue}if(r===")"||r==="]"||r==="}"){s--;continue}if(r==="|"&&s===0){if(e[n+1]==="|"){n++;continue}if(e[n-1]==="|")continue;return e.slice(0,n)}}return e}var qe=new Set([":for","x-for","v-for"]),ae=/(?:^|\s)((?::|x-|v-|@)[\w.:-]+)\s*=\s*(["'])([\s\S]*?)\2/g,ge="__stx_interpolated",Ke="__StxElement",Ye="__StxTemplateValue",Wt=`type ${Ye}<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? (T extends () => infer V ? T & V : T) : T`;function He(e){return e.replace(/\{\{[\s\S]*?\}\}/g,ge).replace(/\{!![\s\S]*?!!\}/g,ge)}function Vt(e,s,t="0"){let n=`__stxScript${t}`;while((e+s).includes(n))n+="_";let r=new Map,i=[],o=[],a=O(e),c=ce(e),u=[],p=0;for(let S of a.matchAll(/\{\{([\s\S]*?)\}\}|\{!!([\s\S]*?)!!\}/g)){let E=S.index,g=e.slice(E,E+S[0].length),v=S[1]!==void 0,k=g.slice(v?2:3,v?-2:-3),_=o.length,A=q(c,E),I=q(c,E+(v?2:3));o.push({code:Ue(k),...I});let N=`${n}_${_}`,R=g.split(`
|
|
31
|
+
`),P=R[0].length;R[0]=N+" ".repeat(Math.max(0,P-N.length));for(let B=1;B<R.length;B++)R[B]=R[B].replace(/[^\r]/g," ");let F=r.get(A.line)??[],W=F.at(-1),H=A.column+(W?W.generatedEnd-W.sourceEnd:0);F.push({sourceStart:A.column,sourceEnd:A.column+P,generatedStart:H,generatedEnd:H+R[0].length}),r.set(A.line,F),u.push(e.slice(p,E),R.join(`
|
|
32
|
+
`)),p=E+g.length}u.push(e.slice(p));let w=u.join("");if(!o.length)return{code:w,columns:r,declarations:i};let{imports:b,body:C}=qt(s),y=[],m=0;for(let S of b.split(/\n(?=import\b)/)){if(!S.trim())continue;let E=/^import\s+(?:type\s+)?([\s\S]+?)\s+from\s*(['"][^'"]+['"])/.exec(S);if(!E){i.push({text:S});continue}let g=`${n}Module${m++}`;i.push({text:`import * as ${g} from ${E[2]}`});let v=E[1],k=/\{([\s\S]*?)\}/.exec(v);for(let N of k?.[1].split(",")??[]){let[R,P=R]=N.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(R==="default")y.push(`const ${P} = ${g}.default; type ${P} = import(${E[2]}).default`);else if(R)y.push(`import ${P} = ${g}.${R}`)}let _=v.replace(/\{[\s\S]*?\}/,""),A=/\*\s+as\s+(\w+)/.exec(_);if(A)y.push(`import ${A[1]} = ${g}`);let I=/^\s*([\w$]+)/.exec(_)?.[1];if(I)y.push(`const ${I} = ${g}.default; type ${I} = import(${E[2]}).default`)}i.push({text:`namespace ${n}Scope {
|
|
33
|
+
${y.join(`
|
|
34
|
+
`)}
|
|
35
|
+
export async function read() {
|
|
36
|
+
${Je(C).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,"")}
|
|
37
|
+
return {`});for(let[S,E]of o.entries())i.push({text:`value${S}: (`}),i.push({text:E.code,origin:{line:E.line,column:E.column}}),i.push({text:"),"});i.push({text:`}
|
|
38
|
+
}
|
|
39
|
+
}`});for(let S=0;S<o.length;S++)i.push({text:`declare var ${n}_${S}: Awaited<ReturnType<typeof ${n}Scope.read>>['value${S}']`});return{code:w,columns:r,declarations:i}}function Gt(e,s){let t=0;for(let n of e){if(s<n.generatedStart)break;if(s<n.generatedEnd)return n.sourceStart+Math.min(s-n.generatedStart,n.sourceEnd-n.sourceStart);t=n.sourceEnd-n.generatedEnd}return s+t}function Qe(e,s){let t=0;for(let n of e){if(s<n.sourceStart)break;if(s<n.sourceEnd)return n.generatedStart+Math.min(s-n.sourceStart,n.generatedEnd-n.generatedStart);t=n.generatedEnd-n.sourceEnd}return s+t}var Kt=["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"],Ht=new RegExp(String.raw`^[ \t]*@(?:${Kt.join("|")})\b[ \t]*(\([^\n)]*\))?[ \t]*$`,"gm");function Je(e){return e.replace(Ht,(s)=>s.replace(/[^\n]/g," "))}var ze=new Set(["x-cloak","x-ref","x-transition","x-teleport","v-slot","x-hydrate",":key","x-tooltip","x-tooltip-position"]);function zt(e){let s=oe(e),t=[],n=/(@?)\{\{([\s\S]*?)\}\}|(@?)\{!!([\s\S]*?)!!\}/g,r;while((r=n.exec(s))!==null){if(r[1]||r[3])continue;let a=r[2]??r[4]??"",c=r[2]!==void 0?2:3,u=Ue(a);if(!u.trim())continue;let p=r.index+c+(u.length-u.trimStart().length);t.push({code:u.trim(),line:J(s,p),column:ee(s,p),offset:p,kind:"interpolation"})}let i=/@(if|elseif|else\s+if|unless)\b\s*\(/g;while((r=i.exec(s))!==null){let o=r.index+r[0].length-1,a=0,c=o;for(;c<s.length;c++){let b=s[c];if(b==="(")a++;else if(b===")"){if(a--,a===0)break}}if(a!==0)continue;let u=s.slice(o+1,c),p=u.trim();if(i.lastIndex=c+1,!p)continue;let w=o+1+(u.length-u.trimStart().length);t.push({code:p,line:J(s,w),column:ee(s,w),offset:r.index,kind:"condition"})}ae.lastIndex=0;while((r=ae.exec(s))!==null){let o=r[1],a=r[3]??"",c=o.replace(/\..*$/,"").replace(/^([^:].*?):.*$/,"$1");if(ze.has(c)||ze.has(o))continue;if(!a.trim())continue;let u=r.index+r[0].indexOf(r[2],r[0].indexOf(o)+o.length)+1;if(qe.has(c)){let w=a.match(/\s+(?:in|of)\s+/);if(!w||w.index===void 0)continue;let b=a.slice(w.index+w[0].length),C=w.index+w[0].length+(b.length-b.trimStart().length);t.push({code:He(b.trim()),line:J(s,u+C),column:ee(s,u+C),offset:u+C,kind:"directive",attribute:c});continue}let p=a.length-a.trimStart().length;t.push({code:He(a.trim()),line:J(s,u+p),column:ee(s,u+p),offset:u+p,kind:"directive",attribute:c})}return t.sort((o,a)=>o.line-a.line||o.column-a.column),t}var Xt=2000;function Zt(e,s){let t=0,n=Math.min(e.length,s+Xt);for(let r=s;r<n;r++){let i=e[r];if(i==="(")t++;else if(i===")"){if(t--,t===0)return e.slice(s+1,r)}}return null}function Ut(e){let s=new Map,t=(a,c)=>{let u=a.split(/[,[\]{}()\s]+/).filter(Boolean);for(let p of u){let w=p.replace(/^\.\.\./,"").trim();if(!/^\$?[A-Z_$][\w$]*$/i.test(w))continue;let b=u.length===1?c:void 0,C=s.get(w);if(!C)s.set(w,{name:w,iterable:b});else if(C.iterable!==b)C.iterable=void 0}},n=/^\$?[A-Z_$][\w$]*$/i,r=(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=ke(c);if(!u)continue;t(u.itemVar.replace(/=>/g," "),r(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"?r(a[3]):void 0);for(let a of e.matchAll(/@for\s*\(\s*(?:let|const|var)\s+([\w$]+)\s*[=;]/g))t(a[1]);let i=oe(e);ae.lastIndex=0;let o;while((o=ae.exec(i))!==null){let a=o[1].replace(/\..*$/,"");if(!qe.has(a))continue;let c=o[3].match(/\s+(?:in|of)\s+/);if(!c||c.index===void 0)continue;t(o[3].slice(0,c.index),r(o[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 re(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 r=n.split(":").pop().split("=")[0].replace(/^\.\.\./,"").trim();if(/^[A-Z_$][\w$]*$/i.test(r))s.add(r)}return[...s].sort()}var Xe=["params","query","cookies","host","ip","setResponseStatus","setResponseHeader","notFound","request","url","definePageMeta","defineClientPayload","defineStore","props","$props"];function qt(e){let s=/^[ \t]*import\b[\s\S]*?(?:from\s*['"][^'"]*['"]|['"][^'"]*['"])[ \t]*;?[ \t]*$/gm,t=[],n=e.replace(s,(r)=>(t.push(r.trim()),r.split(`
|
|
40
|
+
`).map(()=>"").join(`
|
|
41
|
+
`)));return{imports:t.join(`
|
|
42
|
+
`),body:n}}var Ze=["$env","$user","$slot","$slots","$attrs","$props","$page","$route","$loop","loop","$errors","$csrf","$native","props","slot"];function et(e){let s=new Set,t=new Set;for(let n of e){let r=n.kind==="server"?s:t;for(let i of re(n.code))r.add(i)}return[...s].filter((n)=>t.has(n)).sort()}var Yt=/^\s*[A-Z_$][\w$]*\s*=[^=]/i;function Qt(e){let s=new Map,t=/!|===|!==|==|!=|&&|\|\||<|>|\btypeof\b|\binstanceof\b|\bin\b/;for(let n of e){let r=O(n),{depths:i,balanced:o}=ne(r);if(!o)continue;let a=/^([ \t]*(?:export[ \t]+)?const[ \t]+)([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=[ \t]*([^\n]+)$/gm;for(let c of r.matchAll(a)){let u=c.index??0;if(i[u+c[1].length]!==0)continue;let p=c[2],w=u+c[0].length-c[3].length,b=n.slice(w,u+c[0].length).trim().replace(/;$/,"").trim(),C=c[3],y=t.test(C)&&!/\bawait\b|=>|\bfunction\b|[{}]/.test(C)&&!/[,+\-*/%&|?:=]$/.test(b)&&ne(C).balanced;s.set(p,s.has(p)||!y?null:b)}}return new Map([...s].filter((n)=>n[1]!==null))}function tt(e,s,t=0,n=new Set){if(s.size===0||t>=5)return e;let r=O(e),i="",o=0;for(let a of r.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 w=r.slice(0,c).trimEnd(),b=r.slice(c+u.length).trimStart();if(w.endsWith(".")||/^:(?!:)/.test(b)&&/[{,]$/.test(w))continue;if(c>0&&/[\w$]/.test(r[c-1]))continue;i+=`${e.slice(o,c)}(${tt(p,s,t+1,new Set([...n,u]))})`,o=c+u.length}return i+e.slice(o)}function Jt(e,s){let t=/@(if|unless|elseif|else|endif|endunless)\b\s*(\()?/g,n=[],r;while((r=t.exec(e))!==null){if(r.index>s)break;let i=r[1];if(r.index===s){if(i==="elseif"){let a=n[n.length-1];if(a?.current)a.seen.push(a.current);if(a)a.current=null}break}if(i==="endif"||i==="endunless"){n.pop();continue}let o="";if(r[2]==="("){let a=0,c=r.index+r[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}}o=e.slice(u,c).trim(),t.lastIndex=c+1}if(i==="if")n.push({seen:[],current:o});else if(i==="unless")n.push({seen:[],current:`!(${o})`});else if(i==="elseif"||i==="else"){let a=n[n.length-1];if(!a)continue;if(a.current)a.seen.push(a.current);a.current=i==="elseif"?o:null}}return n.flatMap((i)=>[...i.seen.map((o)=>`!(${o})`),...i.current?[i.current]:[]]).filter(Boolean)}function en(e){let s=e.code.trim();if(!s)return null;if(e.attribute?.startsWith("@")){if(Yt.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 tn=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.{1,2}\/[^'"\n]*)\2/g;function pe(e,s){if(!s)return e;return e.replace(tn,(t,n,r,i)=>{let o=me.default.resolve(s,i).replace(/\\/g,"/");return`${n}${r}${o}${r}`})}function nn(e){return" ".repeat(Math.max(0,(e.startColumn??1)-1))}function sn(e){let s=new Set,t=O(e);for(let n of t.matchAll(/\bimport\s+(?:type\s+)?([\w$*{}\s,]+?)\s+from\b/g)){let r=n[1],i=/\{([^}]*)\}/.exec(r);for(let u of i?.[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 o=r.replace(/\{[^}]*\}/,""),a=/\*\s*as\s+([A-Z_$][\w$]*)/i.exec(o);if(a)s.add(a[1]);let c=/^\s*([A-Z_$][\w$]*)/i.exec(o);if(c&&c[1]!=="type")s.add(c[1])}return[...s].sort()}function nt(e,s={}){let t=ie(e),n=e.split(`
|
|
43
|
+
`),r=Array.from({length:n.length},()=>""),i=new Map,o=new Map,a=[],c=t.filter((y)=>y.kind==="server").map((y)=>y.code).join(`
|
|
44
|
+
`),u=s.filePath&&s.templateExpressions!==!1?We(e,oe(e),{filePath:s.filePath,componentsDir:s.componentsDir,projectRoot:s.projectRoot,readComponent:s.readComponent,scriptCode:(y,m)=>ie(y).map((S)=>pe(S.code,me.default.dirname(m))).join(`
|
|
45
|
+
`)}):void 0,p=new Set,w=[];for(let[y,m]of t.entries()){let S=Vt(nn(m)+m.code,c,String(y));for(let[v,k]of S.columns)o.set(m.startLine+v-1,k);for(let v of S.declarations)a.push({text:pe(v.text,s.originDir??""),origin:v.origin?{...v.origin,line:v.origin.line+m.startLine-1}:void 0});let E=Je(S.code),g=pe(E,s.originDir??"").split(`
|
|
46
|
+
`);g.forEach((v,k)=>{let _=m.startLine-1+k;if(_<r.length)r[_]=v,p.add(_)}),w.push(m.startLine-1+g.length-1)}for(let y of w){let m=r[y]?.trim()===""?y:y+1;if(m<r.length&&r[m].trim()===""&&(m===y||!p.has(m)))r[m]=";"}let b=(y,m)=>{for(let[S,E]of y.split(`
|
|
47
|
+
`).entries())if(r.push(E),m)i.set(r.length,S===0?m:{...m,line:m.line+S,column:1,prefixLength:0})};for(let y of a)b(y.text,y.origin);if(s.globals!==!1){b("");let y=new Set([...t.flatMap((g)=>re(g.code)),...t.flatMap((g)=>sn(g.code))]),m=(g)=>{if(!y.has(g))b(`declare var ${g}: any`)};if(s.runtimeGlobals!==!1){if(!y.has("window"))b("declare var window: any");for(let g of Z)m(g)}let S=[...new Set([...Xe,...fe,...Ze])].filter((g)=>s.runtimeGlobals!==!1||!Z.includes(g));if(s.contextScope==="global"){b("declare global {");for(let g of S)b(` var ${g}: any`);b("}")}else{for(let g of Xe)m(g);for(let g of fe)m(g);for(let g of Ze)m(g)}b(`declare var ${ge}: any`);let E=new Set(t.flatMap((g)=>re(g.code)));b(`type ${Ke}<T> = T extends readonly (infer E)[] ? E : T extends Iterable<infer E2> ? E2 : any`);for(let g of Ut(e)){if(E.has(g.name))continue;let v=g.iterable&&E.has(g.iterable)?`${Ke}<typeof ${g.iterable}>`:"any";b(`declare var ${g.name}: ${v}`)}}if(s.templateExpressions!==!1){if(u?.declarations)for(let m of u.declarations.split(`
|
|
48
|
+
`))b(m);let y=zt(e).map((m)=>{let S=u?.events.get(m.offset??-1);if(S){m.anchor=!0;let E=m.code.trim(),g=/^([\w$]+)\s*=\s*([^=][\s\S]*)$/.exec(E),v=g?`void ((${g[2]}) satisfies __StxAssignedValue<typeof ${g[1]}>)`:/^[\w$]+(?:\.[\w$]+)*$/.test(E)?`${E} satisfies (($event: ${S}) => unknown)`:E,k=`;(($event: ${S}): void => { `;return{expression:m,statement:{text:`${k}${v} });`,prefixLength:k.length}}}return{expression:m,statement:en(m)}}).filter((m)=>m.statement!==null);if(y.push(...u?.checks||[]),y.length>0){let m=oe(e),S=Ve(m),E=Qt(t.map((_)=>_.code)),v=[...new Set(t.flatMap((_)=>re(_.code)))].filter((_)=>/^[A-Z_$][\w$]*$/i.test(_)),k=0;if(v.length>0){b(Wt);for(let _ of v)b(`function __StxRead_${_}() { return ${_} }`),b(`type __StxT_${_} = ${Ye}<ReturnType<typeof __StxRead_${_}>>`);b(`;((${v.map((_)=>`${_}: __StxT_${_}`).join(", ")}) => {`),k=1}for(let{expression:_,statement:A}of y){let I=" ".repeat(k),N=_.offset===void 0?[]:S.filter((B)=>_.offset>=B.start&&_.offset<B.end),R=N.map((B)=>`;((${B.binding.replace(/[\r\n]/g," ")}: any) => { `).join(""),P=" });".repeat(N.length),F=_.offset===void 0?[]:Jt(m,_.offset),W=F.length>0?`${F.map((B)=>`if (${tt(B,E)}) `).join("")}{ `:"",H=F.length>0?" }":"";b(I+R+W+A.text+H+P,{line:_.line,column:_.column,expression:_,prefixLength:A.prefixLength+I.length+R.length+W.length,guardPrefixLength:I.length+R.length+W.length})}if(k>0)b("});")}}let C=!1;if(s.reference&&r[0]!==void 0&&r[0].trim()==="")r[0]=`/// <reference path=${JSON.stringify(s.reference.replace(/\\/g,"/"))} />`,C=!0;return b("export {}"),{text:r.join(`
|
|
49
|
+
`),lineMap:i,sourceLineCount:n.length,componentDependencies:u?.dependencies,referenced:C,scriptColumns:o}}function ce(e){let s=[0];for(let t=0;t<e.length;t++)if(e.charCodeAt(t)===10)s.push(t+1);return s}function q(e,s){let t=0,n=e.length-1;while(t<n){let r=Math.ceil((t+n)/2);if(e[r]<=s)t=r;else n=r-1}return{line:t+1,column:s-e[t]+1}}function le(e,s,t){let n=Math.min(Math.max(s,1),e.length)-1,r=n+1<e.length?e[n+1]-1:Number.MAX_SAFE_INTEGER;return Math.min(e[n]+Math.max(t,1)-1,r)}function st(e,s){if(!e.expression)return!1;return e.inGuard===!0||s===2774}function rt(e,s,t){let n=e.lineMap.get(s);if(!n)return s<=e.sourceLineCount?{line:s,column:Gt(e.scriptColumns?.get(s)??[],t)}:null;let r=n.expression?.anchor?0:Math.max(0,t-1-(n.prefixLength??0));return{line:n.line,column:n.column+r,expression:n.expression,inGuard:t<=(n.guardPrefixLength??0)}}var it=["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 rn=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),at=it.filter((e)=>!rn.has(e)).sort(),ct=[...Z].sort(),on=[...new Set([...at,...ct])].sort(),an=new Set(at),cn=new Set(ct),ln=new Set(on),ot=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function un(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 lt(e,s){let t=[];for(let n of s){if(n.offset===void 0)continue;let r=n.kind==="server"?an:cn;ot.lastIndex=0;for(let i of n.code.matchAll(ot)){let o=i.index+i[0].indexOf("{")+1;for(let a of i[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(!ln.has(p)||r.has(p))continue;let w=n.offset+o+a.index+u[0].length-p.length,b=e.slice(0,w),C=b.split(`
|
|
50
|
+
`).length;t.push({line:C,column:w-(b.lastIndexOf(`
|
|
51
|
+
`)+1)+1,offset:w,length:p.length,name:p,kind:n.kind,message:un(p,n.kind)})}}}return t}var K=z(require("node:path"),1),fn="@stacksjs/stx-typescript-plugin";function dn(e,s){let t=K.default.resolve(e);for(;;){let n=K.default.join(t,"tsconfig.json");if(s(n))return n;let r=K.default.dirname(t);if(r===t)return;t=r}}function ut(e,s,t){let n=dn(e,t);if(!n)return;let r=new Set,i=(o)=>{if(r.has(o))return;r.add(o);let a=s(o);if(!a)return;let c=a.compilerOptions?.plugins;if(Array.isArray(c)){let p=c.find((b)=>b?.name===fn),w=Array.isArray(p?.libs)?p.libs.filter((b)=>typeof b==="string"):[];return p?{configPath:o,libs:w.map((b)=>K.default.resolve(K.default.dirname(o),b))}: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 w=K.default.resolve(K.default.dirname(o),p.endsWith(".json")?p:`${p}.json`),b=i(w);if(b!==void 0)return b}return};return i(n)??void 0}var ft=Symbol.for("@stacksjs/stx-typescript-plugin"),pn=new Set([2300,2451,2403]);function te(e){return e.endsWith(".stx")}function dt(e){return te(e)||e.endsWith(".md")}function gn(e){if(!e)return;return V.existsSync(j.default.join(e,"stx-module.d.ts"))&&V.existsSync(j.default.join(e,"stx.d.ts"))?j.default.join(e,"stx-module.d.ts"):void 0}function mn(e,s=V.existsSync){let t=e;for(;;){let n=j.default.join(t,"node_modules","@stacksjs","stx","stx-module.d.ts");if(s(n))return n;let r=j.default.dirname(t);if(r===t)return;t=r}}function hn(e,s=j.default.join(gt.tmpdir(),"stx-typescript-plugin")){let t=e.map((r)=>`/// <reference path=${JSON.stringify(r.replace(/\\/g,"/"))} />`).join(`
|
|
41
52
|
`)+`
|
|
42
|
-
`,n=
|
|
53
|
+
`,n=j.default.join(s,`${pt.createHash("sha1").update(t).digest("hex").slice(0,16)}.d.ts`);if(!V.existsSync(n))V.mkdirSync(s,{recursive:!0}),V.writeFileSync(n,t);return n}function xn(e,s,t,n){let r=(a)=>nt(s,{templateExpressions:te(e),originDir:j.default.dirname(e),filePath:e,readComponent:n.readComponent,componentsDir:n.componentsDir,projectRoot:n.projectRoot,reference:a,runtimeGlobals:!a,contextScope:"global"}),i=r(n.declarations);if(n.declarations&&!i.referenced)i=r(void 0);let o=ie(s);return{version:t,source:s,virtual:i,blocks:o,sourceStarts:ce(s),virtualStarts:ce(i.text),collisions:new Set(et(o))}}function bn(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 r=e.parseJsonConfigFileContent(n.config,e.sys,j.default.dirname(t),void 0,t),i={};if(r.options.types)i.types=r.options.types;let o=r.options.paths;if(o){let a=r.options.baseUrl??r.options.pathsBasePath??j.default.dirname(t);i.paths={};for(let[c,u]of Object.entries(o))i.paths[c]=u.map((p)=>j.default.isAbsolute(p)?p:j.default.resolve(a,p))}return i}function Sn(e,s={}){let t=e.typescript,n={},r=new Set,i=new WeakSet;return{create(o){let a=(l)=>{o.project.projectService.logger.info(`[stx-plugin] ${l}`)};if(o.languageService[ft])return i.add(o.project),a("already applied to this project by another registration of the plugin; leaving it as it is"),o.languageService;a("TypeScript stx plugin initialized");let{languageService:c,languageServiceHost:u}=o,p=(l)=>{let d=c[l];return typeof d==="function"?d.bind(c):()=>{return}},w=u.getScriptSnapshot?.bind(u),b=u.getScriptVersion?.bind(u),C=gn(s.declarationsDir);if(!C)a("the bundled stx declarations were not found; apps without their own fall back to `any`");let y=(l)=>t.sys?.fileExists(l)??V.existsSync(l),m=(l)=>{let d=t.readConfigFile?.(l,(f)=>t.sys.readFile(f));return d&&!d.error?d.config:void 0},S=new Map,E=(l)=>{let d=j.default.dirname(l);if(!S.has(d)){let f=mn(d,y)??C,x=[];try{x=(ut(d,m,y)?.libs??[]).filter(y)}catch(h){a(`could not read the stx entry of the project's tsconfig: ${String(h)}`)}S.set(d,f&&x.length>0?hn([f,...x]):f)}return S.get(d)},g=new Map,v=(l)=>{let d=w?.(l);return d?d.getText(0,d.getLength()):t.sys?.readFile(l)},k=()=>n.enabled!==!1;r.add(()=>{g.clear(),o.project.refreshDiagnostics?.()});let _=(l)=>{if(!dt(l)||!w)return;let d=`${b?.(l)||"0"}:${u.getProjectVersion?.()||""}`,f=g.get(l);if(f&&f.version===d&&[...f.virtual.componentDependencies||[]].every(([h,T])=>v(h)===T))return f;let x=w(l);if(!x)return;try{let h=o.project.getCurrentDirectory?.(),T=h?j.default.resolve(h,typeof o.config?.componentsDir==="string"?o.config.componentsDir:"components"):void 0,L=xn(l,x.getText(0,x.getLength()),d,{declarations:E(l),readComponent:v,componentsDir:T,projectRoot:h});return g.set(l,L),L}catch(h){a(`failed to build virtual document for ${l}: ${String(h)}`);return}},A=(l)=>te(l)?_(l):void 0,I=(l,d)=>{let f=q(l.virtualStarts,d);return rt(l.virtual,f.line,f.column)},N=(l,d)=>{let f=I(l,d);if(!f)return;return le(l.sourceStarts,f.line,f.column)},R=(l,d)=>{let f=q(l.sourceStarts,d);return le(l.virtualStarts,f.line,Qe(l.virtual.scriptColumns?.get(f.line)??[],f.column))},P=(l,d)=>{let f=N(l,d.start);if(f===void 0)return;let x=N(l,d.start+d.length);return{start:f,length:x!==void 0&&x>=f?x-f:d.length}},F=(l,d)=>l.blocks.some((f)=>f.offset!==void 0&&d>=f.offset&&d<=f.offset+f.code.length),W=(l)=>{let d=A(l.fileName);if(!d)return l;let f=P(d,l.textSpan);if(!f)return;let x=l.contextSpan?P(d,l.contextSpan):void 0;return{...l,textSpan:f,contextSpan:x}},H=(l)=>l?.map(W).filter((d)=>d!==void 0),B=(l)=>l?.filter((d)=>{let f=A(d.fileName);if(!f)return!0;let{line:x}=q(f.virtualStarts,d.textSpan.start);return x<=f.virtual.sourceLineCount&&!f.virtual.lineMap.has(x)});if(w)u.getScriptSnapshot=(l)=>{let d=_(l);if(d)return t.ScriptSnapshot.fromString(d.virtual.text);return w(l)};let he=u.getCompilationSettings?.bind(u),ht=t.server?.ProjectKind!==void 0&&o.project.projectKind===t.server.ProjectKind.Inferred;if(he&&ht){let l=null,d;u.getCompilationSettings=()=>{let f=he();if(l===null)try{l=bn(t,o.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 ue=(l,d)=>{let f=_(l);if(!f)return d;if(te(l)&&!k())return[];let x=[];for(let h of d){let T=typeof h.messageText==="string"?h.messageText:h.messageText.messageText;if(pn.has(h.code)){let G=T.match(/'([^']+)'/)?.[1];if(G&&f.collisions.has(G))continue}if(h.start===void 0){x.push(h);continue}let L=I(f,h.start);if(!L||st(L,h.code))continue;let M=le(f.sourceStarts,L.line,L.column),Y=N(f,h.start+(h.length??0));x.push({...h,start:M,length:Y!==void 0&&Y>M?Y-M:h.length??0})}return x},xt=p("getSemanticDiagnostics");c.getSemanticDiagnostics=(l)=>{let d=ue(l,xt(l)),f=A(l);if(!f||!k())return d;let x=c.getProgram?.()?.getSourceFile(l);for(let h of lt(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 bt=p("getSyntacticDiagnostics");c.getSyntacticDiagnostics=(l)=>ue(l,bt(l));let St=p("getSuggestionDiagnostics");c.getSuggestionDiagnostics=(l)=>ue(l,St(l));let xe=p("getQuickInfoAtPosition");c.getQuickInfoAtPosition=(l,d,...f)=>{let x=A(l);if(!x)return xe(l,d,...f);if(!k())return;let h=xe(l,R(x,d),...f);if(!h)return h;let T=P(x,h.textSpan);return T?{...h,textSpan:T}:void 0};let be=p("getCompletionsAtPosition");c.getCompletionsAtPosition=(l,d,f,...x)=>{let h=A(l);if(!h)return be(l,d,f,...x);if(!k()||!F(h,d))return;let T=be(l,R(h,d),{...f,includeCompletionsForModuleExports:!1},...x);if(!T)return T;let L=(M)=>M&&P(h,M);return{...T,optionalReplacementSpan:L(T.optionalReplacementSpan),entries:T.entries.filter((M)=>!M.name.startsWith("__stx")&&!M.name.startsWith("__Stx")).map((M)=>M.replacementSpan?{...M,replacementSpan:L(M.replacementSpan)}:M)}};let Se=p("getCompletionEntryDetails");c.getCompletionEntryDetails=(l,d,...f)=>{let x=A(l);if(!x)return Se(l,d,...f);let h=Se(l,R(x,d),...f);return h?{...h,codeActions:void 0}:h};let ye=p("getSignatureHelpItems");c.getSignatureHelpItems=(l,d,...f)=>{let x=A(l);if(!x)return ye(l,d,...f);if(!k()||!F(x,d))return;let h=ye(l,R(x,d),...f),T=h&&P(x,h.applicableSpan);return h&&T?{...h,applicableSpan:T}:void 0};let we=p("getDefinitionAndBoundSpan");c.getDefinitionAndBoundSpan=(l,d)=>{let f=A(l);if(!f)return $e(we(l,d));if(!k())return;let x=we(l,R(f,d)),h=x&&P(f,x.textSpan);return x&&h?{...$e(x),textSpan:h}:void 0};let $e=(l)=>l&&{...l,definitions:B(l.definitions)};for(let l of["getDefinitionAtPosition","getTypeDefinitionAtPosition","getImplementationAtPosition"]){let d=p(l);c[l]=(f,x,...h)=>{let T=A(f);if(T&&!k())return;return B(d(f,T?R(T,x):x,...h))}}for(let l of["getReferencesAtPosition"]){let d=p(l);c[l]=(f,x,...h)=>{let T=A(f);if(T&&!k())return;return H(d(f,T?R(T,x):x,...h))}}let yt=p("findReferences");c.findReferences=(l,d)=>{let f=A(l);if(f&&!k())return;return yt(l,f?R(f,d):d)?.map((x)=>{let h=W(x.definition);return h?{definition:h,references:H(x.references)}:void 0}).filter((x)=>x!==void 0)};let wt=p("getDocumentHighlights");c.getDocumentHighlights=(l,d,f)=>{let x=A(l);if(x&&(!k()||!F(x,d)))return;return wt(l,x?R(x,d):d,f)?.map((h)=>{let T=A(h.fileName);if(!T)return h;return{...h,highlightSpans:h.highlightSpans.map((L)=>{let M=P(T,L.textSpan);return M?{...L,textSpan:M,contextSpan:L.contextSpan&&P(T,L.contextSpan)}:void 0}).filter((L)=>L!==void 0)}})};let $t=p("getNavigationTree");c.getNavigationTree=(l)=>{let d=$t(l),f=A(l);if(!f)return d;let x=(T)=>{let L=T.spans.map((G)=>P(f,G)).filter((G)=>G!==void 0);if(L.length===0)return;let M=T.nameSpan&&P(f,T.nameSpan),Y=T.childItems?.map(x).filter((G)=>G!==void 0);return{...T,spans:L,nameSpan:M,childItems:Y}},h={...d,spans:[{start:0,length:f.source.length}]};return k()?{...h,childItems:d.childItems?.map(x).filter((T)=>T!==void 0)}:{...h,childItems:[]}};let Et={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(Et)){let f=c[l];if(typeof f!=="function")continue;let x=f.bind(c);c[l]=(h,...T)=>typeof h==="string"&&te(h)?d():x(h,...T)}return c[ft]=!0,a("Language service proxy created"),c},getExternalFiles(o){if(i.has(o))return[];return o.getFileNames().filter(dt)},onConfigurationChanged(o){n={...n,...o};for(let a of r)a()}}}var mt=Sn;module.exports=mt;
|
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.798",
|
|
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",
|