@coffre/ui 0.1.18 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -3
- package/dist/{server/_coffre/assets/affordances-CKANXDTG.js → chunks/affordances-DAvsVz7u.js} +12 -7
- package/dist/chunks/affordances-DAvsVz7u.js.map +1 -0
- package/dist/chunks/directory-CSjWWUQ1.js +370 -0
- package/dist/chunks/directory-CSjWWUQ1.js.map +1 -0
- package/dist/{server/_coffre/assets/grants-DdKT11Ny.js → chunks/grants-saMQagmG.js} +41 -39
- package/dist/chunks/grants-saMQagmG.js.map +1 -0
- package/dist/chunks/icons-D-PfAfnH.js +203 -0
- package/dist/chunks/icons-D-PfAfnH.js.map +1 -0
- package/dist/chunks/mounted-jJmqqV_n.js +17 -0
- package/dist/chunks/mounted-jJmqqV_n.js.map +1 -0
- package/dist/{server/_coffre/assets/offboarding-CRz-K82H.js → chunks/offboarding-C6l30DZR.js} +70 -69
- package/dist/chunks/offboarding-C6l30DZR.js.map +1 -0
- package/dist/chunks/page-C5HcNqf2.js +190 -0
- package/dist/chunks/page-C5HcNqf2.js.map +1 -0
- package/dist/chunks/page-route-Drfw7lmn.js +20 -0
- package/dist/chunks/page-route-Drfw7lmn.js.map +1 -0
- package/dist/{server/_coffre/assets/principal-page-C-EFwJQw.js → chunks/principal-page-D_91OA0l.js} +105 -103
- package/dist/chunks/principal-page-D_91OA0l.js.map +1 -0
- package/dist/{server/_coffre/assets → chunks}/project-environments-lEzFHUt4.js +2 -0
- package/dist/chunks/project-environments-lEzFHUt4.js.map +1 -0
- package/dist/chunks/queries-CQ81o4so.js +376 -0
- package/dist/chunks/queries-CQ81o4so.js.map +1 -0
- package/dist/{server/_coffre/assets/row-state-C2P57xT1.js → chunks/row-state-0PsrEzOL.js} +22 -21
- package/dist/chunks/row-state-0PsrEzOL.js.map +1 -0
- package/dist/{server/_coffre/assets → chunks}/signin-errors-BEFlVDbQ.js +2 -0
- package/dist/chunks/signin-errors-BEFlVDbQ.js.map +1 -0
- package/dist/chunks/theme-B2vQolVR.js +86 -0
- package/dist/chunks/theme-B2vQolVR.js.map +1 -0
- package/dist/chunks/ui-DixXLQvQ.js +405 -0
- package/dist/chunks/ui-DixXLQvQ.js.map +1 -0
- package/dist/{server/_coffre/assets/use-action-B-xpvVRO.js → chunks/use-action-CWsg_YWU.js} +8 -6
- package/dist/chunks/use-action-CWsg_YWU.js.map +1 -0
- package/dist/{server/_coffre/assets/use-change-C8BCf3oU.js → chunks/use-change-c6CeLRin.js} +10 -474
- package/dist/chunks/use-change-c6CeLRin.js.map +1 -0
- package/dist/chunks/use-shell-jxd7Tzd-.js +26 -0
- package/dist/chunks/use-shell-jxd7Tzd-.js.map +1 -0
- package/dist/{server/_coffre/assets → chunks}/validation-BQtqPe2V.js +2 -0
- package/dist/chunks/validation-BQtqPe2V.js.map +1 -0
- package/dist/index.d.ts +386 -18
- package/dist/index.js +1147 -0
- package/dist/index.js.map +1 -0
- package/dist/pages/account.d.ts +9 -0
- package/dist/pages/account.js +334 -0
- package/dist/pages/account.js.map +1 -0
- package/dist/pages/audit.d.ts +3 -0
- package/dist/{server/_coffre/assets/audit-qB9G2AQJ.js → pages/audit.js} +102 -100
- package/dist/pages/audit.js.map +1 -0
- package/dist/pages/device-login.d.ts +9 -0
- package/dist/pages/device-login.js +211 -0
- package/dist/pages/device-login.js.map +1 -0
- package/dist/pages/environment.d.ts +3 -0
- package/dist/{server/_coffre/assets/projects._project._environment-C6uybzeU.js → pages/environment.js} +323 -469
- package/dist/pages/environment.js.map +1 -0
- package/dist/pages/login.d.ts +10 -0
- package/dist/pages/login.js +104 -0
- package/dist/pages/login.js.map +1 -0
- package/dist/pages/project.d.ts +2 -0
- package/dist/{server/_coffre/assets/projects._project.index-3CXwkyTh.js → pages/project.js} +223 -225
- package/dist/pages/project.js.map +1 -0
- package/dist/pages/projects.d.ts +3 -0
- package/dist/{server/_coffre/assets/projects.index-iSoBpRFz.js → pages/projects.js} +83 -81
- package/dist/pages/projects.js.map +1 -0
- package/dist/pages/settings.d.ts +3 -0
- package/dist/{server/_coffre/assets/settings-BDQTF5XW.js → pages/settings.js} +20 -18
- package/dist/pages/settings.js.map +1 -0
- package/dist/pages/token.d.ts +3 -0
- package/dist/{server/_coffre/assets/tokens._token-CrBMpcbN.js → pages/token.js} +198 -267
- package/dist/pages/token.js.map +1 -0
- package/dist/pages/tokens.d.ts +3 -0
- package/dist/pages/tokens.js +39 -0
- package/dist/pages/tokens.js.map +1 -0
- package/dist/pages/unregistered.d.ts +8 -0
- package/dist/pages/unregistered.js +54 -0
- package/dist/pages/unregistered.js.map +1 -0
- package/dist/pages/user.d.ts +3 -0
- package/dist/pages/user.js +16 -0
- package/dist/pages/user.js.map +1 -0
- package/dist/pages/users.d.ts +3 -0
- package/dist/pages/users.js +39 -0
- package/dist/pages/users.js.map +1 -0
- package/dist/project-BqIy8gYR.d.ts +5 -0
- package/dist/vite.d.ts +16 -0
- package/dist/vite.js +52 -0
- package/package.json +36 -21
- package/src/assets/icon.svg +1 -0
- package/src/components/affordances.ts +10 -4
- package/src/components/command-palette.tsx +229 -203
- package/src/components/directory.tsx +34 -38
- package/src/components/principal.tsx +7 -3
- package/src/components/service-tokens.tsx +3 -2
- package/src/components/shell.tsx +89 -127
- package/src/components/theme.tsx +14 -81
- package/src/components/ui.tsx +97 -68
- package/src/index.ts +29 -0
- package/src/layout.tsx +113 -0
- package/src/lib/coffre.ts +8 -4
- package/src/lib/mounted.ts +13 -0
- package/src/lib/page-context.ts +31 -0
- package/src/lib/page-route.ts +22 -0
- package/src/lib/preferences.tsx +46 -0
- package/src/options.ts +240 -0
- package/src/{routes → pages}/account.tsx +7 -24
- package/src/{routes → pages}/audit.tsx +5 -16
- package/src/{routes/auth.device.tsx → pages/device-login.tsx} +8 -21
- package/src/{routes/projects.$project.$environment.tsx → pages/environment.tsx} +43 -52
- package/src/{routes → pages}/login.tsx +5 -16
- package/src/{routes/projects.$project.index.tsx → pages/project.tsx} +38 -50
- package/src/{routes/projects.index.tsx → pages/projects.tsx} +2 -7
- package/src/{routes → pages}/settings.tsx +3 -10
- package/src/{routes/tokens.$token.tsx → pages/token.tsx} +6 -7
- package/src/{routes/tokens.index.tsx → pages/tokens.tsx} +3 -8
- package/src/{routes → pages}/unregistered.tsx +1 -6
- package/src/pages/user.tsx +10 -0
- package/src/{routes/users.index.tsx → pages/users.tsx} +3 -8
- package/src/register.ts +55 -0
- package/src/router.tsx +31 -62
- package/src/styles/globals.css +104 -46
- package/src/vite.ts +78 -0
- package/dist/client/.assetsignore +0 -2
- package/dist/client/_coffre/assets/account-BoLGAxbD.js +0 -2
- package/dist/client/_coffre/assets/account-CnnuRTDB.js +0 -1
- package/dist/client/_coffre/assets/affordances-CEafRJcN.js +0 -1
- package/dist/client/_coffre/assets/audit-CHSvKLWX.js +0 -1
- package/dist/client/_coffre/assets/audit-Cn4hmS4u.js +0 -2
- package/dist/client/_coffre/assets/auth.device-Co5vrpaA.js +0 -2
- package/dist/client/_coffre/assets/auth.device-DAlqWacc.js +0 -1
- package/dist/client/_coffre/assets/directory-H8Eh3MnS.js +0 -1
- package/dist/client/_coffre/assets/dist-Braunv_x.js +0 -1
- package/dist/client/_coffre/assets/globals-CpMrgkV6.css +0 -1
- package/dist/client/_coffre/assets/grants-DPDxJXU1.js +0 -1
- package/dist/client/_coffre/assets/icons-Dc_-t0lp.js +0 -1
- package/dist/client/_coffre/assets/index-sUCIXRgJ.js +0 -12
- package/dist/client/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/client/_coffre/assets/link-DBINMwm6.js +0 -1
- package/dist/client/_coffre/assets/login-BZFYfL1Y.js +0 -1
- package/dist/client/_coffre/assets/login-CYCKWTOD.js +0 -2
- package/dist/client/_coffre/assets/offboarding-Bwpftp3g.js +0 -1
- package/dist/client/_coffre/assets/page-C_hnzdaR.js +0 -1
- package/dist/client/_coffre/assets/preload-helper-CLkO85Nq.js +0 -1
- package/dist/client/_coffre/assets/principal-page-DLho8TSJ.js +0 -1
- package/dist/client/_coffre/assets/project-environments-CfIH5kFM.js +0 -1
- package/dist/client/_coffre/assets/projects._project._environment-DHRRvQw0.js +0 -3
- package/dist/client/_coffre/assets/projects._project._environment-TLI-RjBZ.js +0 -2
- package/dist/client/_coffre/assets/projects._project.index-BO-8FZIY.js +0 -2
- package/dist/client/_coffre/assets/projects._project.index-DGl921dP.js +0 -1
- package/dist/client/_coffre/assets/projects.index-BDn7Bhoo.js +0 -1
- package/dist/client/_coffre/assets/row-state-DJ-KLamZ.js +0 -1
- package/dist/client/_coffre/assets/settings-q9G1QvR_.js +0 -1
- package/dist/client/_coffre/assets/signin-errors-CroZWZgm.js +0 -1
- package/dist/client/_coffre/assets/suspense-O8sP0mEC.js +0 -1
- package/dist/client/_coffre/assets/tokens._token-B_qczpT9.js +0 -2
- package/dist/client/_coffre/assets/tokens._token-T-sqwMbz.js +0 -2
- package/dist/client/_coffre/assets/tokens.index-CcXSZnAG.js +0 -1
- package/dist/client/_coffre/assets/ui-BXP2IqrW.js +0 -46
- package/dist/client/_coffre/assets/unregistered-D2JXJ90x.js +0 -1
- package/dist/client/_coffre/assets/use-action-BpzKWhgg.js +0 -1
- package/dist/client/_coffre/assets/use-change-CKj3Inq9.js +0 -1
- package/dist/client/_coffre/assets/use-shell-W0SusPkz.js +0 -1
- package/dist/client/_coffre/assets/useQuery-B-lxFSES.js +0 -1
- package/dist/client/_coffre/assets/useSuspenseQuery-BZ-nzHST.js +0 -1
- package/dist/client/_coffre/assets/users._user-Bb3BGYHl.js +0 -1
- package/dist/client/_coffre/assets/users._user-DXmvKrzE.js +0 -2
- package/dist/client/_coffre/assets/users.index-BvzP3qwW.js +0 -1
- package/dist/client/_coffre/assets/validation-9Cl_XS-l.js +0 -1
- package/dist/server/.vite/manifest.json +0 -668
- package/dist/server/_coffre/assets/_tanstack-start-manifest_v-GsKnGGRy.js +0 -162
- package/dist/server/_coffre/assets/account-CV-a2IU2.js +0 -329
- package/dist/server/_coffre/assets/account-hk6wcIXU.js +0 -162
- package/dist/server/_coffre/assets/async-local-storage-C10uQtMM.js +0 -3108
- package/dist/server/_coffre/assets/audit-C1_Ej6YB.js +0 -31
- package/dist/server/_coffre/assets/auth.device-6JRrWbSV.js +0 -210
- package/dist/server/_coffre/assets/auth.device-CLoAxC2T.js +0 -29
- package/dist/server/_coffre/assets/directory-B-_rqsPx.js +0 -371
- package/dist/server/_coffre/assets/dist-CnnV3t2g.js +0 -908
- package/dist/server/_coffre/assets/empty-plugin-adapters-Cq4--YW-.js +0 -5
- package/dist/server/_coffre/assets/globals-CpMrgkV6.css +0 -1
- package/dist/server/_coffre/assets/icons-DOFT-eWB.js +0 -1704
- package/dist/server/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/server/_coffre/assets/lazyRouteComponent-CqBNCGuZ.js +0 -480
- package/dist/server/_coffre/assets/link-42ZWdjzZ.js +0 -422
- package/dist/server/_coffre/assets/login-DRKUKkaW.js +0 -22
- package/dist/server/_coffre/assets/login-DnwxVl4Y.js +0 -102
- package/dist/server/_coffre/assets/matchContext-qLfYbC6_.js +0 -56
- package/dist/server/_coffre/assets/page-D6n45dcK.js +0 -3561
- package/dist/server/_coffre/assets/projects._project._environment-CS8DdSMY.js +0 -48
- package/dist/server/_coffre/assets/projects._project.index-BGfcNpj0.js +0 -23
- package/dist/server/_coffre/assets/react-dom-bBoJXlK2.js +0 -1718
- package/dist/server/_coffre/assets/router-9BTgJhWG.js +0 -2322
- package/dist/server/_coffre/assets/start-DR3rN0St.js +0 -4
- package/dist/server/_coffre/assets/suspense-C-2QfDd2.js +0 -602
- package/dist/server/_coffre/assets/tokens._token-rY86Cjgp.js +0 -10
- package/dist/server/_coffre/assets/tokens.index-Bq5qDW9q.js +0 -37
- package/dist/server/_coffre/assets/ui-Cc0CGMtr.js +0 -14881
- package/dist/server/_coffre/assets/unregistered-D9ZKLOPJ.js +0 -53
- package/dist/server/_coffre/assets/use-shell-DwOzEi87.js +0 -462
- package/dist/server/_coffre/assets/useQuery-CTe86qFq.js +0 -8
- package/dist/server/_coffre/assets/useRouter-CaUSUNsw.js +0 -473
- package/dist/server/_coffre/assets/useSuspenseQuery-CSoHzrMb.js +0 -117
- package/dist/server/_coffre/assets/users._user-BmLKYeo_.js +0 -10
- package/dist/server/_coffre/assets/users._user-BmiHwQx3.js +0 -14
- package/dist/server/_coffre/assets/users.index-BiEax90r.js +0 -37
- package/dist/server/index.js +0 -13911
- package/src/assets/favicon-32.png +0 -0
- package/src/components/agentation.tsx +0 -34
- package/src/entry.ts +0 -19
- package/src/routeTree.gen.ts +0 -367
- package/src/routes/__root.tsx +0 -169
- package/src/routes/access.tsx +0 -11
- package/src/routes/index.tsx +0 -15
- package/src/routes/users.$user.tsx +0 -13
- package/src/types.ts +0 -21
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/@tanstack+react-start@1.168.32_esbuild@0.28.1_react-dom@19.2.7_react@19.2.7__react@19.2_25463611d577cfc3cbee287b278aee95/node_modules/@tanstack/react-start/dist/plugin/default-entry/start.ts
|
|
2
|
-
var startInstance = void 0;
|
|
3
|
-
//#endregion
|
|
4
|
-
export { startInstance };
|
|
@@ -1,602 +0,0 @@
|
|
|
1
|
-
import { i as require_react, r as require_jsx_runtime, s as __toESM } from "./useRouter-CaUSUNsw.js";
|
|
2
|
-
import { A as isServer, B as timeoutManager, D as notifyManager, E as fetchState, I as resolveQueryValue, L as shallowEqualObjects, M as isValidTimeout, N as noop, O as focusManager, P as replaceData, R as shouldThrowError, k as Subscribable, z as timeUntilStale } from "./page-D6n45dcK.js";
|
|
3
|
-
//#region ../../node_modules/.pnpm/@tanstack+react-query@5.103.1_react@19.2.7/node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js
|
|
4
|
-
var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
|
|
5
|
-
var import_jsx_runtime = require_jsx_runtime();
|
|
6
|
-
/**
|
|
7
|
-
* The context that `useQueryClient` reads from. `QueryClientProvider` is the normal way to set it.
|
|
8
|
-
*/
|
|
9
|
-
var QueryClientContext = import_react.createContext(void 0);
|
|
10
|
-
/**
|
|
11
|
-
* The `useQueryClient` hook returns the current `QueryClient` instance.
|
|
12
|
-
*
|
|
13
|
-
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
|
|
14
|
-
* be used.
|
|
15
|
-
* @returns The current `QueryClient` instance.
|
|
16
|
-
* @throws If no `queryClient` argument is passed and no `QueryClientProvider` is found in the component tree.
|
|
17
|
-
*/
|
|
18
|
-
var useQueryClient = (queryClient) => {
|
|
19
|
-
const client = import_react.useContext(QueryClientContext);
|
|
20
|
-
if (queryClient) return queryClient;
|
|
21
|
-
if (!client) throw new Error("No QueryClient set, use QueryClientProvider to set one");
|
|
22
|
-
return client;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Use the `QueryClientProvider` component to connect and provide a `QueryClient` to your application. Also
|
|
26
|
-
* calls `client.mount()`/`client.unmount()` as this component mounts/unmounts, which subscribes the client to
|
|
27
|
-
* focus/online events (resuming any paused mutations and refetching as needed when the app regains focus or
|
|
28
|
-
* comes back online).
|
|
29
|
-
*
|
|
30
|
-
* @returns The provided `children`, wrapped so they can read the `QueryClient` via `useQueryClient`.
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```tsx
|
|
34
|
-
* import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
35
|
-
*
|
|
36
|
-
* const queryClient = new QueryClient()
|
|
37
|
-
*
|
|
38
|
-
* function App() {
|
|
39
|
-
* return <QueryClientProvider client={queryClient}>...</QueryClientProvider>
|
|
40
|
-
* }
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
var QueryClientProvider = ({ client, children }) => {
|
|
44
|
-
import_react.useEffect(() => {
|
|
45
|
-
client.mount();
|
|
46
|
-
return () => {
|
|
47
|
-
client.unmount();
|
|
48
|
-
};
|
|
49
|
-
}, [client]);
|
|
50
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(QueryClientContext.Provider, {
|
|
51
|
-
value: client,
|
|
52
|
-
children
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
//#endregion
|
|
56
|
-
//#region ../../node_modules/.pnpm/@tanstack+query-core@5.103.1/node_modules/@tanstack/query-core/build/modern/queryObserver.js
|
|
57
|
-
/**
|
|
58
|
-
* A `QueryObserver` watches a single query in the `QueryCache` and computes a
|
|
59
|
-
* `QueryObserverResult` from its state, recomputing and notifying subscribers
|
|
60
|
-
* whenever the underlying query (or the observer's options) changes. It is
|
|
61
|
-
* the primitive that framework adapters (e.g. `useQuery`) build their hooks
|
|
62
|
-
* on top of, but it can also be used directly to observe and switch between
|
|
63
|
-
* queries outside of any framework.
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* ```ts
|
|
67
|
-
* const observer = new QueryObserver(queryClient, {
|
|
68
|
-
* queryKey: ['posts'],
|
|
69
|
-
* queryFn: fetchPosts,
|
|
70
|
-
* })
|
|
71
|
-
*
|
|
72
|
-
* const unsubscribe = observer.subscribe((result) => {
|
|
73
|
-
* console.log(result.data)
|
|
74
|
-
* })
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
var QueryObserver = class extends Subscribable {
|
|
78
|
-
#client;
|
|
79
|
-
#currentQuery = void 0;
|
|
80
|
-
#currentQueryInitialState = void 0;
|
|
81
|
-
#currentResult = void 0;
|
|
82
|
-
#currentResultState;
|
|
83
|
-
#currentResultOptions;
|
|
84
|
-
#selectError;
|
|
85
|
-
#selectFn;
|
|
86
|
-
#selectResult;
|
|
87
|
-
#lastQueryWithDefinedData;
|
|
88
|
-
#staleTimeoutId;
|
|
89
|
-
#refetchIntervalId;
|
|
90
|
-
#currentRefetchInterval;
|
|
91
|
-
#trackedProps = /* @__PURE__ */ new Set();
|
|
92
|
-
constructor(client, options) {
|
|
93
|
-
super();
|
|
94
|
-
this.options = options;
|
|
95
|
-
this.#client = client;
|
|
96
|
-
this.#selectError = null;
|
|
97
|
-
this.bindMethods();
|
|
98
|
-
this.setOptions(options);
|
|
99
|
-
}
|
|
100
|
-
bindMethods() {
|
|
101
|
-
this.refetch = this.refetch.bind(this);
|
|
102
|
-
}
|
|
103
|
-
onSubscribe() {
|
|
104
|
-
if (this.listeners.size === 1) {
|
|
105
|
-
this.#currentQuery.addObserver(this);
|
|
106
|
-
if (shouldFetchOnMount(this.#currentQuery, this.options)) this.#executeFetch();
|
|
107
|
-
else this.updateResult();
|
|
108
|
-
this.#updateTimers();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
onUnsubscribe() {
|
|
112
|
-
if (!this.hasListeners()) this.destroy();
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Returns whether the observed query is currently stale and configured
|
|
116
|
-
* (via the `refetchOnReconnect` option) to refetch when the network
|
|
117
|
-
* reconnects.
|
|
118
|
-
*/
|
|
119
|
-
shouldFetchOnReconnect() {
|
|
120
|
-
return shouldFetchOn(this.#currentQuery, this.options, this.options.refetchOnReconnect);
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Returns whether the observed query is currently stale and configured
|
|
124
|
-
* (via the `refetchOnWindowFocus` option) to refetch when the window
|
|
125
|
-
* regains focus.
|
|
126
|
-
*/
|
|
127
|
-
shouldFetchOnWindowFocus() {
|
|
128
|
-
return shouldFetchOn(this.#currentQuery, this.options, this.options.refetchOnWindowFocus);
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Stops observing the current query: clears all listeners, cancels the
|
|
132
|
-
* stale and refetch-interval timers, and removes this observer from the
|
|
133
|
-
* query it was observing.
|
|
134
|
-
*/
|
|
135
|
-
destroy() {
|
|
136
|
-
this.listeners = /* @__PURE__ */ new Set();
|
|
137
|
-
this.#clearStaleTimeout();
|
|
138
|
-
this.#clearRefetchInterval();
|
|
139
|
-
this.#currentQuery.removeObserver(this);
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Updates the observer's options. This will re-resolve the query being
|
|
143
|
-
* observed (switching to a different query if the `queryKey` changed),
|
|
144
|
-
* trigger a fetch if the new options require one and the observer has
|
|
145
|
-
* subscribers, recompute the current result, and reschedule the stale and
|
|
146
|
-
* refetch-interval timers as needed.
|
|
147
|
-
*
|
|
148
|
-
* @example
|
|
149
|
-
* ```ts
|
|
150
|
-
* observer.setOptions({ queryKey: ['posts', 1], queryFn: () => fetchPost(1) })
|
|
151
|
-
* // later: switch to a different query, reusing the same observer
|
|
152
|
-
* observer.setOptions({ queryKey: ['posts', 2], queryFn: () => fetchPost(2) })
|
|
153
|
-
* ```
|
|
154
|
-
*/
|
|
155
|
-
setOptions(options) {
|
|
156
|
-
const prevOptions = this.options;
|
|
157
|
-
const prevQuery = this.#currentQuery;
|
|
158
|
-
this.options = this.#client.defaultQueryOptions(options);
|
|
159
|
-
if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveQueryValue(this.options.enabled, this.#currentQuery) !== "boolean") throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");
|
|
160
|
-
this.#updateQuery();
|
|
161
|
-
this.#currentQuery.setOptions(this.options);
|
|
162
|
-
if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) this.#client.getQueryCache().notify({
|
|
163
|
-
type: "observerOptionsUpdated",
|
|
164
|
-
query: this.#currentQuery,
|
|
165
|
-
observer: this
|
|
166
|
-
});
|
|
167
|
-
const mounted = this.hasListeners();
|
|
168
|
-
if (mounted && shouldFetchOptionally(this.#currentQuery, prevQuery, this.options, prevOptions)) this.#executeFetch();
|
|
169
|
-
this.updateResult();
|
|
170
|
-
if (mounted && (this.#currentQuery !== prevQuery || resolveQueryValue(this.options.enabled, this.#currentQuery) !== resolveQueryValue(prevOptions.enabled, this.#currentQuery) || resolveQueryValue(this.options.staleTime, this.#currentQuery) !== resolveQueryValue(prevOptions.staleTime, this.#currentQuery))) this.#updateStaleTimeout();
|
|
171
|
-
const nextRefetchInterval = this.#computeRefetchInterval();
|
|
172
|
-
if (mounted && (this.#currentQuery !== prevQuery || resolveQueryValue(this.options.enabled, this.#currentQuery) !== resolveQueryValue(prevOptions.enabled, this.#currentQuery) || nextRefetchInterval !== this.#currentRefetchInterval)) this.#updateRefetchInterval(nextRefetchInterval);
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Computes the result the observer would produce for the given (already-defaulted) options
|
|
176
|
-
* right now, building the underlying `Query` if it doesn't exist yet, without waiting for a
|
|
177
|
-
* subscription callback. Called by framework adapters on every render (e.g. `useQuery`) so the
|
|
178
|
-
* returned value is available synchronously, ahead of `setOptions` triggering an actual fetch.
|
|
179
|
-
*/
|
|
180
|
-
getOptimisticResult(options) {
|
|
181
|
-
const query = this.#client.getQueryCache().build(this.#client, options);
|
|
182
|
-
const result = this.createResult(query, options);
|
|
183
|
-
if (!shallowEqualObjects(this.getCurrentResult(), result)) {
|
|
184
|
-
this.#currentResult = result;
|
|
185
|
-
this.#currentResultOptions = this.options;
|
|
186
|
-
this.#currentResultState = this.#currentQuery.state;
|
|
187
|
-
}
|
|
188
|
-
return result;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Returns the most recently computed `QueryObserverResult` for the
|
|
192
|
-
* observed query. This is a point-in-time read; to be notified of updates
|
|
193
|
-
* as they happen, subscribe to the observer instead (its inherited
|
|
194
|
-
* `subscribe` method).
|
|
195
|
-
*
|
|
196
|
-
* @example
|
|
197
|
-
* ```ts
|
|
198
|
-
* const result = observer.getCurrentResult()
|
|
199
|
-
* console.log(result.status, result.data)
|
|
200
|
-
* ```
|
|
201
|
-
*/
|
|
202
|
-
getCurrentResult() {
|
|
203
|
-
return this.#currentResult;
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via
|
|
207
|
-
* {@link QueryObserver#trackProp} (and an optional `onPropTracked` callback). Used by framework
|
|
208
|
-
* adapters when `notifyOnChangeProps` is not set, to implement its default "only re-render on
|
|
209
|
-
* properties you actually read" behavior.
|
|
210
|
-
*/
|
|
211
|
-
trackResult(result, onPropTracked) {
|
|
212
|
-
return new Proxy(result, { get: (target, key) => {
|
|
213
|
-
this.trackProp(key);
|
|
214
|
-
onPropTracked?.(key);
|
|
215
|
-
return Reflect.get(target, key);
|
|
216
|
-
} });
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Records that the given `QueryObserverResult` property was read, so a subsequent update only
|
|
220
|
-
* notifies this observer if a tracked property actually changed. Normally called indirectly via
|
|
221
|
-
* {@link QueryObserver#trackResult}'s proxy; exposed directly for adapters that track property
|
|
222
|
-
* access themselves (e.g. through their own reactivity system) instead of via the proxy.
|
|
223
|
-
*/
|
|
224
|
-
trackProp(key) {
|
|
225
|
-
this.#trackedProps.add(key);
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Returns the `Query` instance this observer is currently observing.
|
|
229
|
-
*/
|
|
230
|
-
getCurrentQuery() {
|
|
231
|
-
return this.#currentQuery;
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Refetches the observed query and returns a promise that resolves with
|
|
235
|
-
* the resulting `QueryObserverResult`.
|
|
236
|
-
*
|
|
237
|
-
* @example
|
|
238
|
-
* ```ts
|
|
239
|
-
* const result = await observer.refetch({ cancelRefetch: false })
|
|
240
|
-
* console.log(result.data)
|
|
241
|
-
* ```
|
|
242
|
-
*/
|
|
243
|
-
refetch({ ...options } = {}) {
|
|
244
|
-
return this.fetch({ ...options });
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Fetches a query defined by the given options without affecting this
|
|
248
|
-
* observer's own tracked query or result, and returns a promise that
|
|
249
|
-
* resolves with the `QueryObserverResult` for that fetch. This is useful
|
|
250
|
-
* for prefetching data that another observer (e.g. a query about to be
|
|
251
|
-
* navigated to) will need, ahead of time.
|
|
252
|
-
*
|
|
253
|
-
* @example
|
|
254
|
-
* ```ts
|
|
255
|
-
* const result = await observer.fetchOptimistic({
|
|
256
|
-
* queryKey: ['posts', 2],
|
|
257
|
-
* queryFn: () => fetchPost(2),
|
|
258
|
-
* })
|
|
259
|
-
* console.log(result.data)
|
|
260
|
-
* ```
|
|
261
|
-
*/
|
|
262
|
-
fetchOptimistic(options) {
|
|
263
|
-
const defaultedOptions = this.#client.defaultQueryOptions(options);
|
|
264
|
-
const query = this.#client.getQueryCache().build(this.#client, defaultedOptions);
|
|
265
|
-
let unsubscribe = () => {};
|
|
266
|
-
let resolveEarly;
|
|
267
|
-
const cachePromise = new Promise((resolve) => {
|
|
268
|
-
resolveEarly = resolve;
|
|
269
|
-
unsubscribe = this.#client.getQueryCache().subscribe((event) => {
|
|
270
|
-
if (event.type === "updated" && event.query.queryHash === query.queryHash && query.state.data !== void 0) {
|
|
271
|
-
unsubscribe();
|
|
272
|
-
resolve(this.createResult(query, defaultedOptions));
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
});
|
|
276
|
-
return Promise.race([query.fetch().then(() => {
|
|
277
|
-
const result = this.createResult(query, defaultedOptions);
|
|
278
|
-
resolveEarly?.(result);
|
|
279
|
-
return result;
|
|
280
|
-
}).finally(() => {
|
|
281
|
-
unsubscribe();
|
|
282
|
-
}), cachePromise]);
|
|
283
|
-
}
|
|
284
|
-
fetch(fetchOptions) {
|
|
285
|
-
return this.#executeFetch({
|
|
286
|
-
...fetchOptions,
|
|
287
|
-
cancelRefetch: fetchOptions.cancelRefetch ?? true
|
|
288
|
-
}).then(() => {
|
|
289
|
-
this.updateResult();
|
|
290
|
-
return this.#currentResult;
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
#executeFetch(fetchOptions) {
|
|
294
|
-
this.#updateQuery();
|
|
295
|
-
let promise = this.#currentQuery.fetch(this.options, fetchOptions);
|
|
296
|
-
if (!fetchOptions?.throwOnError) promise = promise.catch(noop);
|
|
297
|
-
return promise;
|
|
298
|
-
}
|
|
299
|
-
#shouldScheduleTimer(timeout) {
|
|
300
|
-
return !isServer() && resolveQueryValue(this.options.enabled, this.#currentQuery) !== false && isValidTimeout(timeout);
|
|
301
|
-
}
|
|
302
|
-
#updateStaleTimeout() {
|
|
303
|
-
this.#clearStaleTimeout();
|
|
304
|
-
const staleTime = resolveQueryValue(this.options.staleTime, this.#currentQuery);
|
|
305
|
-
if (this.#currentResult.isStale || !this.#shouldScheduleTimer(staleTime)) return;
|
|
306
|
-
const timeout = timeUntilStale(this.#currentResult.dataUpdatedAt, staleTime) + 1;
|
|
307
|
-
this.#staleTimeoutId = timeoutManager.setTimeout(() => {
|
|
308
|
-
if (!this.#currentResult.isStale) this.updateResult();
|
|
309
|
-
}, timeout);
|
|
310
|
-
}
|
|
311
|
-
#computeRefetchInterval() {
|
|
312
|
-
return resolveQueryValue(this.options.refetchInterval, this.#currentQuery) ?? false;
|
|
313
|
-
}
|
|
314
|
-
#updateRefetchInterval(nextInterval) {
|
|
315
|
-
this.#clearRefetchInterval();
|
|
316
|
-
this.#currentRefetchInterval = nextInterval;
|
|
317
|
-
if (this.#currentRefetchInterval === 0 || !this.#shouldScheduleTimer(this.#currentRefetchInterval)) return;
|
|
318
|
-
this.#refetchIntervalId = timeoutManager.setInterval(() => {
|
|
319
|
-
if (this.options.refetchIntervalInBackground || focusManager.isFocused()) this.#executeFetch();
|
|
320
|
-
}, this.#currentRefetchInterval);
|
|
321
|
-
}
|
|
322
|
-
#updateTimers() {
|
|
323
|
-
this.#updateStaleTimeout();
|
|
324
|
-
this.#updateRefetchInterval(this.#computeRefetchInterval());
|
|
325
|
-
}
|
|
326
|
-
#clearStaleTimeout() {
|
|
327
|
-
if (this.#staleTimeoutId !== void 0) {
|
|
328
|
-
timeoutManager.clearTimeout(this.#staleTimeoutId);
|
|
329
|
-
this.#staleTimeoutId = void 0;
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
#clearRefetchInterval() {
|
|
333
|
-
if (this.#refetchIntervalId !== void 0) {
|
|
334
|
-
timeoutManager.clearInterval(this.#refetchIntervalId);
|
|
335
|
-
this.#refetchIntervalId = void 0;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
createResult(query, options) {
|
|
339
|
-
const prevQuery = this.#currentQuery;
|
|
340
|
-
const prevOptions = this.options;
|
|
341
|
-
const prevResult = this.#currentResult;
|
|
342
|
-
const prevResultState = this.#currentResultState;
|
|
343
|
-
const prevResultOptions = this.#currentResultOptions;
|
|
344
|
-
const queryInitialState = query !== prevQuery ? query.state : this.#currentQueryInitialState;
|
|
345
|
-
const { state } = query;
|
|
346
|
-
let newState = { ...state };
|
|
347
|
-
let isPlaceholderData = false;
|
|
348
|
-
let data;
|
|
349
|
-
if (options._optimisticResults) {
|
|
350
|
-
const mounted = this.hasListeners();
|
|
351
|
-
const fetchOnMount = !mounted && shouldFetchOnMount(query, options);
|
|
352
|
-
const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions);
|
|
353
|
-
if (fetchOnMount || fetchOptionally) newState = {
|
|
354
|
-
...newState,
|
|
355
|
-
...fetchState(state.data, query.options)
|
|
356
|
-
};
|
|
357
|
-
if (options._optimisticResults === "isRestoring") newState.fetchStatus = "idle";
|
|
358
|
-
}
|
|
359
|
-
let { error, errorUpdatedAt, status } = newState;
|
|
360
|
-
data = newState.data;
|
|
361
|
-
let skipSelect = false;
|
|
362
|
-
if (options.placeholderData !== void 0 && data === void 0 && status === "pending") {
|
|
363
|
-
let placeholderData;
|
|
364
|
-
if (prevResult?.isPlaceholderData && options.placeholderData === prevResultOptions?.placeholderData) {
|
|
365
|
-
placeholderData = prevResult.data;
|
|
366
|
-
skipSelect = true;
|
|
367
|
-
} else placeholderData = typeof options.placeholderData === "function" ? options.placeholderData(this.#lastQueryWithDefinedData?.state.data, this.#lastQueryWithDefinedData) : options.placeholderData;
|
|
368
|
-
if (placeholderData !== void 0) {
|
|
369
|
-
status = "success";
|
|
370
|
-
data = replaceData(prevResult?.data, placeholderData, options);
|
|
371
|
-
isPlaceholderData = true;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
if (options.select && data !== void 0 && !skipSelect) if (prevResult && data === prevResultState?.data && options.select === this.#selectFn) data = this.#selectResult;
|
|
375
|
-
else try {
|
|
376
|
-
this.#selectFn = options.select;
|
|
377
|
-
data = options.select(data);
|
|
378
|
-
data = replaceData(prevResult?.data, data, options);
|
|
379
|
-
this.#selectResult = data;
|
|
380
|
-
this.#selectError = null;
|
|
381
|
-
} catch (selectError) {
|
|
382
|
-
this.#selectError = selectError;
|
|
383
|
-
}
|
|
384
|
-
else if (data === void 0) this.#selectError = null;
|
|
385
|
-
if (this.#selectError) {
|
|
386
|
-
error = this.#selectError;
|
|
387
|
-
data = this.#selectResult;
|
|
388
|
-
errorUpdatedAt = Date.now();
|
|
389
|
-
status = "error";
|
|
390
|
-
isPlaceholderData = false;
|
|
391
|
-
}
|
|
392
|
-
const isFetching = newState.fetchStatus === "fetching";
|
|
393
|
-
const isPending = status === "pending";
|
|
394
|
-
const isError = status === "error";
|
|
395
|
-
const isLoading = isPending && isFetching;
|
|
396
|
-
const hasData = data !== void 0;
|
|
397
|
-
return {
|
|
398
|
-
status,
|
|
399
|
-
fetchStatus: newState.fetchStatus,
|
|
400
|
-
isPending,
|
|
401
|
-
isSuccess: status === "success",
|
|
402
|
-
isError,
|
|
403
|
-
isInitialLoading: isLoading,
|
|
404
|
-
isLoading,
|
|
405
|
-
data,
|
|
406
|
-
dataUpdatedAt: newState.dataUpdatedAt,
|
|
407
|
-
error,
|
|
408
|
-
errorUpdatedAt,
|
|
409
|
-
failureCount: newState.fetchFailureCount,
|
|
410
|
-
failureReason: newState.fetchFailureReason,
|
|
411
|
-
errorUpdateCount: newState.errorUpdateCount,
|
|
412
|
-
isFetched: query.isFetched(),
|
|
413
|
-
isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount,
|
|
414
|
-
isFetching,
|
|
415
|
-
isRefetching: isFetching && !isPending,
|
|
416
|
-
isLoadingError: isError && !hasData,
|
|
417
|
-
isPaused: newState.fetchStatus === "paused",
|
|
418
|
-
isPlaceholderData,
|
|
419
|
-
isRefetchError: isError && hasData,
|
|
420
|
-
isStale: isStale(query, options),
|
|
421
|
-
refetch: this.refetch,
|
|
422
|
-
isEnabled: resolveQueryValue(options.enabled, query) !== false
|
|
423
|
-
};
|
|
424
|
-
}
|
|
425
|
-
/**
|
|
426
|
-
* Recomputes and stores the current result from the current query/options, notifying listeners
|
|
427
|
-
* if it changed. Framework adapters call this right after subscribing to make sure no query
|
|
428
|
-
* update was missed in the gap between creating the observer and subscribing to it.
|
|
429
|
-
*/
|
|
430
|
-
updateResult() {
|
|
431
|
-
const prevResult = this.#currentResult;
|
|
432
|
-
const nextResult = this.createResult(this.#currentQuery, this.options);
|
|
433
|
-
this.#currentResultState = this.#currentQuery.state;
|
|
434
|
-
this.#currentResultOptions = this.options;
|
|
435
|
-
if (this.#currentResultState.data !== void 0) this.#lastQueryWithDefinedData = this.#currentQuery;
|
|
436
|
-
if (shallowEqualObjects(nextResult, prevResult)) return;
|
|
437
|
-
this.#currentResult = nextResult;
|
|
438
|
-
const shouldNotifyListeners = () => {
|
|
439
|
-
if (!prevResult) return true;
|
|
440
|
-
const { notifyOnChangeProps } = this.options;
|
|
441
|
-
const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps;
|
|
442
|
-
if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !this.#trackedProps.size) return true;
|
|
443
|
-
const includedProps = new Set(notifyOnChangePropsValue ?? this.#trackedProps);
|
|
444
|
-
if (this.options.throwOnError) includedProps.add("error");
|
|
445
|
-
return Object.keys(this.#currentResult).some((key) => {
|
|
446
|
-
const typedKey = key;
|
|
447
|
-
return this.#currentResult[typedKey] !== prevResult[typedKey] && includedProps.has(typedKey);
|
|
448
|
-
});
|
|
449
|
-
};
|
|
450
|
-
const notifyListeners = shouldNotifyListeners();
|
|
451
|
-
notifyManager.batch(() => {
|
|
452
|
-
if (notifyListeners) this.listeners.forEach((listener) => {
|
|
453
|
-
listener(this.#currentResult);
|
|
454
|
-
});
|
|
455
|
-
this.#client.getQueryCache().notify({
|
|
456
|
-
query: this.#currentQuery,
|
|
457
|
-
type: "observerResultsUpdated"
|
|
458
|
-
});
|
|
459
|
-
});
|
|
460
|
-
}
|
|
461
|
-
#updateQuery() {
|
|
462
|
-
const query = this.#client.getQueryCache().build(this.#client, this.options);
|
|
463
|
-
if (query === this.#currentQuery) return;
|
|
464
|
-
const prevQuery = this.#currentQuery;
|
|
465
|
-
this.#currentQuery = query;
|
|
466
|
-
this.#currentQueryInitialState = query.state;
|
|
467
|
-
if (this.hasListeners()) {
|
|
468
|
-
prevQuery?.removeObserver(this);
|
|
469
|
-
query.addObserver(this);
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
/** @internal */
|
|
473
|
-
onQueryUpdate() {
|
|
474
|
-
this.updateResult();
|
|
475
|
-
if (this.hasListeners()) this.#updateTimers();
|
|
476
|
-
}
|
|
477
|
-
};
|
|
478
|
-
function shouldLoadOnMount(query, options) {
|
|
479
|
-
return resolveQueryValue(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && resolveQueryValue(options.retryOnMount, query) === false);
|
|
480
|
-
}
|
|
481
|
-
function shouldFetchOnMount(query, options) {
|
|
482
|
-
return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount);
|
|
483
|
-
}
|
|
484
|
-
function shouldFetchOn(query, options, field) {
|
|
485
|
-
if (resolveQueryValue(options.enabled, query) !== false && resolveQueryValue(options.staleTime, query) !== "static") {
|
|
486
|
-
const value = resolveQueryValue(field, query);
|
|
487
|
-
return value === "always" || value !== false && isStale(query, options);
|
|
488
|
-
}
|
|
489
|
-
return false;
|
|
490
|
-
}
|
|
491
|
-
function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
|
|
492
|
-
return (query !== prevQuery || resolveQueryValue(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
|
|
493
|
-
}
|
|
494
|
-
function isStale(query, options) {
|
|
495
|
-
return resolveQueryValue(options.enabled, query) !== false && query.isStaleByTime(resolveQueryValue(options.staleTime, query));
|
|
496
|
-
}
|
|
497
|
-
//#endregion
|
|
498
|
-
//#region ../../node_modules/.pnpm/@tanstack+react-query@5.103.1_react@19.2.7/node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js
|
|
499
|
-
var IsRestoringContext = import_react.createContext(false);
|
|
500
|
-
/**
|
|
501
|
-
* If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` hook alongside it to
|
|
502
|
-
* check if a restore is currently in progress. `useQuery` and friends also check this internally to avoid
|
|
503
|
-
* race conditions between the restore and mounting queries.
|
|
504
|
-
*
|
|
505
|
-
* @returns `true` while a persisted client is being restored, `false` otherwise.
|
|
506
|
-
*/
|
|
507
|
-
var useIsRestoring = () => import_react.useContext(IsRestoringContext);
|
|
508
|
-
IsRestoringContext.Provider;
|
|
509
|
-
//#endregion
|
|
510
|
-
//#region ../../node_modules/.pnpm/@tanstack+react-query@5.103.1_react@19.2.7/node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js
|
|
511
|
-
/**
|
|
512
|
-
* Resets any query errors within the boundary, so queries know they can try again.
|
|
513
|
-
*/
|
|
514
|
-
function createValue() {
|
|
515
|
-
let isReset = false;
|
|
516
|
-
return {
|
|
517
|
-
/**
|
|
518
|
-
* Clears the reset state, so queries know not to try again until the boundary is reset again.
|
|
519
|
-
*/
|
|
520
|
-
clearReset: () => {
|
|
521
|
-
isReset = false;
|
|
522
|
-
},
|
|
523
|
-
/**
|
|
524
|
-
* Resets any query errors within the boundary, so queries know they can try again.
|
|
525
|
-
*/
|
|
526
|
-
reset: () => {
|
|
527
|
-
isReset = true;
|
|
528
|
-
},
|
|
529
|
-
/**
|
|
530
|
-
* Returns whether the boundary has been reset and not yet cleared.
|
|
531
|
-
*/
|
|
532
|
-
isReset: () => {
|
|
533
|
-
return isReset;
|
|
534
|
-
}
|
|
535
|
-
};
|
|
536
|
-
}
|
|
537
|
-
var QueryErrorResetBoundaryContext = import_react.createContext(createValue());
|
|
538
|
-
/**
|
|
539
|
-
* This hook will reset any query errors within the closest `QueryErrorResetBoundary`. If there is no boundary
|
|
540
|
-
* defined it will reset them globally.
|
|
541
|
-
*
|
|
542
|
-
* @returns The boundary's {@link QueryErrorResetBoundaryValue}.
|
|
543
|
-
*
|
|
544
|
-
* @example
|
|
545
|
-
* ```tsx
|
|
546
|
-
* import { ErrorBoundary } from 'react-error-boundary'
|
|
547
|
-
* import { useQueryErrorResetBoundary } from '@tanstack/react-query'
|
|
548
|
-
*
|
|
549
|
-
* function App({ children }: { children: React.ReactNode }) {
|
|
550
|
-
* const { reset } = useQueryErrorResetBoundary()
|
|
551
|
-
*
|
|
552
|
-
* return (
|
|
553
|
-
* <ErrorBoundary
|
|
554
|
-
* onReset={reset}
|
|
555
|
-
* fallbackRender={({ resetErrorBoundary }) => (
|
|
556
|
-
* <div>
|
|
557
|
-
* There was an error!
|
|
558
|
-
* <button onClick={() => resetErrorBoundary()}>Try again</button>
|
|
559
|
-
* </div>
|
|
560
|
-
* )}
|
|
561
|
-
* >
|
|
562
|
-
* {children}
|
|
563
|
-
* </ErrorBoundary>
|
|
564
|
-
* )
|
|
565
|
-
* }
|
|
566
|
-
* ```
|
|
567
|
-
*/
|
|
568
|
-
var useQueryErrorResetBoundary = () => import_react.useContext(QueryErrorResetBoundaryContext);
|
|
569
|
-
//#endregion
|
|
570
|
-
//#region ../../node_modules/.pnpm/@tanstack+react-query@5.103.1_react@19.2.7/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js
|
|
571
|
-
var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary, query) => {
|
|
572
|
-
const throwOnError = query?.state.error && typeof options.throwOnError === "function" ? shouldThrowError(options.throwOnError, [query.state.error, query]) : options.throwOnError;
|
|
573
|
-
if (options.suspense || throwOnError) {
|
|
574
|
-
if (!errorResetBoundary.isReset()) options.retryOnMount = false;
|
|
575
|
-
}
|
|
576
|
-
};
|
|
577
|
-
var useClearResetErrorBoundary = (errorResetBoundary) => {
|
|
578
|
-
import_react.useEffect(() => {
|
|
579
|
-
errorResetBoundary.clearReset();
|
|
580
|
-
}, [errorResetBoundary]);
|
|
581
|
-
};
|
|
582
|
-
var getHasError = ({ result, errorResetBoundary, throwOnError, query, suspense }) => {
|
|
583
|
-
return result.isError && !errorResetBoundary.isReset() && !result.isFetching && query && (suspense && result.data === void 0 || shouldThrowError(throwOnError, [result.error, query]));
|
|
584
|
-
};
|
|
585
|
-
//#endregion
|
|
586
|
-
//#region ../../node_modules/.pnpm/@tanstack+react-query@5.103.1_react@19.2.7/node_modules/@tanstack/react-query/build/modern/suspense.js
|
|
587
|
-
var defaultThrowOnError = (_error, query) => query.state.data === void 0;
|
|
588
|
-
var ensureSuspenseTimers = (defaultedOptions) => {
|
|
589
|
-
if (defaultedOptions.suspense) {
|
|
590
|
-
const MIN_SUSPENSE_TIME_MS = 1e3;
|
|
591
|
-
const clamp = (value) => value === "static" ? value : Math.max(value ?? MIN_SUSPENSE_TIME_MS, MIN_SUSPENSE_TIME_MS);
|
|
592
|
-
const originalStaleTime = defaultedOptions.staleTime;
|
|
593
|
-
defaultedOptions.staleTime = typeof originalStaleTime === "function" ? (...args) => clamp(originalStaleTime(...args)) : clamp(originalStaleTime);
|
|
594
|
-
if (typeof defaultedOptions.gcTime === "number") defaultedOptions.gcTime = Math.max(defaultedOptions.gcTime, MIN_SUSPENSE_TIME_MS);
|
|
595
|
-
}
|
|
596
|
-
};
|
|
597
|
-
var shouldSuspend = (defaultedOptions, result) => defaultedOptions?.suspense && result.isPending;
|
|
598
|
-
var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => {
|
|
599
|
-
errorResetBoundary.clearReset();
|
|
600
|
-
});
|
|
601
|
-
//#endregion
|
|
602
|
-
export { ensurePreventErrorBoundaryRetry as a, useQueryErrorResetBoundary as c, QueryClientProvider as d, useQueryClient as f, shouldSuspend as i, useIsRestoring as l, ensureSuspenseTimers as n, getHasError as o, fetchOptimistic as r, useClearResetErrorBoundary as s, defaultThrowOnError as t, QueryObserver as u };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { n as createFileRoute, t as lazyRouteComponent } from "./lazyRouteComponent-CqBNCGuZ.js";
|
|
2
|
-
import { u as loadPrincipal } from "./page-D6n45dcK.js";
|
|
3
|
-
//#region src/routes/tokens.$token.tsx
|
|
4
|
-
var $$splitComponentImporter = () => import("./tokens._token-CrBMpcbN.js");
|
|
5
|
-
var Route = createFileRoute("/tokens/$token")({
|
|
6
|
-
loader: ({ context: { client, queryClient }, params }) => loadPrincipal(queryClient, client, "service", params.token),
|
|
7
|
-
component: lazyRouteComponent($$splitComponentImporter, "component")
|
|
8
|
-
});
|
|
9
|
-
//#endregion
|
|
10
|
-
export { Route as t };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { r as require_jsx_runtime } from "./useRouter-CaUSUNsw.js";
|
|
2
|
-
import { C as useCoffre, h as queries, i as PageHeader, n as ClosedDoor } from "./page-D6n45dcK.js";
|
|
3
|
-
import { t as useShell } from "./use-shell-DwOzEi87.js";
|
|
4
|
-
import { t as useSuspenseQuery } from "./useSuspenseQuery-CSoHzrMb.js";
|
|
5
|
-
import { v as Key } from "./icons-DOFT-eWB.js";
|
|
6
|
-
import { n as DirectoryTable, t as AddPrincipal } from "./directory-B-_rqsPx.js";
|
|
7
|
-
import { n as RemovedList } from "./offboarding-CRz-K82H.js";
|
|
8
|
-
//#region src/routes/tokens.index.tsx?tsr-split=component
|
|
9
|
-
var import_jsx_runtime = require_jsx_runtime();
|
|
10
|
-
function TokensPage() {
|
|
11
|
-
const { capabilities } = useShell();
|
|
12
|
-
const { data: result } = useSuspenseQuery(queries.directory(useCoffre(), capabilities.canManageGrants));
|
|
13
|
-
if (!result.ok) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ClosedDoor, {
|
|
14
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Key, { size: 18 }),
|
|
15
|
-
label: "Tokens",
|
|
16
|
-
title: "Tokens are closed to you",
|
|
17
|
-
children: result.error
|
|
18
|
-
});
|
|
19
|
-
const tokens = result.principals.filter((principal) => principal.principalType === "service");
|
|
20
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
21
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageHeader, {
|
|
22
|
-
title: "Tokens",
|
|
23
|
-
actions: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AddPrincipal, { principalType: "service" })
|
|
24
|
-
}),
|
|
25
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DirectoryTable, {
|
|
26
|
-
principalType: "service",
|
|
27
|
-
principals: tokens,
|
|
28
|
-
hasRemoved: result.removed.some((principal) => principal.principalType === "service")
|
|
29
|
-
}),
|
|
30
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(RemovedList, {
|
|
31
|
-
principalType: "service",
|
|
32
|
-
removed: result.removed
|
|
33
|
-
})
|
|
34
|
-
] });
|
|
35
|
-
}
|
|
36
|
-
//#endregion
|
|
37
|
-
export { TokensPage as component };
|