@coffre/ui 0.1.18 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) hide show
  1. package/README.md +23 -3
  2. package/dist/{server/_coffre/assets/affordances-CKANXDTG.js → chunks/affordances-DAvsVz7u.js} +12 -7
  3. package/dist/chunks/affordances-DAvsVz7u.js.map +1 -0
  4. package/dist/chunks/directory-CSjWWUQ1.js +370 -0
  5. package/dist/chunks/directory-CSjWWUQ1.js.map +1 -0
  6. package/dist/{server/_coffre/assets/grants-DdKT11Ny.js → chunks/grants-saMQagmG.js} +41 -39
  7. package/dist/chunks/grants-saMQagmG.js.map +1 -0
  8. package/dist/chunks/icons-D-PfAfnH.js +203 -0
  9. package/dist/chunks/icons-D-PfAfnH.js.map +1 -0
  10. package/dist/chunks/mounted-jJmqqV_n.js +17 -0
  11. package/dist/chunks/mounted-jJmqqV_n.js.map +1 -0
  12. package/dist/{server/_coffre/assets/offboarding-CRz-K82H.js → chunks/offboarding-C6l30DZR.js} +70 -69
  13. package/dist/chunks/offboarding-C6l30DZR.js.map +1 -0
  14. package/dist/chunks/page-C5HcNqf2.js +190 -0
  15. package/dist/chunks/page-C5HcNqf2.js.map +1 -0
  16. package/dist/chunks/page-route-Drfw7lmn.js +20 -0
  17. package/dist/chunks/page-route-Drfw7lmn.js.map +1 -0
  18. package/dist/{server/_coffre/assets/principal-page-C-EFwJQw.js → chunks/principal-page-D_91OA0l.js} +105 -103
  19. package/dist/chunks/principal-page-D_91OA0l.js.map +1 -0
  20. package/dist/{server/_coffre/assets → chunks}/project-environments-lEzFHUt4.js +2 -0
  21. package/dist/chunks/project-environments-lEzFHUt4.js.map +1 -0
  22. package/dist/chunks/queries-CQ81o4so.js +376 -0
  23. package/dist/chunks/queries-CQ81o4so.js.map +1 -0
  24. package/dist/{server/_coffre/assets/row-state-C2P57xT1.js → chunks/row-state-0PsrEzOL.js} +22 -21
  25. package/dist/chunks/row-state-0PsrEzOL.js.map +1 -0
  26. package/dist/{server/_coffre/assets → chunks}/signin-errors-BEFlVDbQ.js +2 -0
  27. package/dist/chunks/signin-errors-BEFlVDbQ.js.map +1 -0
  28. package/dist/chunks/theme-B2vQolVR.js +86 -0
  29. package/dist/chunks/theme-B2vQolVR.js.map +1 -0
  30. package/dist/chunks/ui-DixXLQvQ.js +405 -0
  31. package/dist/chunks/ui-DixXLQvQ.js.map +1 -0
  32. package/dist/{server/_coffre/assets/use-action-B-xpvVRO.js → chunks/use-action-CWsg_YWU.js} +8 -6
  33. package/dist/chunks/use-action-CWsg_YWU.js.map +1 -0
  34. package/dist/{server/_coffre/assets/use-change-C8BCf3oU.js → chunks/use-change-c6CeLRin.js} +10 -474
  35. package/dist/chunks/use-change-c6CeLRin.js.map +1 -0
  36. package/dist/chunks/use-shell-jxd7Tzd-.js +26 -0
  37. package/dist/chunks/use-shell-jxd7Tzd-.js.map +1 -0
  38. package/dist/{server/_coffre/assets → chunks}/validation-BQtqPe2V.js +2 -0
  39. package/dist/chunks/validation-BQtqPe2V.js.map +1 -0
  40. package/dist/index.d.ts +386 -18
  41. package/dist/index.js +1147 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/pages/account.d.ts +9 -0
  44. package/dist/pages/account.js +334 -0
  45. package/dist/pages/account.js.map +1 -0
  46. package/dist/pages/audit.d.ts +3 -0
  47. package/dist/{server/_coffre/assets/audit-qB9G2AQJ.js → pages/audit.js} +102 -100
  48. package/dist/pages/audit.js.map +1 -0
  49. package/dist/pages/device-login.d.ts +9 -0
  50. package/dist/pages/device-login.js +211 -0
  51. package/dist/pages/device-login.js.map +1 -0
  52. package/dist/pages/environment.d.ts +3 -0
  53. package/dist/{server/_coffre/assets/projects._project._environment-C6uybzeU.js → pages/environment.js} +323 -469
  54. package/dist/pages/environment.js.map +1 -0
  55. package/dist/pages/login.d.ts +10 -0
  56. package/dist/pages/login.js +104 -0
  57. package/dist/pages/login.js.map +1 -0
  58. package/dist/pages/project.d.ts +2 -0
  59. package/dist/{server/_coffre/assets/projects._project.index-3CXwkyTh.js → pages/project.js} +223 -225
  60. package/dist/pages/project.js.map +1 -0
  61. package/dist/pages/projects.d.ts +3 -0
  62. package/dist/{server/_coffre/assets/projects.index-iSoBpRFz.js → pages/projects.js} +83 -81
  63. package/dist/pages/projects.js.map +1 -0
  64. package/dist/pages/settings.d.ts +3 -0
  65. package/dist/{server/_coffre/assets/settings-BDQTF5XW.js → pages/settings.js} +20 -18
  66. package/dist/pages/settings.js.map +1 -0
  67. package/dist/pages/token.d.ts +3 -0
  68. package/dist/{server/_coffre/assets/tokens._token-CrBMpcbN.js → pages/token.js} +195 -265
  69. package/dist/pages/token.js.map +1 -0
  70. package/dist/pages/tokens.d.ts +3 -0
  71. package/dist/pages/tokens.js +39 -0
  72. package/dist/pages/tokens.js.map +1 -0
  73. package/dist/pages/unregistered.d.ts +8 -0
  74. package/dist/pages/unregistered.js +54 -0
  75. package/dist/pages/unregistered.js.map +1 -0
  76. package/dist/pages/user.d.ts +3 -0
  77. package/dist/pages/user.js +16 -0
  78. package/dist/pages/user.js.map +1 -0
  79. package/dist/pages/users.d.ts +3 -0
  80. package/dist/pages/users.js +39 -0
  81. package/dist/pages/users.js.map +1 -0
  82. package/dist/project-BqIy8gYR.d.ts +5 -0
  83. package/dist/vite.d.ts +16 -0
  84. package/dist/vite.js +52 -0
  85. package/package.json +36 -21
  86. package/src/assets/icon.svg +1 -0
  87. package/src/components/affordances.ts +10 -4
  88. package/src/components/command-palette.tsx +229 -203
  89. package/src/components/directory.tsx +34 -38
  90. package/src/components/principal.tsx +7 -3
  91. package/src/components/shell.tsx +89 -127
  92. package/src/components/theme.tsx +14 -81
  93. package/src/components/ui.tsx +97 -68
  94. package/src/index.ts +29 -0
  95. package/src/layout.tsx +113 -0
  96. package/src/lib/coffre.ts +8 -4
  97. package/src/lib/mounted.ts +13 -0
  98. package/src/lib/page-context.ts +31 -0
  99. package/src/lib/page-route.ts +22 -0
  100. package/src/lib/preferences.tsx +46 -0
  101. package/src/options.ts +240 -0
  102. package/src/{routes → pages}/account.tsx +7 -24
  103. package/src/{routes → pages}/audit.tsx +5 -16
  104. package/src/{routes/auth.device.tsx → pages/device-login.tsx} +8 -21
  105. package/src/{routes/projects.$project.$environment.tsx → pages/environment.tsx} +43 -52
  106. package/src/{routes → pages}/login.tsx +5 -16
  107. package/src/{routes/projects.$project.index.tsx → pages/project.tsx} +38 -50
  108. package/src/{routes/projects.index.tsx → pages/projects.tsx} +2 -7
  109. package/src/{routes → pages}/settings.tsx +3 -10
  110. package/src/{routes/tokens.$token.tsx → pages/token.tsx} +6 -7
  111. package/src/{routes/tokens.index.tsx → pages/tokens.tsx} +3 -8
  112. package/src/{routes → pages}/unregistered.tsx +1 -6
  113. package/src/pages/user.tsx +10 -0
  114. package/src/{routes/users.index.tsx → pages/users.tsx} +3 -8
  115. package/src/register.ts +55 -0
  116. package/src/router.tsx +31 -62
  117. package/src/styles/globals.css +104 -46
  118. package/src/vite.ts +78 -0
  119. package/dist/client/.assetsignore +0 -2
  120. package/dist/client/_coffre/assets/account-BoLGAxbD.js +0 -2
  121. package/dist/client/_coffre/assets/account-CnnuRTDB.js +0 -1
  122. package/dist/client/_coffre/assets/affordances-CEafRJcN.js +0 -1
  123. package/dist/client/_coffre/assets/audit-CHSvKLWX.js +0 -1
  124. package/dist/client/_coffre/assets/audit-Cn4hmS4u.js +0 -2
  125. package/dist/client/_coffre/assets/auth.device-Co5vrpaA.js +0 -2
  126. package/dist/client/_coffre/assets/auth.device-DAlqWacc.js +0 -1
  127. package/dist/client/_coffre/assets/directory-H8Eh3MnS.js +0 -1
  128. package/dist/client/_coffre/assets/dist-Braunv_x.js +0 -1
  129. package/dist/client/_coffre/assets/globals-CpMrgkV6.css +0 -1
  130. package/dist/client/_coffre/assets/grants-DPDxJXU1.js +0 -1
  131. package/dist/client/_coffre/assets/icons-Dc_-t0lp.js +0 -1
  132. package/dist/client/_coffre/assets/index-sUCIXRgJ.js +0 -12
  133. package/dist/client/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
  134. package/dist/client/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
  135. package/dist/client/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
  136. package/dist/client/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
  137. package/dist/client/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
  138. package/dist/client/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
  139. package/dist/client/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
  140. package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
  141. package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  142. package/dist/client/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  143. package/dist/client/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  144. package/dist/client/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  145. package/dist/client/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  146. package/dist/client/_coffre/assets/link-DBINMwm6.js +0 -1
  147. package/dist/client/_coffre/assets/login-BZFYfL1Y.js +0 -1
  148. package/dist/client/_coffre/assets/login-CYCKWTOD.js +0 -2
  149. package/dist/client/_coffre/assets/offboarding-Bwpftp3g.js +0 -1
  150. package/dist/client/_coffre/assets/page-C_hnzdaR.js +0 -1
  151. package/dist/client/_coffre/assets/preload-helper-CLkO85Nq.js +0 -1
  152. package/dist/client/_coffre/assets/principal-page-DLho8TSJ.js +0 -1
  153. package/dist/client/_coffre/assets/project-environments-CfIH5kFM.js +0 -1
  154. package/dist/client/_coffre/assets/projects._project._environment-DHRRvQw0.js +0 -3
  155. package/dist/client/_coffre/assets/projects._project._environment-TLI-RjBZ.js +0 -2
  156. package/dist/client/_coffre/assets/projects._project.index-BO-8FZIY.js +0 -2
  157. package/dist/client/_coffre/assets/projects._project.index-DGl921dP.js +0 -1
  158. package/dist/client/_coffre/assets/projects.index-BDn7Bhoo.js +0 -1
  159. package/dist/client/_coffre/assets/row-state-DJ-KLamZ.js +0 -1
  160. package/dist/client/_coffre/assets/settings-q9G1QvR_.js +0 -1
  161. package/dist/client/_coffre/assets/signin-errors-CroZWZgm.js +0 -1
  162. package/dist/client/_coffre/assets/suspense-O8sP0mEC.js +0 -1
  163. package/dist/client/_coffre/assets/tokens._token-B_qczpT9.js +0 -2
  164. package/dist/client/_coffre/assets/tokens._token-T-sqwMbz.js +0 -2
  165. package/dist/client/_coffre/assets/tokens.index-CcXSZnAG.js +0 -1
  166. package/dist/client/_coffre/assets/ui-BXP2IqrW.js +0 -46
  167. package/dist/client/_coffre/assets/unregistered-D2JXJ90x.js +0 -1
  168. package/dist/client/_coffre/assets/use-action-BpzKWhgg.js +0 -1
  169. package/dist/client/_coffre/assets/use-change-CKj3Inq9.js +0 -1
  170. package/dist/client/_coffre/assets/use-shell-W0SusPkz.js +0 -1
  171. package/dist/client/_coffre/assets/useQuery-B-lxFSES.js +0 -1
  172. package/dist/client/_coffre/assets/useSuspenseQuery-BZ-nzHST.js +0 -1
  173. package/dist/client/_coffre/assets/users._user-Bb3BGYHl.js +0 -1
  174. package/dist/client/_coffre/assets/users._user-DXmvKrzE.js +0 -2
  175. package/dist/client/_coffre/assets/users.index-BvzP3qwW.js +0 -1
  176. package/dist/client/_coffre/assets/validation-9Cl_XS-l.js +0 -1
  177. package/dist/server/.vite/manifest.json +0 -668
  178. package/dist/server/_coffre/assets/_tanstack-start-manifest_v-GsKnGGRy.js +0 -162
  179. package/dist/server/_coffre/assets/account-CV-a2IU2.js +0 -329
  180. package/dist/server/_coffre/assets/account-hk6wcIXU.js +0 -162
  181. package/dist/server/_coffre/assets/async-local-storage-C10uQtMM.js +0 -3108
  182. package/dist/server/_coffre/assets/audit-C1_Ej6YB.js +0 -31
  183. package/dist/server/_coffre/assets/auth.device-6JRrWbSV.js +0 -210
  184. package/dist/server/_coffre/assets/auth.device-CLoAxC2T.js +0 -29
  185. package/dist/server/_coffre/assets/directory-B-_rqsPx.js +0 -371
  186. package/dist/server/_coffre/assets/dist-CnnV3t2g.js +0 -908
  187. package/dist/server/_coffre/assets/empty-plugin-adapters-Cq4--YW-.js +0 -5
  188. package/dist/server/_coffre/assets/globals-CpMrgkV6.css +0 -1
  189. package/dist/server/_coffre/assets/icons-DOFT-eWB.js +0 -1704
  190. package/dist/server/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
  191. package/dist/server/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
  192. package/dist/server/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
  193. package/dist/server/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
  194. package/dist/server/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
  195. package/dist/server/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
  196. package/dist/server/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
  197. package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
  198. package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  199. package/dist/server/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  200. package/dist/server/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  201. package/dist/server/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  202. package/dist/server/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  203. package/dist/server/_coffre/assets/lazyRouteComponent-CqBNCGuZ.js +0 -480
  204. package/dist/server/_coffre/assets/link-42ZWdjzZ.js +0 -422
  205. package/dist/server/_coffre/assets/login-DRKUKkaW.js +0 -22
  206. package/dist/server/_coffre/assets/login-DnwxVl4Y.js +0 -102
  207. package/dist/server/_coffre/assets/matchContext-qLfYbC6_.js +0 -56
  208. package/dist/server/_coffre/assets/page-D6n45dcK.js +0 -3561
  209. package/dist/server/_coffre/assets/projects._project._environment-CS8DdSMY.js +0 -48
  210. package/dist/server/_coffre/assets/projects._project.index-BGfcNpj0.js +0 -23
  211. package/dist/server/_coffre/assets/react-dom-bBoJXlK2.js +0 -1718
  212. package/dist/server/_coffre/assets/router-9BTgJhWG.js +0 -2322
  213. package/dist/server/_coffre/assets/start-DR3rN0St.js +0 -4
  214. package/dist/server/_coffre/assets/suspense-C-2QfDd2.js +0 -602
  215. package/dist/server/_coffre/assets/tokens._token-rY86Cjgp.js +0 -10
  216. package/dist/server/_coffre/assets/tokens.index-Bq5qDW9q.js +0 -37
  217. package/dist/server/_coffre/assets/ui-Cc0CGMtr.js +0 -14881
  218. package/dist/server/_coffre/assets/unregistered-D9ZKLOPJ.js +0 -53
  219. package/dist/server/_coffre/assets/use-shell-DwOzEi87.js +0 -462
  220. package/dist/server/_coffre/assets/useQuery-CTe86qFq.js +0 -8
  221. package/dist/server/_coffre/assets/useRouter-CaUSUNsw.js +0 -473
  222. package/dist/server/_coffre/assets/useSuspenseQuery-CSoHzrMb.js +0 -117
  223. package/dist/server/_coffre/assets/users._user-BmLKYeo_.js +0 -10
  224. package/dist/server/_coffre/assets/users._user-BmiHwQx3.js +0 -14
  225. package/dist/server/_coffre/assets/users.index-BiEax90r.js +0 -37
  226. package/dist/server/index.js +0 -13911
  227. package/src/assets/favicon-32.png +0 -0
  228. package/src/components/agentation.tsx +0 -34
  229. package/src/entry.ts +0 -19
  230. package/src/routeTree.gen.ts +0 -367
  231. package/src/routes/__root.tsx +0 -169
  232. package/src/routes/access.tsx +0 -11
  233. package/src/routes/index.tsx +0 -15
  234. package/src/routes/users.$user.tsx +0 -13
  235. package/src/types.ts +0 -21
@@ -1,53 +0,0 @@
1
- import { r as require_jsx_runtime } from "./useRouter-CaUSUNsw.js";
2
- import { n as ClosedDoor } from "./page-D6n45dcK.js";
3
- import { t as useShell } from "./use-shell-DwOzEi87.js";
4
- import { H as User } from "./icons-DOFT-eWB.js";
5
- //#region src/routes/unregistered.tsx?tsr-split=component
6
- var import_jsx_runtime = require_jsx_runtime();
7
- /**
8
- * Cloudflare Access has authenticated this person, but Coffre has not
9
- * registered them as a member. Keep this deliberately actionless: registration is
10
- * an owner decision, not a self-service privilege escalation path.
11
- */
12
- function UnregisteredPage() {
13
- const { principal, accessTampered } = useShell();
14
- if (accessTampered) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ClosedDoor, {
15
- icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(User, { size: 18 }),
16
- label: "Integrity check failed",
17
- title: "Your access is on hold",
18
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
19
- "Your access record",
20
- principal !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
21
- " ",
22
- "(",
23
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
24
- className: "mono",
25
- children: principal.id
26
- }),
27
- ")"
28
- ] }),
29
- " ",
30
- "was changed outside coffre, so its vault refuses it until someone looks. Nothing you held is available meanwhile."
31
- ] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Ask a coffre owner to remove you under Users and add you again, which starts your access over." })]
32
- });
33
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ClosedDoor, {
34
- icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(User, { size: 18 }),
35
- label: "Registration required",
36
- title: "You are not a member yet",
37
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
38
- "Cloudflare Access knows who you are",
39
- principal !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
40
- " ",
41
- "(",
42
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
43
- className: "mono",
44
- children: principal.id
45
- }),
46
- ")"
47
- ] }),
48
- ", but this coffre instance has not registered that identity. Until it does, no projects, secrets, audit entries or API operations are available to you."
49
- ] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Ask a coffre owner or root admin to add your Access email under Users." })]
50
- });
51
- }
52
- //#endregion
53
- export { UnregisteredPage as component };
@@ -1,462 +0,0 @@
1
- import { i as require_react, s as __toESM } from "./useRouter-CaUSUNsw.js";
2
- import { C as useCoffre, D as notifyManager, F as replaceEqualDeep, L as shallowEqualObjects, N as noop, _ as shellOf, h as queries, k as Subscribable } from "./page-D6n45dcK.js";
3
- import { a as ensurePreventErrorBoundaryRetry, c as useQueryErrorResetBoundary, f as useQueryClient, i as shouldSuspend, l as useIsRestoring, n as ensureSuspenseTimers, o as getHasError, r as fetchOptimistic, s as useClearResetErrorBoundary, t as defaultThrowOnError, u as QueryObserver } from "./suspense-C-2QfDd2.js";
4
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.103.1/node_modules/@tanstack/query-core/build/modern/queriesObserver.js
5
- function difference(array1, array2) {
6
- const excludeSet = new Set(array2);
7
- return array1.filter((x) => !excludeSet.has(x));
8
- }
9
- /**
10
- * A `QueriesObserver` watches an array of queries at once, exposing them as
11
- * a single array of `QueryObserverResult`s (or, when a `combine` option is
12
- * given, as a combined value derived from that array). It manages one
13
- * internal `QueryObserver` per query, and is the primitive that framework
14
- * adapters (e.g. `useQueries`) build their hooks on top of.
15
- *
16
- * @example
17
- * ```ts
18
- * const observer = new QueriesObserver(queryClient, [
19
- * { queryKey: ['post', 1], queryFn: fetchPost },
20
- * { queryKey: ['post', 2], queryFn: fetchPost },
21
- * ])
22
- *
23
- * const unsubscribe = observer.subscribe((result) => {
24
- * console.log(result)
25
- * })
26
- * ```
27
- */
28
- var QueriesObserver = class extends Subscribable {
29
- #client;
30
- #result;
31
- #queries;
32
- #options;
33
- #observers;
34
- #combinedResult;
35
- #lastCombine;
36
- #lastResult;
37
- #lastQueryHashes;
38
- #observerMatches = [];
39
- constructor(client, queries, options) {
40
- super();
41
- this.#client = client;
42
- this.#options = options;
43
- this.#queries = [];
44
- this.#observers = [];
45
- this.#result = [];
46
- this.setQueries(queries);
47
- }
48
- onSubscribe() {
49
- if (this.listeners.size === 1) this.#observers.forEach((observer) => {
50
- observer.subscribe((result) => {
51
- this.#onUpdate(observer, result);
52
- });
53
- });
54
- }
55
- onUnsubscribe() {
56
- if (!this.listeners.size) this.destroy();
57
- }
58
- /**
59
- * Stops observing all queries: clears all listeners and destroys every
60
- * underlying `QueryObserver` this observer manages.
61
- */
62
- destroy() {
63
- this.listeners = /* @__PURE__ */ new Set();
64
- this.#observers.forEach((observer) => {
65
- observer.destroy();
66
- });
67
- }
68
- /**
69
- * Replaces the set of queries being observed. Existing `QueryObserver`s
70
- * are reused for queries that match an already-observed query hash;
71
- * observers for queries that are no longer present are destroyed, and new
72
- * observers are created and subscribed to for newly added queries.
73
- *
74
- * @example
75
- * ```ts
76
- * observer.setQueries([
77
- * { queryKey: ['post', 1], queryFn: fetchPost },
78
- * { queryKey: ['post', 3], queryFn: fetchPost },
79
- * ])
80
- * ```
81
- */
82
- setQueries(queries, options) {
83
- this.#queries = queries;
84
- this.#options = options;
85
- notifyManager.batch(() => {
86
- const prevObservers = this.#observers;
87
- const newObserverMatches = this.#findMatchingObservers(this.#queries);
88
- newObserverMatches.forEach((match) => match.observer.setOptions(match.defaultedQueryOptions));
89
- const newObservers = newObserverMatches.map((match) => match.observer);
90
- const newResult = newObservers.map((observer) => observer.getCurrentResult());
91
- const hasLengthChange = prevObservers.length !== newObservers.length;
92
- const hasIndexChange = newObservers.some((observer, index) => observer !== prevObservers[index]);
93
- const hasStructuralChange = hasLengthChange || hasIndexChange;
94
- const hasResultChange = hasStructuralChange ? true : newResult.some((result, index) => {
95
- const prev = this.#result[index];
96
- return !prev || !shallowEqualObjects(result, prev);
97
- });
98
- if (!hasStructuralChange && !hasResultChange) return;
99
- if (hasStructuralChange) {
100
- this.#observerMatches = newObserverMatches;
101
- this.#observers = newObservers;
102
- }
103
- this.#result = newResult;
104
- if (!this.hasListeners()) return;
105
- if (hasStructuralChange) {
106
- difference(prevObservers, newObservers).forEach((observer) => {
107
- observer.destroy();
108
- });
109
- difference(newObservers, prevObservers).forEach((observer) => {
110
- observer.subscribe((result) => {
111
- this.#onUpdate(observer, result);
112
- });
113
- });
114
- }
115
- this.#notify();
116
- });
117
- }
118
- /**
119
- * Returns the most recently computed array of `QueryObserverResult`s, one
120
- * per observed query, in the same order as the queries passed to the
121
- * constructor or `setQueries`.
122
- *
123
- * @example
124
- * ```ts
125
- * const results = observer.getCurrentResult()
126
- * const data = results.map((result) => result.data)
127
- * ```
128
- */
129
- getCurrentResult() {
130
- return this.#result;
131
- }
132
- /**
133
- * Returns the underlying `Query` instances currently being observed, in
134
- * the same order as the queries passed to the constructor or `setQueries`.
135
- */
136
- getQueries() {
137
- return this.#observers.map((observer) => observer.getCurrentQuery());
138
- }
139
- /**
140
- * Returns the underlying `QueryObserver` instances this observer manages,
141
- * in the same order as the queries passed to the constructor or
142
- * `setQueries`.
143
- */
144
- getObservers() {
145
- return this.#observers;
146
- }
147
- /**
148
- * The `QueriesObserver` counterpart of {@link QueryObserver#getOptimisticResult} — computes
149
- * the result for the given (already-defaulted) queries right now, synchronously. Called by
150
- * framework adapters (e.g. `useQueries`) ahead of subscribing, returning a tuple of the raw
151
- * per-query results, a function to compute the combined result from them, and a function to
152
- * wrap the results for property-access tracking.
153
- */
154
- getOptimisticResult(queries, combine) {
155
- const matches = this.#findMatchingObservers(queries);
156
- const result = matches.map((match) => match.observer.getOptimisticResult(match.defaultedQueryOptions));
157
- const queryHashes = matches.map((match) => match.defaultedQueryOptions.queryHash);
158
- return [
159
- result,
160
- (r) => {
161
- return this.#combineResult(r ?? result, combine, queryHashes);
162
- },
163
- () => {
164
- return this.#trackResult(result, matches);
165
- }
166
- ];
167
- }
168
- #trackResult(result, matches) {
169
- const trackedProps = /* @__PURE__ */ new Set();
170
- return matches.map((match, index) => {
171
- const observerResult = result[index];
172
- return !match.defaultedQueryOptions.notifyOnChangeProps ? match.observer.trackResult(observerResult, (accessedProp) => {
173
- if (!trackedProps.has(accessedProp)) {
174
- trackedProps.add(accessedProp);
175
- matches.forEach((m) => {
176
- m.observer.trackProp(accessedProp);
177
- });
178
- }
179
- }) : observerResult;
180
- });
181
- }
182
- #combineResult(input, combine, queryHashes) {
183
- if (combine) {
184
- const lastHashes = this.#lastQueryHashes;
185
- const queryHashesChanged = queryHashes !== void 0 && lastHashes !== void 0 && (lastHashes.length !== queryHashes.length || queryHashes.some((hash, i) => hash !== lastHashes[i]));
186
- if (this.#result !== this.#lastResult || queryHashesChanged || combine !== this.#lastCombine) {
187
- this.#lastCombine = combine;
188
- this.#lastResult = this.#result;
189
- if (queryHashes !== void 0) this.#lastQueryHashes = queryHashes;
190
- this.#combinedResult = replaceEqualDeep(this.#combinedResult, combine(input));
191
- }
192
- return this.#combinedResult;
193
- }
194
- return input;
195
- }
196
- #shouldSkipCombine() {
197
- return !this.#options?.combine || this.#observers.some((observer, index) => {
198
- return observer.options.suspense && this.#result[index]?.data === void 0;
199
- });
200
- }
201
- #findMatchingObservers(queries) {
202
- const prevObserversMap = /* @__PURE__ */ new Map();
203
- this.#observers.forEach((observer) => {
204
- const key = observer.options.queryHash;
205
- if (!key) return;
206
- const previousObservers = prevObserversMap.get(key);
207
- if (previousObservers) previousObservers.push(observer);
208
- else prevObserversMap.set(key, [observer]);
209
- });
210
- const observers = [];
211
- queries.forEach((options) => {
212
- const defaultedOptions = this.#client.defaultQueryOptions(options);
213
- const observer = prevObserversMap.get(defaultedOptions.queryHash)?.shift() ?? new QueryObserver(this.#client, defaultedOptions);
214
- observers.push({
215
- defaultedQueryOptions: defaultedOptions,
216
- observer
217
- });
218
- });
219
- return observers;
220
- }
221
- #onUpdate(observer, result) {
222
- const index = this.#observers.indexOf(observer);
223
- if (index !== -1) {
224
- this.#result = this.#result.slice();
225
- this.#result[index] = result;
226
- this.#notify();
227
- }
228
- }
229
- #notify() {
230
- if (this.hasListeners()) {
231
- const shouldSkipCombine = this.#shouldSkipCombine();
232
- const previousResult = this.#combinedResult;
233
- const newResult = shouldSkipCombine ? previousResult : this.#combineResult(this.#trackResult(this.#result, this.#observerMatches), this.#options?.combine);
234
- if (shouldSkipCombine || previousResult !== newResult) notifyManager.batch(() => {
235
- this.listeners.forEach((listener) => {
236
- listener(this.#result);
237
- });
238
- });
239
- }
240
- }
241
- };
242
- //#endregion
243
- //#region ../../node_modules/.pnpm/@tanstack+react-query@5.103.1_react@19.2.7/node_modules/@tanstack/react-query/build/modern/useQueries.js
244
- var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
245
- /**
246
- * The `useQueries` hook can be used to fetch a variable number of queries.
247
- *
248
- * The `queries` key accepts an array with query option objects mostly identical to `useQuery` — the top-level
249
- * `subscribed` option isn't accepted per query (see `placeholderData` below for another difference). A custom
250
- * `QueryClient` is supplied once, as `useQueries`' own top-level second argument, rather than per query.
251
- *
252
- * Having the same query key more than once in the array of query objects may cause some data to be shared
253
- * between queries. To avoid this, consider de-duplicating the queries and map the results back to the desired
254
- * structure.
255
- *
256
- * The `combine` option can be used to combine the results of the queries into a single value. The result will
257
- * be structurally shared to be as referentially stable as possible.
258
- *
259
- * @remarks The `combine` function only re-runs if it changed referentially, or if any of the query results
260
- * changed. An inlined `combine` function, as shown in the example below, therefore runs on every render — wrap
261
- * it in `useCallback`, or extract it to a stable function reference if it doesn't have any dependencies, to
262
- * avoid that.
263
- *
264
- * Unlike `useQuery`, `useQueries` cannot infer the `data` argument of an _inline_ `select` from its sibling
265
- * `queryFn`. Because `useQueries` infers the type of the whole `queries` array at once, the `select` parameter
266
- * of a query object written inline cannot be contextually typed from that same object's `queryFn`, so it falls
267
- * back to `unknown` — a [known TypeScript limitation](https://github.com/TanStack/query/issues/6556). Annotate
268
- * the `select` parameter explicitly, or define the query with {@link queryOptions}, which resolves its types in
269
- * a single object _before_ it reaches `useQueries`, to work around this — see the example below. The same
270
- * limitation applies to {@link useSuspenseQueries}.
271
- *
272
- * `placeholderData` is supported here too, but unlike `useQuery`, it doesn't receive information from
273
- * previously rendered queries, because the number of queries can differ between renders.
274
- * @param queryClient - Use this to provide a custom `QueryClient`. Otherwise, the one from the nearest context
275
- * will be used.
276
- * @returns The combined result. Without `combine`, this is an array with all the query results, in the same
277
- * order as the input. When `combine` is provided, this is the value returned by `combine` instead.
278
- *
279
- * @example
280
- * ```tsx
281
- * import { useQueries } from '@tanstack/react-query'
282
- *
283
- * function Posts({ ids }: { ids: Array<number> }) {
284
- * const postQueries = useQueries({
285
- * queries: ids.map((id) => ({
286
- * queryKey: ['post', id],
287
- * queryFn: () => fetchPost(id),
288
- * staleTime: Infinity,
289
- * })),
290
- * })
291
- *
292
- * return (
293
- * <ul>
294
- * {postQueries.map((query, index) => {
295
- * if (query.isPending) return <li key={ids[index]}>Loading...</li>
296
- * if (query.isError) return <li key={ids[index]}>Error: {query.error.message}</li>
297
- * return <li key={ids[index]}>{query.data.title}</li>
298
- * })}
299
- * </ul>
300
- * )
301
- * }
302
- * ```
303
- *
304
- * @example
305
- * Combining results into a single value:
306
- * ```tsx
307
- * import { useQueries } from '@tanstack/react-query'
308
- *
309
- * function Posts({ ids }: { ids: Array<number> }) {
310
- * const { data, isPending, isError } = useQueries({
311
- * queries: ids.map((id) => ({
312
- * queryKey: ['post', id],
313
- * queryFn: () => fetchPost(id),
314
- * })),
315
- * combine: (postQueries) => {
316
- * return {
317
- * data: postQueries.map((query) => query.data),
318
- * isPending: postQueries.some((query) => query.isPending),
319
- * isError: postQueries.some((query) => query.isError),
320
- * }
321
- * },
322
- * })
323
- *
324
- * if (isPending) return 'Loading...'
325
- * if (isError) return 'Error loading posts'
326
- *
327
- * return (
328
- * <ul>
329
- * {data.map((post) => (
330
- * <li key={post?.id}>{post?.title}</li>
331
- * ))}
332
- * </ul>
333
- * )
334
- * }
335
- * ```
336
- *
337
- * @example
338
- * Typing `select` via {@link queryOptions}. Note that spreading a `queryOptions` result and overriding
339
- * `select` inline still falls back to `unknown` — wrap the spread in `queryOptions` again so the override is
340
- * resolved before it reaches `useQueries`:
341
- * ```tsx
342
- * import { queryOptions, useQueries } from '@tanstack/react-query'
343
- *
344
- * const postOptions = (id: number) =>
345
- * queryOptions({
346
- * queryKey: ['post', id],
347
- * queryFn: () => fetchPost(id),
348
- * })
349
- *
350
- * function PostTitle({ id }: { id: number }) {
351
- * const [{ data: broken }] = useQueries({
352
- * queries: [
353
- * {
354
- * ...postOptions(id),
355
- * // ❌ `data` is `unknown` here
356
- * select: (data) => data.title,
357
- * },
358
- * ],
359
- * })
360
- *
361
- * const [{ data: fixed }] = useQueries({
362
- * queries: [
363
- * queryOptions({
364
- * ...postOptions(id),
365
- * // ✅ `data` is `Post`
366
- * select: (data) => data.title,
367
- * }),
368
- * ],
369
- * })
370
- *
371
- * return <h1>{fixed}</h1>
372
- * }
373
- * ```
374
- */
375
- function useQueries({ queries, ...options }, queryClient) {
376
- const client = useQueryClient(queryClient);
377
- const isRestoring = useIsRestoring();
378
- const errorResetBoundary = useQueryErrorResetBoundary();
379
- const subscribed = options.subscribed !== false;
380
- const defaultedQueries = import_react.useMemo(() => queries.map((opts) => {
381
- const defaultedOptions = client.defaultQueryOptions(opts);
382
- defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : subscribed ? "optimistic" : void 0;
383
- return defaultedOptions;
384
- }), [
385
- queries,
386
- client,
387
- isRestoring,
388
- subscribed
389
- ]);
390
- defaultedQueries.forEach((queryOptions) => {
391
- ensureSuspenseTimers(queryOptions);
392
- const query = client.getQueryCache().get(queryOptions.queryHash);
393
- ensurePreventErrorBoundaryRetry(queryOptions, errorResetBoundary, query);
394
- });
395
- useClearResetErrorBoundary(errorResetBoundary);
396
- const [observer] = import_react.useState(() => new QueriesObserver(client, defaultedQueries, options));
397
- const [optimisticResult, getCombinedResult, trackResult] = observer.getOptimisticResult(defaultedQueries, options.combine);
398
- const shouldSubscribe = !isRestoring && subscribed;
399
- import_react.useSyncExternalStore(import_react.useCallback((onStoreChange) => shouldSubscribe ? observer.subscribe(notifyManager.batchCalls(onStoreChange)) : noop, [observer, shouldSubscribe]), () => observer.getCurrentResult(), () => observer.getCurrentResult());
400
- import_react.useEffect(() => {
401
- observer.setQueries(defaultedQueries, options);
402
- }, [
403
- defaultedQueries,
404
- options,
405
- observer
406
- ]);
407
- const suspensePromises = optimisticResult.some((result, index) => shouldSuspend(defaultedQueries[index], result)) ? optimisticResult.flatMap((result, index) => {
408
- const opts = defaultedQueries[index];
409
- if (opts && shouldSuspend(opts, result)) return fetchOptimistic(opts, new QueryObserver(client, opts), errorResetBoundary);
410
- return [];
411
- }) : [];
412
- if (suspensePromises.length > 0) throw Promise.all(suspensePromises);
413
- const firstSingleResultWhichShouldThrow = optimisticResult.find((result, index) => {
414
- const query = defaultedQueries[index];
415
- return query && getHasError({
416
- result,
417
- errorResetBoundary,
418
- throwOnError: query.throwOnError,
419
- query: client.getQueryCache().get(query.queryHash),
420
- suspense: query.suspense
421
- });
422
- });
423
- if (firstSingleResultWhichShouldThrow) throw firstSingleResultWhichShouldThrow.error;
424
- return getCombinedResult(trackResult());
425
- }
426
- //#endregion
427
- //#region ../../node_modules/.pnpm/@tanstack+react-query@5.103.1_react@19.2.7/node_modules/@tanstack/react-query/build/modern/useSuspenseQueries.js
428
- function useSuspenseQueries(options, queryClient) {
429
- return useQueries({
430
- ...options,
431
- queries: options.queries.map((query) => {
432
- return {
433
- ...query,
434
- suspense: true,
435
- throwOnError: defaultThrowOnError,
436
- enabled: true,
437
- placeholderData: void 0
438
- };
439
- })
440
- }, queryClient);
441
- }
442
- //#endregion
443
- //#region src/lib/use-shell.ts
444
- /**
445
- * The shell as a component reads it: from the same queries the root loader
446
- * fetched, so it follows any change that refetches them.
447
- */
448
- function useShell() {
449
- const client = useCoffre();
450
- const [auth, me, projects] = useSuspenseQueries({ queries: [
451
- queries.auth(client),
452
- queries.me(client),
453
- queries.projects(client)
454
- ] });
455
- return (0, import_react.useMemo)(() => shellOf(auth.data, me.data, projects.data), [
456
- auth.data,
457
- me.data,
458
- projects.data
459
- ]);
460
- }
461
- //#endregion
462
- export { useSuspenseQueries as n, useShell as t };
@@ -1,8 +0,0 @@
1
- import { u as QueryObserver } from "./suspense-C-2QfDd2.js";
2
- import { n as useBaseQuery } from "./useSuspenseQuery-CSoHzrMb.js";
3
- //#region ../../node_modules/.pnpm/@tanstack+react-query@5.103.1_react@19.2.7/node_modules/@tanstack/react-query/build/modern/useQuery.js
4
- function useQuery(options, queryClient) {
5
- return useBaseQuery(options, QueryObserver, queryClient);
6
- }
7
- //#endregion
8
- export { useQuery as t };