@stacksjs/stx-vscode 0.2.937 → 0.2.939
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.
|
@@ -13,7 +13,7 @@ catch (e) {
|
|
|
13
13
|
}
|
|
14
14
|
throw e;
|
|
15
15
|
}
|
|
16
|
-
`),s.set(l,u)}return u(...c)}catch{return}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:a,context:n.slice()});return a}clear(){this.pool.length=0,this.fnCache.clear()}}var qr=new at;class ct{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled(e){this.enabled=e}isEnabled(){return this.enabled}setBudget(e,n){this.budgets.set(e,{warnThreshold:0.8,action:"warn",...n})}setBudgets(e){for(let[n,r]of Object.entries(e))this.setBudget(n,r)}removeBudget(e){this.budgets.delete(e)}getBudgets(){let e={};for(let[n,r]of this.budgets.entries())e[n]=r;return e}onViolation(e){this.violationHandlers.push(e)}offViolation(e){let n=this.violationHandlers.indexOf(e);if(n!==-1)this.violationHandlers.splice(n,1)}time(e,n){if(!this.enabled)return n();let r=performance.now(),t=n(),s=performance.now()-r;return this.recordTime(e,s),this.checkBudget(e,s),t}async timeAsync(e,n){if(!this.enabled)return n();let r=performance.now(),t=await n(),s=performance.now()-r;return this.recordTime(e,s),this.checkBudget(e,s),t}checkBudget(e,n){let r=this.budgets.get(e);if(!r)return;let t=n/r.maxTime*100,s=r.warnThreshold!==void 0?n>=r.maxTime*r.warnThreshold&&n<r.maxTime:!1,i=n>=r.maxTime;if(!s&&!i)return;let a={label:e,actualTime:n,budgetTime:r.maxTime,exceedancePercent:t,timestamp:new Date,isWarning:s};this.violations.push(a);while(this.violations.length>this.maxViolations)this.violations.shift();for(let o of this.violationHandlers)try{o(a)}catch{}let c=s?`[Performance Warning] "${e}" took ${n.toFixed(2)}ms (${t.toFixed(1)}% of ${r.maxTime}ms budget)`:`[Performance Budget Exceeded] "${e}" took ${n.toFixed(2)}ms (exceeded ${r.maxTime}ms budget by ${(t-100).toFixed(1)}%)`;switch(r.action){case"log":console.log(c);break;case"warn":console.warn(c);break;case"error":console.error(c);break;case"throw":if(i)throw Error(c);else console.warn(c);break}}recordTime(e,n){let r=this.metrics.get(e);if(r)r.count++,r.totalTime+=n,r.maxTime=Math.max(r.maxTime,n),r.minTime=Math.min(r.minTime,n);else this.metrics.set(e,{count:1,totalTime:n,maxTime:n,minTime:n})}getStats(e){if(e){let r=this.metrics.get(e);if(!r)return{};let t=this.budgets.get(e);return{count:r.count,avgTime:r.totalTime/r.count,totalTime:r.totalTime,maxTime:r.maxTime,minTime:r.minTime,budget:t?.maxTime,budgetUtilization:t?r.totalTime/r.count/t.maxTime*100:void 0}}let n={};for(let[r,t]of this.metrics.entries()){let s=this.budgets.get(r);n[r]={count:t.count,avgTime:t.totalTime/t.count,totalTime:t.totalTime,maxTime:t.maxTime,minTime:t.minTime,budget:s?.maxTime,budgetUtilization:s?t.totalTime/t.count/s.maxTime*100:void 0}}return n}getViolations(e){if(e)return this.violations.filter((n)=>n.label===e);return[...this.violations]}getViolationStats(){let e={},n=0,r=0;for(let t of this.violations)if(e[t.label]=(e[t.label]||0)+1,t.isWarning)n++;else r++;return{total:this.violations.length,byLabel:e,warnings:n,errors:r}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}var Ve=null;function Cn(){if(!Ve)Ve=new ct;return Ve}var Xr=new Proxy({},{get(e,n){return Cn()[n]}});var lt=new ve(32,{maxBytes:2097152,sizeOf:(e)=>e.code.length*4}),oe=/^[A-Za-z_$][\w$]*$/,Tn=new Set(["if","for","while","switch","with"]),ut=["(","[","{"],pt=[")","]","}"],Rn=new Set(["const","let","var","return","if","for","while","do","switch","try","throw","export"]);function An(e){let n=j(e),r=[];for(let t of n.matchAll(/[A-Za-z_$][\w$]*|=>|\.\.\.|[^\s]/g)){let s=t.index??0;r.push({text:t[0],start:s,end:s+t[0].length})}return{code:n,tokens:r}}function On(e){let n=lt.get(e);if(n)return n;let{code:r,tokens:t}=An(e),s=new Map,i=[];for(let d=0;d<t.length;d++){let f=t[d].text;if(["(","[","{"].includes(f))i.push(d);else if([")","]","}"].includes(f)){let w=i.at(-1);if(w!==void 0&&["()","[]","{}"].includes(t[w].text+f))i.pop(),s.set(w,d),s.set(d,w)}}function a(d,f){let w=[],b=d;for(let p=d;p<f;p++){if(["(","[","{"].includes(t[p].text)&&(s.get(p)??f)<f){p=s.get(p);continue}if(t[p].text===",")w.push([b,p]),b=p+1}return w.push([b,f]),w}let c=[];function o(d,f,w,b=!1,p){if(t[d]?.text==="...")d++;if(d>=f)return;let m=t[d].text;if(oe.test(m)){if(w.add(m),w===g)c.push({name:m,token:d,functionScoped:b,declarationToken:p});return}if(m!=="{"&&m!=="[")return;let E=s.get(d);if(E===void 0||E>=f)return;for(let[A,v]of a(d+1,E)){let O=A;if(m==="{")for(let M=A;M<v;M++){if(t[M].text===":"){O=M+1;break}if(t[M].text==="=")break;if(["(","[","{"].includes(t[M].text)&&s.has(M))M=s.get(M)}o(O,v,w,b,p)}}function l(d,f){let w=new Set;for(let[b,p]of a(d,f))o(b,p,w);return w}function u(d){let f=d;for(;f<t.length;f++){let w=t[f].text;if(["(","[","{"].includes(w)&&s.has(f)){f=s.get(f);continue}if([",",";",")","]","}"].includes(w))break}return t[Math.max(d,f-1)]?.end??r.length}let g=new Set,x=[];for(let d=0;d<t.length;d++)if(t[d].text==="=>"){let f=d-1,w=f,b;if(t[f]?.text===")"&&s.has(f))w=s.get(f),b=l(w+1,f);else if(t[f]&&oe.test(t[f].text))b=new Set([t[f].text]);else continue;let p=d+1,m=t[p]?.text==="{"&&s.has(p)?t[s.get(p)].end:u(p);x.push({start:t[w].start,end:m,bodyStart:t[p]?.start??m,functionBody:!0,names:b})}else if(t[d].text==="("&&s.has(d)){let f=t[d-1]?.text;if(!f||Tn.has(f)||!oe.test(f)&&f!=="*"&&f!=="]")continue;let w=s.get(d),b=w+1;if(t[b]?.text===":"){b++;while(b<t.length&&!["{","=>",";","="].includes(t[b].text))b++}if(t[b]?.text!=="{"||!s.has(b))continue;x.push({start:t[d].start,end:t[s.get(b)].end,bodyStart:t[b].start,functionBody:f!=="catch",names:l(d+1,w)})}function _(d){let f=d;for(;f<t.length;f++){let w=t[f].text;if(ut.includes(w)&&s.has(f)){f=s.get(f);continue}if(w===";"||pt.includes(w))break;let b=t[f-1];if(f>d&&Rn.has(w)&&b.text!==".")break;if(f>d&&/[\n\r]/.test(r.slice(b.end,t[f].start))&&(/^[\w$]+$/.test(b.text)||pt.includes(b.text)||['"',"'","`"].includes(b.text))&&oe.test(w)&&!["in","of","instanceof"].includes(w))break}return f}let R=[];for(let d=0;d<t.length;d++){if(t[d].text!=="for")continue;let f=t[d+1]?.text==="await"?d+2:d+1;if(t[f]?.text!=="("||!s.has(f))continue;let w=s.get(f),b=w+1,p=t[b]?.text==="{"&&s.has(b)?s.get(b):_(b),m=t[p]?.text===";"||t[p]?.text==="}"?t[p].end:t[Math.max(b,p-1)]?.end??r.length;R.push({headStart:f,headEnd:w,start:t[f].start,end:m})}for(let d=0;d<t.length;d++){let f=t[d].text,w=t[d-1]?.text;if(w==="."||t[d+1]?.text===":")continue;if(w==="as"||w==="<")continue;if(f==="const"||f==="let"||f==="var"){let b=_(d+1),p=d+1,m=!1,E=!1,A=0;for(let v=d+1;v<=b;v++){let O=t[v]?.text;if(v<b&&ut.includes(O)&&s.has(v)&&s.get(v)<b){v=s.get(v);continue}if(v<b&&O===":"&&!E)m=!0;else if(v<b&&O==="="&&A===0)m=!1,E=!0;else if(v<b&&m&&O==="<")A++;else if(v<b&&m&&O===">"&&A>0)A--;else if(v===b||O===","&&A===0)o(p,v,g,f==="var",d),p=v+1,m=!1,E=!1}}else if(f==="function"||f==="class"){let b=d+1;if(t[b]?.text==="*")b++;if(t[b]&&oe.test(t[b].text)&&t[b].text!=="extends")g.add(t[b].text),c.push({name:t[b].text,token:b,declarationToken:d})}else if(f==="import"){let b=d+1;if(t[b]?.text==="*"&&t[b+1]?.text==="as")b+=2;let p=t[b]?.text;if(p&&oe.test(p)&&p!=="type"&&t[b+1]?.text!=="("&&t[b+1]?.text!==".")g.add(p),c.push({name:p,token:b,file:!0});let m=t[b]?.text==="{"?b:t[b+1]?.text===","&&t[b+2]?.text==="{"?b+2:-1;if(m!==-1&&s.has(m)){let E=s.get(m);for(let[A,v]of a(m+1,E)){let O=v-1;while(O>=A&&!oe.test(t[O].text))O--;if(O>=A&&t[O].text!=="type")c.push({name:t[O].text,token:O,file:!0})}}}}let C={code:r,scopes:x,loops:R,declarations:g,sites:c,tokens:t,pairs:s};return lt.set(e,C),C}function _e(e){let n=On(e),r=ot(e),{depths:t}=U(r),s=[...r.matchAll(/[A-Za-z_$][\w$]*|\d+(?:[.]\d+)?|[^\s]/g)],i=[];for(let a of n.sites){if(a.file||a.declarationToken===void 0)continue;let c=n.tokens[a.declarationToken];if(t[c.start]!==0)continue;let o=0,l=s.length;while(o<l){let x=o+l>>>1;if(s[x].index<c.start)o=x+1;else l=x}let u=o-1,g=s[u--];if(g?.[0]==="declare")continue;if(c.text==="function"||c.text==="class"){while(g&&["async","export","default","abstract"].includes(g[0]))g=s[u--];if(g&&![";","}"].includes(g[0])){let x=r.slice(g.index+g[0].length,c.start);if(!/[\r\n]/.test(x)||!/^(?:[\w$]+|[)\]])$/.test(g[0])||["return","throw","yield","await","new"].includes(g[0]))continue}}i.push({name:a.name,start:c.start,nameEnd:n.tokens[a.token].end})}return i}function dt(e){return[...new Set(_e(e).map((n)=>n.name))].sort()}function ft(e){let n=e.indexOf(" as ");if(n!==-1){let i=e.slice(0,n).trim(),a=e.slice(n+4).trim();return i&&a?{arrayExpr:i,itemVar:a}:null}let r=/^\s*(.+?)\s+in\s+([\s\S]+)$/.exec(e);if(!r)return null;let t=r[1].trim().replace(/^\(([\s\S]*)\)$/,"$1").trim(),s=r[2].trim();return t&&s?{arrayExpr:s,itemVar:t}:null}var de=["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","useAsyncData","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 Pn=["defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","withDefaults"];var is=de.filter((e)=>!Pn.includes(e));var Mn=["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"],In=["x-init","x-transition","x-effect","x-on"],os=[...Mn,...In];var Re=ee(require("node:fs"),1),fe=ee(require("node:path"),1);function mt(e,n,r,t){let s=0;for(let i=n;i<e.length;i++)if(e[i]===r)s++;else if(e[i]===t&&!(t===">"&&e[i-1]==="=")){if(--s===0)return i}return-1}function Nn(e){let n=j(e),r=0,t=0,s=[];for(let i=0;i<n.length;i++)if("([{".includes(n[i]))r++;else if(")]}".includes(n[i]))r--;else if(n[i]===","&&r===0)s.push(e.slice(t,i).trim()),t=i+1;return s.push(e.slice(t).trim()),s}function ke(e,n,r=!1){let t=j(e),s=new RegExp(`\\b(?:${n.map((a)=>a.replace(/[$]/g,"\\$&")).join("|")})\\s*(?=[<(])`,"g"),i=r?U(t).depths:void 0;for(let a of t.matchAll(s)){if(i&&i[a.index]!==0)continue;let c=a.index+a[0].length,o="";if(t[c]==="<"){let u=mt(t,c,"<",">");if(u<0)continue;o=e.slice(c+1,u),c=u+1;while(/\s/.test(t[c]||"")&&c<t.length)c++}if(t[c]!=="(")continue;let l=mt(t,c,"(",")");if(l>=0)return{type:o,args:Nn(e.slice(c+1,l)),start:a.index,end:l+1}}return null}var Ce=`
|
|
16
|
+
`),s.set(l,u)}return u(...c)}catch{return}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:a,context:n.slice()});return a}clear(){this.pool.length=0,this.fnCache.clear()}}var qr=new at;class ct{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled(e){this.enabled=e}isEnabled(){return this.enabled}setBudget(e,n){this.budgets.set(e,{warnThreshold:0.8,action:"warn",...n})}setBudgets(e){for(let[n,r]of Object.entries(e))this.setBudget(n,r)}removeBudget(e){this.budgets.delete(e)}getBudgets(){let e={};for(let[n,r]of this.budgets.entries())e[n]=r;return e}onViolation(e){this.violationHandlers.push(e)}offViolation(e){let n=this.violationHandlers.indexOf(e);if(n!==-1)this.violationHandlers.splice(n,1)}time(e,n){if(!this.enabled)return n();let r=performance.now(),t=n(),s=performance.now()-r;return this.recordTime(e,s),this.checkBudget(e,s),t}async timeAsync(e,n){if(!this.enabled)return n();let r=performance.now(),t=await n(),s=performance.now()-r;return this.recordTime(e,s),this.checkBudget(e,s),t}checkBudget(e,n){let r=this.budgets.get(e);if(!r)return;let t=n/r.maxTime*100,s=r.warnThreshold!==void 0?n>=r.maxTime*r.warnThreshold&&n<r.maxTime:!1,i=n>=r.maxTime;if(!s&&!i)return;let a={label:e,actualTime:n,budgetTime:r.maxTime,exceedancePercent:t,timestamp:new Date,isWarning:s};this.violations.push(a);while(this.violations.length>this.maxViolations)this.violations.shift();for(let o of this.violationHandlers)try{o(a)}catch{}let c=s?`[Performance Warning] "${e}" took ${n.toFixed(2)}ms (${t.toFixed(1)}% of ${r.maxTime}ms budget)`:`[Performance Budget Exceeded] "${e}" took ${n.toFixed(2)}ms (exceeded ${r.maxTime}ms budget by ${(t-100).toFixed(1)}%)`;switch(r.action){case"log":console.log(c);break;case"warn":console.warn(c);break;case"error":console.error(c);break;case"throw":if(i)throw Error(c);else console.warn(c);break}}recordTime(e,n){let r=this.metrics.get(e);if(r)r.count++,r.totalTime+=n,r.maxTime=Math.max(r.maxTime,n),r.minTime=Math.min(r.minTime,n);else this.metrics.set(e,{count:1,totalTime:n,maxTime:n,minTime:n})}getStats(e){if(e){let r=this.metrics.get(e);if(!r)return{};let t=this.budgets.get(e);return{count:r.count,avgTime:r.totalTime/r.count,totalTime:r.totalTime,maxTime:r.maxTime,minTime:r.minTime,budget:t?.maxTime,budgetUtilization:t?r.totalTime/r.count/t.maxTime*100:void 0}}let n={};for(let[r,t]of this.metrics.entries()){let s=this.budgets.get(r);n[r]={count:t.count,avgTime:t.totalTime/t.count,totalTime:t.totalTime,maxTime:t.maxTime,minTime:t.minTime,budget:s?.maxTime,budgetUtilization:s?t.totalTime/t.count/s.maxTime*100:void 0}}return n}getViolations(e){if(e)return this.violations.filter((n)=>n.label===e);return[...this.violations]}getViolationStats(){let e={},n=0,r=0;for(let t of this.violations)if(e[t.label]=(e[t.label]||0)+1,t.isWarning)n++;else r++;return{total:this.violations.length,byLabel:e,warnings:n,errors:r}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}var Ve=null;function Cn(){if(!Ve)Ve=new ct;return Ve}var Xr=new Proxy({},{get(e,n){return Cn()[n]}});var lt=new ve(32,{maxBytes:2097152,sizeOf:(e)=>e.code.length*4}),oe=/^[A-Za-z_$][\w$]*$/,Tn=new Set(["if","for","while","switch","with"]),ut=["(","[","{"],pt=[")","]","}"],An=new Set(["const","let","var","return","if","for","while","do","switch","try","throw","export"]);function Rn(e){let n=j(e),r=[];for(let t of n.matchAll(/[A-Za-z_$][\w$]*|=>|\.\.\.|[^\s]/g)){let s=t.index??0;r.push({text:t[0],start:s,end:s+t[0].length})}return{code:n,tokens:r}}function On(e){let n=lt.get(e);if(n)return n;let{code:r,tokens:t}=Rn(e),s=new Map,i=[];for(let d=0;d<t.length;d++){let f=t[d].text;if(["(","[","{"].includes(f))i.push(d);else if([")","]","}"].includes(f)){let w=i.at(-1);if(w!==void 0&&["()","[]","{}"].includes(t[w].text+f))i.pop(),s.set(w,d),s.set(d,w)}}function a(d,f){let w=[],b=d;for(let p=d;p<f;p++){if(["(","[","{"].includes(t[p].text)&&(s.get(p)??f)<f){p=s.get(p);continue}if(t[p].text===",")w.push([b,p]),b=p+1}return w.push([b,f]),w}let c=[];function o(d,f,w,b=!1,p){if(t[d]?.text==="...")d++;if(d>=f)return;let m=t[d].text;if(oe.test(m)){if(w.add(m),w===g)c.push({name:m,token:d,functionScoped:b,declarationToken:p});return}if(m!=="{"&&m!=="[")return;let E=s.get(d);if(E===void 0||E>=f)return;for(let[R,v]of a(d+1,E)){let O=R;if(m==="{")for(let M=R;M<v;M++){if(t[M].text===":"){O=M+1;break}if(t[M].text==="=")break;if(["(","[","{"].includes(t[M].text)&&s.has(M))M=s.get(M)}o(O,v,w,b,p)}}function l(d,f){let w=new Set;for(let[b,p]of a(d,f))o(b,p,w);return w}function u(d){let f=d;for(;f<t.length;f++){let w=t[f].text;if(["(","[","{"].includes(w)&&s.has(f)){f=s.get(f);continue}if([",",";",")","]","}"].includes(w))break}return t[Math.max(d,f-1)]?.end??r.length}let g=new Set,x=[];for(let d=0;d<t.length;d++)if(t[d].text==="=>"){let f=d-1,w=f,b;if(t[f]?.text===")"&&s.has(f))w=s.get(f),b=l(w+1,f);else if(t[f]&&oe.test(t[f].text))b=new Set([t[f].text]);else continue;let p=d+1,m=t[p]?.text==="{"&&s.has(p)?t[s.get(p)].end:u(p);x.push({start:t[w].start,end:m,bodyStart:t[p]?.start??m,functionBody:!0,names:b})}else if(t[d].text==="("&&s.has(d)){let f=t[d-1]?.text;if(!f||Tn.has(f)||!oe.test(f)&&f!=="*"&&f!=="]")continue;let w=s.get(d),b=w+1;if(t[b]?.text===":"){b++;while(b<t.length&&!["{","=>",";","="].includes(t[b].text))b++}if(t[b]?.text!=="{"||!s.has(b))continue;x.push({start:t[d].start,end:t[s.get(b)].end,bodyStart:t[b].start,functionBody:f!=="catch",names:l(d+1,w)})}function _(d){let f=d;for(;f<t.length;f++){let w=t[f].text;if(ut.includes(w)&&s.has(f)){f=s.get(f);continue}if(w===";"||pt.includes(w))break;let b=t[f-1];if(f>d&&An.has(w)&&b.text!==".")break;if(f>d&&/[\n\r]/.test(r.slice(b.end,t[f].start))&&(/^[\w$]+$/.test(b.text)||pt.includes(b.text)||['"',"'","`"].includes(b.text))&&oe.test(w)&&!["in","of","instanceof"].includes(w))break}return f}let A=[];for(let d=0;d<t.length;d++){if(t[d].text!=="for")continue;let f=t[d+1]?.text==="await"?d+2:d+1;if(t[f]?.text!=="("||!s.has(f))continue;let w=s.get(f),b=w+1,p=t[b]?.text==="{"&&s.has(b)?s.get(b):_(b),m=t[p]?.text===";"||t[p]?.text==="}"?t[p].end:t[Math.max(b,p-1)]?.end??r.length;A.push({headStart:f,headEnd:w,start:t[f].start,end:m})}for(let d=0;d<t.length;d++){let f=t[d].text,w=t[d-1]?.text;if(w==="."||t[d+1]?.text===":")continue;if(w==="as"||w==="<")continue;if(f==="const"||f==="let"||f==="var"){let b=_(d+1),p=d+1,m=!1,E=!1,R=0;for(let v=d+1;v<=b;v++){let O=t[v]?.text;if(v<b&&ut.includes(O)&&s.has(v)&&s.get(v)<b){v=s.get(v);continue}if(v<b&&O===":"&&!E)m=!0;else if(v<b&&O==="="&&R===0)m=!1,E=!0;else if(v<b&&m&&O==="<")R++;else if(v<b&&m&&O===">"&&R>0)R--;else if(v===b||O===","&&R===0)o(p,v,g,f==="var",d),p=v+1,m=!1,E=!1}}else if(f==="function"||f==="class"){let b=d+1;if(t[b]?.text==="*")b++;if(t[b]&&oe.test(t[b].text)&&t[b].text!=="extends")g.add(t[b].text),c.push({name:t[b].text,token:b,declarationToken:d})}else if(f==="import"){let b=d+1;if(t[b]?.text==="*"&&t[b+1]?.text==="as")b+=2;let p=t[b]?.text;if(p&&oe.test(p)&&p!=="type"&&t[b+1]?.text!=="("&&t[b+1]?.text!==".")g.add(p),c.push({name:p,token:b,file:!0});let m=t[b]?.text==="{"?b:t[b+1]?.text===","&&t[b+2]?.text==="{"?b+2:-1;if(m!==-1&&s.has(m)){let E=s.get(m);for(let[R,v]of a(m+1,E)){let O=v-1;while(O>=R&&!oe.test(t[O].text))O--;if(O>=R&&t[O].text!=="type")c.push({name:t[O].text,token:O,file:!0})}}}}let C={code:r,scopes:x,loops:A,declarations:g,sites:c,tokens:t,pairs:s};return lt.set(e,C),C}function _e(e){let n=On(e),r=ot(e),{depths:t}=U(r),s=[...r.matchAll(/[A-Za-z_$][\w$]*|\d+(?:[.]\d+)?|[^\s]/g)],i=[];for(let a of n.sites){if(a.file||a.declarationToken===void 0)continue;let c=n.tokens[a.declarationToken];if(t[c.start]!==0)continue;let o=0,l=s.length;while(o<l){let x=o+l>>>1;if(s[x].index<c.start)o=x+1;else l=x}let u=o-1,g=s[u--];if(g?.[0]==="declare")continue;if(c.text==="function"||c.text==="class"){while(g&&["async","export","default","abstract"].includes(g[0]))g=s[u--];if(g&&![";","}"].includes(g[0])){let x=r.slice(g.index+g[0].length,c.start);if(!/[\r\n]/.test(x)||!/^(?:[\w$]+|[)\]])$/.test(g[0])||["return","throw","yield","await","new"].includes(g[0]))continue}}i.push({name:a.name,start:c.start,nameEnd:n.tokens[a.token].end})}return i}function dt(e){return[...new Set(_e(e).map((n)=>n.name))].sort()}function ft(e){let n=e.indexOf(" as ");if(n!==-1){let i=e.slice(0,n).trim(),a=e.slice(n+4).trim();return i&&a?{arrayExpr:i,itemVar:a}:null}let r=/^\s*(.+?)\s+in\s+([\s\S]+)$/.exec(e);if(!r)return null;let t=r[1].trim().replace(/^\(([\s\S]*)\)$/,"$1").trim(),s=r[2].trim();return t&&s?{arrayExpr:s,itemVar:t}:null}var de=["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","useAsyncData","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 Pn=["defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","withDefaults"];var is=de.filter((e)=>!Pn.includes(e));var Mn=["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"],In=["x-init","x-transition","x-effect","x-on"],os=[...Mn,...In];var Ae=ee(require("node:fs"),1),fe=ee(require("node:path"),1);function mt(e,n,r,t){let s=0;for(let i=n;i<e.length;i++)if(e[i]===r)s++;else if(e[i]===t&&!(t===">"&&e[i-1]==="=")){if(--s===0)return i}return-1}function Nn(e){let n=j(e),r=0,t=0,s=[];for(let i=0;i<n.length;i++)if("([{".includes(n[i]))r++;else if(")]}".includes(n[i]))r--;else if(n[i]===","&&r===0)s.push(e.slice(t,i).trim()),t=i+1;return s.push(e.slice(t).trim()),s}function ke(e,n,r=!1){let t=j(e),s=new RegExp(`\\b(?:${n.map((a)=>a.replace(/[$]/g,"\\$&")).join("|")})\\s*(?=[<(])`,"g"),i=r?U(t).depths:void 0;for(let a of t.matchAll(s)){if(i&&i[a.index]!==0)continue;let c=a.index+a[0].length,o="";if(t[c]==="<"){let u=mt(t,c,"<",">");if(u<0)continue;o=e.slice(c+1,u),c=u+1;while(/\s/.test(t[c]||"")&&c<t.length)c++}if(t[c]!=="(")continue;let l=mt(t,c,"(",")");if(l>=0)return{type:o,args:Nn(e.slice(c+1,l)),start:a.index,end:l+1}}return null}var Ce=`
|
|
17
17
|
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;
|
|
18
18
|
type __StxWiden<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T;
|
|
19
19
|
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>;
|
|
@@ -21,33 +21,33 @@ type __StxRequired<O> = { [K in keyof O]-?: O[K] extends { required: true } ? K
|
|
|
21
21
|
type __StxDefaulted<O> = { [K in keyof O]-?: O[K] extends { default: unknown } ? K : never }[keyof O];
|
|
22
22
|
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]> };
|
|
23
23
|
type __StxDefaults<P, K> = Omit<P, Extract<keyof P, K>> & Partial<Pick<P, Extract<keyof P, K>>>;
|
|
24
|
-
`;function Te(e,n){let r=[],t={defineProps:["defineProps"],defineEmits:["defineEmits"],withDefaults:["withDefaults"]},s=j(e),i=e.replace(/\bimport\s+(?:type\s+)?(\{[^}]*\}|\*\s+as\s+[\w$]+|[\w$]+)\s+from\s*(['"])([^'"]+)\2\s*;?/g,(x,_,
|
|
24
|
+
`;function Te(e,n){let r=[],t={defineProps:["defineProps"],defineEmits:["defineEmits"],withDefaults:["withDefaults"]},s=j(e),i=e.replace(/\bimport\s+(?:type\s+)?(\{[^}]*\}|\*\s+as\s+[\w$]+|[\w$]+)\s+from\s*(['"])([^'"]+)\2\s*;?/g,(x,_,A,C,d)=>{if(s.slice(d,d+6)!=="import")return x;if(C.endsWith(".stx"))return"";let f=`${n}Import${r.length}`;if(r.push(`import * as ${f} from ${JSON.stringify(C)};`),_.startsWith("*"))return`import ${_.replace(/^\*\s+as\s+/,"")} = ${f};`;if(!_.startsWith("{"))return`import ${_} = ${f}.default;`;return _.slice(1,-1).split(",").map((w)=>{let[b,p=b]=w.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(!b)return"";if(/^(?:stx|@stacksjs\/stx)(?:\/|$)/.test(C)&&b in t)t[b].push(p);return`import ${p} = ${f}.${b};`}).join(`
|
|
25
25
|
`)}),a=ke(e,t.defineProps),c=ke(e,t.defineEmits),o=ke(e,t.withDefaults);if(!a&&!c)return{declarations:"",props:null,events:null};let l=[],u=null,g=null;if(a){l.push(`const __options = (${a.args[0]||"{}"}) as const;`),l.push(`const __defaults = (${o?.args[1]||"{}"});`);let x=a.type||"__StxOptions<typeof __options>";l.push(`export type __StxProps = __StxDefaults<${x}, keyof typeof __defaults | __StxDefaulted<typeof __options>>;`),u=`${n}.__StxProps`}if(c)l.push(`const __events = (${c.args[0]||"[]"}) as const;`),l.push(`export type __StxEvents = ${c.type||"Record<(typeof __events)[number], any[]>"};`),g=`${n}.__StxEvents`;return{declarations:`${r.join(`
|
|
26
26
|
`)}
|
|
27
27
|
namespace ${n} {
|
|
28
28
|
${i}
|
|
29
29
|
${l.join(`
|
|
30
30
|
`)}
|
|
31
|
-
}`,props:u,events:g}}var ae=ee(require("node:fs"),1),D=ee(require("node:path"),1);function ht(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}var gt=new Map;function xt(e,n=!0){let r=gt.get(e);if(n&&r)return r;let t=new Map,s=[D.default.join(e,"src"),D.default.join(e,"dist"),e];function i(a,c){if(c>6)return;let o;try{o=ae.default.readdirSync(a,{withFileTypes:!0})}catch{return}for(let l of o){let u=D.default.join(a,l.name);if(l.isDirectory()){if(l.name==="node_modules"||l.name.startsWith("."))continue;i(u,c+1)}else if(l.isFile()&&l.name.endsWith(".stx")){let g=l.name.slice(0,-4);if(!t.has(g))t.set(g,u);let x=g.toLowerCase();if(!t.has(x))t.set(x,u);let _=ht(g);if(!t.has(_))t.set(_,u)}}}for(let a of s)if(i(a,0),t.size>0)break;if(n)gt.set(e,t);return t}function bt(e,n){if(e.startsWith(".")||e.startsWith("/"))return null;let r=n;while(!0){let t=D.default.join(r,"node_modules",e);try{if(ae.default.statSync(t).isDirectory())return t}catch{}let s=D.default.dirname(r);if(s===r)return null;r=s}}function yt(e,n,r={}){return[D.default.resolve(D.default.dirname(n),`${e}.stx`),D.default.resolve(D.default.dirname(n),e),D.default.resolve(r.componentsDir||"components",`${e}.stx`),D.default.resolve(r.componentsDir||"components",e),e.endsWith(".stx")?e:`${e}.stx`]}function St(e){let n=e.endsWith(".stx")?e.slice(0,-4):e,r=n.split("-").map((s)=>s.charAt(0).toUpperCase()+s.slice(1)).join(""),t=ht(n);return[n,r,t]}function Dn(e,n){let[r,t,s]=St(e);for(let i of[r,r.toLowerCase(),t,s]){let a=n?.__importedComponents?.get(i);if(a!==void 0)return a}}function Ln(e,n){let r=n?D.default.resolve(n):void 0,t=D.default.dirname(D.default.resolve(e));for(;;){if(ae.default.existsSync(D.default.join(t,"package.json")))return r&&t===r?void 0:t;let s=D.default.dirname(t);if(s===t)return;t=s}}var jn=["src/ui","src/components","components","dist"];function Fn(e,n){let r=D.default.resolve(e);if(!n&&!r.split(D.default.sep).includes("node_modules"))return[];let t=Ln(r,n);if(!t)return[];let s=[];try{let c=JSON.parse(ae.default.readFileSync(D.default.join(t,"package.json"),"utf8")).stx?.components;if(Array.isArray(c))s=c.filter((o)=>typeof o==="string")}catch{}let i=s.length?s:jn;return[D.default.dirname(D.default.resolve(e)),...i.map((a)=>D.default.resolve(t,a))]}function*Bn(e,n,r={},t){let s=St(e);if(s[0].startsWith("./")||s[0].startsWith("../")){yield D.default.resolve(D.default.dirname(n),`${s[0]}.stx`);return}let i=[...new Set(s.map((o)=>`${o}.stx`))],a=r.projectRoot||process.cwd(),c=[...Fn(n,r.projectRoot),...t?.__originalFilePath?[D.default.join(D.default.dirname(t.__originalFilePath),"components")]:[],...r.componentsDir?[r.componentsDir]:[],D.default.join(D.default.dirname(n),"components"),D.default.resolve(a,"src/components"),D.default.resolve(a,"components"),D.default.resolve("/home/runner/work/stx/stx/packages/stx/src","components")];for(let o of new Set(c)){for(let l of i)yield D.default.join(o,l);try{for(let l of ae.default.readdirSync(o,{withFileTypes:!0}))if(l.isDirectory())for(let u of i)yield D.default.join(o,l.name,u)}catch{}}}function vt(e,n,r={},t){let s=Dn(e,t);if(s!==void 0)return s;for(let i of Bn(e,n,r,t))try{if(ae.default.statSync(i,{throwIfNoEntry:!1})?.isFile())return i}catch{}return null}var Et=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 wt(e){if(e.includes("-")||e==="component")return!1;if(/^[A-Z]/.test(e))return!/[a-z]/.test(e)&&[...Et].some((n)=>n.toLowerCase()===e.toLowerCase());return Et.has(e)||/[A-Z]/.test(e)}function*zn(e){let n=/<([A-Za-z][\w.-]*)(?=[\s/>])/g,r;while(r=n.exec(e)){let t=n.lastIndex,s=[];while(t<e.length){while(/\s/.test(e[t]||""))t++;if(e[t]===">"||e.slice(t,t+2)==="/>"){t+=e[t]===">"?1:2;break}let i=/^[^\s=/>]+/.exec(e.slice(t))?.[0];if(!i){t++;continue}let a=t;t+=i.length;while(/\s/.test(e[t]||""))t++;if(e[t]!=="="){s.push({name:i,value:!0,offset:a,braced:!1});continue}t++;while(/\s/.test(e[t]||""))t++;let c=e[t],o=c==="{",l=c==='"'||c==="'";if(l||o)t++;let u=t;if(o){let g=j(e.slice(t)),x=1,_=0;for(;_<g.length;_++){if(g[_]==="{")x++;if(g[_]==="}"&&--x===0)break}t+=_}else if(l)while(t<e.length&&e[t]!==c)t++;else while(t<e.length&&!/[\s/>]/.test(e[t]))t++;if(s.push({name:i,value:e.slice(u,t),offset:u,braced:o}),l||o)t++}n.lastIndex=t,yield{name:r[1],offset:r.index,attributes:s}}}function $t(e,n,r){let t=[],s=[Ce,"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,a=new Map,c=new Map,o=r.scriptCode(e,r.filePath),l=j(o);for(let
|
|
32
|
-
`).length,column:
|
|
33
|
-
`)}},_=(
|
|
34
|
-
`):"",checks:t,events:i,dependencies:a}}var qe=ee(require("node:fs"),1),J=ee(require("node:path"),1);var
|
|
31
|
+
}`,props:u,events:g}}var ae=ee(require("node:fs"),1),D=ee(require("node:path"),1);function ht(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}var gt=new Map;function xt(e,n=!0){let r=gt.get(e);if(n&&r)return r;let t=new Map,s=[D.default.join(e,"src"),D.default.join(e,"dist"),e];function i(a,c){if(c>6)return;let o;try{o=ae.default.readdirSync(a,{withFileTypes:!0})}catch{return}for(let l of o){let u=D.default.join(a,l.name);if(l.isDirectory()){if(l.name==="node_modules"||l.name.startsWith("."))continue;i(u,c+1)}else if(l.isFile()&&l.name.endsWith(".stx")){let g=l.name.slice(0,-4);if(!t.has(g))t.set(g,u);let x=g.toLowerCase();if(!t.has(x))t.set(x,u);let _=ht(g);if(!t.has(_))t.set(_,u)}}}for(let a of s)if(i(a,0),t.size>0)break;if(n)gt.set(e,t);return t}function bt(e,n){if(e.startsWith(".")||e.startsWith("/"))return null;let r=n;while(!0){let t=D.default.join(r,"node_modules",e);try{if(ae.default.statSync(t).isDirectory())return t}catch{}let s=D.default.dirname(r);if(s===r)return null;r=s}}function yt(e,n,r={}){return[D.default.resolve(D.default.dirname(n),`${e}.stx`),D.default.resolve(D.default.dirname(n),e),D.default.resolve(r.componentsDir||"components",`${e}.stx`),D.default.resolve(r.componentsDir||"components",e),e.endsWith(".stx")?e:`${e}.stx`]}function St(e){let n=e.endsWith(".stx")?e.slice(0,-4):e,r=n.split("-").map((s)=>s.charAt(0).toUpperCase()+s.slice(1)).join(""),t=ht(n);return[n,r,t]}function Dn(e,n){let[r,t,s]=St(e);for(let i of[r,r.toLowerCase(),t,s]){let a=n?.__importedComponents?.get(i);if(a!==void 0)return a}}function Ln(e,n){let r=n?D.default.resolve(n):void 0,t=D.default.dirname(D.default.resolve(e));for(;;){if(ae.default.existsSync(D.default.join(t,"package.json")))return r&&t===r?void 0:t;let s=D.default.dirname(t);if(s===t)return;t=s}}var jn=["src/ui","src/components","components","dist"];function Fn(e,n){let r=D.default.resolve(e);if(!n&&!r.split(D.default.sep).includes("node_modules"))return[];let t=Ln(r,n);if(!t)return[];let s=[];try{let c=JSON.parse(ae.default.readFileSync(D.default.join(t,"package.json"),"utf8")).stx?.components;if(Array.isArray(c))s=c.filter((o)=>typeof o==="string")}catch{}let i=s.length?s:jn;return[D.default.dirname(D.default.resolve(e)),...i.map((a)=>D.default.resolve(t,a))]}function*Bn(e,n,r={},t){let s=St(e);if(s[0].startsWith("./")||s[0].startsWith("../")){yield D.default.resolve(D.default.dirname(n),`${s[0]}.stx`);return}let i=[...new Set(s.map((o)=>`${o}.stx`))],a=r.projectRoot||process.cwd(),c=[...Fn(n,r.projectRoot),...t?.__originalFilePath?[D.default.join(D.default.dirname(t.__originalFilePath),"components")]:[],...r.componentsDir?[r.componentsDir]:[],D.default.join(D.default.dirname(n),"components"),D.default.resolve(a,"src/components"),D.default.resolve(a,"components"),D.default.resolve("/home/runner/work/stx/stx/packages/stx/src","components")];for(let o of new Set(c)){for(let l of i)yield D.default.join(o,l);try{for(let l of ae.default.readdirSync(o,{withFileTypes:!0}))if(l.isDirectory())for(let u of i)yield D.default.join(o,l.name,u)}catch{}}}function vt(e,n,r={},t){let s=Dn(e,t);if(s!==void 0)return s;for(let i of Bn(e,n,r,t))try{if(ae.default.statSync(i,{throwIfNoEntry:!1})?.isFile())return i}catch{}return null}var Et=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 wt(e){if(e.includes("-")||e==="component")return!1;if(/^[A-Z]/.test(e))return!/[a-z]/.test(e)&&[...Et].some((n)=>n.toLowerCase()===e.toLowerCase());return Et.has(e)||/[A-Z]/.test(e)}function*zn(e){let n=/<([A-Za-z][\w.-]*)(?=[\s/>])/g,r;while(r=n.exec(e)){let t=n.lastIndex,s=[];while(t<e.length){while(/\s/.test(e[t]||""))t++;if(e[t]===">"||e.slice(t,t+2)==="/>"){t+=e[t]===">"?1:2;break}let i=/^[^\s=/>]+/.exec(e.slice(t))?.[0];if(!i){t++;continue}let a=t;t+=i.length;while(/\s/.test(e[t]||""))t++;if(e[t]!=="="){s.push({name:i,value:!0,offset:a,braced:!1});continue}t++;while(/\s/.test(e[t]||""))t++;let c=e[t],o=c==="{",l=c==='"'||c==="'";if(l||o)t++;let u=t;if(o){let g=j(e.slice(t)),x=1,_=0;for(;_<g.length;_++){if(g[_]==="{")x++;if(g[_]==="}"&&--x===0)break}t+=_}else if(l)while(t<e.length&&e[t]!==c)t++;else while(t<e.length&&!/[\s/>]/.test(e[t]))t++;if(s.push({name:i,value:e.slice(u,t),offset:u,braced:o}),l||o)t++}n.lastIndex=t,yield{name:r[1],offset:r.index,attributes:s}}}function $t(e,n,r){let t=[],s=[Ce,"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,a=new Map,c=new Map,o=r.scriptCode(e,r.filePath),l=j(o);for(let A of o.matchAll(/\bimport\s+(\{[^}]+\}|[\w$]+)\s+from\s*['"]([^'"]+)['"]/g)){if(l.slice(A.index,A.index+6)!=="import")continue;let C=A[2],d=fe.default.isAbsolute(C)||C.startsWith(".")?fe.default.resolve(fe.default.dirname(r.filePath),C):bt(C,fe.default.dirname(r.filePath));if(!d)continue;let f=d.endsWith(".stx")?d:Ae.default.existsSync(`${d}.stx`)?`${d}.stx`:void 0,w=f?null:xt(d,!1),b=A[1].startsWith("{")?A[1].slice(1,-1).split(","):[A[1]];for(let p of b){let[m,E=m]=p.trim().split(/\s+as\s+/),R=f||w?.get(m)||w?.get(m.toLowerCase());if(R)c.set(E,R),c.set(E.toLowerCase(),R),c.set(E.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),R)}}for(let A of n.matchAll(/@import\s*\(([^)]+)\)/g))for(let C of A[1].matchAll(/['"]([^'"]+)['"]/g)){let d=yt(C[1],r.filePath,r).find((f)=>Ae.default.statSync(f,{throwIfNoEntry:!1})?.isFile());if(d)c.set(fe.default.basename(C[1]).replace(/\.stx$/,""),d)}let u={__importedComponents:c},g=new Map,x=(A,C,d)=>{let f=e.slice(0,A);return{code:C,offset:A,attribute:d,anchor:!0,kind:"directive",line:f.split(`
|
|
32
|
+
`).length,column:A-f.lastIndexOf(`
|
|
33
|
+
`)}},_=(A,C,d)=>t.push({expression:A,statement:{text:C+A.code+d,prefixLength:C.length}});for(let A of zn(n)){if(wt(A.name)||A.name==="component")continue;let C=vt(A.name,r.filePath,r,u);if(!C)continue;let d=g.get(C);if(!d){let w;try{w=r.readComponent?r.readComponent(C):Ae.default.readFileSync(C,"utf8")}catch{continue}if(w===void 0)continue;a.set(C,w),d=Te(r.scriptCode(w,C),`__StxComponent${g.size}`),g.set(C,d),s.push(d.declarations)}let f=[];for(let w of A.attributes){let{name:b,offset:p}=w,m=w.value===!0?"true":w.value;if(b.startsWith("@")||b.startsWith("v-on:")){if(d.events&&w.value!==!0)i.set(p,`__StxEvent<${d.events}, ${JSON.stringify(b.replace(/^@|^v-on:/,"").split(".")[0])}>`);continue}let E=/^v-model(?::([\w-]+))?(?:\.[\w-]+)*$/.exec(b);if(b.startsWith("v-")&&!b.startsWith("v-bind:")&&!E)continue;if(/^(?:x-|:)(?:if|for|show|key|else)(?:$|[.:-])/.test(b))continue;let R=(E?E[1]||"modelValue":b.replace(/^:|^v-bind:/,"")).replace(/-([a-z])/g,(I,P)=>P.toUpperCase());if(f.push(R),!d.props)continue;let v=b.startsWith(":")||b.startsWith("v-bind:")||!!E||w.braced,O=v?m:w.value!==!0?JSON.stringify(m):"true",M=!v&&w.value!==!0&&(m==="true"||m==="false");_(x(p,O,b),";void ((",`) satisfies ${M?"__StxStaticProp":"__StxProp"}<${d.props}, ${JSON.stringify(R)}>);`)}if(d.props){let w=[...new Set(f)].map((p)=>`${JSON.stringify(p)}: undefined as any`).join(", "),b=x(A.offset,`<${A.name}>`);t.push({expression:b,statement:{text:`;void ({ ${w} } satisfies ${d.props} & Record<string, unknown>);`,prefixLength:0}})}}return{declarations:g.size?s.join(`
|
|
34
|
+
`):"",checks:t,events:i,dependencies:a}}var qe=ee(require("node:fs"),1),J=ee(require("node:path"),1);var Re=["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"];function Vn(){let{NODE_ENV:e}=process.env;return e==="production"}function We(){let{STX_DEBUG:e}=process.env;return!Vn()||e==="true"}var Wn={showRelativePaths:!1,enableAutoRecovery:We(),logRecoveryWarnings:!0},Es={...Wn};class He{errors=[];maxErrors;enableFileLogging;logFilePath;logFormat;maxFileSize;maxLogFiles;minLevel;writeQueue=Promise.resolve();constructor(e={}){this.maxErrors=e.maxErrors??1000,this.enableFileLogging=e.enableFileLogging??!1,this.logFilePath=e.logFilePath??".stx/errors.log",this.logFormat=e.logFormat??"json",this.maxFileSize=e.maxFileSize??10485760,this.maxLogFiles=e.maxLogFiles??5,this.minLevel=e.minLevel??"all"}configure(e){if(e.maxErrors!==void 0)this.maxErrors=e.maxErrors;if(e.enableFileLogging!==void 0)this.enableFileLogging=e.enableFileLogging;if(e.logFilePath!==void 0)this.logFilePath=e.logFilePath;if(e.logFormat!==void 0)this.logFormat=e.logFormat;if(e.maxFileSize!==void 0)this.maxFileSize=e.maxFileSize;if(e.maxLogFiles!==void 0)this.maxLogFiles=e.maxLogFiles;if(e.minLevel!==void 0)this.minLevel=e.minLevel}log(e,n,r="error"){let t={timestamp:new Date,error:e,context:n,level:r};if(this.errors.push(t),this.errors.length>this.maxErrors)this.errors=this.errors.slice(-this.maxErrors);if(this.enableFileLogging&&this.shouldLog(r))this.writeToFile(t)}shouldLog(e){if(this.minLevel==="all")return!0;if(this.minLevel==="warning")return e==="error"||e==="warning";if(this.minLevel==="error")return e==="error";return!0}formatEntry(e){if(this.logFormat==="json")return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level||"error",type:e.error.constructor.name,message:e.error.message,stack:e.error.stack,context:e.context});let n=[`[${e.timestamp.toISOString()}] [${(e.level||"error").toUpperCase()}] ${e.error.constructor.name}: ${e.error.message}`];if(e.error.stack)n.push(` Stack: ${e.error.stack.split(`
|
|
35
35
|
`).slice(1).join(`
|
|
36
36
|
`)}`);if(e.context)n.push(` Context: ${JSON.stringify(e.context)}`);return n.join(`
|
|
37
37
|
`)}writeToFile(e){this.writeQueue=this.writeQueue.then(async()=>{try{let n=await import("node:fs"),r=await import("node:path"),t=r.dirname(this.logFilePath);if(!n.existsSync(t))n.mkdirSync(t,{recursive:!0});await this.rotateIfNeeded(n);let s=`${this.formatEntry(e)}
|
|
38
38
|
`;n.appendFileSync(this.logFilePath,s,"utf-8")}catch(n){if(process.env.STX_DEBUG==="true")console.error("Failed to write to error log:",n)}})}async rotateIfNeeded(e){try{if(!e.existsSync(this.logFilePath))return;if(e.statSync(this.logFilePath).size<this.maxFileSize)return;for(let r=this.maxLogFiles-1;r>=1;r--){let t=`${this.logFilePath}.${r}`,s=`${this.logFilePath}.${r+1}`;if(e.existsSync(t))if(r>=this.maxLogFiles-1)e.unlinkSync(t);else e.renameSync(t,s)}if(this.maxLogFiles<=1)e.writeFileSync(this.logFilePath,"");else e.renameSync(this.logFilePath,`${this.logFilePath}.1`)}catch(n){if(process.env.STX_DEBUG==="true")console.error("Failed to rotate error logs:",n)}}getRecentErrors(e=10){return this.errors.slice(-e)}getErrorsByType(e){return this.errors.filter((n)=>n.error.constructor.name===e)}getErrorsByLevel(e){return this.errors.filter((n)=>n.level===e)}clear(){this.errors.length=0}async clearLogFile(){try{let e=await import("node:fs");if(e.existsSync(this.logFilePath))e.writeFileSync(this.logFilePath,"","utf-8")}catch(e){if(process.env.STX_DEBUG==="true")console.error("Failed to clear error log:",e)}}getStats(){let e={},n={error:0,warning:0,info:0};for(let r of this.errors){let t=r.error.constructor.name;e[t]=(e[t]||0)+1;let s=r.level||"error";n[s]=(n[s]||0)+1}return{total:this.errors.length,byType:e,byLevel:n}}async exportToFile(e,n="json"){let r=await import("node:fs"),t=await import("node:path"),s=t.dirname(e);if(!r.existsSync(s))r.mkdirSync(s,{recursive:!0});if(n==="json"){let i=this.errors.map((a)=>({timestamp:a.timestamp.toISOString(),level:a.level||"error",type:a.error.constructor.name,message:a.error.message,stack:a.error.stack,context:a.context}));r.writeFileSync(e,JSON.stringify(i,null,2),"utf-8")}else{let i=this.errors.map((a)=>this.formatEntry(a));r.writeFileSync(e,i.join(`
|
|
39
39
|
|
|
40
|
-
`),"utf-8")}}async flush(){await this.writeQueue}}var Gn=new He;var qn={maxSanitizeDepth:10,allowBracketNotation:!1},mi={...qn};var Xn="__stx_safe_ctors",kt=["Bun","Deno","Buffer","fetch","atob","btoa","console","Response","Request","Headers","WebAssembly","structuredClone","queueMicrotask","crypto","performance","navigator","Worker","WebSocket","BroadcastChannel","EventSource","XMLHttpRequest","localStorage","sessionStorage"],Zn=[...kt,"Function","setTimeout","setInterval","setImmediate","process","require","exports","module","window","document","global","globalThis","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry"],gi=Zn.map(()=>{return}),hi=Object.freeze(Object.assign(Object.create(null),{keys:Object.keys,values:Object.values,entries:Object.entries,fromEntries:Object.fromEntries,assign:Object.assign,hasOwn:Object.hasOwn,is:Object.is}));var xi=new Set([...kt,"eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this",Xn]);var Ct=["Collator","DateTimeFormat","DisplayNames","ListFormat","Locale","NumberFormat","PluralRules","RelativeTimeFormat","Segmenter"],bi=(()=>{let e={Date,URL,URLSearchParams},n=Intl;for(let r of Ct)if(typeof n[r]==="function")e[`Intl_${r}`]=n[r];return Object.freeze(Object.assign(Object.create(null),e))})();var yi=`only new Date(), new URL(), new URLSearchParams() and new Intl.{${Ct.join(",")}}() are allowed`;var Si=Symbol("stx.sanitizeCache");var vi=`stx-compile-probe:${globalThis.crypto.randomUUID()}`;var Ei=new ve(2000,{maxBytes:2097152,sizeOf:(e)=>e.sourceBytes});function Ee(e,n,r,t){if(e[n]!==r)return-1;let s=0,i=null;for(let a=n;a<e.length;a++){let c=e[a];if(i){if(c==="\\"){a++;continue}if(c===i)i=null;continue}if(c==="'"||c==='"'||c==="`"){i=c;continue}if(c===r)s++;else if(c===t){if(t===">"&&e[a-1]==="=")continue;if(s--,s===0)return a+1}}return-1}var
|
|
40
|
+
`),"utf-8")}}async flush(){await this.writeQueue}}var Gn=new He;var qn={maxSanitizeDepth:10,allowBracketNotation:!1},mi={...qn};var Xn="__stx_safe_ctors",kt=["Bun","Deno","Buffer","fetch","atob","btoa","console","Response","Request","Headers","WebAssembly","structuredClone","queueMicrotask","crypto","performance","navigator","Worker","WebSocket","BroadcastChannel","EventSource","XMLHttpRequest","localStorage","sessionStorage"],Zn=[...kt,"Function","setTimeout","setInterval","setImmediate","process","require","exports","module","window","document","global","globalThis","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry"],gi=Zn.map(()=>{return}),hi=Object.freeze(Object.assign(Object.create(null),{keys:Object.keys,values:Object.values,entries:Object.entries,fromEntries:Object.fromEntries,assign:Object.assign,hasOwn:Object.hasOwn,is:Object.is}));var xi=new Set([...kt,"eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this",Xn]);var Ct=["Collator","DateTimeFormat","DisplayNames","ListFormat","Locale","NumberFormat","PluralRules","RelativeTimeFormat","Segmenter"],bi=(()=>{let e={Date,URL,URLSearchParams},n=Intl;for(let r of Ct)if(typeof n[r]==="function")e[`Intl_${r}`]=n[r];return Object.freeze(Object.assign(Object.create(null),e))})();var yi=`only new Date(), new URL(), new URLSearchParams() and new Intl.{${Ct.join(",")}}() are allowed`;var Si=Symbol("stx.sanitizeCache");var vi=`stx-compile-probe:${globalThis.crypto.randomUUID()}`;var Ei=new ve(2000,{maxBytes:2097152,sizeOf:(e)=>e.sourceBytes});function Ee(e,n,r,t){if(e[n]!==r)return-1;let s=0,i=null;for(let a=n;a<e.length;a++){let c=e[a];if(i){if(c==="\\"){a++;continue}if(c===i)i=null;continue}if(c==="'"||c==='"'||c==="`"){i=c;continue}if(c===r)s++;else if(c===t){if(t===">"&&e[a-1]==="=")continue;if(s--,s===0)return a+1}}return-1}var At=require("node:module");var to=new Set(At.builtinModules);function Ke(e){return e.replace(/<!--[\s\S]*?-->|\{\{--[\s\S]*?--\}\}/g,(n)=>n.replace(/[^\n]/g," "))}function Ue(e){for(let n of ue(Ke(e))){let r=pe(n.attrs);if(!r.has("component")&&!r.has("stx:component"))continue;return{code:e.slice(n.bodyStart,n.bodyEnd),start:n.bodyStart,open:n.start}}}function Rt(e,n){let r=Ue(e);if(!r)return{};let t=r.code.trim();if(!t)return{};try{let s=JSON.parse(t);if(!s||typeof s!=="object"||Array.isArray(s))throw Error("expected a JSON object");return s}catch(s){throw Error(`${n}: <script component> must contain JSON metadata (${s.message})`)}}function Ge(e,n){let r=j(e),t=new Set(_e(e).map((o)=>o.start)),s=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)/g,i=[],a=n?void 0:new Bun.Transpiler({loader:"ts"}),c;while(c=s.exec(r)){if(!t.has(c.index+c[0].indexOf("function")))continue;let o=s.lastIndex;while(/\s/.test(r[o]||""))o++;let l=o;if(r[o]==="<")o=Ee(r,o,"<",">");if(o<0)continue;let u=e.slice(l,o).trim();while(/\s/.test(r[o]||""))o++;if(r[o]!=="(")continue;let g=o,x=Ee(r,o,"(",")");if(x<0)continue;for(o=x;o<e.length;o++){let _=r[o];if(_!=="{"&&_!==";")continue;let A=e.slice(c.index,o).trim();if(n){if(!n(A,_,c[1]))continue}else{let d;try{d=a.transformSync(A+(_==="{"?"{}":";"))}catch{continue}if(_==="{"&&!d.includes(`function ${c[1]}(`))continue;if(_===";"&&d.trim())continue}let C=_==="{"?Ee(r,o,"{","}"):o+1;if(C<0)break;i.push({name:c[1],header:A,generic:u,parameterOffset:g+1,parameters:e.slice(g+1,x-1),returns:e.slice(x,o).trim().replace(/^:\s*/,""),async:/\basync\s+function/.test(c[0]),..._==="{"?{source:e.slice(c.index,C)}:{}}),s.lastIndex=C;break}}return i}function Oe(e,n){if(e[n]!=="(")return null;let r=0,t="";for(let s=n;s<e.length;s++){let i=e[s];if(t!==""){if(i==="\\")s++;else if(i===t)t="";continue}if(i==="'"||i==='"'||i==="`"){t=i;continue}if(i==="(")r++;else if(i===")"){if(r--,r===0)return{expression:e.slice(n+1,s),end:s+1}}}return null}function Ot(e){let n=/^([\s\S]+?)\s+as\s+(?:([A-Za-z_$][\w$]*)\s*=>\s*)?([A-Za-z_$][\w$]*)$/.exec(e.trim());return n?{iterable:n[1],key:n[2],value:n[3]}:void 0}function Je(e){if(!e||typeof e!=="object")return"unknown";switch(e.type){case"boolean":return"boolean";case"number":return"number";case"array":return"unknown[]";case"object":return"Record<string, unknown>";default:return"string"}}var tr=new Set(Re);function Pe(e){let n=he(e),r=n.find((g)=>g.name==="InheritedContext");if(!r)return;let t=/^(?:interface\s+InheritedContext|type\s+InheritedContext\s*=)\s*\{/.test(j(r.text).trim()),s=j(e),i=U(s).depths,a=[...s.matchAll(/\b(?:interface|type)\s+InheritedContext\b/g)].find((g)=>i[g.index]===0)?.index??0,c=r.text.slice(r.text.indexOf("{")+1,r.text.lastIndexOf("}")),o=j(c),l=U(o).depths,u=[...o.matchAll(/(?:^|[;,\n])\s*(?:readonly\s+)?([A-Za-z_$][\w$]*)\??\s*:/g)].filter((g)=>l[g.index]===0).map((g)=>g[1]);return{keys:t?u:[],types:n.map((g)=>g.text).join(`
|
|
41
41
|
`),offset:Math.max(0,a),...!t?{unsupported:"InheritedContext requires a local non-generic object interface or object type alias with named properties"}:{}}}function nr(e){let n=[],r=j(e);for(let t of e.matchAll(/\bimport\s+(type\s+)?([\w$*{}\s,]+?)\s+from\s*(['"])([^'"]+)\3/g)){if(t[1]||r.slice(t.index,t.index+6)!=="import")continue;let s=t[2].trim(),i=["stx","@stacksjs/stx"].includes(t[4]);if(/^[A-Za-z_$][\w$]*$/.test(s)){n.push(s);continue}if(!s.startsWith("{")||!s.endsWith("}"))continue;for(let a of s.slice(1,-1).split(",")){if(/^\s*type\s+/.test(a))continue;let[c,o=c]=a.trim().split(/\s+as\s+/);if(o&&!(i&&tr.has(c)))n.push(o)}}return n}function Pt(e){let n=Pe(e);if(!n||n.unsupported)return"";let r=new Set(ce(e));return n.keys.filter((t)=>!r.has(t)).map((t)=>`declare const ${t}: InheritedContext[${JSON.stringify(t)}];`).join(`
|
|
42
|
-
`)}function Mt(e,n){let r=[Ce],t=[],s=new Map,i=J.default.resolve(n.filePath),a=i.split(J.default.sep).lastIndexOf("views"),c=a>=0?i.split(J.default.sep).slice(0,a).join(J.default.sep):J.default.dirname(i),o=J.default.resolve(n.partialsDir||J.default.join(c,"partials")),l=J.default.resolve(n.layoutsDir||J.default.join(c,"views/layouts"));if([o,l].some((d)=>i===d||i.startsWith(d+J.default.sep)))return{declarations:"",checks:t,dependencies:s};let u=(d)=>n.readTemplate?.(d)??(qe.default.existsSync(d)?qe.default.readFileSync(d,"utf8"):void 0),g=0,x=!1,_=[];function
|
|
42
|
+
`)}function Mt(e,n){let r=[Ce],t=[],s=new Map,i=J.default.resolve(n.filePath),a=i.split(J.default.sep).lastIndexOf("views"),c=a>=0?i.split(J.default.sep).slice(0,a).join(J.default.sep):J.default.dirname(i),o=J.default.resolve(n.partialsDir||J.default.join(c,"partials")),l=J.default.resolve(n.layoutsDir||J.default.join(c,"views/layouts"));if([o,l].some((d)=>i===d||i.startsWith(d+J.default.sep)))return{declarations:"",checks:t,dependencies:s};let u=(d)=>n.readTemplate?.(d)??(qe.default.existsSync(d)?qe.default.readFileSync(d,"utf8"):void 0),g=0,x=!1,_=[];function A(d,f){let w=e.slice(0,d).split(`
|
|
43
43
|
`).length,b=d-e.lastIndexOf(`
|
|
44
44
|
`,d-1),p={code:e.slice(d,e.indexOf(`
|
|
45
45
|
`,d)<0?e.length:e.indexOf(`
|
|
46
|
-
`,d)),line:w,column:b,kind:"directive",offset:d,anchor:!0};t.push({expression:p,statement:{text:`;${f}`,prefixLength:1}})}function C(d,f,w,b,p,m){let E=`__StxInherited${g++}`;while((e+d+[...s.values()].join("")).includes(E))E+="_";let
|
|
47
|
-
`),v=`${E}ParentValue`,O=`${E}ParentType`;r.push(`type ${O} = ${w};`);let M=Xe(Ie(
|
|
46
|
+
`,d)),line:w,column:b,kind:"directive",offset:d,anchor:!0};t.push({expression:p,statement:{text:`;${f}`,prefixLength:1}})}function C(d,f,w,b,p,m){let E=`__StxInherited${g++}`;while((e+d+[...s.values()].join("")).includes(E))E+="_";let R=me(d).filter((L)=>L.kind==="server").map((L)=>L.code).join(`
|
|
47
|
+
`),v=`${E}ParentValue`,O=`${E}ParentType`;r.push(`type ${O} = ${w};`);let M=Xe(Ie(R,J.default.dirname(f)),E);r.push(...M.imports);let I=Pe(R);if(I&&p!==void 0){x=!0;let L=M.imports.length?M.aliases.join(`
|
|
48
48
|
`):"",W=Te(`${L}
|
|
49
49
|
${I.types}
|
|
50
|
-
const __contract = defineProps<InheritedContext>();`,`${E}Contract`);r.push(W.declarations),r.push(`declare const ${E}Input: ${O};`),
|
|
50
|
+
const __contract = defineProps<InheritedContext>();`,`${E}Contract`);r.push(W.declarations),r.push(`declare const ${E}Input: ${O};`),A(p,I.unsupported?`({})[${JSON.stringify(I.unsupported)}];`:`${E}Input satisfies ${W.props};`)}let P=[...new Set([...ce(R),...nr(R)])],B=[...new Set([...b,...I?.keys||[]])].filter((L)=>!P.includes(L)),K=I?`${O} & ${E}Contract.__StxProps`:O,q=Me(M.body).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,""),G=[],te=ge(d),se=/@(include|extends|layout)\s*\(/g,X;while(X=se.exec(te)){let L=Oe(te,se.lastIndex-1);if(!L)continue;se.lastIndex=L.end;let W=/^\s*(['"])(.*?)\1\s*(?:,\s*([\s\S]*))?$/.exec(L.expression);if(!W){_.push({offset:p??X.index,message:`Inherited context cannot be checked across dynamic @${X[1]}`});continue}let Q=W[2],F=X[1];if(F!=="include"&&W[3])_.push({offset:p??X.index,message:`Inherited context cannot be checked for unsupported @${F} data arguments`});let $e=F==="include"?o:l,be=J.default.resolve(Q.startsWith(".")?J.default.dirname(f):$e,Q.endsWith(".stx")?Q:Q+".stx");if(u(be)===void 0){_.push({offset:p??X.index,message:`Inherited context target cannot be resolved: ${Q}`});continue}G.push({name:`edge${G.length}`,target:be,kind:F,args:F==="include"?W[3]||"{}":"{}",offset:p??X.index})}let le=`{ ...${v}${P.length?", "+P.join(", "):""} }`;r.push(`namespace ${E} {
|
|
51
51
|
${M.aliases.join(`
|
|
52
52
|
`)}
|
|
53
53
|
export async function read(${v}: ${p===void 0?"{}":K}) {
|
|
@@ -55,47 +55,47 @@ ${B.length?`const { ${B.join(", ")} } = ${v};`:""}
|
|
|
55
55
|
${q}
|
|
56
56
|
return { context: ${le}${G.map((L)=>`, ${L.name}: { ...${le}, ...(${L.args}) }`).join("")} };
|
|
57
57
|
}
|
|
58
|
-
}`);for(let L of G){if(m.includes(L.target)||m.length>=32){_.push({offset:L.offset,message:"Inherited context cannot be checked across a cyclic or overly deep template graph"});continue}let W=u(L.target);s.set(L.target,W),C(W,L.target,`Awaited<ReturnType<typeof ${E}.read>>[${JSON.stringify(L.name)}]`,[...new Set([...b,...P])],L.offset,[...m,L.target])}return E}if(C(e,i,"{}",[],void 0,[i]),x||n.contractsKnown)for(let d of _)
|
|
59
|
-
`):"",checks:t,dependencies:s}}function It(e,n){let r=Ke(e),t=Ue(e);if(!t)return;let s;try{s=
|
|
58
|
+
}`);for(let L of G){if(m.includes(L.target)||m.length>=32){_.push({offset:L.offset,message:"Inherited context cannot be checked across a cyclic or overly deep template graph"});continue}let W=u(L.target);s.set(L.target,W),C(W,L.target,`Awaited<ReturnType<typeof ${E}.read>>[${JSON.stringify(L.name)}]`,[...new Set([...b,...P])],L.offset,[...m,L.target])}return E}if(C(e,i,"{}",[],void 0,[i]),x||n.contractsKnown)for(let d of _)A(d.offset,`({})[${JSON.stringify(d.message)}];`);return{declarations:x?r.join(`
|
|
59
|
+
`):"",checks:t,dependencies:s}}function It(e,n){let r=Ke(e),t=Ue(e);if(!t)return;let s;try{s=Rt(e,"component")}catch(p){let m=t.open,E=p instanceof Error?p.message:"Invalid component metadata";return{declarations:"",checks:[{text:`({})[${JSON.stringify(E)}];`,line:e.slice(0,m).split(`
|
|
60
60
|
`).length,column:m-e.lastIndexOf(`
|
|
61
|
-
`,m-1),origin:"component"}],project:(
|
|
61
|
+
`,m-1),origin:"component"}],project:(R)=>({code:R,columns:new Map})}}let i=ue(r).filter((p)=>{let m=pe(p.attrs);return Se(m)&&m.has("client")&&!m.has("server")&&!m.has("component")&&!m.has("stx:component")&&!m.has("src")}),a=i.map((p)=>e.slice(p.bodyStart,p.bodyEnd)).join(`
|
|
62
62
|
`),c=Ge(a,n),o=he(a).some((p)=>p.name==="ComponentState")||Ne(a).includes("ComponentState"),l=Object.entries(s.properties||s.props||{}).map(([p,m])=>`${JSON.stringify(p)}: ${Je(m)}`).join("; "),u=[...new Set(c.map((p)=>p.name))],g=[`interface __StxMetadataProperties { ${l} }`,"type __StxNativeProperties = Omit<__StxMetadataProperties, keyof HTMLElement> & Pick<HTMLElement, Extract<keyof __StxMetadataProperties, keyof HTMLElement>>;","type __StxAny<T> = 0 extends (1 & T) ? true : false;","type __StxAnyFields<T> = { [K in keyof T]-?: __StxAny<T[K]> extends true ? K : never }[keyof T];","type __StxSpecific<T> = __StxAny<T> extends true ? false : T extends object ? string extends keyof T ? false : number extends keyof T ? false : symbol extends keyof T ? false : __StxAnyFields<T> extends never ? true : false : false;",o?"type __StxState = __StxSpecific<ComponentState> extends true ? ComponentState : {};":"type __StxState = {};",o?'declare function __stxSpecificState(value: __StxSpecific<ComponentState> extends true ? true : "ComponentState requires named explicit fields without any or index signatures"): void;':"",o?"declare const __stxStateProperties: Pick<ComponentState, Extract<keyof ComponentState, keyof __StxInstanceProperties>>;":"",o?'declare function __stxStateMethods(value: Extract<keyof ComponentState, __StxMethodNames | "emit" | "requestUpdate" | "updateComplete" | "renderRoot"> extends never ? true : "ComponentState cannot redeclare component methods"): void;':"",`type __StxMethodNames = ${u.map((p)=>JSON.stringify(p)).join(" | ")||"never"};`,"type __StxInstanceProperties = Omit<HTMLElement, __StxMethodNames | keyof __StxNativeProperties> & __StxNativeProperties;",'type __StxPrivateKeys<T> = Exclude<keyof T, keyof HTMLElement | keyof __StxNativeProperties | __StxMethodNames | "emit" | "updateComplete" | "requestUpdate" | "renderRoot">;',o?'declare function __stxOptionalPrivate(value: { [K in __StxPrivateKeys<ComponentState>]-?: {} extends Pick<ComponentState, K> ? never : K }[__StxPrivateKeys<ComponentState>] extends never ? true : "Private ComponentState fields must be optional until initialized"): void;':"","type __StxRefinedProperties = { [K in keyof __StxNativeProperties]: K extends keyof __StxState ? __StxAny<__StxState[K]> extends true ? __StxNativeProperties[K] : __StxState[K] extends __StxNativeProperties[K] ? __StxState[K] : __StxNativeProperties[K] : __StxNativeProperties[K] };","type __StxNativeComponent = Omit<HTMLElement, keyof __StxNativeProperties | __StxMethodNames> & __StxRefinedProperties & Partial<Pick<__StxState, __StxPrivateKeys<__StxState>>> & {","readonly updateComplete: Promise<void>; requestUpdate(): Promise<void>; readonly renderRoot: HTMLElement | ShadowRoot;","emit<T = unknown>(name: string, detail?: T, options?: CustomEventInit<T>): boolean;",...u.map((p)=>`${JSON.stringify(p)}: typeof ${p};`),"}"].filter(Boolean).join(`
|
|
63
|
-
`),x=-1;for(let p of i){let m=p.bodyStart,E=e.slice(m,p.bodyEnd),
|
|
63
|
+
`),x=-1;for(let p of i){let m=p.bodyStart,E=e.slice(m,p.bodyEnd),R=j(E),v=U(R).depths,O=[...R.matchAll(/\b(?:interface|type)\s+ComponentState\b/g)].find((M)=>v[M.index]===0)??(Ne(E).includes("ComponentState")?/\bComponentState\b/.exec(R):void 0);if(O){x=m+O.index;break}}let _=o&&x>=0?[{origin:"client",text:"__stxSpecificState(true); __stxStateMethods(true); __stxOptionalPrivate(true); __stxStateProperties satisfies Pick<__StxInstanceProperties, Extract<keyof ComponentState, keyof __StxInstanceProperties>>;",line:e.slice(0,x).split(`
|
|
64
64
|
`).length,column:x-e.lastIndexOf(`
|
|
65
|
-
`,x-1)}]:[],{start:
|
|
65
|
+
`,x-1)}]:[],{start:A,code:C}=t,d=j(C),f=U(d).depths,w=new Map,b=!1;for(let p of C.matchAll(/"(?:\\.|[^"\\])*"\s*:/g)){let m=JSON.parse(p[0].slice(0,p[0].lastIndexOf(":")).trim());if(f[p.index]===1&&["properties","props"].includes(m)){b=!0;continue}if(b&&f[p.index]===1)b=!1;if(b&&f[p.index]===2&&!w.has(m))w.set(m,A+p.index)}for(let[p,m]of Object.entries(s.properties||s.props||{})){let E=w.get(p)??A,R=e.slice(0,E).split(`
|
|
66
66
|
`).length,v=E-e.lastIndexOf(`
|
|
67
|
-
`,E-1);if(!m||typeof m!=="object"||!["string","number","boolean","object","array"].includes(m.type))_.push({text:`({})[${JSON.stringify(`Property ${p} must declare string, number, boolean, object or array`)}];`,line:
|
|
67
|
+
`,E-1);if(!m||typeof m!=="object"||!["string","number","boolean","object","array"].includes(m.type))_.push({text:`({})[${JSON.stringify(`Property ${p} must declare string, number, boolean, object or array`)}];`,line:R,column:v,origin:"component"});if(m&&m.default!==void 0)_.push({text:`const __stxDefault${_.length}: ${Je(m)} = ${JSON.stringify(m.default)};`,line:R,column:v,origin:"component"})}return{declarations:g,checks:_,project(p){let m=new Map,E=[],R=0;for(let v of Ge(p,n)){if(/^\s*this\s*:/.test(v.parameters))continue;let O=v.parameterOffset,M=`this: __StxNativeComponent${v.parameters.trim()?", ":""}`;E.push(p.slice(R,O),M);let I=p.slice(0,O).split(`
|
|
68
68
|
`).length,P=O-p.lastIndexOf(`
|
|
69
|
-
`,O-1),B=m.get(I)||[],K=B.at(-1),q=P+(K?K.generatedEnd-K.sourceEnd:0);B.push({sourceStart:P,sourceEnd:P,generatedStart:q,generatedEnd:q+M.length}),m.set(I,B),
|
|
69
|
+
`,O-1),B=m.get(I)||[],K=B.at(-1),q=P+(K?K.generatedEnd-K.sourceEnd:0);B.push({sourceStart:P,sourceEnd:P,generatedStart:q,generatedEnd:q+M.length}),m.set(I,B),R=O}return E.push(p.slice(R)),{code:E.join(""),columns:m}}}}function Nt(e){let n=[],r=[],t=/@foreach\s*\(|@endforeach\b/g,s;while(s=t.exec(e)){if(s[0].startsWith("@endforeach")){let o=r.pop();if(o)o.end=s.index,n.push(o);continue}let i=Oe(e,t.lastIndex-1);if(!i)continue;let a=Ot(i.expression),c=i.end;if(a)r.push({start:c,end:e.length,iterable:a.iterable,binding:a.key?`${a.value}, ${a.key}`:a.value});t.lastIndex=c}return n.sort((i,a)=>i.start-a.start)}function Dt(e){if(!e.includes("#")&&!e.includes("v-slot:")&&!e.includes("data-stx-slot-binding"))return[];let n=[],r=[],t=/<!--[\s\S]*?-->|<script\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/script\s*>|<style\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/style\s*>|<\/?[a-z][\w:-]*\b(?:"[^"]*"|'[^']*'|[^'">])*>/gi;for(let s of e.matchAll(t)){let i=s[0];if(/^<\/template\s*>$/i.test(i)){let a=r.pop();if(a)a.end=s.index}else if(/^<template\b/i.test(i)&&!/\/\s*>$/.test(i)){let c=[...i.slice(9).matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g)].find((u)=>/^(?:#[\w-]+|v-slot:[\w-]+|data-stx-slot-binding)$/i.test(u[1])),o=(c?.[2]??c?.[3])?.trim();if(o&&c?.[1]==="data-stx-slot-binding")try{o=decodeURIComponent(o)}catch{o=void 0}let l=o?{start:s.index+i.length,end:e.length,binding:o}:void 0;if(r.push(l),l)n.push(l)}}return n}function rr(e){let n=(r)=>r.replace(/[^\n]/g," ");return e.replace(/<!--[\s\S]*?-->/g,n).replace(/\{\{--[\s\S]*?--\}\}/g,n)}function me(e){let n=[],r=rr(e);for(let t of ue(r)){let s=t.attrs.trim(),i=pe(s),{bodyStart:a,bodyEnd:c}=t,o=e.slice(a,c);if(i.has("src")||i.has("component")||i.has("stx:component"))continue;if(!Se(i))continue;let l=i.has("server")?"server":i.has("client")?"client":"plain",u=sr(e,a);n.push({kind:l,code:o,startLine:u,startColumn:ir(e,a),offset:a,attrs:s})}return n}function sr(e,n){let r=1;for(let t=0;t<n&&t<e.length;t++)if(e.charCodeAt(t)===10)r++;return r}function ir(e,n){let r=e.lastIndexOf(`
|
|
70
70
|
`,n-1)+1;return n-r+1}function ge(e){let n=e.split(""),r=(s,i)=>{for(let a=s;a<i&&a<n.length;a++)if(n[a]!==`
|
|
71
|
-
`)n[a]=" "},t=[/<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 s of t){s.lastIndex=0;let i;while((i=s.exec(e))!==null)r(i.index,i.index+i[0].length)}return n.join("")}function Vt(e){let n=0,r="";for(let t=0;t<e.length;t++){let s=e[t];if(r){if(s==="\\"){t++;continue}if(s===r)r="";continue}if(s==='"'||s==="'"||s==="`"){r=s;continue}if(s==="("||s==="["||s==="{"){n++;continue}if(s===")"||s==="]"||s==="}"){n--;continue}if(s==="|"&&n===0){if(e[t+1]==="|"){t++;continue}if(e[t-1]==="|")continue;return e.slice(0,t)}}return e}var Wt=new Set([":for","x-for","v-for"]),De=/(?:^|\s)((?::|x-|v-|@)[\w.:-]+)\s*=\s*(["'])([\s\S]*?)\2/g,Qe="__stx_interpolated",Lt="__StxElement",Ht="__StxTemplateValue",or=`type ${Ht}<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? (T extends () => infer V ? T & V : T) : T`;function jt(e){return e.replace(/\{\{[\s\S]*?\}\}/g,Qe).replace(/\{!![\s\S]*?!!\}/g,Qe)}function ar(e,n,r){let t=0;for(let s=n;s<e.length;s++){let i=e[s];if(i==="{"){t++;continue}if(i!=="}"&&i!=="!")continue;if(e.startsWith(r,s)&&t===0)return s;if(i==="}"&&t>0)t--}return-1}function cr(e,n,r="0"){let t=`__stxScript${r}`;while((e+n).includes(t))t+="_";let s=new Map,i=[],a=[],c=j(e),o=xe(e),l=[],u=0;for(let C=0;C<c.length;C++){let d=c.startsWith("{{",C);if(!d&&!c.startsWith("{!!",C))continue;let f=d?2:3,w=d?"}}":"!!}",b=ar(c,C+f,w);if(b<0)continue;let p=C,m=e.slice(p,b+w.length),E=m.slice(f,-w.length);C=b+w.length-1;let
|
|
71
|
+
`)n[a]=" "},t=[/<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 s of t){s.lastIndex=0;let i;while((i=s.exec(e))!==null)r(i.index,i.index+i[0].length)}return n.join("")}function Vt(e){let n=0,r="";for(let t=0;t<e.length;t++){let s=e[t];if(r){if(s==="\\"){t++;continue}if(s===r)r="";continue}if(s==='"'||s==="'"||s==="`"){r=s;continue}if(s==="("||s==="["||s==="{"){n++;continue}if(s===")"||s==="]"||s==="}"){n--;continue}if(s==="|"&&n===0){if(e[t+1]==="|"){t++;continue}if(e[t-1]==="|")continue;return e.slice(0,t)}}return e}var Wt=new Set([":for","x-for","v-for"]),De=/(?:^|\s)((?::|x-|v-|@)[\w.:-]+)\s*=\s*(["'])([\s\S]*?)\2/g,Qe="__stx_interpolated",Lt="__StxElement",Ht="__StxTemplateValue",or=`type ${Ht}<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? (T extends () => infer V ? T & V : T) : T`;function jt(e){return e.replace(/\{\{[\s\S]*?\}\}/g,Qe).replace(/\{!![\s\S]*?!!\}/g,Qe)}function ar(e,n,r){let t=0;for(let s=n;s<e.length;s++){let i=e[s];if(i==="{"){t++;continue}if(i!=="}"&&i!=="!")continue;if(e.startsWith(r,s)&&t===0)return s;if(i==="}"&&t>0)t--}return-1}function cr(e,n,r="0"){let t=`__stxScript${r}`;while((e+n).includes(t))t+="_";let s=new Map,i=[],a=[],c=j(e),o=xe(e),l=[],u=0;for(let C=0;C<c.length;C++){let d=c.startsWith("{{",C);if(!d&&!c.startsWith("{!!",C))continue;let f=d?2:3,w=d?"}}":"!!}",b=ar(c,C+f,w);if(b<0)continue;let p=C,m=e.slice(p,b+w.length),E=m.slice(f,-w.length);C=b+w.length-1;let R=a.length,v=Y(o,p),O=Y(o,p+(d?2:3));a.push({code:Vt(E),...O});let M=`${t}_${R}`,I=m.split(`
|
|
72
72
|
`),P=I[0].length;I[0]=M+" ".repeat(Math.max(0,P-M.length));for(let G=1;G<I.length;G++)I[G]=I[G].replace(/[^\r]/g," ");let B=s.get(v.line)??[],K=B.at(-1),q=v.column+(K?K.generatedEnd-K.sourceEnd:0);B.push({sourceStart:v.column,sourceEnd:v.column+P,generatedStart:q,generatedEnd:q+I[0].length}),s.set(v.line,B),l.push(e.slice(u,p),I.join(`
|
|
73
|
-
`)),u=p+m.length}l.push(e.slice(u));let g=l.join("");if(!a.length)return{code:g,columns:s,declarations:i};let{imports:x,aliases:_,body:
|
|
73
|
+
`)),u=p+m.length}l.push(e.slice(u));let g=l.join("");if(!a.length)return{code:g,columns:s,declarations:i};let{imports:x,aliases:_,body:A}=Xe(n,t);for(let C of x)i.push({text:C});i.push({text:`namespace ${t}Scope {
|
|
74
74
|
${_.join(`
|
|
75
75
|
`)}
|
|
76
76
|
export async function read() {
|
|
77
|
-
${Me(
|
|
77
|
+
${Me(A).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,"")}
|
|
78
78
|
return {`});for(let[C,d]of a.entries())i.push({text:`value${C}: (`}),i.push({text:d.code,origin:{line:d.line,column:d.column}}),i.push({text:"),"});i.push({text:`}
|
|
79
79
|
}
|
|
80
|
-
}`});for(let C=0;C<a.length;C++)i.push({text:`declare var ${t}_${C}: Awaited<ReturnType<typeof ${t}Scope.read>>['value${C}']`});return{code:g,columns:s,declarations:i}}function Xe(e,n){let r=[],{imports:t,body:s}=gr(e),i=[],a=0;for(let c of t.split(/\n(?=import\b)/)){if(!c.trim())continue;let o=/^import\s+(?:type\s+)?([\s\S]+?)\s+from\s*(['"][^'"]+['"])/.exec(c);if(!o){r.push(c);continue}let l=`${n}Module${a++}`;r.push(`import * as ${l} from ${o[2]}`);let u=o[1],g=/\{([\s\S]*?)\}/.exec(u);for(let C of g?.[1].split(",")??[]){let[d,f=d]=C.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(d==="default")i.push(`const ${f} = ${l}.default; type ${f} = import(${o[2]}).default`);else if(d)i.push(`import ${f} = ${l}.${d}`)}let x=u.replace(/\{[\s\S]*?\}/,""),_=/\*\s+as\s+(\w+)/.exec(x);if(_)i.push(`import ${_[1]} = ${l}`);let
|
|
80
|
+
}`});for(let C=0;C<a.length;C++)i.push({text:`declare var ${t}_${C}: Awaited<ReturnType<typeof ${t}Scope.read>>['value${C}']`});return{code:g,columns:s,declarations:i}}function Xe(e,n){let r=[],{imports:t,body:s}=gr(e),i=[],a=0;for(let c of t.split(/\n(?=import\b)/)){if(!c.trim())continue;let o=/^import\s+(?:type\s+)?([\s\S]+?)\s+from\s*(['"][^'"]+['"])/.exec(c);if(!o){r.push(c);continue}let l=`${n}Module${a++}`;r.push(`import * as ${l} from ${o[2]}`);let u=o[1],g=/\{([\s\S]*?)\}/.exec(u);for(let C of g?.[1].split(",")??[]){let[d,f=d]=C.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(d==="default")i.push(`const ${f} = ${l}.default; type ${f} = import(${o[2]}).default`);else if(d)i.push(`import ${f} = ${l}.${d}`)}let x=u.replace(/\{[\s\S]*?\}/,""),_=/\*\s+as\s+(\w+)/.exec(x);if(_)i.push(`import ${_[1]} = ${l}`);let A=/^\s*([\w$]+)/.exec(x)?.[1];if(A)i.push(`const ${A} = ${l}.default; type ${A} = import(${o[2]}).default`)}return{imports:r,aliases:i,body:s}}function Ze(e,n){let r=0;for(let t of e){if(n<t.generatedStart)break;if(n<t.generatedEnd)return t.sourceStart+Math.min(n-t.generatedStart,t.sourceEnd-t.sourceStart);r=t.sourceEnd-t.generatedEnd}return n+r}function Ye(e,n){let r=0;for(let t of e){if(n<t.sourceStart)break;if(n<t.sourceEnd)return t.generatedStart+Math.min(n-t.sourceStart,t.generatedEnd-t.generatedStart);r=t.generatedEnd-t.sourceEnd}return n+r}var lr=["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"],ur=new RegExp(String.raw`^[ \t]*@(?:${lr.join("|")})\b[ \t]*(\([^\n)]*\))?[ \t]*$`,"gm");function Me(e){return e.replace(ur,(n)=>n.replace(/[^\n]/g," "))}var Ft=new Set(["x-cloak","x-ref","x-transition","x-teleport","v-slot","x-hydrate",":key","x-tooltip","x-tooltip-position"]);function pr(e){let n=ge(e),r=[],t=xe(n),s=/(@?)\{\{([\s\S]*?)\}\}|(@?)\{!!([\s\S]*?)!!\}/g,i;while((i=s.exec(n))!==null){if(i[1]||i[3])continue;let o=i[2]??i[4]??"",l=i[2]!==void 0?2:3,u=Vt(o);if(!u.trim())continue;let g=i.index+l+(u.length-u.trimStart().length);r.push({code:u.trim(),...Y(t,g),offset:g,kind:"interpolation"})}let a=/@(if|elseif|else\s+if|unless)\b\s*\(/g;while((i=a.exec(n))!==null){let c=i.index+i[0].length-1,o=0,l=c;for(;l<n.length;l++){let _=n[l];if(_==="(")o++;else if(_===")"){if(o--,o===0)break}}if(o!==0)continue;let u=n.slice(c+1,l),g=u.trim();if(a.lastIndex=l+1,!g)continue;let x=c+1+(u.length-u.trimStart().length);r.push({code:g,...Y(t,x),offset:i.index,kind:"condition"})}De.lastIndex=0;while((i=De.exec(n))!==null){let c=i[1],o=i[3]??"",l=c.replace(/\..*$/,"").replace(/^([^:].*?):.*$/,"$1");if(Ft.has(l)||Ft.has(c))continue;if(!o.trim())continue;let u=i.index+i[0].indexOf(i[2],i[0].indexOf(c)+c.length)+1;if(Wt.has(l)){let x=o.match(/\s+(?:in|of)\s+/);if(!x||x.index===void 0)continue;let _=o.slice(x.index+x[0].length),A=x.index+x[0].length+(_.length-_.trimStart().length);r.push({code:jt(_.trim()),...Y(t,u+A),offset:u+A,kind:"directive",attribute:l});continue}let g=o.length-o.trimStart().length;r.push({code:jt(o.trim()),...Y(t,u+g),offset:u+g,kind:"directive",attribute:l})}return r.sort((c,o)=>c.line-o.line||c.column-o.column),r}var dr=2000;function fr(e,n){let r=0,t=Math.min(e.length,n+dr);for(let s=n;s<t;s++){let i=e[s];if(i==="(")r++;else if(i===")"){if(r--,r===0)return e.slice(n+1,s)}}return null}function mr(e){let n=new Map,r=(c,o)=>{let l=c.split(/[,[\]{}()\s]+/).filter(Boolean);for(let u of l){let g=u.replace(/^\.\.\./,"").trim();if(!/^\$?[A-Z_$][\w$]*$/i.test(g))continue;let x=l.length===1?o:void 0,_=n.get(g);if(!_)n.set(g,{name:g,iterable:x});else if(_.iterable!==x)_.iterable=void 0}},t=/^\$?[A-Z_$][\w$]*$/i,s=(c)=>{let o=c.trim();return t.test(o)?o:void 0};for(let c of e.matchAll(/@for(?:each|else)\s*\(/g)){let o=fr(e,c.index+c[0].length-1);if(o===null)continue;let l=ft(o);if(!l)continue;r(l.itemVar.replace(/=>/g," "),s(l.arrayExpr))}for(let c of e.matchAll(/@for\s*\(\s*(?:(?:let|const|var)\s+)?([\w$]+|\[[^\]]*\]|\{[^}]*\})\s+(of|in)\s+([^)]*)/g))r(c[1],c[2]==="of"?s(c[3]):void 0);for(let c of e.matchAll(/@for\s*\(\s*(?:let|const|var)\s+([\w$]+)\s*[=;]/g))r(c[1]);let i=ge(e);De.lastIndex=0;let a;while((a=De.exec(i))!==null){let c=a[1].replace(/\..*$/,"");if(!Wt.has(c))continue;let o=a[3].match(/\s+(?:in|of)\s+/);if(!o||o.index===void 0)continue;r(a[3].slice(0,o.index),s(a[3].slice(o.index+o[0].length)))}for(let c of e.matchAll(/@(?:php|js|ts)\b([\s\S]*?)@end(?:php|js|ts)\b/g))for(let o of c[1].matchAll(/\b(?:const|let|var|function|class)\s+([\w$]+)/g))r(o[1]);return[...n.values()].sort((c,o)=>c.name.localeCompare(o.name))}function ce(e){return dt(e)}var Bt=["params","query","cookies","host","ip","setResponseStatus","setResponseHeader","notFound","request","url","definePageMeta","defineClientPayload","defineStore","props","$props"];function Kt(e){return new Set([...e.matchAll(/^declare (?:function|const|let|var)\s+([A-Za-z_$][\w$]*)/gm)].map((n)=>n[1]))}function gr(e){let n=/^[ \t]*import\b[\s\S]*?(?:from\s*['"][^'"]*['"]|['"][^'"]*['"])[ \t]*;?[ \t]*$/gm,r=[],t=e.replace(n,(s)=>(r.push(s.trim()),s.split(`
|
|
81
81
|
`).map(()=>"").join(`
|
|
82
82
|
`)));return{imports:r.join(`
|
|
83
83
|
`),body:t}}function he(e){let n=j(e),r=Array(n.length),t=0;for(let c=0;c<n.length;c++){let o=n[c];if(o==="}"||o===")"||o==="]")t=Math.max(0,t-1);if(r[c]=t,o==="{"||o==="("||o==="[")t++}let s=[],i=/^[ \t]*(?:export[ \t]+)?(interface|type)[ \t]+([A-Za-z_$][\w$]*)/gm,a;while((a=i.exec(n))!==null){if(r[a.index]!==0)continue;let c=a[1],o=a[2],l;if(c==="interface"){let u=n.indexOf("{",a.index);if(u===-1)continue;let g=0;l=-1;for(let x=u;x<n.length;x++)if(n[x]==="{")g++;else if(n[x]==="}"&&--g===0){l=x+1;break}if(l===-1)continue}else{let u=0;l=n.length;for(let g=n.indexOf("=",a.index)+1;g<n.length;g++){let x=n[g];if(x==="{"||x==="["||x==="("||x==="<")u++;else if(x==="}"||x==="]"||x===")"||x===">")u--;else if(u<=0&&(x===";"||x===`
|
|
84
84
|
`&&!/[=|&,<([{]\s*$/.test(n.slice(Math.max(0,g-40),g)))){l=x===";"?g+1:g;break}}}s.push({name:o,text:e.slice(a.index,l).replace(/^[ \t]*export[ \t]+/,"")}),i.lastIndex=l}return s}function hr(e){let n=j(e),r=[],t=/^[ \t]*(?:export[ \t]+)?(?:const|let|var)[ \t]+/gm,s,i=0,a=0;while((s=t.exec(n))!==null){for(;a<s.index;a++){let l=n[a];if(l==="{"||l==="("||l==="[")i++;else if(l==="}"||l===")"||l==="]")i=Math.max(0,i-1)}if(i!==0)continue;let c=0,o=n.length;for(let l=s.index+s[0].length;l<n.length;l++){let u=n[l];if(u==="{"||u==="("||u==="[")c++;else if(u==="}"||u===")"||u==="]")c--;else if(c<=0&&(u===";"||u===`
|
|
85
85
|
`)){o=u===";"?l+1:l;break}}if(/\bdefineProps\s*(?:<|\()/.test(n.slice(s.index,o)))r.push(e.slice(s.index,o).replace(/^[ \t]*export[ \t]+/,"").trim())}return r}function xr(e){let n=e.filter((s)=>s.kind==="server").map((s)=>s.code).join(`
|
|
86
86
|
`);if(/\bdefineProps\s*(?:<|\()/.test(j(n)))return n;let r=br(n),t=e.filter((s)=>s.kind!=="server").flatMap((s)=>{let i=hr(s.code);if(!i.length)return[];return[...he(s.code).filter((a)=>!r.has(a.name)).map((a)=>a.text),...i]});return[n,...t].filter(Boolean).join(`
|
|
87
|
-
`)}function br(e){return new Set(he(e).map((n)=>n.name))}var zt=["$env","$user","$slot","$slots","$attrs","$props","$page","$route","$loop","loop","$errors","$csrf","$native","props","slot"];function Ut(e){let n=new Set,r=new Set;for(let t of e){let s=t.kind==="server"?n:r;for(let i of ce(t.code))s.add(i)}return[...n].filter((t)=>r.has(t)).sort()}var yr=/^\s*[A-Z_$][\w$]*\s*=[^=]/i;function Sr(e){let n=new Map,r=/!|===|!==|==|!=|&&|\|\||<|>|\btypeof\b|\binstanceof\b|\bin\b/;for(let t of e){let s=j(t),{depths:i,balanced:a}=U(s);if(!a)continue;let c=/^([ \t]*(?:export[ \t]+)?const[ \t]+)([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=[ \t]*([^\n]+)$/gm;for(let o of s.matchAll(c)){let l=o.index??0;if(i[l+o[1].length]!==0)continue;let u=o[2],g=l+o[0].length-o[3].length,x=t.slice(g,l+o[0].length).trim().replace(/;$/,"").trim(),_=o[3],
|
|
88
|
-
`))continue;let
|
|
89
|
-
`),o=Array.from({length:c.length},()=>""),l=new Map,u=new Map,g=new Map,x=[],_=xr(r),
|
|
90
|
-
`)}):void 0,C=new Set,d=[];for(let[p,m]of t.entries()){let E=cr(_r(m)+m.code,_,String(p));for(let[I,P]of E.columns)u.set(m.startLine+I-1,P);for(let I of E.declarations)x.push({text:Ie(I.text,n.originDir??""),origin:I.origin?{...I.origin,line:I.origin.line+m.startLine-1}:void 0});let
|
|
91
|
-
`);M.forEach((I,P)=>{let B=m.startLine-1+P;if(B<o.length)o[B]=I,C.add(B)}),d.push(m.startLine-1+M.length-1)}for(let p of d){let m=o[p]?.trim()===""?p:p+1;if(m<o.length&&o[m].trim()===""&&(m===p||!C.has(m)))o[m]=";"}let f=(p,m)=>{for(let[E,
|
|
92
|
-
`).entries())if(o.push(
|
|
93
|
-
`));if(w)f(w);for(let p of t.filter((m)=>m.kind==="server")){let m=Pe(p.code);if(!m?.unsupported)continue;let E=p.code.slice(0,m.offset),
|
|
87
|
+
`)}function br(e){return new Set(he(e).map((n)=>n.name))}var zt=["$env","$user","$slot","$slots","$attrs","$props","$page","$route","$loop","loop","$errors","$csrf","$native","props","slot"];function Ut(e){let n=new Set,r=new Set;for(let t of e){let s=t.kind==="server"?n:r;for(let i of ce(t.code))s.add(i)}return[...n].filter((t)=>r.has(t)).sort()}var yr=/^\s*[A-Z_$][\w$]*\s*=[^=]/i;function Sr(e){let n=new Map,r=/!|===|!==|==|!=|&&|\|\||<|>|\btypeof\b|\binstanceof\b|\bin\b/;for(let t of e){let s=j(t),{depths:i,balanced:a}=U(s);if(!a)continue;let c=/^([ \t]*(?:export[ \t]+)?const[ \t]+)([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=[ \t]*([^\n]+)$/gm;for(let o of s.matchAll(c)){let l=o.index??0;if(i[l+o[1].length]!==0)continue;let u=o[2],g=l+o[0].length-o[3].length,x=t.slice(g,l+o[0].length).trim().replace(/;$/,"").trim(),_=o[3],A=r.test(_)&&!/\bawait\b|=>|\bfunction\b|[{}]/.test(_)&&!/[,+\-*/%&|?:=]$/.test(x)&&U(_).balanced;n.set(u,n.has(u)||!A?null:x)}}return new Map([...n].filter((t)=>t[1]!==null))}function Gt(e,n,r=0,t=new Set){if(n.size===0||r>=5)return e;let s=j(e),i="",a=0;for(let c of s.matchAll(/[A-Za-z_$][\w$]*/g)){let o=c.index??0,l=c[0],u=n.get(l);if(!u||t.has(l))continue;let g=s.slice(0,o).trimEnd(),x=s.slice(o+l.length).trimStart();if(g.endsWith(".")||/^:(?!:)/.test(x)&&/[{,]$/.test(g))continue;if(o>0&&/[\w$]/.test(s[o-1]))continue;i+=`${e.slice(a,o)}(${Gt(u,n,r+1,new Set([...t,l]))})`,a=o+l.length}return i+e.slice(a)}function vr(e,n){let r=/@(if|unless|elseif|else|endif|endunless)\b\s*(\()?/g,t=[],s;while((s=r.exec(e))!==null){if(s.index>n)break;let i=s[1];if(s.index===n){if(i==="elseif"){let c=t[t.length-1];if(c?.current)c.seen.push(c.current);if(c)c.current=null}break}if(i==="endif"||i==="endunless"){t.pop();continue}let a="";if(s[2]==="("){let c=0,o=s.index+s[0].length-1,l=o+1;for(;o<e.length;o++){let u=e[o];if(u==="(")c++;else if(u===")"){if(c--,c===0)break}}a=e.slice(l,o).trim(),r.lastIndex=o+1}if(i==="if")t.push({seen:[],current:a});else if(i==="unless")t.push({seen:[],current:`!(${a})`});else if(i==="elseif"||i==="else"){let c=t[t.length-1];if(!c)continue;if(c.current)c.seen.push(c.current);c.current=i==="elseif"?a:null}}return t.flatMap((i)=>[...i.seen.map((a)=>`!(${a})`),...i.current?[i.current]:[]]).filter(Boolean)}function Er(e){let n=e.code.trim();if(!n)return null;if(e.attribute?.startsWith("@")){if(yr.test(n))return null;let t=";(($event: any): void => { ";return{text:`${t}${n} });`,prefixLength:t.length}}let r=";void ((";return{text:`${r}${n}));`,prefixLength:r.length}}var wr=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.{1,2}\/[^'"\n]*)\2/g;function Ie(e,n){return Jt(e,n).code}function Jt(e,n){let r=new Map;if(!n)return{code:e,columns:r};let t=xe(e),s=[],i=0;for(let a of e.matchAll(wr)){let c=a.index,[o,l,u,g]=a,x=et.default.resolve(n,g).replace(/\\/g,"/"),_=`${l}${u}${x}${u}`;if(s.push(e.slice(i,c),_),i=c+o.length,o.includes(`
|
|
88
|
+
`))continue;let A=Y(t,c),C=r.get(A.line)??[],d=C.at(-1),f=A.column+(d?d.generatedEnd-d.sourceEnd:0);C.push({sourceStart:A.column,sourceEnd:A.column+o.length,generatedStart:f,generatedEnd:f+_.length}),r.set(A.line,C)}return s.push(e.slice(i)),{code:s.join(""),columns:r}}function $r(e,n,r){let t=Ze(e.importColumns?.get(n)??[],r);return Ze(e.scriptColumns?.get(n)??[],Ze(e.componentColumns?.get(n)??[],t))}function qt(e,n,r){let t=Ye(e.scriptColumns?.get(n)??[],r);return Ye(e.importColumns?.get(n)??[],Ye(e.componentColumns?.get(n)??[],t))}function _r(e){return" ".repeat(Math.max(0,(e.startColumn??1)-1))}function Ne(e){let n=new Set,r=j(e);for(let t of r.matchAll(/\bimport\s+(?:type\s+)?([\w$*{}\s,]+?)\s+from\b/g)){let s=t[1],i=/\{([^}]*)\}/.exec(s);for(let l of i?.[1].split(",")??[]){let u=l.trim().replace(/^type\s+/,"").split(/\s+as\s+/).pop()?.trim();if(u&&/^[A-Z_$][\w$]*$/i.test(u))n.add(u)}let a=s.replace(/\{[^}]*\}/,""),c=/\*\s*as\s+([A-Z_$][\w$]*)/i.exec(a);if(c)n.add(c[1]);let o=/^\s*([A-Z_$][\w$]*)/i.exec(a);if(o&&o[1]!=="type")n.add(o[1])}return[...n].sort()}function Xt(e,n={}){let r=me(e),t=n.scriptKinds?r.filter((p)=>n.scriptKinds.includes(p.kind)):r,s=It(e,n.componentMethodValidator),i=n.filePath&&n.templateExpressions!==!1?Mt(e,{filePath:n.filePath,partialsDir:n.partialsDir,layoutsDir:n.layoutsDir,contractsKnown:n.inheritedContractsKnown,readTemplate:n.readComponent}):void 0,a=new Map,c=e.split(`
|
|
89
|
+
`),o=Array.from({length:c.length},()=>""),l=new Map,u=new Map,g=new Map,x=[],_=xr(r),A=n.filePath&&n.templateExpressions!==!1?$t(e,ge(e),{filePath:n.filePath,componentsDir:n.componentsDir,projectRoot:n.projectRoot,readComponent:n.readComponent,scriptCode:(p,m)=>me(p).map((E)=>Ie(E.code,et.default.dirname(m))).join(`
|
|
90
|
+
`)}):void 0,C=new Set,d=[];for(let[p,m]of t.entries()){let E=cr(_r(m)+m.code,_,String(p));for(let[I,P]of E.columns)u.set(m.startLine+I-1,P);for(let I of E.declarations)x.push({text:Ie(I.text,n.originDir??""),origin:I.origin?{...I.origin,line:I.origin.line+m.startLine-1}:void 0});let R=m.kind==="client"&&s?s.project(E.code):void 0;for(let[I,P]of R?.columns??[])a.set(m.startLine+I-1,P);let v=Me(R?.code??E.code),O=Jt(v,n.originDir??"");for(let[I,P]of O.columns)g.set(m.startLine+I-1,P);let M=O.code.split(`
|
|
91
|
+
`);M.forEach((I,P)=>{let B=m.startLine-1+P;if(B<o.length)o[B]=I,C.add(B)}),d.push(m.startLine-1+M.length-1)}for(let p of d){let m=o[p]?.trim()===""?p:p+1;if(m<o.length&&o[m].trim()===""&&(m===p||!C.has(m)))o[m]=";"}let f=(p,m)=>{for(let[E,R]of p.split(`
|
|
92
|
+
`).entries())if(o.push(R),m)l.set(o.length,E===0?m:{...m,line:m.line+E,column:1,prefixLength:0})},w=Pt(t.filter((p)=>p.kind==="server").map((p)=>p.code).join(`
|
|
93
|
+
`));if(w)f(w);for(let p of t.filter((m)=>m.kind==="server")){let m=Pe(p.code);if(!m?.unsupported)continue;let E=p.code.slice(0,m.offset),R=p.startLine+E.split(`
|
|
94
94
|
`).length-1,v=m.offset-p.code.lastIndexOf(`
|
|
95
|
-
`,m.offset-1)+(
|
|
96
|
-
`))f(m);let p=pr(e).map((m)=>{let E=
|
|
97
|
-
`),lineMap:l,sourceLineCount:c.length,componentDependencies:new Map([...
|
|
95
|
+
`,m.offset-1)+(R===p.startLine?(p.startColumn??1)-1:0);f(`;({})[${JSON.stringify(m.unsupported)}];`,{line:R,column:v,anchor:!0})}if(i?.declarations)f(i.declarations);for(let p of x)f(p.text,p.origin);if(s){if(f(s.declarations),n.nativeChecks!==!1)for(let p of s.checks)f(p.text,{line:p.line,column:p.column,diagnosticOrigin:p.origin,anchor:!0})}if(n.globals!==!1){f("");let p=new Set([...t.flatMap((v)=>ce(v.code)),...t.flatMap((v)=>Ne(v.code))]),m=(v)=>{if(!p.has(v)&&!n.declaredGlobals?.includes(v))f(`declare var ${v}: any`)};if(n.runtimeGlobals!==!1){if(!p.has("window"))f("declare var window: any");for(let v of de)m(v)}let E=[...new Set([...Bt,...Fe,...zt])].filter((v)=>!n.declaredGlobals?.includes(v)&&(n.runtimeGlobals!==!1||!de.includes(v)));if(n.contextScope==="global"){f("declare global {");for(let v of E)f(` var ${v}: any`);f("}")}else{for(let v of Bt)m(v);for(let v of Fe)m(v);for(let v of zt)m(v)}f(`declare var ${Qe}: any`);let R=new Set(t.flatMap((v)=>ce(v.code)));f(`type ${Lt}<T> = T extends readonly (infer E)[] ? E : T extends Iterable<infer E2> ? E2 : any`);for(let v of s?[]:mr(e)){if(R.has(v.name))continue;let O=v.iterable&&R.has(v.iterable)?`${Lt}<typeof ${v.iterable}>`:"any";f(`declare var ${v.name}: ${O}`)}}if(n.templateExpressions!==!1){if(A?.declarations)for(let m of A.declarations.split(`
|
|
96
|
+
`))f(m);let p=pr(e).map((m)=>{let E=A?.events.get(m.offset??-1);if(E){m.anchor=!0;let R=m.code.trim(),v=/^([\w$]+)\s*=\s*([^=][\s\S]*)$/.exec(R),O=v?`void ((${v[2]}) satisfies __StxAssignedValue<typeof ${v[1]}>)`:/^[\w$]+(?:\.[\w$]+)*$/.test(R)?`${R} satisfies (($event: ${E}) => unknown)`:R,M=`;(($event: ${E}): void => { `;return{expression:m,statement:{text:`${M}${O} });`,prefixLength:M.length}}}return{expression:m,statement:Er(m)}}).filter((m)=>m.statement!==null);if(p.push(...A?.checks||[],...i?.checks||[]),p.length>0){let m=ge(e),E=Dt(m),R=s?Nt(m):[];if(s)f("type __StxNativeValue<T> = T extends readonly (infer E)[] ? E : T extends object ? T[keyof T] : never; declare function __stxEach<T>(items: T, callback: (item: __StxNativeValue<T>, key: string) => void): void;");let v=Sr(t.map((P)=>P.code)),M=[...new Set(t.flatMap((P)=>ce(P.code)))].filter((P)=>/^[A-Z_$][\w$]*$/i.test(P)),I=0;if(s)f("function __stxNativeTemplate(this: __StxNativeComponent) {");if(M.length>0){f(or);for(let P of M)f(`function __StxRead_${P}() { return ${P} }`),f(`type __StxT_${P} = ${Ht}<ReturnType<typeof __StxRead_${P}>>`);f(`;((${M.map((P)=>`${P}: __StxT_${P}`).join(", ")}) => {`),I=1}for(let{expression:P,statement:B}of p){let K=" ".repeat(I),q=P.offset===void 0?[]:E.filter((F)=>P.offset>=F.start&&P.offset<F.end),G=P.offset===void 0?[]:R.filter((F)=>P.offset>=F.start&&P.offset<F.end),te=G.map((F)=>`;__stxEach(${F.iterable}, (${F.binding}) => { `).join(""),se=" });".repeat(G.length),X=te+q.map((F)=>`;((${F.binding.replace(/[\r\n]/g," ")}: any) => { `).join(""),le=" });".repeat(q.length)+se,L=P.offset===void 0?[]:vr(m,P.offset),W=L.length>0?`${L.map((F)=>`if (${Gt(F,v)}) `).join("")}{ `:"",Q=L.length>0?" }":"";f(K+X+W+B.text+Q+le,{line:P.line,column:P.column,expression:P,prefixLength:B.prefixLength+K.length+X.length+W.length,guardPrefixLength:K.length+X.length+W.length})}if(I>0)f("});");if(s)f("}")}}let b=!1;if(n.reference&&o[0]!==void 0&&o[0].trim()==="")o[0]=`/// <reference path=${JSON.stringify(n.reference.replace(/\\/g,"/"))} />`,b=!0;return f("export {}"),{text:o.join(`
|
|
97
|
+
`),lineMap:l,sourceLineCount:c.length,componentDependencies:new Map([...A?.dependencies??[],...i?.dependencies??[]]),referenced:b,scriptColumns:u,importColumns:g,componentColumns:a}}function xe(e){let n=[0];for(let r=0;r<e.length;r++)if(e.charCodeAt(r)===10)n.push(r+1);return n}function Y(e,n){let r=0,t=e.length-1;while(r<t){let s=Math.ceil((r+t)/2);if(e[s]<=n)r=s;else t=s-1}return{line:r+1,column:n-e[r]+1}}function Le(e,n,r){let t=Math.min(Math.max(n,1),e.length)-1,s=t+1<e.length?e[t+1]-1:Number.MAX_SAFE_INTEGER;return Math.min(e[t]+Math.max(r,1)-1,s)}function Zt(e,n){if(!e.expression)return!1;return e.inGuard===!0||n===2774}function Yt(e,n,r){let t=e.lineMap.get(n);if(!t)return n<=e.sourceLineCount?{line:n,column:$r(e,n,r)}:null;let s=t.anchor||t.expression?.anchor||t.diagnosticOrigin==="component"?0:Math.max(0,r-1-(t.prefixLength??0));return{line:t.line,column:t.column+s,expression:t.expression,diagnosticOrigin:t.diagnosticOrigin,inGuard:r<=(t.guardPrefixLength??0)}}var kr=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),en=Re.filter((e)=>!kr.has(e)).sort(),tn=[...de].sort(),Cr=[...new Set([...en,...tn])].sort(),Tr=new Set(en),Ar=new Set(tn),Rr=new Set(Cr),Qt=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Or(e,n){if(n==="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 nn(e,n){let r=[];for(let t of n){if(t.offset===void 0)continue;let s=t.kind==="server"?Tr:Ar;Qt.lastIndex=0;for(let i of t.code.matchAll(Qt)){let a=i.index+i[0].indexOf("{")+1;for(let c of i[1].matchAll(/[^,]+/g)){let o=c[0];if(/^\s*type\s/.test(o))continue;let l=/^\s*([A-Za-z_$][\w$]*)/.exec(o);if(!l)continue;let u=l[1];if(!Rr.has(u)||s.has(u))continue;let g=t.offset+a+c.index+l[0].length-u.length,x=e.slice(0,g),_=x.split(`
|
|
98
98
|
`).length;r.push({line:_,column:g-(x.lastIndexOf(`
|
|
99
99
|
`)+1)+1,offset:g,length:u.length,name:u,kind:t.kind,message:Or(u,t.kind)})}}}return r}var re=ee(require("node:path"),1),Pr="@stacksjs/stx-typescript-plugin";function Mr(e,n){let r=re.default.resolve(e);for(;;){let t=re.default.join(r,"tsconfig.json");if(n(t))return t;let s=re.default.dirname(r);if(s===r)return;r=s}}function rn(e,n,r){let t=Mr(e,r);if(!t)return;let s=new Set,i=(a)=>{if(s.has(a))return;s.add(a);let c=n(a);if(!c)return;let o=c.compilerOptions?.plugins;if(Array.isArray(o)){let u=o.find((x)=>x?.name===Pr),g=Array.isArray(u?.libs)?u.libs.filter((x)=>typeof x==="string"):[];return u?{configPath:a,libs:g.map((x)=>re.default.resolve(re.default.dirname(a),x))}:null}let l=typeof c.extends==="string"?[c.extends]:Array.isArray(c.extends)?c.extends:[];for(let u of[...l].reverse()){if(typeof u!=="string"||!u.startsWith("."))continue;let g=re.default.resolve(re.default.dirname(a),u.endsWith(".json")?u:`${u}.json`),x=i(g);if(x!==void 0)return x}return};return i(t)??void 0}var sn=Symbol.for("@stacksjs/stx-typescript-plugin"),Ir=new Set([2300,2451,2403]);function we(e){return e.endsWith(".stx")}function on(e){return we(e)||e.endsWith(".md")}function Nr(e){if(!e)return;return Z.existsSync(H.default.join(e,"stx-module.d.ts"))&&Z.existsSync(H.default.join(e,"stx.d.ts"))?H.default.join(e,"stx-module.d.ts"):void 0}function Dr(e,n=Z.existsSync){let r=e;for(;;){let t=H.default.join(r,"node_modules","@stacksjs","stx","stx-module.d.ts");if(n(t))return t;let s=H.default.dirname(r);if(s===r)return;r=s}}function Lr(e,n=H.default.join(cn.tmpdir(),"stx-typescript-plugin")){let r=e.map((s)=>`/// <reference path=${JSON.stringify(s.replace(/\\/g,"/"))} />`).join(`
|
|
100
100
|
`)+`
|
|
101
|
-
`,t=H.default.join(n,`${an.createHash("sha1").update(r).digest("hex").slice(0,16)}.d.ts`);if(!Z.existsSync(t))Z.mkdirSync(n,{recursive:!0}),Z.writeFileSync(t,r);return t}function jr(e){let n=new Set,r=new Set;function t(s){if(r.has(s)||!Z.existsSync(s))return;r.add(s);let i=Z.readFileSync(s,"utf8");for(let a of Kt(i))n.add(a);for(let a of i.matchAll(/<reference\s+path=["']([^"']+)["']/g))t(H.default.resolve(H.default.dirname(s),a[1]))}if(e)t(e);return[...n]}function Fr(e,n,r,t){let s=(c)=>Xt(n,{templateExpressions:we(e),componentMethodValidator:(o,l,u)=>{let g=t.typescript.transpileModule(o+(l==="{"?"{}":";"),{reportDiagnostics:!0,compilerOptions:{target:t.typescript.ScriptTarget.ESNext}});if(g.diagnostics?.some((x)=>x.category===t.typescript.DiagnosticCategory.Error))return!1;return l==="{"?g.outputText.includes(`function ${u}(`):!g.outputText.trim()},originDir:H.default.dirname(e),filePath:e,readComponent:t.readComponent,componentsDir:t.componentsDir,projectRoot:t.projectRoot,reference:c,declaredGlobals:jr(c),runtimeGlobals:!c,contextScope:"global"}),i=s(t.declarations);if(t.declarations&&!i.referenced)i=s(void 0);let a=me(n);return{version:r,source:n,virtual:i,blocks:a,sourceStarts:xe(n),virtualStarts:xe(i.text),collisions:new Set(Ut(a))}}function Br(e,n){let r=e.findConfigFile(n,e.sys.fileExists);if(!r)return;let t=e.readConfigFile(r,e.sys.readFile);if(t.error)return;let s=e.parseJsonConfigFileContent(t.config,e.sys,H.default.dirname(r),void 0,r),i={};if(s.options.types)i.types=s.options.types;let a=s.options.paths;if(a){let c=s.options.baseUrl??s.options.pathsBasePath??H.default.dirname(r);i.paths={};for(let[o,l]of Object.entries(a))i.paths[o]=l.map((u)=>H.default.isAbsolute(u)?u:H.default.resolve(c,u))}return i}function zr(e,n={}){let r=e.typescript,t={},s=new Set,i=new WeakSet;return{create(a){let c=(h)=>{a.project.projectService.logger.info(`[stx-plugin] ${h}`)};if(a.languageService[sn])return i.add(a.project),c("already applied to this project by another registration of the plugin; leaving it as it is"),a.languageService;c("TypeScript stx plugin initialized");let{languageService:o,languageServiceHost:l}=a,u=(h)=>{let S=o[h];return typeof S==="function"?S.bind(o):()=>{return}},g=l.getScriptSnapshot?.bind(l),x=l.getScriptVersion?.bind(l),_=Nr(n.declarationsDir);if(!_)c("the bundled stx declarations were not found; apps without their own fall back to `any`");let R=(h)=>r.sys?.fileExists(h)??Z.existsSync(h),C=(h)=>{let S=r.readConfigFile?.(h,(y)=>r.sys.readFile(y));return S&&!S.error?S.config:void 0},d=new Map,f=(h)=>{let S=H.default.dirname(h);if(!d.has(S)){let y=Dr(S,R)??_,T=[];try{T=(rn(S,C,R)?.libs??[]).filter(R)}catch(k){c(`could not read the stx entry of the project's tsconfig: ${String(k)}`)}d.set(S,y&&T.length>0?Lr([y,...T]):y)}return d.get(S)},w=new Map,b=(h)=>{let S=g?.(h);return S?S.getText(0,S.getLength()):r.sys?.readFile(h)},p=()=>t.enabled!==!1;s.add(()=>{w.clear(),a.project.refreshDiagnostics?.()});let m=(h)=>{if(!on(h)||!g)return;let S=`${x?.(h)||"0"}:${l.getProjectVersion?.()||""}`,y=w.get(h);if(y&&y.version===S&&[...y.virtual.componentDependencies||[]].every(([k,N])=>b(k)===N))return y;let T=g(h);if(!T)return;try{let k=a.project.getCurrentDirectory?.(),N=k?H.default.resolve(k,typeof a.config?.componentsDir==="string"?a.config.componentsDir:"components"):void 0,z=Fr(h,T.getText(0,T.getLength()),S,{typescript:r,declarations:f(h),readComponent:b,componentsDir:N,projectRoot:k});return w.set(h,z),z}catch(k){c(`failed to build virtual document for ${h}: ${String(k)}`);return}},E=(h)=>we(h)?m(h):void 0,A=(h,S)=>{let y=Y(h.virtualStarts,S);return Yt(h.virtual,y.line,y.column)},v=(h,S)=>{let y=A(h,S);if(!y)return;return Le(h.sourceStarts,y.line,y.column)},O=(h,S)=>{let y=Y(h.sourceStarts,S);return Le(h.virtualStarts,y.line,qt(h.virtual,y.line,y.column))},M=(h,S)=>{let y=v(h,S.start);if(y===void 0)return;let T=v(h,S.start+S.length);return{start:y,length:T!==void 0&&T>=y?T-y:S.length}},I=(h,S)=>h.blocks.some((y)=>y.offset!==void 0&&S>=y.offset&&S<=y.offset+y.code.length),P=(h)=>{let S=E(h.fileName);if(!S)return h;let y=M(S,h.textSpan);if(!y)return;let T=h.contextSpan?M(S,h.contextSpan):void 0;return{...h,textSpan:y,contextSpan:T}},B=(h)=>h?.map(P).filter((S)=>S!==void 0),K=(h)=>h?.filter((S)=>{let y=E(S.fileName);if(!y)return!0;let{line:T}=Y(y.virtualStarts,S.textSpan.start);return T<=y.virtual.sourceLineCount&&!y.virtual.lineMap.has(T)});if(g)l.getScriptSnapshot=(h)=>{let S=m(h);if(S)return r.ScriptSnapshot.fromString(S.virtual.text);return g(h)};let q=l.getCompilationSettings?.bind(l),G=r.server?.ProjectKind!==void 0&&a.project.projectKind===r.server.ProjectKind.Inferred;if(q&&G){let h=null,S;l.getCompilationSettings=()=>{let y=q();if(h===null)try{h=Br(r,a.project.getCurrentDirectory())}catch(T){c(`could not read the project's tsconfig: ${String(T)}`),h=void 0}if(!h)return y;if(S?.from!==y)S={from:y,options:{...y,...h.paths&&!y.paths?{paths:h.paths}:{},...h.types&&!y.types?{types:h.types}:{}}};return S.options}}let te=(h,S)=>{let y=m(h);if(!y)return S;if(we(h)&&!p())return[];let T=[];for(let k of S){let N=typeof k.messageText==="string"?k.messageText:k.messageText.messageText;if(Ir.has(k.code)){let ne=N.match(/'([^']+)'/)?.[1];if(ne&&y.collisions.has(ne))continue}if(k.start===void 0){T.push(k);continue}let z=A(y,k.start);if(!z||Zt(z,k.code))continue;let V=Le(y.sourceStarts,z.line,z.column),ye=v(y,k.start+(k.length??0));T.push({...k,start:V,length:ye!==void 0&&ye>V?ye-V:k.length??0})}return T},se=u("getSemanticDiagnostics");o.getSemanticDiagnostics=(h)=>{let S=te(h,se(h)),y=E(h);if(!y||!p())return S;let T=o.getProgram?.()?.getSourceFile(h);for(let k of nn(y.source,y.blocks))S.push({file:T,start:k.offset,length:k.length,messageText:k.message,category:r.DiagnosticCategory?.Error??1,code:0,source:"stx"});return S};let X=u("getSyntacticDiagnostics");o.getSyntacticDiagnostics=(h)=>te(h,X(h));let le=u("getSuggestionDiagnostics");o.getSuggestionDiagnostics=(h)=>te(h,le(h));let L=u("getQuickInfoAtPosition");o.getQuickInfoAtPosition=(h,S,...y)=>{let T=E(h);if(!T)return L(h,S,...y);if(!p())return;let k=L(h,O(T,S),...y);if(!k)return k;let N=M(T,k.textSpan);return N?{...k,textSpan:N}:void 0};let W=u("getCompletionsAtPosition");o.getCompletionsAtPosition=(h,S,y,...T)=>{let k=E(h);if(!k)return W(h,S,y,...T);if(!p()||!I(k,S))return;let N=W(h,O(k,S),{...y,includeCompletionsForModuleExports:!1},...T);if(!N)return N;let z=(V)=>V&&M(k,V);return{...N,optionalReplacementSpan:z(N.optionalReplacementSpan),entries:N.entries.filter((V)=>!V.name.startsWith("__stx")&&!V.name.startsWith("__Stx")).map((V)=>V.replacementSpan?{...V,replacementSpan:z(V.replacementSpan)}:V)}};let Q=u("getCompletionEntryDetails");o.getCompletionEntryDetails=(h,S,...y)=>{let T=E(h);if(!T)return Q(h,S,...y);let k=Q(h,O(T,S),...y);return k?{...k,codeActions:void 0}:k};let F=u("getSignatureHelpItems");o.getSignatureHelpItems=(h,S,...y)=>{let T=E(h);if(!T)return F(h,S,...y);if(!p()||!I(T,S))return;let k=F(h,O(T,S),...y),N=k&&M(T,k.applicableSpan);return k&&N?{...k,applicableSpan:N}:void 0};let $e=u("getDefinitionAndBoundSpan");o.getDefinitionAndBoundSpan=(h,S)=>{let y=E(h);if(!y)return be($e(h,S));if(!p())return;let T=$e(h,O(y,S)),k=T&&M(y,T.textSpan);return T&&k?{...be(T),textSpan:k}:void 0};let be=(h)=>h&&{...h,definitions:K(h.definitions)};for(let h of["getDefinitionAtPosition","getTypeDefinitionAtPosition","getImplementationAtPosition"]){let S=u(h);o[h]=(y,T,...k)=>{let N=E(y);if(N&&!p())return;return K(S(y,N?O(N,T):T,...k))}}for(let h of["getReferencesAtPosition"]){let S=u(h);o[h]=(y,T,...k)=>{let N=E(y);if(N&&!p())return;return B(S(y,N?O(N,T):T,...k))}}let un=u("findReferences");o.findReferences=(h,S)=>{let y=E(h);if(y&&!p())return;return un(h,y?O(y,S):S)?.map((T)=>{let k=P(T.definition);return k?{definition:k,references:B(T.references)}:void 0}).filter((T)=>T!==void 0)};let pn=u("getDocumentHighlights");o.getDocumentHighlights=(h,S,y)=>{let T=E(h);if(T&&(!p()||!I(T,S)))return;return pn(h,T?O(T,S):S,y)?.map((k)=>{let N=E(k.fileName);if(!N)return k;return{...k,highlightSpans:k.highlightSpans.map((z)=>{let V=M(N,z.textSpan);return V?{...z,textSpan:V,contextSpan:z.contextSpan&&M(N,z.contextSpan)}:void 0}).filter((z)=>z!==void 0)}})};let dn=u("getNavigationTree");o.getNavigationTree=(h)=>{let S=dn(h),y=E(h);if(!y)return S;let T=(N)=>{let z=N.spans.map((ne)=>M(y,ne)).filter((ne)=>ne!==void 0);if(z.length===0)return;let V=N.nameSpan&&M(y,N.nameSpan),ye=N.childItems?.map(T).filter((ne)=>ne!==void 0);return{...N,spans:z,nameSpan:V,childItems:ye}},k={...S,spans:[{start:0,length:y.source.length}]};return p()?{...k,childItems:S.childItems?.map(T).filter((N)=>N!==void 0)}:{...k,childItems:[]}};let fn={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[h,S]of Object.entries(fn)){let y=o[h];if(typeof y!=="function")continue;let T=y.bind(o);o[h]=(k,...N)=>typeof k==="string"&&we(k)?S():T(k,...N)}return o[sn]=!0,c("Language service proxy created"),o},getExternalFiles(a){if(i.has(a))return[];return a.getFileNames().filter(on)},onConfigurationChanged(a){t={...t,...a};for(let c of s)c()}}}var ln=zr;module.exports=ln;
|
|
101
|
+
`,t=H.default.join(n,`${an.createHash("sha1").update(r).digest("hex").slice(0,16)}.d.ts`);if(!Z.existsSync(t))Z.mkdirSync(n,{recursive:!0}),Z.writeFileSync(t,r);return t}function jr(e){let n=new Set,r=new Set;function t(s){if(r.has(s)||!Z.existsSync(s))return;r.add(s);let i=Z.readFileSync(s,"utf8");for(let a of Kt(i))n.add(a);for(let a of i.matchAll(/<reference\s+path=["']([^"']+)["']/g))t(H.default.resolve(H.default.dirname(s),a[1]))}if(e)t(e);return[...n]}function Fr(e,n,r,t){let s=(c)=>Xt(n,{templateExpressions:we(e),componentMethodValidator:(o,l,u)=>{let g=t.typescript.transpileModule(o+(l==="{"?"{}":";"),{reportDiagnostics:!0,compilerOptions:{target:t.typescript.ScriptTarget.ESNext}});if(g.diagnostics?.some((x)=>x.category===t.typescript.DiagnosticCategory.Error))return!1;return l==="{"?g.outputText.includes(`function ${u}(`):!g.outputText.trim()},originDir:H.default.dirname(e),filePath:e,readComponent:t.readComponent,componentsDir:t.componentsDir,projectRoot:t.projectRoot,reference:c,declaredGlobals:jr(c),runtimeGlobals:!c,contextScope:"global"}),i=s(t.declarations);if(t.declarations&&!i.referenced)i=s(void 0);let a=me(n);return{version:r,source:n,virtual:i,blocks:a,sourceStarts:xe(n),virtualStarts:xe(i.text),collisions:new Set(Ut(a))}}function Br(e,n){let r=e.findConfigFile(n,e.sys.fileExists);if(!r)return;let t=e.readConfigFile(r,e.sys.readFile);if(t.error)return;let s=e.parseJsonConfigFileContent(t.config,e.sys,H.default.dirname(r),void 0,r),i={};if(s.options.types)i.types=s.options.types;let a=s.options.paths;if(a){let c=s.options.baseUrl??s.options.pathsBasePath??H.default.dirname(r);i.paths={};for(let[o,l]of Object.entries(a))i.paths[o]=l.map((u)=>H.default.isAbsolute(u)?u:H.default.resolve(c,u))}return i}function zr(e,n={}){let r=e.typescript,t={},s=new Set,i=new WeakSet;return{create(a){let c=(h)=>{a.project.projectService.logger.info(`[stx-plugin] ${h}`)};if(a.languageService[sn])return i.add(a.project),c("already applied to this project by another registration of the plugin; leaving it as it is"),a.languageService;c("TypeScript stx plugin initialized");let{languageService:o,languageServiceHost:l}=a,u=(h)=>{let S=o[h];return typeof S==="function"?S.bind(o):()=>{return}},g=l.getScriptSnapshot?.bind(l),x=l.getScriptVersion?.bind(l),_=Nr(n.declarationsDir);if(!_)c("the bundled stx declarations were not found; apps without their own fall back to `any`");let A=(h)=>r.sys?.fileExists(h)??Z.existsSync(h),C=(h)=>{let S=r.readConfigFile?.(h,(y)=>r.sys.readFile(y));return S&&!S.error?S.config:void 0},d=new Map,f=(h)=>{let S=H.default.dirname(h);if(!d.has(S)){let y=Dr(S,A)??_,T=[];try{T=(rn(S,C,A)?.libs??[]).filter(A)}catch(k){c(`could not read the stx entry of the project's tsconfig: ${String(k)}`)}d.set(S,y&&T.length>0?Lr([y,...T]):y)}return d.get(S)},w=new Map,b=(h)=>{let S=g?.(h);return S?S.getText(0,S.getLength()):r.sys?.readFile(h)},p=()=>t.enabled!==!1;s.add(()=>{w.clear(),a.project.refreshDiagnostics?.()});let m=(h)=>{if(!on(h)||!g)return;let S=`${x?.(h)||"0"}:${l.getProjectVersion?.()||""}`,y=w.get(h);if(y&&y.version===S&&[...y.virtual.componentDependencies||[]].every(([k,N])=>b(k)===N))return y;let T=g(h);if(!T)return;try{let k=a.project.getCurrentDirectory?.(),N=k?H.default.resolve(k,typeof a.config?.componentsDir==="string"?a.config.componentsDir:"components"):void 0,z=Fr(h,T.getText(0,T.getLength()),S,{typescript:r,declarations:f(h),readComponent:b,componentsDir:N,projectRoot:k});return w.set(h,z),z}catch(k){c(`failed to build virtual document for ${h}: ${String(k)}`);return}},E=(h)=>we(h)?m(h):void 0,R=(h,S)=>{let y=Y(h.virtualStarts,S);return Yt(h.virtual,y.line,y.column)},v=(h,S)=>{let y=R(h,S);if(!y)return;return Le(h.sourceStarts,y.line,y.column)},O=(h,S)=>{let y=Y(h.sourceStarts,S);return Le(h.virtualStarts,y.line,qt(h.virtual,y.line,y.column))},M=(h,S)=>{let y=v(h,S.start);if(y===void 0)return;let T=v(h,S.start+S.length);return{start:y,length:T!==void 0&&T>=y?T-y:S.length}},I=(h,S)=>h.blocks.some((y)=>y.offset!==void 0&&S>=y.offset&&S<=y.offset+y.code.length),P=(h)=>{let S=E(h.fileName);if(!S)return h;let y=M(S,h.textSpan);if(!y)return;let T=h.contextSpan?M(S,h.contextSpan):void 0;return{...h,textSpan:y,contextSpan:T}},B=(h)=>h?.map(P).filter((S)=>S!==void 0),K=(h)=>h?.filter((S)=>{let y=E(S.fileName);if(!y)return!0;let{line:T}=Y(y.virtualStarts,S.textSpan.start);return T<=y.virtual.sourceLineCount&&!y.virtual.lineMap.has(T)});if(g)l.getScriptSnapshot=(h)=>{let S=m(h);if(S)return r.ScriptSnapshot.fromString(S.virtual.text);return g(h)};let q=l.getCompilationSettings?.bind(l),G=r.server?.ProjectKind!==void 0&&a.project.projectKind===r.server.ProjectKind.Inferred;if(q&&G){let h=null,S;l.getCompilationSettings=()=>{let y=q();if(h===null)try{h=Br(r,a.project.getCurrentDirectory())}catch(T){c(`could not read the project's tsconfig: ${String(T)}`),h=void 0}if(!h)return y;if(S?.from!==y)S={from:y,options:{...y,...h.paths&&!y.paths?{paths:h.paths}:{},...h.types&&!y.types?{types:h.types}:{}}};return S.options}}let te=(h,S)=>{let y=m(h);if(!y)return S;if(we(h)&&!p())return[];let T=[];for(let k of S){let N=typeof k.messageText==="string"?k.messageText:k.messageText.messageText;if(Ir.has(k.code)){let ne=N.match(/'([^']+)'/)?.[1];if(ne&&y.collisions.has(ne))continue}if(k.start===void 0){T.push(k);continue}let z=R(y,k.start);if(!z||Zt(z,k.code))continue;let V=Le(y.sourceStarts,z.line,z.column),ye=v(y,k.start+(k.length??0));T.push({...k,start:V,length:ye!==void 0&&ye>V?ye-V:k.length??0})}return T},se=u("getSemanticDiagnostics");o.getSemanticDiagnostics=(h)=>{let S=te(h,se(h)),y=E(h);if(!y||!p())return S;let T=o.getProgram?.()?.getSourceFile(h);for(let k of nn(y.source,y.blocks))S.push({file:T,start:k.offset,length:k.length,messageText:k.message,category:r.DiagnosticCategory?.Error??1,code:0,source:"stx"});return S};let X=u("getSyntacticDiagnostics");o.getSyntacticDiagnostics=(h)=>te(h,X(h));let le=u("getSuggestionDiagnostics");o.getSuggestionDiagnostics=(h)=>te(h,le(h));let L=u("getQuickInfoAtPosition");o.getQuickInfoAtPosition=(h,S,...y)=>{let T=E(h);if(!T)return L(h,S,...y);if(!p())return;let k=L(h,O(T,S),...y);if(!k)return k;let N=M(T,k.textSpan);return N?{...k,textSpan:N}:void 0};let W=u("getCompletionsAtPosition");o.getCompletionsAtPosition=(h,S,y,...T)=>{let k=E(h);if(!k)return W(h,S,y,...T);if(!p()||!I(k,S))return;let N=W(h,O(k,S),{...y,includeCompletionsForModuleExports:!1},...T);if(!N)return N;let z=(V)=>V&&M(k,V);return{...N,optionalReplacementSpan:z(N.optionalReplacementSpan),entries:N.entries.filter((V)=>!V.name.startsWith("__stx")&&!V.name.startsWith("__Stx")).map((V)=>V.replacementSpan?{...V,replacementSpan:z(V.replacementSpan)}:V)}};let Q=u("getCompletionEntryDetails");o.getCompletionEntryDetails=(h,S,...y)=>{let T=E(h);if(!T)return Q(h,S,...y);let k=Q(h,O(T,S),...y);return k?{...k,codeActions:void 0}:k};let F=u("getSignatureHelpItems");o.getSignatureHelpItems=(h,S,...y)=>{let T=E(h);if(!T)return F(h,S,...y);if(!p()||!I(T,S))return;let k=F(h,O(T,S),...y),N=k&&M(T,k.applicableSpan);return k&&N?{...k,applicableSpan:N}:void 0};let $e=u("getDefinitionAndBoundSpan");o.getDefinitionAndBoundSpan=(h,S)=>{let y=E(h);if(!y)return be($e(h,S));if(!p())return;let T=$e(h,O(y,S)),k=T&&M(y,T.textSpan);return T&&k?{...be(T),textSpan:k}:void 0};let be=(h)=>h&&{...h,definitions:K(h.definitions)};for(let h of["getDefinitionAtPosition","getTypeDefinitionAtPosition","getImplementationAtPosition"]){let S=u(h);o[h]=(y,T,...k)=>{let N=E(y);if(N&&!p())return;return K(S(y,N?O(N,T):T,...k))}}for(let h of["getReferencesAtPosition"]){let S=u(h);o[h]=(y,T,...k)=>{let N=E(y);if(N&&!p())return;return B(S(y,N?O(N,T):T,...k))}}let un=u("findReferences");o.findReferences=(h,S)=>{let y=E(h);if(y&&!p())return;return un(h,y?O(y,S):S)?.map((T)=>{let k=P(T.definition);return k?{definition:k,references:B(T.references)}:void 0}).filter((T)=>T!==void 0)};let pn=u("getDocumentHighlights");o.getDocumentHighlights=(h,S,y)=>{let T=E(h);if(T&&(!p()||!I(T,S)))return;return pn(h,T?O(T,S):S,y)?.map((k)=>{let N=E(k.fileName);if(!N)return k;return{...k,highlightSpans:k.highlightSpans.map((z)=>{let V=M(N,z.textSpan);return V?{...z,textSpan:V,contextSpan:z.contextSpan&&M(N,z.contextSpan)}:void 0}).filter((z)=>z!==void 0)}})};let dn=u("getNavigationTree");o.getNavigationTree=(h)=>{let S=dn(h),y=E(h);if(!y)return S;let T=(N)=>{let z=N.spans.map((ne)=>M(y,ne)).filter((ne)=>ne!==void 0);if(z.length===0)return;let V=N.nameSpan&&M(y,N.nameSpan),ye=N.childItems?.map(T).filter((ne)=>ne!==void 0);return{...N,spans:z,nameSpan:V,childItems:ye}},k={...S,spans:[{start:0,length:y.source.length}]};return p()?{...k,childItems:S.childItems?.map(T).filter((N)=>N!==void 0)}:{...k,childItems:[]}};let fn={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[h,S]of Object.entries(fn)){let y=o[h];if(typeof y!=="function")continue;let T=y.bind(o);o[h]=(k,...N)=>typeof k==="string"&&we(k)?S():T(k,...N)}return o[sn]=!0,c("Language service proxy created"),o},getExternalFiles(a){if(i.has(a))return[];return a.getFileNames().filter(on)},onConfigurationChanged(a){t={...t,...a};for(let c of s)c()}}}var ln=zr;module.exports=ln;
|
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.939",
|
|
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",
|