@coffre/ui 0.1.10 → 0.1.11

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 (167) hide show
  1. package/dist/client/_coffre/assets/account-BJAdDvZf.js +2 -0
  2. package/dist/client/_coffre/assets/account-D0jLpk5c.js +1 -0
  3. package/dist/client/_coffre/assets/affordances-Bq2-oUB5.js +1 -0
  4. package/dist/client/_coffre/assets/audit-C-pcBgKe.js +2 -0
  5. package/dist/client/_coffre/assets/audit-CHGlDeBB.js +1 -0
  6. package/dist/client/_coffre/assets/{auth.device-BP5FY0K1.js → auth.device-BndOUjse.js} +1 -1
  7. package/dist/client/_coffre/assets/auth.device-CWHNQn9W.js +2 -0
  8. package/dist/client/_coffre/assets/directory-nDExpkAz.js +1 -0
  9. package/dist/client/_coffre/assets/dist-QVHMLatb.js +1 -0
  10. package/dist/client/_coffre/assets/globals-CKBoTlyH.css +1 -0
  11. package/dist/client/_coffre/assets/grants-CjoOnxzz.js +1 -0
  12. package/dist/client/_coffre/assets/icons-BQ27Ds9u.js +1 -0
  13. package/dist/client/_coffre/assets/index-CUGytaO3.js +12 -0
  14. package/dist/client/_coffre/assets/link-DP8SVWon.js +1 -0
  15. package/dist/client/_coffre/assets/login-CeaxDMcr.js +2 -0
  16. package/dist/client/_coffre/assets/login-DrMgvqZn.js +1 -0
  17. package/dist/client/_coffre/assets/offboarding-CNr_1tnl.js +1 -0
  18. package/dist/client/_coffre/assets/page-CGmvjSy4.js +1 -0
  19. package/dist/client/_coffre/assets/preload-helper-ClBkJ19f.js +1 -0
  20. package/dist/client/_coffre/assets/principal-page-DNLb_q_e.js +1 -0
  21. package/dist/client/_coffre/assets/projects._project._environment-CHzbboGp.js +3 -0
  22. package/dist/client/_coffre/assets/projects._project._environment-DDxu_HHD.js +2 -0
  23. package/dist/client/_coffre/assets/projects._project.index-CIAsjvg6.js +2 -0
  24. package/dist/client/_coffre/assets/projects._project.index-DZ9l6d-1.js +1 -0
  25. package/dist/client/_coffre/assets/projects.index-4eUXreE_.js +1 -0
  26. package/dist/client/_coffre/assets/row-state-ByET1OKX.js +1 -0
  27. package/dist/client/_coffre/assets/settings-D2zp1Ssu.js +1 -0
  28. package/dist/client/_coffre/assets/suspense-C7KwSnTG.js +1 -0
  29. package/dist/client/_coffre/assets/tokens._token-DWmbqzNk.js +2 -0
  30. package/dist/client/_coffre/assets/tokens._token-Dui_4KfS.js +1 -0
  31. package/dist/client/_coffre/assets/tokens.index-CSi5Wxwf.js +1 -0
  32. package/dist/client/_coffre/assets/ui-BdipqGpP.js +46 -0
  33. package/dist/client/_coffre/assets/unregistered-CA7B4C1m.js +1 -0
  34. package/dist/client/_coffre/assets/use-action-DRm9yVhV.js +1 -0
  35. package/dist/client/_coffre/assets/use-change-BRRMJocl.js +1 -0
  36. package/dist/client/_coffre/assets/use-shell-BMGlJ25Q.js +1 -0
  37. package/dist/client/_coffre/assets/useQuery-D__2KBOs.js +1 -0
  38. package/dist/client/_coffre/assets/useSuspenseQuery-CSXyDALB.js +1 -0
  39. package/dist/client/_coffre/assets/users._user-BkNrX7Qf.js +1 -0
  40. package/dist/client/_coffre/assets/users._user-jbSvtdOg.js +2 -0
  41. package/dist/client/_coffre/assets/users.index-CKnQ1G76.js +1 -0
  42. package/dist/server/.vite/manifest.json +343 -246
  43. package/dist/server/_coffre/assets/_tanstack-start-manifest_v-Dx-c3XVk.js +162 -0
  44. package/dist/server/_coffre/assets/{account-CUQYGCYh.js → account-BocTPU1J.js} +150 -117
  45. package/dist/server/_coffre/assets/{account-DMlUoBxQ.js → account-CL8hOGhO.js} +10 -24
  46. package/dist/server/_coffre/assets/{affordances-BNaXjMOb.js → affordances-CKANXDTG.js} +2 -22
  47. package/dist/server/_coffre/assets/{async-local-storage-C0cwgkEr.js → async-local-storage-C10uQtMM.js} +3 -2
  48. package/dist/server/_coffre/assets/{audit-CCdSLmvK.js → audit-Bcka4vA6.js} +46 -16
  49. package/dist/server/_coffre/assets/audit-CSRQYIhu.js +31 -0
  50. package/dist/server/_coffre/assets/{auth.device-C05u5ROO.js → auth.device-CMcUISZY.js} +7 -5
  51. package/dist/server/_coffre/assets/{auth.device-BoFM1jcf.js → auth.device-DqO0T-rU.js} +5 -5
  52. package/dist/server/_coffre/assets/{directory-GsnYkse0.js → directory-CyYx6Jx1.js} +87 -112
  53. package/dist/server/_coffre/assets/{use-action-DwEmf58L.js → dist-CnnV3t2g.js} +3 -48
  54. package/dist/server/_coffre/assets/globals-CKBoTlyH.css +1 -0
  55. package/dist/server/_coffre/assets/grants-CRijabX0.js +158 -0
  56. package/dist/server/_coffre/assets/{page-BdnhpwvH.js → icons-Dy-5ccDF.js} +3 -196
  57. package/dist/server/_coffre/assets/lazyRouteComponent-CqBNCGuZ.js +480 -0
  58. package/dist/server/_coffre/assets/link-42ZWdjzZ.js +422 -0
  59. package/dist/server/_coffre/assets/{login-DUtCQju5.js → login-BI9tzJEy.js} +7 -5
  60. package/dist/server/_coffre/assets/{login-B2njIq_o.js → login-C-v88YwP.js} +2 -2
  61. package/dist/server/_coffre/assets/matchContext-qLfYbC6_.js +56 -0
  62. package/dist/server/_coffre/assets/{offboarding-8yMa7ViM.js → offboarding-1H0LavTd.js} +6 -4
  63. package/dist/server/_coffre/assets/page-D_mO0-sn.js +3592 -0
  64. package/dist/server/_coffre/assets/{principal-page-B8zPcS2b.js → principal-page-DQDoXute.js} +51 -42
  65. package/dist/server/_coffre/assets/{projects._project._environment-BZ5Z80V8.js → projects._project._environment-C-yVwC92.js} +168 -248
  66. package/dist/server/_coffre/assets/{projects._project._environment-DdIOc7wx.js → projects._project._environment-D_5R40of.js} +4 -11
  67. package/dist/server/_coffre/assets/{projects._project.index-CuEAUwGn.js → projects._project.index-A2BImFIT.js} +134 -96
  68. package/dist/server/_coffre/assets/{projects._project.index-DvbcU1kh.js → projects._project.index-BPPKxKrt.js} +5 -4
  69. package/dist/server/_coffre/assets/{projects.index-5HI0wOuG.js → projects.index-543IsPzY.js} +57 -55
  70. package/dist/server/_coffre/assets/{react-dom-qCTiwGGR.js → react-dom-bBoJXlK2.js} +417 -51
  71. package/dist/server/_coffre/assets/{router-CQDoql8s.js → router-CM3vK8QO.js} +376 -92
  72. package/dist/server/_coffre/assets/row-state-XBtDoIA4.js +117 -0
  73. package/dist/server/_coffre/assets/{settings-BVz78wjP.js → settings-BLVU74ym.js} +8 -6
  74. package/dist/server/_coffre/assets/suspense-CzYTwxOj.js +602 -0
  75. package/dist/server/_coffre/assets/tokens._token-B-hBgwBW.js +10 -0
  76. package/dist/server/_coffre/assets/{tokens._token-CWs3Mtki.js → tokens._token-aubAUonP.js} +97 -79
  77. package/dist/server/_coffre/assets/{tokens.index-Ck0LN7aC.js → tokens.index-4D3jwp5v.js} +9 -6
  78. package/dist/server/_coffre/assets/{ui-D_slKpSF.js → ui-BI3Bf72q.js} +7 -836
  79. package/dist/server/_coffre/assets/{unregistered-Z17da4Rc.js → unregistered-CagDxMyw.js} +5 -3
  80. package/dist/server/_coffre/assets/use-action-tzBZvjjQ.js +47 -0
  81. package/dist/server/_coffre/assets/use-change-Dggqxy5y.js +1212 -0
  82. package/dist/server/_coffre/assets/use-shell-CwStDfzX.js +462 -0
  83. package/dist/server/_coffre/assets/useQuery-C6_dBjem.js +8 -0
  84. package/dist/server/_coffre/assets/{useStore-DWGPqzXR.js → useRouter-CaUSUNsw.js} +1 -420
  85. package/dist/server/_coffre/assets/useSuspenseQuery-BuapQt_P.js +117 -0
  86. package/dist/server/_coffre/assets/{users._user-CMwj-VI9.js → users._user-137WNyxn.js} +4 -5
  87. package/dist/server/_coffre/assets/users._user-C252Iilj.js +10 -0
  88. package/dist/server/_coffre/assets/{users.index-fWHv6A30.js → users.index-DQHsfnal.js} +9 -6
  89. package/dist/server/index.js +6 -5
  90. package/package.json +5 -3
  91. package/src/components/directory.tsx +75 -104
  92. package/src/components/grants.tsx +60 -112
  93. package/src/components/principal-page.tsx +54 -67
  94. package/src/components/principal-picker.tsx +7 -16
  95. package/src/components/row-state.tsx +95 -0
  96. package/src/components/service-tokens.tsx +75 -64
  97. package/src/components/shell.tsx +1 -1
  98. package/src/components/syncs.tsx +42 -26
  99. package/src/lib/announce.ts +36 -0
  100. package/src/lib/changes.ts +498 -0
  101. package/src/lib/optimistic.ts +233 -0
  102. package/src/lib/queries.ts +393 -0
  103. package/src/lib/use-action.ts +20 -15
  104. package/src/lib/use-change.ts +42 -0
  105. package/src/lib/use-shell.ts +17 -0
  106. package/src/router.tsx +17 -9
  107. package/src/routes/__root.tsx +8 -38
  108. package/src/routes/account.tsx +163 -154
  109. package/src/routes/audit.tsx +51 -72
  110. package/src/routes/auth.device.tsx +4 -2
  111. package/src/routes/login.tsx +3 -2
  112. package/src/routes/projects.$project.$environment.tsx +226 -231
  113. package/src/routes/projects.$project.index.tsx +136 -118
  114. package/src/routes/projects.index.tsx +117 -145
  115. package/src/routes/settings.tsx +7 -7
  116. package/src/routes/tokens.$token.tsx +14 -17
  117. package/src/routes/tokens.index.tsx +8 -4
  118. package/src/routes/unregistered.tsx +3 -2
  119. package/src/routes/users.$user.tsx +4 -4
  120. package/src/routes/users.index.tsx +8 -4
  121. package/src/styles/globals.css +78 -1
  122. package/dist/client/_coffre/assets/account-B48wuSF8.js +0 -1
  123. package/dist/client/_coffre/assets/account-BkNyIDT7.js +0 -2
  124. package/dist/client/_coffre/assets/affordances-CmoY-8Xf.js +0 -1
  125. package/dist/client/_coffre/assets/audit-BvwKYb-5.js +0 -2
  126. package/dist/client/_coffre/assets/audit-D02H-zxS.js +0 -1
  127. package/dist/client/_coffre/assets/auth.device-DYOONgFF.js +0 -2
  128. package/dist/client/_coffre/assets/coffre-BBp7cKVa.js +0 -1
  129. package/dist/client/_coffre/assets/directory-Bu0EIxqI.js +0 -1
  130. package/dist/client/_coffre/assets/globals-Bh2x1gBM.css +0 -1
  131. package/dist/client/_coffre/assets/grants-DavcwofW.js +0 -1
  132. package/dist/client/_coffre/assets/index-CDPlq5rM.js +0 -12
  133. package/dist/client/_coffre/assets/login-C-wTm_t1.js +0 -2
  134. package/dist/client/_coffre/assets/login-CLLv1om9.js +0 -1
  135. package/dist/client/_coffre/assets/offboarding-DWsE2FSa.js +0 -1
  136. package/dist/client/_coffre/assets/page-DbSS7pYH.js +0 -1
  137. package/dist/client/_coffre/assets/preload-helper-DduCCcmc.js +0 -46
  138. package/dist/client/_coffre/assets/principal-page-Bp_iwuSd.js +0 -1
  139. package/dist/client/_coffre/assets/projects._project._environment-BMeX_B8l.js +0 -2
  140. package/dist/client/_coffre/assets/projects._project._environment-CT0A-hIU.js +0 -3
  141. package/dist/client/_coffre/assets/projects._project.index-C_xYOGLT.js +0 -2
  142. package/dist/client/_coffre/assets/projects._project.index-Chcf-cUd.js +0 -1
  143. package/dist/client/_coffre/assets/projects.index-CfOtb1X5.js +0 -2
  144. package/dist/client/_coffre/assets/projects.index-DSjOhLDh.js +0 -1
  145. package/dist/client/_coffre/assets/settings-BC9cUJNK.js +0 -1
  146. package/dist/client/_coffre/assets/settings-Bkj_E21y.js +0 -2
  147. package/dist/client/_coffre/assets/tokens._token-BA0KqvaW.js +0 -1
  148. package/dist/client/_coffre/assets/tokens._token-Dh9jLOkm.js +0 -2
  149. package/dist/client/_coffre/assets/tokens.index-BgAMWkHT.js +0 -2
  150. package/dist/client/_coffre/assets/tokens.index-CHueIAv1.js +0 -1
  151. package/dist/client/_coffre/assets/unregistered-D5go1AfR.js +0 -1
  152. package/dist/client/_coffre/assets/use-action-l__xZDYY.js +0 -1
  153. package/dist/client/_coffre/assets/users._user-Dwqa0gv5.js +0 -1
  154. package/dist/client/_coffre/assets/users._user-xJAb3T6Y.js +0 -2
  155. package/dist/client/_coffre/assets/users.index-BJoF-L37.js +0 -2
  156. package/dist/client/_coffre/assets/users.index-YUjtbTGy.js +0 -1
  157. package/dist/server/_coffre/assets/_tanstack-start-manifest_v-BKg2AlPu.js +0 -133
  158. package/dist/server/_coffre/assets/audit-CThXn2v7.js +0 -74
  159. package/dist/server/_coffre/assets/coffre-C2ANsTAz.js +0 -281
  160. package/dist/server/_coffre/assets/globals-Bh2x1gBM.css +0 -1
  161. package/dist/server/_coffre/assets/grants-B6k4Fu9z.js +0 -243
  162. package/dist/server/_coffre/assets/projects.index-uiomWX_l.js +0 -54
  163. package/dist/server/_coffre/assets/settings-4oRyDizv.js +0 -18
  164. package/dist/server/_coffre/assets/tokens._token-CF_deAwq.js +0 -18
  165. package/dist/server/_coffre/assets/tokens.index-DF_07KEe.js +0 -10
  166. package/dist/server/_coffre/assets/users._user-DUzwkSKT.js +0 -10
  167. package/dist/server/_coffre/assets/users.index-BbuweTwH.js +0 -10
@@ -0,0 +1,462 @@
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-D_mO0-sn.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-CzYTwxOj.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 };
@@ -0,0 +1,8 @@
1
+ import { u as QueryObserver } from "./suspense-CzYTwxOj.js";
2
+ import { n as useBaseQuery } from "./useSuspenseQuery-BuapQt_P.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 };