@stacksjs/stx-vscode 0.2.405 → 0.2.407

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.405",
3
+ "version": "0.2.407",
4
4
  "private": true,
5
5
  "main": "index.js"
6
6
  }
@@ -112,6 +112,9 @@ declare module 'stx' {
112
112
  export const useSessionStorage: typeof globalThis.useSessionStorage
113
113
  export const keptState: typeof globalThis.keptState
114
114
  export const forgetKeptState: typeof globalThis.forgetKeptState
115
+ export const setKeptScope: typeof globalThis.setKeptScope
116
+ export const flushKeptState: typeof globalThis.flushKeptState
117
+ export const cachedQuery: typeof globalThis.cachedQuery
115
118
  export const useSlots: typeof globalThis.useSlots
116
119
  export const useStore: typeof globalThis.useStore
117
120
  export const useThrottle: typeof globalThis.useThrottle
@@ -484,7 +484,51 @@ declare function useSessionStorage<T>(_key: string, _defaultValue: T): StxSignal
484
484
  /** A value kept between visits (a phone app between launches) in a scope such as the signed-in account; a scope of false keeps nothing. */
485
485
  declare function keptState<T>(_name: string, _initialValue: T, _options?: { scope?: string | number | false | null }): StxSignal<T>
486
486
  /** Remove a scope's kept values, or every kept value. */
487
- declare function forgetKeptState(_scope?: string | number | false | null): void
487
+ declare function forgetKeptState(_scope?: string | number | false | null): Promise<void>
488
+ /** The account kept state and cached queries belong to when they name no scope. */
489
+ declare function setKeptScope(_scope: string | number | false | null | undefined): void
490
+ /** Finish writing what is kept (large values are written behind, to IndexedDB). */
491
+ declare function flushKeptState(): Promise<void>
492
+
493
+ /** Options of `cachedQuery`: see offline/query-cache.ts. */
494
+ interface StxCachedQueryOptions<T> {
495
+ /** The URL to GET (answered as JSON), or a function giving it. */
496
+ url?: string | (() => string | null | undefined)
497
+ /** Load the data some other way than a GET of `url`. */
498
+ load?: (_context: { force: boolean, url: string | null, signal?: AbortSignal }) => Promise<T>
499
+ /** How to send the GET, with current credentials. */
500
+ fetch?: (_url: string, _init: RequestInit) => Promise<Response>
501
+ /** Whose data this is, as for keptState; a function is read at every load. Default: setKeptScope's. */
502
+ scope?: string | number | false | null | (() => string | number | false | null | undefined)
503
+ /** How long an answer counts as fresh, ms. Default 0. */
504
+ staleTime?: number
505
+ initial?: T
506
+ transform?: (_raw: any) => T
507
+ /** Give up on a request after this long, ms. Default 15000. */
508
+ timeoutMs?: number
509
+ /** Fetch when created. */
510
+ immediate?: boolean
511
+ }
512
+
513
+ interface StxCachedQuery<T> {
514
+ /** The last answer, with writes still waiting in the outbox applied. */
515
+ data: StxSignal<T>
516
+ loading: StxSignal<boolean>
517
+ isFetching: StxSignal<boolean>
518
+ error: StxSignal<string | null>
519
+ /** When the data shown was fetched (ms); 0 for none. */
520
+ updatedAt: StxSignal<number>
521
+ /** Fetch when older than staleTime (or always, with force). One request for every caller. */
522
+ load: (_force?: boolean) => Promise<T>
523
+ /** Fetch now, past every cache. */
524
+ refresh: () => Promise<T>
525
+ set: (_value: T | ((_current: T) => T)) => void
526
+ invalidate: () => void
527
+ readonly key: string
528
+ }
529
+
530
+ /** Data kept per account, shown at once from last time and refreshed behind. Same key, same query. */
531
+ declare function cachedQuery<T = any>(_key: string, _options?: StxCachedQueryOptions<T>): StxCachedQuery<T>
488
532
 
489
533
  /**
490
534
  * Options accepted by the auto-imported `useCookie` global.
@@ -921,6 +965,9 @@ interface StxRuntimeRegistry {
921
965
  useSessionStorage: typeof useSessionStorage
922
966
  keptState: typeof keptState
923
967
  forgetKeptState: typeof forgetKeptState
968
+ setKeptScope: typeof setKeptScope
969
+ flushKeptState: typeof flushKeptState
970
+ cachedQuery: typeof cachedQuery
924
971
  useEventListener: typeof useEventListener
925
972
  useScrollLock: typeof useScrollLock
926
973
  useWebSocket: typeof useWebSocket
@@ -7,7 +7,7 @@ var w2=Object.create;var{getPrototypeOf:B2,defineProperty:D$,getOwnPropertyNames
7
7
  `?`
8
8
  `:" ",J++}Q+=" ",J++,Z=a,K="";continue}if(j==="/"&&C2(Z,K)){let z=y2($,J);if(z!==-1){Q+=`/${" ".repeat(z-J-2)}/`,J=z,Z=a,K="";continue}}if(j==="`"){Q+=" ",J++;while(J<$.length&&$[J]!=="`"){if($[J]==="\\"){Q+=" ",J+=2;continue}if($[J]==="$"&&$[J+1]==="{"){let z=J+2,V=I$($,z);if(Q+=" ",Q+=E($.slice(z,V)),V<$.length)Q+=" ";J=V+1;continue}Q+=$[J]===`
9
9
  `?`
10
- `:" ",J++}Q+=" ",J++,Z=a,K="";continue}if(Q+=j,J++,/[\w$]/.test(j))K=/[\w$]/.test(Z)?K+j:j,Z=j;else if(!/\s/.test(j))Z=j,K=""}return Q}function o($){let Q=new Uint16Array($.length),J=0,Z=!0;for(let K=0;K<$.length;K++){let Y=$[K];if(Y===")"||Y==="]"||Y==="}")if(J===0)Z=!1;else J--;if(Q[K]=J,Y==="("||Y==="["||Y==="{")J++}return{depths:Q,balanced:Z&&J===0}}function P$($){let Q=$.indexOf(" as ");if(Q!==-1){let Y=$.slice(0,Q).trim(),j=$.slice(Q+4).trim();return Y&&j?{arrayExpr:Y,itemVar:j}:null}let J=/^\s*(.+?)\s+in\s+([\s\S]+)$/.exec($);if(!J)return null;let Z=J[1].trim().replace(/^\(([\s\S]*)\)$/,"$1").trim(),K=J[2].trim();return Z&&K?{arrayExpr:K,itemVar:Z}:null}var p=["batch","clearServerData","computed","configureFetch","defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","defineStore","derived","effect","forgetKeptState","goBack","goForward","inject","invalidateRoute","isDerived","isSignal","keptState","navigate","nextTick","onBeforeMount","onBeforeUnmount","onDestroy","onMount","onMounted","onUnmounted","peek","provide","reactive","ref","refresh","registerStoresClient","setRouteParams","state","untrack","useAsync","useClickOutside","useColorMode","useCookie","useCounter","useDark","useDebounce","useDebouncedValue","useDocumentVisibility","useEventListener","useFetch","useFocus","useHead","useId","useInterval","useLocalStorage","useMediaQuery","useModel","useMutation","useOptimistic","usePreferredContrast","usePreferredDark","usePreferredLight","usePreferredReducedMotion","useQuery","useReactiveProp","useRef","useRoute","useRouteParam","useRouteParams","useScrollLock","useSearchParams","useSeoMeta","useSessionStorage","useSlots","useStore","useThrottle","useTimeout","useToggle","useWebSocket","watch","watchEffect","watchMultiple","withDefaults"];var A2=["defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","withDefaults"];var I4=p.filter(($)=>!A2.includes($));var R2=["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"],_2=["x-init","x-transition","x-effect","x-on"],P4=[...R2,..._2];var t=h(require("node:fs")),m=h(require("node:path"));function L$($,Q,J,Z){let K=0;for(let Y=Q;Y<$.length;Y++)if($[Y]===J)K++;else if($[Y]===Z&&!(Z===">"&&$[Y-1]==="=")){if(--K===0)return Y}return-1}function S2($){let Q=E($),J=0,Z=0,K=[];for(let Y=0;Y<Q.length;Y++)if("([{".includes(Q[Y]))J++;else if(")]}".includes(Q[Y]))J--;else if(Q[Y]===","&&J===0)K.push($.slice(Z,Y).trim()),Z=Y+1;return K.push($.slice(Z).trim()),K}function Y$($,Q){let J=E($),Z=new RegExp(`\\b(?:${Q.map((K)=>K.replace(/[$]/g,"\\$&")).join("|")})\\s*(?=[<(])`,"g");for(let K of J.matchAll(Z)){let Y=K.index+K[0].length,j="";if(J[Y]==="<"){let V=L$(J,Y,"<",">");if(V<0)continue;j=$.slice(Y+1,V),Y=V+1;while(/\s/.test(J[Y]||"")&&Y<J.length)Y++}if(J[Y]!=="(")continue;let z=L$(J,Y,"(",")");if(z>=0)return{type:j,args:S2($.slice(Y+1,z))}}return null}var C$=`
10
+ `:" ",J++}Q+=" ",J++,Z=a,K="";continue}if(Q+=j,J++,/[\w$]/.test(j))K=/[\w$]/.test(Z)?K+j:j,Z=j;else if(!/\s/.test(j))Z=j,K=""}return Q}function o($){let Q=new Uint16Array($.length),J=0,Z=!0;for(let K=0;K<$.length;K++){let Y=$[K];if(Y===")"||Y==="]"||Y==="}")if(J===0)Z=!1;else J--;if(Q[K]=J,Y==="("||Y==="["||Y==="{")J++}return{depths:Q,balanced:Z&&J===0}}function P$($){let Q=$.indexOf(" as ");if(Q!==-1){let Y=$.slice(0,Q).trim(),j=$.slice(Q+4).trim();return Y&&j?{arrayExpr:Y,itemVar:j}:null}let J=/^\s*(.+?)\s+in\s+([\s\S]+)$/.exec($);if(!J)return null;let Z=J[1].trim().replace(/^\(([\s\S]*)\)$/,"$1").trim(),K=J[2].trim();return Z&&K?{arrayExpr:K,itemVar:Z}:null}var p=["batch","cachedQuery","clearServerData","computed","configureFetch","defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","defineStore","derived","effect","flushKeptState","forgetKeptState","goBack","goForward","inject","invalidateRoute","isDerived","isSignal","keptState","navigate","nextTick","onBeforeMount","onBeforeUnmount","onDestroy","onMount","onMounted","onUnmounted","peek","provide","reactive","ref","refresh","registerStoresClient","setKeptScope","setRouteParams","state","untrack","useAsync","useClickOutside","useColorMode","useCookie","useCounter","useDark","useDebounce","useDebouncedValue","useDocumentVisibility","useEventListener","useFetch","useFocus","useHead","useId","useInterval","useLocalStorage","useMediaQuery","useModel","useMutation","useOptimistic","usePreferredContrast","usePreferredDark","usePreferredLight","usePreferredReducedMotion","useQuery","useReactiveProp","useRef","useRoute","useRouteParam","useRouteParams","useScrollLock","useSearchParams","useSeoMeta","useSessionStorage","useSlots","useStore","useThrottle","useTimeout","useToggle","useWebSocket","watch","watchEffect","watchMultiple","withDefaults"];var A2=["defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","withDefaults"];var I4=p.filter(($)=>!A2.includes($));var R2=["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"],_2=["x-init","x-transition","x-effect","x-on"],P4=[...R2,..._2];var t=h(require("node:fs")),m=h(require("node:path"));function L$($,Q,J,Z){let K=0;for(let Y=Q;Y<$.length;Y++)if($[Y]===J)K++;else if($[Y]===Z&&!(Z===">"&&$[Y-1]==="=")){if(--K===0)return Y}return-1}function S2($){let Q=E($),J=0,Z=0,K=[];for(let Y=0;Y<Q.length;Y++)if("([{".includes(Q[Y]))J++;else if(")]}".includes(Q[Y]))J--;else if(Q[Y]===","&&J===0)K.push($.slice(Z,Y).trim()),Z=Y+1;return K.push($.slice(Z).trim()),K}function Y$($,Q){let J=E($),Z=new RegExp(`\\b(?:${Q.map((K)=>K.replace(/[$]/g,"\\$&")).join("|")})\\s*(?=[<(])`,"g");for(let K of J.matchAll(Z)){let Y=K.index+K[0].length,j="";if(J[Y]==="<"){let V=L$(J,Y,"<",">");if(V<0)continue;j=$.slice(Y+1,V),Y=V+1;while(/\s/.test(J[Y]||"")&&Y<J.length)Y++}if(J[Y]!=="(")continue;let z=L$(J,Y,"(",")");if(z>=0)return{type:j,args:S2($.slice(Y+1,z))}}return null}var C$=`
11
11
  type __StxCtor<T> = T extends StringConstructor ? string : T extends NumberConstructor ? number : T extends BooleanConstructor ? boolean : T extends ArrayConstructor ? unknown[] : T extends ObjectConstructor ? object : T extends readonly unknown[] ? __StxCtor<T[number]> : T extends abstract new (...args: any[]) => infer V ? V : unknown;
12
12
  type __StxWiden<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T;
13
13
  type __StxOption<T> = T extends { type: infer C } ? __StxCtor<C> : T extends { default: infer D } ? D extends (...args: any[]) => infer V ? V : __StxWiden<D> : __StxCtor<T>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx-vscode",
3
3
  "type": "module",
4
- "version": "0.2.405",
4
+ "version": "0.2.407",
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",