@epoch32/visage 0.0.0 → 1.1.0

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.
Files changed (139) hide show
  1. package/dist/api/client.d.ts +5 -0
  2. package/dist/api/file-router.d.ts +29 -0
  3. package/dist/api/handler.d.ts +15 -0
  4. package/dist/api/index.d.ts +12 -0
  5. package/dist/{src/api → api}/index.js +87 -2
  6. package/dist/api/middleware.d.ts +11 -0
  7. package/dist/api/pragma.d.ts +21 -0
  8. package/dist/api/procedure.d.ts +66 -0
  9. package/dist/api/types.d.ts +181 -0
  10. package/dist/charts/Area.d.ts +18 -0
  11. package/dist/charts/Axis.d.ts +21 -0
  12. package/dist/charts/Bar.d.ts +10 -0
  13. package/dist/charts/CartesianGrid.d.ts +10 -0
  14. package/dist/charts/Chart.d.ts +16 -0
  15. package/dist/charts/Cursor.d.ts +8 -0
  16. package/dist/charts/Legend.d.ts +9 -0
  17. package/dist/charts/Line.d.ts +18 -0
  18. package/dist/charts/Pie.d.ts +12 -0
  19. package/dist/charts/Tooltip.d.ts +12 -0
  20. package/dist/charts/context.d.ts +20 -0
  21. package/dist/charts/index.d.ts +14 -0
  22. package/dist/{src/charts → charts}/index.js +87 -2
  23. package/dist/charts/path.d.ts +27 -0
  24. package/dist/charts/scale.d.ts +23 -0
  25. package/dist/charts/types.d.ts +43 -0
  26. package/dist/devtools/DomTab.d.ts +6 -0
  27. package/dist/devtools/GraphInspector.d.ts +11 -0
  28. package/dist/devtools/GraphTab.d.ts +10 -0
  29. package/dist/devtools/QueryTab.d.ts +10 -0
  30. package/dist/devtools/RpcTab.d.ts +10 -0
  31. package/dist/devtools/SignalsTab.d.ts +10 -0
  32. package/dist/devtools/component.d.ts +2 -0
  33. package/dist/devtools/highlighter.d.ts +2 -0
  34. package/dist/devtools/hub.d.ts +41 -0
  35. package/dist/devtools/index.d.ts +9 -0
  36. package/dist/{src/devtools → devtools}/index.js +87 -2
  37. package/dist/devtools/styles.d.ts +1 -0
  38. package/dist/devtools/types.d.ts +44 -0
  39. package/dist/dom/async.d.ts +41 -0
  40. package/dist/dom/control-flow.d.ts +53 -0
  41. package/dist/dom/index.d.ts +3 -0
  42. package/dist/{src/dom → dom}/index.js +87 -2
  43. package/dist/dom/lazy.d.ts +30 -0
  44. package/dist/dom/render.d.ts +23 -0
  45. package/dist/dom/resource.d.ts +34 -0
  46. package/dist/form/form.d.ts +41 -0
  47. package/dist/form/index.d.ts +2 -0
  48. package/dist/{src/form → form}/index.js +87 -2
  49. package/dist/form/schema.d.ts +96 -0
  50. package/dist/index.d.ts +15 -0
  51. package/dist/index.js +3571 -1293
  52. package/dist/jsx-dev-runtime/index.d.ts +1 -0
  53. package/dist/jsx-runtime/index.d.ts +8 -0
  54. package/dist/{src/jsx-runtime → jsx-runtime}/index.js +87 -2
  55. package/dist/query/create-mutation.d.ts +3 -0
  56. package/dist/query/create-query.d.ts +4 -0
  57. package/dist/query/focus-manager.d.ts +14 -0
  58. package/dist/query/index.d.ts +9 -0
  59. package/dist/{src/query → query}/index.js +87 -2
  60. package/dist/query/mutation-cache.d.ts +24 -0
  61. package/dist/query/online-manager.d.ts +14 -0
  62. package/dist/query/query-cache.d.ts +69 -0
  63. package/dist/query/query-client.d.ts +46 -0
  64. package/dist/query/types.d.ts +131 -0
  65. package/dist/query/utils.d.ts +16 -0
  66. package/dist/router/index.d.ts +1 -0
  67. package/dist/{src/router → router}/index.js +87 -2
  68. package/dist/router/router.d.ts +91 -0
  69. package/dist/rpc/client.d.ts +2 -0
  70. package/dist/rpc/error.d.ts +16 -0
  71. package/dist/rpc/index.d.ts +7 -0
  72. package/dist/{src/rpc → rpc}/index.js +87 -2
  73. package/dist/rpc/procedure.d.ts +8 -0
  74. package/dist/rpc/router.d.ts +19 -0
  75. package/dist/rpc/server.d.ts +3 -0
  76. package/dist/rpc/types.d.ts +200 -0
  77. package/dist/server/hydrate.d.ts +5 -0
  78. package/dist/server/index.d.ts +3 -0
  79. package/dist/{src/server → server}/index.js +87 -2
  80. package/dist/server/render-to-stream.d.ts +9 -0
  81. package/dist/server/render-to-string.d.ts +6 -0
  82. package/dist/signals/computed.d.ts +61 -0
  83. package/dist/signals/context.d.ts +44 -0
  84. package/dist/signals/effect.d.ts +56 -0
  85. package/dist/signals/index.d.ts +8 -0
  86. package/dist/{src/signals → signals}/index.js +87 -2
  87. package/dist/signals/scope.d.ts +61 -0
  88. package/dist/signals/signal.d.ts +40 -0
  89. package/dist/signals/store.d.ts +45 -0
  90. package/dist/signals/system.d.ts +56 -0
  91. package/dist/signals/types.d.ts +58 -0
  92. package/dist/style/component.d.ts +49 -0
  93. package/dist/style/create-style.d.ts +63 -0
  94. package/dist/style/cx.d.ts +18 -0
  95. package/dist/style/hash.d.ts +8 -0
  96. package/dist/style/index.d.ts +8 -0
  97. package/dist/{src/style → style}/index.js +87 -2
  98. package/dist/style/layout.d.ts +129 -0
  99. package/dist/style/manager.d.ts +31 -0
  100. package/dist/style/parser.d.ts +12 -0
  101. package/dist/style/scale.d.ts +82 -0
  102. package/dist/template/index.d.ts +1 -0
  103. package/dist/{src/template → template}/index.js +87 -2
  104. package/dist/template/template.d.ts +8 -0
  105. package/dist/ui/accordion.d.ts +81 -0
  106. package/dist/ui/command-dialog.d.ts +10 -0
  107. package/dist/ui/command.d.ts +103 -0
  108. package/dist/ui/data-table.d.ts +38 -0
  109. package/dist/ui/dialog.d.ts +102 -0
  110. package/dist/ui/dropdown-menu.d.ts +92 -0
  111. package/dist/ui/icon.d.ts +18 -0
  112. package/dist/ui/index.d.ts +14 -0
  113. package/dist/{src/ui → ui}/index.js +87 -2
  114. package/dist/ui/layout.d.ts +1 -0
  115. package/dist/ui/popover.d.ts +68 -0
  116. package/dist/ui/switch.d.ts +31 -0
  117. package/dist/ui/tabs.d.ts +71 -0
  118. package/dist/ui/toast.d.ts +91 -0
  119. package/dist/ui/tooltip.d.ts +64 -0
  120. package/dist/ui/utils.d.ts +21 -0
  121. package/dist/virtual/index.d.ts +2 -0
  122. package/dist/{src/virtual → virtual}/index.js +87 -2
  123. package/dist/virtual/virtual-list.d.ts +21 -0
  124. package/dist/virtual/virtualizer.d.ts +31 -0
  125. package/dist/vite/hmr.d.ts +7 -0
  126. package/dist/vite/index.d.ts +3 -0
  127. package/dist/vite/index.js +296 -15
  128. package/dist/vite/lucide.d.ts +27 -0
  129. package/dist/vite/plugin.d.ts +3 -0
  130. package/dist/vite/rpc-middleware.d.ts +5 -0
  131. package/dist/vite/types.d.ts +59 -0
  132. package/package.json +40 -40
  133. package/src/signals/index.ts +1 -0
  134. package/src/signals/signal.ts +110 -2
  135. package/src/signals/types.ts +9 -0
  136. package/src/vite/plugin.ts +4 -0
  137. package/dist/bundle.dev.js +0 -4875
  138. package/dist/src/index.js +0 -11826
  139. package/dist/src/vite/index.js +0 -984
@@ -0,0 +1 @@
1
+ export { Fragment, type JSX, jsx, jsxDEV, jsxs } from "../jsx-runtime";
@@ -0,0 +1,8 @@
1
+ import { type Child } from "../dom";
2
+ export type { JSX } from "./jsx";
3
+ export declare function Fragment(props: {
4
+ children?: Child;
5
+ }): any;
6
+ export declare function jsx(type: any, props?: Record<string, any>, key?: any): any;
7
+ export declare const jsxs: typeof jsx;
8
+ export declare const jsxDEV: typeof jsx;
@@ -848,10 +848,12 @@ class Signal {
848
848
  _value;
849
849
  _subscribers = new Set;
850
850
  _equals;
851
+ _onSet;
851
852
  version = 0;
852
- constructor(initialValue, equals) {
853
+ constructor(initialValue, equals, onSet) {
853
854
  this._value = initialValue;
854
855
  this._equals = equals ?? Object.is;
856
+ this._onSet = onSet;
855
857
  }
856
858
  get() {
857
859
  if (currentSubscriber !== null && currentSubscriber.state !== 3 /* DISPOSED */) {
@@ -876,6 +878,9 @@ class Signal {
876
878
  }
877
879
  this._value = newValue;
878
880
  this.version++;
881
+ if (this._onSet) {
882
+ this._onSet(newValue);
883
+ }
879
884
  batch(() => {
880
885
  this.notify();
881
886
  });
@@ -901,11 +906,91 @@ class Signal {
901
906
  }
902
907
  }
903
908
  }
909
+ function resolveStorage(storageOption) {
910
+ if (storageOption && typeof storageOption === "object") {
911
+ return storageOption;
912
+ }
913
+ if (storageOption === "session") {
914
+ try {
915
+ if (typeof sessionStorage !== "undefined")
916
+ return sessionStorage;
917
+ } catch {}
918
+ try {
919
+ if (typeof window !== "undefined" && window.sessionStorage) {
920
+ return window.sessionStorage;
921
+ }
922
+ } catch {}
923
+ try {
924
+ if (typeof globalThis !== "undefined" && globalThis.sessionStorage) {
925
+ return globalThis.sessionStorage;
926
+ }
927
+ } catch {}
928
+ return null;
929
+ }
930
+ try {
931
+ if (typeof localStorage !== "undefined")
932
+ return localStorage;
933
+ } catch {}
934
+ try {
935
+ if (typeof window !== "undefined" && window.localStorage) {
936
+ return window.localStorage;
937
+ }
938
+ } catch {}
939
+ try {
940
+ if (typeof globalThis !== "undefined" && globalThis.localStorage) {
941
+ return globalThis.localStorage;
942
+ }
943
+ } catch {}
944
+ return null;
945
+ }
904
946
  function signal(initialValue, optionsOrEquals) {
905
947
  const equals = typeof optionsOrEquals === "function" ? optionsOrEquals : optionsOrEquals?.equals;
906
948
  const isInternal = typeof optionsOrEquals === "object" ? optionsOrEquals?.internal : false;
907
949
  const customName = typeof optionsOrEquals === "object" ? optionsOrEquals?.name : undefined;
908
- const s = new Signal(initialValue, equals);
950
+ const persistOption = typeof optionsOrEquals === "object" ? optionsOrEquals?.persist : undefined;
951
+ const persistConfig = persistOption ? typeof persistOption === "string" ? { key: persistOption } : persistOption : undefined;
952
+ let effectiveInitial = initialValue;
953
+ const storage = persistConfig ? resolveStorage(persistConfig.storage) : null;
954
+ const serialize = persistConfig?.serialize ?? JSON.stringify;
955
+ const deserialize = persistConfig?.deserialize ?? JSON.parse;
956
+ if (persistConfig && storage) {
957
+ try {
958
+ const stored = storage.getItem(persistConfig.key);
959
+ if (stored !== null) {
960
+ effectiveInitial = deserialize(stored);
961
+ }
962
+ } catch {}
963
+ }
964
+ let isSyncing = false;
965
+ const onSet = persistConfig && storage ? (val) => {
966
+ if (isSyncing)
967
+ return;
968
+ try {
969
+ storage.setItem(persistConfig.key, serialize(val));
970
+ } catch {}
971
+ } : undefined;
972
+ const s = new Signal(effectiveInitial, equals, onSet);
973
+ if (persistConfig && storage && (persistConfig.syncTabs ?? true) && typeof window !== "undefined" && typeof window.addEventListener === "function") {
974
+ const onStorage = (e) => {
975
+ if (e.key === persistConfig.key) {
976
+ try {
977
+ const nextVal = e.newValue !== null ? deserialize(e.newValue) : initialValue;
978
+ isSyncing = true;
979
+ try {
980
+ s.set(nextVal);
981
+ } finally {
982
+ isSyncing = false;
983
+ }
984
+ } catch {}
985
+ }
986
+ };
987
+ window.addEventListener("storage", onStorage);
988
+ if (currentScope) {
989
+ currentScope.addCleanup(() => {
990
+ window.removeEventListener("storage", onStorage);
991
+ });
992
+ }
993
+ }
909
994
  const accessor = (...args) => {
910
995
  if (args.length === 0) {
911
996
  return s.get();
@@ -0,0 +1,3 @@
1
+ import { type QueryClient } from "./query-client";
2
+ import type { MutationOptions, MutationResult } from "./types";
3
+ export declare function createMutation<TData = unknown, TError = any, TVariables = void, TContext = unknown>(options: MutationOptions<TData, TError, TVariables, TContext> | (() => MutationOptions<TData, TError, TVariables, TContext>), client?: QueryClient): MutationResult<TData, TError, TVariables, TContext>;
@@ -0,0 +1,4 @@
1
+ import { type QueryClient } from "./query-client";
2
+ import type { CreateQueryOptions, InfiniteData, InfiniteQueryOptions, InfiniteQueryResult, QueryKey, QueryResult } from "./types";
3
+ export declare function createQuery<TData = unknown, TError = any, TSelected = TData, TQueryKey extends QueryKey = QueryKey>(options: CreateQueryOptions<TData, TError, TSelected, TQueryKey> | (() => CreateQueryOptions<TData, TError, TSelected, TQueryKey>), client?: QueryClient): QueryResult<TSelected, TError>;
4
+ export declare function createInfiniteQuery<TData = unknown, TError = any, TPageParam = unknown, TSelected = InfiniteData<TData, TPageParam>, TQueryKey extends QueryKey = QueryKey>(options: InfiniteQueryOptions<TData, TError, TPageParam, TSelected, TQueryKey> | (() => InfiniteQueryOptions<TData, TError, TPageParam, TSelected, TQueryKey>), client?: QueryClient): InfiniteQueryResult<TData, TError, TPageParam>;
@@ -0,0 +1,14 @@
1
+ export type FocusListener = (focused: boolean) => void;
2
+ export declare class FocusManager {
3
+ private _focused?;
4
+ private _listeners;
5
+ private _cleanup?;
6
+ constructor();
7
+ private setupEventListener;
8
+ setFocused(focused?: boolean): void;
9
+ isFocused(): boolean;
10
+ subscribe(listener: FocusListener): () => void;
11
+ private notify;
12
+ cleanup(): void;
13
+ }
14
+ export declare const focusManager: FocusManager;
@@ -0,0 +1,9 @@
1
+ export { createMutation } from "./create-mutation";
2
+ export { createInfiniteQuery, createQuery } from "./create-query";
3
+ export { type FocusListener, FocusManager, focusManager } from "./focus-manager";
4
+ export { Mutation, MutationCache } from "./mutation-cache";
5
+ export { type OnlineListener, OnlineManager, onlineManager } from "./online-manager";
6
+ export { Query, QueryCache, type QueryObserver } from "./query-cache";
7
+ export { QueryClient, type QueryClientConfig, QueryClientContext, QueryClientProvider, useQueryClient } from "./query-client";
8
+ export type { CreateQueryOptions, DefaultOptions, FetchStatus, InfiniteData, InfiniteQueryOptions, InfiniteQueryResult, MutateOptions, MutationFunction, MutationOptions, MutationResult, MutationStatus, QueryFilters, QueryFunction, QueryFunctionContext, QueryKey, QueryOptions, QueryResult, QueryState, QueryStatus, RefetchOptions, RetryDelayValue, RetryValue } from "./types";
9
+ export { deepEqual, hashKey, isPlainObject, matchQuery, partialDeepEqual, sleep } from "./utils";
@@ -848,10 +848,12 @@ class Signal {
848
848
  _value;
849
849
  _subscribers = new Set;
850
850
  _equals;
851
+ _onSet;
851
852
  version = 0;
852
- constructor(initialValue, equals) {
853
+ constructor(initialValue, equals, onSet) {
853
854
  this._value = initialValue;
854
855
  this._equals = equals ?? Object.is;
856
+ this._onSet = onSet;
855
857
  }
856
858
  get() {
857
859
  if (currentSubscriber !== null && currentSubscriber.state !== 3 /* DISPOSED */) {
@@ -876,6 +878,9 @@ class Signal {
876
878
  }
877
879
  this._value = newValue;
878
880
  this.version++;
881
+ if (this._onSet) {
882
+ this._onSet(newValue);
883
+ }
879
884
  batch(() => {
880
885
  this.notify();
881
886
  });
@@ -901,11 +906,91 @@ class Signal {
901
906
  }
902
907
  }
903
908
  }
909
+ function resolveStorage(storageOption) {
910
+ if (storageOption && typeof storageOption === "object") {
911
+ return storageOption;
912
+ }
913
+ if (storageOption === "session") {
914
+ try {
915
+ if (typeof sessionStorage !== "undefined")
916
+ return sessionStorage;
917
+ } catch {}
918
+ try {
919
+ if (typeof window !== "undefined" && window.sessionStorage) {
920
+ return window.sessionStorage;
921
+ }
922
+ } catch {}
923
+ try {
924
+ if (typeof globalThis !== "undefined" && globalThis.sessionStorage) {
925
+ return globalThis.sessionStorage;
926
+ }
927
+ } catch {}
928
+ return null;
929
+ }
930
+ try {
931
+ if (typeof localStorage !== "undefined")
932
+ return localStorage;
933
+ } catch {}
934
+ try {
935
+ if (typeof window !== "undefined" && window.localStorage) {
936
+ return window.localStorage;
937
+ }
938
+ } catch {}
939
+ try {
940
+ if (typeof globalThis !== "undefined" && globalThis.localStorage) {
941
+ return globalThis.localStorage;
942
+ }
943
+ } catch {}
944
+ return null;
945
+ }
904
946
  function signal(initialValue, optionsOrEquals) {
905
947
  const equals = typeof optionsOrEquals === "function" ? optionsOrEquals : optionsOrEquals?.equals;
906
948
  const isInternal = typeof optionsOrEquals === "object" ? optionsOrEquals?.internal : false;
907
949
  const customName = typeof optionsOrEquals === "object" ? optionsOrEquals?.name : undefined;
908
- const s = new Signal(initialValue, equals);
950
+ const persistOption = typeof optionsOrEquals === "object" ? optionsOrEquals?.persist : undefined;
951
+ const persistConfig = persistOption ? typeof persistOption === "string" ? { key: persistOption } : persistOption : undefined;
952
+ let effectiveInitial = initialValue;
953
+ const storage = persistConfig ? resolveStorage(persistConfig.storage) : null;
954
+ const serialize = persistConfig?.serialize ?? JSON.stringify;
955
+ const deserialize = persistConfig?.deserialize ?? JSON.parse;
956
+ if (persistConfig && storage) {
957
+ try {
958
+ const stored = storage.getItem(persistConfig.key);
959
+ if (stored !== null) {
960
+ effectiveInitial = deserialize(stored);
961
+ }
962
+ } catch {}
963
+ }
964
+ let isSyncing = false;
965
+ const onSet = persistConfig && storage ? (val) => {
966
+ if (isSyncing)
967
+ return;
968
+ try {
969
+ storage.setItem(persistConfig.key, serialize(val));
970
+ } catch {}
971
+ } : undefined;
972
+ const s = new Signal(effectiveInitial, equals, onSet);
973
+ if (persistConfig && storage && (persistConfig.syncTabs ?? true) && typeof window !== "undefined" && typeof window.addEventListener === "function") {
974
+ const onStorage = (e) => {
975
+ if (e.key === persistConfig.key) {
976
+ try {
977
+ const nextVal = e.newValue !== null ? deserialize(e.newValue) : initialValue;
978
+ isSyncing = true;
979
+ try {
980
+ s.set(nextVal);
981
+ } finally {
982
+ isSyncing = false;
983
+ }
984
+ } catch {}
985
+ }
986
+ };
987
+ window.addEventListener("storage", onStorage);
988
+ if (currentScope) {
989
+ currentScope.addCleanup(() => {
990
+ window.removeEventListener("storage", onStorage);
991
+ });
992
+ }
993
+ }
909
994
  const accessor = (...args) => {
910
995
  if (args.length === 0) {
911
996
  return s.get();
@@ -0,0 +1,24 @@
1
+ import { type ReadonlySignal, type WritableSignal } from "../signals";
2
+ import type { MutateOptions, MutationOptions, MutationStatus } from "./types";
3
+ export declare class Mutation<TData = unknown, TError = any, TVariables = void, TContext = unknown> {
4
+ readonly options: MutationOptions<TData, TError, TVariables, TContext>;
5
+ readonly data: WritableSignal<TData | undefined>;
6
+ readonly error: WritableSignal<TError | null>;
7
+ readonly status: WritableSignal<MutationStatus>;
8
+ readonly submittedAt: WritableSignal<number>;
9
+ readonly variables: WritableSignal<TVariables | undefined>;
10
+ readonly isIdle: ReadonlySignal<boolean>;
11
+ readonly isPending: ReadonlySignal<boolean>;
12
+ readonly isLoading: ReadonlySignal<boolean>;
13
+ readonly isSuccess: ReadonlySignal<boolean>;
14
+ readonly isError: ReadonlySignal<boolean>;
15
+ constructor(options: MutationOptions<TData, TError, TVariables, TContext>);
16
+ execute(variables: TVariables, mutateOptions?: MutateOptions<TData, TError, TVariables, TContext>): Promise<TData>;
17
+ reset(): void;
18
+ }
19
+ export declare class MutationCache {
20
+ mutations: Set<Mutation<any, any, any, any>>;
21
+ build<TData, TError, TVariables, TContext>(options: MutationOptions<TData, TError, TVariables, TContext>): Mutation<TData, TError, TVariables, TContext>;
22
+ remove(mutation: Mutation<any, any, any, any>): void;
23
+ clear(): void;
24
+ }
@@ -0,0 +1,14 @@
1
+ export type OnlineListener = (online: boolean) => void;
2
+ export declare class OnlineManager {
3
+ private _online?;
4
+ private _listeners;
5
+ private _cleanup?;
6
+ constructor();
7
+ private setupEventListener;
8
+ setOnline(online?: boolean): void;
9
+ isOnline(): boolean;
10
+ subscribe(listener: OnlineListener): () => void;
11
+ private notify;
12
+ cleanup(): void;
13
+ }
14
+ export declare const onlineManager: OnlineManager;
@@ -0,0 +1,69 @@
1
+ import { type WritableSignal } from "../signals";
2
+ import type { QueryClient } from "./query-client";
3
+ import type { FetchStatus, QueryFilters, QueryKey, QueryOptions, QueryState, QueryStatus } from "./types";
4
+ export interface QueryObserver<TData = any, TError = any> {
5
+ onQueryUpdate(): void;
6
+ options: QueryOptions<TData, TError, any>;
7
+ }
8
+ export declare class Query<TData = unknown, TError = any> {
9
+ readonly queryKey: QueryKey;
10
+ readonly queryHash: string;
11
+ cache: QueryCache;
12
+ readonly data: WritableSignal<TData | undefined>;
13
+ readonly error: WritableSignal<TError | null>;
14
+ readonly status: WritableSignal<QueryStatus>;
15
+ readonly fetchStatus: WritableSignal<FetchStatus>;
16
+ readonly dataUpdatedAt: WritableSignal<number>;
17
+ readonly errorUpdatedAt: WritableSignal<number>;
18
+ readonly failureCount: WritableSignal<number>;
19
+ readonly isInvalidated: WritableSignal<boolean>;
20
+ observers: Set<QueryObserver<TData, TError>>;
21
+ private _gcTimeout;
22
+ private _abortController;
23
+ promise: Promise<TData> | null;
24
+ defaultGcTime: number;
25
+ constructor(options: {
26
+ queryKey: QueryKey;
27
+ queryHash: string;
28
+ cache: QueryCache;
29
+ initialData?: TData | (() => TData);
30
+ initialDataUpdatedAt?: number | (() => number);
31
+ });
32
+ get state(): QueryState<TData, TError>;
33
+ isStale(staleTime?: number): boolean;
34
+ addObserver(observer: QueryObserver<TData, TError>): void;
35
+ removeObserver(observer: QueryObserver<TData, TError>): void;
36
+ scheduleGc(gcTime?: number): void;
37
+ clearGcTimeout(): void;
38
+ setData(updater: TData | ((prev: TData | undefined) => TData), options?: {
39
+ updatedAt?: number;
40
+ }): TData;
41
+ invalidate(): void;
42
+ cancel(): void;
43
+ reset(): void;
44
+ fetch(options?: Partial<QueryOptions<TData, TError, any>>, fetchOptions?: {
45
+ cancelRefetch?: boolean;
46
+ }): Promise<TData>;
47
+ private notifyObservers;
48
+ destroy(): void;
49
+ }
50
+ export declare class QueryCache {
51
+ queries: Map<string, Query<any, any>>;
52
+ private _subscribers;
53
+ subscribe(listener: (event: {
54
+ type: string;
55
+ query?: Query<any, any>;
56
+ }) => void): () => void;
57
+ notify(event: {
58
+ type: string;
59
+ query?: Query<any, any>;
60
+ }): void;
61
+ getAll(): Query<any, any>[];
62
+ build<TData, TError>(_client: QueryClient, options: QueryOptions<TData, TError, any>): Query<TData, TError>;
63
+ get<TData = unknown, TError = any>(queryHash: string): Query<TData, TError> | undefined;
64
+ add(query: Query<any, any>): void;
65
+ remove(query: Query<any, any>): void;
66
+ find<TData = unknown, TError = any>(filters: QueryFilters): Query<TData, TError> | undefined;
67
+ findAll<TData = unknown, TError = any>(filters?: QueryFilters): Query<TData, TError>[];
68
+ clear(): void;
69
+ }
@@ -0,0 +1,46 @@
1
+ import type { Child } from "../dom/render";
2
+ import { type Context } from "../signals/context";
3
+ import { MutationCache } from "./mutation-cache";
4
+ import { QueryCache } from "./query-cache";
5
+ import type { DefaultOptions, QueryFilters, QueryKey, QueryOptions, QueryState } from "./types";
6
+ export interface QueryClientConfig {
7
+ defaultOptions?: DefaultOptions;
8
+ queryCache?: QueryCache;
9
+ mutationCache?: MutationCache;
10
+ }
11
+ export declare class QueryClient {
12
+ queryCache: QueryCache;
13
+ mutationCache: MutationCache;
14
+ defaultOptions: DefaultOptions;
15
+ private _unsubscribeFocus?;
16
+ private _unsubscribeOnline?;
17
+ private _isMounted;
18
+ constructor(config?: QueryClientConfig);
19
+ mount(): void;
20
+ unmount(): void;
21
+ private onWindowFocus;
22
+ private onOnline;
23
+ getDefaultOptions(): DefaultOptions;
24
+ setDefaultOptions(options: DefaultOptions): void;
25
+ getQueryCache(): QueryCache;
26
+ getMutationCache(): MutationCache;
27
+ getQueryData<TData = unknown>(queryKey: QueryKey): TData | undefined;
28
+ setQueryData<TData = unknown>(queryKey: QueryKey, updater: TData | ((prev: TData | undefined) => TData), options?: {
29
+ updatedAt?: number;
30
+ }): TData;
31
+ getQueryState<TData = unknown, TError = any>(queryKey: QueryKey): QueryState<TData, TError> | undefined;
32
+ fetchQuery<TData = unknown, TError = any>(options: QueryOptions<TData, TError, any>): Promise<TData>;
33
+ prefetchQuery<TData = unknown, TError = any>(options: QueryOptions<TData, TError, any>): Promise<void>;
34
+ invalidateQueries(filters?: QueryFilters): Promise<void>;
35
+ refetchQueries(filters?: QueryFilters): Promise<void>;
36
+ cancelQueries(filters?: QueryFilters): void;
37
+ removeQueries(filters?: QueryFilters): void;
38
+ resetQueries(filters?: QueryFilters): Promise<void>;
39
+ clear(): void;
40
+ }
41
+ export declare const QueryClientContext: Context<QueryClient | null>;
42
+ export declare function QueryClientProvider(props: {
43
+ client: QueryClient;
44
+ children: Child;
45
+ }): any;
46
+ export declare function useQueryClient(client?: QueryClient): QueryClient;
@@ -0,0 +1,131 @@
1
+ import type { ReadonlySignal } from "../signals";
2
+ export type QueryKey = readonly unknown[];
3
+ export interface QueryFunctionContext<TQueryKey extends QueryKey = QueryKey, TPageParam = any> {
4
+ queryKey: TQueryKey;
5
+ signal: AbortSignal;
6
+ pageParam?: TPageParam;
7
+ meta?: Record<string, unknown>;
8
+ }
9
+ export type QueryFunction<TData = unknown, TQueryKey extends QueryKey = QueryKey, TPageParam = any> = (context: QueryFunctionContext<TQueryKey, TPageParam>) => Promise<TData> | TData;
10
+ export type QueryStatus = "pending" | "success" | "error";
11
+ export type FetchStatus = "fetching" | "paused" | "idle";
12
+ export type MutationStatus = "idle" | "pending" | "success" | "error";
13
+ export type RetryValue = boolean | number | ((failureCount: number, error: any) => boolean);
14
+ export type RetryDelayValue = number | ((attemptIndex: number, error: any) => number);
15
+ export interface QueryFilters {
16
+ queryKey?: QueryKey;
17
+ exact?: boolean;
18
+ type?: "all" | "active" | "inactive";
19
+ stale?: boolean;
20
+ fetchStatus?: FetchStatus;
21
+ predicate?: (query: any) => boolean;
22
+ }
23
+ export interface QueryState<TData = unknown, TError = any> {
24
+ data: TData | undefined;
25
+ error: TError | null;
26
+ status: QueryStatus;
27
+ fetchStatus: FetchStatus;
28
+ dataUpdatedAt: number;
29
+ errorUpdatedAt: number;
30
+ failureCount: number;
31
+ isInvalidated: boolean;
32
+ }
33
+ export interface QueryOptions<TData = unknown, _TError = any, TQueryKey extends QueryKey = QueryKey> {
34
+ queryKey: TQueryKey;
35
+ queryFn?: QueryFunction<TData, TQueryKey>;
36
+ enabled?: boolean | (() => boolean);
37
+ staleTime?: number;
38
+ gcTime?: number;
39
+ retry?: RetryValue;
40
+ retryDelay?: RetryDelayValue;
41
+ refetchInterval?: number | false | (() => number | false);
42
+ refetchIntervalInBackground?: boolean;
43
+ refetchOnWindowFocus?: boolean | "always";
44
+ refetchOnReconnect?: boolean | "always";
45
+ initialData?: TData | (() => TData);
46
+ initialDataUpdatedAt?: number | (() => number);
47
+ placeholderData?: TData | ((previousData: TData | undefined) => TData);
48
+ meta?: Record<string, unknown>;
49
+ }
50
+ export interface CreateQueryOptions<TData = unknown, TError = any, TSelected = TData, TQueryKey extends QueryKey = QueryKey> extends QueryOptions<TData, TError, TQueryKey> {
51
+ select?: (data: TData) => TSelected;
52
+ suspense?: boolean;
53
+ }
54
+ export interface RefetchOptions {
55
+ throwOnError?: boolean;
56
+ cancelRefetch?: boolean;
57
+ }
58
+ export interface QueryResult<TData = unknown, TError = any> {
59
+ data: ReadonlySignal<TData | undefined>;
60
+ error: ReadonlySignal<TError | null>;
61
+ status: ReadonlySignal<QueryStatus>;
62
+ fetchStatus: ReadonlySignal<FetchStatus>;
63
+ isLoading: ReadonlySignal<boolean>;
64
+ isFetching: ReadonlySignal<boolean>;
65
+ isSuccess: ReadonlySignal<boolean>;
66
+ isError: ReadonlySignal<boolean>;
67
+ isStale: ReadonlySignal<boolean>;
68
+ dataUpdatedAt: ReadonlySignal<number>;
69
+ errorUpdatedAt: ReadonlySignal<number>;
70
+ refetch: (options?: RefetchOptions) => Promise<TData | undefined>;
71
+ (): TData | undefined;
72
+ }
73
+ export type MutationFunction<TData = unknown, TVariables = void> = (variables: TVariables) => Promise<TData>;
74
+ export interface MutationOptions<TData = unknown, TError = any, TVariables = void, TContext = unknown> {
75
+ mutationKey?: QueryKey;
76
+ mutationFn: MutationFunction<TData, TVariables>;
77
+ onMutate?: (variables: TVariables) => Promise<TContext | void> | TContext | void;
78
+ onSuccess?: (data: TData, variables: TVariables, context: TContext | undefined) => Promise<void> | void;
79
+ onError?: (error: TError, variables: TVariables, context: TContext | undefined) => Promise<void> | void;
80
+ onSettled?: (data: TData | undefined, error: TError | null, variables: TVariables, context: TContext | undefined) => Promise<void> | void;
81
+ retry?: RetryValue;
82
+ retryDelay?: RetryDelayValue;
83
+ meta?: Record<string, unknown>;
84
+ }
85
+ export interface MutateOptions<TData = unknown, TError = any, TVariables = void, TContext = unknown> {
86
+ onSuccess?: (data: TData, variables: TVariables, context: TContext | undefined) => void;
87
+ onError?: (error: TError, variables: TVariables, context: TContext | undefined) => void;
88
+ onSettled?: (data: TData | undefined, error: TError | null, variables: TVariables, context: TContext | undefined) => void;
89
+ }
90
+ export interface MutationResult<TData = unknown, TError = any, TVariables = void, TContext = unknown> {
91
+ mutate: (variables: TVariables, options?: MutateOptions<TData, TError, TVariables, TContext>) => void;
92
+ mutateAsync: (variables: TVariables, options?: MutateOptions<TData, TError, TVariables, TContext>) => Promise<TData>;
93
+ data: ReadonlySignal<TData | undefined>;
94
+ error: ReadonlySignal<TError | null>;
95
+ status: ReadonlySignal<MutationStatus>;
96
+ isIdle: ReadonlySignal<boolean>;
97
+ isPending: ReadonlySignal<boolean>;
98
+ isLoading: ReadonlySignal<boolean>;
99
+ isSuccess: ReadonlySignal<boolean>;
100
+ isError: ReadonlySignal<boolean>;
101
+ reset: () => void;
102
+ variables: ReadonlySignal<TVariables | undefined>;
103
+ submittedAt: ReadonlySignal<number>;
104
+ (): TData | undefined;
105
+ }
106
+ export interface InfiniteData<TData = unknown, TPageParam = unknown> {
107
+ pages: TData[];
108
+ pageParams: TPageParam[];
109
+ }
110
+ export interface InfiniteQueryOptions<TData = unknown, TError = any, TPageParam = unknown, TSelected = InfiniteData<TData, TPageParam>, TQueryKey extends QueryKey = QueryKey> extends Omit<QueryOptions<InfiniteData<TData, TPageParam>, TError, TQueryKey>, "queryFn"> {
111
+ queryFn?: (context: QueryFunctionContext<TQueryKey, TPageParam>) => Promise<TData> | TData;
112
+ initialPageParam: TPageParam;
113
+ getNextPageParam: (lastPage: TData, allPages: TData[], lastPageParam: TPageParam, allPageParams: TPageParam[]) => TPageParam | undefined | null;
114
+ getPreviousPageParam?: (firstPage: TData, allPages: TData[], firstPageParam: TPageParam, allPageParams: TPageParam[]) => TPageParam | undefined | null;
115
+ maxPages?: number;
116
+ select?: (data: InfiniteData<TData, TPageParam>) => TSelected;
117
+ suspense?: boolean;
118
+ }
119
+ export interface InfiniteQueryResult<TData = unknown, TError = any, TPageParam = unknown> extends Omit<QueryResult<InfiniteData<TData, TPageParam>, TError>, "refetch"> {
120
+ fetchNextPage: () => Promise<InfiniteData<TData, TPageParam> | undefined>;
121
+ fetchPreviousPage: () => Promise<InfiniteData<TData, TPageParam> | undefined>;
122
+ hasNextPage: ReadonlySignal<boolean>;
123
+ hasPreviousPage: ReadonlySignal<boolean>;
124
+ isFetchingNextPage: ReadonlySignal<boolean>;
125
+ isFetchingPreviousPage: ReadonlySignal<boolean>;
126
+ refetch: (options?: RefetchOptions) => Promise<InfiniteData<TData, TPageParam> | undefined>;
127
+ }
128
+ export interface DefaultOptions {
129
+ queries?: Partial<QueryOptions<any, any, any>>;
130
+ mutations?: Partial<MutationOptions<any, any, any, any>>;
131
+ }
@@ -0,0 +1,16 @@
1
+ import type { QueryFilters } from "./types";
2
+ export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
3
+ /**
4
+ * Deterministic JSON stringifier for consistent query key hashing
5
+ */
6
+ export declare function hashKey(queryKey: unknown): string;
7
+ /**
8
+ * Deep equality check for primitives, arrays, and objects
9
+ */
10
+ export declare function deepEqual(a: unknown, b: unknown): boolean;
11
+ /**
12
+ * Partial matching check: matches if `a` is a subset or partial structure of `b`
13
+ */
14
+ export declare function partialDeepEqual(a: unknown, b: unknown): boolean;
15
+ export declare function matchQuery(filters: QueryFilters | undefined, query: any): boolean;
16
+ export declare function sleep(ms: number): Promise<void>;
@@ -0,0 +1 @@
1
+ export { Link, type LinkProps, type LocationState, lazy, type MatchedRoute, Route, type RouteDefinition, type RouteProps, Router, type RouterContextValue, type RouterProps, Routes, type RoutesProps, useLocation, useNavigate, useParams, useSearchParams } from "./router";