pelatform-ui 1.2.5 → 1.2.8
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.
- package/dist/components.d.ts +18 -4
- package/dist/components.js +178 -2130
- package/dist/index.d.ts +1 -5
- package/dist/index.js +1 -14
- package/dist/utils.d.ts +6 -0
- package/dist/utils.js +14 -0
- package/package.json +16 -15
- /package/dist/{chunk-7EOSDFS3.js → chunk-QEWGMDVY.js} +0 -0
package/dist/components.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-NOAZYT3J.js";
|
|
5
5
|
import {
|
|
6
6
|
cn
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-QEWGMDVY.js";
|
|
8
8
|
import {
|
|
9
9
|
DEFAULT_THEME_MODE,
|
|
10
10
|
THEME_MODES
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
TriangleAlertIcon
|
|
21
21
|
} from "lucide-react";
|
|
22
22
|
import { toast } from "sonner";
|
|
23
|
-
import { Alert, AlertTitle } from "@pelatform/ui.components/
|
|
23
|
+
import { Alert, AlertTitle } from "@pelatform/ui.components/radix";
|
|
24
24
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
25
25
|
var iconMap = {
|
|
26
26
|
primary: /* @__PURE__ */ jsx(CircleAlertIcon, {}),
|
|
@@ -98,7 +98,7 @@ import {
|
|
|
98
98
|
AlertDialogFooter,
|
|
99
99
|
AlertDialogHeader,
|
|
100
100
|
AlertDialogTitle
|
|
101
|
-
} from "@pelatform/ui.components/
|
|
101
|
+
} from "@pelatform/ui.components/radix";
|
|
102
102
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
103
103
|
var ConfirmDismissDialog = ({
|
|
104
104
|
open,
|
|
@@ -136,13 +136,13 @@ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
|
136
136
|
function ScreenLoader({
|
|
137
137
|
loadingText = "Loading...",
|
|
138
138
|
className = "",
|
|
139
|
-
spinnerClassName
|
|
139
|
+
spinnerClassName,
|
|
140
140
|
textClassName = "text-muted-foreground font-medium text-sm",
|
|
141
141
|
contentLoader = false
|
|
142
142
|
} = {}) {
|
|
143
143
|
if (contentLoader) {
|
|
144
144
|
return /* @__PURE__ */ jsx3("div", { className: cn("flex w-full grow items-center justify-center", className), children: /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2.5", children: [
|
|
145
|
-
/* @__PURE__ */ jsx3(LoaderIcon, { className: cn("animate-spin", spinnerClassName) }),
|
|
145
|
+
/* @__PURE__ */ jsx3(LoaderIcon, { className: cn("size-6 animate-spin", spinnerClassName) }),
|
|
146
146
|
/* @__PURE__ */ jsx3("span", { className: textClassName, children: loadingText })
|
|
147
147
|
] }) });
|
|
148
148
|
}
|
|
@@ -157,7 +157,7 @@ function ScreenLoader({
|
|
|
157
157
|
"aria-live": "polite",
|
|
158
158
|
"aria-label": loadingText,
|
|
159
159
|
children: [
|
|
160
|
-
/* @__PURE__ */ jsx3(LoaderIcon, { className: cn("animate-spin", spinnerClassName) }),
|
|
160
|
+
/* @__PURE__ */ jsx3(LoaderIcon, { className: cn("size-6 animate-spin", spinnerClassName) }),
|
|
161
161
|
/* @__PURE__ */ jsx3("div", { className: textClassName, children: loadingText })
|
|
162
162
|
]
|
|
163
163
|
}
|
|
@@ -165,7 +165,7 @@ function ScreenLoader({
|
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
// src/components/layout/auth.tsx
|
|
168
|
-
import { Card, CardContent } from "@pelatform/ui.components/
|
|
168
|
+
import { Card, CardContent } from "@pelatform/ui.components/radix";
|
|
169
169
|
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
170
170
|
function LayoutAuth({
|
|
171
171
|
children,
|
|
@@ -297,7 +297,7 @@ function ComingSoon({ className, title, description }) {
|
|
|
297
297
|
}
|
|
298
298
|
|
|
299
299
|
// src/components/layout/error.tsx
|
|
300
|
-
import { Badge } from "@pelatform/ui.components/
|
|
300
|
+
import { Badge } from "@pelatform/ui.components/radix";
|
|
301
301
|
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
302
302
|
function ErrorComponents({
|
|
303
303
|
className,
|
|
@@ -327,7 +327,7 @@ function ErrorComponents({
|
|
|
327
327
|
}
|
|
328
328
|
)
|
|
329
329
|
] }),
|
|
330
|
-
/* @__PURE__ */ jsx9(Badge, { variant: "destructive", className: "mb-3", children: "404 Error" }),
|
|
330
|
+
/* @__PURE__ */ jsx9(Badge, { variant: "destructive-outline", className: "mb-3", children: "404 Error" }),
|
|
331
331
|
/* @__PURE__ */ jsx9("h3", { className: "mb-2 text-center font-semibold text-2xl text-foreground", children: textTitle }),
|
|
332
332
|
/* @__PURE__ */ jsx9("div", { className: "mb-10 text-center text-base text-secondary-foreground", children: textSubtitle })
|
|
333
333
|
] });
|
|
@@ -352,7 +352,7 @@ function ErrorComponents({
|
|
|
352
352
|
}
|
|
353
353
|
)
|
|
354
354
|
] }),
|
|
355
|
-
/* @__PURE__ */ jsx9(Badge, { variant: "destructive", className: "mb-3", children: "500 Error" }),
|
|
355
|
+
/* @__PURE__ */ jsx9(Badge, { variant: "destructive-outline", className: "mb-3", children: "500 Error" }),
|
|
356
356
|
/* @__PURE__ */ jsx9("h3", { className: "mb-2 text-center font-semibold text-2xl text-foreground", children: textTitle }),
|
|
357
357
|
/* @__PURE__ */ jsx9("div", { className: "mb-10 text-center text-base text-secondary-foreground", children: textSubtitle }),
|
|
358
358
|
button
|
|
@@ -484,7 +484,7 @@ function CodeDisplay({
|
|
|
484
484
|
|
|
485
485
|
// src/components/mdx/download.tsx
|
|
486
486
|
import { DownloadIcon } from "lucide-react";
|
|
487
|
-
import { Button } from "@pelatform/ui.components/
|
|
487
|
+
import { Button } from "@pelatform/ui.components/radix";
|
|
488
488
|
import { jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
489
489
|
function DownloadFile({ children, className, href }) {
|
|
490
490
|
return /* @__PURE__ */ jsx16("div", { className: "inline-flex pb-4", children: /* @__PURE__ */ jsx16(Button, { size: "lg", className: cn("rounded-full", className), children: /* @__PURE__ */ jsxs12("a", { href, target: "_blank", rel: "noopener noreferrer", children: [
|
|
@@ -565,7 +565,7 @@ function Youtube({ id }) {
|
|
|
565
565
|
|
|
566
566
|
// src/components/navigation/back-link.tsx
|
|
567
567
|
import { ChevronLeftIcon } from "lucide-react";
|
|
568
|
-
import { Button as Button2 } from "@pelatform/ui.components/
|
|
568
|
+
import { Button as Button2 } from "@pelatform/ui.components/radix";
|
|
569
569
|
import { jsx as jsx22, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
570
570
|
function BackLink({ Link = DefaultLink, children, href, className }) {
|
|
571
571
|
return /* @__PURE__ */ jsxs13(
|
|
@@ -595,7 +595,7 @@ function BackLink({ Link = DefaultLink, children, href, className }) {
|
|
|
595
595
|
// src/components/navigation/command-menu.tsx
|
|
596
596
|
import * as React from "react";
|
|
597
597
|
import { SearchIcon } from "lucide-react";
|
|
598
|
-
import { Button as Button3, CommandDialog, CommandInput, CommandList } from "@pelatform/ui.components/
|
|
598
|
+
import { Button as Button3, CommandDialog, CommandInput, CommandList } from "@pelatform/ui.components/radix";
|
|
599
599
|
import { Fragment as Fragment2, jsx as jsx23, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
600
600
|
function CommandMenu({
|
|
601
601
|
children,
|
|
@@ -680,7 +680,7 @@ import {
|
|
|
680
680
|
DropdownMenuSubContent,
|
|
681
681
|
DropdownMenuSubTrigger,
|
|
682
682
|
DropdownMenuTrigger
|
|
683
|
-
} from "@pelatform/ui.components/
|
|
683
|
+
} from "@pelatform/ui.components/radix";
|
|
684
684
|
import { jsx as jsx24, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
685
685
|
function MainNav({ Link = DefaultLink, pathname, items, className }) {
|
|
686
686
|
return /* @__PURE__ */ jsx24("div", { className: cn("me-4 hidden items-center justify-center md:flex", className), children: /* @__PURE__ */ jsx24("nav", { className: "flex items-center gap-4 font-medium text-sm xl:gap-6", children: items.map((item) => /* @__PURE__ */ jsx24(NavItemRenderer, { Link, item, pathname, level: 1 }, item.title)) }) });
|
|
@@ -694,7 +694,7 @@ function NavItemRenderer({ Link = DefaultLink, item, pathname, level }) {
|
|
|
694
694
|
) ?? false : item.href === pathname || item.href !== "/" && item.href && pathname?.startsWith(item.href);
|
|
695
695
|
if (hasChildren && level <= 3) {
|
|
696
696
|
return /* @__PURE__ */ jsxs15(DropdownMenu, { children: [
|
|
697
|
-
/* @__PURE__ */ jsx24(DropdownMenuTrigger, { children: /* @__PURE__ */ jsxs15(
|
|
697
|
+
/* @__PURE__ */ jsx24(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs15(
|
|
698
698
|
"button",
|
|
699
699
|
{
|
|
700
700
|
className: cn(
|
|
@@ -777,7 +777,7 @@ function ChildNavItemRenderer({ Link = DefaultLink, item, pathname, level }) {
|
|
|
777
777
|
)) })
|
|
778
778
|
] });
|
|
779
779
|
}
|
|
780
|
-
return /* @__PURE__ */ jsx24(DropdownMenuItem, { children: /* @__PURE__ */ jsxs15(
|
|
780
|
+
return /* @__PURE__ */ jsx24(DropdownMenuItem, { asChild: true, children: /* @__PURE__ */ jsxs15(
|
|
781
781
|
Link,
|
|
782
782
|
{
|
|
783
783
|
href: item.href || "",
|
|
@@ -808,7 +808,7 @@ import {
|
|
|
808
808
|
DrawerDescription,
|
|
809
809
|
DrawerTitle,
|
|
810
810
|
DrawerTrigger
|
|
811
|
-
} from "@pelatform/ui.components/
|
|
811
|
+
} from "@pelatform/ui.components/radix";
|
|
812
812
|
import { jsx as jsx25, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
813
813
|
function MobileNav({ children, className }) {
|
|
814
814
|
const { setMetaColor, metaColor } = useMetaColor();
|
|
@@ -911,2013 +911,11 @@ function MobileNavItemRenderer({
|
|
|
911
911
|
|
|
912
912
|
// src/components/providers/query-provider.tsx
|
|
913
913
|
import { useState as useState3 } from "react";
|
|
914
|
-
|
|
915
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/subscribable.js
|
|
916
|
-
var Subscribable = class {
|
|
917
|
-
constructor() {
|
|
918
|
-
this.listeners = /* @__PURE__ */ new Set();
|
|
919
|
-
this.subscribe = this.subscribe.bind(this);
|
|
920
|
-
}
|
|
921
|
-
subscribe(listener) {
|
|
922
|
-
this.listeners.add(listener);
|
|
923
|
-
this.onSubscribe();
|
|
924
|
-
return () => {
|
|
925
|
-
this.listeners.delete(listener);
|
|
926
|
-
this.onUnsubscribe();
|
|
927
|
-
};
|
|
928
|
-
}
|
|
929
|
-
hasListeners() {
|
|
930
|
-
return this.listeners.size > 0;
|
|
931
|
-
}
|
|
932
|
-
onSubscribe() {
|
|
933
|
-
}
|
|
934
|
-
onUnsubscribe() {
|
|
935
|
-
}
|
|
936
|
-
};
|
|
937
|
-
|
|
938
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/timeoutManager.js
|
|
939
|
-
var defaultTimeoutProvider = {
|
|
940
|
-
// We need the wrapper function syntax below instead of direct references to
|
|
941
|
-
// global setTimeout etc.
|
|
942
|
-
//
|
|
943
|
-
// BAD: `setTimeout: setTimeout`
|
|
944
|
-
// GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`
|
|
945
|
-
//
|
|
946
|
-
// If we use direct references here, then anything that wants to spy on or
|
|
947
|
-
// replace the global setTimeout (like tests) won't work since we'll already
|
|
948
|
-
// have a hard reference to the original implementation at the time when this
|
|
949
|
-
// file was imported.
|
|
950
|
-
setTimeout: (callback, delay) => setTimeout(callback, delay),
|
|
951
|
-
clearTimeout: (timeoutId) => clearTimeout(timeoutId),
|
|
952
|
-
setInterval: (callback, delay) => setInterval(callback, delay),
|
|
953
|
-
clearInterval: (intervalId) => clearInterval(intervalId)
|
|
954
|
-
};
|
|
955
|
-
var TimeoutManager = class {
|
|
956
|
-
// We cannot have TimeoutManager<T> as we must instantiate it with a concrete
|
|
957
|
-
// type at app boot; and if we leave that type, then any new timer provider
|
|
958
|
-
// would need to support ReturnType<typeof setTimeout>, which is infeasible.
|
|
959
|
-
//
|
|
960
|
-
// We settle for type safety for the TimeoutProvider type, and accept that
|
|
961
|
-
// this class is unsafe internally to allow for extension.
|
|
962
|
-
#provider = defaultTimeoutProvider;
|
|
963
|
-
#providerCalled = false;
|
|
964
|
-
setTimeoutProvider(provider) {
|
|
965
|
-
if (process.env.NODE_ENV !== "production") {
|
|
966
|
-
if (this.#providerCalled && provider !== this.#provider) {
|
|
967
|
-
console.error(
|
|
968
|
-
`[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`,
|
|
969
|
-
{ previous: this.#provider, provider }
|
|
970
|
-
);
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
this.#provider = provider;
|
|
974
|
-
if (process.env.NODE_ENV !== "production") {
|
|
975
|
-
this.#providerCalled = false;
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
setTimeout(callback, delay) {
|
|
979
|
-
if (process.env.NODE_ENV !== "production") {
|
|
980
|
-
this.#providerCalled = true;
|
|
981
|
-
}
|
|
982
|
-
return this.#provider.setTimeout(callback, delay);
|
|
983
|
-
}
|
|
984
|
-
clearTimeout(timeoutId) {
|
|
985
|
-
this.#provider.clearTimeout(timeoutId);
|
|
986
|
-
}
|
|
987
|
-
setInterval(callback, delay) {
|
|
988
|
-
if (process.env.NODE_ENV !== "production") {
|
|
989
|
-
this.#providerCalled = true;
|
|
990
|
-
}
|
|
991
|
-
return this.#provider.setInterval(callback, delay);
|
|
992
|
-
}
|
|
993
|
-
clearInterval(intervalId) {
|
|
994
|
-
this.#provider.clearInterval(intervalId);
|
|
995
|
-
}
|
|
996
|
-
};
|
|
997
|
-
var timeoutManager = new TimeoutManager();
|
|
998
|
-
function systemSetTimeoutZero(callback) {
|
|
999
|
-
setTimeout(callback, 0);
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/utils.js
|
|
1003
|
-
var isServer = typeof window === "undefined" || "Deno" in globalThis;
|
|
1004
|
-
function noop() {
|
|
1005
|
-
}
|
|
1006
|
-
function functionalUpdate(updater, input) {
|
|
1007
|
-
return typeof updater === "function" ? updater(input) : updater;
|
|
1008
|
-
}
|
|
1009
|
-
function isValidTimeout(value) {
|
|
1010
|
-
return typeof value === "number" && value >= 0 && value !== Infinity;
|
|
1011
|
-
}
|
|
1012
|
-
function timeUntilStale(updatedAt, staleTime) {
|
|
1013
|
-
return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
|
|
1014
|
-
}
|
|
1015
|
-
function resolveStaleTime(staleTime, query) {
|
|
1016
|
-
return typeof staleTime === "function" ? staleTime(query) : staleTime;
|
|
1017
|
-
}
|
|
1018
|
-
function resolveEnabled(enabled, query) {
|
|
1019
|
-
return typeof enabled === "function" ? enabled(query) : enabled;
|
|
1020
|
-
}
|
|
1021
|
-
function matchQuery(filters, query) {
|
|
1022
|
-
const {
|
|
1023
|
-
type = "all",
|
|
1024
|
-
exact,
|
|
1025
|
-
fetchStatus,
|
|
1026
|
-
predicate,
|
|
1027
|
-
queryKey,
|
|
1028
|
-
stale
|
|
1029
|
-
} = filters;
|
|
1030
|
-
if (queryKey) {
|
|
1031
|
-
if (exact) {
|
|
1032
|
-
if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) {
|
|
1033
|
-
return false;
|
|
1034
|
-
}
|
|
1035
|
-
} else if (!partialMatchKey(query.queryKey, queryKey)) {
|
|
1036
|
-
return false;
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
|
-
if (type !== "all") {
|
|
1040
|
-
const isActive = query.isActive();
|
|
1041
|
-
if (type === "active" && !isActive) {
|
|
1042
|
-
return false;
|
|
1043
|
-
}
|
|
1044
|
-
if (type === "inactive" && isActive) {
|
|
1045
|
-
return false;
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
if (typeof stale === "boolean" && query.isStale() !== stale) {
|
|
1049
|
-
return false;
|
|
1050
|
-
}
|
|
1051
|
-
if (fetchStatus && fetchStatus !== query.state.fetchStatus) {
|
|
1052
|
-
return false;
|
|
1053
|
-
}
|
|
1054
|
-
if (predicate && !predicate(query)) {
|
|
1055
|
-
return false;
|
|
1056
|
-
}
|
|
1057
|
-
return true;
|
|
1058
|
-
}
|
|
1059
|
-
function matchMutation(filters, mutation) {
|
|
1060
|
-
const { exact, status, predicate, mutationKey } = filters;
|
|
1061
|
-
if (mutationKey) {
|
|
1062
|
-
if (!mutation.options.mutationKey) {
|
|
1063
|
-
return false;
|
|
1064
|
-
}
|
|
1065
|
-
if (exact) {
|
|
1066
|
-
if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) {
|
|
1067
|
-
return false;
|
|
1068
|
-
}
|
|
1069
|
-
} else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) {
|
|
1070
|
-
return false;
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
if (status && mutation.state.status !== status) {
|
|
1074
|
-
return false;
|
|
1075
|
-
}
|
|
1076
|
-
if (predicate && !predicate(mutation)) {
|
|
1077
|
-
return false;
|
|
1078
|
-
}
|
|
1079
|
-
return true;
|
|
1080
|
-
}
|
|
1081
|
-
function hashQueryKeyByOptions(queryKey, options) {
|
|
1082
|
-
const hashFn = options?.queryKeyHashFn || hashKey;
|
|
1083
|
-
return hashFn(queryKey);
|
|
1084
|
-
}
|
|
1085
|
-
function hashKey(queryKey) {
|
|
1086
|
-
return JSON.stringify(
|
|
1087
|
-
queryKey,
|
|
1088
|
-
(_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => {
|
|
1089
|
-
result[key] = val[key];
|
|
1090
|
-
return result;
|
|
1091
|
-
}, {}) : val
|
|
1092
|
-
);
|
|
1093
|
-
}
|
|
1094
|
-
function partialMatchKey(a, b) {
|
|
1095
|
-
if (a === b) {
|
|
1096
|
-
return true;
|
|
1097
|
-
}
|
|
1098
|
-
if (typeof a !== typeof b) {
|
|
1099
|
-
return false;
|
|
1100
|
-
}
|
|
1101
|
-
if (a && b && typeof a === "object" && typeof b === "object") {
|
|
1102
|
-
return Object.keys(b).every((key) => partialMatchKey(a[key], b[key]));
|
|
1103
|
-
}
|
|
1104
|
-
return false;
|
|
1105
|
-
}
|
|
1106
|
-
var hasOwn = Object.prototype.hasOwnProperty;
|
|
1107
|
-
function replaceEqualDeep(a, b, depth = 0) {
|
|
1108
|
-
if (a === b) {
|
|
1109
|
-
return a;
|
|
1110
|
-
}
|
|
1111
|
-
if (depth > 500) return b;
|
|
1112
|
-
const array = isPlainArray(a) && isPlainArray(b);
|
|
1113
|
-
if (!array && !(isPlainObject(a) && isPlainObject(b))) return b;
|
|
1114
|
-
const aItems = array ? a : Object.keys(a);
|
|
1115
|
-
const aSize = aItems.length;
|
|
1116
|
-
const bItems = array ? b : Object.keys(b);
|
|
1117
|
-
const bSize = bItems.length;
|
|
1118
|
-
const copy = array ? new Array(bSize) : {};
|
|
1119
|
-
let equalItems = 0;
|
|
1120
|
-
for (let i = 0; i < bSize; i++) {
|
|
1121
|
-
const key = array ? i : bItems[i];
|
|
1122
|
-
const aItem = a[key];
|
|
1123
|
-
const bItem = b[key];
|
|
1124
|
-
if (aItem === bItem) {
|
|
1125
|
-
copy[key] = aItem;
|
|
1126
|
-
if (array ? i < aSize : hasOwn.call(a, key)) equalItems++;
|
|
1127
|
-
continue;
|
|
1128
|
-
}
|
|
1129
|
-
if (aItem === null || bItem === null || typeof aItem !== "object" || typeof bItem !== "object") {
|
|
1130
|
-
copy[key] = bItem;
|
|
1131
|
-
continue;
|
|
1132
|
-
}
|
|
1133
|
-
const v = replaceEqualDeep(aItem, bItem, depth + 1);
|
|
1134
|
-
copy[key] = v;
|
|
1135
|
-
if (v === aItem) equalItems++;
|
|
1136
|
-
}
|
|
1137
|
-
return aSize === bSize && equalItems === aSize ? a : copy;
|
|
1138
|
-
}
|
|
1139
|
-
function isPlainArray(value) {
|
|
1140
|
-
return Array.isArray(value) && value.length === Object.keys(value).length;
|
|
1141
|
-
}
|
|
1142
|
-
function isPlainObject(o) {
|
|
1143
|
-
if (!hasObjectPrototype(o)) {
|
|
1144
|
-
return false;
|
|
1145
|
-
}
|
|
1146
|
-
const ctor = o.constructor;
|
|
1147
|
-
if (ctor === void 0) {
|
|
1148
|
-
return true;
|
|
1149
|
-
}
|
|
1150
|
-
const prot = ctor.prototype;
|
|
1151
|
-
if (!hasObjectPrototype(prot)) {
|
|
1152
|
-
return false;
|
|
1153
|
-
}
|
|
1154
|
-
if (!prot.hasOwnProperty("isPrototypeOf")) {
|
|
1155
|
-
return false;
|
|
1156
|
-
}
|
|
1157
|
-
if (Object.getPrototypeOf(o) !== Object.prototype) {
|
|
1158
|
-
return false;
|
|
1159
|
-
}
|
|
1160
|
-
return true;
|
|
1161
|
-
}
|
|
1162
|
-
function hasObjectPrototype(o) {
|
|
1163
|
-
return Object.prototype.toString.call(o) === "[object Object]";
|
|
1164
|
-
}
|
|
1165
|
-
function sleep(timeout) {
|
|
1166
|
-
return new Promise((resolve) => {
|
|
1167
|
-
timeoutManager.setTimeout(resolve, timeout);
|
|
1168
|
-
});
|
|
1169
|
-
}
|
|
1170
|
-
function replaceData(prevData, data, options) {
|
|
1171
|
-
if (typeof options.structuralSharing === "function") {
|
|
1172
|
-
return options.structuralSharing(prevData, data);
|
|
1173
|
-
} else if (options.structuralSharing !== false) {
|
|
1174
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1175
|
-
try {
|
|
1176
|
-
return replaceEqualDeep(prevData, data);
|
|
1177
|
-
} catch (error) {
|
|
1178
|
-
console.error(
|
|
1179
|
-
`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${options.queryHash}]: ${error}`
|
|
1180
|
-
);
|
|
1181
|
-
throw error;
|
|
1182
|
-
}
|
|
1183
|
-
}
|
|
1184
|
-
return replaceEqualDeep(prevData, data);
|
|
1185
|
-
}
|
|
1186
|
-
return data;
|
|
1187
|
-
}
|
|
1188
|
-
function addToEnd(items, item, max = 0) {
|
|
1189
|
-
const newItems = [...items, item];
|
|
1190
|
-
return max && newItems.length > max ? newItems.slice(1) : newItems;
|
|
1191
|
-
}
|
|
1192
|
-
function addToStart(items, item, max = 0) {
|
|
1193
|
-
const newItems = [item, ...items];
|
|
1194
|
-
return max && newItems.length > max ? newItems.slice(0, -1) : newItems;
|
|
1195
|
-
}
|
|
1196
|
-
var skipToken = /* @__PURE__ */ Symbol();
|
|
1197
|
-
function ensureQueryFn(options, fetchOptions) {
|
|
1198
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1199
|
-
if (options.queryFn === skipToken) {
|
|
1200
|
-
console.error(
|
|
1201
|
-
`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${options.queryHash}'`
|
|
1202
|
-
);
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
|
-
if (!options.queryFn && fetchOptions?.initialPromise) {
|
|
1206
|
-
return () => fetchOptions.initialPromise;
|
|
1207
|
-
}
|
|
1208
|
-
if (!options.queryFn || options.queryFn === skipToken) {
|
|
1209
|
-
return () => Promise.reject(new Error(`Missing queryFn: '${options.queryHash}'`));
|
|
1210
|
-
}
|
|
1211
|
-
return options.queryFn;
|
|
1212
|
-
}
|
|
1213
|
-
function addConsumeAwareSignal(object, getSignal, onCancelled) {
|
|
1214
|
-
let consumed = false;
|
|
1215
|
-
let signal;
|
|
1216
|
-
Object.defineProperty(object, "signal", {
|
|
1217
|
-
enumerable: true,
|
|
1218
|
-
get: () => {
|
|
1219
|
-
signal ??= getSignal();
|
|
1220
|
-
if (consumed) {
|
|
1221
|
-
return signal;
|
|
1222
|
-
}
|
|
1223
|
-
consumed = true;
|
|
1224
|
-
if (signal.aborted) {
|
|
1225
|
-
onCancelled();
|
|
1226
|
-
} else {
|
|
1227
|
-
signal.addEventListener("abort", onCancelled, { once: true });
|
|
1228
|
-
}
|
|
1229
|
-
return signal;
|
|
1230
|
-
}
|
|
1231
|
-
});
|
|
1232
|
-
return object;
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1235
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/focusManager.js
|
|
1236
|
-
var FocusManager = class extends Subscribable {
|
|
1237
|
-
#focused;
|
|
1238
|
-
#cleanup;
|
|
1239
|
-
#setup;
|
|
1240
|
-
constructor() {
|
|
1241
|
-
super();
|
|
1242
|
-
this.#setup = (onFocus) => {
|
|
1243
|
-
if (!isServer && window.addEventListener) {
|
|
1244
|
-
const listener = () => onFocus();
|
|
1245
|
-
window.addEventListener("visibilitychange", listener, false);
|
|
1246
|
-
return () => {
|
|
1247
|
-
window.removeEventListener("visibilitychange", listener);
|
|
1248
|
-
};
|
|
1249
|
-
}
|
|
1250
|
-
return;
|
|
1251
|
-
};
|
|
1252
|
-
}
|
|
1253
|
-
onSubscribe() {
|
|
1254
|
-
if (!this.#cleanup) {
|
|
1255
|
-
this.setEventListener(this.#setup);
|
|
1256
|
-
}
|
|
1257
|
-
}
|
|
1258
|
-
onUnsubscribe() {
|
|
1259
|
-
if (!this.hasListeners()) {
|
|
1260
|
-
this.#cleanup?.();
|
|
1261
|
-
this.#cleanup = void 0;
|
|
1262
|
-
}
|
|
1263
|
-
}
|
|
1264
|
-
setEventListener(setup) {
|
|
1265
|
-
this.#setup = setup;
|
|
1266
|
-
this.#cleanup?.();
|
|
1267
|
-
this.#cleanup = setup((focused) => {
|
|
1268
|
-
if (typeof focused === "boolean") {
|
|
1269
|
-
this.setFocused(focused);
|
|
1270
|
-
} else {
|
|
1271
|
-
this.onFocus();
|
|
1272
|
-
}
|
|
1273
|
-
});
|
|
1274
|
-
}
|
|
1275
|
-
setFocused(focused) {
|
|
1276
|
-
const changed = this.#focused !== focused;
|
|
1277
|
-
if (changed) {
|
|
1278
|
-
this.#focused = focused;
|
|
1279
|
-
this.onFocus();
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
onFocus() {
|
|
1283
|
-
const isFocused = this.isFocused();
|
|
1284
|
-
this.listeners.forEach((listener) => {
|
|
1285
|
-
listener(isFocused);
|
|
1286
|
-
});
|
|
1287
|
-
}
|
|
1288
|
-
isFocused() {
|
|
1289
|
-
if (typeof this.#focused === "boolean") {
|
|
1290
|
-
return this.#focused;
|
|
1291
|
-
}
|
|
1292
|
-
return globalThis.document?.visibilityState !== "hidden";
|
|
1293
|
-
}
|
|
1294
|
-
};
|
|
1295
|
-
var focusManager = new FocusManager();
|
|
1296
|
-
|
|
1297
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/thenable.js
|
|
1298
|
-
function pendingThenable() {
|
|
1299
|
-
let resolve;
|
|
1300
|
-
let reject;
|
|
1301
|
-
const thenable = new Promise((_resolve, _reject) => {
|
|
1302
|
-
resolve = _resolve;
|
|
1303
|
-
reject = _reject;
|
|
1304
|
-
});
|
|
1305
|
-
thenable.status = "pending";
|
|
1306
|
-
thenable.catch(() => {
|
|
1307
|
-
});
|
|
1308
|
-
function finalize(data) {
|
|
1309
|
-
Object.assign(thenable, data);
|
|
1310
|
-
delete thenable.resolve;
|
|
1311
|
-
delete thenable.reject;
|
|
1312
|
-
}
|
|
1313
|
-
thenable.resolve = (value) => {
|
|
1314
|
-
finalize({
|
|
1315
|
-
status: "fulfilled",
|
|
1316
|
-
value
|
|
1317
|
-
});
|
|
1318
|
-
resolve(value);
|
|
1319
|
-
};
|
|
1320
|
-
thenable.reject = (reason) => {
|
|
1321
|
-
finalize({
|
|
1322
|
-
status: "rejected",
|
|
1323
|
-
reason
|
|
1324
|
-
});
|
|
1325
|
-
reject(reason);
|
|
1326
|
-
};
|
|
1327
|
-
return thenable;
|
|
1328
|
-
}
|
|
1329
|
-
|
|
1330
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/notifyManager.js
|
|
1331
|
-
var defaultScheduler = systemSetTimeoutZero;
|
|
1332
|
-
function createNotifyManager() {
|
|
1333
|
-
let queue = [];
|
|
1334
|
-
let transactions = 0;
|
|
1335
|
-
let notifyFn = (callback) => {
|
|
1336
|
-
callback();
|
|
1337
|
-
};
|
|
1338
|
-
let batchNotifyFn = (callback) => {
|
|
1339
|
-
callback();
|
|
1340
|
-
};
|
|
1341
|
-
let scheduleFn = defaultScheduler;
|
|
1342
|
-
const schedule = (callback) => {
|
|
1343
|
-
if (transactions) {
|
|
1344
|
-
queue.push(callback);
|
|
1345
|
-
} else {
|
|
1346
|
-
scheduleFn(() => {
|
|
1347
|
-
notifyFn(callback);
|
|
1348
|
-
});
|
|
1349
|
-
}
|
|
1350
|
-
};
|
|
1351
|
-
const flush = () => {
|
|
1352
|
-
const originalQueue = queue;
|
|
1353
|
-
queue = [];
|
|
1354
|
-
if (originalQueue.length) {
|
|
1355
|
-
scheduleFn(() => {
|
|
1356
|
-
batchNotifyFn(() => {
|
|
1357
|
-
originalQueue.forEach((callback) => {
|
|
1358
|
-
notifyFn(callback);
|
|
1359
|
-
});
|
|
1360
|
-
});
|
|
1361
|
-
});
|
|
1362
|
-
}
|
|
1363
|
-
};
|
|
1364
|
-
return {
|
|
1365
|
-
batch: (callback) => {
|
|
1366
|
-
let result;
|
|
1367
|
-
transactions++;
|
|
1368
|
-
try {
|
|
1369
|
-
result = callback();
|
|
1370
|
-
} finally {
|
|
1371
|
-
transactions--;
|
|
1372
|
-
if (!transactions) {
|
|
1373
|
-
flush();
|
|
1374
|
-
}
|
|
1375
|
-
}
|
|
1376
|
-
return result;
|
|
1377
|
-
},
|
|
1378
|
-
/**
|
|
1379
|
-
* All calls to the wrapped function will be batched.
|
|
1380
|
-
*/
|
|
1381
|
-
batchCalls: (callback) => {
|
|
1382
|
-
return (...args) => {
|
|
1383
|
-
schedule(() => {
|
|
1384
|
-
callback(...args);
|
|
1385
|
-
});
|
|
1386
|
-
};
|
|
1387
|
-
},
|
|
1388
|
-
schedule,
|
|
1389
|
-
/**
|
|
1390
|
-
* Use this method to set a custom notify function.
|
|
1391
|
-
* This can be used to for example wrap notifications with `React.act` while running tests.
|
|
1392
|
-
*/
|
|
1393
|
-
setNotifyFunction: (fn) => {
|
|
1394
|
-
notifyFn = fn;
|
|
1395
|
-
},
|
|
1396
|
-
/**
|
|
1397
|
-
* Use this method to set a custom function to batch notifications together into a single tick.
|
|
1398
|
-
* By default React Query will use the batch function provided by ReactDOM or React Native.
|
|
1399
|
-
*/
|
|
1400
|
-
setBatchNotifyFunction: (fn) => {
|
|
1401
|
-
batchNotifyFn = fn;
|
|
1402
|
-
},
|
|
1403
|
-
setScheduler: (fn) => {
|
|
1404
|
-
scheduleFn = fn;
|
|
1405
|
-
}
|
|
1406
|
-
};
|
|
1407
|
-
}
|
|
1408
|
-
var notifyManager = createNotifyManager();
|
|
1409
|
-
|
|
1410
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/onlineManager.js
|
|
1411
|
-
var OnlineManager = class extends Subscribable {
|
|
1412
|
-
#online = true;
|
|
1413
|
-
#cleanup;
|
|
1414
|
-
#setup;
|
|
1415
|
-
constructor() {
|
|
1416
|
-
super();
|
|
1417
|
-
this.#setup = (onOnline) => {
|
|
1418
|
-
if (!isServer && window.addEventListener) {
|
|
1419
|
-
const onlineListener = () => onOnline(true);
|
|
1420
|
-
const offlineListener = () => onOnline(false);
|
|
1421
|
-
window.addEventListener("online", onlineListener, false);
|
|
1422
|
-
window.addEventListener("offline", offlineListener, false);
|
|
1423
|
-
return () => {
|
|
1424
|
-
window.removeEventListener("online", onlineListener);
|
|
1425
|
-
window.removeEventListener("offline", offlineListener);
|
|
1426
|
-
};
|
|
1427
|
-
}
|
|
1428
|
-
return;
|
|
1429
|
-
};
|
|
1430
|
-
}
|
|
1431
|
-
onSubscribe() {
|
|
1432
|
-
if (!this.#cleanup) {
|
|
1433
|
-
this.setEventListener(this.#setup);
|
|
1434
|
-
}
|
|
1435
|
-
}
|
|
1436
|
-
onUnsubscribe() {
|
|
1437
|
-
if (!this.hasListeners()) {
|
|
1438
|
-
this.#cleanup?.();
|
|
1439
|
-
this.#cleanup = void 0;
|
|
1440
|
-
}
|
|
1441
|
-
}
|
|
1442
|
-
setEventListener(setup) {
|
|
1443
|
-
this.#setup = setup;
|
|
1444
|
-
this.#cleanup?.();
|
|
1445
|
-
this.#cleanup = setup(this.setOnline.bind(this));
|
|
1446
|
-
}
|
|
1447
|
-
setOnline(online) {
|
|
1448
|
-
const changed = this.#online !== online;
|
|
1449
|
-
if (changed) {
|
|
1450
|
-
this.#online = online;
|
|
1451
|
-
this.listeners.forEach((listener) => {
|
|
1452
|
-
listener(online);
|
|
1453
|
-
});
|
|
1454
|
-
}
|
|
1455
|
-
}
|
|
1456
|
-
isOnline() {
|
|
1457
|
-
return this.#online;
|
|
1458
|
-
}
|
|
1459
|
-
};
|
|
1460
|
-
var onlineManager = new OnlineManager();
|
|
1461
|
-
|
|
1462
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/retryer.js
|
|
1463
|
-
function defaultRetryDelay(failureCount) {
|
|
1464
|
-
return Math.min(1e3 * 2 ** failureCount, 3e4);
|
|
1465
|
-
}
|
|
1466
|
-
function canFetch(networkMode) {
|
|
1467
|
-
return (networkMode ?? "online") === "online" ? onlineManager.isOnline() : true;
|
|
1468
|
-
}
|
|
1469
|
-
var CancelledError = class extends Error {
|
|
1470
|
-
constructor(options) {
|
|
1471
|
-
super("CancelledError");
|
|
1472
|
-
this.revert = options?.revert;
|
|
1473
|
-
this.silent = options?.silent;
|
|
1474
|
-
}
|
|
1475
|
-
};
|
|
1476
|
-
function createRetryer(config) {
|
|
1477
|
-
let isRetryCancelled = false;
|
|
1478
|
-
let failureCount = 0;
|
|
1479
|
-
let continueFn;
|
|
1480
|
-
const thenable = pendingThenable();
|
|
1481
|
-
const isResolved = () => thenable.status !== "pending";
|
|
1482
|
-
const cancel = (cancelOptions) => {
|
|
1483
|
-
if (!isResolved()) {
|
|
1484
|
-
const error = new CancelledError(cancelOptions);
|
|
1485
|
-
reject(error);
|
|
1486
|
-
config.onCancel?.(error);
|
|
1487
|
-
}
|
|
1488
|
-
};
|
|
1489
|
-
const cancelRetry = () => {
|
|
1490
|
-
isRetryCancelled = true;
|
|
1491
|
-
};
|
|
1492
|
-
const continueRetry = () => {
|
|
1493
|
-
isRetryCancelled = false;
|
|
1494
|
-
};
|
|
1495
|
-
const canContinue = () => focusManager.isFocused() && (config.networkMode === "always" || onlineManager.isOnline()) && config.canRun();
|
|
1496
|
-
const canStart = () => canFetch(config.networkMode) && config.canRun();
|
|
1497
|
-
const resolve = (value) => {
|
|
1498
|
-
if (!isResolved()) {
|
|
1499
|
-
continueFn?.();
|
|
1500
|
-
thenable.resolve(value);
|
|
1501
|
-
}
|
|
1502
|
-
};
|
|
1503
|
-
const reject = (value) => {
|
|
1504
|
-
if (!isResolved()) {
|
|
1505
|
-
continueFn?.();
|
|
1506
|
-
thenable.reject(value);
|
|
1507
|
-
}
|
|
1508
|
-
};
|
|
1509
|
-
const pause = () => {
|
|
1510
|
-
return new Promise((continueResolve) => {
|
|
1511
|
-
continueFn = (value) => {
|
|
1512
|
-
if (isResolved() || canContinue()) {
|
|
1513
|
-
continueResolve(value);
|
|
1514
|
-
}
|
|
1515
|
-
};
|
|
1516
|
-
config.onPause?.();
|
|
1517
|
-
}).then(() => {
|
|
1518
|
-
continueFn = void 0;
|
|
1519
|
-
if (!isResolved()) {
|
|
1520
|
-
config.onContinue?.();
|
|
1521
|
-
}
|
|
1522
|
-
});
|
|
1523
|
-
};
|
|
1524
|
-
const run = () => {
|
|
1525
|
-
if (isResolved()) {
|
|
1526
|
-
return;
|
|
1527
|
-
}
|
|
1528
|
-
let promiseOrValue;
|
|
1529
|
-
const initialPromise = failureCount === 0 ? config.initialPromise : void 0;
|
|
1530
|
-
try {
|
|
1531
|
-
promiseOrValue = initialPromise ?? config.fn();
|
|
1532
|
-
} catch (error) {
|
|
1533
|
-
promiseOrValue = Promise.reject(error);
|
|
1534
|
-
}
|
|
1535
|
-
Promise.resolve(promiseOrValue).then(resolve).catch((error) => {
|
|
1536
|
-
if (isResolved()) {
|
|
1537
|
-
return;
|
|
1538
|
-
}
|
|
1539
|
-
const retry = config.retry ?? (isServer ? 0 : 3);
|
|
1540
|
-
const retryDelay = config.retryDelay ?? defaultRetryDelay;
|
|
1541
|
-
const delay = typeof retryDelay === "function" ? retryDelay(failureCount, error) : retryDelay;
|
|
1542
|
-
const shouldRetry = retry === true || typeof retry === "number" && failureCount < retry || typeof retry === "function" && retry(failureCount, error);
|
|
1543
|
-
if (isRetryCancelled || !shouldRetry) {
|
|
1544
|
-
reject(error);
|
|
1545
|
-
return;
|
|
1546
|
-
}
|
|
1547
|
-
failureCount++;
|
|
1548
|
-
config.onFail?.(failureCount, error);
|
|
1549
|
-
sleep(delay).then(() => {
|
|
1550
|
-
return canContinue() ? void 0 : pause();
|
|
1551
|
-
}).then(() => {
|
|
1552
|
-
if (isRetryCancelled) {
|
|
1553
|
-
reject(error);
|
|
1554
|
-
} else {
|
|
1555
|
-
run();
|
|
1556
|
-
}
|
|
1557
|
-
});
|
|
1558
|
-
});
|
|
1559
|
-
};
|
|
1560
|
-
return {
|
|
1561
|
-
promise: thenable,
|
|
1562
|
-
status: () => thenable.status,
|
|
1563
|
-
cancel,
|
|
1564
|
-
continue: () => {
|
|
1565
|
-
continueFn?.();
|
|
1566
|
-
return thenable;
|
|
1567
|
-
},
|
|
1568
|
-
cancelRetry,
|
|
1569
|
-
continueRetry,
|
|
1570
|
-
canStart,
|
|
1571
|
-
start: () => {
|
|
1572
|
-
if (canStart()) {
|
|
1573
|
-
run();
|
|
1574
|
-
} else {
|
|
1575
|
-
pause().then(run);
|
|
1576
|
-
}
|
|
1577
|
-
return thenable;
|
|
1578
|
-
}
|
|
1579
|
-
};
|
|
1580
|
-
}
|
|
1581
|
-
|
|
1582
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/removable.js
|
|
1583
|
-
var Removable = class {
|
|
1584
|
-
#gcTimeout;
|
|
1585
|
-
destroy() {
|
|
1586
|
-
this.clearGcTimeout();
|
|
1587
|
-
}
|
|
1588
|
-
scheduleGc() {
|
|
1589
|
-
this.clearGcTimeout();
|
|
1590
|
-
if (isValidTimeout(this.gcTime)) {
|
|
1591
|
-
this.#gcTimeout = timeoutManager.setTimeout(() => {
|
|
1592
|
-
this.optionalRemove();
|
|
1593
|
-
}, this.gcTime);
|
|
1594
|
-
}
|
|
1595
|
-
}
|
|
1596
|
-
updateGcTime(newGcTime) {
|
|
1597
|
-
this.gcTime = Math.max(
|
|
1598
|
-
this.gcTime || 0,
|
|
1599
|
-
newGcTime ?? (isServer ? Infinity : 5 * 60 * 1e3)
|
|
1600
|
-
);
|
|
1601
|
-
}
|
|
1602
|
-
clearGcTimeout() {
|
|
1603
|
-
if (this.#gcTimeout) {
|
|
1604
|
-
timeoutManager.clearTimeout(this.#gcTimeout);
|
|
1605
|
-
this.#gcTimeout = void 0;
|
|
1606
|
-
}
|
|
1607
|
-
}
|
|
1608
|
-
};
|
|
1609
|
-
|
|
1610
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/query.js
|
|
1611
|
-
var Query = class extends Removable {
|
|
1612
|
-
#initialState;
|
|
1613
|
-
#revertState;
|
|
1614
|
-
#cache;
|
|
1615
|
-
#client;
|
|
1616
|
-
#retryer;
|
|
1617
|
-
#defaultOptions;
|
|
1618
|
-
#abortSignalConsumed;
|
|
1619
|
-
constructor(config) {
|
|
1620
|
-
super();
|
|
1621
|
-
this.#abortSignalConsumed = false;
|
|
1622
|
-
this.#defaultOptions = config.defaultOptions;
|
|
1623
|
-
this.setOptions(config.options);
|
|
1624
|
-
this.observers = [];
|
|
1625
|
-
this.#client = config.client;
|
|
1626
|
-
this.#cache = this.#client.getQueryCache();
|
|
1627
|
-
this.queryKey = config.queryKey;
|
|
1628
|
-
this.queryHash = config.queryHash;
|
|
1629
|
-
this.#initialState = getDefaultState(this.options);
|
|
1630
|
-
this.state = config.state ?? this.#initialState;
|
|
1631
|
-
this.scheduleGc();
|
|
1632
|
-
}
|
|
1633
|
-
get meta() {
|
|
1634
|
-
return this.options.meta;
|
|
1635
|
-
}
|
|
1636
|
-
get promise() {
|
|
1637
|
-
return this.#retryer?.promise;
|
|
1638
|
-
}
|
|
1639
|
-
setOptions(options) {
|
|
1640
|
-
this.options = { ...this.#defaultOptions, ...options };
|
|
1641
|
-
this.updateGcTime(this.options.gcTime);
|
|
1642
|
-
if (this.state && this.state.data === void 0) {
|
|
1643
|
-
const defaultState = getDefaultState(this.options);
|
|
1644
|
-
if (defaultState.data !== void 0) {
|
|
1645
|
-
this.setState(
|
|
1646
|
-
successState(defaultState.data, defaultState.dataUpdatedAt)
|
|
1647
|
-
);
|
|
1648
|
-
this.#initialState = defaultState;
|
|
1649
|
-
}
|
|
1650
|
-
}
|
|
1651
|
-
}
|
|
1652
|
-
optionalRemove() {
|
|
1653
|
-
if (!this.observers.length && this.state.fetchStatus === "idle") {
|
|
1654
|
-
this.#cache.remove(this);
|
|
1655
|
-
}
|
|
1656
|
-
}
|
|
1657
|
-
setData(newData, options) {
|
|
1658
|
-
const data = replaceData(this.state.data, newData, this.options);
|
|
1659
|
-
this.#dispatch({
|
|
1660
|
-
data,
|
|
1661
|
-
type: "success",
|
|
1662
|
-
dataUpdatedAt: options?.updatedAt,
|
|
1663
|
-
manual: options?.manual
|
|
1664
|
-
});
|
|
1665
|
-
return data;
|
|
1666
|
-
}
|
|
1667
|
-
setState(state, setStateOptions) {
|
|
1668
|
-
this.#dispatch({ type: "setState", state, setStateOptions });
|
|
1669
|
-
}
|
|
1670
|
-
cancel(options) {
|
|
1671
|
-
const promise = this.#retryer?.promise;
|
|
1672
|
-
this.#retryer?.cancel(options);
|
|
1673
|
-
return promise ? promise.then(noop).catch(noop) : Promise.resolve();
|
|
1674
|
-
}
|
|
1675
|
-
destroy() {
|
|
1676
|
-
super.destroy();
|
|
1677
|
-
this.cancel({ silent: true });
|
|
1678
|
-
}
|
|
1679
|
-
reset() {
|
|
1680
|
-
this.destroy();
|
|
1681
|
-
this.setState(this.#initialState);
|
|
1682
|
-
}
|
|
1683
|
-
isActive() {
|
|
1684
|
-
return this.observers.some(
|
|
1685
|
-
(observer) => resolveEnabled(observer.options.enabled, this) !== false
|
|
1686
|
-
);
|
|
1687
|
-
}
|
|
1688
|
-
isDisabled() {
|
|
1689
|
-
if (this.getObserversCount() > 0) {
|
|
1690
|
-
return !this.isActive();
|
|
1691
|
-
}
|
|
1692
|
-
return this.options.queryFn === skipToken || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
|
|
1693
|
-
}
|
|
1694
|
-
isStatic() {
|
|
1695
|
-
if (this.getObserversCount() > 0) {
|
|
1696
|
-
return this.observers.some(
|
|
1697
|
-
(observer) => resolveStaleTime(observer.options.staleTime, this) === "static"
|
|
1698
|
-
);
|
|
1699
|
-
}
|
|
1700
|
-
return false;
|
|
1701
|
-
}
|
|
1702
|
-
isStale() {
|
|
1703
|
-
if (this.getObserversCount() > 0) {
|
|
1704
|
-
return this.observers.some(
|
|
1705
|
-
(observer) => observer.getCurrentResult().isStale
|
|
1706
|
-
);
|
|
1707
|
-
}
|
|
1708
|
-
return this.state.data === void 0 || this.state.isInvalidated;
|
|
1709
|
-
}
|
|
1710
|
-
isStaleByTime(staleTime = 0) {
|
|
1711
|
-
if (this.state.data === void 0) {
|
|
1712
|
-
return true;
|
|
1713
|
-
}
|
|
1714
|
-
if (staleTime === "static") {
|
|
1715
|
-
return false;
|
|
1716
|
-
}
|
|
1717
|
-
if (this.state.isInvalidated) {
|
|
1718
|
-
return true;
|
|
1719
|
-
}
|
|
1720
|
-
return !timeUntilStale(this.state.dataUpdatedAt, staleTime);
|
|
1721
|
-
}
|
|
1722
|
-
onFocus() {
|
|
1723
|
-
const observer = this.observers.find((x) => x.shouldFetchOnWindowFocus());
|
|
1724
|
-
observer?.refetch({ cancelRefetch: false });
|
|
1725
|
-
this.#retryer?.continue();
|
|
1726
|
-
}
|
|
1727
|
-
onOnline() {
|
|
1728
|
-
const observer = this.observers.find((x) => x.shouldFetchOnReconnect());
|
|
1729
|
-
observer?.refetch({ cancelRefetch: false });
|
|
1730
|
-
this.#retryer?.continue();
|
|
1731
|
-
}
|
|
1732
|
-
addObserver(observer) {
|
|
1733
|
-
if (!this.observers.includes(observer)) {
|
|
1734
|
-
this.observers.push(observer);
|
|
1735
|
-
this.clearGcTimeout();
|
|
1736
|
-
this.#cache.notify({ type: "observerAdded", query: this, observer });
|
|
1737
|
-
}
|
|
1738
|
-
}
|
|
1739
|
-
removeObserver(observer) {
|
|
1740
|
-
if (this.observers.includes(observer)) {
|
|
1741
|
-
this.observers = this.observers.filter((x) => x !== observer);
|
|
1742
|
-
if (!this.observers.length) {
|
|
1743
|
-
if (this.#retryer) {
|
|
1744
|
-
if (this.#abortSignalConsumed) {
|
|
1745
|
-
this.#retryer.cancel({ revert: true });
|
|
1746
|
-
} else {
|
|
1747
|
-
this.#retryer.cancelRetry();
|
|
1748
|
-
}
|
|
1749
|
-
}
|
|
1750
|
-
this.scheduleGc();
|
|
1751
|
-
}
|
|
1752
|
-
this.#cache.notify({ type: "observerRemoved", query: this, observer });
|
|
1753
|
-
}
|
|
1754
|
-
}
|
|
1755
|
-
getObserversCount() {
|
|
1756
|
-
return this.observers.length;
|
|
1757
|
-
}
|
|
1758
|
-
invalidate() {
|
|
1759
|
-
if (!this.state.isInvalidated) {
|
|
1760
|
-
this.#dispatch({ type: "invalidate" });
|
|
1761
|
-
}
|
|
1762
|
-
}
|
|
1763
|
-
async fetch(options, fetchOptions) {
|
|
1764
|
-
if (this.state.fetchStatus !== "idle" && // If the promise in the retryer is already rejected, we have to definitely
|
|
1765
|
-
// re-start the fetch; there is a chance that the query is still in a
|
|
1766
|
-
// pending state when that happens
|
|
1767
|
-
this.#retryer?.status() !== "rejected") {
|
|
1768
|
-
if (this.state.data !== void 0 && fetchOptions?.cancelRefetch) {
|
|
1769
|
-
this.cancel({ silent: true });
|
|
1770
|
-
} else if (this.#retryer) {
|
|
1771
|
-
this.#retryer.continueRetry();
|
|
1772
|
-
return this.#retryer.promise;
|
|
1773
|
-
}
|
|
1774
|
-
}
|
|
1775
|
-
if (options) {
|
|
1776
|
-
this.setOptions(options);
|
|
1777
|
-
}
|
|
1778
|
-
if (!this.options.queryFn) {
|
|
1779
|
-
const observer = this.observers.find((x) => x.options.queryFn);
|
|
1780
|
-
if (observer) {
|
|
1781
|
-
this.setOptions(observer.options);
|
|
1782
|
-
}
|
|
1783
|
-
}
|
|
1784
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1785
|
-
if (!Array.isArray(this.options.queryKey)) {
|
|
1786
|
-
console.error(
|
|
1787
|
-
`As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']`
|
|
1788
|
-
);
|
|
1789
|
-
}
|
|
1790
|
-
}
|
|
1791
|
-
const abortController = new AbortController();
|
|
1792
|
-
const addSignalProperty = (object) => {
|
|
1793
|
-
Object.defineProperty(object, "signal", {
|
|
1794
|
-
enumerable: true,
|
|
1795
|
-
get: () => {
|
|
1796
|
-
this.#abortSignalConsumed = true;
|
|
1797
|
-
return abortController.signal;
|
|
1798
|
-
}
|
|
1799
|
-
});
|
|
1800
|
-
};
|
|
1801
|
-
const fetchFn = () => {
|
|
1802
|
-
const queryFn = ensureQueryFn(this.options, fetchOptions);
|
|
1803
|
-
const createQueryFnContext = () => {
|
|
1804
|
-
const queryFnContext2 = {
|
|
1805
|
-
client: this.#client,
|
|
1806
|
-
queryKey: this.queryKey,
|
|
1807
|
-
meta: this.meta
|
|
1808
|
-
};
|
|
1809
|
-
addSignalProperty(queryFnContext2);
|
|
1810
|
-
return queryFnContext2;
|
|
1811
|
-
};
|
|
1812
|
-
const queryFnContext = createQueryFnContext();
|
|
1813
|
-
this.#abortSignalConsumed = false;
|
|
1814
|
-
if (this.options.persister) {
|
|
1815
|
-
return this.options.persister(
|
|
1816
|
-
queryFn,
|
|
1817
|
-
queryFnContext,
|
|
1818
|
-
this
|
|
1819
|
-
);
|
|
1820
|
-
}
|
|
1821
|
-
return queryFn(queryFnContext);
|
|
1822
|
-
};
|
|
1823
|
-
const createFetchContext = () => {
|
|
1824
|
-
const context2 = {
|
|
1825
|
-
fetchOptions,
|
|
1826
|
-
options: this.options,
|
|
1827
|
-
queryKey: this.queryKey,
|
|
1828
|
-
client: this.#client,
|
|
1829
|
-
state: this.state,
|
|
1830
|
-
fetchFn
|
|
1831
|
-
};
|
|
1832
|
-
addSignalProperty(context2);
|
|
1833
|
-
return context2;
|
|
1834
|
-
};
|
|
1835
|
-
const context = createFetchContext();
|
|
1836
|
-
this.options.behavior?.onFetch(context, this);
|
|
1837
|
-
this.#revertState = this.state;
|
|
1838
|
-
if (this.state.fetchStatus === "idle" || this.state.fetchMeta !== context.fetchOptions?.meta) {
|
|
1839
|
-
this.#dispatch({ type: "fetch", meta: context.fetchOptions?.meta });
|
|
1840
|
-
}
|
|
1841
|
-
this.#retryer = createRetryer({
|
|
1842
|
-
initialPromise: fetchOptions?.initialPromise,
|
|
1843
|
-
fn: context.fetchFn,
|
|
1844
|
-
onCancel: (error) => {
|
|
1845
|
-
if (error instanceof CancelledError && error.revert) {
|
|
1846
|
-
this.setState({
|
|
1847
|
-
...this.#revertState,
|
|
1848
|
-
fetchStatus: "idle"
|
|
1849
|
-
});
|
|
1850
|
-
}
|
|
1851
|
-
abortController.abort();
|
|
1852
|
-
},
|
|
1853
|
-
onFail: (failureCount, error) => {
|
|
1854
|
-
this.#dispatch({ type: "failed", failureCount, error });
|
|
1855
|
-
},
|
|
1856
|
-
onPause: () => {
|
|
1857
|
-
this.#dispatch({ type: "pause" });
|
|
1858
|
-
},
|
|
1859
|
-
onContinue: () => {
|
|
1860
|
-
this.#dispatch({ type: "continue" });
|
|
1861
|
-
},
|
|
1862
|
-
retry: context.options.retry,
|
|
1863
|
-
retryDelay: context.options.retryDelay,
|
|
1864
|
-
networkMode: context.options.networkMode,
|
|
1865
|
-
canRun: () => true
|
|
1866
|
-
});
|
|
1867
|
-
try {
|
|
1868
|
-
const data = await this.#retryer.start();
|
|
1869
|
-
if (data === void 0) {
|
|
1870
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1871
|
-
console.error(
|
|
1872
|
-
`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
|
|
1873
|
-
);
|
|
1874
|
-
}
|
|
1875
|
-
throw new Error(`${this.queryHash} data is undefined`);
|
|
1876
|
-
}
|
|
1877
|
-
this.setData(data);
|
|
1878
|
-
this.#cache.config.onSuccess?.(data, this);
|
|
1879
|
-
this.#cache.config.onSettled?.(
|
|
1880
|
-
data,
|
|
1881
|
-
this.state.error,
|
|
1882
|
-
this
|
|
1883
|
-
);
|
|
1884
|
-
return data;
|
|
1885
|
-
} catch (error) {
|
|
1886
|
-
if (error instanceof CancelledError) {
|
|
1887
|
-
if (error.silent) {
|
|
1888
|
-
return this.#retryer.promise;
|
|
1889
|
-
} else if (error.revert) {
|
|
1890
|
-
if (this.state.data === void 0) {
|
|
1891
|
-
throw error;
|
|
1892
|
-
}
|
|
1893
|
-
return this.state.data;
|
|
1894
|
-
}
|
|
1895
|
-
}
|
|
1896
|
-
this.#dispatch({
|
|
1897
|
-
type: "error",
|
|
1898
|
-
error
|
|
1899
|
-
});
|
|
1900
|
-
this.#cache.config.onError?.(
|
|
1901
|
-
error,
|
|
1902
|
-
this
|
|
1903
|
-
);
|
|
1904
|
-
this.#cache.config.onSettled?.(
|
|
1905
|
-
this.state.data,
|
|
1906
|
-
error,
|
|
1907
|
-
this
|
|
1908
|
-
);
|
|
1909
|
-
throw error;
|
|
1910
|
-
} finally {
|
|
1911
|
-
this.scheduleGc();
|
|
1912
|
-
}
|
|
1913
|
-
}
|
|
1914
|
-
#dispatch(action) {
|
|
1915
|
-
const reducer = (state) => {
|
|
1916
|
-
switch (action.type) {
|
|
1917
|
-
case "failed":
|
|
1918
|
-
return {
|
|
1919
|
-
...state,
|
|
1920
|
-
fetchFailureCount: action.failureCount,
|
|
1921
|
-
fetchFailureReason: action.error
|
|
1922
|
-
};
|
|
1923
|
-
case "pause":
|
|
1924
|
-
return {
|
|
1925
|
-
...state,
|
|
1926
|
-
fetchStatus: "paused"
|
|
1927
|
-
};
|
|
1928
|
-
case "continue":
|
|
1929
|
-
return {
|
|
1930
|
-
...state,
|
|
1931
|
-
fetchStatus: "fetching"
|
|
1932
|
-
};
|
|
1933
|
-
case "fetch":
|
|
1934
|
-
return {
|
|
1935
|
-
...state,
|
|
1936
|
-
...fetchState(state.data, this.options),
|
|
1937
|
-
fetchMeta: action.meta ?? null
|
|
1938
|
-
};
|
|
1939
|
-
case "success":
|
|
1940
|
-
const newState = {
|
|
1941
|
-
...state,
|
|
1942
|
-
...successState(action.data, action.dataUpdatedAt),
|
|
1943
|
-
dataUpdateCount: state.dataUpdateCount + 1,
|
|
1944
|
-
...!action.manual && {
|
|
1945
|
-
fetchStatus: "idle",
|
|
1946
|
-
fetchFailureCount: 0,
|
|
1947
|
-
fetchFailureReason: null
|
|
1948
|
-
}
|
|
1949
|
-
};
|
|
1950
|
-
this.#revertState = action.manual ? newState : void 0;
|
|
1951
|
-
return newState;
|
|
1952
|
-
case "error":
|
|
1953
|
-
const error = action.error;
|
|
1954
|
-
return {
|
|
1955
|
-
...state,
|
|
1956
|
-
error,
|
|
1957
|
-
errorUpdateCount: state.errorUpdateCount + 1,
|
|
1958
|
-
errorUpdatedAt: Date.now(),
|
|
1959
|
-
fetchFailureCount: state.fetchFailureCount + 1,
|
|
1960
|
-
fetchFailureReason: error,
|
|
1961
|
-
fetchStatus: "idle",
|
|
1962
|
-
status: "error",
|
|
1963
|
-
// flag existing data as invalidated if we get a background error
|
|
1964
|
-
// note that "no data" always means stale so we can set unconditionally here
|
|
1965
|
-
isInvalidated: true
|
|
1966
|
-
};
|
|
1967
|
-
case "invalidate":
|
|
1968
|
-
return {
|
|
1969
|
-
...state,
|
|
1970
|
-
isInvalidated: true
|
|
1971
|
-
};
|
|
1972
|
-
case "setState":
|
|
1973
|
-
return {
|
|
1974
|
-
...state,
|
|
1975
|
-
...action.state
|
|
1976
|
-
};
|
|
1977
|
-
}
|
|
1978
|
-
};
|
|
1979
|
-
this.state = reducer(this.state);
|
|
1980
|
-
notifyManager.batch(() => {
|
|
1981
|
-
this.observers.forEach((observer) => {
|
|
1982
|
-
observer.onQueryUpdate();
|
|
1983
|
-
});
|
|
1984
|
-
this.#cache.notify({ query: this, type: "updated", action });
|
|
1985
|
-
});
|
|
1986
|
-
}
|
|
1987
|
-
};
|
|
1988
|
-
function fetchState(data, options) {
|
|
1989
|
-
return {
|
|
1990
|
-
fetchFailureCount: 0,
|
|
1991
|
-
fetchFailureReason: null,
|
|
1992
|
-
fetchStatus: canFetch(options.networkMode) ? "fetching" : "paused",
|
|
1993
|
-
...data === void 0 && {
|
|
1994
|
-
error: null,
|
|
1995
|
-
status: "pending"
|
|
1996
|
-
}
|
|
1997
|
-
};
|
|
1998
|
-
}
|
|
1999
|
-
function successState(data, dataUpdatedAt) {
|
|
2000
|
-
return {
|
|
2001
|
-
data,
|
|
2002
|
-
dataUpdatedAt: dataUpdatedAt ?? Date.now(),
|
|
2003
|
-
error: null,
|
|
2004
|
-
isInvalidated: false,
|
|
2005
|
-
status: "success"
|
|
2006
|
-
};
|
|
2007
|
-
}
|
|
2008
|
-
function getDefaultState(options) {
|
|
2009
|
-
const data = typeof options.initialData === "function" ? options.initialData() : options.initialData;
|
|
2010
|
-
const hasData = data !== void 0;
|
|
2011
|
-
const initialDataUpdatedAt = hasData ? typeof options.initialDataUpdatedAt === "function" ? options.initialDataUpdatedAt() : options.initialDataUpdatedAt : 0;
|
|
2012
|
-
return {
|
|
2013
|
-
data,
|
|
2014
|
-
dataUpdateCount: 0,
|
|
2015
|
-
dataUpdatedAt: hasData ? initialDataUpdatedAt ?? Date.now() : 0,
|
|
2016
|
-
error: null,
|
|
2017
|
-
errorUpdateCount: 0,
|
|
2018
|
-
errorUpdatedAt: 0,
|
|
2019
|
-
fetchFailureCount: 0,
|
|
2020
|
-
fetchFailureReason: null,
|
|
2021
|
-
fetchMeta: null,
|
|
2022
|
-
isInvalidated: false,
|
|
2023
|
-
status: hasData ? "success" : "pending",
|
|
2024
|
-
fetchStatus: "idle"
|
|
2025
|
-
};
|
|
2026
|
-
}
|
|
2027
|
-
|
|
2028
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js
|
|
2029
|
-
function infiniteQueryBehavior(pages) {
|
|
2030
|
-
return {
|
|
2031
|
-
onFetch: (context, query) => {
|
|
2032
|
-
const options = context.options;
|
|
2033
|
-
const direction = context.fetchOptions?.meta?.fetchMore?.direction;
|
|
2034
|
-
const oldPages = context.state.data?.pages || [];
|
|
2035
|
-
const oldPageParams = context.state.data?.pageParams || [];
|
|
2036
|
-
let result = { pages: [], pageParams: [] };
|
|
2037
|
-
let currentPage = 0;
|
|
2038
|
-
const fetchFn = async () => {
|
|
2039
|
-
let cancelled = false;
|
|
2040
|
-
const addSignalProperty = (object) => {
|
|
2041
|
-
addConsumeAwareSignal(
|
|
2042
|
-
object,
|
|
2043
|
-
() => context.signal,
|
|
2044
|
-
() => cancelled = true
|
|
2045
|
-
);
|
|
2046
|
-
};
|
|
2047
|
-
const queryFn = ensureQueryFn(context.options, context.fetchOptions);
|
|
2048
|
-
const fetchPage = async (data, param, previous) => {
|
|
2049
|
-
if (cancelled) {
|
|
2050
|
-
return Promise.reject();
|
|
2051
|
-
}
|
|
2052
|
-
if (param == null && data.pages.length) {
|
|
2053
|
-
return Promise.resolve(data);
|
|
2054
|
-
}
|
|
2055
|
-
const createQueryFnContext = () => {
|
|
2056
|
-
const queryFnContext2 = {
|
|
2057
|
-
client: context.client,
|
|
2058
|
-
queryKey: context.queryKey,
|
|
2059
|
-
pageParam: param,
|
|
2060
|
-
direction: previous ? "backward" : "forward",
|
|
2061
|
-
meta: context.options.meta
|
|
2062
|
-
};
|
|
2063
|
-
addSignalProperty(queryFnContext2);
|
|
2064
|
-
return queryFnContext2;
|
|
2065
|
-
};
|
|
2066
|
-
const queryFnContext = createQueryFnContext();
|
|
2067
|
-
const page = await queryFn(queryFnContext);
|
|
2068
|
-
const { maxPages } = context.options;
|
|
2069
|
-
const addTo = previous ? addToStart : addToEnd;
|
|
2070
|
-
return {
|
|
2071
|
-
pages: addTo(data.pages, page, maxPages),
|
|
2072
|
-
pageParams: addTo(data.pageParams, param, maxPages)
|
|
2073
|
-
};
|
|
2074
|
-
};
|
|
2075
|
-
if (direction && oldPages.length) {
|
|
2076
|
-
const previous = direction === "backward";
|
|
2077
|
-
const pageParamFn = previous ? getPreviousPageParam : getNextPageParam;
|
|
2078
|
-
const oldData = {
|
|
2079
|
-
pages: oldPages,
|
|
2080
|
-
pageParams: oldPageParams
|
|
2081
|
-
};
|
|
2082
|
-
const param = pageParamFn(options, oldData);
|
|
2083
|
-
result = await fetchPage(oldData, param, previous);
|
|
2084
|
-
} else {
|
|
2085
|
-
const remainingPages = pages ?? oldPages.length;
|
|
2086
|
-
do {
|
|
2087
|
-
const param = currentPage === 0 ? oldPageParams[0] ?? options.initialPageParam : getNextPageParam(options, result);
|
|
2088
|
-
if (currentPage > 0 && param == null) {
|
|
2089
|
-
break;
|
|
2090
|
-
}
|
|
2091
|
-
result = await fetchPage(result, param);
|
|
2092
|
-
currentPage++;
|
|
2093
|
-
} while (currentPage < remainingPages);
|
|
2094
|
-
}
|
|
2095
|
-
return result;
|
|
2096
|
-
};
|
|
2097
|
-
if (context.options.persister) {
|
|
2098
|
-
context.fetchFn = () => {
|
|
2099
|
-
return context.options.persister?.(
|
|
2100
|
-
fetchFn,
|
|
2101
|
-
{
|
|
2102
|
-
client: context.client,
|
|
2103
|
-
queryKey: context.queryKey,
|
|
2104
|
-
meta: context.options.meta,
|
|
2105
|
-
signal: context.signal
|
|
2106
|
-
},
|
|
2107
|
-
query
|
|
2108
|
-
);
|
|
2109
|
-
};
|
|
2110
|
-
} else {
|
|
2111
|
-
context.fetchFn = fetchFn;
|
|
2112
|
-
}
|
|
2113
|
-
}
|
|
2114
|
-
};
|
|
2115
|
-
}
|
|
2116
|
-
function getNextPageParam(options, { pages, pageParams }) {
|
|
2117
|
-
const lastIndex = pages.length - 1;
|
|
2118
|
-
return pages.length > 0 ? options.getNextPageParam(
|
|
2119
|
-
pages[lastIndex],
|
|
2120
|
-
pages,
|
|
2121
|
-
pageParams[lastIndex],
|
|
2122
|
-
pageParams
|
|
2123
|
-
) : void 0;
|
|
2124
|
-
}
|
|
2125
|
-
function getPreviousPageParam(options, { pages, pageParams }) {
|
|
2126
|
-
return pages.length > 0 ? options.getPreviousPageParam?.(pages[0], pages, pageParams[0], pageParams) : void 0;
|
|
2127
|
-
}
|
|
2128
|
-
|
|
2129
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/mutation.js
|
|
2130
|
-
var Mutation = class extends Removable {
|
|
2131
|
-
#client;
|
|
2132
|
-
#observers;
|
|
2133
|
-
#mutationCache;
|
|
2134
|
-
#retryer;
|
|
2135
|
-
constructor(config) {
|
|
2136
|
-
super();
|
|
2137
|
-
this.#client = config.client;
|
|
2138
|
-
this.mutationId = config.mutationId;
|
|
2139
|
-
this.#mutationCache = config.mutationCache;
|
|
2140
|
-
this.#observers = [];
|
|
2141
|
-
this.state = config.state || getDefaultState2();
|
|
2142
|
-
this.setOptions(config.options);
|
|
2143
|
-
this.scheduleGc();
|
|
2144
|
-
}
|
|
2145
|
-
setOptions(options) {
|
|
2146
|
-
this.options = options;
|
|
2147
|
-
this.updateGcTime(this.options.gcTime);
|
|
2148
|
-
}
|
|
2149
|
-
get meta() {
|
|
2150
|
-
return this.options.meta;
|
|
2151
|
-
}
|
|
2152
|
-
addObserver(observer) {
|
|
2153
|
-
if (!this.#observers.includes(observer)) {
|
|
2154
|
-
this.#observers.push(observer);
|
|
2155
|
-
this.clearGcTimeout();
|
|
2156
|
-
this.#mutationCache.notify({
|
|
2157
|
-
type: "observerAdded",
|
|
2158
|
-
mutation: this,
|
|
2159
|
-
observer
|
|
2160
|
-
});
|
|
2161
|
-
}
|
|
2162
|
-
}
|
|
2163
|
-
removeObserver(observer) {
|
|
2164
|
-
this.#observers = this.#observers.filter((x) => x !== observer);
|
|
2165
|
-
this.scheduleGc();
|
|
2166
|
-
this.#mutationCache.notify({
|
|
2167
|
-
type: "observerRemoved",
|
|
2168
|
-
mutation: this,
|
|
2169
|
-
observer
|
|
2170
|
-
});
|
|
2171
|
-
}
|
|
2172
|
-
optionalRemove() {
|
|
2173
|
-
if (!this.#observers.length) {
|
|
2174
|
-
if (this.state.status === "pending") {
|
|
2175
|
-
this.scheduleGc();
|
|
2176
|
-
} else {
|
|
2177
|
-
this.#mutationCache.remove(this);
|
|
2178
|
-
}
|
|
2179
|
-
}
|
|
2180
|
-
}
|
|
2181
|
-
continue() {
|
|
2182
|
-
return this.#retryer?.continue() ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before
|
|
2183
|
-
this.execute(this.state.variables);
|
|
2184
|
-
}
|
|
2185
|
-
async execute(variables) {
|
|
2186
|
-
const onContinue = () => {
|
|
2187
|
-
this.#dispatch({ type: "continue" });
|
|
2188
|
-
};
|
|
2189
|
-
const mutationFnContext = {
|
|
2190
|
-
client: this.#client,
|
|
2191
|
-
meta: this.options.meta,
|
|
2192
|
-
mutationKey: this.options.mutationKey
|
|
2193
|
-
};
|
|
2194
|
-
this.#retryer = createRetryer({
|
|
2195
|
-
fn: () => {
|
|
2196
|
-
if (!this.options.mutationFn) {
|
|
2197
|
-
return Promise.reject(new Error("No mutationFn found"));
|
|
2198
|
-
}
|
|
2199
|
-
return this.options.mutationFn(variables, mutationFnContext);
|
|
2200
|
-
},
|
|
2201
|
-
onFail: (failureCount, error) => {
|
|
2202
|
-
this.#dispatch({ type: "failed", failureCount, error });
|
|
2203
|
-
},
|
|
2204
|
-
onPause: () => {
|
|
2205
|
-
this.#dispatch({ type: "pause" });
|
|
2206
|
-
},
|
|
2207
|
-
onContinue,
|
|
2208
|
-
retry: this.options.retry ?? 0,
|
|
2209
|
-
retryDelay: this.options.retryDelay,
|
|
2210
|
-
networkMode: this.options.networkMode,
|
|
2211
|
-
canRun: () => this.#mutationCache.canRun(this)
|
|
2212
|
-
});
|
|
2213
|
-
const restored = this.state.status === "pending";
|
|
2214
|
-
const isPaused = !this.#retryer.canStart();
|
|
2215
|
-
try {
|
|
2216
|
-
if (restored) {
|
|
2217
|
-
onContinue();
|
|
2218
|
-
} else {
|
|
2219
|
-
this.#dispatch({ type: "pending", variables, isPaused });
|
|
2220
|
-
if (this.#mutationCache.config.onMutate) {
|
|
2221
|
-
await this.#mutationCache.config.onMutate(
|
|
2222
|
-
variables,
|
|
2223
|
-
this,
|
|
2224
|
-
mutationFnContext
|
|
2225
|
-
);
|
|
2226
|
-
}
|
|
2227
|
-
const context = await this.options.onMutate?.(
|
|
2228
|
-
variables,
|
|
2229
|
-
mutationFnContext
|
|
2230
|
-
);
|
|
2231
|
-
if (context !== this.state.context) {
|
|
2232
|
-
this.#dispatch({
|
|
2233
|
-
type: "pending",
|
|
2234
|
-
context,
|
|
2235
|
-
variables,
|
|
2236
|
-
isPaused
|
|
2237
|
-
});
|
|
2238
|
-
}
|
|
2239
|
-
}
|
|
2240
|
-
const data = await this.#retryer.start();
|
|
2241
|
-
await this.#mutationCache.config.onSuccess?.(
|
|
2242
|
-
data,
|
|
2243
|
-
variables,
|
|
2244
|
-
this.state.context,
|
|
2245
|
-
this,
|
|
2246
|
-
mutationFnContext
|
|
2247
|
-
);
|
|
2248
|
-
await this.options.onSuccess?.(
|
|
2249
|
-
data,
|
|
2250
|
-
variables,
|
|
2251
|
-
this.state.context,
|
|
2252
|
-
mutationFnContext
|
|
2253
|
-
);
|
|
2254
|
-
await this.#mutationCache.config.onSettled?.(
|
|
2255
|
-
data,
|
|
2256
|
-
null,
|
|
2257
|
-
this.state.variables,
|
|
2258
|
-
this.state.context,
|
|
2259
|
-
this,
|
|
2260
|
-
mutationFnContext
|
|
2261
|
-
);
|
|
2262
|
-
await this.options.onSettled?.(
|
|
2263
|
-
data,
|
|
2264
|
-
null,
|
|
2265
|
-
variables,
|
|
2266
|
-
this.state.context,
|
|
2267
|
-
mutationFnContext
|
|
2268
|
-
);
|
|
2269
|
-
this.#dispatch({ type: "success", data });
|
|
2270
|
-
return data;
|
|
2271
|
-
} catch (error) {
|
|
2272
|
-
try {
|
|
2273
|
-
await this.#mutationCache.config.onError?.(
|
|
2274
|
-
error,
|
|
2275
|
-
variables,
|
|
2276
|
-
this.state.context,
|
|
2277
|
-
this,
|
|
2278
|
-
mutationFnContext
|
|
2279
|
-
);
|
|
2280
|
-
} catch (e) {
|
|
2281
|
-
void Promise.reject(e);
|
|
2282
|
-
}
|
|
2283
|
-
try {
|
|
2284
|
-
await this.options.onError?.(
|
|
2285
|
-
error,
|
|
2286
|
-
variables,
|
|
2287
|
-
this.state.context,
|
|
2288
|
-
mutationFnContext
|
|
2289
|
-
);
|
|
2290
|
-
} catch (e) {
|
|
2291
|
-
void Promise.reject(e);
|
|
2292
|
-
}
|
|
2293
|
-
try {
|
|
2294
|
-
await this.#mutationCache.config.onSettled?.(
|
|
2295
|
-
void 0,
|
|
2296
|
-
error,
|
|
2297
|
-
this.state.variables,
|
|
2298
|
-
this.state.context,
|
|
2299
|
-
this,
|
|
2300
|
-
mutationFnContext
|
|
2301
|
-
);
|
|
2302
|
-
} catch (e) {
|
|
2303
|
-
void Promise.reject(e);
|
|
2304
|
-
}
|
|
2305
|
-
try {
|
|
2306
|
-
await this.options.onSettled?.(
|
|
2307
|
-
void 0,
|
|
2308
|
-
error,
|
|
2309
|
-
variables,
|
|
2310
|
-
this.state.context,
|
|
2311
|
-
mutationFnContext
|
|
2312
|
-
);
|
|
2313
|
-
} catch (e) {
|
|
2314
|
-
void Promise.reject(e);
|
|
2315
|
-
}
|
|
2316
|
-
this.#dispatch({ type: "error", error });
|
|
2317
|
-
throw error;
|
|
2318
|
-
} finally {
|
|
2319
|
-
this.#mutationCache.runNext(this);
|
|
2320
|
-
}
|
|
2321
|
-
}
|
|
2322
|
-
#dispatch(action) {
|
|
2323
|
-
const reducer = (state) => {
|
|
2324
|
-
switch (action.type) {
|
|
2325
|
-
case "failed":
|
|
2326
|
-
return {
|
|
2327
|
-
...state,
|
|
2328
|
-
failureCount: action.failureCount,
|
|
2329
|
-
failureReason: action.error
|
|
2330
|
-
};
|
|
2331
|
-
case "pause":
|
|
2332
|
-
return {
|
|
2333
|
-
...state,
|
|
2334
|
-
isPaused: true
|
|
2335
|
-
};
|
|
2336
|
-
case "continue":
|
|
2337
|
-
return {
|
|
2338
|
-
...state,
|
|
2339
|
-
isPaused: false
|
|
2340
|
-
};
|
|
2341
|
-
case "pending":
|
|
2342
|
-
return {
|
|
2343
|
-
...state,
|
|
2344
|
-
context: action.context,
|
|
2345
|
-
data: void 0,
|
|
2346
|
-
failureCount: 0,
|
|
2347
|
-
failureReason: null,
|
|
2348
|
-
error: null,
|
|
2349
|
-
isPaused: action.isPaused,
|
|
2350
|
-
status: "pending",
|
|
2351
|
-
variables: action.variables,
|
|
2352
|
-
submittedAt: Date.now()
|
|
2353
|
-
};
|
|
2354
|
-
case "success":
|
|
2355
|
-
return {
|
|
2356
|
-
...state,
|
|
2357
|
-
data: action.data,
|
|
2358
|
-
failureCount: 0,
|
|
2359
|
-
failureReason: null,
|
|
2360
|
-
error: null,
|
|
2361
|
-
status: "success",
|
|
2362
|
-
isPaused: false
|
|
2363
|
-
};
|
|
2364
|
-
case "error":
|
|
2365
|
-
return {
|
|
2366
|
-
...state,
|
|
2367
|
-
data: void 0,
|
|
2368
|
-
error: action.error,
|
|
2369
|
-
failureCount: state.failureCount + 1,
|
|
2370
|
-
failureReason: action.error,
|
|
2371
|
-
isPaused: false,
|
|
2372
|
-
status: "error"
|
|
2373
|
-
};
|
|
2374
|
-
}
|
|
2375
|
-
};
|
|
2376
|
-
this.state = reducer(this.state);
|
|
2377
|
-
notifyManager.batch(() => {
|
|
2378
|
-
this.#observers.forEach((observer) => {
|
|
2379
|
-
observer.onMutationUpdate(action);
|
|
2380
|
-
});
|
|
2381
|
-
this.#mutationCache.notify({
|
|
2382
|
-
mutation: this,
|
|
2383
|
-
type: "updated",
|
|
2384
|
-
action
|
|
2385
|
-
});
|
|
2386
|
-
});
|
|
2387
|
-
}
|
|
2388
|
-
};
|
|
2389
|
-
function getDefaultState2() {
|
|
2390
|
-
return {
|
|
2391
|
-
context: void 0,
|
|
2392
|
-
data: void 0,
|
|
2393
|
-
error: null,
|
|
2394
|
-
failureCount: 0,
|
|
2395
|
-
failureReason: null,
|
|
2396
|
-
isPaused: false,
|
|
2397
|
-
status: "idle",
|
|
2398
|
-
variables: void 0,
|
|
2399
|
-
submittedAt: 0
|
|
2400
|
-
};
|
|
2401
|
-
}
|
|
2402
|
-
|
|
2403
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/mutationCache.js
|
|
2404
|
-
var MutationCache = class extends Subscribable {
|
|
2405
|
-
constructor(config = {}) {
|
|
2406
|
-
super();
|
|
2407
|
-
this.config = config;
|
|
2408
|
-
this.#mutations = /* @__PURE__ */ new Set();
|
|
2409
|
-
this.#scopes = /* @__PURE__ */ new Map();
|
|
2410
|
-
this.#mutationId = 0;
|
|
2411
|
-
}
|
|
2412
|
-
#mutations;
|
|
2413
|
-
#scopes;
|
|
2414
|
-
#mutationId;
|
|
2415
|
-
build(client, options, state) {
|
|
2416
|
-
const mutation = new Mutation({
|
|
2417
|
-
client,
|
|
2418
|
-
mutationCache: this,
|
|
2419
|
-
mutationId: ++this.#mutationId,
|
|
2420
|
-
options: client.defaultMutationOptions(options),
|
|
2421
|
-
state
|
|
2422
|
-
});
|
|
2423
|
-
this.add(mutation);
|
|
2424
|
-
return mutation;
|
|
2425
|
-
}
|
|
2426
|
-
add(mutation) {
|
|
2427
|
-
this.#mutations.add(mutation);
|
|
2428
|
-
const scope = scopeFor(mutation);
|
|
2429
|
-
if (typeof scope === "string") {
|
|
2430
|
-
const scopedMutations = this.#scopes.get(scope);
|
|
2431
|
-
if (scopedMutations) {
|
|
2432
|
-
scopedMutations.push(mutation);
|
|
2433
|
-
} else {
|
|
2434
|
-
this.#scopes.set(scope, [mutation]);
|
|
2435
|
-
}
|
|
2436
|
-
}
|
|
2437
|
-
this.notify({ type: "added", mutation });
|
|
2438
|
-
}
|
|
2439
|
-
remove(mutation) {
|
|
2440
|
-
if (this.#mutations.delete(mutation)) {
|
|
2441
|
-
const scope = scopeFor(mutation);
|
|
2442
|
-
if (typeof scope === "string") {
|
|
2443
|
-
const scopedMutations = this.#scopes.get(scope);
|
|
2444
|
-
if (scopedMutations) {
|
|
2445
|
-
if (scopedMutations.length > 1) {
|
|
2446
|
-
const index = scopedMutations.indexOf(mutation);
|
|
2447
|
-
if (index !== -1) {
|
|
2448
|
-
scopedMutations.splice(index, 1);
|
|
2449
|
-
}
|
|
2450
|
-
} else if (scopedMutations[0] === mutation) {
|
|
2451
|
-
this.#scopes.delete(scope);
|
|
2452
|
-
}
|
|
2453
|
-
}
|
|
2454
|
-
}
|
|
2455
|
-
}
|
|
2456
|
-
this.notify({ type: "removed", mutation });
|
|
2457
|
-
}
|
|
2458
|
-
canRun(mutation) {
|
|
2459
|
-
const scope = scopeFor(mutation);
|
|
2460
|
-
if (typeof scope === "string") {
|
|
2461
|
-
const mutationsWithSameScope = this.#scopes.get(scope);
|
|
2462
|
-
const firstPendingMutation = mutationsWithSameScope?.find(
|
|
2463
|
-
(m) => m.state.status === "pending"
|
|
2464
|
-
);
|
|
2465
|
-
return !firstPendingMutation || firstPendingMutation === mutation;
|
|
2466
|
-
} else {
|
|
2467
|
-
return true;
|
|
2468
|
-
}
|
|
2469
|
-
}
|
|
2470
|
-
runNext(mutation) {
|
|
2471
|
-
const scope = scopeFor(mutation);
|
|
2472
|
-
if (typeof scope === "string") {
|
|
2473
|
-
const foundMutation = this.#scopes.get(scope)?.find((m) => m !== mutation && m.state.isPaused);
|
|
2474
|
-
return foundMutation?.continue() ?? Promise.resolve();
|
|
2475
|
-
} else {
|
|
2476
|
-
return Promise.resolve();
|
|
2477
|
-
}
|
|
2478
|
-
}
|
|
2479
|
-
clear() {
|
|
2480
|
-
notifyManager.batch(() => {
|
|
2481
|
-
this.#mutations.forEach((mutation) => {
|
|
2482
|
-
this.notify({ type: "removed", mutation });
|
|
2483
|
-
});
|
|
2484
|
-
this.#mutations.clear();
|
|
2485
|
-
this.#scopes.clear();
|
|
2486
|
-
});
|
|
2487
|
-
}
|
|
2488
|
-
getAll() {
|
|
2489
|
-
return Array.from(this.#mutations);
|
|
2490
|
-
}
|
|
2491
|
-
find(filters) {
|
|
2492
|
-
const defaultedFilters = { exact: true, ...filters };
|
|
2493
|
-
return this.getAll().find(
|
|
2494
|
-
(mutation) => matchMutation(defaultedFilters, mutation)
|
|
2495
|
-
);
|
|
2496
|
-
}
|
|
2497
|
-
findAll(filters = {}) {
|
|
2498
|
-
return this.getAll().filter((mutation) => matchMutation(filters, mutation));
|
|
2499
|
-
}
|
|
2500
|
-
notify(event) {
|
|
2501
|
-
notifyManager.batch(() => {
|
|
2502
|
-
this.listeners.forEach((listener) => {
|
|
2503
|
-
listener(event);
|
|
2504
|
-
});
|
|
2505
|
-
});
|
|
2506
|
-
}
|
|
2507
|
-
resumePausedMutations() {
|
|
2508
|
-
const pausedMutations = this.getAll().filter((x) => x.state.isPaused);
|
|
2509
|
-
return notifyManager.batch(
|
|
2510
|
-
() => Promise.all(
|
|
2511
|
-
pausedMutations.map((mutation) => mutation.continue().catch(noop))
|
|
2512
|
-
)
|
|
2513
|
-
);
|
|
2514
|
-
}
|
|
2515
|
-
};
|
|
2516
|
-
function scopeFor(mutation) {
|
|
2517
|
-
return mutation.options.scope?.id;
|
|
2518
|
-
}
|
|
2519
|
-
|
|
2520
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/queryCache.js
|
|
2521
|
-
var QueryCache = class extends Subscribable {
|
|
2522
|
-
constructor(config = {}) {
|
|
2523
|
-
super();
|
|
2524
|
-
this.config = config;
|
|
2525
|
-
this.#queries = /* @__PURE__ */ new Map();
|
|
2526
|
-
}
|
|
2527
|
-
#queries;
|
|
2528
|
-
build(client, options, state) {
|
|
2529
|
-
const queryKey = options.queryKey;
|
|
2530
|
-
const queryHash = options.queryHash ?? hashQueryKeyByOptions(queryKey, options);
|
|
2531
|
-
let query = this.get(queryHash);
|
|
2532
|
-
if (!query) {
|
|
2533
|
-
query = new Query({
|
|
2534
|
-
client,
|
|
2535
|
-
queryKey,
|
|
2536
|
-
queryHash,
|
|
2537
|
-
options: client.defaultQueryOptions(options),
|
|
2538
|
-
state,
|
|
2539
|
-
defaultOptions: client.getQueryDefaults(queryKey)
|
|
2540
|
-
});
|
|
2541
|
-
this.add(query);
|
|
2542
|
-
}
|
|
2543
|
-
return query;
|
|
2544
|
-
}
|
|
2545
|
-
add(query) {
|
|
2546
|
-
if (!this.#queries.has(query.queryHash)) {
|
|
2547
|
-
this.#queries.set(query.queryHash, query);
|
|
2548
|
-
this.notify({
|
|
2549
|
-
type: "added",
|
|
2550
|
-
query
|
|
2551
|
-
});
|
|
2552
|
-
}
|
|
2553
|
-
}
|
|
2554
|
-
remove(query) {
|
|
2555
|
-
const queryInMap = this.#queries.get(query.queryHash);
|
|
2556
|
-
if (queryInMap) {
|
|
2557
|
-
query.destroy();
|
|
2558
|
-
if (queryInMap === query) {
|
|
2559
|
-
this.#queries.delete(query.queryHash);
|
|
2560
|
-
}
|
|
2561
|
-
this.notify({ type: "removed", query });
|
|
2562
|
-
}
|
|
2563
|
-
}
|
|
2564
|
-
clear() {
|
|
2565
|
-
notifyManager.batch(() => {
|
|
2566
|
-
this.getAll().forEach((query) => {
|
|
2567
|
-
this.remove(query);
|
|
2568
|
-
});
|
|
2569
|
-
});
|
|
2570
|
-
}
|
|
2571
|
-
get(queryHash) {
|
|
2572
|
-
return this.#queries.get(queryHash);
|
|
2573
|
-
}
|
|
2574
|
-
getAll() {
|
|
2575
|
-
return [...this.#queries.values()];
|
|
2576
|
-
}
|
|
2577
|
-
find(filters) {
|
|
2578
|
-
const defaultedFilters = { exact: true, ...filters };
|
|
2579
|
-
return this.getAll().find(
|
|
2580
|
-
(query) => matchQuery(defaultedFilters, query)
|
|
2581
|
-
);
|
|
2582
|
-
}
|
|
2583
|
-
findAll(filters = {}) {
|
|
2584
|
-
const queries = this.getAll();
|
|
2585
|
-
return Object.keys(filters).length > 0 ? queries.filter((query) => matchQuery(filters, query)) : queries;
|
|
2586
|
-
}
|
|
2587
|
-
notify(event) {
|
|
2588
|
-
notifyManager.batch(() => {
|
|
2589
|
-
this.listeners.forEach((listener) => {
|
|
2590
|
-
listener(event);
|
|
2591
|
-
});
|
|
2592
|
-
});
|
|
2593
|
-
}
|
|
2594
|
-
onFocus() {
|
|
2595
|
-
notifyManager.batch(() => {
|
|
2596
|
-
this.getAll().forEach((query) => {
|
|
2597
|
-
query.onFocus();
|
|
2598
|
-
});
|
|
2599
|
-
});
|
|
2600
|
-
}
|
|
2601
|
-
onOnline() {
|
|
2602
|
-
notifyManager.batch(() => {
|
|
2603
|
-
this.getAll().forEach((query) => {
|
|
2604
|
-
query.onOnline();
|
|
2605
|
-
});
|
|
2606
|
-
});
|
|
2607
|
-
}
|
|
2608
|
-
};
|
|
2609
|
-
|
|
2610
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/queryClient.js
|
|
2611
|
-
var QueryClient = class {
|
|
2612
|
-
#queryCache;
|
|
2613
|
-
#mutationCache;
|
|
2614
|
-
#defaultOptions;
|
|
2615
|
-
#queryDefaults;
|
|
2616
|
-
#mutationDefaults;
|
|
2617
|
-
#mountCount;
|
|
2618
|
-
#unsubscribeFocus;
|
|
2619
|
-
#unsubscribeOnline;
|
|
2620
|
-
constructor(config = {}) {
|
|
2621
|
-
this.#queryCache = config.queryCache || new QueryCache();
|
|
2622
|
-
this.#mutationCache = config.mutationCache || new MutationCache();
|
|
2623
|
-
this.#defaultOptions = config.defaultOptions || {};
|
|
2624
|
-
this.#queryDefaults = /* @__PURE__ */ new Map();
|
|
2625
|
-
this.#mutationDefaults = /* @__PURE__ */ new Map();
|
|
2626
|
-
this.#mountCount = 0;
|
|
2627
|
-
}
|
|
2628
|
-
mount() {
|
|
2629
|
-
this.#mountCount++;
|
|
2630
|
-
if (this.#mountCount !== 1) return;
|
|
2631
|
-
this.#unsubscribeFocus = focusManager.subscribe(async (focused) => {
|
|
2632
|
-
if (focused) {
|
|
2633
|
-
await this.resumePausedMutations();
|
|
2634
|
-
this.#queryCache.onFocus();
|
|
2635
|
-
}
|
|
2636
|
-
});
|
|
2637
|
-
this.#unsubscribeOnline = onlineManager.subscribe(async (online) => {
|
|
2638
|
-
if (online) {
|
|
2639
|
-
await this.resumePausedMutations();
|
|
2640
|
-
this.#queryCache.onOnline();
|
|
2641
|
-
}
|
|
2642
|
-
});
|
|
2643
|
-
}
|
|
2644
|
-
unmount() {
|
|
2645
|
-
this.#mountCount--;
|
|
2646
|
-
if (this.#mountCount !== 0) return;
|
|
2647
|
-
this.#unsubscribeFocus?.();
|
|
2648
|
-
this.#unsubscribeFocus = void 0;
|
|
2649
|
-
this.#unsubscribeOnline?.();
|
|
2650
|
-
this.#unsubscribeOnline = void 0;
|
|
2651
|
-
}
|
|
2652
|
-
isFetching(filters) {
|
|
2653
|
-
return this.#queryCache.findAll({ ...filters, fetchStatus: "fetching" }).length;
|
|
2654
|
-
}
|
|
2655
|
-
isMutating(filters) {
|
|
2656
|
-
return this.#mutationCache.findAll({ ...filters, status: "pending" }).length;
|
|
2657
|
-
}
|
|
2658
|
-
/**
|
|
2659
|
-
* Imperative (non-reactive) way to retrieve data for a QueryKey.
|
|
2660
|
-
* Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.
|
|
2661
|
-
*
|
|
2662
|
-
* Hint: Do not use this function inside a component, because it won't receive updates.
|
|
2663
|
-
* Use `useQuery` to create a `QueryObserver` that subscribes to changes.
|
|
2664
|
-
*/
|
|
2665
|
-
getQueryData(queryKey) {
|
|
2666
|
-
const options = this.defaultQueryOptions({ queryKey });
|
|
2667
|
-
return this.#queryCache.get(options.queryHash)?.state.data;
|
|
2668
|
-
}
|
|
2669
|
-
ensureQueryData(options) {
|
|
2670
|
-
const defaultedOptions = this.defaultQueryOptions(options);
|
|
2671
|
-
const query = this.#queryCache.build(this, defaultedOptions);
|
|
2672
|
-
const cachedData = query.state.data;
|
|
2673
|
-
if (cachedData === void 0) {
|
|
2674
|
-
return this.fetchQuery(options);
|
|
2675
|
-
}
|
|
2676
|
-
if (options.revalidateIfStale && query.isStaleByTime(resolveStaleTime(defaultedOptions.staleTime, query))) {
|
|
2677
|
-
void this.prefetchQuery(defaultedOptions);
|
|
2678
|
-
}
|
|
2679
|
-
return Promise.resolve(cachedData);
|
|
2680
|
-
}
|
|
2681
|
-
getQueriesData(filters) {
|
|
2682
|
-
return this.#queryCache.findAll(filters).map(({ queryKey, state }) => {
|
|
2683
|
-
const data = state.data;
|
|
2684
|
-
return [queryKey, data];
|
|
2685
|
-
});
|
|
2686
|
-
}
|
|
2687
|
-
setQueryData(queryKey, updater, options) {
|
|
2688
|
-
const defaultedOptions = this.defaultQueryOptions({ queryKey });
|
|
2689
|
-
const query = this.#queryCache.get(
|
|
2690
|
-
defaultedOptions.queryHash
|
|
2691
|
-
);
|
|
2692
|
-
const prevData = query?.state.data;
|
|
2693
|
-
const data = functionalUpdate(updater, prevData);
|
|
2694
|
-
if (data === void 0) {
|
|
2695
|
-
return void 0;
|
|
2696
|
-
}
|
|
2697
|
-
return this.#queryCache.build(this, defaultedOptions).setData(data, { ...options, manual: true });
|
|
2698
|
-
}
|
|
2699
|
-
setQueriesData(filters, updater, options) {
|
|
2700
|
-
return notifyManager.batch(
|
|
2701
|
-
() => this.#queryCache.findAll(filters).map(({ queryKey }) => [
|
|
2702
|
-
queryKey,
|
|
2703
|
-
this.setQueryData(queryKey, updater, options)
|
|
2704
|
-
])
|
|
2705
|
-
);
|
|
2706
|
-
}
|
|
2707
|
-
getQueryState(queryKey) {
|
|
2708
|
-
const options = this.defaultQueryOptions({ queryKey });
|
|
2709
|
-
return this.#queryCache.get(
|
|
2710
|
-
options.queryHash
|
|
2711
|
-
)?.state;
|
|
2712
|
-
}
|
|
2713
|
-
removeQueries(filters) {
|
|
2714
|
-
const queryCache = this.#queryCache;
|
|
2715
|
-
notifyManager.batch(() => {
|
|
2716
|
-
queryCache.findAll(filters).forEach((query) => {
|
|
2717
|
-
queryCache.remove(query);
|
|
2718
|
-
});
|
|
2719
|
-
});
|
|
2720
|
-
}
|
|
2721
|
-
resetQueries(filters, options) {
|
|
2722
|
-
const queryCache = this.#queryCache;
|
|
2723
|
-
return notifyManager.batch(() => {
|
|
2724
|
-
queryCache.findAll(filters).forEach((query) => {
|
|
2725
|
-
query.reset();
|
|
2726
|
-
});
|
|
2727
|
-
return this.refetchQueries(
|
|
2728
|
-
{
|
|
2729
|
-
type: "active",
|
|
2730
|
-
...filters
|
|
2731
|
-
},
|
|
2732
|
-
options
|
|
2733
|
-
);
|
|
2734
|
-
});
|
|
2735
|
-
}
|
|
2736
|
-
cancelQueries(filters, cancelOptions = {}) {
|
|
2737
|
-
const defaultedCancelOptions = { revert: true, ...cancelOptions };
|
|
2738
|
-
const promises = notifyManager.batch(
|
|
2739
|
-
() => this.#queryCache.findAll(filters).map((query) => query.cancel(defaultedCancelOptions))
|
|
2740
|
-
);
|
|
2741
|
-
return Promise.all(promises).then(noop).catch(noop);
|
|
2742
|
-
}
|
|
2743
|
-
invalidateQueries(filters, options = {}) {
|
|
2744
|
-
return notifyManager.batch(() => {
|
|
2745
|
-
this.#queryCache.findAll(filters).forEach((query) => {
|
|
2746
|
-
query.invalidate();
|
|
2747
|
-
});
|
|
2748
|
-
if (filters?.refetchType === "none") {
|
|
2749
|
-
return Promise.resolve();
|
|
2750
|
-
}
|
|
2751
|
-
return this.refetchQueries(
|
|
2752
|
-
{
|
|
2753
|
-
...filters,
|
|
2754
|
-
type: filters?.refetchType ?? filters?.type ?? "active"
|
|
2755
|
-
},
|
|
2756
|
-
options
|
|
2757
|
-
);
|
|
2758
|
-
});
|
|
2759
|
-
}
|
|
2760
|
-
refetchQueries(filters, options = {}) {
|
|
2761
|
-
const fetchOptions = {
|
|
2762
|
-
...options,
|
|
2763
|
-
cancelRefetch: options.cancelRefetch ?? true
|
|
2764
|
-
};
|
|
2765
|
-
const promises = notifyManager.batch(
|
|
2766
|
-
() => this.#queryCache.findAll(filters).filter((query) => !query.isDisabled() && !query.isStatic()).map((query) => {
|
|
2767
|
-
let promise = query.fetch(void 0, fetchOptions);
|
|
2768
|
-
if (!fetchOptions.throwOnError) {
|
|
2769
|
-
promise = promise.catch(noop);
|
|
2770
|
-
}
|
|
2771
|
-
return query.state.fetchStatus === "paused" ? Promise.resolve() : promise;
|
|
2772
|
-
})
|
|
2773
|
-
);
|
|
2774
|
-
return Promise.all(promises).then(noop);
|
|
2775
|
-
}
|
|
2776
|
-
fetchQuery(options) {
|
|
2777
|
-
const defaultedOptions = this.defaultQueryOptions(options);
|
|
2778
|
-
if (defaultedOptions.retry === void 0) {
|
|
2779
|
-
defaultedOptions.retry = false;
|
|
2780
|
-
}
|
|
2781
|
-
const query = this.#queryCache.build(this, defaultedOptions);
|
|
2782
|
-
return query.isStaleByTime(
|
|
2783
|
-
resolveStaleTime(defaultedOptions.staleTime, query)
|
|
2784
|
-
) ? query.fetch(defaultedOptions) : Promise.resolve(query.state.data);
|
|
2785
|
-
}
|
|
2786
|
-
prefetchQuery(options) {
|
|
2787
|
-
return this.fetchQuery(options).then(noop).catch(noop);
|
|
2788
|
-
}
|
|
2789
|
-
fetchInfiniteQuery(options) {
|
|
2790
|
-
options.behavior = infiniteQueryBehavior(options.pages);
|
|
2791
|
-
return this.fetchQuery(options);
|
|
2792
|
-
}
|
|
2793
|
-
prefetchInfiniteQuery(options) {
|
|
2794
|
-
return this.fetchInfiniteQuery(options).then(noop).catch(noop);
|
|
2795
|
-
}
|
|
2796
|
-
ensureInfiniteQueryData(options) {
|
|
2797
|
-
options.behavior = infiniteQueryBehavior(options.pages);
|
|
2798
|
-
return this.ensureQueryData(options);
|
|
2799
|
-
}
|
|
2800
|
-
resumePausedMutations() {
|
|
2801
|
-
if (onlineManager.isOnline()) {
|
|
2802
|
-
return this.#mutationCache.resumePausedMutations();
|
|
2803
|
-
}
|
|
2804
|
-
return Promise.resolve();
|
|
2805
|
-
}
|
|
2806
|
-
getQueryCache() {
|
|
2807
|
-
return this.#queryCache;
|
|
2808
|
-
}
|
|
2809
|
-
getMutationCache() {
|
|
2810
|
-
return this.#mutationCache;
|
|
2811
|
-
}
|
|
2812
|
-
getDefaultOptions() {
|
|
2813
|
-
return this.#defaultOptions;
|
|
2814
|
-
}
|
|
2815
|
-
setDefaultOptions(options) {
|
|
2816
|
-
this.#defaultOptions = options;
|
|
2817
|
-
}
|
|
2818
|
-
setQueryDefaults(queryKey, options) {
|
|
2819
|
-
this.#queryDefaults.set(hashKey(queryKey), {
|
|
2820
|
-
queryKey,
|
|
2821
|
-
defaultOptions: options
|
|
2822
|
-
});
|
|
2823
|
-
}
|
|
2824
|
-
getQueryDefaults(queryKey) {
|
|
2825
|
-
const defaults = [...this.#queryDefaults.values()];
|
|
2826
|
-
const result = {};
|
|
2827
|
-
defaults.forEach((queryDefault) => {
|
|
2828
|
-
if (partialMatchKey(queryKey, queryDefault.queryKey)) {
|
|
2829
|
-
Object.assign(result, queryDefault.defaultOptions);
|
|
2830
|
-
}
|
|
2831
|
-
});
|
|
2832
|
-
return result;
|
|
2833
|
-
}
|
|
2834
|
-
setMutationDefaults(mutationKey, options) {
|
|
2835
|
-
this.#mutationDefaults.set(hashKey(mutationKey), {
|
|
2836
|
-
mutationKey,
|
|
2837
|
-
defaultOptions: options
|
|
2838
|
-
});
|
|
2839
|
-
}
|
|
2840
|
-
getMutationDefaults(mutationKey) {
|
|
2841
|
-
const defaults = [...this.#mutationDefaults.values()];
|
|
2842
|
-
const result = {};
|
|
2843
|
-
defaults.forEach((queryDefault) => {
|
|
2844
|
-
if (partialMatchKey(mutationKey, queryDefault.mutationKey)) {
|
|
2845
|
-
Object.assign(result, queryDefault.defaultOptions);
|
|
2846
|
-
}
|
|
2847
|
-
});
|
|
2848
|
-
return result;
|
|
2849
|
-
}
|
|
2850
|
-
defaultQueryOptions(options) {
|
|
2851
|
-
if (options._defaulted) {
|
|
2852
|
-
return options;
|
|
2853
|
-
}
|
|
2854
|
-
const defaultedOptions = {
|
|
2855
|
-
...this.#defaultOptions.queries,
|
|
2856
|
-
...this.getQueryDefaults(options.queryKey),
|
|
2857
|
-
...options,
|
|
2858
|
-
_defaulted: true
|
|
2859
|
-
};
|
|
2860
|
-
if (!defaultedOptions.queryHash) {
|
|
2861
|
-
defaultedOptions.queryHash = hashQueryKeyByOptions(
|
|
2862
|
-
defaultedOptions.queryKey,
|
|
2863
|
-
defaultedOptions
|
|
2864
|
-
);
|
|
2865
|
-
}
|
|
2866
|
-
if (defaultedOptions.refetchOnReconnect === void 0) {
|
|
2867
|
-
defaultedOptions.refetchOnReconnect = defaultedOptions.networkMode !== "always";
|
|
2868
|
-
}
|
|
2869
|
-
if (defaultedOptions.throwOnError === void 0) {
|
|
2870
|
-
defaultedOptions.throwOnError = !!defaultedOptions.suspense;
|
|
2871
|
-
}
|
|
2872
|
-
if (!defaultedOptions.networkMode && defaultedOptions.persister) {
|
|
2873
|
-
defaultedOptions.networkMode = "offlineFirst";
|
|
2874
|
-
}
|
|
2875
|
-
if (defaultedOptions.queryFn === skipToken) {
|
|
2876
|
-
defaultedOptions.enabled = false;
|
|
2877
|
-
}
|
|
2878
|
-
return defaultedOptions;
|
|
2879
|
-
}
|
|
2880
|
-
defaultMutationOptions(options) {
|
|
2881
|
-
if (options?._defaulted) {
|
|
2882
|
-
return options;
|
|
2883
|
-
}
|
|
2884
|
-
return {
|
|
2885
|
-
...this.#defaultOptions.mutations,
|
|
2886
|
-
...options?.mutationKey && this.getMutationDefaults(options.mutationKey),
|
|
2887
|
-
...options,
|
|
2888
|
-
_defaulted: true
|
|
2889
|
-
};
|
|
2890
|
-
}
|
|
2891
|
-
clear() {
|
|
2892
|
-
this.#queryCache.clear();
|
|
2893
|
-
this.#mutationCache.clear();
|
|
2894
|
-
}
|
|
2895
|
-
};
|
|
2896
|
-
|
|
2897
|
-
// ../../node_modules/.bun/@tanstack+react-query@5.90.21+b1ab299f0a400331/node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js
|
|
2898
|
-
import * as React2 from "react";
|
|
2899
|
-
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
2900
|
-
var QueryClientContext = React2.createContext(
|
|
2901
|
-
void 0
|
|
2902
|
-
);
|
|
2903
|
-
var QueryClientProvider = ({
|
|
2904
|
-
client,
|
|
2905
|
-
children
|
|
2906
|
-
}) => {
|
|
2907
|
-
React2.useEffect(() => {
|
|
2908
|
-
client.mount();
|
|
2909
|
-
return () => {
|
|
2910
|
-
client.unmount();
|
|
2911
|
-
};
|
|
2912
|
-
}, [client]);
|
|
2913
|
-
return /* @__PURE__ */ jsx26(QueryClientContext.Provider, { value: client, children });
|
|
2914
|
-
};
|
|
2915
|
-
|
|
2916
|
-
// src/components/providers/query-provider.tsx
|
|
914
|
+
import { QueryCache, QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
2917
915
|
import { CircleAlertIcon as CircleAlertIcon2 } from "lucide-react";
|
|
2918
916
|
import { toast as toast2 } from "sonner";
|
|
2919
|
-
import { Alert as Alert2, AlertTitle as AlertTitle2 } from "@pelatform/ui.components/
|
|
2920
|
-
import { jsx as
|
|
917
|
+
import { Alert as Alert2, AlertTitle as AlertTitle2 } from "@pelatform/ui.components/radix";
|
|
918
|
+
import { jsx as jsx26, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2921
919
|
var QueryProvider = ({
|
|
2922
920
|
client: clientProps,
|
|
2923
921
|
children
|
|
@@ -2966,8 +964,8 @@ var QueryProvider = ({
|
|
|
2966
964
|
}
|
|
2967
965
|
toast2.custom(
|
|
2968
966
|
() => /* @__PURE__ */ jsxs17(Alert2, { variant: "default", children: [
|
|
2969
|
-
/* @__PURE__ */
|
|
2970
|
-
/* @__PURE__ */
|
|
967
|
+
/* @__PURE__ */ jsx26(CircleAlertIcon2, {}),
|
|
968
|
+
/* @__PURE__ */ jsx26(AlertTitle2, { children: message })
|
|
2971
969
|
] }),
|
|
2972
970
|
{
|
|
2973
971
|
position: "top-center",
|
|
@@ -2981,15 +979,15 @@ var QueryProvider = ({
|
|
|
2981
979
|
})
|
|
2982
980
|
})
|
|
2983
981
|
);
|
|
2984
|
-
return /* @__PURE__ */
|
|
982
|
+
return /* @__PURE__ */ jsx26(QueryClientProvider, { client: clientProps ?? queryClient, children });
|
|
2985
983
|
};
|
|
2986
984
|
|
|
2987
985
|
// src/components/providers/theme-provider.tsx
|
|
2988
986
|
import { ThemeProvider as NextThemesProvider } from "next-themes";
|
|
2989
|
-
import { TooltipProvider } from "@pelatform/ui.components/
|
|
2990
|
-
import { jsx as
|
|
987
|
+
import { TooltipProvider } from "@pelatform/ui.components/radix";
|
|
988
|
+
import { jsx as jsx27 } from "react/jsx-runtime";
|
|
2991
989
|
function ThemeProvider({ children, ...props }) {
|
|
2992
|
-
return /* @__PURE__ */
|
|
990
|
+
return /* @__PURE__ */ jsx27(
|
|
2993
991
|
NextThemesProvider,
|
|
2994
992
|
{
|
|
2995
993
|
attribute: "class",
|
|
@@ -3000,20 +998,20 @@ function ThemeProvider({ children, ...props }) {
|
|
|
3000
998
|
storageKey: "theme",
|
|
3001
999
|
themes: [THEME_MODES.LIGHT, THEME_MODES.DARK, THEME_MODES.SYSTEM],
|
|
3002
1000
|
...props,
|
|
3003
|
-
children: /* @__PURE__ */
|
|
1001
|
+
children: /* @__PURE__ */ jsx27(TooltipProvider, { delayDuration: 0, children })
|
|
3004
1002
|
}
|
|
3005
1003
|
);
|
|
3006
1004
|
}
|
|
3007
1005
|
|
|
3008
1006
|
// src/components/ui/announcement.tsx
|
|
3009
|
-
import { Badge as Badge2 } from "@pelatform/ui.components/
|
|
3010
|
-
import { jsx as
|
|
1007
|
+
import { Badge as Badge2 } from "@pelatform/ui.components/radix";
|
|
1008
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
3011
1009
|
var Announcement = ({
|
|
3012
1010
|
variant = "outline",
|
|
3013
1011
|
themed = false,
|
|
3014
1012
|
className,
|
|
3015
1013
|
...props
|
|
3016
|
-
}) => /* @__PURE__ */
|
|
1014
|
+
}) => /* @__PURE__ */ jsx28(
|
|
3017
1015
|
Badge2,
|
|
3018
1016
|
{
|
|
3019
1017
|
variant,
|
|
@@ -3026,7 +1024,7 @@ var Announcement = ({
|
|
|
3026
1024
|
...props
|
|
3027
1025
|
}
|
|
3028
1026
|
);
|
|
3029
|
-
var AnnouncementTag = ({ className, ...props }) => /* @__PURE__ */
|
|
1027
|
+
var AnnouncementTag = ({ className, ...props }) => /* @__PURE__ */ jsx28(
|
|
3030
1028
|
"div",
|
|
3031
1029
|
{
|
|
3032
1030
|
className: cn(
|
|
@@ -3037,11 +1035,11 @@ var AnnouncementTag = ({ className, ...props }) => /* @__PURE__ */ jsx29(
|
|
|
3037
1035
|
...props
|
|
3038
1036
|
}
|
|
3039
1037
|
);
|
|
3040
|
-
var AnnouncementTitle = ({ className, ...props }) => /* @__PURE__ */
|
|
1038
|
+
var AnnouncementTitle = ({ className, ...props }) => /* @__PURE__ */ jsx28("div", { className: cn("flex items-center gap-1 truncate py-1", className), ...props });
|
|
3041
1039
|
|
|
3042
1040
|
// src/components/ui/background-paths.tsx
|
|
3043
1041
|
import { motion } from "motion/react";
|
|
3044
|
-
import { jsx as
|
|
1042
|
+
import { jsx as jsx29, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
3045
1043
|
function FloatingPaths({
|
|
3046
1044
|
position,
|
|
3047
1045
|
color = "text-slate-950 dark:text-white"
|
|
@@ -3052,7 +1050,7 @@ function FloatingPaths({
|
|
|
3052
1050
|
color: `rgba(15,23,42,${0.1 + i * 0.03})`,
|
|
3053
1051
|
width: 0.5 + i * 0.03
|
|
3054
1052
|
}));
|
|
3055
|
-
return /* @__PURE__ */
|
|
1053
|
+
return /* @__PURE__ */ jsx29("div", { className: "pointer-events-none absolute inset-0 -z-50", children: /* @__PURE__ */ jsx29("svg", { className: cn("h-full w-full", color), viewBox: "0 0 696 316", fill: "none", children: paths.map((path) => /* @__PURE__ */ jsx29(
|
|
3056
1054
|
motion.path,
|
|
3057
1055
|
{
|
|
3058
1056
|
d: path.d,
|
|
@@ -3075,14 +1073,14 @@ function FloatingPaths({
|
|
|
3075
1073
|
)) }) });
|
|
3076
1074
|
}
|
|
3077
1075
|
function BackgroundPaths({ color = "text-slate-950 dark:text-white" }) {
|
|
3078
|
-
return /* @__PURE__ */
|
|
3079
|
-
/* @__PURE__ */
|
|
3080
|
-
/* @__PURE__ */
|
|
1076
|
+
return /* @__PURE__ */ jsx29("div", { className: "relative flex min-h-screen w-full items-center justify-center overflow-hidden bg-white dark:bg-neutral-950", children: /* @__PURE__ */ jsxs18("div", { className: "absolute inset-0", children: [
|
|
1077
|
+
/* @__PURE__ */ jsx29(FloatingPaths, { position: 1, color }),
|
|
1078
|
+
/* @__PURE__ */ jsx29(FloatingPaths, { position: -1, color })
|
|
3081
1079
|
] }) });
|
|
3082
1080
|
}
|
|
3083
1081
|
|
|
3084
1082
|
// src/components/ui/book.tsx
|
|
3085
|
-
import { jsx as
|
|
1083
|
+
import { jsx as jsx30, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
3086
1084
|
function Book(props) {
|
|
3087
1085
|
const {
|
|
3088
1086
|
children,
|
|
@@ -3094,7 +1092,7 @@ function Book(props) {
|
|
|
3094
1092
|
illustration,
|
|
3095
1093
|
width
|
|
3096
1094
|
} = props;
|
|
3097
|
-
return /* @__PURE__ */
|
|
1095
|
+
return /* @__PURE__ */ jsx30(
|
|
3098
1096
|
"div",
|
|
3099
1097
|
{
|
|
3100
1098
|
className: cn("group perspective-[900px] inline-block w-fit"),
|
|
@@ -3121,16 +1119,16 @@ function Book(props) {
|
|
|
3121
1119
|
"relative min-w-[calc(var(--book-width))] overflow-hidden bg-(--book-color)"
|
|
3122
1120
|
),
|
|
3123
1121
|
children: [
|
|
3124
|
-
/* @__PURE__ */
|
|
3125
|
-
illustration && /* @__PURE__ */
|
|
1122
|
+
/* @__PURE__ */ jsx30("div", { className: "absolute inset-y-0 min-w-[8.2%] bg-book-bind-bg opacity-100 mix-blend-overlay" }),
|
|
1123
|
+
illustration && /* @__PURE__ */ jsx30("div", { className: "object-cover", children: illustration })
|
|
3126
1124
|
]
|
|
3127
1125
|
}
|
|
3128
1126
|
),
|
|
3129
1127
|
/* @__PURE__ */ jsxs19(Stack, { grow: variant === "simple", direction: "row", className: "h-fit", children: [
|
|
3130
|
-
/* @__PURE__ */
|
|
3131
|
-
/* @__PURE__ */
|
|
1128
|
+
/* @__PURE__ */ jsx30("div", { className: "h-full min-w-[8.2%] bg-book-bind-bg opacity-100 mix-blend-overlay" }),
|
|
1129
|
+
/* @__PURE__ */ jsx30("div", { className: "w-full contain-inline-size", children })
|
|
3132
1130
|
] }),
|
|
3133
|
-
texture && /* @__PURE__ */
|
|
1131
|
+
texture && /* @__PURE__ */ jsx30(
|
|
3134
1132
|
"div",
|
|
3135
1133
|
{
|
|
3136
1134
|
"aria-hidden": true,
|
|
@@ -3140,7 +1138,7 @@ function Book(props) {
|
|
|
3140
1138
|
]
|
|
3141
1139
|
}
|
|
3142
1140
|
),
|
|
3143
|
-
/* @__PURE__ */
|
|
1141
|
+
/* @__PURE__ */ jsx30(
|
|
3144
1142
|
"div",
|
|
3145
1143
|
{
|
|
3146
1144
|
"aria-hidden": true,
|
|
@@ -3150,7 +1148,7 @@ function Book(props) {
|
|
|
3150
1148
|
}
|
|
3151
1149
|
}
|
|
3152
1150
|
),
|
|
3153
|
-
/* @__PURE__ */
|
|
1151
|
+
/* @__PURE__ */ jsx30(
|
|
3154
1152
|
"div",
|
|
3155
1153
|
{
|
|
3156
1154
|
"aria-hidden": true,
|
|
@@ -3178,7 +1176,7 @@ function Stack(props) {
|
|
|
3178
1176
|
className,
|
|
3179
1177
|
...etc
|
|
3180
1178
|
} = props;
|
|
3181
|
-
return /* @__PURE__ */
|
|
1179
|
+
return /* @__PURE__ */ jsx30(
|
|
3182
1180
|
"div",
|
|
3183
1181
|
{
|
|
3184
1182
|
className,
|
|
@@ -3202,7 +1200,7 @@ function Stack(props) {
|
|
|
3202
1200
|
|
|
3203
1201
|
// src/components/ui/dots-pattern.tsx
|
|
3204
1202
|
import { useId as useId2 } from "react";
|
|
3205
|
-
import { jsx as
|
|
1203
|
+
import { jsx as jsx31, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
3206
1204
|
function DotsPattern({
|
|
3207
1205
|
dotSize = 2,
|
|
3208
1206
|
gapSize = 10,
|
|
@@ -3217,7 +1215,7 @@ function DotsPattern({
|
|
|
3217
1215
|
width: "100%",
|
|
3218
1216
|
height: "100%",
|
|
3219
1217
|
children: [
|
|
3220
|
-
/* @__PURE__ */
|
|
1218
|
+
/* @__PURE__ */ jsx31("defs", { children: /* @__PURE__ */ jsx31(
|
|
3221
1219
|
"pattern",
|
|
3222
1220
|
{
|
|
3223
1221
|
id: `dots-${id}`,
|
|
@@ -3226,17 +1224,17 @@ function DotsPattern({
|
|
|
3226
1224
|
width: dotSize + gapSize,
|
|
3227
1225
|
height: dotSize + gapSize,
|
|
3228
1226
|
patternUnits: "userSpaceOnUse",
|
|
3229
|
-
children: /* @__PURE__ */
|
|
1227
|
+
children: /* @__PURE__ */ jsx31("rect", { x: 1, y: 1, width: dotSize, height: dotSize, fill: "currentColor" })
|
|
3230
1228
|
}
|
|
3231
1229
|
) }),
|
|
3232
|
-
/* @__PURE__ */
|
|
1230
|
+
/* @__PURE__ */ jsx31("rect", { fill: `url(#dots-${id})`, width: "100%", height: "100%" })
|
|
3233
1231
|
]
|
|
3234
1232
|
}
|
|
3235
1233
|
);
|
|
3236
1234
|
}
|
|
3237
1235
|
|
|
3238
1236
|
// src/components/ui/hexagon-badge.tsx
|
|
3239
|
-
import { jsx as
|
|
1237
|
+
import { jsx as jsx32, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
3240
1238
|
var HexagonBadge = ({ children, classNames }) => {
|
|
3241
1239
|
return /* @__PURE__ */ jsxs21("div", { className: cn("relative shrink-0", classNames?.base), children: [
|
|
3242
1240
|
/* @__PURE__ */ jsxs21(
|
|
@@ -3249,14 +1247,14 @@ var HexagonBadge = ({ children, classNames }) => {
|
|
|
3249
1247
|
fill: "none",
|
|
3250
1248
|
xmlns: "http://www.w3.org/2000/svg",
|
|
3251
1249
|
children: [
|
|
3252
|
-
/* @__PURE__ */
|
|
1250
|
+
/* @__PURE__ */ jsx32(
|
|
3253
1251
|
"path",
|
|
3254
1252
|
{
|
|
3255
1253
|
d: "M16 2.4641C19.7128 0.320509 24.2872 0.320508 28 2.4641L37.6506 8.0359C41.3634 10.1795 43.6506 14.141 43.6506\n 18.4282V29.5718C43.6506 33.859 41.3634 37.8205 37.6506 39.9641L28 45.5359C24.2872 47.6795 19.7128 47.6795 16 45.5359L6.34937\n 39.9641C2.63655 37.8205 0.349365 33.859 0.349365 29.5718V18.4282C0.349365 14.141 2.63655 10.1795 6.34937 8.0359L16 2.4641Z",
|
|
3256
1254
|
fill: ""
|
|
3257
1255
|
}
|
|
3258
1256
|
),
|
|
3259
|
-
/* @__PURE__ */
|
|
1257
|
+
/* @__PURE__ */ jsx32(
|
|
3260
1258
|
"path",
|
|
3261
1259
|
{
|
|
3262
1260
|
d: "M16.25 2.89711C19.8081 0.842838 24.1919 0.842837 27.75 2.89711L37.4006 8.46891C40.9587 10.5232 43.1506 14.3196 43.1506\n 18.4282V29.5718C43.1506 33.6804 40.9587 37.4768 37.4006 39.5311L27.75 45.1029C24.1919 47.1572 19.8081 47.1572 16.25 45.1029L6.59937\n 39.5311C3.04125 37.4768 0.849365 33.6803 0.849365 29.5718V18.4282C0.849365 14.3196 3.04125 10.5232 6.59937 8.46891L16.25 2.89711Z",
|
|
@@ -3266,7 +1264,7 @@ var HexagonBadge = ({ children, classNames }) => {
|
|
|
3266
1264
|
]
|
|
3267
1265
|
}
|
|
3268
1266
|
),
|
|
3269
|
-
/* @__PURE__ */
|
|
1267
|
+
/* @__PURE__ */ jsx32(
|
|
3270
1268
|
"div",
|
|
3271
1269
|
{
|
|
3272
1270
|
className: cn(
|
|
@@ -3285,7 +1283,7 @@ import {
|
|
|
3285
1283
|
useRef,
|
|
3286
1284
|
useState as useState4
|
|
3287
1285
|
} from "react";
|
|
3288
|
-
import { Fragment as Fragment3, jsx as
|
|
1286
|
+
import { Fragment as Fragment3, jsx as jsx33, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
3289
1287
|
var DEFAULT_NULL_INDEX = -1;
|
|
3290
1288
|
var DEFAULT_DATA_URL_KEY = "dataURL";
|
|
3291
1289
|
var openFileDialog = (inputRef) => {
|
|
@@ -3422,7 +1420,7 @@ var ImageInput = ({
|
|
|
3422
1420
|
e.dataTransfer.clearData();
|
|
3423
1421
|
};
|
|
3424
1422
|
return /* @__PURE__ */ jsxs22(Fragment3, { children: [
|
|
3425
|
-
/* @__PURE__ */
|
|
1423
|
+
/* @__PURE__ */ jsx33(
|
|
3426
1424
|
"input",
|
|
3427
1425
|
{
|
|
3428
1426
|
ref: inputRef,
|
|
@@ -3469,8 +1467,8 @@ import {
|
|
|
3469
1467
|
DropdownMenuSubContent as DropdownMenuSubContent2,
|
|
3470
1468
|
DropdownMenuSubTrigger as DropdownMenuSubTrigger2,
|
|
3471
1469
|
DropdownMenuTrigger as DropdownMenuTrigger2
|
|
3472
|
-
} from "@pelatform/ui.components/
|
|
3473
|
-
import { jsx as
|
|
1470
|
+
} from "@pelatform/ui.components/radix";
|
|
1471
|
+
import { jsx as jsx34, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
3474
1472
|
function getFlagUrl(flag) {
|
|
3475
1473
|
const flagCode = flag.toLowerCase();
|
|
3476
1474
|
return `"https://assets.pelatform.com"/media/flags/${flagCode}.svg`;
|
|
@@ -3505,7 +1503,7 @@ function LanguageSwitcher({
|
|
|
3505
1503
|
}
|
|
3506
1504
|
if (type === "dropdown") {
|
|
3507
1505
|
return /* @__PURE__ */ jsxs23(DropdownMenu2, { children: [
|
|
3508
|
-
/* @__PURE__ */
|
|
1506
|
+
/* @__PURE__ */ jsx34(DropdownMenuTrigger2, { asChild: true, children: /* @__PURE__ */ jsxs23(
|
|
3509
1507
|
Button5,
|
|
3510
1508
|
{
|
|
3511
1509
|
variant,
|
|
@@ -3517,33 +1515,41 @@ function LanguageSwitcher({
|
|
|
3517
1515
|
),
|
|
3518
1516
|
disabled: isPending,
|
|
3519
1517
|
children: [
|
|
3520
|
-
/* @__PURE__ */
|
|
3521
|
-
/* @__PURE__ */
|
|
1518
|
+
/* @__PURE__ */ jsx34(LanguagesIcon, { className: "size-4" }),
|
|
1519
|
+
/* @__PURE__ */ jsx34("span", { className: "sr-only", children: isPending ? "Changing language..." : "Language dropdown" })
|
|
3522
1520
|
]
|
|
3523
1521
|
}
|
|
3524
1522
|
) }),
|
|
3525
|
-
/* @__PURE__ */
|
|
3526
|
-
|
|
1523
|
+
/* @__PURE__ */ jsx34(
|
|
1524
|
+
DropdownMenuContent2,
|
|
3527
1525
|
{
|
|
3528
|
-
|
|
3529
|
-
className:
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
1526
|
+
align: "end",
|
|
1527
|
+
className: "min-w-[150px]",
|
|
1528
|
+
onCloseAutoFocus: (e) => e.preventDefault(),
|
|
1529
|
+
children: languages.map((lang) => /* @__PURE__ */ jsxs23(
|
|
1530
|
+
DropdownMenuItem2,
|
|
1531
|
+
{
|
|
1532
|
+
onClick: () => handleLanguageChange(lang.code),
|
|
1533
|
+
className: cn("gap-2", currentLocale === lang.code && "bg-accent"),
|
|
1534
|
+
children: [
|
|
1535
|
+
showFlags && lang.flag ? /* @__PURE__ */ jsx34(
|
|
1536
|
+
Image2,
|
|
1537
|
+
{
|
|
1538
|
+
src: customFlagUrl ? lang.flag : getFlagUrl(lang.flag),
|
|
1539
|
+
alt: `${lang.name} flag`,
|
|
1540
|
+
className: "size-4 rounded-full object-cover",
|
|
1541
|
+
width: 24,
|
|
1542
|
+
height: 24
|
|
1543
|
+
}
|
|
1544
|
+
) : showFlags ? /* @__PURE__ */ jsx34(GlobeIcon, { className: "size-4" }) : null,
|
|
1545
|
+
showNames && /* @__PURE__ */ jsx34("span", { className: "text-sm", children: lang.name }),
|
|
1546
|
+
currentLocale === lang.code && /* @__PURE__ */ jsx34("span", { className: "ms-auto text-muted-foreground text-xs", children: "\u2713" })
|
|
1547
|
+
]
|
|
1548
|
+
},
|
|
1549
|
+
lang.code
|
|
1550
|
+
))
|
|
1551
|
+
}
|
|
1552
|
+
)
|
|
3547
1553
|
] });
|
|
3548
1554
|
}
|
|
3549
1555
|
return /* @__PURE__ */ jsxs23(DropdownMenuSub2, { children: [
|
|
@@ -3555,12 +1561,12 @@ function LanguageSwitcher({
|
|
|
3555
1561
|
className
|
|
3556
1562
|
),
|
|
3557
1563
|
children: [
|
|
3558
|
-
/* @__PURE__ */
|
|
1564
|
+
/* @__PURE__ */ jsx34(GlobeIcon, { className: "size-4" }),
|
|
3559
1565
|
/* @__PURE__ */ jsxs23("span", { className: "relative flex grow items-center justify-between gap-2", children: [
|
|
3560
1566
|
label,
|
|
3561
1567
|
currentLanguage && /* @__PURE__ */ jsxs23(Badge3, { variant: "outline", className: "absolute end-0 top-1/2 -translate-y-1/2", children: [
|
|
3562
1568
|
currentLanguage.name,
|
|
3563
|
-
showFlags && currentLanguage.flag && /* @__PURE__ */
|
|
1569
|
+
showFlags && currentLanguage.flag && /* @__PURE__ */ jsx34(
|
|
3564
1570
|
Image2,
|
|
3565
1571
|
{
|
|
3566
1572
|
src: customFlagUrl ? currentLanguage.flag : getFlagUrl(currentLanguage.flag),
|
|
@@ -3575,7 +1581,7 @@ function LanguageSwitcher({
|
|
|
3575
1581
|
]
|
|
3576
1582
|
}
|
|
3577
1583
|
),
|
|
3578
|
-
/* @__PURE__ */
|
|
1584
|
+
/* @__PURE__ */ jsx34(DropdownMenuSubContent2, { className: "w-48", children: /* @__PURE__ */ jsx34(
|
|
3579
1585
|
DropdownMenuRadioGroup,
|
|
3580
1586
|
{
|
|
3581
1587
|
value: currentLocale,
|
|
@@ -3586,7 +1592,7 @@ function LanguageSwitcher({
|
|
|
3586
1592
|
value: item.code,
|
|
3587
1593
|
className: "flex items-center gap-2",
|
|
3588
1594
|
children: [
|
|
3589
|
-
showFlags && item.flag ? /* @__PURE__ */
|
|
1595
|
+
showFlags && item.flag ? /* @__PURE__ */ jsx34(
|
|
3590
1596
|
Image2,
|
|
3591
1597
|
{
|
|
3592
1598
|
src: customFlagUrl ? item.flag : getFlagUrl(item.flag),
|
|
@@ -3595,8 +1601,8 @@ function LanguageSwitcher({
|
|
|
3595
1601
|
width: 24,
|
|
3596
1602
|
height: 24
|
|
3597
1603
|
}
|
|
3598
|
-
) : showFlags ? /* @__PURE__ */
|
|
3599
|
-
/* @__PURE__ */
|
|
1604
|
+
) : showFlags ? /* @__PURE__ */ jsx34(GlobeIcon, { className: "size-4" }) : null,
|
|
1605
|
+
/* @__PURE__ */ jsx34("span", { children: item.name })
|
|
3600
1606
|
]
|
|
3601
1607
|
},
|
|
3602
1608
|
item.code
|
|
@@ -3607,15 +1613,15 @@ function LanguageSwitcher({
|
|
|
3607
1613
|
}
|
|
3608
1614
|
|
|
3609
1615
|
// src/components/ui/logo.tsx
|
|
3610
|
-
import { jsx as
|
|
1616
|
+
import { jsx as jsx35 } from "react/jsx-runtime";
|
|
3611
1617
|
function Logo({ className }) {
|
|
3612
|
-
return /* @__PURE__ */
|
|
1618
|
+
return /* @__PURE__ */ jsx35(
|
|
3613
1619
|
"svg",
|
|
3614
1620
|
{
|
|
3615
1621
|
xmlns: "http://www.w3.org/2000/svg",
|
|
3616
1622
|
viewBox: "0 0 300 300",
|
|
3617
1623
|
className: cn("size-8 text-primary", className),
|
|
3618
|
-
children: /* @__PURE__ */
|
|
1624
|
+
children: /* @__PURE__ */ jsx35(
|
|
3619
1625
|
"path",
|
|
3620
1626
|
{
|
|
3621
1627
|
fill: "currentColor",
|
|
@@ -3627,7 +1633,7 @@ function Logo({ className }) {
|
|
|
3627
1633
|
}
|
|
3628
1634
|
|
|
3629
1635
|
// src/components/ui/mode-switcher.tsx
|
|
3630
|
-
import * as
|
|
1636
|
+
import * as React2 from "react";
|
|
3631
1637
|
import { MonitorIcon, MoonIcon, SunIcon } from "lucide-react";
|
|
3632
1638
|
import { useTheme } from "next-themes";
|
|
3633
1639
|
import {
|
|
@@ -3636,8 +1642,8 @@ import {
|
|
|
3636
1642
|
DropdownMenuContent as DropdownMenuContent3,
|
|
3637
1643
|
DropdownMenuItem as DropdownMenuItem3,
|
|
3638
1644
|
DropdownMenuTrigger as DropdownMenuTrigger3
|
|
3639
|
-
} from "@pelatform/ui.components/
|
|
3640
|
-
import { Fragment as Fragment4, jsx as
|
|
1645
|
+
} from "@pelatform/ui.components/radix";
|
|
1646
|
+
import { Fragment as Fragment4, jsx as jsx36, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
3641
1647
|
function ModeSwitcher({
|
|
3642
1648
|
className,
|
|
3643
1649
|
variant = "ghost",
|
|
@@ -3651,7 +1657,7 @@ function ModeSwitcher({
|
|
|
3651
1657
|
}
|
|
3652
1658
|
}) {
|
|
3653
1659
|
const { setTheme, theme } = useTheme();
|
|
3654
|
-
const toggleTheme =
|
|
1660
|
+
const toggleTheme = React2.useCallback(() => {
|
|
3655
1661
|
const currentIndex = cycleOrder.indexOf(theme);
|
|
3656
1662
|
const nextIndex = (currentIndex + 1) % cycleOrder.length;
|
|
3657
1663
|
const nextTheme = cycleOrder[nextIndex];
|
|
@@ -3660,22 +1666,22 @@ function ModeSwitcher({
|
|
|
3660
1666
|
const getCurrentIcon = (withLabel = false) => {
|
|
3661
1667
|
if (theme === THEME_MODES.SYSTEM) {
|
|
3662
1668
|
return /* @__PURE__ */ jsxs24(Fragment4, { children: [
|
|
3663
|
-
/* @__PURE__ */
|
|
1669
|
+
/* @__PURE__ */ jsx36(MonitorIcon, {}),
|
|
3664
1670
|
" ",
|
|
3665
|
-
withLabel && /* @__PURE__ */
|
|
1671
|
+
withLabel && /* @__PURE__ */ jsx36("span", { children: label.system })
|
|
3666
1672
|
] });
|
|
3667
1673
|
}
|
|
3668
1674
|
if (theme === THEME_MODES.DARK) {
|
|
3669
1675
|
return /* @__PURE__ */ jsxs24(Fragment4, { children: [
|
|
3670
|
-
/* @__PURE__ */
|
|
1676
|
+
/* @__PURE__ */ jsx36(MoonIcon, {}),
|
|
3671
1677
|
" ",
|
|
3672
|
-
withLabel && /* @__PURE__ */
|
|
1678
|
+
withLabel && /* @__PURE__ */ jsx36("span", { children: label.dark })
|
|
3673
1679
|
] });
|
|
3674
1680
|
}
|
|
3675
1681
|
return /* @__PURE__ */ jsxs24(Fragment4, { children: [
|
|
3676
|
-
/* @__PURE__ */
|
|
1682
|
+
/* @__PURE__ */ jsx36(SunIcon, {}),
|
|
3677
1683
|
" ",
|
|
3678
|
-
withLabel && /* @__PURE__ */
|
|
1684
|
+
withLabel && /* @__PURE__ */ jsx36("span", { children: label.light })
|
|
3679
1685
|
] });
|
|
3680
1686
|
};
|
|
3681
1687
|
const isActive = (val) => theme === val;
|
|
@@ -3690,14 +1696,14 @@ function ModeSwitcher({
|
|
|
3690
1696
|
"aria-label": "Switch theme",
|
|
3691
1697
|
children: [
|
|
3692
1698
|
getCurrentIcon(),
|
|
3693
|
-
/* @__PURE__ */
|
|
1699
|
+
/* @__PURE__ */ jsx36("span", { className: "sr-only", children: "Toggle theme" })
|
|
3694
1700
|
]
|
|
3695
1701
|
}
|
|
3696
1702
|
);
|
|
3697
1703
|
}
|
|
3698
1704
|
if (type === "dropdown") {
|
|
3699
1705
|
return /* @__PURE__ */ jsxs24(DropdownMenu3, { children: [
|
|
3700
|
-
/* @__PURE__ */
|
|
1706
|
+
/* @__PURE__ */ jsx36(DropdownMenuTrigger3, { asChild: true, children: /* @__PURE__ */ jsxs24(
|
|
3701
1707
|
Button6,
|
|
3702
1708
|
{
|
|
3703
1709
|
size,
|
|
@@ -3708,18 +1714,18 @@ function ModeSwitcher({
|
|
|
3708
1714
|
),
|
|
3709
1715
|
children: [
|
|
3710
1716
|
getCurrentIcon(),
|
|
3711
|
-
/* @__PURE__ */
|
|
1717
|
+
/* @__PURE__ */ jsx36("span", { className: "sr-only", children: "Toggle theme" })
|
|
3712
1718
|
]
|
|
3713
1719
|
}
|
|
3714
1720
|
) }),
|
|
3715
|
-
/* @__PURE__ */ jsxs24(DropdownMenuContent3, { align: "end", children: [
|
|
1721
|
+
/* @__PURE__ */ jsxs24(DropdownMenuContent3, { align: "end", onCloseAutoFocus: (e) => e.preventDefault(), children: [
|
|
3716
1722
|
/* @__PURE__ */ jsxs24(
|
|
3717
1723
|
DropdownMenuItem3,
|
|
3718
1724
|
{
|
|
3719
1725
|
className: isActive("light") ? "bg-accent" : "",
|
|
3720
1726
|
onClick: () => setTheme("light"),
|
|
3721
1727
|
children: [
|
|
3722
|
-
/* @__PURE__ */
|
|
1728
|
+
/* @__PURE__ */ jsx36(SunIcon, {}),
|
|
3723
1729
|
label.light
|
|
3724
1730
|
]
|
|
3725
1731
|
}
|
|
@@ -3730,7 +1736,7 @@ function ModeSwitcher({
|
|
|
3730
1736
|
className: isActive("dark") ? "bg-accent" : "",
|
|
3731
1737
|
onClick: () => setTheme("dark"),
|
|
3732
1738
|
children: [
|
|
3733
|
-
/* @__PURE__ */
|
|
1739
|
+
/* @__PURE__ */ jsx36(MoonIcon, {}),
|
|
3734
1740
|
label.dark
|
|
3735
1741
|
]
|
|
3736
1742
|
}
|
|
@@ -3741,7 +1747,7 @@ function ModeSwitcher({
|
|
|
3741
1747
|
className: isActive("system") ? "bg-accent" : "",
|
|
3742
1748
|
onClick: () => setTheme("system"),
|
|
3743
1749
|
children: [
|
|
3744
|
-
/* @__PURE__ */
|
|
1750
|
+
/* @__PURE__ */ jsx36(MonitorIcon, {}),
|
|
3745
1751
|
label.system
|
|
3746
1752
|
]
|
|
3747
1753
|
}
|
|
@@ -3749,7 +1755,7 @@ function ModeSwitcher({
|
|
|
3749
1755
|
] })
|
|
3750
1756
|
] });
|
|
3751
1757
|
}
|
|
3752
|
-
return /* @__PURE__ */
|
|
1758
|
+
return /* @__PURE__ */ jsx36(
|
|
3753
1759
|
DropdownMenuItem3,
|
|
3754
1760
|
{
|
|
3755
1761
|
className,
|
|
@@ -3771,7 +1777,7 @@ import {
|
|
|
3771
1777
|
useMotionValue,
|
|
3772
1778
|
useTransform
|
|
3773
1779
|
} from "motion/react";
|
|
3774
|
-
import { Fragment as Fragment5, jsx as
|
|
1780
|
+
import { Fragment as Fragment5, jsx as jsx37, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
3775
1781
|
function MovingLabel({
|
|
3776
1782
|
borderRadius = "1.75rem",
|
|
3777
1783
|
children,
|
|
@@ -3791,7 +1797,7 @@ function MovingLabel({
|
|
|
3791
1797
|
},
|
|
3792
1798
|
...otherProps,
|
|
3793
1799
|
children: [
|
|
3794
|
-
/* @__PURE__ */
|
|
1800
|
+
/* @__PURE__ */ jsx37("div", { className: "absolute inset-0", style: { borderRadius: `calc(${borderRadius} * 0.96)` }, children: /* @__PURE__ */ jsx37(MovingBorder, { duration, rx: "30%", ry: "30%", children: /* @__PURE__ */ jsx37(
|
|
3795
1801
|
"div",
|
|
3796
1802
|
{
|
|
3797
1803
|
className: cn(
|
|
@@ -3800,7 +1806,7 @@ function MovingLabel({
|
|
|
3800
1806
|
)
|
|
3801
1807
|
}
|
|
3802
1808
|
) }) }),
|
|
3803
|
-
/* @__PURE__ */
|
|
1809
|
+
/* @__PURE__ */ jsx37(
|
|
3804
1810
|
"div",
|
|
3805
1811
|
{
|
|
3806
1812
|
className: cn(
|
|
@@ -3837,7 +1843,7 @@ var MovingBorder = ({
|
|
|
3837
1843
|
const y = useTransform(progress, (val) => pathRef.current?.getPointAtLength(val).y);
|
|
3838
1844
|
const transform = useMotionTemplate`translateX(${x}px) translateY(${y}px) translateX(-50%) translateY(-50%)`;
|
|
3839
1845
|
return /* @__PURE__ */ jsxs25(Fragment5, { children: [
|
|
3840
|
-
/* @__PURE__ */
|
|
1846
|
+
/* @__PURE__ */ jsx37(
|
|
3841
1847
|
"svg",
|
|
3842
1848
|
{
|
|
3843
1849
|
preserveAspectRatio: "none",
|
|
@@ -3845,10 +1851,10 @@ var MovingBorder = ({
|
|
|
3845
1851
|
width: "100%",
|
|
3846
1852
|
height: "100%",
|
|
3847
1853
|
...otherProps,
|
|
3848
|
-
children: /* @__PURE__ */
|
|
1854
|
+
children: /* @__PURE__ */ jsx37("rect", { fill: "none", width: "100%", height: "100%", rx, ry, ref: pathRef })
|
|
3849
1855
|
}
|
|
3850
1856
|
),
|
|
3851
|
-
/* @__PURE__ */
|
|
1857
|
+
/* @__PURE__ */ jsx37(
|
|
3852
1858
|
motion2.div,
|
|
3853
1859
|
{
|
|
3854
1860
|
style: {
|
|
@@ -3865,29 +1871,47 @@ var MovingBorder = ({
|
|
|
3865
1871
|
};
|
|
3866
1872
|
|
|
3867
1873
|
// src/components/ui/toolbar.tsx
|
|
3868
|
-
import { jsx as
|
|
1874
|
+
import { jsx as jsx38 } from "react/jsx-runtime";
|
|
3869
1875
|
var Toolbar = ({ children }) => {
|
|
3870
|
-
return /* @__PURE__ */
|
|
1876
|
+
return /* @__PURE__ */ jsx38("div", { className: "flex grow items-center justify-between gap-2.5 pb-5", children });
|
|
3871
1877
|
};
|
|
3872
1878
|
var ToolbarHeading = ({ children, className }) => {
|
|
3873
|
-
return /* @__PURE__ */
|
|
1879
|
+
return /* @__PURE__ */ jsx38("div", { className: cn("flex flex-col flex-wrap gap-px", className), children });
|
|
3874
1880
|
};
|
|
3875
1881
|
var ToolbarTitle = ({ className, children }) => {
|
|
3876
|
-
return /* @__PURE__ */
|
|
1882
|
+
return /* @__PURE__ */ jsx38("h1", { className: cn("font-semibold text-foreground text-lg", className), children });
|
|
3877
1883
|
};
|
|
3878
1884
|
var ToolbarActions = ({ children }) => {
|
|
3879
|
-
return /* @__PURE__ */
|
|
1885
|
+
return /* @__PURE__ */ jsx38("div", { className: "flex flex-wrap items-center gap-1.5 lg:gap-3.5", children });
|
|
3880
1886
|
};
|
|
3881
1887
|
|
|
3882
1888
|
// src/components/ui/user-avatar.tsx
|
|
3883
|
-
import {
|
|
3884
|
-
import {
|
|
3885
|
-
|
|
1889
|
+
import { cva } from "class-variance-authority";
|
|
1890
|
+
import { Avatar, AvatarFallback, AvatarImage } from "@pelatform/ui.components/radix";
|
|
1891
|
+
import { jsx as jsx39, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
1892
|
+
var avatarStatusVariants = cva(
|
|
1893
|
+
"flex size-2 items-center rounded-full border-2 border-background",
|
|
1894
|
+
{
|
|
1895
|
+
variants: {
|
|
1896
|
+
variant: {
|
|
1897
|
+
online: "bg-green-600",
|
|
1898
|
+
offline: "bg-zinc-400 dark:bg-zinc-500",
|
|
1899
|
+
busy: "bg-yellow-600",
|
|
1900
|
+
away: "bg-blue-600"
|
|
1901
|
+
}
|
|
1902
|
+
},
|
|
1903
|
+
defaultVariants: {
|
|
1904
|
+
variant: "online"
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
);
|
|
1908
|
+
function UserAvatar({ className, indicator = false, src, alt }) {
|
|
3886
1909
|
const name = alt ?? "User";
|
|
3887
1910
|
const initial = getInitials(name);
|
|
3888
1911
|
return /* @__PURE__ */ jsxs26(Avatar, { className, children: [
|
|
3889
|
-
/* @__PURE__ */
|
|
3890
|
-
/* @__PURE__ */
|
|
1912
|
+
/* @__PURE__ */ jsx39(AvatarImage, { src: src ?? void 0, alt: name }),
|
|
1913
|
+
/* @__PURE__ */ jsx39(AvatarFallback, { children: initial }),
|
|
1914
|
+
indicator && /* @__PURE__ */ jsx39(AvatarIndicator, { className: "-end-2 -top-2", children: /* @__PURE__ */ jsx39(AvatarStatus, { variant: "online", className: "size-2.5" }) })
|
|
3891
1915
|
] });
|
|
3892
1916
|
}
|
|
3893
1917
|
var getInitials = (name, count) => {
|
|
@@ -3897,9 +1921,33 @@ var getInitials = (name, count) => {
|
|
|
3897
1921
|
const initials = name.split(" ").filter(Boolean).map((part) => part[0].toUpperCase());
|
|
3898
1922
|
return count && count > 0 ? initials.slice(0, count).join("") : initials.join("");
|
|
3899
1923
|
};
|
|
1924
|
+
function AvatarIndicator({ className, ...props }) {
|
|
1925
|
+
return /* @__PURE__ */ jsx39(
|
|
1926
|
+
"div",
|
|
1927
|
+
{
|
|
1928
|
+
"data-slot": "avatar-indicator",
|
|
1929
|
+
className: cn("absolute flex size-6 items-center justify-center", className),
|
|
1930
|
+
...props
|
|
1931
|
+
}
|
|
1932
|
+
);
|
|
1933
|
+
}
|
|
1934
|
+
function AvatarStatus({
|
|
1935
|
+
className,
|
|
1936
|
+
variant,
|
|
1937
|
+
...props
|
|
1938
|
+
}) {
|
|
1939
|
+
return /* @__PURE__ */ jsx39(
|
|
1940
|
+
"div",
|
|
1941
|
+
{
|
|
1942
|
+
"data-slot": "avatar-status",
|
|
1943
|
+
className: cn(avatarStatusVariants({ variant }), className),
|
|
1944
|
+
...props
|
|
1945
|
+
}
|
|
1946
|
+
);
|
|
1947
|
+
}
|
|
3900
1948
|
|
|
3901
1949
|
// src/components/utils/fonts.tsx
|
|
3902
|
-
import { jsx as
|
|
1950
|
+
import { jsx as jsx40 } from "react/jsx-runtime";
|
|
3903
1951
|
var satoshiFontUrl = "https://assets.pelatform.com/fonts/satoshi/Satoshi-Variable.woff2";
|
|
3904
1952
|
var cssFontFace = `
|
|
3905
1953
|
@font-face {
|
|
@@ -3911,7 +1959,7 @@ var cssFontFace = `
|
|
|
3911
1959
|
}
|
|
3912
1960
|
`;
|
|
3913
1961
|
function SatoshiFontCSS() {
|
|
3914
|
-
return /* @__PURE__ */
|
|
1962
|
+
return /* @__PURE__ */ jsx40("style", { dangerouslySetInnerHTML: { __html: cssFontFace } });
|
|
3915
1963
|
}
|
|
3916
1964
|
export {
|
|
3917
1965
|
AlertComingsoon,
|