@powerhousedao/connect 6.2.3-dev.8 → 6.2.3-dev.80
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/README.md +29 -1
- package/dist/{AddDriveModal-xAw48kdl.js → AddDriveModal-CFi-9FQU.js} +28 -15
- package/dist/AddDriveModal-CFi-9FQU.js.map +1 -0
- package/dist/{ClearStorageModal-BAqs4G2s.js → ClearStorageModal-XlHarNph.js} +11 -13
- package/dist/ClearStorageModal-XlHarNph.js.map +1 -0
- package/dist/{ConfirmDocumentUpgradeModal-FUOhZsk7.js → ConfirmDocumentUpgradeModal-CoixS60F.js} +9 -8
- package/dist/ConfirmDocumentUpgradeModal-CoixS60F.js.map +1 -0
- package/dist/{CookiesPolicyModal-BpyPPyxS.js → CookiesPolicyModal-BpFjYc7T.js} +5 -5
- package/dist/{CookiesPolicyModal-BpyPPyxS.js.map → CookiesPolicyModal-BpFjYc7T.js.map} +1 -1
- package/dist/CreateDocumentModal-CiIW3pzx.js +45 -0
- package/dist/CreateDocumentModal-CiIW3pzx.js.map +1 -0
- package/dist/{DebugSettingsModal-rV_v0F0d.js → DebugSettingsModal-BSafp4hB.js} +9 -9
- package/dist/DebugSettingsModal-BSafp4hB.js.map +1 -0
- package/dist/{DeleteDriveModal-Dug84t1j.js → DeleteDriveModal-1pAIayG_.js} +7 -7
- package/dist/DeleteDriveModal-1pAIayG_.js.map +1 -0
- package/dist/{DeleteItemModal-mMzy3V8o.js → DeleteItemModal-BUpqmFxS.js} +8 -8
- package/dist/DeleteItemModal-BUpqmFxS.js.map +1 -0
- package/dist/{DisclaimerModal-DvpD5dPM.js → DisclaimerModal-TIJXRYLF.js} +7 -7
- package/dist/DisclaimerModal-TIJXRYLF.js.map +1 -0
- package/dist/{DocumentVersionUnsupportedModal-C3Q0V75l.js → DocumentVersionUnsupportedModal-DH9Zzsyw.js} +6 -6
- package/dist/DocumentVersionUnsupportedModal-DH9Zzsyw.js.map +1 -0
- package/dist/{DownloadDocumentWithErrorsModal-IKl0ljQb.js → DownloadDocumentWithErrorsModal-Beh-xw8B.js} +8 -7
- package/dist/DownloadDocumentWithErrorsModal-Beh-xw8B.js.map +1 -0
- package/dist/{DriveAuthRequiredModal-DVK7ZQzO.js → DriveAuthRequiredModal-XTcoJKvj.js} +7 -7
- package/dist/DriveAuthRequiredModal-XTcoJKvj.js.map +1 -0
- package/dist/{DriveSettingsModal-C6-mRQiv.js → DriveSettingsModal-DZKawN7w.js} +6 -6
- package/dist/DriveSettingsModal-DZKawN7w.js.map +1 -0
- package/dist/FloatingTanStackRouterDevtools-CqogiFob-dxj8lrTP.js +2565 -0
- package/dist/FloatingTanStackRouterDevtools-CqogiFob-dxj8lrTP.js.map +1 -0
- package/dist/{InspectorModal-CpEhVnM6.js → InspectorModal-BEil2KCK.js} +70 -30
- package/dist/InspectorModal-BEil2KCK.js.map +1 -0
- package/dist/{LoginModal-CybbOm3N.js → LoginModal-O06ZvWFI.js} +8 -8
- package/dist/LoginModal-O06ZvWFI.js.map +1 -0
- package/dist/{OpenFileDocumentsModal-BW3ZFRDR.js → OpenFileDocumentsModal-DJsC1oR1.js} +22 -16
- package/dist/OpenFileDocumentsModal-DJsC1oR1.js.map +1 -0
- package/dist/{UpgradeDriveModal-_8t9slxQ.js → UpgradeDriveModal-CCWKp5yn.js} +7 -7
- package/dist/UpgradeDriveModal-CCWKp5yn.js.map +1 -0
- package/dist/app-loader-C1jLx7Yk.js +4 -0
- package/dist/app-loader-i_orb0RX.js +1254 -0
- package/dist/app-loader-i_orb0RX.js.map +1 -0
- package/dist/app-skeleton-CMUP2zaz.js +132 -0
- package/dist/app-skeleton-CMUP2zaz.js.map +1 -0
- package/dist/app-skeleton-CdD1m8G3.js +4 -0
- package/dist/boot-66bf7yVc.js +233 -0
- package/dist/boot-66bf7yVc.js.map +1 -0
- package/dist/buffer-DNTcuap_.js +66 -0
- package/dist/buffer-DNTcuap_.js.map +1 -0
- package/dist/{build-info-D1h45Bga.js → build-info-Dg9V2Zes.js} +10 -6
- package/dist/build-info-Dg9V2Zes.js.map +1 -0
- package/dist/components-C5X9jfPL.js +121 -0
- package/dist/components-C5X9jfPL.js.map +1 -0
- package/dist/{connect.config-DaHDEUrw.js → connect.config-DL9nKtlW.js} +28 -15
- package/dist/connect.config-DL9nKtlW.js.map +1 -0
- package/dist/{connection-state-3w4liC1X.js → connection-state-Bwm9Agwy.js} +20 -9
- package/dist/connection-state-Bwm9Agwy.js.map +1 -0
- package/dist/context-De2EB1AA-Ni0d829Q.js +1759 -0
- package/dist/context-De2EB1AA-Ni0d829Q.js.map +1 -0
- package/dist/{cookie-banner-BH6bIq24.js → cookie-banner-NclLYtB0.js} +7 -7
- package/dist/{cookie-banner-BH6bIq24.js.map → cookie-banner-NclLYtB0.js.map} +1 -1
- package/dist/document-editor-container-CGLXOl0t.js +4 -0
- package/dist/document-editor-container-FNIEsf8H.js +310 -0
- package/dist/document-editor-container-FNIEsf8H.js.map +1 -0
- package/dist/drive-icon-BIpd8edR.js +49 -0
- package/dist/drive-icon-BIpd8edR.js.map +1 -0
- package/dist/error-boundary-BsUBww61.js +155 -0
- package/dist/error-boundary-BsUBww61.js.map +1 -0
- package/dist/esm-BDACZntJ.js +148 -0
- package/dist/esm-BDACZntJ.js.map +1 -0
- package/dist/generic.d.ts +140 -0
- package/dist/generic.d.ts.map +1 -0
- package/dist/generic.js +31 -0
- package/dist/generic.js.map +1 -0
- package/dist/{i18n-CWO0vYVd.js → i18n-D9WYPgk9.js} +4 -4
- package/dist/{i18n-CWO0vYVd.js.map → i18n-D9WYPgk9.js.map} +1 -1
- package/dist/index-D7c2WAbn.d.ts +4 -0
- package/dist/layout-Dj3_KscE.js +5 -0
- package/dist/layout.d.ts +3 -0
- package/dist/layout.js +4 -0
- package/dist/{load-B0xIT-MF.js → load-jNCWf-Tp.js} +48 -46
- package/dist/load-jNCWf-Tp.js.map +1 -0
- package/dist/load-runtime-config-BAaAgQg0.js +14 -0
- package/dist/load-runtime-config-BAaAgQg0.js.map +1 -0
- package/dist/main.d.ts +2 -1
- package/dist/main.js +8 -8
- package/dist/main.js.map +1 -1
- package/dist/open-file-uploads-B5pr1sA2.js +183 -0
- package/dist/open-file-uploads-B5pr1sA2.js.map +1 -0
- package/dist/package-manager-B-bEk-5n.js +543 -0
- package/dist/package-manager-B-bEk-5n.js.map +1 -0
- package/dist/{pglite-major-B39aOEiE.js → pglite-major-p4_YefAE.js} +23 -5
- package/dist/pglite-major-p4_YefAE.js.map +1 -0
- package/dist/{pglite-migrate-core-Boxqqx-c.js → pglite-migrate-core-DBlU6HIc.js} +9 -7
- package/dist/pglite-migrate-core-DBlU6HIc.js.map +1 -0
- package/dist/{pglite-seed-BqAUvNFw.js → pglite-seed-QPbGbLB_.js} +4 -4
- package/dist/{pglite-seed-BqAUvNFw.js.map → pglite-seed-QPbGbLB_.js.map} +1 -1
- package/dist/pglite.worker.d.ts +2 -1
- package/dist/pglite.worker.js +4 -3
- package/dist/pglite.worker.js.map +1 -1
- package/dist/pglite.worker.legacy.d.ts +2 -1
- package/dist/pglite.worker.legacy.js +4 -3
- package/dist/pglite.worker.legacy.js.map +1 -1
- package/dist/plugin-configs.d.ts +242 -0
- package/dist/plugin-configs.d.ts.map +1 -0
- package/dist/plugin-configs.js +26 -0
- package/dist/plugin-configs.js.map +1 -0
- package/dist/plugins-CPd2_0eG.js +264 -0
- package/dist/plugins-CPd2_0eG.js.map +1 -0
- package/dist/{preferences-store-_5Cw4_YV.js → preferences-store-DxYAnGCc.js} +6 -25
- package/dist/preferences-store-DxYAnGCc.js.map +1 -0
- package/dist/prerender.d.ts +38 -0
- package/dist/prerender.d.ts.map +1 -0
- package/dist/prerender.js +195 -0
- package/dist/prerender.js.map +1 -0
- package/dist/prerendered-shell-peKE7AqI.js +51 -0
- package/dist/prerendered-shell-peKE7AqI.js.map +1 -0
- package/dist/{pwa-manifest-link-DIgOSo2Q.js → pwa-manifest-link-DQRJpF0r.js} +3 -3
- package/dist/{pwa-manifest-link-DIgOSo2Q.js.map → pwa-manifest-link-DQRJpF0r.js.map} +1 -1
- package/dist/{reactor-B6xhZK1N.js → reactor-BEYvZrpZ.js} +565 -567
- package/dist/reactor-BEYvZrpZ.js.map +1 -0
- package/dist/reactor-chat-BwR9R1ah.js +46 -0
- package/dist/reactor-chat-BwR9R1ah.js.map +1 -0
- package/dist/reactor.worker.d.ts +2 -1
- package/dist/reactor.worker.js +478 -158
- package/dist/reactor.worker.js.map +1 -1
- package/dist/{registerServiceWorker-BSzbNfvz.js → registerServiceWorker-X6fT91iL.js} +5 -5
- package/dist/{registerServiceWorker-BSzbNfvz.js.map → registerServiceWorker-X6fT91iL.js.map} +1 -1
- package/dist/root-v9fj27sn.js +27 -0
- package/dist/root-v9fj27sn.js.map +1 -0
- package/dist/route-tree.d.ts +2220 -0
- package/dist/route-tree.d.ts.map +1 -0
- package/dist/route-tree.js +135 -0
- package/dist/route-tree.js.map +1 -0
- package/dist/route-views-BovMNHyn.js +60 -0
- package/dist/route-views-BovMNHyn.js.map +1 -0
- package/dist/route-views-C-H3ofJW.js +4 -0
- package/dist/route-views-DzgRMAx8.js +55 -0
- package/dist/route-views-DzgRMAx8.js.map +1 -0
- package/dist/route-views.d.ts +7 -0
- package/dist/route-views.d.ts.map +1 -0
- package/dist/route-views.js +4 -0
- package/dist/router-CWIsjETx.js +54 -0
- package/dist/router-CWIsjETx.js.map +1 -0
- package/dist/router-CnWkTEey.js +4 -0
- package/dist/router.d.ts +2 -0
- package/dist/router.js +3 -0
- package/dist/sentry-Cuc_Nbba.js +22 -0
- package/dist/sentry-Cuc_Nbba.js.map +1 -0
- package/dist/settings-KlgfolUd.js +1089 -0
- package/dist/settings-KlgfolUd.js.map +1 -0
- package/dist/settings-tabs-CJ40jEPe.js +424 -0
- package/dist/settings-tabs-CJ40jEPe.js.map +1 -0
- package/dist/shell-core-head.html +2 -0
- package/dist/shell-core.html +1 -0
- package/dist/shell-head.html +2 -0
- package/dist/shell-plugins.json +1 -0
- package/dist/shell.html +1 -0
- package/dist/start-connect.d.ts +7 -9
- package/dist/start-connect.d.ts.map +1 -1
- package/dist/start-connect.js +9 -8
- package/dist/start-connect.js.map +1 -1
- package/dist/store-lock-Bi3B9VJD.js +159 -0
- package/dist/store-lock-Bi3B9VJD.js.map +1 -0
- package/dist/style.css +3340 -755
- package/dist/{toast-BXIGd4Eb.js → toast-C6WW-_O-.js} +3 -3
- package/dist/{toast-BXIGd4Eb.js.map → toast-C6WW-_O-.js.map} +1 -1
- package/dist/ui-C1-l-Eyh.js +170 -0
- package/dist/ui-C1-l-Eyh.js.map +1 -0
- package/dist/ui-DFO6kV2V.js +66 -0
- package/dist/ui-DFO6kV2V.js.map +1 -0
- package/dist/{use-renown-login-Cf3va6u_.js → use-renown-login-dPpDOYq5.js} +4 -4
- package/dist/use-renown-login-dPpDOYq5.js.map +1 -0
- package/dist/workflows-C3qEvx1R.js +63 -0
- package/dist/workflows-C3qEvx1R.js.map +1 -0
- package/fonts.css +177 -0
- package/generic-routes.json +9 -0
- package/package.json +87 -26
- package/scripts/assert-plugin-configs.mjs +47 -0
- package/scripts/prerender-shell.ts +51 -0
- package/skills/customize-connect/SKILL.md +80 -0
- package/skills/customize-connect/references/data-and-navigation.md +315 -0
- package/skills/customize-connect/references/drive-apps.md +44 -0
- package/skills/customize-connect/references/hosts-and-plugins.md +88 -0
- package/skills/customize-connect/references/layout.md +162 -0
- package/skills/customize-connect/references/modals.md +99 -0
- package/skills/customize-connect/references/overrides.md +177 -0
- package/skills/customize-connect/references/packages.md +41 -0
- package/skills/customize-connect/references/pages.md +141 -0
- package/skills/customize-connect/references/runtime-config.md +403 -0
- package/skills/customize-connect/references/styles-and-branding.md +76 -0
- package/skills/customize-connect/references/types-and-troubleshooting.md +64 -0
- package/src/route-tree.ts +3 -0
- package/src/routeTree.gen.ts +235 -0
- package/src/router/index.ts +2 -0
- package/src/router/register.ts +9 -0
- package/src/routes/__root.tsx +12 -0
- package/src/routes/_app/$.tsx +13 -0
- package/src/routes/_app/d/$driveSlug/{-$nodeSlug}.tsx +13 -0
- package/src/routes/_app/d/$driveSlug.tsx +13 -0
- package/src/routes/_app/index.tsx +13 -0
- package/src/routes/_app/settings/appearance.tsx +13 -0
- package/src/routes/_app/settings/packages.tsx +13 -0
- package/src/routes/_app/settings.tsx +13 -0
- package/src/routes/_app.tsx +13 -0
- package/style.css +8 -23
- package/tailwind.css +12 -0
- package/theme.css +5 -0
- package/dist/AddDriveModal-xAw48kdl.js.map +0 -1
- package/dist/ClearStorageModal-BAqs4G2s.js.map +0 -1
- package/dist/ConfirmDocumentUpgradeModal-FUOhZsk7.js.map +0 -1
- package/dist/CreateDocumentModal-C45W8J0V.js +0 -35
- package/dist/CreateDocumentModal-C45W8J0V.js.map +0 -1
- package/dist/DebugSettingsModal-rV_v0F0d.js.map +0 -1
- package/dist/DeleteDriveModal-Dug84t1j.js.map +0 -1
- package/dist/DeleteItemModal-mMzy3V8o.js.map +0 -1
- package/dist/DisclaimerModal-DvpD5dPM.js.map +0 -1
- package/dist/DocumentVersionUnsupportedModal-C3Q0V75l.js.map +0 -1
- package/dist/DownloadDocumentWithErrorsModal-IKl0ljQb.js.map +0 -1
- package/dist/DriveAuthRequiredModal-DVK7ZQzO.js.map +0 -1
- package/dist/DriveSettingsModal-C6-mRQiv.js.map +0 -1
- package/dist/InspectorModal-CpEhVnM6.js.map +0 -1
- package/dist/LoginModal-CybbOm3N.js.map +0 -1
- package/dist/MissingPackageModal-nBnExqO0.js +0 -49
- package/dist/MissingPackageModal-nBnExqO0.js.map +0 -1
- package/dist/OpenFileDocumentsModal-BW3ZFRDR.js.map +0 -1
- package/dist/SettingsModal-DlxUZEQ4.js +0 -569
- package/dist/SettingsModal-DlxUZEQ4.js.map +0 -1
- package/dist/UpgradeDriveModal-_8t9slxQ.js.map +0 -1
- package/dist/app-loader-D4tbk4ev.js +0 -4
- package/dist/app-loader-Dz_X0r7a.js +0 -2244
- package/dist/app-loader-Dz_X0r7a.js.map +0 -1
- package/dist/build-info-D1h45Bga.js.map +0 -1
- package/dist/components-Bmn9nGdQ.js +0 -4
- package/dist/connect.config-DaHDEUrw.js.map +0 -1
- package/dist/connection-state-3w4liC1X.js.map +0 -1
- package/dist/load-B0xIT-MF.js.map +0 -1
- package/dist/pglite-major-B39aOEiE.js.map +0 -1
- package/dist/pglite-migrate-core-Boxqqx-c.js.map +0 -1
- package/dist/preferences-store-_5Cw4_YV.js.map +0 -1
- package/dist/reactor-B6xhZK1N.js.map +0 -1
- package/dist/runtime-config-DL3QjcfM.js +0 -24
- package/dist/runtime-config-DL3QjcfM.js.map +0 -1
- package/dist/sentry-QXKgQmr2.js +0 -15
- package/dist/sentry-QXKgQmr2.js.map +0 -1
- package/dist/use-renown-login-Cf3va6u_.js.map +0 -1
- package/dist/useRegistryPackages-BnUcL_nZ.js +0 -390
- package/dist/useRegistryPackages-BnUcL_nZ.js.map +0 -1
|
@@ -1,2244 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="15683bfd-9902-5c1c-8759-c972139db200")}catch(e){}}();
|
|
3
|
-
import { n as getRuntimeConfig } from "./runtime-config-DL3QjcfM.js";
|
|
4
|
-
import { c as idbError } from "./pglite-major-B39aOEiE.js";
|
|
5
|
-
import { n as cloneFileData, r as migrateIdb } from "./pglite-migrate-core-Boxqqx-c.js";
|
|
6
|
-
import { a as defaultPHDocumentEditorConfig, i as defaultPHAppConfig, r as connectConfig } from "./connect.config-DaHDEUrw.js";
|
|
7
|
-
import { f as PRIMARY_IDB_NAMES, r as subscribeWorkerConnection, s as getCachedMigrationMajor, t as getWorkerConnectionStatus, u as subscribeMigrationMajor } from "./connection-state-3w4liC1X.js";
|
|
8
|
-
import { n as serviceWorkerManager, r as subscribeServiceWorkerUpdate, t as getServiceWorkerUpdateAvailable } from "./registerServiceWorker-BSzbNfvz.js";
|
|
9
|
-
import { t as setSentryModule } from "./sentry-QXKgQmr2.js";
|
|
10
|
-
import { i as useIsEmbedded, r as getIsEmbedded, t as useAcceptedCookies } from "./preferences-store-_5Cw4_YV.js";
|
|
11
|
-
import { n as dismissToast, r as toast, t as ToastContainer } from "./toast-BXIGd4Eb.js";
|
|
12
|
-
import { t as useOpenRenownLogin } from "./use-renown-login-Cf3va6u_.js";
|
|
13
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
-
import { useTranslation } from "react-i18next";
|
|
15
|
-
import React, { StrictMode, Suspense, createElement, lazy, useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
16
|
-
import { DriveCollectionId, RenownWalletProvider, addFileWithProgress, getRevisionFromDate, initTheme, logout, setPHAppConfig, setPHDocumentEditorConfig, setRevisionHistoryVisible, setSelectedDrive, setSelectedNode, showPHModal, useAppModuleById, useConnectionStates, useDefaultAppModule, useDocumentById, useDocumentModelModuleById, useDocumentOperations, useDocumentVersionStatus, useDrives, useEditorModuleById, useEditorPreloader, useFallbackEditorModule, useIsAddDriveEnabled, useNodeParentFolderById, usePHModal, usePackageDiscoveryService, useReactorClientModule, useRevisionHistoryVisible, useSelectedDocument, useSelectedDocumentId, useSelectedDriveId, useSelectedDriveSafe, useSelectedFolder, useSelectedTimelineItem, useSync, useSyncList, useTheme, useUser, useVetraPackageManager, useVetraPackages } from "@powerhousedao/reactor-browser";
|
|
17
|
-
import { childLogger } from "document-model";
|
|
18
|
-
import { ConnectSidebar, ConnectTooltipProvider, DefaultEditorLoader, DriveAuthGate, DropZoneWrapper, HomeScreen, HomeScreenAddDriveItem, HomeScreenItem, LogoAnimation, PackageInstallModal, RevisionHistory, SidebarAddDriveItem, SidebarItem, UploadFileListContainer, formatFileSize, mapProgressStageToStatus, useEns } from "@powerhousedao/design-system/connect";
|
|
19
|
-
import { Outlet, RouterProvider, createBrowserRouter, createRoutesFromChildren, matchRoutes, useLocation, useNavigationType } from "react-router-dom";
|
|
20
|
-
import { useHotkeys } from "react-hotkeys-hook";
|
|
21
|
-
import { Icon, Modal, PowerhouseButton } from "@powerhousedao/design-system";
|
|
22
|
-
import { ErrorBoundary } from "react-error-boundary";
|
|
23
|
-
import { z } from "zod";
|
|
24
|
-
import { GenericDriveExplorer } from "@powerhousedao/powerhouse-vetra-packages/editors";
|
|
25
|
-
import { createReactorMcpProvider } from "@powerhousedao/reactor-mcp/tools";
|
|
26
|
-
import { ReactorChatFab, createSwitchboardSchemaTool } from "@powerhousedao/reactor-browser/ai";
|
|
27
|
-
import { twMerge } from "tailwind-merge";
|
|
28
|
-
import { mockAdapter } from "@renown/sdk/wallet/mock";
|
|
29
|
-
import { privyAdapter } from "@renown/sdk/wallet/privy";
|
|
30
|
-
import { rainbowAdapter } from "@renown/sdk/wallet/rainbow";
|
|
31
|
-
import { arbitrum, base, mainnet, optimism, polygon, sepolia } from "wagmi/chains";
|
|
32
|
-
import { redo, undo } from "@powerhousedao/shared/document-model";
|
|
33
|
-
//#region src/utils/browser.ts
|
|
34
|
-
function getBasePath() {
|
|
35
|
-
if (typeof document === "undefined") return "/";
|
|
36
|
-
return document.querySelector("base")?.getAttribute("href") || "/";
|
|
37
|
-
}
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region src/utils/document-editor-debug-tools.ts
|
|
40
|
-
var DocumentEditorDebugTools = class {
|
|
41
|
-
document;
|
|
42
|
-
operations = [];
|
|
43
|
-
constructor(document) {
|
|
44
|
-
if (document) this.document = document;
|
|
45
|
-
}
|
|
46
|
-
operationsToTableObject(operations) {
|
|
47
|
-
return operations.map((op) => ({
|
|
48
|
-
...op,
|
|
49
|
-
input: JSON.stringify(op.action.input)
|
|
50
|
-
}));
|
|
51
|
-
}
|
|
52
|
-
setDocument(document) {
|
|
53
|
-
this.document = document;
|
|
54
|
-
}
|
|
55
|
-
getDocument() {
|
|
56
|
-
return this.document;
|
|
57
|
-
}
|
|
58
|
-
getOperations() {
|
|
59
|
-
return this.operations;
|
|
60
|
-
}
|
|
61
|
-
pushOperation(operation) {
|
|
62
|
-
this.operations.push(operation);
|
|
63
|
-
}
|
|
64
|
-
operationsTable() {
|
|
65
|
-
if (!this.document) console.warn("No document");
|
|
66
|
-
const ops = Object.values(this.document?.operations || {}).filter((array) => array !== void 0).flatMap((array) => array).sort((a, b) => a.index - b.index);
|
|
67
|
-
console.table(this.operationsToTableObject(ops));
|
|
68
|
-
}
|
|
69
|
-
scopeOperationsTable(scope) {
|
|
70
|
-
if (!this.document) console.warn("No document");
|
|
71
|
-
const ops = this.document?.operations[scope] || [];
|
|
72
|
-
console.table(this.operationsToTableObject(ops));
|
|
73
|
-
}
|
|
74
|
-
operationsLog() {
|
|
75
|
-
console.log(this.operations);
|
|
76
|
-
}
|
|
77
|
-
operationsLogTable() {
|
|
78
|
-
console.table(this.operationsToTableObject(this.operations));
|
|
79
|
-
}
|
|
80
|
-
clear() {
|
|
81
|
-
this.operations = [];
|
|
82
|
-
this.document = void 0;
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
//#endregion
|
|
86
|
-
//#region src/utils/launch-queue.ts
|
|
87
|
-
let pendingImportFiles = [];
|
|
88
|
-
const pendingListeners = /* @__PURE__ */ new Set();
|
|
89
|
-
function notifyPendingListeners() {
|
|
90
|
-
for (const listener of pendingListeners) listener();
|
|
91
|
-
}
|
|
92
|
-
function getPendingImportFiles() {
|
|
93
|
-
return pendingImportFiles;
|
|
94
|
-
}
|
|
95
|
-
/** Stable identity of a pending file (also the picker's pre-check cache key). */
|
|
96
|
-
function pendingFileKey(file) {
|
|
97
|
-
return `${file.name}|${file.size}|${file.lastModified}`;
|
|
98
|
-
}
|
|
99
|
-
function addPendingImportFiles(files) {
|
|
100
|
-
const seen = new Set(pendingImportFiles.map(pendingFileKey));
|
|
101
|
-
const fresh = files.filter((file) => {
|
|
102
|
-
const key = pendingFileKey(file);
|
|
103
|
-
if (seen.has(key)) return false;
|
|
104
|
-
seen.add(key);
|
|
105
|
-
return true;
|
|
106
|
-
});
|
|
107
|
-
if (fresh.length === 0) return;
|
|
108
|
-
pendingImportFiles = [...pendingImportFiles, ...fresh];
|
|
109
|
-
notifyPendingListeners();
|
|
110
|
-
}
|
|
111
|
-
function clearPendingImportFiles() {
|
|
112
|
-
if (pendingImportFiles.length === 0) return;
|
|
113
|
-
pendingImportFiles = [];
|
|
114
|
-
notifyPendingListeners();
|
|
115
|
-
}
|
|
116
|
-
function subscribePendingImportFiles(cb) {
|
|
117
|
-
pendingListeners.add(cb);
|
|
118
|
-
return () => {
|
|
119
|
-
pendingListeners.delete(cb);
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
async function handleLaunchParams(params) {
|
|
123
|
-
const handles = params.files.filter((handle) => handle.kind === "file");
|
|
124
|
-
if (handles.length === 0) return;
|
|
125
|
-
const files = [];
|
|
126
|
-
for (const handle of handles) try {
|
|
127
|
-
files.push(await handle.getFile());
|
|
128
|
-
} catch (error) {
|
|
129
|
-
console.error("Failed to read launched file:", handle.name, error);
|
|
130
|
-
}
|
|
131
|
-
if (files.length === 0) return;
|
|
132
|
-
addPendingImportFiles(files);
|
|
133
|
-
showPHModal({ type: "openFileDocuments" });
|
|
134
|
-
}
|
|
135
|
-
function maybeReopenImportModal() {
|
|
136
|
-
if (getPendingImportFiles().length === 0) return;
|
|
137
|
-
if (window.ph?.modal !== void 0) return;
|
|
138
|
-
showPHModal({ type: "openFileDocuments" });
|
|
139
|
-
}
|
|
140
|
-
let initialized = false;
|
|
141
|
-
/**
|
|
142
|
-
* Register the launchQueue consumer that receives files opened with Connect
|
|
143
|
-
* through the OS file association. Idempotent (safe under StrictMode double
|
|
144
|
-
* effects) and a no-op where the File Handling API doesn't exist — Firefox,
|
|
145
|
-
* Safari, and any context without an installed PWA manifest simply never
|
|
146
|
-
* deliver launches.
|
|
147
|
-
*/
|
|
148
|
-
function initLaunchQueueFileHandling() {
|
|
149
|
-
if (initialized) return;
|
|
150
|
-
initialized = true;
|
|
151
|
-
window.addEventListener("ph:modalUpdated", maybeReopenImportModal);
|
|
152
|
-
window.launchQueue?.setConsumer((params) => {
|
|
153
|
-
handleLaunchParams(params);
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
//#endregion
|
|
157
|
-
//#region src/utils/open-file-uploads.ts
|
|
158
|
-
let uploads = [];
|
|
159
|
-
const listeners$1 = /* @__PURE__ */ new Set();
|
|
160
|
-
function notifyUploadListeners() {
|
|
161
|
-
for (const listener of listeners$1) listener();
|
|
162
|
-
}
|
|
163
|
-
function getOpenFileUploads() {
|
|
164
|
-
return uploads;
|
|
165
|
-
}
|
|
166
|
-
function subscribeOpenFileUploads(cb) {
|
|
167
|
-
listeners$1.add(cb);
|
|
168
|
-
return () => {
|
|
169
|
-
listeners$1.delete(cb);
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
function removeOpenFileUpload(id) {
|
|
173
|
-
const next = uploads.filter((upload) => upload.id !== id);
|
|
174
|
-
if (next.length === uploads.length) return;
|
|
175
|
-
uploads = next;
|
|
176
|
-
notifyUploadListeners();
|
|
177
|
-
}
|
|
178
|
-
function clearOpenFileUploads() {
|
|
179
|
-
if (uploads.length === 0) return;
|
|
180
|
-
uploads = [];
|
|
181
|
-
notifyUploadListeners();
|
|
182
|
-
}
|
|
183
|
-
function addOpenFileUploads(rows) {
|
|
184
|
-
uploads = [...uploads, ...rows];
|
|
185
|
-
notifyUploadListeners();
|
|
186
|
-
}
|
|
187
|
-
function patchOpenFileUpload(id, patch) {
|
|
188
|
-
uploads = uploads.map((upload) => upload.id === id ? {
|
|
189
|
-
...upload,
|
|
190
|
-
...patch
|
|
191
|
-
} : upload);
|
|
192
|
-
notifyUploadListeners();
|
|
193
|
-
}
|
|
194
|
-
let uploadCounter = 0;
|
|
195
|
-
let importChain = Promise.resolve();
|
|
196
|
-
/**
|
|
197
|
-
* Import one file and resolve once the flow truly ends. Completion is
|
|
198
|
-
* tracked through the progress stages, NOT the returned promise — the
|
|
199
|
-
* package-discovery retry path resolves early and keeps reporting through
|
|
200
|
-
* the callback. `resolveConflict: "duplicate"` is always passed: duplicates
|
|
201
|
-
* were resolved in the picker (rename), so the conflict stage must never
|
|
202
|
-
* fire — this also covers a duplicate appearing between pre-check and import.
|
|
203
|
-
*/
|
|
204
|
-
function importOne(row, driveId, documentTypes) {
|
|
205
|
-
return new Promise((resolve) => {
|
|
206
|
-
let settled = false;
|
|
207
|
-
const settle = (fileNode) => {
|
|
208
|
-
if (settled) return;
|
|
209
|
-
settled = true;
|
|
210
|
-
resolve(fileNode);
|
|
211
|
-
};
|
|
212
|
-
addFileWithProgress(row.file, driveId, row.name, void 0, (progress) => {
|
|
213
|
-
patchOpenFileUpload(row.id, {
|
|
214
|
-
status: mapProgressStageToStatus(progress.stage),
|
|
215
|
-
progress: progress.progress,
|
|
216
|
-
...progress.error ? { errorDetails: progress.error } : {},
|
|
217
|
-
...progress.documentType ? { documentType: progress.documentType } : {},
|
|
218
|
-
...progress.fileNode ? { fileNode: progress.fileNode } : {}
|
|
219
|
-
});
|
|
220
|
-
switch (progress.stage) {
|
|
221
|
-
case "complete":
|
|
222
|
-
settle(progress.fileNode);
|
|
223
|
-
break;
|
|
224
|
-
case "failed":
|
|
225
|
-
case "unsupported-document-type":
|
|
226
|
-
settle(void 0);
|
|
227
|
-
break;
|
|
228
|
-
default: break;
|
|
229
|
-
}
|
|
230
|
-
}, documentTypes, "duplicate").catch(() => {
|
|
231
|
-
settle(void 0);
|
|
232
|
-
});
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Run a confirmed batch of imports into a drive, feeding the floating upload
|
|
237
|
-
* panel. Rows appear immediately (queued), files import sequentially, and a
|
|
238
|
-
* single-file batch that succeeds opens its document in the editor.
|
|
239
|
-
*/
|
|
240
|
-
function runOpenFileImports(args) {
|
|
241
|
-
const { driveId, imports, documentTypes } = args;
|
|
242
|
-
if (imports.length === 0) return importChain;
|
|
243
|
-
const rows = imports.map(({ file, name }) => ({
|
|
244
|
-
id: `open-file-${++uploadCounter}`,
|
|
245
|
-
file,
|
|
246
|
-
name
|
|
247
|
-
}));
|
|
248
|
-
addOpenFileUploads(rows.map((row) => ({
|
|
249
|
-
id: row.id,
|
|
250
|
-
fileName: row.name,
|
|
251
|
-
fileSize: formatFileSize(row.file.size),
|
|
252
|
-
status: "pending",
|
|
253
|
-
progress: 0
|
|
254
|
-
})));
|
|
255
|
-
const run = async () => {
|
|
256
|
-
const results = [];
|
|
257
|
-
for (const row of rows) results.push(await importOne(row, driveId, documentTypes));
|
|
258
|
-
if (rows.length === 1 && results[0]) setSelectedNode(results[0]);
|
|
259
|
-
};
|
|
260
|
-
importChain = importChain.then(run, run);
|
|
261
|
-
return importChain;
|
|
262
|
-
}
|
|
263
|
-
//#endregion
|
|
264
|
-
//#region src/components/migration-status.ts
|
|
265
|
-
let current = null;
|
|
266
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
267
|
-
function setMigrationStatus(status) {
|
|
268
|
-
current = status;
|
|
269
|
-
for (const l of listeners) l();
|
|
270
|
-
}
|
|
271
|
-
function getMigrationStatus() {
|
|
272
|
-
return current;
|
|
273
|
-
}
|
|
274
|
-
function subscribeMigrationStatus(cb) {
|
|
275
|
-
listeners.add(cb);
|
|
276
|
-
return () => {
|
|
277
|
-
listeners.delete(cb);
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
//#endregion
|
|
281
|
-
//#region src/utils/pglite-migration.ts
|
|
282
|
-
const BACKUP_PREFIX = "ph-pglite-backup::";
|
|
283
|
-
const BACKUP_INDEX_KEY = "ph:pglite-backups";
|
|
284
|
-
const BACKUP_RETENTION_MS = 720 * 60 * 60 * 1e3;
|
|
285
|
-
function deleteIdb(name, timeoutMs = 15e3) {
|
|
286
|
-
return new Promise((resolve, reject) => {
|
|
287
|
-
const req = indexedDB.deleteDatabase(name);
|
|
288
|
-
let settled = false;
|
|
289
|
-
const done = (fn) => {
|
|
290
|
-
if (settled) return;
|
|
291
|
-
settled = true;
|
|
292
|
-
fn();
|
|
293
|
-
};
|
|
294
|
-
const timer = setTimeout(() => done(() => reject(/* @__PURE__ */ new Error(`IDB delete timed out for ${name} after ${timeoutMs}ms`))), timeoutMs);
|
|
295
|
-
req.onsuccess = () => done(() => {
|
|
296
|
-
clearTimeout(timer);
|
|
297
|
-
resolve();
|
|
298
|
-
});
|
|
299
|
-
req.onerror = () => done(() => {
|
|
300
|
-
clearTimeout(timer);
|
|
301
|
-
reject(idbError(req, `IDB delete failed for ${name}`));
|
|
302
|
-
});
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
function readBackupIndex() {
|
|
306
|
-
try {
|
|
307
|
-
const raw = localStorage.getItem(BACKUP_INDEX_KEY);
|
|
308
|
-
if (!raw) return [];
|
|
309
|
-
const parsed = JSON.parse(raw);
|
|
310
|
-
return Array.isArray(parsed) ? parsed : [];
|
|
311
|
-
} catch {
|
|
312
|
-
return [];
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
function writeBackupIndex(records) {
|
|
316
|
-
try {
|
|
317
|
-
localStorage.setItem(BACKUP_INDEX_KEY, JSON.stringify(records));
|
|
318
|
-
} catch {}
|
|
319
|
-
}
|
|
320
|
-
function registerBackup(rec) {
|
|
321
|
-
writeBackupIndex([...readBackupIndex(), rec]);
|
|
322
|
-
}
|
|
323
|
-
function forgetBackup(name) {
|
|
324
|
-
writeBackupIndex(readBackupIndex().filter((r) => r.name !== name));
|
|
325
|
-
}
|
|
326
|
-
async function janitor() {
|
|
327
|
-
const cutoff = Date.now() - BACKUP_RETENTION_MS;
|
|
328
|
-
const keep = [];
|
|
329
|
-
for (const rec of readBackupIndex()) {
|
|
330
|
-
if (rec.createdAt >= cutoff) {
|
|
331
|
-
keep.push(rec);
|
|
332
|
-
continue;
|
|
333
|
-
}
|
|
334
|
-
try {
|
|
335
|
-
await deleteIdb(rec.name);
|
|
336
|
-
} catch (err) {
|
|
337
|
-
console.warn(`Failed to delete expired pglite backup ${rec.name}`, err);
|
|
338
|
-
keep.push(rec);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
writeBackupIndex(keep);
|
|
342
|
-
}
|
|
343
|
-
function createPersistentBackup() {
|
|
344
|
-
return {
|
|
345
|
-
snapshot: async (idbName) => {
|
|
346
|
-
const backupName = `${BACKUP_PREFIX}${idbName}::${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
347
|
-
await cloneFileData(idbName, backupName);
|
|
348
|
-
registerBackup({
|
|
349
|
-
name: backupName,
|
|
350
|
-
idbName,
|
|
351
|
-
createdAt: Date.now()
|
|
352
|
-
});
|
|
353
|
-
return backupName;
|
|
354
|
-
},
|
|
355
|
-
rollback: async (handle, idbName, cause) => {
|
|
356
|
-
const backupName = handle;
|
|
357
|
-
try {
|
|
358
|
-
await cloneFileData(backupName, idbName);
|
|
359
|
-
} catch (rollbackErr) {
|
|
360
|
-
console.error(`PGlite migration rollback failed for ${idbName}; backup ${backupName} retained. Primary migration error:`, cause, "Rollback error:", rollbackErr);
|
|
361
|
-
return;
|
|
362
|
-
}
|
|
363
|
-
await deleteIdb(backupName).catch(() => void 0);
|
|
364
|
-
forgetBackup(backupName);
|
|
365
|
-
},
|
|
366
|
-
discard: async (handle) => {
|
|
367
|
-
const backupName = handle;
|
|
368
|
-
await deleteIdb(backupName).catch(() => void 0);
|
|
369
|
-
forgetBackup(backupName);
|
|
370
|
-
},
|
|
371
|
-
commit: () => Promise.resolve()
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
async function migrateAllLocked() {
|
|
375
|
-
const backup = createPersistentBackup();
|
|
376
|
-
try {
|
|
377
|
-
for (const idbName of PRIMARY_IDB_NAMES) await migrateIdb(idbName, (phase) => setMigrationStatus({
|
|
378
|
-
idbName,
|
|
379
|
-
phase
|
|
380
|
-
}), backup);
|
|
381
|
-
} finally {
|
|
382
|
-
setMigrationStatus(null);
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
async function migrateAllIfNeeded() {
|
|
386
|
-
janitor().catch((err) => console.warn("PGlite backup janitor failed", err));
|
|
387
|
-
if (!(typeof navigator !== "undefined" && "locks" in navigator && typeof navigator.locks.request === "function")) {
|
|
388
|
-
await migrateAllLocked();
|
|
389
|
-
return;
|
|
390
|
-
}
|
|
391
|
-
await navigator.locks.request("ph-pglite-migration", { mode: "exclusive" }, async () => {
|
|
392
|
-
await migrateAllLocked();
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
//#endregion
|
|
396
|
-
//#region src/hooks/useFailedInstallations.ts
|
|
397
|
-
const emptyArray$1 = [];
|
|
398
|
-
function useFailedInstallations() {
|
|
399
|
-
const discoveryService = usePackageDiscoveryService();
|
|
400
|
-
return useSyncExternalStore((cb) => discoveryService?.subscribeFailed(cb) ?? (() => {}), () => discoveryService?.getFailedInstallations() ?? emptyArray$1);
|
|
401
|
-
}
|
|
402
|
-
//#endregion
|
|
403
|
-
//#region src/hooks/useInitSentry.ts
|
|
404
|
-
const logger$2 = childLogger(["sentry"]);
|
|
405
|
-
let clientStarted = false;
|
|
406
|
-
async function getSentry() {
|
|
407
|
-
return await import("@sentry/react");
|
|
408
|
-
}
|
|
409
|
-
async function initSentry() {
|
|
410
|
-
const Sentry = await getSentry();
|
|
411
|
-
const integrations = [
|
|
412
|
-
Sentry.httpClientIntegration(),
|
|
413
|
-
Sentry.extraErrorDataIntegration({ depth: 5 }),
|
|
414
|
-
Sentry.replayIntegration(),
|
|
415
|
-
Sentry.captureConsoleIntegration({ levels: ["error"] })
|
|
416
|
-
];
|
|
417
|
-
if (connectConfig.sentry.tracing) integrations.push(Sentry.reactRouterV6BrowserTracingIntegration({
|
|
418
|
-
useEffect: React.useEffect,
|
|
419
|
-
useLocation,
|
|
420
|
-
useNavigationType,
|
|
421
|
-
createRoutesFromChildren,
|
|
422
|
-
matchRoutes
|
|
423
|
-
}));
|
|
424
|
-
Sentry.init({
|
|
425
|
-
release: connectConfig.sentry.release,
|
|
426
|
-
dsn: connectConfig.sentry.dsn ?? void 0,
|
|
427
|
-
environment: connectConfig.sentry.env,
|
|
428
|
-
integrations,
|
|
429
|
-
ignoreErrors: [
|
|
430
|
-
"User is not allowed to create files",
|
|
431
|
-
"User is not allowed to move documents",
|
|
432
|
-
"The user aborted a request."
|
|
433
|
-
],
|
|
434
|
-
sendDefaultPii: true,
|
|
435
|
-
tracesSampleRate: 1,
|
|
436
|
-
replaysSessionSampleRate: .1,
|
|
437
|
-
replaysOnErrorSampleRate: 1,
|
|
438
|
-
beforeSend(event, hint) {
|
|
439
|
-
const error = hint.originalException;
|
|
440
|
-
if (error instanceof TypeError && error.message.includes("Failed to fetch") && !navigator.onLine) return null;
|
|
441
|
-
return event;
|
|
442
|
-
}
|
|
443
|
-
});
|
|
444
|
-
setSentryModule(Sentry);
|
|
445
|
-
clientStarted = true;
|
|
446
|
-
}
|
|
447
|
-
async function closeClient() {
|
|
448
|
-
if (!clientStarted) return;
|
|
449
|
-
const sentry = await getSentry();
|
|
450
|
-
setSentryModule(void 0);
|
|
451
|
-
return sentry.getClient()?.close();
|
|
452
|
-
}
|
|
453
|
-
function useInitSentry() {
|
|
454
|
-
const [acceptedCookies] = useAcceptedCookies();
|
|
455
|
-
const { analytics } = acceptedCookies;
|
|
456
|
-
useEffect(() => {
|
|
457
|
-
if (!analytics) {
|
|
458
|
-
closeClient().catch((error) => logger$2.error("@error", error));
|
|
459
|
-
return;
|
|
460
|
-
}
|
|
461
|
-
if (clientStarted || connectConfig.sentry.dsn === null || connectConfig.sentry.dsn === void 0 || connectConfig.sentry.dsn === "") return;
|
|
462
|
-
initSentry().catch((error) => logger$2.error("@error", error));
|
|
463
|
-
}, [analytics]);
|
|
464
|
-
}
|
|
465
|
-
//#endregion
|
|
466
|
-
//#region src/services/openpanel/buffer.ts
|
|
467
|
-
const buffer = [];
|
|
468
|
-
let errorHandler;
|
|
469
|
-
function defaultOnError(err) {
|
|
470
|
-
console.warn("[useOpenPanelAnalytics] track failed:", err);
|
|
471
|
-
}
|
|
472
|
-
/**
|
|
473
|
-
* Forward a single event to the active client, swallowing any throw.
|
|
474
|
-
*
|
|
475
|
-
* The outer try/catch handles synchronous throws from `client.track`; the
|
|
476
|
-
* inner `.catch()` handles rejected promises. Both are needed because
|
|
477
|
-
* `Promise.resolve(x).catch()` cannot catch a throw from evaluating `x`.
|
|
478
|
-
*/
|
|
479
|
-
function forward(client, name, props) {
|
|
480
|
-
try {
|
|
481
|
-
Promise.resolve(client.track(name, props)).catch((err) => (errorHandler ?? defaultOnError)(err));
|
|
482
|
-
} catch (err) {
|
|
483
|
-
(errorHandler ?? defaultOnError)(err);
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
/**
|
|
487
|
-
* Drain the pre-init buffer in FIFO order through `client.track`, then forward
|
|
488
|
-
* subsequent events directly. Called once from `getOpenPanelClient()`.
|
|
489
|
-
*/
|
|
490
|
-
function drainOpenPanelBuffer(client, onError) {
|
|
491
|
-
errorHandler = onError;
|
|
492
|
-
const pending = buffer.splice(0, buffer.length);
|
|
493
|
-
for (const [name, props] of pending) forward(client, name, props);
|
|
494
|
-
}
|
|
495
|
-
/**
|
|
496
|
-
* Clear the buffer and reset the active client. Buffered pre-consent events
|
|
497
|
-
* are discarded so they are not replayed if the user later re-accepts.
|
|
498
|
-
*/
|
|
499
|
-
function clearOpenPanelBuffer() {
|
|
500
|
-
buffer.length = 0;
|
|
501
|
-
errorHandler = void 0;
|
|
502
|
-
}
|
|
503
|
-
//#endregion
|
|
504
|
-
//#region src/hooks/usePendingInstallations.ts
|
|
505
|
-
const emptyArray = [];
|
|
506
|
-
function usePendingInstallations() {
|
|
507
|
-
const discoveryService = usePackageDiscoveryService();
|
|
508
|
-
const cacheRef = useRef(emptyArray);
|
|
509
|
-
return useSyncExternalStore((cb) => discoveryService?.subscribePending(cb) ?? (() => {}), useCallback(() => {
|
|
510
|
-
if (!discoveryService) return emptyArray;
|
|
511
|
-
const next = discoveryService.getPendingInstallations() ?? emptyArray;
|
|
512
|
-
const prev = cacheRef.current;
|
|
513
|
-
if (next === prev || next.length === prev.length && next.every((p, i) => p === prev[i])) return prev;
|
|
514
|
-
cacheRef.current = next;
|
|
515
|
-
return next;
|
|
516
|
-
}, [discoveryService]));
|
|
517
|
-
}
|
|
518
|
-
//#endregion
|
|
519
|
-
//#region src/hooks/useUndoRedoShortcuts.ts
|
|
520
|
-
const useUndoRedoShortcuts = (props) => {
|
|
521
|
-
const { undo, redo, canRedo, canUndo } = props;
|
|
522
|
-
const isMac = window.navigator.userAgent.includes("Mac");
|
|
523
|
-
let undoShortcut = "ctrl+z";
|
|
524
|
-
let redoShortcut = "ctrl+y";
|
|
525
|
-
if (isMac) {
|
|
526
|
-
undoShortcut = "mod+z";
|
|
527
|
-
redoShortcut = "mod+shift+z";
|
|
528
|
-
}
|
|
529
|
-
useHotkeys(undoShortcut, (event) => {
|
|
530
|
-
event.preventDefault();
|
|
531
|
-
if (canUndo) undo();
|
|
532
|
-
}, {}, [canUndo, undo]);
|
|
533
|
-
useHotkeys(redoShortcut, (event) => {
|
|
534
|
-
event.preventDefault();
|
|
535
|
-
if (canRedo) redo();
|
|
536
|
-
}, {}, [canRedo, redo]);
|
|
537
|
-
};
|
|
538
|
-
//#endregion
|
|
539
|
-
//#region src/components/app-skeleton.tsx
|
|
540
|
-
const LOADER_DELAY = 250;
|
|
541
|
-
const PHASE_LABEL = {
|
|
542
|
-
clone: "Backing up local database…",
|
|
543
|
-
dump: "Exporting data from previous version…",
|
|
544
|
-
restore: "Restoring data into the new database…"
|
|
545
|
-
};
|
|
546
|
-
const MigrationOverlay = () => {
|
|
547
|
-
const status = useSyncExternalStore(subscribeMigrationStatus, getMigrationStatus, () => null);
|
|
548
|
-
if (!status) return null;
|
|
549
|
-
return /* @__PURE__ */ jsx("div", {
|
|
550
|
-
className: "absolute inset-0 z-20 flex items-center justify-center",
|
|
551
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
552
|
-
className: "rounded-lg bg-card/90 px-6 py-4 text-sm text-foreground shadow-lg",
|
|
553
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
554
|
-
className: "font-medium",
|
|
555
|
-
children: "Upgrading local database…"
|
|
556
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
557
|
-
className: "text-foreground",
|
|
558
|
-
children: PHASE_LABEL[status.phase]
|
|
559
|
-
})]
|
|
560
|
-
})
|
|
561
|
-
});
|
|
562
|
-
};
|
|
563
|
-
const Loader = ({ delay = LOADER_DELAY }) => {
|
|
564
|
-
const isSSR = typeof window === "undefined";
|
|
565
|
-
const showInitialLoader = typeof document !== "undefined" && document.body.getAttribute("data-show-loader") === "true";
|
|
566
|
-
if (!isSSR) initTheme();
|
|
567
|
-
const [showLoading, setShowLoading] = useState(!delay || showInitialLoader);
|
|
568
|
-
useEffect(() => {
|
|
569
|
-
const id = setTimeout(() => {
|
|
570
|
-
setShowLoading(true);
|
|
571
|
-
}, delay);
|
|
572
|
-
return () => clearTimeout(id);
|
|
573
|
-
}, []);
|
|
574
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
575
|
-
className: `skeleton-loader absolute inset-0 z-10 flex items-center justify-center ${showLoading ? "" : "hidden"}`,
|
|
576
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
577
|
-
className: "animate-pulse overflow-hidden rounded-full shadow-lg",
|
|
578
|
-
children: /* @__PURE__ */ jsx(LogoAnimation, {})
|
|
579
|
-
}), isSSR ? /* @__PURE__ */ jsx("script", { dangerouslySetInnerHTML: { __html: `setTimeout(() => {
|
|
580
|
-
document.querySelector('.skeleton-loader')?.classList.remove('hidden');
|
|
581
|
-
document.body.setAttribute('data-show-loader', 'true');
|
|
582
|
-
}, ${delay})` } }) : null]
|
|
583
|
-
});
|
|
584
|
-
};
|
|
585
|
-
const AppSkeleton = (props) => {
|
|
586
|
-
const isSSR = typeof window === "undefined";
|
|
587
|
-
const isHomeScreen = !isSSR && window.location.pathname === getBasePath();
|
|
588
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
589
|
-
className: "flex h-screen overflow-hidden bg-background",
|
|
590
|
-
children: [
|
|
591
|
-
!(!isSSR && getIsEmbedded()) && /* @__PURE__ */ jsx(ConnectSidebar, {
|
|
592
|
-
className: "animate-pulse",
|
|
593
|
-
onLogin: void 0,
|
|
594
|
-
onDisconnect: void 0,
|
|
595
|
-
onClickSettings: void 0,
|
|
596
|
-
address: void 0
|
|
597
|
-
}),
|
|
598
|
-
/* @__PURE__ */ jsx(HomeScreen, {
|
|
599
|
-
containerClassName: isSSR || !isHomeScreen ? "home-screen hidden" : void 0,
|
|
600
|
-
children: props.children ?? null
|
|
601
|
-
}),
|
|
602
|
-
isSSR ? /* @__PURE__ */ jsx("script", { dangerouslySetInnerHTML: { __html: `
|
|
603
|
-
const baseEl = document.querySelector('base');
|
|
604
|
-
const href = baseEl?.getAttribute('href');
|
|
605
|
-
const basePath = href || '/';
|
|
606
|
-
if (window.location.pathname === basePath) {
|
|
607
|
-
document.querySelector('.home-screen')?.classList.remove('hidden')
|
|
608
|
-
}` } }) : null,
|
|
609
|
-
!props.children ? /* @__PURE__ */ jsx(Loader, {}) : null,
|
|
610
|
-
/* @__PURE__ */ jsx(MigrationOverlay, {})
|
|
611
|
-
]
|
|
612
|
-
});
|
|
613
|
-
};
|
|
614
|
-
//#endregion
|
|
615
|
-
//#region src/components/error-boundary.tsx
|
|
616
|
-
const logger$1 = childLogger(["Connect"]);
|
|
617
|
-
function hasCustomFallback(props) {
|
|
618
|
-
return "fallbackRender" in props;
|
|
619
|
-
}
|
|
620
|
-
function SilentFallback() {
|
|
621
|
-
return null;
|
|
622
|
-
}
|
|
623
|
-
/**
|
|
624
|
-
* Simple text-based fallback component.
|
|
625
|
-
* Displays a centered message when an error occurs.
|
|
626
|
-
*/
|
|
627
|
-
function TextFallback({ message = "Something went wrong" }) {
|
|
628
|
-
return /* @__PURE__ */ jsx("div", {
|
|
629
|
-
className: "text-center wrap-break-word text-foreground",
|
|
630
|
-
children: message
|
|
631
|
-
});
|
|
632
|
-
}
|
|
633
|
-
/**
|
|
634
|
-
* Detailed fallback component showing full error information.
|
|
635
|
-
* Displays error message with a collapsible details section.
|
|
636
|
-
* Useful for development and debugging purposes.
|
|
637
|
-
*/
|
|
638
|
-
function DetailedFallback({ error, resetErrorBoundary }) {
|
|
639
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
640
|
-
const errorDetails = error instanceof Error ? error.stack ?? String(error.cause) : JSON.stringify(error, null, 2);
|
|
641
|
-
return /* @__PURE__ */ jsx("div", {
|
|
642
|
-
className: "z-10 mx-auto flex max-w-[80%] flex-1 items-center justify-center p-6",
|
|
643
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
644
|
-
className: "w-full max-w-lg rounded-lg border border-border bg-card p-6 text-foreground shadow-sm",
|
|
645
|
-
children: [
|
|
646
|
-
/* @__PURE__ */ jsxs("div", {
|
|
647
|
-
className: "mb-3 flex items-center gap-2",
|
|
648
|
-
children: [/* @__PURE__ */ jsx(Icon, {
|
|
649
|
-
name: "Error",
|
|
650
|
-
className: "size-5 shrink-0 text-destructive"
|
|
651
|
-
}), /* @__PURE__ */ jsx("h1", {
|
|
652
|
-
className: "text-lg font-semibold text-foreground",
|
|
653
|
-
children: "Something went wrong"
|
|
654
|
-
})]
|
|
655
|
-
}),
|
|
656
|
-
/* @__PURE__ */ jsx("p", {
|
|
657
|
-
className: "mb-4 text-sm wrap-break-word text-foreground",
|
|
658
|
-
children: errorMessage
|
|
659
|
-
}),
|
|
660
|
-
errorDetails !== "{}" && /* @__PURE__ */ jsxs("details", {
|
|
661
|
-
className: "group",
|
|
662
|
-
children: [/* @__PURE__ */ jsx("summary", {
|
|
663
|
-
className: "cursor-pointer text-sm font-medium text-foreground underline select-none hover:hover-effect",
|
|
664
|
-
children: "Show details"
|
|
665
|
-
}), /* @__PURE__ */ jsx("pre", {
|
|
666
|
-
className: "mt-2 max-h-48 overflow-auto rounded-sm bg-muted p-3 text-xs text-foreground",
|
|
667
|
-
children: errorDetails
|
|
668
|
-
})]
|
|
669
|
-
}),
|
|
670
|
-
/* @__PURE__ */ jsx(PowerhouseButton, {
|
|
671
|
-
type: "button",
|
|
672
|
-
onClick: resetErrorBoundary,
|
|
673
|
-
className: "mt-4 px-3 py-1.5 text-base font-medium",
|
|
674
|
-
children: "Try again"
|
|
675
|
-
})
|
|
676
|
-
]
|
|
677
|
-
})
|
|
678
|
-
});
|
|
679
|
-
}
|
|
680
|
-
/**
|
|
681
|
-
* Centered error message fallback component.
|
|
682
|
-
* Displays the error message in a centered, full-size container.
|
|
683
|
-
* Suitable for use as a custom fallbackRender when you need simple error display.
|
|
684
|
-
*/
|
|
685
|
-
function CenteredErrorMessage({ error }) {
|
|
686
|
-
return /* @__PURE__ */ jsx("div", {
|
|
687
|
-
className: "flex size-full items-center justify-center p-6",
|
|
688
|
-
children: /* @__PURE__ */ jsx("h3", {
|
|
689
|
-
className: "max-w-lg min-w-0 text-center text-lg font-semibold wrap-break-word text-foreground",
|
|
690
|
-
children: error instanceof Error ? error.message : String(error)
|
|
691
|
-
})
|
|
692
|
-
});
|
|
693
|
-
}
|
|
694
|
-
function getFallbackComponent(variant, fallbackMessage) {
|
|
695
|
-
switch (variant) {
|
|
696
|
-
case "silent": return SilentFallback;
|
|
697
|
-
case "text": return () => /* @__PURE__ */ jsx(TextFallback, { message: fallbackMessage });
|
|
698
|
-
case "detailed": return DetailedFallback;
|
|
699
|
-
default: return CenteredErrorMessage;
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
/**
|
|
703
|
-
* Unified error boundary component for catching and handling React errors.
|
|
704
|
-
*
|
|
705
|
-
* Built on top of `react-error-boundary`, this component provides:
|
|
706
|
-
* - Automatic error logging with configurable context
|
|
707
|
-
* - Multiple fallback UI variants (silent, text, detailed)
|
|
708
|
-
* - Support for custom fallback render functions
|
|
709
|
-
* - Reset capability via `resetKeys`
|
|
710
|
-
*
|
|
711
|
-
* @example
|
|
712
|
-
* // Using a predefined variant
|
|
713
|
-
* <ErrorBoundary variant="detailed" loggerContext={["Connect", "Editor"]}>
|
|
714
|
-
* <EditorComponent />
|
|
715
|
-
* </ErrorBoundary>
|
|
716
|
-
*
|
|
717
|
-
* @example
|
|
718
|
-
* // Using a custom message with the text variant
|
|
719
|
-
* <ErrorBoundary variant="text" fallbackMessage="Failed to load drives">
|
|
720
|
-
* <DrivesList />
|
|
721
|
-
* </ErrorBoundary>
|
|
722
|
-
*
|
|
723
|
-
* @example
|
|
724
|
-
* // Using a custom fallback render
|
|
725
|
-
* <ErrorBoundary
|
|
726
|
-
* fallbackRender={CenteredErrorMessage}
|
|
727
|
-
* onError={(error) => trackError(error)}
|
|
728
|
-
* >
|
|
729
|
-
* <MyComponent />
|
|
730
|
-
* </ErrorBoundary>
|
|
731
|
-
*
|
|
732
|
-
* @example
|
|
733
|
-
* // Silent mode for modals (renders null on error)
|
|
734
|
-
* <ErrorBoundary variant="silent" loggerContext={["Connect", "Modals"]}>
|
|
735
|
-
* <ModalContent />
|
|
736
|
-
* </ErrorBoundary>
|
|
737
|
-
*/
|
|
738
|
-
function ErrorBoundary$1(props) {
|
|
739
|
-
const { children, onError, resetKeys, loggerContext } = props;
|
|
740
|
-
const handleError = (error, info) => {
|
|
741
|
-
if (error.message.includes("Failed to fetch dynamically imported module") && error.message.includes("node_modules/.vite")) {
|
|
742
|
-
console.error(error);
|
|
743
|
-
console.log("Outdated chunk detected, reloading page...");
|
|
744
|
-
window.location.reload();
|
|
745
|
-
return;
|
|
746
|
-
}
|
|
747
|
-
(loggerContext ? childLogger(loggerContext) : logger$1).error("@error @info", error, info);
|
|
748
|
-
onError?.(error, info);
|
|
749
|
-
};
|
|
750
|
-
return /* @__PURE__ */ jsx(ErrorBoundary, {
|
|
751
|
-
fallbackRender: hasCustomFallback(props) ? props.fallbackRender : getFallbackComponent(props.variant, props.fallbackMessage),
|
|
752
|
-
onError: handleError,
|
|
753
|
-
resetKeys,
|
|
754
|
-
children
|
|
755
|
-
});
|
|
756
|
-
}
|
|
757
|
-
//#endregion
|
|
758
|
-
//#region src/components/analytics.tsx
|
|
759
|
-
function gtag(...args) {
|
|
760
|
-
window.dataLayer?.push(...args);
|
|
761
|
-
}
|
|
762
|
-
const Analytics = () => {
|
|
763
|
-
const gaTrackingId = connectConfig.gaTrackingId;
|
|
764
|
-
const [{ analytics }] = useAcceptedCookies();
|
|
765
|
-
const useAnalytics = gaTrackingId && analytics;
|
|
766
|
-
useEffect(() => {
|
|
767
|
-
if (useAnalytics) {
|
|
768
|
-
const script = document.createElement("script");
|
|
769
|
-
script.src = `https://www.googletagmanager.com/gtag/js?id=${gaTrackingId}`;
|
|
770
|
-
script.async = true;
|
|
771
|
-
document.head.appendChild(script);
|
|
772
|
-
window.dataLayer = window.dataLayer || [];
|
|
773
|
-
gtag("js", /* @__PURE__ */ new Date());
|
|
774
|
-
gtag("config", gaTrackingId);
|
|
775
|
-
return () => {
|
|
776
|
-
document.head.removeChild(script);
|
|
777
|
-
};
|
|
778
|
-
}
|
|
779
|
-
}, [useAnalytics, gaTrackingId]);
|
|
780
|
-
return null;
|
|
781
|
-
};
|
|
782
|
-
//#endregion
|
|
783
|
-
//#region src/services/openpanel/client.ts
|
|
784
|
-
let client;
|
|
785
|
-
/**
|
|
786
|
-
* Returns the cached `OpenPanel` singleton, building it on first call.
|
|
787
|
-
*
|
|
788
|
-
* When `config.clientId` is empty it returns `undefined` without importing
|
|
789
|
-
* `@openpanel/web`, so the bundler can tree-shake the SDK out of production.
|
|
790
|
-
*/
|
|
791
|
-
async function getOpenPanelClient(config) {
|
|
792
|
-
if (!config.clientId) return;
|
|
793
|
-
if (client) return client;
|
|
794
|
-
const { OpenPanel: OpenPanelClass } = await import("@openpanel/web");
|
|
795
|
-
client = new OpenPanelClass({
|
|
796
|
-
clientId: config.clientId,
|
|
797
|
-
...config.apiUrl ? { apiUrl: config.apiUrl } : {},
|
|
798
|
-
trackScreenViews: true,
|
|
799
|
-
trackOutgoingLinks: true
|
|
800
|
-
});
|
|
801
|
-
client.setGlobalProperties({ app: "connect" });
|
|
802
|
-
drainOpenPanelBuffer(client);
|
|
803
|
-
return client;
|
|
804
|
-
}
|
|
805
|
-
/**
|
|
806
|
-
* Clears the cached singleton and the pre-init buffer. Call on consent
|
|
807
|
-
* revocation or during tests; buffered events are discarded, not replayed.
|
|
808
|
-
*/
|
|
809
|
-
function resetOpenPanelClient() {
|
|
810
|
-
client = void 0;
|
|
811
|
-
clearOpenPanelBuffer();
|
|
812
|
-
}
|
|
813
|
-
//#endregion
|
|
814
|
-
//#region src/services/openpanel/events.json
|
|
815
|
-
var events_default = [
|
|
816
|
-
{
|
|
817
|
-
"documentType": "powerhouse/document-drive",
|
|
818
|
-
"actionTypes": [
|
|
819
|
-
"ADD_FOLDER",
|
|
820
|
-
"DELETE_NODE",
|
|
821
|
-
"ADD_FILE",
|
|
822
|
-
"UPDATE_FILE",
|
|
823
|
-
"COPY_NODE",
|
|
824
|
-
"MOVE_NODE",
|
|
825
|
-
"SET_DRIVE_NAME",
|
|
826
|
-
"SET_DRIVE_ICON"
|
|
827
|
-
]
|
|
828
|
-
},
|
|
829
|
-
{
|
|
830
|
-
"documentType": "powerhouse/document-model",
|
|
831
|
-
"actionTypes": [
|
|
832
|
-
"SET_MODEL_NAME",
|
|
833
|
-
"SET_MODEL_ID",
|
|
834
|
-
"ADD_MODULE",
|
|
835
|
-
"DELETE_MODULE",
|
|
836
|
-
"ADD_OPERATION",
|
|
837
|
-
"DELETE_OPERATION"
|
|
838
|
-
]
|
|
839
|
-
},
|
|
840
|
-
{
|
|
841
|
-
"documentType": "powerhouse/reactor-drive",
|
|
842
|
-
"actionTypes": [
|
|
843
|
-
"ADD_FOLDER",
|
|
844
|
-
"REMOVE_FOLDER",
|
|
845
|
-
"UPDATE_FOLDER"
|
|
846
|
-
]
|
|
847
|
-
}
|
|
848
|
-
];
|
|
849
|
-
//#endregion
|
|
850
|
-
//#region src/services/openpanel/events.ts
|
|
851
|
-
const EventMappingSchema = z.object({
|
|
852
|
-
documentType: z.string().min(1),
|
|
853
|
-
actionTypes: z.array(z.string().min(1)).min(1),
|
|
854
|
-
alias: z.string().optional()
|
|
855
|
-
}).strict();
|
|
856
|
-
const EventMappingsSchema = z.array(EventMappingSchema).readonly();
|
|
857
|
-
/**
|
|
858
|
-
* Parses and validates the event mapping table, returning the validated array
|
|
859
|
-
* and an O(1) lookup map. Accepts a `raw` override for tests. Throws on zod
|
|
860
|
-
* failures and on duplicate `(documentType, actionType)` pairs.
|
|
861
|
-
*/
|
|
862
|
-
function loadEvents(raw = events_default) {
|
|
863
|
-
const result = EventMappingsSchema.safeParse(raw);
|
|
864
|
-
if (!result.success) throw new Error(`Invalid OpenPanel events.json: ${result.error.message}`);
|
|
865
|
-
const mappings = result.data;
|
|
866
|
-
const lookupMap = /* @__PURE__ */ new Map();
|
|
867
|
-
for (const mapping of mappings) {
|
|
868
|
-
let inner = lookupMap.get(mapping.documentType);
|
|
869
|
-
if (!inner) {
|
|
870
|
-
inner = /* @__PURE__ */ new Map();
|
|
871
|
-
lookupMap.set(mapping.documentType, inner);
|
|
872
|
-
}
|
|
873
|
-
for (const actionType of mapping.actionTypes) {
|
|
874
|
-
if (inner.has(actionType)) throw new Error(`Duplicate OpenPanel event mapping for ${mapping.documentType}/${actionType}`);
|
|
875
|
-
inner.set(actionType, mapping);
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
return {
|
|
879
|
-
mappings,
|
|
880
|
-
lookupMap
|
|
881
|
-
};
|
|
882
|
-
}
|
|
883
|
-
const { mappings: defaultMappings, lookupMap: defaultLookupMap } = loadEvents();
|
|
884
|
-
/** Validated mapping array from the bundled events.json. */
|
|
885
|
-
const eventMappings = defaultMappings;
|
|
886
|
-
/** O(1) lookup map: documentType → actionType → mapping. */
|
|
887
|
-
const eventLookupMap = defaultLookupMap;
|
|
888
|
-
/**
|
|
889
|
-
* Normalizes a document type into a safe event-name segment: lowercased, `/`
|
|
890
|
-
* replaced with `.`, and any character outside `[a-z0-9._-]` stripped.
|
|
891
|
-
* e.g. `powerhouse/document-drive` → `powerhouse.document-drive`.
|
|
892
|
-
*/
|
|
893
|
-
function normalize(documentType) {
|
|
894
|
-
return documentType.toLowerCase().replace(/\//g, ".").replace(/[^a-z0-9._-]/g, "");
|
|
895
|
-
}
|
|
896
|
-
/**
|
|
897
|
-
* Derives the OpenPanel event name: `mapping.alias` when present, otherwise
|
|
898
|
-
* `${normalize(documentType)}.${actionType.toLowerCase()}`.
|
|
899
|
-
*/
|
|
900
|
-
function deriveEventName(mapping, op) {
|
|
901
|
-
if (mapping.alias) return mapping.alias;
|
|
902
|
-
return `${normalize(op.context.documentType)}.${op.operation.action.type.toLowerCase()}`;
|
|
903
|
-
}
|
|
904
|
-
/**
|
|
905
|
-
* Builds the default properties attached to every OpenPanel event. The `app`
|
|
906
|
-
* property is stamped globally by the client, not here.
|
|
907
|
-
*/
|
|
908
|
-
function buildDefaultProperties(op) {
|
|
909
|
-
return {
|
|
910
|
-
documentType: op.context.documentType,
|
|
911
|
-
actionType: op.operation.action.type,
|
|
912
|
-
documentId: op.context.documentId,
|
|
913
|
-
scope: op.context.scope,
|
|
914
|
-
branch: op.context.branch
|
|
915
|
-
};
|
|
916
|
-
}
|
|
917
|
-
//#endregion
|
|
918
|
-
//#region src/services/openpanel/processor.ts
|
|
919
|
-
/**
|
|
920
|
-
* Read-only reactor `IProcessor` that translates matching document operations
|
|
921
|
-
* into OpenPanel analytics events. Operations whose `(documentType, actionType)`
|
|
922
|
-
* pair is absent from the lookup map are skipped; per-operation errors are
|
|
923
|
-
* routed to `onError` and never thrown back to the manager.
|
|
924
|
-
*/
|
|
925
|
-
var OpenPanelProcessor = class {
|
|
926
|
-
constructor(client, lookupMap, onError = (err) => console.warn("[OpenPanelProcessor] Error tracking event:", err)) {
|
|
927
|
-
this.client = client;
|
|
928
|
-
this.lookupMap = lookupMap;
|
|
929
|
-
this.onError = onError;
|
|
930
|
-
}
|
|
931
|
-
async onOperations(operations) {
|
|
932
|
-
for (const op of operations) {
|
|
933
|
-
const inner = this.lookupMap.get(op.context.documentType);
|
|
934
|
-
if (!inner) continue;
|
|
935
|
-
const mapping = inner.get(op.operation.action.type);
|
|
936
|
-
if (!mapping) continue;
|
|
937
|
-
const name = deriveEventName(mapping, op);
|
|
938
|
-
const payload = buildDefaultProperties(op);
|
|
939
|
-
try {
|
|
940
|
-
await this.client.track(name, payload);
|
|
941
|
-
} catch (err) {
|
|
942
|
-
this.onError(err, op);
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
onDisconnect() {
|
|
947
|
-
this.client.flush?.();
|
|
948
|
-
return Promise.resolve();
|
|
949
|
-
}
|
|
950
|
-
};
|
|
951
|
-
//#endregion
|
|
952
|
-
//#region src/services/openpanel/factory.ts
|
|
953
|
-
/**
|
|
954
|
-
* Returns a `ProcessorFactory` that, for each drive, creates a single
|
|
955
|
-
* `OpenPanelProcessor` record whose `filter.documentType` is the union of all
|
|
956
|
-
* document types present in the event mapping table.
|
|
957
|
-
*/
|
|
958
|
-
function createOpenPanelProcessorFactory(config) {
|
|
959
|
-
return function openPanelProcessorFactory(_driveHeader) {
|
|
960
|
-
const documentType = Array.from(config.events.lookupMap.keys());
|
|
961
|
-
return [{
|
|
962
|
-
processor: new OpenPanelProcessor(config.client, config.events.lookupMap, config.onError),
|
|
963
|
-
filter: { documentType },
|
|
964
|
-
startFrom: config.startFrom ?? "current"
|
|
965
|
-
}];
|
|
966
|
-
};
|
|
967
|
-
}
|
|
968
|
-
//#endregion
|
|
969
|
-
//#region src/components/openpanel-traits.ts
|
|
970
|
-
/**
|
|
971
|
-
* Builds the OpenPanel identity traits from a renown User.
|
|
972
|
-
*
|
|
973
|
-
* Canonical trait schema (shared with Renown and Vetra — each app sends every
|
|
974
|
-
* field it has data for, under these names):
|
|
975
|
-
* - `address`, `did`, `networkId`, `chainId`, `caip2` — wallet/chain facts.
|
|
976
|
-
* - `ensName`, `ensAvatar` — raw ENS facts.
|
|
977
|
-
* - `username`, `userImage`, `profileDocumentId`, `profileCreatedAt` — raw
|
|
978
|
-
* Renown profile facts.
|
|
979
|
-
* - `accountType` — wallet-adapter concept; only Renown has it.
|
|
980
|
-
*
|
|
981
|
-
* Rules:
|
|
982
|
-
* - `credential` (contains a JWT) is **never** forwarded.
|
|
983
|
-
* - Traits carry raw facts only; resolved presentation values (avatar,
|
|
984
|
-
* display name) go in OpenPanel's native identify fields — see
|
|
985
|
-
* {@link buildIdentifyPayload}.
|
|
986
|
-
* - Optional fields (`ens`, `profile`) are only included when their value is
|
|
987
|
-
* non-nullish (guards against `null` from `RenownProfile` fields as well
|
|
988
|
-
* as plain `undefined`).
|
|
989
|
-
*
|
|
990
|
-
* Mirror the Sentry pattern in `store/user.ts`: destructure off `credential`
|
|
991
|
-
* first, then assemble the trait payload from the remainder.
|
|
992
|
-
*/
|
|
993
|
-
function buildTraits(user) {
|
|
994
|
-
const { credential: _credential, ...rest } = user;
|
|
995
|
-
const traits = {
|
|
996
|
-
address: rest.address,
|
|
997
|
-
did: rest.did,
|
|
998
|
-
networkId: rest.networkId,
|
|
999
|
-
chainId: rest.chainId,
|
|
1000
|
-
caip2: `${rest.networkId}:${rest.chainId}`
|
|
1001
|
-
};
|
|
1002
|
-
if (rest.ens?.name != null) traits.ensName = rest.ens.name;
|
|
1003
|
-
if (rest.ens?.avatarUrl != null) traits.ensAvatar = rest.ens.avatarUrl;
|
|
1004
|
-
if (rest.profile?.username != null) traits.username = rest.profile.username;
|
|
1005
|
-
if (rest.profile?.userImage != null) traits.userImage = rest.profile.userImage;
|
|
1006
|
-
if (rest.profile?.documentId != null) traits.profileDocumentId = rest.profile.documentId;
|
|
1007
|
-
if (rest.profile?.createdAt != null) traits.profileCreatedAt = rest.profile.createdAt;
|
|
1008
|
-
return traits;
|
|
1009
|
-
}
|
|
1010
|
-
/**
|
|
1011
|
-
* Builds the full `identify()` payload:
|
|
1012
|
-
* - `profileId` is the wallet address — the cross-app profile key shared with
|
|
1013
|
-
* Renown and Vetra.
|
|
1014
|
-
* - `avatar` / `firstName` are OpenPanel's native profile fields (they drive
|
|
1015
|
-
* the picture and name in the dashboard UI), resolved as
|
|
1016
|
-
* `userImage ?? ensAvatar` and `ensName ?? username`.
|
|
1017
|
-
* - `properties` are the raw traits from {@link buildTraits}.
|
|
1018
|
-
*/
|
|
1019
|
-
function buildIdentifyPayload(user) {
|
|
1020
|
-
const avatar = user.profile?.userImage ?? user.ens?.avatarUrl;
|
|
1021
|
-
const firstName = user.ens?.name ?? user.profile?.username;
|
|
1022
|
-
return {
|
|
1023
|
-
profileId: user.address,
|
|
1024
|
-
...avatar != null ? { avatar } : {},
|
|
1025
|
-
...firstName != null ? { firstName } : {},
|
|
1026
|
-
properties: buildTraits(user)
|
|
1027
|
-
};
|
|
1028
|
-
}
|
|
1029
|
-
//#endregion
|
|
1030
|
-
//#region src/components/openpanel.tsx
|
|
1031
|
-
/**
|
|
1032
|
-
* `OpenPanel` is a `null`-rendering component that manages the full lifecycle
|
|
1033
|
-
* of the OpenPanel analytics subsystem.
|
|
1034
|
-
*
|
|
1035
|
-
* Gates:
|
|
1036
|
-
* - `useAcceptedCookies().analytics === true` — the existing analytics cookie.
|
|
1037
|
-
* - `connectConfig.openPanel.clientId` non-empty — no client ID → no-op.
|
|
1038
|
-
*
|
|
1039
|
-
* Behaviour when both gates pass:
|
|
1040
|
-
* 1. Lazy-imports `@openpanel/web` and builds the singleton via
|
|
1041
|
-
* `getOpenPanelClient(connectConfig.openPanel)`.
|
|
1042
|
-
* 2. Exposes the client on `window.openPanel` for the card-6
|
|
1043
|
-
* `useOpenPanelAnalytics()` hook to consume.
|
|
1044
|
-
* 3. If `connectConfig.openPanel.trackOperations`, registers the processor
|
|
1045
|
-
* factory against `processorManager` so document operations are forwarded.
|
|
1046
|
-
* 4. Calls `client.identify()` when the renown user transitions from
|
|
1047
|
-
* `undefined` → defined (login). The profile ID is the wallet address —
|
|
1048
|
-
* the cross-app key shared with Renown and Vetra.
|
|
1049
|
-
* 5. Calls `client.clear()` when the user transitions from defined →
|
|
1050
|
-
* `undefined` (logout).
|
|
1051
|
-
*
|
|
1052
|
-
* Teardown (unmount **or** consent revocation):
|
|
1053
|
-
* - `unregisterFactory("openpanel")` to remove the processor.
|
|
1054
|
-
* - `resetOpenPanelClient()` to clear the singleton.
|
|
1055
|
-
* - `window.openPanel` is cleared.
|
|
1056
|
-
*
|
|
1057
|
-
* Mirrors the Sentry pattern in `store/user.ts` for login/logout detection.
|
|
1058
|
-
* Analytics failures are caught and forwarded to `console.warn` — they must
|
|
1059
|
-
* never throw into the application.
|
|
1060
|
-
*
|
|
1061
|
-
* Mounted next to `<Analytics />` in `app.tsx`.
|
|
1062
|
-
*/
|
|
1063
|
-
function OpenPanel() {
|
|
1064
|
-
const [{ analytics }] = useAcceptedCookies();
|
|
1065
|
-
const user = useUser();
|
|
1066
|
-
const module = useReactorClientModule();
|
|
1067
|
-
const reactorClientModule = module?.kind === "browser" ? module : void 0;
|
|
1068
|
-
const [client, setClient] = useState();
|
|
1069
|
-
/**
|
|
1070
|
-
* Tracks the previous `user` value so we can detect the two transitions:
|
|
1071
|
-
* undefined → defined (login)
|
|
1072
|
-
* defined → undefined (logout)
|
|
1073
|
-
*/
|
|
1074
|
-
const prevUserRef = useRef(void 0);
|
|
1075
|
-
const enabled = analytics && !!connectConfig.openPanel.clientId;
|
|
1076
|
-
const processorManager = reactorClientModule?.reactorModule?.processorManager;
|
|
1077
|
-
useEffect(() => {
|
|
1078
|
-
if (!enabled) return;
|
|
1079
|
-
let cancelled = false;
|
|
1080
|
-
const isCancelled = () => cancelled;
|
|
1081
|
-
const setup = async () => {
|
|
1082
|
-
let builtClient;
|
|
1083
|
-
try {
|
|
1084
|
-
builtClient = await getOpenPanelClient(connectConfig.openPanel);
|
|
1085
|
-
} catch (err) {
|
|
1086
|
-
console.warn("[OpenPanel] Failed to build client:", err);
|
|
1087
|
-
return;
|
|
1088
|
-
}
|
|
1089
|
-
if (isCancelled() || !builtClient) return;
|
|
1090
|
-
setClient(builtClient);
|
|
1091
|
-
window.openPanel = builtClient;
|
|
1092
|
-
if (connectConfig.openPanel.trackOperations && processorManager) try {
|
|
1093
|
-
await processorManager.registerFactory("openpanel", createOpenPanelProcessorFactory({
|
|
1094
|
-
client: builtClient,
|
|
1095
|
-
events: {
|
|
1096
|
-
mappings: eventMappings,
|
|
1097
|
-
lookupMap: eventLookupMap
|
|
1098
|
-
},
|
|
1099
|
-
startFrom: "current"
|
|
1100
|
-
}));
|
|
1101
|
-
if (isCancelled()) await processorManager.unregisterFactory("openpanel").catch((err) => console.warn("[OpenPanel] Failed to unregister factory after cancellation:", err));
|
|
1102
|
-
} catch (err) {
|
|
1103
|
-
console.warn("[OpenPanel] Failed to register processor factory:", err);
|
|
1104
|
-
}
|
|
1105
|
-
};
|
|
1106
|
-
setup();
|
|
1107
|
-
return () => {
|
|
1108
|
-
cancelled = true;
|
|
1109
|
-
prevUserRef.current = void 0;
|
|
1110
|
-
if (connectConfig.openPanel.trackOperations && processorManager) processorManager.unregisterFactory("openpanel").catch((err) => console.warn("[OpenPanel] Failed to unregister processor factory:", err));
|
|
1111
|
-
resetOpenPanelClient();
|
|
1112
|
-
window.openPanel = void 0;
|
|
1113
|
-
setClient(void 0);
|
|
1114
|
-
};
|
|
1115
|
-
}, [enabled, processorManager]);
|
|
1116
|
-
useEffect(() => {
|
|
1117
|
-
if (!enabled || !client) return;
|
|
1118
|
-
const prev = prevUserRef.current;
|
|
1119
|
-
prevUserRef.current = user;
|
|
1120
|
-
if (!prev && user) try {
|
|
1121
|
-
client.identify(buildIdentifyPayload(user));
|
|
1122
|
-
} catch (err) {
|
|
1123
|
-
console.warn("[OpenPanel] Failed to identify user:", err);
|
|
1124
|
-
}
|
|
1125
|
-
else if (prev && !user) try {
|
|
1126
|
-
client.clear();
|
|
1127
|
-
} catch (err) {
|
|
1128
|
-
console.warn("[OpenPanel] Failed to clear user:", err);
|
|
1129
|
-
}
|
|
1130
|
-
}, [
|
|
1131
|
-
client,
|
|
1132
|
-
user,
|
|
1133
|
-
enabled
|
|
1134
|
-
]);
|
|
1135
|
-
return null;
|
|
1136
|
-
}
|
|
1137
|
-
//#endregion
|
|
1138
|
-
//#region src/components/document-editor-container.tsx
|
|
1139
|
-
function DocumentEditorContainer() {
|
|
1140
|
-
const [selectedDocument] = useSelectedDocument();
|
|
1141
|
-
const parentFolder = useNodeParentFolderById(selectedDocument.header.id);
|
|
1142
|
-
useMemo(() => {
|
|
1143
|
-
return async () => {};
|
|
1144
|
-
}, []);
|
|
1145
|
-
useCallback(() => {
|
|
1146
|
-
setSelectedNode(parentFolder);
|
|
1147
|
-
}, [parentFolder]);
|
|
1148
|
-
return /* @__PURE__ */ jsx("div", {
|
|
1149
|
-
id: "document-editor-container",
|
|
1150
|
-
className: "flex-1",
|
|
1151
|
-
"data-document-type": selectedDocument.header.documentType,
|
|
1152
|
-
children: /* @__PURE__ */ jsx(DocumentEditor, { document: selectedDocument })
|
|
1153
|
-
});
|
|
1154
|
-
}
|
|
1155
|
-
//#endregion
|
|
1156
|
-
//#region src/components/editor-loader.tsx
|
|
1157
|
-
function EditorLoader(props) {
|
|
1158
|
-
const [showLoading, setShowLoading] = useState(false);
|
|
1159
|
-
useEffect(() => {
|
|
1160
|
-
setTimeout(() => {
|
|
1161
|
-
setShowLoading(true);
|
|
1162
|
-
}, props.loadingTimeout ?? 200);
|
|
1163
|
-
}, [props]);
|
|
1164
|
-
if (!showLoading) return null;
|
|
1165
|
-
const { customEditorLoader, ...defaultProps } = props;
|
|
1166
|
-
if (customEditorLoader) return /* @__PURE__ */ jsx(Fragment, { children: customEditorLoader });
|
|
1167
|
-
return /* @__PURE__ */ jsx(DefaultEditorLoader, { ...defaultProps });
|
|
1168
|
-
}
|
|
1169
|
-
//#endregion
|
|
1170
|
-
//#region src/components/app-container.tsx
|
|
1171
|
-
function AppContainer() {
|
|
1172
|
-
const [selectedDrive] = useSelectedDriveSafe();
|
|
1173
|
-
const selectedDocumentId = useSelectedDocumentId();
|
|
1174
|
-
const app = useAppModuleById(selectedDrive?.header.meta?.preferredEditor);
|
|
1175
|
-
const defaultApp = useDefaultAppModule();
|
|
1176
|
-
if (!selectedDrive) return /* @__PURE__ */ jsx(EditorLoader, {});
|
|
1177
|
-
const AppComponent = app?.Component ?? defaultApp?.Component ?? GenericDriveExplorer.Component;
|
|
1178
|
-
if (!AppComponent) throw new Error("No app component found");
|
|
1179
|
-
return /* @__PURE__ */ jsx(ErrorBoundary$1, {
|
|
1180
|
-
variant: "detailed",
|
|
1181
|
-
resetKeys: [selectedDrive.header.id],
|
|
1182
|
-
loggerContext: ["Connect", "App"],
|
|
1183
|
-
children: /* @__PURE__ */ jsx(Suspense, {
|
|
1184
|
-
fallback: /* @__PURE__ */ jsx(EditorLoader, {}),
|
|
1185
|
-
children: /* @__PURE__ */ jsx(DropZoneWrapper, {
|
|
1186
|
-
className: "flex h-full flex-col overflow-auto",
|
|
1187
|
-
children: /* @__PURE__ */ jsx(AppComponent, { children: selectedDocumentId ? /* @__PURE__ */ jsx(DocumentEditorContainer, {}) : null })
|
|
1188
|
-
})
|
|
1189
|
-
})
|
|
1190
|
-
});
|
|
1191
|
-
}
|
|
1192
|
-
//#endregion
|
|
1193
|
-
//#region src/context/sentry-provider.tsx
|
|
1194
|
-
const SentryProvider = ({ children }) => {
|
|
1195
|
-
useInitSentry();
|
|
1196
|
-
return children;
|
|
1197
|
-
};
|
|
1198
|
-
//#endregion
|
|
1199
|
-
//#region src/components/reactor-chat.tsx
|
|
1200
|
-
/**
|
|
1201
|
-
* Resolves the reactor tool descriptors for the chat agent from the
|
|
1202
|
-
* browser's live reactor client. Built lazily at send time so the reactor
|
|
1203
|
-
* (and its SharedWorker) do not need to be ready at render time.
|
|
1204
|
-
*/
|
|
1205
|
-
function getReactorTools() {
|
|
1206
|
-
const ph = window.ph;
|
|
1207
|
-
const client = ph?.reactorClient;
|
|
1208
|
-
if (!client) return Promise.reject(/* @__PURE__ */ new Error("The reactor client is not available yet. Try again shortly."));
|
|
1209
|
-
const syncManager = ph?.reactorClientModule?.reactorModule?.syncModule?.syncManager;
|
|
1210
|
-
return createReactorMcpProvider({
|
|
1211
|
-
client,
|
|
1212
|
-
syncManager
|
|
1213
|
-
}).then((provider) => {
|
|
1214
|
-
const builtInTools = Object.values(provider.tools).map((tool) => ({
|
|
1215
|
-
...tool,
|
|
1216
|
-
inputSchema: tool.inputSchema ?? {}
|
|
1217
|
-
}));
|
|
1218
|
-
const taken = new Set(builtInTools.map((tool) => tool.name));
|
|
1219
|
-
const packageTools = (ph?.vetraPackageManager?.packages ?? []).flatMap((pkg) => (pkg.aiTools ?? []).filter((tool) => {
|
|
1220
|
-
if (taken.has(tool.name)) {
|
|
1221
|
-
console.warn(`[Connect][AI] Package tool "${tool.name}" shadows an existing tool and was ignored.`);
|
|
1222
|
-
return false;
|
|
1223
|
-
}
|
|
1224
|
-
taken.add(tool.name);
|
|
1225
|
-
return true;
|
|
1226
|
-
}));
|
|
1227
|
-
return [
|
|
1228
|
-
...builtInTools,
|
|
1229
|
-
createSwitchboardSchemaTool(),
|
|
1230
|
-
...packageTools
|
|
1231
|
-
];
|
|
1232
|
-
});
|
|
1233
|
-
}
|
|
1234
|
-
/** Connect's bottom-right AI chat FAB, bound to the browser reactor. */
|
|
1235
|
-
function ConnectReactorChatFab() {
|
|
1236
|
-
return /* @__PURE__ */ jsx(ReactorChatFab, { getTools: getReactorTools });
|
|
1237
|
-
}
|
|
1238
|
-
//#endregion
|
|
1239
|
-
//#region src/components/missing-model-banner.tsx
|
|
1240
|
-
const reasonLabels = {
|
|
1241
|
-
"no-registry": "No package registry is configured.",
|
|
1242
|
-
"not-in-registry": "No matching package found in the registry.",
|
|
1243
|
-
"registry-error": "Couldn't reach the package registry.",
|
|
1244
|
-
"install-failed": "Package failed to install.",
|
|
1245
|
-
dismissed: "Installation was dismissed.",
|
|
1246
|
-
offline: "You're offline — this package can't be loaded until you reconnect."
|
|
1247
|
-
};
|
|
1248
|
-
function canRetry(reason) {
|
|
1249
|
-
return reason !== "no-registry";
|
|
1250
|
-
}
|
|
1251
|
-
function MissingModelBanner() {
|
|
1252
|
-
const failed = useFailedInstallations();
|
|
1253
|
-
const discoveryService = usePackageDiscoveryService();
|
|
1254
|
-
const [open, setOpen] = useState(false);
|
|
1255
|
-
const [dismissed, setDismissed] = useState(false);
|
|
1256
|
-
useEffect(() => {
|
|
1257
|
-
return discoveryService?.subscribeEvents((event) => {
|
|
1258
|
-
if (event.type === "load-failed") setDismissed(false);
|
|
1259
|
-
});
|
|
1260
|
-
}, [discoveryService]);
|
|
1261
|
-
if (failed.length === 0) return null;
|
|
1262
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [dismissed ? null : /* @__PURE__ */ jsx("div", {
|
|
1263
|
-
className: "absolute inset-x-0 top-0 z-200 bg-background",
|
|
1264
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
1265
|
-
className: "flex items-center justify-between gap-3 bg-warning/10 px-4 py-2 text-sm text-warning",
|
|
1266
|
-
children: [/* @__PURE__ */ jsx("span", { children: failed.length === 1 ? "1 document type couldn't load (missing model)." : `${failed.length} document types couldn't load (missing models).` }), /* @__PURE__ */ jsxs("div", {
|
|
1267
|
-
className: "flex items-center gap-2",
|
|
1268
|
-
children: [/* @__PURE__ */ jsx("button", {
|
|
1269
|
-
type: "button",
|
|
1270
|
-
onClick: () => setOpen(true),
|
|
1271
|
-
className: "rounded-md border border-warning bg-background px-3 py-1 text-warning hover:hover-effect",
|
|
1272
|
-
children: "View"
|
|
1273
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
1274
|
-
type: "button",
|
|
1275
|
-
onClick: () => setDismissed(true),
|
|
1276
|
-
"aria-label": "Dismiss",
|
|
1277
|
-
className: "flex items-center text-warning hover:hover-effect",
|
|
1278
|
-
children: /* @__PURE__ */ jsx(Icon, {
|
|
1279
|
-
name: "XmarkLight",
|
|
1280
|
-
size: 16
|
|
1281
|
-
})
|
|
1282
|
-
})]
|
|
1283
|
-
})]
|
|
1284
|
-
})
|
|
1285
|
-
}), /* @__PURE__ */ jsx(MissingModelDetailsModal, {
|
|
1286
|
-
open,
|
|
1287
|
-
failed,
|
|
1288
|
-
onClose: () => setOpen(false)
|
|
1289
|
-
})] });
|
|
1290
|
-
}
|
|
1291
|
-
function MissingModelDetailsModal(props) {
|
|
1292
|
-
const { open, failed, onClose } = props;
|
|
1293
|
-
const discoveryService = usePackageDiscoveryService();
|
|
1294
|
-
const [retrying, setRetrying] = useState(() => /* @__PURE__ */ new Set());
|
|
1295
|
-
async function handleRetry(documentType) {
|
|
1296
|
-
if (!discoveryService) return;
|
|
1297
|
-
setRetrying((prev) => new Set(prev).add(documentType));
|
|
1298
|
-
try {
|
|
1299
|
-
await discoveryService.retryInstallation(documentType);
|
|
1300
|
-
} finally {
|
|
1301
|
-
setRetrying((prev) => {
|
|
1302
|
-
const next = new Set(prev);
|
|
1303
|
-
next.delete(documentType);
|
|
1304
|
-
return next;
|
|
1305
|
-
});
|
|
1306
|
-
}
|
|
1307
|
-
}
|
|
1308
|
-
return /* @__PURE__ */ jsx(Modal, {
|
|
1309
|
-
open,
|
|
1310
|
-
onOpenChange: (isOpen) => {
|
|
1311
|
-
if (!isOpen) onClose();
|
|
1312
|
-
},
|
|
1313
|
-
contentProps: { className: "rounded-3xl" },
|
|
1314
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
1315
|
-
className: "w-[520px] max-w-[90vw] bg-background p-6",
|
|
1316
|
-
children: [
|
|
1317
|
-
/* @__PURE__ */ jsx("div", {
|
|
1318
|
-
className: "border-b border-border pb-2 text-2xl font-bold text-foreground",
|
|
1319
|
-
children: "Missing document models"
|
|
1320
|
-
}),
|
|
1321
|
-
/* @__PURE__ */ jsx("div", {
|
|
1322
|
-
className: "my-4 text-sm text-foreground",
|
|
1323
|
-
children: "The following document types couldn't be loaded. Documents using them won't display until the underlying package is installed."
|
|
1324
|
-
}),
|
|
1325
|
-
failed.length === 0 ? /* @__PURE__ */ jsx("div", {
|
|
1326
|
-
className: "rounded-xl bg-background p-4 text-sm text-foreground",
|
|
1327
|
-
children: "No outstanding failures."
|
|
1328
|
-
}) : /* @__PURE__ */ jsx("div", {
|
|
1329
|
-
className: "flex max-h-[60vh] flex-col gap-3 overflow-y-auto",
|
|
1330
|
-
children: failed.map((entry) => {
|
|
1331
|
-
const isRetrying = retrying.has(entry.documentType);
|
|
1332
|
-
const retryDisabled = !canRetry(entry.reason) || isRetrying;
|
|
1333
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
1334
|
-
className: "rounded-xl bg-background p-4",
|
|
1335
|
-
children: [
|
|
1336
|
-
/* @__PURE__ */ jsx("div", {
|
|
1337
|
-
className: "mb-1 font-mono text-sm font-semibold text-foreground",
|
|
1338
|
-
children: entry.documentType
|
|
1339
|
-
}),
|
|
1340
|
-
/* @__PURE__ */ jsx("div", {
|
|
1341
|
-
className: "mb-2 text-xs text-foreground",
|
|
1342
|
-
children: reasonLabels[entry.reason]
|
|
1343
|
-
}),
|
|
1344
|
-
entry.packageNames.length > 0 ? /* @__PURE__ */ jsxs("div", {
|
|
1345
|
-
className: "mb-2 text-xs text-muted-foreground",
|
|
1346
|
-
children: [
|
|
1347
|
-
"Package",
|
|
1348
|
-
entry.packageNames.length > 1 ? "s" : "",
|
|
1349
|
-
":",
|
|
1350
|
-
" ",
|
|
1351
|
-
entry.packageNames.join(", ")
|
|
1352
|
-
]
|
|
1353
|
-
}) : null,
|
|
1354
|
-
entry.error ? /* @__PURE__ */ jsx("div", {
|
|
1355
|
-
className: "mb-2 font-mono text-xs wrap-break-word text-destructive",
|
|
1356
|
-
children: entry.error.message
|
|
1357
|
-
}) : null,
|
|
1358
|
-
/* @__PURE__ */ jsx("div", {
|
|
1359
|
-
className: "flex justify-end",
|
|
1360
|
-
children: /* @__PURE__ */ jsx("button", {
|
|
1361
|
-
type: "button",
|
|
1362
|
-
onClick: () => void handleRetry(entry.documentType),
|
|
1363
|
-
disabled: retryDisabled,
|
|
1364
|
-
title: canRetry(entry.reason) ? void 0 : "No registry is configured; nothing to retry against.",
|
|
1365
|
-
className: twMerge("min-h-[32px] rounded-xl px-3 py-1 text-sm font-semibold text-foreground transition-all hover:hover-effect", retryDisabled ? "cursor-not-allowed bg-secondary hover:hover-effect" : "bg-primary text-primary-foreground active:active-effect"),
|
|
1366
|
-
children: isRetrying ? "Retrying..." : "Try install again"
|
|
1367
|
-
})
|
|
1368
|
-
})
|
|
1369
|
-
]
|
|
1370
|
-
}, entry.documentType);
|
|
1371
|
-
})
|
|
1372
|
-
}),
|
|
1373
|
-
/* @__PURE__ */ jsx("div", {
|
|
1374
|
-
className: "mt-4 flex justify-end",
|
|
1375
|
-
children: /* @__PURE__ */ jsx("button", {
|
|
1376
|
-
type: "button",
|
|
1377
|
-
onClick: onClose,
|
|
1378
|
-
className: "min-h-[36px] rounded-xl border border-border bg-background px-4 py-2 text-sm font-semibold text-foreground hover:hover-effect",
|
|
1379
|
-
children: "Close"
|
|
1380
|
-
})
|
|
1381
|
-
})
|
|
1382
|
-
]
|
|
1383
|
-
})
|
|
1384
|
-
});
|
|
1385
|
-
}
|
|
1386
|
-
//#endregion
|
|
1387
|
-
//#region src/components/open-file-upload-list.tsx
|
|
1388
|
-
function OpenFileUploadList() {
|
|
1389
|
-
const uploads = useSyncExternalStore(subscribeOpenFileUploads, getOpenFileUploads);
|
|
1390
|
-
return /* @__PURE__ */ jsx(UploadFileListContainer, {
|
|
1391
|
-
uploadsArray: uploads,
|
|
1392
|
-
uploadsCount: uploads.length,
|
|
1393
|
-
removeUpload: removeOpenFileUpload,
|
|
1394
|
-
clearAllUploads: clearOpenFileUploads,
|
|
1395
|
-
setSelectedNode
|
|
1396
|
-
});
|
|
1397
|
-
}
|
|
1398
|
-
//#endregion
|
|
1399
|
-
//#region src/components/package-install-prompt.tsx
|
|
1400
|
-
function PackageInstallPrompt() {
|
|
1401
|
-
const pendingInstallations = usePendingInstallations();
|
|
1402
|
-
const discoveryService = usePackageDiscoveryService();
|
|
1403
|
-
if (!discoveryService || pendingInstallations.length === 0) return null;
|
|
1404
|
-
return /* @__PURE__ */ jsx(PackageInstallModal, {
|
|
1405
|
-
pendingInstallations: pendingInstallations.flatMap((p) => p.packageNames.map((packageName) => ({
|
|
1406
|
-
documentType: p.documentType,
|
|
1407
|
-
packageName
|
|
1408
|
-
}))),
|
|
1409
|
-
onInstall: (packageName) => discoveryService.approveInstallation(packageName),
|
|
1410
|
-
onDismiss: (packageName) => discoveryService.dismissInstallation(packageName)
|
|
1411
|
-
});
|
|
1412
|
-
}
|
|
1413
|
-
//#endregion
|
|
1414
|
-
//#region src/components/renown-adapter-descriptors.ts
|
|
1415
|
-
function describe(id, build) {
|
|
1416
|
-
try {
|
|
1417
|
-
return [build()];
|
|
1418
|
-
} catch (error) {
|
|
1419
|
-
console.error(`[connect] Ignoring the "${id}" wallet adapter: connect.renown.adapters.${id} was rejected.`, error);
|
|
1420
|
-
return [];
|
|
1421
|
-
}
|
|
1422
|
-
}
|
|
1423
|
-
const CHAINS_BY_ID = new Map([
|
|
1424
|
-
mainnet,
|
|
1425
|
-
sepolia,
|
|
1426
|
-
polygon,
|
|
1427
|
-
optimism,
|
|
1428
|
-
arbitrum,
|
|
1429
|
-
base
|
|
1430
|
-
].map((chain) => [chain.id, chain]));
|
|
1431
|
-
function chainsFor(chainId) {
|
|
1432
|
-
if (chainId === void 0) return void 0;
|
|
1433
|
-
const chain = CHAINS_BY_ID.get(chainId);
|
|
1434
|
-
if (!chain) {
|
|
1435
|
-
console.error(`[connect] connect.renown.chainId ${chainId} is not a chain Connect can offer, so in-page sign-in will be rejected. Supported: ${[...CHAINS_BY_ID.keys()].join(", ")}.`);
|
|
1436
|
-
return;
|
|
1437
|
-
}
|
|
1438
|
-
return [chain];
|
|
1439
|
-
}
|
|
1440
|
-
/** Map Connect's declarative `connect.renown.adapters` config to the descriptors `RenownWalletProvider` takes. Array order sets the order of the login buttons. A rejected adapter config is dropped (logged), leaving the others working. `chainId` is `connect.renown.chainId`, the chain Renown issues credentials on. */
|
|
1441
|
-
function configToDescriptors(config, chainId) {
|
|
1442
|
-
if (!config) return [];
|
|
1443
|
-
const { rainbow, privy, mock } = config;
|
|
1444
|
-
const descriptors = [];
|
|
1445
|
-
const chains = chainsFor(chainId);
|
|
1446
|
-
if (rainbow) descriptors.push(...describe("rainbow", () => rainbowAdapter({
|
|
1447
|
-
...rainbow,
|
|
1448
|
-
...chains ? { chains } : {}
|
|
1449
|
-
})));
|
|
1450
|
-
if (privy) {
|
|
1451
|
-
const { appId, clientId, methods } = privy;
|
|
1452
|
-
if (appId) descriptors.push(...describe("privy", () => privyAdapter({
|
|
1453
|
-
appId,
|
|
1454
|
-
clientId,
|
|
1455
|
-
methods,
|
|
1456
|
-
chain: chains?.[0]
|
|
1457
|
-
})));
|
|
1458
|
-
}
|
|
1459
|
-
if (mock) descriptors.push(...describe("mock", () => mockAdapter({
|
|
1460
|
-
...mock,
|
|
1461
|
-
methods: mock.methods
|
|
1462
|
-
})));
|
|
1463
|
-
return descriptors;
|
|
1464
|
-
}
|
|
1465
|
-
//#endregion
|
|
1466
|
-
//#region src/components/renown-wallet-providers.tsx
|
|
1467
|
-
function resolveColor(expr, fallback) {
|
|
1468
|
-
if (typeof document === "undefined") return fallback;
|
|
1469
|
-
const probe = document.createElement("span");
|
|
1470
|
-
probe.style.color = fallback;
|
|
1471
|
-
probe.style.color = expr;
|
|
1472
|
-
probe.style.display = "none";
|
|
1473
|
-
document.body.appendChild(probe);
|
|
1474
|
-
const resolved = getComputedStyle(probe).color;
|
|
1475
|
-
probe.remove();
|
|
1476
|
-
return resolved || fallback;
|
|
1477
|
-
}
|
|
1478
|
-
function RenownWalletProviders({ children }) {
|
|
1479
|
-
const config = getRuntimeConfig().connect.renown?.adapters;
|
|
1480
|
-
const chainId = getRuntimeConfig().connect.renown?.chainId;
|
|
1481
|
-
const { theme } = useTheme();
|
|
1482
|
-
const adapters = useMemo(() => configToDescriptors(config, chainId), [config, chainId]);
|
|
1483
|
-
const walletTheme = useMemo(() => adapters.length > 0 ? {
|
|
1484
|
-
mode: theme,
|
|
1485
|
-
accentColor: resolveColor("var(--primary)", "#0084ff"),
|
|
1486
|
-
accentColorForeground: resolveColor("var(--primary-foreground)", "#ffffff")
|
|
1487
|
-
} : void 0, [theme, adapters]);
|
|
1488
|
-
if (adapters.length === 0) return /* @__PURE__ */ jsx(Fragment, { children });
|
|
1489
|
-
return /* @__PURE__ */ jsx(RenownWalletProvider, {
|
|
1490
|
-
adapters,
|
|
1491
|
-
theme: walletTheme,
|
|
1492
|
-
children
|
|
1493
|
-
});
|
|
1494
|
-
}
|
|
1495
|
-
//#endregion
|
|
1496
|
-
//#region src/components/app.tsx
|
|
1497
|
-
const App = () => {
|
|
1498
|
-
useTheme();
|
|
1499
|
-
useEditorPreloader();
|
|
1500
|
-
useEffect(() => {
|
|
1501
|
-
const handlePreloadError = (event) => {
|
|
1502
|
-
const payload = event.payload;
|
|
1503
|
-
const failedUrl = (payload instanceof Error ? payload.message : typeof payload === "string" ? payload : "").match(/https?:\/\/[^\s"']+/)?.[0];
|
|
1504
|
-
if (failedUrl && !failedUrl.startsWith(window.location.origin)) {
|
|
1505
|
-
console.debug(`[Connect] Skipping reload — vite:preloadError for off-origin URL: ${failedUrl}`);
|
|
1506
|
-
return;
|
|
1507
|
-
}
|
|
1508
|
-
console.log("Outdated chunks detected, reloading page...");
|
|
1509
|
-
window.location.reload();
|
|
1510
|
-
};
|
|
1511
|
-
window.addEventListener("vite:preloadError", handlePreloadError);
|
|
1512
|
-
return () => {
|
|
1513
|
-
window.removeEventListener("vite:preloadError", handlePreloadError);
|
|
1514
|
-
};
|
|
1515
|
-
}, []);
|
|
1516
|
-
useEffect(() => {
|
|
1517
|
-
if (import.meta.env.MODE === "development") window.documentEditorDebugTools = new DocumentEditorDebugTools();
|
|
1518
|
-
else if (connectConfig.offline) serviceWorkerManager.registerServiceWorker(false);
|
|
1519
|
-
else serviceWorkerManager.unregisterAll();
|
|
1520
|
-
}, []);
|
|
1521
|
-
useEffect(() => {
|
|
1522
|
-
initLaunchQueueFileHandling();
|
|
1523
|
-
}, []);
|
|
1524
|
-
return /* @__PURE__ */ jsx(SentryProvider, { children: /* @__PURE__ */ jsxs(RenownWalletProviders, { children: [
|
|
1525
|
-
/* @__PURE__ */ jsx(ToastContainer, { position: "bottom-right" }),
|
|
1526
|
-
connectConfig.aiAssistantEnabled && /* @__PURE__ */ jsx(ConnectReactorChatFab, {}),
|
|
1527
|
-
/* @__PURE__ */ jsx(MissingModelBanner, {}),
|
|
1528
|
-
/* @__PURE__ */ jsx(Router, {}),
|
|
1529
|
-
/* @__PURE__ */ jsx(OpenFileUploadList, {}),
|
|
1530
|
-
/* @__PURE__ */ jsx(PackageInstallPrompt, {}),
|
|
1531
|
-
/* @__PURE__ */ jsx(Analytics, {}),
|
|
1532
|
-
/* @__PURE__ */ jsx(OpenPanel, {})
|
|
1533
|
-
] }) });
|
|
1534
|
-
};
|
|
1535
|
-
//#endregion
|
|
1536
|
-
//#region src/components/drive-icon.tsx
|
|
1537
|
-
function DriveIcon({ drive }) {
|
|
1538
|
-
const remotes = useSyncList();
|
|
1539
|
-
const isRemoteDrive = useMemo(() => {
|
|
1540
|
-
if (!drive) return false;
|
|
1541
|
-
return remotes.some((remote) => remote.meta.collectionId.equals(DriveCollectionId.forDrive(drive.header.id)));
|
|
1542
|
-
}, [remotes, drive]);
|
|
1543
|
-
const driveIconSrc = drive?.state.global.icon;
|
|
1544
|
-
if (driveIconSrc) return /* @__PURE__ */ jsx("img", {
|
|
1545
|
-
src: driveIconSrc,
|
|
1546
|
-
alt: drive.header.name,
|
|
1547
|
-
height: 32,
|
|
1548
|
-
width: 32
|
|
1549
|
-
});
|
|
1550
|
-
if (!isRemoteDrive) return /* @__PURE__ */ jsx(Icon, {
|
|
1551
|
-
name: "Hdd",
|
|
1552
|
-
size: 32
|
|
1553
|
-
});
|
|
1554
|
-
return /* @__PURE__ */ jsx(Icon, {
|
|
1555
|
-
name: "Server",
|
|
1556
|
-
size: 32
|
|
1557
|
-
});
|
|
1558
|
-
}
|
|
1559
|
-
//#endregion
|
|
1560
|
-
//#region src/components/document-upgrade-toast.tsx
|
|
1561
|
-
const DocumentUpgradeToast = ({ documentId }) => {
|
|
1562
|
-
const { t } = useTranslation();
|
|
1563
|
-
return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
|
|
1564
|
-
className: "font-medium",
|
|
1565
|
-
children: t("notifications.documentUpgradeAvailable")
|
|
1566
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
1567
|
-
onClick: () => {
|
|
1568
|
-
showPHModal({
|
|
1569
|
-
type: "confirmDocumentUpgrade",
|
|
1570
|
-
documentId
|
|
1571
|
-
});
|
|
1572
|
-
},
|
|
1573
|
-
className: "underline decoration-solid underline-offset-2",
|
|
1574
|
-
children: t("common.updateDocument")
|
|
1575
|
-
})] });
|
|
1576
|
-
};
|
|
1577
|
-
//#endregion
|
|
1578
|
-
//#region src/components/editors.tsx
|
|
1579
|
-
function EditorError({ title, children }) {
|
|
1580
|
-
return /* @__PURE__ */ jsx("div", {
|
|
1581
|
-
className: "flex size-full items-center justify-center p-6",
|
|
1582
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
1583
|
-
className: "w-full max-w-lg rounded-lg border border-border bg-card p-6 text-foreground shadow-sm",
|
|
1584
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
1585
|
-
className: "mb-3 flex items-center gap-2",
|
|
1586
|
-
children: [/* @__PURE__ */ jsx(Icon, {
|
|
1587
|
-
name: "Error",
|
|
1588
|
-
className: "size-5 shrink-0 text-destructive"
|
|
1589
|
-
}), /* @__PURE__ */ jsx("h3", {
|
|
1590
|
-
className: "min-w-0 text-lg font-semibold wrap-break-word text-foreground",
|
|
1591
|
-
children: title
|
|
1592
|
-
})]
|
|
1593
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
1594
|
-
className: "wrap-break-word",
|
|
1595
|
-
children
|
|
1596
|
-
})]
|
|
1597
|
-
})
|
|
1598
|
-
});
|
|
1599
|
-
}
|
|
1600
|
-
function OpenPackageManagerButton() {
|
|
1601
|
-
return /* @__PURE__ */ jsx(PowerhouseButton, {
|
|
1602
|
-
className: "px-3 py-1.5 text-base font-medium",
|
|
1603
|
-
onClick: () => {
|
|
1604
|
-
showPHModal({ type: "settings" });
|
|
1605
|
-
},
|
|
1606
|
-
type: "button",
|
|
1607
|
-
children: "Open package manager"
|
|
1608
|
-
});
|
|
1609
|
-
}
|
|
1610
|
-
const DocumentEditor = (props) => {
|
|
1611
|
-
const { document: initialDocument } = props;
|
|
1612
|
-
const selectedTimelineItem = useSelectedTimelineItem();
|
|
1613
|
-
const revisionHistoryVisible = useRevisionHistoryVisible();
|
|
1614
|
-
const [document, dispatch] = useDocumentById(initialDocument.header.id);
|
|
1615
|
-
const documentId = document?.header.id ?? void 0;
|
|
1616
|
-
const documentName = document?.header.name ?? void 0;
|
|
1617
|
-
const documentType = document?.header.documentType ?? void 0;
|
|
1618
|
-
const preferredEditor = document?.header.meta?.preferredEditor ?? void 0;
|
|
1619
|
-
const { globalOperations, localOperations, isLoading: isLoadingOperations, refetch: refetchOperations } = useDocumentOperations(documentId);
|
|
1620
|
-
useEffect(() => {
|
|
1621
|
-
if (revisionHistoryVisible) refetchOperations();
|
|
1622
|
-
}, [revisionHistoryVisible, refetchOperations]);
|
|
1623
|
-
const globalRevisionNumber = document?.header.revision.global ?? 0;
|
|
1624
|
-
const localRevisionNumber = document?.header.revision.local ?? 0;
|
|
1625
|
-
const documentModelModule = useDocumentModelModuleById(documentType);
|
|
1626
|
-
const preferredEditorModule = useEditorModuleById(preferredEditor);
|
|
1627
|
-
const fallbackEditorModule = useFallbackEditorModule(documentType);
|
|
1628
|
-
const editorModule = preferredEditorModule ?? fallbackEditorModule;
|
|
1629
|
-
const versionStatus = useDocumentVersionStatus(document ?? void 0);
|
|
1630
|
-
const versionStatusKind = versionStatus?.kind;
|
|
1631
|
-
const upgradeAvailable = versionStatus?.kind === "upgrade-available" && versionStatus.canUpgrade;
|
|
1632
|
-
useEffect(() => {
|
|
1633
|
-
if (upgradeAvailable && documentId) toast(createElement(DocumentUpgradeToast, { documentId }), {
|
|
1634
|
-
type: "connect-warning",
|
|
1635
|
-
toastId: `outdated-document-${documentId}`,
|
|
1636
|
-
autoClose: false
|
|
1637
|
-
});
|
|
1638
|
-
else if (versionStatusKind && versionStatusKind !== "upgrade-available" && documentId) dismissToast(`outdated-document-${documentId}`);
|
|
1639
|
-
}, [
|
|
1640
|
-
upgradeAvailable,
|
|
1641
|
-
versionStatusKind,
|
|
1642
|
-
documentId
|
|
1643
|
-
]);
|
|
1644
|
-
const vetraPackages = useVetraPackages();
|
|
1645
|
-
const packageManager = useVetraPackageManager();
|
|
1646
|
-
const owningPackageName = editorModule ? vetraPackages.find((pkg) => pkg.editors.includes(editorModule))?.manifest.name : void 0;
|
|
1647
|
-
const owningPackageVersion = owningPackageName && packageManager ? packageManager.getPackageVersion(owningPackageName) : void 0;
|
|
1648
|
-
const editorBundleKey = owningPackageName ? `${owningPackageName}@${owningPackageVersion ?? "unknown"}` : editorModule?.config.id ?? "no-editor";
|
|
1649
|
-
const isLoadingDocument = !document;
|
|
1650
|
-
const isLoadingEditor = editorModule && documentType && !editorModule.documentTypes.includes(documentType) && !editorModule.documentTypes.includes("*");
|
|
1651
|
-
const canUndo = globalRevisionNumber > 0 || localRevisionNumber > 0;
|
|
1652
|
-
const canRedo = !!document?.clipboard.length;
|
|
1653
|
-
const addUndoAction = () => dispatch(undo());
|
|
1654
|
-
const addRedoAction = () => dispatch(redo());
|
|
1655
|
-
useUndoRedoShortcuts({
|
|
1656
|
-
undo: addUndoAction,
|
|
1657
|
-
redo: addRedoAction,
|
|
1658
|
-
canUndo,
|
|
1659
|
-
canRedo
|
|
1660
|
-
});
|
|
1661
|
-
useEffect(() => {
|
|
1662
|
-
return () => {
|
|
1663
|
-
window.documentEditorDebugTools?.clear();
|
|
1664
|
-
};
|
|
1665
|
-
}, []);
|
|
1666
|
-
const [editorError, setEditorError] = useState(void 0);
|
|
1667
|
-
useEffect(() => {
|
|
1668
|
-
if (editorError && editorError.documentId !== documentId) setEditorError(void 0);
|
|
1669
|
-
}, [editorError, documentId]);
|
|
1670
|
-
const handleEditorError = (error, info) => {
|
|
1671
|
-
setEditorError({
|
|
1672
|
-
error,
|
|
1673
|
-
documentId,
|
|
1674
|
-
info
|
|
1675
|
-
});
|
|
1676
|
-
};
|
|
1677
|
-
if (isLoadingEditor) return /* @__PURE__ */ jsx(EditorLoader, { message: "Loading editor" });
|
|
1678
|
-
if (isLoadingDocument) return /* @__PURE__ */ jsx(EditorLoader, { message: "Loading document" });
|
|
1679
|
-
if (!documentModelModule) return /* @__PURE__ */ jsxs(EditorError, {
|
|
1680
|
-
title: "Document type not supported",
|
|
1681
|
-
children: [/* @__PURE__ */ jsxs("p", {
|
|
1682
|
-
className: "mb-4 text-sm text-foreground",
|
|
1683
|
-
children: [
|
|
1684
|
-
"This document can't be opened because the \"",
|
|
1685
|
-
documentType,
|
|
1686
|
-
"\" document model isn't installed. Install the package that provides it to open the document."
|
|
1687
|
-
]
|
|
1688
|
-
}), /* @__PURE__ */ jsx(OpenPackageManagerButton, {})]
|
|
1689
|
-
});
|
|
1690
|
-
if (versionStatus?.kind === "unsupported") return /* @__PURE__ */ jsxs(EditorError, {
|
|
1691
|
-
title: "Document version not supported",
|
|
1692
|
-
children: [/* @__PURE__ */ jsxs("p", {
|
|
1693
|
-
className: "mb-4 text-sm text-foreground",
|
|
1694
|
-
children: [
|
|
1695
|
-
"This document requires version ",
|
|
1696
|
-
versionStatus.documentVersion,
|
|
1697
|
-
" of the \"",
|
|
1698
|
-
documentType,
|
|
1699
|
-
"\" document model, but only version",
|
|
1700
|
-
versionStatus.availableVersions.length > 1 ? "s" : "",
|
|
1701
|
-
" ",
|
|
1702
|
-
versionStatus.availableVersions.join(", "),
|
|
1703
|
-
" ",
|
|
1704
|
-
versionStatus.availableVersions.length > 1 ? "are" : "is",
|
|
1705
|
-
" installed. Update the package that provides \"",
|
|
1706
|
-
documentType,
|
|
1707
|
-
"\" to open it."
|
|
1708
|
-
]
|
|
1709
|
-
}), /* @__PURE__ */ jsx(OpenPackageManagerButton, {})]
|
|
1710
|
-
});
|
|
1711
|
-
if (!editorModule) return /* @__PURE__ */ jsxs(EditorError, {
|
|
1712
|
-
title: "No editor available",
|
|
1713
|
-
children: [/* @__PURE__ */ jsxs("p", {
|
|
1714
|
-
className: "mb-4 text-sm text-foreground",
|
|
1715
|
-
children: [
|
|
1716
|
-
"The \"",
|
|
1717
|
-
documentType,
|
|
1718
|
-
"\" document model is installed, but no editor for it was found. Install a package that provides an editor for this document type."
|
|
1719
|
-
]
|
|
1720
|
-
}), /* @__PURE__ */ jsx(OpenPackageManagerButton, {})]
|
|
1721
|
-
});
|
|
1722
|
-
const EditorComponent = editorModule.Component;
|
|
1723
|
-
return /* @__PURE__ */ jsx("div", {
|
|
1724
|
-
className: "relative h-full",
|
|
1725
|
-
id: "document-editor-context",
|
|
1726
|
-
"data-editor": editorModule.config.id,
|
|
1727
|
-
"data-document-type": documentType,
|
|
1728
|
-
children: revisionHistoryVisible ? isLoadingOperations ? /* @__PURE__ */ jsx(EditorLoader, { message: "Loading operations" }) : /* @__PURE__ */ jsx(RevisionHistory, {
|
|
1729
|
-
documentTitle: documentName ?? "",
|
|
1730
|
-
documentId: documentId ?? "",
|
|
1731
|
-
globalOperations,
|
|
1732
|
-
localOperations,
|
|
1733
|
-
onClose: () => setRevisionHistoryVisible(false),
|
|
1734
|
-
documentState: document.state,
|
|
1735
|
-
onCopyState: () => {
|
|
1736
|
-
toast("Copied document state to clipboard", { type: "success" });
|
|
1737
|
-
},
|
|
1738
|
-
onCopyDocId: () => {
|
|
1739
|
-
toast("Copied document ID to clipboard", { type: "success" });
|
|
1740
|
-
}
|
|
1741
|
-
}, documentId) : /* @__PURE__ */ jsx(Suspense, {
|
|
1742
|
-
fallback: /* @__PURE__ */ jsx(EditorLoader, { message: "Loading editor" }),
|
|
1743
|
-
name: "EditorLoader",
|
|
1744
|
-
children: /* @__PURE__ */ jsx(ErrorBoundary$1, {
|
|
1745
|
-
fallbackRender: CenteredErrorMessage,
|
|
1746
|
-
resetKeys: [documentId],
|
|
1747
|
-
onError: handleEditorError,
|
|
1748
|
-
loggerContext: ["Connect", "DocumentEditor"],
|
|
1749
|
-
children: !editorError?.error && /* @__PURE__ */ jsx(EditorComponent, {
|
|
1750
|
-
context: {
|
|
1751
|
-
readMode: !!selectedTimelineItem,
|
|
1752
|
-
selectedTimelineRevision: getRevisionFromDate(selectedTimelineItem?.startDate, selectedTimelineItem?.endDate, globalOperations)
|
|
1753
|
-
},
|
|
1754
|
-
documentId: document.header.id
|
|
1755
|
-
}, `${editorBundleKey}:${documentId}`)
|
|
1756
|
-
})
|
|
1757
|
-
})
|
|
1758
|
-
});
|
|
1759
|
-
};
|
|
1760
|
-
//#endregion
|
|
1761
|
-
//#region src/components/root.tsx
|
|
1762
|
-
function Root() {
|
|
1763
|
-
return /* @__PURE__ */ jsx("div", {
|
|
1764
|
-
className: "h-screen bg-background",
|
|
1765
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
1766
|
-
className: `flex h-screen items-stretch overflow-auto`,
|
|
1767
|
-
role: "presentation",
|
|
1768
|
-
tabIndex: 0,
|
|
1769
|
-
children: /* @__PURE__ */ jsxs(Suspense, {
|
|
1770
|
-
name: "Root",
|
|
1771
|
-
children: [!useIsEmbedded() && /* @__PURE__ */ jsx(Sidebar, {}), /* @__PURE__ */ jsx("div", {
|
|
1772
|
-
className: "relative flex-1 overflow-auto",
|
|
1773
|
-
children: /* @__PURE__ */ jsx(Outlet, {})
|
|
1774
|
-
})]
|
|
1775
|
-
})
|
|
1776
|
-
})
|
|
1777
|
-
});
|
|
1778
|
-
}
|
|
1779
|
-
//#endregion
|
|
1780
|
-
//#region src/components/use-drive-auth-gate.ts
|
|
1781
|
-
/**
|
|
1782
|
-
* Decides the gate for the drive the user selected, and only that drive. A
|
|
1783
|
-
* refusal on any other drive must not hide the rest of Connect.
|
|
1784
|
-
*
|
|
1785
|
-
* Connection states are keyed by remote name, which is a random uuid, so the
|
|
1786
|
-
* caller supplies the remote -> drive mapping.
|
|
1787
|
-
*/
|
|
1788
|
-
function computeAuthGate(isAuthenticated, connectionStates, selection) {
|
|
1789
|
-
const { selectedDriveId, remotes } = selection;
|
|
1790
|
-
if (!selectedDriveId) return null;
|
|
1791
|
-
let refused = false;
|
|
1792
|
-
for (const remote of remotes) {
|
|
1793
|
-
if (remote.driveId !== selectedDriveId) continue;
|
|
1794
|
-
const snapshot = connectionStates.get(remote.name);
|
|
1795
|
-
if (snapshot?.state === "error" && snapshot.requiresAuth) {
|
|
1796
|
-
refused = true;
|
|
1797
|
-
break;
|
|
1798
|
-
}
|
|
1799
|
-
}
|
|
1800
|
-
if (!refused) return null;
|
|
1801
|
-
return isAuthenticated ? "unauthorized" : "login";
|
|
1802
|
-
}
|
|
1803
|
-
const hiddenDriveIds = /* @__PURE__ */ new Set();
|
|
1804
|
-
let hiddenDriveIdsSnapshot = [];
|
|
1805
|
-
const hiddenDriveListeners = /* @__PURE__ */ new Set();
|
|
1806
|
-
function publishHiddenDrives() {
|
|
1807
|
-
hiddenDriveIdsSnapshot = [...hiddenDriveIds];
|
|
1808
|
-
for (const listener of [...hiddenDriveListeners]) listener();
|
|
1809
|
-
}
|
|
1810
|
-
function subscribeHiddenDrives(listener) {
|
|
1811
|
-
hiddenDriveListeners.add(listener);
|
|
1812
|
-
return () => {
|
|
1813
|
-
hiddenDriveListeners.delete(listener);
|
|
1814
|
-
};
|
|
1815
|
-
}
|
|
1816
|
-
function getHiddenDriveIds() {
|
|
1817
|
-
return hiddenDriveIdsSnapshot;
|
|
1818
|
-
}
|
|
1819
|
-
/** Hides a drive from Connect's drive lists until the page reloads. */
|
|
1820
|
-
function hideDriveForSession(driveId) {
|
|
1821
|
-
if (hiddenDriveIds.has(driveId)) return;
|
|
1822
|
-
hiddenDriveIds.add(driveId);
|
|
1823
|
-
publishHiddenDrives();
|
|
1824
|
-
}
|
|
1825
|
-
/** Restores every drive hidden this session. */
|
|
1826
|
-
function clearHiddenDrives() {
|
|
1827
|
-
if (hiddenDriveIds.size === 0) return;
|
|
1828
|
-
hiddenDriveIds.clear();
|
|
1829
|
-
publishHiddenDrives();
|
|
1830
|
-
}
|
|
1831
|
-
function useHiddenDriveIds() {
|
|
1832
|
-
return useSyncExternalStore(subscribeHiddenDrives, getHiddenDriveIds, getHiddenDriveIds);
|
|
1833
|
-
}
|
|
1834
|
-
/** `useDrives()` minus the drives dismissed from the auth gate this session. */
|
|
1835
|
-
function useVisibleDrives() {
|
|
1836
|
-
const drives = useDrives();
|
|
1837
|
-
const hidden = useHiddenDriveIds();
|
|
1838
|
-
return useMemo(() => {
|
|
1839
|
-
if (!drives || hidden.length === 0) return drives;
|
|
1840
|
-
return drives.filter((drive) => !hidden.includes(drive.header.id));
|
|
1841
|
-
}, [drives, hidden]);
|
|
1842
|
-
}
|
|
1843
|
-
/** Live wrapper over {@link computeAuthGate}, plus the dismiss action. */
|
|
1844
|
-
function useDriveAuthGate() {
|
|
1845
|
-
const user = useUser();
|
|
1846
|
-
const connectionStates = useConnectionStates();
|
|
1847
|
-
const syncManager = useSync();
|
|
1848
|
-
const selectedDriveId = useSelectedDriveId();
|
|
1849
|
-
const remotes = useMemo(() => (syncManager?.list() ?? []).map((remote) => ({
|
|
1850
|
-
name: remote.meta.name,
|
|
1851
|
-
driveId: remote.meta.collectionId.driveId
|
|
1852
|
-
})), [syncManager, connectionStates]);
|
|
1853
|
-
const address = user?.address;
|
|
1854
|
-
useEffect(() => {
|
|
1855
|
-
clearHiddenDrives();
|
|
1856
|
-
}, [address]);
|
|
1857
|
-
const dismiss = useCallback(() => {
|
|
1858
|
-
if (selectedDriveId) hideDriveForSession(selectedDriveId);
|
|
1859
|
-
setSelectedDrive(void 0);
|
|
1860
|
-
}, [selectedDriveId]);
|
|
1861
|
-
return {
|
|
1862
|
-
gate: computeAuthGate(Boolean(user), connectionStates, {
|
|
1863
|
-
selectedDriveId,
|
|
1864
|
-
remotes
|
|
1865
|
-
}),
|
|
1866
|
-
dismiss
|
|
1867
|
-
};
|
|
1868
|
-
}
|
|
1869
|
-
//#endregion
|
|
1870
|
-
//#region src/pages/content.tsx
|
|
1871
|
-
function Content() {
|
|
1872
|
-
const { gate, dismiss } = useDriveAuthGate();
|
|
1873
|
-
const openLogin = useOpenRenownLogin();
|
|
1874
|
-
const [selectedDrive] = useSelectedDriveSafe();
|
|
1875
|
-
const selectedFolder = useSelectedFolder();
|
|
1876
|
-
const selectedDocumentId = useSelectedDocumentId();
|
|
1877
|
-
useEffect(() => {
|
|
1878
|
-
if (!selectedDocumentId) setPHDocumentEditorConfig(defaultPHDocumentEditorConfig);
|
|
1879
|
-
}, [selectedDocumentId]);
|
|
1880
|
-
useEffect(() => {
|
|
1881
|
-
if (!selectedDrive) setPHAppConfig(defaultPHAppConfig);
|
|
1882
|
-
}, [selectedDrive]);
|
|
1883
|
-
return /* @__PURE__ */ jsx(ContentContainer, { children: gate ? /* @__PURE__ */ jsx("div", {
|
|
1884
|
-
className: "flex h-full items-center justify-center p-4",
|
|
1885
|
-
children: /* @__PURE__ */ jsx(DriveAuthGate, {
|
|
1886
|
-
mode: gate,
|
|
1887
|
-
onLogin: openLogin,
|
|
1888
|
-
onLogout: () => void logout(),
|
|
1889
|
-
onClose: dismiss
|
|
1890
|
-
})
|
|
1891
|
-
}) : !selectedDocumentId && !selectedDrive && !selectedFolder ? /* @__PURE__ */ jsx(HomeScreenContainer, {}) : /* @__PURE__ */ jsx(AppContainer, {}) });
|
|
1892
|
-
}
|
|
1893
|
-
function ContentContainer({ children }) {
|
|
1894
|
-
return /* @__PURE__ */ jsx("div", {
|
|
1895
|
-
className: "flex h-full flex-col overflow-auto",
|
|
1896
|
-
id: "content-view",
|
|
1897
|
-
children
|
|
1898
|
-
});
|
|
1899
|
-
}
|
|
1900
|
-
function DriveItem({ drive }) {
|
|
1901
|
-
const description = useAppModuleById(drive.header.meta?.preferredEditor)?.config.name || "Drive Explorer App";
|
|
1902
|
-
return /* @__PURE__ */ jsx(HomeScreenItem, {
|
|
1903
|
-
title: drive.state.global.name || drive.header.name,
|
|
1904
|
-
description,
|
|
1905
|
-
icon: /* @__PURE__ */ jsx(DriveIcon, { drive }),
|
|
1906
|
-
onClick: () => setSelectedDrive(drive)
|
|
1907
|
-
}, drive.header.id);
|
|
1908
|
-
}
|
|
1909
|
-
function HomeScreenContainer() {
|
|
1910
|
-
const drives = useVisibleDrives();
|
|
1911
|
-
const isAddDriveEnabled = useIsAddDriveEnabled();
|
|
1912
|
-
const homeBackground = getRuntimeConfig().connect?.branding?.homeBackground;
|
|
1913
|
-
return /* @__PURE__ */ jsxs(HomeScreen, {
|
|
1914
|
-
homeBackground,
|
|
1915
|
-
children: [drives?.map((drive) => {
|
|
1916
|
-
return /* @__PURE__ */ jsx(DriveItem, { drive }, drive.header.id);
|
|
1917
|
-
}), isAddDriveEnabled && /* @__PURE__ */ jsx(HomeScreenAddDriveItem, {})]
|
|
1918
|
-
});
|
|
1919
|
-
}
|
|
1920
|
-
//#endregion
|
|
1921
|
-
//#region src/components/router.tsx
|
|
1922
|
-
function createRouter(routes) {
|
|
1923
|
-
const routerBasename = connectConfig.routerBasename;
|
|
1924
|
-
return createBrowserRouter(routes, {
|
|
1925
|
-
basename: routerBasename,
|
|
1926
|
-
future: {
|
|
1927
|
-
v7_fetcherPersist: true,
|
|
1928
|
-
v7_relativeSplatPath: true
|
|
1929
|
-
}
|
|
1930
|
-
});
|
|
1931
|
-
}
|
|
1932
|
-
function createRoutes() {
|
|
1933
|
-
return [{
|
|
1934
|
-
element: /* @__PURE__ */ jsx(Suspense, {
|
|
1935
|
-
name: "RouteRoot",
|
|
1936
|
-
children: /* @__PURE__ */ jsx(Root, {})
|
|
1937
|
-
}),
|
|
1938
|
-
children: [{
|
|
1939
|
-
index: true,
|
|
1940
|
-
path: "d?/:driveId?/*?",
|
|
1941
|
-
element: /* @__PURE__ */ jsx(Suspense, {
|
|
1942
|
-
name: "Drive",
|
|
1943
|
-
children: /* @__PURE__ */ jsx(Content, {})
|
|
1944
|
-
})
|
|
1945
|
-
}]
|
|
1946
|
-
}];
|
|
1947
|
-
}
|
|
1948
|
-
const router = createRouter(createRoutes());
|
|
1949
|
-
const Router = () => {
|
|
1950
|
-
return /* @__PURE__ */ jsx(RouterProvider, { router });
|
|
1951
|
-
};
|
|
1952
|
-
//#endregion
|
|
1953
|
-
//#region src/components/sidebar.tsx
|
|
1954
|
-
function Sidebar() {
|
|
1955
|
-
const user = useUser();
|
|
1956
|
-
const openLogin = useOpenRenownLogin();
|
|
1957
|
-
const drives = useVisibleDrives();
|
|
1958
|
-
const isAddDriveEnabled = useIsAddDriveEnabled();
|
|
1959
|
-
const [selectedDrive] = useSelectedDriveSafe();
|
|
1960
|
-
const connectDebug = localStorage.getItem("CONNECT_DEBUG") === "true";
|
|
1961
|
-
const ensName = user?.ens?.name || user?.profile?.username || void 0;
|
|
1962
|
-
const avatarUrl = user?.ens?.avatarUrl || user?.profile?.userImage || void 0;
|
|
1963
|
-
const ensInfo = useEns(!avatarUrl ? user?.address : void 0);
|
|
1964
|
-
const onClickSettings = () => {
|
|
1965
|
-
showPHModal({ type: "settings" });
|
|
1966
|
-
};
|
|
1967
|
-
const onAddDriveClick = () => {
|
|
1968
|
-
showPHModal({ type: "addDrive" });
|
|
1969
|
-
};
|
|
1970
|
-
const etherscanUrl = user?.address ? `https://etherscan.io/address/${user.address}` : "";
|
|
1971
|
-
return /* @__PURE__ */ jsx(ConnectTooltipProvider, { children: /* @__PURE__ */ jsx(ConnectSidebar, {
|
|
1972
|
-
id: "sidebar",
|
|
1973
|
-
onClick: () => setSelectedDrive(void 0),
|
|
1974
|
-
onClickSettings,
|
|
1975
|
-
address: user?.address,
|
|
1976
|
-
onLogin: openLogin,
|
|
1977
|
-
onDisconnect: () => {
|
|
1978
|
-
logout();
|
|
1979
|
-
},
|
|
1980
|
-
ensName: ensName || ensInfo.data?.ens,
|
|
1981
|
-
avatarUrl: avatarUrl || ensInfo.data?.avatar_small || ensInfo.data?.avatar_url || void 0,
|
|
1982
|
-
etherscanUrl,
|
|
1983
|
-
showDebug: connectDebug,
|
|
1984
|
-
onDebugClick: () => showPHModal({ type: "debugSettings" }),
|
|
1985
|
-
children: /* @__PURE__ */ jsxs(ErrorBoundary$1, {
|
|
1986
|
-
variant: "text",
|
|
1987
|
-
fallbackMessage: "There was an error loading drives",
|
|
1988
|
-
loggerContext: ["Connect", "Sidebar"],
|
|
1989
|
-
children: [drives?.map((drive) => /* @__PURE__ */ jsx(SidebarItem, {
|
|
1990
|
-
title: drive.header.name,
|
|
1991
|
-
onClick: () => setSelectedDrive(drive),
|
|
1992
|
-
active: selectedDrive?.header.id === drive.header.id,
|
|
1993
|
-
icon: /* @__PURE__ */ jsx(DriveIcon, { drive })
|
|
1994
|
-
}, drive.header.id)), isAddDriveEnabled && /* @__PURE__ */ jsx(SidebarAddDriveItem, { onClick: onAddDriveClick })]
|
|
1995
|
-
})
|
|
1996
|
-
}) });
|
|
1997
|
-
}
|
|
1998
|
-
//#endregion
|
|
1999
|
-
//#region src/components/connection-banner.tsx
|
|
2000
|
-
const CONNECTED = "connected";
|
|
2001
|
-
const ConnectionBanner = () => {
|
|
2002
|
-
if (useSyncExternalStore(subscribeWorkerConnection, getWorkerConnectionStatus, () => CONNECTED) !== "lost") return null;
|
|
2003
|
-
return /* @__PURE__ */ jsx("div", {
|
|
2004
|
-
className: "absolute inset-x-0 top-0 z-30 flex justify-center p-3",
|
|
2005
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
2006
|
-
className: "flex max-w-3xl items-center gap-3 rounded-lg border border-destructive bg-warning px-4 py-3 text-sm text-warning-foreground shadow-lg",
|
|
2007
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
2008
|
-
className: "flex-1",
|
|
2009
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
2010
|
-
className: "font-semibold",
|
|
2011
|
-
children: "Lost connection to the reactor"
|
|
2012
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
2013
|
-
className: "text-foreground",
|
|
2014
|
-
children: "The background worker stopped responding. Reload to reconnect."
|
|
2015
|
-
})]
|
|
2016
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
2017
|
-
type: "button",
|
|
2018
|
-
onClick: () => window.location.reload(),
|
|
2019
|
-
className: "rounded-sm bg-primary px-3 py-1 text-sm font-medium text-primary-foreground hover:hover-effect",
|
|
2020
|
-
children: "Reload"
|
|
2021
|
-
})]
|
|
2022
|
-
})
|
|
2023
|
-
});
|
|
2024
|
-
};
|
|
2025
|
-
//#endregion
|
|
2026
|
-
//#region src/components/migration-banner.tsx
|
|
2027
|
-
function BannerShell({ title, body, error, children }) {
|
|
2028
|
-
return /* @__PURE__ */ jsx("div", {
|
|
2029
|
-
className: "absolute inset-x-0 top-0 z-30 flex justify-center p-3",
|
|
2030
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
2031
|
-
className: "flex max-w-3xl items-center gap-3 rounded-lg border border-warning bg-warning px-4 py-3 text-sm text-warning-foreground shadow-lg",
|
|
2032
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
2033
|
-
className: "flex-1",
|
|
2034
|
-
children: [
|
|
2035
|
-
/* @__PURE__ */ jsx("div", {
|
|
2036
|
-
className: "font-semibold",
|
|
2037
|
-
children: title
|
|
2038
|
-
}),
|
|
2039
|
-
/* @__PURE__ */ jsx("div", {
|
|
2040
|
-
className: "text-foreground",
|
|
2041
|
-
children: body
|
|
2042
|
-
}),
|
|
2043
|
-
error && /* @__PURE__ */ jsxs("div", {
|
|
2044
|
-
className: "mt-2 font-medium text-destructive",
|
|
2045
|
-
children: ["Migration failed: ", error]
|
|
2046
|
-
})
|
|
2047
|
-
]
|
|
2048
|
-
}), children]
|
|
2049
|
-
})
|
|
2050
|
-
});
|
|
2051
|
-
}
|
|
2052
|
-
const actionButton = "rounded-sm bg-primary px-3 py-1 text-sm font-medium text-primary-foreground hover:hover-effect disabled:disabled-effect";
|
|
2053
|
-
const dismissButton = "rounded-sm border border-foreground bg-transparent px-3 py-1 text-sm font-medium text-foreground hover:hover-effect disabled:disabled-effect";
|
|
2054
|
-
let browserDismissed = false;
|
|
2055
|
-
const browserListeners = /* @__PURE__ */ new Set();
|
|
2056
|
-
function WorkerMigrationBanner({ adminClient }) {
|
|
2057
|
-
const state = useSyncExternalStore((cb) => adminClient.subscribeMigration(cb), () => adminClient.getMigrationState());
|
|
2058
|
-
const [dismissed, setDismissed] = useState(false);
|
|
2059
|
-
const [error, setError] = useState(null);
|
|
2060
|
-
if (state.status === "idle") return null;
|
|
2061
|
-
if (state.status === "needed" && dismissed) return null;
|
|
2062
|
-
const migrating = state.status === "migrating";
|
|
2063
|
-
const handleMigrate = () => {
|
|
2064
|
-
setError(null);
|
|
2065
|
-
adminClient.migrate().catch((err) => {
|
|
2066
|
-
setError(err instanceof Error ? err.message : String(err));
|
|
2067
|
-
});
|
|
2068
|
-
};
|
|
2069
|
-
return /* @__PURE__ */ jsxs(BannerShell, {
|
|
2070
|
-
title: migrating ? `Migrating to Postgres 17…` : `Your local database uses Postgres ${state.legacyMajor ?? "?"}.`,
|
|
2071
|
-
body: migrating ? `Working (${state.phase ?? "starting"}). Your data is backed up first.` : `Migrate to Postgres 17 to pick up the latest features. Your data will be backed up first.`,
|
|
2072
|
-
error: error ?? (state.status === "failed" ? state.error : null),
|
|
2073
|
-
children: [!migrating && /* @__PURE__ */ jsx("button", {
|
|
2074
|
-
type: "button",
|
|
2075
|
-
onClick: handleMigrate,
|
|
2076
|
-
className: actionButton,
|
|
2077
|
-
children: state.status === "failed" ? "Retry" : "Migrate now"
|
|
2078
|
-
}), state.status === "needed" && /* @__PURE__ */ jsx("button", {
|
|
2079
|
-
type: "button",
|
|
2080
|
-
onClick: () => setDismissed(true),
|
|
2081
|
-
className: dismissButton,
|
|
2082
|
-
children: "Dismiss"
|
|
2083
|
-
})]
|
|
2084
|
-
});
|
|
2085
|
-
}
|
|
2086
|
-
function BrowserMigrationBanner() {
|
|
2087
|
-
const isDismissed = useSyncExternalStore((cb) => {
|
|
2088
|
-
browserListeners.add(cb);
|
|
2089
|
-
return () => browserListeners.delete(cb);
|
|
2090
|
-
}, () => browserDismissed, () => false);
|
|
2091
|
-
const major = useSyncExternalStore(subscribeMigrationMajor, getCachedMigrationMajor, () => void 0);
|
|
2092
|
-
const [migrating, setMigrating] = useState(false);
|
|
2093
|
-
const [error, setError] = useState(null);
|
|
2094
|
-
if (major === void 0 || major === null || major === 17) return null;
|
|
2095
|
-
if (isDismissed) return null;
|
|
2096
|
-
const handleMigrate = () => {
|
|
2097
|
-
setError(null);
|
|
2098
|
-
setMigrating(true);
|
|
2099
|
-
migrateAllIfNeeded().then(() => window.location.reload()).catch((err) => {
|
|
2100
|
-
setError(err instanceof Error ? err.message : String(err));
|
|
2101
|
-
setMigrating(false);
|
|
2102
|
-
});
|
|
2103
|
-
};
|
|
2104
|
-
return /* @__PURE__ */ jsxs(BannerShell, {
|
|
2105
|
-
title: `Your local database uses Postgres ${major}.`,
|
|
2106
|
-
body: `Migrate to Postgres 17 to pick up the latest features. Your data will be backed up first.`,
|
|
2107
|
-
error,
|
|
2108
|
-
children: [/* @__PURE__ */ jsx("button", {
|
|
2109
|
-
type: "button",
|
|
2110
|
-
disabled: migrating,
|
|
2111
|
-
onClick: handleMigrate,
|
|
2112
|
-
className: actionButton,
|
|
2113
|
-
children: migrating ? "Migrating…" : "Migrate now"
|
|
2114
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
2115
|
-
type: "button",
|
|
2116
|
-
disabled: migrating,
|
|
2117
|
-
onClick: () => {
|
|
2118
|
-
browserDismissed = true;
|
|
2119
|
-
for (const l of browserListeners) l();
|
|
2120
|
-
},
|
|
2121
|
-
className: dismissButton,
|
|
2122
|
-
children: "Dismiss"
|
|
2123
|
-
})]
|
|
2124
|
-
});
|
|
2125
|
-
}
|
|
2126
|
-
const MigrationBanner = () => {
|
|
2127
|
-
const module = useReactorClientModule();
|
|
2128
|
-
if (module?.kind === "worker") return /* @__PURE__ */ jsx(WorkerMigrationBanner, { adminClient: module.adminClient });
|
|
2129
|
-
return /* @__PURE__ */ jsx(BrowserMigrationBanner, {});
|
|
2130
|
-
};
|
|
2131
|
-
//#endregion
|
|
2132
|
-
//#region src/components/modal/modals-container.tsx
|
|
2133
|
-
const AddDriveModal$1 = lazy(() => import("./AddDriveModal-xAw48kdl.js").then((m) => ({ default: m.AddDriveModal })));
|
|
2134
|
-
const ClearStorageModal = lazy(() => import("./ClearStorageModal-BAqs4G2s.js").then((m) => ({ default: m.ClearStorageModal })));
|
|
2135
|
-
const CookiesPolicyModal = lazy(() => import("./CookiesPolicyModal-BpyPPyxS.js").then((m) => ({ default: m.CookiesPolicyModal })));
|
|
2136
|
-
const CreateDocumentModal$1 = lazy(() => import("./CreateDocumentModal-C45W8J0V.js").then((m) => ({ default: m.CreateDocumentModal })));
|
|
2137
|
-
const DebugSettingsModal = lazy(() => import("./DebugSettingsModal-rV_v0F0d.js").then((m) => ({ default: m.DebugSettingsModal })));
|
|
2138
|
-
const DeleteDriveModal = lazy(() => import("./DeleteDriveModal-Dug84t1j.js").then((m) => ({ default: m.DeleteDriveModal })));
|
|
2139
|
-
const DeleteItemModal = lazy(() => import("./DeleteItemModal-mMzy3V8o.js").then((m) => ({ default: m.DeleteItemModal })));
|
|
2140
|
-
const DisclaimerModal = lazy(() => import("./DisclaimerModal-DvpD5dPM.js").then((m) => ({ default: m.DisclaimerModal })));
|
|
2141
|
-
const DriveSettingsModal$1 = lazy(() => import("./DriveSettingsModal-C6-mRQiv.js").then((m) => ({ default: m.DriveSettingsModal })));
|
|
2142
|
-
const DownloadDocumentWithErrorsModal = lazy(() => import("./DownloadDocumentWithErrorsModal-IKl0ljQb.js").then((m) => ({ default: m.DownloadDocumentWithErrorsModal })));
|
|
2143
|
-
const DocumentVersionUnsupportedModal = lazy(() => import("./DocumentVersionUnsupportedModal-C3Q0V75l.js").then((m) => ({ default: m.DocumentVersionUnsupportedModal })));
|
|
2144
|
-
const ConfirmDocumentUpgradeModal = lazy(() => import("./ConfirmDocumentUpgradeModal-FUOhZsk7.js").then((m) => ({ default: m.ConfirmDocumentUpgradeModal })));
|
|
2145
|
-
const SettingsModal$1 = lazy(() => import("./SettingsModal-DlxUZEQ4.js").then((m) => ({ default: m.SettingsModal })));
|
|
2146
|
-
const UpgradeDriveModal = lazy(() => import("./UpgradeDriveModal-_8t9slxQ.js").then((m) => ({ default: m.UpgradeDriveModal })));
|
|
2147
|
-
const modalComponents = {
|
|
2148
|
-
addDrive: AddDriveModal$1,
|
|
2149
|
-
clearStorage: ClearStorageModal,
|
|
2150
|
-
cookiesPolicy: CookiesPolicyModal,
|
|
2151
|
-
createDocument: CreateDocumentModal$1,
|
|
2152
|
-
debugSettings: DebugSettingsModal,
|
|
2153
|
-
deleteDrive: DeleteDriveModal,
|
|
2154
|
-
deleteItem: DeleteItemModal,
|
|
2155
|
-
disclaimer: DisclaimerModal,
|
|
2156
|
-
driveSettings: DriveSettingsModal$1,
|
|
2157
|
-
downloadDocumentWithErrors: DownloadDocumentWithErrorsModal,
|
|
2158
|
-
documentVersionUnsupported: DocumentVersionUnsupportedModal,
|
|
2159
|
-
confirmDocumentUpgrade: ConfirmDocumentUpgradeModal,
|
|
2160
|
-
inspector: lazy(() => import("./InspectorModal-CpEhVnM6.js").then((m) => ({ default: m.InspectorModal }))),
|
|
2161
|
-
settings: SettingsModal$1,
|
|
2162
|
-
upgradeDrive: UpgradeDriveModal,
|
|
2163
|
-
missingPackage: lazy(() => import("./MissingPackageModal-nBnExqO0.js").then((m) => ({ default: m.ConnectMissingPackageModal }))),
|
|
2164
|
-
driveAuthRequired: lazy(() => import("./DriveAuthRequiredModal-DVK7ZQzO.js").then((m) => ({ default: m.DriveAuthRequiredModal }))),
|
|
2165
|
-
openFileDocuments: lazy(() => import("./OpenFileDocumentsModal-BW3ZFRDR.js").then((m) => ({ default: m.OpenFileDocumentsModal }))),
|
|
2166
|
-
login: lazy(() => import("./LoginModal-CybbOm3N.js").then((m) => ({ default: m.LoginModal })))
|
|
2167
|
-
};
|
|
2168
|
-
const ModalsContainer = lazy(() => {
|
|
2169
|
-
return Promise.resolve({ default: () => {
|
|
2170
|
-
const phModal = usePHModal();
|
|
2171
|
-
if (!phModal?.type) return null;
|
|
2172
|
-
const ModalComponent = modalComponents[phModal.type];
|
|
2173
|
-
return ModalComponent ? /* @__PURE__ */ jsx(ErrorBoundary$1, {
|
|
2174
|
-
variant: "silent",
|
|
2175
|
-
loggerContext: ["Connect", "Modals"],
|
|
2176
|
-
children: /* @__PURE__ */ jsx(Suspense, {
|
|
2177
|
-
fallback: null,
|
|
2178
|
-
children: /* @__PURE__ */ jsx(ModalComponent, {})
|
|
2179
|
-
})
|
|
2180
|
-
}) : null;
|
|
2181
|
-
} });
|
|
2182
|
-
});
|
|
2183
|
-
//#endregion
|
|
2184
|
-
//#region src/components/service-worker-update-prompt.tsx
|
|
2185
|
-
const ServiceWorkerUpdatePrompt = () => {
|
|
2186
|
-
if (!useSyncExternalStore(subscribeServiceWorkerUpdate, getServiceWorkerUpdateAvailable, () => false)) return null;
|
|
2187
|
-
return /* @__PURE__ */ jsx("div", {
|
|
2188
|
-
className: "absolute inset-x-0 bottom-0 z-30 flex justify-center p-3",
|
|
2189
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
2190
|
-
className: "flex max-w-3xl items-center gap-3 rounded-lg border border-foreground bg-primary px-4 py-3 text-sm text-primary-foreground shadow-lg",
|
|
2191
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
2192
|
-
className: "flex-1 font-medium",
|
|
2193
|
-
children: "A new version of Connect is available."
|
|
2194
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
2195
|
-
type: "button",
|
|
2196
|
-
onClick: () => serviceWorkerManager.applyUpdate(),
|
|
2197
|
-
className: "rounded-sm bg-primary-foreground px-3 py-1 text-sm font-medium text-primary hover:hover-effect",
|
|
2198
|
-
children: "Refresh"
|
|
2199
|
-
})]
|
|
2200
|
-
})
|
|
2201
|
-
});
|
|
2202
|
-
};
|
|
2203
|
-
//#endregion
|
|
2204
|
-
//#region src/components/app-loader.tsx
|
|
2205
|
-
const CookieBanner$1 = lazy(() => import("./cookie-banner-BH6bIq24.js").then((m) => ({ default: m.CookieBanner })));
|
|
2206
|
-
const AppLoader = (props) => {
|
|
2207
|
-
const Load = lazy(() => import("./load-B0xIT-MF.js").then((m) => m.loadComponent(props.localPackage)));
|
|
2208
|
-
return /* @__PURE__ */ jsx(StrictMode, { children: /* @__PURE__ */ jsxs(ErrorBoundary$1, {
|
|
2209
|
-
fallbackRender: (props) => /* @__PURE__ */ jsx(AppSkeleton, { children: /* @__PURE__ */ jsx(DetailedFallback, { ...props }) }),
|
|
2210
|
-
resetKeys: [props.localPackage],
|
|
2211
|
-
loggerContext: ["Connect"],
|
|
2212
|
-
children: [
|
|
2213
|
-
/* @__PURE__ */ jsx(Suspense, {
|
|
2214
|
-
fallback: /* @__PURE__ */ jsx(AppSkeleton, {}),
|
|
2215
|
-
name: "AppLoader",
|
|
2216
|
-
children: /* @__PURE__ */ jsx(Load, {
|
|
2217
|
-
...props,
|
|
2218
|
-
children: /* @__PURE__ */ jsx(App, {})
|
|
2219
|
-
})
|
|
2220
|
-
}),
|
|
2221
|
-
/* @__PURE__ */ jsx(ErrorBoundary$1, {
|
|
2222
|
-
variant: "silent",
|
|
2223
|
-
loggerContext: ["Connect", "CookieBanner"],
|
|
2224
|
-
children: /* @__PURE__ */ jsx(Suspense, {
|
|
2225
|
-
fallback: null,
|
|
2226
|
-
name: "CookieBanner",
|
|
2227
|
-
children: /* @__PURE__ */ jsx(CookieBanner$1, {})
|
|
2228
|
-
})
|
|
2229
|
-
}),
|
|
2230
|
-
/* @__PURE__ */ jsx(Suspense, {
|
|
2231
|
-
name: "ModalsContainer",
|
|
2232
|
-
children: /* @__PURE__ */ jsx(ModalsContainer, {})
|
|
2233
|
-
}),
|
|
2234
|
-
/* @__PURE__ */ jsx(MigrationBanner, {}),
|
|
2235
|
-
/* @__PURE__ */ jsx(ServiceWorkerUpdatePrompt, {}),
|
|
2236
|
-
/* @__PURE__ */ jsx(ConnectionBanner, {})
|
|
2237
|
-
]
|
|
2238
|
-
}) });
|
|
2239
|
-
};
|
|
2240
|
-
//#endregion
|
|
2241
|
-
export { pendingFileKey as _, DocumentEditor as a, AppContainer as c, OpenPanel as d, Analytics as f, getPendingImportFiles as g, clearPendingImportFiles as h, Root as i, EditorLoader as l, runOpenFileImports as m, Sidebar as n, DriveIcon as o, AppSkeleton as p, Router as r, App as s, AppLoader as t, DocumentEditorContainer as u, subscribePendingImportFiles as v };
|
|
2242
|
-
|
|
2243
|
-
//# sourceMappingURL=app-loader-Dz_X0r7a.js.map
|
|
2244
|
-
//# debugId=15683bfd-9902-5c1c-8759-c972139db200
|