@protobase/ui 0.113.0 → 0.114.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 (206) hide show
  1. package/dist/account/messages.d.ts +2 -2
  2. package/dist/app/app.d.ts +4 -1
  3. package/dist/app/app.js +9 -7
  4. package/dist/app/change-confirm/messages.d.ts +2 -2
  5. package/dist/app/charts/messages.d.ts +2 -2
  6. package/dist/app/confirm-sign-in-messages.d.ts +2 -2
  7. package/dist/app/create/messages.d.ts +2 -2
  8. package/dist/app/delete/messages.d.ts +2 -2
  9. package/dist/app/displays/messages.d.ts +2 -2
  10. package/dist/app/displays/virtual-cards.js +1 -0
  11. package/dist/app/embedded-list/messages.d.ts +2 -2
  12. package/dist/app/export/messages.d.ts +2 -2
  13. package/dist/app/field-messages.d.ts +2 -2
  14. package/dist/app/field-types/workflow/messages.d.ts +2 -2
  15. package/dist/app/field-types/workflow-page/messages.d.ts +2 -2
  16. package/dist/app/field-types/workflow-run/messages.d.ts +2 -2
  17. package/dist/app/field-types/workflow-status/messages.d.ts +2 -2
  18. package/dist/app/file-viewers/messages.d.ts +2 -2
  19. package/dist/app/first-frame.d.ts +13 -0
  20. package/dist/app/first-frame.js +23 -0
  21. package/dist/app/focus/messages.d.ts +2 -2
  22. package/dist/app/gallery/gallery-layout.d.ts +2 -2
  23. package/dist/app/gallery/messages.d.ts +2 -2
  24. package/dist/app/hand-order/messages.d.ts +2 -2
  25. package/dist/app/import/messages.d.ts +2 -2
  26. package/dist/app/index.html +0 -17
  27. package/dist/app/list-messages.d.ts +2 -2
  28. package/dist/app/main.js +19 -7
  29. package/dist/app/messages.d.ts +2 -2
  30. package/dist/app/pages/messages.d.ts +2 -2
  31. package/dist/app/record-chart/messages.d.ts +2 -2
  32. package/dist/app/record-messages.d.ts +2 -2
  33. package/dist/app/record-mode/shown-layout.d.ts +1 -1
  34. package/dist/app/record-row/messages.d.ts +2 -2
  35. package/dist/app/record-row/record-row.d.ts +3 -2
  36. package/dist/app/record-row/record-row.js +43 -27
  37. package/dist/app/record-row/row-window.d.ts +11 -0
  38. package/dist/app/record-row/row-window.js +15 -2
  39. package/dist/app/refresh-mark.d.ts +2 -1
  40. package/dist/app/refresh-mark.js +3 -1
  41. package/dist/app/related-cards/messages.d.ts +2 -2
  42. package/dist/app/reveal-when-loaded.d.ts +8 -2
  43. package/dist/app/reveal-when-loaded.js +12 -5
  44. package/dist/app/runtime/messages.d.ts +2 -2
  45. package/dist/app/saved/messages.d.ts +2 -2
  46. package/dist/app/searches/messages.d.ts +2 -2
  47. package/dist/app/splash-hold.d.ts +0 -1
  48. package/dist/app/splash-hold.js +1 -1
  49. package/dist/app/start-screen.d.ts +0 -9
  50. package/dist/app/start-screen.js +1 -10
  51. package/dist/app/ui-ready.d.ts +11 -0
  52. package/dist/app/ui-ready.js +12 -0
  53. package/dist/app-shell/app-shell.js +3 -1
  54. package/dist/app-shell/close-sidebar.d.ts +10 -0
  55. package/dist/app-shell/close-sidebar.js +17 -0
  56. package/dist/app-shell/drawer.d.ts +7 -1
  57. package/dist/app-shell/drawer.js +26 -7
  58. package/dist/app-shell/index.d.ts +2 -1
  59. package/dist/app-shell/index.js +2 -1
  60. package/dist/app-shell/messages.d.ts +2 -2
  61. package/dist/app-shell/top-bar.js +4 -4
  62. package/dist/assistant-dock/messages.d.ts +2 -2
  63. package/dist/auth/messages.d.ts +2 -2
  64. package/dist/calls/messages.d.ts +2 -2
  65. package/dist/compact-table/messages.d.ts +2 -2
  66. package/dist/data/query-keys.d.ts +6 -0
  67. package/dist/data/query-keys.js +10 -0
  68. package/dist/data/start-cache/cached-plugins.d.ts +6 -0
  69. package/dist/data/start-cache/cached-plugins.js +10 -0
  70. package/dist/data-grid/column-spec.d.ts +1 -1
  71. package/dist/data-grid/data-grid.js +1 -0
  72. package/dist/data-grid/messages.d.ts +2 -2
  73. package/dist/data-grid/row-source.d.ts +5 -0
  74. package/dist/data-grid/use-paged-rows.d.ts +5 -3
  75. package/dist/data-grid/use-paged-rows.js +21 -6
  76. package/dist/filter-panel/messages.d.ts +2 -2
  77. package/dist/focus-page/messages.d.ts +2 -2
  78. package/dist/index.d.ts +4 -1
  79. package/dist/index.js +4 -1
  80. package/dist/invitations/messages.d.ts +2 -2
  81. package/dist/live/grid-loader.d.ts +1 -0
  82. package/dist/live/grid-loader.js +3 -1
  83. package/dist/live/use-live-rows.js +1 -0
  84. package/dist/mailbox/messages.d.ts +2 -2
  85. package/dist/mocks/customers.d.ts +1 -1
  86. package/dist/mocks/invoices.d.ts +1 -1
  87. package/dist/mocks/orders.d.ts +3 -3
  88. package/dist/notifications/bell/messages.d.ts +2 -2
  89. package/dist/organizations/members-page.js +13 -7
  90. package/dist/organizations/messages.d.ts +2 -2
  91. package/dist/organizations/use-organizations.d.ts +4 -1
  92. package/dist/organizations/use-organizations.js +25 -19
  93. package/dist/package.js +1 -1
  94. package/dist/plugins/plugin-source.d.ts +24 -4
  95. package/dist/plugins/plugin-source.js +48 -14
  96. package/dist/plugins/use-plugin-loads.d.ts +3 -1
  97. package/dist/plugins/use-plugin-loads.js +24 -7
  98. package/dist/primitives/messages.d.ts +2 -2
  99. package/dist/primitives/skeleton.js +1 -0
  100. package/dist/record-view/messages.d.ts +2 -2
  101. package/dist/roles/use-active-role.d.ts +4 -1
  102. package/dist/roles/use-active-role.js +18 -13
  103. package/dist/shell/assets/api-provider-BJJrOoO4.js +2 -0
  104. package/dist/shell/assets/app-VoTi41IN.js +16 -0
  105. package/dist/shell/assets/badge-OU9hb6yQ.js +2 -0
  106. package/dist/shell/assets/checkbox-DFfK432Y.js +2 -0
  107. package/dist/shell/assets/createLucideIcon-DGm8SdFI.js +2 -0
  108. package/dist/shell/assets/display-value-CIH2qfgQ.js +2 -0
  109. package/dist/shell/assets/{field-badge-3QmjR1r3.js → field-badge-DX2Mc_fH.js} +2 -2
  110. package/dist/shell/assets/{graph-view-BcbWbnHO.js → graph-view-CY9LPr0B.js} +2 -2
  111. package/dist/shell/assets/{html-viewer-tGtSpy9M.js → html-viewer-BPGMH_GA.js} +2 -2
  112. package/dist/shell/assets/{in-place-form-B0EkP4B1.js → in-place-form-RWSQGEg4.js} +2 -2
  113. package/dist/shell/assets/index-Bzb-O7ER.js +2 -0
  114. package/dist/shell/assets/index-HnFovy2Q.css +2 -0
  115. package/dist/shell/assets/{intl-cache-bXVNV0Yq.js → intl-cache-D4doUjK1.js} +2 -2
  116. package/dist/shell/assets/{lib-d3-interpolate-Cl0dHO4f.js → lib-d3-interpolate-D3u38iyJ.js} +2 -2
  117. package/dist/shell/assets/{lib-d3-transition-DUHAGQ8z.js → lib-d3-transition-BUpPvFvt.js} +2 -2
  118. package/dist/shell/assets/{lib-d3-zoom-gQh2osrj.js → lib-d3-zoom-BF7SPKNh.js} +2 -2
  119. package/dist/shell/assets/{lib-vis.gl-react-maplibre-CU7gWYjg.js → lib-vis.gl-react-maplibre-C7-0xNFC.js} +2 -2
  120. package/dist/shell/assets/{lib-xyflow-react-DGg_5r7u.js → lib-xyflow-react-CKyW7szC.js} +2 -2
  121. package/dist/shell/assets/maplibre-9ViQO48S.js +2 -0
  122. package/dist/shell/assets/{markdown-content-DHKbAJjx.js → markdown-content-DTB9RQDs.js} +2 -2
  123. package/dist/shell/assets/{record-map-nGRmsk6x.js → record-map-CVqCWtfe.js} +2 -2
  124. package/dist/shell/assets/{records-map-D2flyaz3.js → records-map-ClYSxrVR.js} +2 -2
  125. package/dist/shell/assets/{run-trace-view-DfrAPeum.js → run-trace-view-CN16MiXg.js} +2 -2
  126. package/dist/shell/assets/search-picker-BGpvJQRD.js +2 -0
  127. package/dist/shell/assets/shared-protobase-ui-BC8LqGQB.js +2 -0
  128. package/dist/shell/assets/step-catalog-CZY0ZpCC.js +2 -0
  129. package/dist/shell/assets/step-panel-DhD80lsJ.js +2 -0
  130. package/dist/shell/assets/use-app-address-B4Uk3nWy.js +2 -0
  131. package/dist/shell/assets/{use-meta-BqEqOLNe.js → use-meta-D5kYywHm.js} +2 -2
  132. package/dist/shell/assets/{use-sibling-page-CiuiG-Tz.js → use-sibling-page-BJ81HcOP.js} +3 -3
  133. package/dist/shell/assets/value-badge-Dpd8dRqq.js +2 -0
  134. package/dist/shell/assets/{vendor-WWp_xlp2.js → vendor-3etemhgS.js} +4 -4
  135. package/dist/shell/assets/{workflow-canvas-DMP7SDWX.js → workflow-canvas-C1nGpi5w.js} +2 -2
  136. package/dist/shell/assets/{workflow-graph-editor-xpV8_qEl.js → workflow-graph-editor-DAJa4lq6.js} +2 -2
  137. package/dist/shell/assets/workflow-workbench-HramVZEJ.js +4 -0
  138. package/dist/shell/assets/{workflows-Bku4o2su.js → workflows-DlvOln9v.js} +2 -2
  139. package/dist/shell/assets/{workflows-start-kl7rSSay.js → workflows-start-QUKfwFqf.js} +2 -2
  140. package/dist/shell/index.html +16 -19
  141. package/dist/shell/protobase.shell.json +2 -2
  142. package/dist/shell/protobase.sw.js +2 -2
  143. package/dist/shell-source-maps/assets/api-provider-BJJrOoO4.js.map +1 -0
  144. package/dist/shell-source-maps/assets/app-VoTi41IN.js.map +1 -0
  145. package/dist/shell-source-maps/assets/{badge-ChHXC28D.js.map → badge-OU9hb6yQ.js.map} +1 -1
  146. package/dist/shell-source-maps/assets/{checkbox-COOOlJPG.js.map → checkbox-DFfK432Y.js.map} +1 -1
  147. package/dist/shell-source-maps/assets/createLucideIcon-DGm8SdFI.js.map +1 -0
  148. package/dist/shell-source-maps/assets/display-value-CIH2qfgQ.js.map +1 -0
  149. package/dist/shell-source-maps/assets/{field-badge-3QmjR1r3.js.map → field-badge-DX2Mc_fH.js.map} +1 -1
  150. package/dist/shell-source-maps/assets/{graph-view-BcbWbnHO.js.map → graph-view-CY9LPr0B.js.map} +1 -1
  151. package/dist/shell-source-maps/assets/{html-viewer-tGtSpy9M.js.map → html-viewer-BPGMH_GA.js.map} +1 -1
  152. package/dist/shell-source-maps/assets/{in-place-form-B0EkP4B1.js.map → in-place-form-RWSQGEg4.js.map} +1 -1
  153. package/dist/shell-source-maps/assets/index-Bzb-O7ER.js.map +1 -0
  154. package/dist/shell-source-maps/assets/{intl-cache-bXVNV0Yq.js.map → intl-cache-D4doUjK1.js.map} +1 -1
  155. package/dist/shell-source-maps/assets/{lib-d3-interpolate-Cl0dHO4f.js.map → lib-d3-interpolate-D3u38iyJ.js.map} +1 -1
  156. package/dist/shell-source-maps/assets/{lib-d3-transition-DUHAGQ8z.js.map → lib-d3-transition-BUpPvFvt.js.map} +1 -1
  157. package/dist/shell-source-maps/assets/{lib-d3-zoom-gQh2osrj.js.map → lib-d3-zoom-BF7SPKNh.js.map} +1 -1
  158. package/dist/shell-source-maps/assets/{lib-vis.gl-react-maplibre-CU7gWYjg.js.map → lib-vis.gl-react-maplibre-C7-0xNFC.js.map} +1 -1
  159. package/dist/shell-source-maps/assets/{lib-xyflow-react-DGg_5r7u.js.map → lib-xyflow-react-CKyW7szC.js.map} +1 -1
  160. package/dist/shell-source-maps/assets/{maplibre-Y7X50Jfk.js.map → maplibre-9ViQO48S.js.map} +1 -1
  161. package/dist/shell-source-maps/assets/{markdown-content-DHKbAJjx.js.map → markdown-content-DTB9RQDs.js.map} +1 -1
  162. package/dist/shell-source-maps/assets/{record-map-nGRmsk6x.js.map → record-map-CVqCWtfe.js.map} +1 -1
  163. package/dist/shell-source-maps/assets/{records-map-D2flyaz3.js.map → records-map-ClYSxrVR.js.map} +1 -1
  164. package/dist/shell-source-maps/assets/{run-trace-view-DfrAPeum.js.map → run-trace-view-CN16MiXg.js.map} +1 -1
  165. package/dist/shell-source-maps/assets/{search-picker-CJcJetBh.js.map → search-picker-BGpvJQRD.js.map} +1 -1
  166. package/dist/shell-source-maps/assets/shared-protobase-ui-BC8LqGQB.js.map +1 -0
  167. package/dist/shell-source-maps/assets/{step-catalog-ZvQOXfSh.js.map → step-catalog-CZY0ZpCC.js.map} +1 -1
  168. package/dist/shell-source-maps/assets/{step-panel-B1yHz7OC.js.map → step-panel-DhD80lsJ.js.map} +1 -1
  169. package/dist/shell-source-maps/assets/{use-app-address-B6k3dkV0.js.map → use-app-address-B4Uk3nWy.js.map} +1 -1
  170. package/dist/shell-source-maps/assets/{use-meta-BqEqOLNe.js.map → use-meta-D5kYywHm.js.map} +1 -1
  171. package/dist/shell-source-maps/assets/{use-sibling-page-CiuiG-Tz.js.map → use-sibling-page-BJ81HcOP.js.map} +1 -1
  172. package/dist/shell-source-maps/assets/{value-badge-BKLV4otJ.js.map → value-badge-Dpd8dRqq.js.map} +1 -1
  173. package/dist/shell-source-maps/assets/{vendor-WWp_xlp2.js.map → vendor-3etemhgS.js.map} +1 -1
  174. package/dist/shell-source-maps/assets/{workflow-canvas-DMP7SDWX.js.map → workflow-canvas-C1nGpi5w.js.map} +1 -1
  175. package/dist/shell-source-maps/assets/{workflow-graph-editor-xpV8_qEl.js.map → workflow-graph-editor-DAJa4lq6.js.map} +1 -1
  176. package/dist/shell-source-maps/assets/{workflow-workbench-Djdd_ODh.js.map → workflow-workbench-HramVZEJ.js.map} +1 -1
  177. package/dist/shell-source-maps/assets/{workflows-Bku4o2su.js.map → workflows-DlvOln9v.js.map} +1 -1
  178. package/dist/shell-source-maps/assets/{workflows-start-kl7rSSay.js.map → workflows-start-QUKfwFqf.js.map} +1 -1
  179. package/dist/status/messages.d.ts +2 -2
  180. package/dist/styles.css +14 -0
  181. package/dist/users/messages.d.ts +2 -2
  182. package/package.json +5 -5
  183. package/dist/app/hold-start-for-first-loads.d.ts +0 -12
  184. package/dist/app/hold-start-for-first-loads.js +0 -43
  185. package/dist/shell/assets/api-provider-CcDtTh0D.js +0 -2
  186. package/dist/shell/assets/app-DG30qs8Q.js +0 -16
  187. package/dist/shell/assets/badge-ChHXC28D.js +0 -2
  188. package/dist/shell/assets/checkbox-COOOlJPG.js +0 -2
  189. package/dist/shell/assets/display-value-fDiKbfJO.js +0 -2
  190. package/dist/shell/assets/index-BkCaPeOq.css +0 -2
  191. package/dist/shell/assets/index-CZ013UoE.js +0 -2
  192. package/dist/shell/assets/maplibre-Y7X50Jfk.js +0 -2
  193. package/dist/shell/assets/messages-ClKBpZlk.js +0 -2
  194. package/dist/shell/assets/search-picker-CJcJetBh.js +0 -2
  195. package/dist/shell/assets/shared-protobase-ui-CVwqj5Cp.js +0 -2
  196. package/dist/shell/assets/step-catalog-ZvQOXfSh.js +0 -2
  197. package/dist/shell/assets/step-panel-B1yHz7OC.js +0 -2
  198. package/dist/shell/assets/use-app-address-B6k3dkV0.js +0 -2
  199. package/dist/shell/assets/value-badge-BKLV4otJ.js +0 -2
  200. package/dist/shell/assets/workflow-workbench-Djdd_ODh.js +0 -4
  201. package/dist/shell-source-maps/assets/api-provider-CcDtTh0D.js.map +0 -1
  202. package/dist/shell-source-maps/assets/app-DG30qs8Q.js.map +0 -1
  203. package/dist/shell-source-maps/assets/display-value-fDiKbfJO.js.map +0 -1
  204. package/dist/shell-source-maps/assets/index-CZ013UoE.js.map +0 -1
  205. package/dist/shell-source-maps/assets/messages-ClKBpZlk.js.map +0 -1
  206. package/dist/shell-source-maps/assets/shared-protobase-ui-CVwqj5Cp.js.map +0 -1
@@ -32,5 +32,6 @@ export type LoadedPage = {
32
32
  export declare const createGridLoader: ({ queryClient, client, resources, views, model, columns, filter, orderBy, related }: GridLoaderOptions) => {
33
33
  page: (number: number) => Promise<LoadedPage>;
34
34
  loadRows: (start: number) => Promise<GridRow[]>;
35
+ cachedRows: (start: number) => GridRow[] | undefined;
35
36
  };
36
37
  //#endregion
@@ -89,9 +89,11 @@ const createGridLoader = ({ queryClient, client, resources, views, model, column
89
89
  queryFn: () => fetchPage(number)
90
90
  });
91
91
  const loadRows = async (start) => (await page(Math.floor(start / 40))).rows;
92
+ const cachedRows = (start) => queryClient.getQueryData(pageKey(Math.floor(start / 40)))?.rows;
92
93
  return {
93
94
  page,
94
- loadRows
95
+ loadRows,
96
+ cachedRows
95
97
  };
96
98
  };
97
99
  //#endregion
@@ -57,6 +57,7 @@ const useLiveRows = ({ resources, views, model, columns, filter, orderBy, relate
57
57
  source: useMemo(() => first.data ? {
58
58
  total: first.data.total,
59
59
  loadRows: loader.loadRows,
60
+ cachedRows: loader.cachedRows,
60
61
  revision: first.dataUpdatedAt
61
62
  } : void 0, [
62
63
  first.data,
@@ -1,7 +1,7 @@
1
1
  import { MessageValue } from "../locale/messages.js";
2
2
  //#region src/mailbox/messages.d.ts
3
3
  export declare const text: {
4
- (id: "expired" | "missing" | "missingTitle" | "expiredTitle" | "signInOnly" | "connect" | "connectAgain", values?: Record<string, MessageValue>): string;
5
- rich(id: "expired" | "missing" | "missingTitle" | "expiredTitle" | "signInOnly" | "connect" | "connectAgain", values: Record<string, MessageValue | import("react").ReactNode>): import("react").ReactNode;
4
+ (id: "missing" | "expired" | "missingTitle" | "expiredTitle" | "signInOnly" | "connect" | "connectAgain", values?: Record<string, MessageValue>): string;
5
+ rich(id: "missing" | "expired" | "missingTitle" | "expiredTitle" | "signInOnly" | "connect" | "connectAgain", values: Record<string, MessageValue | import("react").ReactNode>): import("react").ReactNode;
6
6
  };
7
7
  //#endregion
@@ -3,7 +3,7 @@ export declare const customerCount = 480;
3
3
  export declare const customerAt: (index: number) => {
4
4
  id: string;
5
5
  name: string;
6
- country: "NL" | "DE" | "GB";
6
+ country: "GB" | "NL" | "DE";
7
7
  city: NonNullable<"Rotterdam" | "Eindhoven" | "Utrecht" | "Zwolle" | "Breda" | "Groningen" | "Düsseldorf" | "Köln" | "Stuttgart" | "Hamburg" | "Münster" | "Nürnberg" | "Leeds" | "Bristol" | "Birmingham" | "Manchester" | "Sheffield">;
8
8
  };
9
9
  export type Customer = ReturnType<typeof customerAt>;
@@ -18,7 +18,7 @@ export declare const invoiceAt: (index: number) => {
18
18
  customer: {
19
19
  id: string;
20
20
  name: string;
21
- country: "NL" | "DE" | "GB";
21
+ country: "GB" | "NL" | "DE";
22
22
  city: NonNullable<"Rotterdam" | "Eindhoven" | "Utrecht" | "Zwolle" | "Breda" | "Groningen" | "Düsseldorf" | "Köln" | "Stuttgart" | "Hamburg" | "Münster" | "Nürnberg" | "Leeds" | "Bristol" | "Birmingham" | "Manchester" | "Sheffield">;
23
23
  };
24
24
  status: "draft" | "sent" | "paid" | "overdue";
@@ -9,10 +9,10 @@ export declare const orderAt: (index: number) => {
9
9
  id: string;
10
10
  name: string;
11
11
  };
12
- country: "NL" | "DE" | "GB";
13
- status: "draft" | "cancelled" | "confirmed" | "picking" | "shipped" | "delivered";
12
+ country: "GB" | "NL" | "DE";
13
+ status: "cancelled" | "draft" | "confirmed" | "picking" | "shipped" | "delivered";
14
14
  totalCents: number;
15
- discount: 0 | 10 | 15 | 5;
15
+ discount: 0 | 15 | 10 | 5;
16
16
  paid: boolean;
17
17
  createdAt: number;
18
18
  owner: "u2" | "u5" | "u8";
@@ -1,7 +1,7 @@
1
1
  import { MessageValue } from "../../locale/messages.js";
2
2
  //#region src/notifications/bell/messages.d.ts
3
3
  export declare const text: {
4
- (id: "unread" | "empty" | "tryAgain" | "showMore" | "turnOn" | "turnOff" | "notifications" | "notificationsUnread" | "notificationsManyUnread" | "markAllRead" | "loadFailed" | "pushOff" | "pushOn" | "pushBlocked" | "pushRegistrationFailed" | "pushNoTokenApns" | "pushNoTokenFcm" | "pushRefused" | "pushFailed" | "pushOffNotStored", values?: Record<string, MessageValue>): string;
5
- rich(id: "unread" | "empty" | "tryAgain" | "showMore" | "turnOn" | "turnOff" | "notifications" | "notificationsUnread" | "notificationsManyUnread" | "markAllRead" | "loadFailed" | "pushOff" | "pushOn" | "pushBlocked" | "pushRegistrationFailed" | "pushNoTokenApns" | "pushNoTokenFcm" | "pushRefused" | "pushFailed" | "pushOffNotStored", values: Record<string, MessageValue | import("react").ReactNode>): import("react").ReactNode;
4
+ (id: "unread" | "empty" | "tryAgain" | "showMore" | "turnOn" | "turnOff" | "loadFailed" | "notifications" | "notificationsUnread" | "notificationsManyUnread" | "markAllRead" | "pushOff" | "pushOn" | "pushBlocked" | "pushRegistrationFailed" | "pushNoTokenApns" | "pushNoTokenFcm" | "pushRefused" | "pushFailed" | "pushOffNotStored", values?: Record<string, MessageValue>): string;
5
+ rich(id: "unread" | "empty" | "tryAgain" | "showMore" | "turnOn" | "turnOff" | "loadFailed" | "notifications" | "notificationsUnread" | "notificationsManyUnread" | "markAllRead" | "pushOff" | "pushOn" | "pushBlocked" | "pushRegistrationFailed" | "pushNoTokenApns" | "pushNoTokenFcm" | "pushRefused" | "pushFailed" | "pushOffNotStored", values: Record<string, MessageValue | import("react").ReactNode>): import("react").ReactNode;
6
6
  };
7
7
  //#endregion
@@ -1,6 +1,7 @@
1
1
  import { Spinner } from "../primitives/spinner.js";
2
2
  import { Button } from "../primitives/button.js";
3
3
  import { useAuth } from "../auth/auth-provider.js";
4
+ import { keys } from "../data/query-keys.js";
4
5
  import { authMessage } from "../auth/auth-messages.js";
5
6
  import { StatusMark } from "../status/status-mark.js";
6
7
  import { PageHeader } from "../app-shell/page-header.js";
@@ -11,9 +12,10 @@ import { AppRolesPicker } from "./app-roles-picker.js";
11
12
  import { grantableRoles, organizationRoleLabel } from "./organization-paths.js";
12
13
  import { PersonRow } from "../people/person-row.js";
13
14
  import { presenceOf } from "../presence/presence.js";
14
- import { useCallback, useEffect, useState } from "react";
15
+ import { useCallback } from "react";
15
16
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
16
17
  import { AuthError } from "@protobase/client";
18
+ import { useQuery } from "@tanstack/react-query";
17
19
  //#region src/organizations/members-page.tsx
18
20
  /** The organization roles the person may set: owners every one, admins those below owner. */
19
21
  const assignableOrganizationRoles = (current) => current?.role === "owner" ? [
@@ -83,13 +85,17 @@ const MemberRow = ({ member, current, status, presence, onChanged }) => {
83
85
  */
84
86
  const MembersPage = ({ current, statuses, presence }) => {
85
87
  const { session } = useAuth();
86
- const [members, setMembers] = useState();
87
- const [error, setError] = useState();
88
88
  const organizationId = current?.organization?.id;
89
- const load = useCallback(() => {
90
- if (organizationId) session.organizations.members(organizationId).then(setMembers, (failure) => setError(failure instanceof AuthError ? authMessage(failure) : text("couldNotReadMembers")));
91
- }, [session, organizationId]);
92
- useEffect(load, [load]);
89
+ const query = useQuery({
90
+ queryKey: keys.organizationMembers(organizationId ?? ""),
91
+ queryFn: () => session.organizations.members(organizationId),
92
+ enabled: Boolean(organizationId),
93
+ retry: false
94
+ });
95
+ const members = query.data;
96
+ const error = query.error ? query.error instanceof AuthError ? authMessage(query.error) : text("couldNotReadMembers") : void 0;
97
+ const { refetch } = query;
98
+ const load = useCallback(() => void refetch(), [refetch]);
93
99
  if (!current?.organization) return null;
94
100
  return /* @__PURE__ */ jsxs("div", {
95
101
  className: "mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6",
@@ -1,7 +1,7 @@
1
1
  import { MessageValue } from "../locale/messages.js";
2
2
  //#region src/organizations/messages.d.ts
3
3
  export declare const text: {
4
- (id: "open" | "create" | "invitations" | "organizations" | "accept" | "join" | "signOut" | "loading" | "name" | "save" | "cancel" | "until" | "current" | "password" | "delete" | "owner" | "admin" | "member" | "passwordOptional" | "yourName" | "invalidLink" | "leave" | "remove" | "guestLinks" | "members" | "organization" | "manageOrganizations" | "slug" | "allOrganizations" | "allOrganizationsDescription" | "findOrganization" | "nameOrSlug" | "cannotChangeRole" | "makeAccountToJoin" | "makeAccount" | "passwordRequired" | "createAndJoin" | "createYourAccount" | "invitation" | "goToApp" | "invitesToApp" | "invitesTo" | "invitesToWith" | "hasAccount" | "signInAs" | "signInAsToJoin" | "otherAddress" | "signOutToAccept" | "inviteSomeone" | "inviteDescription" | "organizationRole" | "peopleInvited" | "notAcceptedYet" | "sendingAgain" | "nobodyWaiting" | "roleOf" | "couldNotReadMembers" | "whoWorks" | "membersDescription" | "details" | "detailsEditable" | "detailsReadOnly" | "guestLinksDescription" | "guestLinksAllowed" | "handOver" | "handOverDescription" | "newOwner" | "chooseMember" | "deleteOrganization" | "deleteDescription" | "deleteTitle" | "deleteConfirm" | "organizationName" | "leaveOwner" | "leaveMember" | "leaveName" | "noOrganization" | "youAre" | "throughGlobalRoles" | "newOrganization" | "newOrganizationDescription" | "invitationsForYou" | "invitationsForYouDescription" | "anOrganization" | "noAppRoles" | "organizationsSubtitle" | "yourOrganizations" | "memberOf" | "notMember" | "couldNotReadOrganizations", values?: Record<string, MessageValue>): string;
5
- rich(id: "open" | "create" | "invitations" | "organizations" | "accept" | "join" | "signOut" | "loading" | "name" | "save" | "cancel" | "until" | "current" | "password" | "delete" | "owner" | "admin" | "member" | "passwordOptional" | "yourName" | "invalidLink" | "leave" | "remove" | "guestLinks" | "members" | "organization" | "manageOrganizations" | "slug" | "allOrganizations" | "allOrganizationsDescription" | "findOrganization" | "nameOrSlug" | "cannotChangeRole" | "makeAccountToJoin" | "makeAccount" | "passwordRequired" | "createAndJoin" | "createYourAccount" | "invitation" | "goToApp" | "invitesToApp" | "invitesTo" | "invitesToWith" | "hasAccount" | "signInAs" | "signInAsToJoin" | "otherAddress" | "signOutToAccept" | "inviteSomeone" | "inviteDescription" | "organizationRole" | "peopleInvited" | "notAcceptedYet" | "sendingAgain" | "nobodyWaiting" | "roleOf" | "couldNotReadMembers" | "whoWorks" | "membersDescription" | "details" | "detailsEditable" | "detailsReadOnly" | "guestLinksDescription" | "guestLinksAllowed" | "handOver" | "handOverDescription" | "newOwner" | "chooseMember" | "deleteOrganization" | "deleteDescription" | "deleteTitle" | "deleteConfirm" | "organizationName" | "leaveOwner" | "leaveMember" | "leaveName" | "noOrganization" | "youAre" | "throughGlobalRoles" | "newOrganization" | "newOrganizationDescription" | "invitationsForYou" | "invitationsForYouDescription" | "anOrganization" | "noAppRoles" | "organizationsSubtitle" | "yourOrganizations" | "memberOf" | "notMember" | "couldNotReadOrganizations", values: Record<string, MessageValue | import("react").ReactNode>): import("react").ReactNode;
4
+ (id: "members" | "create" | "open" | "organizations" | "accept" | "join" | "leave" | "organization" | "name" | "invitations" | "remove" | "guestLinks" | "yourName" | "signOut" | "loading" | "save" | "cancel" | "until" | "current" | "password" | "delete" | "owner" | "admin" | "member" | "passwordOptional" | "invalidLink" | "manageOrganizations" | "slug" | "allOrganizations" | "allOrganizationsDescription" | "findOrganization" | "nameOrSlug" | "cannotChangeRole" | "makeAccountToJoin" | "makeAccount" | "passwordRequired" | "createAndJoin" | "createYourAccount" | "invitation" | "goToApp" | "invitesToApp" | "invitesTo" | "invitesToWith" | "hasAccount" | "signInAs" | "signInAsToJoin" | "otherAddress" | "signOutToAccept" | "inviteSomeone" | "inviteDescription" | "organizationRole" | "peopleInvited" | "notAcceptedYet" | "sendingAgain" | "nobodyWaiting" | "roleOf" | "couldNotReadMembers" | "whoWorks" | "membersDescription" | "details" | "detailsEditable" | "detailsReadOnly" | "guestLinksDescription" | "guestLinksAllowed" | "handOver" | "handOverDescription" | "newOwner" | "chooseMember" | "deleteOrganization" | "deleteDescription" | "deleteTitle" | "deleteConfirm" | "organizationName" | "leaveOwner" | "leaveMember" | "leaveName" | "noOrganization" | "youAre" | "throughGlobalRoles" | "newOrganization" | "newOrganizationDescription" | "invitationsForYou" | "invitationsForYouDescription" | "anOrganization" | "noAppRoles" | "organizationsSubtitle" | "yourOrganizations" | "memberOf" | "notMember" | "couldNotReadOrganizations", values?: Record<string, MessageValue>): string;
5
+ rich(id: "members" | "create" | "open" | "organizations" | "accept" | "join" | "leave" | "organization" | "name" | "invitations" | "remove" | "guestLinks" | "yourName" | "signOut" | "loading" | "save" | "cancel" | "until" | "current" | "password" | "delete" | "owner" | "admin" | "member" | "passwordOptional" | "invalidLink" | "manageOrganizations" | "slug" | "allOrganizations" | "allOrganizationsDescription" | "findOrganization" | "nameOrSlug" | "cannotChangeRole" | "makeAccountToJoin" | "makeAccount" | "passwordRequired" | "createAndJoin" | "createYourAccount" | "invitation" | "goToApp" | "invitesToApp" | "invitesTo" | "invitesToWith" | "hasAccount" | "signInAs" | "signInAsToJoin" | "otherAddress" | "signOutToAccept" | "inviteSomeone" | "inviteDescription" | "organizationRole" | "peopleInvited" | "notAcceptedYet" | "sendingAgain" | "nobodyWaiting" | "roleOf" | "couldNotReadMembers" | "whoWorks" | "membersDescription" | "details" | "detailsEditable" | "detailsReadOnly" | "guestLinksDescription" | "guestLinksAllowed" | "handOver" | "handOverDescription" | "newOwner" | "chooseMember" | "deleteOrganization" | "deleteDescription" | "deleteTitle" | "deleteConfirm" | "organizationName" | "leaveOwner" | "leaveMember" | "leaveName" | "noOrganization" | "youAre" | "throughGlobalRoles" | "newOrganization" | "newOrganizationDescription" | "invitationsForYou" | "invitationsForYouDescription" | "anOrganization" | "noAppRoles" | "organizationsSubtitle" | "yourOrganizations" | "memberOf" | "notMember" | "couldNotReadOrganizations", values: Record<string, MessageValue | import("react").ReactNode>): import("react").ReactNode;
6
6
  };
7
7
  //#endregion
@@ -8,7 +8,10 @@ export type OrganizationsState = {
8
8
  error?: string;
9
9
  reload: () => void;
10
10
  };
11
- /** The current organization and the person's organizations, read again with `reload` after a change. */
11
+ /**
12
+ * The current organization and the person's organizations, read again with `reload` after a change; a query, so the
13
+ * start cache keeps them and the app's first frame draws them.
14
+ */
12
15
  export declare const useOrganizations: (enabled: boolean) => OrganizationsState;
13
16
  /**
14
17
  * Starts the app again in another organization: what it shows, the menu included, follows from the roles there, so it
@@ -1,31 +1,37 @@
1
1
  import { useAuth } from "../auth/auth-provider.js";
2
+ import { keys } from "../data/query-keys.js";
2
3
  import { authMessage } from "../auth/auth-messages.js";
3
4
  import { text } from "./messages.js";
4
- import { useCallback, useEffect, useState } from "react";
5
+ import { useCallback } from "react";
5
6
  import { AuthError } from "@protobase/client";
7
+ import { useQuery } from "@tanstack/react-query";
6
8
  //#region src/organizations/use-organizations.ts
7
- /** The current organization and the person's organizations, read again with `reload` after a change. */
9
+ const none = [];
10
+ /**
11
+ * The current organization and the person's organizations, read again with `reload` after a change; a query, so the
12
+ * start cache keeps them and the app's first frame draws them.
13
+ */
8
14
  const useOrganizations = (enabled) => {
9
15
  const { session } = useAuth();
10
- const [current, setCurrent] = useState();
11
- const [organizations, setOrganizations] = useState([]);
12
- const [error, setError] = useState();
13
- const [round, setRound] = useState(0);
14
- const reload = useCallback(() => setRound((value) => value + 1), []);
15
- useEffect(() => {
16
- if (!enabled) return;
17
- Promise.all([session.organizations.current(), session.organizations.list()]).then(([currentOrganization, list]) => {
18
- setCurrent(currentOrganization);
19
- setOrganizations(list);
20
- }, (failure) => setError(failure instanceof AuthError ? authMessage(failure) : text("couldNotReadOrganizations")));
21
- }, [
16
+ const query = useQuery({
17
+ queryKey: keys.organizations,
18
+ queryFn: async () => {
19
+ const [current, organizations] = await Promise.all([session.organizations.current(), session.organizations.list()]);
20
+ return {
21
+ current,
22
+ organizations
23
+ };
24
+ },
22
25
  enabled,
23
- session,
24
- round
25
- ]);
26
+ retry: false
27
+ });
28
+ const { refetch } = query;
29
+ const reload = useCallback(() => void refetch(), [refetch]);
30
+ const data = enabled ? query.data : void 0;
31
+ const error = enabled && query.error ? query.error instanceof AuthError ? authMessage(query.error) : text("couldNotReadOrganizations") : void 0;
26
32
  return {
27
- current,
28
- organizations,
33
+ current: data?.current,
34
+ organizations: data?.organizations ?? none,
29
35
  ...error && { error },
30
36
  reload
31
37
  };
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.113.0";
2
+ var version = "0.114.0";
3
3
  var protobase = { "pluginApi": 1 };
4
4
  //#endregion
5
5
  export { protobase, version };
@@ -2,15 +2,35 @@ import { PluginLoad, PluginLoader } from "./load-plugin.js";
2
2
  import { ReactNode } from "react";
3
3
  import { PluginRef } from "@protobase/client";
4
4
  //#region src/plugins/plugin-source.d.ts
5
- /** Where the app's plugins come from: each loaded once for the page, by whichever gate asks for it first. */
5
+ /**
6
+ * The event a host dispatches on `window` when the app's plugins changed where they are served, such as Protobase's
7
+ * official app once it has fetched a workspace's new plugin files: the app loads its plugins again and swaps them in
8
+ * where they draw, keeping what it shows meanwhile. Their components start afresh; the old code stays in memory.
9
+ */
10
+ export declare const pluginsChangedEvent = "protobase:plugins-changed";
11
+ /**
12
+ * Where the app's plugins come from: each loaded once for the page, by whichever gate asks for it first, or before the
13
+ * app's first render; `loaded` is a plugin's load once it has settled, read at once. `forget` drops every load, so each
14
+ * plugin loads again, and moves `revision` on, which `subscribe` tells.
15
+ */
6
16
  export type PluginSource = {
7
17
  load: (ref: PluginRef) => Promise<PluginLoad>;
18
+ loaded: (ref: PluginRef) => PluginLoad | undefined;
19
+ forget: () => void;
20
+ revision: () => number;
21
+ subscribe: (changed: () => void) => () => void;
8
22
  };
9
23
  /** A source that loads with `loader` and keeps each plugin's load, so one named before and after sign-in loads once. */
10
- export declare const createPluginSource: (loader: PluginLoader) => PluginSource;
11
- /** The app's plugin source, loading with `loader`: the page's `fetch` and `import()` by default. */
12
- export declare const PluginSourceProvider: ({ loader, children }: {
24
+ export declare const createPluginSource: (loader: PluginLoader, base?: () => string) => PluginSource;
25
+ /**
26
+ * Loads `refs` ahead of the app's first render, such as the plugins the start cache's `/meta` names, so the plugin gate
27
+ * draws the app with them at once; at most `waitMs`, after which the app starts and the slow ones arrive later.
28
+ */
29
+ export declare const preloadPlugins: (source: PluginSource, refs: readonly PluginRef[], waitMs: number) => Promise<undefined>;
30
+ /** The app's plugin source: `source` when the page made one before rendering, or one loading with `loader`, the page's `fetch` and `import()` by default. */
31
+ export declare const PluginSourceProvider: ({ loader, source: given, children }: {
13
32
  loader?: PluginLoader;
33
+ source?: PluginSource;
14
34
  children: ReactNode;
15
35
  }) => import("react").JSX.Element;
16
36
  export declare const usePluginSource: () => PluginSource;
@@ -1,23 +1,57 @@
1
1
  import { browserLoader, loadPlugin } from "./load-plugin.js";
2
- import { createContext, useContext, useMemo } from "react";
2
+ import { createContext, useContext, useEffect, useMemo } from "react";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
  //#region src/plugins/plugin-source.tsx
5
+ /**
6
+ * The event a host dispatches on `window` when the app's plugins changed where they are served, such as Protobase's
7
+ * official app once it has fetched a workspace's new plugin files: the app loads its plugins again and swaps them in
8
+ * where they draw, keeping what it shows meanwhile. Their components start afresh; the old code stays in memory.
9
+ */
10
+ const pluginsChangedEvent = "protobase:plugins-changed";
5
11
  /** A source that loads with `loader` and keeps each plugin's load, so one named before and after sign-in loads once. */
6
- const createPluginSource = (loader) => {
12
+ const createPluginSource = (loader, base = () => window.location.href) => {
7
13
  const loads = /* @__PURE__ */ new Map();
8
- return { load: (ref) => {
9
- const key = JSON.stringify(ref);
10
- const known = loads.get(key);
11
- if (known) return known;
12
- const load = loadPlugin(ref, loader, window.location.href);
13
- loads.set(key, load);
14
- return load;
15
- } };
14
+ const settled = /* @__PURE__ */ new Map();
15
+ const listeners = /* @__PURE__ */ new Set();
16
+ let revision = 0;
17
+ return {
18
+ load: (ref) => {
19
+ const key = JSON.stringify(ref);
20
+ const known = loads.get(key);
21
+ if (known) return known;
22
+ const load = loadPlugin(ref, loader, base());
23
+ loads.set(key, load);
24
+ load.then((result) => settled.set(key, result));
25
+ return load;
26
+ },
27
+ loaded: (ref) => settled.get(JSON.stringify(ref)),
28
+ forget: () => {
29
+ loads.clear();
30
+ settled.clear();
31
+ revision += 1;
32
+ for (const changed of listeners) changed();
33
+ },
34
+ revision: () => revision,
35
+ subscribe: (changed) => {
36
+ listeners.add(changed);
37
+ return () => void listeners.delete(changed);
38
+ }
39
+ };
16
40
  };
41
+ /**
42
+ * Loads `refs` ahead of the app's first render, such as the plugins the start cache's `/meta` names, so the plugin gate
43
+ * draws the app with them at once; at most `waitMs`, after which the app starts and the slow ones arrive later.
44
+ */
45
+ const preloadPlugins = (source, refs, waitMs) => Promise.race([Promise.all(refs.map((ref) => source.load(ref))), new Promise((resolve) => setTimeout(resolve, waitMs))]).then(() => void 0);
17
46
  const PluginSourceContext = createContext(null);
18
- /** The app's plugin source, loading with `loader`: the page's `fetch` and `import()` by default. */
19
- const PluginSourceProvider = ({ loader = browserLoader, children }) => {
20
- const source = useMemo(() => createPluginSource(loader), [loader]);
47
+ /** The app's plugin source: `source` when the page made one before rendering, or one loading with `loader`, the page's `fetch` and `import()` by default. */
48
+ const PluginSourceProvider = ({ loader = browserLoader, source: given, children }) => {
49
+ const source = useMemo(() => given ?? createPluginSource(loader), [given, loader]);
50
+ useEffect(() => {
51
+ const changed = () => source.forget();
52
+ window.addEventListener(pluginsChangedEvent, changed);
53
+ return () => window.removeEventListener(pluginsChangedEvent, changed);
54
+ }, [source]);
21
55
  return /* @__PURE__ */ jsx(PluginSourceContext.Provider, {
22
56
  value: source,
23
57
  children
@@ -29,4 +63,4 @@ const usePluginSource = () => {
29
63
  return source;
30
64
  };
31
65
  //#endregion
32
- export { PluginSourceProvider, createPluginSource, usePluginSource };
66
+ export { PluginSourceProvider, createPluginSource, pluginsChangedEvent, preloadPlugins, usePluginSource };
@@ -6,12 +6,14 @@ import { PluginRef } from "@protobase/client";
6
6
  export declare const pluginWaitMs = 10000;
7
7
  type Loads = {
8
8
  key: string;
9
+ refs?: string;
9
10
  loads: PluginLoad[];
10
11
  settled: boolean;
11
12
  };
12
13
  /**
13
14
  * The plugins `refs` names, in their order, as they load. `settled` once every one has loaded or failed, or after
14
- * `pluginWaitMs`, so a slow plugin delays the app only that long. Without plugins it is settled at once.
15
+ * `pluginWaitMs`, so a slow plugin delays the app only that long. Without plugins it is settled at once, and so it is
16
+ * when the source has loaded every one already, as before the app's first render.
15
17
  */
16
18
  export declare const usePluginLoads: (refs: readonly PluginRef[], source: PluginSource) => Loads | {
17
19
  loads: PluginLoad[];
@@ -1,15 +1,18 @@
1
- import { useEffect, useState } from "react";
1
+ import { useEffect, useState, useSyncExternalStore } from "react";
2
2
  //#region src/plugins/use-plugin-loads.ts
3
3
  /** How long the app waits for its plugins before it draws without the ones still loading, which arrive later. */
4
4
  const pluginWaitMs = 1e4;
5
5
  const none = [];
6
6
  /**
7
7
  * The plugins `refs` names, in their order, as they load. `settled` once every one has loaded or failed, or after
8
- * `pluginWaitMs`, so a slow plugin delays the app only that long. Without plugins it is settled at once.
8
+ * `pluginWaitMs`, so a slow plugin delays the app only that long. Without plugins it is settled at once, and so it is
9
+ * when the source has loaded every one already, as before the app's first render.
9
10
  */
10
11
  const usePluginLoads = (refs, source) => {
11
- const key = JSON.stringify(refs);
12
- const [state, setState] = useState({
12
+ const revision = useSyncExternalStore(source.subscribe, source.revision, source.revision);
13
+ const named = JSON.stringify(refs);
14
+ const key = `${named}#${revision}`;
15
+ const [state, setState] = useState(() => loadedAlready(refs, source, key) ?? {
13
16
  key: "[]",
14
17
  loads: none,
15
18
  settled: true
@@ -22,10 +25,12 @@ const usePluginLoads = (refs, source) => {
22
25
  const publish = () => {
23
26
  if (!active) return;
24
27
  const loads = results.filter((load) => load !== void 0);
25
- setState({
28
+ const settled = waited || loads.length === refs.length;
29
+ setState((current) => current.refs === named && current.settled && !settled ? current : {
26
30
  key,
31
+ refs: named,
27
32
  loads,
28
- settled: waited || loads.length === refs.length
33
+ settled
29
34
  });
30
35
  };
31
36
  const timer = setTimeout(() => {
@@ -47,10 +52,22 @@ const usePluginLoads = (refs, source) => {
47
52
  loads: none,
48
53
  settled: true
49
54
  };
50
- return state.key === key ? state : {
55
+ if (state.key === key) return state;
56
+ if (state.refs === named && state.settled) return state;
57
+ return loadedAlready(refs, source, key) ?? {
51
58
  loads: none,
52
59
  settled: false
53
60
  };
54
61
  };
62
+ const loadedAlready = (refs, source, key) => {
63
+ if (refs.length === 0) return void 0;
64
+ const loads = refs.map((ref) => source.loaded(ref));
65
+ return loads.every((load) => load !== void 0) ? {
66
+ key,
67
+ refs: JSON.stringify(refs),
68
+ loads,
69
+ settled: true
70
+ } : void 0;
71
+ };
55
72
  //#endregion
56
73
  export { pluginWaitMs, usePluginLoads };
@@ -1,7 +1,7 @@
1
1
  import { MessageValue } from "../locale/messages.js";
2
2
  //#region src/primitives/messages.d.ts
3
3
  export declare const text: {
4
- (id: "loading" | "next" | "remove" | "close" | "previous" | "dragToClose", values?: Record<string, MessageValue>): string;
5
- rich(id: "loading" | "next" | "remove" | "close" | "previous" | "dragToClose", values: Record<string, MessageValue | import("react").ReactNode>): import("react").ReactNode;
4
+ (id: "remove" | "close" | "loading" | "next" | "previous" | "dragToClose", values?: Record<string, MessageValue>): string;
5
+ rich(id: "remove" | "close" | "loading" | "next" | "previous" | "dragToClose", values: Record<string, MessageValue | import("react").ReactNode>): import("react").ReactNode;
6
6
  };
7
7
  //#endregion
@@ -6,6 +6,7 @@ import { jsx } from "react/jsx-runtime";
6
6
  * load that quick shows no flash, then shimmers, or stays still when less motion is asked for.
7
7
  */
8
8
  const Skeleton = ({ className, style }) => /* @__PURE__ */ jsx("span", {
9
+ "data-placeholder": true,
9
10
  className: cn("block h-3 rounded bg-muted", skeletonMotion, className),
10
11
  style
11
12
  });
@@ -1,7 +1,7 @@
1
1
  import { MessageValue } from "../locale/messages.js";
2
2
  //#region src/record-view/messages.d.ts
3
3
  export declare const text: {
4
- (id: "tabs" | "actions" | "saving" | "headingCount" | "headingCountRecords" | "savedDifferent" | "example" | "savedThis" | "keepMine" | "useTheirs" | "savedAgo" | "notSavedRetrying" | "lastEditedBy" | "lastUpdated" | "viewing", values?: Record<string, MessageValue>): string;
5
- rich(id: "tabs" | "actions" | "saving" | "headingCount" | "headingCountRecords" | "savedDifferent" | "example" | "savedThis" | "keepMine" | "useTheirs" | "savedAgo" | "notSavedRetrying" | "lastEditedBy" | "lastUpdated" | "viewing", values: Record<string, MessageValue | import("react").ReactNode>): import("react").ReactNode;
4
+ (id: "saving" | "actions" | "tabs" | "headingCount" | "headingCountRecords" | "savedDifferent" | "example" | "savedThis" | "keepMine" | "useTheirs" | "savedAgo" | "notSavedRetrying" | "lastEditedBy" | "lastUpdated" | "viewing", values?: Record<string, MessageValue>): string;
5
+ rich(id: "saving" | "actions" | "tabs" | "headingCount" | "headingCountRecords" | "savedDifferent" | "example" | "savedThis" | "keepMine" | "useTheirs" | "savedAgo" | "notSavedRetrying" | "lastEditedBy" | "lastUpdated" | "viewing", values: Record<string, MessageValue | import("react").ReactNode>): import("react").ReactNode;
6
6
  };
7
7
  //#endregion
@@ -6,6 +6,9 @@ export type ActiveRoleState = {
6
6
  /** Acts with another role, then starts the app again, as a switch of organization does. */
7
7
  switchTo: (name: string) => void;
8
8
  };
9
- /** The role the session acts with, read while `enabled` (someone is signed in); a failed read or switch shows as a toast. */
9
+ /**
10
+ * The role the session acts with, read while `enabled` (someone is signed in) as a query, so the start cache keeps it and
11
+ * the app's first frame draws it; a failed read or switch shows as a toast.
12
+ */
10
13
  export declare const useActiveRole: (reopen: () => void, enabled?: boolean) => ActiveRoleState;
11
14
  //#endregion
@@ -1,27 +1,32 @@
1
1
  import { useAuth } from "../auth/auth-provider.js";
2
+ import { keys } from "../data/query-keys.js";
2
3
  import { useToast } from "../toasts/toast-provider.js";
3
4
  import { authMessage } from "../auth/auth-messages.js";
4
5
  import { text } from "./messages.js";
5
- import { useCallback, useEffect, useState } from "react";
6
+ import { useCallback, useEffect } from "react";
6
7
  import { AuthError } from "@protobase/client";
8
+ import { useQuery } from "@tanstack/react-query";
7
9
  //#region src/roles/use-active-role.ts
8
10
  const failureMessage = (failure, fallback) => failure instanceof AuthError ? authMessage(failure) : fallback;
9
- /** The role the session acts with, read while `enabled` (someone is signed in); a failed read or switch shows as a toast. */
11
+ /**
12
+ * The role the session acts with, read while `enabled` (someone is signed in) as a query, so the start cache keeps it and
13
+ * the app's first frame draws it; a failed read or switch shows as a toast.
14
+ */
10
15
  const useActiveRole = (reopen, enabled = true) => {
11
16
  const { session } = useAuth();
12
17
  const toast = useToast();
13
- const [current, setCurrent] = useState();
18
+ const role = useQuery({
19
+ queryKey: keys.activeRole,
20
+ queryFn: () => session.roles.current(),
21
+ enabled,
22
+ retry: false
23
+ });
14
24
  useEffect(() => {
15
- if (!enabled) return;
16
- session.roles.current().then(setCurrent, (failure) => toast.show({
25
+ if (role.error) toast.show({
17
26
  state: "error",
18
- title: failureMessage(failure, text("couldNotReadRoles"))
19
- }));
20
- }, [
21
- session,
22
- toast,
23
- enabled
24
- ]);
27
+ title: failureMessage(role.error, text("couldNotReadRoles"))
28
+ });
29
+ }, [role.error, toast]);
25
30
  const switchTo = useCallback((name) => void session.roles.switchTo(name).then(reopen, (failure) => toast.show({
26
31
  state: "error",
27
32
  title: failureMessage(failure, text("couldNotSwitch"))
@@ -31,7 +36,7 @@ const useActiveRole = (reopen, enabled = true) => {
31
36
  reopen
32
37
  ]);
33
38
  return {
34
- ...current && { current },
39
+ ...enabled && role.data && { current: role.data },
35
40
  switchTo
36
41
  };
37
42
  };