@powerhousedao/connect-core 6.2.3-dev.89 → 6.2.3-dev.91
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/{index-BNdsbq2I.d.ts → index-BEhL5Pyf.d.ts} +12 -5
- package/dist/{index-BNdsbq2I.d.ts.map → index-BEhL5Pyf.d.ts.map} +1 -1
- package/dist/index-Beqvfchq.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -7
- package/dist/{multi-reactor-91g8OeBB.js → multi-reactor-CZnlLi8M.js} +2 -2
- package/dist/{multi-reactor-91g8OeBB.js.map → multi-reactor-CZnlLi8M.js.map} +1 -1
- package/dist/{plugin-host-CMr7lN40.js → plugin-host-CaTO1tq-.js} +2 -2
- package/dist/{plugin-host-CMr7lN40.js.map → plugin-host-CaTO1tq-.js.map} +1 -1
- package/dist/{plugin-ui-DHlnXJmN.js → plugin-ui-BS5j5g1d.js} +3 -3
- package/dist/{plugin-ui-DHlnXJmN.js.map → plugin-ui-BS5j5g1d.js.map} +1 -1
- package/dist/plugins.js +2 -2
- package/dist/{router-C4hDJ4_J.js → router-C5uD96ZP.js} +2 -2
- package/dist/{router-C4hDJ4_J.js.map → router-C5uD96ZP.js.map} +1 -1
- package/dist/router.js +2 -2
- package/dist/{runtime-CtZfHUnR.js → runtime-CJ3UJrQ2.js} +30 -6
- package/dist/runtime-CJ3UJrQ2.js.map +1 -0
- package/dist/runtime-config.js +4 -4
- package/dist/{runtime-flag-DvxW_SD4.js → runtime-flag-DwQ3Jpdw.js} +2 -2
- package/dist/{runtime-flag-DvxW_SD4.js.map → runtime-flag-DwQ3Jpdw.js.map} +1 -1
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.js +3 -3
- package/dist/{views-BtUVboYl.js → views-LyRJcSKu.js} +20 -6
- package/dist/views-LyRJcSKu.js.map +1 -0
- package/dist/views.js +1 -1
- package/package.json +8 -8
- package/src/runtime/drive-placements.ts +41 -6
- package/src/runtime/index.ts +2 -0
- package/src/views/modals.tsx +15 -3
- package/dist/runtime-CtZfHUnR.js.map +0 -1
- package/dist/views-BtUVboYl.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"views-LyRJcSKu.js","names":["modalViews"],"sources":["../src/views/index-table.tsx","../src/views/directory-listing.tsx","../src/views/document-history.tsx","../src/views/document-json.tsx","../src/views/editor-host.tsx","../src/views/content.tsx","../src/views/home.tsx","../src/views/backend-auth-gate.tsx","../src/views/theme-toggle.tsx","../src/views/modals.tsx","../src/views/layout.tsx","../src/views/not-found-page.tsx","../src/views/route-views.tsx","../src/views/settings.tsx","../src/views/settings-packages.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\n\n/** `YYYY-MM-DD HH:mm` in UTC, as a server index lists it; \"-\" when unknown. */\nexport function formatModified(iso: string | undefined) {\n if (!iso) return \"-\";\n const date = new Date(iso);\n if (Number.isNaN(date.getTime())) return \"-\";\n return date.toISOString().slice(0, 16).replace(\"T\", \" \");\n}\n\n/** An \"Index of\" page: a title above a name / type / last modified table. */\nexport function IndexTable(props: {\n title: ReactNode;\n label: string;\n children: ReactNode;\n}) {\n return (\n <div className=\"p-6 font-mono text-sm text-core-fg\">\n <h1 className=\"mb-4 text-xl font-semibold\">{props.title}</h1>\n <table aria-label={props.label} className=\"w-full border-collapse\">\n <thead>\n <tr className=\"border-b border-core-border text-left text-core-muted\">\n <th className=\"py-1 pr-6 font-normal\">Name</th>\n <th className=\"py-1 pr-6 font-normal\">Type</th>\n <th className=\"py-1 font-normal\">Last modified</th>\n </tr>\n </thead>\n <tbody>{props.children}</tbody>\n </table>\n </div>\n );\n}\n\nexport function IndexRow(props: {\n name: ReactNode;\n type: ReactNode;\n modified: ReactNode;\n}) {\n return (\n <tr className=\"border-b border-core-border/50 hover:bg-core-hover\">\n <td className=\"py-1 pr-6\">{props.name}</td>\n <td className=\"py-1 pr-6 text-core-muted\">{props.type}</td>\n <td className=\"py-1 whitespace-nowrap text-core-muted\">\n {props.modified}\n </td>\n </tr>\n );\n}\n\nexport const linkClass = \"text-core-link underline-offset-2 hover:underline\";\n","import {\n getDriveName,\n makeDriveSlug,\n makeNodeSlug,\n useDocumentById,\n useDriveNodes,\n useLinkProps,\n} from \"@powerhousedao/reactor-browser\";\nimport type {\n DocumentDriveDocument,\n FolderNode,\n Node,\n} from \"@powerhousedao/shared/document-drive\";\nimport { isFileNode } from \"@powerhousedao/shared/document-drive\";\nimport type { ReactNode } from \"react\";\nimport { Component, Fragment, Suspense } from \"react\";\nimport type { DriveViewProps } from \"../router/route-components.js\";\nimport {\n formatModified,\n IndexRow,\n IndexTable,\n linkClass,\n} from \"./index-table.js\";\n\nfunction NodeLink(props: {\n drive: DocumentDriveDocument;\n node: Node | undefined;\n children: ReactNode;\n}) {\n const link = useLinkProps({\n driveSlug: makeDriveSlug(props.drive),\n nodeSlug: props.node ? makeNodeSlug(props.node) : undefined,\n });\n return (\n <a {...link} className={linkClass}>\n {props.children}\n </a>\n );\n}\n\nfunction HomeLink(props: { children: ReactNode }) {\n const link = useLinkProps(undefined);\n return (\n <a {...link} className={linkClass}>\n {props.children}\n </a>\n );\n}\n\n// A row's date is a nicety: it shows \"-\" when the document can't load.\nclass Quiet extends Component<{ children: ReactNode }, { failed: boolean }> {\n override state = { failed: false };\n static getDerivedStateFromError() {\n return { failed: true };\n }\n override render() {\n return this.state.failed ? \"-\" : this.props.children;\n }\n}\n\nfunction DocumentModified({ id }: { id: string }) {\n const [document] = useDocumentById(id);\n return formatModified(document?.header.lastModifiedAtUtcIso);\n}\n\n/** The folders from the drive's root down to `folder`. */\nfunction folderPath(nodes: readonly Node[], folder: FolderNode | undefined) {\n const path: Node[] = [];\n for (let node: Node | undefined = folder; node;) {\n path.unshift(node);\n const parentId: string | null | undefined = node.parentFolder;\n node = parentId ? nodes.find((n) => n.id === parentId) : undefined;\n }\n return path;\n}\n\nconst byKindThenName = (a: Node, b: Node) =>\n a.kind === b.kind\n ? a.name.localeCompare(b.name)\n : a.kind === \"folder\"\n ? -1\n : 1;\n\n/** Core's drive fallback: a listing of the open folder; an open document shows instead. */\nexport function DirectoryListing({ drive, folder, children }: DriveViewProps) {\n if (children) return children;\n return <FolderListing drive={drive} folder={folder} />;\n}\n\nfunction FolderListing({\n drive,\n folder,\n}: {\n drive: DocumentDriveDocument;\n folder: FolderNode | undefined;\n}) {\n const nodes = useDriveNodes(drive.header.id) ?? [];\n const path = folderPath(nodes, folder);\n const parent = path.at(-2);\n const entries = nodes\n .filter((node) => (node.parentFolder ?? null) === (folder?.id ?? null))\n .sort(byKindThenName);\n const title = (\n <>\n Index of /\n <NodeLink drive={drive} node={undefined}>\n {getDriveName(drive)}\n </NodeLink>\n /\n {path.map((node) => (\n <Fragment key={node.id}>\n <NodeLink drive={drive} node={node}>\n {node.name}\n </NodeLink>\n /\n </Fragment>\n ))}\n </>\n );\n return (\n <IndexTable title={title} label=\"Directory listing\">\n <IndexRow\n name={\n folder ? (\n <NodeLink drive={drive} node={parent}>\n Parent Directory\n </NodeLink>\n ) : (\n <HomeLink>Parent Directory</HomeLink>\n )\n }\n type=\"-\"\n modified=\"-\"\n />\n {entries.map((node) => (\n <IndexRow\n key={node.id}\n name={\n <NodeLink drive={drive} node={node}>\n {node.kind === \"folder\" ? `${node.name}/` : node.name}\n </NodeLink>\n }\n type={isFileNode(node) ? node.documentType : \"Folder\"}\n modified={\n node.kind === \"folder\" ? (\n \"-\"\n ) : (\n <Quiet>\n <Suspense fallback=\"…\">\n <DocumentModified id={node.id} />\n </Suspense>\n </Quiet>\n )\n }\n />\n ))}\n </IndexTable>\n );\n}\n","import {\n hideRevisionHistory,\n setRevisionHistoryPage,\n useReactorClient,\n useRevisionHistoryPage,\n} from \"@powerhousedao/reactor-browser\";\nimport type { Operation } from \"@powerhousedao/shared/document-model\";\nimport { useEffect, useState } from \"react\";\nimport type { DocumentViewProps } from \"../router/route-components.js\";\nimport { formatModified, linkClass } from \"./index-table.js\";\n\nconst pagerClass = `${linkClass} disabled:text-core-muted disabled:no-underline`;\n\n/** Operations per scope on a history page. */\nexport const HISTORY_PAGE_SIZE = 50;\n\n/** Page `page`'s index range of a scope with `count` operations, newest first. */\nexport function historyPageRange(count: number, page: number) {\n const end = Math.max(count - (page - 1) * HISTORY_PAGE_SIZE, 0);\n return { start: Math.max(end - HISTORY_PAGE_SIZE, 0), end };\n}\n\ntype PageState =\n | { status: \"loading\" }\n | { status: \"ready\"; operations: Operation[] }\n | { status: \"error\"; error: Error };\n\n// Fetches only the page's range: `sinceRevision` and a limit of the page size.\nfunction useScopePage(\n documentId: string,\n scope: string,\n start: number,\n end: number,\n) {\n const client = useReactorClient();\n // Each result is kept with its request; a newer request reads as loading.\n const key = `${documentId}:${scope}:${start}:${end}`;\n const [result, setResult] = useState<{ key: string; state: PageState }>();\n const empty = !client || end <= start;\n useEffect(() => {\n if (empty) return;\n const controller = new AbortController();\n const setState = (state: PageState) => setResult({ key, state });\n client\n .getOperations(\n documentId,\n { scopes: [scope] },\n { sinceRevision: start },\n { cursor: \"\", limit: end - start },\n controller.signal,\n )\n .then(\n (page) => {\n const operations = page.results\n .filter((operation) => operation.index < end)\n .sort((a, b) => b.index - a.index);\n setState({ status: \"ready\", operations });\n },\n (reason: unknown) => {\n if (controller.signal.aborted) return;\n setState({\n status: \"error\",\n error: reason instanceof Error ? reason : new Error(String(reason)),\n });\n },\n );\n return () => controller.abort();\n }, [client, empty, key, documentId, scope, start, end]);\n if (empty) return { status: \"ready\", operations: [] } as const;\n return result?.key === key ? result.state : ({ status: \"loading\" } as const);\n}\n\nfunction ScopeOperations(props: {\n documentId: string;\n scope: string;\n count: number;\n page: number;\n}) {\n const { start, end } = historyPageRange(props.count, props.page);\n const state = useScopePage(props.documentId, props.scope, start, end);\n return (\n <section className=\"mb-6\">\n <h2 className=\"mb-2 font-semibold\">\n {props.scope}{\" \"}\n <span className=\"font-normal text-core-muted\">\n {end > start\n ? `${end - start} of ${props.count}, ${start}-${end - 1}`\n : `0 of ${props.count}`}\n </span>\n </h2>\n {state.status === \"error\" ? (\n <p className=\"text-core-danger\">{state.error.message}</p>\n ) : state.status === \"loading\" ? (\n <p className=\"text-core-muted\">Loading…</p>\n ) : state.operations.length === 0 ? (\n <p className=\"text-core-muted\">No operations on this page.</p>\n ) : (\n <table\n aria-label={`${props.scope} operations`}\n className=\"w-full border-collapse\"\n >\n <thead>\n <tr className=\"border-b border-core-border text-left text-core-muted\">\n <th className=\"py-1 pr-6 font-normal\">Index</th>\n <th className=\"py-1 pr-6 font-normal\">Action</th>\n <th className=\"py-1 font-normal\">Timestamp</th>\n </tr>\n </thead>\n <tbody>\n {state.operations.map((operation) => (\n <tr\n key={operation.index}\n className=\"border-b border-core-border/50 hover:bg-core-hover\"\n >\n <td className=\"py-1 pr-6\">{operation.index}</td>\n <td className=\"py-1 pr-6\">{operation.action.type}</td>\n <td className=\"py-1\">\n {formatModified(operation.timestampUtcMs)}\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n )}\n </section>\n );\n}\n\n/** Core's revision history: each scope's operations, newest first, a page at a time. */\nexport function DocumentHistory({ document }: DocumentViewProps) {\n const page = useRevisionHistoryPage();\n const { header } = document;\n const scopes = Object.entries(header.revision);\n const pageCount = Math.max(\n 1,\n ...scopes.map(([, count]) => Math.ceil(count / HISTORY_PAGE_SIZE)),\n );\n const pager = (\n <nav aria-label=\"History pages\" className=\"flex items-center gap-4\">\n <button\n type=\"button\"\n className={pagerClass}\n disabled={page <= 1}\n onClick={() => setRevisionHistoryPage(page - 1)}\n >\n Newer\n </button>\n <span className=\"text-core-muted\">\n Page {page} of {pageCount}\n </span>\n <button\n type=\"button\"\n className={pagerClass}\n disabled={page >= pageCount}\n onClick={() => setRevisionHistoryPage(page + 1)}\n >\n Older\n </button>\n </nav>\n );\n return (\n <div className=\"p-6 font-mono text-sm text-core-fg\">\n <div className=\"mb-4 flex items-baseline justify-between\">\n <h1 className=\"text-xl font-semibold\">\n History of {header.name || header.id}\n </h1>\n <button\n type=\"button\"\n className={linkClass}\n onClick={hideRevisionHistory}\n >\n Close\n </button>\n </div>\n <div className=\"mb-4\">{pager}</div>\n {scopes.length === 0 ? (\n <p className=\"text-core-muted\">No operations yet.</p>\n ) : (\n scopes.map(([scope, count]) => (\n <ScopeOperations\n key={scope}\n documentId={header.id}\n scope={scope}\n count={count}\n page={page}\n />\n ))\n )}\n </div>\n );\n}\n","import type { ReactNode } from \"react\";\nimport type { DocumentViewProps } from \"../router/route-components.js\";\nimport { formatModified } from \"./index-table.js\";\n\nfunction Leaf({ value }: { value: unknown }) {\n if (value === null) return <span className=\"text-core-muted\">null</span>;\n if (typeof value === \"string\") {\n return <span className=\"text-core-string\">{JSON.stringify(value)}</span>;\n }\n return <span className=\"text-core-number\">{JSON.stringify(value)}</span>;\n}\n\nfunction JsonNode(props: { name: ReactNode; value: unknown; open?: boolean }) {\n const { name, value } = props;\n if (value === null || typeof value !== \"object\") {\n return (\n <div className=\"pl-4\">\n <span className=\"text-core-muted\">{name}: </span>\n <Leaf value={value} />\n </div>\n );\n }\n const entries = Object.entries(value as Record<string, unknown>);\n const isArray = Array.isArray(value);\n const summary = isArray ? `[${entries.length}]` : `{${entries.length}}`;\n return (\n <details open={props.open} className=\"pl-4\">\n <summary className=\"cursor-pointer select-none\">\n <span className=\"text-core-muted\">{name}: </span>\n <span className=\"text-core-muted\">{summary}</span>\n </summary>\n {entries.map(([key, child]) => (\n <JsonNode key={key} name={key} value={child} />\n ))}\n </details>\n );\n}\n\n/** Core's document fallback: the document's state, read-only, as a JSON tree. */\nexport function DocumentJson({ document }: DocumentViewProps) {\n const { header } = document;\n const revisions = Object.entries(header.revision);\n const operations = revisions.reduce((sum, [, count]) => sum + count, 0);\n const state = document.state as Record<string, unknown>;\n const scopes = [\"global\", \"local\"].filter((scope) => scope in state);\n return (\n <div className=\"p-6 font-mono text-sm text-core-fg\">\n <h1 className=\"mb-1 text-xl font-semibold\">{header.name || header.id}</h1>\n <dl className=\"mb-4 grid grid-cols-[max-content_1fr] gap-x-4 text-core-muted\">\n <dt>Type</dt>\n <dd>{header.documentType}</dd>\n <dt>Id</dt>\n <dd>{header.id}</dd>\n <dt>Last modified</dt>\n <dd>{formatModified(header.lastModifiedAtUtcIso)}</dd>\n <dt>Operations</dt>\n <dd data-testid=\"operation-count\">\n {operations}\n {revisions.length > 0 &&\n ` (${revisions.map(([scope, count]) => `${scope} ${count}`).join(\", \")})`}\n </dd>\n </dl>\n <p className=\"mb-2 text-core-muted\">\n No editor is installed for this document type; its state is shown\n read-only.\n </p>\n <div aria-label=\"Document state\" className=\"-ml-4\">\n {scopes.map((scope) => (\n <JsonNode key={scope} name={scope} value={state[scope]} open />\n ))}\n </div>\n </div>\n );\n}\n","import type { EditorProps } from \"@powerhousedao/shared/document-model\";\nimport type { ErrorInfo, ReactNode } from \"react\";\nimport { Component, Suspense } from \"react\";\n\n/** What core passes a document editor; drive apps get `DriveViewProps`. */\nexport type DocumentEditorProps = EditorProps & {\n documentId: string;\n context?: { readMode?: boolean; selectedTimelineRevision?: number };\n};\n\ntype BoundaryProps = {\n resetKeys: readonly unknown[];\n label: string;\n children: ReactNode;\n};\ntype BoundaryState = { error?: unknown; keys: readonly unknown[] };\n\nclass EditorErrorBoundary extends Component<BoundaryProps, BoundaryState> {\n override state: BoundaryState = { keys: this.props.resetKeys };\n\n static getDerivedStateFromError(error: unknown): Partial<BoundaryState> {\n return { error };\n }\n\n // A new document or drive gets a fresh try.\n static getDerivedStateFromProps(\n props: BoundaryProps,\n state: BoundaryState,\n ): Partial<BoundaryState> | null {\n const changed =\n props.resetKeys.length !== state.keys.length ||\n props.resetKeys.some((key, i) => !Object.is(key, state.keys[i]));\n return changed ? { error: undefined, keys: props.resetKeys } : null;\n }\n\n override componentDidCatch(error: unknown, info: ErrorInfo) {\n console.error(`[connect] ${this.props.label} failed:`, error, info);\n }\n\n override render() {\n const { error } = this.state;\n if (error === undefined) return this.props.children;\n return (\n <div role=\"alert\" className=\"p-6 text-core-fg\">\n <h2 className=\"font-semibold\">The {this.props.label} failed</h2>\n <pre className=\"mt-2 overflow-x-auto text-sm text-core-muted\">\n {error instanceof Error ? error.message : JSON.stringify(error)}\n </pre>\n </div>\n );\n }\n}\n\nexport type EditorHostProps = {\n /** A change shows the editor again after an error. */\n resetKeys?: readonly unknown[];\n /** Names what failed, e.g. \"editor\" or \"drive app\". */\n label?: string;\n children: ReactNode;\n};\n\n/** Hosts a drive app or an editor: it loads in Suspense, and an error stays inside. */\nexport function EditorHost({\n resetKeys = [],\n label = \"editor\",\n children,\n}: EditorHostProps) {\n return (\n <EditorErrorBoundary resetKeys={resetKeys} label={label}>\n <Suspense\n name=\"EditorHost\"\n fallback={\n <p role=\"status\" className=\"p-6 text-core-muted\">\n Loading {label}…\n </p>\n }\n >\n {children}\n </Suspense>\n </EditorErrorBoundary>\n );\n}\n","import {\n DriveProvider,\n EditorDocumentProvider,\n useAppModuleById,\n useDispatch,\n useDocument,\n useEditorModuleFor,\n useRevisionHistoryVisible,\n} from \"@powerhousedao/reactor-browser\";\nimport type { PHDocument } from \"@powerhousedao/shared/document-model\";\nimport { Outlet } from \"@tanstack/react-router\";\nimport { useMemo } from \"react\";\nimport { useDriveRouteData } from \"../router/route-data.js\";\nimport { DirectoryListing } from \"./directory-listing.js\";\nimport { DocumentHistory } from \"./document-history.js\";\nimport { DocumentJson } from \"./document-json.js\";\nimport { EditorHost } from \"./editor-host.js\";\n\n/** `document`: its revision history while `?history` is set, else its\n * editor (given `document` and `dispatch`), else its JSON. */\nexport function DocumentView({ document }: { document: PHDocument }) {\n const [, dispatch] = useDispatch(document);\n const editor = useEditorModuleFor(document);\n const historyVisible = useRevisionHistoryVisible();\n if (historyVisible) return <DocumentHistory document={document} />;\n if (!editor) return <DocumentJson document={document} />;\n const Editor = editor.Component;\n return (\n <div\n className=\"relative h-full\"\n data-editor={editor.config.id}\n data-document-type={document.header.documentType}\n >\n <EditorDocumentProvider document={document} dispatch={dispatch}>\n <Editor\n documentId={document.header.id}\n document={document}\n dispatch={dispatch}\n context={{ readMode: false }}\n />\n </EditorDocumentProvider>\n </div>\n );\n}\n\nfunction OpenDocument({ documentId }: { documentId: string }) {\n const document = useDocument(documentId);\n return document ? <DocumentView document={document} /> : null;\n}\n\n/** The drive layout: the drive app its `preferredEditor` names (given the\n * drive as `document`), else the directory listing, around the node route. */\nexport function DriveLayout() {\n const { drive, folder, documentId } = useDriveRouteData();\n const app = useAppModuleById(drive?.header.meta?.preferredEditor);\n const [, dispatch] = useDispatch(drive);\n const nodeId = documentId ?? folder?.id;\n const context = useMemo(\n () => drive && { drive, dispatch, folder, nodeId },\n [drive, dispatch, folder, nodeId],\n );\n if (!drive || !context) return null;\n const App = app?.Component;\n // Drive apps show their own view until they get a document to show.\n const document = documentId ? <Outlet /> : null;\n return (\n <DriveProvider value={context}>\n <EditorHost\n resetKeys={[drive.header.id]}\n label={App ? \"drive app\" : \"drive view\"}\n >\n {App ? (\n <App document={drive} dispatch={dispatch}>\n {document}\n </App>\n ) : (\n <DirectoryListing drive={drive} folder={folder}>\n {document}\n </DirectoryListing>\n )}\n </EditorHost>\n </DriveProvider>\n );\n}\n\n/** The node route: the open document, or nothing on a folder or the drive's root. */\nexport function NodeView() {\n const { documentId } = useDriveRouteData();\n if (!documentId) return null;\n return (\n <EditorHost resetKeys={[documentId]} label=\"editor\">\n <OpenDocument documentId={documentId} />\n </EditorHost>\n );\n}\n","import {\n getDriveName,\n makeDriveSlug,\n preloadDrive,\n useAppModuleById,\n useDrives,\n useLinkProps,\n} from \"@powerhousedao/reactor-browser\";\nimport type { DocumentDriveDocument } from \"@powerhousedao/shared/document-drive\";\nimport {\n formatModified,\n IndexRow,\n IndexTable,\n linkClass,\n} from \"./index-table.js\";\n\nfunction DriveRow({ drive }: { drive: DocumentDriveDocument }) {\n const app = useAppModuleById(drive.header.meta?.preferredEditor);\n const link = useLinkProps({ driveSlug: makeDriveSlug(drive) });\n return (\n <IndexRow\n name={\n <a\n {...link}\n className={linkClass}\n onMouseEnter={() => {\n link.onMouseEnter();\n preloadDrive(drive);\n }}\n >\n {getDriveName(drive)}/\n </a>\n }\n type={app?.config.name ?? \"Drive\"}\n modified={formatModified(drive.header.lastModifiedAtUtcIso)}\n />\n );\n}\n\n/** Core's home: an index of the drives. */\nexport function DriveIndex() {\n const drives = useDrives();\n // Empty until the reactor lists its drives, e.g. in the prerendered shell.\n if (!drives) return null;\n return (\n <IndexTable title=\"Index of /\" label=\"Drives\">\n {drives.map((drive) => (\n <DriveRow key={drive.header.id} drive={drive} />\n ))}\n {!drives.length && (\n <tr>\n <td colSpan={3} className=\"py-2 text-core-muted\">\n No drives yet.\n </td>\n </tr>\n )}\n </IndexTable>\n );\n}\n","import {\n logout,\n openRenown,\n useBackendAuth,\n useUser,\n} from \"@powerhousedao/reactor-browser\";\nimport type { BackendAuthGateMode } from \"../runtime/backend-auth-gate.js\";\n\n// The decision lives with the runtime, so a root view outside this chunk\n// (Connect's own) can take it without loading every core view.\nexport { useBackendAuthGate } from \"../runtime/backend-auth-gate.js\";\nexport type { BackendAuthGateMode } from \"../runtime/backend-auth-gate.js\";\n\n/**\n * Full-page gate rendered by the root view in place of the routes when the\n * backend refused the caller. Signing in goes through Renown's redirect, so\n * the page comes back with the user and boots again as them.\n */\nexport function BackendAuthGate({\n mode,\n}: {\n mode: Exclude<BackendAuthGateMode, null>;\n}) {\n const user = useUser();\n const refusal = useBackendAuth();\n const where = refusal?.backend ? ` (${refusal.backend})` : \"\";\n return (\n <div\n role=\"dialog\"\n aria-labelledby=\"backend-auth-gate-title\"\n className=\"flex h-full min-h-[60vh] items-center justify-center p-6\"\n >\n <div 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\">\n {mode === \"login\" ? (\n <>\n <h1 id=\"backend-auth-gate-title\" className=\"text-lg font-semibold\">\n Sign in to continue\n </h1>\n <p className=\"text-sm text-core-muted\">\n This server{where} only answers signed-in users. Sign in with\n Renown to open it.\n </p>\n <button\n type=\"button\"\n className=\"self-start rounded border border-core-border px-3 py-1 hover:bg-core-hover\"\n onClick={() => openRenown()}\n >\n Sign in with Renown\n </button>\n </>\n ) : (\n <>\n <h1 id=\"backend-auth-gate-title\" className=\"text-lg font-semibold\">\n This account is not allowed here\n </h1>\n <p className=\"text-sm text-core-muted\">\n You are signed in as{\" \"}\n <code className=\"break-all\">{user?.address}</code>, but this\n server{where} does not accept that account. Ask its admin for\n access, or switch to another account.\n </p>\n <button\n type=\"button\"\n className=\"self-start rounded border border-core-border px-3 py-1 hover:bg-core-hover\"\n onClick={() => {\n void logout().then(() => openRenown());\n }}\n >\n Switch account\n </button>\n </>\n )}\n </div>\n </div>\n );\n}\n","import { useTheme } from \"@powerhousedao/reactor-browser\";\n\n/** Flips between light and dark; the first flip pins the system theme's opposite. */\nexport function ThemeToggle({ className }: { className?: string }) {\n const { theme, setTheme } = useTheme();\n const next = theme === \"dark\" ? \"light\" : \"dark\";\n return (\n <button\n type=\"button\"\n aria-label={`Switch to ${next} theme`}\n title={`Switch to ${next} theme`}\n className={\n className ??\n \"rounded px-2 py-1 text-core-muted hover:bg-core-hover hover:text-core-fg\"\n }\n onClick={() => setTheme(next)}\n >\n {theme === \"dark\" ? \"☾\" : \"☀\"}\n </button>\n );\n}\n","// Core's modals: the ones editors, drive apps and the reactor open, in core's plain style.\nimport {\n addDocument,\n closePHModal,\n deleteNode,\n exportFile,\n getDocumentUpgradePreview,\n getDriveName,\n getNodeTarget,\n logout,\n openRenown,\n openTarget,\n setSelectedNode,\n showPHModal,\n upgradeDocument,\n useDocumentById,\n useDocumentModelModuleById,\n useModelRegistry,\n useNodeById,\n useNodeParentFolderById,\n usePHModal,\n useRenownAuth,\n useRenownLoginMethods,\n useUser,\n validateDocument,\n} from \"@powerhousedao/reactor-browser\";\nimport type { PHModal } from \"@powerhousedao/reactor-browser\";\nimport type { ReactNode } from \"react\";\nimport { createElement, useEffect, useId, useState } from \"react\";\nimport type { ModalFrameProps } from \"../router/modal-frame.js\";\nimport { ModalDialog, useModalFrame } from \"../router/modal-frame.js\";\nimport { useCreateDocumentTarget } from \"../router/create-target.js\";\nimport { useDriveRouteData } from \"../router/route-data.js\";\n\nconst buttonClass =\n \"rounded border border-core-border px-3 py-1 text-sm hover:bg-core-hover disabled:opacity-50\";\nconst primaryClass = `${buttonClass} font-semibold`;\n\n/** Core's modal frame: title, content, and the buttons on the right. */\nfunction CoreModalFrame({\n title,\n titleId,\n actions,\n children,\n}: ModalFrameProps) {\n return (\n <ModalDialog\n labelledBy={titleId}\n className=\"m-auto w-96 max-w-[calc(100vw-2rem)] rounded border border-core-border bg-core-bg p-5 text-core-fg backdrop:bg-black/30\"\n >\n <h2 id={titleId} className=\"mb-3 text-lg font-semibold\">\n {title}\n </h2>\n <div className=\"flex flex-col gap-2 text-sm\">{children}</div>\n <div className=\"mt-4 flex justify-end gap-2\">{actions}</div>\n </ModalDialog>\n );\n}\n\n/** A modal in the routes' frame, else core's. */\nfunction Dialog(props: {\n title: string;\n children: ReactNode;\n actions?: ReactNode;\n}) {\n const Frame = useModalFrame() ?? CoreModalFrame;\n const titleId = useId();\n const actions = props.actions ?? (\n <button type=\"button\" className={buttonClass} onClick={closePHModal}>\n Close\n </button>\n );\n // A registered frame, not one made here.\n return createElement(Frame, {\n title: props.title,\n titleId,\n actions,\n children: props.children,\n });\n}\n\nconst Cancel = () => (\n <button type=\"button\" className={buttonClass} onClick={closePHModal}>\n Cancel\n </button>\n);\n\nfunction useModal<T extends PHModal[\"type\"]>(type: T) {\n const modal = usePHModal();\n return modal?.type === type\n ? (modal as Extract<PHModal, { type: T }>)\n : undefined;\n}\n\n/** A new document of the modal's type: in its `driveId`, else the open drive\n * and folder, else a drive picked here. */\nexport function CreateDocumentModal() {\n const modal = useModal(\"createDocument\");\n const module = useDocumentModelModuleById(\n modal?.documentType,\n modal?.documentModelVersion,\n );\n const { folder } = useDriveRouteData();\n const target = useCreateDocumentTarget(modal?.driveId);\n const { drive } = target;\n const [name, setName] = useState(\"\");\n const typeName = module?.documentModel.global.name ?? modal?.documentType;\n const create = async () => {\n if (!drive || !module || !modal) return;\n closePHModal();\n const node = await addDocument(\n drive.header.id,\n name.trim() || `New ${typeName}`,\n module.documentModel.global.id,\n target.isOpenDrive ? folder?.id : undefined,\n undefined,\n undefined,\n undefined,\n modal.documentModelVersion,\n );\n // Opens it in its drive, wherever the modal was opened.\n openTarget(getNodeTarget(node, drive));\n };\n return (\n <Dialog\n title={`New ${typeName ?? \"document\"}`}\n actions={\n <>\n <Cancel />\n <button\n type=\"submit\"\n form=\"create-document\"\n className={primaryClass}\n disabled={!drive || !module}\n >\n Create\n </button>\n </>\n }\n >\n <form\n id=\"create-document\"\n className=\"flex flex-col gap-2\"\n onSubmit={(event) => {\n event.preventDefault();\n void create();\n }}\n >\n <label className=\"flex flex-col gap-1\">\n Name\n <input\n autoFocus\n value={name}\n onChange={(event) => setName(event.target.value)}\n placeholder={`New ${typeName}`}\n className=\"rounded border border-core-border bg-core-bg px-2 py-1\"\n />\n </label>\n {!!target.choices?.length && (\n <label className=\"flex flex-col gap-1\">\n Drive\n <select\n value={drive?.header.id ?? \"\"}\n onChange={(event) => target.pick(event.target.value)}\n className=\"rounded border border-core-border bg-core-bg px-2 py-1\"\n >\n {!drive && <option value=\"\">Choose a drive</option>}\n {target.choices.map((choice) => (\n <option key={choice.header.id} value={choice.header.id}>\n {getDriveName(choice)}\n </option>\n ))}\n </select>\n </label>\n )}\n </form>\n {target.choices?.length === 0 && (\n <p className=\"text-core-muted\">\n There's no drive to create it in.{\" \"}\n <button\n type=\"button\"\n className=\"underline\"\n onClick={() => showPHModal({ type: \"addDrive\" })}\n >\n Add a drive\n </button>\n </p>\n )}\n </Dialog>\n );\n}\n\n/** Signs in with Renown: the configured methods, else its portal. */\nexport function LoginModal() {\n const user = useUser();\n const methods = useRenownLoginMethods();\n const { login, pending, error } = useRenownAuth();\n useEffect(() => {\n if (user) closePHModal();\n }, [user]);\n return (\n <Dialog title=\"Log in\">\n {methods.length ? (\n methods.map((method) => (\n <button\n key={method.id}\n type=\"button\"\n className={buttonClass}\n disabled={pending}\n onClick={() => {\n closePHModal();\n login(undefined, method.id);\n }}\n >\n {method.label}\n </button>\n ))\n ) : (\n <button\n type=\"button\"\n className={primaryClass}\n onClick={() => openRenown()}\n >\n Continue with Renown\n </button>\n )}\n {error && <p className=\"text-core-muted\">{error.message}</p>}\n </Dialog>\n );\n}\n\n/** Deletes a file or folder, then opens its parent. */\nexport function DeleteItemModal() {\n const modal = useModal(\"deleteItem\");\n const node = useNodeById(modal?.id);\n const parent = useNodeParentFolderById(modal?.id);\n const { drive } = useDriveRouteData();\n const [pending, setPending] = useState(false);\n const [error, setError] = useState<string>();\n const remove = async () => {\n if (!drive || !modal) return;\n setPending(true);\n setError(undefined);\n try {\n await deleteNode(drive.header.id, modal.id);\n } catch (cause) {\n setError(cause instanceof Error ? cause.message : String(cause));\n setPending(false);\n return;\n }\n closePHModal();\n setSelectedNode(parent);\n };\n return (\n <Dialog\n title={`Delete ${node?.name ?? \"item\"}?`}\n actions={\n <>\n <Cancel />\n <button\n type=\"button\"\n className={primaryClass}\n disabled={pending}\n onClick={() => void remove()}\n >\n {pending ? \"Deleting…\" : \"Delete\"}\n </button>\n </>\n }\n >\n <p>\n {node?.kind === \"folder\"\n ? \"The folder and everything in it will be deleted.\"\n : \"The document will be deleted.\"}\n </p>\n {error && <p className=\"text-core-muted\">{error}</p>}\n </Dialog>\n );\n}\n\n/** Upgrades a document to its model's latest version. */\nexport function ConfirmDocumentUpgradeModal() {\n const modal = useModal(\"confirmDocumentUpgrade\");\n const [document] = useDocumentById(modal?.documentId);\n const registry = useModelRegistry();\n const preview = document\n ? getDocumentUpgradePreview(document, registry)\n : undefined;\n if (!document || !preview) return null;\n const upgrade = () => {\n closePHModal();\n upgradeDocument(document.header.id).catch((error: unknown) => {\n console.error(\"[connect] the document upgrade failed:\", error);\n });\n };\n return (\n <Dialog\n title=\"Update document\"\n actions={\n <>\n <Cancel />\n <button type=\"button\" className={primaryClass} onClick={upgrade}>\n Update document\n </button>\n </>\n }\n >\n <p>\n From version {preview.fromVersion} to {preview.toVersion}. Existing\n content is migrated; this can't be undone.\n </p>\n {preview.steps\n .filter((step) => step.description)\n .map((step) => (\n <p key={step.toVersion}>\n v{step.toVersion}: {step.description}\n </p>\n ))}\n </Dialog>\n );\n}\n\n/** Exports a document that has validation errors, after listing them. */\nexport function DownloadDocumentWithErrorsModal() {\n const modal = useModal(\"downloadDocumentWithErrors\");\n const [document] = useDocumentById(modal?.documentId);\n if (!document) return null;\n const errors = validateDocument(document);\n const download = () => {\n closePHModal();\n exportFile(document).catch((error: unknown) => {\n console.error(\"[connect] the export failed:\", error);\n });\n };\n return (\n <Dialog\n title=\"The document has errors\"\n actions={\n <>\n <Cancel />\n <button type=\"button\" className={primaryClass} onClick={download}>\n Export anyway\n </button>\n </>\n }\n >\n <ul className=\"list-disc pl-5 text-core-muted\">\n {errors.map((error, index) => (\n <li key={index}>{error.message}</li>\n ))}\n </ul>\n </Dialog>\n );\n}\n\n/** A document whose model version no installed package provides. */\nexport function DocumentVersionUnsupportedModal() {\n const modal = useModal(\"documentVersionUnsupported\");\n if (!modal) return null;\n const { documentType, requiredVersion, availableVersions } = modal;\n return (\n <Dialog\n title=\"Document version not supported\"\n actions={\n <>\n <Cancel />\n <button\n type=\"button\"\n className={primaryClass}\n onClick={() => {\n closePHModal();\n openTarget({ settings: \"packages\" });\n }}\n >\n Show packages\n </button>\n </>\n }\n >\n <p>\n This document needs version {requiredVersion} of \"{documentType}\"; the\n installed packages provide {availableVersions.join(\", \")}.\n </p>\n </Dialog>\n );\n}\n\n/** A protected drive that couldn't be added: sign in, or as someone else. */\nexport function DriveAuthRequiredModal() {\n const user = useUser();\n return (\n <Dialog\n title={user ? \"No access to this drive\" : \"Log in to access this drive\"}\n actions={\n <>\n <Cancel />\n {user ? (\n <button\n type=\"button\"\n className={primaryClass}\n onClick={() => {\n closePHModal();\n void logout();\n }}\n >\n Log out\n </button>\n ) : (\n <button\n type=\"button\"\n className={primaryClass}\n onClick={() => showPHModal({ type: \"login\" })}\n >\n Log in\n </button>\n )}\n </>\n }\n >\n <p>\n {user\n ? \"The account you're signed in with can't open this drive.\"\n : \"This drive is only open to signed-in users.\"}\n </p>\n </Dialog>\n );\n}\n","import {\n initTheme,\n useLinkProps,\n useTheme,\n} from \"@powerhousedao/reactor-browser\";\nimport { HeadContent, Link, Outlet, useRouter } from \"@tanstack/react-router\";\nimport { Suspense } from \"react\";\nimport type { ConnectModals } from \"../router/modals.js\";\nimport { CORE_MODAL_VIEWS, ModalOutlet } from \"../router/modals.js\";\nimport { ContentOutlet } from \"../router/route-components.js\";\nimport { useNavRoutes, useSidebarMode } from \"../router/sidebar.js\";\nimport { appTitle } from \"../router/titles.js\";\nimport { useIsEmbedded } from \"../runtime/embedded.js\";\nimport { ThemeToggle } from \"./theme-toggle.js\";\nimport { linkClass } from \"./index-table.js\";\nimport * as modalViews from \"./modals.js\";\nimport { BackendAuthGate, useBackendAuthGate } from \"./backend-auth-gate.js\";\n\n// The layout shares the modals' chunk, so it renders them directly.\nconst coreModals: ConnectModals = Object.fromEntries(\n Object.entries(CORE_MODAL_VIEWS).map(([type, name]) => [\n type,\n modalViews[name],\n ]),\n);\n\n/** Core's root: the page, in the theme. When the app's backend refused the\n * caller, the sign-in gate stands in for every route, so a shell that\n * replaces core's layout still gets it. */\nexport function CoreRoot() {\n initTheme();\n useTheme();\n const gate = useBackendAuthGate();\n return (\n <div className=\"h-screen overflow-auto bg-core-bg text-core-fg\">\n {/* The matched routes' head: the document title. */}\n <HeadContent />\n <Suspense name=\"CoreRoot\">\n {gate ? <BackendAuthGate mode={gate} /> : <Outlet />}\n </Suspense>\n <ModalOutlet modals={coreModals} />\n </div>\n );\n}\n\n/** Core's header: home, the `staticData.nav` routes, settings and the theme. */\nexport function CoreHeader() {\n const appName = useRouter().options.context.appName;\n const home = useLinkProps(undefined);\n const settings = useLinkProps({ settings: true });\n const navRoutes = useNavRoutes();\n return (\n <header className=\"flex items-center gap-4 border-b border-core-border px-4 py-2 text-sm\">\n <a {...home} className=\"font-semibold text-core-fg\">\n {appTitle(appName)}\n </a>\n <nav aria-label=\"Pages\" className=\"flex gap-3\">\n {navRoutes.map((item) => (\n // `to` is a plain string: the routes are only known at runtime.\n <Link key={item.routeId} to={item.to as never} className={linkClass}>\n {item.label}\n </Link>\n ))}\n </nav>\n <div className=\"ml-auto flex items-center gap-2\">\n <a {...settings} className={linkClass}>\n Settings\n </a>\n <ThemeToggle />\n </div>\n </header>\n );\n}\n\n/** Core's `_app` layout: the header above the matched route. Embedded mode\n * and `staticData.sidebar: \"hidden\"` drop the header. */\nexport function CoreLayout() {\n const isEmbedded = useIsEmbedded();\n const hidden = useSidebarMode() === \"hidden\";\n return (\n <div className=\"flex h-full flex-col\">\n {!isEmbedded && !hidden && <CoreHeader />}\n <main className=\"relative min-h-0 flex-1\">\n <ContentOutlet />\n </main>\n </div>\n );\n}\n","import { useLinkProps } from \"@powerhousedao/reactor-browser\";\nimport { useRouterState } from \"@tanstack/react-router\";\n\n/** The 404 page: what was asked for, and a way home. */\nexport function NotFoundPage({ driveSlug }: { driveSlug?: string }) {\n const pathname = useRouterState({ select: (s) => s.location.pathname });\n const home = useLinkProps(undefined);\n return (\n <div\n role=\"alert\"\n className=\"flex size-full flex-col items-center justify-center gap-3 p-6 text-center\"\n >\n <h1 className=\"text-2xl font-semibold text-core-fg\">\n {driveSlug ? `Drive ${driveSlug} not found` : \"Page not found\"}\n </h1>\n <p className=\"text-core-muted\">\n Nothing is at{\" \"}\n <code data-testid=\"not-found-path\" className=\"text-core-fg\">\n {pathname}\n </code>\n .\n </p>\n <a {...home} className=\"text-core-fg underline\">\n Go to the home page\n </a>\n </div>\n );\n}\n\nexport function DriveNotFoundPage({ driveSlug }: { driveSlug: string }) {\n return <NotFoundPage driveSlug={driveSlug} />;\n}\n","import type { ErrorComponentProps } from \"@tanstack/react-router\";\n\n/** A route's loader or render error. */\nexport function CoreRouteError({ error, reset }: ErrorComponentProps) {\n return (\n <div role=\"alert\" className=\"flex flex-col gap-2 p-6 text-core-fg\">\n <h1 className=\"text-lg font-semibold\">Something went wrong</h1>\n <pre className=\"overflow-x-auto text-sm text-core-muted\">\n {error instanceof Error ? error.message : JSON.stringify(error)}\n </pre>\n <button\n type=\"button\"\n className=\"self-start rounded border border-core-border px-3 py-1 hover:bg-core-hover\"\n onClick={reset}\n >\n Try again\n </button>\n </div>\n );\n}\n","import {\n useLinkProps,\n usePHNavigation,\n useTheme,\n} from \"@powerhousedao/reactor-browser\";\nimport { Outlet } from \"@tanstack/react-router\";\nimport { Suspense } from \"react\";\nimport type { SettingsTabEntry } from \"../router/settings.js\";\nimport { useSettingsTabs } from \"../router/settings.js\";\n\nfunction TabLink({ tab }: { tab: SettingsTabEntry }) {\n const link = useLinkProps({ settings: tab.id });\n const current = link[\"aria-current\"] === \"page\";\n const Icon = tab.icon;\n return (\n <a\n {...link}\n className={[\n \"flex items-center gap-2 rounded px-3 py-1.5\",\n current ? \"bg-core-hover font-semibold\" : \"hover:bg-core-hover\",\n tab.destructive ? \"text-core-danger\" : \"text-core-fg\",\n ].join(\" \")}\n >\n {Icon && <Icon size={16} />}\n {tab.label}\n </a>\n );\n}\n\n/** Core's settings page: the tabs from `staticData.settings` beside the open one. */\nexport function CoreSettingsPage() {\n const tabs = useSettingsTabs();\n const navigation = usePHNavigation();\n // Back to where settings was opened from, else home.\n const close = () => {\n if (navigation.closeOpened?.()) return;\n navigation.open(undefined, { replace: true });\n };\n return (\n <div className=\"flex h-full flex-col text-core-fg\">\n <div className=\"flex items-center justify-between border-b border-core-border px-4 py-3\">\n <h1 className=\"text-lg font-semibold\">Settings</h1>\n <button\n type=\"button\"\n className=\"rounded px-2 text-core-muted hover:bg-core-hover\"\n onClick={close}\n >\n Close\n </button>\n </div>\n <div className=\"flex min-h-0 flex-1\">\n <nav aria-label=\"Settings\" className=\"w-48 shrink-0 p-3\">\n <ul className=\"flex flex-col gap-1\">\n {tabs.map((tab) => (\n <li key={tab.id}>\n <TabLink tab={tab} />\n </li>\n ))}\n </ul>\n </nav>\n <section className=\"min-w-0 flex-1 overflow-auto p-6\">\n <Suspense name=\"SettingsTab\">\n <Outlet />\n </Suspense>\n </section>\n </div>\n </div>\n );\n}\n\nconst THEMES = [\n { value: \"light\", label: \"Light\" },\n { value: \"dark\", label: \"Dark\" },\n { value: \"system\", label: \"System\" },\n] as const;\n\n/** Core's Appearance tab: light, dark, or the system's. */\nexport function AppearanceTab() {\n const { theme, isSystem, setTheme } = useTheme();\n const selected = isSystem ? \"system\" : theme;\n return (\n <fieldset className=\"flex flex-col gap-2\">\n <legend className=\"mb-2 font-semibold\">Theme</legend>\n {THEMES.map((option) => (\n <label key={option.value} className=\"flex items-center gap-2\">\n <input\n type=\"radio\"\n name=\"theme\"\n value={option.value}\n checked={selected === option.value}\n onChange={() => setTheme(option.value)}\n />\n {option.label}\n </label>\n ))}\n </fieldset>\n );\n}\n","import {\n DRIVE_DOCUMENT_TYPES,\n useVetraPackageManager,\n useVetraPackages,\n} from \"@powerhousedao/reactor-browser\";\nimport type {\n DocumentModelLib,\n EditorModule,\n} from \"@powerhousedao/shared/document-model\";\nimport type { ReactNode } from \"react\";\n\nconst SOURCE_LABELS: Record<string, string> = {\n common: \"built-in\",\n project: \"project\",\n \"local-install\": \"local\",\n \"registry-install\": \"registry\",\n};\n\nconst isDriveApp = (editor: EditorModule) =>\n editor.documentTypes.some((type) =>\n (DRIVE_DOCUMENT_TYPES as readonly string[]).includes(type),\n );\n\n/** A package's document models by type, with every version it ships. */\nfunction modelsOf(pkg: DocumentModelLib) {\n const byType = new Map<string, { name: string; versions: number[] }>();\n for (const model of pkg.documentModels) {\n const { id, name } = model.documentModel.global;\n const entry = byType.get(id) ?? { name, versions: [] };\n entry.versions.push(model.version ?? 1);\n byType.set(id, entry);\n }\n return [...byType].map(([type, { name, versions }]) => ({\n type,\n name,\n versions: versions.sort((a, b) => a - b),\n }));\n}\n\nfunction Section(props: { title: string; children: ReactNode }) {\n return (\n <div className=\"mt-3\">\n <h3 className=\"mb-1 text-xs font-semibold tracking-wide text-core-muted uppercase\">\n {props.title}\n </h3>\n {props.children}\n </div>\n );\n}\n\nconst cell = \"py-1 pr-4 align-top break-words\";\n\nfunction EditorTable(props: { label: string; editors: EditorModule[] }) {\n return (\n <table\n aria-label={props.label}\n className=\"w-full table-fixed border-collapse text-sm\"\n >\n <tbody>\n {props.editors.map((editor) => (\n <tr key={editor.config.id} className=\"border-t border-core-border/50\">\n <td className={`${cell} w-1/3`}>{editor.config.name}</td>\n <td className={`${cell} w-1/3 font-mono text-core-muted`}>\n {editor.config.id}\n </td>\n <td className={`${cell} font-mono`}>\n {editor.documentTypes.join(\", \")}\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n );\n}\n\nfunction PackageEntry({ pkg }: { pkg: DocumentModelLib }) {\n const manager = useVetraPackageManager();\n const name = pkg.manifest.name;\n const version = manager?.getPackageVersion(name);\n const source = manager?.getPackageSource(name);\n const models = modelsOf(pkg);\n const apps = pkg.editors.filter(isDriveApp);\n const editors = pkg.editors.filter((editor) => !isDriveApp(editor));\n return (\n <li\n aria-label={name}\n className=\"rounded border border-core-border px-4 py-3\"\n >\n <div className=\"flex flex-wrap items-baseline gap-x-3\">\n <h2 className=\"font-semibold\">{name}</h2>\n {version && (\n <span className=\"font-mono text-sm text-core-muted\">{version}</span>\n )}\n {source && (\n <span className=\"rounded border border-core-border px-1.5 text-xs text-core-muted\">\n {SOURCE_LABELS[source] ?? source}\n </span>\n )}\n </div>\n {models.length > 0 && (\n <Section title=\"Document models\">\n <table\n aria-label={`${name} document models`}\n className=\"w-full table-fixed border-collapse text-sm\"\n >\n <tbody>\n {models.map((model) => (\n <tr key={model.type} className=\"border-t border-core-border/50\">\n <td className={`${cell} w-1/3`}>{model.name}</td>\n <td className={`${cell} w-1/3 font-mono`}>{model.type}</td>\n <td className={`${cell} text-core-muted`}>\n {model.versions.map((v) => `v${v}`).join(\", \")}\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </Section>\n )}\n {editors.length > 0 && (\n <Section title=\"Editors\">\n <EditorTable label={`${name} editors`} editors={editors} />\n </Section>\n )}\n {apps.length > 0 && (\n <Section title=\"Drive apps\">\n <EditorTable label={`${name} drive apps`} editors={apps} />\n </Section>\n )}\n </li>\n );\n}\n\n/** Core's Packages tab: the loaded packages, their document models, editors and drive apps. */\nexport function PackagesTab() {\n const packages = useVetraPackages();\n return (\n <div className=\"w-full max-w-3xl\">\n {packages.length === 0 ? (\n <p className=\"text-core-muted\">No packages are loaded.</p>\n ) : (\n <ul aria-label=\"Packages\" className=\"flex flex-col gap-3\">\n {packages.map((pkg, index) => (\n <PackageEntry key={`${pkg.manifest.name}:${index}`} pkg={pkg} />\n ))}\n </ul>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGA,SAAgB,eAAe,KAAyB;CACtD,IAAI,CAAC,KAAK,OAAO;CACjB,MAAM,OAAO,IAAI,KAAK,GAAG;CACzB,IAAI,OAAO,MAAM,KAAK,QAAQ,CAAC,GAAG,OAAO;CACzC,OAAO,KAAK,YAAY,CAAC,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,QAAQ,KAAK,GAAG;AACzD;;AAGA,SAAgB,WAAW,OAIxB;CACD,OACE,qBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,oBAAC,MAAD;GAAI,WAAU;GAA8B,UAAA,MAAM;EAAU,CAAA,GAC5D,qBAAC,SAAD;GAAO,cAAY,MAAM;GAAO,WAAU;GAA1C,UAAA,CACE,oBAAC,SAAD,EAAA,UACE,qBAAC,MAAD;IAAI,WAAU;IAAd,UAAA;KACE,oBAAC,MAAD;MAAI,WAAU;MAAwB,UAAA;KAAQ,CAAA;KAC9C,oBAAC,MAAD;MAAI,WAAU;MAAwB,UAAA;KAAQ,CAAA;KAC9C,oBAAC,MAAD;MAAI,WAAU;MAAmB,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AAK,UAClB,oBAAC,cAAD,EAAyD,IAAM,GAA5C,GAAG,IAAI,SAAS,KAAK,GAAG,OAAoB,CAChE;EACC,CAAA;CAEH,CAAA;AAET"}
|
package/dist/views.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { C as EditorHost, D as DirectoryListing, E as HISTORY_PAGE_SIZE, O as formatModified, S as NodeView, T as DocumentHistory, _ as ThemeToggle, a as DriveNotFoundPage, b as DocumentView, c as CoreLayout, d as CreateDocumentModal, f as DeleteItemModal, g as LoginModal, h as DriveAuthRequiredModal, i as CoreRouteError, l as CoreRoot, m as DownloadDocumentWithErrorsModal, n as AppearanceTab, o as NotFoundPage, p as DocumentVersionUnsupportedModal, r as CoreSettingsPage, s as CoreHeader, t as PackagesTab, u as ConfirmDocumentUpgradeModal, v as BackendAuthGate, w as DocumentJson, x as DriveLayout, y as DriveIndex } from "./views-
|
|
1
|
+
import { C as EditorHost, D as DirectoryListing, E as HISTORY_PAGE_SIZE, O as formatModified, S as NodeView, T as DocumentHistory, _ as ThemeToggle, a as DriveNotFoundPage, b as DocumentView, c as CoreLayout, d as CreateDocumentModal, f as DeleteItemModal, g as LoginModal, h as DriveAuthRequiredModal, i as CoreRouteError, l as CoreRoot, m as DownloadDocumentWithErrorsModal, n as AppearanceTab, o as NotFoundPage, p as DocumentVersionUnsupportedModal, r as CoreSettingsPage, s as CoreHeader, t as PackagesTab, u as ConfirmDocumentUpgradeModal, v as BackendAuthGate, w as DocumentJson, x as DriveLayout, y as DriveIndex } from "./views-LyRJcSKu.js";
|
|
2
2
|
import { t as useBackendAuthGate } from "./backend-auth-gate-DNKg_v4Y.js";
|
|
3
3
|
export { AppearanceTab, BackendAuthGate, ConfirmDocumentUpgradeModal, CoreHeader, CoreLayout, CoreRoot, CoreRouteError, CoreSettingsPage, CreateDocumentModal, DeleteItemModal, DirectoryListing, DocumentHistory, DocumentJson, DocumentVersionUnsupportedModal, DocumentView, DownloadDocumentWithErrorsModal, DriveAuthRequiredModal, DriveIndex, DriveLayout, DriveNotFoundPage, EditorHost, HISTORY_PAGE_SIZE, LoginModal, NodeView, NotFoundPage, PackagesTab, ThemeToggle, formatModified, useBackendAuthGate };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/connect-core",
|
|
3
|
-
"version": "6.2.3-dev.
|
|
3
|
+
"version": "6.2.3-dev.91",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -73,17 +73,17 @@
|
|
|
73
73
|
"./package.json": "./package.json"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"@powerhousedao/host-core": "6.2.3-dev.
|
|
77
|
-
"@powerhousedao/reactor": "6.2.3-dev.
|
|
78
|
-
"@powerhousedao/reactor-browser": "6.2.3-dev.
|
|
79
|
-
"@powerhousedao/reactor-router": "6.2.3-dev.
|
|
80
|
-
"@powerhousedao/shared": "6.2.3-dev.
|
|
81
|
-
"document-model": "6.2.3-dev.
|
|
76
|
+
"@powerhousedao/host-core": "6.2.3-dev.91",
|
|
77
|
+
"@powerhousedao/reactor": "6.2.3-dev.91",
|
|
78
|
+
"@powerhousedao/reactor-browser": "6.2.3-dev.91",
|
|
79
|
+
"@powerhousedao/reactor-router": "6.2.3-dev.91",
|
|
80
|
+
"@powerhousedao/shared": "6.2.3-dev.91",
|
|
81
|
+
"document-model": "6.2.3-dev.91"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
84
|
"@electric-sql/pglite": "0.3.15",
|
|
85
85
|
"@playwright/test": "^1.60.0",
|
|
86
|
-
"@renown/sdk": "6.2.3-dev.
|
|
86
|
+
"@renown/sdk": "6.2.3-dev.91",
|
|
87
87
|
"@tanstack/react-router": "^1.170.41",
|
|
88
88
|
"@tanstack/router-cli": "1.167.40",
|
|
89
89
|
"@tanstack/router-core": "1.171.34",
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
IRoutableBackend,
|
|
3
|
+
RoutingReactorClient,
|
|
4
|
+
} from "@powerhousedao/reactor-router";
|
|
2
5
|
import { driveDocumentType } from "@powerhousedao/shared/document-drive";
|
|
3
6
|
import { logger } from "document-model";
|
|
4
7
|
import {
|
|
@@ -41,13 +44,45 @@ export function needsCopy(backend: string): boolean {
|
|
|
41
44
|
return backend === LOCAL_BACKEND_NAME;
|
|
42
45
|
}
|
|
43
46
|
|
|
44
|
-
/** A
|
|
47
|
+
/** A switchboard, or the copy here, read for the operations it stores. */
|
|
48
|
+
export type OperationReader = Pick<IRoutableBackend, "getOperations">;
|
|
49
|
+
|
|
50
|
+
/** Action ids in `scope` from index `from`, and the next index to read. */
|
|
51
|
+
export async function actionIdsFrom(
|
|
52
|
+
reader: OperationReader,
|
|
53
|
+
documentId: string,
|
|
54
|
+
scope: string,
|
|
55
|
+
from: number,
|
|
56
|
+
): Promise<{ ids: string[]; next: number }> {
|
|
57
|
+
const ids: string[] = [];
|
|
58
|
+
let next = from;
|
|
59
|
+
let paging: Parameters<OperationReader["getOperations"]>[3];
|
|
60
|
+
do {
|
|
61
|
+
const page = await reader.getOperations(
|
|
62
|
+
documentId,
|
|
63
|
+
{ branch: "main", scopes: [scope] },
|
|
64
|
+
{ sinceRevision: from },
|
|
65
|
+
paging,
|
|
66
|
+
);
|
|
67
|
+
for (const operation of page.results) {
|
|
68
|
+
ids.push(operation.action.id);
|
|
69
|
+
next = Math.max(next, operation.index + 1);
|
|
70
|
+
}
|
|
71
|
+
paging =
|
|
72
|
+
page.nextCursor && page.results.length > 0
|
|
73
|
+
? { cursor: page.nextCursor, limit: page.options.limit }
|
|
74
|
+
: undefined;
|
|
75
|
+
} while (paging);
|
|
76
|
+
return { ids, next };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Holds every action the source holds; each replica numbers its own revisions. */
|
|
45
80
|
export function caughtUp(
|
|
46
|
-
local: Readonly<Record<string,
|
|
47
|
-
source: Readonly<Record<string,
|
|
81
|
+
local: Readonly<Record<string, ReadonlySet<string>>>,
|
|
82
|
+
source: Readonly<Record<string, readonly string[]>>,
|
|
48
83
|
): boolean {
|
|
49
|
-
return Object.entries(source).every(
|
|
50
|
-
(
|
|
84
|
+
return Object.entries(source).every(([scope, ids]) =>
|
|
85
|
+
ids.every((id) => local[scope]?.has(id) ?? false),
|
|
51
86
|
);
|
|
52
87
|
}
|
|
53
88
|
|
package/src/runtime/index.ts
CHANGED
|
@@ -53,6 +53,7 @@ export type {
|
|
|
53
53
|
SwitchboardDrive,
|
|
54
54
|
} from "./drive-placement.js";
|
|
55
55
|
export {
|
|
56
|
+
actionIdsFrom,
|
|
56
57
|
caughtUp,
|
|
57
58
|
DrivePlacements,
|
|
58
59
|
effectiveBackend,
|
|
@@ -61,6 +62,7 @@ export {
|
|
|
61
62
|
} from "./drive-placements.js";
|
|
62
63
|
export type {
|
|
63
64
|
DrivePlacement,
|
|
65
|
+
OperationReader,
|
|
64
66
|
PlacementRouter,
|
|
65
67
|
PlacementStore,
|
|
66
68
|
PlacementSync,
|
package/src/views/modals.tsx
CHANGED
|
@@ -235,10 +235,20 @@ export function DeleteItemModal() {
|
|
|
235
235
|
const node = useNodeById(modal?.id);
|
|
236
236
|
const parent = useNodeParentFolderById(modal?.id);
|
|
237
237
|
const { drive } = useDriveRouteData();
|
|
238
|
+
const [pending, setPending] = useState(false);
|
|
239
|
+
const [error, setError] = useState<string>();
|
|
238
240
|
const remove = async () => {
|
|
239
|
-
closePHModal();
|
|
240
241
|
if (!drive || !modal) return;
|
|
241
|
-
|
|
242
|
+
setPending(true);
|
|
243
|
+
setError(undefined);
|
|
244
|
+
try {
|
|
245
|
+
await deleteNode(drive.header.id, modal.id);
|
|
246
|
+
} catch (cause) {
|
|
247
|
+
setError(cause instanceof Error ? cause.message : String(cause));
|
|
248
|
+
setPending(false);
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
closePHModal();
|
|
242
252
|
setSelectedNode(parent);
|
|
243
253
|
};
|
|
244
254
|
return (
|
|
@@ -250,9 +260,10 @@ export function DeleteItemModal() {
|
|
|
250
260
|
<button
|
|
251
261
|
type="button"
|
|
252
262
|
className={primaryClass}
|
|
263
|
+
disabled={pending}
|
|
253
264
|
onClick={() => void remove()}
|
|
254
265
|
>
|
|
255
|
-
Delete
|
|
266
|
+
{pending ? "Deleting…" : "Delete"}
|
|
256
267
|
</button>
|
|
257
268
|
</>
|
|
258
269
|
}
|
|
@@ -262,6 +273,7 @@ export function DeleteItemModal() {
|
|
|
262
273
|
? "The folder and everything in it will be deleted."
|
|
263
274
|
: "The document will be deleted."}
|
|
264
275
|
</p>
|
|
276
|
+
{error && <p className="text-core-muted">{error}</p>}
|
|
265
277
|
</Dialog>
|
|
266
278
|
);
|
|
267
279
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-CtZfHUnR.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/new-drive.ts","../src/runtime/drive-placement.ts","../src/runtime/drive-placements.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\";\nimport { logger } from \"document-model\";\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\nconst LOCAL_ONLY: ReadonlySet<ReactorClientMode> = new Set([\n \"in-process\",\n \"worker\",\n]);\n\n/** Set while this page load keeps its reactor to itself against the host's `newDrives`. */\nlet blockedNewDrives: Error | undefined;\n\n/** While new drives go to a switchboard, a local-only override applies only from the URL, never from storage. */\nfunction fromTab(newDrives: string | undefined): 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 const localOnly = (mode: ReactorClientMode | undefined) =>\n newDrives !== undefined && mode !== undefined && LOCAL_ONLY.has(mode);\n try {\n if (query) {\n if (localOnly(query)) {\n window.localStorage.removeItem(REACTOR_CLIENT_STORAGE_KEY);\n } else {\n window.localStorage.setItem(REACTOR_CLIENT_STORAGE_KEY, query);\n }\n return query;\n }\n const stored = asMode(\n window.localStorage.getItem(REACTOR_CLIENT_STORAGE_KEY),\n );\n if (!localOnly(stored)) return stored;\n window.localStorage.removeItem(REACTOR_CLIENT_STORAGE_KEY);\n logger.warn(\n \"Ignoring the stored ?reactorClient=@mode: new drives go to @switchboard\",\n stored,\n newDrives,\n );\n return undefined;\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 instance = getRuntimeConfig().connect.instance;\n const newDrives = instance?.router?.newDrives;\n const override = fromTab(newDrives);\n blockedNewDrives =\n override && newDrives !== undefined && LOCAL_ONLY.has(override)\n ? new Error(\n `New drives go to ${newDrives}, but this browser is set to keep its reactor to itself (?reactorClient=${override}).`,\n )\n : undefined;\n if (override) return override;\n const configured = 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\n/** Why this page load can't create a drive where the host says, or undefined when it can. */\nexport function newDrivesBlocked(): Error | undefined {\n return blockedNewDrives;\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 {\n PHConnectRemoteBackend,\n PHConnectRouterSettings,\n} from \"@powerhousedao/shared/clis\";\nimport type { DocumentDriveDocument } from \"@powerhousedao/shared/document-drive\";\nimport type { ISigner } from \"@powerhousedao/shared/document-model\";\nimport { logger } from \"document-model\";\nimport { switchboardOfDrive } from \"@powerhousedao/shared/host-tokens\";\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\n// Kept here: multi-reactor.ts is loaded lazily.\nconst REMOTE_BACKEND_NAME = \"switchboard-remote\";\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 /** The fallback switchboard when `remoteBackends` is empty. */\n remoteDriveUrl: string | undefined;\n /** One per switchboard, by host key; `url` is a drive address on it. */\n remoteBackends?: readonly PHConnectRemoteBackend[];\n /** Where new drives go and the router's timeouts, from the host config. */\n router?: PHConnectRouterSettings;\n /** Config placements known at build time; later ones go through `setConfiguredPlacement`. */\n collections?: Readonly<Record<string, string>>;\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, router } = await selectClient({\n ...params,\n mode: plan.mode,\n module,\n });\n return { plan, module, client, router };\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 return (await selectClient(params)).client;\n}\n\n/** The app's client, and the router when it is one. */\nasync function selectClient(params: AppReactorClientParams): Promise<{\n client: IReactorClient;\n router?: MultiReactor.ConnectRoutingClient;\n}> {\n if (params.mode === \"remote\") {\n setFullReactorClient(undefined);\n const remote = await buildRemoteOnly(params);\n setFullReactorClient(remote);\n return { client: remote, router: remote };\n }\n if (params.mode !== \"router\") {\n if (getPHStore()?.fullReactorClient) {\n setFullReactorClient(undefined);\n }\n return { client: requireModule(params).client };\n }\n setFullReactorClient(undefined);\n const routed = await buildRouter(params);\n setFullReactorClient(routed);\n return routed\n ? { client: routed, router: routed }\n : { client: 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\n/** The switchboards to route to: the host's remote backends, else the default drive's. */\nfunction switchboardRemotes(params: AppReactorClientParams): {\n remotes: MultiReactor.SwitchboardRemote[];\n unparsed: string[];\n} {\n const listed: readonly PHConnectRemoteBackend[] = params.remoteBackends\n ?.length\n ? params.remoteBackends\n : params.remoteDriveUrl\n ? [{ name: REMOTE_BACKEND_NAME, url: params.remoteDriveUrl }]\n : [];\n const remotes: MultiReactor.SwitchboardRemote[] = [];\n const unparsed: string[] = [];\n for (const { url, ...remote } of listed) {\n const graphqlUrl = switchboardOfDrive(url)?.graphql;\n if (graphqlUrl) remotes.push({ ...remote, graphqlUrl });\n else unparsed.push(url);\n }\n return { remotes, unparsed };\n}\n\nasync function buildRouter(\n params: AppReactorClientParams,\n): Promise<MultiReactor.ConnectRoutingClient | undefined> {\n const { remotes, unparsed } = switchboardRemotes(params);\n for (const url of unparsed) {\n logger.warn(\n \"multiReactor is on but the remote drive URL @url does not parse; skipping it\",\n url,\n );\n }\n // New drives belong on a switchboard: without the router they would be\n // created in this browser, so it is required.\n const newDrives = params.router?.newDrives;\n if (remotes.length === 0) {\n if (newDrives !== undefined) {\n throw new Error(\n `New drives go to ${newDrives}, but this Connect has no address for it, so it can't start.`,\n );\n }\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 if (newDrives !== undefined) {\n throw new Error(\n `New drives go to ${newDrives}, but the router that reaches it didn't load, so Connect can't start.`,\n { cause: error },\n );\n }\n logger.error(\"Could not load the multi-reactor router: @error\", error);\n return undefined;\n }\n logger.info(\n \"Multi-reactor routing to @urls\",\n remotes.map((remote) => remote.graphqlUrl).join(\", \"),\n );\n return multiReactor.buildMultiReactorClient({\n module: requireModule(params),\n remotes,\n collections: params.collections,\n ...params.router,\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<MultiReactor.ConnectRoutingClient> {\n const { remotes, unparsed } = switchboardRemotes(params);\n if (unparsed.length > 0) {\n throw new Error(\n `reactorClient \"remote\": the remote drive URL \"${unparsed[0]}\" does not resolve to a Switchboard GraphQL endpoint`,\n );\n }\n if (remotes.length === 0) {\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 logger.info(\n \"Remote reactor client → @urls\",\n remotes.map((remote) => remote.graphqlUrl).join(\", \"),\n );\n return multiReactor.buildMultiReactorClient({\n module: undefined,\n remotes,\n collections: params.collections,\n ...params.router,\n signer: params.signer,\n documentModelModules: params.documentModelModules,\n });\n}\n","import { isDriveAuthError } from \"@powerhousedao/reactor\";\n\n/** A drive create the switchboard new drives go to did not answer. */\nexport class NewDriveUnansweredError extends Error {\n override readonly name = \"NewDriveUnansweredError\";\n\n constructor(\n readonly backend: string,\n options?: ErrorOptions,\n ) {\n super(`${backend} isn't answering, so the drive wasn't created.`, options);\n }\n}\n\n/** `auth`: the switchboard refused the caller, so signing in may help. */\nexport class NewDriveRefusedError extends Error {\n override readonly name = \"NewDriveRefusedError\";\n\n constructor(\n readonly backend: string,\n readonly auth: boolean,\n reason: string | undefined,\n options?: ErrorOptions,\n ) {\n super(\n reason\n ? `${backend} refused the new drive: ${reason}`\n : `${backend} refused the new drive.`,\n options,\n );\n }\n}\n\n// fetch's network failure: Node, Chrome, Firefox, Safari.\nconst NETWORK_FAILURE =\n /fetch failed|failed to fetch|networkerror|load failed/i;\n\ntype Failure = {\n name?: unknown;\n message?: unknown;\n cause?: unknown;\n statusCode?: unknown;\n category?: unknown;\n response?: { status?: unknown; errors?: { message?: unknown }[] };\n};\n\n/** Each error in the cause chain, outermost first. */\nfunction* chain(error: unknown): Generator<Failure> {\n for (let at = error; at; at = (at as Failure).cause) yield at as Failure;\n}\n\nfunction statusOf(at: Failure): number | undefined {\n const status = at.response?.status ?? at.statusCode;\n return typeof status === \"number\" ? status : undefined;\n}\n\n/** A failure to reach a switchboard, not an answer from it. */\nfunction isUnanswered(error: unknown): boolean {\n for (const at of chain(error)) {\n if (\n at.name === \"SwitchboardUnreachableError\" ||\n at.name === \"TimeoutError\" ||\n at.name === \"ProbeTimeoutError\" ||\n at.category === \"network\" ||\n (at instanceof TypeError && NETWORK_FAILURE.test(at.message))\n ) {\n return true;\n }\n const status = statusOf(at);\n if (status !== undefined && status >= 500) return true;\n }\n return false;\n}\n\nfunction isAuthRefusal(error: unknown): boolean {\n for (const at of chain(error)) {\n if (isDriveAuthError(at)) return true;\n const status = statusOf(at);\n if (status === 401 || status === 403) return true;\n }\n return false;\n}\n\n/** An answer from a server, not a failure in this browser. */\nfunction isServerAnswer(error: unknown): boolean {\n for (const at of chain(error)) {\n if (\n at.response !== undefined ||\n statusOf(at) !== undefined ||\n at.name === \"GraphQLRequestError\" ||\n at.name === \"MisrouteUnresolvedError\"\n ) {\n return true;\n }\n }\n return false;\n}\n\n/** The first reason the switchboard gave, if it gave one. */\nfunction reasonOf(error: unknown): string | undefined {\n for (const at of chain(error)) {\n const message = at.response?.errors?.[0]?.message;\n if (typeof message === \"string\" && message !== \"\") return message;\n if (at.name === \"GraphQLRequestError\" && typeof at.message === \"string\") {\n return at.message;\n }\n }\n return undefined;\n}\n\n/** A failed drive create, named for the switchboard `client` creates new drives on; else `error` itself. */\nexport function newDriveError(client: unknown, error: unknown): unknown {\n const backend = (client as { newDrives?: unknown } | null | undefined)\n ?.newDrives;\n if (typeof backend !== \"string\") return error;\n if (isUnanswered(error)) {\n return new NewDriveUnansweredError(backend, { cause: error });\n }\n if (!isServerAnswer(error)) return error;\n return new NewDriveRefusedError(\n backend,\n isAuthRefusal(error),\n reasonOf(error),\n { cause: error },\n );\n}\n","import { DriveCollectionId } from \"@powerhousedao/reactor\";\nimport type {\n PHConnectCollection,\n PHConnectRemoteBackend,\n PHConnectRuntimeDefaultDrive,\n} from \"@powerhousedao/shared/clis\";\nimport { switchboardOfDrive } from \"@powerhousedao/shared/host-tokens\";\nimport { logger } from \"document-model\";\n\n/** The router backend of the reactor in this browser. */\nexport const LOCAL_BACKEND_NAME = \"connect-local\";\n\n/** A drive the host keeps on a switchboard, and where its config opens it. */\nexport type SwitchboardDrive = {\n /** The host's name for it: its address's slug, or a collection's key. */\n slug: string;\n url: string;\n /** The switchboard's backend. */\n remote: string;\n /** `remote` (no copy here) or `LOCAL_BACKEND_NAME` (a synced copy). */\n configured: string;\n /** Not a default drive: its address may not be the one it is served at. */\n collection: boolean;\n};\n\n/** A switchboard drive with the names callers reach it by. */\nexport type ResolvedSwitchboardDrive = SwitchboardDrive & {\n id?: string;\n servedSlug?: string;\n};\n\n/** A drive this browser moved away from its host config. */\nexport type PlacementEntry = {\n slug: string;\n backend: string;\n configWas: string;\n};\n\ntype PlacementConfig = {\n drives?: { defaultDrives?: readonly PHConnectRuntimeDefaultDrive[] };\n instance?: {\n remoteBackends?: readonly PHConnectRemoteBackend[];\n collections?: Record<string, PHConnectCollection>;\n };\n};\n\n/** The config's local default drives, placed on this browser so a\n * switchboard `newDrives` doesn't take them. */\nexport function localDrivePlacements(\n defaultDrives: readonly PHConnectRuntimeDefaultDrive[],\n): Record<string, string> {\n return Object.fromEntries(\n defaultDrives.flatMap((drive) =>\n !(\"url\" in drive) && drive.id ? [[drive.id, LOCAL_BACKEND_NAME]] : [],\n ),\n );\n}\n\nexport function keepsLocalCopy(drive: PHConnectRuntimeDefaultDrive): boolean {\n return !(\"url\" in drive) || drive.sync !== false;\n}\n\n/** Remote default drives with a backend, then collections. */\nexport function switchboardDrives(config: PlacementConfig): SwitchboardDrive[] {\n const drives: SwitchboardDrive[] = [];\n for (const drive of config.drives?.defaultDrives ?? []) {\n if (!(\"url\" in drive) || !drive.backend) continue;\n const slug = switchboardOfDrive(drive.url)?.slug;\n if (slug === undefined) continue;\n drives.push({\n slug,\n url: drive.url,\n remote: drive.backend,\n configured: drive.sync === false ? drive.backend : LOCAL_BACKEND_NAME,\n collection: false,\n });\n }\n const remotes = config.instance?.remoteBackends ?? [];\n for (const [slug, entry] of Object.entries(\n config.instance?.collections ?? {},\n )) {\n const remote = remotes.find((r) => r.name === entry.backend);\n const base = remote && switchboardOfDrive(remote.url)?.base;\n if (!base || drives.some((drive) => drive.slug === slug)) continue;\n drives.push({\n slug,\n url: `${base}/d/${encodeURIComponent(slug)}`,\n remote: entry.backend,\n configured: entry.sync === false ? entry.backend : LOCAL_BACKEND_NAME,\n collection: true,\n });\n }\n return drives;\n}\n\n/** Stale: no such drive, a backend it can't open on, back to config, or a changed config value. */\nexport function applyPlacementEntries(\n drives: readonly SwitchboardDrive[],\n entries: readonly PlacementEntry[],\n): { applied: PlacementEntry[]; stale: PlacementEntry[] } {\n const applied: PlacementEntry[] = [];\n const stale: PlacementEntry[] = [];\n for (const entry of entries) {\n const drive = drives.find((d) => d.slug === entry.slug);\n const holds =\n drive !== undefined &&\n entry.configWas === drive.configured &&\n entry.backend !== drive.configured &&\n (entry.backend === drive.remote || entry.backend === LOCAL_BACKEND_NAME);\n (holds ? applied : stale).push(entry);\n }\n return { applied, stale };\n}\n\n/** A served slug names a declared one as is, or hashed (`<slug>-<8 hex>`). */\nexport function servesSlug(declared: string, served: string): boolean {\n return (\n served === declared ||\n (served.startsWith(`${declared}-`) &&\n /^[0-9a-f]{8}$/.test(served.slice(declared.length + 1)))\n );\n}\n\ntype DriveNames = { id: string; slug: string };\n\nfunction withinDeadline<T>(work: Promise<T>, timeoutMs: number): Promise<T> {\n let timer: ReturnType<typeof setTimeout> | undefined;\n const deadline = new Promise<never>((_, reject) => {\n timer = setTimeout(\n () => reject(new Error(`no answer in ${timeoutMs} ms`)),\n timeoutMs,\n );\n });\n return Promise.race([work, deadline]).finally(() => clearTimeout(timer));\n}\n\nexport type ResolveSwitchboardDrivesOptions = {\n timeoutMs?: number;\n /** A collection whose address does not answer: find it among its switchboard's drives. */\n findServed?: (drive: SwitchboardDrive) => Promise<DriveNames | undefined>;\n};\n\n/** An unreachable drive keeps only the slug in its address. */\nexport async function resolveSwitchboardDrives(\n drives: readonly SwitchboardDrive[],\n fetchInfo: (url: string) => Promise<DriveNames>,\n { timeoutMs = 5_000, findServed }: ResolveSwitchboardDrivesOptions = {},\n): Promise<ResolvedSwitchboardDrive[]> {\n return Promise.all(\n drives.map(async (drive): Promise<ResolvedSwitchboardDrive> => {\n try {\n const { id, slug } = await withinDeadline(\n fetchInfo(drive.url),\n timeoutMs,\n );\n return { ...drive, id, servedSlug: slug };\n } catch (error) {\n if (drive.collection && findServed) {\n try {\n const served = await withinDeadline(findServed(drive), timeoutMs);\n if (served) {\n return { ...drive, id: served.id, servedSlug: served.slug };\n }\n } catch (findError) {\n logger.warn(\n \"Could not find drive @slug on @remote: @error\",\n drive.slug,\n drive.remote,\n findError,\n );\n }\n }\n logger.warn(\n \"Could not read drive @url; routing it by its address only: @error\",\n drive.url,\n error,\n );\n const slug = switchboardOfDrive(drive.url)?.slug;\n return slug === undefined ? drive : { ...drive, servedSlug: slug };\n }\n }),\n );\n}\n\n/** The address the drive is served at. */\nexport function servedUrl(drive: ResolvedSwitchboardDrive): string {\n const at = switchboardOfDrive(drive.url);\n return at && drive.servedSlug && drive.servedSlug !== at.slug\n ? `${at.base}/d/${encodeURIComponent(drive.servedSlug)}`\n : drive.url;\n}\n\n/** The keys a placement is installed under: the id and the served slug. */\nexport function placementKeys(drive: ResolvedSwitchboardDrive): string[] {\n return [drive.id, drive.servedSlug].filter(\n (key): key is string => key !== undefined && key !== \"\",\n );\n}\n\nexport type SyncRemotes = {\n list(): readonly {\n meta: { name: string; collectionId: DriveCollectionId };\n }[];\n remove(name: string): Promise<void>;\n};\n\n/** Drops the sync remote of every given drive; its local data is left unread. */\nexport async function removeLocalCopies(\n sync: SyncRemotes,\n resolved: readonly { id?: string }[],\n): Promise<void> {\n for (const drive of resolved) {\n if (!drive.id) continue;\n const collectionId = DriveCollectionId.forDrive(drive.id);\n const remotes = sync\n .list()\n .filter((remote) => remote.meta.collectionId.equals(collectionId));\n for (const remote of remotes) {\n await sync.remove(remote.meta.name);\n }\n }\n}\n","import type { RoutingReactorClient } from \"@powerhousedao/reactor-router\";\nimport { driveDocumentType } from \"@powerhousedao/shared/document-drive\";\nimport { logger } from \"document-model\";\nimport {\n applyPlacementEntries,\n servesSlug,\n LOCAL_BACKEND_NAME,\n placementKeys,\n removeLocalCopies,\n servedUrl,\n type PlacementEntry,\n type ResolvedSwitchboardDrive,\n type SwitchboardDrive,\n type SyncRemotes,\n} from \"./drive-placement.js\";\n\n/** A collection by its declared slug among its switchboard's drives, e.g. one served hashed. */\nexport async function findServedDrive(\n router: Pick<RoutingReactorClient, \"backends\">,\n drive: SwitchboardDrive,\n): Promise<{ id: string; slug: string } | undefined> {\n const backend = router.backends.find((b) => b.name === drive.remote);\n if (!backend) return undefined;\n const { results } = await backend.api.find({ type: driveDocumentType });\n const served = results.find(\n (doc) => doc.header.slug && servesSlug(drive.slug, doc.header.slug),\n );\n return served && { id: served.header.id, slug: served.header.slug };\n}\n\n/** Where a drive opens given its stored move, if any: the move, else the host config. */\nexport function effectiveBackend(\n drive: SwitchboardDrive,\n entry: PlacementEntry | undefined,\n): string {\n return entry?.backend ?? drive.configured;\n}\n\n/** A drive opening on `backend` reads its copy here, which must arrive first. */\nexport function needsCopy(backend: string): boolean {\n return backend === LOCAL_BACKEND_NAME;\n}\n\n/** A copy has caught up once every scope is at least at the source's revision. */\nexport function caughtUp(\n local: Readonly<Record<string, number>>,\n source: Readonly<Record<string, number>>,\n): boolean {\n return Object.entries(source).every(\n ([scope, revision]) => (local[scope] ?? -1) >= revision,\n );\n}\n\n/** Where this browser keeps its moves; per origin, so every tab shares it. */\nexport interface PlacementStore {\n list(): Promise<PlacementEntry[]>;\n put(entry: PlacementEntry): Promise<void>;\n delete(slug: string): Promise<void>;\n}\n\n/** The router's two placement layers. */\nexport type PlacementRouter = {\n setPlacement(key: string, backend: string | undefined): void;\n setConfiguredPlacement(key: string, backend: string | undefined): void;\n};\n\nexport type PlacementSync = SyncRemotes & {\n /** Adds a sync remote for the drive. */\n add(url: string, driveId: string): Promise<void>;\n /** Bounded wait until the local copy holds what `remote` holds; rejects when it does not. */\n untilCopied(driveId: string, remote: string): Promise<void>;\n};\n\nexport type DrivePlacement = {\n drive: ResolvedSwitchboardDrive;\n /** Where the drive opens in this browser now. */\n backend: string;\n /** This browser moved it away from the host config. */\n moved: boolean;\n /** A move is running. */\n busy: boolean;\n /** Where a running move takes the drive. */\n movingTo?: string;\n};\n\n/** Config placement plus this browser's moves: store, then sync remote, then router. */\nexport class DrivePlacements {\n private applied = new Map<string, PlacementEntry>();\n private resolved: ResolvedSwitchboardDrive[] = [];\n private router: PlacementRouter | undefined;\n private readonly busy = new Map<string, string>();\n private attached = false;\n private readonly listeners = new Set<() => void>();\n private snapshot = new Map<string, DrivePlacement>();\n\n constructor(\n readonly drives: readonly SwitchboardDrive[],\n applied: readonly PlacementEntry[],\n private readonly store: PlacementStore,\n private readonly sync: PlacementSync,\n ) {\n for (const entry of applied) this.applied.set(entry.slug, entry);\n }\n\n /** Reads the store and drops the entries the config has overtaken (O2). */\n static async load(\n drives: readonly SwitchboardDrive[],\n store: PlacementStore,\n sync: PlacementSync,\n ): Promise<DrivePlacements> {\n let entries: PlacementEntry[] = [];\n try {\n entries = await store.list();\n } catch (error) {\n logger.warn(\"Could not read this browser's drive moves: @error\", error);\n }\n const { applied, stale } = applyPlacementEntries(drives, entries);\n for (const entry of stale) {\n store.delete(entry.slug).catch((error: unknown) => {\n logger.warn(\n \"Could not drop drive move @slug: @error\",\n entry.slug,\n error,\n );\n });\n }\n return new DrivePlacements(drives, applied, store, sync);\n }\n\n /** Where `drive` opens in this browser: a move, else the config. */\n backendOf(drive: SwitchboardDrive): string {\n return effectiveBackend(drive, this.applied.get(drive.slug));\n }\n\n /** Whether a remote default drive at `url` keeps a copy here. */\n keepsCopy(url: string): boolean {\n const drive = this.drives.find((d) => d.url === url);\n return !drive || this.backendOf(drive) === LOCAL_BACKEND_NAME;\n }\n\n /** Drives that open on their switchboard with no copy here. */\n placed(): SwitchboardDrive[] {\n return this.drives.filter(\n (drive) => this.backendOf(drive) !== LOCAL_BACKEND_NAME,\n );\n }\n\n /** Collections this browser keeps a copy of; default drives are added with the others. */\n keptCollections(): ResolvedSwitchboardDrive[] {\n return this.resolved.filter(\n (drive) =>\n drive.collection &&\n drive.id !== undefined &&\n this.backendOf(drive) === LOCAL_BACKEND_NAME,\n );\n }\n\n /** Installs both layers for every drive the router can be told about. */\n attach(\n router: PlacementRouter | undefined,\n resolved: readonly ResolvedSwitchboardDrive[],\n ): void {\n this.router = router;\n this.resolved = [...resolved];\n this.attached = true;\n for (const drive of this.resolved) this.install(drive);\n this.notify();\n }\n\n /**\n * Attaches, follows the moves other tabs made since `load`, then brings\n * the sync remotes in line; returns the collections to keep a copy of.\n */\n async start(\n router: PlacementRouter | undefined,\n resolved: readonly ResolvedSwitchboardDrive[],\n syncsDrives: boolean,\n ): Promise<ResolvedSwitchboardDrive[]> {\n this.attach(router, resolved);\n await this.reload();\n if (!syncsDrives) return [];\n const placed = new Set(this.placed().map((drive) => drive.slug));\n await removeLocalCopies(\n this.sync,\n this.resolved.filter(\n (drive) => placed.has(drive.slug) && !this.busy.has(drive.slug),\n ),\n );\n return this.keptCollections();\n }\n\n /** The drive's placement in this browser; undefined for a drive the host does not place on a switchboard. */\n placementOf(driveId: string): DrivePlacement | undefined {\n return this.snapshot.get(driveId);\n }\n\n subscribe(listener: () => void): () => void {\n this.listeners.add(listener);\n return () => {\n this.listeners.delete(listener);\n };\n }\n\n /** Opens the drive on `backend` in this browser: its switchboard, or a copy here. */\n async move(driveId: string, backend: string): Promise<void> {\n const drive = this.resolved.find((d) => d.id === driveId);\n if (!drive?.id) {\n throw new Error(\n `Drive ${driveId} is not on a switchboard this app links`,\n );\n }\n if (backend !== drive.remote && backend !== LOCAL_BACKEND_NAME) {\n throw new Error(`Drive ${drive.slug} can't open on ${backend}`);\n }\n if (this.busy.has(drive.slug) || this.backendOf(drive) === backend) return;\n const previous = this.applied.get(drive.slug);\n const entry: PlacementEntry | undefined =\n backend === drive.configured\n ? undefined\n : { slug: drive.slug, backend, configWas: drive.configured };\n const id = drive.id;\n this.busy.set(drive.slug, backend);\n this.notify();\n try {\n await this.record(drive.slug, entry);\n if (needsCopy(backend)) {\n try {\n await this.sync.add(servedUrl(drive), id);\n await this.sync.untilCopied(id, drive.remote);\n } catch (error) {\n // Store first: the removal's broadcast makes other tabs re-read it.\n await this.record(drive.slug, previous);\n await removeLocalCopies(this.sync, [drive]);\n throw error;\n }\n } else {\n try {\n await removeLocalCopies(this.sync, [drive]);\n } catch (error) {\n await this.record(drive.slug, previous);\n throw error;\n }\n }\n this.install(drive);\n } finally {\n this.busy.delete(drive.slug);\n this.notify();\n }\n }\n\n /** Back to where the host config opens the drive. */\n reset(driveId: string): Promise<void> {\n const drive = this.resolved.find((d) => d.id === driveId);\n return drive ? this.move(driveId, drive.configured) : Promise.resolve();\n }\n\n /** Re-reads the store after another tab moved a drive; true when something changed. */\n async reload(): Promise<boolean> {\n if (!this.attached) return false;\n const next = await this.readMoves();\n if (!next) return false;\n const changed = this.drives.filter(\n (drive) =>\n !this.busy.has(drive.slug) &&\n effectiveBackend(drive, next.get(drive.slug)) !== this.backendOf(drive),\n );\n if (changed.length === 0) return false;\n await Promise.all(\n changed.map((drive) => this.follow(drive, next.get(drive.slug))),\n );\n this.notify();\n return true;\n }\n\n /** A copy kept by another tab is routed here only once it has arrived. */\n private async follow(\n drive: SwitchboardDrive,\n entry: PlacementEntry | undefined,\n ): Promise<void> {\n const resolved = this.resolved.find((d) => d.slug === drive.slug);\n if (needsCopy(effectiveBackend(drive, entry)) && resolved?.id) {\n this.busy.set(drive.slug, LOCAL_BACKEND_NAME);\n this.notify();\n try {\n await this.sync.untilCopied(resolved.id, resolved.remote);\n } catch (error) {\n logger.warn(\n \"Drive @slug was not copied into this browser; leaving it where it opens: @error\",\n drive.slug,\n error,\n );\n return;\n } finally {\n this.busy.delete(drive.slug);\n }\n // The mover may have rolled back while this tab waited.\n const latest = await this.readMoves();\n if (!latest) return;\n entry = latest.get(drive.slug);\n }\n if (entry) this.applied.set(drive.slug, entry);\n else this.applied.delete(drive.slug);\n if (resolved) this.install(resolved);\n }\n\n private async readMoves(): Promise<Map<string, PlacementEntry> | undefined> {\n let entries: PlacementEntry[];\n try {\n entries = await this.store.list();\n } catch (error) {\n logger.warn(\"Could not read this browser's drive moves: @error\", error);\n return undefined;\n }\n const { applied } = applyPlacementEntries(this.drives, entries);\n return new Map(applied.map((entry) => [entry.slug, entry]));\n }\n\n private async record(\n slug: string,\n entry: PlacementEntry | undefined,\n ): Promise<void> {\n if (entry) {\n await this.store.put(entry);\n this.applied.set(slug, entry);\n } else {\n await this.store.delete(slug);\n this.applied.delete(slug);\n }\n }\n\n private install(drive: ResolvedSwitchboardDrive): void {\n const router = this.router;\n if (!router) return;\n const configured =\n drive.configured === drive.remote ? drive.remote : undefined;\n const runtime = this.applied.get(drive.slug)?.backend;\n for (const key of placementKeys(drive)) {\n router.setConfiguredPlacement(key, configured);\n router.setPlacement(key, runtime);\n }\n }\n\n private notify(): void {\n const snapshot = new Map<string, DrivePlacement>();\n for (const drive of this.resolved) {\n if (!drive.id) continue;\n const backend = this.backendOf(drive);\n snapshot.set(drive.id, {\n drive,\n backend,\n moved: backend !== drive.configured,\n busy: this.busy.has(drive.slug),\n ...(this.busy.has(drive.slug)\n ? { movingTo: this.busy.get(drive.slug) }\n : {}),\n });\n }\n this.snapshot = snapshot;\n for (const listener of [...this.listeners]) listener();\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);\n return pkg;\n}\n"],"mappings":";;;;;;;;;AAGA,SAAgB,wBAAiC;CAC/C,OAAO,iBAAiB,CAAC,CAAC,QAAQ,UAAU,gBAAgB;AAC9D;;;ACEA,MAAa,2BAA2B;AACxC,MAAa,6BAA6B;AAI1C,SAAgB,4BACd,OACS;CACT,OAAO,mBAAmB,KAAK;AACjC;AAEA,SAAgB,yBAAkC;CAChD,OAAO,qBAAqB;EAC1B,UAAU;EACV,YAAY;EACZ,sBACE,iBAAiB,CAAC,CAAC,QAAQ,UAAU,iBAAiB;CAC1D,C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