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