@stacksjs/stx-vscode 0.2.919 → 0.2.922

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stacksjs/stx-typescript-plugin",
3
- "version": "0.2.919",
3
+ "version": "0.2.922",
4
4
  "private": true,
5
5
  "main": "index.js"
6
6
  }
@@ -86,6 +86,7 @@ declare module 'stx' {
86
86
  export const useDebouncedValue: typeof globalThis.useDebouncedValue
87
87
  export const useDocumentVisibility: typeof globalThis.useDocumentVisibility
88
88
  export const useEventListener: typeof globalThis.useEventListener
89
+ export const useAsyncData: typeof globalThis.useAsyncData
89
90
  export const useFetch: typeof globalThis.useFetch
90
91
  export const useFocus: typeof globalThis.useFocus
91
92
  export const useHead: typeof globalThis.useHead
@@ -279,7 +279,8 @@ interface StxFetchResult<T> {
279
279
  * inverse mistake is worse — declaring `invalidate` on `useFetch` would
280
280
  * type-check a call to something that is undefined at runtime.
281
281
  */
282
- interface StxQueryResult<T> extends StxFetchResult<T> {
282
+ interface StxQueryResult<T> extends Omit<StxFetchResult<T>, 'error'> {
283
+ error: StxSignal<string | null>
283
284
  /** True when cached data is on screen while a revalidation runs. */
284
285
  isStale: StxSignal<boolean>
285
286
  /** Drop this key from the cache and refetch. */
@@ -289,17 +290,39 @@ interface StxQueryResult<T> extends StxFetchResult<T> {
289
290
  interface StxMutationResult<T> {
290
291
  data: StxSignal<T | null>
291
292
  loading: StxSignal<boolean>
292
- error: StxSignal<Error | null>
293
+ error: StxSignal<string | null>
293
294
  mutate: (body?: unknown) => Promise<T>
295
+ reset: () => void
294
296
  }
295
297
 
296
- declare function useFetch<T = any>(_url: string, _options?: any): StxFetchResult<T>
298
+ interface StxAsyncDataOptions<T> {
299
+ immediate?: boolean
300
+ transform?: (data: T) => T
301
+ initialData?: T | null
302
+ key?: string
303
+ hydrate?: boolean
304
+ cacheTime?: number
305
+ suspense?: boolean
306
+ }
307
+
308
+ interface StxAsyncDataResult<T> extends StxFetchResult<T> {
309
+ status: StxSignal<number | null>
310
+ statusText: StxSignal<string | null>
311
+ execute: () => Promise<void>
312
+ abort: () => void
313
+ }
314
+
315
+ type StxAsyncDataValue<T> = T | AsyncIterable<T> | PromiseLike<T | AsyncIterable<T>>
316
+
317
+ declare function useAsyncData<T>(fetcher: (signal: AbortSignal) => StxAsyncDataValue<T>, options?: StxAsyncDataOptions<T>): StxAsyncDataResult<T>
318
+ declare function useAsyncData<S, T>(source: () => S, fetcher: (value: S, signal: AbortSignal) => StxAsyncDataValue<T>, options?: StxAsyncDataOptions<T>): StxAsyncDataResult<T>
319
+ declare function useFetch<T = any>(_url: string | (() => string), _options?: any): StxFetchResult<T>
297
320
  /** Server-only, keyed JSON data exposed to this render's client hydration. */
298
321
  declare function useServerData<T>(_key: string, _loader: () => T | Promise<T>): Promise<T>
299
322
  /** Clear a hydration snapshot without changing existing signals. */
300
323
  declare function clearServerData(_key?: string): void
301
- declare function useQuery<T = any>(_url: string, _options?: any): StxQueryResult<T>
302
- declare function useMutation<T = any>(_url: string, _options?: any): StxMutationResult<T>
324
+ declare function useQuery<T = any>(_url: string | (() => string), _options?: import('@stacksjs/stx/composables').UseQueryOptions<T>): StxQueryResult<T>
325
+ declare function useMutation<T = any>(_url: string | (() => string), _options?: any): StxMutationResult<T>
303
326
 
304
327
  /** Context handed to a request interceptor. Mutate it; the return is ignored. */
305
328
  interface StxFetchRequestContext {
@@ -365,7 +388,7 @@ declare function configureFetch(_config: {
365
388
  declare function useOptimistic<T = any, A = any>(
366
389
  _base: StxSignal<T> | (() => T) | T,
367
390
  _reducer: (_current: T, _action: A) => T,
368
- ): [StxSignal<T>, (_action: A, _settleWhen?: PromiseLike<unknown>) => () => void]
391
+ ): [StxSignal<T>, (_action: A, _settleWhen?: PromiseLike<unknown> | false) => (commit?: () => void) => void]
369
392
 
370
393
  // ============================================================================
371
394
  // DOM utilities
@@ -978,6 +1001,7 @@ interface StxRuntimeRegistry {
978
1001
 
979
1002
  // Composables
980
1003
  useFetch: typeof useFetch
1004
+ useAsyncData: typeof useAsyncData
981
1005
  clearServerData: typeof clearServerData
982
1006
  useRef: typeof useRef
983
1007
  useQuery: typeof useQuery
@@ -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})}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","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=[")","]","}"],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=`
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>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx-vscode",
3
3
  "type": "module",
4
- "version": "0.2.919",
4
+ "version": "0.2.922",
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",