@powerhousedao/connect 6.2.3-dev.61 → 6.2.3-dev.62

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 (178) hide show
  1. package/README.md +101 -0
  2. package/dist/{AddDriveModal-C5odBO8y.js → AddDriveModal-D_3jDwjp.js} +6 -6
  3. package/dist/AddDriveModal-D_3jDwjp.js.map +1 -0
  4. package/dist/{ClearStorageModal-nzpz8MeW.js → ClearStorageModal-CXWhHez-.js} +9 -11
  5. package/dist/ClearStorageModal-CXWhHez-.js.map +1 -0
  6. package/dist/{ConfirmDocumentUpgradeModal-k79v2wM6.js → ConfirmDocumentUpgradeModal-CrU2Z1CL.js} +5 -5
  7. package/dist/{ConfirmDocumentUpgradeModal-k79v2wM6.js.map → ConfirmDocumentUpgradeModal-CrU2Z1CL.js.map} +1 -1
  8. package/dist/{CookiesPolicyModal-BLw4pnhn.js → CookiesPolicyModal-DQwsgDI9.js} +5 -5
  9. package/dist/{CookiesPolicyModal-BLw4pnhn.js.map → CookiesPolicyModal-DQwsgDI9.js.map} +1 -1
  10. package/dist/{CreateDocumentModal-Bmv0V-kY.js → CreateDocumentModal-Cf1APibL.js} +4 -4
  11. package/dist/{CreateDocumentModal-Bmv0V-kY.js.map → CreateDocumentModal-Cf1APibL.js.map} +1 -1
  12. package/dist/{DebugSettingsModal-BW0HWI1D.js → DebugSettingsModal-C0j4mtkx.js} +8 -8
  13. package/dist/{DebugSettingsModal-BW0HWI1D.js.map → DebugSettingsModal-C0j4mtkx.js.map} +1 -1
  14. package/dist/{DeleteDriveModal-CjGnG0ht.js → DeleteDriveModal-lE9eCBua.js} +5 -5
  15. package/dist/{DeleteDriveModal-CjGnG0ht.js.map → DeleteDriveModal-lE9eCBua.js.map} +1 -1
  16. package/dist/{DeleteItemModal-BbY_4_xT.js → DeleteItemModal-BFgcGsm3.js} +6 -6
  17. package/dist/{DeleteItemModal-BbY_4_xT.js.map → DeleteItemModal-BFgcGsm3.js.map} +1 -1
  18. package/dist/{DisclaimerModal-DuglmEwL.js → DisclaimerModal-CF6JkIIu.js} +6 -6
  19. package/dist/{DisclaimerModal-DuglmEwL.js.map → DisclaimerModal-CF6JkIIu.js.map} +1 -1
  20. package/dist/{DocumentVersionUnsupportedModal-C4fy7fZ6.js → DocumentVersionUnsupportedModal-Cm9Jb9W7.js} +5 -5
  21. package/dist/DocumentVersionUnsupportedModal-Cm9Jb9W7.js.map +1 -0
  22. package/dist/{DownloadDocumentWithErrorsModal-BsPQ5qgy.js → DownloadDocumentWithErrorsModal-CShKhfEQ.js} +5 -5
  23. package/dist/{DownloadDocumentWithErrorsModal-BsPQ5qgy.js.map → DownloadDocumentWithErrorsModal-CShKhfEQ.js.map} +1 -1
  24. package/dist/{DriveAuthRequiredModal-CtsB0kwH.js → DriveAuthRequiredModal-CMwPUyZf.js} +5 -5
  25. package/dist/{DriveAuthRequiredModal-CtsB0kwH.js.map → DriveAuthRequiredModal-CMwPUyZf.js.map} +1 -1
  26. package/dist/{DriveSettingsModal-d1L0eYof.js → DriveSettingsModal-BSImj4BH.js} +5 -5
  27. package/dist/{DriveSettingsModal-d1L0eYof.js.map → DriveSettingsModal-BSImj4BH.js.map} +1 -1
  28. package/dist/FloatingTanStackRouterDevtools-CqogiFob-dxj8lrTP.js +2565 -0
  29. package/dist/FloatingTanStackRouterDevtools-CqogiFob-dxj8lrTP.js.map +1 -0
  30. package/dist/{InspectorModal-Dpf-3LVT.js → InspectorModal-CKuKR5g7.js} +9 -9
  31. package/dist/{InspectorModal-Dpf-3LVT.js.map → InspectorModal-CKuKR5g7.js.map} +1 -1
  32. package/dist/{LoginModal-CI0ogC2-.js → LoginModal-DT_05uva.js} +6 -6
  33. package/dist/{LoginModal-CI0ogC2-.js.map → LoginModal-DT_05uva.js.map} +1 -1
  34. package/dist/{MissingPackageModal-DS3dgJ1K.js → MissingPackageModal-DtISKgub.js} +6 -6
  35. package/dist/{MissingPackageModal-DS3dgJ1K.js.map → MissingPackageModal-DtISKgub.js.map} +1 -1
  36. package/dist/{OpenFileDocumentsModal-BOmFtxS1.js → OpenFileDocumentsModal-X9GnX2Bk.js} +13 -12
  37. package/dist/OpenFileDocumentsModal-X9GnX2Bk.js.map +1 -0
  38. package/dist/{UpgradeDriveModal-CXX6D5Au.js → UpgradeDriveModal-DvM-PNWe.js} +6 -6
  39. package/dist/{UpgradeDriveModal-CXX6D5Au.js.map → UpgradeDriveModal-DvM-PNWe.js.map} +1 -1
  40. package/dist/app-layout-BIq-ZW-6.js +394 -0
  41. package/dist/app-layout-BIq-ZW-6.js.map +1 -0
  42. package/dist/app-loader-DqNf3gc0.js +1291 -0
  43. package/dist/app-loader-DqNf3gc0.js.map +1 -0
  44. package/dist/app-loader-gMCokq-Y.js +4 -0
  45. package/dist/{app-skeleton-CBN4tenZ.js → app-skeleton-DYLZ7npI.js} +3 -3
  46. package/dist/{app-skeleton--Me5zlSz.js → app-skeleton-gzg8cRzm.js} +7 -7
  47. package/dist/app-skeleton-gzg8cRzm.js.map +1 -0
  48. package/dist/{boot-CNW7ypcB.js → boot-CC_DgQKX.js} +32 -9
  49. package/dist/boot-CC_DgQKX.js.map +1 -0
  50. package/dist/{build-info-DNKZUbvY.js → build-info-BL03di3M.js} +5 -5
  51. package/dist/{build-info-DNKZUbvY.js.map → build-info-BL03di3M.js.map} +1 -1
  52. package/dist/components-D4yHqff7.js +120 -0
  53. package/dist/components-D4yHqff7.js.map +1 -0
  54. package/dist/connect-router-KmNBGS0G.js +434 -0
  55. package/dist/connect-router-KmNBGS0G.js.map +1 -0
  56. package/dist/{connect.config-CB78ZsFz.js → connect.config-uZF-gnvV.js} +7 -7
  57. package/dist/{connect.config-CB78ZsFz.js.map → connect.config-uZF-gnvV.js.map} +1 -1
  58. package/dist/{connection-state-BDikOGKo.js → connection-state-C_477Kr_.js} +6 -6
  59. package/dist/{connection-state-BDikOGKo.js.map → connection-state-C_477Kr_.js.map} +1 -1
  60. package/dist/context-De2EB1AA-Ni0d829Q.js +1759 -0
  61. package/dist/context-De2EB1AA-Ni0d829Q.js.map +1 -0
  62. package/dist/{cookie-banner-D05DZRqY.js → cookie-banner-HPgyuHM5.js} +6 -6
  63. package/dist/{cookie-banner-D05DZRqY.js.map → cookie-banner-HPgyuHM5.js.map} +1 -1
  64. package/dist/drive-icon-BiVP8yJc.js +38 -0
  65. package/dist/drive-icon-BiVP8yJc.js.map +1 -0
  66. package/dist/esm-BDACZntJ.js +148 -0
  67. package/dist/esm-BDACZntJ.js.map +1 -0
  68. package/dist/index-UrZFqSgm.d.ts +166 -0
  69. package/dist/index-UrZFqSgm.d.ts.map +1 -0
  70. package/dist/layout.d.ts +29 -0
  71. package/dist/layout.d.ts.map +1 -0
  72. package/dist/layout.js +6 -0
  73. package/dist/{load-BxQ82Cxc.js → load-CEuzCNRz.js} +48 -48
  74. package/dist/load-CEuzCNRz.js.map +1 -0
  75. package/dist/main.js +2 -2
  76. package/dist/{multi-reactor-BG-DqUcm.js → multi-reactor-fSKpLBjT.js} +10 -7
  77. package/dist/multi-reactor-fSKpLBjT.js.map +1 -0
  78. package/dist/open-file-uploads-BcyWmUZn.js +183 -0
  79. package/dist/open-file-uploads-BcyWmUZn.js.map +1 -0
  80. package/dist/{package-manager-BPVMRBoV.js → package-manager-BkFRzovd.js} +52 -45
  81. package/dist/package-manager-BkFRzovd.js.map +1 -0
  82. package/dist/{pglite-migrate-core-BcXcImng.js → pglite-migrate-core-DBlU6HIc.js} +4 -4
  83. package/dist/pglite-migrate-core-DBlU6HIc.js.map +1 -0
  84. package/dist/{pglite-seed-CQJ97bEt.js → pglite-seed-BsEPByVM.js} +4 -4
  85. package/dist/{pglite-seed-CQJ97bEt.js.map → pglite-seed-BsEPByVM.js.map} +1 -1
  86. package/dist/{preferences-store-Cm0BoiHA.js → preferences-store-DANUajdg.js} +4 -4
  87. package/dist/{preferences-store-Cm0BoiHA.js.map → preferences-store-DANUajdg.js.map} +1 -1
  88. package/dist/prerendered-shell-DxCUDEXL.js +45 -0
  89. package/dist/prerendered-shell-DxCUDEXL.js.map +1 -0
  90. package/dist/{reactor-DHJyk5ow.js → reactor-DmBtssmg.js} +50 -46
  91. package/dist/reactor-DmBtssmg.js.map +1 -0
  92. package/dist/reactor-chat-LAB-9G3G.js +50 -0
  93. package/dist/reactor-chat-LAB-9G3G.js.map +1 -0
  94. package/dist/reactor.worker.js +85 -27
  95. package/dist/reactor.worker.js.map +1 -1
  96. package/dist/{registerServiceWorker-DT6t8wjg.js → registerServiceWorker-CkVxA2KC.js} +4 -4
  97. package/dist/{registerServiceWorker-DT6t8wjg.js.map → registerServiceWorker-CkVxA2KC.js.map} +1 -1
  98. package/dist/route-components-BkztQruF.js +148 -0
  99. package/dist/route-components-BkztQruF.js.map +1 -0
  100. package/dist/route-tree.d.ts +2229 -0
  101. package/dist/route-tree.d.ts.map +1 -0
  102. package/dist/route-tree.js +211 -0
  103. package/dist/route-tree.js.map +1 -0
  104. package/dist/router-B4Z1LV9b.js +4 -0
  105. package/dist/router-BlxJIE3W.js +604 -0
  106. package/dist/router-BlxJIE3W.js.map +1 -0
  107. package/dist/router.d.ts +4 -0
  108. package/dist/router.js +7 -0
  109. package/dist/{runtime-config-DI5OfIC6.js → runtime-config-DdN1Frg7.js} +6 -9
  110. package/dist/runtime-config-DdN1Frg7.js.map +1 -0
  111. package/dist/{sentry-jfDyrxdX.js → sentry-CJb7--mu.js} +7 -4
  112. package/dist/{sentry-jfDyrxdX.js.map → sentry-CJb7--mu.js.map} +1 -1
  113. package/dist/{SettingsModal-BJVPEHbo.js → settings-2Id1UgNY.js} +126 -83
  114. package/dist/settings-2Id1UgNY.js.map +1 -0
  115. package/dist/settings-CjvK8OKA.js +91 -0
  116. package/dist/settings-CjvK8OKA.js.map +1 -0
  117. package/dist/shell-head.html +1 -0
  118. package/dist/shell.html +1 -0
  119. package/dist/sidebar-BXf8OEwm.d.ts +34 -0
  120. package/dist/sidebar-BXf8OEwm.d.ts.map +1 -0
  121. package/dist/sidebar-lAVFRsni.js +31 -0
  122. package/dist/sidebar-lAVFRsni.js.map +1 -0
  123. package/dist/start-connect.d.ts +4 -1
  124. package/dist/start-connect.d.ts.map +1 -1
  125. package/dist/start-connect.js +9 -5
  126. package/dist/start-connect.js.map +1 -1
  127. package/dist/style.css +36 -18
  128. package/dist/{useRegistryPackages-3EcR3GOh.js → useRegistryPackages-BqIWwXV-.js} +5 -5
  129. package/dist/{useRegistryPackages-3EcR3GOh.js.map → useRegistryPackages-BqIWwXV-.js.map} +1 -1
  130. package/fonts.css +177 -0
  131. package/package.json +51 -22
  132. package/scripts/critical-css.ts +243 -0
  133. package/scripts/prerender-shell.ts +100 -0
  134. package/src/routeTree.gen.ts +293 -0
  135. package/src/router/connect-router.ts +170 -0
  136. package/src/router/drive-route-loader.ts +116 -0
  137. package/src/router/index.ts +51 -0
  138. package/src/router/navigation.ts +230 -0
  139. package/src/router/perf-marks.test.tsx +98 -0
  140. package/src/router/perf-marks.ts +97 -0
  141. package/src/router/register.ts +9 -0
  142. package/src/router/route-components.tsx +98 -0
  143. package/src/router/route-tree.ts +88 -0
  144. package/src/router/scroll.ts +69 -0
  145. package/src/router/search.ts +66 -0
  146. package/src/router/settings.ts +120 -0
  147. package/src/router/sidebar.ts +55 -0
  148. package/src/router/titles.test.ts +24 -0
  149. package/src/router/titles.ts +33 -0
  150. package/src/routes/__root.tsx +28 -0
  151. package/src/routes/core/_app/$.tsx +13 -0
  152. package/src/routes/core/_app/_content/d/$driveSlug/{-$nodeSlug}.tsx +52 -0
  153. package/src/routes/core/_app/_content/index.tsx +3 -0
  154. package/src/routes/core/_app/_content.tsx +9 -0
  155. package/src/routes/core/_app/settings/about.tsx +20 -0
  156. package/src/routes/core/_app/settings/ai-assistant.tsx +20 -0
  157. package/src/routes/core/_app/settings/danger-zone.tsx +21 -0
  158. package/src/routes/core/_app/settings/default-editors.tsx +20 -0
  159. package/src/routes/core/_app/settings/package-manager.tsx +20 -0
  160. package/src/routes/core/_app/settings.tsx +35 -0
  161. package/src/routes/core/_app.tsx +10 -0
  162. package/dist/AddDriveModal-C5odBO8y.js.map +0 -1
  163. package/dist/ClearStorageModal-nzpz8MeW.js.map +0 -1
  164. package/dist/DocumentVersionUnsupportedModal-C4fy7fZ6.js.map +0 -1
  165. package/dist/OpenFileDocumentsModal-BOmFtxS1.js.map +0 -1
  166. package/dist/SettingsModal-BJVPEHbo.js.map +0 -1
  167. package/dist/app-loader-CNCzLxgV.js +0 -2379
  168. package/dist/app-loader-CNCzLxgV.js.map +0 -1
  169. package/dist/app-loader-DvnGgSyC.js +0 -4
  170. package/dist/app-skeleton--Me5zlSz.js.map +0 -1
  171. package/dist/boot-CNW7ypcB.js.map +0 -1
  172. package/dist/components-BKUI79po.js +0 -5
  173. package/dist/load-BxQ82Cxc.js.map +0 -1
  174. package/dist/multi-reactor-BG-DqUcm.js.map +0 -1
  175. package/dist/package-manager-BPVMRBoV.js.map +0 -1
  176. package/dist/pglite-migrate-core-BcXcImng.js.map +0 -1
  177. package/dist/reactor-DHJyk5ow.js.map +0 -1
  178. package/dist/runtime-config-DI5OfIC6.js.map +0 -1
@@ -0,0 +1,166 @@
1
+ import "./sidebar-BXf8OEwm.js";
2
+ import { ComponentType, ErrorInfo, PropsWithChildren, ReactElement } from "react";
3
+ import { DriveArrivals, FEATURE_FLAG_PARAM_PREFIX, GLOBAL_SEARCH_PARAMS, PHNavigation, PHStore } from "@powerhousedao/reactor-browser";
4
+ import { AnyRoute, AnyRouter, ErrorRouteComponent, RouteComponent, Router, RouterHistory, SearchMiddleware } from "@tanstack/react-router";
5
+ import { FileRoutesById, routeTree } from "@powerhousedao/connect/route-tree";
6
+ //#region src/router/route-components.d.ts
7
+ type ConnectRouteComponents = {
8
+ /** What every page shares; it renders an `<Outlet />`. */
9
+ root: RouteComponent;
10
+ /** The `_app` layout, e.g. the sidebar; it renders an `<Outlet />`. */
11
+ app?: RouteComponent;
12
+ /** Stays mounted between the home and drive views. */
13
+ content: RouteComponent;
14
+ /** Unknown paths and loaders' notFound(), inside the layout. */
15
+ notFound?: RouteComponent;
16
+ drivePending?: RouteComponent;
17
+ /** A drive that is not listed once arrivals settle; `notFound` without it. */
18
+ driveNotFound?: ComponentType<{
19
+ driveSlug: string;
20
+ }>;
21
+ /** Any route's loader or render error. */
22
+ error?: ErrorRouteComponent;
23
+ /** The settings page around its tabs; it renders an `<Outlet />`. */
24
+ settings?: RouteComponent;
25
+ /** Connect's own settings tabs; one left out is not listed. */
26
+ settingsTabs?: Partial<Record<CoreSettingsTabId, RouteComponent>>;
27
+ };
28
+ type CoreSettingsTabId = "ai-assistant" | "package-manager" | "default-editors" | "danger-zone" | "about";
29
+ declare const DRIVE_PENDING_MS = 200;
30
+ //#endregion
31
+ //#region src/router/drive-route-loader.d.ts
32
+ type ConnectRouterContext = {
33
+ store: PHStore;
34
+ /** Without it the drive route never waits for drives to arrive. */
35
+ arrivals?: DriveArrivals;
36
+ /** What the file routes render; `createConnectRouter` sets them. */
37
+ components?: ConnectRouteComponents;
38
+ /** Ends every document title; "Connect" without one. */
39
+ appName?: string;
40
+ };
41
+ /** What the drive route resolved its params to. */
42
+ type DriveRouteData = {
43
+ driveId: string;
44
+ nodeId?: string;
45
+ };
46
+ type DriveRouteParams = {
47
+ driveSlug: string;
48
+ nodeSlug?: string;
49
+ };
50
+ /** Resolves a drive route's slugs; a missing drive is not found and a missing
51
+ * node leads to its drive. */
52
+ declare function loadDriveRoute(options: {
53
+ params: DriveRouteParams;
54
+ context: ConnectRouterContext;
55
+ signal: AbortSignal;
56
+ preload: boolean;
57
+ }): Promise<DriveRouteData>;
58
+ //#endregion
59
+ //#region src/router/route-tree.d.ts
60
+ /** The home route's id; a tree change that moves it is a type error here. */
61
+ declare const HOME_ROUTE_ID = "/_app/_content/";
62
+ /** The sidebar layout's id; a project's _app/ routes nest in it. */
63
+ declare const APP_ROUTE_ID = "/_app";
64
+ declare const CONTENT_ROUTE_ID = "/_app/_content";
65
+ declare const DRIVE_PATH = "/d/$driveSlug/{-$nodeSlug}";
66
+ declare const SETTINGS_ROUTE_ID$1 = "/_app/settings";
67
+ type ConnectRootRoute = typeof routeTree;
68
+ type ConnectRoutes = {
69
+ routeTree: ConnectRootRoute;
70
+ rootRoute: ConnectRootRoute;
71
+ appRoute: FileRoutesById[typeof APP_ROUTE_ID];
72
+ contentRoute: FileRoutesById[typeof CONTENT_ROUTE_ID];
73
+ homeRoute: FileRoutesById[typeof HOME_ROUTE_ID];
74
+ driveRoute: FileRoutesById[`${typeof CONTENT_ROUTE_ID}${typeof DRIVE_PATH}`];
75
+ settingsRoute: FileRoutesById[typeof SETTINGS_ROUTE_ID$1];
76
+ };
77
+ /** Connect's routes in the generated tree; deployment routes attach to these. */
78
+ declare function connectRoutes(): ConnectRoutes;
79
+ /** Code routes, e.g. `createRoute({ getParentRoute: () => rootRoute })`, join
80
+ * their parent's file routes; an embedding app without the router plugin adds routes so. */
81
+ declare function addConnectRoutes(routes: readonly AnyRoute[]): void;
82
+ /** The route tree; components reach its routes through router context. */
83
+ declare function createConnectRouteTree(_components?: ConnectRouteComponents): ConnectRouteTree;
84
+ type ConnectRouteTree = Pick<ConnectRoutes, "routeTree" | "homeRoute" | "driveRoute">;
85
+ //#endregion
86
+ //#region src/router/connect-router.d.ts
87
+ /** The scroll container of the content view. */
88
+ declare const CONTENT_VIEW_ID = "content-view";
89
+ type ConnectRouterOptions = {
90
+ store: PHStore;
91
+ arrivals?: DriveArrivals;
92
+ components: ConnectRouteComponents;
93
+ basepath?: string;
94
+ history?: RouterHistory;
95
+ InnerWrap?: (props: PropsWithChildren) => ReactElement;
96
+ /** Code routes added to Connect's file routes; see `addConnectRoutes`. */
97
+ routes?: readonly AnyRoute[];
98
+ /** Reports a route's loader or render error; Sentry by default. */
99
+ onCatch?: (error: unknown, info?: ErrorInfo) => void;
100
+ /** Ends every document title; "Connect" without one. */
101
+ appName?: string;
102
+ };
103
+ /** The router over `TRouteTree`; a project's generated tree registers its own. */
104
+ type ConnectRouterFor<TRouteTree extends AnyRoute> = Router<TRouteTree, "never", false, RouterHistory, Record<string, any>>;
105
+ type ConnectRouter = ConnectRouterFor<ConnectRootRoute>;
106
+ type ConnectRouterBundle = Pick<ConnectRoutes, "homeRoute" | "driveRoute" | "settingsRoute"> & {
107
+ router: ConnectRouter;
108
+ };
109
+ declare function createConnectRouter(options: ConnectRouterOptions): ConnectRouterBundle;
110
+ /** Makes `router` the store's navigation and writes the selection it commits. */
111
+ declare function bindConnectRouter(connectRouter: ConnectRouterBundle, store: PHStore): () => void;
112
+ //#endregion
113
+ //#region src/router/navigation.d.ts
114
+ /** The PH navigation backed by `router`; its hooks take the router directly,
115
+ * so they work outside the RouterProvider. */
116
+ declare function createConnectNavigation(connectRouter: ConnectRouterBundle): PHNavigation & {
117
+ dispose(): void;
118
+ };
119
+ //#endregion
120
+ //#region src/router/search.d.ts
121
+ /** Connect's query params: plain strings, as in the URL. */
122
+ type ConnectSearch = Record<string, string | undefined>;
123
+ /** The root route's middlewares; they apply to every navigation and redirect. */
124
+ declare const connectSearchMiddlewares: SearchMiddleware<ConnectSearch>[];
125
+ /** Parses a query string into plain string values, unlike the JSON default. */
126
+ declare function parseConnectSearch(searchStr: string): ConnectSearch;
127
+ /** Writes plain `key=value` pairs, so other readers of the URL see strings. */
128
+ declare function stringifyConnectSearch(search: Record<string, unknown>): string;
129
+ //#endregion
130
+ //#region src/router/settings.d.ts
131
+ /** A settings tab, as a child route of /settings declares it in `staticData`. */
132
+ type ConnectSettingsTab = {
133
+ label: string;
134
+ /** Ascending; Connect's own tabs use multiples of 10. */
135
+ order: number;
136
+ icon?: ComponentType<{
137
+ size?: number;
138
+ className?: string;
139
+ }>;
140
+ /** Marks the tab as destructive, e.g. the danger zone. */
141
+ destructive?: boolean;
142
+ /** Hidden, and redirected away from, when this returns false. */
143
+ enabled?: (context: ConnectRouterContext) => boolean;
144
+ };
145
+ declare module "@tanstack/react-router" {
146
+ interface StaticDataRouteOption {
147
+ settings?: ConnectSettingsTab;
148
+ }
149
+ }
150
+ /** The settings layout route's id. */
151
+ declare const SETTINGS_ROUTE_ID = "/_app/settings";
152
+ /** A listed tab: its id is its path below /settings. */
153
+ type SettingsTabEntry = ConnectSettingsTab & {
154
+ id: string;
155
+ routeId: string;
156
+ to: string;
157
+ };
158
+ /** The settings tabs of `router`'s tree; empty without a settings route. */
159
+ declare function settingsTabs(router: AnyRouter): SettingsTabEntry[];
160
+ declare function useSettingsTabs(): SettingsTabEntry[];
161
+ /** `Settings · <tab> · <app>`. */
162
+ declare function settingsTitle(tabLabel: string | undefined, appName?: string): string;
163
+ //#endregion
164
+ export { DriveRouteData as A, ConnectRouteTree as C, connectRoutes as D, addConnectRoutes as E, DRIVE_PENDING_MS as F, loadDriveRoute as M, ConnectRouteComponents as N, createConnectRouteTree as O, CoreSettingsTabId as P, ConnectRootRoute as S, HOME_ROUTE_ID as T, ConnectRouterFor as _, settingsTitle as a, createConnectRouter as b, FEATURE_FLAG_PARAM_PREFIX as c, parseConnectSearch as d, stringifyConnectSearch as f, ConnectRouterBundle as g, ConnectRouter as h, settingsTabs as i, DriveRouteParams as j, ConnectRouterContext as k, GLOBAL_SEARCH_PARAMS as l, CONTENT_VIEW_ID as m, SETTINGS_ROUTE_ID as n, useSettingsTabs as o, createConnectNavigation as p, SettingsTabEntry as r, ConnectSearch as s, ConnectSettingsTab as t, connectSearchMiddlewares as u, ConnectRouterOptions as v, ConnectRoutes as w, APP_ROUTE_ID as x, bindConnectRouter as y };
165
+ export {};
166
+ //# sourceMappingURL=index-UrZFqSgm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-UrZFqSgm.d.ts","names":[],"sources":["../src/router/route-components.tsx","../src/router/drive-route-loader.ts","../src/router/route-tree.ts","../src/router/connect-router.ts","../src/router/navigation.ts","../src/router/search.ts","../src/router/settings.ts"],"mappings":";;;;;;KAOY;;EAEV,MAAM;;EAEN,MAAM;;EAEN,SAAS;;EAET,WAAW;EACX,eAAe;;EAEf,gBAAgB;IAAgB;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as useSidebarMode } from "./sidebar-BXf8OEwm.js";
2
+ import { ReactNode } from "react";
3
+ import { SidebarItem } from "@powerhousedao/design-system/connect";
4
+ //#region src/components/app-layout.d.ts
5
+ type AppLayoutProps = {
6
+ /** Replaces Connect's sidebar, e.g. `<ConnectSidebar extraItems={...} />`. */
7
+ sidebar?: ReactNode;
8
+ };
9
+ /** The `_app` layout: the sidebar beside the matched route. Embedded mode and
10
+ * `staticData.sidebar: "hidden"` drop the sidebar. */
11
+ export declare function AppLayout({ sidebar }?: AppLayoutProps): import("react/jsx-runtime").JSX.Element;
12
+ //#endregion
13
+ //#region src/components/sidebar.d.ts
14
+ /** The drives the user may open, and the add-drive item when enabled. */
15
+ export declare function SidebarDriveItems(): import("react/jsx-runtime").JSX.Element;
16
+ /** Links to the routes that declare `staticData.nav`, in order. */
17
+ export declare function SidebarNavItems(): import("react/jsx-runtime").JSX.Element;
18
+ type SidebarProps = {
19
+ /** Items after the drives and nav routes, e.g. a custom layout's links. */
20
+ extraItems?: ReactNode;
21
+ /** Header and footer only, no items. */
22
+ collapsed?: boolean;
23
+ };
24
+ /** Connect's sidebar: drives, nav routes, settings and the user. */
25
+ declare function Sidebar({ extraItems, collapsed }?: SidebarProps): import("react/jsx-runtime").JSX.Element;
26
+ //#endregion
27
+ export { type AppLayoutProps, Sidebar as ConnectSidebar, type SidebarProps as ConnectSidebarProps, SidebarItem, useNavRoutes, useSidebarMode };
28
+ export {};
29
+ //# sourceMappingURL=layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.d.ts","names":[],"sources":["../src/components/app-layout.tsx","../src/components/sidebar.tsx"],"mappings":";;;;KAUY;;EAEV,UAAU;;;;wBAKI,YAAY,YAAW,6CAAmB,IAAA;;;;wBCqC1C,iDAAiB,IAAA;;wBAiDjB,+CAAe,IAAA;KAWnB;;EAEV,aAAa;;EAEb;;;iBAIc,UAAU,YAAY,cAAa,2CAAiB,IAAA"}
package/dist/layout.js ADDED
@@ -0,0 +1,6 @@
1
+ import { n as useNavRoutes, r as useSidebarMode } from "./sidebar-lAVFRsni.js";
2
+ import { i as SidebarNavItems, n as Sidebar, r as SidebarDriveItems, t as AppLayout } from "./app-layout-BIq-ZW-6.js";
3
+ import { SidebarItem } from "@powerhousedao/design-system/connect";
4
+ export { AppLayout, Sidebar as ConnectSidebar, SidebarDriveItems, SidebarItem, SidebarNavItems, useNavRoutes, useSidebarMode };
5
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="869a0af9-3911-52f9-8fa0-b8d574968aa3")}catch(e){}}();
6
+ //# debugId=869a0af9-3911-52f9-8fa0-b8d574968aa3
@@ -1,16 +1,50 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d2f57276-04c5-5749-b94c-da11d286fd19")}catch(e){}}();
3
- import { r as loadRuntimeConfig, t as applyConnectBranding } from "./runtime-config-DI5OfIC6.js";
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="4ccb3697-cc90-54c3-a9ab-c447d2e6e3b6")}catch(e){}}();
3
+ import { n as loadRuntimeConfig } from "./runtime-config-DdN1Frg7.js";
4
+ import { r as setUser } from "./sentry-CJb7--mu.js";
4
5
  import "./i18n-CTgT1HG-.js";
5
- import { r as connectConfig } from "./connect.config-CB78ZsFz.js";
6
- import { n as setUser } from "./sentry-jfDyrxdX.js";
7
- import { t as getBuildHash } from "./build-info-DNKZUbvY.js";
8
- import { a as detectMigrationMajor, o as detectReactorPgMajor } from "./connection-state-BDikOGKo.js";
9
- import { n as seedPendingPgVersion } from "./pglite-seed-CQJ97bEt.js";
10
- import { n as createReactor } from "./reactor-DHJyk5ow.js";
11
- import { logger } from "document-model";
6
+ import { r as connectConfig } from "./connect.config-uZF-gnvV.js";
7
+ import { t as getBuildHash } from "./build-info-BL03di3M.js";
8
+ import { a as detectMigrationMajor, o as detectReactorPgMajor } from "./connection-state-C_477Kr_.js";
9
+ import { n as seedPendingPgVersion } from "./pglite-seed-BsEPByVM.js";
10
+ import { n as createReactor } from "./reactor-DmBtssmg.js";
12
11
  import { useEffect } from "react";
13
12
  import { initTheme, useUser } from "@powerhousedao/reactor-browser";
13
+ import { logger } from "document-model";
14
+ window.navigator.appVersion.includes("Mac");
15
+ /**
16
+ * Same-origin build-identity probe. The build bakes a hash of the inputs that
17
+ * determine the deployed content into the bundle (define
18
+ * `PH_CONNECT_BUILD_HASH`, see builder-tools' connectBuildHashPlugin) and
19
+ * emits `build-hash.json` next to the app (served no-cache). Comparing the
20
+ * two tells us whether the server is serving a different build than the one
21
+ * this page was loaded from — the reliable "a new deploy went out" signal.
22
+ * Unlike the old GitHub-raw version check it works on localhost (it compares
23
+ * against what the origin actually serves, not a remote branch head) and
24
+ * needs no network beyond the app's own origin.
25
+ *
26
+ * Returns null when there is nothing to compare: dev/studio builds (no hash
27
+ * baked), a server predating `build-hash.json`, an offline fetch, or a
28
+ * malformed body.
29
+ */
30
+ const getBuildHashStatus = async () => {
31
+ const currentHash = getBuildHash();
32
+ if (!currentHash || currentHash === "unknown") return null;
33
+ try {
34
+ const result = await fetch(`${import.meta.env.BASE_URL}build-hash.json`, { cache: "no-cache" });
35
+ if (!result.ok) return null;
36
+ const data = await result.json();
37
+ if (typeof data.hash !== "string" || !data.hash) return null;
38
+ return {
39
+ currentHash,
40
+ deployedHash: data.hash,
41
+ isCurrent: data.hash === currentHash
42
+ };
43
+ } catch {
44
+ return null;
45
+ }
46
+ };
47
+ //#endregion
14
48
  //#region src/hooks/useCheckLatestVersion.ts
15
49
  const RELOADED_FOR_KEY = "ph-reloaded-for-build-hash";
16
50
  /**
@@ -61,39 +95,6 @@ const useCheckLatestVersion = () => {
61
95
  };
62
96
  }, []);
63
97
  };
64
- window.navigator.appVersion.includes("Mac");
65
- /**
66
- * Same-origin build-identity probe. The build bakes a hash of the inputs that
67
- * determine the deployed content into the bundle (define
68
- * `PH_CONNECT_BUILD_HASH`, see builder-tools' connectBuildHashPlugin) and
69
- * emits `build-hash.json` next to the app (served no-cache). Comparing the
70
- * two tells us whether the server is serving a different build than the one
71
- * this page was loaded from — the reliable "a new deploy went out" signal.
72
- * Unlike the old GitHub-raw version check it works on localhost (it compares
73
- * against what the origin actually serves, not a remote branch head) and
74
- * needs no network beyond the app's own origin.
75
- *
76
- * Returns null when there is nothing to compare: dev/studio builds (no hash
77
- * baked), a server predating `build-hash.json`, an offline fetch, or a
78
- * malformed body.
79
- */
80
- const getBuildHashStatus = async () => {
81
- const currentHash = getBuildHash();
82
- if (!currentHash || currentHash === "unknown") return null;
83
- try {
84
- const result = await fetch(`${import.meta.env.BASE_URL}build-hash.json`, { cache: "no-cache" });
85
- if (!result.ok) return null;
86
- const data = await result.json();
87
- if (typeof data.hash !== "string" || !data.hash) return null;
88
- return {
89
- currentHash,
90
- deployedHash: data.hash,
91
- isCurrent: data.hash === currentHash
92
- };
93
- } catch {
94
- return null;
95
- }
96
- };
97
98
  //#endregion
98
99
  //#region src/store/user.ts
99
100
  function useSetSentryUser() {
@@ -113,12 +114,11 @@ function useSetSentryUser() {
113
114
  }
114
115
  //#endregion
115
116
  //#region src/components/load.tsx
116
- async function loadComponent(localPackage) {
117
+ async function loadComponent(localPackage, store) {
117
118
  await seedPendingPgVersion();
118
119
  await Promise.all([detectReactorPgMajor(), detectMigrationMajor()]);
119
- const runtimeConfig = await loadRuntimeConfig();
120
- applyConnectBranding(runtimeConfig);
121
- await createReactor(localPackage);
120
+ await loadRuntimeConfig();
121
+ await createReactor(await localPackage, store);
122
122
  return { default: ({ children }) => {
123
123
  initTheme();
124
124
  useSetSentryUser();
@@ -129,5 +129,5 @@ async function loadComponent(localPackage) {
129
129
  //#endregion
130
130
  export { loadComponent };
131
131
 
132
- //# sourceMappingURL=load-BxQ82Cxc.js.map
133
- //# debugId=d2f57276-04c5-5749-b94c-da11d286fd19
132
+ //# sourceMappingURL=load-CEuzCNRz.js.map
133
+ //# debugId=4ccb3697-cc90-54c3-a9ab-c447d2e6e3b6
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-CEuzCNRz.js","sources":["../src/hooks/utils.ts","../src/hooks/useCheckLatestVersion.ts","../src/store/user.ts","../src/components/load.tsx"],"sourcesContent":["import { getBuildHash } from \"../utils/build-info.js\";\n\nexport const isMac = window.navigator.appVersion.includes(\"Mac\");\n\nexport interface BuildHashStatus {\n /** Hash baked into the running build. */\n currentHash: string;\n /** Hash the server is currently serving. */\n deployedHash: string;\n /** true when the running build matches what the server serves. */\n isCurrent: boolean;\n}\n\n/**\n * Same-origin build-identity probe. The build bakes a hash of the inputs that\n * determine the deployed content into the bundle (define\n * `PH_CONNECT_BUILD_HASH`, see builder-tools' connectBuildHashPlugin) and\n * emits `build-hash.json` next to the app (served no-cache). Comparing the\n * two tells us whether the server is serving a different build than the one\n * this page was loaded from — the reliable \"a new deploy went out\" signal.\n * Unlike the old GitHub-raw version check it works on localhost (it compares\n * against what the origin actually serves, not a remote branch head) and\n * needs no network beyond the app's own origin.\n *\n * Returns null when there is nothing to compare: dev/studio builds (no hash\n * baked), a server predating `build-hash.json`, an offline fetch, or a\n * malformed body.\n */\nexport const getBuildHashStatus = async (): Promise<BuildHashStatus | null> => {\n const currentHash = getBuildHash();\n if (!currentHash || currentHash === \"unknown\") return null;\n try {\n const result = await fetch(`${import.meta.env.BASE_URL}build-hash.json`, {\n cache: \"no-cache\",\n });\n if (!result.ok) return null;\n const data = (await result.json()) as { hash?: unknown };\n if (typeof data.hash !== \"string\" || !data.hash) return null;\n return {\n currentHash,\n deployedHash: data.hash,\n isCurrent: data.hash === currentHash,\n };\n } catch {\n return null;\n }\n};\n","import { connectConfig } from \"@powerhousedao/connect/config\";\nimport { getBuildHashStatus } from \"./utils.js\";\nimport { logger } from \"document-model\";\nimport { useEffect } from \"react\";\n\n// Session-scoped guard: records the deployed hash this tab already reloaded\n// for, so a broken or rolling deploy (server hash keeps changing under us)\n// cannot turn the tab into a reload loop. Cleared implicitly with the tab.\nconst RELOADED_FOR_KEY = \"ph-reloaded-for-build-hash\";\n\n/**\n * Drop the service worker's stale caches (precache + the NetworkFirst shell\n * cache) before reloading onto a new deploy, so the post-reload navigation\n * is answered from the network / fresh build instead of leftovers of the\n * build we are leaving. Best-effort: if the Caches API is unavailable or a\n * delete fails, the reload still picks up the new shell (the navigation\n * route is NetworkFirst).\n */\nasync function clearStaleCaches(): Promise<void> {\n try {\n if (!(\"caches\" in window)) return;\n const keys = await window.caches.keys();\n await Promise.all(\n keys\n .filter((key) => key.includes(\"precache\") || key.includes(\"ph-shell\"))\n .map((key) => window.caches.delete(key)),\n );\n } catch (error) {\n logger.warn(\n \"Failed to clear stale caches before update reload @error\",\n error,\n );\n }\n}\n\n/**\n * Detects that the server is serving a different build than the one this\n * page was loaded from (a new deploy) and reloads onto it — once per session\n * per deployed hash. Checked on mount and whenever the tab returns to the\n * foreground, so a deploy that lands while the tab sits open is picked up on\n * the next focus without a manual reload. The in-tab \"new version available\"\n * service-worker prompt (ServiceWorkerUpdatePrompt) remains the opt-in path\n * for workers that are waiting but not yet controlling.\n */\nexport const useCheckLatestVersion = () => {\n useEffect(() => {\n if (\n import.meta.env.MODE === \"development\" ||\n connectConfig.studioMode ||\n !connectConfig.warnOutdatedApp\n ) {\n return;\n }\n\n const checkBuildHash = async () => {\n const status = await getBuildHashStatus();\n if (!status || status.isCurrent) return;\n\n const reloadedFor = window.sessionStorage.getItem(RELOADED_FOR_KEY);\n if (reloadedFor === status.deployedHash) return;\n window.sessionStorage.setItem(RELOADED_FOR_KEY, status.deployedHash);\n\n logger.info(\n \"New deploy detected — reloading from build @currentHash to @deployedHash\",\n status.currentHash,\n status.deployedHash,\n );\n await clearStaleCaches();\n window.location.reload();\n };\n\n void checkBuildHash();\n const onVisibilityChange = () => {\n if (document.visibilityState === \"visible\") void checkBuildHash();\n };\n document.addEventListener(\"visibilitychange\", onVisibilityChange);\n return () => {\n document.removeEventListener(\"visibilitychange\", onVisibilityChange);\n };\n }, []);\n};\n","import { useUser } from \"@powerhousedao/reactor-browser\";\nimport type { User as SentryUser } from \"@sentry/react\";\nimport { useEffect } from \"react\";\nimport { setUser as setSentryUser } from \"../services/sentry.js\";\n\nexport function useSetSentryUser() {\n const user = useUser();\n useEffect(() => {\n let sentryUser: SentryUser | null = null;\n if (user) {\n // saves the user info except the credential\n const { credential: _credential, ...rest } = user;\n sentryUser = { id: rest.did, username: rest.ens?.name, ...rest };\n }\n setSentryUser(sentryUser);\n }, [user]);\n}\n","import { useCheckLatestVersion } from \"@powerhousedao/connect/hooks\";\nimport \"@powerhousedao/connect/i18n\";\nimport { createReactor, useSetSentryUser } from \"@powerhousedao/connect/store\";\nimport {\n detectMigrationMajor,\n detectReactorPgMajor,\n seedPendingPgVersion,\n} from \"@powerhousedao/connect/utils\";\nimport type { PHStore } from \"@powerhousedao/reactor-browser\";\nimport { initTheme } from \"@powerhousedao/reactor-browser\";\nimport type { DocumentModelLib } from \"document-model\";\nimport { type ReactNode } from \"react\";\nimport { loadRuntimeConfig } from \"../runtime-config.js\";\n\nexport async function loadComponent(\n localPackage: DocumentModelLib | Promise<DocumentModelLib> | undefined,\n store: PHStore,\n) {\n await seedPendingPgVersion();\n await Promise.all([detectReactorPgMajor(), detectMigrationMajor()]);\n await loadRuntimeConfig();\n await createReactor(await localPackage, store);\n return {\n default: ({ children }: { children?: ReactNode }) => {\n initTheme();\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useSetSentryUser();\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useCheckLat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AO,YACT;GACA,MAAM,iBAAiB;GACvB,OAAO,SAAS,OAAO;EACzB;EAEA,eAAoB;EACpB,MAAM,2BAA2B;GAC/B,IAAI,SAAS,oBAAoB,WAAW,eAAoB;EAClE;EACA,SAAS,iBAAiB,oBAAoB,kBAAkB;EAChE,aAAa;GACX,SAAS,oBAAoB,oBAAoB,kBAAkB;EACrE;CACF,GAAG,CAAC,CAAC;AACP;;;AC3EA,SAAgB,mBAAmB;CACjC,MAAM,OAAO,QAAQ;CACrB,gBAAgB;EACd,IAAI,aAAgC;EACpC,IAAI,MAAM;GAER,MAAM,EAAE,YAAY,aAAa,GAAG,SAAS;GAC7C,aAAa;IAAE,IAAI,KAAK;IAAK,UAAU,KAAK,KAAK;IAAM,GAAG;GAAK;EACjE;EACA,QAAc,UAAU;CAC1B,GAAG,CAAC,IAAI,CAAC;AACX;;;ACFA,eAAsB,cACpB,cACA,OACA;CACA,MAAM,qBAAqB;CAC3B,MAAM,QAAQ,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC,CAAC;CAClE,MAAM,kBAAkB;CACxB,MAAM,cAAc,MAAM,cAAc,KAAK;CAC7C,OAAO,EACL,UAAU,EAAE,eAAyC;EACnD,UAAU;EAEV,iBAAiB;EAEjB,sBAAsB;EACtB,OAAO;CACT,EACF;AACF","debug_id":"4ccb3697-cc90-54c3-a9ab-c447d2e6e3b6"}
package/dist/main.js CHANGED
@@ -1,11 +1,11 @@
1
1
 
2
2
  !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="1f52a123-ef3c-5452-bdfa-b05d09bb17c0")}catch(e){}}();
3
- import { t as bootConnect } from "./boot-CNW7ypcB.js";
3
+ import { t as bootConnect } from "./boot-CC_DgQKX.js";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  //#region main.tsx
6
6
  const root = await bootConnect();
7
7
  if (root) {
8
- const { AppLoader } = await import("./app-loader-DvnGgSyC.js");
8
+ const { AppLoader } = await import("./app-loader-gMCokq-Y.js");
9
9
  root.render(/* @__PURE__ */ jsx(AppLoader, {}));
10
10
  }
11
11
  //#endregion
@@ -1,8 +1,8 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a3ba8f94-c39e-5f63-9159-cbf355de9c47")}catch(e){}}();
3
- import { JOB_NOT_FOUND_ERROR_NAME, JobStatus, createReactorInspector } from "@powerhousedao/reactor";
4
- import { logger } from "document-model";
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="cd7ca6e1-c72a-5e8b-9872-f7bd8cf4f5c1")}catch(e){}}();
5
3
  import { DRIVE_DOCUMENT_TYPES, GraphQLReactorClient, findIsServableOverGraphQL } from "@powerhousedao/reactor-browser";
4
+ import { logger } from "document-model";
5
+ import { JOB_NOT_FOUND_ERROR_NAME, JobStatus, createReactorInspector } from "@powerhousedao/reactor";
6
6
  import { FanInPartialFailureError, RoutingReactorClient, fromReactorClient } from "@powerhousedao/reactor-router";
7
7
  //#region src/store/graphql-routable-backend.ts
8
8
  const REMOTE_INFO_QUERY = `
@@ -184,9 +184,11 @@ function failedOnlyOnRemote(error) {
184
184
  async function buildMultiReactorClient(params) {
185
185
  const module = params.module;
186
186
  const registry = module?.reactorModule?.documentModelRegistry;
187
+ const loaded = params.documentModelModules;
188
+ const loadedModules = typeof loaded === "function" ? loaded : () => loaded;
187
189
  const remote = createGraphQLRoutableBackend({
188
190
  url: params.remoteGraphqlUrl,
189
- documentModels: () => registry?.getAllModules() ?? params.documentModelModules
191
+ documentModels: () => registry?.getAllModules() ?? loadedModules()
190
192
  });
191
193
  const remoteBackend = {
192
194
  name: REMOTE_BACKEND_NAME,
@@ -205,7 +207,8 @@ async function buildMultiReactorClient(params) {
205
207
  primaryBackend: module ? LOCAL_BACKEND_NAME : REMOTE_BACKEND_NAME,
206
208
  defaultRequirements: module ? PLACE_ON_LOCAL : PLACE_ON_REMOTE,
207
209
  signer: params.signer,
208
- onDiagnostic: params.onDiagnostic
210
+ onDiagnostic: params.onDiagnostic,
211
+ documentModelModules: module ? void 0 : loadedModules
209
212
  }, remote, Boolean(module));
210
213
  await router.refreshFacts();
211
214
  return router;
@@ -213,5 +216,5 @@ async function buildMultiReactorClient(params) {
213
216
  //#endregion
214
217
  export { ConnectRoutingClient, LOCAL_BACKEND_NAME, PLACE_ON_LOCAL, PLACE_ON_REMOTE, REMOTE_BACKEND_NAME, buildMultiReactorClient, deriveSwitchboardGraphqlUrl, localFacts, localReach };
215
218
 
216
- //# sourceMappingURL=multi-reactor-BG-DqUcm.js.map
217
- //# debugId=a3ba8f94-c39e-5f63-9159-cbf355de9c47
219
+ //# sourceMappingURL=multi-reactor-fSKpLBjT.js.map
220
+ //# debugId=cd7ca6e1-c72a-5e8b-9872-f7bd8cf4f5c1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multi-reactor-fSKpLBjT.js","sources":["../src/store/graphql-routable-backend.ts","../src/store/multi-reactor.ts"],"sourcesContent":["import {\n JOB_NOT_FOUND_ERROR_NAME,\n JobStatus,\n type PagedResults,\n type ReactorInfo,\n type ViewFilter,\n} from \"@powerhousedao/reactor\";\nimport {\n DRIVE_DOCUMENT_TYPES,\n findIsServableOverGraphQL,\n GraphQLReactorClient,\n type DriveIdCall,\n type GraphQLReactorClientOptions,\n} from \"@powerhousedao/reactor-browser\";\nimport type { IRoutableBackend } from \"@powerhousedao/reactor-router\";\nimport type { Action, PHDocument } from \"@powerhousedao/shared/document-model\";\n\nconst REMOTE_INFO_QUERY = /* GraphQL */ `\n query RemoteReactorInfo {\n inspection {\n info {\n storage {\n engine\n persistence\n durable\n selfHeal\n }\n workflows\n syncChannels\n }\n }\n }\n`;\n\ntype RemoteReactorInfo = {\n inspection: { info: Omit<ReactorInfo, \"access\"> };\n};\n\n/** Ids and slugs of documents this backend answered as drives, by drive id. */\nclass KnownDrives {\n private readonly ids = new Map<string, string>();\n\n learn<T extends PHDocument>(document: T): T {\n const { id, slug, documentType } = document.header;\n if ((DRIVE_DOCUMENT_TYPES as readonly string[]).includes(documentType)) {\n this.ids.set(id, id);\n if (slug) {\n this.ids.set(slug, id);\n }\n }\n return document;\n }\n\n learnPage<T extends PHDocument>(page: PagedResults<T>): PagedResults<T> {\n for (const document of page.results) {\n this.learn(document);\n }\n return page;\n }\n\n driveOf(identifier: string | undefined): string | undefined {\n return identifier === undefined ? undefined : this.ids.get(identifier);\n }\n\n /** Names a drive only when this backend proved it is one. */\n driveIdFor = (call: DriveIdCall): string | undefined => {\n switch (call.method) {\n case \"create\":\n case \"find\":\n return this.driveOf(call.parentId);\n case \"execute\":\n case \"deleteDocument\":\n return this.driveOf(call.documentId);\n case \"executeBatch\":\n for (const job of call.jobs ?? []) {\n const drive = this.driveOf(job.documentId);\n if (drive !== undefined) {\n return drive;\n }\n }\n return undefined;\n }\n };\n}\n\nexport type GraphQLRoutableBackendOptions = Omit<\n GraphQLReactorClientOptions,\n \"driveIdFor\"\n>;\n\nexport type GraphQLRoutableBackend = {\n readonly backend: IRoutableBackend;\n /** The Switchboard's own facts, from its inspection subgraph. */\n info(): Promise<ReactorInfo>;\n /** Reopens the realtime socket on the new credentials. */\n notifyCredentialsChanged(): void;\n};\n\n/** A Switchboard as a router backend; members GraphQL cannot serve are absent. */\nexport function createGraphQLRoutableBackend(\n options: GraphQLRoutableBackendOptions,\n): GraphQLRoutableBackend {\n const drives = new KnownDrives();\n const gql = new GraphQLReactorClient({\n ...options,\n driveIdFor: drives.driveIdFor,\n });\n const backend: IRoutableBackend = {\n supports: { find: findIsServableOverGraphQL, pointInTimeViews: false },\n get: async <TDocument extends PHDocument>(\n identifier: string,\n view?: ViewFilter,\n signal?: AbortSignal,\n ) => drives.learn(await gql.get<TDocument>(identifier, view, signal)),\n getOperations: (identifier, view, filter, paging, signal) =>\n gql.getOperations(identifier, view, filter, paging, signal),\n find: async (search, view, paging, signal) =>\n drives.learnPage(await gql.find(search, view, paging, signal)),\n isServed: (identifier, view, signal) =>\n gql.isServed(identifier, view, signal),\n getOutgoingRelationships: (source, type, view, paging, signal) =>\n gql.getOutgoingRelationships(source, type, view, paging, signal),\n getIncomingRelationships: (target, type, view, paging, signal) =>\n gql.getIncomingRelationships(target, type, view, paging, signal),\n getOutgoingRelationshipEdges: (source, type, view, paging, signal) =>\n gql.getOutgoingRelationshipEdges(source, type, view, paging, signal),\n getIncomingRelationshipEdges: (target, type, view, paging, signal) =>\n gql.getIncomingRelationshipEdges(target, type, view, paging, signal),\n subscribe: (search, callback, view) =>\n gql.subscribe(search, callback, view),\n getCreateSignaturePolicy: () => gql.getCreateSignaturePolicy(),\n getCreateProtocolVersions: (parent, signal) =>\n gql.getCreateProtocolVersions(parent, signal),\n create: async <TDocument extends PHDocument = PHDocument>(\n document: PHDocument,\n parent?: string,\n signal?: AbortSignal,\n ) => drives.learn(await gql.create<TDocument>(document, parent, signal)),\n execute: async <TDocument extends PHDocument>(\n identifier: string,\n branch: string,\n actions: Action[],\n signal?: AbortSignal,\n ) =>\n drives.learn(\n await gql.execute<TDocument>(identifier, branch, actions, signal),\n ),\n executeBatch: (request, signal) => gql.executeBatch(request, signal),\n deleteDocument: (identifier, propagate, signal) =>\n gql.deleteDocument(identifier, propagate, signal),\n setPreferredEditor: (identifier, editor, branch, signal) =>\n gql.setPreferredEditor(identifier, editor, branch, signal),\n getJob: async (jobId, signal) => {\n const job = await gql.getJob(jobId, signal);\n return job?.status === JobStatus.FAILED &&\n job.error?.name === JOB_NOT_FOUND_ERROR_NAME\n ? undefined\n : job;\n },\n waitForJob: (job, signal) => gql.waitForJob(job, signal),\n };\n return {\n backend,\n info: async () => {\n const result = await gql.request<RemoteReactorInfo>(REMOTE_INFO_QUERY);\n return {\n ...result.inspection.info,\n access: { admin: false, sql: false },\n };\n },\n notifyCredentialsChanged: () => gql.notifyCredentialsChanged(),\n };\n}\n","import {\n createReactorInspector,\n type ReactorInfo,\n} from \"@powerhousedao/reactor\";\nimport type {\n BrowserReactorClientModule,\n WorkerReactorClientModule,\n} from \"@powerhousedao/reactor-browser\";\nimport {\n FanInPartialFailureError,\n fromReactorClient,\n RoutingReactorClient,\n type CollectionRequirementsInput,\n type ReactorReach,\n type RoutableBackendConfig,\n type RouterDiagnostic,\n type RoutingClientOptions,\n} from \"@powerhousedao/reactor-router\";\nimport type {\n DocumentModelModule,\n ISigner,\n} from \"@powerhousedao/shared/document-model\";\nimport { logger } from \"document-model\";\nimport {\n createGraphQLRoutableBackend,\n type GraphQLRoutableBackend,\n} from \"./graphql-routable-backend.js\";\n\nexport const LOCAL_BACKEND_NAME = \"connect-local\";\nexport const REMOTE_BACKEND_NAME = \"switchboard-remote\";\n\nexport type LocalReactorModule =\n | BrowserReactorClientModule\n | WorkerReactorClientModule;\n\nconst REMOTE_REACH: ReactorReach = Object.freeze({\n hosting: \"remote\",\n inspection: \"none\",\n});\n\n/** Only the tab's reactor is inspectable here, so new collections land on it. */\nexport const PLACE_ON_LOCAL: CollectionRequirementsInput = Object.freeze({\n inspectable: true,\n});\n\nexport function localReach(kind: LocalReactorModule[\"kind\"]): ReactorReach {\n return kind === \"worker\"\n ? { hosting: \"worker\", inspection: \"rpc\" }\n : { hosting: \"in-process\", inspection: \"direct\" };\n}\n\n/** Read at every refresh, never kept: a rebuilt reactor reports its own. */\nexport function localFacts(\n module: LocalReactorModule,\n): () => Promise<ReactorInfo> {\n if (module.kind === \"worker\") {\n return () => module.inspector.info();\n }\n return async () => {\n const reactorModule = module.reactorModule;\n if (!reactorModule) {\n throw new Error(\"The in-tab reactor exposes no module to inspect\");\n }\n return createReactorInspector(reactorModule).info();\n };\n}\n\n/** `<origin>[/<prefix>]/d/<slug>` -> `<origin>[/<prefix>]/graphql`. */\nexport function deriveSwitchboardGraphqlUrl(\n remoteDriveUrl: string,\n): string | undefined {\n let parsed: URL;\n try {\n parsed = new URL(remoteDriveUrl);\n } catch {\n return undefined;\n }\n const prefix = /^(.*)\\/d\\/[^/]+\\/?$/.exec(parsed.pathname)?.[1];\n return prefix === undefined ? undefined : `${parsed.origin}${prefix}/graphql`;\n}\n\n/** The loaded document models, or a getter that reads the current ones. */\nexport type LoadedDocumentModels =\n | readonly DocumentModelModule[]\n | (() => readonly DocumentModelModule[]);\n\nexport type MultiReactorParams = {\n /** The local module, built and ready. Undefined builds a REMOTE-ONLY router\n * (no local backend → no local reactor, no PGlite): the `remote` client. */\n module: LocalReactorModule | undefined;\n remoteGraphqlUrl: string;\n signer: ISigner;\n /** Signing models when the local module exposes no registry; the router asks the local reactor (or, remote-only, the loaded set). */\n documentModelModules: LoadedDocumentModels;\n onDiagnostic?: RouterDiagnostic;\n};\n\n/** Remote-only placement: the Switchboard serves every collection. (It offers\n * no inspection surface over GraphQL, so PLACE_ON_LOCAL's `inspectable`\n * requirement must NOT apply, or no backend would be eligible.) */\nexport const PLACE_ON_REMOTE: CollectionRequirementsInput = Object.freeze({});\n\n/** The router Connect installs, with Connect's handling of credentials and id checks. */\nexport class ConnectRoutingClient extends RoutingReactorClient {\n private readonly remote: GraphQLRoutableBackend;\n private readonly hasLocal: boolean;\n\n constructor(\n backends: readonly RoutableBackendConfig[],\n options: RoutingClientOptions,\n remote: GraphQLRoutableBackend,\n hasLocal: boolean,\n ) {\n super(backends, options);\n this.remote = remote;\n this.hasLocal = hasLocal;\n }\n\n /** Renown's sign-in and sign-out call this on whatever client is installed. */\n notifyCredentialsChanged(): void {\n this.remote.notifyCredentialsChanged();\n }\n\n /** The local answer stands when only the Switchboard could not answer — but\n * only when there IS a local backend. Remote-only has nothing to fall back\n * to, so its errors surface. */\n override async isDocumentIdTaken(\n documentId: string,\n signal?: AbortSignal,\n ): Promise<boolean> {\n try {\n return await super.isDocumentIdTaken(documentId, signal);\n } catch (error) {\n if (!this.hasLocal || !failedOnlyOnRemote(error)) {\n throw error;\n }\n logger.warn(\n \"The Switchboard could not say whether @id is taken; using the local reactor's answer: @error\",\n documentId,\n error,\n );\n return false;\n }\n }\n}\n\nfunction failedOnlyOnRemote(error: unknown): boolean {\n return (\n error instanceof FanInPartialFailureError &&\n error.failures.every((failure) => failure.backend === REMOTE_BACKEND_NAME)\n );\n}\n\n/**\n * Build the Connect routing client. With a local `module` it is the router\n * over the tab's reactor (primary) and the Switchboard; WITHOUT one it is the\n * `remote` client — a remote-only router whose single backend is the\n * Switchboard, so no local reactor (and no PGlite) is built. Either way the\n * result is a full IReactorClient the app graph consumes unchanged.\n */\nexport async function buildMultiReactorClient(\n params: MultiReactorParams,\n): Promise<ConnectRoutingClient> {\n const module = params.module;\n const registry = module?.reactorModule?.documentModelRegistry;\n const loaded = params.documentModelModules;\n const loadedModules = typeof loaded === \"function\" ? loaded : () => loaded;\n const remote = createGraphQLRoutableBackend({\n url: params.remoteGraphqlUrl,\n documentModels: () => registry?.getAllModules() ?? loadedModules(),\n });\n const remoteBackend: RoutableBackendConfig = {\n name: REMOTE_BACKEND_NAME,\n backend: remote.backend,\n facts: () => remote.info(),\n reach: REMOTE_REACH,\n refusesMisroutes: false,\n };\n const backends: RoutableBackendConfig[] = module\n ? [\n {\n name: LOCAL_BACKEND_NAME,\n backend: fromReactorClient(module.client),\n facts: localFacts(module),\n reach: localReach(module.kind),\n refusesMisroutes: false,\n },\n remoteBackend,\n ]\n : [remoteBackend];\n const router = new ConnectRoutingClient(\n backends,\n {\n // Remote-only: the Switchboard is primary and serves every collection;\n // with a local reactor, new collections land on it (inspectable).\n primaryBackend: module ? LOCAL_BACKEND_NAME : REMOTE_BACKEND_NAME,\n defaultRequirements: module ? PLACE_ON_LOCAL : PLACE_ON_REMOTE,\n signer: params.signer,\n onDiagnostic: params.onDiagnostic,\n // The Switchboard serves no models over GraphQL; remote-only uses the loaded set.\n documentModelModules: module ? undefined : loadedModules,\n },\n remote,\n Boolean(module),\n );\n await router.refreshFacts();\n return router;\n}\n"],"names":[],"mappings":";;;;;;;AAiBA,MAAM,oBAAkC;;;;;;;;;;;;;;;;;AAsBxC,IAAM,cAAN,MAAkB;CAChB,sBAAuB,IAAI,IAAoB;CAE/C,MAA4B,UAAgB;EAC1C,MAAM,EAAE,IAAI,MAAM,iBAAiB,SAAS;EAC5C,IAAK,qBAA2C,SAAS,YAAY,GAAG;GACtE,KAAK,IAAI,IAAI,IAAI,EAAE;GACnB,IAAI,MACF,KAAK,IAAI,IAAI,MAAM,EAAE;EAEzB;EACA,OAAO;CACT;CAEA,UAAgC,MAAwC;EACtE,KAAK,MAAM,YAAY,KAAK,SAC1B,KAAK,MAAM,QAAQ;EAErB,OAAO;CACT;CAEA,QAAQ,YAAoD;EAC1D,OAAO,eAAe,KAAA,IAAY,KAAA,IAAY,KAAK,IAAI,IAAI,UAAU;CACvE;;CAGA,cAAc,SAA0C;EACtD,QAAQ,KAAK,QAAb;GACE,KAAK;GACL,KAAK,QACH,OAAO,KAAK,QAAQ,KAAK,QAAQ;GACnC,KAAK;GACL,KAAK,kBACH,OAAO,KAAK,QAAQ,KAAK,UAAU;GACrC,KAAK;IACH,KAAK,MAAM,OAAO,KAAK,QAAQ,CAAC,GAAG;KACjC,MAAM,QAAQ,KAAK,QAAQ,IAAI,UAAU;KACzC,IAAI,UAAU,KAAA,GACZ,OAAO;IAEX;IACA;EACJ;CACF;AACF;;AAgBA,SAAgB,6BACd,SACwB;CACxB,MAAM,SAAS,IAAI,YAAY;CAC/B,MAAM,MAAM,IAAI,qBAAqB;EACnC,GAAG;EACH,YAAY,OAAO;CACrB,CAAC;CAuDD,OAAO;EACL,SAAA;GAtDA,UAAU;IAAE,MAAM;IAA2B,kBAAkB;GAAM;GACrE,KAAK,OACH,YACA,MAC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AAa;CAC1B,OAAO;AACT","debug_id":"cd7ca6e1-c72a-5e8b-9872-f7bd8cf4f5c1"}
@@ -0,0 +1,183 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="54f17b90-acbe-5ba5-a870-6fd370beb817")}catch(e){}}();
3
+ import { addFileWithProgress, getPHStore, setSelectedNode, showPHModal, subscribeToPHValue } from "@powerhousedao/reactor-browser";
4
+ import { formatFileSize, mapProgressStageToStatus } from "@powerhousedao/design-system/connect";
5
+ //#region src/utils/launch-queue.ts
6
+ let pendingImportFiles = [];
7
+ const pendingListeners = /* @__PURE__ */ new Set();
8
+ function notifyPendingListeners() {
9
+ for (const listener of pendingListeners) listener();
10
+ }
11
+ function getPendingImportFiles() {
12
+ return pendingImportFiles;
13
+ }
14
+ /** Stable identity of a pending file (also the picker's pre-check cache key). */
15
+ function pendingFileKey(file) {
16
+ return `${file.name}|${file.size}|${file.lastModified}`;
17
+ }
18
+ function addPendingImportFiles(files) {
19
+ const seen = new Set(pendingImportFiles.map(pendingFileKey));
20
+ const fresh = files.filter((file) => {
21
+ const key = pendingFileKey(file);
22
+ if (seen.has(key)) return false;
23
+ seen.add(key);
24
+ return true;
25
+ });
26
+ if (fresh.length === 0) return;
27
+ pendingImportFiles = [...pendingImportFiles, ...fresh];
28
+ notifyPendingListeners();
29
+ }
30
+ function clearPendingImportFiles() {
31
+ if (pendingImportFiles.length === 0) return;
32
+ pendingImportFiles = [];
33
+ notifyPendingListeners();
34
+ }
35
+ function subscribePendingImportFiles(cb) {
36
+ pendingListeners.add(cb);
37
+ return () => {
38
+ pendingListeners.delete(cb);
39
+ };
40
+ }
41
+ async function handleLaunchParams(params) {
42
+ const handles = params.files.filter((handle) => handle.kind === "file");
43
+ if (handles.length === 0) return;
44
+ const files = [];
45
+ for (const handle of handles) try {
46
+ files.push(await handle.getFile());
47
+ } catch (error) {
48
+ console.error("Failed to read launched file:", handle.name, error);
49
+ }
50
+ if (files.length === 0) return;
51
+ addPendingImportFiles(files);
52
+ showPHModal({ type: "openFileDocuments" });
53
+ }
54
+ function maybeReopenImportModal() {
55
+ if (getPendingImportFiles().length === 0) return;
56
+ if (getPHStore()?.modal !== void 0) return;
57
+ showPHModal({ type: "openFileDocuments" });
58
+ }
59
+ let initialized = false;
60
+ /**
61
+ * Register the launchQueue consumer that receives files opened with Connect
62
+ * through the OS file association. Idempotent (safe under StrictMode double
63
+ * effects) and a no-op where the File Handling API doesn't exist — Firefox,
64
+ * Safari, and any context without an installed PWA manifest simply never
65
+ * deliver launches.
66
+ */
67
+ function initLaunchQueueFileHandling() {
68
+ if (initialized) return;
69
+ initialized = true;
70
+ subscribeToPHValue("modal", maybeReopenImportModal);
71
+ window.launchQueue?.setConsumer((params) => {
72
+ handleLaunchParams(params);
73
+ });
74
+ }
75
+ //#endregion
76
+ //#region src/utils/open-file-uploads.ts
77
+ let uploads = [];
78
+ const listeners = /* @__PURE__ */ new Set();
79
+ function notifyUploadListeners() {
80
+ for (const listener of listeners) listener();
81
+ }
82
+ function getOpenFileUploads() {
83
+ return uploads;
84
+ }
85
+ function subscribeOpenFileUploads(cb) {
86
+ listeners.add(cb);
87
+ return () => {
88
+ listeners.delete(cb);
89
+ };
90
+ }
91
+ function removeOpenFileUpload(id) {
92
+ const next = uploads.filter((upload) => upload.id !== id);
93
+ if (next.length === uploads.length) return;
94
+ uploads = next;
95
+ notifyUploadListeners();
96
+ }
97
+ function clearOpenFileUploads() {
98
+ if (uploads.length === 0) return;
99
+ uploads = [];
100
+ notifyUploadListeners();
101
+ }
102
+ function addOpenFileUploads(rows) {
103
+ uploads = [...uploads, ...rows];
104
+ notifyUploadListeners();
105
+ }
106
+ function patchOpenFileUpload(id, patch) {
107
+ uploads = uploads.map((upload) => upload.id === id ? {
108
+ ...upload,
109
+ ...patch
110
+ } : upload);
111
+ notifyUploadListeners();
112
+ }
113
+ let uploadCounter = 0;
114
+ let importChain = Promise.resolve();
115
+ /**
116
+ * Import one file and resolve once the flow truly ends. Completion is
117
+ * tracked through the progress stages, NOT the returned promise — the
118
+ * package-discovery retry path resolves early and keeps reporting through
119
+ * the callback. `resolveConflict: "duplicate"` is always passed: duplicates
120
+ * were resolved in the picker (rename), so the conflict stage must never
121
+ * fire — this also covers a duplicate appearing between pre-check and import.
122
+ */
123
+ function importOne(row, driveId, documentTypes) {
124
+ return new Promise((resolve) => {
125
+ let settled = false;
126
+ const settle = (fileNode) => {
127
+ if (settled) return;
128
+ settled = true;
129
+ resolve(fileNode);
130
+ };
131
+ addFileWithProgress(row.file, driveId, row.name, void 0, (progress) => {
132
+ patchOpenFileUpload(row.id, {
133
+ status: mapProgressStageToStatus(progress.stage),
134
+ progress: progress.progress,
135
+ ...progress.error ? { errorDetails: progress.error } : {},
136
+ ...progress.documentType ? { documentType: progress.documentType } : {},
137
+ ...progress.fileNode ? { fileNode: progress.fileNode } : {}
138
+ });
139
+ switch (progress.stage) {
140
+ case "complete":
141
+ settle(progress.fileNode);
142
+ break;
143
+ case "failed":
144
+ case "unsupported-document-type": settle(void 0);
145
+ }
146
+ }, documentTypes, "duplicate").catch(() => {
147
+ settle(void 0);
148
+ });
149
+ });
150
+ }
151
+ /**
152
+ * Run a confirmed batch of imports into a drive, feeding the floating upload
153
+ * panel. Rows appear immediately (queued), files import sequentially, and a
154
+ * single-file batch that succeeds opens its document in the editor.
155
+ */
156
+ function runOpenFileImports(args) {
157
+ const { driveId, imports, documentTypes } = args;
158
+ if (imports.length === 0) return importChain;
159
+ const rows = imports.map(({ file, name }) => ({
160
+ id: `open-file-${++uploadCounter}`,
161
+ file,
162
+ name
163
+ }));
164
+ addOpenFileUploads(rows.map((row) => ({
165
+ id: row.id,
166
+ fileName: row.name,
167
+ fileSize: formatFileSize(row.file.size),
168
+ status: "pending",
169
+ progress: 0
170
+ })));
171
+ const run = async () => {
172
+ const results = [];
173
+ for (const row of rows) results.push(await importOne(row, driveId, documentTypes));
174
+ if (rows.length === 1 && results[0]) setSelectedNode(results[0]);
175
+ };
176
+ importChain = importChain.then(run, run);
177
+ return importChain;
178
+ }
179
+ //#endregion
180
+ export { subscribeOpenFileUploads as a, initLaunchQueueFileHandling as c, runOpenFileImports as i, pendingFileKey as l, getOpenFileUploads as n, clearPendingImportFiles as o, removeOpenFileUpload as r, getPendingImportFiles as s, clearOpenFileUploads as t, subscribePendingImportFiles as u };
181
+
182
+ //# sourceMappingURL=open-file-uploads-BcyWmUZn.js.map
183
+ //# debugId=54f17b90-acbe-5ba5-a870-6fd370beb817