@powerhousedao/connect-core 6.2.3-dev.79 → 6.2.3-dev.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backend-auth-gate-DNKg_v4Y.js +65 -0
- package/dist/backend-auth-gate-DNKg_v4Y.js.map +1 -0
- package/dist/backend-auth-gate-DiFpY5rt.d.ts +19 -0
- package/dist/backend-auth-gate-DiFpY5rt.d.ts.map +1 -0
- package/dist/{index-r46ba0Kx.d.ts → index-BMlma368.d.ts} +23 -3
- package/dist/{index-r46ba0Kx.d.ts.map → index-BMlma368.d.ts.map} +1 -1
- package/dist/{index-DQ0nbYne.d.ts → index-Beqvfchq.d.ts} +16 -3
- package/dist/index-Beqvfchq.d.ts.map +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +8 -7
- package/dist/{plugin-host-D_EW56IQ.js → plugin-host-CMr7lN40.js} +2 -2
- package/dist/{plugin-host-D_EW56IQ.js.map → plugin-host-CMr7lN40.js.map} +1 -1
- package/dist/{plugin-ui-fDXhKTCK.js → plugin-ui-DHlnXJmN.js} +3 -3
- package/dist/{plugin-ui-fDXhKTCK.js.map → plugin-ui-DHlnXJmN.js.map} +1 -1
- package/dist/plugins.js +2 -2
- package/dist/route-tree-D0aszMrk.js.map +1 -1
- package/dist/{router-wVNdTI-Y.js → router-C4hDJ4_J.js} +2 -2
- package/dist/{router-wVNdTI-Y.js.map → router-C4hDJ4_J.js.map} +1 -1
- package/dist/router.js +2 -2
- package/dist/{runtime-BUG9vT2E.js → runtime-D20_LlB_.js} +47 -9
- package/dist/runtime-D20_LlB_.js.map +1 -0
- package/dist/runtime-config-D3YPhYyj.d.ts.map +1 -1
- package/dist/runtime-config.js +11 -5
- package/dist/runtime-config.js.map +1 -1
- package/dist/{runtime-flag-Bp6QasS8.js → runtime-flag-DvxW_SD4.js} +2 -2
- package/dist/{runtime-flag-Bp6QasS8.js.map → runtime-flag-DvxW_SD4.js.map} +1 -1
- package/dist/runtime.d.ts +3 -2
- package/dist/runtime.js +4 -3
- package/dist/{views-Ba9OeN3c.js → views-BtUVboYl.js} +78 -5
- package/dist/views-BtUVboYl.js.map +1 -0
- package/dist/views.d.ts +3 -2
- package/dist/views.js +3 -2
- package/package.json +8 -8
- package/src/router/modals.tsx +3 -3
- package/src/runtime/app-reactor-client.ts +63 -12
- package/src/runtime/backend-auth-gate.ts +57 -0
- package/src/runtime/drive-relist.ts +18 -0
- package/src/runtime/index.ts +3 -0
- package/src/runtime/runtime-config.ts +12 -1
- package/src/views/backend-auth-gate.tsx +76 -0
- package/src/views/directory-listing.tsx +2 -2
- package/src/views/editor-host.tsx +3 -3
- package/src/views/index.ts +5 -0
- package/src/views/layout.tsx +6 -2
- package/dist/index-DQ0nbYne.d.ts.map +0 -1
- package/dist/runtime-BUG9vT2E.js.map +0 -1
- package/dist/views-Ba9OeN3c.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-wVNdTI-Y.js","names":[],"sources":["../src/router/perf-marks.ts","../src/router/scroll.ts","../src/router/search.ts","../src/router/navigation.ts","../src/router/connect-router.ts","../src/router/app-router.ts","../src/router/core-app.tsx","../src/router/route-options.ts"],"sourcesContent":["import type { AnyRouter } from \"@tanstack/react-router\";\n\n/** `localStorage[PERF_STORAGE_KEY] = \"1\"` or `?perf=1` turns the marks on in production. */\nexport const PERF_STORAGE_KEY = \"ph:perf\";\n\n/** The measures each navigation writes, as the bench reads them. */\nexport const ROUTER_MEASURES = {\n /** `navigation.open` to the router starting the navigation. */\n click: \"nav click\",\n /** Route loaders, until the router commits the matches. */\n loader: \"nav loader\",\n /** The commit until React has rendered it. */\n commit: \"nav commit\",\n /** The click (or the navigation's start) to the next frame after render. */\n total: \"nav total\",\n} as const;\n\n// Chrome's Performance panel shows these as \"Connect › Router\".\nconst DETAIL = {\n devtools: { dataType: \"track-entry\", track: \"Router\", trackGroup: \"Connect\" },\n} as const;\n\nlet marking = 0;\nlet clickedAt: number | undefined;\n\n/** On in dev builds; elsewhere only with the runtime flag. */\nexport function routerPerfEnabled(dev = !!import.meta.env?.DEV) {\n if (dev) return true;\n try {\n return (\n new URLSearchParams(location.search).get(\"perf\") === \"1\" ||\n localStorage.getItem(PERF_STORAGE_KEY) === \"1\"\n );\n } catch {\n return false;\n }\n}\n\n/** Marks a navigation's click; a no-op unless a router is being marked. */\nexport function markNavigationClick() {\n if (!marking) return;\n clickedAt = performance.now();\n performance.mark(\"nav:click\", { detail: DETAIL });\n}\n\nfunction measure(name: string, start: number | undefined, end: number) {\n if (start === undefined) return;\n performance.measure(name, { start, end, detail: DETAIL });\n}\n\n/** Writes each navigation's phases as performance measures; returns the unsubscribe. */\nexport function markRouterNavigations(\n router: Pick<AnyRouter, \"subscribe\">,\n enabled = routerPerfEnabled(),\n) {\n if (!enabled) return () => {};\n marking++;\n let generation = 0;\n let clicked: number | undefined;\n let navigated: number | undefined;\n let loading: number | undefined;\n let loaded: number | undefined;\n const unsubscribes = [\n router.subscribe(\"onBeforeNavigate\", () => {\n generation++;\n navigated = performance.now();\n clicked = clickedAt;\n clickedAt = undefined;\n measure(ROUTER_MEASURES.click, clicked, navigated);\n loading = loaded = undefined;\n }),\n router.subscribe(\"onBeforeLoad\", () => {\n loading = performance.now();\n }),\n router.subscribe(\"onLoad\", () => {\n loaded = performance.now();\n measure(ROUTER_MEASURES.loader, loading, loaded);\n }),\n router.subscribe(\"onRendered\", () => {\n measure(ROUTER_MEASURES.commit, loaded, performance.now());\n const current = generation;\n const start = clicked ?? navigated;\n // The frame after render, as close to paint as a script sees.\n requestAnimationFrame(() =>\n setTimeout(() => {\n if (current === generation) {\n measure(ROUTER_MEASURES.total, start, performance.now());\n }\n }),\n );\n }),\n ];\n return () => {\n marking--;\n for (const unsubscribe of unsubscribes) unsubscribe();\n };\n}\n","import type {\n AnyRouter,\n ParsedLocation,\n RouterHistory,\n} from \"@tanstack/react-router\";\n\ntype ScrollRouter = Pick<AnyRouter, \"subscribe\" | \"_scroll\" | \"options\"> & {\n history: RouterHistory;\n};\n\nconst TRAVERSALS = new Set([\"BACK\", \"FORWARD\", \"GO\"]);\nconst traversals = new WeakMap<object, { traversal: boolean }>();\n\n/** The router's `scrollRestoration`: on for back/forward only; other\n * navigations reset the content view in `bindConnectScroll`. */\nexport function connectScrollRestoration() {\n // The first load restores a reloaded page's scroll.\n const state = { traversal: true };\n const restore = ({ location }: { location: ParsedLocation }) =>\n state.traversal || !!location.hash;\n traversals.set(restore, state);\n return restore;\n}\n\n/** Tracks history actions, and resets a scrolled content view on new views. */\nexport function bindConnectScroll(router: ScrollRouter, contentViewId: string) {\n const state = traversals.get(router.options.scrollRestoration as object);\n if (!state) return () => {};\n const unsubscribeHistory = router.history.subscribe(({ action }) => {\n state.traversal = TRAVERSALS.has(action.type);\n });\n if (typeof document === \"undefined\") return unsubscribeHistory;\n\n // Read in the scroll event, where layout is clean, not at navigation.\n let scrolledView: Element | undefined;\n let windowScrolled = false;\n const onScroll = (event: Event) => {\n const target = event.target;\n if (target === document) {\n windowScrolled = window.scrollY > 0 || window.scrollX > 0;\n } else if (target instanceof Element && target.id === contentViewId) {\n scrolledView = target.scrollTop > 0 ? target : undefined;\n }\n };\n document.addEventListener(\"scroll\", onScroll, {\n capture: true,\n passive: true,\n });\n\n let resetScroll = true;\n const unsubscribes = [\n unsubscribeHistory,\n // The navigation's `resetScroll`, before the router clears it on render.\n router.subscribe(\"onBeforeRouteMount\", () => {\n resetScroll = router._scroll.n;\n }),\n router.subscribe(\"onRendered\", ({ toLocation }) => {\n if (state.traversal || toLocation.hash || !resetScroll) return;\n if (scrolledView?.isConnected) scrolledView.scrollTo(0, 0);\n if (windowScrolled) window.scrollTo(0, 0);\n scrolledView = undefined;\n windowScrolled = false;\n }),\n ];\n return () => {\n document.removeEventListener(\"scroll\", onScroll, { capture: true });\n for (const unsubscribe of unsubscribes) unsubscribe();\n };\n}\n","import {\n FEATURE_FLAG_PARAM_PREFIX,\n GLOBAL_SEARCH_PARAMS,\n parseRevisionHistoryPage,\n REVISION_HISTORY_PAGE_PARAM,\n REVISION_HISTORY_PARAM,\n searchParamsToString,\n} from \"@powerhousedao/reactor-browser\";\nimport type { SearchMiddleware } from \"@tanstack/react-router\";\nimport { retainSearchParams } from \"@tanstack/react-router\";\n\n// Shared with reactor-browser's fallback navigation.\nexport { FEATURE_FLAG_PARAM_PREFIX, GLOBAL_SEARCH_PARAMS };\n\n/** Connect's query params: plain strings, as in the URL. */\nexport type ConnectSearch = Record<string, string | undefined>;\n\nconst retainFeatureFlags: SearchMiddleware<ConnectSearch> = ({\n search,\n next,\n}) => {\n const result = { ...next(search) };\n for (const [key, value] of Object.entries(search)) {\n if (key.startsWith(FEATURE_FLAG_PARAM_PREFIX) && !(key in result)) {\n result[key] = value;\n }\n }\n return result;\n};\n\n/** The root route's middlewares; they apply to every navigation and redirect. */\nexport const connectSearchMiddlewares: SearchMiddleware<ConnectSearch>[] = [\n retainSearchParams<ConnectSearch>([...GLOBAL_SEARCH_PARAMS]),\n retainFeatureFlags,\n];\n\n/** Lets every param through; routes add none of their own. */\nexport function validateConnectSearch(\n search: Record<string, unknown>,\n): ConnectSearch {\n return search as ConnectSearch;\n}\n\n/** Parses a query string into plain string values, unlike the JSON default. */\nexport function parseConnectSearch(searchStr: string): ConnectSearch {\n return Object.fromEntries(new URLSearchParams(searchStr));\n}\n\n/** Writes plain `key=value` pairs, so other readers of the URL see strings. */\nexport function stringifyConnectSearch(search: Record<string, unknown>) {\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(search)) {\n if (value === undefined || value === null) continue;\n params.set(key, typeof value === \"string\" ? value : JSON.stringify(value));\n }\n const searchStr = searchParamsToString(params);\n return searchStr ? `?${searchStr}` : \"\";\n}\n\n/** The drive route's params: `?history` opens the document's revision history,\n * and `historyPage` (a positive integer; 1 is dropped) pages it. */\nexport function validateDriveSearch(\n search: Record<string, unknown>,\n): ConnectSearch {\n const result = { ...search } as ConnectSearch;\n if (result[REVISION_HISTORY_PARAM] === undefined) return result;\n result[REVISION_HISTORY_PARAM] = \"\";\n const page = parseRevisionHistoryPage(result[REVISION_HISTORY_PAGE_PARAM]);\n if (page > 1) result[REVISION_HISTORY_PAGE_PARAM] = String(page);\n // Undefined, not deleted: a route's search is merged over its parent's.\n else result[REVISION_HISTORY_PAGE_PARAM] = undefined;\n return result;\n}\n\n/** The defined values of `search`, for callers that take plain records. */\nexport function definedSearch(search: object): Record<string, string> {\n const record: Record<string, string> = {};\n for (const [key, value] of Object.entries(search)) {\n if (typeof value === \"string\") record[key] = value;\n else if (value !== undefined && value !== null) {\n record[key] = JSON.stringify(value);\n }\n }\n return record;\n}\n","import type {\n PHDriveTarget,\n PHNavigation,\n PHNavigationTarget,\n PHSettingsTarget,\n SetSearchParams,\n} from \"@powerhousedao/reactor-browser\";\nimport {\n applySearchUpdate,\n findDriveBySlugOrId,\n isSettingsTarget,\n makeDriveSlug,\n OPENED_FROM_STATE_KEY,\n openedFromIndex,\n resolveSearchUpdate,\n} from \"@powerhousedao/reactor-browser\";\nimport type {\n AnyRouter,\n HistoryState,\n MakeRouteMatchUnion,\n} from \"@tanstack/react-router\";\nimport { useRouterState } from \"@tanstack/react-router\";\nimport { useMemo } from \"react\";\nimport type { ConnectRouterBundle } from \"./connect-router.js\";\nimport { markNavigationClick } from \"./perf-marks.js\";\nimport { definedSearch } from \"./search.js\";\nimport { keepOpenedFrom, settingsTabs } from \"./settings.js\";\n\n// Hover intent: a pointer passing over cards doesn't preload each of them.\nconst PRELOAD_DELAY_MS = 50;\n\n/** The PH navigation backed by `router`; its hooks take the router directly,\n * so they work outside the RouterProvider. */\nexport function createConnectNavigation(\n connectRouter: ConnectRouterBundle,\n): PHNavigation & { dispose(): void } {\n const { router, homeRoute, nodeRoute, settingsRoute } = connectRouter;\n // Settings tabs can come from a project's routes, unknown to Connect's types.\n const anyRouter = router as unknown as AnyRouter;\n\n // A listed drive is addressed by its canonical slug, whatever form came in.\n const driveParams = (target: PHDriveTarget) => {\n const drive = findDriveBySlugOrId(\n router.options.context.store,\n target.driveSlug,\n );\n return {\n driveSlug: drive ? makeDriveSlug(drive) : target.driveSlug,\n nodeSlug: target.nodeSlug || undefined,\n };\n };\n\n // `true` is the first tab, so the URL names a tab without a redirect.\n const settingsPath = ({ settings }: PHSettingsTarget) => {\n const tab =\n settings === true ? settingsTabs(anyRouter).at(0)?.id : settings;\n return tab ? `${settingsRoute.fullPath}/${tab}` : settingsRoute.fullPath;\n };\n\n // In-document writes keep the entry's state, so its opened-from index too.\n const setSearch: PHNavigation[\"setSearch\"] = (update, options) => {\n void router.navigate({\n to: \".\",\n search: (prev) => applySearchUpdate({}, update(definedSearch(prev))),\n state: true,\n replace: options?.replace,\n resetScroll: false,\n });\n };\n\n const showsSettings = () =>\n router.state.matches.some((match) => match.routeId === settingsRoute.id);\n\n // A push remembers the entry it leaves; a replace keeps what that one had,\n // as does a move between settings tabs.\n const openedFromState = (\n replace: boolean | undefined,\n target: PHNavigationTarget | undefined,\n ) => {\n const { state } = router.history.location;\n const next =\n replace || (isSettingsTarget(target) && showsSettings())\n ? keepOpenedFrom(state)\n : ({\n [OPENED_FROM_STATE_KEY]: state.__TSR_index,\n } as unknown as HistoryState);\n return () => next;\n };\n\n const targetKey = (target: PHNavigationTarget | undefined) => {\n if (!target) return homeRoute.id;\n if (isSettingsTarget(target)) return settingsPath(target);\n const { driveSlug, nodeSlug } = driveParams(target);\n return JSON.stringify([driveSlug, nodeSlug ?? \"\"]);\n };\n let keyedMatches: readonly MakeRouteMatchUnion[] | undefined;\n let matchesKey: string | undefined;\n const currentKey = (matches: readonly MakeRouteMatchUnion[]) => {\n if (matches === keyedMatches) return matchesKey;\n keyedMatches = matches;\n const drive = matches.find((match) => match.routeId === nodeRoute.id);\n const settings = matches.some(\n (match) => match.routeId === settingsRoute.id,\n );\n if (drive) {\n matchesKey = targetKey(drive.params as PHDriveTarget);\n } else if (settings) {\n // A tab's key is its path, as settingsPath builds it.\n matchesKey = matches.at(-1)?.fullPath.replace(/\\/$/, \"\");\n } else {\n matchesKey = matches.find(\n (match) => match.routeId === homeRoute.id,\n )?.routeId;\n }\n return matchesKey;\n };\n\n // Hrefs depend only on the target and the global params of the current search.\n const hrefs = new Map<string, string>();\n let hrefsSearch: string | undefined;\n\n const setSearchParams: SetSearchParams = (update, options) =>\n setSearch((prev) => resolveSearchUpdate(prev, update), options);\n\n let preloadTimer: ReturnType<typeof setTimeout> | undefined;\n return {\n location: () => router.history.location,\n // The root route's middlewares add the global params to `search`.\n open: (target, options) => {\n markNavigationClick();\n const search = applySearchUpdate({}, options?.search ?? {});\n const replace = options?.replace;\n const state = openedFromState(replace, target);\n if (!target) {\n void router.navigate({\n to: homeRoute.fullPath,\n search,\n replace,\n state,\n });\n return;\n }\n if (isSettingsTarget(target)) {\n void anyRouter.navigate({\n to: settingsPath(target),\n search,\n replace,\n state,\n });\n return;\n }\n void router.navigate({\n to: nodeRoute.fullPath,\n params: driveParams(target),\n search,\n replace,\n state,\n });\n },\n // The public href, base path included; global params as `open` keeps them.\n hrefFor: (target) => {\n const { searchStr } = router.latestLocation;\n if (searchStr !== hrefsSearch) {\n hrefs.clear();\n hrefsSearch = searchStr;\n }\n const key = targetKey(target);\n let href = hrefs.get(key);\n if (href === undefined) {\n const location = !target\n ? router.buildLocation({ to: homeRoute.fullPath, search: {} })\n : isSettingsTarget(target)\n ? anyRouter.buildLocation({ to: settingsPath(target), search: {} })\n : router.buildLocation({\n to: nodeRoute.fullPath,\n params: driveParams(target),\n search: {},\n });\n href = location.publicHref;\n hrefs.set(key, href);\n }\n return href;\n },\n // One key per shown matches, so each link's selector is a string compare.\n useIsCurrent: (target) => {\n // The settings page itself is current on any of its tabs.\n const anyTab = isSettingsTarget(target) && target.settings === true;\n const key = anyTab ? `${settingsRoute.fullPath}/` : targetKey(target);\n return useRouterState({\n router,\n select: (state) => {\n const current = currentKey(state.matches);\n return anyTab ? !!current?.startsWith(key) : current === key;\n },\n });\n },\n preload: (target) => {\n clearTimeout(preloadTimer);\n if (!target) return;\n preloadTimer = setTimeout(() => {\n const preloading = isSettingsTarget(target)\n ? anyRouter.preloadRoute({ to: settingsPath(target) })\n : router.preloadRoute({\n to: nodeRoute.fullPath,\n params: driveParams(target),\n });\n preloading.catch(() => undefined);\n }, PRELOAD_DELAY_MS);\n },\n setSearch,\n // The presented matches' params, else the location's.\n useSearchParams() {\n const search = useRouterState({\n router,\n select: (state) =>\n state.matches.at(-1)?.search ?? state.location.search,\n });\n return useMemo(() => definedSearch(search), [search]);\n },\n useSetSearchParams: () => setSearchParams,\n closeOpened: () => {\n const { state } = router.history.location;\n const from = openedFromIndex(state, state.__TSR_index);\n if (from === undefined) return false;\n router.history.go(from - state.__TSR_index);\n return true;\n },\n dispose: () => clearTimeout(preloadTimer),\n };\n}\n","import type { DriveArrivals, PHStore } from \"@powerhousedao/reactor-browser\";\nimport {\n getPHStoreSubscribe,\n isRoutedModal,\n modalFromSearch,\n} from \"@powerhousedao/reactor-browser\";\nimport type {\n AnyRoute,\n ErrorRouteComponent,\n NotFoundRouteComponent,\n RouteComponent,\n Router,\n RouterHistory,\n} from \"@tanstack/react-router\";\nimport { createRouter } from \"@tanstack/react-router\";\nimport type { ErrorInfo, PropsWithChildren, ReactElement } from \"react\";\nimport type { ConnectPluginUiSet } from \"../plugins/plugin-ui.js\";\nimport { applyConnectPluginUi } from \"../plugins/plugin-ui.js\";\nimport { markRouterNavigations } from \"./perf-marks.js\";\nimport { bindConnectScroll, connectScrollRestoration } from \"./scroll.js\";\nimport type { DriveRouteData } from \"./drive-route-loader.js\";\nimport type { ConnectRootRoute, ConnectRoutes } from \"./route-tree.js\";\nimport { createConnectNavigation } from \"./navigation.js\";\nimport { CoreError, CoreNotFound } from \"./core-views.js\";\nimport { CONTENT_VIEW_ID } from \"./route-components.js\";\nimport { addConnectRoutes, connectRoutes } from \"./route-tree.js\";\nimport { setSettingsRoute } from \"./settings.js\";\nimport { parseConnectSearch, stringifyConnectSearch } from \"./search.js\";\nimport { driveTitle } from \"./titles.js\";\n\nexport type ConnectRouterOptions = {\n store: PHStore;\n arrivals?: DriveArrivals;\n basepath?: string;\n history?: RouterHistory;\n InnerWrap?: (props: PropsWithChildren) => ReactElement;\n /** Shown while a route's loader or chunks are pending, after the router's `pendingMs`. */\n pendingComponent?: RouteComponent;\n /** Any route's loader or render error; the plugins', else core's error view. */\n errorComponent?: ErrorRouteComponent;\n /** The active plugins' UI, set on the routes that show core's views. */\n pluginUi?: ConnectPluginUiSet;\n /** Loaders' notFound(), e.g. a missing drive's; core's page by default. */\n notFoundComponent?: NotFoundRouteComponent;\n /** The tree to route with: `@powerhousedao/connect/route-tree`, core's or a project's. */\n routeTree: AnyRoute;\n /** Code routes added to the file routes; see `addConnectRoutes`. A function\n * receives the tree's core routes to attach to. */\n routes?:\n | readonly AnyRoute[]\n | ((routes: ConnectRoutes) => readonly AnyRoute[]);\n /** Reports a route's loader or render error; logged by default. */\n onCatch?: (error: unknown, info?: ErrorInfo) => void;\n /** Ends every document title; \"Connect\" without one. */\n appName?: string;\n /** Renders the loading shell: layouts show their pendingComponent, not their page. */\n shell?: boolean;\n};\n\nfunction reportRouteError(error: unknown, info?: ErrorInfo) {\n console.error(error, info?.componentStack ?? \"\");\n}\n\n/** The router over `TRouteTree`; a project's generated tree registers its own. */\nexport type ConnectRouterFor<TRouteTree extends AnyRoute> = Router<\n TRouteTree,\n \"never\",\n false,\n RouterHistory,\n Record<string, any>\n>;\n// Written out, not inferred; see ConnectRootRoute.\nexport type ConnectRouter = ConnectRouterFor<ConnectRootRoute>;\nexport type ConnectRouterBundle = Pick<\n ConnectRoutes,\n \"homeRoute\" | \"driveRoute\" | \"nodeRoute\" | \"settingsRoute\"\n> & { router: ConnectRouter };\n\nexport function createConnectRouter(\n options: ConnectRouterOptions,\n): ConnectRouterBundle {\n const { routeTree, homeRoute, driveRoute, nodeRoute, settingsRoute } =\n connectRoutes(options.routeTree);\n if (options.pluginUi) applyConnectPluginUi(routeTree, options.pluginUi);\n if (options.routes) {\n addConnectRoutes(\n typeof options.routes === \"function\"\n ? options.routes(connectRoutes(routeTree))\n : options.routes,\n );\n }\n setSettingsRoute(settingsRoute);\n const router = createRouter({\n routeTree,\n basepath: options.basepath,\n history: options.history,\n context: {\n store: options.store,\n arrivals: options.arrivals,\n appName: options.appName,\n shell: options.shell,\n },\n parseSearch: parseConnectSearch,\n stringifySearch: stringifyConnectSearch,\n scrollRestoration: connectScrollRestoration(),\n scrollToTopSelectors: [`#${CONTENT_VIEW_ID}`],\n InnerWrap: options.InnerWrap,\n defaultPendingComponent: options.pendingComponent,\n defaultErrorComponent:\n options.errorComponent ?? options.pluginUi?.errorComponent ?? CoreError,\n // Not per route: a route's notFoundComponent mounts a boundary that\n // re-renders on every navigation.\n defaultNotFoundComponent: options.notFoundComponent ?? CoreNotFound,\n defaultOnCatch: options.onCatch ?? reportRouteError,\n });\n return { router, homeRoute, driveRoute, nodeRoute, settingsRoute };\n}\n\nfunction writeSelection(store: PHStore, data: DriveRouteData | undefined) {\n // Drive first: a new drive resets the node.\n store.selectedDriveId = data?.driveId;\n store.selectedNodeId = data?.nodeId;\n}\n\n/** Makes `router` the store's navigation and writes the selection it commits. */\nexport function bindConnectRouter(\n connectRouter: ConnectRouterBundle,\n store: PHStore,\n) {\n const { router, nodeRoute } = connectRouter;\n\n // Only committed matches select; pending ones keep the open view.\n const commitSelection = () => {\n const matches = router.state.matches;\n const drive = matches.find((match) => match.routeId === nodeRoute.id);\n if (drive) {\n if (drive.status === \"success\" && drive.loaderData) {\n writeSelection(store, drive.loaderData);\n } else if (matches.some((match) => match.status === \"notFound\")) {\n // The drive's 404 page shows no drive.\n writeSelection(store, undefined);\n }\n return;\n }\n // Any other page (home, settings, a project's, a 404) shows no drive.\n const shown = matches.at(-1)?.status;\n if (shown === \"success\" || shown === \"notFound\") {\n writeSelection(store, undefined);\n }\n };\n\n // A routed modal is the URL's: the store holds what the location names,\n // unless a confirmation is open over it.\n const syncModal = () => {\n const routed = modalFromSearch(router.state.location.search);\n if (store.modal && !isRoutedModal(store.modal)) return;\n if (routed) {\n if (JSON.stringify(store.modal) !== JSON.stringify(routed)) {\n store.modal = routed;\n }\n } else if (isRoutedModal(store.modal)) {\n store.modal = undefined;\n }\n };\n\n // Set once, before the first render; selection setters navigate from the start.\n const navigation = createConnectNavigation(connectRouter);\n store.navigation = navigation;\n\n // The node route's head reads names from the store; a rename re-runs it.\n const shownTitle = () => {\n const node = router.state.matches.find((m) => m.routeId === nodeRoute.id);\n return driveTitle(store, node?.loaderData, router.options.context.appName);\n };\n let title = shownTitle();\n const retitle = () => {\n const next = shownTitle();\n if (next === title) return;\n title = next;\n void router.invalidate({ filter: (m) => m.routeId === nodeRoute.id });\n };\n\n // Before mount, so the view and scroll restoration see the new selection.\n const unsubscribes = [\n router.subscribe(\"onBeforeRouteMount\", commitSelection),\n router.subscribe(\"onResolved\", commitSelection),\n router.subscribe(\"onResolved\", () => {\n title = shownTitle();\n }),\n router.subscribe(\"onResolved\", syncModal),\n getPHStoreSubscribe(store, \"drives\")(retitle),\n getPHStoreSubscribe(store, \"driveNodes\")(retitle),\n markRouterNavigations(router),\n ];\n const unbindScroll = bindConnectScroll(router, CONTENT_VIEW_ID);\n commitSelection();\n syncModal();\n\n return () => {\n navigation.dispose();\n unbindScroll();\n for (const unsubscribe of unsubscribes) unsubscribe();\n if (store.navigation === navigation) store.navigation = undefined;\n };\n}\n","import type { PHStore } from \"@powerhousedao/reactor-browser\";\nimport { createDriveArrivals } from \"@powerhousedao/reactor-browser\";\nimport { getConnectPluginUi } from \"../plugins/plugin-ui.js\";\nimport { getConnectRegistry } from \"../registry.js\";\nimport type {\n ConnectRouterBundle,\n ConnectRouterOptions,\n} from \"./connect-router.js\";\nimport { bindConnectRouter, createConnectRouter } from \"./connect-router.js\";\nimport { resolveConnectRoutes } from \"./route-tree.js\";\n\nexport type ConnectAppRouterOptions = Omit<\n ConnectRouterOptions,\n \"store\" | \"arrivals\"\n>;\n\n/** The app's one router over `store`; created, and made the store's navigation,\n * on first use. Registered routes join `options.routes`. */\nexport function getConnectAppRouter(\n store: PHStore,\n options: () => ConnectAppRouterOptions,\n): ConnectRouterBundle {\n const registry = getConnectRegistry();\n const current = registry.app;\n if (current) {\n if (import.meta.env?.DEV && current.store !== store) {\n throw new Error(\"Connect's router is already bound to another PH store\");\n }\n return current.bundle;\n }\n const { routes, ...rest } = options();\n const bundle = createConnectRouter({\n store,\n arrivals: createDriveArrivals(store),\n pluginUi: getConnectPluginUi(),\n ...rest,\n routes: (tree) => [\n ...(routes ? resolveConnectRoutes(routes, tree.routeTree) : []),\n ...registry.routes.flatMap((entry) => {\n entry.added = [\n ...resolveConnectRoutes(entry.registration, tree.routeTree),\n ];\n return entry.added;\n }),\n ],\n });\n registry.app = { store, bundle, unbind: bindConnectRouter(bundle, store) };\n return bundle;\n}\n\n/** Stops the app's router writing the selection, e.g. on HMR. */\nexport function disposeConnectAppRouter() {\n const registry = getConnectRegistry();\n registry.app?.unbind();\n registry.app = undefined;\n}\n","import type { PHStore } from \"@powerhousedao/reactor-browser\";\nimport { PHStoreProvider } from \"@powerhousedao/reactor-browser\";\nimport type { AnyRoute } from \"@tanstack/react-router\";\nimport { RouterProvider } from \"@tanstack/react-router\";\nimport type { ConnectAppRouterOptions } from \"./app-router.js\";\nimport { getConnectAppRouter } from \"./app-router.js\";\n\n/** A core-only app: `routeTree`'s views over `store`. */\nexport function ConnectCoreApp(props: {\n store: PHStore;\n routeTree: AnyRoute;\n basepath?: string;\n options?: () => Omit<ConnectAppRouterOptions, \"routeTree\">;\n}) {\n const { router } = getConnectAppRouter(props.store, () => ({\n basepath: props.basepath,\n ...props.options?.(),\n routeTree: props.routeTree,\n }));\n return (\n <PHStoreProvider store={props.store}>\n <RouterProvider router={router} />\n </PHStoreProvider>\n );\n}\n","import type { AnyRoute } from \"@tanstack/react-router\";\n\ntype RouteOptionKey = keyof AnyRoute[\"options\"];\n\n/** A core route's `options`: what it sets, as it sets it, and every other\n * route option, unset. */\nexport type CoreRouteOptions<T extends object> = T & {\n [K in Exclude<RouteOptionKey, keyof T>]?: undefined;\n};\n\n/** Types a core route file's exported `options` as {@link CoreRouteOptions}. */\nexport function coreRouteOptions<T extends object>(\n options: T,\n): CoreRouteOptions<T> {\n return options as CoreRouteOptions<T>;\n}\n"],"mappings":";;;;;;;;;;AAGA,MAAa,mBAAmB;;AAGhC,MAAa,kBAAkB;;CAE7B,OAAO;;CAEP,QAAQ;;CAER,QAAQ;;CAER,OAAO;AACT;AAGA,MAAM,SAAS,EACb,UAAU;CAAE,UAAU;CAAe,OAAO;CAAU,YAAY;AAAU,EAC9E;AAEA,IAAI,UAAU;AACd,IAAI;;AAGJ,SAAgB,kBAAkB,MAAM,CAAC,CAAC,YAAY,KAAK,KAAK;CAC9D,IAAI,KAAK,OAAO;CAChB,IAAI;EACF,OACE,IAAI,gBAAgB,SAAS,MAAM,CAAC,CAAC,IAAI,MAAM,MAAM,OACrD,aAAa,QAAA,SAAwB,MAAM;CAE/C,QAAQ;EACN,OAAO;CACT;AACF;;AAGA,SAAgB,sBAAsB;CACpC,IAAI,CAAC,SAAS;CACd,YAAY,YAAY,IAAI;CAC5B,YAAY,KAAK,aAAa,EAAE,QAAQ,OAAO,CAAC;AAClD;AAEA,SAAS,QAAQ,MAAc,OAA2B,KAAa;CACrE,IAAI,UAAU,KAAA,GAAW;CACzB,YAAY,QAAQ,MAAM;EAAE;EAAO;EAAK,QAAQ;CAAO,CAAC;AAC1D;;AAGA,SAAgB,sBACd,QACA,UAAU,kBAAkB,GAC5B;CACA,IAAI,CAAC,SAAS,aAAa,CAAC;CAC5B;CACA,IAAI,aAAa;CACjB,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,MAAM,eAAe;EACnB,OAAO,UAAU,0BAA0B;GACzC;GACA,YAAY,YAAY,IAAI;GAC5B,UAAU;GACV,YAAY,KAAA;GACZ,QAAQ,gBAAgB,OAAO,SAAS,SAAS;GACjD,UAAU,SAAS,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cAAc,KAAK,SAAS,CAC5D;GACA,OAAO,MAAM;EACf,CAAC,CACH;CACF,CAAC;CACD,SAAS,MAAM;EAAE;EAAO;EAAQ,QAAQ,kBAAkB,QAAQ,KAAK;CAAE;CACzE,OAAO;AACT;;AAGA,SAAgB,0BAA0B;CACxC,MAAM,WAAW,mBAAmB;CACpC,SAAS,KAAK,OAAO;CACrB,SAAS,MAAM,KAAA;AACjB;;;;AC/CA,SAAgB,eAAe,OAK5B;CACD,MAAM,EAAE,WAAW,oBAAoB,MAAM,cAAc;EACzD,UAAU,MAAM;EAChB,GAAG,MAAM,UAAU;EACnB,WAAW,MAAM;CACnB,EAAE;CACF,OACE,oBAAC,iBAAD;EAAiB,OAAO,MAAM;EAC5B,UAAA,oBAAC,gBAAD,EAAwB,OAAS,CAAA;CAClB,CAAA;AAErB;;;;ACbA,SAAgB,iBACd,SACqB;CACrB,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"router-C4hDJ4_J.js","names":[],"sources":["../src/router/perf-marks.ts","../src/router/scroll.ts","../src/router/search.ts","../src/router/navigation.ts","../src/router/connect-router.ts","../src/router/app-router.ts","../src/router/core-app.tsx","../src/router/route-options.ts"],"sourcesContent":["import type { AnyRouter } from \"@tanstack/react-router\";\n\n/** `localStorage[PERF_STORAGE_KEY] = \"1\"` or `?perf=1` turns the marks on in production. */\nexport const PERF_STORAGE_KEY = \"ph:perf\";\n\n/** The measures each navigation writes, as the bench reads them. */\nexport const ROUTER_MEASURES = {\n /** `navigation.open` to the router starting the navigation. */\n click: \"nav click\",\n /** Route loaders, until the router commits the matches. */\n loader: \"nav loader\",\n /** The commit until React has rendered it. */\n commit: \"nav commit\",\n /** The click (or the navigation's start) to the next frame after render. */\n total: \"nav total\",\n} as const;\n\n// Chrome's Performance panel shows these as \"Connect › Router\".\nconst DETAIL = {\n devtools: { dataType: \"track-entry\", track: \"Router\", trackGroup: \"Connect\" },\n} as const;\n\nlet marking = 0;\nlet clickedAt: number | undefined;\n\n/** On in dev builds; elsewhere only with the runtime flag. */\nexport function routerPerfEnabled(dev = !!import.meta.env?.DEV) {\n if (dev) return true;\n try {\n return (\n new URLSearchParams(location.search).get(\"perf\") === \"1\" ||\n localStorage.getItem(PERF_STORAGE_KEY) === \"1\"\n );\n } catch {\n return false;\n }\n}\n\n/** Marks a navigation's click; a no-op unless a router is being marked. */\nexport function markNavigationClick() {\n if (!marking) return;\n clickedAt = performance.now();\n performance.mark(\"nav:click\", { detail: DETAIL });\n}\n\nfunction measure(name: string, start: number | undefined, end: number) {\n if (start === undefined) return;\n performance.measure(name, { start, end, detail: DETAIL });\n}\n\n/** Writes each navigation's phases as performance measures; returns the unsubscribe. */\nexport function markRouterNavigations(\n router: Pick<AnyRouter, \"subscribe\">,\n enabled = routerPerfEnabled(),\n) {\n if (!enabled) return () => {};\n marking++;\n let generation = 0;\n let clicked: number | undefined;\n let navigated: number | undefined;\n let loading: number | undefined;\n let loaded: number | undefined;\n const unsubscribes = [\n router.subscribe(\"onBeforeNavigate\", () => {\n generation++;\n navigated = performance.now();\n clicked = clickedAt;\n clickedAt = undefined;\n measure(ROUTER_MEASURES.click, clicked, navigated);\n loading = loaded = undefined;\n }),\n router.subscribe(\"onBeforeLoad\", () => {\n loading = performance.now();\n }),\n router.subscribe(\"onLoad\", () => {\n loaded = performance.now();\n measure(ROUTER_MEASURES.loader, loading, loaded);\n }),\n router.subscribe(\"onRendered\", () => {\n measure(ROUTER_MEASURES.commit, loaded, performance.now());\n const current = generation;\n const start = clicked ?? navigated;\n // The frame after render, as close to paint as a script sees.\n requestAnimationFrame(() =>\n setTimeout(() => {\n if (current === generation) {\n measure(ROUTER_MEASURES.total, start, performance.now());\n }\n }),\n );\n }),\n ];\n return () => {\n marking--;\n for (const unsubscribe of unsubscribes) unsubscribe();\n };\n}\n","import type {\n AnyRouter,\n ParsedLocation,\n RouterHistory,\n} from \"@tanstack/react-router\";\n\ntype ScrollRouter = Pick<AnyRouter, \"subscribe\" | \"_scroll\" | \"options\"> & {\n history: RouterHistory;\n};\n\nconst TRAVERSALS = new Set([\"BACK\", \"FORWARD\", \"GO\"]);\nconst traversals = new WeakMap<object, { traversal: boolean }>();\n\n/** The router's `scrollRestoration`: on for back/forward only; other\n * navigations reset the content view in `bindConnectScroll`. */\nexport function connectScrollRestoration() {\n // The first load restores a reloaded page's scroll.\n const state = { traversal: true };\n const restore = ({ location }: { location: ParsedLocation }) =>\n state.traversal || !!location.hash;\n traversals.set(restore, state);\n return restore;\n}\n\n/** Tracks history actions, and resets a scrolled content view on new views. */\nexport function bindConnectScroll(router: ScrollRouter, contentViewId: string) {\n const state = traversals.get(router.options.scrollRestoration as object);\n if (!state) return () => {};\n const unsubscribeHistory = router.history.subscribe(({ action }) => {\n state.traversal = TRAVERSALS.has(action.type);\n });\n if (typeof document === \"undefined\") return unsubscribeHistory;\n\n // Read in the scroll event, where layout is clean, not at navigation.\n let scrolledView: Element | undefined;\n let windowScrolled = false;\n const onScroll = (event: Event) => {\n const target = event.target;\n if (target === document) {\n windowScrolled = window.scrollY > 0 || window.scrollX > 0;\n } else if (target instanceof Element && target.id === contentViewId) {\n scrolledView = target.scrollTop > 0 ? target : undefined;\n }\n };\n document.addEventListener(\"scroll\", onScroll, {\n capture: true,\n passive: true,\n });\n\n let resetScroll = true;\n const unsubscribes = [\n unsubscribeHistory,\n // The navigation's `resetScroll`, before the router clears it on render.\n router.subscribe(\"onBeforeRouteMount\", () => {\n resetScroll = router._scroll.n;\n }),\n router.subscribe(\"onRendered\", ({ toLocation }) => {\n if (state.traversal || toLocation.hash || !resetScroll) return;\n if (scrolledView?.isConnected) scrolledView.scrollTo(0, 0);\n if (windowScrolled) window.scrollTo(0, 0);\n scrolledView = undefined;\n windowScrolled = false;\n }),\n ];\n return () => {\n document.removeEventListener(\"scroll\", onScroll, { capture: true });\n for (const unsubscribe of unsubscribes) unsubscribe();\n };\n}\n","import {\n FEATURE_FLAG_PARAM_PREFIX,\n GLOBAL_SEARCH_PARAMS,\n parseRevisionHistoryPage,\n REVISION_HISTORY_PAGE_PARAM,\n REVISION_HISTORY_PARAM,\n searchParamsToString,\n} from \"@powerhousedao/reactor-browser\";\nimport type { SearchMiddleware } from \"@tanstack/react-router\";\nimport { retainSearchParams } from \"@tanstack/react-router\";\n\n// Shared with reactor-browser's fallback navigation.\nexport { FEATURE_FLAG_PARAM_PREFIX, GLOBAL_SEARCH_PARAMS };\n\n/** Connect's query params: plain strings, as in the URL. */\nexport type ConnectSearch = Record<string, string | undefined>;\n\nconst retainFeatureFlags: SearchMiddleware<ConnectSearch> = ({\n search,\n next,\n}) => {\n const result = { ...next(search) };\n for (const [key, value] of Object.entries(search)) {\n if (key.startsWith(FEATURE_FLAG_PARAM_PREFIX) && !(key in result)) {\n result[key] = value;\n }\n }\n return result;\n};\n\n/** The root route's middlewares; they apply to every navigation and redirect. */\nexport const connectSearchMiddlewares: SearchMiddleware<ConnectSearch>[] = [\n retainSearchParams<ConnectSearch>([...GLOBAL_SEARCH_PARAMS]),\n retainFeatureFlags,\n];\n\n/** Lets every param through; routes add none of their own. */\nexport function validateConnectSearch(\n search: Record<string, unknown>,\n): ConnectSearch {\n return search as ConnectSearch;\n}\n\n/** Parses a query string into plain string values, unlike the JSON default. */\nexport function parseConnectSearch(searchStr: string): ConnectSearch {\n return Object.fromEntries(new URLSearchParams(searchStr));\n}\n\n/** Writes plain `key=value` pairs, so other readers of the URL see strings. */\nexport function stringifyConnectSearch(search: Record<string, unknown>) {\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(search)) {\n if (value === undefined || value === null) continue;\n params.set(key, typeof value === \"string\" ? value : JSON.stringify(value));\n }\n const searchStr = searchParamsToString(params);\n return searchStr ? `?${searchStr}` : \"\";\n}\n\n/** The drive route's params: `?history` opens the document's revision history,\n * and `historyPage` (a positive integer; 1 is dropped) pages it. */\nexport function validateDriveSearch(\n search: Record<string, unknown>,\n): ConnectSearch {\n const result = { ...search } as ConnectSearch;\n if (result[REVISION_HISTORY_PARAM] === undefined) return result;\n result[REVISION_HISTORY_PARAM] = \"\";\n const page = parseRevisionHistoryPage(result[REVISION_HISTORY_PAGE_PARAM]);\n if (page > 1) result[REVISION_HISTORY_PAGE_PARAM] = String(page);\n // Undefined, not deleted: a route's search is merged over its parent's.\n else result[REVISION_HISTORY_PAGE_PARAM] = undefined;\n return result;\n}\n\n/** The defined values of `search`, for callers that take plain records. */\nexport function definedSearch(search: object): Record<string, string> {\n const record: Record<string, string> = {};\n for (const [key, value] of Object.entries(search)) {\n if (typeof value === \"string\") record[key] = value;\n else if (value !== undefined && value !== null) {\n record[key] = JSON.stringify(value);\n }\n }\n return record;\n}\n","import type {\n PHDriveTarget,\n PHNavigation,\n PHNavigationTarget,\n PHSettingsTarget,\n SetSearchParams,\n} from \"@powerhousedao/reactor-browser\";\nimport {\n applySearchUpdate,\n findDriveBySlugOrId,\n isSettingsTarget,\n makeDriveSlug,\n OPENED_FROM_STATE_KEY,\n openedFromIndex,\n resolveSearchUpdate,\n} from \"@powerhousedao/reactor-browser\";\nimport type {\n AnyRouter,\n HistoryState,\n MakeRouteMatchUnion,\n} from \"@tanstack/react-router\";\nimport { useRouterState } from \"@tanstack/react-router\";\nimport { useMemo } from \"react\";\nimport type { ConnectRouterBundle } from \"./connect-router.js\";\nimport { markNavigationClick } from \"./perf-marks.js\";\nimport { definedSearch } from \"./search.js\";\nimport { keepOpenedFrom, settingsTabs } from \"./settings.js\";\n\n// Hover intent: a pointer passing over cards doesn't preload each of them.\nconst PRELOAD_DELAY_MS = 50;\n\n/** The PH navigation backed by `router`; its hooks take the router directly,\n * so they work outside the RouterProvider. */\nexport function createConnectNavigation(\n connectRouter: ConnectRouterBundle,\n): PHNavigation & { dispose(): void } {\n const { router, homeRoute, nodeRoute, settingsRoute } = connectRouter;\n // Settings tabs can come from a project's routes, unknown to Connect's types.\n const anyRouter = router as unknown as AnyRouter;\n\n // A listed drive is addressed by its canonical slug, whatever form came in.\n const driveParams = (target: PHDriveTarget) => {\n const drive = findDriveBySlugOrId(\n router.options.context.store,\n target.driveSlug,\n );\n return {\n driveSlug: drive ? makeDriveSlug(drive) : target.driveSlug,\n nodeSlug: target.nodeSlug || undefined,\n };\n };\n\n // `true` is the first tab, so the URL names a tab without a redirect.\n const settingsPath = ({ settings }: PHSettingsTarget) => {\n const tab =\n settings === true ? settingsTabs(anyRouter).at(0)?.id : settings;\n return tab ? `${settingsRoute.fullPath}/${tab}` : settingsRoute.fullPath;\n };\n\n // In-document writes keep the entry's state, so its opened-from index too.\n const setSearch: PHNavigation[\"setSearch\"] = (update, options) => {\n void router.navigate({\n to: \".\",\n search: (prev) => applySearchUpdate({}, update(definedSearch(prev))),\n state: true,\n replace: options?.replace,\n resetScroll: false,\n });\n };\n\n const showsSettings = () =>\n router.state.matches.some((match) => match.routeId === settingsRoute.id);\n\n // A push remembers the entry it leaves; a replace keeps what that one had,\n // as does a move between settings tabs.\n const openedFromState = (\n replace: boolean | undefined,\n target: PHNavigationTarget | undefined,\n ) => {\n const { state } = router.history.location;\n const next =\n replace || (isSettingsTarget(target) && showsSettings())\n ? keepOpenedFrom(state)\n : ({\n [OPENED_FROM_STATE_KEY]: state.__TSR_index,\n } as unknown as HistoryState);\n return () => next;\n };\n\n const targetKey = (target: PHNavigationTarget | undefined) => {\n if (!target) return homeRoute.id;\n if (isSettingsTarget(target)) return settingsPath(target);\n const { driveSlug, nodeSlug } = driveParams(target);\n return JSON.stringify([driveSlug, nodeSlug ?? \"\"]);\n };\n let keyedMatches: readonly MakeRouteMatchUnion[] | undefined;\n let matchesKey: string | undefined;\n const currentKey = (matches: readonly MakeRouteMatchUnion[]) => {\n if (matches === keyedMatches) return matchesKey;\n keyedMatches = matches;\n const drive = matches.find((match) => match.routeId === nodeRoute.id);\n const settings = matches.some(\n (match) => match.routeId === settingsRoute.id,\n );\n if (drive) {\n matchesKey = targetKey(drive.params as PHDriveTarget);\n } else if (settings) {\n // A tab's key is its path, as settingsPath builds it.\n matchesKey = matches.at(-1)?.fullPath.replace(/\\/$/, \"\");\n } else {\n matchesKey = matches.find(\n (match) => match.routeId === homeRoute.id,\n )?.routeId;\n }\n return matchesKey;\n };\n\n // Hrefs depend only on the target and the global params of the current search.\n const hrefs = new Map<string, string>();\n let hrefsSearch: string | undefined;\n\n const setSearchParams: SetSearchParams = (update, options) =>\n setSearch((prev) => resolveSearchUpdate(prev, update), options);\n\n let preloadTimer: ReturnType<typeof setTimeout> | undefined;\n return {\n location: () => router.history.location,\n // The root route's middlewares add the global params to `search`.\n open: (target, options) => {\n markNavigationClick();\n const search = applySearchUpdate({}, options?.search ?? {});\n const replace = options?.replace;\n const state = openedFromState(replace, target);\n if (!target) {\n void router.navigate({\n to: homeRoute.fullPath,\n search,\n replace,\n state,\n });\n return;\n }\n if (isSettingsTarget(target)) {\n void anyRouter.navigate({\n to: settingsPath(target),\n search,\n replace,\n state,\n });\n return;\n }\n void router.navigate({\n to: nodeRoute.fullPath,\n params: driveParams(target),\n search,\n replace,\n state,\n });\n },\n // The public href, base path included; global params as `open` keeps them.\n hrefFor: (target) => {\n const { searchStr } = router.latestLocation;\n if (searchStr !== hrefsSearch) {\n hrefs.clear();\n hrefsSearch = searchStr;\n }\n const key = targetKey(target);\n let href = hrefs.get(key);\n if (href === undefined) {\n const location = !target\n ? router.buildLocation({ to: homeRoute.fullPath, search: {} })\n : isSettingsTarget(target)\n ? anyRouter.buildLocation({ to: settingsPath(target), search: {} })\n : router.buildLocation({\n to: nodeRoute.fullPath,\n params: driveParams(target),\n search: {},\n });\n href = location.publicHref;\n hrefs.set(key, href);\n }\n return href;\n },\n // One key per shown matches, so each link's selector is a string compare.\n useIsCurrent: (target) => {\n // The settings page itself is current on any of its tabs.\n const anyTab = isSettingsTarget(target) && target.settings === true;\n const key = anyTab ? `${settingsRoute.fullPath}/` : targetKey(target);\n return useRouterState({\n router,\n select: (state) => {\n const current = currentKey(state.matches);\n return anyTab ? !!current?.startsWith(key) : current === key;\n },\n });\n },\n preload: (target) => {\n clearTimeout(preloadTimer);\n if (!target) return;\n preloadTimer = setTimeout(() => {\n const preloading = isSettingsTarget(target)\n ? anyRouter.preloadRoute({ to: settingsPath(target) })\n : router.preloadRoute({\n to: nodeRoute.fullPath,\n params: driveParams(target),\n });\n preloading.catch(() => undefined);\n }, PRELOAD_DELAY_MS);\n },\n setSearch,\n // The presented matches' params, else the location's.\n useSearchParams() {\n const search = useRouterState({\n router,\n select: (state) =>\n state.matches.at(-1)?.search ?? state.location.search,\n });\n return useMemo(() => definedSearch(search), [search]);\n },\n useSetSearchParams: () => setSearchParams,\n closeOpened: () => {\n const { state } = router.history.location;\n const from = openedFromIndex(state, state.__TSR_index);\n if (from === undefined) return false;\n router.history.go(from - state.__TSR_index);\n return true;\n },\n dispose: () => clearTimeout(preloadTimer),\n };\n}\n","import type { DriveArrivals, PHStore } from \"@powerhousedao/reactor-browser\";\nimport {\n getPHStoreSubscribe,\n isRoutedModal,\n modalFromSearch,\n} from \"@powerhousedao/reactor-browser\";\nimport type {\n AnyRoute,\n ErrorRouteComponent,\n NotFoundRouteComponent,\n RouteComponent,\n Router,\n RouterHistory,\n} from \"@tanstack/react-router\";\nimport { createRouter } from \"@tanstack/react-router\";\nimport type { ErrorInfo, PropsWithChildren, ReactElement } from \"react\";\nimport type { ConnectPluginUiSet } from \"../plugins/plugin-ui.js\";\nimport { applyConnectPluginUi } from \"../plugins/plugin-ui.js\";\nimport { markRouterNavigations } from \"./perf-marks.js\";\nimport { bindConnectScroll, connectScrollRestoration } from \"./scroll.js\";\nimport type { DriveRouteData } from \"./drive-route-loader.js\";\nimport type { ConnectRootRoute, ConnectRoutes } from \"./route-tree.js\";\nimport { createConnectNavigation } from \"./navigation.js\";\nimport { CoreError, CoreNotFound } from \"./core-views.js\";\nimport { CONTENT_VIEW_ID } from \"./route-components.js\";\nimport { addConnectRoutes, connectRoutes } from \"./route-tree.js\";\nimport { setSettingsRoute } from \"./settings.js\";\nimport { parseConnectSearch, stringifyConnectSearch } from \"./search.js\";\nimport { driveTitle } from \"./titles.js\";\n\nexport type ConnectRouterOptions = {\n store: PHStore;\n arrivals?: DriveArrivals;\n basepath?: string;\n history?: RouterHistory;\n InnerWrap?: (props: PropsWithChildren) => ReactElement;\n /** Shown while a route's loader or chunks are pending, after the router's `pendingMs`. */\n pendingComponent?: RouteComponent;\n /** Any route's loader or render error; the plugins', else core's error view. */\n errorComponent?: ErrorRouteComponent;\n /** The active plugins' UI, set on the routes that show core's views. */\n pluginUi?: ConnectPluginUiSet;\n /** Loaders' notFound(), e.g. a missing drive's; core's page by default. */\n notFoundComponent?: NotFoundRouteComponent;\n /** The tree to route with: `@powerhousedao/connect/route-tree`, core's or a project's. */\n routeTree: AnyRoute;\n /** Code routes added to the file routes; see `addConnectRoutes`. A function\n * receives the tree's core routes to attach to. */\n routes?:\n | readonly AnyRoute[]\n | ((routes: ConnectRoutes) => readonly AnyRoute[]);\n /** Reports a route's loader or render error; logged by default. */\n onCatch?: (error: unknown, info?: ErrorInfo) => void;\n /** Ends every document title; \"Connect\" without one. */\n appName?: string;\n /** Renders the loading shell: layouts show their pendingComponent, not their page. */\n shell?: boolean;\n};\n\nfunction reportRouteError(error: unknown, info?: ErrorInfo) {\n console.error(error, info?.componentStack ?? \"\");\n}\n\n/** The router over `TRouteTree`; a project's generated tree registers its own. */\nexport type ConnectRouterFor<TRouteTree extends AnyRoute> = Router<\n TRouteTree,\n \"never\",\n false,\n RouterHistory,\n Record<string, any>\n>;\n// Written out, not inferred; see ConnectRootRoute.\nexport type ConnectRouter = ConnectRouterFor<ConnectRootRoute>;\nexport type ConnectRouterBundle = Pick<\n ConnectRoutes,\n \"homeRoute\" | \"driveRoute\" | \"nodeRoute\" | \"settingsRoute\"\n> & { router: ConnectRouter };\n\nexport function createConnectRouter(\n options: ConnectRouterOptions,\n): ConnectRouterBundle {\n const { routeTree, homeRoute, driveRoute, nodeRoute, settingsRoute } =\n connectRoutes(options.routeTree);\n if (options.pluginUi) applyConnectPluginUi(routeTree, options.pluginUi);\n if (options.routes) {\n addConnectRoutes(\n typeof options.routes === \"function\"\n ? options.routes(connectRoutes(routeTree))\n : options.routes,\n );\n }\n setSettingsRoute(settingsRoute);\n const router = createRouter({\n routeTree,\n basepath: options.basepath,\n history: options.history,\n context: {\n store: options.store,\n arrivals: options.arrivals,\n appName: options.appName,\n shell: options.shell,\n },\n parseSearch: parseConnectSearch,\n stringifySearch: stringifyConnectSearch,\n scrollRestoration: connectScrollRestoration(),\n scrollToTopSelectors: [`#${CONTENT_VIEW_ID}`],\n InnerWrap: options.InnerWrap,\n defaultPendingComponent: options.pendingComponent,\n defaultErrorComponent:\n options.errorComponent ?? options.pluginUi?.errorComponent ?? CoreError,\n // Not per route: a route's notFoundComponent mounts a boundary that\n // re-renders on every navigation.\n defaultNotFoundComponent: options.notFoundComponent ?? CoreNotFound,\n defaultOnCatch: options.onCatch ?? reportRouteError,\n });\n return { router, homeRoute, driveRoute, nodeRoute, settingsRoute };\n}\n\nfunction writeSelection(store: PHStore, data: DriveRouteData | undefined) {\n // Drive first: a new drive resets the node.\n store.selectedDriveId = data?.driveId;\n store.selectedNodeId = data?.nodeId;\n}\n\n/** Makes `router` the store's navigation and writes the selection it commits. */\nexport function bindConnectRouter(\n connectRouter: ConnectRouterBundle,\n store: PHStore,\n) {\n const { router, nodeRoute } = connectRouter;\n\n // Only committed matches select; pending ones keep the open view.\n const commitSelection = () => {\n const matches = router.state.matches;\n const drive = matches.find((match) => match.routeId === nodeRoute.id);\n if (drive) {\n if (drive.status === \"success\" && drive.loaderData) {\n writeSelection(store, drive.loaderData);\n } else if (matches.some((match) => match.status === \"notFound\")) {\n // The drive's 404 page shows no drive.\n writeSelection(store, undefined);\n }\n return;\n }\n // Any other page (home, settings, a project's, a 404) shows no drive.\n const shown = matches.at(-1)?.status;\n if (shown === \"success\" || shown === \"notFound\") {\n writeSelection(store, undefined);\n }\n };\n\n // A routed modal is the URL's: the store holds what the location names,\n // unless a confirmation is open over it.\n const syncModal = () => {\n const routed = modalFromSearch(router.state.location.search);\n if (store.modal && !isRoutedModal(store.modal)) return;\n if (routed) {\n if (JSON.stringify(store.modal) !== JSON.stringify(routed)) {\n store.modal = routed;\n }\n } else if (isRoutedModal(store.modal)) {\n store.modal = undefined;\n }\n };\n\n // Set once, before the first render; selection setters navigate from the start.\n const navigation = createConnectNavigation(connectRouter);\n store.navigation = navigation;\n\n // The node route's head reads names from the store; a rename re-runs it.\n const shownTitle = () => {\n const node = router.state.matches.find((m) => m.routeId === nodeRoute.id);\n return driveTitle(store, node?.loaderData, router.options.context.appName);\n };\n let title = shownTitle();\n const retitle = () => {\n const next = shownTitle();\n if (next === title) return;\n title = next;\n void router.invalidate({ filter: (m) => m.routeId === nodeRoute.id });\n };\n\n // Before mount, so the view and scroll restoration see the new selection.\n const unsubscribes = [\n router.subscribe(\"onBeforeRouteMount\", commitSelection),\n router.subscribe(\"onResolved\", commitSelection),\n router.subscribe(\"onResolved\", () => {\n title = shownTitle();\n }),\n router.subscribe(\"onResolved\", syncModal),\n getPHStoreSubscribe(store, \"drives\")(retitle),\n getPHStoreSubscribe(store, \"driveNodes\")(retitle),\n markRouterNavigations(router),\n ];\n const unbindScroll = bindConnectScroll(router, CONTENT_VIEW_ID);\n commitSelection();\n syncModal();\n\n return () => {\n navigation.dispose();\n unbindScroll();\n for (const unsubscribe of unsubscribes) unsubscribe();\n if (store.navigation === navigation) store.navigation = undefined;\n };\n}\n","import type { PHStore } from \"@powerhousedao/reactor-browser\";\nimport { createDriveArrivals } from \"@powerhousedao/reactor-browser\";\nimport { getConnectPluginUi } from \"../plugins/plugin-ui.js\";\nimport { getConnectRegistry } from \"../registry.js\";\nimport type {\n ConnectRouterBundle,\n ConnectRouterOptions,\n} from \"./connect-router.js\";\nimport { bindConnectRouter, createConnectRouter } from \"./connect-router.js\";\nimport { resolveConnectRoutes } from \"./route-tree.js\";\n\nexport type ConnectAppRouterOptions = Omit<\n ConnectRouterOptions,\n \"store\" | \"arrivals\"\n>;\n\n/** The app's one router over `store`; created, and made the store's navigation,\n * on first use. Registered routes join `options.routes`. */\nexport function getConnectAppRouter(\n store: PHStore,\n options: () => ConnectAppRouterOptions,\n): ConnectRouterBundle {\n const registry = getConnectRegistry();\n const current = registry.app;\n if (current) {\n if (import.meta.env?.DEV && current.store !== store) {\n throw new Error(\"Connect's router is already bound to another PH store\");\n }\n return current.bundle;\n }\n const { routes, ...rest } = options();\n const bundle = createConnectRouter({\n store,\n arrivals: createDriveArrivals(store),\n pluginUi: getConnectPluginUi(),\n ...rest,\n routes: (tree) => [\n ...(routes ? resolveConnectRoutes(routes, tree.routeTree) : []),\n ...registry.routes.flatMap((entry) => {\n entry.added = [\n ...resolveConnectRoutes(entry.registration, tree.routeTree),\n ];\n return entry.added;\n }),\n ],\n });\n registry.app = { store, bundle, unbind: bindConnectRouter(bundle, store) };\n return bundle;\n}\n\n/** Stops the app's router writing the selection, e.g. on HMR. */\nexport function disposeConnectAppRouter() {\n const registry = getConnectRegistry();\n registry.app?.unbind();\n registry.app = undefined;\n}\n","import type { PHStore } from \"@powerhousedao/reactor-browser\";\nimport { PHStoreProvider } from \"@powerhousedao/reactor-browser\";\nimport type { AnyRoute } from \"@tanstack/react-router\";\nimport { RouterProvider } from \"@tanstack/react-router\";\nimport type { ConnectAppRouterOptions } from \"./app-router.js\";\nimport { getConnectAppRouter } from \"./app-router.js\";\n\n/** A core-only app: `routeTree`'s views over `store`. */\nexport function ConnectCoreApp(props: {\n store: PHStore;\n routeTree: AnyRoute;\n basepath?: string;\n options?: () => Omit<ConnectAppRouterOptions, \"routeTree\">;\n}) {\n const { router } = getConnectAppRouter(props.store, () => ({\n basepath: props.basepath,\n ...props.options?.(),\n routeTree: props.routeTree,\n }));\n return (\n <PHStoreProvider store={props.store}>\n <RouterProvider router={router} />\n </PHStoreProvider>\n );\n}\n","import type { AnyRoute } from \"@tanstack/react-router\";\n\ntype RouteOptionKey = keyof AnyRoute[\"options\"];\n\n/** A core route's `options`: what it sets, as it sets it, and every other\n * route option, unset. */\nexport type CoreRouteOptions<T extends object> = T & {\n [K in Exclude<RouteOptionKey, keyof T>]?: undefined;\n};\n\n/** Types a core route file's exported `options` as {@link CoreRouteOptions}. */\nexport function coreRouteOptions<T extends object>(\n options: T,\n): CoreRouteOptions<T> {\n return options as CoreRouteOptions<T>;\n}\n"],"mappings":";;;;;;;;;;AAGA,MAAa,mBAAmB;;AAGhC,MAAa,kBAAkB;;CAE7B,OAAO;;CAEP,QAAQ;;CAER,QAAQ;;CAER,OAAO;AACT;AAGA,MAAM,SAAS,EACb,UAAU;CAAE,UAAU;CAAe,OAAO;CAAU,YAAY;AAAU,EAC9E;AAEA,IAAI,UAAU;AACd,IAAI;;AAGJ,SAAgB,kBAAkB,MAAM,CAAC,CAAC,YAAY,KAAK,KAAK;CAC9D,IAAI,KAAK,OAAO;CAChB,IAAI;EACF,OACE,IAAI,gBAAgB,SAAS,MAAM,CAAC,CAAC,IAAI,MAAM,MAAM,OACrD,aAAa,QAAA,SAAwB,MAAM;CAE/C,QAAQ;EACN,OAAO;CACT;AACF;;AAGA,SAAgB,sBAAsB;CACpC,IAAI,CAAC,SAAS;CACd,YAAY,YAAY,IAAI;CAC5B,YAAY,KAAK,aAAa,EAAE,QAAQ,OAAO,CAAC;AAClD;AAEA,SAAS,QAAQ,MAAc,OAA2B,KAAa;CACrE,IAAI,UAAU,KAAA,GAAW;CACzB,YAAY,QAAQ,MAAM;EAAE;EAAO;EAAK,QAAQ;CAAO,CAAC;AAC1D;;AAGA,SAAgB,sBACd,QACA,UAAU,kBAAkB,GAC5B;CACA,IAAI,CAAC,SAAS,aAAa,CAAC;CAC5B;CACA,IAAI,aAAa;CACjB,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,MAAM,eAAe;EACnB,OAAO,UAAU,0BAA0B;GACzC;GACA,YAAY,YAAY,IAAI;GAC5B,UAAU;GACV,YAAY,KAAA;GACZ,QAAQ,gBAAgB,OAAO,SAAS,SAAS;GACjD,UAAU,SAAS,KAAA;EACrB,CAAC;E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AC5D;GACA,OAAO,MAAM;EACf,CAAC,CACH;CACF,CAAC;CACD,SAAS,MAAM;EAAE;EAAO;EAAQ,QAAQ,kBAAkB,QAAQ,KAAK;CAAE;CACzE,OAAO;AACT;;AAGA,SAAgB,0BAA0B;CACxC,MAAM,WAAW,mBAAmB;CACpC,SAAS,KAAK,OAAO;CACrB,SAAS,MAAM,KAAA;AACjB;;;;AC/CA,SAAgB,eAAe,OAK5B;CACD,MAAM,EAAE,WAAW,oBAAoB,MAAM,cAAc;EACzD,UAAU,MAAM;EAChB,GAAG,MAAM,UAAU;EACnB,WAAW,MAAM;CACnB,EAAE;CACF,OACE,oBAAC,iBAAD;EAAiB,OAAO,MAAM;EAC5B,UAAA,oBAAC,gBAAD,EAAwB,OAAS,CAAA;CAClB,CAAA;AAErB;;;;ACbA,SAAgB,iBACd,SACqB;CACrB,OAAO;AACT"}
|
package/dist/router.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as CoreNotFound, d as isCoreView, f as isDriveNotFound, l as coreModals, m as loadNode, p as loadDrive, s as CoreError, u as coreView } from "./plugin-ui-
|
|
1
|
+
import { c as CoreNotFound, d as isCoreView, f as isDriveNotFound, l as coreModals, m as loadNode, p as loadDrive, s as CoreError, u as coreView } from "./plugin-ui-DHlnXJmN.js";
|
|
2
2
|
import { a as connectRoutesSettled, c as registerPackageRoutes, f as CORE_MODAL_VIEWS, h as useModalFrame, i as connectRoutes, l as removeConnectRoutes, m as ModalDialog, n as HOME_ROUTE_ID, o as holdConnectRoutes, p as ModalOutlet, r as addConnectRoutes, s as registerConnectRoutes, t as APP_ROUTE_ID } from "./route-tree-D0aszMrk.js";
|
|
3
3
|
import { C as CONTENT_VIEW_ID, D as useIsColdStart, E as DrivePending, S as notFoundTitle, T as DRIVE_PENDING_MS, _ as showsSettingsTab, a as useCreateDocumentTarget, b as appTitle, c as useDriveRouteData, d as keepOpenedFrom, f as redirectToSettingsTab, g as settingsTitle, h as settingsTabsOf, i as useSidebarMode, l as useDriveRouteIds, m as settingsTabs, n as useConnectChrome, o as DRIVE_ROUTE_ID, p as setSettingsRoute, r as useNavRoutes, s as NODE_ROUTE_ID, t as navRoutes, u as SETTINGS_ROUTE_ID, v as useForgetSettingsOpenedFrom, w as ContentOutlet, x as driveTitle, y as useSettingsTabs } from "./sidebar-C2y4mZnX.js";
|
|
4
|
-
import { S as routerPerfEnabled, _ as connectScrollRestoration, a as bindConnectRouter, b as markNavigationClick, c as FEATURE_FLAG_PARAM_PREFIX, d as definedSearch, f as parseConnectSearch, g as bindConnectScroll, h as validateDriveSearch, i as getConnectAppRouter, l as GLOBAL_SEARCH_PARAMS, m as validateConnectSearch, n as ConnectCoreApp, o as createConnectRouter, p as stringifyConnectSearch, r as disposeConnectAppRouter, s as createConnectNavigation, t as coreRouteOptions, u as connectSearchMiddlewares, v as PERF_STORAGE_KEY, x as markRouterNavigations, y as ROUTER_MEASURES } from "./router-
|
|
4
|
+
import { S as routerPerfEnabled, _ as connectScrollRestoration, a as bindConnectRouter, b as markNavigationClick, c as FEATURE_FLAG_PARAM_PREFIX, d as definedSearch, f as parseConnectSearch, g as bindConnectScroll, h as validateDriveSearch, i as getConnectAppRouter, l as GLOBAL_SEARCH_PARAMS, m as validateConnectSearch, n as ConnectCoreApp, o as createConnectRouter, p as stringifyConnectSearch, r as disposeConnectAppRouter, s as createConnectNavigation, t as coreRouteOptions, u as connectSearchMiddlewares, v as PERF_STORAGE_KEY, x as markRouterNavigations, y as ROUTER_MEASURES } from "./router-C4hDJ4_J.js";
|
|
5
5
|
export { APP_ROUTE_ID, CONTENT_VIEW_ID, CORE_MODAL_VIEWS, ConnectCoreApp, ContentOutlet, CoreError, CoreNotFound, DRIVE_PENDING_MS, DRIVE_ROUTE_ID, DrivePending, FEATURE_FLAG_PARAM_PREFIX, GLOBAL_SEARCH_PARAMS, HOME_ROUTE_ID, ModalDialog, ModalOutlet, NODE_ROUTE_ID, PERF_STORAGE_KEY, ROUTER_MEASURES, SETTINGS_ROUTE_ID, addConnectRoutes, appTitle, bindConnectRouter, bindConnectScroll, connectRoutes, connectRoutesSettled, connectScrollRestoration, connectSearchMiddlewares, coreModals, coreRouteOptions, coreView, createConnectNavigation, createConnectRouter, definedSearch, disposeConnectAppRouter, driveTitle, getConnectAppRouter, holdConnectRoutes, isCoreView, isDriveNotFound, keepOpenedFrom, loadDrive, loadNode, markNavigationClick, markRouterNavigations, navRoutes, notFoundTitle, parseConnectSearch, redirectToSettingsTab, registerConnectRoutes, registerPackageRoutes, removeConnectRoutes, routerPerfEnabled, setSettingsRoute, settingsTabs, settingsTabsOf, settingsTitle, showsSettingsTab, stringifyConnectSearch, useConnectChrome, useCreateDocumentTarget, useDriveRouteData, useDriveRouteIds, useForgetSettingsOpenedFrom, useIsColdStart, useModalFrame, useNavRoutes, useSettingsTabs, useSidebarMode, validateConnectSearch, validateDriveSearch };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getRuntimeConfig } from "./runtime-config.js";
|
|
2
|
-
import { n as resolveRuntimeFlag, t as isRuntimeFlagEnabled } from "./runtime-flag-
|
|
3
|
-
import {
|
|
2
|
+
import { n as resolveRuntimeFlag, t as isRuntimeFlagEnabled } from "./runtime-flag-DvxW_SD4.js";
|
|
3
|
+
import { n as setDriveRelister } from "./backend-auth-gate-DNKg_v4Y.js";
|
|
4
|
+
import { bindPHStoreToWindow, createPHStore, getActivePHStore, getDrives, getFullReactorClient, getPHStore, recordBackendAuthError, setBackendAuth, setDrives, setFullReactorClient } from "@powerhousedao/reactor-browser";
|
|
4
5
|
import { logger } from "document-model";
|
|
5
6
|
//#region src/runtime/multi-reactor-flag.ts
|
|
6
7
|
function isMultiReactorEnabled() {
|
|
@@ -117,20 +118,57 @@ function requireModule(params) {
|
|
|
117
118
|
if (!params.module) throw new Error(`reactorClient mode "${params.mode}" needs a local reactor, but none was built`);
|
|
118
119
|
return params.module;
|
|
119
120
|
}
|
|
120
|
-
/**
|
|
121
|
+
/**
|
|
122
|
+
* A Switchboard that cannot answer must not fail boot: list the tab's drives.
|
|
123
|
+
*
|
|
124
|
+
* A Switchboard that REFUSES the caller (401/403) must not fail boot either:
|
|
125
|
+
* the refusal is recorded (`backendAuth`) so the root view shows the sign-in
|
|
126
|
+
* gate, and the drive list is empty until the user is someone the backend
|
|
127
|
+
* accepts. A remote-only client has no local drives to fall back on.
|
|
128
|
+
*/
|
|
121
129
|
async function getAppDrives(client, local) {
|
|
122
|
-
if (client === local)
|
|
130
|
+
if (client === local) try {
|
|
131
|
+
const drives = await getDrives(local);
|
|
132
|
+
setBackendAuth(void 0);
|
|
133
|
+
return drives;
|
|
134
|
+
} catch (error) {
|
|
135
|
+
if (recordBackendAuthError(error, "switchboard")) {
|
|
136
|
+
logger.warn("The Switchboard refused this caller; showing the sign-in gate: @error", error);
|
|
137
|
+
return [];
|
|
138
|
+
}
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
123
141
|
try {
|
|
124
|
-
|
|
142
|
+
const drives = await getDrives(client);
|
|
143
|
+
setBackendAuth(void 0);
|
|
144
|
+
return drives;
|
|
125
145
|
} catch (error) {
|
|
126
|
-
logger.warn("
|
|
146
|
+
if (recordBackendAuthError(error, "switchboard")) logger.warn("A remote backend refused this caller; listing the local reactor's drives: @error", error);
|
|
147
|
+
else logger.warn("Could not list drives through the router; listing the local reactor's: @error", error);
|
|
127
148
|
return getDrives(local);
|
|
128
149
|
}
|
|
129
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* The boot refresh of the drives store. It lists through `getAppDrives`
|
|
153
|
+
* whichever client is in use, so a Switchboard that refuses the caller is
|
|
154
|
+
* recorded for the sign-in gate here too: the remote-only client is its own
|
|
155
|
+
* `local`, and a bare `refreshReactorDataClient` would let the 401 escape
|
|
156
|
+
* and fail the boot before the gate can render.
|
|
157
|
+
*/
|
|
130
158
|
async function refreshAppDrives(client, local) {
|
|
131
|
-
if (client === local) return refreshReactorDataClient(client);
|
|
132
159
|
setDrives(await getAppDrives(client, local));
|
|
133
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Lists the drives again as the caller the tab now is, through the clients
|
|
163
|
+
* boot left in the store: after a sign-in landing or a sign-out that followed
|
|
164
|
+
* a backend's refusal. Nothing to do before boot has set a client.
|
|
165
|
+
*/
|
|
166
|
+
async function relistAppDrives() {
|
|
167
|
+
const client = getFullReactorClient();
|
|
168
|
+
if (!client) return;
|
|
169
|
+
await refreshAppDrives(client, getPHStore()?.reactorClientModule?.client ?? client);
|
|
170
|
+
}
|
|
171
|
+
setDriveRelister(relistAppDrives);
|
|
134
172
|
async function buildRouter(params) {
|
|
135
173
|
if (!params.remoteDriveUrl) {
|
|
136
174
|
logger.warn("multiReactor is on but no remote drive URL is configured; using the local reactor only");
|
|
@@ -196,6 +234,6 @@ function loadLocalPackage(source) {
|
|
|
196
234
|
return pkg;
|
|
197
235
|
}
|
|
198
236
|
//#endregion
|
|
199
|
-
export { planReactorClient as a,
|
|
237
|
+
export { planReactorClient as a, selectAppReactorClient as c, resolveReactorClientMode as d, REACTOR_WORKER_QUERY_KEY as f, isMultiReactorEnabled as g, resolveReactorWorkerEnabled as h, getAppDrives as i, REACTOR_CLIENT_QUERY_KEY as l, isReactorWorkerEnabled as m, getConnectPHStore as n, refreshAppDrives as o, REACTOR_WORKER_STORAGE_KEY as p, createAppReactorClient as r, relistAppDrives as s, loadLocalPackage as t, REACTOR_CLIENT_STORAGE_KEY as u };
|
|
200
238
|
|
|
201
|
-
//# sourceMappingURL=runtime-
|
|
239
|
+
//# sourceMappingURL=runtime-D20_LlB_.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-D20_LlB_.js","names":[],"sources":["../src/runtime/multi-reactor-flag.ts","../src/runtime/reactor-worker-flag.ts","../src/runtime/reactor-client-mode.ts","../src/runtime/app-reactor-client.ts","../src/runtime/ph-store.ts","../src/runtime/local-package.ts"],"sourcesContent":["import { getRuntimeConfig } from \"./runtime-config.js\";\n\n// Config only: the flag is in the worker fingerprint, so a per-tab value would split tabs.\nexport function isMultiReactorEnabled(): boolean {\n return getRuntimeConfig().connect.instance?.multiReactor ?? false;\n}\n","import { getRuntimeConfig } from \"./runtime-config.js\";\nimport {\n isRuntimeFlagEnabled,\n resolveRuntimeFlag,\n type RuntimeFlagInput,\n} from \"./runtime-flag.js\";\n\nexport const REACTOR_WORKER_QUERY_KEY = \"reactorWorker\";\nexport const REACTOR_WORKER_STORAGE_KEY = \"ph:reactorWorker\";\n\nexport type ReactorWorkerFlagInput = RuntimeFlagInput;\n\nexport function resolveReactorWorkerEnabled(\n input: ReactorWorkerFlagInput,\n): boolean {\n return resolveRuntimeFlag(input);\n}\n\nexport function isReactorWorkerEnabled(): boolean {\n return isRuntimeFlagEnabled({\n queryKey: REACTOR_WORKER_QUERY_KEY,\n storageKey: REACTOR_WORKER_STORAGE_KEY,\n readConfigFlag: () =>\n getRuntimeConfig().connect.instance?.reactorWorker ?? false,\n });\n}\n","import type { PHReactorClientMode } from \"@powerhousedao/shared/clis\";\nimport { getRuntimeConfig } from \"./runtime-config.js\";\nimport { isMultiReactorEnabled } from \"./multi-reactor-flag.js\";\nimport { isReactorWorkerEnabled } from \"./reactor-worker-flag.js\";\n\n/**\n * Which of the four reactor clients Connect boots. Standardized by the\n * multi-reactor work; this resolves the single selector Connect acts on:\n *\n * in-process | worker | remote | router\n *\n * Precedence: an explicit `?reactorClient=` query override (kept in\n * localStorage so it survives a reload), then a stored override, then the\n * served `connect.instance.reactorClient` (projected from the host's reactor\n * backends), then the LEGACY booleans — so a config that only sets\n * reactorWorker/multiReactor behaves exactly as before.\n *\n * `remote` is the only mode that builds NO local reactor (no PGlite): it is a\n * pure client to a remote Switchboard. `router` keeps the local reactor and\n * adds remote backends; `worker`/`in-process` are the local reactor alone.\n */\nexport type ReactorClientMode = PHReactorClientMode;\n\nconst MODES: ReadonlySet<string> = new Set([\n \"in-process\",\n \"worker\",\n \"remote\",\n \"router\",\n]);\n\nexport const REACTOR_CLIENT_QUERY_KEY = \"reactorClient\";\nexport const REACTOR_CLIENT_STORAGE_KEY = \"ph:reactorClient\";\n\nconst asMode = (value: string | null | undefined) =>\n value && MODES.has(value) ? (value as ReactorClientMode) : undefined;\n\nfunction fromTab(): ReactorClientMode | undefined {\n if (typeof window === \"undefined\") return undefined;\n let query: ReactorClientMode | undefined;\n try {\n query = asMode(\n new URLSearchParams(window.location.search).get(REACTOR_CLIENT_QUERY_KEY),\n );\n } catch {\n return undefined;\n }\n try {\n if (query) {\n window.localStorage.setItem(REACTOR_CLIENT_STORAGE_KEY, query);\n return query;\n }\n return asMode(window.localStorage.getItem(REACTOR_CLIENT_STORAGE_KEY));\n } catch {\n // Blocked storage: the query still applies for this page load.\n return query;\n }\n}\n\nexport function resolveReactorClientMode(): ReactorClientMode {\n const override = fromTab();\n if (override) return override;\n const configured = getRuntimeConfig().connect.instance?.reactorClient;\n if (configured && MODES.has(configured)) return configured;\n // Legacy fallback — unchanged behaviour for configs without reactorClient.\n if (isMultiReactorEnabled()) return \"router\";\n if (isReactorWorkerEnabled()) return \"worker\";\n return \"in-process\";\n}\n","import type { IReactorClient } from \"@powerhousedao/reactor\";\nimport {\n getDrives,\n getFullReactorClient,\n getPHStore,\n recordBackendAuthError,\n setBackendAuth,\n setDrives,\n setFullReactorClient,\n} from \"@powerhousedao/reactor-browser\";\nimport type { DocumentDriveDocument } from \"@powerhousedao/shared/document-drive\";\nimport type { ISigner } from \"@powerhousedao/shared/document-model\";\nimport { logger } from \"document-model\";\nimport type * as MultiReactor from \"./multi-reactor.js\";\nimport type {\n LoadedDocumentModels,\n LocalReactorModule,\n} from \"./multi-reactor.js\";\nimport type { ReactorClientMode } from \"./reactor-client-mode.js\";\nimport { resolveReactorClientMode } from \"./reactor-client-mode.js\";\nimport { isReactorWorkerEnabled } from \"./reactor-worker-flag.js\";\nimport { setDriveRelister } from \"./drive-relist.js\";\n\ntype MultiReactorModule = typeof MultiReactor;\n\nexport type AppReactorClientParams = {\n mode: ReactorClientMode;\n /** Built, and ready (the worker has started up). Undefined in `remote`\n * mode, where no local reactor is built. */\n module: LocalReactorModule | undefined;\n remoteDriveUrl: string | undefined;\n /** Signs routed writes; unsigned (anonymous) without one. */\n signer?: ISigner;\n documentModelModules: LoadedDocumentModels;\n loadRouter?: () => Promise<MultiReactorModule>;\n};\n\nconst loadMultiReactor = (): Promise<MultiReactorModule> =>\n import(\"./multi-reactor.js\");\n\n/** What a mode builds in the tab; `remote` builds no local reactor (no PGlite). */\nexport type ReactorClientPlan = {\n mode: ReactorClientMode;\n /** `router`: the local reactor plus remote backends. */\n multiReactor: boolean;\n needsLocalReactor: boolean;\n /** The local reactor runs in the shared worker. */\n localAsWorker: boolean;\n};\n\nexport function planReactorClient(\n mode: ReactorClientMode = resolveReactorClientMode(),\n): ReactorClientPlan {\n const needsLocalReactor = mode !== \"remote\";\n return {\n mode,\n multiReactor: mode === \"router\",\n needsLocalReactor,\n localAsWorker:\n needsLocalReactor &&\n (mode === \"worker\" || (mode === \"router\" && isReactorWorkerEnabled())),\n };\n}\n\n/** Builds the tab's reactor, e.g. Connect's PGlite or worker reactor. */\nexport type LocalReactorFactory = (\n plan: ReactorClientPlan,\n) => Promise<LocalReactorModule>;\n\nexport type CreateAppReactorClientOptions = Omit<\n AppReactorClientParams,\n \"mode\" | \"module\"\n> & {\n plan?: ReactorClientPlan;\n /** Called only when the plan needs a local reactor. */\n localReactor?: LocalReactorFactory;\n};\n\n/** Builds the local reactor the plan needs, then selects the app's client. */\nexport async function createAppReactorClient(\n options: CreateAppReactorClientOptions,\n) {\n const { localReactor, ...params } = options;\n const plan = options.plan ?? planReactorClient();\n let module: LocalReactorModule | undefined;\n if (plan.needsLocalReactor) {\n if (!localReactor) {\n throw new Error(\n `reactorClient mode \"${plan.mode}\" needs a local reactor; pass localReactor`,\n );\n }\n module = await localReactor(plan);\n }\n const client = await selectAppReactorClient({\n ...params,\n mode: plan.mode,\n module,\n });\n return { plan, module, client };\n}\n\n/**\n * Pick the client for the resolved mode:\n * - `in-process` / `worker`: the local client, router module never loaded.\n * - `router`: the local reactor plus remote backends.\n * - `remote`: a remote-only router — a full IReactorClient that proxies to\n * the Switchboard over GraphQL with NO local reactor (no PGlite).\n */\nexport async function selectAppReactorClient(\n params: AppReactorClientParams,\n): Promise<IReactorClient> {\n if (params.mode === \"remote\") {\n setFullReactorClient(undefined);\n const remote = await buildRemoteOnly(params);\n setFullReactorClient(remote);\n return remote;\n }\n if (params.mode !== \"router\") {\n if (getPHStore()?.fullReactorClient) {\n setFullReactorClient(undefined);\n }\n return requireModule(params).client;\n }\n setFullReactorClient(undefined);\n const routed = await buildRouter(params);\n setFullReactorClient(routed);\n return routed ?? requireModule(params).client;\n}\n\nfunction requireModule(params: AppReactorClientParams): LocalReactorModule {\n if (!params.module) {\n throw new Error(\n `reactorClient mode \"${params.mode}\" needs a local reactor, but none was built`,\n );\n }\n return params.module;\n}\n\n/**\n * A Switchboard that cannot answer must not fail boot: list the tab's drives.\n *\n * A Switchboard that REFUSES the caller (401/403) must not fail boot either:\n * the refusal is recorded (`backendAuth`) so the root view shows the sign-in\n * gate, and the drive list is empty until the user is someone the backend\n * accepts. A remote-only client has no local drives to fall back on.\n */\nexport async function getAppDrives(\n client: IReactorClient,\n local: IReactorClient,\n): Promise<DocumentDriveDocument[]> {\n if (client === local) {\n try {\n const drives = await getDrives(local);\n setBackendAuth(undefined);\n return drives;\n } catch (error) {\n if (recordBackendAuthError(error, \"switchboard\")) {\n logger.warn(\n \"The Switchboard refused this caller; showing the sign-in gate: @error\",\n error,\n );\n return [];\n }\n throw error;\n }\n }\n try {\n const drives = await getDrives(client);\n setBackendAuth(undefined);\n return drives;\n } catch (error) {\n if (recordBackendAuthError(error, \"switchboard\")) {\n logger.warn(\n \"A remote backend refused this caller; listing the local reactor's drives: @error\",\n error,\n );\n } else {\n logger.warn(\n \"Could not list drives through the router; listing the local reactor's: @error\",\n error,\n );\n }\n return getDrives(local);\n }\n}\n\n/**\n * The boot refresh of the drives store. It lists through `getAppDrives`\n * whichever client is in use, so a Switchboard that refuses the caller is\n * recorded for the sign-in gate here too: the remote-only client is its own\n * `local`, and a bare `refreshReactorDataClient` would let the 401 escape\n * and fail the boot before the gate can render.\n */\nexport async function refreshAppDrives(\n client: IReactorClient,\n local: IReactorClient,\n): Promise<void> {\n setDrives(await getAppDrives(client, local));\n}\n\n/**\n * Lists the drives again as the caller the tab now is, through the clients\n * boot left in the store: after a sign-in landing or a sign-out that followed\n * a backend's refusal. Nothing to do before boot has set a client.\n */\nexport async function relistAppDrives(): Promise<void> {\n const client = getFullReactorClient();\n if (!client) return;\n const local = getPHStore()?.reactorClientModule?.client ?? client;\n await refreshAppDrives(client, local);\n}\n\n// The backend auth gate relists through drive-relist (see there)\nsetDriveRelister(relistAppDrives);\n\nasync function buildRouter(\n params: AppReactorClientParams,\n): Promise<IReactorClient | undefined> {\n if (!params.remoteDriveUrl) {\n logger.warn(\n \"multiReactor is on but no remote drive URL is configured; using the local reactor only\",\n );\n return undefined;\n }\n let multiReactor: MultiReactorModule;\n try {\n multiReactor = await (params.loadRouter ?? loadMultiReactor)();\n } catch (error) {\n logger.error(\"Could not load the multi-reactor router: @error\", error);\n return undefined;\n }\n const remoteGraphqlUrl = multiReactor.deriveSwitchboardGraphqlUrl(\n params.remoteDriveUrl,\n );\n if (!remoteGraphqlUrl) {\n logger.warn(\n \"multiReactor is on but the remote drive URL @url does not parse; using the local reactor only\",\n params.remoteDriveUrl,\n );\n return undefined;\n }\n logger.info(\"Multi-reactor routing to @url\", remoteGraphqlUrl);\n return multiReactor.buildMultiReactorClient({\n module: requireModule(params),\n remoteGraphqlUrl,\n signer: params.signer,\n documentModelModules: params.documentModelModules,\n });\n}\n\n/**\n * The `remote` mode: a remote-only router — a full IReactorClient that proxies\n * to the Switchboard over GraphQL with NO local backend, so no local reactor\n * and no PGlite are ever built. A missing/unparseable remote URL is a hard\n * config error here (unlike `router`, there is no local reactor to fall back\n * to).\n */\nasync function buildRemoteOnly(\n params: AppReactorClientParams,\n): Promise<IReactorClient> {\n if (!params.remoteDriveUrl) {\n throw new Error(\n 'reactorClient \"remote\" needs a remote drive URL — declare a remote backend / default drive the client can proxy to',\n );\n }\n const multiReactor = await (params.loadRouter ?? loadMultiReactor)();\n const remoteGraphqlUrl = multiReactor.deriveSwitchboardGraphqlUrl(\n params.remoteDriveUrl,\n );\n if (!remoteGraphqlUrl) {\n throw new Error(\n `reactorClient \"remote\": the remote drive URL \"${params.remoteDriveUrl}\" does not resolve to a Switchboard GraphQL endpoint`,\n );\n }\n logger.info(\"Remote reactor client → @url\", remoteGraphqlUrl);\n return multiReactor.buildMultiReactorClient({\n module: undefined,\n remoteGraphqlUrl,\n signer: params.signer,\n documentModelModules: params.documentModelModules,\n });\n}\n","import type { PHStore } from \"@powerhousedao/reactor-browser\";\nimport {\n bindPHStoreToWindow,\n createPHStore,\n getActivePHStore,\n} from \"@powerhousedao/reactor-browser\";\n\n/** The app's PH store: the active one, else a new one bound to `window.ph`.\n * Values set on `window.ph` before carry over. */\nexport function getConnectPHStore(): PHStore {\n const active = getActivePHStore();\n if (active) return active;\n const store = createPHStore();\n bindPHStoreToWindow(store);\n return store;\n}\n","import type { DocumentModelLib } from \"document-model\";\n\n/** A module namespace, as `import * as pkg` or Vite HMR hands it over. */\nexport type ModuleNamespace = Record<string, any> & {\n [Symbol.toStringTag]: \"Module\";\n};\n\nexport type LocalPackage = DocumentModelLib<any> | ModuleNamespace;\n\n/** The package itself, or a loader (`() => import(\"./index.js\")`) that keeps it off the boot path. */\nexport type LocalPackageSource = LocalPackage | (() => Promise<LocalPackage>);\n\n/** Starts loading the project's package; a loader runs once, here. */\nexport function loadLocalPackage(\n source: LocalPackageSource | undefined,\n): DocumentModelLib | Promise<DocumentModelLib> | undefined {\n const pkg = (typeof source === \"function\" ? source() : source) as\n | DocumentModelLib\n | Promise<DocumentModelLib>\n | undefined;\n // Consumers await it; this only stops an early rejection being reported as unhandled.\n if (pkg instanceof Promise) pkg.catch(() => undefined);\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R,iDAAiD,OAAO,eAAe,qDACzE;CAEF,OAAO,KAAK,gCAAgC,gBAAgB;CAC5D,OAAO,aAAa,wBAAwB;EAC1C,QAAQ,KAAA;EACR;EACA,QAAQ,OAAO;EACf,sBAAsB,OAAO;CAC/B,CAAC;AACH;;;;;AChRA,SAAgB,oBAA6B;CAC3C,MAAM,SAAS,iBAAiB;CAChC,IAAI,QAAQ,OAAO;CACnB,MAAM,QAAQ,cAAc;CAC5B,oBAAoB,KAAK;CACzB,OAAO;AACT;;;;ACFA,SAAgB,iBACd,QAC0D;CAC1D,MAAM,MAAO,OAAO,WAAW,aAAa,OAAO,IAAI;CAKvD,IAAI,eAAe,SAAS,IAAI,YAAY,KAAA,CAAS;CACrD,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-config-D3YPhYyj.d.ts","names":[],"sources":["../src/runtime/runtime-config.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"runtime-config-D3YPhYyj.d.ts","names":[],"sources":["../src/runtime/runtime-config.ts"],"mappings":";;;KAiBY;;;EAGV,gBAAgB,QAAQ,eAAe;;iBAGnB,kBACpB,UAAS,2BACR,QAAQ;;;;;iBA2DK,oBAAoB;;iBAKpB,mBAAmB,QAAQ"}
|
package/dist/runtime-config.js
CHANGED
|
@@ -1,26 +1,32 @@
|
|
|
1
1
|
import { t as getConnectRegistry } from "./registry-DCZHBP7M.js";
|
|
2
2
|
import { ConfigLoader } from "@powerhousedao/shared/connect/config-loader";
|
|
3
3
|
import { JsonConfigAdapter } from "@powerhousedao/shared/connect/json-adapter";
|
|
4
|
+
import { resolveOriginPlaceholders } from "@powerhousedao/shared/connect/origin-placeholder";
|
|
4
5
|
//#region src/runtime/runtime-config.ts
|
|
5
6
|
const loader = () => getConnectRegistry().runtimeConfig ??= new ConfigLoader(new JsonConfigAdapter({ path: `${import.meta.env?.BASE_URL ?? "/"}powerhouse.config.json` }));
|
|
6
7
|
async function loadRuntimeConfig(options = {}) {
|
|
7
|
-
const pluginHost = options.plugins ? import("./plugin-host-
|
|
8
|
+
const pluginHost = options.plugins ? import("./plugin-host-CMr7lN40.js").then((n) => n.r).then(async (host) => {
|
|
8
9
|
host.registerConnectPlugins(options.plugins);
|
|
9
10
|
await host.knownPlugins();
|
|
10
11
|
return host;
|
|
11
12
|
}) : void 0;
|
|
12
|
-
const pluginUi = options.plugins ? import("./plugin-ui-
|
|
13
|
+
const pluginUi = options.plugins ? import("./plugin-ui-DHlnXJmN.js").then((n) => n.a) : void 0;
|
|
13
14
|
pluginHost?.catch(() => void 0);
|
|
14
15
|
pluginUi?.catch(() => void 0);
|
|
15
|
-
|
|
16
|
+
let config = await loader().read();
|
|
17
|
+
const origin = globalThis.location?.origin;
|
|
18
|
+
if (origin) {
|
|
19
|
+
config = resolveOriginPlaceholders(config, origin);
|
|
20
|
+
loader().prime(config);
|
|
21
|
+
}
|
|
16
22
|
if (config.connect?.composition) {
|
|
17
|
-
const { isRuntimeFlagEnabled } = await import("./runtime-flag-
|
|
23
|
+
const { isRuntimeFlagEnabled } = await import("./runtime-flag-DvxW_SD4.js").then((n) => n.r);
|
|
18
24
|
if (isRuntimeFlagEnabled({
|
|
19
25
|
queryKey: "pluginRunner",
|
|
20
26
|
storageKey: "ph:flag:pluginRunner",
|
|
21
27
|
readConfigFlag: () => true
|
|
22
28
|
})) {
|
|
23
|
-
const { applyComposition } = await pluginHost ?? await import("./plugin-host-
|
|
29
|
+
const { applyComposition } = await pluginHost ?? await import("./plugin-host-CMr7lN40.js").then((n) => n.r);
|
|
24
30
|
config.connect = await applyComposition(config.connect);
|
|
25
31
|
loader().prime(config);
|
|
26
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-config.js","names":[],"sources":["../src/runtime/runtime-config.ts"],"sourcesContent":["// Narrow subpaths: the shared/connect barrel puts zod and semver on the boot path.\nimport type { RuntimePowerhouseConfig } from \"@powerhousedao/shared/connect\";\nimport { ConfigLoader } from \"@powerhousedao/shared/connect/config-loader\";\nimport { JsonConfigAdapter } from \"@powerhousedao/shared/connect/json-adapter\";\nimport type { ConnectPluginDefinition } from \"../plugins/types.js\";\nimport { getConnectRegistry } from \"../registry.js\";\n\n// Shared and made on first use: the app's boot copy makes it, with the app's base.\nconst loader = () =>\n (getConnectRegistry().runtimeConfig ??= new ConfigLoader(\n new JsonConfigAdapter({\n // Optional: Node runs this file untransformed when it prerenders the shell.\n path: `${import.meta.env?.BASE_URL ?? \"/\"}powerhouse.config.json`,\n }),\n ));\n\nexport type LoadRuntimeConfigOptions = {\n /** The host's plugin modules: the composition's transform the config, and\n * the active ones' UI loads (every one's without a composition). */\n plugins?: () => Promise<Record<string, ConnectPluginDefinition>>;\n};\n\nexport async function loadRuntimeConfig(\n options: LoadRuntimeConfigOptions = {},\n): Promise<RuntimePowerhouseConfig> {\n // Beside the config's fetch: the plugin modules and the UI loader don't\n // depend on it; only which plugins' UI loads does.\n const pluginHost = options.plugins\n ? import(\"../plugins/plugin-host.js\").then(async (host) => {\n host.registerConnectPlugins(options.plugins!);\n await host.knownPlugins();\n return host;\n })\n : undefined;\n const pluginUi = options.plugins\n ? import(\"../plugins/plugin-ui.js\")\n : undefined;\n // Handled here so a failed config read doesn't leave them unhandled.\n void pluginHost?.catch(() => undefined);\n void pluginUi?.catch(() => undefined);\n
|
|
1
|
+
{"version":3,"file":"runtime-config.js","names":[],"sources":["../src/runtime/runtime-config.ts"],"sourcesContent":["// Narrow subpaths: the shared/connect barrel puts zod and semver on the boot path.\nimport type { RuntimePowerhouseConfig } from \"@powerhousedao/shared/connect\";\nimport { ConfigLoader } from \"@powerhousedao/shared/connect/config-loader\";\nimport { JsonConfigAdapter } from \"@powerhousedao/shared/connect/json-adapter\";\nimport { resolveOriginPlaceholders } from \"@powerhousedao/shared/connect/origin-placeholder\";\nimport type { ConnectPluginDefinition } from \"../plugins/types.js\";\nimport { getConnectRegistry } from \"../registry.js\";\n\n// Shared and made on first use: the app's boot copy makes it, with the app's base.\nconst loader = () =>\n (getConnectRegistry().runtimeConfig ??= new ConfigLoader(\n new JsonConfigAdapter({\n // Optional: Node runs this file untransformed when it prerenders the shell.\n path: `${import.meta.env?.BASE_URL ?? \"/\"}powerhouse.config.json`,\n }),\n ));\n\nexport type LoadRuntimeConfigOptions = {\n /** The host's plugin modules: the composition's transform the config, and\n * the active ones' UI loads (every one's without a composition). */\n plugins?: () => Promise<Record<string, ConnectPluginDefinition>>;\n};\n\nexport async function loadRuntimeConfig(\n options: LoadRuntimeConfigOptions = {},\n): Promise<RuntimePowerhouseConfig> {\n // Beside the config's fetch: the plugin modules and the UI loader don't\n // depend on it; only which plugins' UI loads does.\n const pluginHost = options.plugins\n ? import(\"../plugins/plugin-host.js\").then(async (host) => {\n host.registerConnectPlugins(options.plugins!);\n await host.knownPlugins();\n return host;\n })\n : undefined;\n const pluginUi = options.plugins\n ? import(\"../plugins/plugin-ui.js\")\n : undefined;\n // Handled here so a failed config read doesn't leave them unhandled.\n void pluginHost?.catch(() => undefined);\n void pluginUi?.catch(() => undefined);\n let config = (await loader().read()) as RuntimePowerhouseConfig;\n // A served config names a switchboard this page's server proxies as\n // `${origin}` (the connect runner's `runner.proxy`): resolved here, once,\n // against the page's origin, so every consumer sees absolute URLs and the\n // same config holds from localhost and from a published site alike. Not\n // in Node (the shell prerender): there is no page origin to resolve to.\n const origin = globalThis.location?.origin;\n if (origin) {\n config = resolveOriginPlaceholders(config, origin);\n loader().prime(config);\n }\n // R3: a served composition (projected from host.js runner.plugins by the\n // uniform-runners connect runner) runs the plugin pipeline over the config\n // BEFORE the cache warms — every downstream consumer sees the transformed\n // config through the classic paths. Runtime-flagged (query/stored override\n // beats the composition's own presence acting as the config flag); no\n // composition = classic boot, byte-identical.\n if (config.connect?.composition) {\n const { isRuntimeFlagEnabled } = await import(\"./runtime-flag.js\");\n const enabled = isRuntimeFlagEnabled({\n queryKey: \"pluginRunner\",\n storageKey: \"ph:flag:pluginRunner\",\n readConfigFlag: () => true,\n });\n if (enabled) {\n const { applyComposition } =\n (await pluginHost) ?? (await import(\"../plugins/plugin-host.js\"));\n config.connect = await applyComposition(config.connect);\n loader().prime(config);\n }\n }\n if (pluginHost && pluginUi) {\n await pluginHost;\n const { loadConnectPluginUi } = await pluginUi;\n await loadConnectPluginUi(config.connect.composition);\n }\n return config;\n}\n\n/**\n * Returns the cached config synchronously.\n * Must be called after `loadRuntimeConfig()` has resolved.\n */\nexport function getRuntimeConfig(): RuntimePowerhouseConfig {\n return loader().getCached() as RuntimePowerhouseConfig;\n}\n\n/** Warms the cache with `config` without a fetch, e.g. in a test or an embedding app. */\nexport function primeRuntimeConfig(config: RuntimePowerhouseConfig) {\n loader().prime(config);\n}\n"],"mappings":";;;;;AASA,MAAM,eACH,mBAAmB,CAAC,CAAC,kBAAkB,IAAI,aAC1C,IAAI,kBAAkB,EAEpB,MAAM,GAAG,YAAY,KAAK,YAAY,IAAI,wBAC5C,CAAC,CACH;AAQF,eAAsB,kBACpB,UAAoC,CAAC,GACH;CAGlC,MAAM,aAAa,QAAQ,UACvB,OAAO,4BAA4B,CAAA,MAAA,MAAA,EAAA,CAAA,CAAA,CAAC,KAAK,OAAO,SAAS;EACvD,KAAK,uBAAuB,QAAQ,OAAQ;EAC5C,MAAM,KAAK,aAAa;EACxB,OAAO;CACT,CAAC,IACD,KAAA;CACJ,MAAM,WAAW,QAAQ,UACrB,OAAO,0BAA0B,CAAA,MAAA,MAAA,EAAA,CAAA,IACjC,KAAA;CAEJ,YAAiB,YAAY,KAAA,CAAS;CACtC,UAAe,YAAY,KAAA,CAAS;CACpC,IAAI,SAAU,MAAM,OAAO,CAAC,CAAC,KAAK;CAMlC,MAAM,SAAS,WAAW,UAAU;CACpC,IAAI,QAAQ;EACV,SAAS,0BAA0B,QAAQ,MAAM;EACjD,OAAO,CAAC,CAAC,MAAM,MAAM;CACvB;CAOA,IAAI,OAAO,SAAS,aAAa;EAC/B,MAAM,EAAE,yBAAyB,MAAM,OAAO,6BAAoB,CAAA,MAAA,MAAA,EAAA,CAAA;EAMlE,IALgB,qBAAqB;GACnC,UAAU;GACV,YAAY;GACZ,sBAAsB;EACxB,CACU,GAAG;GACX,MAAM,EAAE,qBACL,MAAM,cAAgB,MAAM,OAAO,4BAA4B,CAAA,MAAA,MAAA,EAAA,CAAA;GAClE,OAAO,UAAU,MAAM,iBAAiB,OAAO,OAAO;GACtD,OAAO,CAAC,CAAC,MAAM,MAAM;EACvB;CACF;CACA,IAAI,cAAc,UAAU;EAC1B,MAAM;EACN,MAAM,EAAE,wBAAwB,MAAM;EACtC,MAAM,oBAAoB,OAAO,QAAQ,WAAW;CACtD;CACA,OAAO;AACT;;;;;AAMA,SAAgB,mBAA4C;CAC1D,OAAO,OAAO,CAAC,CAAC,UAAU;AAC5B;;AAGA,SAAgB,mBAAmB,QAAiC;CAClE,OAAO,CAAC,CAAC,MAAM,MAAM;AACvB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { k as __exportAll } from "./views-BtUVboYl.js";
|
|
2
2
|
//#region src/runtime/runtime-flag.ts
|
|
3
3
|
var runtime_flag_exports = /* @__PURE__ */ __exportAll({
|
|
4
4
|
isRuntimeFlagEnabled: () => isRuntimeFlagEnabled,
|
|
@@ -44,4 +44,4 @@ function parseFlag(value) {
|
|
|
44
44
|
//#endregion
|
|
45
45
|
export { resolveRuntimeFlag as n, runtime_flag_exports as r, isRuntimeFlagEnabled as t };
|
|
46
46
|
|
|
47
|
-
//# sourceMappingURL=runtime-flag-
|
|
47
|
+
//# sourceMappingURL=runtime-flag-DvxW_SD4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-flag-
|
|
1
|
+
{"version":3,"file":"runtime-flag-DvxW_SD4.js","names":[],"sources":["../src/runtime/runtime-flag.ts"],"sourcesContent":["export type RuntimeFlagInput = {\n configFlag: boolean;\n queryParam?: string | null;\n storedValue?: string | null;\n};\n\n// A query-param override wins, then a stored dev override, then the config flag.\nexport function resolveRuntimeFlag(input: RuntimeFlagInput): boolean {\n const fromQuery = parseFlag(input.queryParam);\n if (fromQuery !== undefined) {\n return fromQuery;\n }\n const fromStore = parseFlag(input.storedValue);\n if (fromStore !== undefined) {\n return fromStore;\n }\n return input.configFlag;\n}\n\nexport type RuntimeFlagKeys = {\n queryKey: string;\n storageKey: string;\n readConfigFlag: () => boolean;\n};\n\n// Effective flag from config + dev override; a query-param override is persisted\n// to localStorage so it survives a refresh. Blocked storage reads as no override.\nexport function isRuntimeFlagEnabled(keys: RuntimeFlagKeys): boolean {\n const configFlag = keys.readConfigFlag();\n if (typeof window === \"undefined\") {\n return configFlag;\n }\n const queryParam = new URLSearchParams(window.location.search).get(\n keys.queryKey,\n );\n const storedValue = readStoredValue(keys.storageKey);\n const enabled = resolveRuntimeFlag({ configFlag, queryParam, storedValue });\n // Persist only an explicit override, not an unrecognized value.\n if (parseFlag(queryParam) !== undefined) {\n persistStoredValue(keys.storageKey, enabled);\n }\n return enabled;\n}\n\nfunction readStoredValue(storageKey: string): string | null {\n try {\n return window.localStorage.getItem(storageKey);\n } catch {\n return null;\n }\n}\n\nfunction persistStoredValue(storageKey: string, enabled: boolean): void {\n try {\n window.localStorage.setItem(storageKey, enabled ? \"true\" : \"false\");\n } catch {\n // The override still applies for this page load.\n }\n}\n\nfunction parseFlag(value: string | null | undefined): boolean | undefined {\n if (value === null || value === undefined) {\n return undefined;\n }\n const normalized = value.trim().toLowerCase();\n if (normalized === \"true\" || normalized === \"1\") {\n return true;\n }\n if (normalized === \"false\" || normalized === \"0\") {\n return false;\n }\n // Unrecognized value (e.g. a typo): no override, fall through to store/config.\n return undefined;\n}\n"],"mappings":";;;;;;AAOA,SAAgB,mBAAmB,OAAkC;CACnE,MAAM,YAAY,UAAU,MAAM,UAAU;CAC5C,IAAI,cAAc,KAAA,GAChB,OAAO;CAET,MAAM,YAAY,UAAU,MAAM,WAAW;CAC7C,IAAI,cAAc,KAAA,GAChB,OAAO;CAET,OAAO,MAAM;AACf;AAUA,SAAgB,qBAAqB,MAAgC;CACnE,MAAM,aAAa,KAAK,eAAe;CACvC,IAAI,OAAO,WAAW,aACpB,OAAO;CAET,MAAM,aAAa,IAAI,gBAAgB,OAAO,SAAS,MAAM,CAAC,CAAC,IAC7D,KAAK,QACP;CAEA,MAAM,UAAU,mBAAmB;EAAE;EAAY;EAAY,aADzC,gBAAgB,KAAK,UAC8B;CAAE,CAAC;CAE1E,IAAI,UAAU,UAAU,MAAM,KAAA,GAC5B,mBAAmB,KAAK,YAAY,OAAO;CAE7C,OAAO;AACT;AAEA,SAAS,gBAAgB,YAAmC;CAC1D,IAAI;EACF,OAAO,OAAO,aAAa,QAAQ,UAAU;CAC/C,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,mBAAmB,YAAoB,SAAwB;CACtE,IAAI;EACF,OAAO,aAAa,QAAQ,YAAY,UAAU,SAAS,OAAO;CACpE,QAAQ,CAER;AACF;AAEA,SAAS,UAAU,OAAuD;CACxE,IAAI,UAAU,QAAQ,UAAU,KAAA,GAC9B;CAEF,MAAM,aAAa,MAAM,KAAK,CAAC,CAAC,YAAY;CAC5C,IAAI,eAAe,UAAU,eAAe,KAC1C,OAAO;CAET,IAAI,eAAe,WAAW,eAAe,KAC3C,OAAO;AAIX"}
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as isRuntimeFlagEnabled, C as REACTOR_WORKER_STORAGE_KEY, D as isMultiReactorEnabled, E as resolveReactorWorkerEnabled, O as RuntimeFlagInput, S as REACTOR_WORKER_QUERY_KEY, T as isReactorWorkerEnabled, _ as LocalReactorModule, a as getConnectPHStore, b as ReactorClientMode, c as LocalReactorFactory, d as getAppDrives, f as planReactorClient, g as LoadedDocumentModels, h as selectAppReactorClient, i as loadLocalPackage, j as resolveRuntimeFlag, k as RuntimeFlagKeys, l as ReactorClientPlan, m as relistAppDrives, n as LocalPackageSource, o as AppReactorClientParams, p as refreshAppDrives, r as ModuleNamespace, s as CreateAppReactorClientOptions, t as LocalPackage, u as createAppReactorClient, v as REACTOR_CLIENT_QUERY_KEY, w as ReactorWorkerFlagInput, x as resolveReactorClientMode, y as REACTOR_CLIENT_STORAGE_KEY } from "./index-BMlma368.js";
|
|
2
2
|
import { i as primeRuntimeConfig, n as getRuntimeConfig, r as loadRuntimeConfig } from "./runtime-config-D3YPhYyj.js";
|
|
3
|
+
import { n as useBackendAuthGate, t as BackendAuthGateMode } from "./backend-auth-gate-DiFpY5rt.js";
|
|
3
4
|
import { n as useIsEmbedded, t as getIsEmbedded } from "./embedded-DT1C47F0.js";
|
|
4
|
-
export { type AppReactorClientParams, type CreateAppReactorClientOptions, type LoadedDocumentModels, type LocalPackage, type LocalPackageSource, type LocalReactorFactory, type LocalReactorModule, type ModuleNamespace, REACTOR_CLIENT_QUERY_KEY, REACTOR_CLIENT_STORAGE_KEY, REACTOR_WORKER_QUERY_KEY, REACTOR_WORKER_STORAGE_KEY, type ReactorClientMode, type ReactorClientPlan, type ReactorWorkerFlagInput, type RuntimeFlagInput, type RuntimeFlagKeys, createAppReactorClient, getAppDrives, getConnectPHStore, getIsEmbedded, getRuntimeConfig, isMultiReactorEnabled, isReactorWorkerEnabled, isRuntimeFlagEnabled, loadLocalPackage, loadRuntimeConfig, planReactorClient, primeRuntimeConfig, refreshAppDrives, resolveReactorClientMode, resolveReactorWorkerEnabled, resolveRuntimeFlag, selectAppReactorClient, useIsEmbedded };
|
|
5
|
+
export { type AppReactorClientParams, type BackendAuthGateMode, type CreateAppReactorClientOptions, type LoadedDocumentModels, type LocalPackage, type LocalPackageSource, type LocalReactorFactory, type LocalReactorModule, type ModuleNamespace, REACTOR_CLIENT_QUERY_KEY, REACTOR_CLIENT_STORAGE_KEY, REACTOR_WORKER_QUERY_KEY, REACTOR_WORKER_STORAGE_KEY, type ReactorClientMode, type ReactorClientPlan, type ReactorWorkerFlagInput, type RuntimeFlagInput, type RuntimeFlagKeys, createAppReactorClient, getAppDrives, getConnectPHStore, getIsEmbedded, getRuntimeConfig, isMultiReactorEnabled, isReactorWorkerEnabled, isRuntimeFlagEnabled, loadLocalPackage, loadRuntimeConfig, planReactorClient, primeRuntimeConfig, refreshAppDrives, relistAppDrives, resolveReactorClientMode, resolveReactorWorkerEnabled, resolveRuntimeFlag, selectAppReactorClient, useBackendAuthGate, useIsEmbedded };
|
|
5
6
|
export {};
|
package/dist/runtime.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getIsEmbedded, useIsEmbedded } from "./embedded.js";
|
|
2
2
|
import { getRuntimeConfig, loadRuntimeConfig, primeRuntimeConfig } from "./runtime-config.js";
|
|
3
|
-
import { n as resolveRuntimeFlag, t as isRuntimeFlagEnabled } from "./runtime-flag-
|
|
4
|
-
import { a as planReactorClient, c as
|
|
5
|
-
|
|
3
|
+
import { n as resolveRuntimeFlag, t as isRuntimeFlagEnabled } from "./runtime-flag-DvxW_SD4.js";
|
|
4
|
+
import { a as planReactorClient, c as selectAppReactorClient, d as resolveReactorClientMode, f as REACTOR_WORKER_QUERY_KEY, g as isMultiReactorEnabled, h as resolveReactorWorkerEnabled, i as getAppDrives, l as REACTOR_CLIENT_QUERY_KEY, m as isReactorWorkerEnabled, n as getConnectPHStore, o as refreshAppDrives, p as REACTOR_WORKER_STORAGE_KEY, r as createAppReactorClient, s as relistAppDrives, t as loadLocalPackage, u as REACTOR_CLIENT_STORAGE_KEY } from "./runtime-D20_LlB_.js";
|
|
5
|
+
import { t as useBackendAuthGate } from "./backend-auth-gate-DNKg_v4Y.js";
|
|
6
|
+
export { REACTOR_CLIENT_QUERY_KEY, REACTOR_CLIENT_STORAGE_KEY, REACTOR_WORKER_QUERY_KEY, REACTOR_WORKER_STORAGE_KEY, createAppReactorClient, getAppDrives, getConnectPHStore, getIsEmbedded, getRuntimeConfig, isMultiReactorEnabled, isReactorWorkerEnabled, isRuntimeFlagEnabled, loadLocalPackage, loadRuntimeConfig, planReactorClient, primeRuntimeConfig, refreshAppDrives, relistAppDrives, resolveReactorClientMode, resolveReactorWorkerEnabled, resolveRuntimeFlag, selectAppReactorClient, useBackendAuthGate, useIsEmbedded };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { f as CORE_MODAL_VIEWS, h as useModalFrame, m as ModalDialog, p as ModalOutlet } from "./route-tree-D0aszMrk.js";
|
|
2
2
|
import { a as useCreateDocumentTarget, b as appTitle, c as useDriveRouteData, i as useSidebarMode, r as useNavRoutes, w as ContentOutlet, y as useSettingsTabs } from "./sidebar-C2y4mZnX.js";
|
|
3
3
|
import { useIsEmbedded } from "./embedded.js";
|
|
4
|
-
import {
|
|
4
|
+
import { t as useBackendAuthGate } from "./backend-auth-gate-DNKg_v4Y.js";
|
|
5
|
+
import { DRIVE_DOCUMENT_TYPES, DriveProvider, EditorDocumentProvider, addDocument, closePHModal, deleteNode, exportFile, getDocumentUpgradePreview, getDriveName, getNodeTarget, hideRevisionHistory, initTheme, logout, makeDriveSlug, makeNodeSlug, openRenown, openTarget, preloadDrive, setRevisionHistoryPage, setSelectedNode, showPHModal, upgradeDocument, useAppModuleById, useBackendAuth, useDispatch, useDocument, useDocumentById, useDocumentModelModuleById, useDriveNodes, useDrives, useEditorModuleFor, useLinkProps, useModelRegistry, useNodeById, useNodeParentFolderById, usePHModal, usePHNavigation, useReactorClient, useRenownAuth, useRenownLoginMethods, useRevisionHistoryPage, useRevisionHistoryVisible, useTheme, useUser, useVetraPackageManager, useVetraPackages, validateDocument } from "@powerhousedao/reactor-browser";
|
|
5
6
|
import { HeadContent, Link, Outlet, useRouter, useRouterState } from "@tanstack/react-router";
|
|
6
7
|
import { Component, Fragment, Suspense, createElement, useEffect, useId, useMemo, useState } from "react";
|
|
7
8
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -618,6 +619,75 @@ function DriveIndex() {
|
|
|
618
619
|
});
|
|
619
620
|
}
|
|
620
621
|
//#endregion
|
|
622
|
+
//#region src/views/backend-auth-gate.tsx
|
|
623
|
+
/**
|
|
624
|
+
* Full-page gate rendered by the root view in place of the routes when the
|
|
625
|
+
* backend refused the caller. Signing in goes through Renown's redirect, so
|
|
626
|
+
* the page comes back with the user and boots again as them.
|
|
627
|
+
*/
|
|
628
|
+
function BackendAuthGate({ mode }) {
|
|
629
|
+
const user = useUser();
|
|
630
|
+
const refusal = useBackendAuth();
|
|
631
|
+
const where = refusal?.backend ? ` (${refusal.backend})` : "";
|
|
632
|
+
return /* @__PURE__ */ jsx("div", {
|
|
633
|
+
role: "dialog",
|
|
634
|
+
"aria-labelledby": "backend-auth-gate-title",
|
|
635
|
+
className: "flex h-full min-h-[60vh] items-center justify-center p-6",
|
|
636
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
637
|
+
className: "flex w-full max-w-md flex-col gap-4 rounded-lg border border-core-border bg-core-bg p-6 text-core-fg",
|
|
638
|
+
children: mode === "login" ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
639
|
+
/* @__PURE__ */ jsx("h1", {
|
|
640
|
+
id: "backend-auth-gate-title",
|
|
641
|
+
className: "text-lg font-semibold",
|
|
642
|
+
children: "Sign in to continue"
|
|
643
|
+
}),
|
|
644
|
+
/* @__PURE__ */ jsxs("p", {
|
|
645
|
+
className: "text-sm text-core-muted",
|
|
646
|
+
children: [
|
|
647
|
+
"This server",
|
|
648
|
+
where,
|
|
649
|
+
" only answers signed-in users. Sign in with Renown to open it."
|
|
650
|
+
]
|
|
651
|
+
}),
|
|
652
|
+
/* @__PURE__ */ jsx("button", {
|
|
653
|
+
type: "button",
|
|
654
|
+
className: "self-start rounded border border-core-border px-3 py-1 hover:bg-core-hover",
|
|
655
|
+
onClick: () => openRenown(),
|
|
656
|
+
children: "Sign in with Renown"
|
|
657
|
+
})
|
|
658
|
+
] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
659
|
+
/* @__PURE__ */ jsx("h1", {
|
|
660
|
+
id: "backend-auth-gate-title",
|
|
661
|
+
className: "text-lg font-semibold",
|
|
662
|
+
children: "This account is not allowed here"
|
|
663
|
+
}),
|
|
664
|
+
/* @__PURE__ */ jsxs("p", {
|
|
665
|
+
className: "text-sm text-core-muted",
|
|
666
|
+
children: [
|
|
667
|
+
"You are signed in as",
|
|
668
|
+
" ",
|
|
669
|
+
/* @__PURE__ */ jsx("code", {
|
|
670
|
+
className: "break-all",
|
|
671
|
+
children: user?.address
|
|
672
|
+
}),
|
|
673
|
+
", but this server",
|
|
674
|
+
where,
|
|
675
|
+
" does not accept that account. Ask its admin for access, or switch to another account."
|
|
676
|
+
]
|
|
677
|
+
}),
|
|
678
|
+
/* @__PURE__ */ jsx("button", {
|
|
679
|
+
type: "button",
|
|
680
|
+
className: "self-start rounded border border-core-border px-3 py-1 hover:bg-core-hover",
|
|
681
|
+
onClick: () => {
|
|
682
|
+
logout().then(() => openRenown());
|
|
683
|
+
},
|
|
684
|
+
children: "Switch account"
|
|
685
|
+
})
|
|
686
|
+
] })
|
|
687
|
+
})
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
//#endregion
|
|
621
691
|
//#region src/views/theme-toggle.tsx
|
|
622
692
|
/** Flips between light and dark; the first flip pins the system theme's opposite. */
|
|
623
693
|
function ThemeToggle({ className }) {
|
|
@@ -931,17 +1001,20 @@ function DriveAuthRequiredModal() {
|
|
|
931
1001
|
//#endregion
|
|
932
1002
|
//#region src/views/layout.tsx
|
|
933
1003
|
const coreModals = Object.fromEntries(Object.entries(CORE_MODAL_VIEWS).map(([type, name]) => [type, modals_exports[name]]));
|
|
934
|
-
/** Core's root: the page, in the theme.
|
|
1004
|
+
/** Core's root: the page, in the theme. When the app's backend refused the
|
|
1005
|
+
* caller, the sign-in gate stands in for every route, so a shell that
|
|
1006
|
+
* replaces core's layout still gets it. */
|
|
935
1007
|
function CoreRoot() {
|
|
936
1008
|
initTheme();
|
|
937
1009
|
useTheme();
|
|
1010
|
+
const gate = useBackendAuthGate();
|
|
938
1011
|
return /* @__PURE__ */ jsxs("div", {
|
|
939
1012
|
className: "h-screen overflow-auto bg-core-bg text-core-fg",
|
|
940
1013
|
children: [
|
|
941
1014
|
/* @__PURE__ */ jsx(HeadContent, {}),
|
|
942
1015
|
/* @__PURE__ */ jsx(Suspense, {
|
|
943
1016
|
name: "CoreRoot",
|
|
944
|
-
children: /* @__PURE__ */ jsx(Outlet, {})
|
|
1017
|
+
children: gate ? /* @__PURE__ */ jsx(BackendAuthGate, { mode: gate }) : /* @__PURE__ */ jsx(Outlet, {})
|
|
945
1018
|
}),
|
|
946
1019
|
/* @__PURE__ */ jsx(ModalOutlet, { modals: coreModals })
|
|
947
1020
|
]
|
|
@@ -1294,6 +1367,6 @@ function PackagesTab() {
|
|
|
1294
1367
|
});
|
|
1295
1368
|
}
|
|
1296
1369
|
//#endregion
|
|
1297
|
-
export {
|
|
1370
|
+
export { EditorHost as C, DirectoryListing as D, HISTORY_PAGE_SIZE as E, formatModified as O, NodeView as S, DocumentHistory as T, ThemeToggle as _, DriveNotFoundPage as a, DocumentView as b, CoreLayout as c, CreateDocumentModal as d, DeleteItemModal as f, LoginModal as g, DriveAuthRequiredModal as h, CoreRouteError as i, __exportAll as k, CoreRoot as l, DownloadDocumentWithErrorsModal as m, AppearanceTab as n, NotFoundPage as o, DocumentVersionUnsupportedModal as p, CoreSettingsPage as r, CoreHeader as s, PackagesTab as t, ConfirmDocumentUpgradeModal as u, BackendAuthGate as v, DocumentJson as w, DriveLayout as x, DriveIndex as y };
|
|
1298
1371
|
|
|
1299
|
-
//# sourceMappingURL=views-
|
|
1372
|
+
//# sourceMappingURL=views-BtUVboYl.js.map
|